コード例 #1
0
ファイル: exec.sarg.php プロジェクト: brucewu16899/1.6.x
function buildconf()
{
    $sock = new sockets();
    $unix = new unix();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    if ($unix->IsProtectedDirectory($SargOutputDir, true)) {
        $sock->SET_INFO("SargOutputDir", "/var/www/html/squid-reports");
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    if (!is_file("/etc/artica-postfix/old_SargOutputDir")) {
        @file_put_contents("/etc/artica-postfix/old_SargOutputDir", $SargOutputDir);
    }
    if ($SargOutputDir == "/usr/share/artica-postfix/squid") {
        $SargOutputDir = "/var/www/html/squid-reports";
        $sock->SET_INFO("SargOutputDir", "/var/www/html/squid-reports");
    }
    if ($SargOutputDir != "/usr/share/artica-postfix/squid") {
        @mkdir("{$SargOutputDir}", 0755, true);
        if (is_dir("/usr/share/artica-postfix/squid")) {
            $cp = $unix->find_program("cp");
            $rm = $unix->find_program("rm");
            shell_exec("{$cp} -rf /usr/share/artica-postfix/squid/* \"{$SargOutputDir}/\"");
            shell_exec("{$rm} -rf \"/usr/share/artica-postfix/squid\"");
            @rmdir("/usr/share/artica-postfix/squid");
        }
    }
    $old_SargOutputDir = @file_get_contents("/etc/artica-postfix/old_SargOutputDir");
    if ($old_SargOutputDir != $SargOutputDir) {
        @mkdir("{$SargOutputDir}", 0755, true);
        if (is_dir($old_SargOutputDir)) {
            $cp = $unix->find_program("cp");
            $rm = $unix->find_program("rm");
            shell_exec("{$cp} -rf \"{$old_SargOutputDir}/*\" \"{$SargOutputDir}/\"");
            if (!$unix->IsProtectedDirectory($old_SargOutputDir, true)) {
                shell_exec("{$rm} -rf \"{$old_SargOutputDir}\"");
                @rmdir($old_SargOutputDir);
            }
            if (!is_dir($old_SargOutputDir)) {
                @file_put_contents("/etc/artica-postfix/old_SargOutputDir", $SargOutputDir);
            }
        } else {
            @file_put_contents("/etc/artica-postfix/old_SargOutputDir", $SargOutputDir);
        }
    }
    events("Output dir: {$SargOutputDir}");
    $SargConfig = unserialize(base64_decode($sock->GET_INFO("SargConfig")));
    $SargConfig = SargDefault($SargConfig);
    if ($SargConfig["lastlog"] == 0) {
        $SargConfig["lastlog"] = 90;
    }
    $SargConfig["lastlog"] * 24;
    $conf[] = "language {$SargConfig["language"]}";
    $conf[] = "graphs {$SargConfig["graphs"]}";
    $conf[] = "title \"{$SargConfig["title"]}\"";
    $conf[] = "topsites_num {$SargConfig["topsites_num"]}";
    $conf[] = "topuser_num {$SargConfig["topuser_num"]}";
    $conf[] = "report_type {$SargConfig["report_type"]}";
    $conf[] = "topsites_sort_order CONNECT {$SargConfig["topsites_sort_order"]}";
    $conf[] = "index_sort_order {$SargConfig["index_sort_order"]}";
    $conf[] = "resolve_ip {$SargConfig["resolve_ip"]}";
    $conf[] = "user_ip {$SargConfig["user_ip"]}";
    $conf[] = "exclude_hosts /etc/squid3/sarg.hosts";
    $conf[] = "date_format {$SargConfig["date_format"]}";
    $conf[] = "records_without_userid {$SargConfig["records_without_userid"]}";
    $conf[] = "long_url {$SargConfig["long_url"]}";
    $conf[] = "lastlog {$SargConfig["lastlog"]}";
    $conf[] = "index yes";
    $conf[] = "index_tree file";
    $conf[] = "overwrite_report yes";
    $conf[] = "mail_utility mail";
    $conf[] = "hostalias /etc/squid3/sarg-aliases";
    $conf[] = "exclude_codes /etc/squid3/sarg-exclude_codes";
    $conf[] = "temporary_dir /tmp";
    $conf[] = "date_time_by bytes";
    $conf[] = "show_sarg_info no";
    $conf[] = "show_sarg_logo no";
    $conf[] = "external_css_file /sarg.css";
    $conf[] = "ulimit none";
    $conf[] = "squid24 off";
    $conf[] = "output_dir {$SargOutputDir}";
    $conf[] = "logo_image /logo.gif";
    $conf[] = "image_size 160 58";
    $conf[] = "access_log /var/log/squid/access.log";
    $conf[] = "realtime_access_log_lines 5000";
    $conf[] = "graph_days_bytes_bar_color orange";
    $conf[] = "";
    add_defaults();
    $q = new mysql_squid_builder();
    $sql = "SELECT *  FROM sarg_aliases ORDER BY `pattern`";
    $results = $q->QUERY_SQL($sql);
    $a = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $zline = "{$ligne["pattern"]}";
        if ($ligne["group"] != null) {
            $zline = $zline . " {$ligne["group"]}";
        }
        if (trim($ligne["replace"] == null)) {
            $ligne["replace"] = str_replace("*.", "", $ligne["pattern"]);
            $zline = $zline . ": {$ligne["replace"]}";
        }
        $a[] = $zline;
    }
    file_put_contents("/etc/squid3/sarg-aliases", @implode("\n", $a));
    file_put_contents("/etc/squid3/sarg.conf", @implode("\n", $conf));
    file_put_contents("/etc/squid3/sarg-configured-1.8.012202.conf", @implode("\n", $conf));
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, sarg.conf done\n";
    events("/etc/squid3/sarg.conf done");
    $ips = array();
    $ips[] = "127.0.0.1";
    $excluescodes[] = "NONE/400";
    $excluescodes[] = "NONE/411";
    $excluescodes[] = "TCP_DENIED/407";
    $excluescodes[] = "TCP_DENIED/403";
    $excluescodes[] = "TCP_DENIED/400";
    $excluescodes[] = "TCP_DENIED/401";
    $excluescodes[] = "TCP_DENIED/411";
    $excluescodes[] = "TCP_MEM_HIT/200";
    $excluescodes[] = "TCP_MEM_HIT/302";
    $excluescodes[] = "TCP_REFRESH_HIT/200";
    $excluescodes[] = "TCP_REFRESH_HIT/304";
    $excluescodes[] = "TCP_NEGATIVE_HIT/404";
    $excluescodes[] = "TCP_IMS_HIT/304";
    $excluescodes[] = "TCP_IMS_HIT/200";
    $excluescodes[] = "TCP_HIT/200";
    $excluescodes[] = "TCP_HIT/302";
    @file_put_contents("/etc/squid3/sarg-exclude_codes", @implode("\n", $excluescodes));
    @file_put_contents("/etc/squid3/sarg.hosts", @implode("\n", $ips));
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, sarg.hosts done\n";
    // $sock=new sockets();$SargOutputDir=$sock->GET_INFO("SargOutputDir");if($SargOutputDir==null){$SargOutputDir="/usr/share/artica-postfix/squid";}
    $unix = new unix();
    $lighttpd_user = $unix->APACHE_SRC_ACCOUNT();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    echo "Starting......: " . date("H:i:s") . " Apache user: {$lighttpd_user}\n";
    @chown("{$SargOutputDir}/sarg.css", $lighttpd_user);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, sarg.css done\n";
    $nice = EXEC_NICE();
    $unix = new unix();
    $sarg_bin = $unix->find_program("sarg");
    $squidbin = $unix->find_program("squid");
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    if (!is_file($squidbin)) {
        $squidbin = $unix->find_program("squid3");
    }
    if (!is_file($sarg_bin)) {
        sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
        return;
    }
    unset($f);
    $f[] = "#!/bin/sh";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice} {$php5} " . __FILE__ . " --exec-daily >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.daily/0sarg.sh", @implode("\n", $f));
    @chmod("/etc/cron.daily/0sarg.sh", 0755);
    events("cron.daily done");
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, cron cron.daily done\n";
    unset($f);
    $f[] = "#!/bin/sh";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice} {$php5} " . __FILE__ . " --exec-hourly >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.hourly/0sarg.sh", @implode("\n", $f));
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, cron cron.hourly done\n";
    @chmod("/etc/cron.hourly/0sarg.sh", 0755);
    events("cron.hourly done");
    unset($f);
    $f[] = "#!/bin/sh";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice} {$php5} " . __FILE__ . " --exec-monthly >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.monthly/0sarg.sh", @implode("\n", $f));
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, cron cron.monthly done\n";
    @chmod("/etc/cron.monthly/sarg.sh", 0755);
    events("cron.monthly done");
    unset($f);
    $f[] = "#!/bin/sh";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice} {$php5} " . __FILE__ . " --exec-weekly >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.weekly/0sarg.sh", @implode("\n", $f));
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, cron cron.weekly done\n";
    @chmod("/etc/cron.weekly/0sarg.sh", 0755);
    events("cron.weekly done");
    unset($f);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, " . __FUNCTION__ . " done\n";
}
コード例 #2
0
function parameters_save()
{
    $sock = new sockets();
    $sock->SET_INFO("EnableSargGenerator", $_GET["EnableSargGenerator"]);
    $tpl = new templates();
    $page = CurrentPageName();
    $SargConfig = unserialize(base64_decode($sock->GET_INFO("SargConfig")));
    $SargConfig = SargDefault($SargConfig);
    while (list($key, $line) = each($_GET)) {
        $SargConfig[$key] = $line;
    }
    $SargConfig = SargDefault($SargConfig);
    $sock->SaveConfigFile(base64_encode(serialize($SargConfig)), "SargConfig");
}
コード例 #3
0
ファイル: sarg.php プロジェクト: brucewu16899/1.6.x
function parameters_save(){
	$sock=new sockets();
	if(isset($_GET["RESTART_SQUID"])){
		$sock->getFrameWork("cmd.php?squid-restart=yes");
	}
	$DisableArticaProxyStatistics=$sock->GET_INFO("DisableArticaProxyStatistics");
	if(!is_numeric($DisableArticaProxyStatistics)){$DisableArticaProxyStatistics=0;}
	$sock->SET_INFO("EnableSargGenerator",$_GET["EnableSargGenerator"]);
	$sock->SET_INFO("DisableArticaProxyStatistics",$_GET["DisableArticaProxyStatistics"]);
	$sock->SET_INFO("SargOutputDir",$_GET["SargOutputDir"]);
	unset($_GET["SargOutputDir"]);
	
	
	if($_GET["DisableArticaProxyStatistics"]<>$DisableArticaProxyStatistics){$sock->getFrameWork("cmd.php?restart-artica-maillog=yes");}
	$tpl=new templates();
	$page=CurrentPageName();
	$SargConfig=unserialize(base64_decode($sock->GET_INFO("SargConfig")));	
	$SargConfig=SargDefault($SargConfig);	
	while (list ($key, $line) = each ($_GET) ){
		$SargConfig[$key]=$line;
		
	}
	$SargConfig=SargDefault($SargConfig);	
	$sock->SaveConfigFile(base64_encode(serialize($SargConfig)),"SargConfig");	
	$sock->getFrameWork("squid.php?test-sarg=yes");
	$sock->getFrameWork("squid.php?sarg-conf=yes");
}
コード例 #4
0
function buildconf()
{
    $sock = new sockets();
    $SargConfig = unserialize(base64_decode($sock->GET_INFO("SargConfig")));
    $SargConfig = SargDefault($SargConfig);
    $conf[] = "language {$SargConfig["language"]}";
    $conf[] = "graphs {$SargConfig["graphs"]}";
    $conf[] = "title \"{$SargConfig["title"]}\"";
    $conf[] = "topsites_num {$SargConfig["topsites_num"]}";
    $conf[] = "topuser_num {$SargConfig["topuser_num"]}";
    $conf[] = "topsites_sort_order CONNECT {$SargConfig["topsites_sort_order"]}";
    $conf[] = "index_sort_order {$SargConfig["index_sort_order"]}";
    $conf[] = "resolve_ip {$SargConfig["resolve_ip"]}";
    $conf[] = "user_ip {$SargConfig["user_ip"]}";
    $conf[] = "exclude_hosts /etc/squid3/sarg.hosts";
    $conf[] = "date_format {$SargConfig["date_format"]}";
    $conf[] = "records_without_userid {$SargConfig["records_without_userid"]}";
    $conf[] = "long_url {$SargConfig["long_url"]}";
    $conf[] = "lastlog {$SargConfig["lastlog"]}";
    $conf[] = "index yes";
    $conf[] = "index_tree file";
    $conf[] = "overwrite_report yes";
    $conf[] = "mail_utility mail";
    $conf[] = "temporary_dir /tmp";
    $conf[] = "date_time_by bytes";
    $conf[] = "show_sarg_info no";
    $conf[] = "show_sarg_logo no";
    $conf[] = "external_css_file /squid/sarg.css";
    $conf[] = "ulimit none";
    $conf[] = "squid24 off";
    $conf[] = "output_dir /usr/share/artica-postfix/squid";
    $conf[] = "logo_image /css/images/logo.gif";
    $conf[] = "image_size 160 35";
    $conf[] = "access_log /var/log/squid/sarg.log";
    $conf[] = "realtime_access_log_lines 5000";
    $conf[] = "graph_days_bytes_bar_color orange";
    $conf[] = "";
    @file_put_contents("/etc/squid3/sarg.conf", @implode("\n", $conf));
    echo "Starting......: Sarg, sarg.conf done\n";
    $ips[] = "127.0.0.1";
    $ips[] = "localhost";
    @file_put_contents("/etc/squid3/sarg.hosts", @implode("\n", $ips));
    if ($GLOBALS["VERBOSE"]) {
        "/etc/squid3/sarg.hosts done\n";
    }
    echo "Starting......: Sarg, sarg.hosts done\n";
    $i[] = "html{background-color:#005447;}";
    $i[] = "table{background-color:white}";
    $i[] = ".body {font-family:Verdana,Tahoma,Arial;color:#000000;background-color:#005447;}";
    $i[] = ".info {font-family:Verdana,Tahoma,Arial;font-size:9px;}";
    $i[] = ".info a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;text-decoration:none;}";
    $i[] = ".title {font-family:Verdana,Tahoma,Arial;font-size:11px;color:#7D7171;background-color:#ffffff;}";
    $i[] = ".title2 {font-family:Verdana,Tahoma,Arial;font-size:11px;color:darkblue;background-color:#ffffff;text-align:left;}";
    $i[] = ".title3 {font-family:Verdana,Tahoma,Arial;font-size:11px;color:darkblue;background-color:#ffffff;text-align:right;}";
    $i[] = ".header {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:left;border-right:1px solid #666666;border-bottom:1px solid #666666;}";
    $i[] = ".header2 {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:right;border-right:1px solid #666666;border-bottom:1px solid #666666;}";
    $i[] = ".header3 {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:center;border-right:1px solid #666666;border-bottom:1px solid #666666;}";
    $i[] = ".text {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;}";
    //$i[]=".data {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:right;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;}";
    //$i[]=".data a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;background-color:lavender;text-align:right;text-decoration:none;}";
    //$i[]=".data2 {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;background-color:lavender;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;}";
    //$i[]=".data3 {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px,text-align:center;background-color:lavender;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;}";
    //$i[]=".data3 a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;text-align:center;background-color:lavender;text-decoration:none;}";
    $i[] = ".text {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;text-align:right;}";
    $i[] = "table thead th ,.header_l { text-align: left; font-weight: normal; font-size: 16px; }";
    $i[] = "table thead th ,.header_l { height: 23px; border-bottom: 1px #b1b1b1 solid; padding: 0px 5px 0px 10px; }";
    $i[] = "table thead tr ,.header_l{ background: transparent url( /ressources/templates/default/img/thead_bg.jpg ) repeat-x left bottom;}";
    $i[] = "table tbody tr thead,.header_l{ background-color: #ffffff; }";
    $i[] = "table{ width: 100%; font-family:Arial;}";
    $i[] = "th,.header_l {\n-moz-background-clip:border;\n-moz-background-inline-policy:continuous;\n-moz-background-origin:padding;\nbackground:#005447 url(/ressources/templates/default/images/ui-bg_highlight.png) repeat-x scroll 50% 50%;\nborder:1px solid #000000;\ncolor:#FFFFFF;\nfont-weight:bold;\ntext-align:left;\ntext-transform:uppercase;\npadding:3px;\n}";
    $i[] = "td.data2 { border-bottom: 1px #d5d5d5 solid; ;padding: 0px 5px 0px 10px;background-color: #fafafa;font-size:14px }";
    $i[] = "td.data2 a:link,a:visited {font-size:14px;text-decoration:underline;color:black}";
    $i[] = "td.data a:link,a:visited {font-size:14px;text-decoration:underline;color:black}";
    $i[] = "td.data{ border-bottom: 1px #d5d5d5 solid; ;padding: 0px 5px 0px 10px;height: 23px; border-bottom: 1px #b1b1b1 solid; padding: 0px 5px 0px 10px; }";
    $i[] = "td.data3{ border-bottom: 1px #d5d5d5 solid; ;padding: 0px 5px 0px 10px;height: 23px; border-bottom: 1px #b1b1b1 solid; padding: 0px 5px 0px 10px;text-align:center }";
    $i[] = "td.header_c{font-size:13px;height:auto}";
    $i[] = "img {border-style: none}";
    $i[] = "td.data2 a:hover{font-size:14px;text-decoration:underline;font-weight:bold;color:#B10000}";
    $i[] = "td.data a:hover{font-size:14px;text-decoration:underline;font-weight:bold;color:#B10000}";
    $i[] = ".logo{background-color:#015548;height:50px;padding:5px}";
    $i[] = "th.title_c{\n\tbackground-color:#8F8785;\n\tfont-size:16px;letter-spacing:1px;font-weight:bold;color:#FFFFFF;background-image:none;border:0px;text-align:left;text-transform:capitalize;}";
    $i[] = "td.header_c,th.header_c{font-size:14px;padding:4px;\n\ttext-transform:capitalize;font-style:italic;color:#7D7171;font-weight:bolder;\n\tbackground-image:none;border:0px;text-align:right;background-color:#FFFFFF}";
    $i[] = "td.link a:link,a:visited{height:auto;color:#B10000}";
    $i[] = "td.link{height:auto;color:#B10000}";
    $i[] = "td.link a:hover{height:auto;color:#B10000;font-weight:bolder}";
    if ($GLOBALS["VERBOSE"]) {
        "/usr/share/artica-postfix/squid/sarg.css done\n";
    }
    @file_put_contents("/usr/share/artica-postfix/squid/sarg.css", @implode("\n", $i));
    $unix = new unix();
    $lighttpd_user = $unix->LIGHTTPD_USER();
    echo "Starting......: lighttpd user: {$lighttpd_user}\n";
    @chown("/usr/share/artica-postfix/squid/sarg.css", $lighttpd_user);
    echo "Starting......: Sarg, css done\n";
    $nice = EXEC_NICE();
    $unix = new unix();
    $sarg_bin = $unix->find_program("sarg");
    unset($f);
    $f[] = "#!/bin/bash";
    $f[] = "#Get current date";
    $f[] = "TODAY=\$(date +%d/%m/%Y)";
    $f[] = "YESTERDAY=\$(date --date \"1 day ago\" +%d/%m/%Y)";
    $f[] = "mkdir -p /usr/share/artica-postfix/squid/daily";
    $f[] = "chown -R  {$lighttpd_user}.{$lighttpd_user} /usr/share/artica-postfix/squid/daily";
    $f[] = "NAAT=\"/var/www-naat/html/genfiles/modules/squid-reports/daily\"";
    $f[] = "if [ -d \${NAAT} ]; then";
    $f[] = "    chown -R apache \${NAAT}";
    $f[] = "fi";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice}{$sarg_bin} -f /etc/squid3/sarg.conf -l /var/log/squid/sarg.log -o /usr/share/artica-postfix/squid/daily -z -d \$YESTERDAY-\$TODAY > /dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.daily/0sarg", @implode("\n", $f));
    echo "Starting......: Sarg, cron cron.daily done\n";
    unset($f);
    $f[] = "#!/bin/bash";
    $f[] = "if [ \$cnt -eq 4 ]; then";
    $f[] = "#Get yesterday date";
    $f[] = "YESTERDAY=\$(date --date \"1 day ago\" +%d/%m/%Y)";
    $f[] = "";
    $f[] = "#Get 4 weeks ago date";
    $f[] = "WEEKSAGO=\$(date --date \"4 weeks ago\" +%d/%m/%Y)";
    $f[] = "";
    $f[] = "mkdir -p  /usr/share/artica-postfix/squid/monthly";
    $f[] = "#chown -R apache /usr/share/artica-postfix/squid/monthly";
    $f[] = "";
    $f[] = "#NAAT=\"/var/www-naat/html/genfiles/modules/squid-reports/monthly \"";
    $f[] = "#if [ -d \${NAAT} ]; then";
    $f[] = "#    chown -R apache \${NAAT}";
    $f[] = "#fi";
    $f[] = "";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice}{$sarg_bin} -f /etc/squid3/sarg.conf -l /var/log/squid/sarg.log -o /usr/share/artica-postfix/squid/monthly -d \$WEEKSAGO-\$YESTERDAY > /dev/null 2>&1";
    $f[] = "";
    $f[] = "/usr/sbin/squid -k rotate";
    $f[] = "";
    $f[] = "#don't move next line to upper, reason is that sed change the cnt assignment of the first 7 lines";
    $f[] = "cnt=1";
    $f[] = "else";
    $f[] = "let cnt++";
    $f[] = "fi";
    $f[] = "#echo Will rename itself \\(\$0\\) with cnt \\(\$cnt\\) increased. 1>&2";
    $f[] = "sargtmp=/var/tmp/`basename \$0`";
    $f[] = "sed \"1,7s/^cnt=.*/cnt=\$cnt/";
    $f[] = "\" \$0 >|\$sargtmp";
    $f[] = "chmod -f 775 \$sargtmp";
    $f[] = "mv -f \$sargtmp \$0";
    @file_put_contents("/etc/cron.monthly/0sarg", @implode("\n", $f));
    shell_exec("/bin/chmod 755 /etc/cron.monthly/0sarg");
    echo "Starting......: Sarg, cron cron.monthly done\n";
    unset($f);
    $f[] = "#!/bin/bash";
    $f[] = "";
    $f[] = "#Get current date";
    $f[] = "TODAY=\$(date +%d/%m/%Y) ";
    $f[] = "";
    $f[] = "#Get one week ago today";
    $f[] = "LASTWEEK=\$(date --date \"1 week ago\" +%d/%m/%Y)";
    $f[] = "";
    $f[] = "mkdir -p /usr/share/artica-postfix/squid/weekly ";
    $f[] = "chown -R apache.apache /usr/share/artica-postfix/squid/weekly ";
    $f[] = "";
    $f[] = "NAAT=\"/var/www-naat/html/genfiles/modules/squid-reports/weekly\"";
    $f[] = "if [ -d \${NAAT} ]; then";
    $f[] = "    chown -R apache \${NAAT}";
    $f[] = "fi";
    $f[] = "";
    $f[] = "export LC_ALL=C";
    $f[] = "{$nice}{$sarg_bin} -f /etc/squid3/sarg.conf -l /var/log/squid/sarg.log -o /usr/share/artica-postfix/squid/weekly -z -d \$LASTWEEK-\$TODAY >/dev/null 2>";
    $f[] = "";
    @file_put_contents("/etc/cron.weekly/0sarg", @implode("\n", $f));
    shell_exec("/bin/chmod 755 /etc/cron.weekly/0sarg");
    echo "Starting......: Sarg, cron cron.weekly done\n";
    users_access();
}