www.gusucode.com > ShopEx481 & PHPWind 整合版码程序 > bbs/admin/help.php
<?php !function_exists('adminmsg') && exit('Forbidden'); $basename = "$admin_file?adminjob=help"; @include_once(D_P.'data/bbscache/help_cache.php'); if ($action=='add' || $action=='edit') { InitGP(array('hid','hup')); $hid = (int)$hid; $hup = (int)$hup; if ($_POST['step']!='2') { $helpslt = ''; $action=='add' && !$hup && $hup = $hid; foreach ($_HELP as $value) { $add = $slted = ''; for ($i=0;$i<$value['lv'];$i++) { $add .= ' '; } $hup>0 && $value['hid']==$hup && $slted = 'SELECTED'; $helpslt .= "<option value=\"$value[hid]\" $slted>$add$value[title]</option>"; } $title = $content = $vieworder = $url = ''; if ($action!='add') { @extract($_HELP[$hid]); if ($ifcontent) { @extract($db->get_one("SELECT content FROM pw_help WHERE hid='$hid'")); $content = htmlspecialchars($content); } } } else { InitGP(array('vieworder','title','content','url'),'P'); $title = Char_cv(trim($title)); $url = Char_cv(trim($url)); $content = str_replace( array("\t","\r",' '), array(' ','',' '), trim($content) ); empty($title) && adminmsg('help_empty'); $lv = 0; $fathers = ''; $vieworder = (int)$vieworder; if ($action=='add') { foreach ($_HELP as $key => $value) { strtolower($title)==strtolower($value['title']) && adminmsg('help_title'); if ($key==$hup) { $lv = $value['lv']+1; $fathers = ($value['fathers'] ? "$value[fathers]," : '').$hup; !$value['ifchild'] && $db->update("UPDATE pw_help SET ifchild='1' WHERE hid='$hup'"); } } $db->update("INSERT INTO pw_help (hup,lv,fathers,title,url,content,vieworder) VALUES ('$hup','$lv','$fathers','$title','$url','$content','$vieworder')"); } else { $hid==$hup && adminmsg('hup_error1'); $_HELP[$hid]['hup']!=$hup && strpos(",{$_HELP[$hup][fathers]},",",$hid,")!==false && adminmsg('hup_error2'); foreach ($_HELP as $key => $value) { $key!=$hid && strtolower($title)==strtolower($value['title']) && adminmsg('help_title'); } $db->update("UPDATE pw_help SET hup='$hup',title='$title',url='$url',content='$content',vieworder='$vieworder' WHERE hid='$hid'"); } updatecache_help(); adminmsg('operate_success'); } } elseif ($action=='update') { $selid = $_POST['selid']; foreach ($selid as $key => $value) { $value = (int)$value; $value!=$_HELP[$key]['vieworder'] && $db->update("UPDATE pw_help SET vieworder='$value' WHERE hid='".(int)$key."'"); } updatecache_help(); adminmsg('operate_success'); } elseif ($action=='delete' && ($hid = (int)GetGP('hid')) > 0) { if ($_POST['step']!='2') { $dtitle = $_HELP[$hid]['title']; } else { $db->update("DELETE FROM pw_help WHERE hid='$hid' OR hup='$hid'"); updatecache_help(); adminmsg('operate_success'); } } else { $listdb = $fathers = array(); $hid = (int)$_GET['hid']; $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) { continue; } if ($lv+2>$value['lv']) { $value['add'] = ''; for ($i=$lv;$i<$value['lv'];$i++) { $value['add'] = ' '; } $listdb[$key] = array('hid' => $value['hid'],'hup' => $value['hup'],'fathers' => $value['fathers'],'ifchild' => $value['ifchild'],'order' => $value['vieworder'],'title' => $value['title'],'add' => $value['add']); } } unset($_HELP); } include PrintEot('help');exit; ?>