Пример #1
0
 public static function pfatal($s = "")
 {
     self::pcolorln(self::ansierr, $s);
     Output::finish(-1);
 }
Пример #2
0
 protected function update_item($r)
 {
     ErrorHandler::RaiseExceptionOnError();
     try {
         Input::ensureRequest($r, array("id"));
         $id = $r["id"];
         Logger::debug("Crud::update_item id:" . $id . " in table " . $this->model->getTableName());
         $post = $this->jsonpost();
         $this->fixValues($post);
         $item = $this->model->getById($id);
         $item->setValues($post);
         $item->save();
         Output::success(array("id" => $id));
     } catch (Exception $e) {
         Output::error($e->getMessage());
     }
 }
Пример #3
0
Файл: cf.php Проект: davbfr/cf
if (!defined("ROOT_DIR")) {
    die("ROOT_DIR not defined." . PHP_EOL);
}
Options::set("CF_DIR", dirname(__FILE__), "Path to the framework");
Options::set("CF_PLUGINS_DIR", CF_DIR);
Options::set("PLUGINS_DIR", ROOT_DIR . DIRECTORY_SEPARATOR . "plugins");
Options::set("ROOT_DIR", dirname(CF_DIR));
Options::set("CONFIG_DIR", ROOT_DIR . DIRECTORY_SEPARATOR . "config");
Options::set("CORE_PLUGIN", "Core");
Options::set("FORCE_HTTPS", false);
Options::set("USE_STS", false);
Options::set("DEFAULT_TIMEZONE", "Europe/Paris");
Options::set("DEBUG", false);
Options::set("IS_CLI", defined("STDIN") && substr(php_sapi_name(), 0, 3) == "cli");
Options::set("IS_PHAR", substr(__FILE__, 0, 7) == "phar://");
if (!IS_CLI && FORCE_HTTPS && $_SERVER["HTTPS"] != "on") {
    if (USE_STS) {
        header('Strict-Transport-Security: max-age=500');
    } else {
        header('Status-Code: 301');
        header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
        Output::finish(301);
    }
}
date_default_timezone_set(DEFAULT_TIMEZONE);
if (function_exists('mb_internal_encoding')) {
    mb_internal_encoding('UTF-8');
}
Plugins::registerAutoload();
Plugins::add(CORE_PLUGIN, Plugins::CORE);
Plugins::addApp();
Пример #4
0
 public function send_error($code, $message = null, $body = null, $backtrace = 1)
 {
     if ($this->inerror) {
         Logger::critical("Already processing error (send_error) {$code} {$message} {$body}");
         return;
     }
     $this->inerror = true;
     $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
     if ($message == null) {
         if (isset(self::$messagecode[$code])) {
             $message = self::$messagecode[$code];
         } else {
             $message = "Error #{$code}";
         }
     }
     if ($body === null) {
         $body = $message;
     }
     if ($code >= 500) {
         Logger::critical("[{$code}] {$message}: {$body}");
     } else {
         Logger::info("[{$code}] {$message}: {$body}");
     }
     if ($this->raise_exception) {
         throw new Exception($body);
     }
     header("{$protocol} {$code} {$message}");
     if ($code < 500 && $code != 404) {
         echo $body;
         Output::finish($code);
     }
     IS_CLI && Output::finish($code);
     if ($backtrace !== false) {
         $this->debugBacktrace($backtrace);
     }
     $this->formatErrorBody($code, $message, $body, $this->backtrace, array_slice(Logger::getInstance()->getLog(), 0, -1));
 }