function ParseResolvMX() { $sock = new sockets(); $WhiteListResolvMX = $sock->GET_INFO("WhiteListResolvMX"); if (!is_numeric($WhiteListResolvMX)) { return null; } if ($WhiteListResolvMX == 0) { return null; } if (!function_exists("getmxrr")) { echo "getmxrr() no such function\n"; return; } $sql = "SELECT sender FROM postfix_global_whitelist WHERE enabled=1 ORDER BY sender"; if ($GLOBALS["VERBOSE"]) { echo $sql . "\n"; } $q = new mysql(); if (!$q->TestingConnection()) { echo "ParseResolvMX()/" . basename(__FILE__) . " Connection to MySQL server failed...\n"; return; } $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } $q = new mysql(); $sql = "SELECT * FROM postfix_whitelist_con"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo "{$q->mysql_error}\n"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $WHITELISTED[$ligne["ipaddr"]] = true; $WHITELISTED[$ligne["hostname"]] = true; } $count_whitelisted_before = count($WHITELISTED); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $domain = trim($ligne["sender"]); if ($domain == null) { continue; } if (preg_match("#@(.+)#", $domain, $re)) { $domain = $re[1]; } if (strpos($domain, "*") > 0) { continue; } $array_mx = resolvMX($domain); if (count($array_mx) == 0) { continue; } echo "{$domain} = " . count($array_mx) . " mx\n"; while (list($ipaddr, $hostname) = each($array_mx)) { $notif[] = "{$domain}: {$hostname} [{$ipaddr}]"; $WHITELISTED[$ipaddr] = $hostname; } } $count_whitelisted_after = count($WHITELISTED); $somme = $count_whitelisted_after - $count_whitelisted_before; if ($somme == 0) { echo "Nothing to do...\n"; return; } if ($somme > 0) { if ($GLOBALS["VERBOSE"]) { echo "{$somme} items added in array\n" . @implode("\n", $notif); } $unix = new unix(); $unix->send_email_events("{$somme} items MX has been whitelisted", @implode("\n", $notif), "postfix"); } reset($WHITELISTED); while (list($value, $hostname) = each($WHITELISTED)) { if (trim($value) == null) { continue; } $sql = "DELETE FROM iptables WHERE serverip='{$value}' AND local_port=25"; $q->QUERY_SQL($sql, "artica_backup"); $sql = "INSERT IGNORE INTO postfix_whitelist_con (ipaddr,hostname) VALUES('{$value}','{$hostname}')"; $q->QUERY_SQL($sql, "artica_backup"); } $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.postfix.maincf.php --postscreen"; shell_exec($cmd); }
function ParseMimeDefangFilter() { $q = new mysql(); $sock = new sockets(); if (!$q->TestingConnection()) { echo "Starting mimedefang: testing connection to MySQL failed, aborting configuration task...\n"; return; } $ldap = new clladp(); $tr = array(); $localdomains = $ldap->hash_get_all_domains(); $disclaimers_rules = disclaimers_rules(); $autocompress_rules = autocompress_rules(); $filehosting_rules = filehosting_rules(); if ($autocompress_rules != null) { $EnableAutocompress = 1; } else { $EnableAutocompress = 0; } if ($filehosting_rules != null) { $EnableFileHosting = 1; } else { $EnableFileHosting = 0; } $Param = unserialize(base64_decode($sock->GET_INFO("MimeDefangServiceOptions"))); if (!is_numeric($Param["DEBUG"])) { $Param["DEBUG"] = 0; } $MySQL_server = $q->mysql_server; $MySQL_user = $q->mysql_admin; $MySQL_password = $q->mysql_password; $MySQL_port = intval($q->mysql_port); $main = new main_cf(); @file_put_contents("/etc/artica-postfix/settings/Daemons/MimeDefangPostFixNetwork", @implode("\n", $main->array_mynetworks)); if ($MySQL_server == null) { $MySQL_server = "127.0.0.1"; } if ($MySQL_server == "localhost") { $MySQL_server = "127.0.0.1"; } if ($MySQL_server == "127.0.0.1") { $MySQL_server = null; } if ($MySQL_server == null) { $DSN = "DBI:mysql:database=artica_backup;mysql_socket=/var/run/mysqld/mysqld.sock"; } else { $DSN = "DBI:mysql:database=artica_backup;host={$MySQL_server};port={$MySQL_port}"; } $sock->SET_INFO("MySQLPerlDSN", $DSN); $sock->SET_INFO("MySQLPerlUsername", $MySQL_user); $sock->SET_INFO("MySQLPerlPassword", $MySQL_password); $TMPDIR = "/var/spool/MIMEDefang"; if (!is_dir($TMPDIR)) { @mkdir($TMPDIR, 0755, true); } if (!is_dir("{$TMPDIR}/BACKUP")) { @mkdir("{$TMPDIR}/BACKUP", 0755, true); } @chown($TMPDIR, "postfix"); @chgrp($TMPDIR, "postfix"); @chown("{$TMPDIR}/BACKUP", "postfix"); @chgrp("{$TMPDIR}/BACKUP", "postfix"); $QuarantineDir = "/var/spool/MD-Quarantine"; if (!is_dir($QuarantineDir)) { @mkdir($QuarantineDir, 0755, true); } @chown($QuarantineDir, "postfix"); @chgrp($QuarantineDir, "postfix"); $TMPDIR_CAPTURED = "/var/spool/MIMEDefang_replaced"; if (!is_dir($TMPDIR_CAPTURED)) { @mkdir($TMPDIR_CAPTURED, 0755, true); } @chown($TMPDIR_CAPTURED, "postfix"); @chgrp($TMPDIR_CAPTURED, "postfix"); @copy("/usr/share/artica-postfix/bin/install/mimedefang/mimedefang-filter.pl", "/etc/mail/mimedefang-filter"); while (list($dim, $line) = each($localdomains)) { $tr[] = "'{$dim}'=>1"; } if (count($tr) > 0) { $hashlocaldomains = @implode(",", $tr); } $MimeDefangFileHostingSubjectPrepend = $sock->GET_INFO("MimeDefangFileHostingSubjectPrepend"); $MimeDefangFileHostingSubjectPrepend = str_replace('"', '\\"', $MimeDefangFileHostingSubjectPrepend); $MimeDefangFileHostingLink = $sock->GET_INFO("MimeDefangFileHostingLink"); $MimeDefangFileHostingText = $sock->GET_INFO("MimeDefangFileHostingText"); $MimeDefangFileHostingExternMySQL = $sock->GET_INFO("MimeDefangFileHostingExternMySQL"); $MimeDefangFileHostingMySQLsrv = $sock->GET_INFO("MimeDefangFileHostingMySQLsrv"); $MimeDefangFileHostingMySQLusr = $sock->GET_INFO("MimeDefangFileHostingMySQLusr"); $MimeDefangFileHostingMySQLPass = $sock->GET_INFO("MimeDefangFileHostingMySQLPass"); $MimeDefangFileMaxDaysStore = $sock->GET_INFO("MimeDefangFileMaxDaysStore"); if (!is_numeric($MimeDefangFileMaxDaysStore)) { $MimeDefangFileMaxDaysStore = 5; } $MimeDefangFileHostingText = stripslashes($MimeDefangFileHostingText); if ($MimeDefangFileHostingText == null) { $MimeDefangFileHostingText = "The %s file exceed the company's messaging rules.\nIt has been moved to our Web server.\nYou can download it by clicking on the link bellow."; } $MimeDefangFileHostingText = str_replace('"', '\\"', $MimeDefangFileHostingText); $MimeDefangFileHostingText = str_replace("\n", "\\n", $MimeDefangFileHostingText); $tb = explode("\n", @file_get_contents("/etc/mail/mimedefang-filter")); while (list($index, $line) = each($tb)) { if (preg_match('#my\\s+\\$dsn#', $line)) { $tb[$index] = "\tmy \$dsn = 'DBI:mysql:artica_backup:{$q->mysql_server}';"; continue; } if (preg_match("#my\\s+\\\$db_user_name#", $line)) { $tb[$index] = "\tmy \$db_user_name = '{$q->mysql_admin}';"; continue; } if (preg_match("#my\\s+\\\$MimeDefangFileHostingSubjectPrepend#", $line)) { $tb[$index] = "\tmy \$MimeDefangFileHostingSubjectPrepend = \"{$MimeDefangFileHostingSubjectPrepend}\";"; continue; } if (preg_match("#my\\s+\\\$MimeDefangFileHostingLink#", $line)) { $tb[$index] = "\tmy \$MimeDefangFileHostingLink = \"{$MimeDefangFileHostingLink}\";"; continue; } if (preg_match("#my\\s+\\\$MimeDefangFileMaxDaysStore#", $line)) { $tb[$index] = "\tmy \$MimeDefangFileMaxDaysStore = \"{$MimeDefangFileMaxDaysStore}\";"; continue; } if (preg_match("#my\\s+\\\$MimeDefangFileHostingText#", $line)) { $tb[$index] = "\tmy \$MimeDefangFileHostingText = \"{$MimeDefangFileHostingText}\";"; continue; } if (preg_match("#my\\s+\\\$DebugMimeFilter#", $line)) { $tb[$index] = "\tmy \$DebugMimeFilter = {$Param["DEBUG"]};"; continue; } if (preg_match("#my\\s+\\\$db_password#", $line)) { $tb[$index] = "\tmy \$db_password = '******';"; continue; } if (preg_match("#my\\s+\\\$EnableCompression#", $line)) { $tb[$index] = "\tmy \$EnableCompression = {$EnableAutocompress};"; continue; } if (preg_match("#my\\s+\\\$EnableFileHosting#", $line)) { $tb[$index] = "\tmy \$EnableFileHosting = {$EnableFileHosting};"; continue; } if (preg_match("#my\\s+%hashLocalDomains#", $line)) { $tb[$index] = "\tmy %hashLocalDomains = ({$hashlocaldomains});"; continue; } if (preg_match("#my\\s+%hashCompressesRules#", $line)) { $tb[$index] = "\tmy %hashCompressesRules = ({$autocompress_rules});"; continue; } if (preg_match("#my\\s+%hashFileHostingRules#", $line)) { $tb[$index] = "\tmy %hashFileHostingRules = ({$filehosting_rules});"; continue; } if (preg_match("#my\\s+%hashDisclaimers#", $line)) { $tb[$index] = "\tmy %hashDisclaimers = ({$disclaimers_rules});"; continue; } } echo "Starting mimedefang: saving /etc/mail/mimedefang-filter done\n"; @file_put_contents("/etc/mail/mimedefang-filter", @implode("\n", $tb)); }
function wizards() { return; $sock = new sockets(); $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement"); $WizardNetLeaveUnconfigured = $sock->GET_INFO("WizardNetLeaveUnconfigured"); if (!is_numeric($DisableNetworksManagement)) { $DisableNetworksManagement = 0; } if (!is_numeric($WizardNetLeaveUnconfigured)) { $WizardNetLeaveUnconfigured = 0; } $hostname = base64_decode($sock->getFrameWork("network.php?fqdn=yes")); writelogs("network.php?fqdn=yes -> hostname=\"{$hostname}\"", __FUNCTION__, __FILE__, __LINE__); $mustchangeHostname = false; if (preg_match("#Name or service not known#", $hostname)) { $hostname = trim($sock->GET_INFO("myhostname")); } if (preg_match("#locahost\\.localdomain#", $hostname)) { $mustchangeHostname = true; } if (preg_match("#localhost\\.localdomain#", $hostname)) { $mustchangeHostname = true; } if (preg_match("#[A-Za-z]+\\s+[A-Za-z]+#", $hostname)) { $mustchangeHostname = true; } if (!$mustchangeHostname) { if (preg_match("#locahost\\.localdomain#", $users->hostname)) { $mustchangeHostname = true; } } if (!$mustchangeHostname) { if (strpos($hostname, ".") == 0) { $mustchangeHostname = true; } } if ($mustchangeHostname) { writelogs("hostname=\"{$hostname}\" mustchangeHostname=True", __FUNCTION__, __FILE__, __LINE__); } else { writelogs("hostname=\"{$hostname}\" mustchangeHostname=False", __FUNCTION__, __FILE__, __LINE__); } if ($mustchangeHostname) { echo "<script>Loadjs('admin.chHostname.php');</script>"; } if ($WizardNetLeaveUnconfigured == 0) { $user = new usersMenus(); if ($user->VPS_OPENVZ) { $sock->SET_INFO("WizardNetLeaveUnconfigured", 1); } $WizardNetLeaveUnconfigured = 1; } if ($DisableNetworksManagement == 0) { if ($WizardNetLeaveUnconfigured == 0) { if (!$mustchangeHostname) { $q = new mysql(); if ($q->TestingConnection()) { $countDeNIC = $q->COUNT_ROWS("nics", "artica_backup"); if ($q->ok) { if ($countDeNIC == 0) { echo "<script>Loadjs('admin.chNICs.php');</script>"; } } } } } } }
function whitelist_global_disable() { if (!is_numeric($_GET["ID"])) { return null; } $sql = "UPDATE postfix_global_whitelist SET enabled='{$_GET["GlobalWhiteDisable"]}' WHERE ID='{$_GET["ID"]}'"; $q = new mysql(); if (!$q->TestingConnection()) { echo "Connection to MySQL server failed\n"; return; } $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n" . $sql . "\n"; return; } $sock = new sockets(); $sock->getFrameWork("cmd.php?postfix-whitelisted-global=yes"); }
function test_mysql() { $q = new mysql(); if (!$q->UseMysql) { return; } $tpl = new templates(); if (!$q->TestingConnection()) { $title = $tpl->_ENGINE_parse_body("{ERROR_MYSQL_CONNECTION}"); $html[] = "\$.jGrowl(\""; $html[] = "<table>"; $html[] = "<tr>"; $html[] = "<td width=1% valign='top'>"; $html[] = "<img src=img/database-error-48.png>"; $html[] = "</td>"; $html[] = "<td valign=top>"; $html[] = "<span style=color:#C3393E;font-size:16px>{$title}"; $html[] = "</span><hr>"; $html[] = $tpl->_ENGINE_parse_body("<a href='#' OnClick=javascript:Loadjs('mysql.password.php'); style='text-decoration:underline'><strong>{$q->mysql_error}</strong>"); $html[] = "\","; $html[] = "{header: '{$title}',life:15000});"; echo implode("", $html) . "\n"; } }
function messages_search() { $tpl = new templates(); $users = new usersMenus(); $q = new mysql(); $search = '%'; $table = "amavisd_tests"; $page = 1; $total = 0; $MyPage = CurrentPageName(); if (!$q->TestingConnection()) { json_error_show("Connection to MySQL server failed"); } if ($q->COUNT_ROWS("amavisd_tests", "artica_backup") == 0) { json_error_show("no data"); } 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(); $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { json_error_show($q->mysql_error . " LINE:" . __LINE__); } $total = $ligne["TCOUNT"]; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { json_error_show($q->mysql_error . " LINE:" . __LINE__); } if (mysql_num_rows($results) == 0) { json_error_show("no row {$sql}", 1); } $score = 0; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["subject"] == null) { $ligne["subject"] = "{subject}:{unknown}"; } $recp = explode(",", $ligne["recipients"]); $rcpt_text = @implode($recp, "<br>"); if ($ligne["finish"] == 0) { $status = "{scheduled}"; } if ($ligne["finish"] == 1) { $status = "{analyzed}"; $ahrf = "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:SpamassShowMsgStatus({$ligne["ID"]})\"\n\t\t\t\tstyle='font-size:16px;font-weight:normal;text-decoration:underline'>"; } $delete = imgtootltip("delete-32.png", "{delete}", "DeleteSpamTest({$ligne["ID"]})"); $analyze = imgtootltip("refresh-32.png", "{analyze}", "spamass_ana_msg({$ligne["ID"]})"); $status = $tpl->_ENGINE_parse_body($status); $data['rows'][] = array('id' => $ligne['prefid'], 'cell' => array("<span style='font-size:16px'>{$ahrf}{$ligne["saved_date"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$ligne["sender"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$rcpt_text}</a></span>", "<span style='font-size:16px'>{$ligne["subject"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$status}</a></span>", "<center>{$analyze}</center>", "<center>{$delete}</center>")); } echo json_encode($data); }
function CheckLibraries() { $prefixOutput = "Starting......: " . date("H:i:s") . " [INIT]: Apache \"Engine\""; if (!isset($GLOBALS["CLASS_UNIX"])) { $GLOBALS["CLASS_UNIX"] = new unix(); } if (!isset($GLOBALS["CLASS_USERS_MENUS"])) { $GLOBALS["CLASS_USERS_MENUS"] = new usersMenus(); } if (!isset($GLOBALS["CLASS_SOCKETS"])) { $GLOBALS["CLASS_SOCKETS"] = new sockets(); } if (!isset($GLOBALS["CLASS_LDAP"])) { $GLOBALS["CLASS_LDAP"] = new clladp(); } if (!isset($GLOBALS["ECHO_BIN"])) { $GLOBALS["ECHO_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("echo"); } if (!isset($GLOBALS["MD5SUM_BIN"])) { $GLOBALS["MD5SUM_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("md5sum"); } if (!isset($GLOBALS["CUT_BIN"])) { $GLOBALS["CUT_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("cut"); } $EnableOpenLDAP = 1; if (is_file("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP")) { $EnableOpenLDAP = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP")); } if ($EnableOpenLDAP == 1) { if ($GLOBALS["CLASS_LDAP"]->ldapFailed) { echo "{$prefixOutput} [" . __LINE__ . "] OpenLDAP system not ready...\n"; build_progress("OpenLDAP system not ready", 110); die; } } $q = new mysql(); if (!$q->TestingConnection()) { echo "{$prefixOutput} [" . __LINE__ . "] MySQL system not ready...\n"; build_progress("MySQL system not ready", 110); die; } }
$GLOBALS["postmap"] = $unix->find_program("postmap"); $GLOBALS["postalias"] = $unix->find_program("postalias"); $GLOBALS["postfix"] = $unix->find_program("postfix"); if (class_exists("clladp")) { $ldap = new clladp(); if ($ldap->ldapFailed) { WriteToSyslogMail("Fatal: connecting to ldap server {$ldap->ldap_host}", basename(__FILE__), true); echo "Starting......: " . date("H:i:s") . " failed connecting to ldap server {$ldap->ldap_host}\n"; $unix->send_email_events("Postfix user databases aborted (ldap failed)", "The process has been scheduled to start in few seconds.", "postfix"); $unix->THREAD_COMMAND_SET(trim($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " {$argv[1]}")); die; } } if (class_exists("mysql")) { $mysql = new mysql(); if (!$mysql->TestingConnection()) { WriteToSyslogMail("Fatal: connecting to MySQL server {$mysql->mysql_error}", basename(__FILE__), true); echo "Starting......: " . date("H:i:s") . " failed connecting to ldap server {$mysql->mysql_error}\n"; $unix->send_email_events("Postfix user databases aborted (MySQL failed)", "The process has been scheduled to start in few seconds.", "postfix"); $unix->THREAD_COMMAND_SET(trim($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " {$argv[1]}")); die; } } if ($argv[1] == '--reconfigure-all') { reconfigure(); die; } if ($argv[1] == '--restart-all') { restart_all_instances(); die; }
function CheckLibraries() { $prefixOutput = "Starting......: " . date("H:i:s") . " [INIT]: Apache \"Engine\""; if (!isset($GLOBALS["CLASS_UNIX"])) { $GLOBALS["CLASS_UNIX"] = new unix(); } if (!isset($GLOBALS["CLASS_USERS_MENUS"])) { $GLOBALS["CLASS_USERS_MENUS"] = new usersMenus(); } if (!isset($GLOBALS["CLASS_SOCKETS"])) { $GLOBALS["CLASS_SOCKETS"] = new sockets(); } if (!isset($GLOBALS["CLASS_LDAP"])) { $GLOBALS["CLASS_LDAP"] = new clladp(); } if (!isset($GLOBALS["ECHO_BIN"])) { $GLOBALS["ECHO_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("echo"); } if (!isset($GLOBALS["MD5SUM_BIN"])) { $GLOBALS["MD5SUM_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("md5sum"); } if (!isset($GLOBALS["CUT_BIN"])) { $GLOBALS["CUT_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("cut"); } if ($GLOBALS["CLASS_LDAP"]->ldapFailed) { echo "{$prefixOutput} [" . __LINE__ . "] OpenLDAP system not ready...\n"; die; } $q = new mysql(); if (!$q->TestingConnection()) { echo "{$prefixOutput} [" . __LINE__ . "] MySQL system not ready...\n"; die; } }
function checkMysql($nollop = false) { $unix = new unix(); $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($unix->file_time_min($timefile) < 1) { echo "Starting......: " . date("H:i:s") . " PowerDNS need at least 1mn, aborting\n"; return; } @unlink($timefile); @file_put_contents($timefile, time()); $passwdcmdline = null; $mysql = $unix->find_program("mysql"); $q = new mysql(); if (!$q->TestingConnection(true)) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating, MySQL seems not ready..\n"; return; } forward_zones(); if (!$q->DATABASE_EXISTS("powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'powerdns' database\n"; if (!$q->CREATE_DATABASE("powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'powerdns' database failed\n"; return; } } echo "Starting......: " . date("H:i:s") . " PowerDNS 'powerdns' database OK\n"; $f["cryptokeys"] = true; $f["domainmetadata"] = true; $f["domains"] = true; $f["perm_items"] = true; $f["perm_templ"] = true; $f["perm_templ_items"] = true; $f["records"] = true; $f["supermasters"] = true; $f["tsigkeys"] = true; $f["users"] = true; $f["zones"] = true; $f["zone_templ"] = true; $f["zone_templ_records"] = true; $resultTables = true; while (list($tablename, $line2) = each($f)) { if (!$q->TABLE_EXISTS($tablename, "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` failed...\n"; $resultTables = false; continue; } echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` OK...\n"; } if ($resultTables) { echo "Starting......: " . date("H:i:s") . " PowerDNS pass tests Success...\n"; return true; } $dumpfile = "/usr/share/artica-postfix/bin/install/pdns/powerdns.sql"; if (!is_file($dumpfile)) { echo "Starting......: " . date("H:i:s") . " PowerDNS /usr/share/artica-postfix/bin/install/pdns/powerdns.sql no such file...\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS installing database...\n"; if ($q->mysql_password != null) { $passwdcmdline = " -p{$q->mysql_password}"; } $cmd = "{$mysql} -B -u {$q->mysql_admin}{$passwdcmdline} --database=powerdns -E < {$dumpfile} >/dev/null 2>&1"; shell_exec($cmd); reset($f); $resultTables = true; while (list($tablename, $line2) = each($f)) { if (!$q->TABLE_EXISTS($tablename, "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` failed...\n"; $resultTables = false; continue; } echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` OK...\n"; } if ($resultTables) { echo "Starting......: " . date("H:i:s") . " PowerDNS Success...\n"; return true; } if (!$q->TABLE_EXISTS("domains", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domains' table\n"; $sql = "CREATE TABLE IF NOT EXISTS domains (\n\t\t\t id\t\t INT auto_increment,\n\t\t\t name\t\t VARCHAR(255) NOT NULL,\n\t\t\t master\t\t VARCHAR(128) DEFAULT NULL,\n\t\t\t last_check\t INT DEFAULT NULL,\n\t\t\t type\t\t VARCHAR(6) NOT NULL,\n\t\t\t notified_serial INT DEFAULT NULL, \n\t\t\t account VARCHAR(40) DEFAULT NULL,\n\t\t\t primary key (id)\n\t\t\t) Engine=InnoDB;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domains' table FAILED\n"; } else { return; } echo "Starting......: " . date("H:i:s") . " PowerDNS table 'domains' Success\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS table 'domains' Success\n"; $q->QUERY_SQL("CREATE UNIQUE INDEX name_index ON domains(name);", "powerdns"); } if (!$q->TABLE_EXISTS("records", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table\n"; $sql = "CREATE TABLE IF NOT EXISTS records (\n\t\t\t id INT auto_increment,\n\t\t\t domain_id INT DEFAULT NULL,\n\t\t\t name VARCHAR(255) DEFAULT NULL,\n\t\t\t type VARCHAR(10) DEFAULT NULL,\n\t\t\t content VARCHAR(255) DEFAULT NULL,\n\t\t\t ttl INT DEFAULT NULL,\n\t\t\t prio INT DEFAULT NULL,\n\t\t\t change_date INT DEFAULT NULL,\n\t\t\t explainthis VARCHAR(255) DEFAULT NULL,\n\t\t\t primary key(id)\n\t\t\t)Engine=InnoDB;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table FAILED\n"; return; } $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns"); $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns"); $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns"); $q->QUERY_SQL("alter table records add ordername VARCHAR(255);", "powerdns"); $q->QUERY_SQL("alter table records add auth bool;", "powerdns"); $q->QUERY_SQL("create index orderindex on records(ordername);", "powerdns"); $q->QUERY_SQL("alter table records change column type type VARCHAR(10);", "powerdns"); echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table success\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table success\n"; } if (!$q->TABLE_EXISTS("supermasters", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table\n"; $sql = "CREATE TABLE IF NOT EXISTS supermasters (\n\t\t\t\t ip VARCHAR(25) NOT NULL, \n\t\t\t\t nameserver VARCHAR(255) NOT NULL, \n\t\t\t\t account VARCHAR(40) DEFAULT NULL\n\t\t\t\t) Engine=InnoDB;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table FAILED\n"; return; } $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns"); $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns"); $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns"); echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table success\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table success\n"; } if (!$q->TABLE_EXISTS("domainmetadata", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table\n"; $sql = "CREATE TABLE IF NOT EXISTS domainmetadata (\n\t\t\t id INT auto_increment,\n\t\t\t domain_id INT NOT NULL,\n\t\t\t kind VARCHAR(16),\n\t\t\t content TEXT,\n\t\t\t primary key(id)\n\t\t\t);"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table success\n"; $q->QUERY_SQL("create index domainmetaidindex on domainmetadata(domain_id);", "powerdns"); } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'domainmetadata' table success\n"; } if (!$q->TABLE_EXISTS("cryptokeys", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table\n"; $sql = "CREATE TABLE IF NOT EXISTS cryptokeys (\n\t\t\t id INT auto_increment,\n\t\t\t domain_id INT NOT NULL,\n\t\t\t flags INT NOT NULL,\n\t\t\t active BOOL,\n\t\t\t content TEXT,\n\t\t\t primary key(id)\n\t\t\t); "; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table success\n"; $q->QUERY_SQL("create index domainidindex on cryptokeys(domain_id);", "powerdns"); } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'cryptokeys' table success\n"; } if (!$q->TABLE_EXISTS("tsigkeys", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table\n"; $sql = "CREATE TABLE IF NOT EXISTS tsigkeys (\n\t\t\t id INT auto_increment,\n\t\t\t name VARCHAR(255), \n\t\t\t algorithm VARCHAR(255),\n\t\t\t secret VARCHAR(255),\n\t\t\t primary key(id)\n\t\t\t);"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table success\n"; $q->QUERY_SQL("create unique index namealgoindex on tsigkeys(name, algorithm);", "powerdns"); } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'tsigkeys' table success\n"; } if (!$q->TABLE_EXISTS("users", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(16) NOT NULL DEFAULT '0', `password` varchar(34) NOT NULL DEFAULT '0', `fullname` varchar(255) NOT NULL DEFAULT '0', `email` varchar(255) NOT NULL DEFAULT '0', `description` varchar(1024) NOT NULL DEFAULT '0', `perm_templ` tinyint(4) NOT NULL DEFAULT '0', `active` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`))"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table success\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'users' table success\n"; } if (!$q->TABLE_EXISTS("perm_items", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `perm_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL DEFAULT '0', `descr` varchar(1024) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table success\n"; $sql = "INSERT INTO `perm_items` (`id`, `name`, `descr`) VALUES (41, 'zone_master_add', 'User is allowed to add new master zones.'), (42, 'zone_slave_add', 'User is allowed to add new slave zones.'), (43, 'zone_content_view_own', 'User is allowed to see the content and meta data of zones he owns.'), (44, 'zone_content_edit_own', 'User is allowed to edit the content of zones he owns.'), (45, 'zone_meta_edit_own', 'User is allowed to edit the meta data of zones he owns.'), (46, 'zone_content_view_others', 'User is allowed to see the content and meta data of zones he does not own.'), (47, 'zone_content_edit_others', 'User is allowed to edit the content of zones he does not own.'), (48, 'zone_meta_edit_others', 'User is allowed to edit the meta data of zones he does not own.'), (49, 'search', 'User is allowed to perform searches.'), (50, 'supermaster_view', 'User is allowed to view supermasters.'), (51, 'supermaster_add', 'User is allowed to add new supermasters.'), (52, 'supermaster_edit', 'User is allowed to edit supermasters.'), (53, 'user_is_ueberuser', 'User has full access. God-like. Redeemer.'), (54, 'user_view_others', 'User is allowed to see other users and their details.'), (55, 'user_add_new', 'User is allowed to add new users.'), (56, 'user_edit_own', 'User is allowed to edit their own details.'), (57, 'user_edit_others', 'User is allowed to edit other users.'), (58, 'user_passwd_edit_others', 'User is allowed to edit the password of other users.'), (59, 'user_edit_templ_perm', 'User is allowed to change the permission template that is assigned to a user.'), (60, 'templ_perm_add', 'User is allowed to add new permission templates.'), (61, 'templ_perm_edit', 'User is allowed to edit existing permission templates.');"; $q->QUERY_SQL($sql, "powerdns"); } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'perm_items' table success\n"; } if (!$q->TABLE_EXISTS("perm_templ", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `perm_templ` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL DEFAULT '0', `descr` varchar(1024) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ' table FAILED\n"; } else { $sql = "INSERT INTO `perm_templ` (`id`, `name`, `descr`) VALUES (1, 'Administrator', 'Administrator template with full rights.');"; $q->QUERY_SQL($sql, "powerdns"); } } if (!$q->TABLE_EXISTS("perm_templ_items", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `perm_templ_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `templ_id` int(11) NOT NULL DEFAULT '0', `perm_id` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=250 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table success\n"; $sql = "INSERT INTO `perm_templ_items` (`id`, `templ_id`, `perm_id`) VALUES (249, 1, 53);"; $q->QUERY_SQL($sql, "powerdns"); } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'perm_templ_items' table success\n"; } if (!$q->TABLE_EXISTS("zones", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zones' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `zones` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) NOT NULL DEFAULT '0', `owner` int(11) NOT NULL DEFAULT '0', `comment` varchar(1024) DEFAULT '0', `zone_templ_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zones' table FAILED\n"; return; } } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'zones' table success\n"; } if (!$q->TABLE_EXISTS("zone_templ", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `zone_templ` ( \n\t\t\t\t`id` bigint(20) NOT NULL AUTO_INCREMENT, \n\t\t\t\t`name` varchar(128) NOT NULL DEFAULT '0', \n\t\t\t\t`descr` varchar(1024) NOT NULL DEFAULT '0', \n\t\t\t\t`owner` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) \n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table FAILED\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table success\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS 'zone_templ' table success\n"; } $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS zone_templ_records (\n\tid INTEGER NOT NULL AUTO_INCREMENT,\n\tzone_templ_id INTEGER NOT NULL,\n\tname VARCHAR(255) NOT NULL,\n\t`type` VARCHAR(6) NOT NULL,\n\tcontent VARCHAR(255) NOT NULL,\n\tttl INTEGER NOT NULL,\n\tprio INTEGER NOT NULL,\n\tPRIMARY KEY (id)\n\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;", "powerdns"); $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS records_zone_templ (\n\tdomain_id INTEGER NOT NULL,\n\trecord_id INTEGER NOT NULL,\n\tzone_templ_id INTEGER NOT NULL\n\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); if (!$q->TABLE_EXISTS("zone_templ_records", "powerdns")) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ_records' table\n"; $sql = "CREATE TABLE IF NOT EXISTS `zone_templ_records` (\n\t\t `id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t `zone_templ_id` bigint(20) NOT NULL DEFAULT '0',\n\t\t `name` varchar(255) NOT NULL DEFAULT '0',\n\t\t `type` varchar(6) NOT NULL DEFAULT '0',\n\t\t `content` varchar(255) NOT NULL DEFAULT '0',\n\t\t `ttl` bigint(20) NOT NULL DEFAULT '0',\n\t\t `prio` bigint(20) NOT NULL DEFAULT '0',\n\t\t PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; $q->QUERY_SQL($sql, "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ_records' table FAILED\n"; } } if (!$q->TABLE_EXISTS("domainmetadata", "powerdns")) { $q->QUERY_SQL("create table domainmetadata ( id INT auto_increment, domain_id INT NOT NULL, kind VARCHAR(16), content TEXT, primary key(id) );", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata failed {$q->mysql_error}\n"; return; } echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata success\n"; $q->QUERY_SQL("create index domainmetaidindex on domainmetadata(domain_id);", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata failed {$q->mysql_error}\n"; } } else { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata OK\n"; } if (!$q->TABLE_EXISTS("cryptokeys", "powerdns")) { $q->QUERY_SQL("create table cryptokeys (\n\tid INT auto_increment,\n \tdomain_id INT NOT NULL,\n\tflags INT NOT NULL,\n \tactive BOOL,\n \tcontent TEXT,\n\tprimary key(id)\n\t);", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys failed {$q->mysql_error}\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys success\n"; $q->QUERY_SQL("create index domainidindex on cryptokeys(domain_id);", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys failed {$q->mysql_error}\n"; } } } else { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys OK\n"; } if ($q->TABLE_EXISTS("records", "powerdns")) { if (!$q->FIELD_EXISTS("records", "ordername", "powerdns")) { $q->QUERY_SQL("alter table records add ordername VARCHAR(255)", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records failed {$q->mysql_error}\n"; } $q->QUERY_SQL("create index orderindex on records(ordername)", "powerdns"); } if (!$q->FIELD_EXISTS("records", "auth", "powerdns")) { $q->QUERY_SQL("alter table records add auth bool", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records failed {$q->mysql_error}\n"; } } if (!$q->FIELD_EXISTS("records", "disabled", "powerdns")) { $q->QUERY_SQL("alter table records add `disabled` TINYINT(1) DEFAULT 0, ADD INDEX `disabled`(`disabled`)", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records/disabled failed {$q->mysql_error}\n"; } } $q->QUERY_SQL("alter table records change column type type VARCHAR(10);", "powerdns"); } if (!$q->TABLE_EXISTS("tsigkeys", "powerdns")) { $q->QUERY_SQL("create table tsigkeys (\n\t\t id INT auto_increment,\n\t\t name VARCHAR(255), \n\t\t algorithm VARCHAR(50),\n\t\t secret VARCHAR(255),\n\t\t primary key(id)\n\t\t);", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys failed {$q->mysql_error}\n"; } else { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys success\n"; $q->QUERY_SQL("create unique index namealgoindex on tsigkeys(name, algorithm);", "powerdns"); if (!$q->ok) { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys failed {$q->mysql_error}\n"; } } } else { echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys OK\n"; } echo "Starting......: " . date("H:i:s") . " PowerDNS Mysql done...\n"; poweradmin(); }
include_once(dirname(__FILE__).'/ressources/class.mysql.inc'); $file=$argv[1]; $_GET["DEBUG"]=false; if(trim(strtolower($argv[2]))=="--debug"){$_GET["DEBUG"]=true;} if($argv[1]=='--rebuild-sites'){ rebuildsites(); die('finish'); } die("depreciated"); if(!file_exists($file)){write_syslog(" Unable to stat $file",__FILE__);} $q=new mysql(); $q->BuildTables(); if(!$q->TestingConnection()){write_syslog("Unable to logon to mysql",__FILE__);} $datas_file=file_get_contents($file); $datas=explode("\n",$datas_file); write_syslog("$file: ".Count($datas) . " line(s) with " . strlen($datas_file). " bytes length",__FILE__); while (list ($num, $val) = each ($datas) ){ if(trim($val==null)){continue;} if($_GET["DEBUG"]){echo "Parsing line number $num/".Count($datas)."\n";} parseDansLine($val); } @unlink($file); System("/etc/init.d/artica-postfix restart squid &");
function search() { $tpl = new templates(); $users = new usersMenus(); $q = new mysql(); $xglobal = "%{$_GET["domain"]}"; $search = '%'; $table = "userpref"; $page = 1; $total = 0; $MyPage = CurrentPageName(); if (!$q->TestingConnection()) { json_error_show("Connection to MySQL server failed"); } if ($q->COUNT_ROWS("userpref", "artica_backup") == 0) { json_error_show("no data"); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $table = "(SELECT * FROM userpref WHERE (preference ='whitelist_from' AND `username`='{$xglobal}') \n\tOR (preference='blacklist_from' AND `username`='{$xglobal}') ) as t"; $searchstring = string_to_flexquery(); $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { json_error_show($q->mysql_error . " LINE:" . __LINE__); } $total = $ligne["TCOUNT"]; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { json_error_show($q->mysql_error . " LINE:" . __LINE__); } if (mysql_num_rows($results) == 0) { json_error_show("no row {$sql}", 1); } $score = 0; $ARRAY["whitelist_from"] = $tpl->javascript_parse_text("{whitelist}"); $ARRAY["blacklist_from"] = $tpl->javascript_parse_text("{blacklist}"); $ARRAY2["whitelist_from"] = "ok32.png"; $ARRAY2["blacklist_from"] = "okdanger32.png"; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $delete = imgsimple("delete-32.png", "{delete}", "Loadjs('{$MyPage}?delete-id-js={$ligne["prefid"]}')"); $prefid = $ligne["prefid"]; $type = $ligne["preference"]; $icon = $ARRAY2[$type]; $text = $ARRAY[$type]; $data['rows'][] = array('id' => $ligne['prefid'], 'cell' => array("<center><img src='img/{$icon}'></center>", "<span style='font-size:22px'>{$text} <code>{$ligne["value"]}</code></span>", "<center>{$delete}</center>")); } echo json_encode($data); }
$file = $argv[1]; $_GET["DEBUG"] = false; if (trim(strtolower($argv[2])) == "--debug") { $_GET["DEBUG"] = true; } if ($argv[1] == '--rebuild-sites') { rebuildsites(); die('finish'); } die("depreciated"); if (!file_exists($file)) { write_syslog(" Unable to stat {$file}", __FILE__); } $q = new mysql(); $q->BuildTables(); if (!$q->TestingConnection()) { write_syslog("Unable to logon to mysql", __FILE__); } $datas_file = file_get_contents($file); $datas = explode("\n", $datas_file); write_syslog("{$file}: " . Count($datas) . " line(s) with " . strlen($datas_file) . " bytes length", __FILE__); while (list($num, $val) = each($datas)) { if (trim($val == null)) { continue; } if ($_GET["DEBUG"]) { echo "Parsing line number {$num}/" . Count($datas) . "\n"; } parseDansLine($val); } @unlink($file);