本文整理汇总了PHP中halt函数的典型用法代码示例。如果您正苦于以下问题:PHP halt函数的具体用法?PHP halt怎么用?PHP halt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了halt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
//排除非POST访问页面的问题
if (!IS_POST) {
halt('页面不存在');
}
//将前端输入的验证码加密后与session中的验证码进行对比
if (I('code', '', 'md5') != session('verify')) {
$this->error('验证码错误');
}
//获取用户名与加密后的pwd
$username = I('username');
$pwd = I('password', '', 'md5');
//查询用户名所对应的后台用户
$user = M('user')->where(array('username' => $username))->find();
//将密码进行比对
if (!$user || $user['password'] != $pwd) {
$this->error('账号或密码错误');
}
//更新后台存储的登录数据
$data = array('id' => $user['id'], 'login_time' => time(), 'login_ip' => get_client_ip());
M('user')->save($data);
//设置登录会话信息
session('uid', $user['id']);
session('username', $user['username']);
session('login_time', date('Y-m-d H:i:s', $user['login_time']));
session('login_ip', $user['login_ip']);
//重定向至后台管理系统
$this->redirect('Admin/Index/index');
}
示例2: login
public function login()
{
if (!IS_POST) {
halt('页面不存在');
}
//sae平台特殊处理验证码
if (md5(strtoupper($_POST['code'])) != $_SESSION['verify']) {
//验证错误处理代码
$this->error('验证码错误');
}
// if(I('code', '', 'strtolower') != session('verify')){
// $this->error('验证码错误');
// }
$db = M('user');
$user = $db->where(array('username' => I('username')))->find();
if (!$user || $user['password'] != I('password', '', 'md5')) {
$this->error('username or password wrong!');
}
//更新最后一次登录时间与IP
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
$db->save($data);
session(C('USER_AUTH_KEY'), $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
session('loginip', $user['loginip']);
//超级管理员识别
if ($user['username'] == C('RBAC_SUPERADMIN')) {
session(C('ADMIN_AUTH_KEY'), true);
}
// p($_SESSION);
//读取用户权限
import('ORG.Util.RBAC');
RBAC::saveAccessList();
redirect(__GROUP__);
}
示例3: login
public function login()
{
//判断是否使用post方法传值
if (!IS_POST) {
halt('页面错误');
}
//读取数据库账号信息
$db = M('user');
$user = $db->where(array('username' => I('username')))->find();
if (!$user || $user['password'] != I('password')) {
$this->error('账号或密码错误');
}
//更新最后一次登录时间与IP
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
$db->save($data);
//设置session
session(C('USER_AUTH_KEY'), $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
session('loginip', $user['loginip']);
//超级管理员识别
if ($user['username'] == C('RBAC_SUPPERADMIN')) {
session(C('ADMIN_AUTH_KEY'), true);
}
//读取用户权限
import('ORG.Util.RBAC');
RBAC::saveAccessList();
redirect(__GROUP__);
}
示例4: login
public function login()
{
if (!IS_POST) {
halt('页面不存在');
}
if (I('code', '', 'md5') != session('verify')) {
$this->error('验证码错误');
}
$usrname = I('username');
$pwd = I('password', '', 'md5');
$db = M('user');
$user = $db->where(array('username' => I('username')))->find();
if (!$user || $user['password'] != $pwd) {
$this->error('账号或密码错误');
}
if ($user['group'] != 'admin') {
$this->error('非管理员,禁止访问');
}
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
$db->save($data);
session('uid', $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
redirect(__GROUP__);
}
示例5: make
/**
* 生成静态页面
* <code>
* array(控制器名,方法名,表态数据,保存表态文件路径)
* array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
* </code>
* @param $control 控制器,需要事先加载
* @param $method 方法
* @param $field 数据array("aid"=>1,"_html"=>"html/2013/2/22/1.html")
* @return bool
*/
public static function make($control, $method, $field)
{
if (!class_exists($control) or !method_exists($control, $method)) {
DEBUG && halt("静态生成需要的控制器{$control}或方法{$method}不存在");
}
if (!isset($field['_html'])) {
DEBUG && halt("请指定静态文件参数'_html',请参考后盾HD框架手册");
}
$obj = NULL;
if (!$obj) {
$obj = new $control();
}
//************创建GET数据****************
$html = $field['_html'];
unset($field['_html']);
$_GET = array_merge($_GET, $field);
if (!dir_create(dirname($html))) {
//创建生成静态的目录
DEBUG && halt("创建目录失败,请检查目录权限");
return false;
}
ob_start();
$obj->{$method}();
//执行控制器方法
$content = ob_get_clean();
file_put_contents($html, $content);
return true;
}
示例6: getTemplateFile
/**
* 获得模版文件
*/
protected function getTemplateFile($file)
{
if (is_null($file)) {
$file = TPL_PATH . CONTROL . '/' . METHOD;
} else {
if (!strstr($file, '/')) {
$file = TPL_PATH . CONTROL . '/' . $file;
}
}
//添加模板后缀
if (!preg_match('@\\.[a-z]+$@', $file)) {
$file .= C('TPL_FIX');
}
//将目录全部转为小写
if (is_file($file)) {
return $file;
} else {
//模版文件不存在
if (DEBUG) {
halt("模板不存在:{$file}");
} else {
return null;
}
}
}
示例7: verify
public function verify()
{
// 判断是否使用POST提交,防偷入
if (!IS_POST) {
halt('页面不存在');
}
// 获取提交的账号密码
$loginname = $_POST['loginname'];
$password = $_POST['password'];
if (!empty($loginname) && !empty($password)) {
// 获取该账号信息
$where['loginname'] = $loginname;
// 判断账号是否存在
if ($data = M('admin')->where($where)->find()) {
/* 存在 */
if ($data['password'] == md5($password . $data['salt'])) {
$this->updateLastLoginTime($data['id']);
$_SESSION['loginname'] = $loginname;
$this->success('登录成功', U('Index/index'));
} else {
$this->error('账号或密码错误');
}
} else {
/* 不存在 */
$this->error('账号不存在');
}
} else {
$this->error('请输入账号或密码');
}
}
示例8: register
public function register()
{
//防止直接输入路径登录页面
if (!IS_POST) {
halt("页面不存在");
}
$username = I('username');
$phonenumber = I('phonenumber');
$password = I('password', '', 'md5');
$user = M('user')->where(array('user_name' => $username))->find();
if ($user) {
$this->ajaxReturn(0);
//用户名已存在
}
$data['user_name'] = $username;
$data['phone_number'] = $phonenumber;
$data['pass_word'] = $password;
$data['user_category'] = 2;
$data['last_login_time'] = date('Y-m-d H:i:s', time());
$data['last_login_ip'] = get_client_ip();
$data['locked'] = 0;
$user = M('user');
$result = $user->add($data);
if ($result) {
$this->ajaxReturn(1);
//注册成功
} else {
$this->ajaxReturn(2);
//注册失败
}
}
示例9: write
/**
+----------------------------------------------------------
* 日志写入
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @param string $message 日志信息
* @param string $type 日志类型
* @param string $file 写入文件 默认取定义日志文件
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
static function write($message, $type = WEB_LOG_ERROR, $file = '')
{
$now = date('[ y-m-d H:i:s ]');
switch ($type) {
case WEB_LOG_DEBUG:
$logType = '[调试]';
$destination = $file == '' ? LOG_PATH . date('y_m_d') . "_systemOut.log" : $file;
break;
case SQL_LOG_DEBUG:
// 调试SQL记录
$logType = '[SQL]';
$destination = $file == '' ? LOG_PATH . date('y_m_d') . "_systemSql.log" : $file;
break;
case WEB_LOG_ERROR:
$logType = '[错误]';
$destination = $file == '' ? LOG_PATH . date('y_m_d') . "_systemErr.log" : $file;
break;
}
if (!is_writable(LOG_PATH)) {
halt(L('_FILE_NOT_WRITEABLE_') . ':' . $destination);
}
//检测日志文件大小,超过配置大小则备份日志文件重新生成
if (file_exists($destination) && floor(C('LOG_FILE_SIZE')) <= filesize($destination)) {
rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
}
error_log("{$now}\n{$message}\n", FILE_LOG, $destination);
self::$log[$type][] = $message;
clearstatcache();
}
示例10: login
/**
* 登录逻辑处理
* @return [type]
*/
public function login()
{
if (!IS_POST) {
halt('页面不存在');
}
//从huaxi-midical表单里提取数据
$username = I('id');
$pwd = I('pwd', '', 'md5');
//对密码进行MD5加密后放入$pwd里
//对输入的用户名在数据库进行检索,检索出来的结果放到$user里
$user = M('user')->where(array('username' => $username))->find();
//判断用户名或者密码是否正确
if (!$user || $user['passward'] != $pwd) {
$this->error('账号或密码错误,请重试');
}
//如果用户被锁定也不能登录
if ($user['lock']) {
$this->error('用户被锁定');
}
//接下来修改数据表中相应的用户表的数据
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
//数据库的hd_user表里保存修改的数据
M('user')->save($data);
//然后向session里写入数据
session('uid', $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
session('loginip', $user['loginip']);
//然后跳转到Index控制器,然后Index控制器加载doctor-page页面
$this->redirect('Index/index');
}
示例11: login
public function login()
{
if (!IS_POST) {
halt('页面不存在');
}
//防止直接通过直接栏 访问
//验证 验证码
$verify = I('verify');
$verify = md5($verify);
if ($verify != session('verify')) {
$this->error('验证码错误');
}
$password = md5($_POST['password']);
//用户名和密码 验证
$db = M('admin');
$user = $db->where(array('username' => I('username')))->find();
//echo $db->getLastSql(); die;
if (!$user || $user['password'] != $password) {
$this->error('用户名或密码错误');
}
//更新用户最后一次登录时间和IP
$data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
$db->save($data);
//写入SESSION
session('admin_id', $user['id']);
session('username', $user['username']);
session('logintime', date('Y-m-d H:i:s'), $user['logintime']);
session('loginip', $user['loginip']);
$this->success('登录成功', U('admin.php/Index/index'));
}
示例12: sort1
public function sort1()
{
if (!IS_AJAX) {
//如果不是ajax提交
halt("页面不存在");
}
$value = cookie('dm_sign');
$value = 'dm.yxs';
setcookie('dm_sign', $value, time() + 30 * 24 * 3600, '/');
// echo cookie('dm_sign');
$dm_items[0] = M("dm_items")->where("item_check=1 and " . time() . "-begin_time<time*3600*24" . " and begin_time<" . time())->order(array("recommend_level" => "desc"))->limit("10")->select();
$dm_items[1] = M("dm_items")->where("item_check=1 and " . time() . "-begin_time<time*3600*24" . " and begin_time<" . time())->order(array("(fund_sup+sup)" => "desc"))->limit("10")->select();
$dm_items[2] = M("dm_items")->where("item_check=1 and " . time() . "-begin_time<time*3600*24" . " and begin_time<" . time())->order(array("(fund_gain+gain)" => "desc"))->limit("10")->select();
$dm_items[3] = M("dm_items")->where("item_check=1 and " . time() . "-begin_time<time*3600*24" . " and begin_time<" . time())->order(array("begin_time" => "asc"))->limit("10")->select();
if ($dm_items) {
for ($j = 0; $j < 4; $j++) {
$i = 0;
while ($dm_items[$j][$i]) {
$dm_items[$j][$i]["remaining_day"] = $dm_items[$j][$i]["time"] - floor((time() - $dm_items[$j][$i]["begin_time"]) / 24 / 3600);
$dm_items[$j][$i]["gain"] = sprintf("%.1f", $dm_items[$j][$i]["gain"] + $dm_items[$j][$i]["fund_gain"]);
$dm_items[$j][$i]["gained"] = ceil($dm_items[$j][$i]["gain"] / $dm_items[$j][$i]["money"] * 100);
$dm_items[$j][$i]["sup"] = $dm_items[$j][$i]["sup"] + $dm_items[$j][$i]["fund_sup"];
// $dm_items[$i]["gain"]=substr($dm_items[$i]["gain"],0,strpos($dm_items[$i]["gain"],".")).'.'.ceil(substr($dm_items[$i]["gain"],strpos($dm_items[$i]["gain"],".")+1,strpos($dm_items[$i]["gain"],".")+2)/100.0);
if (strlen($dm_items[$j][$i]["items_description"]) > 50) {
$dm_items[$j][$i]["items_description"] = mb_substr($dm_items[$j][$i]["items_description"], 0, 50, "UTF-8") . "...";
}
$i++;
}
}
}
$this->ajaxReturn($dm_items, "json");
}
示例13: run
public static function run()
{
if (empty($_GET['s'])) {
$_GET = array_merge(array('m' => 'index', 'c' => 'index', 'a' => 'index'), $_GET);
//设置默认值
} else {
if ($suffix = C('URL_SUFFIX')) {
$_GET['s'] = str_replace($suffix, '', $_GET['s']);
}
$_GET['s'] = trim($_GET['s'], '/');
//去除左右的/防止干扰
self::router();
//路由校验
self::parseSuperVar();
//解析超级变量
}
//module映射
$mapModule = C('map_module', null, array());
if (isset($mapModule[$_GET['m']])) {
halt('当前模块已经改名', __FILE__, __LINE__ - 1);
} elseif (in_array($_GET['m'], $mapModule)) {
$_GET['m'] = array_search($_GET['m'], $mapModule);
}
$_REQUEST = array_merge($_GET, $_POST);
}
示例14: daemons_servers_delete
function daemons_servers_delete()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$server_id = intval(params('server_id'));
$daemon_id = intval(params('daemon_id'));
$arrService = $db->select("SELECT id\n FROM {$cfg['tblService']}\n WHERE server_id='{$server_id}'\n AND daemon_id='{$daemon_id}'");
if (!$arrService) {
halt(SERVER_ERROR);
return;
}
$id = $arrService[0]['id'];
$result = $db->delete("DELETE FROM {$cfg['tblService']}\n WHERE id='{$id}'\n LIMIT 1");
$resultForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE dienst_id='{$id}'");
if (!$result || !$resultForeign) {
halt(SERVER_ERROR);
return;
}
set('server', array('id' => $server_id));
set('daemon', array('id' => $daemon_id));
if (isAjaxRequest()) {
return js('daemons_servers/delete.js.php', null);
} else {
halt(HTTP_NOT_IMPLEMENTED);
}
}
示例15: login
public function login()
{
if (!IS_POST) {
halt('页面不存在');
}
$username = I('username');
$password = I('password', '', 'md5');
$user = M('user')->where(array('username' => $username))->find();
if (!$user || $password != $user['password']) {
$this->error('登陆失败');
}
//更新登陆信息
$date = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
M('user')->save($date);
//为session写入数据
//$_SESSION['uid']=$user['id'];
//$_SESSION['username']=$user['username'];
//$_SESSION['loginip']=$user['loginip'];
//$_SESSION['logintime']=$user['logintime'];
session('uid', $user['id']);
session('username', $user['username']);
session('loginip', $user['loginip']);
session('logintime', date('Y-m-d H:i:s', $user['logintime']));
$this->redirect('Admin/Index/index');
}