本文整理汇总了PHP中mysql_squid_builder::BD_CONNECT方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql_squid_builder::BD_CONNECT方法的具体用法?PHP mysql_squid_builder::BD_CONNECT怎么用?PHP mysql_squid_builder::BD_CONNECT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql_squid_builder
的用法示例。
在下文中一共展示了mysql_squid_builder::BD_CONNECT方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doexport
function doexport()
{
$q = new mysql_squid_builder();
$q->BD_CONNECT();
$t = $_GET["t"];
$squidlogs["webfilters_sqacls"] = true;
$squidlogs["webfilters_sqaclaccess"] = true;
$squidlogs["webfilters_sqgroups"] = true;
$squidlogs["webfilters_sqacllinks"] = true;
$squidlogs["webfilters_sqitems"] = true;
$squidlogs["webfilters_sqtimes_rules"] = true;
$squidlogs["webfilters_blkwhlts"] = true;
$squidlogs["webfilters_usersasks"] = true;
$squidlogs["webfilters_quotas"] = true;
$squidlogs["webfilter_avwhitedoms"] = true;
$squidlogs["webfilter_aclsdynamic"] = true;
$squidlogs["squidtpls"] = true;
$dir = dirname(__FILE__) . "/ressources/logs/web/acls.gz";
$databases["squidlogs"] = $squidlogs;
if (is_file($dir)) {
@unlink($dir);
}
$dump = new phpMyDumper("squidlogs", $q->mysql_connection, "{$dir}", true, $squidlogs);
$dump->doDump();
}
示例2: do_export
function do_export(){
if($_GET["single-id"]>0){
do_export_single_id();
return;
}
$q=new mysql_squid_builder();
$q->BD_CONNECT();
$t=$_GET["t"];
$squidlogs["webfilters_sqacls"]=true;
$squidlogs["webfilters_sqaclaccess"]=true;
$squidlogs["webfilters_sqgroups"]=true;
$squidlogs["webfilters_sqacllinks"]=true;
$squidlogs["webfilters_sqitems"]=true;
$squidlogs["webfilters_sqtimes_rules"]=true;
$squidlogs["webfilters_blkwhlts"]=true;
$squidlogs["webfilters_usersasks"]=true;
$squidlogs["webfilters_quotas"]=true;
$squidlogs["webfilter_avwhitedoms"]=true;
$squidlogs["webfilter_aclsdynamic"]=true;
$squidlogs["squidtpls"]=true;
$artica_backup["ext_time_quota_acl"]=true;
$artica_backup["ext_time_quota_acl_rules"]=true;
$artica_backup["ext_time_quota_acl_link"]=true;
$dir=dirname(__FILE__)."/ressources/logs/web/acls.gz";
$databases["squidlogs"]=$squidlogs;
$databases["artica_backup"]=$artica_backup;
if(is_file($dir)){@unlink($dir);}
$dump=new phpMyDumper("squidlogs",$q->mysql_connection,"$dir",true,$squidlogs);
$dump->doDump();
if(!is_file($dir)){
$tpl=new templates();
echo $tpl->_ENGINE_parse_body(
"<div style='font-size:18px;color:red;margin-top:15px;margin-bottom:15px'>{failed}</div>");
return;
}
$size=@filesize($dir);
echo "
<div style='margin-top:15px;margin-bottom:15px;text-align:center'>
<a href=\"ressources/logs/web/acls.gz\"
style='text-decoration:underline;font-size:18px;font-weight:bold'>acls.gz ". FormatBytes($size/1024)."</a>
</div>
<script>
if(document.getElementById('text-$t')){
document.getElementById('text-$t').innerHTML='';
}
</script>
";
}
示例3: categories_search
function categories_search()
{
$MyPage = CurrentPageName();
$page = CurrentPageName();
$tpl = new templates();
$sock = new sockets();
$q = new mysql_squid_builder();
$dans = new dansguardian_rules();
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
$t = $_GET["t"];
$OnlyPersonal = 0;
$artica = $forceArtica;
if (isset($_GET["OnlyPersonal"])) {
$OnlyPersonal = 1;
}
$rp = 200;
if (isset($_GET["artica"])) {
$artica = true;
}
if ($_POST["sortname"] == "table_name") {
$_POST["sortname"] = "categorykey";
}
if (!$q->BD_CONNECT()) {
json_error_show("Testing connection to MySQL server failed...", 1);
}
$sql = "SELECT * FROM personal_categories";
$table = "personal_categories";
if ($_POST["sortname"] == "categorykey") {
$_POST["sortname"] = "category";
}
$prefix = "INSERT IGNORE INTO webfilters_categories_caches (`categorykey`,`description`,`picture`,`master_category`,`categoryname`) VALUES ";
$searchstring = string_to_flexquery();
$page = 1;
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if ($searchstring != null) {
$sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}";
writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}.<br>{$sql}", 1);
}
$total = $ligne["tcount"];
} else {
$total = $q->COUNT_ROWS($table);
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$limitSql = "LIMIT {$pageStart}, {$rp}";
$sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql} ";
writelogs("{$q->mysql_admin}:{$q->mysql_password}:{$sql}", __FUNCTION__, __FILE__, __LINE__);
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
if ($q->mysql_error != null) {
json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1);
}
}
if (mysql_num_rows($results) == 0) {
json_error_show("Not found...", 1);
}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$enc = new mysql_catz();
$field = "category";
$field_description = "category_description";
$CATZ_ARRAY = unserialize(@file_get_contents("/home/artica/categories_databases/CATZ_ARRAY"));
$TransArray = $enc->TransArray();
while (list($tablename, $items) = each($CATZ_ARRAY)) {
if (!isset($TransArray[$tablename])) {
continue;
}
$CATZ_ARRAY2[$TransArray[$tablename]] = $items;
}
while ($ligne = mysql_fetch_assoc($results)) {
$color = "black";
$categorykey = $ligne["category"];
if ($categorykey == null) {
$categorykey = "UnkNown";
}
//Array ( [category] => [category_description] => Ma catégorie [master_category] => [sended] => 1 )
if ($GLOBALS["VERBOSE"]) {
echo "Found {$field}:{$categorykey}<br>\n";
}
$categoryname = $categorykey;
$text_category = null;
$table = $q->cat_totablename($categorykey);
if ($GLOBALS["VERBOSE"]) {
//.........这里部分代码省略.........
示例4: status_remote_mysql_server
function status_remote_mysql_server(){
$tpl=new templates();
$q=new mysql_squid_builder();
if(!$q->BD_CONNECT()){
return Paragraphe32("mysql_error", "noacco:mysql://$q->mysql_server:$q->mysql_port<br>$q->mysql_error","","database-error-32.png");
}else{
$results=$q->EXECUTE_SQL("SHOW STATUS");
if(!$q->ok){echo $q->mysql_error_html();}
while ($ligne = mysql_fetch_assoc($results)) { $ARRAY[$ligne["Variable_name"]]=$ligne["Value"]; }
$time=time()-$ARRAY["Uptime"];
$Uptime=distanceOfTimeInWords($time,time());
$Threads_connected=$ARRAY["Threads_connected"];
$Connections=$ARRAY["Connections"];
$Connections=FormatNumber($Connections);
$MySqlServer="$q->mysql_server:$q->mysql_port";
if($q->mysql_server){$MySqlServer=$tpl->_ENGINE_parse_body("{local_database}");}
return Paragraphe32("noacco:$MySqlServer", "{running} {since} $Uptime<br>Threads: $Threads_connected<br>{connections}:$Connections
","","database-link-32.png");
}
}
示例5: db_status_info_text
function db_status_info_text(){
$q=new mysql_squid_builder();
$page=CurrentPageName();
$tpl=new templates();
if($q->BD_CONNECT()){return;}
$t=time();
$img="status_postfix_bg_failed.png";
$title="{MYSQL_ERROR}";
$text_error_sql="<div style='width:93%' class=form>
<table style='width:100%'>
<tr>
<td width=1% nowrap style='vertical-align:top'><img src='img/database-error-48.png'></td>
<td style='color:#D70707;font-size:14px;font-weight:bold'>{APP_SQUID_DB}:<br>
<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.mysql.php');\"
style='font-size:14px;color:#D70707;text-decoration:underline'>$title</a><hr>
$q->mysql_error
</td>
</tr>
</table>
<div style='text-align:right'>". imgtootltip("refresh-24.png","{refresh}","LoadAjax('db-status-infos','$page?db-status-infos=yes&force=true',true);")."</div>
</div>";
echo $tpl->_ENGINE_parse_body($text_error_sql);
}
示例6: categories_search
function categories_search($forceArtica = false)
{
$MyPage = CurrentPageName();
$page = CurrentPageName();
$tpl = new templates();
$sock = new sockets();
$q = new mysql_squid_builder();
$dans = new dansguardian_rules();
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
$t = $_GET["t"];
$artica = $forceArtica;
if (isset($_GET["artica"])) {
$artica = true;
}
$tableSchema = "squidlogs";
if (!$q->BD_CONNECT()) {
json_error_show("Testing connection to MySQL server failed...", 1);
}
if (!$q->TABLE_EXISTS("webfilters_categories_caches")) {
$q->CheckTables();
}
$dans = new dansguardian_rules();
$dans->LoadBlackListes();
$sql = "SELECT * FROM personal_categories";
if (!$q->TABLE_EXISTS("personal_categories")) {
json_error_show("personal_categories no such table!", 1);
}
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1);
}
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$PERSONALSCATS[$ligne["category"]] = $ligne["category_description"];
}
$search = '%';
$page = 1;
$ORDER = "ORDER BY table_name";
$searchstring = "table_name LIKE 'category_%'";
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if ($artica) {
$q = new mysql_catz();
writelogs("Artica mode -> {$q->database} " . $q->COUNT_CATEGORIES(), __FUNCTION__, __FILE__, __LINE__);
$tableSchema = "catz";
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if ($_POST["query"] != null) {
$_POST["query"] = "*{$_POST["query"]}*";
$_POST["query"] = str_replace("**", "*", $_POST["query"]);
$_POST["query"] = str_replace("**", "*", $_POST["query"]);
$_POST["query"] = str_replace("*", "%", $_POST["query"]);
$search = $_POST["query"];
$searchstring = "table_name LIKE 'category_{$search}'";
$sql = "SELECT COUNT( table_name ) AS tcount FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND table_name LIKE 'category_{$search}'";
writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1);
}
$total = $ligne["tcount"];
} else {
$sql = "SELECT COUNT(table_name) as TCOUNT FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND table_name LIKE 'category_%'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1);
}
$total = $ligne["TCOUNT"];
writelogs("{$sql} = {$total}", __FUNCTION__, __FILE__, __LINE__);
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$limitSql = "LIMIT {$pageStart}, {$rp}";
$sql = "SELECT table_name as c,TABLE_ROWS FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND {$searchstring} {$ORDER} {$limitSql}";
writelogs("{$q->mysql_admin}:{$q->mysql_password}:{$sql}", __FUNCTION__, __FILE__, __LINE__);
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1);
}
if (mysql_num_rows($results) == 0) {
if (!$artica) {
categories_search(true);
return;
}
}
if (mysql_num_rows($results) == 0) {
json_error_show("({$tableSchema}) No categories table found...", 1);
}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
//.........这里部分代码省略.........
示例7: squid_mysql_status
function squid_mysql_status(){
$q=new mysql_squid_builder();
$page=CurrentPageName();
$img="ok64.png";
$title="{MYSQL_CONNECTION}";
$text=date('H:i:s')."<br>".$q->mysql_server.":".$q->mysql_port;
$button=button("{migrate_local_datas}", "Loadjs('$page?migrate-localdata-js=yes')",16);
$button="<hr><center style='margin:5px'>$button</center>";
if(!$q->BD_CONNECT()){
$img="danger64.png";
$title="{MYSQL_ERROR}";
$text=$text."<br>".$q->mysql_error;
$button=null;
}
$tpl=new templates();
echo "<center>".$tpl->_ENGINE_parse_body(Paragraphe($img, $title, $text,null,$text)."<div style='text-align:right'>". imgtootltip("refresh-24.png","{refresh}","RefreshMysqlConnection()").$button)."</center>";
}
示例8: export_squid_table
function export_squid_table()
{
$workdir = dirname(__FILE__) . "/ressources/squid-export";
$table = $_GET["squid-table"];
$q = new mysql_squid_builder();
$q->BD_CONNECT();
if (is_file("{$workdir}/{$table}.gz")) {
@unlink("{$workdir}/{$table}.gz");
}
$dump = new phpMyDumper("squidlogs", $q->mysql_connection, "{$workdir}/{$table}.gz", true, $table);
$dump->doDump();
$sock = new sockets();
$content_type = base64_decode($sock->getFrameWork("cmd.php?mime-type=" . base64_encode("{$workdir}/{$table}.gz")));
$fsize = filesize("{$workdir}/{$table}.gz");
if ($GLOBALS["VERBOSE"]) {
echo "Content-type: {$content_type}<br>\nfilesize:{$fsize}<br>\n";
return;
}
header('Content-type: ' . $content_type);
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=\"{$table}.gz\"");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date dans le passé
header("Content-Length: " . $fsize);
ob_clean();
flush();
readfile("{$workdir}/{$table}.gz");
}
示例9: categories_search
function categories_search($forceArtica = false)
{
$MyPage = CurrentPageName();
$page = CurrentPageName();
$tpl = new templates();
$sock = new sockets();
$q = new mysql_squid_builder();
$dans = new dansguardian_rules();
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
$t = $_GET["t"];
$OnlyPersonal = 0;
$artica = $forceArtica;
if (isset($_GET["OnlyPersonal"])) {
$OnlyPersonal = 1;
}
$rp = 200;
if (isset($_GET["artica"])) {
$artica = true;
}
if ($_POST["sortname"] == "table_name") {
$_POST["sortname"] = "categorykey";
}
if (!$q->BD_CONNECT()) {
json_error_show("Testing connection to MySQL server failed...", 1);
}
$table = "webfilters_categories_caches";
$sql = "SELECT * FROM personal_categories";
if ($OnlyPersonal == 0) {
if (!$q->TABLE_EXISTS($table)) {
$q->create_webfilters_categories_caches();
}
$dans = new dansguardian_rules();
if ($q->COUNT_ROWS($table) == 0) {
$dans->CategoriesTableCache();
}
$dans->LoadBlackListes();
} else {
$table = "personal_categories";
if ($_POST["sortname"] == "categorykey") {
$_POST["sortname"] = "category";
}
}
$prefix = "INSERT IGNORE INTO webfilters_categories_caches (`categorykey`,`description`,`picture`,`master_category`,`categoryname`) VALUES ";
$searchstring = string_to_flexquery();
$page = 1;
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if ($searchstring != null) {
$sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}";
writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}.<br>{$sql}", 1);
}
$total = $ligne["tcount"];
} else {
$total = $q->COUNT_ROWS($table);
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
$limitSql = "LIMIT {$pageStart}, {$rp}";
$sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql} ";
writelogs("{$q->mysql_admin}:{$q->mysql_password}:{$sql}", __FUNCTION__, __FILE__, __LINE__);
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
if ($q->mysql_error != null) {
json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1);
}
}
if (mysql_num_rows($results) == 0) {
json_error_show("Not found...", 1);
}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$AS_SELECT = false;
if ($_GET["select"] == "yes") {
$AS_SELECT = true;
}
$enc = new mysql_catz();
$field = "categorykey";
$field_description = "description";
if ($OnlyPersonal == 1) {
$field = "category";
$field_description = "category_description";
}
$ProductName = "Artica";
$ProductNamef = dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf";
//.........这里部分代码省略.........
示例10: TemplatesInMysql
function TemplatesInMysql($aspid = false)
{
$unix = new unix();
$pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if (!$aspid) {
$pid = $unix->get_pid_from_file($pidpath);
if ($unix->process_exists($pid)) {
return;
}
}
@file_put_contents($pidpath, getmypid());
EventsWatchdog("writing /etc/artica-postfix/SQUID_TEMPLATE_DONE");
@file_put_contents("/etc/artica-postfix/SQUID_TEMPLATE_DONE", time());
@file_put_contents("/etc/artica-postfix/SQUID_TEMPLATE_DONEv2", time());
$sock = new sockets();
$SquidTemplateSimple = $sock->GET_INFO("SquidTemplateSimple");
if (!is_numeric($SquidTemplateSimple)) {
$SquidTemplateSimple = 1;
}
if ($SquidTemplateSimple == 1) {
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$by = "--FUNC-" . __FUNCTION__ . "-L-" . __LINE__;
shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.squid.templates.php {$by} >/dev/null 2>&1 &");
return;
}
$TimeExec = $unix->file_time_min($pidtime);
if (!$GLOBALS["FORCE"]) {
if ($TimeExec < 240) {
return;
}
}
$users = new usersMenus();
$sock = new sockets();
$EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
if (!is_numeric($EnableRemoteStatisticsAppliance)) {
$EnableRemoteStatisticsAppliance = 0;
}
$UnlockWebStats = $sock->GET_INFO("UnlockWebStats");
if (!is_numeric($UnlockWebStats)) {
$UnlockWebStats = 0;
}
if ($UnlockWebStats == 1) {
$EnableRemoteStatisticsAppliance = 0;
}
if ($EnableRemoteStatisticsAppliance == 1) {
if (!$users->CORP_LICENSE) {
if (!is_file("/etc/artica-postfix/SQUID_TEMPLATE_DONE")) {
DefaultTemplatesInArtica();
return;
}
}
EventsWatchdog("Using the Web statistics appliance to get template files");
if ($GLOBALS["VERBOSE"]) {
echo "Use the Web statistics appliance to get template files...\n";
}
TemplatesInMysql_remote();
return;
}
@mkdir("/etc/artica-postfix", 0755, true);
$base = "/usr/share/squid-langpack";
@mkdir($base, 0755, true);
if (!is_dir("{$base}/templates")) {
@mkdir("{$base}/templates", 0755, true);
}
$headerTemp = @file_get_contents(dirname(__FILE__) . "/ressources/databases/squid.default.header.db");
$q = new mysql_squid_builder();
if (!$q->BD_CONNECT(true)) {
squid_admin_mysql(2, "Error, unable to connect to MySQL", __FILE__, __LINE__);
if (!$users->CORP_LICENSE) {
DefaultTemplatesInArtica();
}
return;
}
$sql = "CREATE TABLE IF NOT EXISTS `squidtpls` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `template_name` varchar(128) NOT NULL,\n\t\t\t `template_body` LONGTEXT NOT NULL,\n\t\t\t `template_header` LONGTEXT NOT NULL,\n\t\t\t `template_title` varchar(255) NOT NULL,\n\t\t\t `template_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t `template_link` smallint(1) NOT NULL,\n\t\t\t `template_uri` varchar(255) NOT NULL,\n\t\t\t `lang` varchar(5) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `template_name` (`template_name`,`lang`),\n\t\t\t KEY `template_title` (`template_title`),\n\t\t\t KEY `template_time` (`template_time`),\n\t\t\t KEY `template_link` (`template_link`),\n\t\t\t FULLTEXT KEY `template_body` (`template_body`)\n\t\t\t) ENGINE = MYISAM;";
$q->QUERY_SQL($sql);
if ($q->COUNT_ROWS("squidtpls") == 0) {
if (!is_file("/etc/artica-postfix/SQUID_TEMPLATE_DONE")) {
squid_admin_mysql(2, "Ask to build default templates squidtpls=0", null, __FILE__, __LINE__);
DefaultTemplatesInArtica();
}
}
if (!$users->CORP_LICENSE) {
if (!is_file("/etc/artica-postfix/SQUID_TEMPLATE_DONE")) {
squid_admin_mysql(2, "Ask to build default templates - no license -", null, __FILE__, __LINE__);
DefaultTemplatesInArtica();
return;
}
}
$sql = "SELECT * FROM squidtpls";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
squid_admin_mysql(1, "MySQL Error on templates", $q->mysql_error, __FILE__, __LINE__);
ufdbguard_admin_events("Fatal,{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "proxy");
//.........这里部分代码省略.........
示例11: do_export
function do_export()
{
if ($_GET["single-id"] > 0) {
do_export_single_id();
return;
}
$q = new mysql_squid_builder();
$q->BD_CONNECT();
$t = $_GET["t"];
$LIST_TABLES_CATEGORIES = $q->LIST_TABLES_CATEGORIES();
while (list($num, $ligne) = each($LIST_TABLES_CATEGORIES)) {
$squidlogs[$num] = true;
}
$squidlogs["webfilter_rules"] = true;
$squidlogs["webfilter_assoc_groups"] = true;
$squidlogs["webfilter_blks"] = true;
$squidlogs["webfilter_group"] = true;
$squidlogs["webfilter_bannedexts"] = true;
$squidlogs["webfilters_dtimes_blks"] = true;
$squidlogs["webfilter_bannedextsdoms"] = true;
$squidlogs["webfilter_termsg"] = true;
$squidlogs["webfilter_blklnk"] = true;
$squidlogs["webfilter_blkgp"] = true;
$squidlogs["webfilter_blkcnt"] = true;
$artica_backup["personal_categories"] = true;
$dir = dirname(__FILE__) . "/ressources/logs/web/webfiltering.sql";
$final = dirname(__FILE__) . "/ressources/logs/web/webfiltering.export";
$compressed = dirname(__FILE__) . "/ressources/logs/web/webfiltering.gz";
@unlink($dir);
@unlink($final);
@unlink($compressed);
$databases["squidlogs"] = $squidlogs;
$databases["artica_backup"] = $artica_backup;
if (is_file($dir)) {
@unlink($dir);
}
$dump = new phpMyDumper("squidlogs", $q->mysql_connection, "{$dir}", false, $squidlogs);
$dump->doDump();
if (!is_file($dir)) {
$tpl = new templates();
echo $tpl->_ENGINE_parse_body("<div style='font-size:18px;color:#d32d2d;margin-top:15px;margin-bottom:15px'>{failed}</div>");
return;
}
$sock = new sockets();
$DansGuardianDefaultMainRule = $sock->GET_INFO("DansGuardianDefaultMainRule");
$array["SQL"] = @file_get_contents($dir);
$array["DansGuardianDefaultMainRule"] = $DansGuardianDefaultMainRule;
@file_put_contents($final, base64_encode(serialize($array)));
compress($final, $compressed);
$size = @filesize($compressed);
@unlink($dir);
@unlink($final);
echo "\n\t\t<div style='margin-top:15px;margin-bottom:15px;text-align:center'>\t\n\t\t\t<a href=\"ressources/logs/web/webfiltering.gz\" \n\t\t\tstyle='text-decoration:underline;font-size:18px;font-weight:bold'>webfiltering.gz " . FormatBytes($size / 1024) . "</a>\n\t\t</div>\n\t\t\t<script>\n\t\t\tif(document.getElementById('text-{$t}')){\n\t\t\t\tdocument.getElementById('text-{$t}').innerHTML='';\n\t\t\t\n\t\t\t}\n\t\t\t\t\n\t\t\t</script>\n\t\t\t\n\t";
}
示例12: backupTable
function backupTable($tablename, $filename)
{
if (isset($GLOBALS["ALREADYDONETABLE"][$tablename])) {
return true;
}
$GLOBALS["ALREADYDONETABLE"][$tablename] = true;
$unix = new unix();
$q = new mysql_squid_builder();
if (!$q->TABLE_EXISTS($tablename)) {
return true;
}
$q->BD_CONNECT();
$dump = new phpMyDumper("squidlogs", $q->mysql_connection, $filename, true, $tablename);
if (!$dump->doDump()) {
ufdbguard_admin_events("Fatal, unable to dump database {$ligne["tablename"]}", __FUNCTION__, __FILE__, __LINE__, "backup");
return false;
}
$filesize = $unix->file_size($filename);
if ($filesize < 200) {
ufdbguard_admin_events("Fatal, {$filesize} bytes it seems there is an issue on {$tablename} table", __FUNCTION__, __FILE__, __LINE__, "backup");
return false;
}
$q->QUERY_SQL("INSERT INTO webstats_backup (`tablename`,`filepath`,`filesize`) \n\tVALUES('{$tablename}','{$filename}','{$filesize}')");
if (!$q->ok) {
ufdbguard_admin_events("Fatal, MySQL error {$q->mysql_error} on webstats_backup", __FUNCTION__, __FILE__, __LINE__, "backup");
return false;
}
$q->DELETE_TABLE($tablename);
return true;
}
示例13: migrate_local
function migrate_local()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
echo "Already executed pid {$pid}\n";
return;
}
@file_put_contents($pidfile, getmypid());
$sock = new sockets();
$mysqldump = $unix->find_program("mysqldump");
$mysqlbin = $unix->find_program("mysql");
$pass = null;
if (!is_file($mysqldump)) {
echo "mysqldump, no such binary\n";
return;
}
if (!is_file($mysqlbin)) {
echo "mysql, no such binary\n";
return;
}
$EnableSquidRemoteMySQL = $sock->GET_INFO("EnableSquidRemoteMySQL");
if (!is_numeric($EnableSquidRemoteMySQL)) {
$EnableSquidRemoteMySQL = 0;
}
if ($EnableSquidRemoteMySQL == 0) {
echo "Error, loopback to myslef...\n";
return;
}
$q = new mysql_squid_builder();
if (!$q->BD_CONNECT(true)) {
echo "Error, Database connection failed...{$q->mysql_error}\n";
return;
}
$q = new mysql_squid_builder(true);
if ($q->mysql_server == "localhost") {
$q->mysql_server = "127.0.0.1";
}
if (strlen($q->mysql_password) > 1) {
$q->mysql_password = $unix->shellEscapeChars($q->mysql_password);
$pass = " -p{$q->mysql_password}";
}
if ($q->mysql_server == "127.0.0.1") {
$serv = "--protocol=socket --socket={$q->SocketName}";
} else {
$serv = "--protocol=tcp --host={$q->mysql_server} --port={$q->mysql_port}";
}
$ArticaProxyStatisticsBackupFolder = $sock->GET_INFO("ArticaProxyStatisticsBackupFolder");
if ($ArticaProxyStatisticsBackupFolder == null) {
$ArticaProxyStatisticsBackupFolder = "/home/artica/squid/backup-statistics";
}
@mkdir($ArticaProxyStatisticsBackupFolder, 0755, true);
$filename = "squidlogs-full." . time() . ".sql";
$filepath = "{$ArticaProxyStatisticsBackupFolder}/{$filename}";
$cmdline[] = $mysqldump;
$cmdline[] = "{$serv} -u {$q->mysql_admin}{$pass}";
$cmdline[] = "--log-error={$filepath}.log";
$cmdline[] = "--skip-add-locks --insert-ignore --quote-names --skip-add-drop-table --verbose {$q->database}";
$cmdline[] = " > {$filepath}";
$cmd = @implode(" ", $cmdline);
echo "{$cmd}\n";
exec($cmd, $results);
if ($unix->MYSQL_BIN_PARSE_ERROR(@file_get_contents("{$filepath}.log"))) {
echo "Error, {$unix->mysql_error}\n";
@unlink($filepath);
@unlink("{$filepath}.log");
return;
}
@unlink("{$filepath}.log");
$filesize = @filesize($filepath);
if ($filesize < 500) {
echo "Error, {$filepath} filesize:{$filesize} too low\n";
@unlink($filepath);
return;
}
echo "Import {$filepath}\n";
$cmdline = array();
$pass = null;
$results = array();
$q = new mysql_squid_builder();
$cmdline[] = $mysqlbin;
$cmdline[] = "--force";
//$cmdline[]="--verbose";
$cmdline[] = "--debug-info";
$cmdline[] = $q->MYSQL_CMDLINES;
$cmdline[] = "--database={$q->database} < {$filepath} 2>&1";
$cmd = @implode(" ", $cmdline);
echo "{$cmd}\n";
exec($cmd, $results);
if ($unix->MYSQL_BIN_PARSE_ERROR(@implode("\n", $results))) {
echo "Error, {$unix->mysql_error}\n";
@unlink($filepath);
@unlink("{$filepath}.log");
return;
}
//.........这里部分代码省略.........
示例14: wizard10
function wizard10(){
$q=new mysql_squid_builder();
$page=CurrentPageName();
$tpl=new templates();
$sock=new sockets();
$t=$_GET["t"];
$tt=time()+rand(0,time());
if(!$q->BD_CONNECT()){
echo FATAL_WARNING_SHOW_128("<hr>{error}<hr>{statistics_database}<hr>$q->mysql_error".wizard_restart());return;
}
$q=new mysql_storelogs();
if(!$q->BD_CONNECT()){
echo FATAL_WARNING_SHOW_128("<hr>{error}<hr>{logs_database}<hr>$q->mysql_error".wizard_restart());return;
}
echo $tpl->_ENGINE_parse_body("<center style='font-size:18px'>{statistics_database}:OK</center>
<center style='font-size:18px'>{logs_database}:OK</center>")."
<div id='$tt'></div>
<script>
LoadAjax('$t','$page?wizard11=yes&t=$t');
</script>
";
}
示例15: squid_mysql_status
function squid_mysql_status()
{
$q = new mysql_squid_builder();
$img = "ok64.png";
$title = "{MYSQL_CONNECTION}";
$text = date('H:i:s') . "<br>" . $q->mysql_server . ":" . $q->mysql_port . "<br>{$q->SocketPath}";
if (!$q->BD_CONNECT()) {
$img = "danger64.png";
$title = "{MYSQL_ERROR}";
$text = $text . "<br>" . $q->mysql_error . "<br>{$q->SocketPath}";
}
$tpl = new templates();
echo Paragraphe($img, $title, $text, null, $text) . "<div style='text-align:right'>" . imgtootltip("refresh-24.png", "{refresh}", "RefreshMysqlConnection()");
}