/** * Log a message if the logQueries property is true. * * @param $textMessage String text of the message to log * @param $severityLevel Integer constant of the logging severity * @return null */ public function log($textMessage, $severityLevel = LOG_LEVEL_DEBUG) { if ($this->debugEnabled) { $logger = AJXP_Logger::getInstance(); $logger->write($textMessage, $severityLevel); } }
function listLogFiles($dir) { $logger = AJXP_Logger::getInstance(); $parts = explode("/", $dir); if (count($parts) > 4) { print '<columns switchDisplayMode="list" switchGridMode="grid"> <column messageString="Date" attributeName="date" sortType="Date" width="10%"/> <column messageString="I.P." attributeName="ip" sortType="String"/> <column messageString="Level" attributeName="level" sortType="String"/> <column messageString="User" attributeName="user" sortType="String"/> <column messageString="Action" attributeName="action" sortType="String"/> <column messageString="Params" attributeName="params" sortType="String"/> </columns>'; $date = $parts[count($parts) - 1]; $logger->xmlLogs($date, "tree"); } else { print '<columns switchGridMode="filelist"><column messageString="File Date" attributeName="ajxp_label" sortType="String"/></columns>'; $logger->xmlListLogFiles("tree", count($parts) > 2 ? $parts[2] : null, count($parts) > 3 ? $parts[3] : null); } }
public function upgradeDB() { $confDriver = ConfService::getConfStorageImpl(); $authDriver = ConfService::getAuthDriverImpl(); $logger = AJXP_Logger::getInstance(); if (is_a($confDriver, "sqlConfDriver")) { $conf = AJXP_Utils::cleanDibiDriverParameters($confDriver->getOption("SQL_DRIVER")); if (!is_array($conf) || !isset($conf["driver"])) { return "Nothing to do"; } switch ($conf["driver"]) { case "sqlite": case "sqlite3": $ext = ".sqlite"; break; case "postgre": $ext = ".pgsql"; break; case "mysql": $ext = is_file($this->workingFolder . "/" . $this->dbUpgrade . ".mysql") ? ".mysql" : ".sql"; break; default: return "ERROR!, DB driver " . $conf["driver"] . " not supported yet in __FUNCTION__"; } $file = $this->dbUpgrade . $ext; if (!is_file($this->workingFolder . "/" . $file)) { return "Nothing to do."; } $sqlInstructions = file_get_contents($this->workingFolder . "/" . $file); $parts = array_map("trim", explode("/* SEPARATOR */", $sqlInstructions)); $results = array(); $errors = array(); dibi::connect($conf); dibi::begin(); foreach ($parts as $sqlPart) { if (empty($sqlPart)) { continue; } try { dibi::nativeQuery($sqlPart); $results[] = $sqlPart; } catch (DibiException $e) { $errors[] = $sqlPart . " (" . $e->getMessage() . ")"; } } dibi::commit(); dibi::disconnect(); if (!count($errors)) { return "Database successfully upgraded"; } else { return "Database upgrade failed. <br>The following statements were executed : <br>" . implode("<br>", $results) . ",<br><br> The following statements failed : <br>" . implode("<br>", $errors) . "<br><br> You should manually upgrade your DB."; } } }
public function listLogFiles($dir, $root = NULL, $hash = null, $returnNodes = false) { $dir = "/{$dir}"; $allNodes = array(); $logger = AJXP_Logger::getInstance(); $parts = explode("/", $dir); if (count($parts) > 4) { $config = '<columns switchDisplayMode="list" switchGridMode="list" template_name="ajxp_conf.logs"> <column messageId="ajxp_conf.17" attributeName="date" sortType="MyDate" defaultWidth="18%"/> <column messageId="ajxp_conf.18" attributeName="ip" sortType="String" defaultWidth="5%"/> <column messageId="ajxp_conf.19" attributeName="level" sortType="String" defaultWidth="10%"/> <column messageId="ajxp_conf.20" attributeName="user" sortType="String" defaultWidth="5%"/> <column messageId="ajxp_conf.124" attributeName="source" sortType="String" defaultWidth="5%"/> <column messageId="ajxp_conf.21" attributeName="action" sortType="String" defaultWidth="7%"/> <column messageId="ajxp_conf.22" attributeName="params" sortType="String" defaultWidth="50%"/> </columns>'; if (!$returnNodes) { AJXP_XMLWriter::sendFilesListComponentConfig($config); } $date = $parts[count($parts) - 1]; $logger->xmlLogs($dir, $date, "tree", "/" . $root . "/logs"); } else { if (!$returnNodes) { AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.16" attributeName="ajxp_label" sortType="String"/></columns>'); } $nodes = $logger->xmlListLogFiles("tree", count($parts) > 2 ? $parts[2] : null, count($parts) > 3 ? $parts[3] : null, "/" . $root . "/logs", false); foreach ($nodes as $last => $nodeXML) { if (is_numeric($last) && $last < 10) { $last = "0" . $last; } $key = "/{$root}{$dir}/{$last}"; if (in_array($key, $this->currentBookmarks)) { $nodeXML = str_replace("/>", ' ajxp_bookmarked="true" overlay_icon="bookmark.png"/>', $nodeXML); } $allNodes[$key] = $nodeXML; if (!$returnNodes) { print $nodeXML; } } } return $allNodes; }
$use_https = false; /**************************************************/ /* MAX NUMBER CHARS FOR FILE AND DIRECTORY NAMES /**************************************************/ $max_caracteres = 50; /*************************************************/ /* WHEN SET, USE SYSTEM CODE TO GET FILESIZE. /* Enable this on 32bits machine, to overcome PHP /* 4GB limit on file size. This requires shell_exec /* permission on linux, and fork permission on /* windows. Under Windows, it's faster to install /* COM PHP Extension. /*************************************************/ $allowRealSizeProbing = true; /**************************************************/ /* ADVANCED : DO NOT CHANGE THESE VARIABLES BELOW /**************************************************/ $installPath = realpath(dirname(__FILE__) . "/../.."); define("INSTALL_PATH", $installPath); define("USERS_DIR", $installPath . "/server/users"); define("SERVER_ACCESS", "content.php"); define("ADMIN_ACCESS", "admin.php"); define("IMAGES_FOLDER", "client/images"); define("CLIENT_RESOURCES_FOLDER", "client"); define("SERVER_RESOURCES_FOLDER", "server/classes"); define("DOCS_FOLDER", "client/doc"); define("TESTS_RESULT_FILE", $installPath . "/server/conf/diag_result.php"); define("OLD_USERS_DIR", $installPath . "/bookmarks"); define("INITIAL_ADMIN_PASSWORD", "admin"); $logger = AJXP_Logger::getInstance(); $logger->initStorage(INSTALL_PATH . "/server/logs/");
function listLogFiles($dir, $root = NULL) { $dir = "/{$dir}"; $logger = AJXP_Logger::getInstance(); $parts = explode("/", $dir); if (count($parts) > 4) { $config = '<columns switchDisplayMode="list" switchGridMode="grid" template_name="ajxp_conf.logs"> <column messageId="ajxp_conf.17" attributeName="date" sortType="MyDate" defaultWidth="10%"/> <column messageId="ajxp_conf.18" attributeName="ip" sortType="String" defaultWidth="10%"/> <column messageId="ajxp_conf.19" attributeName="level" sortType="String" defaultWidth="10%"/> <column messageId="ajxp_conf.20" attributeName="user" sortType="String" defaultWidth="10%"/> <column messageId="ajxp_conf.21" attributeName="action" sortType="String" defaultWidth="10%"/> <column messageId="ajxp_conf.22" attributeName="params" sortType="String" defaultWidth="50%"/> </columns>'; AJXP_XMLWriter::sendFilesListComponentConfig($config); $date = $parts[count($parts) - 1]; $logger->xmlLogs($dir, $date, "tree", $root . "/logs"); } else { AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.16" attributeName="ajxp_label" sortType="String"/></columns>'); $logger->xmlListLogFiles("tree", count($parts) > 2 ? $parts[2] : null, count($parts) > 3 ? $parts[3] : null, $root . "/logs"); } }
function logAction($action, $params = array()) { $logger = AJXP_Logger::getInstance(); $message = "{$action}\t"; if (count($params)) { $message .= $logger->arrayToString($params); } $logger->write($message, LOG_LEVEL_INFO); }