示例#1
0
 public function get_templates($dir = NULL, $plubs = 0, $skins = NULL, $ulog = 0)
 {
     if (!defined('IS_ADMIN') && strpos(REQUEST_URI, 'index.php/install/') === FALSE && !file_exists(FCPATH . 'packs/install/plub_install.lock')) {
         msg_txt(L('plub_no_instal'), Web_Path . 'admin.php');
     }
     if (!defined('PLUBPATH') && $plubs == 0) {
         //系统默认视图路径
         $path = str_replace("\\", "/", CSCMS);
         if (!$dir) {
             $dirs = 'tpl/skins/' . Web_Skins;
         } else {
             if ($dir == 'user') {
                 $dirs = 'tpl/' . $dir . '/' . User_Skins;
                 //会员中心默认视图
             } elseif ($dir == 'home') {
                 if (!empty($skins)) {
                     $dirs = 'tpl/' . $dir . '/' . $skins;
                     //会员空间默认视图
                 } else {
                     $dirs = 'tpl/' . $dir . '/' . Home_Skins;
                     //会员空间默认视图
                 }
             } else {
                 $dirs = 'tpl/' . $dir . '/';
                 //系统后台视图
             }
         }
         if (defined('MOBILE') && Mobile_Is == 1) {
             //手机门户视图
             if ($dir == 'user') {
                 $dirs = 'tpl/mobile/' . Mobile_Skins . 'user/';
             } elseif ($dir == 'home') {
                 $dirs = 'tpl/mobile/' . Mobile_Skins . 'home/';
             } elseif ($dir != 'admin') {
                 $dirs = 'tpl/mobile/' . Mobile_Skins;
             }
         }
     } else {
         //版块视图路径
         $path = str_replace("\\", "/", APPPATH);
         $dir_file = APPPATH . 'config/site.php';
         if ($plubs == 1 && !defined('PLUBPATH')) {
             define('PLUBPATH', $dir);
             $path = FCPATH . 'plugins/' . $dir . '/';
             $dir_file = FCPATH . 'plugins/' . $dir . '/config/site.php';
         }
         $ak = getzd('plugins', 'ak', PLUBPATH, 'dir');
         if (empty($ak)) {
             msg_txt(vsprintf(L('plub_key_err1'), array(PLUBPATH)), Web_Path);
         }
         $arrs = unarraystring(sys_auth($ak, 'D'));
         if ($arrs == '' || empty($arrs['md5']) || md5(PLUBPATH . $arrs['key'] . host_ym(1)) != $arrs['md5']) {
             msg_txt(vsprintf(L('plub_key_err2'), array(PLUBPATH)), Web_Path);
         }
         $dirs = 'tpl/skins/default/';
         if (is_file($dir_file)) {
             $plub = (require $dir_file);
             if (is_array($plub)) {
                 //后台视图
                 if (defined('IS_ADMIN') && $plubs < 2) {
                     $dirs = 'tpl/admin/';
                     //手机视图
                 } elseif (!defined('IS_ADMIN') && defined('MOBILE') && $plub['Mobile_Is'] == 1) {
                     $dirs = 'tpl/mobile/' . $plub['Mobile_Dir'];
                     if (defined('HOMEPATH')) {
                         $dirs .= 'home/';
                     }
                     if (defined('USERPATH')) {
                         $dirs .= 'user/';
                     }
                     //前台视图
                 } else {
                     if (defined('HOMEPATH')) {
                         if ($ulog == 1) {
                             $path = str_replace("\\", "/", CSCMS);
                         }
                         if (!empty($skins)) {
                             $dirs = 'tpl/home/' . $skins;
                         } else {
                             $dirs = 'tpl/home/' . Home_Skins;
                         }
                     } elseif (defined('USERPATH')) {
                         $dirs = 'tpl/user/' . $plub['User_Dir'];
                     } else {
                         $dirs = 'tpl/skins/' . $plub['Skins_Dir'];
                     }
                 }
             }
         }
     }
     if (substr($dirs, -1) != '/') {
         $dirs .= '/';
     }
     $this->_ci_view_paths = array($path . $dirs => TRUE);
 }
示例#2
0
 public function cscms_sql($fields, $para, $str_arr, $label, $sorts = '', $autoarr = array(), $cid = 0, $sql = '')
 {
     preg_match_all("/([a-z]+)\\=[\"]?([^\"]+)[\"]?/i", stripslashes($para), $matches, PREG_SET_ORDER);
     $arr = array('field', 'table', 'loop', 'pagesize', 'order', 'sort', 'start');
     //获取数据表
     $table = $this->arr_val('table', $matches);
     if ($table == '') {
         //模板标签错误,缺少table参数
         $strs = str_replace($label, ".....", $str_arr);
         msg_txt(vsprintf(L('skins_table'), array($strs)));
     }
     //获取要查询的字段
     $field = $this->arr_val('field', $matches);
     if (!$field) {
         $field = "*";
     }
     $ci =& get_instance();
     if (!isset($ci->db)) {
         $ci->load->database();
     }
     if (!$ci->db->table_exists(CS_SqlPrefix . $table)) {
         //数据表不存在
         $strs = str_replace($label, ".....", $str_arr);
         msg_txt(vsprintf(L('skins_table_err'), array($strs, $table)));
     }
     if ($sql == '') {
         $sql = "select " . $field . " from `" . CS_SqlPrefix . $table . "` where 1=1";
     } else {
         $sql = str_replace("{field}", $field, $sql);
     }
     $yid = $hid = 0;
     foreach ($matches as $v) {
         if (in_array($v[1], $arr)) {
             $v[1] = $v[2];
             continue;
         }
         //解析字母搜索标签
         if ($v[1] == 'zm') {
             $zmall = explode(",", $v[2]);
             if ($ci->db->field_exists($zmall[0], $table)) {
                 //判断条件字段是否存在
                 $zimu_arr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
                 $zimu_arr1 = array(-20319, -20283, -19775, -19218, -18710, -18526, -18239, -17922, -1, -17417, -16474, -16212, -15640, -15165, -14922, -14914, -14630, -14149, -14090, -13318, -1, -1, -12838, -12556, -11847, -11055);
                 $zimu_arr2 = array(-20284, -19776, -19219, -18711, -18527, -18240, -17923, -17418, -1, -16475, -16213, -15641, -15166, -14923, -14915, -14631, -14150, -14091, -13319, -12839, -1, -1, -12557, -11848, -11056, -2050);
                 if (!in_array(strtoupper($zmall[1]), $zimu_arr)) {
                     //其他
                     $sql .= " and substring( " . $zmall[0] . ", 1, 1 ) NOT REGEXP '^[a-zA-Z]' and substring( " . $zmall[0] . ", 1, 1 ) REGEXP '^[u4e00-u9fa5]'";
                 } else {
                     $posarr = array_keys($zimu_arr, strtoupper($zmall[1]));
                     $pos = $posarr[0];
                     $sql .= " and (((ord( substring(" . $zmall[0] . ", 1, 1 ) ) -65536>=" . $zimu_arr1[$pos] . " and  ord( substring( " . $zmall[0] . ", 1, 1 ) ) -65536<=" . $zimu_arr2[$pos] . ")) or UPPER(substring( " . $zmall[0] . ", 1, 1 ))='" . $zimu_arr[$pos] . "')";
                 }
             }
         } elseif ($ci->db->field_exists($v[1], $table)) {
             //判断条件字段是否存在
             if ($v[2] == 'auto' || substr($v[2], 0, 5) == 'auto,') {
                 //当前分类
                 $auall = explode(",", $v[2]);
                 if (!empty($auall[1])) {
                     if (empty($autoarr[$auall[1]])) {
                         $vs = 0;
                     } else {
                         $vs = is_array($autoarr) ? $autoarr[$auall[1]] : $autoarr;
                     }
                 } else {
                     if (empty($autoarr[$v[1]])) {
                         $vs = 0;
                     } else {
                         $vs = is_array($autoarr) ? $autoarr[$v[1]] : $autoarr;
                     }
                 }
                 if ($v[1] == 'tags') {
                     //TAGS标签
                     $sql .= " and (" . $this->gettags($vs) . ")";
                 } elseif (!empty($vs)) {
                     $sql .= " and " . $v[1] . " in (" . $vs . ")";
                 }
             } else {
                 if (strpos($v[2], ',') === FALSE) {
                     $sql .= " and " . $v[1] . "=" . $v[2];
                 } else {
                     $sql .= " and " . $v[1] . " in (" . $v[2] . ")";
                 }
             }
         }
         if ($v[1] == 'hid') {
             $hid = 1;
         }
         if ($v[1] == 'yid') {
             $yid = 1;
         }
     }
     //判断审核字段
     if ($yid == 0 && strpos($sql, 'yid=') === FALSE && $ci->db->field_exists('yid', $table)) {
         $sql .= ' and yid=0';
     }
     //判断回收站字段
     if ($hid == 0 && strpos($sql, 'hid=') === FALSE && $ci->db->field_exists('hid', $table)) {
         $sql .= ' and hid=0';
     }
     if ($cid > 0) {
         $sql .= " and cid=" . $cid;
     }
     $sort = $sorts ? $sorts : $this->arr_val('sort', $matches);
     if (!$sort) {
         $sort = 'id';
     }
     $order = $this->arr_val('order', $matches);
     if (!$order) {
         $order = 'desc';
     }
     if ($sort == 'rand') {
         $sort = 'rand()';
     }
     $sql .= " order by " . $sort . " " . $order;
     $loop = (int) $this->arr_val('loop', $matches);
     $start = (int) $this->arr_val('start', $matches);
     if (!$start) {
         $start = 1;
     }
     if ($loop > 0) {
         $sql .= " limit " . ($start - 1) . "," . $loop . "";
     }
     unset($matches);
     return $sql;
 }