本文整理汇总了PHP中mysql::mysql_real_escape_string2方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::mysql_real_escape_string2方法的具体用法?PHP mysql::mysql_real_escape_string2怎么用?PHP mysql::mysql_real_escape_string2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql
的用法示例。
在下文中一共展示了mysql::mysql_real_escape_string2方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules_save
function rules_save()
{
$q = new mysql();
$rulename = $q->mysql_real_escape_string2($_GET["rule_name"]);
if ($rulename == null) {
$rulename = $_GET["rule_name"];
}
$delay_pool_net = $_GET["delay_pool_net"];
$delay_pool_net = $delay_pool_net * 1000;
$delay_pool_net = $delay_pool_net / 8;
$delay_pool_max_file = $_GET["delay_pool_max_file"];
$delay_pool_max_file = $delay_pool_max_file * 1000;
$delay_pool_max_file = $delay_pool_max_file / 8;
$delay_pool_limit = $_GET["delay_pool_limit"];
$delay_pool_limit = $delay_pool_limit * 1000;
$delay_pool_limit = $delay_pool_limit / 8;
$delay_pool_net = "{$delay_pool_net}/{$delay_pool_net}";
$delay_pool_net2 = "{$delay_pool_limit}/{$delay_pool_max_file}";
$sql = "INSERT INTO squid_pools (rulename,total_net,total_users)\n\tVALUES('{$_GET["rule_name"]}','{$delay_pool_net}','{$delay_pool_net2}')";
if ($_GET["ID"] > 0) {
$sql = "UPDATE squid_pools\n\t\tSET rulename='{$rulename}',\n\t\ttotal_net='{$delay_pool_net}',\n\t\ttotal_users='{$delay_pool_net2}',\n\t\tenable='{$_GET["enable"]}'\n\t\tWHERE ID={$_GET["ID"]}\n\t\t";
}
$q->QUERY_SQL($sql, 'artica_backup');
if (!$q->ok) {
echo $q->mysql_error;
return;
}
$sock = new sockets();
$sock->getFrameWork("cmd.php?squid-reload=yes");
}
示例2: task_computers_events
function task_computers_events($text)
{
$sql = "SELECT events FROM computers_deploy_tasks_sub WHERE ID={$GLOBALS[__FILE__]["SUBTASKID"]}";
$q = new mysql();
$ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
$datas = unserialize(base64_decode($ligne["events"]));
$text = date('m-d H:i:s') . " {$text}";
echo $text . "\n";
$text = $q->mysql_real_escape_string2($text);
$text = htmlentities($text);
$datas[] = "<div>{$text}</div>";
$translate = base64_encode(serialize($datas));
$sql = "UPDATE computers_deploy_tasks_sub SET events='{$translate}' WHERE ID={$GLOBALS[__FILE__]["SUBTASKID"]}";
$q = new mysql();
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "{$sql} {$q->mysql_error}\n";
}
}
示例3: user_agent_ban_search
function user_agent_ban_search()
{
$query = "*" . $_GET["user-agent-ban-search"] . "*";
$query = str_replace("**", "*", $query);
$q = new mysql();
$query = $q->mysql_real_escape_string2($query);
$query = str_replace("*", "%", $query);
$limit = 50;
if (strlen($query) > 2) {
$limit = 150;
}
$sql = "SELECT * FROM UserAgents WHERE string LIKE '{$query}' ORDER BY browser,string LIMIT 0,50";
$results = $q->QUERY_SQL($sql, "artica_backup");
$html = "<table class=tableView style='width:99%'>\n\t\t\t\t<thead class=thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th width=1% nowrap colspan=3> </td>\n\t\t\t\t</tr>\n\t\t\t\t</thead>";
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
if ($cl == "oddRow") {
$cl = null;
} else {
$cl = "oddRow";
}
$html = $html . "\n\t\t<tr class={$cl}>\n\t\t\t<td width=1% nowrap><code style='font-size:10px'>{$ligne["browser"]}</code></td>\n\t\t\t<td width=99%><code style='font-size:10px'>{$ligne["string"]}</td>\n\t\t\t<td width=1%><span id='id_{$ligne["unique_key"]}'>" . Field_checkbox("{$ligne["unique_key"]}", 1, 0, "AddBanUserAgent('{$ligne["unique_key"]}')") . "</span></td>\n\t\t</tr>";
}
$html = $html . "</table>";
$tpl = new templates();
echo $tpl->_ENGINE_parse_body($html);
}
示例4: rules_save
function rules_save(){
$q=new mysql();
$rulename=$q->mysql_real_escape_string2($_GET["rule_name"]);
if($rulename==null){$rulename=$_GET["rule_name"];}
$delay_pool_net=$_GET["delay_pool_net"];
$delay_pool_net=$delay_pool_net*1000;
$delay_pool_net=$delay_pool_net/8;
$delay_pool_max_file=$_GET["delay_pool_max_file"];
$delay_pool_max_file=$delay_pool_max_file*1000;
$delay_pool_max_file=$delay_pool_max_file/8;
$delay_pool_limit=$_GET["delay_pool_limit"];
$delay_pool_limit=$delay_pool_limit*1000;
$delay_pool_limit=$delay_pool_limit/8;
$delay_pool_net="$delay_pool_net/$delay_pool_net";
$delay_pool_net2="$delay_pool_limit/$delay_pool_max_file";
$rule_class=$_GET["rule_class"];
if(!is_numeric($rule_class)){$rule_class=2;}
$sql="INSERT INTO squid_pools (rulename,total_net,total_users,rule_class)
VALUES('{$_GET["rule_name"]}','$delay_pool_net','$delay_pool_net2',$rule_class)";
if($_GET["ID"]>0){
$sql="UPDATE squid_pools
SET rulename='$rulename',
total_net='$delay_pool_net',
total_users='$delay_pool_net2',
rule_class=$rule_class,
enable='{$_GET["enable"]}'
WHERE ID={$_GET["ID"]}
";
}
$q->QUERY_SQL($sql,'artica_backup');
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();$sock->getFrameWork("cmd.php?squid-reload=yes");
}
示例5: rules_save
function rules_save()
{
$q = new mysql();
$q->CheckTablesSquid();
$rulename = $q->mysql_real_escape_string2(url_decode_special_tool($_POST["rule_name"]));
if ($rulename == null) {
$rulename = "New rule";
}
$rule_class = 2;
$sql = "CREATE TABLE IF NOT EXISTS `artica_backup`.`squid_pools` (\n\t\t\t`ID` INT(10) AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`rulename` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`rule_class` INT( 1 ) NOT NULL DEFAULT '2',\n\t\t\t`total_net_enabled` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t`total_net_max` BIGINT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t`total_net` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`total_net_band` BIGINT UNSIGNED NOT NULL,\n\t\t\t`total_computer_enabled` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t`total_computer_max` BIGINT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t`total_computer_band` BIGINT UNSIGNED NOT NULL ,\n\t\t\t`total_member_enabled` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t`total_member_max` BIGINT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t`total_member_band` BIGINT UNSIGNED NOT NULL ,\t\t\t\n\t\t\t`total_user_enabled` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t`total_user_max` BIGINT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t`total_user_band` BIGINT UNSIGNED NOT NULL ,\n\t\t\t`total_users` VARCHAR( 90 ) NOT NULL ,\n\t\t\tINDEX ( `rulename` )) ENGINE=MYISAM;";
$q->QUERY_SQL($sql, 'artica_backup');
if (!$q->FIELD_EXISTS("squid_pools", "total_member_enabled", "artica_backup")) {
$sql = "ALTER TABLE `squid_pools` ADD `total_member_enabled` smallint(1) NOT NULL DEFAULT '0',ADD INDEX ( `total_member_enabled` )";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "{$q->mysql_error}\n{$sql}";
return;
}
}
if (!$q->FIELD_EXISTS("squid_pools", "total_member_max", "artica_backup")) {
$sql = "ALTER TABLE `squid_pools` ADD `total_member_max` BIGINT UNSIGNED NOT NULL DEFAULT '0',ADD INDEX ( `total_member_max` )";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "{$q->mysql_error}\n{$sql}";
return;
}
}
if (!$q->FIELD_EXISTS("squid_pools", "total_member_band", "artica_backup")) {
$sql = "ALTER TABLE `squid_pools` ADD `total_member_band` BIGINT UNSIGNED NOT NULL DEFAULT '0',ADD INDEX ( `total_member_band` )";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "{$q->mysql_error}\n{$sql}";
return;
}
}
$total_net_max = intval($_POST["total_net_max"]);
$total_net_max = $total_net_max * 1024;
$total_net_max = $total_net_max * 1024;
$total_computer_max = intval($_POST["total_computer_max"]);
$total_computer_max = $total_computer_max * 1024;
$total_computer_max = $total_computer_max * 1024;
$total_user_max = intval($_POST["total_user_max"]);
$total_user_max = $total_user_max * 1024;
$total_user_max = $total_user_max * 1024;
$total_net_band = intval($_POST["total_net_band"]);
$total_net_band = $total_net_band * 1000;
$total_net_band = $total_net_band / 8;
$total_computer_band = intval($_POST["total_computer_band"]);
$total_computer_band = $total_computer_band * 1000;
$total_computer_band = $total_computer_band / 8;
$total_user_band = intval($_POST["total_user_band"]);
$total_user_band = $total_user_band * 1000;
$total_user_band = $total_user_band / 8;
$total_member_band = intval($_POST["total_member_band"]);
$total_member_band = $total_user_band * 1000;
$total_member_band = $total_user_band / 8;
$total_member_max = intval($_POST["total_member_max"]);
$total_member_max = $total_member_max * 1024;
$total_member_max = $total_member_max * 1024;
$total_user_enabled = intval($_POST["totaluserenabled"]);
$total_member_enabled = intval($_POST["total_member_enabled"]);
$total_net_enabled = intval($_POST["total_net_enabled"]);
$total_computer_enabled = intval($_POST["total_computer_enabled"]);
$sql = "INSERT INTO squid_pools (rulename,total_user_enabled,total_net_enabled,total_computer_enabled,total_member_enabled,\n\ttotal_net_max,total_computer_max,total_user_max,total_net_band,total_computer_band,total_user_band\n\t)\n\tVALUES('{$rulename}','{$total_user_enabled}','{$total_net_enabled}','{$total_computer_enabled}','{$total_member_enabled}',\n\t'{$total_net_max}','{$total_computer_max}','{$total_user_max}','{$total_net_band}','{$total_computer_band}','{$total_user_band}'\n\t)";
if ($_POST["ID"] > 0) {
$sql = "UPDATE squid_pools\n\t\tSET rulename='{$rulename}',\n\t\ttotal_user_enabled='{$total_user_enabled}',\n\t\ttotal_net_enabled='{$total_net_enabled}',\n\t\ttotal_member_enabled='{$total_member_enabled}',\n\t\ttotal_computer_enabled='{$total_computer_enabled}',\n\t\ttotal_net_max='{$total_net_max}',\n\t\ttotal_computer_max='{$total_computer_max}',\n\t\ttotal_user_max='{$total_user_max}',\n\t\ttotal_member_max='{$total_member_max}',\n\t\ttotal_net_band='{$total_net_band}',\n\t\ttotal_computer_band='{$total_computer_band}',\n\t\ttotal_member_band='{$total_member_band}',\n\t\ttotal_user_band='{$total_user_band}',\n\t\tenable='{$_POST["enable"]}'\n\t\tWHERE ID='{$_POST["ID"]}'\n\t\t";
}
$q->QUERY_SQL($sql, 'artica_backup');
if (!$q->ok) {
echo $q->mysql_error . "\n{$sql}\n";
return;
}
}
示例6: ParseEvents
function ParseEvents(){
ParseReboot();
$path="/var/log/artica-postfix/events";
$f=new filesClasses();
$hash=$f->DirListTable($path);
if(!is_array($hash)){return null;}
$users=new usersMenus();
$sock=new sockets();
$ArticaMetaEnabled=$sock->GET_INFO("ArticaMetaEnabled");
echo date('Y-m-d h:i:s')." " .count($hash) . " file(s) notifications...\n";
events(count($hash) . " file(s) notifications...");
if(count($hash)==0){return;}
if($ArticaMetaEnabled==1){
$meta=new artica_meta();
$datasToSend=base64_encode(serialize($meta->GLOBAL_ARRAY));
$ArticaMetaHostname=$meta->ArticaMetaHostname;
events("ArticaMetaEnabled: \"$ArticaMetaEnabled\" -> ($ArticaMetaHostname)");
}
$mysql=new mysql();
while (list ($num, $file) = each ($hash)){
$text=null;
$processname=null;
$date=null;
$context=null;
$subject=null;
$recipient=null;
$bigtext=@file_get_contents($path.'/'.$file);
echo date('Y-m-d h:i:s')." Parsing $file ". strlen($bigtext)." bytes text\n";
$ini=new Bs_IniHandler();
if(preg_match("#<text>(.+?)</text>#is",$bigtext,$re)){
$text=$re[1];
if(strlen($text)>0){
$bigtext=str_replace($re[0],'',$bigtext);
}
}
if(preg_match("#<attachedfiles>(.+?)</attachedfiles>#is",$bigtext,$re)){
$files_text=addslashes($re[1]);
}
$ini->loadString($bigtext);
$processname=$ini->_params["LOG"]["processname"];
$date=$ini->_params["LOG"]["date"];
$context=$ini->_params["LOG"]["context"];
if($context=="YTowOnt9"){$context="system";}
$subject=$ini->_params["LOG"]["subject"];
$recipient=$ini->_params["LOG"]["recipient"];
if(strlen($text)<2){
$text=$ini->_params["LOG"]["text"];
}
$arrayToSend["context"]=$context;
$arrayToSend["subject"]=$subject;
$arrayToSend["text"]=$text;
$arrayToSend["date"]=$date;
echo date('Y-m-d h:i:s')." Parsing subject $subject ". strlen($text)." bytes text\n";
writelogs("New notification: $subject (". strlen($text)." bytes) $date",__FUNCTION__,__FILE__,__LINE__);
$event_id=time();
//$text=addslashes($text);
$text=$mysql->mysql_real_escape_string2($text);
$subject=addslashes($subject);
$sql="INSERT IGNORE INTO events (zDate,hostname,
process,text,context,content,attached_files,recipient,event_id) VALUES(
'$date',
'$mysql->hostname',
'$processname',
'$subject',
'$context','$text','$files_text','$recipient','$event_id')";
if(!$mysql->UseMysql){
$sql="INSERT IGNORE INTO events (id,zDate,hostname,
process,text,context,content,attached_files,recipient,event_id) VALUES(
'$event_id','$date',
'$users->hostname',
'$processname',
'$subject',
'$context','$text','$files_text','$recipient','$event_id')";
}
events(date('Y-m-d h:i:s')." run mysql query -> $subject");
if(!$mysql->QUERY_SQL($sql,'artica_events')){
events("Mysql error keep $path/$file;");
events("Fatal: $mysql->mysql_error",__FUNCTION__,__FILE__,__LINE__);
if(preg_match("#Access denied for user.+?using password:#",$mysql->mysql_error)){
//.........这里部分代码省略.........