function TEMPLATE_SAVE() { //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); if (isset($_POST["TITLE"])) { $_POST["TITLE"] = url_decode_special_tool($_POST["TITLE"]); } if (isset($_POST["BODY"])) { $_POST["BODY"] = url_decode_special_tool($_POST["BODY"]); } $sock = new sockets(); $sock->SET_INFO("SquidADSTemplateSmiley", $_POST["SquidADSTemplateSmiley"]); $sock->SET_INFO("SquidADSTemplateFamily", $_POST["SquidADSTemplateFamily"]); $sock->SET_INFO("SquidADSTemplateBackgroundColor", $_POST["SquidADSTemplateBackgroundColor"]); $sock->SET_INFO("SquidADSTemplateFontColor", $_POST["SquidADSTemplateFontColor"]); $sock->SET_INFO("SquidADSTemplateFontColor", $_POST["SquidADSTemplateFontColor"]); $sock->SET_INFO("SquidADSTemplateTitle", utf8_encode($_POST["TITLE"])); $sock->SET_INFO("SquidADSTemplateBody", utf8_encode($_POST["BODY"])); $xtpl = new template_simple("ERR_ADS_BLOCK", "en"); while (list($num, $ligne) = each($_POST)) { $xtpl->{$num} = $ligne; } $xtpl->Save(); }
function sexec() { $EXEC_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . ".sexec.pid"; $TILE_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . ".sexec.pid"; $unix = new unix(); $sock = new sockets(); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if ($SQUIDEnable == 0) { die; } $pid = @file_get_contents($EXEC_PID_FILE); if ($unix->process_exists($pid, basename(__FILE__))) { build_progress("Already running", 110); return false; } $TILE_PID_TIME = $unix->file_time_min($TILE_PID_FILE); $SquidHTTPTemplateLanguage = $sock->GET_INFO("SquidHTTPTemplateLanguage"); if ($SquidHTTPTemplateLanguage == null) { $SquidHTTPTemplateLanguage = "en-us"; } $GLOBALS["XTPL_SQUID_DEFAULT"] = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/databases/squid.default.templates.db")); $xtpl = new template_simple(); $MAIN = $GLOBALS["XTPL_SQUID_DEFAULT"][$SquidHTTPTemplateLanguage]; @mkdir("/usr/share/squid-langpack/{$SquidHTTPTemplateLanguage}", 0755, true); @chown("/usr/share/squid-langpack/{$SquidHTTPTemplateLanguage}", "squid"); @chgrp("/usr/share/squid-langpack/{$SquidHTTPTemplateLanguage}", "squid"); $arrayxLangs = $xtpl->arrayxLangs; while (list($TEMPLATE_TITLE, $subarray) = each($MAIN)) { build_progress("{building} {$TEMPLATE_TITLE}", 50); $xtpl = new template_simple($TEMPLATE_TITLE, $SquidHTTPTemplateLanguage); $templateDestination = "/usr/share/squid-langpack/templates/{$TEMPLATE_TITLE}"; $templateLangDestination = "/usr/share/squid-langpack/templates/{$SquidHTTPTemplateLanguage}/{$TEMPLATE_TITLE}"; $design = $xtpl->TemplatesDesign(); @file_put_contents($templateDestination, $design); @file_put_contents($templateLangDestination, $design); if ($GLOBALS["VERBOSE"]) { echo "{$TEMPLATE_TITLE}: {$SquidHTTPTemplateLanguage} {$templateDestination} done\n"; } if ($GLOBALS["VERBOSE"]) { echo "{$TEMPLATE_TITLE}: {$SquidHTTPTemplateLanguage} {$templateLangDestination} done\n"; } @chown($templateLangDestination, "squid"); @chgrp($templateLangDestination, "squid"); @chown($templateDestination, "squid"); @chgrp($templateDestination, "squid"); } $ln = $unix->find_program("ln"); while (list($Mainlang, $xarr) = each($xtpl->arrayxLangs)) { while (list($index, $z) = each($xarr)) { build_progress("Saving {$z}", 60); $destination_path = "/usr/share/squid-langpack/templates/{$z}"; if (!is_link($destination_path)) { shell_exec("/bin/rm -rf {$destination_path}"); } @unlink("{$destination_path}"); shell_exec("{$ln} -sf \"/usr/share/squid-langpack/templates/{$Mainlang}\" \"{$destination_path}\""); } } $php = $unix->LOCATE_PHP5_BIN(); if ($GLOBALS["BYINITD"]) { $addon = "By init.d"; } if ($GLOBALS["BY"] != null) { $addon = $GLOBALS["BY"]; } shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --mime"); @file_put_contents("/etc/artica-postfix/SQUID_TEMPLATE_DONEv3", time()); if ($GLOBALS["PROGRESS"]) { build_progress("{reloading} Proxy service", 70); $squidbin = $unix->LOCATE_SQUID_BIN(); squid_admin_mysql(2, "Restarting proxy service in order to refresh templates ({$addon})", null, __FILE__, __LINE__); system("/etc/init.d/squid restart --force"); build_progress("{done}", 100); $TILE_PID_TIME = 0; return; } if (!$GLOBALS["NORELOAD"]) { if ($TILE_PID_TIME > 30) { build_progress("{reloading} Proxy service", 70); squid_admin_mysql(2, "Reloading proxy service in order to refresh templates ({$addon})", null, __FILE__, __LINE__); $squidbin = $unix->LOCATE_SQUID_BIN(); system("/etc/init.d/squid reload --script=exec.squid.templates.php/" . __LINE__); @unlink($TILE_PID_FILE); @file_put_contents($TILE_PID_FILE, time()); } else { squid_admin_mysql(2, "Reloading proxy service ({$addon}) skipped (timed out - {$TILE_PID_TIME}Mn )", null, __FILE__, __LINE__); } } build_progress("{done}", 100); }
function TEMPLATE_SAVE() { //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); if (isset($_POST["TITLE"])) { $_POST["TITLE"] = url_decode_special_tool($_POST["TITLE"]); } if (isset($_POST["BODY"])) { $_POST["BODY"] = url_decode_special_tool($_POST["BODY"]); } $xtpl = new template_simple($_POST["TEMPLATE_TITLE"], $_POST["lang"]); while (list($num, $ligne) = each($_POST)) { $xtpl->{$num} = $ligne; } $xtpl->Save(); }