console.log('Session values updated');";
if (($_SESSION['host'] !== $_POST['host']) && (!empty($_POST['host']))){
$_SESSION['trig'] = 0;
$_SESSION['host'] = $_POST['host'];
}
if (($_SESSION['site'] !== $_POST['site']) && (!empty($_POST['site']))){
$_SESSION['trig'] = 0;
$_SESSION['site'] = $_POST['site'];
}
if (($_SESSION['device'] !== $_POST['device']) && (!empty($_POST['site']))){
$_SESSION['trig'] = 0;
$_SESSION['device'] = $_POST['device'];
}
if (($_SESSION['user'] !== $_POST['user']) && (!empty($_POST['site']))){
$_SESSION['trig'] = 0;
$_SESSION['user'] = $_POST['user'];
}
if (($_SESSION['password'] !== $_POST['password']) && (!empty($_POST['site']))){
$_SESSION['trig'] = 0;
$_SESSION['password'] = $_POST['password'];
}
if ($_SESSION['trig'] < 1){
$_SESSION['trig']++;
echo "";
}
if(empty($_SESSION['host'])){
echo ('
NO CONNECTION ESTABLISHED
');
}
$host = $_SESSION['host'];
$site = $_SESSION['site'];
$device = $_SESSION['device'];
$user = $_SESSION['user'];
$password = $_SESSION['password'];
/// for debug purposes only
///echo '
Values in Session:
Site: '.$_SESSION['site'].' Host: '.$_SESSION['host'].' Device: '.$_SESSION['device'].'
';
$auth = base64_encode($user . ":" . $password);
$headers = array(
"Authorization: Basic $auth",
"Accept: application/json",
"Content-Type: application/json"
);
$url = "http://".$host."/enteliweb/api/.bacnet/".$site."?alt=json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic $auth",
"Accept: application/json",
"Content-Type: application/json"));
$output = curl_exec($ch);
curl_close($ch);
$contents = json_decode($output, true);
$table = "";
$keys = array_keys($contents);
$keyId =1;
foreach ($contents as $content){
if ($content!="Collection"){
$table .= '
| '.$keys[$keyId].' | '.$content["displayName"].' | '.$content["nodeType"].' |
';
$keyId++;
}
}
$html ="
Devices online:
| Dev ID | Dev Dame | Dev Type |
".$table."
";
echo $html;
$table="";
?>
';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
}
$directory = "./uploads";
$filelist ='';
// Check if Path is a Directory
if ( is_dir ( $directory ))
{
// open directory
if ( $handle = opendir($directory) )
{
// read every file in directory
while (($file = readdir($handle)) !== false)
{
$rowfilelist++;
///create Dropdown
if ($rowfilelist > 2){
$filelist .= '
';
}
}
closedir($handle);
}
}
;
?>
console.log('Logfile created');";
if (file_exists('counter')==TRUE){
unlink('counter');
echo "";
}
$row = 1;
$csv ="";
if (($handle = fopen('./uploads/'.$_POST['files'],"r")) !== FALSE) {
$file = $_POST['files'];
echo "";
while (($data = fgetcsv($handle, 0, ",","\"","\\")) !== FALSE) {
// usleep(500000);
$num = count($data);
echo "";
$row++;
if ($row>2){
$handlecounter=fopen('counter',"a+");
$data[13] = strtolower($data[13]);
analogvalue($data,$device,$ch,$row,$logfile);
binaryvalue($data,$device,$ch,$row,$logfile);
analoginput($data,$device,$ch,$row,$logfile);
analogoutput($data,$device,$ch,$row,$logfile);
binaryinput($data,$device,$ch,$row,$logfile);
binaryoutput($data,$device,$ch,$row,$logfile);
multistatevalue($data,$device,$ch,$row,$logfile);
program($data,$device,$ch,$row,$logfile);
schedule($data,$device,$ch,$row,$logfile);
controller($data,$device,$ch,$row,$logfile);
if ($data[13] == 'tl'){
trendlog($data,$device,$ch,$row,$logfile);
}
if ($data[13] == 'pgo'){
pgobject($data,$device,$ch,$row,$logfile);
}
$ctName = bacname($data);
fwrite($handlecounter,sprintf("%'.04d", $row).' | '.$ctName.' | '.$data[13].' '.$data[14]."\r\n");
fclose($handlecounter);
}
}
fclose($handle);
}
curl_close($ch);
fclose($datei); ///Logfile close
$handlecounter=fopen('counter',"a+");
fwrite($handlecounter,'Mainloop FINISHED'."\r\n");
fclose($handlecounter);
}
?>