$domXmlFile->preserveWhiteSpace = false; $domXmlFile->Load(get_ini('UPLOAD_FOLDER') . 'running/' . $proc->cmd); if ($domXmlFile->schemaValidate('plugins/core/xsd/core.xsd')) { // Get header data $item_XML = $domXmlFile->getElementsByTagName('XML')->item(0); $item_HEADER = $item_XML->getElementsByTagName('HEADER')->item(0); $item_DATA = $item_XML->getElementsByTagName('DATA')->item(0); // Set timeout both on execution script and in the database set_time_limit($item_HEADER->getElementsByTagName('TIMEOUT')->item(0)->nodeValue); $q0 = get_link()->prepare('UPDATE ' . get_ini('BDD_PREFIX') . 'core_processus SET timeout=:timeout WHERE id=:id'); $q0->execute(array('timeout' => time() + $item_HEADER->getElementsByTagName('TIMEOUT')->item(0)->nodeValue, 'id' => $proc->id)); // Include the file we need $g = $item_HEADER->getElementsByTagName('PLUGIN')->item(0)->nodeValue; $p = $item_HEADER->getElementsByTagName('PAGE')->item(0)->nodeValue; // Get the date $xmlDate = toTime($item_HEADER->getElementsByTagName('DATE')->item(0)->nodeValue); // If the Xsd file exist if (is_file('plugins/' . $g . '/xsd/' . $p . '.xsd') && $domXmlFile->schemaValidate('plugins/' . $g . '/xsd/' . $p . '.xsd') && is_file('plugins/' . $g . '/' . $p . '.php') || !is_file('plugins/' . $g . '/xsd/' . $p . '.xsd') && is_file('plugins/' . $g . '/' . $p . '.php')) { if ($g != 'core' && is_file('plugins/' . $g . '/__functions.php')) { require_once 'plugins/' . $g . '/__functions.php'; } include 'plugins/' . $g . '/' . $p . '.php'; } else { $error = 'XML file is not valid or process file does not exist.'; } } else { $error = 'XML file is not valid.'; } // if ko, archive the file in the failed folder if (isset($error)) { $procM->update($proc->id, 'failed', '100');
function calculNoturnas($noturno, $h_not_noite) { /*$tempo_noturno = 0; $temp_old = 0; foreach($noturno->result() as $row) { $continu = true; $temp = toSeconds($row->horas); $dia = date($row->dia); if($temp < MANHA_NOT && $temp > LAST_TIME_SEC) { $tempo_noturno += MANHA_NOT - $temp; $temp_old = 0; $continu = false; } if($h_not_noite < $temp && $temp < (LAST_TIME_SEC + 86400) && $continu) { if($temp_old != 0) { //se o dia é o mesmo é que faço isso if(strtotime($dia) > strtotime($old_dia)) { $tempo_noturno += $temp - $temp_old; }else{ $tempo_noturno += $temp - $temp_old - ($temp_old - $h_not_noite); } $temp_old = $temp; $continu = false; }else{ $tempo_noturno += $temp - $h_not_noite; $temp_old = $temp; $continu = false; } } if($temp < LAST_TIME_SEC && $temp_old != 0 && $continu) { $tempo_noturno += ($temp + 86400) - $temp_old; $temp_old = $temp + 86400; $continu = false; } if($continu) { $temp_old = 0; } $old_dia = $dia; }*/ $tempo_noturno = 0; $i = true; $picagem_number = 0; $ar_picnum = array(3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25); $tempoinf = 0; $temposup = 0; $newdia = false; $old_dia = ''; foreach ($noturno->result() as $row) { //$dia = new DateTime($row->dia); $dia = date($row->dia); $cont_cal = true; if (strtotime($dia) > strtotime($old_dia) && $old_dia != '' && toSeconds($row->horas) > LAST_TIME_SEC) { $newdia = true; } //echo ' av '.var_export($newdia); if ($newdia) { //echo ' ENTREI '; $tempoinf = 0; $temposup = 0; $i = true; $picagem_number = 0; $newdia = false; } //echo ' dp '.var_export($newdia); if ($i) { /*echo ' '.$row->horas.' ';*/ $tempoinf = toSeconds($row->horas); $picagem_number++; $i = false; if ($tempoinf > $temposup && $temposup != 0 && $dia > $old_dia) { $temposup = 0; $picagem_number = 1; $cont_cal = false; } /*echo ' dia '.$dia.' '; echo ' old '.$old_dia.' '; if(strtotime($dia) > strtotime($old_dia)) echo ' supppppppppppp ';*/ if ($cont_cal && $tempoinf < $temposup && strtotime($dia) > strtotime($old_dia) && $old_dia != '') { //echo ' '.$picagem_number.' '; /*echo ' '.$row->horas.' '; echo $tempoinf.' ';*/ $temposup = 0; $picagem_number = 1; $cont_cal = false; } } else { $temposup = toSeconds($row->horas); $picagem_number++; $i = true; //aqui vou fazer como se fosse para mudar de dia if ($temposup < $tempoinf && $temposup < LAST_TIME_SEC) { //aqui acrescento 24h $temposup = $temposup + 86400; $newdia = true; } } if ($temposup != 0) { if ($temposup > $h_not_noite || $tempoinf > $h_not_noite) { if (in_array($picagem_number, $ar_picnum)) { //se é uma picagem a verificar if ($tempoinf - $temposup < PAUSA) { //$tempo_noturno += $tempoinf - $temposup; /*if($tempoinf > $h_not_noite) {*/ if ($temposup > $h_not_noite) { $tempo_noturno += $tempoinf - $temposup; } else { $tempo_noturno += $tempoinf - $h_not_noite; } /*}else{ $tempo_noturno += $temposup - $h_not_noite; }*/ } } else { if ($tempoinf > $h_not_noite) { $tempo_noturno += $temposup - $tempoinf; } else { $tempo_noturno += $temposup - $h_not_noite; } } } } else { //aqui é para contar as horas da manha caso seja o caso if ($tempoinf < MANHA_NOT && $tempoinf > LAST_TIME_SEC) { $tempo_noturno += MANHA_NOT - $tempoinf; } } $old_dia = $dia; } return toTime($tempo_noturno); }
} $rs = pg_query($postgis, "SET TIME ZONE 'UTC'"); if (isset($_REQUEST["phenomena"])) { $year = isset($_GET["year"]) ? intval($_GET["year"]) : 2006; $wfo = isset($_GET["wfo"]) ? substr($_GET["wfo"], 0, 3) : "MPX"; $eventid = isset($_GET["eventid"]) ? intval($_GET["eventid"]) : 103; $phenomena = isset($_GET["phenomena"]) ? substr($_GET["phenomena"], 0, 2) : "SV"; $significance = isset($_GET["significance"]) ? substr($_GET["significance"], 0, 1) : "W"; /* Now we fetch warning and perhaps polygon */ $rs = pg_prepare($postgis, "SELECT", "SELECT l.*, \n \t\tto_char(valid, 'YYYY-MM-DDThh24:MI:SSZ') as iso_valid,\n \t\t\tST_x(l.geom) as lon, ST_y(l.geom) as lat\n from sbw_{$year} w, lsrs_{$year} l\n WHERE w.wfo = \$1 and w.phenomena = \$2 and \n w.eventid = \$3 and w.significance = \$4\n and w.geom && l.geom and l.valid BETWEEN w.issue and w.expire\n and w.status = 'NEW'"); $rs = pg_execute($postgis, "SELECT", array($wfo, $phenomena, $eventid, $significance)); } else { /* Look for calling values */ $wfos = isset($_REQUEST["wfos"]) ? explode(",", $_REQUEST["wfos"]) : array(); $sts = isset($_REQUEST["sts"]) ? toTime($_REQUEST["sts"]) : die("sts not defined"); $ets = isset($_REQUEST["ets"]) ? toTime($_REQUEST["ets"]) : die("ets not defined"); $wfoList = implode("','", $wfos); $str_wfo_list = "and wfo in ('{$wfoList}')"; if ($wfoList == "") { $str_wfo_list = ""; } $rs = pg_prepare($postgis, "SELECT", "SELECT *, \n\t\t\tto_char(valid, 'YYYY-MM-DDThh24:MI:SSZ') as iso_valid,\n ST_x(geom) as lon, ST_y(geom) as lat \n FROM lsrs WHERE\n valid BETWEEN \$1 and \$2 {$str_wfo_list}\n LIMIT 3000"); $rs = pg_execute($postgis, "SELECT", array(date("Y-m-d H:i", $sts), date("Y-m-d H:i", $ets))); } $ar = array("type" => "FeatureCollection", "crs" => array("type" => "EPSG", "properties" => array("code" => 4326, "coordinate_order" => array(1, 0))), "features" => array()); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $lon = $row["lon"]; $lat = $row["lat"]; $wfo = $row["wfo"]; $products = "N/A"; if (isset($_GET["inc_ap"]) && $_GET["inc_ap"] == "yes") {
public function calculoHorasInventario($userid, $datefirst, $datesecond) { $sql = "select CONVERT(VARCHAR(10),format(BDate, 'yyyy-MM-dd'),110) as datestart, CONVERT(VARCHAR(10),format(DATEADD(DAY,1,BDate), 'yyyy-MM-dd'),110) as dateend from Holiday where BDate between '" . $datefirst . "' and '" . $datesecond . "' AND Name LIKE '%INV%' order by BDate"; $result_inv = $this->db->query($sql); if ($result_inv->num_rows() > 0) { /*$sql = "SELECT DISTINCT vr.CheckTime, FORMAT(vr.CheckTime, 'HH:mm:ss') as horas, Format(CheckTime, 'dd/MM/yyyy') as dia, hol.Name as Name FROM V_Record as vr, Holiday as hol WHERE vr.Userid =".$userid." AND (";*/ /*$sql = "SELECT DISTINCT vr.Logid FROM V_Record as vr, Holiday as hol WHERE vr.Userid = ".$userid." AND (";*/ /*$sql = "SELECT DISTINCT vr.Logid FROM V_Record as vr, Holiday as hol WHERE vr.Userid = 22 AND (";*/ /*$sql2 = "AND (";*/ $tempo_inv = 0; $continue = false; $i = 0; foreach ($result_inv->result() as $row) { $sql = "SELECT DISTINCT vr.CheckTime, FORMAT(vr.CheckTime, 'HH:mm:ss') as horas, Format(CheckTime, 'dd/MM/yyyy') as dia, hol.Name as Name FROM V_Record as vr, Holiday as hol WHERE vr.Userid =" . $userid . " AND (vr.CheckTime between '" . $row->datestart . " " . FIRST_TIME . "' and '" . $row->dateend . " " . LAST_TIME . "') AND hol.Name LIKE '%INV%' AND Format(hol.BDate, 'yyyy-MM-dd') = '" . $row->datestart . "'"; $result_inv2 = $this->db->query($sql); if ($result_inv2->num_rows() % 2 == 0) { $tempo_inv += calculoInventario($result_inv2->result()); //$tempo_inv = 'ds'; } else { // é impar $continue = true; $tempo_inv = 'Faltam picagens'; } if ($continue) { break; } /*if($i > 0) $sql.= " or ";*/ /*$sql .= "vr.CheckTime between '".$row->datestart." ".FIRST_TIME."' and '".$row->dateend." ".LAST_TIME."'";*/ /*if($i > 0) $sql2.= " or "; $sql2 .= "Format(hol.BDate, 'yyyy-MM-dd') = '".$row->datestart."'";*/ /*$i++;*/ } if (!$continue) { $tempo_inv = toTime($tempo_inv); } /*$sql .= ") AND hol.Name LIKE '%INV%' AND (Format(vr.CheckTime, 'dd/MM/yyyy') = Format(hol.BDate, 'dd/MM/yyyy') or Format(vr.CheckTime, 'dd/MM/yyyy') = format(DATEADD(DAY,1,hol.BDate),'dd/MM/yyyy'))";*/ /*$sql .= ") AND hol.Name LIKE '%INV%' ".$sql2." )";*/ /*echo $sql;*/ /*log_message('utilizadores', $sql);*/ /*$result_inv2 = $this->db->query($sql);*/ /*print_r($result_inv2);*/ /*echo $result_inv2->num_rows();*/ /*if($result_inv2->num_rows() > 0) {*/ /*$sql = "SELECT DISTINCT vr.CheckTime,vr.Logid, FORMAT(vr.CheckTime, 'HH:mm:ss') as horas, Format(CheckTime, 'dd/MM/yyyy') as dia, hol.Name as Name FROM V_Record as vr, Holiday as hol WHERE ("; $i = 0; /*print_r($result_inv2->result());*/ /*foreach($result_inv2->result() as $row) { if($i > 0) $sql.= " or "; $sql .= "vr.Logid = ".$row->Logid; $i++; } $sql .= ") AND hol.Name LIKE '%INV%' AND (Format(vr.CheckTime, 'dd/MM/yyyy') = Format(hol.BDate, 'dd/MM/yyyy') or Format(DATEADD(DAY,-1,vr.CheckTime), 'dd/MM/yyyy') = format(hol.BDate,'dd/MM/yyyy'))"; echo $sql; $tempo_inv = 0; $result_inv3 = $this->db->query($sql);*/ /*print_r($result_inv3->result());*/ /*echo $result_inv3->num_rows().' d ';*/ /*if(($result_inv2->num_rows()) % 2 == 0) { $tempo_inv = calculoInventario($result_inv2->result()); //$tempo_inv = 'ds'; }else{ // é impar $tempo_inv = 'Faltam picagens'; }*/ /*}else{ $tempo_inv = 'Não Há Inv.'; }*/ } else { $tempo_inv = 'Não Há Inv.'; } return $tempo_inv; }
} if ($osName != 'ERROR' && $osName != '' && $osArch == 'ERROR') { $osArch = '32-bit'; } if (isset($osItem->getElementsByTagName("SERIALNUMBER")->item(0)->nodeValue)) { $osSerial = $osItem->getElementsByTagName("SERIALNUMBER")->item(0)->nodeValue; } else { $osSerial = ''; } if (isset($osItem->getElementsByTagName("INSTALLDATE")->item(0)->nodeValue)) { $osInstallDate = toTime($osItem->getElementsByTagName("INSTALLDATE")->item(0)->nodeValue); } else { $osInstallDate = '0'; } if (isset($osItem->getElementsByTagName("LASTBOOTDATE")->item(0)->nodeValue)) { $osLastBootDate = toTime($osItem->getElementsByTagName("LASTBOOTDATE")->item(0)->nodeValue); } else { $osLastBootDate = '0'; } if (isset($osItem->getElementsByTagName("MEMORYSIZE")->item(0)->nodeValue)) { $osMemorySize = $osItem->getElementsByTagName("MEMORYSIZE")->item(0)->nodeValue; } else { $osMemorySize = '0'; } if ($osName != 'ERROR') { $osM->update($os->id, $osName, $osVersion, $osType, $osArch, $osSerial, $osInstallDate, $osLastBootDate, $osMemorySize); // Cpus $cpuIndex = array(); $cpuArray = array(); $cpuItemCount = 0; while (is_object($cpuItems = $item->getElementsByTagName("CPUS")->item($cpuItemCount))) {
require 'functions.php'; #> Required objects and preparation $c = new Canvas(thisURL()); $q = new Query($db); $data = new Template('player.tpl'); $id = getvar('id', ''); $q->select('action,content,t')->from('runrow')->where("rid='{$id}'")->orderby('t,id'); $inner = $q->run(); $cols = extractValues($inner); $v = $cols['version']; #> Some more values that do not depend on the frames (i.e., single values that do not change) list($scwidth, $scheight) = explode(',', $cols['scsize']); list($vpwidth, $vpheight) = explode(',', $cols['vpsize']); $data->assign('scwidth', intval($scwidth * $scalefactor)); $data->assign('scheight', intval($scheight * $scalefactor)); $data->assign('totaltime', toTime($cols['tmax'] - $cols['tmin'])); $data->assign('version', $cols['Version']); $data->assign('context', $cols['Context']); $data->assign('intent', $cols['intent']); $data->assign('browser', $cols['browser']); $data->assign('os', $cols['os']); #> We reset some needed values in the template. $data->assign('obj1backg', ''); $data->assign('obj1top', ''); $data->assign('obj1left', ''); $data->assign('obj1width', ''); $data->assign('obj1height', ''); $data->assign('obj1backwidth', ''); $data->assign('obj1backheight', ''); $data->assign('obj2backg', ''); $data->assign('obj2top', '');