Initial commit
This commit is contained in:
+152
@@ -0,0 +1,152 @@
|
||||
|
||||
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
echo 'starting ...<br>';
|
||||
require_once("soap.php");
|
||||
$cl = new SyndisConnector("http://172.21.11.101/SyndisSpm.wsdl"); //zmienić URL na inny - ten kieruje na moj komputer
|
||||
//$cl->__setLocation('http://172.20.43.10:3615/');
|
||||
$cl->__setLocation('http://172.21.11.101:3615/');
|
||||
echo 'connected ...<br>';
|
||||
echo 'Start: '.date("Y-m-d H:i:s").'<br/><br/>';
|
||||
|
||||
$scriptDate = date("Y-m-d H:i:s");
|
||||
|
||||
date_default_timezone_set('Europe/Warsaw');
|
||||
require_once("func.php");
|
||||
require_once("dbaccess.php");
|
||||
$polacz = mysql_connect($db_host, $db_user, $db_user_pass) or die ('cannot connect to db');
|
||||
mysql_select_db($db_name);
|
||||
mysql_query("SET NAMES utf8");
|
||||
mysql_query("SET CHARACTER_SET utf8_general_ci");
|
||||
|
||||
|
||||
function convertData($insertDate)
|
||||
{
|
||||
unset($res);
|
||||
//re-contruct to format
|
||||
$res = date('Y-m-d H:i:s', strtotime($insertDate));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function time_to_int($inParam)
|
||||
{
|
||||
unset($outParam);
|
||||
$outParam = (float) str_replace(array(' ','-',':'), array('','',''), $inParam);
|
||||
|
||||
return $outParam;
|
||||
}
|
||||
|
||||
function objectToArray($d) {
|
||||
if (is_object($d)) {
|
||||
// Gets the properties of the given object
|
||||
// with get_object_vars function
|
||||
$d = get_object_vars($d);
|
||||
}
|
||||
|
||||
if (is_array($d)) {
|
||||
/*
|
||||
* Return array converted to object
|
||||
* Using __FUNCTION__ (Magic constant)
|
||||
* for recursive call
|
||||
*/
|
||||
return array_map(__FUNCTION__, $d);
|
||||
}
|
||||
else {
|
||||
// Return array
|
||||
return $d;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function split_to_array($inArray)
|
||||
{
|
||||
unset($outArray); unset($newArray);
|
||||
$newArray = objectToArray($inArray);
|
||||
|
||||
if (count($newArray['probes'])>0 && count($newArray['probes'])<=4)
|
||||
{
|
||||
unset($tmpStat); $tmpStat = (int) $newArray['probes']['value'];
|
||||
if ($tmpStat==1) $tmpStat="ON"; else $tmpStat="OFF";
|
||||
|
||||
$outArray[] = array(
|
||||
'value' => $tmpStat,
|
||||
'date' => convertData($newArray['probes']['date']),
|
||||
'reason' => $newArray['probes']['reason']
|
||||
);
|
||||
}
|
||||
elseif (count($newArray['probes'])>4)
|
||||
{
|
||||
$tmpArray = $newArray['probes'];
|
||||
foreach ($tmpArray as $tb)
|
||||
{
|
||||
unset($tmpStat); $tmpStat = (int) $tb['value'];
|
||||
if ($tmpStat==1) $tmpStat="ON"; else $tmpStat="OFF";
|
||||
|
||||
$outArray[] = array(
|
||||
'value' => $tmpStat,
|
||||
'date' => convertData($tb['date']),
|
||||
'reason' => $tb['reason']
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$outArray = null;
|
||||
}
|
||||
|
||||
return $outArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// pobieramy tablice studni
|
||||
$ile_zmian=0;
|
||||
$well_array=null;
|
||||
$wynik = mysql_query("select WLL_NAME from seg_wells,seg_well_pump_eng_rel where RWL_WLL_ID=WLL_ID and WLL_CAT_DIC_ID in (18,19)");
|
||||
if($wynik)while ($r = mysql_fetch_array($wynik))
|
||||
{
|
||||
$well_array[] = $r["WLL_NAME"];
|
||||
}
|
||||
$wl = $cl->GetWellsDataAsArray($well_array);
|
||||
|
||||
//pobiera informacje o statusie pompy (załączniku - czy się zmianił oraz o łącznoiści)
|
||||
// ============================================================================================ //
|
||||
unset($hisOnOffArray);
|
||||
//$hisOnOffArray = objectToArray($cl->GetPumpSwitchAndReasonsHistory('S40','2019-01-19T08:48:43Z'));
|
||||
$hisOnOffArray = split_to_array($cl->GetPumpSwitchAndReasonsHistory('S40','2019-01-19T08:48:43Z'));
|
||||
// ============================================================================================ //
|
||||
//print_r($new_array);
|
||||
echo'<br/>';
|
||||
echo 'Ile: '.count($hisOnOffArray);
|
||||
echo'<br/>';
|
||||
print_r($hisOnOffArray);
|
||||
echo'<br/>';
|
||||
|
||||
|
||||
/*
|
||||
unset($hisOnOffArray);
|
||||
$hisOnOffArray = $cl->GetPumpSwitchAndReasonsHistory('S40','2018-01-19T08:48:43Z');
|
||||
//print_r($hisOnOffArray);
|
||||
echo'<br/>';
|
||||
$array = get_object_vars($hisOnOffArray);
|
||||
echo'Ile: '.count($array);
|
||||
print_r($array);
|
||||
echo'<br/>';
|
||||
$new_array = get_object_vars($array['probes']);
|
||||
echo'Ile: '.count($new_array);
|
||||
echo'<br/>';
|
||||
print_r($new_array);
|
||||
echo'<br/>';
|
||||
*/
|
||||
|
||||
|
||||
|
||||
mysql_close($polacz);
|
||||
|
||||
echo 'Zmieniono <b>'.$ile_zmian.'</b> stanów załączenia/wyłączenia dla studni.<br/><br/>';
|
||||
echo 'Finish: '.date("Y-m-d H:i:s").'<br>';
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user