Пример #1
0
profile_point('classes ready');
require 'lib/config.php';
profile_point('config loaded');
h2_init_hubbub_environment();
// if there was output up to this point, it has to be an error message
$GLOBALS['content.startuperrors'] = trim(ob_get_clean());
// enable gzip compression by default
profile_point('environment ready');
WriteToFile('log/activity.log', 'call ' . $_REQUEST['controller'] . '-' . $_REQUEST['action'] . "\n");
// instantiate controller, invoke action, render view
$_REQUEST['controller'] = getDefault($_REQUEST['controller'], cfg('service/defaultcontroller'));
$baseCtr = h2_getController($_REQUEST['controller']);
profile_point('controller invoked');
h2_invokeAction($baseCtr, $_REQUEST['action']);
profile_point('action executed');
$GLOBALS['content']['main'] = h2_invokeView($baseCtr, $_REQUEST['action']);
profile_point('view executed');
// output through page template
$templateName = cfg('page/template', 'default');
switch ($templateName) {
    case 'blank':
        print $GLOBALS['content']['main'];
        break;
    default:
        header('content-type: text/html;charset=UTF-8');
        require 'themes/' . cfg('theme/name', 'default') . '/' . $templateName . '.php';
        break;
}
/* temporarily disabled (fixme)
  if($_REQUEST['controller'] != 'endpoint')
    h2_statlog('web', $_REQUEST['controller'].'.'.$_REQUEST['action']);  
Пример #2
0
    case 'verify':
        if ($pingPassword == trim($_REQUEST['password'])) {
            $result = array('result' => 'OK');
        } else {
            $result = array('result' => 'fail', 'reason' => 'wrong ping password');
        }
        print json_encode($result);
        break;
    case 'ping':
        if (trim(cfg('ping/password')) == trim($_REQUEST['password'])) {
            $baseCtr = h2_getController('endpoint');
            h2_invokeAction($baseCtr, 'cron');
            print h2_invokeView($baseCtr, 'cron');
            h2_statlog('cron', 'cron');
            $result = array('result' => 'OK', 'stamp' => time(), 'runtime' => profiler_microtime_diff(microtime(), $GLOBALS['profiler_start']));
        } else {
            $result = array('result' => 'fail', 'reason' => 'wrong ping password');
        }
        print json_encode($result);
        break;
    default:
        if ($_SERVER['SERVER_PROTOCOL'] != '') {
            print json_encode(array('result' => 'fail', 'reason' => 'invalid ping request'));
        } else {
            $baseCtr = h2_getController('endpoint');
            h2_invokeAction($baseCtr, 'cron');
            print h2_invokeView($baseCtr, 'cron');
            h2_statlog('cron', 'cron');
        }
        break;
}