Example #1
0
 public function get_user_info()
 {
     $this->db = $this->getDB($this->input['access_token']);
     if ($this->input['access_token']) {
         $sql = 'SELECT * FROM ' . $this->dbname . DB_PREFIX . 'user_login WHERE token = "' . $this->input['access_token'] . '"';
         $user = $this->db->query_first($sql);
         if (!$user) {
             $this->erroroutput(NO_ACCESS_TOKEN);
         }
         $token_expired = defined('TOKEN_EXPIRED') ? TOKEN_EXPIRED : 3600;
         if ($user['login_time'] < TIMENOW - $token_expired) {
             $sql = 'UPDATE ' . $this->dbname . DB_PREFIX . 'user_login SET login_time = ' . TIMENOW . ' WHERE token="' . $this->input['access_token'] . '"';
             $this->db->query($sql);
             //删除过期会话
             $sql = 'DELETE FROM ' . $this->dbname . DB_PREFIX . 'user_login WHERE login_time < ' . (TIMENOW - $token_expired);
             $this->db->query($sql);
         }
         if ($user['user_id'] && $this->iscp) {
             //$user['slave_org'] = explode(',', $user['slave_org']);
             //非管理型用户加在权限
             if ($user['group_type'] > MAX_ADMIN_TYPE && $user['slave_group']) {
                 $app_uniqueid = $this->input['app_uniqueid'];
                 $complex = hg_check_prms($user);
                 //合并多角色用户权限
                 $user['prms'] = merge_user_prms($complex);
             }
         }
     }
     if (!$user) {
         if ($this->input['appid'] && $this->input['appkey']) {
             $appinfo = $this->verify_appkey($this->input['appid'], $this->input['appkey']);
             $user_name = $appinfo['display_name'] ? $appinfo['display_name'] : $appinfo['custom_name'];
             $user = array('user_id' => 0, 'user_name' => $user_name, 'group_type' => 9999999999, 'appid' => $appinfo['appid'], 'display_name' => $user_name, 'visit_client' => $appinfo['mobile'], 'expire_time' => $appinfo['expire_time']);
         } else {
             if (!DEBUG_MODE) {
                 $this->erroroutput(NO_APP_INFO);
             }
         }
     }
     //判断当期那用户表里面的字段(是否是第一次登陆,如果是就提示必须修改密码
     /********************************
     		if($user['is_first_login'])
     		{
     			$this->errorOutput(YOU_MUST_MODIFY_PASSWORD_FIRST);
     		}
     		********************************/
     if ($user['user_id'] > 0 && ($this->input['isextend'] || defined('IS_EXTEND') && IS_EXTEND)) {
         $user['extend'] = $this->getUserExtendInfo($user['user_id']);
         $sql = 'SELECT avatar FROM ' . DB_PREFIX . 'admin WHERE id = ' . $user['user_id'];
         $avatar = $this->db->query_first($sql);
         if ($avatar = unserialize($avatar['avatar'])) {
             $user['avatar'] = $avatar;
         }
     }
     $this->addItem($user);
     $this->output();
 }
Example #2
0
 public function get_user_prms()
 {
     $role_id = urldecode($this->input['role_id']);
     if (!$role_id) {
         return;
     }
     $prms = hg_update_role_prms($role_id);
     $prms = merge_user_prms($prms);
     $apps = @array_keys($prms['app_prms']);
     if ($apps) {
         $apps = implode('","', $apps);
         $sql = 'SELECT bundle,name FROM ' . DB_PREFIX . 'apps WHERE bundle IN("' . $apps . '")';
         $query = $this->db->query($sql);
         $apps = array();
         while ($row = $this->db->fetch_array($query)) {
             $apps[$row['bundle']] = $row['name'];
         }
     }
     require_once ROOT_PATH . 'lib/class/publishconfig.class.php';
     $publishconfig = new publishconfig();
     $publish_sites = $publish_columns = array();
     if ($prms['site_prms']) {
         $publish_sites = $publishconfig->get_sites();
         $prms['site_prms'] = array_intersect_key($publish_sites, array_flip($prms['site_prms']));
     }
     if ($prms['publish_prms']) {
         $column_ids = implode(',', $prms['publish_prms']);
         $publish_columns = $publishconfig->get_columnname_by_ids('*', $column_ids);
         $prms['publish_prms'] = $publish_columns;
     }
     if ($prms['app_prms']) {
         foreach ($prms['app_prms'] as $k => $v) {
             if ($prms['app_prms'][$k]['action']) {
                 $prms['app_prms'][$k]['action'] = array_intersect_key($this->settings['auth_op'], array_flip($prms['app_prms'][$k]['action']));
             }
             $prms['app_prms'][$k]['app_name'] = $apps[$k];
         }
     }
     $this->addItem($prms);
     $this->output();
 }