Exemplo n.º 1
0
 /**
  * 检测登录
  *
  * @return bool|\Illuminate\Http\RedirectResponse
  * @author yangyifan <*****@*****.**>
  */
 private function checkIsLogin()
 {
     load_func('common');
     $uid = is_admn_login();
     return $uid <= 0 && header('location:' . action('Admin\\LoginController@getIndex'));
     die;
 }
Exemplo n.º 2
0
 function send_to_swoole_server($step, $targer, $params, $callback)
 {
     //加载函数库
     load_func('instanceof');
     $swoole_client = get_swoole_client();
     return $swoole_client->send(json_encode(['step' => $step, 'targer' => $targer, 'params' => $params, 'callback' => $callback]) . config('swoole.package_eof'));
 }
 /**
  * 构造方法
  *
  * @author yangyifan <*****@*****.**>
  */
 public function __construct()
 {
     //加载函数库
     load_func('common');
     //获得导航数据
     $this->getSearch();
 }
Exemplo n.º 4
0
 /**
  * 获得全部文章分类--无限极分类(编辑菜单时选项)
  *
  * @descript  递归组合无限极分类,为了编辑页面和增加页面select 展示
  * @param $name 表单name名称
  * @param $id 当前id
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getAllForSchemaOption($name, $id = 0, $first = true)
 {
     //加载函数库
     load_func('common');
     $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->where('user_info_id', '=', is_user_login())->where('deleted_at', '=', '0000-00-00 00:00:00')->get())) : merge_tree_node(obj_to_array(self::where('user_info_id', '=', is_user_login())->get()));
     $first == true && array_unshift($data, ['id' => '0', $name => '顶级分类']);
     return $data;
 }
 /**
  * 保用用户信息到redis
  *
  * @param Requests $requests
  * @author yangyifan <*****@*****.**>
  */
 public function getSaveUserInfo(Request $requests)
 {
     $user_info = unserialize(urldecode($requests->get('user_info')));
     //保存用户信息到redis hash表
     load_func('instanceof,swoole');
     //返回状态
     get_redis()->hSet(config('config.user_list_hash_table'), $user_info->id, serialize($user_info)) != false ? $this->response(200, 'success') : $this->response(400, trans('response.save_user_info_to_redis_error'));
 }
 /**
  * 获得当前栏目全部角色权限
  *
  * @param null $role_id
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserForumCat($forum_cat_id)
 {
     if (!empty($forum_cat_id)) {
         //加载函数库
         load_func('common');
         return obj_to_array(DB::table('forum_access AS fa')->select('r.id', 'r.role_name')->join('role AS r', 'fa.role_id', '=', 'r.id')->where('fa.forum_cat_id', '=', $forum_cat_id)->get());
     }
     return false;
 }
 /**
  * 登录操作
  *
  * @return Response
  * @author yangyifan <*****@*****.**>
  */
 public function getIndex()
 {
     load_func('common');
     //判断是否已经登录
     if (is_admin_login() > 0) {
         return redirect(url('admin/home'), 302);
     }
     return view('admin.login.login');
 }
 /**
  * 构造方法
  *
  * @author yangyifan <*****@*****.**>
  */
 public function __construct()
 {
     //加载函数库
     load_func('common');
     //检测是否登陆
     $this->checkIsLogin();
     //获得导航数据
     $this->getSearch();
 }
 /**
  * 构造方法
  *
  * @author yangyifan <*****@*****.**>
  */
 public function __construct()
 {
     parent::__construct();
     $this->disk = Storage::disk('qiniu');
     //获得一块硬盘
     //加载函数库
     load_func('common');
     //设置会员头像保存路径
     $this->user_avatar_prefix = '/avatar/' . is_user_login() . '/';
 }
Exemplo n.º 10
0
 /**
  * 写入用户信息到SESSION
  *
  * @param $user_info
  * @author yangyifan <*****@*****.**>
  */
 private static function saveUserSession($user_info)
 {
     //引入函数库
     load_func('common');
     $user_info = obj_to_array($user_info);
     $user_info['admin_user_data'] = ['id' => $user_info['id'], 'email' => $user_info['email'], 'updated_at' => $user_info['updated_at']];
     $user_info['sign'] = hash_user_sign($user_info['admin_user_data']);
     Session::put('admin_info', $user_info);
     Session::save();
 }
Exemplo n.º 11
0
 /**
  * 保存用户头像
  *
  * @param $image
  * @param null $user_id
  * @return bool
  */
 public static function saveUserAvatar($image, $user_id = null)
 {
     if (!empty($image)) {
         //加载函数库
         load_func('common');
         $user_id = $user_id != null ? $user_id : is_user_login();
         return self::where('id', '=', $user_id)->update(['face' => $image]);
     }
     return false;
 }
Exemplo n.º 12
0
 /**
  * 添加好友
  *
  * @param $user_id
  * @param $contents
  * @author yangyifan <*****@*****.**>
  */
 public static function addFriend($user_id, $contents = '')
 {
     //加载函数库
     load_func('common');
     $affected_id = DB::table('add_user')->insertGetId(['user_info_id' => is_user_login(), 'invitee' => $user_id, 'created_at' => date('Y-m-d H:i:s')]);
     //发送私信
     if ($affected_id > 0) {
         LetterModel::sendLetter($user_id, trans('log.add_user_log', ['user_name' => Session::get('user_info.email'), 'contents' => $contents]));
     }
 }
Exemplo n.º 13
0
 /**
  * 获得用户web socket fd
  *
  * @param Request $request
  */
 public function postSocketFd(Request $request)
 {
     $user_id = $request->get('id');
     //加载函数库
     load_func('instanceof,image');
     //获得发送对象$fb
     $user_info = unserialize(get_redis()->hGet(config('config.user_list_hash_table'), $user_id));
     if (!empty($user_info)) {
         $this->response(200, 'success', ['fd' => $user_info->web_socket_fd, 'name' => $user_info->user_name, 'face' => get_user_info_face($user_info->face)]);
     } else {
         $this->response(400, trans('response.save_user_socket_to_redis_error'));
     }
 }
Exemplo n.º 14
0
 /**
  * 检测登录
  *
  * @return bool|\Illuminate\Http\RedirectResponse
  * @author yangyifan <*****@*****.**>
  */
 private function checkIsLogin()
 {
     //记载函数库
     load_func('common');
     $uid = is_user_login();
     if ($uid <= 0 && Request::method() == 'POST') {
         $this->response(400, trans('response.no_login'));
     } else {
         if ($uid <= 0) {
             header('location:' . action('Home\\UserController@getLogin'));
             die;
         }
     }
 }
Exemplo n.º 15
0
 /**
  * 获得全部分类
  *
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserChoseCagetory()
 {
     //加载函数库
     load_func('common');
     //获得当前用户全部新闻分类
     $user_new_category_id = self::getUserCagetory();
     $all_category = self::all();
     if (!empty($all_category)) {
         foreach ($all_category as &$category) {
             $category->checked = in_array($category->id, $user_new_category_id) ? true : false;
         }
     }
     $all_category = obj_to_array($all_category);
     return array_to_obj(merge_tree_child_node($all_category));
 }
Exemplo n.º 16
0
 /**
  * 更新用户当前权限
  *
  * @param array $access_array
  * @param null $role_id
  * @return bool
  * @author yangyifan <*****@*****.**>
  */
 public static function updateUserAccess(array $access_array = null, $role_id = null)
 {
     //删除会员当前全部新闻分类
     self::deleteUserAccess($role_id);
     if (!empty($access_array)) {
         //加载函数库
         load_func('common');
         $role_id = self::getRoleId($role_id);
         foreach ($access_array as $access) {
             if ($access <= 0) {
                 continue;
             }
             DB::table('role_relation_menu')->insertGetId(['role_id' => $role_id, 'menu_id' => $access]);
         }
     }
     return true;
 }
Exemplo n.º 17
0
 /**
  * 获得在线好友
  *
  * @param $params array 用户登录名和密码参数
  * @return int
  * @author yangyifan <*****@*****.**>
  */
 public static function onlineUser()
 {
     load_func('instanceof,image,common');
     $online_user = get_redis()->hGetAll(config('config.user_list_hash_table'));
     $item = [];
     //获得全部我的好友
     $my_friends = FriendsModel::getMyFriends();
     foreach ($online_user as $user) {
         $user = unserialize($user);
         //如果是自己,则跳过 || 如果不是自己好友,则跳过
         if ($user->id == is_user_login() || !in_array($user->id, $my_friends)) {
             continue;
         }
         $item[] = ['id' => $user->id, 'name' => $user->user_name, 'face' => get_user_info_face($user->face), 'url' => action("User\\UserController@getIndex", ['id' => $user->id])];
     }
     $data = [['name' => '在线好友', 'nums' => count($item), 'id' => 1, 'item' => $item]];
     return $data;
 }
Exemplo n.º 18
0
 /**
  * 检测登录
  *
  * @return bool|\Illuminate\Http\RedirectResponse
  * @author yangyifan <*****@*****.**>
  */
 private function checkIsLogin()
 {
     load_func('common');
     $uid = is_login();
     return $uid <= 0 && header('location:/admin/login');
 }
Exemplo n.º 19
0
 /**
  * 获得全部菜单--递归(左侧菜单显示)
  *
  * @return array
  * @auther yangyifan <*****@*****.**>
  */
 public static function getAllForMenuSide()
 {
     //加载函数库
     load_func('common');
     return merge_tree_child_node(obj_to_array(self::all()));
 }
Exemplo n.º 20
0
 /**
  * 添加网址分类
  *
  * @param Request $request
  * @author yangyifan <*****@*****.**>
  */
 public function postSiteCategory(SearchCatRequest $request)
 {
     $data = $request->all();
     //加载函数库
     load_func('common');
     $data['user_info_id'] = is_user_login();
     $affected_number = SiteCatModel::create($data);
     return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], false) : $this->response(400, trans('response.add_error'), [], false);
 }
Exemplo n.º 21
0
 /**
  * 获得全部文章分类--无限极分类(编辑菜单时选项)
  *
  * @descript  递归组合无限极分类,为了编辑页面和增加页面select 展示
  * @param $name 表单name名称
  * @param $id 当前id
  * @return array
  * @auther yangyifan <*****@*****.**>
  */
 public static function getAllForSchemaOption($name, $id = 0)
 {
     //加载函数库
     load_func('common');
     $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->get())) : merge_tree_node(obj_to_array(self::all()));
     array_unshift($data, ['id' => '0', $name => '顶级分类']);
     return $data;
 }
Exemplo n.º 22
0
 /**
  * 获得全部分类
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public static function getAllCategory()
 {
     //加载函数库
     load_func('common');
     $data = obj_to_array(self::all());
     $data = array_to_obj(merge_tree_child_node($data));
     return $data;
 }
Exemplo n.º 23
0
 /**
  * 组合用户信息
  *
  * @param $user_info
  * @author yangyifan <*****@*****.**>
  */
 private static function mergeUserInfo($user_info)
 {
     if (!empty($user_info)) {
         load_func('image');
         $user_info->face = get_user_info_face($user_info->face);
         $user_info->url = action("User\\UserController@getIndex", ['id' => $user_info->id]);
         $user_info->user_name = !empty($user_info->user_name) ? $user_info->user_name : $user_info->email;
         return $user_info;
     }
 }
Exemplo n.º 24
0
              <td align="left" class="admintitle" colspan="5">浏览器列表&#12288; </td>
            </tr>
            <tr bgcolor="#f1f3f5" style="font-weight:bold;">
              <td width="2%" height="30" align="center" class="ButtonList">&nbsp;</td>
              <td width="10%" height="30" align="center" class="ButtonList">名称</td>
              <td width="20%" align="center" class="ButtonList">IP|地址</td>
              <td width="8%" align="center" class="ButtonList">上线时间</td>
              <td width="10%" align="center" class="ButtonList">浏览器</td>
              <td width="10%" align="center" class="ButtonList">系统</td>
              <td width="15%" height="25" align="center" class="ButtonList">管理</td>
            </tr>
            <?php 
if (is_array($browsers)) {
    foreach ($browsers as $browser) {
        $utime = date("Y-m-d H:i:s", $browser->dateline);
        load_func("IptoAddr");
        $addr = ip_to_addr($browser->ip);
        print <<<END
\t\t\t   \t      <tr>
              <td></td>
              <td>{$browser->name}</td>
              <td>{$browser->ip} | {$addr}</td>
              <td>{$utime}</td>
              <td>{$browser->type}</td>
              <td>{$browser->os} </td>
 
              <td>
                  <a href="?m=xing&a=info&bid={$browser->bid}"><span class="ico_Preview"> </span> 信息 </a> 
                  <a href="?m=project&a=edit&pid={$project['pid']}"><span class="ico_Modify"> </span> 编辑 </a> 
                  <a href="?m=xing&a=del&bid={$browser->bid}"><span class="ico_Del"> </span> 删除 </a></td>
            </tr>
Exemplo n.º 25
0
 /**
  * 获得用户id
  *
  * @param $user_id
  * @return bool
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserId($user_id = null)
 {
     //加载函数库
     load_func('common');
     return $user_id != null ? $user_id : is_user_login();
 }
Exemplo n.º 26
0
 /**
  * 获得全部论坛分类
  *
  * @param $data
  * @author yangyifan <*****@*****.**>
  */
 public static function getForumLocation($data)
 {
     //加载函数库
     load_func('common');
     $all_category = obj_to_array(self::select('cat_name', 'id', 'pid')->get());
     $data = get_location($all_category, $data->forum_cat_id);
     //翻转函数
     $data = array_reverse($data);
     return $data;
 }
Exemplo n.º 27
0
 /**
  * 获得角色列表
  *
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getRoleList()
 {
     //加载函数库
     load_func('common');
     return obj_to_array(DB::table('role')->where('status', '=', 1)->get());
 }
 /**
  * 获得全部文章分类
  *
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getAll()
 {
     //加载函数库
     load_func('common');
     return merge_tree_node(obj_to_array(self::mergeData(self::where('status', '=', 1)->where('deleted_at', '=', '0000-00-00 00:00:00')->get())));
 }
Exemplo n.º 29
0
 /**
  * 保存用户信息 到 swoole
  *
  * @param $user_info
  * @author yangyifan <*****@*****.**>
  */
 private static function saveUserInfo($user_info)
 {
     //加载函数库
     load_func('swoole');
     send_save_user_to_swoole_server(action('Home\\UserController@getSaveUserInfo'), serialize($user_info), '');
 }
 /**
  * 构建tree数据
  *
  * @param $data
  * @return \Illuminate\View\View
  * @author yangyifan <*****@*****.**>
  */
 public function builderTreeData($data)
 {
     //加载函数库
     load_func('common');
     $this->tree_data = merge_tree_node(obj_to_array($data));
     return $this;
 }