Пример #1
0
 public function caiji()
 {
     $ac = $this->input->get('ac', true);
     $id = intval($this->input->get('id'));
     $xid = intval($this->input->get('xid'));
     $page = intval($this->input->get('page'));
     $okid = intval($this->input->get('okid'));
     if ($page == 0) {
         $page = 1;
     }
     if ($xid == 0) {
         $xid = 1;
     }
     if ($id == 0) {
         admin_msg(L('plub_09'), 'javascript:history.back();', 'no');
     }
     //ID不能为空
     $row = $this->db->query("SELECT * FROM " . CS_SqlPrefix . "caiji where id='" . $id . "'")->row();
     if (!$row) {
         admin_msg(L('plub_10'), 'javascript:history.back();', 'no');
     }
     //记录存在
     //总页数
     $pagejs = $row->jsid - $row->ksid;
     if ($pagejs < 1) {
         $pagejs = 1;
     }
     //倒顺采集
     if ($row->dxid == 1) {
         if ($xid == 1) {
             $xid = $row->jsid;
         }
         $cjurl = str_replace('{$id}', $xid, $row->cjurl);
         $data['ids'] = $xid;
         $xid = $xid - 1;
     } else {
         if ($xid == 1) {
             $xid = $row->ksid;
         }
         $cjurl = str_replace('{$id}', $xid, $row->cjurl);
         $data['ids'] = $xid;
         $xid = $xid + 1;
     }
     //读取列表文件
     $Content = trim($this->caiji->str($cjurl, $row->code));
     if (empty($Content)) {
         admin_msg(L('plub_11'), site_url('collect'), 'no');
     }
     //赋予网站主路径
     $this->caiji->weburl($row->url);
     //获取列表开始-结束
     $Liststr = $this->caiji->getstr($Content, trim($row->listks), trim($row->listjs));
     if (empty($Liststr)) {
         admin_msg(L('plub_12'), site_url('collect'), 'no');
     }
     //获取到连接地址 返回数组
     $LinkArr = $this->caiji->getarr(trim($row->linkks), trim($row->linkjs), $Liststr);
     if (empty($LinkArr)) {
         admin_msg(L('plub_13'), site_url('collect'), 'no');
     }
     //列表页采集图片
     $pic = '';
     if ($row->picmode == 1) {
         //获取到图片地址 返回数组
         $PicArr = $this->caiji->getarr(trim($row->picks), trim($row->picjs), $Liststr);
         $pic = $PicArr[$okid];
         if (!empty($pic) && substr($pic, 0, 7) != 'http://') {
             $pic = $row->url . $pic;
         }
     }
     $data['pic'] = $pic;
     //当前页内容总数
     $LinkCount = count($LinkArr);
     if ($page > $pagejs + 1) {
         //采集完毕
         admin_msg(L('plub_14'), site_url('collect'));
     }
     //采集内容页开始
     $data['err'] = '';
     $data['pagejs'] = $pagejs + 1;
     $data['page'] = $page;
     $data['okid'] = $okid;
     $data['xid'] = $xid;
     $data['oknum'] = $okid + 1;
     $data['names'] = $row->name;
     $data['linkcount'] = $LinkCount;
     $data['title'] = '';
     $neirurl = substr($LinkArr[$okid], 0, 7) != 'http://' ? $row->url . $LinkArr[$okid] : $LinkArr[$okid];
     //读取内容文件
     $cjzt = 0;
     $DanceContent = $this->caiji->str($neirurl, $row->code);
     if (empty($DanceContent)) {
         $data['err'] = vsprintf(L('plub_15'), array($neirurl));
     } else {
         //标题
         $name = $this->caiji->getstr($DanceContent, trim($row->nameks), trim($row->namejs));
         $data['name'] = str_checkhtml($this->caiji->rep($name, $row->strth));
         //图片
         if ($row->picmode == 2) {
             $data['pic'] = $this->caiji->getstr($DanceContent, trim($row->picks), trim($row->picjs));
         } else {
             $data['pic'] = str_checkhtml($pic);
         }
         if (empty($data['name'])) {
             $data['err'] = L('plub_16');
         } else {
             //获取自定义
             $query = $this->db->query("SELECT * FROM " . CS_SqlPrefix . "cjannex where cid=" . $id . " order by id desc");
             foreach ($query->result() as $rowz) {
                 $zdy = $this->caiji->getstr($DanceContent, trim($rowz->ks), trim($rowz->js));
                 $data['zdy']['name'][] = $rowz->name;
                 $data['zdy']['zd'][] = $rowz->zd;
                 if ($rowz->fid == 1) {
                     $data['zdy']['text'][] = $rowz->fname;
                 } else {
                     $data['zdy']['text'][] = str_checkhtml($this->caiji->rep($zdy, $row->strth));
                 }
             }
             if ($ac == 'ceshi') {
                 //测试不入库
                 $data['title'] = L('plub_17');
             } else {
                 $cjzt = 1;
                 //---------------------------入库---------------------------------------
                 $add['name'] = $data['name'];
                 $add['pic'] = $data['pic'];
                 $add['dir'] = $row->dir;
                 $add['zdy'] = !empty($data['zdy']) ? arraystring($data['zdy']) : '';
                 $add['addtime'] = time();
                 //------------------------判断保存图片到本地----------------------------------
                 if ($row->picid == 1) {
                     if (!empty($data['pic']) && substr($data['pic'], 0, 7) == 'http://') {
                         $picdata = @file_get_contents($data['pic']);
                         // 读文件内容
                         $picfolder = FCPATH . "attachment/vod/";
                         $picname = date('Ymd') . "/" . date('Ymd') . time() . mt_rand(1, 100) . ".jpg";
                         if (!empty($picdata)) {
                             if (write_file($picfolder . $picname, $picdata)) {
                                 $add['pic'] = $picname;
                             }
                         }
                     }
                 }
                 //------------------------判断入未审核库----------------------------------
                 if ($row->rkid == 0) {
                     //临时库
                     $add['cfid'] = $row->cfid;
                     //判断相同数据
                     $rows = $this->db->query("SELECT id FROM " . CS_SqlPrefix . "cjdata where name='" . $add['name'] . "' and dir='" . $row->dir . "'")->row();
                     if ($rows) {
                         if ($row->cfid == 0) {
                             //不入库
                             $data['title'] = L('plub_18');
                         } elseif ($row->cfid == 1) {
                             //新增
                             $this->CsdjDB->get_insert('cjdata', $add);
                             $data['title'] = "入库成功~!";
                         } elseif ($row->cfid == 2) {
                             //覆盖
                             $this->CsdjDB->get_update('cjdata', $rows->id, $add);
                             $data['title'] = L('plub_19');
                         }
                     } else {
                         $this->CsdjDB->get_insert('cjdata', $add);
                         $data['title'] = L('plub_20');
                     }
                 } else {
                     //入板块主数据库
                     //判断板块数据表是否存在
                     if ($this->db->table_exists(CS_SqlPrefix . $row->dir)) {
                         $strs = '';
                         unset($add['dir']);
                         unset($add['zdy']);
                         //判断名称字段
                         if (!$this->db->field_exists('name', CS_SqlPrefix . $row->dir)) {
                             unset($add['name']);
                         } else {
                             $strs .= "and name='" . $add['name'] . "' ";
                         }
                         //判断图片字段
                         if (!$this->db->field_exists('pic', CS_SqlPrefix . $row->dir)) {
                             unset($add['pic']);
                         } else {
                             $strs .= "and pic='" . $add['pic'] . "' ";
                         }
                         //判断时间字段
                         if (!$this->db->field_exists('addtime', CS_SqlPrefix . $row->dir)) {
                             unset($add['addtime']);
                         }
                         //自定义规则
                         $zdy = $data['zdy'];
                         if (!empty($zdy)) {
                             for ($i = 0; $i < count($zdy['zd']); $i++) {
                                 $add[$zdy['zd'][$i]] = $zdy['text'][$i];
                                 if (strlen($zdy['text'][$i]) < 200) {
                                     $strs .= "and " . $zdy['zd'][$i] . "='" . $zdy['text'][$i] . "' ";
                                 }
                             }
                         }
                         $strs = substr($strs, 3);
                         $rowk = $this->db->query("SELECT id FROM " . CS_SqlPrefix . $row->dir . " where " . $strs . "")->row();
                         if ($rowk) {
                             if ($row->cfid == 2) {
                                 //覆盖
                                 $data['title'] = L('plub_19');
                                 $this->CsdjDB->get_update($row->dir, $rowk->id, $add);
                             } elseif ($row->cfid == 1) {
                                 //新增
                                 $this->CsdjDB->get_insert($row->dir, $add);
                                 $data['title'] = L('plub_20');
                             } else {
                                 $data['title'] = L('plub_18');
                             }
                         } else {
                             $this->CsdjDB->get_insert($row->dir, $add);
                             $data['title'] = L('plub_20');
                         }
                     }
                 }
                 //修改采集时间
                 $cjtdata['addtime'] = time();
                 $this->CsdjDB->get_update('caiji', $row->id, $cjtdata);
             }
         }
     }
     if ($ac != 'ceshi' && !empty($data['name'])) {
         //写入采集记录,测试不入库
         $cjdata['name'] = $data['name'];
         $cjdata['names'] = $row->name;
         $cjdata['dir'] = $row->dir;
         $cjdata['url'] = $neirurl;
         $cjdata['zid'] = $cjzt;
         $this->CsdjDB->get_insert('cjlist', $cjdata);
     }
     $data['id'] = $row->id;
     $data['ac'] = $ac;
     $this->load->view('collect_caiji.html', $data);
 }
Пример #2
0
 public function save()
 {
     //注册开关
     if (User_Reg == 0) {
         msg_url(L('reg_35'), Web_Path);
     }
     $userinfo = array();
     $token = $this->input->post('token', TRUE);
     if ($token != $_SESSION['token']) {
         msg_url(L('reg_02'), 'javascript:history.back();');
     }
     //判断验证码开关
     if (User_Code_Mode == 1) {
         $codes = str_checkhtml($this->input->post('usercode', TRUE));
         if (empty($codes) || $this->cookie->get_cookie('codes') != strtolower($codes)) {
             msg_url(L('reg_03'), 'javascript:history.back();');
         }
     }
     $userinfo['code'] = random_string('alnum', 6);
     $userinfo['name'] = $this->input->post('username', TRUE, TRUE);
     $userinfo['pass'] = $this->input->post('userpass', TRUE, TRUE);
     $userinfo['nichen'] = $this->input->post('usernichen', TRUE);
     $userinfo['email'] = $this->input->post('useremail', TRUE, TRUE);
     $userinfo['tel'] = $this->input->post('usertel', TRUE, TRUE);
     $userinfo['regip'] = getip();
     $userinfo['cion'] = User_Cion_Reg;
     $userinfo['jinyan'] = User_Jinyan_Reg;
     $userinfo['addtime'] = time();
     $userinfo['yid'] = 0;
     if ($userinfo['nichen'] == "0") {
         $userinfo['nichen'] = '';
     }
     if (!is_username($userinfo['name'])) {
         msg_url(L('reg_04'), 'javascript:history.back();');
     }
     if (!is_userpass($userinfo['pass'])) {
         msg_url(L('reg_05'), 'javascript:history.back();');
     }
     if (!empty($userinfo['nichen']) && !is_username($userinfo['nichen'], 1)) {
         msg_url(L('reg_06'), 'javascript:history.back();');
     }
     if (!is_email($userinfo['email'])) {
         msg_url(L('reg_07'), 'javascript:history.back();');
     }
     //判断保留用户名
     $ymext = explode('|', Home_Ymext);
     if (in_array($userinfo['name'], $ymext)) {
         msg_url(L('reg_08'), 'javascript:history.back();');
     }
     //判断同一IP注册时间限制
     if (User_RegIP > 0) {
         $row = $this->db->query("SELECT addtime FROM " . CS_SqlPrefix . "user where regip='" . $userinfo['regip'] . "' order by id desc")->row();
         if ($row && $row->addtime + 3600 * User_RegIP > time()) {
             msg_url(L('reg_09'), 'javascript:history.back();');
         }
     }
     //判断用户名是否注册
     $username = $this->CsdjDB->get_row('user', 'id', $userinfo['name'], 'name');
     if ($username) {
         msg_url(L('reg_10'), 'javascript:history.back();');
     }
     //判断邮箱是否注册
     $useremail = $this->CsdjDB->get_row('user', 'id', $userinfo['email'], 'email');
     if ($useremail) {
         msg_url(L('reg_11'), 'javascript:history.back();');
     }
     //下面选填字段
     $userinfo['qq'] = $this->input->post('userqq', TRUE);
     $userinfo['sex'] = intval($this->input->post('usersex', TRUE));
     $userinfo['city'] = $this->input->post('usercity', TRUE);
     $userinfo['skins'] = Home_Skins;
     $userinfo['qianm'] = '';
     if (!empty($userinfo['tel'])) {
         if (!is_tel($userinfo['tel'])) {
             msg_url(L('reg_12'), 'javascript:history.back();');
         }
         //判断手机号码是否注册
         $usertel = $this->CsdjDB->get_row('user', 'id', $userinfo['tel'], 'tel');
         if ($usertel) {
             msg_url(L('reg_13'), 'javascript:history.back();');
         }
     }
     //判断手机强制验证
     if (User_Tel == 1) {
         if (empty($userinfo['tel'])) {
             msg_url(L('reg_12'), 'javascript:history.back();');
         }
         $telcode = intval($this->input->post('telcode', TRUE));
         if ($telcode == 0 || $telcode != $_SESSION['tel_code']) {
             msg_url(L('reg_14'), 'javascript:history.back();');
         }
     }
     //是否需要人工验证
     if (User_RegFun == 1) {
         $userinfo['yid'] = 1;
         $title = L('reg_15');
     }
     //是否需要邮件验证
     if (User_RegEmailFun == 1) {
         $userinfo['yid'] = 2;
         $title = L('reg_16', array($userinfo['email']));
     }
     //--------------------------- Ucenter ---------------------------
     if (User_Uc_Mode == 1) {
         include CSCMS . 'lib/Cs_Ucenter.php';
         include CSCMSPATH . 'uc_client/client.php';
         $uid = uc_user_register($userinfo['name'], $userinfo['pass'], $userinfo['email']);
         if ($uid > 0) {
             $userinfo['uid'] = $uid;
         }
     }
     //--------------------------- Ucenter End ---------------------------
     //密码加密
     $userinfo['pass'] = md5(md5($userinfo['pass']) . $userinfo['code']);
     $regid = $this->CsdjDB->get_insert('user', $userinfo);
     if (intval($regid) == 0) {
         msg_url(L('reg_17'), 'javascript:history.back();');
     }
     //摧毁token
     unset($_SESSION['token']);
     $this->load->model('CsdjEmail');
     if (User_RegEmailFun == 1) {
         //发送激活邮件
         $key = md5($regid . $userinfo['name'] . $userinfo['pass'] . $userinfo['yid']);
         $Msgs['username'] = $userinfo['name'];
         $Msgs['url'] = userurl(site_url('user/reg/verify')) . "?key=" . $key . "&username="******"user_id", $regid, time() + 86400);
         $this->cookie->set_cookie("user_login", $user_login, time() + 86400);
         msg_url(L('reg_21'), userurl(site_url('user/space')), 'ok');
     } else {
         msg_url(L('reg_21') . $title . '~!', userurl(site_url('user/login')), 'ok');
     }
 }
Пример #3
0
 public function cscms_skins($field, $str, $label, $row, $sorti = 1, $autoarr = array())
 {
     preg_match_all('/\\[' . $field . ':\\s*([0-9a-zA-Z\\_\\-]+)([\\s]*[link|ulink|dir|level|zd|len|style]*)[=]??([\\d0-9a-zA-Z\\,\\{\\}\\/\\-\\\\:\\s]*)\\]/', $str, $field_arr);
     if (!empty($field_arr)) {
         //判断是否嵌套二级
         preg_match('/{cscmstype:([\\S]+)\\s+(.*?)}([\\s\\S]+?){\\/cscmstype:\\1}/', $label, $type_arr);
         if (!empty($type_arr)) {
             $label = $this->cscms_sql_to($type_arr[1], $type_arr[2], $type_arr[0], $type_arr[3], $label, $row['id']);
         }
         unset($type_arr);
         for ($i = 0; $i < count($field_arr[0]); $i++) {
             $type = $field_arr[1][$i];
             if (array_key_exists($type, $row) && trim($field_arr[2][$i]) != 'zd') {
                 if ($type == 'addtime') {
                     $label = str_replace('[' . $field . ':' . $type . ']', date('Y-m-d H:i:s', $row[$type]), $label);
                 } else {
                     $label = str_replace('[' . $field . ':' . $type . ']', $row[$type], $label);
                 }
                 //判断自定义标签
                 if (!empty($field_arr[2][$i]) && !empty($field_arr[3][$i])) {
                     //格式化时间
                     if (trim($field_arr[2][$i]) == 'style' && trim($field_arr[3][$i]) == 'time') {
                         $label = str_replace($field_arr[0][$i], datetime($row[$type]), $label);
                         //获取IP地区
                     } elseif (trim($field_arr[2][$i]) == 'style' && trim($field_arr[3][$i]) == 'city') {
                         $ci =& get_instance();
                         $ci->load->library('ip');
                         $label = str_replace($field_arr[0][$i], $ci->ip->address($row[$type]), $label);
                         //自定义时间
                     } elseif (trim($field_arr[2][$i]) == 'style') {
                         $label = str_replace($field_arr[0][$i], date(str_replace('f', 'i', $field_arr[3][$i]), $row[$type]), $label);
                         //图片地址
                     } elseif (trim($field_arr[2][$i]) == 'dir') {
                         $lall = explode(",", $field_arr[3][$i]);
                         $lass = count($lall) > 1 ? $lall[1] : '';
                         $pic = piclink($lall[0], $row[$type], $lass);
                         $label = str_replace($field_arr[0][$i], $pic, $label);
                     }
                     //字符截取
                     if (trim($field_arr[2][$i]) == 'len') {
                         $label = str_replace($field_arr[0][$i], sub_str(str_checkhtml($row[$type]), $field_arr[3][$i]), $label);
                     }
                 }
             } else {
                 //外部字段
                 switch ($type) {
                     //序
                     case 'i':
                         $label = str_replace($field_arr[0][$i], $sorti, $label);
                         break;
                         //序
                     //序
                     case 'addres':
                         if (trim($field_arr[2][$i]) == 'zd' && !empty($field_arr[3][$i]) && array_key_exists($field_arr[3][$i], $row)) {
                             $zd = $field_arr[3][$i];
                             $ci =& get_instance();
                             $ci->load->library('ip');
                             $label = str_replace($field_arr[0][$i], $ci->ip->address($row[$zd]), $label);
                         }
                         break;
                         //数据统计
                     //数据统计
                     case 'count':
                         if (trim($field_arr[2][$i]) == 'zdy' && !empty($field_arr[3][$i])) {
                             $count = 0;
                             $arr = explode(',', $field_arr[3][$i]);
                             $table = $arr[0];
                             $czd = empty($arr[1]) ? 'id' : $arr[1];
                             $szd = empty($arr[2]) ? 'id' : $arr[2];
                             if (array_key_exists($szd, $row)) {
                                 $ci =& get_instance();
                                 if (!isset($ci->db)) {
                                     $ci->load->database();
                                 }
                                 $uid = !empty($row[$szd]) ? $row[$szd] : (!empty($row['uid']) ? $row['uid'] : 0);
                                 if (!empty($table) && $ci->db->table_exists(CS_SqlPrefix . $table) && $ci->db->field_exists($czd, CS_SqlPrefix . $table)) {
                                     if (!empty($arr[3]) && (!empty($arr[4]) || (int) $arr[4] == 0)) {
                                         if ($ci->db->field_exists($arr[3], CS_SqlPrefix . $table)) {
                                             $count = $ci->db->query("SELECT id FROM " . CS_SqlPrefix . $table . " where " . $czd . "='" . $uid . "' and " . $arr[3] . "='" . $arr[4] . "'")->num_rows();
                                         }
                                     } else {
                                         $count = $ci->db->query("SELECT id FROM " . CS_SqlPrefix . $table . " where " . $czd . "='" . $uid . "'")->num_rows();
                                     }
                                 }
                             }
                             $label = str_replace($field_arr[0][$i], $count, $label);
                         }
                         break;
                         //会员信息
                     //会员信息
                     case 'user':
                         if (($field == 'user' or array_key_exists('uid', $row) or array_key_exists('uidb', $row)) && trim($field_arr[2][$i]) == 'zd' && !empty($field_arr[3][$i])) {
                             $ci =& get_instance();
                             if (!isset($ci->db)) {
                                 $ci->load->database();
                             }
                             $ziduan = $field_arr[3][$i];
                             $zdneir = ($field == 'gbook' or $field == 'pl') ? '游客' : 'null';
                             if ($field == 'user') {
                                 $uid = $row['id'];
                             } else {
                                 $lall = explode(",", $ziduan);
                                 if (!empty($lall[1])) {
                                     $uid = !empty($lall[1]) ? $lall[1] : 0;
                                     $ziduan = $lall[1];
                                 } else {
                                     if (!empty($row['uid'])) {
                                         $uid = $row['uid'];
                                     } else {
                                         $uid = !empty($row['uidb']) ? $row['uidb'] : 0;
                                     }
                                 }
                             }
                             $czd = $ziduan == 'nichen' ? $ziduan . ',name' : $ziduan;
                             if ($ci->db->field_exists($ziduan, CS_SqlPrefix . 'user')) {
                                 $rowu = $ci->db->query("SELECT " . $czd . " FROM " . CS_SqlPrefix . "user where id='" . $uid . "'")->row();
                                 if ($rowu) {
                                     $zdneir = $field_arr[3][$i] == 'nichen' && empty($rowu->{$ziduan}) ? $rowu->name : $rowu->{$ziduan};
                                 }
                             }
                             if ($ziduan == 'logo') {
                                 if ($uid == 0) {
                                     $zdneir = '';
                                 }
                                 $zdneir = piclink('logo', $zdneir);
                             }
                             if ($ziduan == 'zid') {
                                 if ($zdneir == 0) {
                                     $zdneir = 1;
                                 }
                                 $zdneir = getzd('userzu', 'name', $zdneir);
                             }
                             if ($ziduan == 'qianm') {
                                 if (empty($zdneir)) {
                                     $zdneir = '暂时没有签名...';
                                 }
                             }
                             if ($ziduan == 'city') {
                                 if (empty($zdneir)) {
                                     $zdneir = '保密';
                                 }
                             }
                             $label = str_replace($field_arr[0][$i], $zdneir, $label);
                             //会员等级
                         } elseif (($field == 'user' or array_key_exists('uid', $row) or array_key_exists('uidb', $row)) && trim($field_arr[2][$i]) == 'level' && !empty($field_arr[3][$i])) {
                             $zdneir = '';
                             if ($field == 'user') {
                                 $uid = $row['id'];
                             } else {
                                 $uid = !empty($row['uid']) ? $row['uid'] : (!empty($row['uidb']) ? $row['uidb'] : 0);
                             }
                             $jinyan = getzd('user', 'jinyan', $uid);
                             if ($field_arr[3][$i] == '1') {
                                 //星星数
                                 $zdneir = getlevel($jinyan, 1);
                             }
                             if ($field_arr[3][$i] == '2') {
                                 //下个级别需要经验
                                 $zdneir = getlevel($jinyan, 2);
                             }
                             if ($field_arr[3][$i] == '3') {
                                 //下个级别剩余经验
                                 $zdneir = getlevel($jinyan, 3);
                             }
                             if ($field_arr[3][$i] == '4') {
                                 //剩余百分比
                                 $zdneir = getlevel($jinyan, 4);
                             }
                             if ($field_arr[3][$i] == '5') {
                                 //名称
                                 $zdneir = getlevel($jinyan, 5);
                             }
                             $label = str_replace($field_arr[0][$i], $zdneir, $label);
                         }
                         break;
                         //歌手信息
                     //歌手信息
                     case 'singer':
                         if (array_key_exists('singerid', $row) && trim($field_arr[2][$i]) == 'zd' && !empty($field_arr[3][$i])) {
                             $ci =& get_instance();
                             if (!isset($ci->db)) {
                                 $ci->load->database();
                             }
                             $zdneir = 'null';
                             if ($ci->db->table_exists(CS_SqlPrefix . 'singer')) {
                                 //歌手表存在
                                 $ziduan = $field_arr[3][$i];
                                 if ($ci->db->field_exists($ziduan, CS_SqlPrefix . 'singer')) {
                                     $rows = $ci->db->query("SELECT " . $ziduan . " FROM " . CS_SqlPrefix . "singer where id='" . $row['singerid'] . "'")->row();
                                     if ($rows) {
                                         $zdneir = $rows->{$ziduan};
                                     }
                                 }
                                 if ($ziduan == 'pic') {
                                     if ($row['singerid'] == 0) {
                                         $zdneir = '';
                                     }
                                     $zdneir = piclink('singer', $zdneir);
                                 }
                             }
                             $label = str_replace($field_arr[0][$i], $zdneir, $label);
                         }
                         break;
                         //版块链接
                     //版块链接
                     case 'murl':
                         if (array_key_exists('dir', $row)) {
                             $link = cscmslink($row['dir']);
                             $label = str_replace($field_arr[0][$i], $link, $label);
                         }
                         break;
                         //网站链接
                     //网站链接
                     case 'url':
                         //全局
                         if (array_key_exists('id', $row) && trim($field_arr[2][$i]) == 'link' && !empty($field_arr[3][$i])) {
                             $lall = explode(",", $field_arr[3][$i]);
                             $lass = count($lall) > 1 ? $lall[1] : '';
                             $link = linkurl($lall[0], $lass, $row['id']);
                             $label = str_replace($field_arr[0][$i], $link, $label);
                         }
                         //会员
                         if ((array_key_exists('uid', $row) || array_key_exists('uidb', $row) || $field == 'user') && trim($field_arr[2][$i]) == 'ulink' && !empty($field_arr[3][$i])) {
                             $ci =& get_instance();
                             if (!isset($ci->db)) {
                                 $ci->load->database();
                             }
                             $link = '';
                             if ($field == 'user') {
                                 if (array_key_exists('id', $row) && array_key_exists('name', $row)) {
                                     $lall = explode(",", $field_arr[3][$i]);
                                     $lass = count($lall) > 1 ? $lall[1] : '';
                                     $link = userlink($lall[0], $row['id'], $row['name'], $lass);
                                 }
                             } else {
                                 $uid = !empty($row['uid']) ? $row['uid'] : (!empty($row['uidb']) ? $row['uidb'] : 0);
                                 $rowu = $ci->db->query("SELECT id,name FROM " . CS_SqlPrefix . "user where id='" . $uid . "'")->row();
                                 if (!$rowu) {
                                     $link = 'http://' . Web_Url . Web_Path;
                                 } else {
                                     $lall = explode(",", $field_arr[3][$i]);
                                     $lass = count($lall) > 1 ? $lall[1] : '';
                                     $link = userlink($lall[0], $rowu->id, $rowu->name, $lass);
                                 }
                             }
                             $label = str_replace($field_arr[0][$i], $link, $label);
                         }
                         //会员中心...
                         if (trim($field_arr[2][$i]) == 'userlink' && !empty($field_arr[3][$i])) {
                             $link = spacelink($field_arr[3][$i]);
                             $label = str_replace($field_arr[0][$i], $link, $label);
                         }
                         //自定义URL,板块,字段,参数,参数...
                         if (trim($field_arr[2][$i]) == 'zdy' && !empty($field_arr[3][$i])) {
                             $lall = explode(",", $field_arr[3][$i]);
                             if (!array_key_exists($lall[1], $row) || $row[$lall[1]] == 0) {
                                 $link = 'http://' . Web_Url . Web_Path;
                             } else {
                                 $lass = count($lall) > 3 ? $lall[3] : '';
                                 $link = linkurl($lall[2], $lass, $row[$lall[1]], 1, $lall[0]);
                             }
                             $label = str_replace($field_arr[0][$i], $link, $label);
                         }
                         break;
                 }
             }
         }
     }
     unset($field_arr);
     return $label;
 }
Пример #4
0
 /**
  * Fetch from array
  *
  * This is a helper function to retrieve values from global arrays
  *
  * @access	private
  * @param	array
  * @param	string
  * @param	bool
  * @return	string
  */
 function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE, $sql_clean = FALSE)
 {
     if (!isset($array[$index])) {
         return FALSE;
     }
     if ($xss_clean === TRUE) {
         $arr = $array[$index];
         $sqlclean = $sql_clean === TRUE ? 1 : 0;
         //清除所有HTML代码
         $arr = str_checkhtml($arr, $sqlclean);
         $arr = $this->security->xss_clean($arr);
         return $arr;
     }
     return $array[$index];
 }
Пример #5
0
 public function cais()
 {
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     if (empty($_SERVER['HTTP_REFERER'])) {
         exit('QQ:848769359');
     }
     $id = intval($this->input->get_post('id', TRUE));
     $callback = $this->input->get('callback', true);
     $lists = array();
     $row2 = $this->db->query("select cid from " . CS_SqlPrefix . "dance where id='" . $id . "'")->row();
     $result2 = $this->db->query("select id,singerid,name,tid,fid,purl,sc,lrc from " . CS_SqlPrefix . "dance where cid=" . $row2->cid . " and yid=0 and hid=0 order by rand() desc LIMIT 10");
     $j = 0;
     foreach ($result2->result() as $row) {
         $lrc = str_checkhtml($row->lrc);
         if (empty($lrc)) {
             $lrc = '0';
         }
         $tpic = piclink('dancetopic', '');
         $topic = '-';
         $topiclink = '###';
         if ($row->tid > 0) {
             $rowt = $this->db->query("select id,pic,name from " . CS_SqlPrefix . "dance_topic where id=" . $row->tid . "")->row();
             if ($rowt) {
                 $topiclink = LinkUrl('topic/show', 'id', $row->tid, 1, 'dance');
                 $tpic = piclink('dancetopic', $rowt->pic);
                 $topic = $rowt->name;
             }
         }
         $purl = $row->purl;
         if ($row->fid > 0) {
             $rowf = $this->db->query("Select purl from " . CS_SqlPrefix . "dance_server where id=" . $row->fid . "")->row();
             if ($rowf) {
                 $purl = $rowf->purl . $row->purl;
             }
         }
         $singer = getzd('singer', 'name', $row->singerid);
         $lists[$j]['name'] = get_bm($row->name, 'gbk', 'utf-8');
         $lists[$j]['singer'] = empty($singer) ? '' : get_bm($singer, 'gbk', 'utf-8');
         $lists[$j]['singerlink'] = LinkUrl('show', 'id', $row->singerid, 1, 'singer');
         $lists[$j]['downlink'] = LinkUrl('down', 'id', $row->id, 1, 'dance');
         $lists[$j]['tpic'] = $tpic;
         $lists[$j]['topic'] = get_bm($topic, 'gbk', 'utf-8');
         $lists[$j]['topiclink'] = $topiclink;
         $lists[$j]['url'] = get_bm($purl, 'gbk', 'utf-8');
         $lists[$j]['id'] = $row->id;
         $lists[$j]['time'] = $this->get_time($row->sc);
         $lists[$j]['lrc'] = get_bm($lrc, 'gbk', 'utf-8');
         $j++;
     }
     echo $callback . "(" . json_encode($lists) . ")";
 }
Пример #6
0
 public function save()
 {
     $token = $this->input->post('token', TRUE);
     if ($token != $_SESSION['token']) {
         msg_url('非法提交~!', 'javascript:history.back();');
     }
     //检测发表权限
     $zuid = getzd('user', 'zid', $_SESSION['cscms__id']);
     $rowu = $this->CsdjDB->get_row('userzu', 'aid,sid', $zuid);
     if (!$rowu || $rowu->aid == 0) {
         msg_url('您所在会员组没有权限发表文章~!', 'javascript:history.back();');
     }
     //检测发表数据是否需要审核
     $news['yid'] = $rowu->sid == 1 ? 0 : 1;
     //选填字段
     $news['cion'] = intval($this->input->post('cion'));
     $news['pic'] = $this->input->post('pic', TRUE, TRUE);
     $news['tags'] = $this->input->post('tags', TRUE, TRUE);
     $news['info'] = $this->input->post('info', TRUE, TRUE);
     $news['uid'] = $_SESSION['cscms__id'];
     $news['addtime'] = time();
     //必填字段
     $news['name'] = $this->input->post('name', TRUE, TRUE);
     $news['cid'] = intval($this->input->post('cid'));
     $news['content'] = remove_xss($this->input->post('content'));
     //检测必须字段
     if ($news['cid'] == 0) {
         msg_url('请选择文章分类~!', 'javascript:history.back();');
     }
     if (empty($news['name'])) {
         msg_url('文章名称不能为空~!', 'javascript:history.back();');
     }
     if (empty($news['content'])) {
         msg_url('文章内容不能为空~!', 'javascript:history.back();');
     }
     //截取概述
     $news['info'] = sub_str(str_checkhtml($news['content']), 120);
     //增加到数据库
     $did = $this->CsdjDB->get_insert('news', $news);
     if (intval($did) == 0) {
         msg_url('文章发布失败,请稍候再试~!', 'javascript:history.back();');
     }
     //摧毁token
     unset($_SESSION['token']);
     //增加动态
     $dt['dir'] = 'news';
     $dt['uid'] = $_SESSION['cscms__id'];
     $dt['did'] = $did;
     $dt['yid'] = $news['yid'];
     $dt['title'] = '发布了文章';
     $dt['name'] = $news['name'];
     $dt['link'] = linkurl('show', 'id', $did, 1, 'news');
     $dt['addtime'] = time();
     $this->CsdjDB->get_insert('dt', $dt);
     //如果免审核,则给会员增加相应金币、积分
     if ($news['yid'] == 0) {
         $addhits = getzd('user', 'addhits', $_SESSION['cscms__id']);
         if ($addhits < User_Nums_Add) {
             $this->db->query("update " . CS_SqlPrefix . "user set cion=cion+" . User_Cion_Add . ",jinyan=jinyan+" . User_Jinyan_Add . ",addhits=addhits+1 where id=" . $_SESSION['cscms__id'] . "");
         }
         msg_url('恭喜您,文章发布成功~!', spacelink('news', 'news'));
     } else {
         msg_url('恭喜您,文章发布成功,请等待管理员审核~!', spacelink('news/verify', 'news'));
     }
 }