1); } else { return array("writeable" => 0,"file" => "Datei $filename nicht beschreibbar", "reason" => ''); } } else { return array("writeable" => 1); } } private static function checkFileDbWriteStatus() { $dir = dirname(__FILE__) . '/../db'; if (!file_exists($dir)) { return array("writeable" => 0,"file" => $dir, "reason" => "Verzeichnis existiert nicht"); } else if (!is_writable($dir)) { return array("writeable" => 0,"file" => $dir, "reason" => ''); } $filesToCheck = array(STATUS_FILE,OSSYSTEM_FILE,IMAGES_FILE,QUEUE_FILE); foreach ($filesToCheck as $aFile) { $filename = $dir . '/' . $aFile; $writeStatus = self::checkIndividualFileWriteStatus($filename); if ($writeStatus["writeable"] == 0) { return $writeStatus; } } return array("writeable" => 1); } public static function getsystemstatus($pdo) { $timezone = DbUtils::getConfigItem($pdo, "timezone", "Europe/Berlin"); date_default_timezone_set($timezone); $writeStatus = array("writeable" => 1); $lastaccess = null; if (DB == "mysql") { $sql = "SELECT date FROM %gueststatus% WHERE item=?"; $result = DbUtils::fetchSqlAll($pdo, $sql, array('lastosaccess')); if (count($result) > 0) { $lastaccess = $result[0]["date"]; } } else { try { $writeStatus = self::checkFileDbWriteStatus(); $lastaccess = file_get_contents("../db/" . STATUS_FILE); } catch (Exception $ex) { $lastaccess = null; } } $date = new DateTime(); $currentTimeStamp = $date->getTimestamp(); if (!is_null($lastaccess)) { if (($currentTimeStamp - $lastaccess) > 60) { $lastaccessok = 0; } else { $lastaccessok = 1; } } else { $lastaccessok = 0; } return array("status" => "OK","msg" => array("lastaccessok" => $lastaccessok,"dbwritestatus" => $writeStatus)); } } if (isset($_GET["command"])) { $command = $_GET["command"]; $pdo = null; if (DB == "mysql") { $pdo = DbUtils::openDbAndReturnPdoStatic(); } switch ($command) { case "getsystemstatus": $ret = OsSystem::getsystemstatus($pdo); echo json_encode($ret); break; case "getlogo": OsSystem::getlogo($pdo); break; case "getprodimage": OsSystem::getprodimage($pdo,$_GET["prodid"]); break; default: break; } }