function updatecache($array = '') { if (empty($array) || !is_array($array)) { updatecache_i(1); if (R_P == D_P || !file_exists(D_P . 'data/bbscache/config.php') || !file_exists(D_P . 'data/bbscache/dbreg.php')) { updatecache_c(); } updatecache_p(1); updatecache_w(); updatecache_sy(); updatecache_g(); updatecache_bk(); updatecache_df(); updatecache_ol(); updatecache_mddb(1); updatecache_ml(); updatecache_f(1); updatecache_l(1); updatecache_gr(1); updatecache_inv(); updatecache_plan(); updatecache_ftp(); updatecache_field(1); updatecache_form(); updatecache_help(); cache_read(); updatecache_hotforum(); updatecache_openforum(); updatecache_topic(); updatecache_postcate(); updateCacheActivity(); updatecache_conf('nf', false, 'newinfo_config.php'); //updateStampCache(); //updateBlockCache(); } else { foreach ($array as $value) { $value(); } } }
/** 添加帮助信息 * * @param int $hup 上级项目 * @param array/string $title 标题(数组时,则为批量添加),例如array('忘记密码','选择风格') 或者 '忘记密码' * @param array/string $content 内容,如果是数组的话,必须和标题键值一一对应,例如array('忘记密码','选择风格')或者 '忘记密码' * @param string $url 外链URL * @param int $hid 编辑或者删除时的帮助项ID * @param string $action 选择操作add,edit,delete * @return int/string 例如:25 或者 25,26 */ function insertHelp($hup = 0, $title, $content, $url = '', $hid = 0, $action = 'add') { //* @include_once pwCache::getPath(D_P.'data/bbscache/help_cache.php'); extract(pwCache::getData(D_P . 'data/bbscache/help_cache.php', false)); require_once R_P . 'admin/cache.php'; $hup = (int) $hup; $hid = (int) $hid; if ($action == 'add' || $action == 'edit') { $url = trim($url); if (is_array($title) && $action == 'add') { $titledb = $title; unset($title); $hids = ''; foreach ($titledb as $key => $title) { $title = trim($title); if (empty($title)) { return new ApiResponse('help_title_empty'); } $desc = ''; if (is_array($content)) { $desc = $content[$key]; } else { $desc = $content; } $desc = str_replace(array("\t", "\r", ' '), array(' ', '', ' '), trim($desc)); $lv = 0; $fathers = ''; foreach ($_HELP as $key => $value) { if (strtolower($title) == strtolower($value['title'])) { return new ApiResponse('help_title_exist'); } if ($key == $hup) { $lv = $value['lv'] + 1; $fathers = ($value['fathers'] ? "{$value['fathers']}," : '') . $hup; !$value['ifchild'] && $this->db->update("UPDATE pw_help SET ifchild='1' WHERE hid=" . S::sqlEscape($hup)); } } $this->db->update("INSERT INTO pw_help" . " SET " . S::sqlSingle(array('hup' => $hup, 'lv' => $lv, 'fathers' => $fathers, 'title' => $title, 'url' => $url, 'content' => $desc, 'vieworder' => 0))); $hid = $this->db->insert_id(); $hids .= $hids ? ',' . $hid : $hid; } } elseif (!is_array($title)) { $title = trim($title); if (empty($title)) { return new ApiResponse('help_title_empty'); } $content = str_replace(array("\t", "\r", ' '), array(' ', '', ' '), trim($content)); $lv = 0; $fathers = ''; if ($action == 'add') { foreach ($_HELP as $key => $value) { if (strtolower($title) == strtolower($value['title'])) { return new ApiResponse('help_title_exist'); } if ($key == $hup) { $lv = $value['lv'] + 1; $fathers = ($value['fathers'] ? "{$value['fathers']}," : '') . $hup; !$value['ifchild'] && $this->db->update("UPDATE pw_help SET ifchild='1' WHERE hid=" . S::sqlEscape($hup)); } } $this->db->update("INSERT INTO pw_help" . " SET " . S::sqlSingle(array('hup' => $hup, 'lv' => $lv, 'fathers' => $fathers, 'title' => $title, 'url' => $url, 'content' => $content, 'vieworder' => 0))); $hids = $this->db->insert_id(); } elseif ($action == 'edit') { if ($hid == $hup) { return new ApiResponse('hup_error1'); } if ($_HELP[$hid]['hup'] != $hup && strpos(",{$_HELP[$hup][fathers]},", ",{$hid},") !== false) { return new ApiResponse('hup_error2'); } foreach ($_HELP as $key => $value) { if ($key != $hid && strtolower($title) == strtolower($value['title'])) { return new ApiResponse('help_title_exist'); } } $this->db->update("UPDATE pw_help" . " SET " . S::sqlSingle(array('hup' => $hup, 'title' => $title, 'url' => $url, 'content' => $content, 'vieworder' => 0)) . " WHERE hid=" . S::sqlEscape($hid)); $hids = $hid; } } else { return new ApiResponse('help_title_error'); } updatecache_help(); return new ApiResponse($hids); } elseif ($action == 'delete' && $hid > 0) { $this->db->update("DELETE FROM pw_help WHERE hid=" . S::sqlEscape($hid) . 'OR hup=' . S::sqlEscape($hid)); updatecache_help(); return new ApiResponse(true); } else { return new ApiResponse('API_OPERATE_ERROR'); } }
updatecache_help(); adminmsg('operate_success'); } } elseif ($action == 'update') { InitGP(array('selid'), 'P', 2); foreach ($selid as $key => $value) { $value != $_HELP[$key]['vieworder'] && $db->update("UPDATE pw_help SET vieworder=" . pwEscape($value) . 'WHERE hid=' . pwEscape((int) $key)); } updatecache_help(); adminmsg('operate_success'); } elseif ($action == 'delete' && $hid > 0) { if ($_POST['step'] != '2') { $dtitle = $_HELP[$hid]['title']; } else { $db->update("DELETE FROM pw_help WHERE hid=" . pwEscape($hid) . 'OR hup=' . pwEscape($hid)); updatecache_help(); adminmsg('operate_success'); } } else { $listdb = $fathers = array(); $lv = isset($_HELP[$hid]['lv']) ? $_HELP[$hid]['lv'] + 1 : 0; $nav = ''; if ($_HELP[$hid]['title']) { $_HELP[$hid]['fathers'] && ($fathers = explode(',', $_HELP[$hid]['fathers'])); foreach ($fathers as $key) { $nav .= " » <a href=\"{$basename}&hid={$_HELP[$key][hid]}\"><b>{$_HELP[$key][title]}</b></a>"; } $nav .= " » <b>{$_HELP[$hid][title]}</b>"; } foreach ($_HELP as $key => $value) { if ($hid > 0 && strpos(",{$value['fathers']},", ",{$hid},") === false) {
function insertHelp($hup = 0, $subject, $content, $url = '', $hid = 0, $action = 'add') { //添加帮助信息 @(include_once D_P . 'data/bbscache/help_cache.php'); require_once R_P . 'admin/cache.php'; $hup = (int) $hup; $hid = (int) $hid; if ($action == 'add' || $action == 'edit') { $title = trim($title); $url = trim($url); $content = str_replace(array("\t", "\r", ' '), array(' ', '', ' '), trim($content)); if (empty($title)) { return new ApiResponse('help_title_empty'); } $lv = 0; $fathers = ''; if ($action == 'add') { foreach ($_HELP as $key => $value) { if (strtolower($title) == strtolower($value['title'])) { return new ApiResponse('help_title_exist'); } if ($key == $hup) { $lv = $value['lv'] + 1; $fathers = ($value['fathers'] ? "{$value['fathers']}," : '') . $hup; !$value['ifchild'] && $this->db->update("UPDATE pw_help SET ifchild='1' WHERE hid=" . pwEscape($hup)); } } $this->db->update("INSERT INTO pw_help" . " SET " . pwSqlSingle(array('hup' => $hup, 'lv' => $lv, 'fathers' => $fathers, 'title' => $title, 'url' => $url, 'content' => $content, 'vieworder' => 0))); $hid = $this->db->insert_id(); } elseif ($action == 'edit') { if ($hid == $hup) { return new ApiResponse('hup_error1'); } if ($_HELP[$hid]['hup'] != $hup && strpos(",{$_HELP[$hup][fathers]},", ",{$hid},") !== false) { return new ApiResponse('hup_error2'); } foreach ($_HELP as $key => $value) { if ($key != $hid && strtolower($title) == strtolower($value['title'])) { return new ApiResponse('help_title_exist'); } } $this->db->update("UPDATE pw_help" . " SET " . pwSqlSingle(array('hup' => $hup, 'title' => $title, 'url' => $url, 'content' => $content, 'vieworder' => 0)) . " WHERE hid=" . pwEscape($hid)); } updatecache_help(); return new ApiResponse($hid); } elseif ($action == 'delete') { $this->db->update("DELETE FROM pw_help WHERE hid=" . pwEscape($hid) . 'OR hup=' . pwEscape($hid)); updatecache_help(); return new ApiResponse(true); } }