Connect($host, $username, $pwd, $db, $new_link); } function Connect($host, $username, $pwd, $db, $new_link = false) { global $db_use_persistent; if ($db_use_persistent) { $this->conn = mysql_pconnect($host, $username, $pwd, $new_link); } else { $this->conn = mysql_connect($host, $username, $pwd, $new_link); } mysql_select_db($db, $this->conn); } function Execute($query) { $query = trim($query); $this->num_query++; if ($this->debug) { static $mysql_query_number; static $mysql_query_time; $mysql_query_number++; $time_start = (float) array_sum(explode(' ', microtime())); } $result = @mysql_query($query, $this->conn); if ($this->debug) { $time_end = (float) array_sum(explode(' ', microtime())); $time = $time_end - $time_start; $time = sprintf("%01.4f", $time); $mysql_query_time += $time; $mysql_query_time = sprintf("%01.3f", $mysql_query_time); $this->query_time = $mysql_query_time; if ($time > 0.1) { $time = "$time [slow query]"; } if (preg_match('/^select/i', $query)) { $num_rows = @mysql_num_rows($result); $this->query_log .= "
QUERY #$mysql_query_number: $query (result : $num_rows, time : $time)$mysql_query_time
"; } else { $this->query_log .= "
QUERY #$mysql_query_number: $query (time : $time)$mysql_query_time
"; } if (mysql_error()) { $this->query_log .= "
ERROR : ".mysql_error()."$mysql_query_time
"; } } $this->error_msg = mysql_error(); if ($this->error_msg) { return false; } else { if (preg_match("/^(update|insert|delete)/msi", $query)) { $this->affected_rows = @mysql_affected_rows($this->conn); return new DB_Resultset_empty(); } else { return new DB_Resultset($result, $query); } } } function PageExecute($query, $pg_which, $pg_size) { if (!$pg_which) { $pg_which = 1; } $query_total = $query; if (!preg_match('/group by/msi', $query_total)) { $query_total = preg_replace("|select(.*?)from|ms", "select count(*) as c from", $query_total); } $result = $this->Execute($query_total); if (preg_match('/group by/msi', $query_total)) { $num_rows = $result->RecordCount(); } else { $num_rows = ($result->Fields('c')) ? $result->Fields('c') : 0; } $start = ($pg_which - 1) * $pg_size; $query = $query . " limit $start, $pg_size"; $result->Close(); $result = $this->Execute($query); $result->num_rows = $num_rows; return $result; } function InsertID() { return @mysql_insert_id($this->conn); } function Close() { return true; } function FetchArray($query, $field = 'all') { $result = $this->Execute($query); $arr = array (); while ($row = $result->FetchRow()) { if ($field == 'all') { $arr[] = $row; } else { $arr[] = $row[$field]; } } $result->Close(); return $arr; } function FetchOne($query) { $result = $this->Execute($query . ' limit 1'); $row = $result->FetchRow(); $result->Close(); return $row; } function Lookup($field, $table, $where) { $result = $this->Execute("select $field from $table where $where limit 1"); $value = $result->Fields($field); $result->Close(); return $value; } function LookupCache($field, $table, $where, $cache_time) { global $base_path; $sql = "select $field from $table where $where limit 1"; $sql_md5 = md5($sql); $cache_dir = "cachedb/$sql_md5[0]/$sql_md5[1]/$sql_md5[2]/$sql_md5[3]/"; $cache_file = "{$cache_dir}$sql_md5.cache"; if (file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)) { return file_get_contents($cache_file); } $result = $this->Execute("select $field from $table where $where limit 1"); $value = $result->Fields($field); $result->Close(); CreateDir($cache_dir, 0777); $fp = fopen($cache_file, 'w+'); fwrite($fp, $value); fclose($fp); @chmod($cache_file, 0777); return $value; } function CountQuery() { return $this->num_query; } function ErrorMsg() { return $this->error_msg; } function AffectedRows() { return $this->affected_rows; } function GetQueryLog() { return $this->query_log; } function GetQueryTime() { return $this->query_time; } } class DB_Resultset { var $resultset = null; var $num_rows = null; var $num_field = null; var $current_row = null; var $EOF = true; var $query = null; function DB_Resultset(&$resultset, $query = '') { $this->resultset = $resultset; $this->query = $query; if (preg_match('/^select|show|describe|explain/msi', $query)) { $this->MoveNext(); } } function RecordCount() { if (is_null($this->num_rows)) { $this->num_rows = @mysql_num_rows($this->resultset); } return $this->num_rows; } function FieldCount() { if (is_null($this->num_field)) { $this->num_field = mysql_num_fields($this->resultset); } return $this->num_field; } function FetchField($offset) { $field = mysql_fetch_field($this->resultset, $offset); $field->max_length = mysql_field_len($this->resultset, $offset); return $field; } function MetaType($field_type) { switch($field_type) { case preg_match('/char/i', $field_type): return 'C'; case preg_match('/int|float|double/i', $field_type): return 'I'; case preg_match('/text/i', $field_type): return 'X'; case preg_match('/blob/', $field_type): return 'B'; default: return ''; } } function Move($offset) { if (@mysql_data_seek($this->resultset, $offset)) { return $this->MoveNext(); } else { return false; } } function MoveFirst() { return $this->Move(0); } function MoveLast() { return $this->Move($this->num_rows - 1); } function MoveNext() { if ($row = @mysql_fetch_assoc($this->resultset)) { $this->current_row = $row; $this->EOF = false; return true; } else { $this->EOF = true; return false; } } function Fields($name) { return $this->current_row[$name]; } function FetchRow() { if (!$this->EOF) { $row = $this->current_row; $this->MoveNext(); return $row; } else { return false; } } function Close() { if ($this->resultset) { mysql_free_result($this->resultset); } } } class DB_Resultset_empty { var $resultset = null; var $num_rows = null; var $num_field = null; var $current_row = null; var $EOF = true; var $query = null; function DB_Resultset() { return true; } function RecordCount() { return 0; } function FieldCount() { return 0; } function FetchField($offset) { return false; } function MetaType($field_type) { return false; } function Move($offset) { return false; } function MoveFirst() { return false; } function MoveLast() { return false; } function MoveNext() { return false; } function Fields($name) { return false; } function FetchRow() { return false; } function Close() { return true; } } $ADODB_SESS_CONN = null; $ADODB_SESS_MD5 = false; class DB_Session { function Open($save_path, $session_name) { global $ADODB_SESS_CONN, $dbServer, $dbHostname, $dbUsername, $dbPassword, $dbName; //echo "open
"; if (is_null($ADODB_SESS_CONN)) { $ADODB_SESS_CONN = new DB_Connection($dbHostname, $dbUsername, $dbPassword, $dbName); } return true; } function Close() { global $ADODB_SESS_CONN; //echo "close
"; if (!is_null($ADODB_SESS_CONN)) { $ADODB_SESS_CONN->Close(); } return true; } function Read($key) { global $ADODB_SESS_CONN, $ADODB_SESS_MD5; //echo "read
"; $data = ''; if ($ADODB_SESS_CONN) { $query = "select data from idx_sessions where sesskey = '$key' AND expiry >= " . time(); $result = $ADODB_SESS_CONN->Execute($query); if ($result->RecordCount()) { $data = rawurldecode($result->Fields('data')); } $ADODB_SESS_MD5 = md5($data); $result->Close(); } return $data; } function Write($key, $data) { global $ADODB_SESS_CONN, $ADODB_SESS_MD5; //echo "write
"; if ($ADODB_SESS_CONN) { $lifetime = ini_get('session.gc_maxlifetime'); if ($lifetime <= 1) { $lifetime = 1440; } $expiry = time() + $lifetime; if ($ADODB_SESS_MD5 !== false && $ADODB_SESS_MD5 == md5($data)) { $query = "update idx_sessions set expiry = '$expiry' where sesskey = '$key'"; } else { $data = rawurlencode($data); $query = "replace into idx_sessions (sesskey, expiry, data) values ('$key', '$expiry', '$data')"; } $ADODB_SESS_CONN->Execute($query); } return true; } function Destroy($key) { global $ADODB_SESS_CONN; //echo "detroy
"; if ($ADODB_SESS_CONN) { $query = "delete from idx_sessions where sesskey = '$key'"; $ADODB_SESS_CONN->Execute($query); } return true; } function GC($maxlifetime) { global $ADODB_SESS_CONN; //echo "gc
"; if ($ADODB_SESS_CONN) { $query = "delete from idx_sessions where expiry < ".time(); $ADODB_SESS_CONN->Execute($query); $query = "optimize table idx_sessions"; $ADODB_SESS_CONN->Execute($query); } return true; } function Init() { //echo "init
"; session_module_name('user'); session_set_save_handler( array('DB_Session', 'Open'), array('DB_Session', 'Close'), array('DB_Session', 'Read'), array('DB_Session', 'Write'), array('DB_Session', 'Destroy'), array('DB_Session', 'GC') ); } } DB_Session::Init(); ?> $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern = str_replace('{$cat_id}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$cat_name}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$page}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browse.php?cat=\${$ordered_pos[cat_id]}&pg_which=\${$ordered_pos[page]}\r\n"; } else { $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-f\r\n"; $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-d\r\n"; $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-l\r\n"; $out .= "{$comment_tag}RewriteRule ^.* browse.php\r\n"; } return $out; } function GenerateHtaccessStringModrewriteDetail($mod_rewrite_pattern, $comment_tag = '') { $array_var_pos = array(); $pos = strpos($mod_rewrite_pattern, '{$link_id}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'link_id'; } $pos = strpos($mod_rewrite_pattern, '{$link_title}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'link_title'; } $pos = strpos($mod_rewrite_pattern, '{$cat_path}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'cat_path'; } ksort($array_var_pos); $array_var_pos_values = array_values($array_var_pos); foreach($array_var_pos_values as $key => $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern = str_replace('{$link_id}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$link_title}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$cat_path}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} detail.php?linkid=\${$ordered_pos[link_id]}\r\n"; return $out; } function GenerateHtaccessStringModrewriteTag($mod_rewrite_pattern, $comment_tag = '') { $array_var_pos = array(); $pos = strpos($mod_rewrite_pattern, '{$tag}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'tag'; } $pos = strpos($mod_rewrite_pattern, '{$page}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'page'; } ksort($array_var_pos); $array_var_pos_values = array_values($array_var_pos); foreach($array_var_pos_values as $key => $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern_orig = $mod_rewrite_pattern; $mod_rewrite_pattern = str_replace('{$tag}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$page}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browsetag.php?tag=\${$ordered_pos[tag]}&pg_which=\${$ordered_pos[page]}\r\n"; $mod_rewrite_pattern = str_replace(strrchr($mod_rewrite_pattern_orig, '/'), '', $mod_rewrite_pattern_orig); $mod_rewrite_pattern = str_replace('{$tag}', '(.*)', $mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browsetag.php?tag=\$1\r\n"; return $out; } ?>Execute($query); // mail('dodyrw@gmail.com','payment log',$query); return mysql_insert_id(); } function UpgradeLink($id, $type, $day) { global $dbConn, $base_path; if ($type == 'PREMIUM') { $premium = 1; $sponsored = 0; } if ($type == 'SPONSORED') { $premium = 0; $sponsored = 1; } if ($type == 'PREMIUM' || $type == 'SPONSORED') { if ($day != 'permanent') { $days_extend = 3600 * 24 * $day; } // check if exist $query = "select link_id, premium, sponsored, expire from idx_paid_listing where link_id = '$id'"; $result = $dbConn->Execute($query); if ($result->RecordCount() == 0) { // create new record if ($day != 'permanent') { $expire = date('Y-m-d H:i:s', strtotime("+$days_extend seconds")); } else { $expire = '2030-01-01 00:00:00'; } $query = "insert into idx_paid_listing (link_id, premium, sponsored, expire, paid) values ('$id', '$premium', '$sponsored', '$expire', 1)"; $result = $dbConn->Execute($query); } else { if ($day != 'permanent') { // get expire time $expire = $result->Fields("expire"); $curr_premium = $result->Fields("premium"); $curr_sponsored = $result->Fields("sponsored"); if ($curr_premium != $premium || $curr_sponsored != $sponsored) { $expire = date('Y-m-d H:i:s'); } if (time() < @strtotime($expire)) { $expire = date('Y-m-d H:i:s', strtotime("$expire +$days_extend seconds")); } else { $expire = date('Y-m-d H:i:s', strtotime("+$days_extend seconds")); } } else { $expire = '2030-01-01 00:00:00'; } // update existing record $query = "update idx_paid_listing set expire = '$expire', premium = $premium, sponsored = $sponsored where link_id = '$id'"; $result = $dbConn->Execute($query); } } // activate link /* $query = "update idx_link set suspended = 0 where link_id = '$id'"; $result = $dbConn->Execute($query); */ ## MZ : delete suspended basic reference $query = "delete from idx_link_suspended_basic where link_id = '$id'"; $result = $dbConn->Execute($query); ## MZ : delete from pending $query = "delete from idx_link_pending where link_id = '$id'"; $result = $dbConn->Execute($query); // remove cache @RemoveDir($base_path . 'cache'); } function MarkAsPaid($id) { global $dbConn; $query = "update idx_invoice set paid = '1', paid_date = now() where invoice_id = '$id'"; $result = $dbConn->Execute($query); } function GetPaymentSystems($model = 'radio') { global $base_path, $id, $gateway; $dir = $base_path . "payment/"; $files = array (); if ($dir = @opendir($dir)) { while (($file = readdir($dir)) !== false) { $files[] = $path . $file; } } closedir($dir); ## make cc as default while (list($k, $v) = @each($files)) { if ($v == 'cc.inc.php') { $first_payment = $files[0]; $files[0] = $v; $files[$k] = $first_payment; break; } } @reset($files); $i = 0; $invoice_id = $id; if (!$gateway) { $checked = "checked=\"checked\""; } foreach ($files as $key => $value) { if (substr($value, -8) == '.inc.php') { /* if ($value == 'cc.inc.php' && $_COOKIE['COOKIE_USERNAME'] != 'flavio') { continue; } */ include $base_path . "payment/" . $value; $ps_name = str_replace('.inc.php','',$value); if($i>0) { $checked = ''; } if ($enable == '1' || $model == 'raw') { if ($model == 'radio') { $ps_html = strip_tags($invoice_html,''); $ps_html = str_replace(' " . $ps_html; } else { $ps .= " " . $ps_html; } } if ($model == 'image') { $ps .= $invoice_html; } if ($model == 'raw') { $ps[$i]['name'] = $ps_name; $ps[$i]['enable'] = $enable; } $i++; } } } return $ps; } function VerifyPaymentGateway($gateway) { global $base_path; $dir = $base_path . "payment/"; $files = array (); if ($dir = @opendir($dir)) { while (($file = readdir($dir)) !== false) { if (substr($file, -8) == '.inc.php') { $payments[] = str_replace('.inc.php', '', $file); } } } closedir ($dir); if (!in_array($gateway, $payments)) { RunPostFilter(); } } function ProcessIDevAffiliate($sale_url, $item_name, $total, $trans_id, $ip_address) { if (strpos($item_name, 'Upgrade ') === false) { $idev_ordernum = $trans_id; $idev_saleamt = $total; HttpRequest($sale_url . "?idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum&ip_address=$ip_address"); } } ?> Vacation Rental Help :: Glossary
Vacation Rental Help

Knowledgebase Home | Glossary | Favorites | Contact | Login Knowledgebase Home | Glossary | Favorites | Contact | Login
Search the Knowledgebase Browse by Category
All 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
No glossary words starting with "K" have been created

Connect($host, $username, $pwd, $db, $new_link); } function Connect($host, $username, $pwd, $db, $new_link = false) { global $db_use_persistent; if ($db_use_persistent) { $this->conn = mysql_pconnect($host, $username, $pwd, $new_link); } else { $this->conn = mysql_connect($host, $username, $pwd, $new_link); } mysql_select_db($db, $this->conn); } function Execute($query) { $query = trim($query); $this->num_query++; if ($this->debug) { static $mysql_query_number; static $mysql_query_time; $mysql_query_number++; $time_start = (float) array_sum(explode(' ', microtime())); } $result = @mysql_query($query, $this->conn); if ($this->debug) { $time_end = (float) array_sum(explode(' ', microtime())); $time = $time_end - $time_start; $time = sprintf("%01.4f", $time); $mysql_query_time += $time; $mysql_query_time = sprintf("%01.3f", $mysql_query_time); $this->query_time = $mysql_query_time; if ($time > 0.1) { $time = "$time [slow query]"; } if (preg_match('/^select/i', $query)) { $num_rows = @mysql_num_rows($result); $this->query_log .= "
QUERY #$mysql_query_number: $query (result : $num_rows, time : $time)$mysql_query_time
"; } else { $this->query_log .= "
QUERY #$mysql_query_number: $query (time : $time)$mysql_query_time
"; } if (mysql_error()) { $this->query_log .= "
ERROR : ".mysql_error()."$mysql_query_time
"; } } $this->error_msg = mysql_error(); if ($this->error_msg) { return false; } else { if (preg_match("/^(update|insert|delete)/msi", $query)) { $this->affected_rows = @mysql_affected_rows($this->conn); return new DB_Resultset_empty(); } else { return new DB_Resultset($result, $query); } } } function PageExecute($query, $pg_which, $pg_size) { if (!$pg_which) { $pg_which = 1; } $query_total = $query; if (!preg_match('/group by/msi', $query_total)) { $query_total = preg_replace("|select(.*?)from|ms", "select count(*) as c from", $query_total); } $result = $this->Execute($query_total); if (preg_match('/group by/msi', $query_total)) { $num_rows = $result->RecordCount(); } else { $num_rows = ($result->Fields('c')) ? $result->Fields('c') : 0; } $start = ($pg_which - 1) * $pg_size; $query = $query . " limit $start, $pg_size"; $result->Close(); $result = $this->Execute($query); $result->num_rows = $num_rows; return $result; } function InsertID() { return @mysql_insert_id($this->conn); } function Close() { return true; } function FetchArray($query, $field = 'all') { $result = $this->Execute($query); $arr = array (); while ($row = $result->FetchRow()) { if ($field == 'all') { $arr[] = $row; } else { $arr[] = $row[$field]; } } $result->Close(); return $arr; } function FetchOne($query) { $result = $this->Execute($query . ' limit 1'); $row = $result->FetchRow(); $result->Close(); return $row; } function Lookup($field, $table, $where) { $result = $this->Execute("select $field from $table where $where limit 1"); $value = $result->Fields($field); $result->Close(); return $value; } function LookupCache($field, $table, $where, $cache_time) { global $base_path; $sql = "select $field from $table where $where limit 1"; $sql_md5 = md5($sql); $cache_dir = "cachedb/$sql_md5[0]/$sql_md5[1]/$sql_md5[2]/$sql_md5[3]/"; $cache_file = "{$cache_dir}$sql_md5.cache"; if (file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)) { return file_get_contents($cache_file); } $result = $this->Execute("select $field from $table where $where limit 1"); $value = $result->Fields($field); $result->Close(); CreateDir($cache_dir, 0777); $fp = fopen($cache_file, 'w+'); fwrite($fp, $value); fclose($fp); @chmod($cache_file, 0777); return $value; } function CountQuery() { return $this->num_query; } function ErrorMsg() { return $this->error_msg; } function AffectedRows() { return $this->affected_rows; } function GetQueryLog() { return $this->query_log; } function GetQueryTime() { return $this->query_time; } } class DB_Resultset { var $resultset = null; var $num_rows = null; var $num_field = null; var $current_row = null; var $EOF = true; var $query = null; function DB_Resultset(&$resultset, $query = '') { $this->resultset = $resultset; $this->query = $query; if (preg_match('/^select|show|describe|explain/msi', $query)) { $this->MoveNext(); } } function RecordCount() { if (is_null($this->num_rows)) { $this->num_rows = @mysql_num_rows($this->resultset); } return $this->num_rows; } function FieldCount() { if (is_null($this->num_field)) { $this->num_field = mysql_num_fields($this->resultset); } return $this->num_field; } function FetchField($offset) { $field = mysql_fetch_field($this->resultset, $offset); $field->max_length = mysql_field_len($this->resultset, $offset); return $field; } function MetaType($field_type) { switch($field_type) { case preg_match('/char/i', $field_type): return 'C'; case preg_match('/int|float|double/i', $field_type): return 'I'; case preg_match('/text/i', $field_type): return 'X'; case preg_match('/blob/', $field_type): return 'B'; default: return ''; } } function Move($offset) { if (@mysql_data_seek($this->resultset, $offset)) { return $this->MoveNext(); } else { return false; } } function MoveFirst() { return $this->Move(0); } function MoveLast() { return $this->Move($this->num_rows - 1); } function MoveNext() { if ($row = @mysql_fetch_assoc($this->resultset)) { $this->current_row = $row; $this->EOF = false; return true; } else { $this->EOF = true; return false; } } function Fields($name) { return $this->current_row[$name]; } function FetchRow() { if (!$this->EOF) { $row = $this->current_row; $this->MoveNext(); return $row; } else { return false; } } function Close() { if ($this->resultset) { mysql_free_result($this->resultset); } } } class DB_Resultset_empty { var $resultset = null; var $num_rows = null; var $num_field = null; var $current_row = null; var $EOF = true; var $query = null; function DB_Resultset() { return true; } function RecordCount() { return 0; } function FieldCount() { return 0; } function FetchField($offset) { return false; } function MetaType($field_type) { return false; } function Move($offset) { return false; } function MoveFirst() { return false; } function MoveLast() { return false; } function MoveNext() { return false; } function Fields($name) { return false; } function FetchRow() { return false; } function Close() { return true; } } $ADODB_SESS_CONN = null; $ADODB_SESS_MD5 = false; class DB_Session { function Open($save_path, $session_name) { global $ADODB_SESS_CONN, $dbServer, $dbHostname, $dbUsername, $dbPassword, $dbName; //echo "open
"; if (is_null($ADODB_SESS_CONN)) { $ADODB_SESS_CONN = new DB_Connection($dbHostname, $dbUsername, $dbPassword, $dbName); } return true; } function Close() { global $ADODB_SESS_CONN; //echo "close
"; if (!is_null($ADODB_SESS_CONN)) { $ADODB_SESS_CONN->Close(); } return true; } function Read($key) { global $ADODB_SESS_CONN, $ADODB_SESS_MD5; //echo "read
"; $data = ''; if ($ADODB_SESS_CONN) { $query = "select data from idx_sessions where sesskey = '$key' AND expiry >= " . time(); $result = $ADODB_SESS_CONN->Execute($query); if ($result->RecordCount()) { $data = rawurldecode($result->Fields('data')); } $ADODB_SESS_MD5 = md5($data); $result->Close(); } return $data; } function Write($key, $data) { global $ADODB_SESS_CONN, $ADODB_SESS_MD5; //echo "write
"; if ($ADODB_SESS_CONN) { $lifetime = ini_get('session.gc_maxlifetime'); if ($lifetime <= 1) { $lifetime = 1440; } $expiry = time() + $lifetime; if ($ADODB_SESS_MD5 !== false && $ADODB_SESS_MD5 == md5($data)) { $query = "update idx_sessions set expiry = '$expiry' where sesskey = '$key'"; } else { $data = rawurlencode($data); $query = "replace into idx_sessions (sesskey, expiry, data) values ('$key', '$expiry', '$data')"; } $ADODB_SESS_CONN->Execute($query); } return true; } function Destroy($key) { global $ADODB_SESS_CONN; //echo "detroy
"; if ($ADODB_SESS_CONN) { $query = "delete from idx_sessions where sesskey = '$key'"; $ADODB_SESS_CONN->Execute($query); } return true; } function GC($maxlifetime) { global $ADODB_SESS_CONN; //echo "gc
"; if ($ADODB_SESS_CONN) { $query = "delete from idx_sessions where expiry < ".time(); $ADODB_SESS_CONN->Execute($query); $query = "optimize table idx_sessions"; $ADODB_SESS_CONN->Execute($query); } return true; } function Init() { //echo "init
"; session_module_name('user'); session_set_save_handler( array('DB_Session', 'Open'), array('DB_Session', 'Close'), array('DB_Session', 'Read'), array('DB_Session', 'Write'), array('DB_Session', 'Destroy'), array('DB_Session', 'GC') ); } } DB_Session::Init(); ?> $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern = str_replace('{$cat_id}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$cat_name}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$page}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browse.php?cat=\${$ordered_pos[cat_id]}&pg_which=\${$ordered_pos[page]}\r\n"; } else { $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-f\r\n"; $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-d\r\n"; $out .= "{$comment_tag}RewriteCond %{REQUEST_FILENAME} !-l\r\n"; $out .= "{$comment_tag}RewriteRule ^.* browse.php\r\n"; } return $out; } function GenerateHtaccessStringModrewriteDetail($mod_rewrite_pattern, $comment_tag = '') { $array_var_pos = array(); $pos = strpos($mod_rewrite_pattern, '{$link_id}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'link_id'; } $pos = strpos($mod_rewrite_pattern, '{$link_title}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'link_title'; } $pos = strpos($mod_rewrite_pattern, '{$cat_path}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'cat_path'; } ksort($array_var_pos); $array_var_pos_values = array_values($array_var_pos); foreach($array_var_pos_values as $key => $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern = str_replace('{$link_id}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$link_title}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$cat_path}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} detail.php?linkid=\${$ordered_pos[link_id]}\r\n"; return $out; } function GenerateHtaccessStringModrewriteTag($mod_rewrite_pattern, $comment_tag = '') { $array_var_pos = array(); $pos = strpos($mod_rewrite_pattern, '{$tag}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'tag'; } $pos = strpos($mod_rewrite_pattern, '{$page}'); if ($pos === false) { } else { $array_var_pos[$pos] = 'page'; } ksort($array_var_pos); $array_var_pos_values = array_values($array_var_pos); foreach($array_var_pos_values as $key => $val) { $ordered_pos[$val] = $key+1; } $mod_rewrite_pattern_orig = $mod_rewrite_pattern; $mod_rewrite_pattern = str_replace('{$tag}','(.*)',$mod_rewrite_pattern); $mod_rewrite_pattern = str_replace('{$page}','(.*)',$mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browsetag.php?tag=\${$ordered_pos[tag]}&pg_which=\${$ordered_pos[page]}\r\n"; $mod_rewrite_pattern = str_replace(strrchr($mod_rewrite_pattern_orig, '/'), '', $mod_rewrite_pattern_orig); $mod_rewrite_pattern = str_replace('{$tag}', '(.*)', $mod_rewrite_pattern); $out .= "{$comment_tag}RewriteRule ^{$mod_rewrite_pattern} browsetag.php?tag=\$1\r\n"; return $out; } ?>Execute($query); // mail('dodyrw@gmail.com','payment log',$query); return mysql_insert_id(); } function UpgradeLink($id, $type, $day) { global $dbConn, $base_path; if ($type == 'PREMIUM') { $premium = 1; $sponsored = 0; } if ($type == 'SPONSORED') { $premium = 0; $sponsored = 1; } if ($type == 'PREMIUM' || $type == 'SPONSORED') { if ($day != 'permanent') { $days_extend = 3600 * 24 * $day; } // check if exist $query = "select link_id, premium, sponsored, expire from idx_paid_listing where link_id = '$id'"; $result = $dbConn->Execute($query); if ($result->RecordCount() == 0) { // create new record if ($day != 'permanent') { $expire = date('Y-m-d H:i:s', strtotime("+$days_extend seconds")); } else { $expire = '2030-01-01 00:00:00'; } $query = "insert into idx_paid_listing (link_id, premium, sponsored, expire, paid) values ('$id', '$premium', '$sponsored', '$expire', 1)"; $result = $dbConn->Execute($query); } else { if ($day != 'permanent') { // get expire time $expire = $result->Fields("expire"); $curr_premium = $result->Fields("premium"); $curr_sponsored = $result->Fields("sponsored"); if ($curr_premium != $premium || $curr_sponsored != $sponsored) { $expire = date('Y-m-d H:i:s'); } if (time() < @strtotime($expire)) { $expire = date('Y-m-d H:i:s', strtotime("$expire +$days_extend seconds")); } else { $expire = date('Y-m-d H:i:s', strtotime("+$days_extend seconds")); } } else { $expire = '2030-01-01 00:00:00'; } // update existing record $query = "update idx_paid_listing set expire = '$expire', premium = $premium, sponsored = $sponsored where link_id = '$id'"; $result = $dbConn->Execute($query); } } // activate link /* $query = "update idx_link set suspended = 0 where link_id = '$id'"; $result = $dbConn->Execute($query); */ ## MZ : delete suspended basic reference $query = "delete from idx_link_suspended_basic where link_id = '$id'"; $result = $dbConn->Execute($query); ## MZ : delete from pending $query = "delete from idx_link_pending where link_id = '$id'"; $result = $dbConn->Execute($query); // remove cache @RemoveDir($base_path . 'cache'); } function MarkAsPaid($id) { global $dbConn; $query = "update idx_invoice set paid = '1', paid_date = now() where invoice_id = '$id'"; $result = $dbConn->Execute($query); } function GetPaymentSystems($model = 'radio') { global $base_path, $id, $gateway; $dir = $base_path . "payment/"; $files = array (); if ($dir = @opendir($dir)) { while (($file = readdir($dir)) !== false) { $files[] = $path . $file; } } closedir($dir); ## make cc as default while (list($k, $v) = @each($files)) { if ($v == 'cc.inc.php') { $first_payment = $files[0]; $files[0] = $v; $files[$k] = $first_payment; break; } } @reset($files); $i = 0; $invoice_id = $id; if (!$gateway) { $checked = "checked=\"checked\""; } foreach ($files as $key => $value) { if (substr($value, -8) == '.inc.php') { /* if ($value == 'cc.inc.php' && $_COOKIE['COOKIE_USERNAME'] != 'flavio') { continue; } */ include $base_path . "payment/" . $value; $ps_name = str_replace('.inc.php','',$value); if($i>0) { $checked = ''; } if ($enable == '1' || $model == 'raw') { if ($model == 'radio') { $ps_html = strip_tags($invoice_html,''); $ps_html = str_replace(' " . $ps_html; } else { $ps .= " " . $ps_html; } } if ($model == 'image') { $ps .= $invoice_html; } if ($model == 'raw') { $ps[$i]['name'] = $ps_name; $ps[$i]['enable'] = $enable; } $i++; } } } return $ps; } function VerifyPaymentGateway($gateway) { global $base_path; $dir = $base_path . "payment/"; $files = array (); if ($dir = @opendir($dir)) { while (($file = readdir($dir)) !== false) { if (substr($file, -8) == '.inc.php') { $payments[] = str_replace('.inc.php', '', $file); } } } closedir ($dir); if (!in_array($gateway, $payments)) { RunPostFilter(); } } function ProcessIDevAffiliate($sale_url, $item_name, $total, $trans_id, $ip_address) { if (strpos($item_name, 'Upgrade ') === false) { $idev_ordernum = $trans_id; $idev_saleamt = $total; HttpRequest($sale_url . "?idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum&ip_address=$ip_address"); } } ?>