/**
  * 入口
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-09-27 17:26:23
  * @lastmodify      2013-01-22 11:02:32 by mrmsl
  *
  * @return void 无返回值
  */
 public function indexAction()
 {
     $module = Filter::get('module', 'get');
     //模块
     $error = '';
     if (!APP_DEBUG) {
         //非调试模式
         if (!REFERER_PAGER) {
             $error = L('REFERER_PAGER,IS_EMPTY');
         } elseif (strpos(REFERER_PAGER, WEB_SITE_URL) === false) {
             $error = L('REFERER_PAGER') . '(' . REFERER_PAGER . ')' . L('IS_EMPTY');
         }
     }
     if (!$error) {
         if (!$module) {
             $error = 'module' . L('IS_EMPTY');
         } elseif (!in_array($module, $this->_verifycode_module)) {
             $error = 'module not in (' . join(',', $this->_verifycode_module) . ')';
         } else {
             $verifycode_setting = get_verifycode_setting($module);
             //验证码设置
             //未开启验证码
             if (!$verifycode_setting['enable']) {
                 $default_setting = get_verifycode_setting('sys', 'enable');
                 //默认设置
                 $error = L('NOT_HAS,TURN_ON') . "(module:{$verifycode_setting['enable']}|sys:{$default_setting})";
             }
         }
     }
     if ($error) {
         //有错误
         $log = get_method_line(__METHOD__, __LINE__, LOG_VERIFYCODE_ERROR) . L('VERIFY_CODE') . "({$module})" . $error;
         trigger_error($log);
         $exit = true;
     } elseif (!check_verifycode_limit($module, 'refresh')) {
         //刷新次数限制
         $exit = true;
     }
     if (!empty($exit)) {
         header('Content-type: image/png');
         readfile(IMGCACHE_PATH . 'common/images/verifycode_error.png');
         exit;
     }
     $width = $verifycode_setting['width'];
     //宽
     $height = $verifycode_setting['height'];
     //高
     $length = $verifycode_setting['length'];
     //字母长
     $type = $verifycode_setting['type'];
     //类型
     $img = new Verifycode();
     $img->buildVerifyImage($verifycode_setting['length'], $verifycode_setting['type'], $verifycode_setting['width'], $verifycode_setting['height']);
 }
示例#2
0
/**
 * 获取验证码设置值
 *
 * @author          mrmsl <*****@*****.**>
 * @date            2012-09-28 09:38:21
 * @lastmodify      2013-01-22 17:16:27 by mrmsl
 *
 * @param string $module 模块
 * @param string $index  具体键值。默认''
 *
 * @return mixed 如果$index不为空,返回该健值,否则返回验证码设置值数组
 */
function get_verifycode_setting($module, $index = '')
{
    static $data = array();
    if (isset($data[$module])) {
        return $index ? $data[$module][$index] : $data[$module];
    } else {
        $data[$module] = array();
    }
    $key_arr = array('enable' => -1, 'width' => 0, 'height' => 0, 'length' => 0, 'order' => -1, 'refresh_limit' => '', 'error_limit' => '', 'case' => -1, 'type' => -1);
    $filename = 'sys' == $module ? 'System' : 'Module';
    $key = $module . '_verifycode_';
    if ('sys' == $module) {
        //用空间换时间
        foreach ($key_arr as $k => $v) {
            $data[$module][$k] = sys_config($key . $k, $filename);
        }
    } else {
        $default = get_verifycode_setting('sys');
        foreach ($key_arr as $k => $v) {
            $_v = sys_config($key . $k, $filename);
            if ('order' == $k && 'module_admin' == $module && -1 !== intval(C('T_VERIFYCODE_ORDER'))) {
                //管理员后台登陆验证码顺序
                $_v = C('T_VERIFYCODE_ORDER');
            }
            $data[$module][$k] = $v == $_v ? $default[$k] : $_v;
        }
    }
    return $index ? $data[$module][$index] : $data[$module];
}
示例#3
0
<?php

/**
 * 加载模板
 *
 * @file            include_template.php
 * @package         Yab\Admin
 * @version         0.2
 * @copyright       Copyright (c) 2013 {@link http://www.yablog.cn yablog} All rights reserved
 * @license         http://www.apache.org/licenses/LICENSE-2.0.html Apache License 2.0
 * @author          mrmsl <*****@*****.**>
 * @date            2013-10-05 15:51:19
 * @lastmodify      $Date$ $Author$
 */
//css文件
$css_file = css('Aqua/css/aqua-all.css,Gray/css/gray-all.css', COMMON_IMGCACHE . 'js/ligerui/skins/');
//ligerui样式
//js文件
$js_file = js('System.js,lang/' . MODULE_NAME . '.' . LANG . '.js', '/static/js/');
//系统信息,语言包
$js_file .= js('System.sys_base_admin_entry = "' . WEB_ADMIN_ENTRY . '";System.module_admin_verifycode_enable = ' . get_verifycode_setting('module_admin', 'enable') . ';var VERIFY_CODE_KEY = "' . SESSION_VERIFY_CODE . '"', 'script');
//后台入口
if (APP_DEBUG) {
    $require_js = (include APP_PATH . 'include/required_js.php');
    $js_file .= js($require_js);
} else {
    $js_file .= js('all.min.js', ADMIN_IMGCACHE . 'js/core/');
}
require TEMPLATE_FILE;
示例#4
0
 /**
  * 验证验证码是否正确
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-06-25 16:34:04
  * @lastmodify      2013-01-22 11:12:24 by mrmsl
  *
  * @param string $code   验证码
  * @param string $module 验证码模块
  *
  * @return mixed 如果正确,返回true,否则返回提示信息
  */
 protected function _checkVerifycode($code, $module)
 {
     if ($v = C('T_VERIFYCODE_MODULE')) {
         //动态设置模块 by mrmsl on 2013-05-21 11:42:23
         $module = $v;
     }
     $verifycode_setting = get_verifycode_setting($module);
     if (!$verifycode_setting['enable']) {
         //未开启验证码
         $this->_check_verifycode = true;
         //通过验证码检测
         return true;
     }
     if ($code === '') {
         //未输入验证码
         return false;
     }
     if (($checked = check_verifycode($code, $module)) === true) {
         //转至check_verifycode验证 by mrmsl on 2012-07-13 16:54:54
         $this->_check_verifycode = true;
         //通过验证码检测 by mrmsl on 2012-07-02 09:55:53
         return true;
     }
     $error = L('VERIFY_CODE,NOT_CORRECT');
     $log = get_method_line(__METHOD__, __LINE__, LOG_VERIFYCODE_ERROR) . $error . ': ';
     $log .= session(SESSION_VERIFY_CODE) . '(' . $verifycode_setting['order'] . ') => ' . $code;
     trigger_error($log);
     return $error;
 }
示例#5
0
 /**
  * 写System.js
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-05-20 21:52:36
  *
  * @param array $js_data        js数据
  * @param array $system_data    系统数据。默认null, 取sys_config()
  *
  * @return void 无返回值
  */
 protected function _writeSystemJsData($js_data, $system_data = null)
 {
     $system_data = null === $system_data ? sys_config() : $system_data;
     //管理员,留言,评论模块是开启验证码
     foreach (array('guestbook', 'comments') as $item) {
         foreach (array('enable', 'order', 'case') as $v) {
             $js_data['module_' . $item . '_verifycode_' . $v] = get_verifycode_setting('module_' . $item, $v);
         }
     }
     array2js($js_data, 'System', WWWROOT . $system_data['sys_base_js_path'] . 'System.js');
 }
示例#6
0
 /**
  * 验证验证码是否正确
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-06-25 16:34:04
  * @lastmodify      2013-01-22 11:12:24 by mrmsl
  *
  * @param string $code   验证码
  * @param string $module 验证码模块
  *
  * @return mixed 如果正确,返回true,否则返回提示信息
  */
 protected function _checkVerifycode($code, $module)
 {
     if ($v = C('T_VERIFYCODE_MODULE')) {
         //动态设置模块 by mrmsl on 2013-05-21 11:42:23
         $module = $v;
     }
     $verifycode_setting = get_verifycode_setting($module);
     if (!$verifycode_setting['enable']) {
         //未开启验证码
         $this->_check_verifycode = true;
         //通过验证码检测
         return true;
     }
     if ($code === '') {
         //未输入验证码
         return false;
     }
     if (($checked = check_verifycode($code, $module)) === true) {
         //转至check_verifycode验证 by mrmsl on 2012-07-13 16:54:54
         $this->_check_verifycode = true;
         //通过验证码检测 by mrmsl on 2012-07-02 09:55:53
         return true;
     }
     $this->addLog(session(SESSION_VERIFY_CODE) . '(' . $verifycode_setting['order'] . ') => ' . $code, LOG_TYPE_VERIFYCODE_ERROR);
     return L('VERIFY_CODE,NOT_CORRECT');
 }