File manager - Edit - /home/missmand/public_html/learning/old/main/couple/error.php
Back
<?php /* For licensing terms, see /license.txt */ /** * Model CRUD for couple_tool_action * @author Batiste Roger <batiste.roger@live.fr> * @package chamilo.couple */ function error_throw ($message, $context = null) { if (!empty($context)) { throw new Exception("$context : $message"); } else { throw new Exception("$message"); } return false; } function error_test_param($param, $error, $context = null) { if (!$param) { error_throw($error, $context); } } /** * Read a param in POST or GET * @param string $name * @param bool $method_is_POST * @param any $default default value to return * @param bool $error_is_not_exists if true, an error is logged when variable can't be found * @return value, any type */ function read_param ($name, $method_is_POST = true, $default = false, $error_is_not_exists = true) { if ($method_is_POST) { if (isset($_POST[$name])) { return $_POST[$name]; } } else { if (isset($_GET[$name])) { return $_GET[$name]; } } if ($error_is_not_exists) { error_throw("Variable $name is not set in " . ($method_is_POST ? 'POST' : 'GET')); } return $default; } /** * My own method to error_log * Easy to disable * @param type $message * @param type $echo */ function error_display($message, $echo = false) { if ($echo) { echo $message; } else { error_log($message); } } /** * My own method to query * @param string $sql * @param bool $return as array (set to true if you want an array, false if you want a Database::result object). * @return array one line per row */ function db_query($sql, $return_as_array = true) { if ($return_as_array) { return result_to_array(Database::query($sql)); } else { return Database::query($sql); } } /** * Converts a result from Database::query into an array * @param type $result * @return type */ function result_to_array($result) { $array = array(); if (Database::num_rows($result) < 1) { // error_display ('0 lignes dans $result'); return null; } else { while($row = Database::fetch_assoc($result)) { $array[] = $row; } return $array; } } /****************** Utils for refresh_tchats ************/ function log_and_tchat($logs, $messages) { if (!is_array($logs)) $logs = array(); if (!is_array($messages)) $messages = array(); $log_and_tchat = array_merge($logs, $messages); $sort = usort($log_and_tchat, "is_before"); if (!$sort) error_throw ('Erreur dans le tri du tchat', 'refresh_tchat.php'); return $log_and_tchat; } function is_before ($item1, $item2) { $date1 = $item1['date_creation']; $date2 = $item2['date_creation']; $timestamp1 = new DateTime($date1); $timestamp2 = new DateTime($date2); return $timestamp1 < $timestamp2; }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings