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(); }
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> "; }
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"]) { echo "Scanning table {$table}<br>\n"; } $itemsEncTxt = null; $items = $q->COUNT_ROWS($table); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } $sizedb_org = $q->TABLE_SIZE($table); $sizedb = FormatBytes($sizedb_org / 1024); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:18px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $tpl->_ENGINE_parse_body(utf8_decode($ligne[$field_description])); $text_category = trim($text_category); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:18px;font-weight:bold;color:{$color};text-decoration:underline'>"; $viewDB = imgsimple("mysql-browse-database-32.png", null, "javascript:Loadjs('squid.categories.php?category={$categoryname}',true)"); $text_category = utf8_encode($text_category); $categoryname_text = utf8_encode($categoryname); $categoryText = $tpl->_ENGINE_parse_body("<span style='font-size:18px';font-weight:bold'>{$linkcat}{$categoryname_text}</span>\n\t\t\t\t\t</a><br><span style='font-size:16px;width:100%;font-weight:normal'><i>{$text_category}</i></span>"); $itemsEncTxt = "<span style='font-size:18px;font-weight:bold'>" . numberFormat($items, 0, "", " "); "</span>"; $compile = imgsimple("compile-distri-48.png", null, "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("dustbin-48.png", null, "TableCategoryPurge('{$table}')"); if ($categoryname == "UnkNown") { $linkcat = null; $delete = imgsimple("delete-48.png", null, "TableCategoryPurge('')"); } $cell = array(); $cell[] = $categoryText; $cell[] = "<span style='font-size:18px;padding-top:15px;font-weight:bold'>{$sizedb}</div>"; $cell[] = $itemsEncTxt; $cell[] = $compile; $cell[] = $delete; $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }
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"); } }
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); }
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; $data['rows'] = array(); $enc = new mysql_catz(); while ($ligne = mysql_fetch_assoc($results)) { $table = $ligne["c"]; writelogs("Scanning table {$table}", __FUNCTION__, __FILE__, __LINE__); $select = imgtootltip("32-parameters.png", "{apply}", "DansGuardianEditMember('{$ligne["ID"]}','{$ligne["pattern"]}')"); $items = $q->COUNT_ROWS($ligne["c"]); $itemsEnc = $enc->COUNT_ROWS($ligne["c"]); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $categoryname = $re[1]; $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); if (!isset($dans->array_blacksites[$categoryname])) { if (isset($dans->array_blacksites[str_replace("_", "-", $categoryname)])) { $categoryname = str_replace("_", "-", $categoryname); } if (isset($dans->array_blacksites[str_replace("_", "/", $categoryname)])) { $categoryname = str_replace("_", "/", $categoryname); } } if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } $sizedb_org = $q->TABLE_SIZE($table); $sizedb = FormatBytes($sizedb_org / 1024); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$categoryname}&t={$t}',true)\"\n\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $dans->array_blacksites[$categoryname]; if (isset($PERSONALSCATS[$categoryname])) { $text_category = utf8_encode($PERSONALSCATS[$categoryname]); if ($pic == " ") { $pic = "<img src='img/20-categories-personnal.png'>"; } $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } if ($EnableWebProxyStatsAppliance == 0) { if ($sizedb_org < 35) { $pic = "<img src='img/warning-panneau-32.png'>"; } } $viewDB = imgsimple("mysql-browse-database-32.png", "{view}", "javascript:Loadjs('squid.categories.php?category={$categoryname}',true)"); $categoryText = $tpl->_ENGINE_parse_body("<div style='font-size:14px';font-weight:bold'>{$linkcat}{$categoryname}</div>\n\t\t</a><div style='font-size:11px;width:100%;font-weight:normal'>{$text_category}</div>"); $items = numberFormat($items, 0, "", " "); $itemsEnc = numberFormat($itemsEnc, 0, "", " "); $compile = imgsimple("compile-distri-32.png", "{saveToDisk} {$categoryname}", "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('{$table}')"); if ($_GET["minisize"] == "yes") { $delete = null; } $cell = array(); $cell[] = $pic; $cell[] = $categoryText; $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>{$sizedb}</div>"; if (!$artica) { $cell[] = "<div style='font-size:13px;padding-top:5px;font-weight:bold'>{$items}<br>{$itemsEnc}</strong>"; } else { $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>-</strong>"; $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>{$items}</strong>"; } $cell[] = $compile; $cell[] = $delete; $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }
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>"; }
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"); }
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"; if (is_file($ProductNamef)) { $ProductName = trim(@file_get_contents($ProductNamef)); } $CATZ_ARRAY = unserialize(base64_decode(@file_get_contents(CATZ_ARRAY_FILE()))); $FULL_ARRAY = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db")); $TLSE_ARRAY = $FULL_ARRAY["TLSE_ARRAY"]; $ARTICA_ARRAY = $FULL_ARRAY["CAT_ARTICAT_ARRAY"]; //print_r($ARTICA_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)) { $sizedb = array(); $ZZCOUNT = 0; $categorykey = $ligne[$field]; 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; $ITEMS_COLONE = array(); $Time = array(); $text_category = null; $table = $q->cat_totablename($categorykey); if ($GLOBALS["VERBOSE"]) { echo "Scanning table {$table}<br>\n"; } $UnivToulouseItems = null; $ligne_databases = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM UPDATE_DBWF_INFOS WHERE category='{$categoryname}'")); $size_artica = $ligne_databases["size_artica"]; $date_artica = $ligne_databases["date_artica"]; $count_artica = $ligne_databases["count_artica"]; $size_tlse = $ligne_databases["size_tlse"]; $date_tlse = $ligne_databases["date_tlse"]; $count_tlse = $ligne_databases["count_tlse"]; $size_perso = $ligne_databases["size_perso"]; $date_perso = $ligne_databases["date_perso"]; $count_perso = $ligne_databases["count_perso"]; $items = $count_perso; $itemsEnc = $count_artica; $ZZCOUNT = $ZZCOUNT + $items; $ZZCOUNT = $ZZCOUNT + $itemsEnc; if ($date_perso > 0) { $Time[] = date("m-d H:i", $date_perso); } else { $Time[] = "-"; } $sizeArtica = $size_artica; if ($date_artica > 0) { $Time[] = date("m-d H:i", $date_artica); } else { $Time[] = "-"; } $ITEMS_COLONE[] = "Perso.: " . numberFormat($items, 0, "", " "); $ITEMS_COLONE[] = "{$ProductName}: " . numberFormat($itemsEnc, 0, "", " "); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); if (!isset($dans->array_blacksites[$categoryname])) { if (isset($dans->array_blacksites[str_replace("_", "-", $categoryname)])) { $categoryname = str_replace("_", "-", $categoryname); } if (isset($dans->array_blacksites[str_replace("_", "/", $categoryname)])) { $categoryname = str_replace("_", "/", $categoryname); } } if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } $sizedb[] = FormatBytes($size_perso / 1024); $sizedb[] = FormatBytes($size_artica / 1024); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$categoryname}&t={$t}',true)\"\n\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $tpl->_ENGINE_parse_body(utf8_decode($ligne[$field_description])); $text_category = trim($text_category); $pic = "<img src='img/20-categories-personnal.png'>"; if ($ligne["picture"] != null) { $pic = "<img src='img/{$ligne["picture"]}'>"; } if ($OnlyPersonal == 0) { if (!isset($dans->array_blacksites[$categoryname])) { $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } } else { $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } $viewDB = imgsimple("mysql-browse-database-32.png", "{view}", "javascript:Loadjs('squid.categories.php?category={$categoryname}',true)"); $text_category = utf8_encode($text_category); $categoryname_text = utf8_encode($categoryname); $categoryText = $tpl->_ENGINE_parse_body("<span style='font-size:14px';font-weight:bold'>{$linkcat}{$categoryname_text}</span>\n\t\t</a><br><span style='font-size:11px;width:100%;font-weight:normal'>{$text_category}</span>"); if ($OnlyPersonal == 1) { $itemsEncTxt = "<br><span style='font-size:11px'>" . numberFormat($itemsEnc, 0, "", " "); "</span>"; } $compile = imgsimple("compile-distri-32.png", null, "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('{$table}')"); if ($_GET["minisize"] == "yes") { $delete = null; } if ($OnlyPersonal == 0) { $UnivToulouse_websitesnum = $count_tlse; $ZZCOUNT = $ZZCOUNT + $UnivToulouse_websitesnum; $UnivToulouse_size = $size_tlse; $sizedb[] = FormatBytes($UnivToulouse_size / 1024); $ITEMS_COLONE[] = "University: " . numberFormat($UnivToulouse_websitesnum, 0, "", " "); if ($date_tlse > 0) { $Time[] = date("m-d H:i", $date_tlse); } else { $Time[] = "-"; } } if ($categoryname == "UnkNown") { $linkcat = null; $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('')"); } if ($EnableWebProxyStatsAppliance == 0) { if ($ZZCOUNT == 0) { $pic = "<img src='img/warning-panneau-32.png'>"; } } $cell = array(); $cell[] = $pic; $cell[] = $categoryText; $cell[] = "<span style='font-size:11px;padding-top:15px;font-weight:bold'>" . @implode("<br>", $sizedb) . "</span>"; $cell[] = "<span style='font-size:11px;padding-top:5px;font-weight:bold'>" . @implode("<br>", $ITEMS_COLONE) . "</span>"; if (!$AS_SELECT) { $cell[] = "<span style='font-size:11px;padding-top:5px;font-weight:bold'>" . @implode("<br>", $Time) . "</span>"; $cell[] = $compile; $cell[] = $delete; } else { $select = imgsimple("arrow-right-32.png", null, "{$_GET["callback"]}('{$categorykey}')"); $cell[] = $select; } $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }
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"); return; } $c = 0; while ($ligne = mysql_fetch_assoc($results)) { $ligne["template_header"] = stripslashes($ligne["template_header"]); $ligne["template_title"] = stripslashes($ligne["template_title"]); $ligne["template_body"] = stripslashes($ligne["template_body"]); $template_name = $ligne["template_name"]; if ($ligne["template_link"] == 1) { continue; } $header = trim($ligne["template_header"]); if ($header == null) { $header = $headerTemp; } if ($GLOBALS["VERBOSE"]) { echo "Template: `{$template_name}`: {$ligne["template_title"]}\n"; } if (!preg_match("#^ERR_.+#", $ligne["template_name"])) { $ligne["template_name"] = "ERR_" . $ligne["template_name"]; } $filename2 = null; $ligne["template_body"] = utf8_encode($ligne["template_body"]); $ligne["template_title"] = utf8_encode($ligne["template_title"]); $filename = "{$base}/{$ligne["lang"]}/{$ligne["template_name"]}"; if ($ligne["lang"] == "en") { $filename2 = "/usr/share/squid-langpack/templates/{$ligne["template_name"]}"; } $newheader = str_replace("{TITLE}", $ligne["template_title"], $header); $templateDatas = "{$newheader}{$ligne["template_body"]}</body></html>"; if ($GLOBALS["VERBOSE"]) { echo "Template: `{$template_name}`: Path `{$filename}`\n"; } if ($ligne["emptytpl"] == 1) { $templateDatas = "<html><head></head><body></body></html>"; } if ($GLOBALS["VERBOSE"]) { echo "Template: `{$template_name}`: {$ligne["lang"]}\n"; } if (is_numeric($ligne["lang"])) { $ligne["lang"] = "en"; } @mkdir(dirname($filename), 0755, true); @file_put_contents($filename, $templateDatas); if ($filename2 != null) { @file_put_contents($filename2, $templateDatas); $unix->chown_func("squid", "squid", "{$filename2}"); } @file_put_contents("{$base}/{$ligne["lang"]}/{$ligne["template_name"]}", $templateDatas); $unix->chown_func("squid", "squid", "{$base}/{$ligne["lang"]}/{$ligne["template_name"]}"); $unix->chown_func("squid", "squid", "{$filename}"); $c++; if ($ligne["lang"] == "en") { if ($GLOBALS["VERBOSE"]) { echo "Writing {$base}/{$ligne["template_name"]}\n"; } @file_put_contents("{$base}/{$ligne["template_name"]}", $templateDatas); $unix->chown_func("squid:squid", null, "{$base}/templates/{$ligne["template_name"]}"); } else { if (!IfTemplateExistsinEn($template_name)) { @mkdir("{$base}/en", 0755, true); @file_put_contents("{$base}/en/{$ligne["template_name"]}", $templateDatas); $unix->chown_func("squid:squid", null, "{$base}/en/{$ligne["template_name"]}"); } } } $sql = "SELECT * FROM squidtpls WHERE emptytpl=1"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { if (is_numeric($ligne["lang"])) { $ligne["lang"] = "en"; } if (!preg_match("#^ERR_.+#", $ligne["template_name"])) { $ligne["template_name"] = "ERR_" . $ligne["template_name"]; } $filename = "{$base}/{$ligne["lang"]}/{$ligne["template_name"]}"; $templateDatas = "<html><head></head><body></body></html>"; @mkdir(dirname($filename), 0755, true); @file_put_contents($filename, $templateDatas); @file_put_contents("{$base}/{$ligne["lang"]}/{$ligne["template_name"]}", $templateDatas); $unix->chown_func("squid", "squid", "{$base}/{$ligne["lang"]}/{$ligne["template_name"]}"); $unix->chown_func("squid", "squid", "{$filename}"); } $unix = new unix(); $tar = $unix->find_program("tar"); $unix->chown_func("squid", "squid", "{$base}/*"); chdir($base); shell_exec("{$tar} -czf " . dirname(__FILE__) . "/ressources/databases/squid-lang-pack.tgz *"); if ($EnableWebProxyStatsAppliance == 1) { if ($GLOBALS["VERBOSE"]) { echo "-> notify_remote_proxys()\n"; } notify_remote_proxys("SQUID_LANG_PACK"); if ($GLOBALS["VERBOSE"]) { echo "This is a statistics appliance, aborting next step\n"; } return; } squid_admin_mysql(2, "{$c} web pages templates saved", "no information", __FILE__, __LINE__); Reload_Squid(); }
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"; }
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; }
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 = "******"; } 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; } echo "Success, task is finish....\nDone...\nOK, close the screen...\n"; @unlink($filepath); }
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> "; }
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()"); }
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_ERROR_SHOW_128("<hr>{error}<hr>{statistics_database}<hr>{$q->mysql_error}" . wizard_restart()); return; } $q = new mysql_storelogs(); if (!$q->BD_CONNECT()) { echo FATAL_ERROR_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>\n\t\t\t<center style='font-size:18px'>{logs_database}:OK</center>") . "\n\t\t\t<div id='{$tt}'></div>\n\t\t\t<script>\n\t\t\tLoadAjax('{$t}','{$page}?wizard11=yes&t={$t}');\n\t\t\t</script>\n\t"; }