public function run(&$content) { if (isset($_GET['m']) && $_GET['m'] === 'Install') { return; } $data = S('hooks'); if (!$data) { $hooks = M('Hooks')->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('Addons')->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } }
public function run(&$content) { if (defined('BIND_MODULE') && BIND_MODULE === 'Install') { return; } $data = S('hooks'); if (!$data) { $hooks = M('hooks')->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = (array) M('addons')->where($map)->getField('id,name'); $data_plugin = (array) M('plugin')->where($map)->getField('id,name'); $data = array_merge($data, $data_plugin); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } }
/** * 查询指定分类的详细信息 * @param int $info detail 查询的 id 或者slug */ public function detail($info = 1) { if (get_opinion("auto_channel", false, false)) { $this->channel($info); Hook::listen('app_end'); die; } $CatsLogic = new CatsLogic(); $PostsLogic = new PostsLogic(); $cat = $CatsLogic->detail($info); // $this->assign('cat_id', $cat['cat_id']); // 赋值数据集 $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了"); //优雅的404 $posts_id = $CatsLogic->getPostsId($cat['cat_id']); $count = sizeof($posts_id); $count == 0 ? $res404 = 0 : ($res404 = 1); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $posts_list = $PostsLogic->getList($limit, 'single', 'post_date desc', true, array(), $posts_id); } $this->assign('title', '分类 ' . $cat['cat_name'] . ' 所有文章'); // 赋值数据集 $this->assign('res404', $res404); $this->assign('postslist', $posts_list); // 赋值数据集 $this->assign('pager', $pager_bar); // 赋值分页输出 $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id'])); $this->display('Archive/single-list'); }
/** * 初始化方法 * @author jry <*****@*****.**> */ protected function _initialize() { // 系统开关 if (!C('TOGGLE_WEB_SITE')) { $this->error('站点已经关闭,请稍后访问~'); } // 获取所有模块配置的用户导航 $mod_con['status'] = 1; $_user_nav_main = array(); $_user_nav_list = D('Admin/Module')->where($mod_con)->getField('user_nav', true); foreach ($_user_nav_list as $key => $val) { if ($val) { $val = json_decode($val, true); $_user_nav_main = array_merge($_user_nav_main, $val['main']); } } // 监听行为扩展 \Think\Hook::listen('corethink_behavior'); $this->assign('meta_keywords', C('WEB_SITE_KEYWORD')); $this->assign('meta_description', C('WEB_SITE_DESCRIPTION')); $this->assign('_new_message', cookie('_new_message')); // 获取用户未读消息数量 $this->assign('_user_auth', session('user_auth')); // 用户登录信息 $this->assign('_user_nav_main', $_user_nav_main); // 用户导航信息 }
public function run(&$content) { if (!file_exist(UPLOAD_PATH . 'install.lock')) { return true; } $data = S('common_behavior_hooks'); if (!$data) { $hooks = M('hooks')->where(array('status' => 1))->getField('name, addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('addons')->where($map)->getField('id, name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('common_behavior_hooks', Hook::get()); } else { Hook::import($data, false); } }
/** * 行为扩展的执行入口必须是run * @author jry <*****@*****.**> */ public function run(&$content) { // 安装模式下直接返回 if (defined('BIND_MODULE') && BIND_MODULE === 'Install') { return; } // 添加插件配置 $addon_config['ADDON_PATH'] = './Addons/'; $addon_config['AUTOLOAD_NAMESPACE'] = C('AUTOLOAD_NAMESPACE'); $addon_config['AUTOLOAD_NAMESPACE']['Addons'] = $addon_config['ADDON_PATH']; C($addon_config); $data = S('hooks'); if (!$data || APP_DEBUG === true) { $hooks = D('Admin/Hook')->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = D('Admin/Addon')->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } }
public function run(&$params) { if (!defined('BUILD_LITE_FILE')) { return; } $litefile = C('RUNTIME_LITE_FILE', null, RUNTIME_PATH . 'lite.php'); if (is_file($litefile)) { return; } $defs = get_defined_constants(true); $content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; if (MEMORY_LIMIT_ON) { $content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();'; } // 生成数组定义 unset($defs['user']['BUILD_LITE_FILE']); $content .= $this->buildArrayDefine($defs['user']) . '}'; // 读取编译列表文件 $filelist = is_file(CONF_PATH . 'lite.php') ? include CONF_PATH . 'lite.php' : array(THINK_PATH . 'Common/functions.php', COMMON_PATH . 'Common/function.php', CORE_PATH . 'Think' . EXT, CORE_PATH . 'Hook' . EXT, CORE_PATH . 'App' . EXT, CORE_PATH . 'Dispatcher' . EXT, CORE_PATH . 'Log' . EXT, CORE_PATH . 'Log/Driver/File' . EXT, CORE_PATH . 'Route' . EXT, CORE_PATH . 'Controller' . EXT, CORE_PATH . 'View' . EXT, CORE_PATH . 'Storage' . EXT, CORE_PATH . 'Storage/Driver/File' . EXT, CORE_PATH . 'Exception' . EXT, BEHAVIOR_PATH . 'ParseTemplateBehavior' . EXT, BEHAVIOR_PATH . 'ContentReplaceBehavior' . EXT); // 编译文件 foreach ($filelist as $file) { if (is_file($file)) { $content .= compile($file); } } // 处理Think类的start方法 $content = preg_replace('/\\$runtimefile = RUNTIME_PATH(.+?)(if\\(APP_STATUS)/', '\\2', $content, 1); $content .= "\nnamespace { Think\\Think::addMap(" . var_export(\Think\Think::getMap(), true) . ");"; $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(\Think\Hook::get(), true) . ');Think\\Think::start();}'; // 生成运行Lite文件 file_put_contents($litefile, strip_whitespace('<?php ' . $content)); }
/** * 发送数据到客户端 * @access public * @param mixed $data 数据 * @param string $type 返回类型 * @param bool $return 是否返回数据 * @return mixed */ public function send($data = [], $type = '', $return = false) { if ('' == $type) { $type = $this->type ?: (IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type')); } $type = strtolower($type); $data = $data ?: $this->data; if (!headers_sent() && isset($this->contentType[$type])) { header('Content-Type:' . $this->contentType[$type] . '; charset=utf-8'); } if (is_callable($this->transform)) { $data = call_user_func_array($this->transform, [$data]); } else { switch ($type) { case 'json': // 返回JSON数据格式到客户端 包含状态信息 $data = json_encode($data, JSON_UNESCAPED_UNICODE); break; case 'jsonp': // 返回JSON数据格式到客户端 包含状态信息 $handler = !empty($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler'); $data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');'; break; } } APP_HOOK && Hook::listen('return_data', $data); if ($return) { return $data; } echo $data; $this->isExit() && exit; }
/** * 初始化方法 * @author jry <*****@*****.**> */ protected function _initialize() { // 系统开关 if (!C('TOGGLE_WEB_SITE')) { $this->error('站点已经关闭,请稍后访问~'); } // 获取所有模块配置的用户导航 $mod_con['status'] = 1; $_user_nav_main = array(); $_user_nav_list = D('Admin/Module')->where($mod_con)->getField('user_nav', true); foreach ($_user_nav_list as $key => $val) { if ($val) { $val = json_decode($val, true); if ($val['main']) { $_user_nav_main = array_merge($_user_nav_main, $val['main']); } } } // 监听行为扩展 \Think\Hook::listen('corethink_behavior'); $this->assign('meta_keywords', C('WEB_SITE_KEYWORD')); $this->assign('meta_description', C('WEB_SITE_DESCRIPTION')); $this->assign('_new_message', cookie('_new_message')); // 获取用户未读消息数量 $this->assign('_user_auth', session('user_auth')); // 用户登录信息 $this->assign('_user_nav_main', $_user_nav_main); // 用户导航信息 $this->assign('_user_center_side', C('USER_CENTER_SIDE')); // 用户中心侧边 $this->assign('_user_login_modal', C('USER_LOGIN_MODAL')); // 用户登录弹窗 $this->assign('_home_public_layout', C('HOME_PUBLIC_LAYOUT')); // 页面公共继承模版 }
/** * @param mixed $content */ public function run(&$content) { /** * //真不知道说什么好。。。 * 这里 原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化 * so。。。。。 * */ if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') { } else { if (isset($_GET['m']) && strtolower($_GET['m']) == 'install') { return; } $data = S('hooks'); if (!$data) { $hooks = M('Hooks')->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('Addons')->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, $addons); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } } }
public function run(&$parms) { //安装时不执行 if (defined('BIND_MODULE') && BIND_MODULE === 'Install') { return; } $data = S('global_hooks'); if (!$data) { $hooks = M('Hooks', "common_")->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('Addons', "common_")->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('global_hooks', Hook::get()); } else { Hook::import($data, false); } }
public function GetUsers($UsersId, $Feild) { $where['userid'] = array('IN', $UsersId); $result = self::where($where)->field($Feild)->select(); if ($result !== false) { return $result; } else { \Think\Hook::listen('HomeLog', $parm = array('function' => 'GetUsers -> $result', 'logmsg' => 'result is false', 'level' => 'ALERT')); } }
public function SmsReady($mobile, $content) { $mobileids = $mobile . date('YmdHis'); $result = self::sendSMS($mobile, $content, $mobileids); if ($result != true) { \Think\Hook::listen('HomeLog', $parm = array('function' => 'SendSmsModel::SmsReady -> $result', 'logmsg' => 'result is false, ' . "{$result}", 'level' => 'ALERT')); return false; } return true; }
/** * 显示404页 * @function 404 ERROR 需要显示错误的信息 * * @param string $message */ public function error404($message = "非常抱歉,你需要的页面暂时不存在,可能它已经躲起来了。.") { $this->assign("message", $message); if (File::file_exists(T('Home@Index/404'))) { $this->display('Index/404'); } else { $this->show($message); } Hook::listen('app_end'); die; }
public function BlackNew($RecordId, $UserId) { $data = array('recordid' => $RecordId, 'userid' => $UserId, 'lasttime' => time()); $result = self::add($data); if ($result !== false) { return true; } else { return false; \Think\Hook::listen('HomeLog', $parm = array('function' => 'BlackNew -> $result', 'logmsg' => 'result is false', 'level' => 'ALERT')); } }
public function testExec() { $data['id'] = 0; $data['name'] = 'thinkphp'; $this->assertEquals(true, Hook::exec('\\tests\\thinkphp\\library\\think\\behavior\\One')); $this->assertEquals(false, Hook::exec('\\tests\\thinkphp\\library\\think\\behavior\\One', 'test', $data)); $this->assertEquals('test', $data['name']); $this->assertEquals('Closure', Hook::exec(function (&$data) { $data['name'] = 'Closure'; return 'Closure'; })); }
/** * @todo: 发送评论 * @author Saki <*****@*****.**> * @date 2014-12-22 上午9:34:18 * @version V1.0 */ public function PostComment() { $model = new \Admin\Model\ArticleCommentModel(); $post = $_POST['ArticleComment']; $id = $post['aid']; $comment_id = $model->createComment($post); //发送邮件,这里为游客发送评论,则为管理员邮箱收到邮件 if ($comment_id) { \Think\Hook::listen('postComment', $comment_id); \Think\Hook::add('postComment', 'Home\\Behaviors\\emailBehavior'); } $this->redirect('Article/view', array('id' => $id, 'p' => 1)); }
/** * @todo: 发送评论-后台管理员发送 * @author Saki <*****@*****.**> * @date 2014-12-22 上午9:34:18 * @version V1.0 */ public function PostComment() { $model = new \Admin\Model\ArticleCommentModel(); $post = $_POST['ArticleComment']; $id = $post['aid']; $admin_info = $this->admin_info; $post['is_admin'] = $admin_info['id']; $comment_id = $model->createComment($post); if ($comment_id) { \Think\Hook::listen('postComment', $comment_id); \Think\Hook::add('postComment', 'Home\\Behaviors\\emailBehavior'); } $this->redirect('ArticleList/view', array('id' => $id, 'p' => 1)); }
public function ajax_add(&$json) { $offset = I('offset'); $data['content'] = I('content'); Hook::listen('hy_filter', $data['content']); $data['user_id'] = ss_uid(); $data['create_time'] = time(); $data['anonymous'] = 0; if (false === $this->add($data)) { return $json['info'] = $this->getError(); } $json['status'] = true; $json['data'] = $this->lists($offset); }
public function app_init() { $bags = self::$tags; foreach ($bags as $hook => $classes) { foreach ($classes as $class) { $tags = Hook::get($hook); if (class_exists($class)) { if (!array_search($class, $tags)) { Hook::add($hook, $class); } } } } }
/** * 用户存放在数据库中的配置,覆盖config中的 */ function customConfig() { $customConfig = S('customConfig'); if ($customConfig && APP_Cache) { $options = $customConfig; } else { $options = D('Options')->where(array('autoload' => 'yes'))->select(); if (APP_Cache) { S('customConfig', $options); } } foreach ($options as $config) { C($config['option_name'], $config['option_value']); } Hook::listen('base_customConfig'); }
/** * 初始化方法 * @author jry <*****@*****.**> */ protected function _initialize() { // 系统开关 if (!C('TOGGLE_WEB_SITE')) { $this->error('站点已经关闭,请稍后访问~'); } // 监听行为扩展 try { \Think\Hook::listen('corethink_behavior'); } catch (\Exception $e) { file_put_contents(RUNTIME_PATH . 'error.json', json_encode($e->getMessage())); } // 记录当前url if (MODULE_NAME !== 'User' && IS_GET === true) { cookie('forward', (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"]); } }
public function getWeiboDetail($id) { $weibo = S('weibo_' . $id); $check_empty = empty($weibo); if ($check_empty) { $weibo = $this->where(array('status' => 1, 'id' => $id))->find(); if (!$weibo) { return null; } $weibo_data = unserialize($weibo['data']); $class_exists = true; $type = array('repost', 'feed', 'image', 'share'); if (!in_array($weibo['type'], $type)) { $class_exists = class_exists('Addons\\Insert' . ucfirst($weibo['type']) . '\\Insert' . ucfirst($weibo['type']) . 'Addon'); } $weibo['content'] = parse_topic(parse_weibo_content($weibo['content'])); if ($weibo['type'] === 'feed' || $weibo['type'] == '' || !$class_exists) { $fetchContent = "<p class='word-wrap'>" . $weibo['content'] . "</p>"; } elseif ($weibo['type'] === 'repost') { $fetchContent = A('Weibo/Type')->fetchRepost($weibo); } elseif ($weibo['type'] === 'image') { $fetchContent = A('Weibo/Type')->fetchImage($weibo); } elseif ($weibo['type'] === 'share') { $fetchContent = R('Weibo/Share/getFetchHtml', array('param' => unserialize($weibo['data']), 'weibo' => $weibo), 'Widget'); } else { $fetchContent = Hook::exec('Addons\\Insert' . ucfirst($weibo['type']) . '\\Insert' . ucfirst($weibo['type']) . 'Addon', 'fetch' . ucfirst($weibo['type']), $weibo); } $weibo = array('id' => intval($weibo['id']), 'content' => strval($weibo['content']), 'create_time' => intval($weibo['create_time']), 'type' => $weibo['type'], 'data' => unserialize($weibo['data']), 'weibo_data' => $weibo_data, 'comment_count' => intval($weibo['comment_count']), 'repost_count' => intval($weibo['repost_count']), 'can_delete' => 0, 'is_top' => $weibo['is_top'], 'uid' => $weibo['uid'], 'fetchContent' => $fetchContent, 'from' => $weibo['from']); S('weibo_' . $id, $weibo, 60 * 60); } $weibo['fetchContent'] = parse_at_users($weibo['fetchContent']); $weibo['user'] = query_user(array('uid', 'nickname', 'avatar64', 'space_url', 'rank_link', 'title'), $weibo['uid']); $weibo['can_delete'] = $this->canDeleteWeibo($weibo); // 判断转发的原微博是否已经删除 if ($weibo['type'] == 'repost') { $source_weibo = $this->getWeiboDetail($weibo['weibo_data']['sourceId']); if (!$source_weibo['uid']) { if (!$check_empty) { S('weibo_' . $id, null); $weibo = $this->getWeiboDetail($id); } } } return $weibo; }
public function run(&$content) { if (isset($_GET['g']) && strtolower($_GET['g']) === 'install') { return; } $data = S('hooks'); if (!$data) { is_array($plugins = M('Plugins')->where("status=1")->getField("name,hooks")) ? null : ($plugins = array()); foreach ($plugins as $plugin => $hooks) { if ($hooks) { $hooks = explode(",", $hooks); foreach ($hooks as $hook) { Hook::add($hook, $plugin); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } }
public function index() { $admin_config = new AdminConfigBuilder(); $data = $admin_config->handleConfig(); $mStep = A('Ucenter/RegStep', 'Widget')->mStep; $step = array(); foreach ($mStep as $key => $v) { $step[] = array('data-id' => $key, 'title' => $v); } $default = array(array('data-id' => 'disable', 'title' => '禁用', 'items' => $step), array('data-id' => 'enable', 'title' => '启用', 'items' => array())); //$default=array('禁用'=>$step,'启用并可跳过'=>array(),'启用但不可跳过'=>array()); $data['REG_STEP'] = $admin_config->parseKanbanArray($data['REG_STEP'], $step, $default); empty($data['LEVEL']) && ($data['LEVEL'] = <<<str 0:Lv1 实习 50:Lv2 试用 100:Lv3 转正 200:Lv4 助理 400:Lv 5 经理 800:Lv6 董事 1600:Lv7 董事长 str ); empty($data['OPEN_QUICK_LOGIN']) && ($data['OPEN_QUICK_LOGIN'] = 0); empty($data['LOGIN_SWITCH']) && ($data['LOGIN_SWITCH'] = 'username'); $addons = \Think\Hook::get('sms'); $opt = array('none' => '无'); foreach ($addons as $name) { if (class_exists($name)) { $class = new $name(); $config = $class->getConfig(); if ($config['switch']) { $opt[$class->info['name']] = $class->info['title']; } } } $admin_config->title('用户配置')->data($data)->keyCheckBox('REG_SWITCH', '注册开关', '允许使用的注册选项,全不选即为关闭注册', array('username' => '用户名', 'email' => '邮箱', 'mobile' => '手机'))->keyRadio('EMAIL_VERIFY_TYPE', '邮箱验证类型', '邮箱验证的类型', array(0 => '不验证', 1 => '注册后发送激活邮件', 2 => '注册前发送验证邮件'))->keyRadio('MOBILE_VERIFY_TYPE', '手机验证类型', '手机验证的类型', array(0 => '不验证', 1 => '注册前发送验证短信'))->keyText('NEW_USER_FOLLOW', '新用户关注', '输入用户id,多个用户以‘,’分割')->keyText('NEW_USER_FANS', '新用户粉丝', '输入用户id,多个用户以‘,’分割')->keyText('NEW_USER_FRIENDS', '新用户好友', '输入用户id,多个用户以‘,’分割')->keyKanban('REG_STEP', '注册步骤', '注册后需要进行的步骤')->keyCheckBox('REG_CAN_SKIP', '注册步骤是否可跳过', '勾选为可跳过,默认不可跳过', $mStep)->keyEditor('REG_EMAIL_VERIFY', '邮箱验证模版', '用于进行邮箱的验证,必填{$verify}验证码,{$account}账号', 'all')->keyEditor('REG_EMAIL_ACTIVATE', '邮箱激活模版', '用于进行用户的激活,必填{$url}激活链接,{$title}网站名称')->keySelect('SMS_HOOK', '短信发送服务商', '短信发送服务商,需要安装插件', $opt)->keyText('SMS_RESEND', '短信重发时间', '短信重发时间')->keyText('SMS_UID', '短信平台帐号', '短信平台帐号')->keyText('SMS_PWD', '短信平台密码', '短信平台密码')->keyTextArea('SMS_CONTENT', '短信内容', '短信内容,必填{$verify}验证码,{$account}账号')->keyTextArea('LEVEL', '等级配置', '每行一条,名称和积分之间用冒号分隔')->keyInteger('NICKNAME_MIN_LENGTH', '昵称长度最小值')->keyDefault('NICKNAME_MIN_LENGTH', 2)->keyInteger('NICKNAME_MAX_LENGTH', '昵称长度最大值')->keyDefault('NICKNAME_MAX_LENGTH', 32)->keyInteger('USERNAME_MIN_LENGTH', '用户名长度最小值')->keyDefault('USERNAME_MIN_LENGTH', 2)->keyInteger('USERNAME_MAX_LENGTH', '用户名长度最大值')->keyDefault('USERNAME_MAX_LENGTH', 32)->keyRadio('OPEN_QUICK_LOGIN', '快捷登录', '默认关闭,开启后用户登录方式更换成快捷登录!', array(0 => '关闭', 1 => '开启'))->keyCheckBox('LOGIN_SWITCH', '登录提示开关', '仅用于登录框的提示作用', array('username' => '用户名', 'email' => '邮箱', 'mobile' => '手机'))->group('注册配置', 'REG_SWITCH,EMAIL_VERIFY_TYPE,MOBILE_VERIFY_TYPE,REG_STEP,REG_CAN_SKIP,NEW_USER_FOLLOW,NEW_USER_FANS,NEW_USER_FRIENDS')->group('登录配置', 'OPEN_QUICK_LOGIN,LOGIN_SWITCH')->group('邮箱验证模版', 'REG_EMAIL_VERIFY')->group('邮箱激活模版', 'REG_EMAIL_ACTIVATE')->group('短信配置', 'SMS_HTTP,SMS_UID,SMS_PWD,SMS_CONTENT,SMS_HOOK,SMS_RESEND')->group('基础设置', 'LEVEL,NICKNAME_MIN_LENGTH,NICKNAME_MAX_LENGTH,USERNAME_MIN_LENGTH,USERNAME_MAX_LENGTH')->buttonSubmit('', '保存')->keyDefault('REG_EMAIL_VERIFY', '您的验证码为{$verify}验证码,账号为{$account}。')->keyDefault('REG_EMAIL_ACTIVATE', '您在{$title}的激活链接为<a href="{$url}" target="_blank">激活</a>,或者请复制链接:{$url}到浏览器打开。')->keyDefault('SMS_CONTENT', '您的校验码为{$verify},注册账号为{$account}')->keyDefault('SMS_RESEND', '60'); $admin_config->display(); }
public function index() { $admin_config = new AdminConfigBuilder(); $data = $admin_config->handleConfig(); $mStep = A('Ucenter/RegStep', 'Widget')->mStep; $step = array(); foreach ($mStep as $key => $v) { $step[] = array('data-id' => $key, 'title' => $v); } $default = array(array('data-id' => 'disable', 'title' => L('_DISABLE_'), 'items' => $step), array('data-id' => 'enable', 'title' => L('_ENABLE_'), 'items' => array())); //$default=array(L('_DISABLE_')=>$step,L('_ENABLE_AND_SKIP_')=>array(),L('_ENABLE_BUT_NOT_SKIP_')=>array()); $data['REG_STEP'] = $admin_config->parseKanbanArray($data['REG_STEP'], $step, $default); empty($data['LEVEL']) && ($data['LEVEL'] = <<<str 0:Lv1 实习 50:Lv2 试用 100:Lv3 转正 200:Lv4 助理 400:Lv 5 经理 800:Lv6 董事 1600:Lv7 董事长 str ); empty($data['OPEN_QUICK_LOGIN']) && ($data['OPEN_QUICK_LOGIN'] = 0); empty($data['LOGIN_SWITCH']) && ($data['LOGIN_SWITCH'] = 'username'); $addons = \Think\Hook::get('sms'); $opt = array('none' => L('_NONE_')); foreach ($addons as $name) { if (class_exists($name)) { $class = new $name(); $config = $class->getConfig(); if ($config['switch']) { $opt[$class->info['name']] = $class->info['title']; } } } $admin_config->title(L('_USER_CONFIGURATION_'))->data($data)->keyCheckBox('REG_SWITCH', L('_REGISTRATION_SWITCH_'), L('_THE_REGISTRATION_OPTION_THAT_ALLOWS_THE_USE_OF_THE_REGISTRATION_IS_CLOSED_'), array('username' => L('_USER_NAME_'), 'email' => L('_MAILBOX_'), 'mobile' => L('_MOBILE_PHONE_')))->keyRadio('EMAIL_VERIFY_TYPE', L('_MAILBOX_VERIFICATION_TYPE_'), L('_TYPE_MAILBOX_VERIFICATION_'), array(0 => L('_NOT_VERIFIED_'), 1 => L('_POST_REGISTRATION_ACTIVATION_MAIL_'), 2 => L('_EMAIL_VERIFY_SEND_BEFORE_REG_')))->keyRadio('MOBILE_VERIFY_TYPE', L('_MOBILE_VERIFICATION_TYPE_'), L('_TYPE_OF_CELL_PHONE_VERIFICATION_'), array(0 => L('_NOT_VERIFIED_'), 1 => L('_REGISTER_BEFORE_SENDING_A_VALIDATION_MESSAGE_')))->keyText('NEW_USER_FOLLOW', L('_NEW_USER_ATTENTION_'), L('_ID_INPUT_SEPARATE_COMMA_'))->keyText('NEW_USER_FANS', L('_NEW_USER_FANS_'), L('_ID_INPUT_SEPARATE_COMMA_'))->keyText('NEW_USER_FRIENDS', L('_NEW_FRIENDS_'), L('_ID_INPUT_SEPARATE_COMMA_'))->keyKanban('REG_STEP', L('_REGISTRATION_STEP_'), L('_STEPS_TO_BE_MADE_AFTER_REGISTRATION_'))->keyCheckBox('REG_CAN_SKIP', L('_WHETHER_THE_REGISTRATION_STEP_CAN_BE_SKIPPED_'), L('_CHECK_TO_SKIP_AND_YOU_CANT_SKIP_THE_DEFAULT_'), $mStep)->keyEditor('REG_EMAIL_VERIFY', L('_MAILBOX_VERIFICATION_TEMPLATE_'), L('_PLEASE_EMAIL_VERIFY_'), 'all')->keyEditor('REG_EMAIL_ACTIVATE', L('_MAILBOX_ACTIVATION_TEMPLATE_'), L('_PLEASE_USER_ACTIVE_'))->keySelect('SMS_HOOK', L('_SMS_SENDING_SERVICE_PROVIDER_'), L('_SMS_SEND_SERVICE_PROVIDERS_NEED_TO_INSTALL_THE_PLUG-IN_'), $opt)->keyText('SMS_RESEND', L('_THE_MESSAGE_RETRANSMISSION_TIME_'), L('_THE_MESSAGE_RETRANSMISSION_TIME_'))->keyText('SMS_UID', L('_SMS_PLATFORM_ACCOUNT_NUMBER_'), L('_SMS_PLATFORM_ACCOUNT_NUMBER_'))->keyText('SMS_PWD', L('_SMS_PLATFORM_PASSWORD_'), L('_SMS_PLATFORM_PASSWORD_'))->keyTextArea('SMS_CONTENT', L('_MESSAGE_CONTENT_'), L('_MSG_VERICODE_ACCOUNT_'))->keyTextArea('LEVEL', L('_HIERARCHY_'), L('_ONE_PER_LINE_BETWEEN_THE_NAME_AND_THE_INTEGRAL_BY_A_COLON_'))->keyInteger('NICKNAME_MIN_LENGTH', L('_NICKNAME_LENGTH_MINIMUM_'))->keyDefault('NICKNAME_MIN_LENGTH', 2)->keyInteger('NICKNAME_MAX_LENGTH', L('_NICKNAME_LENGTH_MAXIMUM_'))->keyDefault('NICKNAME_MAX_LENGTH', 32)->keyInteger('USERNAME_MIN_LENGTH', L('_USERNAME_LENGTH_MINIMUM_'))->keyDefault('USERNAME_MIN_LENGTH', 2)->keyInteger('USERNAME_MAX_LENGTH', L('_USERNAME_LENGTH_MAXIMUM_'))->keyDefault('USERNAME_MAX_LENGTH', 32)->keyRadio('OPEN_QUICK_LOGIN', L('_QUICK_LOGIN_'), L('_BY_DEFAULT_AFTER_THE_USER_IS_LOGGED_IN_THE_USER_IS_LOGGED_IN_'), array(0 => L('_OFF_'), 1 => L('_OPEN_')))->keyCheckBox('LOGIN_SWITCH', L('_LOGIN_PROMPT_SWITCH_'), L('_JUST_THE_TIP_OF_THE_LOGIN_BOX_'), array('username' => L('_USER_NAME_'), 'email' => L('_MAILBOX_'), 'mobile' => L('_MOBILE_PHONE_')))->group(L('_REGISTER_CONFIGURATION_'), 'REG_SWITCH,EMAIL_VERIFY_TYPE,MOBILE_VERIFY_TYPE,REG_STEP,REG_CAN_SKIP,NEW_USER_FOLLOW,NEW_USER_FANS,NEW_USER_FRIENDS')->group(L('_LOGIN_CONFIGURATION_'), 'OPEN_QUICK_LOGIN,LOGIN_SWITCH')->group(L('_MAILBOX_VERIFICATION_TEMPLATE_'), 'REG_EMAIL_VERIFY')->group(L('_MAILBOX_ACTIVATION_TEMPLATE_'), 'REG_EMAIL_ACTIVATE')->group(L('_SMS_CONFIGURATION_'), 'SMS_HTTP,SMS_UID,SMS_PWD,SMS_CONTENT,SMS_HOOK,SMS_RESEND')->group(L('_BASIC_SETTINGS_'), 'LEVEL,NICKNAME_MIN_LENGTH,NICKNAME_MAX_LENGTH,USERNAME_MIN_LENGTH,USERNAME_MAX_LENGTH')->buttonSubmit('', L('_SAVE_'))->keyDefault('REG_EMAIL_VERIFY', L('_VERICODE_ACCOUNT_') . L('_PERIOD_'))->keyDefault('REG_EMAIL_ACTIVATE', L('_LINK_ACTIVE_IS_'))->keyDefault('SMS_CONTENT', L('_VERICODE_ACCOUNT_'))->keyDefault('SMS_RESEND', '60'); $admin_config->display(); }
/** * 下载文件 */ public function download_site() { $site_id = I('site_id', session('site_info.id')); if (empty($site_id)) { return $this->error('请选择网站'); } $site_info = M()->table('site_info')->field('site_name,url,json')->where(array('id' => $site_id, 'user_id' => session('user_info.id'), 'status' => 0))->find(); if (empty($site_info)) { return $this->error('此网站无效'); } $info = M()->table('user_column')->where(array('site_id' => $site_id, 'forbidden' => 0))->order('sort')->select(); if (empty($info)) { return $this->error('没有找到文件'); } $rootpath = C('TEMP_DIR') . $site_info['url'] . "/"; if (is_dir($rootpath)) { deleteAll($rootpath, true); } elseif (!mkdir($rootpath)) { return $this->error('创建根目录失败'); } $public_rootpath = $rootpath . "Public/"; if (!mkdir($public_rootpath)) { return $this->error('创建Public目录失败'); } /*=================================生成html==============================*/ $html_rootpath = $rootpath . "html/"; if (!mkdir($html_rootpath)) { return $this->error('创建html目录失败'); } $user_info = M()->table('user_info')->field('nickname,head_img')->find(session('user_info')['id']); $site_common = A('Panel')->get_site_common($site_id); $theme_templet = $site_common['theme_templet']; unset($site_common['theme_templet']); $this->collect_link($site_common['theme_links']); //var_dump($site_common['theme_links']); $this->assign($site_common); $this->assign('user_info', $user_info); $this->assign('download', true); /*==================生成栏目页===================*/ foreach ($info as $key => $value) { $widget_common = A('Panel')->resolve_json($site_id, $value['html']); $this->collect_link($widget_common['links']); $links = array_merge_recursive($site_common['theme_links'], $widget_common['links']); $this->assign($links); $this->assign('now_column', $value['id']); $this->assign('content', $widget_common['content']); $html = $this->fetch('Theme/theme'); $html = $this->replaceHtml($html); $result = file_put_contents($html_rootpath . $value['url'] . '.html', $html); if (!$result) { ////***删除文件**/// deleteAll($rootpath); return $this->error('下载失败:html失败'); } } /*==================生成详情页===================*/ $desc = json_decode($site_info['json'], true); foreach ($desc as $key => $value) { $desc_info = D($key)->get_all_info($site_id); $desc_path = $rootpath . '/' . $key . '/'; if (!mkdir($desc_path)) { deleteAll($rootpath); return $this->error('创建$key目录失败'); } $widget = A('Panel')->load_widget(ucwords(strtolower($key)) . 'Desc', $value); $widget_link = $widget->load_template_link(); $this->collect_link($widget_link, $rootpath); $links = array_merge_recursive($site_common['theme_links'], $widget_link); $this->assign($links); foreach ($desc_info as $desc_key => $desc_resource) { ob_start(); ob_implicit_flush(0); $widget->index($site_id, null, $desc_resource); $content = ob_get_clean(); \Think\Hook::listen('view_filter', $content); $this->assign('content', $content); $html = $this->fetch('Theme/theme'); $html = $this->replaceHtml($html); $result = file_put_contents($desc_path . $desc_resource['id'] . '.html', $html); if (!$result) { ////***删除文件**/// deleteAll($rootpath); return $this->error('下载失败:article失败'); } } } /*=================================引入资源文件==============================*/ /*=============引入js css=============*/ $this->download_theme_link($public_rootpath, $site_common['site_ifno']['theme']); $this->download_widget_link($public_rootpath); /*=============引入img=============*/ $img_path = $rootpath . 'Uploads/'; $photo_info = M()->table('photo as a')->field('c.savename,c.savepath')->join('home_picture as c on a.pic_id = c.id')->where(array('a.site_id' => $site_id))->select(); $admin_column_info = M()->table('user_column as a')->field('b.savename,b.savepath')->join('left join picture as b on a.icon = b.id')->where(array('a.site_id' => $site_id, 'a.is_default' => 1))->select(); $home_column_info = M()->table('user_column as a')->field('b.savename,b.savepath')->join('left join home_picture as b on a.icon = b.id')->where(array('a.site_id' => $site_id, 'a.is_default' => 0))->select(); $article_info = M()->table('article as a')->field('b.savename,b.savepath')->join('left join home_picture as b on a.pic_id = b.id')->where(array('a.site_id' => $site_id))->select(); $img_info = array_merge($photo_info, $admin_column_info, $home_column_info, $article_info); $uploads_path = C('PICTURE_UPLOAD')['rootPath']; foreach ($img_info as $key => $value) { hCopy($uploads_path . $value['savepath'] . $value['savename'], $img_path . $value['savepath'] . $value['savename']); } /*========================生成zip==============================*/ load("@.HZip#class"); $zip_name = C('TEMP_DIR') . $site_info['url'] . '.zip'; $zip = \HZip::zipDir(C('TEMP_DIR') . $site_info['url'], $zip_name); /*========================下载==================================*/ header("Cache-Control: max-age=0"); header("Content-Description: File Transfer"); header('Content-disposition: attachment; filename=' . basename($zip_name)); // 文件名 header("Content-Type: application/zip"); // zip格式的 header("Content-Transfer-Encoding: binary"); //二进制文件 header('Content-Length: ' . filesize($zip_name)); // 告诉浏览器,文件大小 @readfile($zip_name); //输出文件; unlink($zip_name); deleteAll($rootpath); }
/** * 执行某个行为 * @param string $name 行为名称 * @param string $tag 标签名称(行为类无需传入) * @param Mixed $params 传入的参数 * @return void */ function B($name, $tag = '', &$params = NULL) { if ('' == $tag) { $name .= 'Behavior'; } \Think\Hook::exec($name, $tag, $params); }
public function showHookAction() { dump(Hook::get()); }
/** * 处理插件钩子 * @param string $hook 钩子名称 * @param mixed $params 传入参数 * @return void * @author jry <*****@*****.**> */ function hook($hook, $params = array()) { \Think\Hook::listen($hook, $params); }