function fixMysqlString($string, &$link) { if (version_compare(phpversion(), "4.3.0", ">=")) { return mysql_real_escape_string($string, $link); } else { return mysql_real_escape($string); } }
function document_search () { global $SEARCH_TEXT, $SEARCH_NEW, $search_records, $db, $url_vars, $list_offsets; $search_records = array (); if (isset ($SEARCH_NEW)) { $SEARCH_TEXT = $SEARCH_NEW; unset ($list_offsets[cms_listsource ()]); unset ($url_vars['list_offsets[' . cms_listsource () . ']']); } if (!$SEARCH_TEXT) return; $SEARCH_TEXT = mysql_real_escape ($SEARCH_TEXT); $url_vars['SEARCH_TEXT'] = $SEARCH_TEXT; $res = $db->select ('id', 'products', "name LIKE '%'$SEARCH_TEXT%' OR bestnr LIKE '%$SEARCH_TEXT%'"); while ($res && $row = $res->get ()) $search_records[] = $row; }
function addrelay($ip) { global $pref; if (!preg_match('/\\d+\\.\\d+\\.\\d+\\.\\d+/', $ip)) { return 1; } // Delete any entries older than 1 hour from the "user" table $query = sprintf("delete from MailRelay where Account='User' and DateAdded < DATE_SUB(NOW(), INTERVAL %d MINUTE)", $pref['smtp_popimaprelay_timeout']); mysql_query($query); // Add the new IP into the database, only if we do not exist $ip = mysql_real_escape($ip); $query = sprintf("select IPaddress from MailRelay where IPaddress='%s'", $ip); $res = mysql_query($query); if ($res === false) { return -1; } if (mysql_result($res, 0)) { $query = sprintf("INSERT INTO MailRelay (IPaddress, Account, DateAdded) VALUES('%s', 'User', NOW() )", $ip); $res = mysql_query($query); } else { // Update the DateAdded to now, so user always in sync to relay $query = sprintf("UPDATE MailRelay set DateAdded=NOW() where IPaddress='%s' and Account='User'", $ip); $res2 = mysql_query($query); } return; }