/** * ck播放器接口 */ public function ckplayer() { $at = $this->input->get('at'); $form = $this->input->get('form'); $data = array('text' => '', 'api_url' => SITE_URL . 'index.php?c=api&m=ckplayer', 'server_url' => SITE_URL . 'dayrui/ckplayer/'); // 功能部分 switch ($at) { case 'js': // 动态加载js // $text = $this->get_cache('poster-text-' . SITE_ID); if ($text) { // 文字滚动广告 $this->load->model('poster_model'); $poster = $this->poster_model->poster($text); if ($poster) { $url = $this->poster_model->get_url($poster['id']); $value = dr_string2array($poster['value']); if ($value) { $data['text'] = '{a href="' . $url . '" target="_blank"}{font color="' . $value['color'] . '" size="12"}' . ($value['text'] ? dr_clearhtml($value['text']) : '没有输入广告内容') . '{/font}{/a}'; } } } $code = file_get_contents(FCPATH . 'dayrui/ckplayer/config/config.js'); break; case 'share': // 分享 header('Content-Type: text/xml'); $code = file_get_contents(FCPATH . 'dayrui/ckplayer/config/share.xml'); break; } // 兼容php5.5 if (version_compare(PHP_VERSION, '5.5.0') >= 0) { $rep = new php5replace($data); $code = preg_replace_callback('#{([a-z_0-9]+)}#U', array($rep, 'php55_replace_data'), $code); unset($rep); } else { extract($data); $code = preg_replace('#{([a-z_0-9]+)}#Ue', "\$\\1", $code); } exit($code); }
/** * 模块内容扩展SEO信息 * * @param array $mod * @param array $cat * @return array */ function dr_extend_seo($mod, $data) { $seo = array(); $cat = $mod['category'][$data['catid']]; $data['extend'] = $data['name']; $data['join'] = SITE_SEOJOIN ? SITE_SEOJOIN : '_'; $data['name'] = $data['catname'] = dr_get_cat_pname($mod, $cat, $data['join']); $data['modulename'] = $data['modname'] = $mod['name']; $meta_title = $cat['setting']['seo']['extend_title'] ? $cat['setting']['seo']['extend_title'] : '{extend}{join}{title}{join}{name}{join}{modulename}{join}{SITE_NAME}'; if ($page > 1) { $meta_title = str_replace(array('[', ']'), '', $meta_title); } else { $meta_title = preg_replace('/\\[.+\\]/U', '', $meta_title); } // 兼容php5.5 if (version_compare(PHP_VERSION, '5.5.0') >= 0) { $rep = new php5replace($data); $seo['meta_title'] = preg_replace_callback("#{([a-z_0-9]+)}#U", array($rep, 'php55_replace_data'), $meta_title); $seo['meta_title'] = preg_replace_callback('#{([A-Z_]+)}#U', array($rep, 'php55_replace_var'), $seo['meta_title']); unset($rep); } else { extract($data); $seo['meta_title'] = preg_replace('#{([a-z_0-9]+)}#Ue', "\$\\1", $meta_title); $seo['meta_title'] = preg_replace('#{([A-Z_]+)}#Ue', "\\1", $seo['meta_title']); } $seo['meta_keywords'] = $data['keywords']; $seo['meta_description'] = dr_clearhtml($seo['meta_description']); return $seo; }
/** * 用于视频播放器字段输出 * * @param string $name 字段名称 * @param array $value 字段值 * @param intval $width 宽度 * @param intval $height 高度 * @param string $next_url 下一集url * @param string $title 视频分享标题 * @param string $url 视频分享url * @param string $desc 视频分享描述 * @param string $thumb 视频分享图片 * @return array */ function dr_player($name, $value, $width, $height, $next_url = '', $title = '', $url = '', $desc = '', $thumb = '') { $file = dr_get_file($value['file']); $str = ' <div id="video" style="position:relative;z-index: 51;width:' . $width . 'px;height:' . $height . 'px;"><div id="a1"></div></div> <script type="text/javascript" src="' . SITE_URL . 'player/offlights.js"></script> <script type="text/javascript" src="' . SITE_URL . 'player/ckplayer.js" charset="utf-8"></script> <script type="text/javascript"> var flashvars={ s:2, f:\'' . SITE_URL . 'player/video.php?url=[$pat]\', a:\'' . $file . '\', c:0, b:1, h:4, p:1,' . PHP_EOL; // 定时点处理 if ($value['point']) { $k = $n = ''; foreach ($value['point'] as $time => $note) { $k .= $time . '|'; $n .= $note . '|'; } $str .= ' k:\'' . trim($k, '|') . '\',' . PHP_EOL; $str .= ' n:\'' . trim($n, '|') . '\',' . PHP_EOL; } // 广告处理 $mod = get_module(APP_DIR, SITE_ID); $option = ''; if ($mod['field'][$name]) { $option = $mod['field'][$name]['setting']['option']; } elseif ($mod['extend'][$name]) { $option = $mod['extend'][$name]['setting']['option']; } if ($option && $option['table']) { $ci =& get_instance(); if ($option['time'][$ci->markrule]) { $time = $option['time'][$ci->markrule]; // 查询该表的数据 $form = $ci->get_cache('form-' . SITE_ID, $option['table']); if ($form) { $data = $ci->site[SITE_ID]->order_by('id', 'RANDOM')->limit(1)->get(SITE_ID . '_form_' . $form['table'])->row_array(); if ($data) { $str .= ' l:\'' . dr_thumb($data['thumb']) . '\',' . PHP_EOL; $str .= ' r:\'' . $data['link'] . '\',' . PHP_EOL; $str .= ' t:\'' . $time . '\',' . PHP_EOL; $str .= ' d:\'' . dr_thumb($data['thumb']) . '\',' . PHP_EOL; $str .= ' u:\'' . $data['link'] . '\',' . PHP_EOL; $member = '<style>.dr_adv td, .dr_adv th { border-bottom: 1px solid #EEEEEE;height: 22px;line-height: 22px;padding-bottom: 3px;padding-top: 3px;}.dr_adv td{ text-align:right;}</style><table class="dr_adv">'; $MEMBER = $ci->get_cache('member'); $member .= '<tr>'; $member .= ' <th align="left" width="200">' . lang('m-347') . '</th>'; $member .= ' <td align="left">'; $member .= ' ' . (int) $option['time'][0] . lang('m-330'); $member .= ' </td>'; $member .= '</tr>'; foreach ($MEMBER['group'] as $group) { if ($group['id'] > 2) { $member .= '<tr>'; $member .= ' <th align="left">' . $group['name'] . '</th>'; $member .= ' <td align="left"></td>'; $member .= '</tr>'; foreach ($group['level'] as $level) { $id = $group['id'] . '_' . $level['id']; $member .= '<tr>'; $member .= '<th align="left" style="padding-left:40px">' . $level['name'] . ' ' . dr_show_stars($level['stars']) . '</th>'; $member .= '<td align="left">'; $member .= '' . (int) $option['time'][$id] . lang('m-330'); $member .= '</td>'; $member .= '</tr>'; } } else { $member .= '<tr>'; $member .= ' <th align="left">' . $group['name'] . '</th>'; $member .= ' <td align="left">'; $member .= ' ' . (int) $option['time'][$group['id']] . lang('m-330'); $member .= ' </td>'; $member .= '</tr>'; } } $member .= '<tr>'; $member .= ' <td style="border:none;text-align:center;"><a href="' . MEMBER_URL . 'index.php?c=account&m=upgrade" target="_blank" style="color:red;">' . lang('m-348') . '</a></td>'; $member .= '</tr>'; $member .= '</table>'; } } } } if ($next_url) { $str .= ' e:0,' . PHP_EOL; } else { $str .= ' e:2,' . PHP_EOL; } $str .= ' my_title:\'' . $title . '\', my_url:\'' . $url . '\', my_summary:\'' . str_replace(array('\'', '"'), '', dr_clearhtml(dr_strcut($desc, 200))) . '\', my_pic:\'' . dr_get_file($thumb) . '\' }; var params={ bgcolor:\'#FFF\', allowFullScreen:true, allowScriptAccess:\'always\' }; CKobject.embedSWF(\'' . SITE_URL . 'player/ckplayer.swf\',\'a1\',\'ckplayer_a1\',\'' . $width . '\',\'' . $height . '\',flashvars,params); '; if ($next_url) { $str .= 'function playerstop(){ location.href="' . $next_url . '"; }'; } $str .= ' function ckadjump(){ var throughBox = art.dialog.through; throughBox({ content: \'' . $member . '\', lock: true, opacity: 0.1 }); } var box = new LightBox(); function closelights(){ box.Show(); CKobject._K_(\'video\').style.width=\'' . $width . 'px\'; CKobject._K_(\'video\').style.height=\'' . $height . 'px\'; swfobject.getObjectById(\'ckplayer_a1\').width=' . $width . '; swfobject.getObjectById(\'ckplayer_a1\').height=' . $height . '; } function openlights(){ box.Close(); CKobject._K_(\'video\').style.width=\'' . $width . 'px\'; CKobject._K_(\'video\').style.height=\'' . $height . 'px\'; swfobject.getObjectById(\'ckplayer_a1\').width=' . $width . '; swfobject.getObjectById(\'ckplayer_a1\').height=' . $height . '; } </script> '; return $str; }
protected function get_content_data($data, $_data = NULL) { if (!$data[1]['description']) { $data[1]['description'] = trim(dr_strcut(dr_clearhtml($data[0]['content']), 200)); } return $data; }
/** * 字段入库值 */ public function insert_value($field) { $value = $this->ci->post[$field['fieldname']]; // 下载远程图片 if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|png))\\2/i", $value, $imgs)) { $uid = isset($this->ci->_data['uid']) ? $this->ci->_data['uid'] : $this->ci->uid; $down = FALSE; // 附件总大小判断 if ($uid && $uid == $this->ci->uid && !$this->ci->member['adminid'] && $this->ci->member_rule['attachsize']) { $data = $this->ci->db->select_sum('filesize')->where('uid', $uid)->get($this->ci->db->dbprefix('attachment'))->row_array(); if ($filesize <= $this->ci->member_rule['attachsize'] * 1024 * 1024) { $down = TRUE; } } // 开始下载远程图片 if ($down) { $this->ci->load->model('attachment_model'); foreach ($imgs[3] as $i => $img) { if ($uid && (strpos($img, SITE_URL) === FALSE || strpos($img, SITE_ATTACH_URL) === FALSE)) { $result = $this->ci->attachment_model->catcher($uid, $img); if (is_array($result)) { list($id, $file, $_ext) = $result; $value = str_replace($imgs[0][$i], " id=\"{$id}\" src=\"" . dr_file($file) . "\"", $value); } } } } } // 第一张作为缩略图 if (isset($this->ci->post['thumb']) && (!($thumb = dr_string2array($this->ci->data[1]['thumb'])) || !$thumb['file']) && preg_match("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|png))\\2/Ui", $value, $img)) { $this->ci->data[1]['thumb'] = $img[3]; } // 描述截取 if (isset($this->ci->post['description']) && !$this->ci->data[1]['description']) { $this->ci->data[1]['description'] = str_replace(array(' ', PHP_EOL, ' '), '', dr_strcut(dr_clearhtml($value), 200)); } $this->ci->data[$field['ismain']][$field['fieldname']] = $value; }
/** * 会员空间页 */ private function _space($uid) { if (!MEMBER_OPEN_SPACE) { $this->member_msg(lang('m-111')); } $this->load->model('space_model'); $this->load->model('space_category_model'); $space = $this->space_model->get($uid); if (!$space) { $this->template->assign('theme', MEMBER_PATH . 'templates/default/'); $this->member_msg(lang('m-234')); } if (!$space['status']) { $this->member_msg(lang('m-235')); } $space = $this->field_format_value($this->get_cache('member', 'spacefield'), $space, 1); $style = $space['style'] ? $space['style'] : 'default'; $theme = MEMBER_URL . 'templates/' . $style . '/'; $action = $this->input->get('action'); $member = $this->member_model->get_member($uid); $selected = 0; // 默认选中首页菜单 $category = $this->space_category_model->get_data(0, $uid, 1); switch ($action) { case 'category': // 栏目处理 $id = (int) $this->input->get('id'); $cat = $category[$id]; if (!$cat) { $this->msg(lang('m-315')); } switch ($cat['type']) { case 0: // 外链 if (!$cat['link']) { $this->msg(lang('m-316')); } redirect($cat['link'], 'location', 301); return NULL; break; case 1: // 模型 $model = $this->get_cache('space-model', $cat['modelid']); if (!$model) { $this->msg(lang('m-317')); } $template = 'list_' . $model['table'] . '.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $id; break; case 2: // 单页 $template = 'page.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $id; // 单页验证是否存在子栏目 if ($cat['child']) { $temp = explode(',', $cat['childids']); if (isset($temp[1]) && $category[$temp[1]]) { $id = $temp[1]; $cat = $category[$id]; } } break; } // 栏目下级或者同级栏目 $related = $parent = array(); if ($cat['pid']) { foreach ($category as $t) { if ($t['pid'] == $cat['pid']) { $related[] = $t; if ($cat['child']) { $parent = $cat; } else { $parent = $category[$t['pid']]; } } } } elseif ($cat['child']) { $parent = $cat; foreach ($category as $t) { if ($t['pid'] == $cat['id']) { $related[] = $t; } } } $this->template->assign(array('cat' => $cat, 'catid' => $id, 'parent' => $parent, 'related' => $related, 'modelid' => $cat['modelid'], 'urlrule' => dr_space_list_url($uid, $id, TRUE))); if ($cat['title']) { $title = $cat['title']; } else { $title = implode('-', array_reverse(explode('{-}', dr_space_catpos($uid, $id, '{-}', FALSE)))) . '-' . $space['name']; } $this->template->assign(array('meta_title' => $title, 'meta_keywords' => $cat['keywords'], 'meta_description' => $cat['description'])); break; case 'show': // 内容处理 $id = (int) $this->input->get('id'); $mid = (int) $this->input->get('mid'); $mod = $this->get_cache('space-model', $mid); if (!$mod) { $this->msg(lang('m-317')); } $name = $this->db->dbprefix('space_' . $mod['table']) . '-space-show-' . $id; $data = $this->get_cache_data($name); if (!$data) { $this->load->model('space_content_model'); $this->space_content_model->tablename = $this->db->dbprefix('space_' . $mod['table']); $data = $this->space_content_model->get($uid, $id); if (!$data) { $this->msg(lang('m-303')); } if (!$data['status'] && $data['uid'] != $this->uid) { $this->msg(lang('m-318')); } $cat = $category[$data['catid']]; if (!$cat) { $this->msg(lang('m-315')); } // 检测转向字段 foreach ($mod['field'] as $t) { if ($t['fieldtype'] == 'Redirect' && $data[$t['fieldname']]) { redirect($data[$t['fieldname']], 'location', 301); exit; } } // 上一篇文章 $data['prev_page'] = $this->db->where('catid', $data['catid'])->where('id<', $id)->where('status', 1)->select('title,id,updatetime')->order_by('id desc')->limit(1)->get($this->space_content_model->tablename)->row_array(); // 下一篇文章 $data['next_page'] = $this->db->where('catid', $data['catid'])->where('id>', $id)->where('status', 1)->select('title,id,updatetime')->order_by('id asc')->limit(1)->get($this->space_content_model->tablename)->row_array(); $this->set_cache_data($name, $data, 360000); } else { $cat = $category[$data['catid']]; if (!$cat) { $this->msg(lang('m-315')); } } // 格式化输出自定义字段 $fields = $mod['field']; $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); $data = $this->field_format_value($fields, $data, max(1, (int) $this->input->get('page'))); // 栏目下级或者同级栏目 $related = $parent = array(); if ($cat['pid']) { foreach ($category as $t) { if ($t['pid'] == $cat['pid']) { $related[] = $t; if ($cat['child']) { $parent = $cat; } else { $parent = $category[$t['pid']]; } } } } elseif ($cat['child']) { $parent = $cat; foreach ($category as $t) { if ($t['pid'] == $cat['id']) { $related[] = $t; } } } $template = 'show_' . $mod['table'] . '.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $cat['id']; $this->template->assign($data); $this->template->assign(array('cat' => $cat, 'catid' => $cat['id'], 'parent' => $parent, 'related' => $related, 'modelid' => $cat['modelid'])); $temp = dr_space_catpos($uid, $cat['id'], '{-}', FALSE); $temp = explode('{-}', $temp); $catstr = implode('-', array_reverse($temp)); $this->template->assign(array('meta_title' => ($data['content_title'] ? $data['content_title'] . '-' : '') . $data['title'] . '-' . $catstr . '-' . $space['name'], 'meta_keywords' => $data['keywords'], 'meta_description' => dr_strcut(dr_clearhtml($data['content']), 200, ''))); break; default: // 首页或者其他自定义页面 $template = $action ? $action . '.html' : 'index.html'; $this->template->assign(array('meta_title' => $space['title'] ? $space['title'] : $space['name'], 'meta_keywords' => $space['keywords'], 'meta_description' => $space['description'])); break; } // 更新访问量pv $this->db->where('uid', (int) $uid)->update('space', array('hits' => $space['hits'] + 1)); $space['mname'] = $member['name']; $this->template->assign(array('theme' => $theme, 'space' => $space + $member, 'spaceid' => $uid, 'tableid' => (int) substr((string) $uid, -1, 1), 'selected' => $selected, 'category' => $category)); $this->template->space($style); $this->template->display($template); }
/** * 发送短消息 * * @param intval $fromuid 发送者uid * @param string $fromusername 发送者username * @param array $data 发送数据 * @return string */ public function send($fromuid, $fromusername, $data) { if (!$fromuid || !$fromusername || !$data['username'] || !$data['message']) { return lang('m-062'); } $subject = dr_safe_replace(htmlspecialchars($data['subject'])); $message = dr_safe_replace(htmlspecialchars($data['message'])); // 查询会员数据 $member = array(); $username = explode(',', $data['username']); foreach ($username as $name) { $uid = get_member_id($name); if ($uid) { $member[$uid] = $name; } } if (!$member) { return lang('m-066'); } // 建立对应关系 $relationship = $existplid = $pm_member_insertsql = array(); // 多个对象是,关系数组为多位数组 foreach ($member as $key => $value) { if ($fromuid == $key) { return lang('m-067'); } //$key是接收者id $relationship[$key] = $this->_relationship($fromuid, $key); } // 处理标题 $subject = !$subject ? dr_strcut(dr_clearhtml($message), 80) : $subject; // 作为最后一条消息内容 $lastsummary = dr_strcut(dr_clearhtml($message), 150); // 短消息会话表中按“对应关系”来查询 $list = $this->db->select('plid, min_max')->where_in('min_max', $relationship)->get('pm_lists')->result_array(); if ($list) { foreach ($list as $t) { $existplid[$t['min_max']] = $t['plid']; // 获取到该关系的plid } } // 最后一条消息的数据组装 $lastmessage = array('lastauthorid' => $fromuid, 'lastauthor' => $fromusername, 'lastsummary' => $lastsummary); $lastmessage = dr_array2string($lastmessage); // 按照对应关系来插入消息表中,当对应关系在库中不存在时,重新创建一个对应关系表 foreach ($relationship as $key => $value) { if (!isset($existplid[$value])) { // 插入新的列表id $this->db->insert('pm_lists', array('authorid' => $fromuid, 'author' => $fromusername, 'pmtype' => 1, 'subject' => $subject, 'members' => 2, 'min_max' => $value, 'dateline' => SYS_TIME, 'lastmessage' => $lastmessage)); // 获取会话列表ID $plid = $this->db->insert_id(); // 将列表id插入到消息索引表中 $this->db->insert('pm_indexes', array('plid' => $plid)); // 得到一个短消息ID $pmid = $this->db->insert_id(); // 以回话列表id作为散列存储 $this->db->insert($this->_pm_tablename($plid), array('pmid' => $pmid, 'plid' => $plid, 'authorid' => $fromuid, 'message' => $message, 'dateline' => SYS_TIME, 'delstatus' => 0)); // 存储到“接受者的”消息状态表 $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $key, 'isnew' => 1, 'pmnum' => 1, 'lastupdate' => 0, 'lastdateline' => SYS_TIME)); // 存储到“发送者的”消息状态表 $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $fromuid, 'isnew' => 0, 'pmnum' => 1, 'lastupdate' => SYS_TIME, 'lastdateline' => SYS_TIME)); } else { // 获取上面查询的会话列表ID $plid = $existplid[$value]; // 将列表id插入到消息索引表中 $this->db->insert('pm_indexes', array('plid' => $plid)); // 得到一个短消息ID $pmid = $this->db->insert_id(); // 以回话列表id作为散列存储 $this->db->insert($this->_pm_tablename($plid), array('pmid' => $pmid, 'plid' => $plid, 'authorid' => $fromuid, 'message' => $message, 'dateline' => SYS_TIME, 'delstatus' => 0)); // 存储到“接受者的”消息状态表 if ($this->db->where('plid', $plid)->where('uid', $key)->count_all_results('pm_members')) { // 如果已经存在了就更新状态表 $this->db->where('plid', $plid)->where('uid', $key)->set('isnew', 1)->set('lastdateline', SYS_TIME)->set('pmnum', 'pmnum+1', FALSE)->update('pm_members'); } else { $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $key, 'isnew' => 1, 'pmnum' => 1, 'lastupdate' => 0, 'lastdateline' => SYS_TIME)); } // 存储到“发送者的”消息状态表 if ($this->db->where('plid', $plid)->where('uid', $fromuid)->count_all_results('pm_members')) { // 如果已经存在了就更新状态表 $this->db->where('plid', $plid)->where('uid', $fromuid)->set('isnew', 0)->set('lastdateline', SYS_TIME)->set('pmnum', 'pmnum+1', FALSE)->update('pm_members'); } else { $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $fromuid, 'isnew' => 0, 'pmnum' => 1, 'lastupdate' => SYS_TIME, 'lastdateline' => SYS_TIME)); } // 更新最后一条消息信息 $this->db->where('plid', $plid)->set('lastmessage', $lastmessage)->update('pm_lists'); } } // 插入用户的新短消息表 foreach ($member as $key => $value) { $this->db->replace('newpm', array('uid' => $key)); } return NULL; }