/** 清理多余的临时验证码文件 @return void */ public function Clear() { global $king; $array = kc_f_getdir(PATH_CACHE . '/verify', 'php'); foreach ($array as $val) { $filetime = filemtime(ROOT . PATH_CACHE . '/verify/' . $val); //读取文件日期 if ($filetime < time() - $king->config('verifytime')) { //如果文件日期小于给定的日期,则删除 kc_f_delete(PATH_CACHE . '/verify/' . $val); } } }
/** 删除文件夹/删除目录 @papram string $path; 要删除的文件夹路径 @return void */ function kc_f_rd($path, $is = 0) { $path = kc_f_iconv($path, 1); if (!is_dir(ROOT . $path)) { return; } $array = kc_f_getdir($path); foreach ($array as $val) { $file = $path . '/' . $val; if ($val != '') { if (is_dir(ROOT . $file)) { //目录 kc_f_rd($file, 1); rmdir(ROOT . $file); } else { kc_f_delete($file); } } } if (!$is && is_dir(ROOT . $path)) { rmdir(ROOT . $path); } }
function king_edt() { global $king; $king->access('portal_content_edt'); //初始化 $listid = kc_get('listid', 2, 1); //$info['listid']; $info = $king->portal->infoList($listid); $model = $king->portal->infoModel($info['modelid']); // kc_error('<pre>'.print_r($array_field,1)); $kid = kc_get('kid', 2); $kid1 = kc_get('kid1', 2); $isadmin = $kid1 ? 'isadmin2' : 'isadmin1'; //次页:首页 $array_field = array_keys($model['field'][$isadmin]); $sql_field = implode(',', $array_field); //[tablemodel]字段调用 // $listid=kc_get('listid',2); if ($GLOBALS['ismethod'] || $kid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $data['kpath'] = $king->portal->depathMode($info); $data['nshow'] = 1; $array_field_default = $model['field']['default']; foreach ($array_field_default as $key => $val) { $data[$key] = $val; } } } else { //编辑数据,从数据库读出 if (!($data = $king->db->getRows_one('select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;'))) { kc_error($king->lang->get('system/error/param') . '<br/>select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;' . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__); } } $data = kc_data($array_field, $data); $data['kid'] = $kid; if (!($res = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isadmin}=1 and kid1=0 order by norder,kid;"))) { //全部调用 $res = array(); } $s = $king->openForm('manage.content.php?action=edt'); $s .= kc_htm_hidden(array('listid' => $listid, 'kid' => $kid, 'kid1' => $kid1)); //这个隐藏域不要放在下面 //kc_error("select * from %s_field where modelid={$info['modelid']} and {$isshow}=1 and kid1=0 order by norder,kid;"); //kc_error('<pre>'.print_r($res,1)); foreach ($res as $rs) { $s .= $king->portal->formdecode($rs, $data, $info, 1, $kid1 ? 2 : 1); } $s .= $king->htmForm($king->lang->get('portal/common/exp'), kc_htm_checkbox('pag', array(1 => $king->lang->get('portal/goto/addpag')), kc_post('pag'))); $s .= $king->closeForm('save'); //数据处理 if ($GLOBALS['ischeck']) { $_array = array(); //设置为空数组 //收集字段的值 foreach ($array_field as $val) { if (in_array($val, array('nshow', 'nhead', 'ncommend', 'nup', 'nfocus', 'nhot')) || array_key_exists($val, $model['field']['offon'])) { //增加判断offon $_array[$val] = $data[$val] ? 1 : 0; } else { if (is_array($data[$val])) { $_array[$val] = implode(',', $data[$val]); } else { $_array[$val] = $data[$val]; } //抓图和过滤链接 if ($val == 'kcontent') { if (kc_post('isgrab')) { //抓图 $_array[$val] = kc_grab($_array[$val]); } if (kc_post('isremovea')) { //过滤链接 $_array[$val] = preg_replace('/<a ([^>]*)>|<\\/a>/is', '', $_array[$val]); } if (kc_post('isremovetable')) { //过滤表格 $_array[$val] = preg_replace('/<(table|tbody|thead|tr|td|th|caption) ?([^>]*)>|<\\/(table|tbody|thead|tr|td|th|caption)>/is', '', $_array[$val]); } if (kc_post('isremovestyle')) { //过滤样式 $_array[$val] = preg_replace('/(<([^>]*))( style=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]); } if (kc_post('isremoveid')) { //过滤样式 $_array[$val] = preg_replace('/(<([^>]*))( id=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]); } if (kc_post('isremoveclass')) { //过滤样式 $_array[$val] = preg_replace('/(<([^>]*))( class=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]); } } } } if (in_array('kimage', $_array) && in_array('kcontent', $_array)) { //如果有选择第一个图作为缩略图 并 kimage在列表里 if (kc_post('isoneimage')) { //抓第一张图为缩略图 if ($oneimage = preg_match('/(<img([^>]*))( src=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', $_array['kcontent'], $oneimage_array)) { $smartimg = $oneimage_array[5]; if (is_file(ROOT . substr($smartimg, strlen($king->config('inst'))))) { //判断是否为本地文件 $_array['kimage'] = substr($smartimg, strlen($king->config('inst'))); } else { //若是远程文件,则抓取 if ($path = kc_grab_get($smartimg)) { //抓取成功 if ($path != $smartimg) { //值不一样,说明抓取成功 $_array['kimage'] = $path; } } } } } } //listid & kid1 $_array['listid'] = $data['listid']; $_array['kid1'] = $data['kid1'] ? $data['kid1'] : 0; /** 检查kpath是否在键名列表里,如果有则判断是否为空值 如果没有,则补充 */ if (empty($_array['kpath'])) { $_array['kpath'] = $king->portal->depathMode($info); } /** 检查kkeywords,如果没有,则自动补充其值 如果有,则更新列表 */ $_array['kkeywords'] = !empty($data['kkeywords']) ? $king->portal->getKey($_array['ktitle'], $_array['kkeywords']) : $king->portal->getKey($_array['ktitle']); /** 关键字替换功能的实现概论 从$_array['kkeywords']中获得关键字列表,从预置的[关键字链接页/待做的表]中查找相关关键字 kname 关键字 kkeywords 关键字相关关键字 kpath 关键字链接网址 preg_replace('',$rs['kpath'],$_array['kcontent'],1); */ /** 检查ktag,如果没有,则自动补充其值 如果有,则更新列表 */ $_array['ktag'] = !empty($data['ktag']) ? $king->portal->getTag($_array['ktitle'], $_array['ktag']) : $king->portal->gettag($_array['ktitle']); /** 如果description值为空,则从content中获取 */ if (empty($data['kdescription']) && !empty($data['kcontent'])) { $kdescription = strip_tags($data['kcontent']); $kdescription = preg_replace('/(\\&[a-z]{1,6};)|\\s/', '', $kdescription); $_array['kdescription'] = kc_substr($kdescription, 0, 200); } //副标题长度 $_array['nsublength'] = isset($data['ksubtitle']) ? kc_strlen($data['ksubtitle']) : 0; //更新时间 $_array['nlastdate'] = time(); //如果有kid1值,则对kid1对应的nlastdate进行更新 if ($kid1) { $king->db->update('%s__' . $model['modeltable'], array('nlastdate' => time()), 'kid=' . $kid1); } //图片框写远程路径的时候,抓图 foreach ($model['field']['image'] as $key => $val) { if (isset($_array[$key])) { //当有image类型的字段的时候,检查一下其值 if (kc_validate($_array[$key], 6)) { //若为网址类型的话,自动抓图到本地 $_array[$key] = kc_grab_get($_array[$key]); } } } //添加&更新数据 if ($kid) { //update $king->db->update('%s__' . $model['modeltable'], $_array, 'kid=' . $kid); $_nlog = 7; } else { $_array['ndate'] = time(); $_array['adminid'] = $king->admin['adminid']; $_array['userid'] = -1; $_array['norder'] = $king->db->neworder('%s__' . $model['modeltable']); //不同的浏览器不同的分页标签,前台不支持 switch (strtolower($king->admin['admineditor'])) { case 'fckeditor': $pagebreak = '<div style="page-break-after: always"><span style="display: none"> </span></div>'; break; case 'tiny_mce': $pagebreak = '<!-- pagebreak -->'; break; case 'edit_area': $pagebreak = '<!-- pagebreak -->'; break; } if (isset($pagebreak) && isset($_array['kcontent'])) { $array = explode($pagebreak, $_array['kcontent']); foreach ($array as $key => $val) { $_array['kcontent'] = $val; $_array['norder']++; if ($key === 0) { //第一个 $kid = $king->db->insert('%s__' . $model['modeltable'], $_array); } else { $_array['kpath'] = $king->portal->depathMode($info); $_array['kid1'] = $data['kid1'] ? $data['kid1'] : $kid; $king->db->insert('%s__' . $model['modeltable'], $_array); } } } else { $kid = $king->db->insert('%s__' . $model['modeltable'], $_array); } $_nlog = 5; if ($kid == 0) { kc_error($king->lang->get('system/error/insert') . kc_clew(__FILE__, __LINE__, nl2br(print_r($_array, 1)))); } } //更新列表信息 $king->portal->lastUpdated($listid, 'list'); //删除缓存重建缓存 $king->cache->del('portal/list/' . $listid); kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid, 1, '/', 1) . '.xml'); $id = $king->portal->infoID($listid, $kid); if ($kid1) { kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid1, 1, '/', 1) . '.xml'); $id = $king->portal->infoID($listid, $kid1); } //生成操作 if ($info['npage'] == 0) { if ($info['npagenumber'] == 1) { $king->portal->createPage($listid, $kid1 ? $kid1 : $kid); //$listid,$kid,$pid=1,$is=null $subkid = $id['subkid']; if ($subkid) { $subid = explode(',', $subkid); foreach ($subid as $sid) { $king->portal->createPage($listid, $sid); } } } else { $pcount = ceil($id['ncount'] / $info['npagenumber']); for ($i = 1; $i <= $pcount; $i++) { $king->portal->createPage($listid, $kid1 ? $kid1 : $kid, $i); } } } //写log $king->log($_nlog, $model['modeltable'] . ':' . $data['ktitle']); // if(kc_post('pag')[0]==1){ if (kc_post('pag') == 1) { $s = kc_goto($king->lang->get('system/goto/saveok'), 'manage.content.php?action=edtpag&listid=' . $data['listid'] . '&kid1=' . ($kid1 ? $kid1 : $kid)); } else { if ($kid1) { kc_goto($king->lang->get('system/goto/is'), 'manage.content.php?action=edtpag&listid=' . $data['listid'] . '&kid1=' . $kid1, 'manage.content.php?action=pag&listid=' . $data['listid'] . '&kid1=' . $kid1); } else { kc_goto($king->lang->get('system/goto/is'), 'manage.content.php?action=edt&listid=' . $data['listid'], 'manage.content.php?listid=' . $data['listid']); } } } list($left, $right) = king_inc_list(); $king->skin->output($info['ktitle'], $left, $right, $s); }
function king_edt() { global $king; $king->access("portal_tag_edt"); $kid = kc_get('kid'); $_sql = 'ktag,kimage,kkeywords,kdescription,kcolor,nsize,isbold,iscommend,ktemplate1,ktemplate2'; if ($GLOBALS['ismethod'] || $kid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $data['kcolor'] = '#000000'; $data['nsize'] = 12; $tpath = $king->config('templatepath'); $tdefa = $king->config('templatedefault'); $ktemplate1 = $tpath . '/' . $tdefa; $data['ktemplate1'] = is_file(ROOT . $ktemplate1) ? $ktemplate1 : ''; $ktemplate2 = $tpath . '/inside/tag/' . $tdefa; $data['ktemplate2'] = is_file(ROOT . $ktemplate2) ? $ktemplate2 : ''; } } else { //编辑数据,从数据库读出 $data = $king->db->getRows_one('select ' . $_sql . ' from %s_tag where kid=' . $kid . ' limit 1;'); } $fields = explode(',', $_sql); $data = kc_data($fields, $data); $s = $king->openForm('manage.tag.php?action=edt'); //ktag $_array = array(array('ktag', 0, 1, 100)); $kid ? array_push($_array, array('ktag', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select kid from %s_tag where ktag='" . $king->db->escape($data['ktag']) . "' and kid<>{$kid};"))) : array_push($_array, array('ktag', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select kid from %s_tag where ktag='" . $king->db->escape($data['ktag']) . "';"))); $s .= $king->htmForm($king->lang->get('portal/label/ktag') . ' (1-100)', '<input class="k_in w200" type="text" name="ktag" value="' . htmlspecialchars($data['ktag']) . '" maxlength="100" />', $_array); //kkeywords $_array = array(array('kkeywords', 0, 0, 100)); $s .= $king->htmForm($king->lang->get('system/common/keywords') . ' (0-100)', '<input class="k_in w400" type="text" name="kkeywords" value="' . htmlspecialchars($data['kkeywords']) . '" maxlength="100" />', $_array); //kdescription $_array = array(array('kdescription', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('system/common/description') . ' (0-255)', '<textarea rows="4" cols="100" class="k_in w400" name="kdescription" maxlength="255" >' . htmlspecialchars($data['kdescription']) . '</textarea>', $_array); //kimage $_array = array(array('kimage', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('system/common/image') . ' (0-255)', '<input class="k_in w400" type="text" id="kimage" name="kimage" value="' . htmlspecialchars($data['kimage']) . '" maxlength="255" />' . kc_f_brow('kimage', $king->config('uppath') . '/image', 0), $_array); //iscommend $data['iscommend'] == 1 ? $checked = 'checked="checked"' : ($checked = ''); $str = '<span><input type="checkbox" name="iscommend" id="iscommend" value="1" ' . $checked . '/><label for="iscommend">' . $king->lang->get('portal/label/attrib/iscommend') . '</label></span>'; $s .= $king->htmForm($king->lang->get('system/common/attrib'), $str); //kcolor,nsize,isbold $_array = array(array('kcolor', 0, 7, 7), array('nsize', 0, 1, 2), array('nsize', 2), array('kcolor', 13)); $str = '<span><input type="text" class="k_in w60" name="nsize" value="' . $data['nsize'] . '" maxlength="2"/><label> px</label>'; $data['isbold'] == 1 ? $checked = 'checked="checked"' : ($checked = ''); $str .= ' <input type="checkbox" name="isbold" id="isbold" value="1" ' . $checked . '/><label for="isbold">' . $king->lang->get('portal/label/bold') . '</label>'; $str .= ' <label for="kcolor">' . $king->lang->get('portal/label/kcolor') . ':</label><input class="k_in w50" type="text" id="kcolor" name="kcolor" value="' . htmlspecialchars($data['kcolor']) . '" maxlength="7"' . (kc_validate($data['kcolor'], 13) ? ' style="background:' . $data['kcolor'] . '"' : '') . ' />' . kc_f_color('kcolor', $data['kcolor']) . '</span>'; $s .= $king->htmForm($king->lang->get('system/common/style'), $str, $_array); //ktemplate1 $_array = array(array('ktemplate1', 0, 5, 255), array('ktemplate1', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatetag1') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplate1" id="ktemplate1" value="' . htmlspecialchars($data['ktemplate1']) . '" maxlength="255" />' . kc_f_brow('ktemplate1', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455), $_array); //ktemplate2 $_array = array(array('ktemplate2', 0, 5, 255), array('ktemplate2', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatetag2') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplate2" id="ktemplate2" value="' . htmlspecialchars($data['ktemplate2']) . '" maxlength="255" />' . kc_f_brow('ktemplate2', $king->config('templatepath') . '/inside/tag', 2), $_array); $s .= kc_htm_hidden(array('kid' => $kid)); $s .= $king->closeForm('save'); if ($GLOBALS['ischeck']) { $array = array(); $array_sql = explode(',', $_sql); $data['isbold'] == 1 ? $data['isbold'] = 1 : ($data['isbold'] = 0); $data['iscommend'] ? $data['iscommend'] = 1 : ($data['iscommend'] = 0); foreach ($array_sql as $val) { $array += array($val => $data[$val]); } /** 检查kkeywords,如果没有,则自动补充其值 如果有,则更新列表 */ if (!$array['kkeywords']) { $array += array('kkeywords' => $king->portal->getkey($array['ktag'])); } else { $array['kkeywords'] = $king->portal->getkey($array['ktag'], $array['kkeywords']); } if ($kid) { //update $king->db->update('%s_tag', $array, 'kid=' . $kid); $nlog = 7; } else { //insert $array += array('norder' => $king->db->neworder('%s_tag')); $king->db->insert('%s_tag', $array); $nlog = 5; } $md5path = preg_replace('/(\\w{2})(\\w+)/', "\$1/\$2", md5($data['ktag'])); $xmlpath = $king->config('xmlpath', 'portal') . '/portal/tag/' . $md5path . '.xml'; kc_f_delete($xmlpath); //写log $king->log($nlog, 'Tag:' . $data['ktag']); kc_goto($king->lang->get('system/goto/is'), 'manage.tag.php?action=edt', 'manage.tag.php'); } list($left, $right) = king_inc_list(); $king->skin->output($king->lang->get('portal/title/tag' . ($kid ? 'edt' : 'add')), $left, $right, $s); }
/** 删除文件 */ function king_ajax_delete_browfile() { global $king; $king->access('#brow_delfile'); $file = ''; //可以不定义,但是在编辑器报错 $info = inc_brow(); $path = ''; extract($info); kc_f_delete($path . $file); $js = "\$.kc_ajax({{$verbs},CMD:'brow_right',path:'{$path}',ID:'browright'});"; //调用右侧文件列表 kc_ajax('', '', '', $js); }
function king_edt() { global $king; $king->load('user'); //初始化zf $listid = kc_get('listid', 2, 1); //$info['listid']; $info = $king->portal->infoList($listid); $model = $king->portal->infoModel($info['modelid']); $kid = kc_get('kid', 2); $kid1 = kc_get('kid1', 2); $isuser = $kid1 ? 'isuser2' : 'isuser1'; //次页:首页 $array_field = array_keys($model['field'][$isuser]); $sql_field = implode(',', $array_field); //[tablemodel]字段调用 //读取管理员列表 $editors = $king->portal->getListEditor($listid); if (!is_array($editors)) { $editors = array(); } //用户权限及登录验证 if ($info['gidpublish'] == -1) { $user = array('userid' => 0, 'username' => '[' . $king->lang->get('user/name/guest') . ']'); } else { $user = $king->user->access(); if (!in_array($king->user->userid, $editors) && $info['gidpublish']) { //非栏目编辑 并 限制组会员 ;栏目编辑员则跳过此验证 $king->user->access($info['gidpublish']); } } //发帖验证,检查是否为不允许发布 //0不允许发布|1直接发布|2验证后发布 if (!in_array($user['userid'], $editors)) { //栏目编辑员无需验证 if ((int) $info['ispublish' . ($kid1 ? 2 : 1)] === 0) { $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/stop')); } } //当kid有值的时候(编辑),进行所有权验证 if ($kid) { $user = empty($user) ? $king->user->access() : $user; //如果$user为null则进行登录验证,目的是要获得userid $id = $king->portal->infoID($listid, $kid); if (in_array($king->user->userid, $editors) || (int) $id['userid'] === (int) $king->user->userid) { if (!in_array($king->user->userid, $editors)) { //如果不是栏目管理员,则进行有效期验证 if (time() - $model['nlocktime'] * 3600 > $id['ndate'] && (int) $model['nlocktime'] !== 0) { //如果超过可允许编辑时间期限 并 可编辑时间不能为0,则提示错误 $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/timeout')); } } } else { $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/noaccess')); } } $fields = explode(',', $sql_field); if ($GLOBALS['ismethod'] || $kid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $data['kpath'] = $king->portal->depathMode($info); $data['nshow'] = 1; $array_field_default = $model['field']['default']; foreach ($array_field_default as $key => $val) { $data[$key] = $val; } //从URL中获取初始值 foreach ($fields as $val) { if (isset($_GET[$val])) { $data[$val] = $_GET[$val]; } } } } else { //编辑数据,从数据库读出 //判断是否为栏目编辑 或 所有人 if (!($data = $king->db->getRows_one('select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;'))) { kc_error($king->lang->get('system/error/param') . '<br/>select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;' . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__); } } $data = kc_data($fields, $data); $data['kid'] = $kid; if (!($res = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isuser}=1 and kid1=0 order by norder,kid;"))) { //全部调用 $res = array(); } $s = $king->openForm('index.php?action=edt'); $s .= kc_htm_hidden(array('listid' => $listid, 'kid' => $kid, 'kid1' => $kid1)); //这个隐藏域不要放在下面 foreach ($res as $rs) { $s .= $king->portal->formdecode($rs, $data, $info, 0, $kid1 ? 2 : 1); } $s .= $king->closeForm($king->lang->get('system/common/publish')); //数据处理 if ($GLOBALS['ischeck']) { $_array = array(); //设置为空数组 //收集字段的值 foreach ($array_field as $val) { if (substr($val, 0, 1) == 'n') { $_array[$val] = $data[$val] ? 1 : 0; } else { if (is_array($data[$val])) { $_array[$val] = implode(',', $data[$val]); } else { $_array[$val] = $data[$val]; } } } //listid & kid1 $_array['listid'] = $data['listid']; $_array['kid1'] = $data['kid1'] ? $data['kid1'] : 0; /** 检查kpath是否在键名列表里,如果有则判断是否为空值 如果没有,则补充 */ if (empty($_array['kpath'])) { $_array['kpath'] = $king->portal->depathMode($info); } /** 检查kkeywords,如果没有,则自动补充其值 如果有,则更新列表 */ $_array['kkeywords'] = !empty($data['kkeywords']) ? $king->portal->getKey($_array['ktitle'], $_array['kkeywords']) : $king->portal->getKey($_array['ktitle']); /** 检查ktag,如果没有,则自动补充其值 如果有,则更新列表 */ $_array['ktag'] = !empty($data['ktag']) ? $king->portal->getTag($_array['ktitle'], $_array['ktag']) : $king->portal->gettag($_array['ktitle']); /** 如果description值为空,则从content中获取 */ if (empty($data['kdescription']) && !empty($data['kcontent'])) { $kdescription = strip_tags($data['kcontent']); $kdescription = preg_replace('/\\&[a-z]{1,6};/', '', $kdescription); $_array['kdescription'] = kc_substr($kdescription, 0, 200); } //副标题长度 $_array['nsublength'] = isset($data['ksubtitle']) ? kc_strlen($data['ksubtitle']) : 0; //更新时间 $_array['nlastdate'] = time(); //如果有kid1值,则对kid1对应的nlastdate进行更新 if ($kid1) { $king->db->update('%s__' . $model['modeltable'], array('nlastdate' => time()), 'kid=' . $kid1 . ' limit 1'); } //添加&更新数据 if ($kid) { //update $king->db->update('%s__' . $model['modeltable'], $_array, 'kid=' . $kid); $_nlog = 7; } else { $_array['ndate'] = time(); $_array['norder'] = $king->db->neworder('%s__' . $model['modeltable']); $_array['userid'] = $user['userid']; $_array['nshow'] = $info['ispublish' . ($kid1 ? 2 : 1)]; $kid = $king->db->insert('%s__' . $model['modeltable'], $_array); $_nlog = 5; if ($kid == 0) { kc_error($king->lang->get('system/error/insert') . kc_clew(__FILE__, __LINE__, nl2br(print_r($_array, 1)))); } } //更新列表信息 $king->portal->lastUpdated($listid, 'list'); //删除缓存重建缓存 $king->cache->del('portal/list/' . $listid); kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid, 1, '/', 1) . '.xml'); $id = $king->portal->infoID($listid, $kid); if ($kid1) { kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid1, 1, '/', 1) . '.xml'); $id = $king->portal->infoID($listid, $kid1); } //生成操作 if ($info['npage'] == 0) { if ($info['npagenumber'] == 1) { $king->portal->createPage($listid, $kid1 ? $kid1 : $kid); //$listid,$kid,$pid=1,$is=null $subkid = $id['subkid']; if (isset($subkid)) { $subid = explode(',', $subkid); foreach ($subid as $sid) { $king->portal->createPage($listid, $sid); } } } else { $pcount = ceil($id['ncount'] / $info['npagenumber']); for ($i = 1; $i <= $pcount; $i++) { $king->portal->createPage($listid, $kid1 ? $kid1 : $kid, $i); } } } //跳转,当留言反馈类型的时候,这个跳转需要改动 echo "<script type=\"text/javascript\">parent.location='" . $king->portal->pathPage($info, $id['kid'], $id['kpath']) . "'</script>"; } $tmp = new KC_Template_class($model['ktemplatepublish']); $tmp->assign('inside', $s); $tmp->assign('listid', $listid); $tmp->assign('title', $info['klistname']); $tmp->assign('type', 'edit'); echo $tmp->output(); // list($left,$right)=king_inc_list(); // $king->skin->output($king->lang->get('portal/title/content'.($kid?'edt':'add')),$left,$right,$s); }
/** 删除缓存文件 @param string $path 路径 */ public function del($path) { $path = strtolower($path); kc_f_delete(PATH_CACHE . '/' . $path . '.php'); }
/** 删除文件或文件夹 */ function king_ajax_delete() { global $king; $king->access('webftp_delete'); $isdir = kc_post('isdir', 2, 1); $path = kc_post('path'); $file = kc_post('file', 0, 1); if ($isdir) { kc_f_rd($path . $file); } else { kc_f_delete($path . $file); } $js = "\$('#k_brow_right_" . _path2id($path . $file) . "').remove();"; //删除右侧内容 $js .= "\$('#k_brow_obj_" . _path2id($path . $file) . "').remove();"; //同步删除左侧显示内容 $cachepath = "system/filemanage/{$path}index"; $king->cache->del($cachepath); //清理缓存 kc_ajax('', kc_icon('a1'), '', $js); }
function king_ajax_delete() { global $king; $king->access('portal_list_delete'); $_list = kc_getlist(); $_array = explode(',', $_list); foreach ($_array as $val) { $listid = $val['listid']; $info = $king->portal->infoList($listid); $model = $king->portal->infoModel($info['modelid']); //删除栏目下面的内容 if ($info['modelid'] > 0) { if ($info['npage'] == 0) { //删除静态页面 if (!($res = $king->db->getRows("select kid,kpath from %s__{$model['modeltable']} where listid={$listid};"))) { $res = array(); } foreach ($res as $rs) { //删除文件,不包含目录,目录用清理空目录的方式去处理 kc_f_delete($king->getfpath($rs['kpath'])); //删除缓存文件 $king->cache->del('portal/_' . $model['modeltable'] . '/' . ceil($rs['kid'] / 1024) . '/' . $rs['kid']); } } //删除数据库中的内容 $king->db->query("delete from %s__{$model['modeltable']} where listid={$listid};"); //删除单页文件列和表文件 kc_f_delete($king->getfpath($info['klistpath'])); kc_f_rd($info['klistpath']); } //删除缓存文件 $king->cache->del('portal/list/' . $listid); //写log $king->log(6, 'ListName:' . $info['klistname']); } $king->db->query("delete from %s_list where listid in ({$_list}) and isexist=0;"); //删除缓存 $king->cache->del('portal/list/id'); $king->cache->rd('system/cache'); kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/ok/delete') . "</p>", 1); }