📄 reports_logs.php
字号:
<?php/******************************************************************** * Copyright (c) 2006, Graham P Phillips * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************/include_once "php_params.php";include_once "layout.php";define("LOCALHOST", '127.0.0.1'); /* 127.0.0.1 is better than localhost */define("LOGMUXD_PORT", 8887);define("DB_USER", '');define("MENU1", "Reports");define("MENU2", "View Logs"); $error = array();$conn = daemon_connect(LOCALHOST, LOGMUXD_PORT, DB_USER, $error);if (is_null($conn)) { display_error_msg(MENU1, MENU2, $error); return;}$logs = read_daemon_logs($conn, $error); if (is_null($logs)) { display_error_msg(MENU1, MENU2, $error); pg_close($conn); return;}display_logs($logs); return;function read_daemon_logs($conn, &$error) { $command = "SELECT log from TblDest"; $result = exec_sql($conn, $command, $error, LOCALHOST, LOGMUXD_PORT); if (!$result) { display_error_msg(MENU1, MENU2, $error); return; } $logs = array(); for ($row = 0; $row < pg_NumRows($result); $row++) { $logs[] = pg_result($result, $row, 0); } pg_freeresult($result); return $logs;} function display_logs($logs) { $widget = "<h2> Logs </h2>\n" . implode("<br>\n", $logs); display_page(MENU1, MENU2, $widget);}/* Provides a wrapper to pg_exec that includes error message generation. * Returns the same result as pg_exec; false on error or a result index if * the sql command could be executed. * $error is an array that is appended to if there is an error * $host and $port just used for error reporting * The caller is expected to free the returned object with pg_freeresult. */function exec_sql($conn, $cmd, &$error, $host, $port) { $result = pg_exec($conn, $cmd); if (!$result) { $detail = pg_ErrorMessage($conn); $error[] = "SQL command failed. Connected to \"" . $host . "\" on port " . $port . "." . " " . $detail; return false; } return $result;}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -