function SearchTask()
{
    $boot = new boostrap_form();
    $sock = new sockets();
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $CheckRunningTasks = base64_decode(unserialize($sock->getFrameWork("squid.php?CheckRunningTasks=yes")));
    $table = "webfilters_schedules";
    $searchstring = string_to_flexquery("SearchTask");
    $sql = "SELECT * FROM {$table} WHERE TaskType={$_GET["TaskID"]} {$searchstring}";
    $results = $q->QUERY_SQL($sql);
    $q2 = new mysql();
    $MyPage = CurrentPageName();
    $schedules = new system_tasks();
    while ($ligne = mysql_fetch_assoc($results)) {
        $sincerun = null;
        $tools = array();
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ID']}", "SquidTaskDelete('{$ligne['ID']}')");
        $disabled = null;
        if (isset($CheckRunningTasks[$ligne['ID']])) {
            $run_icon = "preloader.gif";
        }
        //print_r($ligne);
        $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"]));
        $TimeText = str_replace("<br>", "", $TimeText);
        if (intval($ligne["enabled"]) == 0) {
            $disabled = $tpl->_ENGINE_parse_body("<span class='label label-info'>{disabled}</span> ");
        }
        if (isset($CheckRunningTasks[$ligne['ID']])) {
            $sincerun = "<br><i>{$CheckRunningTasks[$ligne['ID']]}</i>";
        }
        $tablename = "TaskSq{$ligne['ID']}";
        if ($q2->TABLE_EXISTS($tablename, "artica_events")) {
            $evs = $q2->COUNT_ROWS($tablename, "artica_events");
            if ($evs > 0) {
                $tools[] = "<i class='icon-info-sign'></i> {$evs} {events}";
            }
        }
        $js = $boot->trswitch("Loadjs('miniadm.ajax.proxy.schedule.php?ID={$ligne['ID']}');");
        $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
        $delete = "<td {$js} width=1% style='text-align:center'>{$delete}</td>";
        $delete = null;
        $tr[] = "\n\t\t<tr class='{$class}'>\n\t\t<td {$js} width=1%>{$ligne['ID']}</td>\n\t\t<td {$js} >{$disabled}<strong style='font-size:16px;font-weight:bold'>{$ligne["TimeDescription"]}</strong>{$sincerun}<div>{$TimeText}</div><div style='font-size:11px'>" . $tpl->_ENGINE_parse_body(@implode("&nbsp;|&nbsp;", $tools)) . "</div></td>\n\t\t\n\t\t</tr>\n\t\t";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th width=1%>{ID}</th>\n\t\t\t\t\t<th width=98%>{task}</th>\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t\n\t\t\t</table>\n";
}
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_meta();
    $search = '%';
    $table = "(SELECT * FROM system_schedules WHERE `uuid`='{$_GET["uuid"]}') as t";
    $page = 1;
    $ORDER = "ORDER BY ID DESC";
    $sock = new sockets();
    $DisableSquidDefaultSchedule = $sock->GET_INFO("DisableSquidDefaultSchedule");
    if (!is_numeric($DisableSquidDefaultSchedule)) {
        $DisableSquidDefaultSchedule = 0;
    }
    $schedules = new system_tasks();
    $ForceTaskType = $_GET["ForceTaskType"];
    if (!is_numeric($ForceTaskType)) {
        $ForceTaskType = 0;
    }
    $total = 0;
    $FORCE = 1;
    if ($ForceTaskType > 0) {
        $FORCE = "TaskType={$ForceTaskType}";
    }
    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 {$FORCE} {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    $total = $ligne["TCOUNT"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE {$FORCE} {$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show("no schedule");
    }
    $q2 = new mysql();
    if (mysql_num_rows($results) == 0) {
        json_error_show("no schedule", 1);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $events = "&nbsp;";
        $md5 = md5("SquidTask{$ligne['ID']}");
        $TaskType = $ligne["TaskType"];
        $jstaskexplain = $tpl->javascript_parse_text($schedules->tasks_array[$ligne["TaskType"]]);
        $ligne["TaskType"] = $tpl->_ENGINE_parse_body($schedules->tasks_array[$ligne["TaskType"]]);
        $TimeDescription = $ligne["TimeDescription"];
        $enable = Field_checkbox($md5, 1, $ligne["enabled"], "SystemTaskEnable('{$md5}',{$ligne['ID']})");
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ID']}", "SquidTaskDelete('{$ligne['ID']}')");
        $run = $tpl->_ENGINE_parse_body(imgtootltip("24-run.png", "{run} {$ligne['ID']}", "SystemTaskRun('{$ligne['ID']}','{$jstaskexplain}')"));
        if ($ligne["enabled"] == 0) {
            $color = "#A0A0A0";
        }
        $tablename = "Taskev{$ligne['ID']}";
        if (!$q->TABLE_EXISTS($tablename, "artica_events")) {
            $events = imgsimple("delete_disabled.png");
        } else {
            $evs = $q2->COUNT_ROWS($tablename, "artica_events");
            if ($evs > 0) {
                $events = imgsimple("events-24.png", "{events} {$ligne['ID']}", "Loadjs('squid.update.events.php?taskid={$ligne['ID']}&table={$tablename}')");
            }
        }
        $explainTXT = $tpl->_ENGINE_parse_body($schedules->tasks_explain_array[$TaskType]);
        $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"]));
        $TimeText = str_replace("<br>", "", $TimeText);
        if (preg_match("#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)#", $TimeDescription, $re)) {
            $TimeDescription = $TimeText;
            $TimeText = null;
        }
        $span = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?AddNewSchedule-js=yes&ID={$ligne['ID']}');\"\n\t\t style='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
        $ligne["TaskType"] = utf8_encode($ligne["TaskType"]);
        //rowSquidTask
        $data['rows'][] = array('id' => "SquidTask" . $ligne['ID'], 'cell' => array("{$span}{$ligne['ID']}</a>", "{$span}{$ligne["TaskType"]}</a>", "{$span}{$TimeDescription}</a>\n\t\t<div style='font-size:11px'><i>{$explainTXT}</i></div>", "<div style='margin-top:5px'>{$enable}</div>", $delete));
    }
    echo json_encode($data);
}
function schedules(){
	include_once(dirname(__FILE__)."/ressources/class.tasks.inc");
	$page=CurrentPageName();
	$tpl=new templates();
	$task=new system_tasks();
	$q=new mysql_squid_builder();
	$sql="SELECT * FROM webfilters_schedules WHERE TaskType='47'";
	$results = $q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo "<H2>$q->mysql_error</H2>";return;}
	while ($ligne = mysql_fetch_assoc($results)) {
		$TimeDescription=$ligne["TimeDescription"];
		$TimeText=$task->PatternToHuman($ligne["TimeText"],true);
		if(preg_match("#(.+?)\s+(.+?)\s+(.+?)\s+(.+?)\s+(.+?)#", $TimeDescription,$re)){$TimeDescription=$TimeText;$TimeText=null;}
		$ID=$ligne["ID"];
		$tr[]="
		<tr>
		<td width=1%><img src=\"img/arrow-right-24.png\"></td>
		<td width=99% nowrap>
		<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.databases.schedules.php?AddNewSchedule-js=yes&ID=$ID&YahooWin=3');\" 
		style=\"font-size:16px;text-decoration:underline\">$TimeDescription</a>
		<div style='font-size:10px'><i>$TimeText</div></div>
		</td>
		<td width=1%>".imgtootltip("32-run.png","{run}","Loadjs('squid.databases.schedules.php?schedule-run-js=yes&ID=$ID');")."</td>
		</tr>
		";
	
	}
	
	$html=$html."
	<div style=\"font-size:18px;margin-top:10px\">{schedules}:</div>
	<div class=\"form\" style=\"width:99%\" >
		<table style=\"width:99%\" >".@implode("\n", $tr)."</table>
	</div>";
	echo $tpl->_ENGINE_parse_body($html);
	
}
function settings()
{
    $schedules = new system_tasks();
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $buttontext = "{apply}";
    $ID = $_GET["ID"];
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilters_schedules WHERE ID={$ID}"));
    $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
    $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"]));
    $TimeText = str_replace("<br>", "", $TimeText);
    $explain = $tpl->_ENGINE_parse_body($q->tasks_explain_array[$ligne["TaskType"]]);
    $boot = new boostrap_form();
    $boot->set_hidden("ID", $ID);
    $boot->set_checkbox("enabled", "{enabled}", $ligne["enabled"]);
    $boot->set_field("TimeDescription", "{description}", $ligne["TimeDescription"], array("ENCODE" => TRUE));
    $boot->set_button("{apply}");
    $boot->set_formtitle("{task} {$ligne["ID"]}");
    $runtask = $tpl->_ENGINE_parse_body("<div style='text-align:right'><i class='icon-play'></i> <a href=\"javascript:Blurz();\" OnClick=\"javascript:Loadjs('miniadm.ajax.squid.schedules.php?schedule-run-js=yes&ID={$ID}');\">{run} {task}</div>");
    $boot->set_formdescription("{$explain}<br>{$TimeText}{$runtask}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function tasks_search()
{
    $boot = new boostrap_form();
    $tpl = new templates();
    $q = new mysql();
    $t = time();
    if (isset($_GET["t"])) {
        $t = $_GET["t"];
    }
    $page = CurrentPageName();
    $table = "system_schedules";
    $searchstring = string_to_flexquery("search-tasks");
    $ORDER = $boot->TableOrder(array("ID" => "DESC"));
    if ($q->COUNT_ROWS($table, "artica_backup") == 0) {
        senderrors("{no_task}");
    }
    if ($_GET["task-section"] > 0) {
        $table = "( SELECT * FROM {$table} WHERE `TaskType`={$_GET["task-section"]} ) as T";
    }
    $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        senderrors($q->mysql_error . "<br>{$sql}");
    }
    $schedules = new system_tasks();
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $events = "&nbsp;";
        $md = md5(serialize($ligne));
        $TaskType = $ligne["TaskType"];
        $jstaskexplain = $tpl->javascript_parse_text($schedules->tasks_array[$ligne["TaskType"]]);
        $ligne["TaskType"] = $tpl->_ENGINE_parse_body($schedules->tasks_array[$ligne["TaskType"]]);
        $TimeDescription = $ligne["TimeDescription"];
        $delete = imgtootltip("delete-32.png", "{delete} {$ligne['ID']}", "Delete{$t}('{$ligne['ID']}','{$md}')");
        $run = $tpl->_ENGINE_parse_body(imgtootltip("24-run.png", "{run} {$ligne['ID']}", "SystemTaskRun('{$ligne['ID']}','{$jstaskexplain}')"));
        if ($ligne["enabled"] == 0) {
            $color = "#A0A0A0";
        }
        $tablename = "Taskev{$ligne['ID']}";
        if (!$q->TABLE_EXISTS($tablename, "artica_events")) {
            $events = null;
        } else {
            $evs = $q->COUNT_ROWS($tablename, "artica_events");
            if ($evs > 0) {
                $events = imgsimple("events-32.png");
            }
        }
        $explainTXT = $tpl->_ENGINE_parse_body($schedules->tasks_explain_array[$TaskType]);
        $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"]));
        $TimeText = str_replace("<br>", "", $TimeText);
        if (preg_match("#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)#", $TimeDescription, $re)) {
            $TimeDescription = $TimeText;
            $TimeText = null;
        }
        $js = "Loadjs('{$page}?schedule-js=yes&ID={$ligne['ID']}')";
        $link = $boot->trswitch($js);
        $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
        $ligne["TaskType"] = utf8_encode($ligne["TaskType"]);
        $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne['ID']}</td>\n\t\t<td style='font-size:16px' width=25% nowrap {$link}>{$ligne["TaskType"]}</td>\n\t\t<td style='font-size:16px' width=70% {$link}>{$TimeDescription}<br>{$explainTXT}</td>\n\t\t<td style='font-size:16px' width=1% nowrap >{$run}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$events}</td>\n\t\t<td style='font-size:12px' width=1%>{$delete}</td>\n\t\t</tr>\n\t\t";
    }
    $run_this_task_now = $tpl->javascript_parse_text("{run_this_task_now}");
    $delete_text = $tpl->javascript_parse_text("{delete_this_task}");
    echo $boot->TableCompile(array("ID" => "ID", "TaskType" => "{type}", "TimeText" => "{explain}", "run:no" => "{run}", "event:no" => "{events}", "delete:no" => null), $tr) . "\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('task-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\nvar xSystemTaskEnable{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>0){alert(results);}\n\tExecuteByClassName('SearchFunction');\t\t\n}\n\nfunction SystemTaskRun{$t}(ID){\n\tif(confirm('{$run_this_task_now} :`'+ID+'`')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('task-run',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xSystemTaskEnable{$t});\t\t\n\t}\n}\n\t\t\t\n</script>\n\t\t\t\n";
}
Esempio n. 6
0
function frewebslist()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new mysql();
    $sql = "SELECT * FROM freeweb WHERE groupware='UPDATEUTILITY'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $servername = $ligne["servername"];
        $tr[] = "\n\t\t<tr>\n\t\t\t<td width=1%><img src=\"img/arrow-right-24.png\"></td>\n\t\t\t<td width=99%>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.edit.php?hostname={$servername}');\" style=\"font-size:16px;text-decoration:underline\">http://{$servername}</a>\n\t\t\t\t</td>\n\t\t</tr>\n\t\t";
    }
    $html = "\n\t\t\t<div style=\"font-size:18px;margin-top:10px\">{web_services}:</div>\n\t\t\t<table style=\"width:99%\" class=\"form\">" . @implode("\n", $tr) . "</table>";
    $tr = array();
    $task = new system_tasks();
    $sql = "SELECT * FROM system_schedules WHERE TaskType='63'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $TimeDescription = $ligne["TimeDescription"];
        $TimeText = $task->PatternToHuman($ligne["TimeText"]);
        if (preg_match("#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)#", $TimeDescription, $re)) {
            $TimeDescription = $TimeText;
            $TimeText = null;
        }
        $ID = $ligne["ID"];
        $tr[] = "\n\t\t<tr>\n\t\t<td width=1%><img src=\"img/arrow-right-24.png\"></td>\n\t\t<td width=99%>\n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('schedules.php?AddNewSchedule-js=yes&ID={$ID}&YahooWin=3');\" style=\"font-size:16px;text-decoration:underline\">{$TimeDescription}</a>\n\t\t<div style='font-size:10px'><i>{$TimeText}</div></div>\n\t\t</td>\n\t\t</tr>\n\t\t";
    }
    $html = $html . "\n\t\t<div style=\"font-size:18px;margin-top:10px\">{schedules}:</div>\n\t\t\t<table style=\"width:99%\" class=\"form\">" . @implode("\n", $tr) . "</table>";
    echo $tpl->_ENGINE_parse_body($html);
}