/**
  *
  */
 private function _currentPostion()
 {
     //  echo CONTROLLER_NAME;
     //  echo ACTION_NAME;
     $cache = get_opinion('admin_big_menu');
     foreach ($cache as $big_url => $big_name) {
         if (strtolower($big_url) == strtolower(CONTROLLER_NAME)) {
             $module = $big_name;
             $module_url = U("Weixin/" . "{$big_url}" . '/index');
         } else {
         }
     }
     $cache = get_opinion('admin_sub_menu');
     foreach ($cache as $big_url => $big_name) {
         if (strtolower($big_url) == strtolower(CONTROLLER_NAME)) {
             foreach ($big_name as $sub_url => $sub_name) {
                 $sub_true_url = explode('/', $sub_url);
                 if (!strcasecmp($sub_true_url[1], strtolower(ACTION_NAME))) {
                     $action = $sub_name;
                     $action_url = U("Weixin/" . "{$sub_url}");
                 }
             }
         }
     }
     $this->assign('module', $module);
     $this->assign('action', $action);
     $this->assign('module_url', $module_url);
     $this->assign('action_url', $action_url);
 }
 /**
  * 注册用户
  * @param $username
  * @param $nickname
  * @param $password
  * @param $email
  * @return string
  */
 public function register($username, $nickname, $password, $email)
 {
     $new_user_role = get_opinion('new_user_role', true, 5);
     $new_user_statue = get_opinion('new_user_statue', true, 1);
     $User = new UserLogic();
     $userDetail = $User->where(array('user_login' => $username))->select();
     if ($userDetail != '') {
         return $this->jsonResult(0, "用户名已存在");
     } else {
         // 组合用户信息并添加
         $newUserDetail = array('user_login' => $username, 'user_nicename' => $nickname, 'user_pass' => encrypt($password), 'user_email' => $email, 'user_status' => $new_user_statue);
         // 添加用户与角色关系
         $newUserDetail['user_level'] = $new_user_role;
         $Role_users = D('Role_users');
         if ($new_id = $User->add($newUserDetail)) {
             $role = array('role_id' => $new_user_role, 'user_id' => $new_id);
             if ($Role_users->add($role)) {
                 return $this->jsonResult(1, "注册成功!", U('Admin/Access/index'));
             } else {
                 return $this->jsonResult(0, "注册成功,添加用户权限失败!");
             }
         } else {
             return $this->jsonResult(0, "注册用户失败");
         }
     }
 }
Пример #3
0
 /**
  * @return mixed
  */
 public function nodeList()
 {
     $cat = new Category('Node', array('id', 'pid', 'title', 'fullname'));
     $temp = $cat->getList();
     // 获取分类结构
     foreach ($temp as $key => $value) {
         if ($value['level'] = 1 && array_key_exists($value['name'], get_opinion('group_level_1'))) {
             $group_level_1 = get_opinion('group_level_1');
             $temp[$key]["remark"] = $group_level_1[$value['name']];
         } else {
             if ($value['level'] = 2 && array_key_exists($value['name'], get_opinion('admin_level_2'))) {
                 $admin_level_2 = get_opinion('admin_level_2');
                 $temp[$key]["remark"] = $admin_level_2[$value['name']];
             }
         }
     }
     $level = array("1" => "项目(GROUP_NAME)", "2" => "模块(MODEL_NAME)", "3" => "操作(ACTION_NAME)");
     foreach ($temp as $k => $v) {
         $temp[$k]['statusTxt'] = $v['status'] == 1 ? "启用" : "禁用";
         $temp[$k]['chStatusTxt'] = $v['status'] == 0 ? "启用" : "禁用";
         $temp[$k]['level'] = $level[$v['level']];
         $list[$v['id']] = $temp[$k];
     }
     unset($temp);
     return $list;
 }
Пример #4
0
 /**
  * 查询指定标签的详细信息
  * @param $info  detail 查询的 id 或者slug
  */
 public function detail($info)
 {
     $TagsLogic = new TagsLogic();
     $PostsLogic = new PostsLogic();
     $tag = $TagsLogic->detail($info);
     $this->if404($tag, "非常抱歉,没有这个标签,可能它已经躲起来了");
     $posts_id = $TagsLogic->getPostsId($tag['tag_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_id desc', true, array(), $posts_id);
     }
     $this->assign('title', $tag['tag_name']);
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('tags', $tag['tag_id']));
     $this->display('Archive/single-list');
 }
Пример #5
0
 /**
  *
  */
 public function checkVersion()
 {
     $software_build_db = get_opinion('software_build');
     $software_build_const = GreenCMS_Build;
     if ($software_build_db == $software_build_const) {
         return true;
     } else {
         return false;
     }
 }
Пример #6
0
 public function logout()
 {
     $User = D('User', 'Logic');
     $authInfo = $User->detail(session(get_opinion('ADMIN_AUTH_KEY')));
     $greencms_hash = $User->genHash($authInfo);
     cookie('user_session', null);
     session_unset();
     session_destroy();
     $this->success('退出成功!', U('Weixin/Login/index'), false);
 }
Пример #7
0
 /**
  * 文章feed
  * @param string $type 文章类型
  * @internal param $null 显示数量由 feed_num决定* 显示数量由 feed_num决定
  */
 public function listPost($type = 'single')
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), $type, 'post_date desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->addItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . get_post_url($list), $list['post_content'], $list['post_date']);
     }
     $RSS->display();
 }
Пример #8
0
function get_post_icon($post)
{
    $now_date = strtotime(date("y-m-d h:i:s"));
    $post_date = strtotime($post['post_date']);
    $days = ceil(($now_date - $post_date) / 86400);
    if ($days > 3) {
        return "<i> · </i>&nbsp;";
    } else {
        return '<img src="' . get_opinion('site_url') . '/Public/Xsc/images/new.png"  style="width:14px;height:14px;float:left; padding-top:5px;">&nbsp;';
    }
}
Пример #9
0
 /**
  * 首页基本信息
  */
 public function index()
 {
     $CountEvent = new CountEvent();
     $this->assign("PostCount", $CountEvent->getPostCount());
     $this->assign("UserCount", $CountEvent->getUserCount());
     if (get_opinion("oem_info", false, 'original') != 'original') {
         $this->display("oem");
     } else {
         $this->display();
     }
 }
Пример #10
0
 /**
  * 页面feed
  * @param null
  * 显示数量由 feed_num决定
  */
 public function listsPage()
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), 'page', 'post_id desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->AddItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . getPageURLByID($list['post_id']), $list['post_content'], $list['post_date']);
     }
     $RSS->Display();
 }
Пример #11
0
 /**
  *
  */
 public function check()
 {
     $software_build = get_opinion('software_build', true);
     $url = Server_API . 'api/update/' . $software_build . '/';
     $json = json_decode(file_get_contents($url), true);
     if ($json['lastest_version'] > $json['user_version']) {
         return $json;
     } else {
         return false;
     }
 }
Пример #12
0
 public function index()
 {
     \Think\Log::record('收到消息' . date('Ymd H:m:s') . 'Form:' . get_client_ip());
     $weixin = new ThinkWechat(get_opinion('weixin_token'));
     /* 获取请求信息 */
     $data = $weixin->request();
     /* 获取回复信息 */
     list($content, $type) = $this->reply($data);
     /* 响应当前请求 */
     $weixin->response($content, $type);
     \Think\Log::record('发送消息' . date('Ymd H:m:s'));
 }
Пример #13
0
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (get_opinion('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         $Addons = A("Addons://{$_addons}/{$_controller}")->{$_action}();
     } else {
         $this->error('没有指定插件名称,控制器或操作!');
     }
 }
Пример #14
0
 /**
  * 获取Access Token
  * @return null | string
  */
 private function _fetchAccessToken()
 {
     $Curl = new Curl();
     $params['grant_type'] = 'client_credential';
     $params['appid'] = get_opinion('Weixin_appid');
     $params['secret'] = get_opinion('Weixin_secret');
     $accessToken = $Curl->callApi($this::$AccessTokenURL, $params, 'GET');
     if (!isset($accessToken['access_token'])) {
         Log::write("Error occurred when call AccessToken Api");
         return null;
     }
     return $accessToken['access_token'];
 }
Пример #15
0
 public function index()
 {
     $page = I('get.page', get_opinion('PAGER'));
     $count = D('Weixinre')->count();
     $Page = new GreenPage($count, $page);
     // 实例化分页类 传入总记录数
     $pager_bar = $Page->show();
     $limit = $Page->firstRow . ',' . $Page->listRows;
     $weixinre = D('Weixinre')->limit($limit)->select();
     $this->assign('pager', $pager_bar);
     $this->assign('weixinre', $weixinre);
     $this->display();
 }
Пример #16
0
 public function preview($info = -1)
 {
     $Posts = new PostsLogic();
     if ($_SESSION[get_opinion('USER_AUTH_KEY')]) {
         $post_detail = $Posts->preview($info, true);
     }
     $this->if404($post_detail, "非常抱歉,你需要的文章暂时不存在,可能它已经躲起来了。.");
     $this->assign('breadcrumbs', get_breadcrumbs('post', $post_detail));
     $this->assign('post', $post_detail);
     // 赋值数据集
     if (File::file_exists(T('Home@Post/' . $post_detail['post_template']))) {
         $this->display($post_detail['post_template']);
     } else {
         $this->display('single');
     }
 }
Пример #17
0
 /**
  * 插入空文章
  * @return mixed
  */
 public function insertEmpty()
 {
     $post_data['post_type'] = 'single';
     $post_data['post_title'] = '未命名';
     $post_data['post_content'] = ' ';
     $post_data['post_template'] = 'single';
     $post_data['post_name'] = 'title';
     $post_data['post_status'] = 'draft';
     $post_data['post_date'] = date("Y-m-d H:m:s", time());
     $post_data['post_modified'] = date("Y-m-d H:m:s", time());
     $post_data['user_id'] = $_SESSION[get_opinion('USER_AUTH_KEY')];
     $post_data['post_tag'] = I('post.tags', array());
     $post_data['post_cat'] = I('post.cats', array());
     $post_id = D('Posts')->relation(true)->add($post_data);
     return $post_id;
 }
Пример #18
0
 /**
  *
  */
 public function guest()
 {
     $page = I('get.page', get_opinion('PAGER'));
     $UserLogic = new UserLogic();
     $where = array("user_level" => array('eq', 5));
     $count = $UserLogic->where($where)->count();
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $list = D('Access', 'Logic')->guestList($limit);
     }
     $this->assign('pager', $pager_bar);
     $this->assign('listname', '游客用户');
     $this->assign('list', $list);
     $this->display('userlist');
 }
 public function manage()
 {
     $order = 'date DESC';
     $page = I('get.page', get_opinion('PAGER'));
     $count = count(M('guestbook')->where($where)->select());
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
     }
     $message = M('guestbook')->where($where)->order($order)->limit($limit)->select();
     $this->assign('message', $message);
     $this->assign('action', '留言板管理');
     $this->assign('module', '留言板');
     $this->assign('module_url', U('Admin/Custom/plugin'));
     $this->display(T('Addons://Guestbook@Guestbook/manage'));
 }
Пример #20
0
 /**
  * @param string $method
  * @param array $args
  * @return array
  */
 public function __call($method, $args)
 {
     $keyword = $method;
     $data = $args[0];
     if ($keyword == "hi" || $keyword == "hello" || $keyword == "你好" || $keyword == "您好") {
         $contentStr = "欢迎使用,回复help获得使用帮助";
         // .$toUsername
     } else {
         if (strtolower($keyword) == "help" || $keyword == '帮助') {
             $contentStr = get_opinion('weixin_help', true, "帮助:");
         } else {
             $CustomTextEvent = new CustomTextEvent();
             $reply = $CustomTextEvent->{$keyword}($data);
             return $reply;
         }
     }
     $reply = array($contentStr, 'text');
     return $reply;
 }
 public function index()
 {
     $page = I('get.page', get_opinion('PAGER'));
     $Bmb = D('Bmb');
     //$stu = $Stu->select();
     $stu_count = $Bmb->count();
     if ($stu_count != 0) {
         $Page = new GreenPage($stu_count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $stu_list = $Bmb->join(GreenCMS_DB_PREFIX . 'stu ON ' . GreenCMS_DB_PREFIX . 'stu.ksh = ' . GreenCMS_DB_PREFIX . 'bmb.ksh')->limit($limit)->select();
     }
     $this->assign('stu_count', $stu_count);
     $this->assign('stu_list', $stu_list);
     $this->assign('pager', $pager_bar);
     $this->assign('action', '2011报名管理');
     $this->display('');
 }
 /**
  * @return bool|mixed
  */
 public function getAccess()
 {
     //使用缓存保存access_token , access_token有效时间是7200秒
     if (S('access_token') == '' || S('access_token') == false) {
         $appid = get_opinion('Weixin_appid');
         $secret = get_opinion('Weixin_secret');
         $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
         $json = file_get_contents($url);
         $res = json_decode($json, true);
         // dump($res);
         if ($res['errcode'] == 40013) {
             return false;
         }
         S('access_token', $res['access_token'], 7000);
         return $res['access_token'];
     } else {
         return S('access_token');
     }
 }
Пример #23
0
function getMenuButtons()
{
    $menu = trim(get_opinion('Weixin_menu'));
    $menu = json_decode($menu, true);
    $array = $menu['button'];
    static $result_array = array();
    foreach ($array as $value) {
        if ($value['name'] != '' && $value['key'] != '') {
            $result_array[$value['key']] = $value['name'];
        }
        if (!empty($value['sub_button'])) {
            foreach ($value['sub_button'] as $value2) {
                if ($value2['name'] != '' && $value2['key'] != '') {
                    $result_array[$value2['key']] = $value2['name'];
                }
            }
        }
    }
    return $result_array;
}
Пример #24
0
 private function reply($data)
 {
     /**
      *
      * @param
      *            $data['Content']输入内容
      * @return $reply数组包括 返回内容和返回类型
      *
      *         <xml>
      *         <ToUserName><![CDATA[toUser]]></ToUserName>
      *         <FromUserName><![CDATA[fromUser]]></FromUserName>
      *         <CreateTime>1348831860</CreateTime>
      *         <MsgType><![CDATA[text]]></MsgType>
      *         <Content><![CDATA[this is a test]]></Content>
      *         <MsgId>1234567890123456</MsgId>
      *         </xml>
      */
     if ('text' == $data['MsgType']) {
         $keyword = $data['Content'];
         if (get_opinion('Weixin_log')) {
             $Weixinlog = D('Weixinlog');
             $Weixinlog->data($data)->add();
         }
         $keyword = trim($keyword);
         $TextEvent = new TextEvent();
         $reply = $TextEvent->{$keyword}($data);
     } elseif ('image' == $data['MsgType']) {
         $reply = array('图像已接受', 'text');
     } elseif ('location' == $data['MsgType']) {
         $TextEvent = new PoiEvent();
         $contentStr = $TextEvent->process($data);
         $reply = array($contentStr, 'text');
     } elseif ('event' == $data['MsgType']) {
         $event = $data['Event'];
         $EveEvent = new EveEvent();
         $reply = $EveEvent->{$event}($data);
     } else {
         $reply = array("error : unknown MsgType" . $data['MsgType'], 'text');
     }
     return $reply;
 }
Пример #25
0
 public function login()
 {
     // $ipLocation = new IpLocation();
     // $ip_info = $ipLocation->getIpInfo();
     $verify = new \Think\Verify();
     if (!$verify->check(I('post.vertify'))) {
         $this->error("验证码错误");
     }
     $map = array();
     $map['user_login'] = $_POST['username'];
     $map['user_status'] = array('gt', 0);
     $authInfo = RBAC::authenticate($map);
     if (false === $authInfo) {
         $this->error('帐号不存在或已禁用!');
     } else {
         if ($authInfo['user_pass'] != encrypt($_POST['password'])) {
             $this->error('密码错误或者帐号已禁用');
         }
         $_SESSION[C('USER_AUTH_KEY')] = $authInfo['user_id'];
         if ($authInfo['user_login'] == get_opinion('Admin')) {
             $_SESSION[C('ADMIN_AUTH_KEY')] = true;
         }
         //记住我
         if (I('post.remember') == 1) {
             if ($authInfo['user_session'] != '') {
                 cookie('user_session', $authInfo['user_session'], 36000);
             } else {
                 if ($authInfo['user_session'] == '') {
                     $user_session = D('User', 'Logic')->genHash($authInfo);
                     cookie('user_session', $user_session, 36000);
                 }
             }
         }
         // 缓存访问权限
         RBAC::saveAccessList();
         $this->success('登录成功!', U("Weixin/Home/index"), false);
     }
 }
Пример #26
0
 /**
  * 查询缓存
  * @access public
  * @param mixed $key
  * @param integer $expire
  * @param string $type
  * @return Model
  */
 public function cache($key = true, $expire = null, $type = '')
 {
     if (false !== $key) {
         if ($expire == null) {
             $expire = get_opinion("DATA_CACHE_TIME", false);
         }
         $this->options['cache'] = array('key' => $key, 'expire' => $expire, 'type' => $type);
     }
     return $this;
 }
<html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><?php 
echo get_opinion('title');
?>
</title>
    <meta name="description" content="<?php 
echo get_opinion('description');
?>
">
    <meta name="keywords" content="<?php 
echo get_opinion('keywords');
?>
"/>
    <meta name="author" content="greenstudio"/>

    <meta name="viewport" content="width=device-width">
    
    <!-- animate css -->
<link rel="stylesheet" href="/Public/Charmy/css/font-awesome.min.css">
<link rel="stylesheet" href="/Public/Charmy/css/animate.min.css">
<!-- bootstrap css -->
<link rel="stylesheet" href="/Public/Charmy/css/bootstrap.min.css">
<!-- font-awesome -->
<link rel="stylesheet" href="/Public/Charmy/css/font-awesome.min.css">
<!-- google font -->
<link href='http://fonts.useso.com/css?family=Open+Sans:400,300,400italic,700,800' rel='stylesheet' type='text/css'>
Пример #28
0
 /**
  * For Mysql only
  */
 public function repair()
 {
     if (get_opinion('DB_TYPE') != 'mysql' && get_opinion('DB_TYPE') != 'mysqli') {
         $this->error('当前数据库类型不被支持');
     }
     $M = M();
     if (IS_POST) {
         $System = new \Common\Event\SystemEvent();
         $System->postIntegrity();
         if (empty($_POST['table']) || count($_POST['table']) == 0) {
             $this->jsonReturn(0, "请选择要处理的表");
         }
         $table = implode(',', $_POST['table']);
         if ($_POST['act'] == 'repair') {
             if ($M->query("REPAIR TABLE {$table} ")) {
                 $this->jsonReturn(1, "修复表成功", U('Admin/Data/repair'));
             }
         } elseif ($_POST['act'] == 'optimize') {
             if ($M->query("OPTIMIZE TABLE {$table}")) {
                 $this->jsonReturn(1, "优化表成功", U('Admin/Data/repair'));
             }
         }
         $this->jsonReturn(0, "请选择操作");
     } else {
         $tabs = $M->query('SHOW TABLE STATUS');
         $total_size = array('table' => 0, 'index' => 0, 'data' => 0, 'free' => 0);
         $tables = array();
         foreach ($tabs as $k => $table) {
             $table['size'] = File::byteFormat($table['Data_length'] + $table['Index_length']);
             $total_size['table'] += $table['Data_length'] + $table['Index_length'];
             $total_size['data'] += $table['Data_length'];
             $table['Data_length'] = File::byteFormat($table['Data_length']);
             $total_size['index'] += $table['Index_length'];
             $table['Index_length'] = File::byteFormat($table['Index_length']);
             $total_size['free'] += $table['Data_free'];
             $table['Data_free'] = File::byteFormat($table['Data_free']);
             $tables[] = $table;
         }
         $total_size['table'] = File::byteFormat($total_size['table']);
         $total_size['free'] = File::byteFormat($total_size['free']);
         $total_size['table'] = File::byteFormat($total_size['table']);
         $total_size['data'] = File::byteFormat($total_size['data']);
         $total_size['index'] = File::byteFormat($total_size['index']);
         $this->assign("list", $tables);
         $this->assign("totalsize", $total_size);
         $this->display();
     }
 }
Пример #29
0
 /**
  * 标签
  */
 public function tag()
 {
     $page = I('get.page', get_opinion('PAGER'));
     $TagsLogic = new TagsLogic();
     $count = $TagsLogic->countAll();
     // 查询满足要求的总记录数
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $tags = $TagsLogic->selectWithPostsCount($limit);
     }
     $this->assign('tags', $tags);
     $this->assign('pager', $pager_bar);
     $this->display();
 }
Пример #30
0
function get_opinion($key, $realtime = false, $default = '')
{
    if (!$realtime) {
        $res = C($key);
        if ($res != null) {
            return $res;
        } else {
            $res = S('option_' . $key);
            if ($res) {
                return $res;
            } else {
                return get_opinion($key, true, $default = '');
            }
        }
    } else {
        $res = D('Options')->where(array('option_name' => $key))->find();
        if (empty($res)) {
            return $default;
        } else {
            S('option_' . $key, $res['option_value']);
            return $res['option_value'];
        }
    }
}