/**
  * Inserts an error log into database
  *
  * @param int    $user_id     User ID
  * @param string $server_ip   Server IP
  * @param string $datetime    Datetime
  * @param string $request_uid Request unique ID
  * @param string $error_type  Error type
  * @param string $text        Error message
  * @param string $file_name   File name
  * @param int    $line_number Line number
  * @param array  $data        Data (stacktrace, GET, POST and session)
  *
  * @return void
  *
  * @throws Exception
  */
 static function insert($user_id, $server_ip, $datetime, $request_uid, $error_type, $text, $file_name, $line_number, $data)
 {
     global $m, $action, $dosql;
     if (empty($action) && isset($dosql)) {
         $action = $dosql;
     }
     // Never trace error logging for readability
     $trace = CSQLDataSource::$trace;
     CSQLDataSource::$trace = false;
     $ds = CSQLDataSource::get("std");
     if (!$ds || !$ds->loadTable("error_log")) {
         throw new Exception("No datasource available");
     }
     foreach ($data as $_field => $_value) {
         if (empty($_value)) {
             $data[$_field] = null;
             continue;
         }
         $data[$_field] = CErrorLogData::insert(json_encode($_value));
     }
     $signature = array("text" => $text, "module" => isset($m) ? $m : null, "action" => isset($action) ? $action : null);
     $signature_hash = md5(json_encode($signature));
     $query = "INSERT INTO" . " `error_log` (\n      `user_id`, `server_ip`,\n      `datetime`, `request_uid`, `error_type`, `text`,\n      `file_name`, `line_number`,\n      `stacktrace_id`, `param_GET_id`, `param_POST_id`, `session_data_id`,\n      `signature_hash`\n    ) VALUES (%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13)";
     $query = $ds->prepare($query, $user_id, $server_ip, $datetime, $request_uid, $error_type, $text, $file_name, $line_number, $data["stacktrace"], $data["param_GET"], $data["param_POST"], $data["session_data"], $signature_hash);
     $result = @$ds->exec($query);
     CSQLDataSource::$trace = $trace;
     if (!$result) {
         throw new Exception("Exec failed");
     }
 }
示例#2
0
文件: main.php 项目: fbone/mediboard4
// Check whether we should trace SQL queries
if ($query_trace = CValue::get("query_trace")) {
    CSQLDataSource::$trace = true;
}
if ($query_report = CValue::get("query_report")) {
    CSQLDataSource::$report = true;
}
// tabBox et inclusion du fichier demandé
if ($tab !== null) {
    $module->showTabs();
} else {
    $module->showAction();
}
// Check whether we should trace SQL queries
if ($query_trace) {
    CSQLDataSource::$trace = false;
}
if ($query_report) {
    CSQLDataSource::$report = false;
    CSQLDataSource::displayReport();
}
CApp::$chrono->stop();
CApp::preparePerformance();
// Unlocalized strings
if (!$suppressHeaders || $ajax) {
    CAppUI::$unlocalized = array_map("utf8_encode", CAppUI::$unlocalized);
    $unloc = new CSmartyDP("modules/system");
    $unloc->display("inc_unlocalized_strings.tpl");
}
// Inclusion du footer
if (!$suppressHeaders) {
示例#3
0
$date_min = $see_yesterday ? CMbDT::date("-1 day", $date) : $date;
$date_max = CMbDT::date("+1 day", $date);
// Chargement des séjours concernés
$sejour = new CSejour();
$where = array();
$where["sejour.entree"] = "BETWEEN '{$date_min}' AND '{$date_max}'";
$where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$order = "entree";
/** @var CSejour[] $sejours */
$sejours = $sejour->loadList($where, $order);
$count = 0;
$operations_merge = array();
foreach ($sejours as $_sejour) {
    CSQLDataSource::$trace = 1;
    $operations = $_sejour->loadRefCurrOperations($date);
    CSQLDataSource::$trace = 0;
    if (count($operations) != 2) {
        if (count($operations) > 2) {
            CAppUI::stepAjax("Il y a plus de deux opérations (" . count($operations) . ") pour {$_sejour->_view}", UI_MSG_WARNING);
        }
        continue;
    }
    $count++;
    $operations_merge[] = $operations;
}
CAppUI::stepAjax("{$count} interventions sont à fusionner");
foreach ($operations_merge as $_operation_merge) {
    /** @var COperation[] $op_merge */
    $op_merge = array_values($_operation_merge);
    $plageop = 0;
    foreach ($op_merge as $_operation) {