Exemplo n.º 1
0
function PEAR_ErrorToPEAR_Exception($err)
{
    //DB_DataObject throws error when an empty set would be returned
    //That behavior is weird, and not how the rest of StatusNet works.
    //So just ignore those errors.
    if ($err->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
        return;
    }
    $msg = $err->getMessage();
    $userInfo = $err->getUserInfo();
    // Log this; push the message up as an exception
    common_error("PEAR Error: {$msg} ({$userInfo})");
    // HACK: queue handlers get kicked by the long-query killer, and
    // keep the same broken connection. We die here to get a new
    // process started.
    if (php_sapi_name() == 'cli' && preg_match('/nativecode=2006/', $userInfo)) {
        common_error("Lost DB connection; dying.");
        exit(100);
    }
    if ($err->getCode()) {
        throw new PEAR_Exception($msg, $err, $err->getCode());
    } else {
        throw new PEAR_Exception($msg, $err);
    }
}
Exemplo n.º 2
0
 function __construct()
 {
     parent::__construct();
     $this->load->library('session');
     if (!DEV_MODE) {
         common_error();
     }
 }
Exemplo n.º 3
0
 static function loadSettings()
 {
     try {
         $settings = self::_getSettings();
         if (!empty($settings)) {
             self::_applySettings($settings);
         }
     } catch (Exception $e) {
         common_error($e->getTraceAsString());
         return;
     }
 }
Exemplo n.º 4
0
 private function _get_post_data_from_submit_key($submit_key, $post_key)
 {
     $this->site_util->set_post_data_from_submit_key($submit_key, $post_key);
     $this->form_validation->set_rules('id', 'id', 'required|max_length[12]|is_natural_no_zero');
     if (!$this->form_validation->run()) {
         common_error(validation_errors());
     }
     return set_value('id');
 }
Exemplo n.º 5
0
 private function _check_admin()
 {
     $this->_check_auth();
     $admin_path = $this->config->item('admin_path', 'site');
     if (!$this->uri->segment(1, false) || $this->uri->segment(1, false) != $admin_path) {
         define('IS_ADMIN', false);
         return;
     }
     // 以下、管理画面の処理
     define('IS_ADMIN', true);
     if (UM_SLAVE_DB_MODE) {
         show_error('admin module is disabled.');
     }
     if (!empty($GLOBALS['ADMIN_ALLOW_IP_LIST'])) {
         if (!in_array($this->input->server('REMOTE_ADDR'), $GLOBALS['ADMIN_ALLOW_IP_LIST'])) {
             common_error();
         }
     }
     if (CURRENT_ACTION) {
         if (in_array(CURRENT_ACTION, $this->config->item('admin_inseccure_actions', 'site'))) {
             if (IS_AUTH) {
                 redirect($admin_path);
             }
             return;
         }
     }
     if (IS_AUTH) {
         return;
     }
     redirect($admin_path . '/login');
 }
Exemplo n.º 6
0
<?php

define('FLUIDFRAME', true);
define('INSTALLDIR', dirname(__FILE__));
require_once INSTALLDIR . '/lib/core.php';
try {
    Fluidframe::init();
    $_lang = common_language();
} catch (Exception $e) {
    common_error($e->getTraceAsString());
    $error = new ErrorAction('en');
    $error->setErrorMessage(500, $e->getMessage());
    $error->handle();
}
// get the incoming request URL path
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// get the route based on the path and server
$route = $router->match($path, $_SERVER);
if (empty($route)) {
    $error = new ErrorAction($_lang);
    $error->setErrorMessage(404, 'Unkown page');
    $error->handle();
}
// does the route indicate an action?
if (isset($route->params['action'])) {
    // take the action class directly from the route
    $action = $route->params['action'];
} else {
    // use a default action class
    $action = 'home';
}