<?php

/**
 * $Id$
 *
 * @category System
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$ids = CValue::post("log_ids");
if ($ids) {
    $ids = explode("-", $ids);
    $error_log = new CErrorLog();
    $rows = $error_log->deleteMulti($ids);
    CAppUI::stepAjax("'{$rows}' rows deleted");
}
Esempio n. 2
0
/**
 * Custom exception handler with backtrace
 * 
 * @param exception $exception Thrown exception
 * 
 * @return void
 */
function exceptionHandler($exception)
{
    global $dPconfig;
    $time = date("Y-m-d H:i:s");
    // User information
    $user_id = null;
    $user_view = "";
    if (class_exists("CAppUI", false) && CAppUI::$user) {
        $user = CAppUI::$user;
        if ($user->_id) {
            $user_id = $user->_id;
            $user_view = $user->_view;
        }
    }
    // Server IP
    $server_ip = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : null;
    $file = mbRelativePath($exception->getFile());
    $line = $exception->getLine();
    $type = "exception";
    $text = $exception->getMessage();
    // Stacktrace
    $contexts = $exception->getTrace();
    foreach ($contexts as &$ctx) {
        unset($ctx['args']);
    }
    // Might noy be ready at the time error is thrown
    $session = isset($_SESSION) ? $_SESSION : array();
    unset($session['AppUI']);
    unset($session['dPcompteRendu']['templateManager']);
    $_all_params = array("GET" => $_GET, "POST" => $_POST, "SESSION" => $session);
    filterInput($_all_params);
    // CApp might not be ready yet as of early error handling
    $request_uid = null;
    if (class_exists("CApp", false)) {
        $request_uid = CApp::getRequestUID();
        CApp::$performance[CError::$_categories["exception"]]++;
    }
    $build_output = ini_get("display_errors");
    $save_to_file = false;
    $data = array("stacktrace" => $contexts, "param_GET" => $_all_params["GET"], "param_POST" => $_all_params["POST"], "session_data" => $_all_params["SESSION"]);
    if (@$dPconfig["error_logs_in_db"] && class_exists("CErrorLog")) {
        try {
            CErrorLog::insert($user_id, $server_ip, $time, $request_uid, $type, $text, $file, $line, $data);
        } catch (Exception $e) {
            $build_output = true;
            $save_to_file = true;
        }
    } else {
        $build_output = true;
        $save_to_file = true;
    }
    if ($build_output) {
        $hash = md5(serialize($contexts));
        $html_class = "big-warning";
        $log = "\n\n<div class='{$html_class}' title='{$hash}'>";
        if ($user_id) {
            $log .= "\n<strong>User: </strong>{$user_view} ({$user_id})";
        }
        $file = CError::openInIDE($file, $line);
        $log .= <<<HTML
  <strong>Time: </strong>{$time}
  <strong>Type: </strong>{$type}
  <strong>Text: </strong>{$text}
  <strong>File: </strong>{$file}
  <strong>Line: </strong>{$line}
HTML;
        foreach ($_all_params as $_type => $_params) {
            $log .= print_infos($_all_params[$_type], $_type);
        }
        foreach ($contexts as $context) {
            $function = isset($context["class"]) ? $context["class"] . ":" : "";
            $function .= $context["function"] . "()";
            $log .= "\n<strong>Function: </strong> {$function}";
            if (isset($context["file"])) {
                $log .= "\n<strong>File: </strong>" . CError::openInIDE($context["file"], isset($context["line"]) ? $context["line"] : null);
            }
            if (isset($context["line"])) {
                $log .= "\n<strong>Line: </strong>" . $context["line"];
            }
            $log .= "<br />";
        }
        $log .= "</div>";
        if ($save_to_file) {
            file_put_contents(LOG_PATH, $log, FILE_APPEND);
        }
        if (ini_get("display_errors")) {
            echo $log;
        }
    }
}
Esempio n. 3
0
 if ($group_similar === 'similar') {
     $groupby = "text, stacktrace_id, param_GET_id, param_POST_id";
 }
 $request = new CRequest();
 $request->addWhere($where);
 $request->addOrder($order);
 $request->addGroup($groupby);
 $request->setLimit($limit);
 $fields = array("GROUP_CONCAT(error_log_id) AS similar_ids", "GROUP_CONCAT(user_id)      AS similar_user_ids", "GROUP_CONCAT(server_ip)    AS similar_server_ips", "MIN(datetime) AS datetime_min", "MAX(datetime) AS datetime_max");
 $error_logs_similar = $ds->loadList($request->makeSelectCount($error_log, $fields));
 $request->setLimit(null);
 $total = count($ds->loadList($request->makeSelectCount($error_log, $fields)));
 $user_ids = array();
 foreach ($error_logs_similar as $_info) {
     $similar_ids = explode(",", $_info["similar_ids"]);
     $error_log = new CErrorLog();
     $error_log->load(reset($similar_ids));
     $error_log->_similar_ids = $similar_ids;
     $error_log->_similar_count = $_info["total"];
     $error_log->_datetime_min = $_info["datetime_min"];
     $error_log->_datetime_max = $_info["datetime_max"];
     $error_log->_similar_user_ids = array_unique(explode(",", $_info["similar_user_ids"]));
     $error_log->_similar_server_ips = array_unique(explode(",", $_info["similar_server_ips"]));
     $error_logs[] = $error_log;
     $user_ids = array_merge($user_ids, $error_log->_similar_user_ids);
     $list_ids = array_merge($list_ids, $error_log->_similar_ids);
 }
 // Load users for similar groupings
 $user_ids = array_unique($user_ids);
 $user = new CUser();
 $users = $user->loadAll($user_ids);
Esempio n. 4
0
<?php

/**
 * $Id: do_error_log_purge.php 20032 2013-07-24 09:48:57Z kgrisel $
 *
 * @category System
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision: 20032 $
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$error_log = new CErrorLog();
$ds = $error_log->getDS();
$query = "TRUNCATE {$error_log->_spec->table}";
$ds->exec($query);
$error_log_data = new CErrorLogData();
$ds = $error_log->getDS();
$query = "TRUNCATE {$error_log_data->_spec->table}";
$ds->exec($query);
CAppUI::stepAjax("Journaux d'erreur vidés");