本文整理汇总了PHP中mysql_escape_string2函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_escape_string2函数的具体用法?PHP mysql_escape_string2怎么用?PHP mysql_escape_string2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_escape_string2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wizard_certificate_save
function wizard_certificate_save()
{
$password = url_decode_special_tool($_POST["wizard-certificate-password"]);
$password = mysql_escape_string2($password);
$CommonName = url_decode_special_tool($_POST["wizard-certificate-commonname"]);
$CommonName = strtolower(trim($CommonName));
if ($CommonName == null) {
echo "CommonName, no such data";
return;
}
$q = new mysql();
$sql = "SELECT CommonName FROM sslcertificates WHERE CommonName='{$CommonName}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if ($ligne["CommonName"] != null) {
echo "{$CommonName} Already exists...\n";
return;
}
$sql = "INSERT IGNORE INTO sslcertificates (CommonName,keyPassword,password) VALUES ('{$CommonName}','{$password}','{$password}')";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "MySQL Error:\n" . $q->mysq_error . "\n{$sql}";
return;
}
$sock = new sockets();
$CommonName = urlencode($CommonName);
echo base64_decode($sock->getFrameWork("system.php?BuildCSR={$CommonName}"));
}
示例2: send_to_mysql
function send_to_mysql($buffer)
{
$dbpath = "/home/artica/postfix/milter-greylist/logger/" . date("YmdH") . ".miltergreylist.db";
if (!berekley_db_create($dbpath)) {
return;
}
$db_con = @dba_open($dbpath, "w", "db4");
if (!$db_con) {
ToSyslog("send_to_mysql:: {$dbpath} failed connect");
@dba_close($db_con);
continue;
}
$results = explode(",", $buffer);
$md5 = md5($buffer . time());
$instance = $results[0];
$publicip = $results[1];
$mailfrom = mysql_escape_string2($results[2]);
$rcpt = mysql_escape_string2($results[3]);
$failed = $results[6];
$Country = $results[7];
$HOUR = date('H');
$date = date("Y-m-d H:i:s");
$tablename = "mgreyh_" . date("YmdH");
$mailfromZ = explode("@", $mailfrom);
$rcptZ = explode("@", $rcpt);
$prefix = "INSERT IGNORE INTO {$tablename} (`zmd5`,`ztime`,`zhour`,`mailfrom`,`instancename`,`mailto`,`domainfrom`,`domainto`,`senderhost`,`failed`) VALUES ";
$suffix = "('{$md5}','{$date}','{$HOUR}','{$mailfrom}','{$instance}','{$rcpt}','{$mailfromZ[1]}','{$rcptZ[1]}','{$publicip}','{$failed}')";
$md5 = md5($suffix);
dba_replace($md5, $suffix, $db_con);
@dba_close($db_con);
return;
}
示例3: Save
function Save()
{
$q = new mysql();
if (!$q->TABLE_EXISTS("storage_containers", "artica_backup")) {
$sql = "CREATE TABLE IF NOT EXISTS `artica_backup`.`storage_containers` (\n\t\t\t\t`groupid` VARCHAR( 255 ) NOT NULL,\n\t\t\t\t`enabled` smallint( 1 ) NOT NULL,\n\t\t\t\t`maxsize` INT UNSIGNED ,\n\t\t\t\t`directory` VARCHAR( 255 ) NOT NULL,\n\t\t\t\t PRIMARY KEY ( `groupid` ),\n\t\t\t\t KEY `enabled`(`enabled`)\n\t\t\t\t) ENGINE=MYISAM;";
$q->QUERY_SQL($sql, 'artica_backup');
if (!$q->ok) {
echo $q->mysql_error;
return;
}
}
$_POST["directory"] = mysql_escape_string2($_POST["directory"]);
$gid = mysql_escape_string2($_POST["gid"]);
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM storage_containers WHERE `groupid`='{$gid}'", "artica_backup"));
//echo "$gid = {$ligne["directory"]} Enabled={$_POST["enabled"]}\n";
if ($ligne["directory"] != null) {
$q->QUERY_SQL("UPDATE storage_containers SET `maxsize`='{$_POST["maxsize"]}',\n\t\tenabled='{$_POST["enabled"]}',`directory`='{$_POST["directory"]}' WHERE `groupid`='{$gid}'", "artica_backup");
} else {
$q->QUERY_SQL("INSERT IGNORE INTO storage_containers (groupid,enabled,maxsize,`directory`)\n\t\t\t\tVALUES ('{$gid}','{$_POST["enabled"]}','{$_POST["maxsize"]}','{$_POST["directory"]}')", "artica_backup");
}
if (!$q->ok) {
echo $q->mysql_error;
return;
}
}
示例4: SaveItems
function SaveItems(){
$category=$_POST["category"];
$datas=$_POST["items"];
$q=new mysql_squid_builder();
$tb=explode("\n",$datas);
while (list ($num, $www) = each ($tb) ){
if(preg_match("#tp:\/\/(.+)#", $www,$re)){$www=$re[1];}
$www=str_replace("www.", "", $www);
$uris[$www]=true;
}
$zDate=date("Y-m-d H:i:s");
while (list ($www, $none) = each ($uris) ){
if(trim($www)==null){continue;}
$md5=md5("$category$www");
echo "Saving $www\n";
$www=mysql_escape_string2($www);
$f[]="('$md5','$zDate','$www',1)";
}
$table="categoryuris_".$q->category_transform_name($category);
if(!$q->CreateCategoryUrisTable(null,$table)){
echo $q->mysql_error;
return;
}
if(count($f)>0){
$sql="INSERT IGNORE INTO `$table` (`zmd5`,`zDate`,`pattern`,`enabled`) VALUES ".@implode(",", $f);
$q->QUERY_SQL($sql);
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("squid.php?ufdbguard-compile-database={$_POST["category"]}");
}
}
示例5: save
function save()
{
$q = new mysql_meta();
$f = array();
$f = explode("\n", $_POST["domains"]);
while (list($index, $line) = each($f)) {
$line = trim(strtolower($line));
if ($line == null) {
continue;
}
$line = mysql_escape_string2($line);
$md5 = md5($line);
$n[] = "('{$md5}','{$line}')";
}
$q->CheckTables();
$q->QUERY_SQL("TRUNCATE TABLE `squid_whitelists`");
if (count($n) > 0) {
$q->QUERY_SQL("INSERT IGNORE INTO `squid_whitelists` (`zMD5`,`pattern`) VALUES " . @implode(",", $n));
if (!$q->ok) {
echo $q->mysql_error;
return;
}
}
$sock = new sockets();
$EnableArticaMetaServer = intval($sock->GET_INFO("EnableArticaMetaServer"));
if ($EnableArticaMetaServer == 0) {
return;
}
$sock->getFrameWork("artica.php?meta-proxy-config=yes");
}
示例6: time_save
function time_save()
{
$ID = $_POST["time-save"];
$array_days = array(1 => "monday", 2 => "tuesday", 3 => "wednesday", 4 => "thursday", 5 => "friday", 6 => "saturday", 7 => "sunday");
while (list($num, $maks) = each($array_days)) {
if ($_POST["D{$num}"] == 1) {
$TTIME["D{$num}"] = 1;
}
}
$TTIME["ttime"] = $_POST["ttime"];
$TTIME["ftime"] = $_POST["ftime"];
$rule1 = strtotime(date("Y-m-d") . " {$TTIME["ftime"]}");
$rule2 = strtotime(date("Y-m-d") . " {$TTIME["ttime"]}");
if ($rule1 > $rule2) {
$tpl = new templates();
echo $tpl->javascript_parse_text("{fwtime_explain}");
return;
}
$TTIMEZ = mysql_escape_string2(serialize($TTIME));
$q = new mysql();
if (!$q->FIELD_EXISTS("iptables_main", "time_restriction", "artica_backup")) {
$sql = "ALTER TABLE `iptables_main` ADD `time_restriction` TEXT";
$q->QUERY_SQL($sql, "artica_backup");
}
if (!$q->FIELD_EXISTS("iptables_main", "enablet", "artica_backup")) {
$sql = "ALTER TABLE `iptables_main` ADD `enablet` smallint( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( enablet ) ";
$q->QUERY_SQL($sql, "artica_backup");
}
$sql = "UPDATE iptables_main SET `enablet`='{$_POST["enablet"]}',`time_restriction`='{$TTIMEZ}' WHERE ID='{$ID}'";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error . "\n{$sql}";
}
}
示例7: Save
function Save()
{
$_POST["rulename"] = mysql_escape_string2(url_decode_special_tool($_POST["rulename"]));
$sql = "UPDATE haproxy_acls_rules SET \n\t\trulename='{$_POST["rulename"]}',\n\t\trule_action='{$_POST["rule_action"]}',\n\t\trule_action_data='{$_POST["rule_action_data"]}',\n\t\tzorder='{$_POST["zorder"]}'\n\t\tWHERE ID={$_POST["ruleid"]}";
$q = new mysql();
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error;
}
}
示例8: import
function import()
{
$q = new mysql_squid_builder();
$sql_add = "INSERT IGNORE INTO webfilter_members (`membertype`,`pattern`,`enabled`,`groupid`) VALUES ";
$f = explode("\n", $_POST["item-import"]);
while (list($num, $ligne) = each($f)) {
$ligne = trim($ligne);
if ($ligne == null) {
continue;
}
$RR = mysql_fetch_array($q->QUERY_SQL("SELECT ID FROM webfilter_members WHERE pattern='{$ligne}'"));
$ID = intval($RR["ID"]);
$ligne = mysql_escape_string2($ligne);
$ZZ[] = "('{$_POST["membertype"]}','{$ligne}',1,{$_POST["group_id"]})";
}
if (count($ZZ) == 0) {
return;
}
$q->QUERY_SQL($sql_add . @implode(",", $ZZ));
}
示例9: smtpd_client_restrictions_save
function smtpd_client_restrictions_save()
{
$sock = new sockets();
$ou = $_POST["ou"];
if ($ou == null) {
$ou = $_SESSION["ou"];
}
if ($ou == null) {
echo "Organization is null!\n";
return;
}
$q = new mysql();
while (list($num, $ligne) = each($_POST)) {
$MAIN[$num] = $ligne;
}
$q->QUERY_SQL("DELETE FROM smptd_client_access WHERE `ou`='{$ou}'");
$DATA = mysql_escape_string2(base64_decode(serialize($MAIN)));
$q->QUERY_SQL("INSERT IGNORE INTO smptd_client_access (ou, configuration) VALUES ('{$ou}','{$DATA}')", "artica_backup");
if (!$q->ok) {
echo $q->mysql_error;
return;
}
$sock->getFrameWork("postfix.php?smtpd-recipient-restrictions=yes");
}
示例10: build_query_js
function build_query_js()
{
$page = CurrentPageName();
$tpl = new templates();
$from = strtotime("{$_GET["date1"]} {$_GET["time1"]}");
$to = strtotime("{$_GET["date2"]} {$_GET["time2"]}");
$interval = $_GET["interval"];
$t = $_GET["t"];
$user = $_GET["user"];
$md5 = md5("WEBSITES:{$from}{$to}{$interval}{$user}{$_GET["searchsites"]}{$_GET["searchuser"]}");
$_SESSION["SQUID_STATS_DATE1"] = $_GET["date1"];
$_SESSION["SQUID_STATS_TIME1"] = $_GET["time1"];
$_SESSION["SQUID_STATS_DATE2"] = $_GET["date2"];
$_SESSION["SQUID_STATS_TIME2"] = $_GET["time2"];
$timetext1 = $tpl->time_to_date(strtotime("{$_GET["date1"]} {$_GET["time1"]}"), true);
$timetext2 = $tpl->time_to_date(strtotime("{$_GET["date2"]} {$_GET["time2"]}"), true);
$nextFunction = "LoadAjax('WEBFILTERING_STATS_MAIN_GRAPH','{$page}?main=yes&zmd5={$md5}&t={$t}');";
$nextFunction_encoded = urlencode(base64_encode($nextFunction));
$q = new mysql_squid_builder();
$q->CheckReportTable();
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT ID,builded FROM reports_cache WHERE `zmd5`='{$md5}'"));
if (intval($ligne["ID"]) == 0) {
$array["FROM"] = $from;
$array["TO"] = $to;
$array["INTERVAL"] = $interval;
$array["USER"] = $user;
$array["categories"] = $_GET["categories"];
$array["searchuser"] = $_GET["searchuser"];
$serialize = mysql_escape_string2(serialize($array));
$title = "{webfiltering}: {$timetext1} - {to} {$timetext2} and {$user} {is} {$array["searchuser"]}";
$sql = "INSERT IGNORE INTO `reports_cache` (`zmd5`,`title`,`report_type`,`zDate`,`params`) VALUES \n\t\t('{$md5}','{$title}','WEBFILTERING',NOW(),'{$serialize}')";
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo "alert('" . $tpl->javascript_parse_text($q->mysql_errror) . "')";
return;
}
echo "Loadjs('squid.statistics.progress.php?zmd5={$md5}&NextFunction={$nextFunction_encoded}')";
return;
}
if (intval($ligne["builded"] == 0)) {
echo "\nfunction Start{$t}(){\n\tLoadjs('squid.statistics.progress.php?zmd5={$md5}&NextFunction={$nextFunction_encoded}&t={$t}');\n}\n\nif(document.getElementById('graph-{$t}')){\n\tdocument.getElementById('graph-{$t}').innerHTML='<center><img src=img/loader-big.gif></center>';\n}\nLockPage();\t\nsetTimeout('Start{$t}()',800);\n";
return;
}
echo $nextFunction;
}
示例11: AddNewSchedule_save
function AddNewSchedule_save()
{
$users = new usersMenus();
$q = new mysql_meta();
$tpl = new templates();
$task = new system_tasks();
$task_type = $task->tasks_array;
$info = $tpl->javascript_parse_text($task_type[$_POST["TaskType"]]);
$defaultdesc = replace_accents($info);
if ($_POST["TimeDescription"] == null) {
$_POST["TimeDescription"] = $defaultdesc . " : {$_POST["TimeText"]}";
}
$_POST["TimeDescription"] = mysql_escape_string2($_POST["TimeDescription"]);
$sql = "INSERT IGNORE INTO system_schedules (TimeDescription,TimeText,TaskType,enabled,uuid) \n\tVALUES('{$_POST["TimeDescription"]}','{$_POST["TimeText"]}','{$_POST["TaskType"]}',1,'{$_POST["uuid"]}')";
if ($_POST["ID"] > 0) {
$sql = "UPDATE system_schedules SET \n\t\t\tTimeDescription='{$_POST["TimeDescription"]}',\n\t\t\tTimeText='{$_POST["TimeText"]}',\n\t\t\tTaskType='{$_POST["TaskType"]}' WHERE ID={$_POST["ID"]}\n\t\t\t";
}
if (!$q->TABLE_EXISTS("system_schedules")) {
$q->BuildTables();
}
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo $q->mysql_error;
return;
}
$sock = new sockets();
$sock->getFrameWork("artica.php?build-meta-schedules=yes&uuid={$_POST["uuid"]}");
}
示例12: new_rule
function new_rule(){
$q=new mysql_squid_builder();
$q->CheckTables(null,true);
$rulename=mysql_escape_string2(url_decode_special_tool($_POST["new-rule"]));
$q->QUERY_SQL("INSERT INTO wpad_rules (rulename,enabled) VALUES ('$rulename','1')");
if(!$q->ok){echo $q->mysql_error;}
}
示例13: _table_hours_perform
function _table_hours_perform($tablename)
{
if (!isset($GLOBALS["Q"])) {
$GLOBALS["Q"] = new mysql_squid_builder();
}
if (!preg_match("#ngixattck_([0-9]+)#", $tablename, $re)) {
writelogs_squid("NOT AN HOUR TABLE `{$tablename}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
$q = new mysql_squid_builder();
$time = $q->TIME_FROM_HOUR_TEMP_TABLE($tablename);
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename} - {$time} - " . date("Y-m-d", $time) . "\n";
}
$sql = "SELECT HOUR(zDate) as `hour`,COUNT(keyr) as hits,`ipaddr`,`familysite`,`hostname`,`country`,`servername`\n\tFROM `{$tablename}` GROUP BY `hour`,`ipaddr`,`familysite`,`hostname`,`country`,`servername`";
if ($GLOBALS["VERBOSE"]) {
echo $sql . "\n";
}
$results = $GLOBALS["Q"]->QUERY_SQL($sql);
if (!$GLOBALS["Q"]->ok) {
writelogs_squid("Fatal: {$GLOBALS["Q"]->mysql_error} on `{$tablename}`\n" . @implode("\n", $GLOBALS["REPAIR_MYSQL_TABLE"]), __FUNCTION__, __FILE__, __LINE__, "stats");
if (strpos(" {$GLOBALS["Q"]->mysql_error}", "is marked as crashed and should be repaired") > 0) {
$q1 = new mysql();
writelogs_squid("try to repair table `{$tablename}`", __FUNCTION__, __FILE__, __LINE__, "stats");
$q1->REPAIR_TABLE("squidlogs", $tablename);
writelogs_squid(@implode("\n", $GLOBALS["REPAIR_MYSQL_TABLE"]), __FUNCTION__, __FILE__, __LINE__, "stats");
}
return false;
}
if (mysql_num_rows($results) == 0) {
return true;
}
$timekey = date('Ymd', $time);
$tabledest = "ngixattckd_{$timekey}";
if (!$q->check_nginx_attacks_DAY($timekey)) {
return false;
}
$prefix = "INSERT IGNORE INTO {$tabledest} (zmd5,`hour`,`ipaddr`,`familysite`,`hostname`,`country`,`servername`,`hits`) VALUES ";
$d = 0;
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$zmd = array();
while (list($key, $value) = each($ligne)) {
$ligne[$key] = mysql_escape_string2($value);
$zmd[] = $value;
}
$zMD5 = md5(@implode("", $zmd));
$f[] = "('{$zMD5}','{$ligne["hour"]}','{$ligne["ipaddr"]}','{$ligne["familysite"]}','{$ligne["hostname"]}','{$ligne["country"]}','{$ligne["servername"]}','{$ligne["hits"]}')";
if (count($f) > 500) {
$q->QUERY_SQL($prefix . @implode(",", $f));
$f = array();
if (!$q->ok) {
writelogs_squid("Fatal: {$q->mysql_error} on `{$tabledest}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
}
}
if (count($f) > 0) {
$q->QUERY_SQL($prefix . @implode(",", $f));
$f = array();
if (!$q->ok) {
writelogs_squid("Fatal: {$q->mysql_error} on `{$tabledest}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
}
return true;
}
示例14: Save
function Save()
{
writelogs("Saving rule", __FUNCTION__, __FILE__, __LINE__);
$q = new mysql_squid_builder();
$table = "transparent_networks";
if (!$q->TABLE_EXISTS($table)) {
$q->CheckTables(null, true);
}
if (!$q->FIELD_EXISTS("transparent_networks", "block")) {
$q->QUERY_SQL("ALTER TABLE `transparent_networks` ADD `block` smallint( 1 ) NOT NULL ,ADD INDEX ( `block`)");
}
$editF = false;
$ID = $_POST["ID"];
unset($_POST["ID"]);
if (preg_match("#[0-9A-Za-z]+-[0-9A-Za-z]+-[0-9A-Za-z]+-[0-9A-Za-z]+-[0-9A-Za-z]+-[0-9A-Za-z]+#", $_POST["pattern"])) {
$_POST["pattern"] = strtolower($_POST["pattern"]);
$_POST["pattern"] = str_replace("-", ":", $_POST["pattern"]);
}
while (list($key, $value) = each($_POST)) {
$value = url_decode_special_tool($value);
$fields[] = "`{$key}`";
$values[] = "'" . mysql_escape_string2($value) . "'";
$edit[] = "`{$key}`='" . mysql_escape_string2($value) . "'";
}
$sql_edit = "UPDATE `{$table}` SET " . @implode(",", $edit) . " WHERE ID='{$ID}'";
$sql = "INSERT IGNORE INTO `{$table}` (" . @implode(",", $fields) . ") VALUES (" . @implode(",", $values) . ")";
if ($ID > 0) {
$sql = $sql_edit;
}
writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo "Mysql error: `{$q->mysql_error}`";
writelogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__);
return;
}
$tpl = new templates();
}
示例15: save
function save()
{
$q = new mysql();
$table = "texttoldap";
$tpl = new templates();
$editF = false;
$ID = $_POST["connection-id"];
unset($_POST["connection-id"]);
while (list($key, $value) = each($_POST)) {
$value = url_decode_special_tool($value);
$fields[] = "`{$key}`";
$values[] = "'" . mysql_escape_string2($value) . "'";
$edit[] = "`{$key}`='" . mysql_escape_string2($value) . "'";
}
$sql_edit = "UPDATE `{$table}` SET " . @implode(",", $edit) . " WHERE ID='{$ID}'";
$sql = "INSERT IGNORE INTO `{$table}` (" . @implode(",", $fields) . ") VALUES (" . @implode(",", $values) . ")";
if ($ID > 0) {
$sql = $sql_edit;
}
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "Mysql error: `{$q->mysql_error}`";
return;
}
$tpl = new templates();
$tpl->javascript_parse_text("{success}");
}