public function auth() { if (preg_match('/{([0-9]+)}/', $this->auth, $role)) { $this->role = $role[1]; $role_obj = new Role(); $role_obj = $role_obj->find($this->role); $auths = $role_obj->auth; } else { $auths = explode(';', $this->auth); } $auths = array_filter(array_merge($auths, AuthCode::codes($this))); return $auths; }
<?php /** * 这个页面用于生成验证码图像 * * @author ♂bingo↗ [coolhpy@163.com] * @since 2006-6-17 */ session_start(); header("Cache-Control: no-cache, must-revalidate"); require "./AuthCode.class.php"; $auth_code = new AuthCode(); // 定义验证码信息 $arr['code'] = array('characters' => 'A-Z,1-9', 'length' => 4, 'deflect' => true, 'multicolor' => false); $auth_code->setCode($arr['code']); // 定义干扰信息 $arr['molestation'] = array('type' => 'both', 'density' => 'normal'); $auth_code->setMolestation($arr['molestation']); // 定义图像信息 $arr['image'] = array('type' => 'gif', 'width' => 70, 'height' => 20); $auth_code->setImage($arr['image']); // 定义字体信息 $arr['font'] = array('space' => 5, 'size' => 12, 'left' => 5, 'top' => 15, 'file' => 'arial.ttf'); $auth_code->setFont($arr['font']); // 定义背景色 $arr['bg'] = array('r' => 255, 'g' => 255, 'b' => 255); $auth_code->setBgColor($arr['bg']); // 输出到浏览器 $auth_code->paint(); // 输出到文件, 文件名中不需要扩展名 //$auth_code->paint('./test');
<? require('../../inc/admin/config.php'); $session->auth_or_redirect('su', '/', true); $admin_title = 'Manage Auth Codes'; $pg = (!empty($_GET['pg'])) ? addslashes($_GET['pg']) : '1'; include(ROOT.'/inc/admin/header.php'); $auth_codes = new AuthCode; $paginator = new Paginator($auth_codes->find()); ?> <p><a href="/admin">Back to Admin Home</a></p> <a href="./new.php"><img src="/images/admin/button_add.jpg" alt="Add New Auth Code" id="button_add" /></a> <div id="auth_codes_index"> <table> <tr> <th>Code</th> <th>Name</th> </tr> <?php foreach ($paginator->this_page() as $auth_code) { ?> <tr> <td><?php echo $auth_code->code; ?>
<?php include '../../inc/config.php'; $session->auth_or_redirect('admin', '/', true); $action = $_GET['f']; $todayDate = date('Y-m-d H:i:s'); switch ($action) { case 'new': $auth_code = new AuthCode(); $auth_code->create($_POST['auth_code']); $URL = './index.php'; break; case 'edit': parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)); $auth_code = new AuthCode(); $auth_code = $auth_code->find($id); $auth_code->update($_POST['auth_code']); $URL = './index.php'; break; case 'delete': parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY)); $auth_code = new AuthCode(); $auth_code = $auth_code->find($id); $auth_code->delete(); $URL = './index.php'; break; default: break; } header("Location: {$URL}"); include ROOT . '/inc/closedb.php';
$db->delete(TABLE_CZECH_SESSION, 'session_id = "' . $_COOKIE['session_id'] . '"'); setcookie('m_account', '', time() - $system_data['cookie_time'], '/'); setcookie('session_id', '', time() - $system_data['cookie_time'], '/'); header('location: /'); exit; } //登录 if ($do_act == 'login') { unset($do_act); if ($_SERVER['HTTP_REFERER'] !== 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) { header('location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } $param = array(); $param['m_account'] = $account; if (!empty($code)) { $auth_code = new AuthCode(); if (!$auth_code->validate($code)) { $param['msg'] = '校验码错误,请重新输入'; $param['codeNum'] = FAILURE_NUM; showTpl($smarty, $param); exit; } } $soapData = array(); $soap = new Soap_xjt(); $result = $soap->login($account, $pwd, $soapData); if ($result) { $_SESSION['login_failure'] = 0; //修改失败次数为0 $_SESSION['userData'] = $soapData; $u_ary = array('login_failure' => 0);
function imgcode($checkcode = '') { if (ispost() && !empty($checkcode)) { include_once ROOT_PATH . 'include/authcode.class.php'; //if (session_id() == "") session_start(); $img = new AuthCode(); return $img->validate($checkcode, false) ? true : false; } elseif (func_num_args() == 0) { return '<img onclick="this.src=\'../checkcode.php?\'+new Date().getTime()" style="cursor:pointer" title="点击刷新" src="../checkcode.php">'; } return false; }