chengkun
2025-04-29 ab5d7bddae4557b9d56d17f21fc8ca232d7d8693
app/public/common.php
@@ -1,7 +1,6 @@
<?php
/**
 *  全局的权限验证 数据验证库
 */
@@ -117,8 +116,7 @@
      }else{
          $this->protocol_wap =  $this->config['sy_wapssl']=='1' ? 'https://' : 'http://';
         if(strpos($this->config['sy_wapdomain'],'http://')===false && strpos($this->config['sy_wapdomain'],'https://')===false)
         {
            if (strpos($this->config['sy_wapdomain'], 'http://') === FALSE && strpos($this->config['sy_wapdomain'], 'https://') === FALSE) {
             $this->config['sy_wapdomain'] = $this->protocol_wap.$this->config['sy_wapdomain'];
         }
@@ -156,6 +154,7 @@
         $this->member_fabudata();
      }
   }
   //底部导航的发布所需数据
   function member_fabudata(){
@@ -197,9 +196,9 @@
      
      
   }
   //同步登录时间
    function upLoginLog($logindate)
    {
    function upLoginLog($logindate) {
        if ($logindate < strtotime('today') && $this->usertype > 0) {
@@ -257,8 +256,7 @@
     * @param null $uid
     * @param null $usertype
     */
    function webLog($model, $uid=null, $usertype=null)
    {
    function webLog($model, $uid = NULL, $usertype = NULL) {
        $weblogM    =   $this->MODEL('weblog');
        $data       =   array(
@@ -277,6 +275,7 @@
   function DoException(){
      $this->ACT_msg("index.php","您请求的页面不存在");
   }
   //后台模板
   function yuntpl($tplarr=array()){
      if(is_array($tplarr) && $tplarr!=''){
@@ -289,9 +288,11 @@
         exit();
         
      }else{
         echo "模版不能为空!";die;
            echo "模版不能为空!";
            die;
      }
   }
   //前台模板
   function yun_tpl($tplarr=array()){
      if(is_array($tplarr) && $tplarr!=''){
@@ -302,12 +303,13 @@
         }
         exit();
      }else{
         echo "模版不能为空!";die;
            echo "模版不能为空!";
            die;
      }
   }
   //UC资料修改
    function uc_edit_pw($post, $old = "1", $url)
    {
    function uc_edit_pw($post, $old = "1", $url) {
        $old_info   =   $this->obj->select_once('member', array('uid' => $post['uid']), "`name_repeat`,`username`");
        if ($post['password'] != "") {
@@ -357,8 +359,7 @@
     * @param mixed $name 单个变量变量名:如“webname”,或包含多个变量的数据:如“array('webname'=>'phpyun人才系统')”
    * @param mixed $value
    */
    function yunset($name, $value = null)
    {
    function yunset($name, $value = NULL) {
        if (is_array($name)) {
            foreach ($name as $k => $v) {
@@ -370,8 +371,7 @@
        }
    }
    function company()
    {
    function company() {
        $this->tpl->is_fun();
        $company        =   $this->obj->select_once('company', array('uid' => $_GET['id']), "`name`,`content`");
@@ -397,7 +397,7 @@
   //前台公共部分
   function index(){
      $UA = strtoupper($_SERVER['HTTP_USER_AGENT']);
      if(strpos($UA, 'WINDOWS NT') === true){
        if (strpos($UA, 'WINDOWS NT') === TRUE) {
         
         header("location:".Url('index',array('c'=>'wap')));
         exit();
@@ -420,7 +420,7 @@
      $aArray = array('getHbBase');
      
      $UA = strtoupper($_SERVER['HTTP_USER_AGENT']);
      if($this->config['sy_pc_jump_wap']!='1' && strpos($UA, 'WINDOWS NT') !== false && !in_array($a,$aArray)){
        if ($this->config['sy_pc_jump_wap'] != '1' && strpos($UA, 'WINDOWS NT') !== FALSE && !in_array($a, $aArray)) {
         //电脑访问手机端 匹配相关链接 
         header('location:'.Url('index',array('c'=>'wap')));
      }
@@ -450,7 +450,7 @@
         header('location:'.$this->config['sy_weburl']);
      }
      $UA = strtoupper($_SERVER['HTTP_USER_AGENT']);
      if($this->config['sy_pc_jump_wap']!='1' && strpos($UA, 'WINDOWS NT') !== false){
        if ($this->config['sy_pc_jump_wap'] != '1' && strpos($UA, 'WINDOWS NT') !== FALSE) {
         header('location:'.Url('index',array('c'=>'wap')));
      }
@@ -462,11 +462,13 @@
                // 外部链接访问,会员中心的,进入微信授权页面,已绑定的,直接登录,进到会员中心首页
             if (!$_SERVER['HTTP_REFERER']){
                 
                 header('location:'.Url('wap',array('c'=>'wxoauth')));die;
                    header('location:' . Url('wap', array('c' => 'wxoauth')));
                    die;
             }
         }
         
         header('location:'.Url('wap',array('c'=>'login')));die;
            header('location:' . Url('wap', array('c' => 'login')));
            die;
      }else{
         $shell=$this->GET_user_shell($this->uid,$_COOKIE['shell']);
@@ -474,7 +476,8 @@
         if(!is_array($shell) && !$this->spid){
            $this->cookie->unset_cookie();
             header('location:'.Url('wap',array('c'=>'login')));die;
                header('location:' . Url('wap', array('c' => 'login')));
                die;
         }else{
             if(is_weixin()){
                 if(in_array($_GET['c'],array('integral','finance','job'))){
@@ -498,8 +501,7 @@
      }
   }
    function member()
    {
    function member() {
        $this->tpl->is_fun();
        if (!$this->uid) {
            $login = Url('login');
@@ -510,6 +512,7 @@
        $this->yunset("useremail", $_COOKIE['email']);
        $this->yunset("is_member", 1);
    }
    function wxapp(){
        
    }
@@ -517,6 +520,7 @@
    function datav(){
    }
   //生成缓存-------------开始
   function web_config(){
      $configM   =   $this->MODEL('config');
@@ -551,8 +555,7 @@
      }
   }
    function header_desc($title = "", $keyword = "", $description = "")
    {
    function header_desc($title = "", $keyword = "", $description = "") {
        $this->yunset("title", $title);
        $this->yunset("keywords", $keyword);
        $this->yunset("description", $description);
@@ -560,8 +563,7 @@
    //TODO:已移动到当前目录的model.php中,待修改完成后删除
   //调用分页,$table表名,$where条件,$pageurl分页链接,$limit条数,$rowsname模板接收变量,$pagenavname分页模板接收变量
    function get_page($table, $where = "", $pageurl = "", $limit = 20, $field = "*", $rowsname = "rows", $pagenavname = "pagenav")
    {
    function get_page($table, $where = "", $pageurl = "", $limit = 20, $field = "*", $rowsname = "rows", $pagenavname = "pagenav") {
        $rows       =   array();
        $page       =   $_GET['page'] < 1 ? 1 : $_GET['page'];
@@ -570,7 +572,7 @@
        $this->yunset("total", $num);
        if ($num > $limit) {
            $pages      =   ceil($num / $limit);
            $pagenav    =   Page($page, $num, $limit, $pageurl, $notpl = false, $this->tpl, $pagenavname);
            $pagenav = Page($page, $num, $limit, $pageurl, $notpl = FALSE, $this->tpl, $pagenavname);
            $this->yunset("pages", $pages);
        }
        $rows   =   $this->obj->DB_select_all($table, "$where limit $ststrsql,$limit", $field);
@@ -579,14 +581,12 @@
    }
   
   //验证手机是否存在
    function FetchMoblie($moblie)
    {
    function FetchMoblie($moblie) {
        $UserInfoM  =   $this->MODEL('userinfo');
        return $UserInfoM->GetMemberOne(array('moblie' => $moblie), array('field' => "`uid`,`username`"));
    }
    function logout($result = true)
    {
    function logout($result = TRUE) {
        if ($this->config['sy_uc_type'] == "uc_center") {
@@ -618,15 +618,14 @@
        }
    }
    function del_dir($dir_adds = '', $del_def = 0)
    {
    function del_dir($dir_adds = '', $del_def = 0) {
        $result =   false;
        $result = FALSE;
        if (!is_dir($dir_adds)) {
            return false;
            return FALSE;
        }
        $handle =   opendir($dir_adds);
        while (($file = readdir($handle)) !== false) {
        while (($file = readdir($handle)) !== FALSE) {
            if ($file != '.' && $file != '..') {
                $dir    =   $dir_adds.DIRECTORY_SEPARATOR.$file;
                is_dir($dir) ? $this->del_dir($dir) : @unlink($dir);
@@ -634,15 +633,14 @@
        }
        closedir($handle);
        if ($del_def == 0) {
            $result =   @rmdir($dir_adds) ? true : false;
            $result = @rmdir($dir_adds) ? TRUE : FALSE;
        } else {
            $result =   true;
            $result = TRUE;
        }
        return $result;
    }
   function seo($ident,$title='',$keyword='',$description='',$settpl = true, $iswxapp = false)
   {
    function seo($ident, $title = '', $keyword = '', $description = '', $settpl = TRUE, $iswxapp = FALSE) {
       if ($iswxapp){
           // 微信小程序用seo
           include DATA_PATH.'api/wxapp/wxseo.cache.php';
@@ -742,8 +740,7 @@
   }
   //获取搜索类别
   function get_seacrh_class($ident,$type='title')
   {
    function get_seacrh_class($ident, $type = 'title') {
       $cacheM  =  $this->MODEL('cache');
       $cache   =  $cacheM->GetCache(array('hy'));
      
@@ -813,8 +810,7 @@
   }
   //获取搜索职能
    function get_search_job($ident, $type = 'title')
    {
    function get_search_job($ident, $type = 'title') {
        $cacheM = $this->MODEL('cache');
        $cache = $cacheM->GetCache(array('job'));
@@ -857,8 +853,7 @@
    }
   //获取搜索城市
    function get_search_city($ident, $type = 'title')
    {
    function get_search_city($ident, $type = 'title') {
        $cacheM     =   $this->MODEL('cache');
        $cache      =   $cacheM->GetCache(array('city'));
        $city_name  =   $cache['city_name'];
@@ -902,8 +897,7 @@
        return $data;
    }
    function addkeywords($type, $keyword)
    {
    function addkeywords($type, $keyword) {
        $info   =   $this->obj->select_once('hot_key', array('key_name' => $keyword, 'type' => $type));
        if (is_array($info)) {
@@ -918,8 +912,7 @@
   /**
     * 系统消息提醒
     */
    function automsg($content, $uid)
    {
    function automsg($content, $uid) {
        $msgM    =   $this->MODEL('sysmsg');
@@ -930,8 +923,7 @@
     * @param $data
     * @return mixed
     */
    function post_trim($data)
    {
    function post_trim($data) {
        foreach ($data as $d_k => $d_v) {
            if (is_array($d_v)) {
@@ -944,15 +936,14 @@
        return $data;
    }
    function get_moblie()
    {
    function get_moblie() {
        if ($this->config['sy_wap_web'] == "2") {
            header('location:' . $this->config['sy_weburl']);
        }
        $UA =   strtoupper($_SERVER['HTTP_USER_AGENT']);
        if ($this->config['sy_pc_jump_wap'] != '1' && strpos($UA, 'WINDOWS NT') !== false) {
        if ($this->config['sy_pc_jump_wap'] != '1' && strpos($UA, 'WINDOWS NT') !== FALSE) {
            header('location:' . Url('index', array('c' => 'wap')));
        }
@@ -964,8 +955,7 @@
     * @param $type
     */
    //  TODO 订阅已调整为计划任务推送,采集职位/简历 不做订阅信息查询推送,待删除
    function send_dingyue($id, $type)
    {
    function send_dingyue($id, $type) {
        $notice =   $this->MODEL('notice');
        if ($type == "2") {
@@ -1040,8 +1030,7 @@
     * @param int $tm       跳转时间
     * @param string $type  1:后台操作
     */
    function ACT_layer_msg($msg = "操作已成功!", $st = 9, $url = '', $tm = 2, $type = '0')
    {
    function ACT_layer_msg(string $msg = "操作已成功!", int $st = 9, string $url = '', int $tm = 2, string $type = '0') {
        //解决ie9 $.get $.post 回调函数的返回值为undefine
        header("Content-Type: text/html; charset=UTF-8");
@@ -1065,15 +1054,14 @@
    /**
     * @desc 消息返回
     *
     * @param $msg          信息提示
     * @param string $msg 信息提示
     * @param string $st    图标编号9 成功 8 失败
     * @param string $type  1-批量 0-单条
     * @param string $url   跳转地址
     * @param string $tm    时间
     * @param string $error
     */
    function layer_msg($msg, $st = '9', $type = '0', $url = '', $tm = '2', $error = '0')
    {
    function layer_msg(string $msg, string $st = '9', string $type = '0', string $url = '', string $tm = '2', string $error = '0') {
        if ($type == '1') {
            $this->ACT_layer_msg($msg, $st, $url, $tm, $type);
@@ -1097,8 +1085,7 @@
        }
    }
    function wapheader($url)
    {
    function wapheader($url) {
        $url    =   $this->config['sy_wapdomain'] . "/" . $url;
        header('Location: '.$url);
        exit();
@@ -1109,8 +1096,7 @@
     * @param $string
     * @return
     */
    function stringfilter($string)
    {
    function stringfilter($string) {
        $str    =   trim($string);
        $regex  =   "/\\$|\'|\\\|/";
@@ -1118,8 +1104,9 @@
        return $str;
    }
    public function MODEL($ModelName = null, $ModelPath = null)
    {
    public function MODEL($ModelName = NULL, $ModelPath = NULL) {
//        var_dump($ModelName);
//        var_dump($ModelPath);
        require_once(APP_PATH.'app/public/action.class.php');
        if ($ModelName) {
            if ($ModelPath) {
@@ -1128,7 +1115,7 @@
                    require_once($ModelPath . '/' . $ModelName . '.class.php');
                } else {
                    return null;
                    return NULL;
                }
            } else {
@@ -1139,7 +1126,7 @@
                    require_once($ModelPath.$ModelFileName);
                } else {
                    return null;
                    return NULL;
                }
            }
            $ModelName  =   $ModelName.'_model';
@@ -1147,13 +1134,17 @@
            $ModelName  =   'model';
        }
//        var_dump($ModelName);
//        exit();
        if (!class_exists($ModelName)) {
            return NULL;
        }
        $Model  =   new $ModelName($this->db, $this->def, array('uid' => $this->uid, 'username' => $this->username, 'usertype' => $this->usertype), $this->tpl);
        return $Model;
    }
   
   //获取描述
    function GET_content_desc($cont)
    {
    function GET_content_desc($cont) {
        return mb_substr(strip_tags($cont), 0, 200, "utf-8");
    }
@@ -1164,8 +1155,7 @@
     * @param int $st       1成功2失败
     * @param int $tm       跳转时间
     */
    function ACT_msg($url = '', $msg = "操作已成功!", $st = 8, $tm = 3)
    {
    function ACT_msg($url = '', $msg = "操作已成功!", $st = 8, $tm = 3) {
        if ($url == '') {
            $url = $this->config['sy_weburl'];
        }
@@ -1187,14 +1177,13 @@
     * @param int $st       1成功 2失败
     * @param int $tm       跳转时间
     */
    function ACT_msg_wap($url = '', $msg = null, $st = 1, $tm = 5)
    {
    function ACT_msg_wap($url = '', $msg = NULL, $st = 1, $tm = 5) {
        if ($url == '') {
            $url = $this->config['sy_weburl'];
        }
        if ($msg == null) {
        if ($msg == NULL) {
            $msg = '操作已成功!';
        }
@@ -1211,15 +1200,14 @@
     * @param $shell
     * @return bool|null
     */
    function GET_user_shell($uid, $shell)
    {
    function GET_user_shell($uid, $shell) {
        if (!preg_match("/^\d*$/", $uid)) {
            return false;
            return FALSE;
        }
        if (!preg_match("/^\d*$/", $_COOKIE['usertype'])) {
            return false;
            return FALSE;
        }
        $SQL    =   "SELECT `uid`,`username`,`usertype`,`password`,`salt`,`pid`,`status`,`login_date` FROM `".$this->def."member` WHERE `uid`='$uid'  limit 1";
@@ -1278,8 +1266,7 @@
     * @param $html
     * @return string
     */
    function CloseTags($html)
    {
    function CloseTags($html) {
        $html       =   preg_replace('/<[^>]*$/', '', $html);
        preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
@@ -1317,17 +1304,16 @@
    * @return string
    */
   //  TODO:暂时无调用,待删除
    function checksrc($post, $url = '')
    {
    function checksrc($post, $url = '') {
        if (strpos($post, $this->config['sy_weburl']) !== false) {
        if (strpos($post, $this->config['sy_weburl']) !== FALSE) {
            $post   =   str_replace($this->config['sy_weburl'], '.', $post);
        }
        $post   =   str_replace(array('./data', '../data'), 'data', $post);
        if ((strpos($post, 'data/logo/') !== false || strpos($post, 'data/upload/special/') !== false) && file_exists(APP_PATH.$post)) {
        if ((strpos($post, 'data/logo/') !== FALSE || strpos($post, 'data/upload/special/') !== FALSE) && file_exists(APP_PATH . $post)) {
            $picUrl =   $post;
        } else {
@@ -1353,8 +1339,7 @@
     * @param $uid
     * @param array $data
     */
    function MemberLock($uid, $data = array())
    {
    function MemberLock($uid, $data = array()) {
        $userInfoM  =   $this->MODEL('userinfo');
        $uInfo      =   $userInfoM->getInfo(array('uid' => $uid), array('field' => '`status`'));
@@ -1378,8 +1363,7 @@
    /**
     * 更多栏目导航
     */
    function moreMenu()
    {
    function moreMenu() {
        include PLUS_PATH.'menu.cache.php';
@@ -1396,7 +1380,7 @@
                    $navList[$k]['url_n'] = $v['url'];
                } else {
                    if (strpos($v['url'], '&') !== false && strpos($v['url'], '=') !== false) {
                    if (strpos($v['url'], '&') !== FALSE && strpos($v['url'], '=') !== FALSE) {
                        $url = explode('&', $v['url']);
                        $sonUrl = array();
@@ -1418,4 +1402,5 @@
    }
}
?>