예제 #1
0
 public function dologin()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     //验证
     $adminModel = AdminModel::where('username', $username)->first();
     if (!$adminModel) {
         echo "<script>alert('无此管理员!');history.go(-1);</script>";
         exit;
     }
     if ($adminModel && !Hash::check($password, $adminModel->password)) {
         echo "<script>alert('密码错误!');history.go(-1);</script>";
         exit;
     }
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $loginTime = time();
     //加入session
     $adminInfo = ['adminid' => $adminModel->id, 'username' => $adminModel->username, 'role_id' => $adminModel->role_id, 'role_name' => $adminModel->role(), 'serial' => $serial, 'createTime' => $adminModel->createTime(), 'loginTime' => date('Y年m月d日 H:i', $loginTime)];
     Session::put('admin', $adminInfo);
     //登陆加入用户日志表
     $ip = \App\Tools::getIp();
     $ipaddress = \App\Tools::getCityByIp($ip);
     $userlog = ['uid' => $adminModel->id, 'uname' => Input::get('username'), 'ip' => $ip, 'genre' => 2, 'serial' => $serial, 'ipaddress' => $ipaddress, 'action' => $_SERVER['REQUEST_URI'], 'loginTime' => $loginTime, 'created_at' => $adminModel->created_at];
     LogModel::create($userlog);
     return redirect(DOMAIN . 'admin');
 }
예제 #2
0
 /**
  * 获取前台控制菜单列表
  */
 public function menus()
 {
     if ($menus = MenusModel::all()) {
         return Tools::getChild($menus, $pid = 0);
     }
     return [];
 }
예제 #3
0
 public function update(Request $request, $id)
 {
     //图片上传处理
     if ($request->hasFile('url_ori')) {
         //判断文件存在
         //验证图片大小
         foreach ($_FILES as $pic) {
             if ($pic['size'] > $this->uploadSizeLimit) {
                 echo "<script>alert(\"对不起,你上传的图片过大,请重新选择\");history.go(-1);</script>";
                 exit;
             }
         }
         $file = $request->file('url_ori');
         //获取文件
         $logo = \App\Tools::upload($file);
     }
     $data = ['logo' => isset($logo) ? $logo : '', 'title' => $request->title, 'keyword' => $request->keyword, 'description' => $request->description, 'updated_at' => date('Y-m-d H:i:s', time())];
     //同时删除原有的logo图片
     $mainModel = ComMainModel::find($id);
     if (isset($logo) && $mainModel->logo && $mainModel->logo != $this->sefLogo) {
         unlink(ltrim($mainModel->logo, '/'));
     }
     ComMainModel::where('id', $id)->update($data);
     return redirect('/company/admin/basic');
 }
예제 #4
0
 public function dologin()
 {
     $userModel = UserModel::where('username', Input::get('username'))->first();
     //查看是否有此用户
     if (!$userModel) {
         echo "<script>alert('没有此用户!');history.go(-1);</script>";
         exit;
     }
     //验证密码正确否
     if (!Hash::check(Input::get('password'), $userModel->password)) {
         echo "<script>alert('密码错误!');history.go(-1);</script>";
         exit;
     }
     //查看2次密码输入是否一致
     if (Input::get('password') != Input::get('password2')) {
         echo "<script>alert('2次密码输入不一致!');history.go(-1);</script>";
         exit;
     }
     //验证码验证
     $rules = ['captcha' => 'required|captcha'];
     $messages = ['captcha.required' => '请输入验证码', 'captcha.captcha' => '验证码错误,请重试'];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         echo "<script>alert('验证码错误!');history.go(-1);</script>";
         exit;
     }
     //个人资料
     if (in_array($userModel->isuser, [1, 3])) {
         $personModel = PersonModel::where('uid', $userModel->id)->first();
         $persons['per_id'] = $personModel->id;
         $persons['realname'] = $personModel->realname;
         $persons['sex'] = $personModel->sex;
         $persons['idcard'] = $personModel->idcard;
         $persons['idfront'] = $personModel->idfront;
     }
     $userperson = isset($persons) ? serialize($persons) : [];
     //企业资料
     if (in_array($userModel->isuser, [2, 4])) {
         $companyModel = CompanyModel::where('uid', $userModel->id)->first();
         $companys['cid'] = $companyModel->id;
         $companys['name'] = $companyModel->name;
         $companys['area'] = $companyModel->area;
         $companys['address'] = $companyModel->address;
         $companys['yyzzid'] = $companyModel->yyzzid;
     }
     $usercompany = isset($companys) ? serialize($companys) : [];
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $userInfo = ['uid' => $userModel->id, 'username' => Input::get('username'), 'email' => $userModel->email, 'userType' => $userModel->isuser, 'serial' => $serial, 'area' => $userModel->area, 'address' => $userModel->address, 'cid' => isset($companyModel) ? $companyModel->id : '', 'loginTime' => time(), 'person' => $userperson, 'company' => $usercompany];
     Session::put('user', $userInfo);
     //登陆加入用户日志表
     $ip = \App\Tools::getIp();
     $ipaddress = \App\Tools::getCityByIp($ip);
     $userlog = ['uid' => $userModel->id, 'uname' => Input::get('username'), 'genre' => 1, 'serial' => $serial, 'ip' => $ip, 'ipaddress' => $ipaddress, 'action' => $_SERVER['REQUEST_URI'], 'loginTime' => time(), 'created_at' => $userModel->created_at];
     LogModel::create($userlog);
     //最近登录更新
     UserModel::where('id', $userModel->id)->update(['lastLogin' => time()]);
     return redirect(DOMAIN . 'member');
 }
예제 #5
0
파일: User.php 프로젝트: gtcrais/gtcms
 public static function usersList()
 {
     $users = User::all();
     if ($users->count()) {
         $params = array('itemName' => 'fullName');
         $list = array();
         $list = Tools::createItemList($users, $list, $params);
         return $list;
     } else {
         return array();
     }
 }
예제 #6
0
파일: Tools.php 프로젝트: 946493655/culture
 public static function childList2($obj, $pid = 0)
 {
     $list = array();
     foreach ($obj as $v) {
         if ($v->pid == $pid) {
             //找到子节点,继续找该子节点的后代节点
             $v->child = Tools::childList2($obj, $v->id);
             $list[] = $v;
         }
     }
     return $list;
 }
예제 #7
0
 /**
  * 得到模糊坐标
  */
 public function getPoint($area, $address, $key)
 {
     //百度地图接口:http://api.map.baidu.com/geocoder/v2/address=地址&output=输出格式类型&key=用户密钥&city=城市名
     //需要4个参数:address详细地址,output格式,ak接口密匙,city城市名
     //地区转换
     //        $areaModel = AreaModel::find($area);
     //        $areaname = $areaModel ? $areaModel->cityname : '';
     $cityModel = new AreaModel();
     $areaname = $area ? $cityModel->getAreaName($area) : '';
     //请求接口,返回数据
     $apiUrl = 'http://api.map.baidu.com/geocoder/v2/';
     $curl = new \Curl\Curl();
     $curl->setHeader('X-Authorization', $key);
     $curl->get($apiUrl, array('address' => $address, 'output' => 'json', 'ak' => $key, 'city' => $areaname));
     $response = json_decode($curl->response);
     $response = \App\Tools::objectToArray($response);
     if ($response['status'] != 0) {
         if ($response['status'] == 1) {
             echo "<script>alert('地址有误或百度地图服务器内部有变!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 2) {
             echo "<script>alert('地区或地址有误!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 3) {
             echo "<script>alert('权限校验失败!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 4) {
             echo "<script>alert('配额校验失败!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 5) {
             echo "<script>alert('百度地图密匙错误!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 101) {
             echo "<script>alert('服务禁用!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == 102) {
             echo "<script>alert('百度地图密匙权限不足!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == "2xx") {
             echo "<script>alert('无权限!');history.go(-1);</script>";
             exit;
         } elseif ($response['status'] == "3xx") {
             echo "<script>alert('配额错误!');history.go(-1);</script>";
             exit;
         }
     }
     return $response['result']['location'];
 }
예제 #8
0
 public function doregist()
 {
     //查看同ip是否已有3个注册,满3个则限制
     if (count(UserModel::where('ip', Tools::getIp())->get()) == 3) {
         echo "<script>alert('此用户已经注册过,不要重复注册!');history.go(-1);</script>";
         exit;
     }
     //查看是否有此用户
     if (UserModel::where('username', Input::get('username'))->first()) {
         echo "<script>alert('此用户已经注册!');history.go(-1);</script>";
         exit;
     }
     //        //验证密码正确否
     //        if (!(Hash::check(Input::get('password'),$userModel->password))) {
     //            echo "<script>alert('密码错误!');history.go(-1);</script>";exit;
     //        }
     //查看2次密码输入是否一致
     if (Input::get('password') != Input::get('password2')) {
         echo "<script>alert('2次密码输入不一致!');history.go(-1);</script>";
         exit;
     }
     //验证码验证
     $rules = [];
     $messages = ['captcha.required' => '请输入验证码', 'captcha.captcha' => '验证码错误,请重试'];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         echo "<script>alert('验证码错误!');history.go(-1);</script>";
         exit;
     }
     //数据写入用户表
     $data = ['username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'ip' => Tools::getIp(), 'email' => Input::get('email'), 'created_at' => time(), 'lastLogin' => time()];
     UserModel::create($data);
     //加入session
     $userinfo = UserModel::where('username', Input::get('username'))->first();
     $userInfo = ['uid' => $userinfo->id, 'username' => Input::get('username'), 'email' => Input::get('email')];
     Session::put('user', $userInfo);
     //登陆加入用户日志表
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $ip = \App\Tools::getIp();
     $ipaddress = \App\Tools::getCityByIp($ip);
     $userlog = ['uid' => $userinfo->id, 'uname' => Input::get('username'), 'genre' => 1, 'serial' => $serial, 'ip' => $ip, 'ipaddress' => $ipaddress, 'action' => $_SERVER['REQUEST_URI'], 'loginTime' => time(), 'created_at' => $userinfo->created_at];
     \App\Models\Admin\LogModel::create($userlog);
     return redirect(DOMAIN . 'regist/success');
 }
예제 #9
0
 public function query()
 {
     $data = new \stdClass();
     //type==1公司简介,2历程,3新闻,4资讯,5服务,6团队,7招聘,21单页
     $data->abouts = ComFuncModel::where('type', '<', 5)->where('cid', $this->cid)->get();
     $data->products = GoodsModel::where('genre', 1)->where('type', 4)->get();
     $data->teams = ComFuncModel::where('type', 6)->where('cid', $this->cid)->get();
     $data->jobs = ComFuncModel::where('type', 7)->where('cid', $this->cid)->get();
     //公司联系方式
     $data->contactFields = ['area', 'point', 'address', 'tel', 'qq', 'web', 'fax', 'email'];
     $data->contactFieldNames = ['地区', '坐标', '地址', '电话', 'qq', '网址', '传真', '邮箱'];
     $data->contact = 0;
     $comMainModel = CompanyModel::find($this->cid);
     $comMainModel = Tools::objectToArray($comMainModel);
     foreach ($data->contactFields as $contactField) {
         if ($comMainModel[$contactField]) {
             $data->contact++;
         }
     }
     $data->parts = GoodsModel::where('genre', 2)->where('type', 4)->get();
     $data->firms = ComFuncModel::where('type', 5)->where('cid', $this->cid)->get();
     return $data;
 }
예제 #10
0
 /**
  * 收集数据
  */
 public function getData(Request $request, $id = null)
 {
     //图片上传处理
     if ($request->urlSel == 1) {
         if ($request->hasFile('url_ori')) {
             //判断文件存在
             //验证图片大小
             foreach ($_FILES as $pic) {
                 if ($pic['size'] > $this->uploadSizeLimit) {
                     echo "<script>alert(\"对不起,你上传的图片过大,请重新选择\");history.go(-1);</script>";
                     exit;
                 }
             }
             $file = $request->file('url_ori');
             //获取文件
             $url = \App\Tools::upload($file);
         }
         if (!isset($url) && ($oldUrl = PicModel::find($id)->url)) {
             $url = $oldUrl;
         }
         if (!isset($url)) {
             echo "<script>alert('对不起,您还没上传图片!');history.go(-1);</script>";
             exit;
         }
     } elseif ($request->urlSel == 2) {
         if (!$request->url2 && ($oldUrl2 = PicModel::find($id)->url2)) {
             $request->url2 = $oldUrl2;
         }
         if (!$request->url2) {
             echo "<script>alert('对不起,您还没填写链接!');history.go(-1);</script>";
             exit;
         }
     }
     $data = ['uid' => $this->userid, 'name' => $request->name, 'intro' => $request->intro, 'urlSel' => $request->urlSel, 'url' => isset($url) ? $url : '', 'url2' => $request->url2];
     return $data;
 }
예제 #11
0
 public static function getActions()
 {
     return Tools::getChild(ActionModel::getAdminMenus(), $pid = 0);
 }
예제 #12
0
 public static function getHeaders()
 {
     return Tools::getChild(LinkModel::headers(), $pid = 0);
 }
예제 #13
0
파일: Tools.php 프로젝트: 946493655/culture
 /**
  * 由ip获得所在城市
  */
 public static function getCityByIp($ip = '')
 {
     $address = '';
     if ($ip && substr($ip, 0, 7) != '192.168') {
         $key = 'Tj1ciyqmG0quiNgpr0nmAimUCCMB5qMk';
         //自己申请的百度地图api的key
         $curl = new \Curl\Curl();
         $apiUrl = 'http://api.map.baidu.com/location/ip';
         $curl->post($apiUrl, array('ak' => $key, 'ip' => $ip));
         $response = $curl->response;
         $response = \App\Tools::objectToArray($response);
         if ($response['status'] == 0) {
             $address = $response['content']['address'];
         }
     } elseif ($ip && substr($ip, 0, 7) == '192.168') {
         $address = '浙江省 杭州市 滨江区';
     } elseif (!$ip) {
         $address = '未知';
     }
     return $address;
 }
예제 #14
0
 public function getData(Request $request)
 {
     //图片上传
     if ($request->hasFile('url_ori')) {
         //判断图片存在
         foreach ($_FILES as $pic1) {
             if ($pic1['size'] > $this->uploadSizeLimit) {
                 echo "<script>alert('对不起,你上传的文件大于5M,请重新选择');history.go(-1);</script>";
                 exit;
             }
         }
         $file = $request->file('url_ori');
         //获取文件
         $picUrl = \App\Tools::upload($file);
         //            $config = [
         //                'fileField' => 'url_ori1',    //文件域字段名
         //                'allowFiles'=> $this->pic_suffixs,   //允许上传的文件后辍
         //                'maxSize'   => $this->uploadSizeLimit, //允许上传文件的大小5M 单位 b
         //                'nameFormat'=> $this->pic_path,
         //            ];
         //            $rst = Uploader::save($config, $request);
         //            if ($rst['state']=='SUCCESS') { $data['pic'] = $rst['url']; }
         //            else { echo "<script>alert('图片上传错误,".$rst['state']."!');history.go(-1);</script>";exit; }
     } elseif ($request->url) {
         $picUrl = $request->url;
     } else {
         echo "<script>alert('图片未上传或者地址为空!');history.go(-1);</script>";
         exit;
     }
     $data = ['uid' => $this->userid, 'name' => $request->name, 'intro' => $request->intro, 'url' => isset($picUrl) ? $picUrl : ''];
     return $data;
 }
예제 #15
0
 public static function getFooters()
 {
     return Tools::getChild(LinkModel::footers(), $pid = 0);
 }
예제 #16
0
파일: Front.php 프로젝트: gtcrais/gtcms
    public static function embedVideo($url, $params = array())
    {
        $data = Tools::parseMediaUrl($url);
        $class = isset($params['class']) ? $params['class'] : "";
        $width = isset($params['width']) ? 'width="' . $params['width'] . '"' : "";
        $height = isset($params['height']) ? 'height="' . $params['height'] . '"' : "";
        $embedCode = "";
        if ($data) {
            if ($data['sourceKey'] == 'youtube') {
                $embedCode = '
					<div class="videoContainer ' . $class . '">
						<iframe ' . $width . ' ' . $height . ' src="//www.youtube.com/embed/' . $data['originalId'] . '" frameborder="0" allowfullscreen></iframe>
					</div>
				';
            } else {
                $embedCode = '
					<div class="videoContainer ' . $class . '">
						<iframe src="//player.vimeo.com/video/' . $data['originalId'] . '"
							' . $width . '
							' . $height . '
							frameborder="0"
							webkitallowfullscreen
							mozallowfullscreen allowfullscreen>
						</iframe>
					</div>
				';
            }
        }
        return $embedCode;
    }
예제 #17
0
 /**
  * Get several configuration values 
  *
  * @param array $keys Keys wanted
  * @param integer $id_lang Language ID
  * @return array Values
  */
 public static function getMultiple($keys)
 {
     if (!is_array($keys) || !is_array(self::$_CONF) || $id_lang && !is_array(self::$_CONF_LANG)) {
         die(Tools::displayError());
     }
     $resTab = array();
     if (!$id_lang) {
         foreach ($keys as $key) {
             if (array_key_exists($key, self::$_CONF)) {
                 $resTab[$key] = self::$_CONF[$key];
             } elseif (array_key_exists($id_lang, self::$_CONF_LANG)) {
                 foreach ($keys as $key) {
                     if (array_key_exists($key, self::$_CONF_LANG[(int) $id_lang])) {
                         $resTab[$key] = self::$_CONF_LANG[(int) $id_lang][$key];
                     }
                 }
             }
         }
     }
     return $resTab;
 }
예제 #18
0
 public static function getCompanyMenus()
 {
     return Tools::getChild(MenusModel::CompanyMenus(), $pid = 0);
 }
예제 #19
0
 public static function edit($id, $historyLink = false, $settings = false)
 {
     $ajaxRequest = \Request::ajax() && \Request::get('getIgnore_isAjax') ? true : false;
     if ($settings) {
         AdminHistoryManager::clearHistory();
     } else {
         AdminHistoryManager::addHistoryLink($historyLink, self::$entity, true);
     }
     /** @var \App\BaseModel $entity */
     $entity = self::$entity;
     /** @var \App\BaseModel $fullEntity */
     $fullEntity = self::$modelConfig->myFullEntityName();
     if (config('gtcms.premium') && $entity == "GtcmsSetting") {
         $object = GtcmsSetting::createSettingsObject();
     } else {
         /** @var \App\BaseModel $object */
         if ($id == "new") {
             $object = new $fullEntity();
         } else {
             $object = $fullEntity::find($id);
         }
     }
     $validator = NULL;
     $action = $object->id ? 'edit' : 'add';
     $quickEdit = false;
     if (config('gtcms.premium')) {
         $quickEdit = GtcmsPremium::getQuickEditVar();
     }
     if (!empty($_POST) && $ajaxRequest) {
         $validator = \Validator::make(\Request::all(), AdminHelper::validationRules(self::$modelConfig, $object, $quickEdit));
         if ($validator->fails()) {
             $message = trans('gtcms.validationFailed');
             $data = array('success' => false, 'errors' => $validator->getMessageBag()->getMessages(), 'errorMsg' => $message, 'quickEdit' => $quickEdit);
             return \Response::json($data);
         } else {
             if ($entity == "GtcmsSetting") {
                 AdminEntityHandler::editSettings(self::$modelConfig);
             } else {
                 if ($object->isEditable()) {
                     $object = AdminEntityHandler::edit($object, self::$modelConfig);
                 }
             }
             return self::ajaxRedirect($object, $action, $quickEdit);
         }
     }
     $viewData = array('active' => $entity, 'modelConfig' => self::$modelConfig, 'object' => $object, 'ajaxRequest' => $ajaxRequest, 'action' => $action, 'quickEdit' => $quickEdit);
     $setUrl = false;
     if (!$settings) {
         $setUrl = '/admin/' . self::$modelConfig->name . '/edit/' . ($object->id ? $object->id : 'new') . Tools::getGets();
     }
     if ($ajaxRequest) {
         $view = \View::make('gtcms.admin.elements.editContent')->with($viewData);
         $data = array('success' => true, 'view' => $view->render(), 'setUrl' => $setUrl, 'history' => AdminHistoryManager::getHistory(), 'setHistoryLinks' => true, 'modelConfigName' => self::$modelConfig->name, 'replaceCurrentHistory' => false);
         return \Response::json($data);
     } else {
         return \View::make('gtcms.admin.elements.edit')->with($viewData);
     }
 }
예제 #20
0
 public static function getNavigates()
 {
     return Tools::getChild(LinkModel::navigates(), $pid = 0);
 }
예제 #21
0
 public static function getMemberMenus()
 {
     return Tools::getChild(MenusModel::MemberMenus(), $pid = 0);
 }
예제 #22
0
 /**
  * 收集数据
  */
 public function getData($data)
 {
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $ip = Tools::getIp();
     $ipaddress = Tools::getCityByIp($ip);
     $companyModel = CompanyModel::find($data['cid']);
     $userModel = UserModel::find($data['uid']);
     return array('cid' => $data['cid'], 'cname' => $companyModel->name, 'visit_id' => $data['uid'], 'uname' => $userModel->username, 'action' => $data['visit_url'], 'ip' => $ip, 'ipaddress' => $ipaddress, 'serial' => $serial, 'loginTime' => time());
 }
예제 #23
0
 /**
  * 收集数据
  */
 public function getData(Request $request, $id = null)
 {
     //判断logo
     $logo = '';
     //给个默认值
     if ($id) {
         $logo = ComMainModel::find($id)->logo;
     }
     //图片上传
     if (!$logo && $request->hasFile('url_ori')) {
         //判断文件存在
         $data['url_ori'] = '';
         //验证图片大小
         foreach ($_FILES as $pic) {
             if ($pic['size'] > $this->uploadSizeLimit) {
                 echo "<script>alert('对不起,你上传的文件大于5M,请重新选择');history.go(-1);</script>";
                 exit;
             }
         }
         $file = $request->file('url_ori');
         //获取文件
         $logo = \App\Tools::upload($file);
     }
     $data = ['title' => $request->title, 'keyword' => $request->keyword, 'description' => $request->description, 'logo' => $logo, 'job' => $request->job, 'job_require' => $request->job_require, 'job_num' => $request->job_num, 'sort' => $request->sort, 'istop' => $request->istop, 'isshow' => $request->isshow];
     return $data;
 }
예제 #24
0
 /**
  * 收集数据
  */
 public function getData(Request $request)
 {
     $data = $request->all();
     //获取图片文件名
     $data['url_ori'] = '';
     if ($request->hasFile('url_ori')) {
         //判断文件存在
         //验证图片大小
         foreach ($_FILES as $pic) {
             if ($pic['size'] > $this->uploadSizeLimit) {
                 echo "<script>alert(\"对不起,你上传的图片过大,请重新选择\");history.go(-1);</script>";
                 exit;
             }
         }
         $file = $request->file('url_ori');
         //获取文件
         $data['url_ori'] = \App\Tools::upload($file);
     }
     if (!$data['url_ori']) {
         echo "<script>alert('对不起,您还没上传图片!');history.go(-1);</script>";
         exit;
     }
     $pic = ['name' => $data['name'], 'url' => $data['url_ori'], 'intro' => $data['intro']];
     return $pic;
 }