txt; } function unique_id( ) { /* mysql_query('INSERT INTO unique_id VALUES()'); $unique_id = mysql_insert_id( ); mysql_query("DELETE FROM unique_id WHERE id<$unique_id"); return $unique_id; */ return hexdec(uniqid("0x")) - 1414213562373095; } function get_field(&$obj, $fld) { return is_object($obj) ? $obj->$fld : $obj[$fld]; } define(CACHE_LIFE, 1800); // 30 minutes define(CACHE_OVERLAP, 300); // 5 minutes function claim_cache($name, $duration=CACHE_OVERLAP) { global $now; $release_time = $now + $duration; mysql_query("UPDATE params SET proc=$release_time WHERE name='$name'"); } function save_cache_array($name, $arr) { global $now; $value= array( ); foreach ($arr as $key => $val) $value[] = $key.':'.$val; $value = "$now;".implode(',', $value); mysql_query("UPDATE params SET updts=$now,proc=NULL,value='$value' WHERE name='$name'"); if (mysql_affected_rows( ) < 1) mysql_query("INSERT INTO params(updts,name,value) VALUES($now,'$name','$value')"); } function read_cache_array($name, $life=CACHE_LIFE) { global $now; $res = mysql_query($sql = "SELECT updts,proc,value FROM params WHERE name='$name'"); if ($res && $obj = mysql_fetch_object($res)) { $arr = explode(';', $obj->value); if ($arr[0] < $now - $life) return false; else { $arr2 = array( ); $arr = explode(',', $arr[1]); foreach ($arr as $aa) { list($key, $val) = explode(':', $aa); if ($key || $val) $arr2[$key] = $val; // vendor_id => value } return $arr2; } } return false; } function save_cache($name, $data) { global $now; $data_enc = serialize($data); mysql_query("UPDATE params SET updts=$now,proc=null,value='$data_enc' WHERE name='$name'"); if (mysql_affected_rows( ) < 1) mysql_query("INSERT INTO params(updts,name,value) VALUES($now,'$name','$data_enc')"); } function read_cache($name, $life=CACHE_LIFE) { global $now; $res = mysql_query("SELECT updts,proc,value FROM params WHERE name='$name'"); if ($res && $obj = mysql_fetch_object($res)) { $pos = strpos($obj->value, ','); if ($pos != 10) $pos = 0; if ($obj->updts) { $updts = $obj->updts; } else if ($pos) { $updts = intval($obj->value); } if (($updts >= $now - $life) || ($now < $obj->proc)) { // fresh cache or cache update // is in progress return unserialize(substr($obj->value, $pos ? $pos+1 : 0)); } } return false; } function sched_vendor_refresh($vendorid) { mysql_query("UPDATE params SET value=value+$vendorid+' ' WHERE name='vendors_upd_list'"); } function unique_form_id($uid, $check = false) { global $now; $ts_from = date('Ymd', $now - TIME_DAY); $ts_now = date('Ymd', $now); $id = false; if ($check) { $check = intval($check); mysql_query("DELETE FROM counter WHERE cat=".COUNTER_CAT_FORMID." AND ts<$ts_from"); $res = mysql_query("SELECT id FROM counter ". "WHERE id=$check AND uid=$uid AND cat=".COUNTER_CAT_FORMID); $id = ($res && mysql_num_rows( $res ) > 0); if ($id) mysql_query("DELETE FROM counter WHERE id=$check"); } else { mysql_query('INSERT INTO counter(ts,cat,uid,lasthit,lastip) '. "VALUES($ts_now,".COUNTER_CAT_FORMID.",$uid,$now,'$GLOBALS[REMOTE_ADDR]')"); $id = mysql_insert_id(); } return $id; } function ip_blacklisted($ip) { $dnsbl_check=array ( 'bl.spamcop.net', 'list.dsbl.org', 'sbl.spamhaus.org', 'dnsbl.sorbs.net' ); $listed = false; if ($ip) { $quads=explode('.', $ip); $rip = $quads[3].'.'.$quads[2].'.'.$quads[1].'.'.$quads[0]; foreach ($dnsbl_check as $srv) { if (checkdnsrr("{$rip}.{$srv}.", 'A')) { $listed = $srv; break; } } } return $listed; } function vendor_order_check($vendorid) { $res = mysql_query('SELECT COUNT(*) AS cnt FROM message AS m '. "WHERE m.targetid=$vendorid AND m.seen=0"); $ret = @mysql_result($res, 0) ? 0x01 : 0; $res = mysql_query($sql = 'SELECT COUNT(*) AS cnt FROM orders AS o '. "WHERE o.owner=$vendorid AND o.status>=0 AND o.status<".ORDSTS_SEEN); $ret |= @mysql_result($res, 0) ? 0x02 : 0; return $ret; } function str_crc32($str) { return sprintf('%u', crc32(mb_strtolower($str))); } function block_contacts($string) { $string = preg_replace('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}\b/si', '[контактная информация недопустима]', $string); return preg_replace('/\+?[0-9][0-9()\-\s+]{8,20}[0-9]/', '[контактная информация недопустима]', $string); } ?>
Warning: Cannot modify header information - headers already sent by (output started at /usr/local/tmp/midgard/20019-20763-20017-0.php:19) in /usr/local/tmp/midgard/20019-20763-20017-0.php on line 217
Описания книг
LibeX: Книжный интернет магазин. Продать книги. Купить книги

Магазин, где можно не только купить, но и продать книги

Статистика сайта

Просмотры книги
Брук, Яков: "Василий Верещагин"



Fatal error: Cannot instantiate non-existent class: sqlstatement in /usr/local/tmp/midgard/20019-20763-20017-0.php on line 1946