function page() { $page = CurrentPageName(); $tpl = new templates(); $squid_reverse = new squid_reverse(); $sslcertificates = $squid_reverse->ssl_certificates_list(); $you_need_to_compile = $tpl->javascript_parse_text("{you_need_to_compile}"); $servername = $_GET["servername"]; $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM reverse_www WHERE servername='{$servername}'")); if (!is_numeric($ligne["ssl_backend_port"])) { $ligne["ssl_backend_port"] = 443; } $t = time(); $ssl_use_rcert = 0; $to = null; $AS_PEER_CERTIFICATE = 0; $AS_PEER_CERTIFICATE_EXPLAIN = null; $cache_peer_id = $ligne["cache_peer_id"]; if ($cache_peer_id > 0) { if (!$q->FIELD_EXISTS("reverse_sources", "ssl_remotecert")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `ssl_remotecert` smallint(1) NOT NULL DEFAULT '0'"); if (!$q->ok) { echo $q->mysql_error_html(); } } $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT servername,ssl_remotecert FROM reverse_sources WHERE ID='{$cache_peer_id}'")); if (!$q->ok) { echo $q->mysql_error_html(); } $to = " {to} «{$ligne2["servername"]}»"; } if (intval($cache_peer_id) > 0) { $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT certificate FROM reverse_sources WHERE ID='{$cache_peer_id}'")); if (trim($ligne2["certificate"] != null)) { $ligne["certificate"] = $ligne2["certificate"]; $AS_PEER_CERTIFICATE = 1; } } if ($AS_PEER_CERTIFICATE == 1) { $AS_PEER_CERTIFICATE_EXPLAIN = "<div class=text-info>{reverse_proxy_use_destination_server_certificate}</div>"; } $html[] = "<div style='width:98%' class=form>{$AS_PEER_CERTIFICATE_EXPLAIN}"; $html[] = "<table style='width:100%'>"; $html[] = "<tr><td colspan=2 style='font-size:28px;padding-bottom:20px'>{port}:{$ligne["port"]} «{$servername}»{$to}</td></tr>"; $html[] = "<tr><td colspan=2>" . Paragraphe_switch_img("{reverse_proxy_ssl}", "{NGINX_USE_SSL_EXPLAIN}", "ssl-{$t}", $ligne["ssl"], null, 700, "SwitchOffCertificate{$t}") . "</td></tr>"; $html[] = Field_list_table("certificate-{$t}", "{certificate}", $ligne["certificate"], 22, $sslcertificates, null, 450); if ($cache_peer_id > 0) { $html[] = "<tr><td colspan=2>" . Paragraphe_switch_img("{destination_use_ssl}", "{NGINX_USE_SSL_EXPLAIN2}", "ssl_backend-{$t}", $ligne["ssl_backend"], null, 700) . "</td></tr>"; $html[] = "<tr><td colspan=2>" . Paragraphe_switch_img("{SSL_CLIENT_VERIFICATION}", "{SSL_CLIENT_VERIFICATION_EXPLAIN}", "ssl_client_certificate-{$t}", $ligne["ssl_client_certificate"], null, 700) . "</td></tr>"; } $html[] = Field_button_table_autonome("{apply}", "Submit{$t}", 30); $html[] = "</table>"; $html[] = "</div>\n<script>\nvar xSubmit{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;}\n\t\$('#NGINX_MAIN_TABLE').flexReload();\n\talert('{$you_need_to_compile}');\n}\n\t\n\t\nfunction Submit{$t}(){\n\tvar XHR = new XHRConnection();\n\tvar AS_PEER_CERTIFICATE={$AS_PEER_CERTIFICATE};\n\tXHR.appendData('servername','{$servername}');\n\tXHR.appendData('cache_peer_id','{$cache_peer_id}');\n\tXHR.appendData('ssl',document.getElementById('ssl-{$t}').value);\n\tif(document.getElementById('ssl_backend-{$t}')){\n\t\tXHR.appendData('ssl_backend',document.getElementById('ssl_backend-{$t}').value);\n\t}\n\tif(document.getElementById('ssl_client_certificate-{$t}')){\n\t\tXHR.appendData('ssl_client_certificate',document.getElementById('ssl_client_certificate-{$t}').value);\n\t}\t\n\t\n\t\n\t\n\tXHR.appendData('certificate',document.getElementById('certificate-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSubmit{$t});\n}\n\nfunction SwitchOffCertificate{$t}(){\n\tvar ssl=document.getElementById('ssl-{$t}').value;\n\t\n}\n\nfunction Check{$t}(){\n\tvar AS_PEER_CERTIFICATE={$AS_PEER_CERTIFICATE};\n\tif( AS_PEER_CERTIFICATE==1){\n\t\tdocument.getElementById('certificate-{$t}').disabled=true;\n\t}\n\tSwitchOffCertificate{$t}();\n}\nCheck{$t}();\n</script>\n\t\n\t"; echo $tpl->_ENGINE_parse_body(@implode("\n", $html)); }
function popup() { $q = new mysql_squid_builder(); $ID = $_GET["ID"]; $page = CurrentPageName(); $tpl = new templates(); $t = time(); if (!$q->FIELD_EXISTS("proxy_ports", "SquidAsMasterCacheChilds")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `SquidAsMasterCacheChilds` smallint(1) NOT NULL DEFAULT '1'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "SquidAsMasterLogExtern")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `SquidAsMasterLogExtern` smallint(1) NOT NULL DEFAULT '0'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "SquidAsMasterFollowxForward")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `SquidAsMasterFollowxForward` smallint(1) NOT NULL DEFAULT '0'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "SquidAsMasterLogChilds")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `SquidAsMasterLogChilds` smallint(1) NOT NULL DEFAULT '0'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$ID}")); $p2 = Paragraphe_switch_img("{logging_childs_connections}", "{logging_childs_connections_explain}", "SquidAsMasterLogChilds-{$t}", $ligne["SquidAsMasterLogChilds"], null, 850); $p21 = Paragraphe_switch_img("{logging_childs_connections2}", "{logging_childs_connections_explain2}", "SquidAsMasterLogExtern-{$t}", $ligne["SquidAsMasterLogChilds"], null, 850); $p3 = Paragraphe_switch_img("{cache_childs_requests}", "{cache_childs_requests_explain}", "SquidAsMasterCacheChilds-{$t}", $ligne["SquidAsMasterCacheChilds"], null, 850); $p4 = Paragraphe_switch_img("{follow_x_forwarded_for}", "{follow_x_forwarded_for_explain}", "SquidAsMasterFollowxForward-{$t}", $ligne["SquidAsMasterFollowxForward"], null, 850); if (intval($ligne["SquidAsMasterFollowxForward"]) == 1) { $error = "<p class=explain style='font-size:16px'>{SquidAsMasterFollowxForward_error}</p>"; } $html = "\n<div style='width:98%' class=form>\n<table style='width:100%'>\n<tr> <td colspan=2>{$p2}</td> </tr>\n<tr> <td colspan=2>{$p21}</td> </tr>\n<tr> <td colspan=2>{$p3}</td> </tr>\n<tr> <td colspan=2>{$p4}</td> </tr>\n<tr>\n\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 32) . "</td>\n</tr>\n</table>\n</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){ alert(results); return; }\n\tRefreshTab('main_proxy_listen_ports');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('ID','{$ID}');\n\tXHR.appendData('SquidAsMasterLogChilds',document.getElementById('SquidAsMasterLogChilds-{$t}').value);\n\tXHR.appendData('SquidAsMasterCacheChilds',document.getElementById('SquidAsMasterCacheChilds-{$t}').value);\n\tXHR.appendData('SquidAsMasterLogExtern',document.getElementById('SquidAsMasterLogExtern-{$t}').value);\n\tXHR.appendData('SquidAsMasterFollowxForward',document.getElementById('SquidAsMasterFollowxForward-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function manual_update() { $t = time(); $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("itcharters", "PdfContent")) { $q->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfContent` LONGBLOB NULL"); if (!$q->ok) { echo $q->mysql_error_html() . "\n"; return; } } if (!$q->FIELD_EXISTS("itcharters", "enablepdf")) { $q->QUERY_SQL("ALTER TABLE `itcharters` ADD `enablepdf` smallint(1) NOT NULL DEFAULT '0',ADD INDEX ( `enablepdf` )"); if (!$q->ok) { echo $q->mysql_error_html() . "\n"; return; } } if (!$q->FIELD_EXISTS("itcharters", "PdfFileName")) { $q->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfFileName` VARCHAR(128) NULL"); if (!$q->ok) { echo $q->mysql_error_html() . "\n"; return; } } if (!$q->FIELD_EXISTS("itcharters", "PdfFileSize")) { $q->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfFileSize` INT UNSIGNED NULL"); if (!$q->ok) { echo $q->mysql_error_html() . "\n"; return; } } $UploadAFile = $tpl->javascript_parse_text("{upload_a_file}"); $allowedExtensions = "allowedExtensions: ['pdf'],"; $UploadAFile = str_replace(" ", " ", $UploadAFile); $html = "\n\t<div style='font-size:30px'>{upload_a_pdf_file}</div>\n\t\n\t\n\t\n\t<center style='margin:10px;width:99%'>\n\t\t<center id='file-uploader-demo-{$t}' style='width:100%;text-align:center'></center>\n\t</center>\n\t<script>\nfunction createUploader{$t}(){\n\tvar uploader{$t} = new qq.FileUploader({\n\t\telement: document.getElementById('file-uploader-demo-{$t}'),\n\t\taction: '{$page}',{$allowedExtensions}\n\t\ttemplate: '<div class=\"qq-uploader\">' +\n\t\t'<div class=\"qq-upload-drop-area\"><span>Drop files here to upload</span></div>' +\n\t\t'<div class=\"qq-upload-button\" style=\"width:100%\"> « {$UploadAFile} » </div>' +\n\t\t'<ul class=\"qq-upload-list\"></ul>' +\n\t\t'</div>',\n\t\tdebug: false,\n\t\tparams: {\n\t\tTargetArticaUploaded: 'yes',\n\t\tID: '{$_GET["ID"]}',\n\t\t//select-file: '{$_GET["select-file"]}'\n\t\t},\n\t\tonComplete: function(id, fileName){\n\t\t\tPathUploaded{$t}(fileName);\n\t\t}\n\t});\n\n}\n\nfunction PathUploaded{$t}(fileName){\n\tLoadAjax('file-uploader-demo-{$t}','{$page}?file-uploader-demo1=yes&fileName='+fileName+'&ID={$_GET["ID"]}');\n}\ncreateUploader{$t}();\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function create_table() { $q = new mysql_squid_builder(); $sql = "CREATE TABLE IF NOT EXISTS `bandquotas_status` (\n\t`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t PatternGroup VARCHAR(90) NOT NULL,\n\tzDate datetime NOT NULL,\n\truleid BIGINT(10) NOT NULL,\n\tsize BIGINT UNSIGNED NOT NULL,\n\tpercent smallint(2) NOT NULL DEFAULT 0,\n\tfreeze smallint(2) NOT NULL DEFAULT 0,\n\tKEY `ruleid` (`ruleid`),\n\tKEY `size` (`size`),\n\tKEY `percent` (`percent`),\n\tKEY `zDate` (`zDate`),\n\tKEY `freeze` (`freeze`)\n\t) ENGINE = MYISAM;"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error_html(); die; } if (!$q->FIELD_EXISTS("bandquotas", "RuleName")) { $sql = "ALTER TABLE `bandquotas` ADD `RuleName` varchar(255) default NULL"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error_html(); die; } } }
function popup() { $q = new mysql_squid_builder(); $ID = $_GET["ID"]; $page = CurrentPageName(); $tpl = new templates(); $t = time(); if (!$q->FIELD_EXISTS("proxy_ports", "FTPProxyMaxClients")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPProxyMaxClients` BIGINT(100) NOT NULL DEFAULT '64'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "FTPProxyTimeOuts")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPProxyTimeOuts` INT(100) NOT NULL DEFAULT '360'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "FTPProxyDestinationTransferMode")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPProxyDestinationTransferMode` VARCHAR(32) NOT NULL DEFAULT 'client'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "FTPUserAuthMagic")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPUserAuthMagic` VARCHAR(128) NOT NULL DEFAULT '@user'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "FTPUseMagicChar")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPUseMagicChar` VARCHAR(32) NOT NULL DEFAULT '@'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("proxy_ports", "FTPAllowMagicUser")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `FTPAllowMagicUser` SMALLINT(1) NOT NULL DEFAULT '1'"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } $DestinationTransferModeR["client"] = "client"; $DestinationTransferModeR["passive"] = "passive"; $DestinationTransferModeR["active"] = "active"; $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$ID}")); $html = "\n<div style='width:98%' class=form>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{MaxClients}:</td>\n\t\t<td style='font-size:18px'>" . field_text("FTPProxyMaxClients-{$t}", $ligne["FTPProxyMaxClients"], "font-size:20px;width:120px") . "</td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{timeout2} ({seconds}):</td>\n\t\t<td style='font-size:18px'>" . field_text("FTPProxyTimeOuts-{$t}", $ligne["FTPProxyTimeOuts"], "font-size:20px;width:120px") . "</td>\n\t\t<td> </td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>" . texttooltip("{FTPProxyDestinationTransferMode}", "{FTPProxyDestinationTransferMode_explain}") . ":</td>\n\t\t<td style='font-size:20px'>" . Field_array_Hash($DestinationTransferModeR, "FTPProxyDestinationTransferMode-{$t}", $ligne["FTPProxyDestinationTransferMode"], "style:font-size:20px") . "</td>\n\t\t<td> </td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>" . texttooltip("{FTPAllowMagicUser}", "{FTPAllowMagicUser_explain}") . ":</td>\n\t\t\t<td style='font-size:20px'>" . Field_checkbox_design("FTPAllowMagicUser-{$t}", 1, $ligne["FTPAllowMagicUser"]) . "</td>\n\t\t<td> </td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>" . texttooltip("{UserAuthMagic}", "{UserAuthMagic_explain}") . ":</td>\n\t\t<td style='font-size:18px'>" . field_text("FTPUserAuthMagic-{$t}", $ligne["FTPUserAuthMagic"], "font-size:20px;width:220px") . "</td>\n\t\t<td> </td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>" . texttooltip("{FTPUseMagicChar}", "{FTPUseMagicChar_explain}") . ":</td>\n\t\t<td style='font-size:18px'>" . field_text("FTPUseMagicChar-{$t}", $ligne["FTPUseMagicChar"], "font-size:20px;width:220px") . "</td>\n\t\t<td> </td>\n\t</tr>\t\n<tr>\n\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 32) . "</td>\n</tr>\n</table>\n</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){ alert(results); return; }\n\tRefreshTab('main_proxy_listen_ports');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('ID','{$ID}');\n\tXHR.appendData('FTPProxyMaxClients',document.getElementById('FTPProxyMaxClients-{$t}').value);\n\tXHR.appendData('FTPProxyTimeOuts',document.getElementById('FTPProxyTimeOuts-{$t}').value);\n\tXHR.appendData('FTPProxyDestinationTransferMode',document.getElementById('FTPProxyDestinationTransferMode-{$t}').value);\n\tXHR.appendData('FTPUserAuthMagic',document.getElementById('FTPUserAuthMagic-{$t}').value);\n\tXHR.appendData('FTPUseMagicChar',document.getElementById('FTPUseMagicChar-{$t}').value);\n\tif(document.getElementById('FTPAllowMagicUser-{$t}').checked){XHR.appendData('FTPAllowMagicUser',1);}else{XHR.appendData('FTPAllowMagicUser',0);}\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function general_settings_save() { $_POST["remote_path"] = url_decode_special_tool($_POST["remote_path"]); $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("reverse_sources", "cacheid")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `cacheid` INT(10) NOT NULL DEFAULT '0'"); } if (!$q->FIELD_EXISTS("reverse_sources", "certificate")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `certificate` CHAR(128) NULL"); } $q->QUERY_SQL("UPDATE `reverse_sources` SET\n\t\t\t`servername`='{$_POST["servername"]}',\n\t\t\t`ipaddr`='{$_POST["ipaddr"]}',\n\t\t\t`remote_path`='{$_POST["remote_path"]}',\n\t\t\t`forceddomain`='{$_POST["forceddomain"]}',\n\t\t\t`port`='{$_POST["port"]}',\n\t\t\t`cacheid`='{$_POST["cacheid"]}',\n\t\t\t`certificate`='{$_POST["certificate"]}'\n\t\t\tWHERE ID='{$_POST["general-settings"]}'"); if (!$q->ok) { echo $q->mysql_error; } }
function websites_script_DenyConfSave() { $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("reverse_www", "DenyConf")) { $q->QUERY_SQL("ALTER TABLE `reverse_www` ADD `DenyConf` smallint(1) NOT NULL DEFAULT 0"); if (!$q->ok) { echo $q->mysql_error_html(); } } $q->QUERY_SQL("UPDATE reverse_www SET `DenyConf`='{$_POST["DenyConfSave"]}' WHERE `servername`='{$_POST["servername"]}'"); if (!$q->ok) { echo $q->mysql_error; } }
function VOLUME_LOG_HOURLY_MYSQL_DUMP($MSSQLFAM) { $q = new mysql_squid_builder(); $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_volume_day` ( \n\t\t\t`TIME` DATETIME,\n\t\t\t`FAMILYSITE` VARCHAR(128),\n\t\t\t`USERID` VARCHAR(64),\n\t\t\t`IPADDR` VARCHAR(64),\n\t\t\t`MAC` VARCHAR(64),\n\t\t\t`CATEGORY` VARCHAR(64),\n\t\t\t`CONTENT_TYPE` VARCHAR(64),\n\t\t\t`SIZE` BIGINT UNSIGNED, \n\t\t\t`RQS` BIGINT UNSIGNED,\n\t\t\tKEY `TIME` (`TIME`),\n\t\t\tKEY `FAMILYSITE` (`FAMILYSITE`),\n\t\t\tKEY `USERID` (`USERID`),\n\t\t\tKEY `IPADDR` (`IPADDR`),\n\t\t\tKEY `MAC` (`MAC`),\n\t\t\tKEY `CONTENT_TYPE` (`CONTENT_TYPE`)\n\t\t\t\n\t\t\t) ENGINE=MYISAM;"); if (!$q->FIELD_EXISTS("dashboard_volume_day", "CATEGORY")) { $sql = "ALTER TABLE `dashboard_volume_day` ADD `CATEGORY` VARCHAR(64), ADD INDEX(`CATEGORY`)"; $q->QUERY_SQL($sql, "artica_backup"); } reset($MSSQLFAM); while (list($KEY, $MAINARRAY) = each($MSSQLFAM)) { $HOURTIME = date("Y-m-d H:00:00", $MAINARRAY["ZDATE"]); $USERID = mysql_escape_string2($MAINARRAY["USERID"]); $IPADDR = $MAINARRAY["IPADDR"]; $MAC = $MAINARRAY["MAC"]; $CONTENT_TYPE = mysql_escape_string2($MAINARRAY["CONTENT_TYPE"]); $FAMILYSITE = $MAINARRAY["FAMILYSITE"]; $CATEGORY = $MAINARRAY["CATEGORY"]; $HITS = $MAINARRAY["RQS"]; $SIZE = $MAINARRAY["SIZE"]; $line = "('{$HOURTIME}','{$FAMILYSITE}','{$USERID}','{$IPADDR}','{$MAC}','{$CONTENT_TYPE}','{$SIZE}','{$HITS}')"; $f[] = "('{$HOURTIME}','{$FAMILYSITE}','{$USERID}','{$IPADDR}','{$MAC}','{$CONTENT_TYPE}','{$SIZE}','{$HITS}')"; } $faildir = "{$GLOBALS["LogFileDeamonLogDir"]}/mysqlvolume-failed"; @mkdir($faildir, 0755, true); if (count($f) == 0) { return; } $sql = "INSERT INTO `dashboard_volume_day` (`TIME`,`FAMILYSITE`,`USERID`,`IPADDR`,`MAC`,`CONTENT_TYPE`,`SIZE`,`RQS`) VALUES " . @implode(",", $f); $failedPath = "{$faildir}/" . time() . ".influx.sql"; $q->QUERY_SQL($sql); if (!$q->ok) { events("INJECTION Failed: backup to {$failedPath} ({$q->curl_error})"); @file_put_contents($failedPath, $sql); } }
function list_items() { $STATUS = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/nginx.status.acl")); $tpl = new templates(); $MyPage = CurrentPageName(); $all_text = $tpl->_ENGINE_parse_body("{all}"); $GLOBALS["CLASS_TPL"] = $tpl; $q = new mysql_squid_builder(); $OrgPage = "miniadmin.proxy.reverse.php"; $sock = new sockets(); $EnableFreeWeb = intval($sock->GET_INFO("EnableFreeWeb")); if (!$q->FIELD_EXISTS("reverse_www", "zOrder")) { $q->QUERY_SQL("ALTER TABLE `reverse_www` ADD `zOrder` smallint(100) NOT NULL default '0'"); if (!$q->ok) { echo $q->mysql_error_html(); } } $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=0&t={$_GET["t"]}')"); $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=1&t={$_GET["t"]}')"); $FORCE = "cache_peer_id={$_GET["ID"]}"; $search = '%'; $table = "reverse_www"; $page = 1; $freeweb_compile_background = $tpl->javascript_parse_text("{freeweb_compile_background}"); $reset_admin_password = $tpl->javascript_parse_text("{reset_admin_password}"); $delete_freeweb_text = $tpl->javascript_parse_text("{delete_freeweb_text}"); $delete_freeweb_nginx_text = $tpl->javascript_parse_text("{delete_freeweb_nginx_text}"); $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}"); $total = 0; if ($q->COUNT_ROWS($table, "artica_backup") == 0) { json_error_show("no data", 1); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { if (strlen($FORCE) > 2) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table, "artica_events"); } } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if (!is_numeric($rp)) { $rp = 50; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE {$FORCE} {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CurrentPage = CurrentPageName(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); if (!AdminPrivs()) { $sql = "SELECT reverse_www.* FROM reverse_www,reverse_privs\n\t\tWHERE reverse_privs.servername=reverse_www.servername\n\t\tAND reverse_privs.uid='{$_SESSION["uid"]}' {$searchstring} ORDER BY servername LIMIT 0,250"; } $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $q1 = new mysql(); $t = time(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $servername = $ligne["servername"]; $explain_text = NGINX_EXPLAIN_REVERSE($ligne["servername"]); $icon = "clound-in-64.png"; $freewebicon = "64-firewall-search.png"; $color = "black"; $status = array(); $portText = null; $md = md5(serialize($ligne)); $RedirectQueries = $ligne["RedirectQueries"]; $default_server = $ligne["default_server"]; $SiteEnabled = $ligne["enabled"]; $servername_enc = urlencode($servername); $Compile = imgsimple("apply-48.png", null, "Loadjs('nginx.single.progress.php?servername={$servername_enc}')"); $limit_rate = $ligne["limit_rate"]; $limit_rate_after = $ligne["limit_rate_after"]; $DeleteFreeWeb = "Loadjs('{$MyPage}?unlink-websites-js=yes&servername={$servername_enc}&md={$md}')"; $icon2 = imgsimple("reconfigure-48.png", null, "Loadjs('miniadmin.proxy.reverse.reconfigure.php?servername={$servername_enc}')"); $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&servername={$servername_enc}&dir=0&t={$_GET["t"]}')"); $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&servername={$servername_enc}&dir=1&t={$_GET["t"]}')"); if ($ligne["DenyConf"] == 1) { $icon = "hearth-blocked-64.png"; } if ($SiteEnabled == 0) { $icon = "domain-main-64-grey.png"; $color = "#8a8a8a"; $icon2 = " "; } $delete = imgsimple("delete-48.png", null, $DeleteFreeWeb); $jsedit = imgsimple($icon, null, "Loadjs('nginx.site.php?servername={$servername_enc}')"); $jsEditWW = $jsedit; $jseditA = $jsedit; $jseditC = imgsimple("script-48.png", null, "Loadjs('nginx.script.php?website-script-js=yes&servername={$servername_enc}')"); if ($limit_rate > 0) { $limit_rate_after_caption = $tpl->_ENGINE_parse_body("{limit_rate_after_caption}"); $limit_rate_after_caption = str_replace("%s", "{$limit_rate}MB/s", $limit_rate_after_caption); $limit_rate_after_caption = str_replace("%f", "{$limit_rate_after}MB", $limit_rate_after_caption); $status[] = "<br><span style='font-size:12px;font-weight:bold;color:#EEB853'>{$limit_rate_after_caption}</span>"; } if (count($status) > 0) { $status_text = $tpl->_ENGINE_parse_body("<div style='font-size:12px'>" . @implode("", $status) . "</div>"); } $FreeWebText = null; if ($EnableFreeWeb == 0) { if ($ligne["ipaddr"] == "127.0.0.1") { $ligne["ipaddr"] = "{error}"; } if ($ligne["cache_peer_id"] == 0) { $ligne["cache_peer_id"] = -1; } } if ($ligne["owa"] == 1) { $freewebicon = "exchange-2010-64.png"; } if ($ligne["poolid"] > 0) { $freewebicon = "64-cluster.png"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT poolname FROM nginx_pools WHERE ID='{$ligne["poolid"]}'")); $ligne["ipaddr"] = $ligne2["poolname"]; } $stats = null; $FinalDestination = "{$ligne["ipaddr"]}{$FreeWebText}"; if ($default_server == 1) { $servername = "{$servername} ({$all_text} * )"; $icon = "free-web-64.png"; if ($SiteEnabled == 0) { $icon = "free-web-64-grey.png"; } } $data['rows'][] = array('id' => $ligne['categorykey'], 'cell' => array("{$jseditC}", "<a href=\"javascript:blur();\"\n\t\t\t\t\t\t\tstyle='font-size:18px;font-weight:bold;text-decoration:underline'\n\t\t\t\t\t\t\tOnClick=\"javascript:Loadjs('nginx.site.php?servername={$servername_enc}')\">{$servername}{$portText}</a>\n\t\t\t\t\t\t\t<br>{$status_text}\n\t\t\t\t\t\t\t{$explain_text}", $Compile, $delete)); } echo json_encode($data); }
function rules_options_save(){ $q=new mysql_squid_builder(); if(!$q->FIELD_EXISTS("wpad_rules", "dntlhstname")){ $q->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `dntlhstname` smallint( 1 ) DEFAULT '0'"); } if(!$q->FIELD_EXISTS("wpad_rules", "isResolvable")){ $q->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `isResolvable` smallint( 1 ) DEFAULT '0'"); } $sql="UPDATE wpad_rules SET dntlhstname='{$_POST["dntlhstname"]}', isResolvable='{$_POST["isResolvable"]}' WHERE ID='{$_POST["ID"]}'"; $q->QUERY_SQL($sql); if(!$q->ok){echo $q->mysql_error;} }
function quota_notification() { $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("webfilters_quotas", "notify")) { $q->QUERY_SQL("ALTER TABLE webfilters_quotas ADD `notify` smallint(1) NOT NULL DEFAULT 0, ADD INDEX (`notify`)"); } if (!$q->FIELD_EXISTS("webfilters_quotas", "notify_params")) { $q->QUERY_SQL("ALTER TABLE webfilters_quotas ADD `notify_params` TEXT"); } }
function UnLock($array) { $REMOTE_ADDR = $array["REMOTE_ADDR"]; $IPADDR = $array["REMOTE_ADDR"]; $SERVER_NAME = $array["SERVER_NAME"]; $redirecturi = $array["redirecturi"]; $LOGIN = $array["LOGIN"]; $uid = $array["LOGIN"]; $ARP = $array["ARP"]; $token = $array["token"]; $HOST = $array["HOST"]; $MAC = $ARP; $username = $uid; $CACHE_AUTH = $GLOBALS["CACHE_AUTH"]; $autocreate = 0; $time = time(); $sock = new sockets(); $md5key = $token; $q = new mysql_squid_builder(); $sql = "SELECT creationtime,uid,ttl,enabled,autocreate,autocreate_confirmed FROM hotspot_members WHERE uid='{$username}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $finaltime = strtotime("+525600 minutes", time()); $ttl = $ligne["ttl"]; if ($ligne["autocreate"] == 1) { if ($ligne["autocreate_confirmed"] == 0) { $autocreate = 1; } } if ($ttl > 0) { $finaltime = strtotime("+{$ttl} minutes", $ligne["creationtime"]); } ToSyslog("wifidog_auth/UnLock: {$username}: Create session {$md5key} ( autocreate ={$autocreate} ) for {$LOGIN} MAC:{$MAC} with a Time To Live of {$ttl}Mn in line:" . __LINE__); $NextCheck = strtotime("+525600 minutes", $time); $logintime = time(); if (!is_numeric($CACHE_AUTH)) { $CACHE_AUTH = 60; } if (!is_numeric($GLOBALS["MAX_TIME"])) { $GLOBALS["MAX_TIME"] = 0; } if ($CACHE_AUTH > 0) { $NextCheck = strtotime("+{$CACHE_AUTH} minutes", $time); } $datelogs = date("Y-m-d H:i:s", $NextCheck); $finaltimeDate = date("Y-m-d H:i:s", $finaltime); $MAC = trim(strtolower($MAC)); if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("wifidog_auth/UnLock: Remove sessions for {$token},{$IPADDR},{$MAC},{$uid}"); } $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE `md5`='{$token}'"); $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE ipaddr='{$IPADDR}'"); $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE MAC='{$MAC}'"); $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE uid='{$uid}'"); if (!$q->FIELD_EXISTS("hotspot_sessions", "nextcheck")) { $q->QUERY_SQL("ALTER TABLE `hotspot_sessions` ADD `nextcheck` BIGINT UNSIGNED ,ADD INDEX ( `nextcheck` )"); } if (!$q->FIELD_EXISTS("hotspot_sessions", "autocreate")) { $q->QUERY_SQL("ALTER TABLE `hotspot_sessions` ADD `autocreate` smallint(1) NOT NULL DEFAULT 0 ,ADD INDEX ( `autocreate` )"); } $sql = "INSERT IGNORE INTO hotspot_sessions (`md5`,logintime, maxtime,finaltime,nextcheck,username,uid,MAC,hostname,ipaddr,autocreate) VALUES('{$token}',{$logintime},{$CACHE_AUTH},{$finaltime},{$NextCheck},'{$username}','{$uid}','{$MAC}','{$HOST}','{$IPADDR}','{$autocreate}')"; if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("wifidog_auth/UnLock: {$sql}"); } $q->QUERY_SQL($sql); if (!$q->ok) { ToSyslog("wifidog_auth/UnLock:{$q->mysql_error} Line:" . __LINE__); return false; } $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `md5` FROM hotspot_sessions WHERE `md5`='{$token}'")); if (trim($ligne["md5"]) == null) { ToSyslog("wifidog_auth/UnLock: MySQL Failed, {$token} is not saved Line:" . __LINE__); return false; } events(2, "{$username}/{$MAC} Create a new session Finish at {$finaltime} ({$finaltimeDate})", __FILE__, __LINE__); ToSyslog("wifidog_auth/UnLock: Create session {$token} for {$LOGIN} MAC:{$MAC} Max time:{$GLOBALS["MAX_TIME"]} Finish at {$finaltime} ({$finaltimeDate})"); return true; }
function events_search() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $rp = 0; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (is_numeric($rp)) { $limitSql = "LIMIT {$pageStart}, {$rp}"; } if (!$q->FIELD_EXISTS("dashboard_volume_day", "CATEGORY")) { $sql = "ALTER TABLE `dashboard_volume_day` ADD `CATEGORY` VARCHAR(64), ADD INDEX(`CATEGORY`)"; $q->QUERY_SQL($sql, "artica_backup"); } $table = "(SELECT SUM(SIZE) as SIZE, SUM(RQS) as RQS,`TIME`,CATEGORY,USERID,IPADDR,MAC,FAMILYSITE \n\t\t\tFROM `dashboard_volume_day` GROUP BY `TIME`,CATEGORY,USERID,IPADDR,MAC,FAMILYSITE) as t"; $searchstring = string_to_flexquery(); $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show($q->mysql_error); } $total = $ligne["TCOUNT"]; $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $tpl = new templates(); $font_size = "font-size:16px"; while ($ligne = mysql_fetch_assoc($results)) { $CATEGORY = $ligne["CATEGORY"]; $FAMILYSITE = $ligne["FAMILYSITE"]; $IPADDR = $ligne["IPADDR"]; $MAC = $ligne["MAC"]; $RQS = $ligne["RQS"]; $SITE = $ligne["FAMILYSITE"]; $SIZE = $ligne["SIZE"]; $USERID = $ligne["USERID"]; $color = "#000000"; $ident = array(); if (intval($SIZE) >= 1024) { $SIZE = FormatBytes(intval($SIZE) / 1024); } else { $SIZE = "{$SIZE}Bytes"; } $RQS = FormatNumber($RQS); $md = md5(serialize($ligne)); $time = $ligne["TIME"]; $spanON = "<span style='color:{$color};{$font_size}'>"; $spanOFF = "</span>"; $cached_text = null; if ($USERID != null) { $ident[] = "<a href=\"javascript:blur()\"\n\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&uid={$USERID}',true);\"\n\t\t\tstyle='text-decoration:underline;color:{$color};{$font_size}'>{$USERID}</a>"; } $ident[] = "<a href=\"javascript:blur()\"\n\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&ipaddr={$IPADDR}',true);\"\n\t\tstyle='text-decoration:underline;color:{$color};{$font_size}'>{$IPADDR}</a>"; if ($MAC != null) { $ident[] = "<a href=\"javascript:blur()\"\n\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$MAC}',true);\"\n\t\t\tstyle='text-decoration:underline;color:{$color};{$font_size}'>{$MAC}</a>"; } $colorDiv = $color; if ($colorDiv == "black") { $colorDiv = "transparent"; } $identities = @implode(" | ", $ident); $data['rows'][] = array('id' => $md, 'cell' => array("{$spanON}{$time}{$spanOFF}", "{$spanON}{$identities}{$spanOFF}", "{$spanON}{$SITE}{$spanOFF}", "{$spanON}{$CATEGORY}{$spanOFF}", "{$spanON}{$SIZE}{$spanOFF}", "{$spanON}{$RQS}{$spanOFF}")); } echo json_encode($data); }
function SaveMysql(){ if($_POST["files"]==1){ $FileTypes["application/octet-stream"]=1; $FileTypes["application/x-gsp"]=1; $FileTypes["application/x-gss"]=1; $FileTypes["application/x-gtar"]=1; $FileTypes["application/x-compressed"]=1; $FileTypes["application/x-gzip"]=1; $FileTypes["multipart/x-gzip"]=1; $FileTypes["multipart/x-zip"]=true; $FileTypes["application/binhex"]=1; $FileTypes["application/binhex4"]=1; $FileTypes["application/mac-binhex"]=1; $FileTypes["application/mac-binhex40"]=1; $FileTypes["application/x-binhex40"]==1; $FileTypes["application/x-mac-binhex40"]=1; $FileTypes["application/msword"]=1; $FileTypes["application/x-bcpio"]=1; $FileTypes["application/mac-binary"]=1; $FileTypes["application/x-compress"]=true; $FileTypes["application/x-compressed"]=true; $FileTypes["application/x-zip-compressed"]=1; $FileTypes["application/zip"]=1; $FileTypes["application/arj"]=1; $FileTypes["application/book"]=1; $FileTypes["application/octet-stream"]=1; $FileTypes["application/x-binary"]=1; $FileTypes["application/macbinary"]=1; $FileTypes["application/x-macbinary"]=1; $FileTypes["application/mspowerpoint"]=1; $FileTypes["application/vnd.ms-powerpoint"]=1; $FileTypes["application/powerpoint"]=1; $FileTypes["application/excel"]=1; $FileTypes["application/vnd.ms-excel"]=1; $FileTypes["application/x-excel"]=1; $FileTypes["application/x-msexcel"]=1; $FileTypes["application/java"]=1; $FileTypes["application/java-byte-code"]=1; $FileTypes["application/x-java-class"]=1; $FileTypes["text/x-asm"]=1; $FileTypes["text/asp"]=1; $FileTypes["text/plain"]=1; $FileTypes["text/css"]=1; $FileTypes["text/x-c"]=1; $FileTypes["text/html"]=1; $FileTypes["text/x-fortran"]=1; $FileTypes["text/x-java-source"]=1; $FileTypes["application/x-java-commerce"]=1; $FileTypes["application/x-javascript"]=1; $FileTypes["application/javascript"]=1; $FileTypes["application/ecmascript"]=1; $FileTypes["text/javascript"]=1; $FileTypes["text/ecmascript"]=1; } if($_POST["images"]==1){ $FileTypes["image/jpeg"]=1; $FileTypes["image/gif"]=1; $FileTypes["image/x-icon"]=1; $FileTypes["image/pjpeg"]=1; $FileTypes["image/bmp"]=1; $FileTypes["image/png"]=1; $FileTypes["image/x-jps"]=1; $FileTypes["image/vnd.fpx"]=1; $FileTypes["image/vnd.net-fpx"]=1; $FileTypes["image/florian"]=1; $FileTypes["image/fif"]=1; $FileTypes["image/vnd.dwg"]=1; $FileTypes["image/x-windows-bmp"]=1; $FileTypes["image/x-dwg"]=1; $FileTypes["image/vnd.dwg"]=1; $FileTypes["image/x-dwg"]=1; $FileTypes["image/g3fax"]=1; $FileTypes["image/gif"]=1; $FileTypes["image/x-icon"]=1; $FileTypes["image/ief"]=1; $FileTypes["image/jutvision"]=1; $FileTypes["image/vasa"]=1; $FileTypes["image/naplps"]=1; } if($_POST["videos"]){ $FileTypes["application/x-mplayer2"]=1; $FileTypes["application/x-troff-msvideo"]=1; $FileTypes["application/x-dvi"]=1; $FileTypes["video/fli"]=1; $FileTypes["video/x-fli"]=1; $FileTypes["video/x-atomic3d-feature"]=1; $FileTypes["video/x-ms-asf"]=1; $FileTypes["video/x-ms-asf-plugin"]=1; $FileTypes["video/avi"]=1; $FileTypes["video/msvideo"]=1; $FileTypes["video/x-msvideo"]=1; $FileTypes["video/x-sgi-movie"]=1; $FileTypes["video/avs-video"]=1; $FileTypes["video/dl"]=1; $FileTypes["video/x-dl"]=1; $FileTypes["video/x-dv"]=1; $FileTypes["video/gl"]=1; $FileTypes["video/x-gl"]=1; $FileTypes["video/x-isvideo"]=1; $FileTypes["video/mpeg"]=1; $FileTypes["video/x-dv"]=1; $FileTypes["video/quicktime"]=1; $FileTypes["video/x-sgi-movie"]=1; $FileTypes["video/mpeg"]=1; $FileTypes["video/x-mpeg"]=1; $FileTypes["video/x-mpeq2a"]=1; $FileTypes["video/x-motion-jpeg"]=1; $FileTypes["video/vnd.rn-realvideo"]=1; $FileTypes["application/x-vnd.audioexplosion.mzz"]=1; $FileTypes["audio/x-gsm"]=1; $FileTypes["audio/make"]=1; $FileTypes["audio/it"]=1; $FileTypes["audio/x-jam"]=1; $FileTypes["audio/basic"]=1; $FileTypes["audio/x-au"]=1; $FileTypes["audio/aiff"]=1; $FileTypes["audio/x-aiff"]=1; $FileTypes["audio/make"]=1; $FileTypes["audio/mpeg"]=1; $FileTypes["audio/x-mpeg"]=1; $FileTypes["audio/mpeg3"]=1; $FileTypes["audio/x-mpeg-3"]=1; $FileTypes["audio/nspaudio"]=1; $FileTypes["audio/x-nspaudio"]=1; $FileTypes["audio/x-liveaudio"]=1; $FileTypes["audio/midi"]=1; $FileTypes["audio/nspaudio"]=1; $FileTypes["audio/x-nspaudio"]=1; $FileTypes["music/x-karaoke"]=1; $FileTypes["audio/mod"]=1; $FileTypes["audio/x-mod"]=1; $FileTypes["application/x-midi"]=1; $FileTypes["audio/x-mid"]=1; $FileTypes["audio/x-midi"]=1; $FileTypes["music/crescendo"]=1; $FileTypes["x-music/x-midi"]=1; $FileTypes["music/crescendo"]=1; $FileTypes["audio/x-vnd.audioexplosion.mjuicemediafile"]=1; } if($_POST["html"]==1){ $FileTypes["text/html"]=1; $FileTypes["text/javascript"]=1; $FileTypes["text/css"]=1; $FileTypes["application/x-javascript"]=1; $FileTypes["application/javascript"]=1; $FileTypes["application/java"]=1; $FileTypes["application/java-byte-code"]=1; $FileTypes["application/x-java-class"]=1; $FileTypes["text/x-asm"]=1; $FileTypes["text/asp"]=1; $FileTypes["text/plain"]=1; $FileTypes["text/css"]=1; $FileTypes["text/x-c"]=1; $FileTypes["text/html"]=1; $FileTypes["text/x-fortran"]=1; $FileTypes["text/x-java-source"]=1; $FileTypes["application/x-java-commerce"]=1; $FileTypes["application/x-javascript"]=1; $FileTypes["application/javascript"]=1; $FileTypes["application/ecmascript"]=1; $FileTypes["text/javascript"]=1; $FileTypes["text/ecmascript"]=1; } $FileTypes_enc=mysql_escape_string2(serialize($FileTypes)); $rulename=mysql_escape_string2($_SESSION["HYPERCACHE_NEW_RULE_WIZARDID"]["rulename"]); $sitename=mysql_escape_string2($_SESSION["HYPERCACHE_NEW_RULE_WIZARDID"]["sitename"]); $q=new mysql_squid_builder(); if(!$q->FIELD_EXISTS("artica_caches","FileTypes","artica_backup")){ $sql="ALTER TABLE `artica_caches` ADD `FileTypes` TEXT"; $q->QUERY_SQL($sql,"artica_backup"); } if(!$q->FIELD_EXISTS("artica_caches","OtherDomains","artica_backup")){ $sql="ALTER TABLE `artica_caches` ADD `OtherDomains` TEXT"; $q->QUERY_SQL($sql,"artica_backup"); } $sql="INSERT IGNORE INTO `artica_caches` (`sitename`,`rulename`,`enabled`,`FileTypes`) VALUES ('$sitename','$rulename','1','$FileTypes_enc')"; $q->QUERY_SQL($sql); if(!$q->ok){echo $q->mysql_error;return;} }
function add_category_popup() { $tpl = new templates(); $page = CurrentPageName(); $dans = new dansguardian_rules(); $time = time(); $q = new mysql_squid_builder(); $error_max_dbname = $tpl->javascript_parse_text("{error_max_database_name_no_more_than}"); $error_category_textexpl = $tpl->javascript_parse_text("{error_category_textexpl}"); $error_category_nomore5 = $tpl->javascript_parse_text("{error_category_nomore5}"); if (!$q->FIELD_EXISTS("personal_categories", "PublicMode")) { $q->QUERY_SQL("ALTER TABLE `personal_categories`\n\t\t\t\tADD `PublicMode` smallint( 1 ) NOT NULL ,\n\t\t\t\tADD INDEX ( `PublicMode` )"); } $t = $_GET["t"]; if (!is_numeric($t)) { $t = time(); } $catenc = urlencode($_GET["cat"]); $actions = button("{compile2}", "Loadjs('ufdbguard.compile.category.php?category={$catenc}&t={$t}')", 26) . " | " . button("{delete}", "Loadjs('{$page}?category-delete-js={$catenc}&t={$t}')", 26) . " | "; if ($_GET["cat"] == null) { $actions = null; } if ($_GET["cat"] != null) { $sql = "SELECT * FROM personal_categories WHERE category='{$_GET["cat"]}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $titleBT = "{apply}"; } else { $action = null; $titleBT = '{add}'; } $proto = "http"; if ($_SERVER["HTTPS"] == "on") { $proto = "https"; } $uri = "{$proto}://{$_SERVER["SERVER_ADDR"]}:{$_SERVER["SERVER_PORT"]}/categories"; $catz_allow_in_public_mode = $tpl->_ENGINE_parse_body("{catz_allow_in_public_mode}"); $catz_allow_in_public_mode = str_replace("%URI", $uri, $catz_allow_in_public_mode); $PublicMode = Paragraphe_switch_img("{allow_in_public_mode}", "{$catz_allow_in_public_mode}", "PublicMode-{$time}", $ligne["PublicMode"], null, 750); $groups = $dans->LoadBlackListesGroups(); $groups[null] = "{select}"; $field = Field_array_Hash($groups, "CatzByGroupL", null, null, null, 0, "font-size:22px"); $blacklists = $dans->array_blacksites; $description = "<textarea name='category_text'\n\tid='category_text-{$t}' style='height:50px;overflow:auto;width:99%;font-size:22px !important'>" . $ligne["category_description"] . "</textarea>"; if (isset($blacklists[$_GET["cat"]])) { $description = "<input type='hidden' id='category_text-{$t}' value=''>\n\t\t<div class=text-info style='font-size:13px'>{$blacklists[$_GET["cat"]]}</div>"; } $html = "\n\t<div id='perso-cat-form'></div>\n\t<div style='width:98%' class=form>\n\t\t\t<table style='width:100%'>\n\t\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:22px'>{category}:</td>\n\t\t\t\t<td>" . Field_text("category-to-add-{$t}", "{$_GET["cat"]}", "font-size:22px;padding:3px;width:99%;font-weight:bold") . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:22px'>{description}:</td>\n\t\t\t\t<td>{$description}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:22px'>{group}:</td>\n\t\t\t\t<td>{$field}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:22px'>{group} ({add}):</td>\n\t\t\t\t<td>" . Field_text("CatzByGroupA", null, "font-size:22px;padding:3px;width:320px") . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2>{$PublicMode}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right' style='font-size:22px'><hr>{$actions}" . button($titleBT, "SavePersonalCategory{$t}()", 26) . "</td>\n\t\t\t</tr>\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\n\n\t\t<script>\nvar X_SavePersonalCategory= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;};\n\t\$('#PERSONAL_CATEGORIES_TABLE').flexReload();\n\tYahooWin5Hide();\n\n}\n\nfunction SavePersonalCategory{$t}(){\n\tvar XHR = new XHRConnection();\n\tvar db=document.getElementById('category-to-add-{$t}').value;\n\tvar expl=document.getElementById('category_text-{$t}').value;\n\tif(db.length<5){alert('{$error_category_nomore5}');return;}\n\tif(expl.length<5){alert('{$error_category_textexpl}');return;}\n\tif(db.length>15){alert('{$error_max_dbname}: 15');return;}\n\tXHR.appendData('personal_database',db);\n\tvar pp=encodeURIComponent(document.getElementById('category_text-{$t}').value);\n\tXHR.appendData('category_text',pp);\n\tXHR.appendData('CatzByGroupA',document.getElementById('CatzByGroupA').value);\n\tXHR.appendData('CatzByGroupL',document.getElementById('CatzByGroupL').value);\n\tXHR.appendData('PublicMode',document.getElementById('PublicMode-{$time}').value);\n\t\n\t\n\t\n\tXHR.sendAndLoad('{$page}', 'POST',X_SavePersonalCategory);\n}\n\nvar X_DeletePersonalCat{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;};\n\t\$('#PERSONAL_CATEGORIES_TABLE').flexReload();\n\tYahooWin5Hide();\n}\n\nvar X_CompilePersonalCat{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tdocument.getElementById('perso-cat-form').innerHTML='';\n\tif(results.length>3){alert(results);return;};\n\t\$('#PERSONAL_CATEGORIES_TABLE').flexReload();\n}\n\n\nfunction DeletePersonalCat{$t}(){\n\tif(confirm('{$delete_personal_cat_ask}')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-personal-cat','{$_GET["cat"]}');\n\t\tAnimateDiv('perso-cat-form');\n\t\tXHR.sendAndLoad('{$page}', 'POST',X_DeletePersonalCat{$t});\n\t}\n\n}\n\nfunction checkform{$t}(){\n\tvar cat='{$_GET["cat"]}';\n\tif(cat.length>0){document.getElementById('category-to-add-{$t}').disabled=true;}\n}\ncheckform{$t}();\n</script>\n\n"; echo $tpl->_ENGINE_parse_body($html); }
function search_records() { //SELECT MacAddress, uid FROM hostsusers $search = '%'; $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $q2 = new mysql(); $limitSql = "LIMIT 0,150"; $t = time(); $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("webfilters_ipaddr", "ip")) { $q->QUERY_SQL("ALTER TABLE `webfilters_ipaddr` ADD `ip` int(10) unsigned NOT NULL default '0',ADD INDEX ( `ip` )"); } $boot = new boostrap_form(); $searchstring = string_to_flexquery("search-records"); $ORDER = $boot->TableOrder(array("ip" => "ASC")); $sql = "SELECT * FROM webfilters_ipaddr WHERE 1 {$searchstring} ORDER BY {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $sock = new sockets(); if (!$q->ok) { echo "<p class=text-error>{$q->mysql_error}<hr><code>{$sql}</code></p>"; } while ($ligne = mysql_fetch_assoc($results)) { $id = md5(serialize($ligne)); $explainthis = null; $articasrv = null; $aliases_text = null; $explainMac = null; $OS = null; $macencoded = urlencode($ligne["ipaddr"]); $delete = imgsimple("delete-24.png", null, "Loadjs('{$page}?delete-ipaddr-js={$macencoded}&id={$id}')"); $jshost = "NewPDNSEntry{$t}({$id});"; $linkipaddr = $boot->trswitch("Loadjs('{$page}?NewipaddrLink-js=yes&ipaddr={$macencoded}')"); $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$linkipaddr} width=1% nowrap><i class='icon-user'></i> {$ligne["ipaddr"]}</a></td>\n\t\t<td nowrap {$linkipaddr}><i class='icon-user'></i> {$ligne["hostname"]}</a></td>\n\t\t<td nowrap {$linkipaddr} width=1% nowrap><i class='icon-user'></i> {$ligne["uid"]}</td>\n\t\t<td style='text-align:center' width=1% nowrap>{$delete}</td>\n\t\t</tr>"; } $html = $boot->TableCompile(array("ip" => "{ipaddr}", "hostname" => "{hostname}", "uid" => "{uid}", "delete:no" => "{delete}"), $tr); echo $tpl->_ENGINE_parse_body($html); }
function view_table() { $q = new mysql_squid_builder(); $Mypage = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $search = '%'; $table = "squidtpls"; $page = 1; $searchstring = null; if ($_GET["lang"] != null) { $FORCEQ = " AND lang='{$_GET["lang"]}'"; } $choose_generic = $_GET["choose-generic"]; if (!$q->FIELD_EXISTS($table, "template_time")) { $q->CheckTables(); } if (!$q->TABLE_EXISTS($table)) { json_error_show("{$table} no such table", 2); } if ($q->COUNT_ROWS($table) == 0) { json_error_show("No data in {$table}", 2); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($_POST["query"] != null) { $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')"; $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCEQ}{$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show("{$q->mysql_error}<hr>{$sql}", 2); } $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table); if (!$q->ok) { json_error_show("{$q->mysql_error}", 2); } } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $data = array(); $data['rows'] = array(); $delete_icon = "delete-24.png"; $fontsize = 12; if (isset($_GET["viatabs"])) { $fontsize = 14; $delete_icon = "delete-32.png"; } $span = "<span style='font-size:{$fontsize}px'>"; $EnableSplashScreen = $sock->GET_INFO("EnableSplashScreen"); $EnableSplashScreenAsObject = $sock->GET_INFO("EnableSplashScreenAsObject"); if (!is_numeric($EnableSplashScreen)) { $EnableSplashScreen = 0; } if (!is_numeric($EnableSplashScreenAsObject)) { $EnableSplashScreenAsObject = 0; } $SplashScreenURI = $sock->GET_INFO("SplashScreenURI"); if (trim($SplashScreenURI) == null) { $EnableSplashScreen = 0; } $URLAR = parse_url($SplashScreenURI); if (isset($URLAR["host"])) { $SplashScreenURI = "http://{$SplashScreenURI}"; } if (!preg_match("^http.*", $SplashScreenURI)) { $SplashScreenURI = "http://{$SplashScreenURI}"; } if ($searchstring == null) { if ($EnableSplashScreen == 1) { if ($EnableSplashScreenAsObject == 1) { $linkZoom = null; $cell = array(); $delete = " "; $cell[] = $tpl->_ENGINE_parse_body("{all}</span>"); $cell[] = "<span style='font-size:{$fontsize}px;font-weight:bold'>{$linkZoom}{$SplashScreenURI}</a></span>"; $cell[] = $tpl->_ENGINE_parse_body("<span style='font-size:{$fontsize}px;fonct-weight:bold'>{$linkZoom}{hotspot_auth}</a></span>"); $cell[] = " </span>"; if ($_GET["choose-acl"] > 0) { $cell[] = imgsimple("arrow-right-24.png", null, "ChooseAclsTplSquid('{$_GET["choose-acl"]}','ARTICA_SLASH_SCREEN')"); } if (strlen($choose_generic) > 3) { $cell[] = imgsimple("arrow-right-24.png", null, "ChooseGenericTemplate('ARTICA_SLASH_SCREEN')"); } $cell[] = $delete; $data['rows'][] = array('id' => "SplashScreen", 'cell' => $cell); $total++; } } } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$FORCEQ}{$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $data['page'] = $page; $data['total'] = $total; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("{$q->mysql_error}", 2); } $statuscodes = $q->LoadStatusCodes(); $empty_template = $tpl->_ENGINE_parse_body("{empty_template}"); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = $ligne["zmd5"]; $title = base64_encode($ligne["template_title"]); $linkZoom = "<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('{$Mypage}?Zoom-js={$ligne['zmd5']}&subject={$title}');\" style='font-size:{$fontsize}px;text-decoration:underline'>"; if ($ligne["template_link"] == 1) { $ligne['lang'] = imgsimple("24-parameters.png", null, "NewTemplate('{$zmd5}')"); if (preg_match("#^([0-9]+):(.+)#", $ligne["template_uri"], $ri)) { $ligne["template_uri"] = $ri[2]; $ligne["template_uri"] = str_replace("%FREEWEBS%", "<div>+FreeWebs</div>", $ligne["template_uri"]); $ligne["template_uri"] = $ligne["template_uri"] . "<div>" . $statuscodes[$ri[1]] . "</div>"; } $ligne["template_title"] = $ligne["template_uri"]; } $cell = array(); if ($ligne["template_title"] == null) { $ligne["template_title"] = $empty_template; } if ($ligne["emptytpl"] == 1) { $linkZoom = "<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('{$Mypage}?template-settings-js=yes&zmd5={$ligne["zmd5"]}&t={$_GET["t"]}');\" style='font-size:{$fontsize}px;text-decoration:underline'>"; } $ligne['template_name'] = utf8_encode($ligne['template_name']); $ligne['template_title'] = utf8_encode($ligne['template_title']); $delete = imgsimple($delete_icon, null, "TemplateDelete('{$ligne['zmd5']}')"); $cell[] = "{$span}{$linkZoom}{$ligne['lang']}</a></span>"; $cell[] = "{$span}{$linkZoom}{$ligne['template_name']}</a></span>"; $cell[] = "{$span}{$linkZoom}{$ligne["template_title"]}</a></span>"; $cell[] = "{$span}{$linkZoom}{$ligne["template_time"]}</a></span>"; if ($_GET["choose-acl"] > 0) { $cell[] = imgsimple("arrow-right-24.png", null, "ChooseAclsTplSquid('{$_GET["choose-acl"]}','{$ligne['zmd5']}')"); } if (strlen($choose_generic) > 3) { $cell[] = imgsimple("arrow-right-24.png", null, "ChooseGenericTemplate('{$ligne['template_name']}')"); } $cell[] = $delete; $data['rows'][] = array('id' => $ligne['zmd5'], 'cell' => $cell); } echo json_encode($data); }
function run_mysql() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, __FILE__)) { return; } $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("import_srclogs", "pid")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `pid` smallint(5)"); } if (!$q->FIELD_EXISTS("import_srclogs", "first_time")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `first_time` INT UNSIGNED"); } if (!$q->FIELD_EXISTS("import_srclogs", "last_time")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `last_time` INT UNSIGNED"); } $php = $unix->LOCATE_PHP5_BIN(); $nohup = $unix->find_program("nohup"); $sql = "SELECT * FROM import_srclogs WHERE status=0 ORDER BY zDate"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { $md5file = $ligne["md5file"]; $path = $ligne["path"]; mysql_progress($md5file, 0, 1, "Open.."); $t1 = time(); if (Scan($path, $md5file)) { $took = $unix->distanceOfTimeInWords($t1, time(), true); mysql_progress($md5file, 100, 2, "{done} {took} {$took}"); @unlink($path); } shell_exec("{$nohup} {$php} " . __FILE__ . " --run-mysql >/dev/null 2>&1"); die; } }
function Save(){ $q=new mysql_squid_builder(); $table="hotspot_networks"; if(!$q->TABLE_EXISTS($table)){$q->CheckTables();} if(!$q->FIELD_EXISTS("hotspot_networks", "direction")){$q->CheckTables();} $editF=false; $ID=$_POST["ID"]; unset($_POST["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); if(!$q->ok){echo "Mysql error: `$q->mysql_error`";;return;} }
function HyperCacheMirror($JustID = 0) { $unix = new unix(); $httrack = $unix->find_program("httrack"); if (!is_file($httrack)) { if ($GLOBALS["VERBOSE"]) { echo "httrack no such binary\n"; } return; } $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("artica_caches_mirror", "ToDelete")) { $sql = "ALTER TABLE `artica_caches_mirror` ADD `ToDelete` SMALLINT(1) NOT NULL DEFAULT '0',ADD INDEX(`ToDelete`)"; $q->QUERY_SQL($sql); if (!$q->ok) { squid_admin_enforce(1, "Fatal: MySQL error", $q->mysql_error, __FILE__, __LINE__); return; } } if (!$q->FIELD_EXISTS("artica_caches_mirror", "RunEvents")) { $sql = "ALTER TABLE `artica_caches_mirror` ADD `RunEvents` TEXT"; $q->QUERY_SQL($sql); if (!$q->ok) { squid_admin_enforce(1, "Fatal: MySQL error", $q->mysql_error, __FILE__, __LINE__); return; } } $nice = EXEC_NICE(); $sql = "SELECT * FROM artica_caches_mirror WHERE enabled=1 AND `ToDelete`=0"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { squid_admin_enforce(1, "Fatal: MySQL error", $q->mysql_error, __FILE__, __LINE__); return; } if (!isset($GLOBALS["HyperCacheStoragePath"])) { $sock = new sockets(); $GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath"); if ($GLOBALS["HyperCacheStoragePath"] == null) { $GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache"; } } $t1 = time(); $count = 0; if (mysql_num_rows($results) == 0) { return; } $proxyport = $unix->squid_internal_port(); $HyperCache = new HyperCache(); while ($ligne = mysql_fetch_assoc($results)) { if ($JustID > 0) { if ($ligne["ID"] != $JustID) { events("Scrapping rule ID {$ligne["ID"]} !skipped", 0, 2, __LINE__); continue; } } $t = time(); $count++; $sitename = $ligne["sitename"]; $sitename_path = $HyperCache->HyperCacheUriToHostname($sitename); $workingdir = $GLOBALS["HyperCacheStoragePath"] . "/mirror/{$sitename_path}"; $TimeExec = $ligne["TimeExec"]; $TimeExecLast = $unix->file_time_min("{$workingdir}/TimeExec"); if (!$GLOBALS["FORCE"]) { events("Scrapping {$sitename} require {$TimeExec}mn, current {$TimeExecLast}Mn", 0, 2, __LINE__); if ($TimeExecLast < $TimeExec) { continue; } } events("Scrapping rule ID {$ligne["ID"]} for {$sitename}", 0, 2, __LINE__); $minrate = $ligne["minrate"]; $maxfilesize = $ligne["maxfilesize"]; $maxsitesize = $ligne["maxsitesize"]; $maxfilesize = $maxfilesize * 1000; $maxsitesize = $maxsitesize * 1000; $minrate = $minrate * 1000; $update = null; $resultsCMD = array(); $pidpath = "{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}/hts-in_progress.lock"; if (!is_dir($workingdir)) { @mkdir($workingdir, 0755, true); } @chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid"); @chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid"); @chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid"); @chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid"); if (is_file($pidpath)) { $PID = HyperCacheMirror_pid($pidpath); if ($unix->process_exists($PID)) { events("Scrapping rule ID {$ligne["ID"]} for {$sitename} Process {$PID} already running since " . $unix->PROCESS_TIME_INT($PID), 0, 2, __LINE__); continue; } } @file_put_contents("{$workingdir}/TimeExec", time()); if (is_file("{$workingdir}/hts-cache")) { $update = " --update"; } $cmdline = array(); $cmdline[] = "{$httrack} \"{$sitename}\" --quiet{$update} -%U squid --proxy 127.0.0.1:{$proxyport}"; $cmdline[] = "--stay-on-same-domain -u2 -C1 -I0 -N100 --robots=0 --max-files={$maxfilesize}"; $cmdline[] = "--max-size={$maxsitesize}"; $cmdline[] = "-O \"{$workingdir}\" 2>&1"; squid_admin_enforce(2, "Scrapping {$sitename} using proxy 127.0.0.1:{$proxyport}...", null, __FILE__, __LINE__); $cmd = @implode(" ", $cmdline); if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } exec($cmd, $resultsCMD); if ($GLOBALS["VERBOSE"]) { echo @implode("\n", $resultsCMD); } $dirsize = $unix->DIRSIZE_BYTES($workingdir); $took = $unix->distanceOfTimeInWords($t, time(), true); $dirsizeText = round($dirsize / 1024 / 1000, 2); squid_admin_enforce(2, "Mirror on {$sitename} done took {$took} size={$dirsizeText} MB", null, __FILE__, __LINE__); $logs = mysql_escape_string2(@file_get_contents("{$workingdir}/hts-log.txt")); $q->QUERY_SQL("UPDATE artica_caches_mirror SET \n\t\t\t\tsize='{$dirsize}',`RunEvents`='{$logs}' WHERE ID={$ligne["ID"]}", "artica_backup"); if (!$q->ok) { squid_admin_enforce(1, "MySQL error", $q->mysql_error, __FILE__, __LINE__); } } $took = $unix->distanceOfTimeInWords($t1, time(), true); squid_admin_enforce(2, "{$count} web site(s) scrapped took {$took}", null, __FILE__, __LINE__); }
function item_save() { $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("nginx_exploits_items", "reverse")) { $q->QUERY_SQL("ALTER TABLE `nginx_exploits_items` ADD `reverse` smallint(1) NOT NULL DEFAULT 0, ADD INDEX ( `reverse`)"); } $ID = $_POST["edititem"]; $_POST["pattern"] = mysql_escape_string2(url_decode_special_tool($_POST["pattern"])); if ($ID == 0) { $sql = "INSERT IGNORE INTO nginx_exploits_groups (`groupname`)\n\t\tVALUES ('{$_POST["groupname"]}')"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; return; } $ID = $q->last_id; $sql = "INSERT IGNORE INTO nginx_exploits_items (`groupid`,`enabled`,`pattern`,`token`,`reverse`) VALUES\n\t\t\t\t('{$_POST["groupid"]}','{$_POST["enabled"]}','{$_POST["pattern"]}','{$_POST["token"]}','{$_POST["reverse"]}')"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; return; } return; } $q->QUERY_SQL("UPDATE nginx_exploits_items SET `pattern`='{$_POST["pattern"]}',`token`='{$_POST["token"]}',`reverse`='{$_POST["reverse"]}',\n\t`enabled`='{$_POST["enabled"]}' WHERE ID={$ID}"); if (!$q->ok) { echo $q->mysql_error; return; } }
function rule_save() { $md5 = $_POST["rule"]; $category = $_POST["category"]; $adgroup = $_POST["adgroup"]; $username = $_POST["username"]; $deny = $_POST["deny"]; $noauth = $_POST["noauth"]; $allow = $_POST["allow"]; $addTocat = $_POST["addTocat"]; $maxtime = $_POST["maxtime"]; $ticket = $_POST["ticket"]; $webruleid = $_POST["webruleid"]; $q = new mysql_squid_builder(); if (trim($adgroup) == null) { $adgroup = "*"; } if (!$q->FIELD_EXISTS("ufdb_page_rules", "maxtime")) { $q->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `maxtime` smallint(3) NOT NULL DEFAULT 0,\n\t\t\t\tADD INDEX ( `maxtime` )"); } if (!$q->FIELD_EXISTS("ufdb_page_rules", "allow")) { $q->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `allow` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t\tADD INDEX ( `allow` )"); } if ($md5 == null) { $md5 = md5(serialize($_POST)); $q->QUERY_SQL("INSERT IGNORE INTO ufdb_page_rules \n\t\t\t(`zmd5`,`category`,`adgroup`,`username`,`deny`,`noauth`,`allow`,`addTocat`,`maxtime`,`ticket`,`webruleid`) VALUES\n\t\t\t('{$md5}','{$category}','{$adgroup}','{$username}','{$deny}','{$noauth}','{$allow}','{$addTocat}','{$maxtime}','{$ticket}','{$webruleid}')\n\t\t\t"); } else { $q->QUERY_SQL("UPDATE ufdb_page_rules SET \n\t\t\t`category`='{$category}',\n\t\t\t`adgroup`='{$adgroup}',\n\t\t\t`username`='{$username}',\n\t\t\t`deny`='{$deny}',\n\t\t\t`noauth`='{$noauth}',\n\t\t\t`allow`='{$allow}',\n\t\t\t`addTocat`='{$addTocat}',\n\t\t\t`maxtime`='{$maxtime}',\n\t\t\t`webruleid`='{$webruleid}',\n\t\t\t`ticket`='{$ticket}'\n\t\t\tWHERE `zmd5`='{$md5}'"); } if (!$q->ok) { echo $q->mysql_error; } $sock = new sockets(); $sock->getFrameWork("squid.php?weberror-cache-remove=yes"); $sock->getFrameWork("ufdbguard.php?remove-sessions-caches=yes"); }
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(); }
function parseTemplate_sendemail_perform($smtp_sender = null, $ARRAY, $ticket = false, $SquidGuardIPWeb = null) { ini_set('html_errors', 0); ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', ''); ini_set('error_append_string', ''); include_once dirname(__FILE__) . '/ressources/class.templates.inc'; include_once dirname(__FILE__) . '/ressources/class.ldap.inc'; include_once dirname(__FILE__) . '/ressources/class.users.menus.inc'; include_once dirname(__FILE__) . "/ressources/class.sockets.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php"; if (!$ticket) { if ($smtp_sender == null) { $tpl = new templates(); return $tpl->_ENGINE_parse_body("{give_your_email_address}"); } } $main_array = base64_encode(serialize($ARRAY)); $tpl = new templates(); $HOST = $ARRAY["HOST"]; $clientname = $ARRAY["clientname"]; if ($clientname != null) { $clientname = "/{$clientname}"; } $Subject = "Web filter request from an user: {$HOST}{$clientname}"; $zDate = date('Y-m-d H:i:s'); $q = new mysql_squid_builder(); $URL = $ARRAY["URL"]; $REASONGIVEN = $ARRAY["REASONGIVEN"]; unset($ARRAY["SquidGuardIPWeb"]); unset($ARRAY["URL"]); unset($ARRAY["REASONGIVEN"]); while (list($a, $b) = each($ARRAY)) { $body[] = "{$a}\t:{$b}"; } $text = mysql_escape_string2(@implode($body, "\r\n")); $Subject = mysql_escape_string2($Subject); $URL = mysql_escape_string2($URL); $REASONGIVEN = mysql_escape_string2($REASONGIVEN); $md5 = md5(serialize($ARRAY) . "{$Subject} {$smtp_sender}"); $ticket_val = 0; if ($ticket) { $ticket_val = 1; } $tablename = "ufdb_smtp"; if ($q->COUNT_ROWS("ufdb_smtp") == 0) { $q->QUERY_SQL("DROP TABLE ufdb_smtp"); } $sql = "CREATE TABLE IF NOT EXISTS `ufdb_smtp` (\n\t`zmd5` varchar(90) NOT NULL,\n\t`zDate` datetime NOT NULL,\n\t`Subject` varchar(255) NOT NULL,\n\t`content` varchar(255) NOT NULL,\n\t`main_array` TEXT,\n\t`URL` varchar(255) NOT NULL,\n\t`REASONGIVEN` varchar(255) NOT NULL,\n\t`sender` varchar(128) NOT NULL,\n\t`retrytime` smallint(1) NOT NULL,\n\t`ticket` smallint(1) NOT NULL,\n\t`SquidGuardIPWeb` varchar(255),\n\tPRIMARY KEY (`zmd5`),\n\tKEY `zDate` (`zDate`),\n\tKEY `Subject` (`Subject`),\n\tKEY `sender` (`sender`),\n\tKEY `ticket` (`ticket`),\n\tKEY `retrytime` (`retrytime`)\n\t\n\t) ENGINE=MYISAM;"; $q->QUERY_SQL($sql); if (!$q->ok) { writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__); echo $q->mysql_error; return; } if (!$q->FIELD_EXISTS("ufdb_smtp", "SquidGuardIPWeb")) { $q->QUERY_SQL("ALTER TABLE `ufdb_smtp` ADD `SquidGuardIPWeb` varchar(255)"); } if (!$q->FIELD_EXISTS("ufdb_smtp", "ticket")) { $q->QUERY_SQL("ALTER TABLE `ufdb_smtp` ADD `ticket` smallint(1) NOT NULL"); } if (!$q->FIELD_EXISTS("ufdb_smtp", "main_array")) { $q->QUERY_SQL("ALTER TABLE `ufdb_smtp` ADD `main_array` TEXT"); } $q->QUERY_SQL("INSERT IGNORE INTO ufdb_smtp (`zmd5`,`zDate`,`Subject`,`content`,`sender`,`URL`,\n\t\t\t`REASONGIVEN`,`retrytime`,`SquidGuardIPWeb`,`ticket`,`main_array`) VALUES\n\t\t\t('{$md5}',NOW(),'{$Subject}','{$text}','{$smtp_sender}','{$URL}','{$REASONGIVEN}','0','{$SquidGuardIPWeb}','{$ticket_val}','{$main_array}')"); if (!$q->ok) { writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__); return $q->mysql_error_html(); return false; } $sock = new sockets(); $sock->getFrameWork("squidguardweb.php?smtp-notifs=yes"); $tpl = new templates(); return $tpl->_ENGINE_parse_body("{your_query_was_sent_to_administrator}"); return true; }
function infra_section() { include_once dirname(__FILE__) . "/ressources/class.squid.inc"; $users = new usersMenus(); $sock = new sockets(); $tpl = new templates(); $q = new mysql_squid_builder(); $icon = "arrow-right-24.png"; $SSLColor = "#000000"; $icon_ssl = "arrow-right-24.png"; $icon_ssl_enc = "arrow-right-24.png"; $ssl_enc_color = "#000000"; $GotoSSLEncrypt = "GotoSSLEncrypt()"; $squid = new squidbee(); $EnableArticaHotSpot = intval($sock->GET_INFO("EnableArticaHotSpot")); $EnableIntelCeleron = intval($sock->GET_INFO("EnableIntelCeleron")); $COUNT_DE_CACHES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_CACHES")); $COUNT_DE_MEMBERS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/MEMBERS_COUNT")); $SquidBoosterEnable = intval($sock->GET_INFO("SquidBoosterEnable")); $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); if (!is_numeric($SquidCacheLevel)) { $SquidCacheLevel = 4; } $HyperCacheStoreID = intval($sock->GET_INFO("HyperCacheStoreID")); $EnableSS5 = intval($sock->GET_INFO("EnableSS5")); $EnableRDPProxy = intval($sock->GET_INFO("EnableRDPProxy")); $PrivoxyEnabled = intval($sock->GET_INFO("PrivoxyEnabled")); $EnableParentProxy = intval($sock->GET_INFO("EnableParentProxy")); if (!$q->FIELD_EXISTS("proxy_ports", "UseSSL")) { $q->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `UseSSL` smallint(1) NOT NULL DEFAULT '0'"); if (!$q->ok) { echo $q->mysql_error_html(); } } $sql = "SELECT COUNT(*) as tcount FROM proxy_ports WHERE UseSSL=1 AND enabled=1"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { echo $q->mysql_error_html(); } $CountOfSSL = intval($ligne["tcount"]); $ssl_rules_js = "GotoSSLRules()"; $WHY_SSL_RULES_DISABLED = null; if ($CountOfSSL == 0) { $icon_ssl = "arrow-right-24-grey.png"; $icon_ssl_enc = $icon_ssl; $SSLColor = "#898989"; $ssl_enc_color = $SSLColor; $GotoSSLEncrypt = "blur()"; $ssl_rules_js = "blur()"; $WHY_SSL_RULES_DISABLED = "<hr>{WHY_SSL_RULES_DISABLED}"; $decrypted_ssl_websites = "<tr>\n\t\t<td valign='middle' style='width:25px'>\n\t\t<img src='img/arrow-right-24-grey.png'>\n\t\t</td>\n\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>{decrypted_ssl_websites}</td>\n\t\t</tr>"; $ssl_rules = "<tr>\n\t\t<td valign='middle' style='width:25px'>\n\t\t<img src='img/arrow-right-24-grey.png'>\n\t\t</td>\n\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>{ssl_rules}</td>\n\t\t</tr>"; } else { if ($squid->SSL_BUMP_WHITE_LIST == 1) { $decrypted_ssl_websites = "<tr>\n\t\t\t<td valign='middle' style='width:25px'>\n\t\t\t\t<img src='img/{$icon_ssl}'>\n\t\t\t</td>\n\t\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>" . texttooltip("{decrypted_ssl_websites}", null, "GotoSSLEncrypt()") . "</td>\n\t\t\t</tr>"; } else { $decrypted_ssl_websites = "<tr>\n\t\t\t<td valign='middle' style='width:25px'>\n\t\t\t<img src='img/arrow-right-24-grey.png'>\n\t\t\t</td>\n\t\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>{decrypted_ssl_websites}</td>\n\t\t\t</tr>"; } } $sslshitelist = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_ssl}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>" . texttooltip("{ssl_whitelist}", "position:left:{SSL_BUMP_WL}", "GotoSquidSSLWL()") . "</td>\n\t</tr>"; $ssl_rules = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_ssl}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>" . texttooltip("{ssl_rules}", "{ssl_rules}{$WHY_SSL_RULES_DISABLED}", $ssl_rules_js) . "</td>\n\t</tr>"; $tr[] = "<table style='width:100%'>\n\t<tr>\n\t<td valign='middle' colspan=2 style='font-size:22px;font-weight:bold'>{infrastructure}:</td>\n\t</tr>"; $icon_ports = "arrow-right-24.png"; $explain_ports = "{dashboard_listen_ports_explain}<br>{dashboard_listen_ports_explain2}"; $js_ports = "GotoSquidPorts()"; $color_port = "black"; if ($EnableArticaHotSpot == 1) { $icon_ports = "arrow-right-24-grey.png"; $explain_ports = "{section_disabled_hotsport}"; $js_ports = "blur();"; $color_port = "#898989"; } $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_ports}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_port}'>" . texttooltip("{listen_ports}", "position:left:{$explain_ports}", $js_ports) . "</td>\n\t</tr>"; $ssl_options = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_ssl}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$SSLColor}'>" . texttooltip("{ssl_options}", null, "Loadjs('squid.ssl.center.php?js=yes')") . "</td>\n\t</tr>"; if (!$squid->IS_35) { $tr[] = $decrypted_ssl_websites; $tr[] = $sslshitelist; $tr[] = $ssl_options; } else { $tr[] = $ssl_rules; } $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/arrow-right-24.png'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:black'>" . texttooltip("{squid_templates_error}", "{squid_templates_error_explain}", "GotoSquidTemplatesErrors()") . "</td>\n\t</tr>"; $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'> </td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:black'>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td valign='middle' style='width:16px'>\n\t\t\t<img src='img/arrow-right-16.png'></td>\n\t\t\t<td valign='middle' style='font-size:16px;width:99%;color:black'>" . texttooltip("{ftp_template}", "{ftp_template_error_explain}", "GotoSquidTemplateFTP()") . "</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t\n\t\t\t</td>\n\t</tr>"; $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/arrow-right-24.png'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:black'>" . texttooltip("{timeouts}", null, "GotoSquidTimeOuts()") . "</td>\n\t</tr>"; $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/arrow-right-24.png'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:black'>" . texttooltip("{dns_settings}", null, "GotoSquidDNSsettings()") . "</td>\n\t</tr>"; $tr[] = "<tr><td colspan=2> </td></tr>"; $squid_parent_proxy_color = "black"; $squid_parent_proxy_icon = "arrow-right-24.png"; $squid_parent_proxy_js = "GotoSquidParentProxy()"; if ($EnableParentProxy == 0) { $squid_parent_proxy_icon = "arrow-right-24-grey.png"; $squid_parent_proxy_color = "#898989"; $squid_parent_proxy_text = " <span style='font-size:14px'>({disabled})</span>"; } if ($PrivoxyEnabled == 1) { $squid_parent_proxy_icon = "arrow-right-24-grey.png"; $squid_parent_proxy_color = "#898989"; $squid_parent_proxy_text = " <span style='font-size:14px'>({disabled} - {APP_PRIVOXY})</span>"; $squid_parent_proxy_js = "blur()"; } $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$squid_parent_proxy_icon}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$squid_parent_proxy_color}'>" . texttooltip("{squid_parent_proxy}{$squid_parent_proxy_text}", "{squid_parent_proxy_explain}", $squid_parent_proxy_js) . "</td>\n\t</tr>"; $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/arrow-right-24.png'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:black'>" . texttooltip("X-Forwarded-For", "{follow_x_forwarded_for_explain}", "GotoFollowXforwardedFor()") . "</td>\n\t</tr>"; $ecap_gzip_icon = "arrow-right-24.png"; $ecap_gzip_color = "#000000"; $ecap_gzip_explain = null; $EnableeCapGzip = intval($sock->GET_INFO("EnableeCapGzip")); if ($EnableeCapGzip == 0) { $ecap_gzip_color = "#898989"; $ecap_gzip_icon = "arrow-right-24-grey.png"; $ecap_gzip_explain = " <span style='font-size:12px'>({disabled})</span>"; } $tr[] = "\n\t<tr>\n\t\t<td valign='middle' style='width:25px'>\n\t\t\t<img src='img/{$ecap_gzip_icon}'>\n\t\t</td>\n\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$ecap_gzip_color}'>" . texttooltip("{http_compression}{$ecap_gzip_explain}", "{http_compression_explain}", "GoToeCapGzip()") . "</td>\n\t</tr>"; $SLAVE_IP = null; $icon_failover = "arrow-right-24.png"; $js_failover = "GotoFailover()"; $color_failover = "black"; $MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings"))); if (isset($MAIN["SLAVE"])) { $SLAVE_IP = $MAIN["SLAVE"]; } if ($SLAVE_IP == null) { $icon_failover = "arrow-right-24-grey.png"; $color_failover = "#898989"; $text_failover = " <span style='font-size:12px'>({disabled})</span>"; } else { $text_failover = " <span style='font-size:12px'>({slave_ip} {$SLAVE_IP})</span>"; } if (!$users->CORP_LICENSE) { $icon_failover = "arrow-right-24-grey.png"; $js_failover = "blur()"; $color_failover = "#898989"; $text_failover = " <span style='font-size:12px'>({no_license})</span>"; } $tr[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_failover}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_failover}'>" . texttooltip("{failover}{$text_failover}", "{failover_explain}", "{$js_failover}") . "</td>\n\t</tr>"; $img_hostpot = "arrow-right-24.png"; $explain_hostpot = "{dashboard_hotspot}"; $js_hostpot = "GotoHostpotv3()"; $color_hotspot = "black"; $TCP_LIST_NICS = TCP_LIST_NICS(); if ($TCP_LIST_NICS < 2) { $img_hostpot = "arrow-right-24-grey.png"; $explain_hostpot = "<div style='background-color:white;color:#d32d2d;margin:10px;padding:10px'>{dashboard_hotspot_nonic}</div>"; $js_hostpot = "blur();"; $color_hotspot = "#898989"; } if ($EnableArticaHotSpot == 0) { $img_hostpot = "arrow-right-24-grey.png"; $color_hotspot = "#898989"; } $tr[] = "\n<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$img_hostpot}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_hotspot}'>" . texttooltip("HotSpot", $explain_hostpot, $js_hostpot) . "</td>\n</tr>"; $tr[] = "</table>"; // *************************************************************************************************** $tr2[] = "<table style='width:100%'>"; $tr2[] = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='middle' colspan=2 style='font-size:22px;font-weight:bold'>{system_pcaches}:</td>\n\t</tr>"; $Color = "black"; $icon = "Database24.png"; $hypercache_mirror_Color = "black"; $icon_center_cache_explain = null; $hypercache_mirror_icon = "arrow-right-24.png"; $js_cache_status = "GoToCaches()"; $icon_cache_status = "Database24.png"; $icon_cache_explain = null; $color_cache_status = "black"; $js = "GoToCachesCenter()"; if (!$users->CORP_LICENSE) { $icon_center_cache_explain = "<span style='font-size:12px'> ({no_license})</span>"; $icon = "Database24-grey.png"; $Color = "#898989"; $js = "blur();"; } if ($COUNT_DE_CACHES > 0) { if ($COUNT_DE_MEMBERS > 15) { if ($COUNT_DE_CACHES < 20000) { $icon = "alert-24.png"; } } } if ($SquidCacheLevel == 0) { $icon = "Database24-grey.png"; $icon_cache_status = $icon; $hypercache_mirror_icon = "arrow-right-24-grey.png"; $icon_cache_explain = "<span style='font-size:12px'> ({disabled})</span>"; $icon_center_cache_explain = "<span style='font-size:12px'> ({disabled})</span>"; $js_cache_status = "blur();"; $Color = "#898989"; $color_cache_status = $Color; $hypercache_mirror_Color = $Color; $js = "blur();"; $SquidBoosterEnable = 0; $EnableRockCache = 0; $HyperCacheStoreID = 0; } $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_cache_status}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_cache_status}'>" . texttooltip("{caches_status}{$icon_cache_explain}", "{your_proxy_caches_explain}", $js_cache_status) . "</td>\n\t</tr>"; $tr2[] = "<tr>\n\t\t<td valign='middle' style='width:25px'>\n\t\t<img src='img/{$icon}'>\n\t\t</td>\n\t\t<td valign='middle' style='font-size:18px;width:99%;color:{$Color}'>" . texttooltip("{caches_center}{$icon_center_cache_explain}", "{caches_center_explain}", "{$js}") . "</td>\n\t</tr>"; $icon_booster_explain = null; $EnableRockCache = intval($sock->GET_INFO("EnableRockCache")); $icon_booster = "Database24.png"; $icon_rock = "Database24.png"; $js_booster = "GotoProxyBooster()"; $Color_booster = "black"; $Color_rock = "black"; $js_rock = "GoToRock()"; if ($SquidBoosterEnable == 0) { $icon_booster = "Database24-grey.png"; $icon_booster_explain = "<span style='font-size:12px'> ({disabled})</span>"; } if (!$users->CORP_LICENSE) { $icon_booster = "Database24-grey.png"; $icon_rock = "Database24-grey.png"; $js_booster = "blur();"; $Color_booster = "#898989"; $Color_rock = "#898989"; $EnableRockCache = 0; $js_rock = "blur()"; $icon_booster_explain = "<span style='font-size:12px'> ({no_license})</span>"; $icon_rock_explain = "<span style='font-size:12px'> ({no_license})</span>"; $icon_caches_rules_explain = "<span style='font-size:12px'> ({no_license})</span>"; } $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_booster}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$Color_booster}'>" . texttooltip("{squid_booster}{$icon_booster_explain}", null, "GotoProxyBooster()") . "</td>\n\t</tr>"; if ($users->CORP_LICENSE) { if ($EnableRockCache == 0 or $SquidCacheLevel == 0) { $icon_rock = "Database24-grey.png"; $Color_rock = "#898989"; $icon_rock_explain = "<span style='font-size:12px'> ({disabled})</span>"; } } if ($SquidCacheLevel == 0) { $icon_rock = "Database24-grey.png"; $Color_rock = "#898989"; $icon_rock_explain = "<span style='font-size:12px'> ({disabled})</span>"; $icon_caches_rules_explain = "<span style='font-size:12px'> ({disabled})</span>"; $icon_caches_rules = "arrow-right-24-grey.png"; $Color_caches_rules = "#898989"; } $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t\t<img src='img/{$icon_rock}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$Color_rock}'>" . texttooltip("{rock_store}{$icon_rock_explain}", null, $js_rock) . "</td>\n\t</tr>"; $tr2[] = "<tR><td colspan=2> </td></tr>"; $icon = "arrow-right-24.png"; $Color = "black"; $icon = "arrow-right-24.png"; $SquidVersion = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidVersion"); if (preg_match("#^3\\.5#", $SquidVersion)) { $HyperCacheCompatible = true; } if (preg_match("#^4\\.#", $SquidVersion)) { $HyperCacheCompatible = true; } if ($HyperCacheStoreID == 0) { $icon = "arrow-right-24-grey.png"; $Color = "#898989"; } $explain = "{HyperCache_explain}"; $js_hypercache = "GoToHyperCache()"; if (!$HyperCacheCompatible) { $icon = "arrow-right-24-grey.png"; $js_hypercache = "blur()"; $Color = "#898989"; $hypercache_explain = "{ERROR_SQUID_MUST_35}"; } if ($EnableIntelCeleron == 1) { $icon = "arrow-right-24-grey.png"; $js_hypercache = "blur()"; $Color = "#898989"; $hypercache_explain = "{ERROR_FEATURE_CELERON}"; } $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/arrow-right-24.png'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%'>" . texttooltip("{cache_level}", null, "GoToCachesLevel()") . "</td>\n\t</tr>"; $js_caches_rules = "GotoSquidCachesRules()"; $Color_caches_rules = "black"; $icon_caches_rules = "arrow-right-24.png"; if (!$users->CORP_LICENSE) { $icon_caches_rules = "arrow-right-24-grey.png"; $Color_caches_rules = "#898989"; $js_caches_rules = null; } $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_caches_rules}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$Color_caches_rules}'>" . texttooltip("{caches_rules}{$icon_caches_rules_explain}", "{refresh_pattern_intro}", "{$js_caches_rules}") . "</td>\n\t</tr>"; $WindowsUpdateCacher_icon = "arrow-right-24.png"; $WindowsUpdateCacher_explain = null; $WindowsUpdateCacher_color = "black"; $EnableUfdbGuard = intval($sock->GET_INFO("EnableUfdbGuard")); $WindowsUpdateCaching = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCaching")); if ($EnableUfdbGuard == 0) { $WindowsUpdateCaching = 0; } if ($WindowsUpdateCaching == 0) { $WindowsUpdateCacher_icon = "arrow-right-24-grey.png"; $WindowsUpdateCacher_color = "#898989"; $WindowsUpdateCacher_explain = " <span style='font-size:12px'> ({disabled})</span>"; } $webcopy_color = "black"; $webcopy_icon = "arrow-right-24.png"; $webcopy_explain = null; $webcopy_js = "GotoWebCopy()"; $HTTrackInSquid = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HTTrackInSquid")); if ($HTTrackInSquid == 0) { $webcopy_icon = "arrow-right-24-grey.png"; $webcopy_color = "#898989"; $webcopy_explain = " <span style='font-size:12px'> ({disabled})</span>"; } if (!is_file("/usr/bin/httrack")) { $webcopy_icon = "arrow-right-24-grey.png"; $webcopy_color = "#898989"; $webcopy_explain = " <span style='font-size:12px'> ({not_installed})</span>"; } $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$webcopy_icon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$webcopy_color}'>" . texttooltip("WebCopy{$webcopy_explain}", "{WebCopy_task_explain}", $webcopy_js) . "</td>\n\t</tr>"; $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$WindowsUpdateCacher_icon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$WindowsUpdateCacher_color}'>" . texttooltip("Windows Updates{$WindowsUpdateCacher_explain}", "{enable_windows_updates_cache_enforcement_explain}", "GotoWindowsUpdate()") . "</td>\n\t</tr>"; $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$Color}'>" . texttooltip("HyperCache{$icon_cache_explain}", "{$hypercache_explain}", $js_hypercache) . "</td>\n\t</tr>"; $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$hypercache_mirror_icon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$hypercache_mirror_Color}'>" . texttooltip("HyperCache mirror{$icon_cache_explain}", "{HyperCache_mirror_explain}", "GoToHyperCacheMirror()") . "</td>\n\t</tr>"; $tr2[] = "<tR><td colspan=2> </td></tr>\n\t<tr>\n\t<td valign='middle' colspan=2 style='font-size:22px;font-weight:bold'>{gateway_services}:</td>\n\t</tr>"; $img_ss5 = "arrow-right-24.png"; $explain_ss5 = "{APP_SS5_ABOUT}"; $js_ss5 = "GoToSS5()"; $color_ss5 = "black"; $img_rdp = "arrow-right-24.png"; $explain_rdp = "{APP_RDPPROXY}"; $js_rdp = "GotToRDPPROX()"; $color_rdp = "black"; if ($EnableSS5 == 0) { $img_ss5 = "arrow-right-24-grey.png"; $explain_ss5 = "{APP_SS5_ABOUT}"; $error_ss5 = " <span style='font-size:12px'>{disabled}</span>"; $js_ss5 = "GoToSS5()"; $color_ss5 = "#898989"; } if (!is_file("/usr/sbin/ss5")) { $img_ss5 = "arrow-right-24-grey.png"; $explain_ss5 = "{APP_SS5_ABOUT}"; $error_ss5 = " <span style='font-size:12px'>{not_installed}</span>"; $js_ss5 = null; $color_ss5 = "#898989"; } if (!is_file("/var/lib/ss5/ss5/mod_socks4.so")) { $img_ss5 = "arrow-right-24-grey.png"; $explain_ss5 = "{APP_SS5_ABOUT}"; $error_ss5 = " <span style='font-size:12px'>{not_installed}</span>"; $js_ss5 = null; $color_ss5 = "#898989"; } if ($EnableRDPProxy == 0) { $img_rdp = "arrow-right-24-grey.png"; $explain_rdp = "{APP_SS5_ABOUT}"; $error_rdp = " <span style='font-size:12px'>{disabled}</span>"; $js_rdp = "GotToRDPPROX()"; $color_rdp = "#898989"; } if (!$users->RDPPROXY_INSTALLED) { $img_rdp = "arrow-right-24-grey.png"; $explain_rdp = "{APP_SS5_ABOUT}"; $error_rdp = " <span style='font-size:12px'>{not_installed}</span>"; $js_rdp = null; $color_rdp = "#898989"; } $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'><img src='img/{$img_ss5}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_ss5}'>" . texttooltip("{APP_SS5}{$error_ss5}", $explain_ss5, $js_ss5) . "</td>\n\t</tr>"; $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'><img src='img/{$img_rdp}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_rdp}'>" . texttooltip("{APP_RDPPROXY}{$error_rdp}", "position:right:{APP_RDPPROXY}", $js_rdp) . "</td>\n\t</tr>"; $EnableSecureGateway = intval($sock->GET_INFO("EnableSecureGateway")); $icon_secure_gateway = "arrow-right-24.png"; $color_secure_gateway = "black"; $text_secure_gateway = null; if ($EnableSecureGateway == 0) { $icon_secure_gateway = "arrow-right-24-grey.png"; $color_secure_gateway = "#898989"; $text_secure_gateway = " <span style='font-size:12px'>({disabled})</span>"; } "arrow-right-24-grey.png"; $tr2[] = "<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$icon_secure_gateway}'></td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$color_secure_gateway}'>" . texttooltip("{secure_gateway}{$text_secure_gateway}", "{secure_gateway_explain}", "GotoGatewaySecure()") . "</td>\n\t</tr>"; $Transmission_icon = "arrow-right-24.png"; $Transmission_Color = "black"; $Transmission_js = "GoToTransmissionDaemon()"; $EnableTransMissionDaemon = intval($sock->GET_INFO("EnableTransMissionDaemon")); $UpdateUtilityWizard = intval($sock->GET_INFO("UpdateUtilityWizard")); if (!is_file("/usr/bin/transmission-daemon")) { $Transmission_icon = "arrow-right-24-grey.png"; $Transmission_Color = "#898989"; $Transmission_js = "blur();"; } else { if ($EnableTransMissionDaemon == 0) { $Transmission_icon = "arrow-right-24-grey.png"; $Transmission_Color = "#898989"; } } $UpdateUtilityIcon = "arrow-right-24.png"; $UpdateUtilityColor = "black"; if ($UpdateUtilityWizard == 0) { $UpdateUtilityIcon = "arrow-right-24-grey.png"; $UpdateUtilityColor = "#898989"; } if (!is_file("/etc/UpdateUtility/UpdateUtility-Console")) { $UpdateUtilityIcon = "arrow-right-24-grey.png"; $UpdateUtilityColor = "#898989"; } $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$Transmission_icon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$Transmission_Color}'>" . texttooltip("{bittorrent_service}", "{bittorrent_service_explain}", "GoToTransmissionDaemon()") . "</td>\n\t</tr>"; $tr2[] = "\n\t<tr>\n\t<td valign='middle' style='width:25px'>\n\t<img src='img/{$UpdateUtilityIcon}'>\n\t</td>\n\t<td valign='middle' style='font-size:18px;width:99%;color:{$UpdateUtilityColor}'>" . texttooltip("{APP_KASPERSKY_UPDATE_UTILITY}", "{APP_KASPERSKY_UPDATE_UTILITY}", "GoToUpdateUtility()") . "</td>\n\t</tr>"; $tr2[] = "</table>"; $final = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td style='width:50%' valign='top'>" . $tpl->_ENGINE_parse_body(@implode("\n", $tr)) . "</td>\n\t\t<td style='width:50%' valign='top'>" . $tpl->_ENGINE_parse_body(@implode("\n", $tr2)) . "</td>\n\t</tr>\n\t</table>\n\t"; $filename = "/usr/share/artica-postfix/ressources/logs/web/cache/" . md5("INFRASECTION" . $tpl->language . $_SESSION["uid"]); @file_put_contents($filename, $final); echo $final; }
function acl_rule_save() { $q = new mysql_squid_builder(); $ID = $_POST["ID"]; $aclname = $_POST["aclname-save"]; if (!isset($_POST["aclgroup"])) { $_POST["aclgroup"] = 0; } if (!isset($_POST["aclgpid"])) { $_POST["aclgpid"] = 0; } if (!isset($_POST["aclport"])) { $_POST["aclport"] = 0; } if (is_numeric($_POST["aclport"])) { $_POST["aclport"] = 0; } $aclname = str_replace("'", "`", $aclname); if (!$q->FIELD_EXISTS("webfilters_sqacls", "aclgroup")) { $q->QUERY_SQL("ALTER TABLE `webfilters_sqacls` ADD `aclgroup` smallint(1) NOT NULL,ADD INDEX(`aclgroup`)"); } if (!$q->FIELD_EXISTS("webfilters_sqacls", "aclgpid")) { $q->QUERY_SQL("ALTER TABLE `webfilters_sqacls` ADD `aclgpid` INT UNSIGNED NOT NULL,ADD INDEX(`aclgpid`)"); } if (!$q->FIELD_EXISTS("webfilters_sqacls", "aclport")) { $q->QUERY_SQL("ALTER TABLE `webfilters_sqacls` ADD `aclport` smallint(5) NOT NULL,\n\t\tADD INDEX(`aclport`)"); } if (!$q->FIELD_EXISTS("webfilters_sqacls", "PortDirection")) { $q->QUERY_SQL("ALTER TABLE `webfilters_sqacls` ADD `PortDirection` smallint(1) NOT NULL DEFAULT '0',ADD INDEX(`PortDirection`)"); } if ($ID < 0) { $q->CheckTables(); $sql = "SELECT xORDER FROM webfilters_sqacls WHERE ORDER BY xORDER DESC LIMIT 0,1"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $xORDER = $ligne["xORDER"]; if (!is_numeric($xORDER)) { $xORDER = 0; } $xORDER = $xORDER + 1; $aclport = trim($_POST["aclport"]); if (!is_numeric($aclport)) { $aclport = 0; } $sql = "INSERT INTO webfilters_sqacls (aclname,enabled,acltpl,xORDER,aclport,aclgroup,aclgpid) \n\t\tVALUES ('{$aclname}',1,'','{$xORDER}','{$aclport}','{$_POST["aclgroup"]}','{$_POST["aclgpid"]}')"; } $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\nLine:" . __LINE__ . "\nfunction\n" . __FUNCTION__ . "\nsql:{$sql}"; return; } }
function test_sources() { $unix = new unix(); if (!$GLOBALS["FORCE"]) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "pidTime: {$pidTime}\n"; } $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx Already Artica task running PID {$pid} since {$time}mn\n"; } return; } $pidTimeEx = $unix->file_time_min($pidTime); if ($pidTime < 15) { return; } @file_put_contents($pidfile, getmypid()); @unlink($pidTime); @file_put_contents($pidTime, time()); } $echo = $unix->find_program("echo"); $nc = $unix->find_program("nc"); $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("reverse_sources", "isSuccess")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `isSuccess` smallint(1) NOT NULL DEFAULT '1', ADD INDEX ( `isSuccess`)"); } if (!$q->FIELD_EXISTS("reverse_sources", "isSuccesstxt")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `isSuccesstxt` TEXT"); } if (!$q->FIELD_EXISTS("reverse_sources", "isSuccessTime")) { $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `isSuccessTime` datetime"); } $sql = "SELECT * FROM reverse_sources"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $ipaddr = $ligne["ipaddr"]; $ID = $ligne["ID"]; $port = $ligne["port"]; $IsSuccess = 1; $linesrows = array(); $cmdline = "{$echo} -e -n \"GET / HTTP/1.1\\r\\n\" | {$nc} -q 2 -v {$ipaddr} {$port} 2>&1"; if ($GLOBALS["VERBOSE"]) { echo "{$ipaddr}: {$cmdline}\n"; } exec($cmdline, $linesrows); while (list($a, $b) = each($linesrows)) { if ($GLOBALS["VERBOSE"]) { echo "{$ipaddr}: {$b}\n"; } if (preg_match("#failed#", $b)) { $IsSuccess = 0; } } reset($linesrows); $linesrowsText = mysql_escape_string2(base64_encode(serialize($linesrows))); $date = date("Y-m-d H:i:s"); $q->QUERY_SQL("UPDATE reverse_sources SET isSuccess={$IsSuccess},isSuccesstxt='{$linesrowsText}',isSuccessTime='{$date}' WHERE ID={$ID}"); } }
public function getDaysInWeek($weekNumber, $year) { if (isset($GLOBALS["getDaysInWeek{$weekNumber}{$year}"])) { return $GLOBALS["getDaysInWeek{$weekNumber}{$year}"]; } $sql = "SELECT zDate,WeekDay FROM tables_day WHERE WeekNum={$weekNumber} AND YEAR(zDate)='{$year}'"; $q = new mysql_squid_builder(); $results = $q->QUERY_SQL($sql); if (preg_match("#Unknown column#i", $q->mysql_error)) { if (!$q->FIELD_EXISTS("tables_day", "WeekDay")) { $q->QUERY_SQL("ALTER TABLE `tables_day` ADD `WeekDay` SMALLINT( 2 ) NOT NULL,ADD INDEX ( `WeekDay`)"); $sock = new sockets(); $sock->GET_INFO("squid.php?weekdaynum=yes"); } if (!$q->FIELD_EXISTS("tables_day", "WeekNum")) { $q->QUERY_SQL("ALTER TABLE `tables_day` ADD `WeekNum` SMALLINT( 2 ) NOT NULL,ADD INDEX ( `WeekNum`)"); $sock = new sockets(); $sock->GET_INFO("squid.php?weekdaynum=yes"); } $results = $q->QUERY_SQL($sql); } if (!$q->ok) { echo $q->mysql_error; return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $time = strtotime($ligne["zDate"] . " 00:00:00"); $dayTimes[$ligne["WeekDay"]] = $time; } $GLOBALS["getDaysInWeek{$weekNumber}{$year}"] = $dayTimes; return $dayTimes; }
function accounts_save() { $q = new mysql_squid_builder(); $users = new usersMenus(); while (list($num, $ligne) = each($_POST)) { $_POST[$num] = url_decode_special_tool($ligne); } if (!$q->FIELD_EXISTS("rdpproxy_items", "domain")) { $q->QUERY_SQL("ALTER TABLE `rdpproxy_items` ADD `domain` VARCHAR(128)"); } $ID = $_POST["ID"]; if ($ID > 0) { $sql = "UPDATE rdpproxy_items SET \n\t\t\t`service` ='{$_POST["service"]}',\n\t\t\t`rhost` ='{$_POST["rhost"]}',\n\t\t\t`username` ='{$_POST["username"]}',\n\t\t\t`domain` ='{$_POST["domain"]}',\n\t\t\t`password` ='{$_POST["password"]}',\n\t\t\t`servicetype` ='{$_POST["servicetype"]}',\n\t\t\t`serviceport` ='{$_POST["serviceport"]}',\n\t\t\t`alive` ='{$_POST["alive"]}',\n\t\t\t`is_rec` ='{$_POST["is_rec"]}' WHERE ID={$_POST["ID"]}"; } else { if (!$users->CORP_LICENSE) { if ($q->COUNT_ROWS("rdpproxy_items") > 50) { echo base64_decode("TGljZW5zZSBlcnJvciBNQVg6NTAK"); return; } } $sql = "INSERT INTO rdpproxy_items (`userid`,\t`service`,`rhost`,`username`,`password`,`servicetype`,\n\t\t\t`serviceport`,`alive`,`is_rec`,`domain`)\n\t\tVALUES ('{$_POST["userid"]}','{$_POST["service"]}','{$_POST["rhost"]}',\n\t\t\t'{$_POST["username"]}',\n\t\t\t'{$_POST["password"]}',\n\t\t\t'{$_POST["servicetype"]}',\n\t\t\t'{$_POST["serviceport"]}',\n\t\t\t'{$_POST["alive"]}',\n\t\t\t'{$_POST["is_rec"]}','{$_POST["domain"]}')"; } $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}"; } $sock = new sockets(); $sock->getFrameWork("rdpproxy.php?restart-auth=yes"); }
function build_defaults() { $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("artica_caches", "OtherDomains", "artica_backup")) { $sql = "ALTER TABLE `artica_caches` ADD `OtherDomains` TEXT"; $q->QUERY_SQL($sql, "artica_backup"); } if (!$q->FIELD_EXISTS("artica_caches", "MaxSizeBytes", "artica_backup")) { $sql = "ALTER TABLE `artica_caches` ADD `MaxSizeBytes` BIGINT UNSIGNED NOT NULL DEFAULT '3145728000'"; $q->QUERY_SQL($sql, "artica_backup"); } }