本文整理汇总了PHP中core::halt方法的典型用法代码示例。如果您正苦于以下问题:PHP core::halt方法的具体用法?PHP core::halt怎么用?PHP core::halt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core
的用法示例。
在下文中一共展示了core::halt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
static function login()
{
core::reg('run-naked',true);
$realm= core::config('cms-realm');
if (!$realm)
{
$realm= strtolower($_SERVER['HTTP_HOST']);
if (substr($realm,0,4)=='www.') $realm= substr($realm,4);
$realm= 'ConKit@'.$realm;
}
if (!isset($_SERVER['PHP_AUTH_USER'])) core::halt(401,$realm);
$exp= (isset($_COOKIE['conkit_cms_exp']) ? $_COOKIE['conkit_cms_exp'] : null);
if ($_SERVER['PHP_AUTH_USER']===$exp)
{
setcookie('conkit_cms_exp','',0,'/');
core::halt(401,$realm);
}
$loginHandler= core::config('cms-user-check');
if (!$loginHandler) $res= cms::loginCheck($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
else $res= call_user_func($loginHandler,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
if ($res!==false)
{
if (!$loginHandler) $res= core::reqSession('.cms-admin', array_merge(array('name'=>$_SERVER['PHP_AUTH_USER']),core::$config['cms-users'][$_SERVER['PHP_AUTH_USER']]));
elseif (is_array($res)) $res= array_merge(array('name'=>$_SERVER['PHP_AUTH_USER'],'password'=>$_SERVER['PHP_AUTH_PW']),$res);
else $res= array('name'=>$_SERVER['PHP_AUTH_USER'],'password'=>$_SERVER['PHP_AUTH_PW'],'attr'=>$res);
core::reqSession('.cms-admin', $res);
core::halt(302,urldecode(core::req('cms-request')));
}
else core::halt(401,$realm);
}
示例2: catch
//throw new controller_exception('Action not found');
} else {
/**
* Create post
* supplied type_name and title
*/
// @todo check rate
if (!empty($post)) {
if (empty($post['title'])) {
$this->get_context()->get_core()->set_message('error_empty_title');
$this->get_context()->get_core()->set_message_data($post, true);
}
try {
$id = $post_handle->create_empty($post, $user);
} catch (validator_exception $e) {
$this->set_null_template();
core::get_instance()->set_raw_message($e->getMessage());
return;
}
if ($id) {
// well done, move user to post edit
$url = $this->get_context()->get_cp_links('post');
$url = $url['url'] . $id . '/';
functions::redirect($url);
core::halt();
} else {
core::get_instance()->set_message(array('users', 'error_post_too_often'));
}
// redirect to this post
}
}
示例3: redirect
static function redirect()
{
core::halt(303, core::url(func_get_args()));
}
示例4:
<?
if (!core::cms()) core::halt(403);
core::reg('run-naked',true);
$file= core::config('data-path').'block1.txt';
$output.= "<h2>File $file</h2>";
if (file_exists($file))
{
if (is_writable($file)) $output.= 'is OK';
else $output.= 'is not writable';
}
else $output.= 'does not exist';
$output.= "<hr>";
$file= core::config('data-path').'block2.txt';
$output.= "<h2>File $file</h2>";
if (file_exists($file))
{
if (is_writable($file)) $output.= 'is OK';
else $output.= 'is not writable';
}
else $output.= 'does not exist';
$output.= "<hr>";
示例5: method
{
$f= cms::form();
$f-> method('post') -> action(core::urlAdd('cms-form-action','upload'));
$f-> file('picture') -> preview('image');
$f-> static('Use only jpeg for the sake of test simplicity');
$f-> submit('Save');
$f-> display();
}
elseif (core::req('cms-form-action')=='upload')
{
$picture= core::req('picture');
move_uploaded_file($picture['tmp_name'],core::config('data-path').'sample.jpg');
core::req('.hide-image',false,'session');
core::redirect('home');
}
elseif (core::req('cms-form-action')=='hide')
{
core::req('.hide-image',true,'session');
core::redirect('home');
}
elseif (core::req('cms-form-action')=='unhide')
{
core::req('.hide-image',false,'session');
core::redirect('home');
}
else
{
core::halt(404,'Unknown action '.core::req('cms-form-action'));
}
return true;
示例6: forward
static function forward($file)
{
core::reg('run-naked', true);
if ($file!='cms.css' && $file!='cms.js') core::halt(403);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !core::config('run-devel'))
{
header('HTTP/1.1 304 Not Modified');
header('Cache-Control: public, max-age=3600');
header('Content-Length: 0');
exit;
}
else
{
if ($file=='cms.js')
{
header('Content-Type: text/javascript');
header('Cache-Control: public, max-age=3600');
header('Content-Length: '.filesize(CORE.$file));
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime(CORE.$file)).' GMT');
header('Pragma: public');
readfile(CORE.$file);
}
elseif ($file=='cms.css')
{
$setcolor= function($color)
{
return str_pad(core::config('cms-'.$color ),24);
};
header('Content-Type: text/css');
header('Cache-Control: public, max-age=3600');
header('Content-Length: '.filesize(CORE.$file.'.php'));
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
header('Pragma: public');
include(CORE.$file.'.php');
}
else core::halt(404);
exit;
}
}