/** 搜索结果显示页 ########## 搜索结果和所属网站做绑定,根据URL判断 ########## */ function king_search() { global $king; $king->Load('portal'); //获得modelid if (!($modelTables = getModelTables())) { $king->portal->error($king->lang->get('portal/common/error'), $king->lang->get('portal/error/notmodel')); } $currentArray = current($modelTables); $modelid = isset($_GET['modelid']) ? $_GET['modelid'] : $currentArray['modelid']; $model = $king->portal->infoModel($modelid); $query = kc_get('query', 0); $querys = preg_split("/[,\\*\\%\\.\\(\\)\\'\\`><\\}\\{ ]/", $query); $querys = array_diff($querys, array('')); $q = implode("%' or ktitle like '%", $querys); if (isset($q[0])) { $q = " and (ktitle like '%" . $q . "%')"; } if (is_array($model['field']['issearch'])) { foreach ($model['field']['issearch'] as $key => $val) { $getVal = kc_get(substr($key, 1), 0); if (isset($getVal[0])) { $q .= " and {$key}='" . $king->db->escape($getVal) . "'"; } } } foreach ($model['field']['id'] as $val) { $getVal = kc_val($_GET, $val); //kc_get($val,2); if (isset($getVal[0])) { if (kc_validate($getVal, 2)) { $q .= " and {$val}='{$getVal}'"; } else { $q .= " and {$val} in ({$getVal})"; } } } $pid = isset($_GET['pid']) ? kc_get('pid', 2, 1) : 1; $rn = isset($_GET['rn']) ? kc_get('rn', 2, 1) : 20; if ($rn > 100) { $rn = 100; } $tmp = new KC_Template_class($model['ktemplatesearch'], $king->config('templatepath') . '/inside/search/' . strtolower($model['modeltable']) . '[page].htm'); $tmp->assign('type', 'search'); $tmp->assign('pid', $pid); $tmp->assign('rn', $rn); $tmp->assign('search', $q); //传递搜索条件,也就是where条件 $tmp->assign('modelid', $modelid); //传递模型类型 // $tmp->assign('siteid');//这个还得获取 $tmp->assign('title', $king->lang->get('system/common/search')); echo $tmp->output(); }
/** 文件操作编码转换 @param strin $s 字符串 @param bool $is=0 默认读取,1的时候是写入 @return */ function kc_f_iconv($s, $is = 0) { $lang = kc_val($_SERVER, 'HTTP_ACCEPT_LANGUAGE'); if (substr($lang, 0, 5) == "zh-cn") { $code = 'GBK'; } elseif (substr($lang, 0, 5) == "zh-tw") { $code = 'BIG5'; } if (isset($code)) { $s = $is ? kc_iconv($s, $code, PAGE_CHARSET) : kc_iconv($s, PAGE_CHARSET, $code); } return $s; }
private function attribBack($m) { $attributes = $m[4]; $attrib = $this->attrib2array($attributes); $s = ''; switch (strtolower($m[2])) { case 'king': $s = kc_val($this->tempArray, $m[3]); //值 if (false !== ($ret = $this->sysinfo($m[3]))) { return $ret; } /* if(in_array($m[3],array('root','version','cms'))){ global $king; switch($m[3]){ case 'root':$s=$king->config('inst');break; case 'version':$s=$king->devname;break; case 'cms':$s="<span>Powerd by <a href=\"http://www.kingcms.com/\" title=\"KingCMS\" target=\"_blank\">KingCMS</a> ".$king->devname ."</span>";break; } return $s; } */ break; case 'get': $s = kc_get($m[3], 0); break; case 'post': $s = kc_post($m[3], 0); break; } return $this->str_format($s, $attrib); }
/** 列表 - 开始 @param array $_cmd 命令列表 array( $key=>$value, 'delete'=>'删除', '-', 'create'=>'生成', ) @param array $right 右键菜单 array( ); @param array $_js 构造javascript函数function ll() array( $value, 每个值对应的是一个HTML标签:<td>$value</td> ) @param string $_plist 分页HTML代码 @param array $_val 预设的隐藏域 及值 @return string */ public function openList($_cmd = null, $right = array(), $_js = null, $_plist = null, $_ext = array()) { $i = 0; $fly = ''; $s = '<form id="k_form_list" name="k_form_list">' . kc_htm_hidden($_ext) . '<script type="text/javascript">var REQUEST_URL=\'' . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '\';'; $s .= 'function kc_button(){var I1=\''; $s .= '<table cellspacing="0" class="k_button"><tr><td><div class="k_submit">'; if (is_array($_cmd)) { $s_but = '<span class="select"><a href="javascript:;" class="k_aselect" >' . addslashes($this->lang->get('system/common/aselect')) . '</a>/'; //onClick="kc_aselect()" $s_but .= '<a href="javascript:;" class="k_rselect">' . addslashes($this->lang->get('system/common/rselect')) . '</a></span>'; $but = ''; $cmd = "<a href=\"javascript:;\" class=\"k_cmd\">" . $this->lang->get('system/common/morecmd') . "</a>"; $fly = '<ul id="k_cmd_Fly" style="display:none;">'; $is = False; foreach ($_cmd as $key => $val) { if (kc_validate($key, 2)) { if ($val == '-') { $is = True; } else { $fly .= '<li class="hr2">' . $val . '</li>'; } } else { $fly .= '<li' . ($is ? ' class="hr1"' : '') . '><a href="javascript:;" class="k_ajax" rel="{CMD:\'' . $key . '\',FORM:\'k_form_list\'}">' . $val . '</a></li>'; $is = 0; if ($key == 'create') { //有create的时候,设置but $but .= '<a href="javascript:;" class="button k_ajax" rel="{CMD:\\\'' . $key . '\\\',FORM:\\\'k_form_list\\\'}">' . addslashes($this->lang->get('system/common/create')) . '</a>'; } if ($key == 'delete' || substr($key, 0, 7) == 'delete_') { //有delete的时候,设置but $but .= '<a href="javascript:;" class="button k_ajax" rel="{CMD:\\\'' . $key . '\\\',FORM:\\\'k_form_list\\\'}">' . addslashes($this->lang->get('system/common/del')) . '</a>'; } } } $fly .= '</ul>'; $s .= $s_but . $but . (count($_cmd) == 1 && isset($but[0]) ? '' : $cmd); } if (is_array($right)) { $fly .= "<div id=\"k_list_right_Fly\" class=\"none\" onClick=\"\$(this).fadeOut(300)\">"; foreach ($right as $key => $val) { if ($val == '-') { $fly .= '<i></i>'; } else { if (is_array($val)) { $ico = kc_val($val, 'ico'); $href = kc_val($val, 'href'); } else { $ico = ''; $href = $val; } if (substr($href, 0, 1) == '{' || substr($href, -1, 1) == '}') { //ajax操作 $fly .= "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{$href}\">" . kc_icon($ico) . $key . "</a>"; } else { $fly .= "<a href=\"{$href}\">" . kc_icon($ico) . $key . "</a>"; } } } $fly .= "<i></i>"; $fly .= "<a href=\"javascript:;\" onClick=\"\$('k_list_right_Fly').fadeOut(300)\">" . kc_icon('k8') . $this->lang->get('system/common/cancel') . "</a>"; $fly .= "</div>"; } $s .= '</div></td>\''; //</div> if ($_plist != null) { $s .= '+\'<td>' . addslashes($_plist) . '</td>\''; } $s .= '+\'</tr></table>\';return I1;};document.write(kc_button());'; $s .= 'function ll(){var K=ll.arguments;if(K[K.length-1]==1){for(i=0;i<K.length-1;i++){if(K[i]!=\'manage\'){document.write(\'<th class="th\'+i+\'">\'+K[i]+\'</th>\')}else{document.write(\'<th class="th\'+i+\'">' . $this->lang->get('system/common/manage') . '</th>\')}}}else{var II=\'<tr id="tr_\'+K[0]+\'">\'' . NL; if (is_array($_js)) { foreach ($_js as $_value) { $s .= '+\'<td id="td_\'+K[0]+\'_' . ++$i . '">\'+$.kc_nbsp(' . $_value . ')+\'</td>\'' . NL; } } $s .= '+\'</tr>\';if(K[K.length-1]==0){document.write(II)}else{return II}}};' . NL; $s .= 'document.write(\'<table class="k_table_list" cellspacing="0" id="k_table_list">\');' . NL; $this->mList = NL . 'document.write(\'</table>\'+kc_button());'; $this->mList .= '</script></form>' . $fly; //灰调显示按钮 return $s; }
public function tag_module($inner = '', $attrib = array()) { global $king; $s = ''; $nshow = kc_val($attrib, 'show', NULL); $pArray = $king->getModule($nshow); if (empty($inner)) { $s = '<ul class="k_menu" id="k_modulelist"><li> <a href="javascript:;">' . $king->lang->get('system/common/module') . '</a> <ul> <li><a href="../system/manage.php?action=module"><img src="../system/images/white.gif" class="os m8"/>' . $king->lang->get('system/menu/module') . '</a></li> <li class="hr"><a href="../system/manage.php"><img src="../system/images/white.gif" class="os k2"/>' . $king->lang->get('system/name') . '</a></li>'; foreach ($pArray as $val) { $s .= '<li><a href="../' . $val . '/manage.php"><img src="../system/images/white.gif" class="os k7"/>' . $king->lang->get($val . '/name') . '</a></li>'; } $s .= ' </ul> </li></ul>'; } else { $tmp = new KC_Template_class(); foreach ($pArray as $val) { if ($king->acc($val)) { $tmp->assign('name', htmlspecialchars($king->lang->get($val . '/name'))); $tmp->assign('url', "../{$val}/manage.php"); $tmp->assign('path', $val); $s .= $tmp->output($inner); } } } return $s; }
private function tag_user_group($inner, $attrib) { global $king; $whereArray = array(); $gid = kc_val($attrib, 'gid'); if ($gid == 0) { //默认帐号 } $group = $this->infoGroup($gid); $tmp = new KC_Template_class(); $tmp->assign('gid', $group['gid']); $tmp->assign('name', $group['kname']); $tmp->assign('access', $group['kaccess']); $tmp->assign('menu', $group['kmenu']); $s = $tmp->output($inner); return $s; }
/** @param string $name 标签名 portal.article @param string $inner 循环体内的 @param array $ass assign 内容 @param array $attrib 属性数组 @return string */ public function tag($name, $inner, $ass, $attrib) { global $king; $name = kc_val($attrib, 'name'); if (empty($name)) { return $king->lang->get('block/error/name', 4); } if (!($res = $king->db->getRows("select kid,ntype,bid,kcontent from %s_block where kname='" . $king->db->escape($name) . "' "))) { return $king->lang->get('block/error/name', 5); } $array = array(); foreach ($res as $rs) { $array["{$rs['ntype']}-{$rs['bid']}"] = $rs['kcontent']; } //很麻烦的绑定判断 $listid = kc_val($ass, 'listid'); if (empty($listid)) { //如果listid为空值的话,直接调用默认值 $content = kc_val($array, '0-0'); } else { if (isset($array["1-{$listid}"])) { //先判断listid $content = $array["1-{$listid}"]; } else { //再判断modelid if (!isset($ass['modelid'])) { //若ass中没有modelid,则从info中加载 $king->Load('portal'); //加载portal类 $info = $king->portal->infoList($listid); $modelid = $info['modelid']; } else { $modelid = $ass['modelid']; } //判断modelid if (isset($array["2-{$modelid}"])) { $content = $array["2-{$modelid}"]; } else { //连modelid都没有的情况下才会去判断siteid if (!isset($ass['siteid'])) { //若ass中没有siteid if (empty($info)) { //如果info没有加载,则加载,似乎这个可能性发生的概率为0? $king->Load('portal'); $info = $king->portal->infoList($listid); } $siteid = $info['siteid']; } else { $siteid = $ass['siteid']; } if (isset($array["3-{$siteid}"])) { $content = $array["3-{$siteid}"]; } else { //只能调用默认值 $content = kc_val($array, "0-0"); } } } } //获得了$content值后,调用模板解析 $tmp = new KC_Template_class(); if (is_array($ass)) { foreach ($ass as $key => $val) { $tmp->assign($key, $val); } } $s = $tmp->output($content); return $s; }
function king_ajax_orders() { global $king; //显示物流方式选择页,并显示对应的物流费用 //订单insert到数据库,并返回订单号。以便客户查询订单,也为邮政付款的用户提供收据上传功能 //清空购物记录 $king->Load('user'); $tip = ($user = $king->user->checkLogin()) ? '' : '<a href="javascript:;" class="k_user_login">' . $king->lang->get('portal/user/nologin') . '</a> <a href="javascript:;" class="k_user_register">' . $king->lang->get('portal/user/regshop') . '</a>'; $array_sql = array('usermail', 'realname', 'useraddress', 'userpost', 'usertel', 'kfeedback'); if ($GLOBALS['ismethod']) { $data = $_POST; } else { $data = array(); if (is_array($user)) { //用户已登录 foreach ($array_sql as $val) { $data[$val] = kc_val($user, $val); } } } $data = kc_data($array_sql, $data); //kconsignee $array = array(array('realname', 0, 2, 30)); $s = $king->htmForm($king->lang->get('portal/orders/realname'), kc_htm_input('realname', $data['realname'], 30, 100), $array, null, $tip); //ktel $array = array(array('usertel', 0, 6, 30)); $s .= $king->htmForm($king->lang->get('portal/orders/tel'), kc_htm_input('usertel', $data['usertel'], 30, 200), $array); //kmail $array = array(array('usermail', 0, 6, 32), array('usermail', 5)); $s .= $king->htmForm($king->lang->get('portal/orders/mail'), kc_htm_input('usermail', $data['usermail'], 32, 200), $array); //kaddress $array = array(array('useraddress', 0, 5, 250)); $s .= $king->htmForm($king->lang->get('portal/orders/address'), '<textarea cols="10" id="useraddress" name="useraddress" rows="3" class="k_in w400">' . htmlspecialchars($data['useraddress']) . '</textarea>', $array); //kpost $array = array(array('userpost', 0, 6, 6), array('userpost', 2)); $s .= $king->htmForm($king->lang->get('portal/orders/post'), kc_htm_input('userpost', $data['userpost'], 6, 50), $array); //kfeedback $array = array(array('kfeedback', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('portal/orders/feedback'), '<textarea cols="10" rows="4" name="kfeedback" id="kfeedback" class="k_in w400">' . htmlspecialchars($data['kfeedback']) . '</textarea>', $array); if ($GLOBALS['ischeck']) { $cart = kc_cookie('KingCMS_Cart'); $eid = kc_post('eid'); if (!($cart && isset($eid))) { kc_error($king->lang->get('system/error/param')); } $weight = 0; $total = 0; $nnum = 0; $cart_array = unserialize($cart); //要过滤掉的内容 $array_black = str_split('<>\'"%'); foreach ($cart_array as $key => $number) { list($listid, $kid) = explode('-', $key); $ID = $king->portal->infoID($listid, $kid); if ($total === 0) { //第一次运算 $mch_name = kc_substr(str_replace($array_black, '', $ID['ktitle']), 0, 16); } $weight += $number * $ID['nweight']; $total += $number * $ID['nprice']; $nnum += $number; } $nexpress = 0; //运费 if ($weight !== 0) { $express = $king->portal->getExpress(); $nexpress = $express[$eid]['nsprice'] + $express[$eid]['niprice'] * ceil($weight > 500 ? $weight / 500 - 1 : 0); } $ono = kc_formatdate(time(), 'Ymd') . sprintf("%08.0d", $king->db->neworder('%s_orders', '', 'oid')); $array = array('kname' => $mch_name, 'userid' => is_array($user) ? $user['userid'] : 0, 'kcontent' => $cart, 'ndate' => time(), 'nip' => kc_getip(), 'eid' => $eid, 'ntotal' => round($total, 2), 'ono' => $ono, 'nnumber' => $nnum, 'kfeedback' => $data['kfeedback'], 'nweight' => $weight, 'nexpress' => $nexpress); foreach ($array_sql as $val) { $array[$val] = kc_val($data, $val); } $oid = $king->db->insert('%s_orders', $array); setcookie('KingCMS_Cart', '', -86400000, $king->config('inst')); $js = "\$.kc_ajax('{URL:\\'" . $king->config('inst') . "portal/cart.php\\',CMD:\\'payment\\',IS:1,oid:{$oid}}')"; kc_ajax('', '', '', $js); } $but = kc_htm_a($king->lang->get('portal/cart/backcart'), "{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'buy',IS:1}"); $but .= kc_htm_a($king->lang->get('portal/cart/suborders'), "{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'orders',eid:" . kc_post('eid') . ",IS:1}"); kc_ajax($king->lang->get('portal/cart/suborders'), $s, $but, '', 600, 350 + $GLOBALS['check_num'] * 15); }
private function tag_dbquery($inner, $attrib) { $query = kc_val($attrib, 'query'); $s = ''; if ($res = $this->db->getRows($query)) { $tmp = new KC_Template_class(); foreach ($res as $rs) { foreach ($rs as $key => $val) { $tmp->assign($key, $val); } $s .= $tmp->output($inner); } } return $s; }
function king_def() { global $king; //die(uc_user_synlogin(2)); if ($GLOBALS['ismethod']) { //POST过程 $data = $_POST; } else { $data = array('re' => kc_val($_SERVER, 'HTTP_REFERER')); } $data = kc_data(array('re', 'username', 'userpass', 'expire')); if ($king->config('blackuser', 'user')) { $array_black = explode('|', $king->config('blackuser', 'user')); $array_black = array_diff($array_black, array(null)); } else { $array_black = array(); } $s = $king->openForm('login.php'); //username $_array = array(array('username', 0, 3, 15), array('username', 14, $king->lang->get('portal/check/reg/u-1'), array('*', '\\', ':', '?', '<', '>', '|', ';', ',', '\'', '!', '~', '$', '#', '@', '^', '(', ')', '{', '}', '=', '+', '%', '/')), array('username', 14, $king->lang->get('portal/check/reg/u-2'), $array_black)); $s .= $king->htmForm($king->lang->get('portal/user/name'), '<input class="k_in w150" type="text" name="username" value="' . htmlspecialchars($data['username']) . '" maxlength="15" />', $_array, null, "<tt><a href=\"javascript:; \" class=\"k_user_register\">" . $king->lang->get('portal/user/reg') . "</a></tt>"); //pass $_array = array(array('userpass', 0, 6, 30)); if ($data['userpass'] && $GLOBALS['ischeck']) { //有密码 并 账号验证成功的时候进行验证 $username = $data['username']; $is = False; if ($king->user->isuc) { //如果有UC if ($array_uc = uc_user_login($data['username'], $data['userpass'])) { //链接成功 if ((int) $array_uc[0] < 0) { //用户名不存在或密码错误 if ($res = $king->db->getRows_one("select usermail,userpass,ksalt,userid from %s_user where username='******' and uid=0")) { //判断本地是否存在这个用户并且未同步到uc $userid = $res['userid']; if (md5($res['ksalt'] . $data['userpass']) == $res['userpass']) { //检测密码 $uid = uc_user_register($username, $data['userpass'], $res['usermail']); //注册用户到uc $king->db->update('%s_user', array('lastlogindate' => time(), 'uid' => $uid > 0 ? $uid : 0), 'username=\'' . $king->db->escape($username . '\'')); uc_user_login($data['username'], $data['userpass']); } else { $is = True; $errId = -2; } } else { $is = True; $errId = $array_uc[0]; } } else { //登录成功的时候,检查一下本地是否有这个账号 $uid = $array_uc[0]; //UC中的UID if ($res = $king->db->getRows_one("select userpass,ksalt,userid from %s_user where username='******'")) { //如果有这么个账号 $userid = $res['userid']; if (md5($res['ksalt'] . $data['userpass']) != $res['userpass']) { //若不一致,则进行更新 $userpass = md5($res['ksalt'] . $data['userpass']); $king->db->update('%s_user', array('userpass' => $userpass, 'lastlogindate' => time()), 'username=\'' . $king->db->escape($username . '\'')); } else { $king->db->update('%s_user', array('lastlogindate' => time()), 'username=\'' . $king->db->escape($username . '\'')); } } else { //如果本地没有这个账号,则添加 $usermail = $array_uc[3]; $ksalt = kc_random(6); $array = array('username' => $username, 'userpass' => md5($ksalt . $data['userpass']), 'usermail' => $usermail, 'ksalt' => $ksalt, 'uid' => $uid, 'regdate' => time(), 'lastlogindate' => time()); $king->db->insert('%s_user', $array); $res = $king->db->getRows_one("select userid from %s_user where uid='" . $uid . "' and isdelete=0"); $userid = $res['userid']; } } } else { kc_error($king->lang->get('portal/error/connect')); //连接错误 } } else { //如果没有UC if ($res = $king->db->getRows_one("select userpass,ksalt,userid from %s_user where username='******' and isdelete=0")) { //如果有这么个账号 $md5pass = md5($res['ksalt'] . $data['userpass']); // kc_error($md5pass."\t".$res['userpass']); if ($md5pass != $res['userpass']) { //若不一致,提示错误 $is = True; $errId = -2; } else { //验证通过 $userid = $res['userid']; $king->db->update('%s_user', array('lastlogindate' => time()), 'userid=' . $userid); // $userpass=md5($res['ksalt'].$data['userpass']); } } else { $is = True; $errId = -1; } } if (!empty($errId)) { $_array[] = array('userpass', 12, $king->lang->get('portal/check/pwd/p' . $errId), $is); } } $s .= $king->htmForm($king->lang->get('portal/user/pass') . '', '<input class="k_in w150" type="password" name="userpass" maxlength="30" />', $_array, null, "<tt><a href=\"javascript:;\" class=\"k_user_lostpwd\">" . $king->lang->get('portal/user/lostpwd') . "</a></tt>"); //expire $array_select = array(0 => $king->lang->get('system/time/cookie'), 86400 => $king->lang->get('system/time/oneday'), 2592000 => $king->lang->get('system/time/jan'), 15768000 => $king->lang->get('system/time/halfyear'), 31536000 => $king->lang->get('system/time/ayear'), 315360000 => $king->lang->get('system/time/forever')); $s .= $king->htmForm($king->lang->get('portal/user/expire'), kc_htm_radio('expire', $array_select, 2592000)); //verify $verify = new KC_Verify_class(); $s .= $verify->Show(); $s .= kc_htm_hidden(array('re' => $data['re'])); $s .= $king->closeForm($king->lang->get('system/common/login')); if ($GLOBALS['ischeck']) { //写Cookie $s = $king->user->userLogin($userid, $data['expire']); $array = array('<a href="/">' . $king->lang->get('portal/user/return/home') . '</a>', '<a href="index.php">' . $king->lang->get('portal/user/return/uc') . '</a>'); if ($data['re']) { $array[] = '<a href="' . $data['re'] . '">' . $king->lang->get('portal/user/return/re') . ' : ' . $data['re'] . '</a>'; $goto = $data['re']; } else { $goto = $king->config('inst') . 'user/index.php'; } $s .= kc_htm_ol($king->lang->get('portal/user/loginok'), $array, $goto); } $tmp = new KC_Template_class($king->config('templateuser', 'user'), $king->config('templatepath') . '/inside/user/login.htm'); $tmp->assign('main', $s); $tmp->assign('title', $king->lang->get('portal/title/login')); echo $tmp->output(); }
/** 对king:portal.comment的解析 Code By: CiBill @param @return */ private function tag_comment($inner, $attrib) { global $king; //读取数量 $number = kc_val($attrib, 'number', 30); $number = kc_validate($number, 2) ? $number : 30; //跳过条数 $skip = kc_val($attrib, 'skip', 0); $skip = kc_validate($skip, 2) ? $skip : 0; //查询条件 $whereArray = array(); $modelid = kc_val($attrib, 'modelid'); //modelid if (!kc_validate($modelid, 2)) { //如果没有modelid传入,则通过listid获取modelid $listid = kc_val($attrib, 'listid'); //listid if (kc_validate($listid, 2)) { //listid为数字时,读取单个modelid if ($list = $king->portal->infoList($listid)) { $modelid = $list['modelid']; $whereArray[] = "modelid={$modelid}"; } else { return false; } } elseif (kc_validate($listid, 3)) { $listid = explode(',', $listid); $modelid = array(); foreach ($listid as $val) { if ($list = $king->portal->infoList($val)) { $modelid[] = $list['modelid']; } } if ($modelid) { $modelid = implode(',', $modelid); $whereArray[] = "modelid in ({$modelid})"; } else { return false; } } } $kid = kc_val($attrib, 'kid'); //文章id if (kc_validate($kid, 2)) { $whereArray[] = "kid={$kid}"; } elseif (kc_validate($kid, 3)) { $whereArray[] = "kid in ({$kid})"; } $orderby = isset($attrib['orderby']) ? ' ORDER BY ' . $attrib['orderby'] : ' ORDER BY cid desc'; $where = $whereArray ? 'where ' . implode(' and ', $whereArray) : ''; $limit = 'limit ' . $skip . ',' . $number; $tmp = new KC_Template_class(); /*if($skip==0 && $number==30 && kc_validate($kid,2) && kc_validate($modelid,2)){ $comment=$king->portal->infoComment($modelid,$kid); if(!$comment)return false; }else*/ if (!($comment = $king->db->getRows("select * from %s_comment {$where} {$orderby} {$limit}"))) { return false; } $s = ''; foreach ($comment as $rs) { $tmp->assign('id', $rs['cid']); $tmp->assign('kid', $rs['kid']); $tmp->assign('modelid', $rs['modelid']); $tmp->assign('username', $rs['username']); $content = $rs['kcontent']; if (substr($content, 0, 7) == '[quote]') { $rid = intval(substr($content, 7, 10)); if ($r = $king->db->getRows_One("select * from %s_comment where cid={$rid}")) { $r['kcontent'] = preg_replace("/\\[quote].*\\[\\/quote]/siU", '', $r['kcontent']); $ypost = "Originally posted by <i><b>" . ($r['username'] != '' ? $r['username'] : '******') . "</b></i> at " . kc_formatdate($r['ndate'], 'Y-m-d') . ":<br>"; $include = "<table border=0 width='100%' cellspacing=1 cellpadding=10 bgcolor='#cccccc'><tr><td width='100%' bgcolor='#FFFFFF' style='word-break:break-all'>" . $ypost . $r['kcontent'] . "</td></tr></table>"; $content = str_replace("[quote]" . $rid . "[/quote]", $include, $content); } } $tmp->assign('content', $content); $tmp->assign('ip', long2ip($rs['nip'])); $tmp->assign('date', $rs['ndate']); $s .= $tmp->output($inner); } return $s; }