/** * 内容页 */ public function show() { $catid = intval($_GET['catid']); $id = intval($_GET['id']); if (!$catid || !$id) { showmessage(L('information_does_not_exist'), 'blank'); } $_userid = $this->_userid; $_username = $this->_username; $_groupid = $this->_groupid; $page = isset($_GET['page']) ? max(intval($_GET['page']), 1) : 1; $CATEGORYS = S('common/category_content'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { showmessage(L('information_does_not_exist'), 'blank'); } $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $MODEL = S('common/model'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->get_prefix() . $MODEL[$modelid]['tablename']; $r = $this->db->getby_id($id); if (!$r || $r['status'] != 99) { showmessage(L('info_does_not_exists'), 'blank'); } $this->db->table_name = $tablename . '_data'; $r2 = $this->db->getby_id($id); $rs = $r2 ? array_merge($r, $r2) : $r; // 再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); // 检查文章会员组权限 if ($groupids_view && is_array($groupids_view)) { $_groupid = cookie('_groupid'); $_groupid = intval($_groupid); if (!$_groupid) { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward))); } if (!in_array($_groupid, $groupids_view)) { showmessage(L('no_priv')); } } else { // 根据栏目访问权限判断权限 $_priv_data = $this->_category_priv($catid); if ($_priv_data == '-1') { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward))); } elseif ($_priv_data == '-2') { showmessage(L('no_priv')); } } if (app_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } // 阅读收费 类型 $paytype = $rs['paytype']; $readpoint = $rs['readpoint']; $allow_visitor = 1; if ($readpoint || $this->category_setting['defaultchargepoint']) { if (!$readpoint) { $readpoint = $this->category_setting['defaultchargepoint']; $paytype = $this->category_setting['paytype']; } // 检查是否支付过 $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype); if (!$allow_visitor) { $http_referer = urlencode(Base_Request::get_url()); $allow_visitor = String::authcode($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer; } else { $allow_visitor = 1; } } // 最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = isset($arrparentid[1]) ? $arrparentid[1] : $catid; $template = $template ? $template : $CAT['setting']['show_template']; if (!$template) { $template = 'show'; } // SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); define('STYLE', $CAT['setting']['template_list']); if (isset($rs['paginationtype'])) { $paginationtype = $rs['paginationtype']; $maxcharperpage = $rs['maxcharperpage']; } $pages = $titles = ''; if ($rs['paginationtype'] == 1) { // 自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = Loader::lib('content:contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($rs['paginationtype'] != 0) { // 手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = Loader::lib('content:url'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } // 当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls); // 判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } } } $this->db->table_name = $tablename; // 上一页 $previous_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('lt', $id)))->order('id DESC')->find(); // 下一页 $next_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('gt', $id)))->find(); if (empty($previous_page)) { $previous_page = array('title' => L('first_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page') . '\');'); } include template('content', $template); }
/** * 生成内容页 * * @param $file 文件地址 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 * @param $upgrade 是否是升级数据 */ public function show($file, $data = '', $array_merge = 1, $action = 'add', $upgrade = 0) { if ($upgrade) { $file = '/' . ltrim($file, WEB_PATH); } $allow_visitor = 1; $id = $data['id']; if ($array_merge) { $data = String::stripslashes($data); $data = array_merge($data['system'], $data['model']); } // 通过rs获取原始值 $rs = $data; if (isset($data['paginationtype'])) { $paginationtype = $data['paginationtype']; $maxcharperpage = $data['maxcharperpage']; } else { $paginationtype = 0; } $catid = $data['catid']; $CATEGORYS = $this->categorys; $CAT = $CATEGORYS[$catid]; $CAT['setting'] = string2array($CAT['setting']); define('STYLE', $CAT['setting']['template_list']); // 最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid; $modelid = $CAT['modelid']; require_once CACHE_MODEL_PATH . 'content_output.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $output_data = $content_output->get($data); extract($output_data); if (app_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } $this->db = Loader::model('content_model'); $this->db->set_model($modelid); // 上一页 $previous_page = $this->db->order('id DESC')->where(array('status' => '99', 'id' => array('lt', $id)))->find(); // 下一页 $next_page = $this->db->where(array('status' => '99', 'id' => array('gt', $id)))->find(); if (empty($previous_page)) { $previous_page = array('title' => L('first_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page', '', 'content') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page', '', 'content') . '\');'); } $title = strip_tags($title); // SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); $ishtml = 1; $template = !empty($template) ? $template : $CAT['setting']['show_template']; // 分页处理 $pages = $titles = ''; if ($paginationtype == 1) { // 自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = Loader::lib('content:contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($paginationtype != 0) { // 手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = Loader::lib('content:url', 'content'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $upgrade = $upgrade ? '/' . ltrim($file, WEB_PATH) : ''; $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], $data['prefix'], '', 'edit', $upgrade); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } // 生成分页 foreach ($pageurls as $page => $urls) { $pages = content_pages($pagenumber, $page, $pageurls); // 判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } $pagefile = $urls[1]; $pagefile = BASE_PATH . $pagefile; ob_start(); include template('content', $template); $this->createhtml($pagefile); } return true; } } // 分页处理结束 $file = BASE_PATH . $file; ob_start(); include template('content', $template); return $this->createhtml($file); }
<?php defined('IN_YUNCMS') or exit('No permission resources.'); /** * * @author Tongle Xu <*****@*****.**> 2012-6-13 * @copyright Copyright (c) 2003-2103 yuncms.net * @license http://leaps.yuncms.net * @version $Id: comment_api.php 660 2013-07-30 02:03:49Z 85825770@qq.com $ */ if (!app_exists('comment')) { showmessage(L('module_not_exists')); } class comment_api { private $db; function __construct() { $this->db = Loader::model('special_model'); } /** * 获取评论信息 * * @param $module 模型 * @param $contentid 文章ID */ function get_info($app, $contentid) { if ($app == 'special') { $r = $this->db->where(array('id' => $contentid))->field('title, url')->find(); return array('title' => $r['title'], 'url' => $r['url']);
function dbtoolkit_admin() { global $user_ID; if (!empty($_GET['open'])) { if (app_exists($_GET['open'])) { update_option('_dbt_activeApp', $_GET['open']); } } $activeApp = get_option('_dbt_activeApp'); if (!empty($_GET['close'])) { if (!empty($activeApp)) { if ($activeApp == $_GET['close']) { update_option('_dbt_activeApp', false); $activeApp = false; } } } if (!empty($_GET['delete'])) { if (!empty($activeApp)) { if ($activeApp == $_GET['delete']) { if ($_GET['delete'] == $activeApp) { $Apps = get_option('dt_int_Apps'); $appConfig = get_option('_' . $activeApp . '_app'); if (!empty($appConfig['interfaces'])) { foreach ($appConfig['interfaces'] as $inf => $val) { dt_removeInterface($inf); } } if (!empty($appConfig['clusters'])) { foreach ($appConfig['clusters'] as $inf => $val) { dt_removeInterface($inf); } } if (!empty($appConfig['imageFile'])) { if (file_exists($appConfig['imageFile'])) { unlink($appConfig['imageFile']); } } delete_option('_' . $activeApp . '_app'); unset($Apps[$activeApp]); update_option('dt_int_Apps', $Apps); update_option('_dbt_activeApp', false); $activeApp = false; } //update_option('_dbt_activeApp', false); ///$activeApp = false; } } } if (!empty($_GET['renderinterface'])) { include_once DB_TOOLKIT . 'dbtoolkit_launcher.php'; return; } if (empty($activeApp)) { update_option('_dbt_activeApp', false); $activeApp = false; include_once DB_TOOLKIT . 'dbtoolkit_builder.php'; return; } include_once DB_TOOLKIT . 'dbtoolkit_admin.php'; }
function app_createApplication($name, $desc = false) { if (empty($name)) { $out['error'] = 'You need an application name first.'; return $out; } $cleanName = sanitize_title($name); if (app_exists($cleanName)) { $out['error'] = 'Application "' . $name . '" already exists'; return $out; } $newApp = array(); $newApp['state'] = 'open'; $newApp['name'] = $name; if (!empty($desc)) { $newApp['description'] = $desc; } if (update_option('_' . $cleanName . '_app', $newApp)) { $apps = get_option('dt_int_Apps'); $apps[$cleanName] = $newApp; if (update_option('dt_int_Apps', $apps)) { if (update_option('_dbt_activeApp', $cleanName)) { return true; } } } $out['error'] = 'There was an error creating the app. Sorry.'; return $out; }
&file=<?php echo $file; ?> " method="post" name="myform" id="myform"> <textarea name="code" id="code" style="height: 80%;width:99%; visibility:inherit"><?php echo $data; ?> </textarea> <div class="bk10"></div> <?php if ($is_write == 0) { echo '<font color="red">' . L("file_does_not_writable") . '</font>'; } ?> <?php if (app_exists('tag')) { ?> <input type="button" class="btn btn-primary btn-sm"onClick="create_tag()" value="<?php echo L('create_tag'); ?> " /> <input type="button" class="btn btn-primary btn-sm"onClick="select_tag()" value="<?php echo L('select_tag'); ?> " /> <?php } ?> <input type="submit" id="dosubmit" class="button pt" name="dosubmit" value="<?php echo L('submit'); ?> " /> </form>
/** * 解析YUN标签 * * @param string $op * 操作方式 * @param string $data * 参数 * @param string $html * 匹配到的所有的HTML代码 */ public static function yun_tag($op, $data, $html) { preg_match_all("/([a-z]+)\\=[\"]?([^\"]+)[\"]?/i", stripslashes($data), $matches, PREG_SET_ORDER); $arr = array('do', 'num', 'cache', 'page', 'pagesize', 'urlrule', 'return', 'start'); $tools = array('json', 'xml', 'block', 'get'); $datas = array(); $tag_id = md5(stripslashes($html)); // 可视化条件 $str_datas = 'op=' . $op . '&tag_md5=' . $tag_id; foreach ($matches as $v) { $str_datas .= $str_datas ? "&{$v['1']}=" . ($op == 'block' && strpos($v[2], '$') === 0 ? $v[2] : urlencode($v[2])) : "{$v['1']}=" . (strpos($v[2], '$') === 0 ? $v[2] : urlencode($v[2])); if (in_array($v[1], $arr)) { ${$v}[1] = $v[2]; continue; } $datas[$v[1]] = $v[2]; } $str = ''; $num = isset($num) && intval($num) ? intval($num) : 20; $cache = isset($cache) && intval($cache) ? intval($cache) : 0; $return = isset($return) && trim($return) ? trim($return) : 'data'; if (!isset($urlrule)) { $urlrule = ''; } if (!empty($cache) && !isset($page)) { $str .= '$tag_cache_name = md5(implode(\'&\',' . self::arr_to_html($datas) . ').\'' . $tag_id . '\');if(!$' . $return . ' = S($tag_cache_name)){'; } if (in_array($op, $tools)) { switch ($op) { case 'json': if (isset($datas['url']) && !empty($datas['url'])) { $str .= '$json = @file_get_contents(\'' . $datas['url'] . '\');'; $str .= '$' . $return . ' = json_decode($json, true);'; } break; case 'xml': $str .= '$xml = Loader::lib(\'Xml\');'; $str .= '$xml_data = @file_get_contents(\'' . $datas['url'] . '\');'; $str .= '$' . $return . ' = $xml->xml_unserialize($xml_data);'; break; case 'get': if ($datas['dbsource']) { $dbsource = S('common/dbsource'); if (isset($dbsource[$datas['dbsource']])) { $str .= 'Loader::model("db_model",false);'; $str .= '$get_db = new db_model("' . $datas['dbsource'] . '");'; } else { return false; } } else { $str .= '$get_db = Loader::model("get_model");'; } $num = isset($num) && intval($num) > 0 ? intval($num) : 20; if (isset($start) && intval($start)) { $limit = intval($start) . ',' . $num; } else { $limit = $num; } if (isset($page)) { $str .= '$pagesize = ' . $num . ';'; $str .= '$page = isset(' . $page . ') && intval(' . $page . ') ? intval(' . $page . ') : 1;if($page<=0){$page=1;}'; $str .= '$offset = ($page - 1) * $pagesize;'; $limit = '$offset,$pagesize'; if ($sql = preg_replace('/select([^from].*)from/i', "SELECT COUNT(*) as count FROM ", $datas['sql'])) { $str .= '$res = $get_db->sql_query("' . $sql . '");$pages=Page::pages($res[0][\'count\'], $page, $pagesize, $urlrule);'; } } $str .= '$res = $get_db->sql_query("' . $datas['sql'] . ' LIMIT ' . $limit . '");$' . $return . ' = $res;unset($res);'; break; case 'block': $str .= '$block_tag = Loader::lib(\'block:block_tag\');'; $str .= 'echo $block_tag->yun_tag(' . self::arr_to_html($datas) . ');'; break; } } else { if (!isset($do) || empty($do)) { return false; } if (app_exists($op) && file_exists(APPS_PATH . $op . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $op . '_tag.php')) { $str .= '$' . $op . '_tag = Loader::lib("' . $op . ':' . $op . '_tag");if (method_exists($' . $op . '_tag, \'' . $do . '\')) {'; if (isset($start) && intval($start)) { $datas['limit'] = intval($start) . ',' . $num; } else { $datas['limit'] = $num; } if (isset($page)) { $str .= '$pagesize = ' . $num . ';'; $str .= '$page = isset(' . $page . ') ? intval(' . $page . ') : 1;if($page<=0){$page=1;}'; $str .= '$offset = ($page - 1) * $pagesize;'; $datas['limit'] = '$offset.",".$pagesize'; $datas['do'] = $do; $str .= '$' . $op . '_total = $' . $op . '_tag->count(' . self::arr_to_html($datas) . ');'; $str .= '$pages = Page::pages($' . $op . '_total, $page, $pagesize, isset($urlrule) ? $urlrule:\'\');'; } $str .= '$' . $return . ' = $' . $op . '_tag->' . $do . '(' . self::arr_to_html($datas) . ');'; $str .= '}'; } } if (!empty($cache) && !isset($page)) { $str .= 'if(!empty($' . $return . ')){S(\'tpl_data/\'. $tag_cache_name, $' . $return . ',' . $cache . ');}'; $str .= '}'; } return "<" . "?php if(defined('IN_ADMIN') && !defined('HTML')) {echo \"<div class=\\\"admin_piao\\\" yun_action=\\\"" . $op . "\\\" data=\\\"" . $str_datas . "\\\"><a href=\\\"javascript:void(0);\\\" class=\\\"admin_piao_edit\\\">" . ($op == 'block' ? L('block_add') : L('edit')) . "</a>\";}" . $str . "?" . ">"; }
/** * 更新评论的状态 * * @param string $commentid 评论ID * @param integer $id 内容ID * @param integer $status 状态{1:通过 ,0:未审核, -1:不通过,将做删除操作} */ public function status($commentid, $id, $status = -1) { if (!($comment = $this->comment_db->where(array('commentid' => $commentid))->field('tableid, commentid')->find())) { $this->msg_code = 6; return false; } // 为数据存储数据模型设置 数据表名。 $this->comment_data_db->table_name($comment['tableid']); if (!($comment_data = $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->find())) { $this->msg_code = 6; return false; } // 读取评论的站点配置信息 $site = S('common/comment'); if ($status == 1) { // 通过的时候 $sql['total'] = '+=1'; // 当评论被设置为通过的时候,更新评论总表的数量。 $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql); // 更新评论内容状态 $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->update(array('status' => $status)); // 当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。 if (!empty($comment_data['userid']) && !empty($site['add_point']) && app_exists('pay')) { Loader::lib('pay:receipts', false); receipts::point($site['add_point'], $comment_data['userid'], $comment_data['username'], '', 'selfincome', 'Comment'); } } elseif ($status == -1) { // 删除数据 // 如果数据原有状态为已经通过,需要删除评论总表中的总数 if ($comment_data['status'] == 1) { $sql['total'] = '-=1'; $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql); } // 删除存储表的数据 $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->delete(); // 删除存储表总数记录 $this->comment_table_db->edit_total($comment['tableid'], '-=1'); // 当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。 if (!empty($comment_data['userid']) && !empty($site['del_point']) && app_exists('pay')) { Loader::lib('pay:receipts', false); $op_userid = cookie('userid'); $op_username = cookie('admin_username'); spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_data['userid'], $comment_data['username'], $op_userid, $op_username); } } // 删除审核表中的数据 $this->comment_check_db->where(array('comment_data_id' => $id))->delete(); $this->msg_code = 0; return true; }