| 1 | <?php |
|---|
| 2 | // $Id: index.php,v 1.6 2005/09/04 20:46:11 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // Based on: // |
|---|
| 9 | // myPHPNUKE Web Portal System - http://myphpnuke.com/ // |
|---|
| 10 | // PHP-NUKE Web Portal System - http://phpnuke.org/ // |
|---|
| 11 | // Thatware - http://thatware.org/ // |
|---|
| 12 | // ------------------------------------------------------------------------- // |
|---|
| 13 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 14 | // it under the terms of the GNU General Public License as published by // |
|---|
| 15 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 16 | // (at your option) any later version. // |
|---|
| 17 | // // |
|---|
| 18 | // You may not change or alter any portion of this comment or credits // |
|---|
| 19 | // of supporting developers from this source code or any supporting // |
|---|
| 20 | // source code which is considered copyrighted (c) material of the // |
|---|
| 21 | // original comment or credit authors. // |
|---|
| 22 | // // |
|---|
| 23 | // This program is distributed in the hope that it will be useful, // |
|---|
| 24 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 26 | // GNU General Public License for more details. // |
|---|
| 27 | // // |
|---|
| 28 | // You should have received a copy of the GNU General Public License // |
|---|
| 29 | // along with this program; if not, write to the Free Software // |
|---|
| 30 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 31 | // ------------------------------------------------------------------------ // |
|---|
| 32 | include '../../../include/cp_header.php'; |
|---|
| 33 | if ( file_exists("../language/".$xoopsConfig['language']."/main.php") ) { |
|---|
| 34 | include "../language/".$xoopsConfig['language']."/main.php"; |
|---|
| 35 | } else { |
|---|
| 36 | include "../language/english/main.php"; |
|---|
| 37 | } |
|---|
| 38 | /*********************************************************/ |
|---|
| 39 | /* Sections Manager Functions */ |
|---|
| 40 | /*********************************************************/ |
|---|
| 41 | |
|---|
| 42 | function sections() { |
|---|
| 43 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
|---|
| 44 | xoops_cp_header(); |
|---|
| 45 | echo "<h4>"._AM_SECCONF."</h4>"; |
|---|
| 46 | $result = $xoopsDB->query("select secid, secname from ".$xoopsDB->prefix("sections")." order by secid"); |
|---|
| 47 | if ($xoopsDB->getRowsNum($result) > 0) { |
|---|
| 48 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 49 | echo "<hr /> |
|---|
| 50 | <b><center>"._MD_CURACTIVESEC."</b><br />"._MD_CLICK2EDIT."<br /> |
|---|
| 51 | <table border='0' width='100%' align='center' cellpadding='1'><tr><td align='center'>"; |
|---|
| 52 | echo "<ul>"; |
|---|
| 53 | while(list($secid, $secname) = $xoopsDB->fetchRow($result)) { |
|---|
| 54 | $secname=$myts->makeTboxData4Show($secname); |
|---|
| 55 | echo "<li><a href=\"index.php?op=sectionedit&secid=".$secid."\">".$secname."</a></li>"; |
|---|
| 56 | } |
|---|
| 57 | echo "</ul>"; |
|---|
| 58 | echo "</td></tr></table>"; |
|---|
| 59 | ?> |
|---|
| 60 | <br /> |
|---|
| 61 | <hr /><h4><?php echo _MD_ADDARTICLE; ?></h4> |
|---|
| 62 | <br /><br /> |
|---|
| 63 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?><br /> |
|---|
| 64 | <b><?php echo _MD_TITLEC; ?></b><br /> |
|---|
| 65 | <input class=textbox type="text" name="title" size=60 value=""><br /><br /> |
|---|
| 66 | <?php |
|---|
| 67 | $result = $xoopsDB->query("select secid, secname from ".$xoopsDB->prefix("sections")." order by secid"); |
|---|
| 68 | $checked = " checked='checked'"; // select first section by default |
|---|
| 69 | while(list($secid, $secname) = $xoopsDB->fetchRow($result)) { |
|---|
| 70 | $secname=$myts->makeTboxData4Show($secname); |
|---|
| 71 | echo "<input type='radio' name='secid' value='$secid'$checked />$secname<br />"; |
|---|
| 72 | $checked = ''; |
|---|
| 73 | } ?> |
|---|
| 74 | <br /> |
|---|
| 75 | <b><?php echo _MD_CONTENTC; ?></b><br /> |
|---|
| 76 | <textarea class="textbox" name="content" cols="60" rows="10"></textarea><br /><br /> |
|---|
| 77 | <?php echo _MULTIPAGE ?><br/><br /> |
|---|
| 78 | <input type="hidden" name="op" value="secarticleadd" /> |
|---|
| 79 | <input type="submit" value="<?php echo _MD_DOADDARTICLE; ?>" /> |
|---|
| 80 | </form> |
|---|
| 81 | <br /> |
|---|
| 82 | <hr /><h4><?php echo _MD_LAST20ART; ?></h4> |
|---|
| 83 | <br /><br /> |
|---|
| 84 | <ul> |
|---|
| 85 | <?php |
|---|
| 86 | $result = $xoopsDB->query("select artid, secid, title from ".$xoopsDB->prefix("seccont")." order by artid desc",20,0); |
|---|
| 87 | while ( list($artid, $secid, $title) = $xoopsDB->fetchRow($result) ) { |
|---|
| 88 | $title = $myts->makeTboxData4Show($title); |
|---|
| 89 | $result2 = $xoopsDB->query("select secid, secname from ".$xoopsDB->prefix("sections")." where secid='$secid'"); |
|---|
| 90 | list($secid, $secname) = $xoopsDB->fetchRow($result2); |
|---|
| 91 | $secname = $myts->makeTboxData4Show($secname); |
|---|
| 92 | echo "<li>$title ($secname) [ <a href=index.php?op=secartedit&artid=$artid>"._MD_EDIT."</a> ]</li>"; |
|---|
| 93 | } ?> |
|---|
| 94 | </ul> |
|---|
| 95 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?> |
|---|
| 96 | <?php echo _MD_EDITARTID; ?> <input class="textbox" type="text" NAME="artid" size="10" /> |
|---|
| 97 | <input type="hidden" name="op" value="secartedit" /> |
|---|
| 98 | <input type="submit" value="<?php echo _MD_GO;?>" /> |
|---|
| 99 | </form> |
|---|
| 100 | <?php |
|---|
| 101 | } |
|---|
| 102 | echo "<br />"; ?> |
|---|
| 103 | <hr /><h4><?php echo _MD_ADDNEWSEC; ?></h4> |
|---|
| 104 | <br /><br /> |
|---|
| 105 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?><br /> |
|---|
| 106 | <b><?php echo _MD_SECNAMEC; ?></b> <?php echo _MD_MAXCHAR; ?><br /> |
|---|
| 107 | <input class="textbox" type="text" name="secname" size="40" maxlength="40" /><br /><br /> |
|---|
| 108 | <b><?php echo _MD_SECIMAGEC; ?></b> <?php echo _MD_EXIMAGE; ?><br /> |
|---|
| 109 | <input class="textbox" type="text" name="image" size="40" maxlength="50" /><br /><br /> |
|---|
| 110 | <input type="hidden" name="op" value="sectionmake" /> |
|---|
| 111 | <input type="submit" value="<?php echo _MD_GOADDSECTION; ?>" /> |
|---|
| 112 | </form> |
|---|
| 113 | <?php |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | function secartedit($artid) { |
|---|
| 117 | global $xoopsDB, $xoopsConfig, $xoopsModule; |
|---|
| 118 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 119 | xoops_cp_header(); |
|---|
| 120 | echo "<h4>"._AM_SECCONF."</h4>"; |
|---|
| 121 | $result = $xoopsDB->query("select artid, secid, title, content from ".$xoopsDB->prefix("seccont")." where artid='$artid'"); |
|---|
| 122 | list($artid, $secid, $title, $content) = $xoopsDB->fetchRow($result); |
|---|
| 123 | $title = $myts->makeTboxData4Edit($title); |
|---|
| 124 | $content = $myts->makeTareaData4Edit($content); |
|---|
| 125 | ?> |
|---|
| 126 | <hr /><h4><?php echo _MD_EDITARTICLE; ?></h4> |
|---|
| 127 | <br /><br /> |
|---|
| 128 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?><br /> |
|---|
| 129 | <b><?php echo _MD_TITLEC; ?></b><br /> |
|---|
| 130 | <input class="textbox" type="text" name="title" size="60" value="<?php echo "$title"; ?>" /><br /><br /> |
|---|
| 131 | <?php |
|---|
| 132 | $result2 = $xoopsDB->query("select secid, secname from ".$xoopsDB->prefix("sections")." order by secname"); |
|---|
| 133 | while(list($secid2, $secname) = $xoopsDB->fetchRow($result2)) { |
|---|
| 134 | $secname = $myts->makeTboxData4Show($secname); |
|---|
| 135 | if ($secid2==$secid) { $che = " checked='checked'"; } |
|---|
| 136 | echo "<input type='radio' name='secid' value='$secid2'$che />$secname<br />"; |
|---|
| 137 | $che = ""; |
|---|
| 138 | } ?> |
|---|
| 139 | <br /> |
|---|
| 140 | <b><?php echo _MD_CONTENTC; ?></b><br /> |
|---|
| 141 | <textarea class="textbox" name="content" cols="60" rows="10"><?php echo "$content"; ?></textarea> |
|---|
| 142 | <input type="hidden" name="artid" value="<?php echo "$artid"; ?>" /> |
|---|
| 143 | <input type="hidden" name="op" value="secartchange" /> |
|---|
| 144 | <table border="0"><tr><td> |
|---|
| 145 | <input type="submit" value="<?php echo _MD_SAVECHANGES; ?>" /> |
|---|
| 146 | </form></td><td> |
|---|
| 147 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?> |
|---|
| 148 | <input type="hidden" name="artid" value="<?php echo "$artid"; ?>" /> |
|---|
| 149 | <input type="hidden" name="op" value="secartdelete" /> |
|---|
| 150 | <input type="submit" value="<?php echo _MD_DELETE; ?>" /> |
|---|
| 151 | </form></td></tr></table> |
|---|
| 152 | <?php |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | function sectionedit($secid) { |
|---|
| 156 | global $xoopsDB, $xoopsConfig, $xoopsModule; |
|---|
| 157 | xoops_cp_header(); |
|---|
| 158 | echo "<h4>"._AM_SECCONF."</h4><br />"; |
|---|
| 159 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 160 | $result = $xoopsDB->query("select secid, secname, image from ".$xoopsDB->prefix("sections")." where secid=$secid"); |
|---|
| 161 | list($secid, $secname, $image) = $xoopsDB->fetchRow($result); |
|---|
| 162 | $secname = $myts->makeTboxData4Edit($secname); |
|---|
| 163 | $image = $myts->makeTboxData4Edit($image); |
|---|
| 164 | $result2 = $xoopsDB->query("select artid from ".$xoopsDB->prefix("seccont")." where secid=$secid"); |
|---|
| 165 | $number = $xoopsDB->getRowsNum($result2); |
|---|
| 166 | ?> |
|---|
| 167 | <?php echo "<img src=\"".XOOPS_URL."/modules/sections/images/".$image."\" border=\"0\" /><br /><br />"; ?> |
|---|
| 168 | <h4><?php printf(_MD_EDITTHISSEC,$secname); ?></h4> |
|---|
| 169 | <br /> |
|---|
| 170 | <?php |
|---|
| 171 | $help = sprintf(_MD_THISSECHAS,$number); |
|---|
| 172 | echo "$help"; |
|---|
| 173 | ?> |
|---|
| 174 | <br /><br /> |
|---|
| 175 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?><br /> |
|---|
| 176 | <b><?php echo _MD_SECNAMEC; ?></b> <?php echo _MD_MAXCHAR; ?><br /> |
|---|
| 177 | <input class="textbox" type="text" name="secname" size="40" maxlength="40" value="<?php echo "$secname"; ?>" /><br /><br /> |
|---|
| 178 | <b><?php echo _MD_SECIMAGEC; ?></b> <?php echo _MD_EXIMAGE; ?><br /> |
|---|
| 179 | <input class="textbox" type="text" name="image" size="40" maxlength="50" value="<?php echo "$image"; ?>" /><br /><br /> |
|---|
| 180 | <input type="hidden" name="secid" value="<?php echo "$secid"; ?>" /> |
|---|
| 181 | <input type="hidden" name="op" value="sectionchange" /> |
|---|
| 182 | <table border="0"><tr><td> |
|---|
| 183 | <input type="submit" value="<?php echo _MD_SAVECHANGES; ?>" /> |
|---|
| 184 | </form></td><td> |
|---|
| 185 | <?php echo "<form action=\"index.php\" method=\"post\">"; ?> |
|---|
| 186 | <input type="hidden" name="secid" value="<?php echo "$secid"; ?>" /> |
|---|
| 187 | <input type="hidden" name="op" value="sectiondelete" /> |
|---|
| 188 | <input type="submit" value="<?php echo _MD_DELETE; ?>" /> |
|---|
| 189 | </form></td></tr></table> |
|---|
| 190 | <?php |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | $op = ''; |
|---|
| 194 | |
|---|
| 195 | if (isset($_GET['op'])) { |
|---|
| 196 | $op = trim($_GET['op']); |
|---|
| 197 | if (isset($_GET['artid'])) { |
|---|
| 198 | $artid = intval($_GET['artid']); |
|---|
| 199 | } |
|---|
| 200 | if (isset($_GET['secid'])) { |
|---|
| 201 | $secid = intval($_GET['secid']); |
|---|
| 202 | } |
|---|
| 203 | } elseif (!empty($_POST['op'])) { |
|---|
| 204 | $op = $_POST['op']; |
|---|
| 205 | $secid = !empty($_POST['secid']) ? intval($_POST['secid']) : 0; |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | switch ($op) { |
|---|
| 209 | case "sections": |
|---|
| 210 | sections(); |
|---|
| 211 | break; |
|---|
| 212 | case "sectionedit": |
|---|
| 213 | sectionedit($secid); |
|---|
| 214 | break; |
|---|
| 215 | case "sectionmake": |
|---|
| 216 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 217 | $secname = !empty($_POST['secname']) ? $myts->stripSlashesGPC($_POST['secname']) : ''; |
|---|
| 218 | if (empty($secname)) { |
|---|
| 219 | redirect_header("index.php", 2, _MD_ERRORSECNAME); |
|---|
| 220 | } |
|---|
| 221 | $image = !empty($_POST['image']) ? $myts->stripSlashesGPC($_POST['image']) : ''; |
|---|
| 222 | $newid = $xoopsDB->genId($xoopsDB->prefix("sections")."_secid_seq"); |
|---|
| 223 | $xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("sections")." (secid, secname, image) VALUES ($newid, ".$xoopsDB->quoteString($secname).", ".$xoopsDB->quoteString($image).")"); |
|---|
| 224 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 225 | break; |
|---|
| 226 | case "secartdelete": |
|---|
| 227 | xoops_cp_header(); |
|---|
| 228 | echo "<h4>"._AM_SECCONF."</h4>"; |
|---|
| 229 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 230 | $artid = !empty($_POST['artid']) ? intval($_POST['artid']) : 0; |
|---|
| 231 | $result = $xoopsDB->query("select title from ".$xoopsDB->prefix("seccont")." where artid=$artid"); |
|---|
| 232 | list($title) = $xoopsDB->fetchRow($result); |
|---|
| 233 | $title = $myts->makeTboxData4Show($title); |
|---|
| 234 | xoops_confirm(array('op' => 'secartdelete_ok', 'artid' => $artid), 'index.php', sprintf(_MD_DELETETHISART,$title).'<br /><br />'._MD_RUSUREDELART); |
|---|
| 235 | break; |
|---|
| 236 | case 'secartdelete_ok': |
|---|
| 237 | $artid = !empty($_POST['artid']) ? intval($_POST['artid']) : 0; |
|---|
| 238 | if ($artid <= 0) { |
|---|
| 239 | redirect_header("index.php?op=sections",2,_MD_DBNOTUPDATED); |
|---|
| 240 | } |
|---|
| 241 | $sql = sprintf("DELETE FROM %s WHERE artid = %u", $xoopsDB->prefix("seccont"), $artid); |
|---|
| 242 | $xoopsDB->query($sql); |
|---|
| 243 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 244 | break; |
|---|
| 245 | case "sectionchange": |
|---|
| 246 | if ($secid <= 0) { |
|---|
| 247 | redirect_header("index.php?op=sections",2,_MD_DBNOTUPDATED); |
|---|
| 248 | } |
|---|
| 249 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 250 | $secname = !empty($_POST['secname']) ? $myts->stripSlashesGPC($_POST['secname']) : ''; |
|---|
| 251 | if (empty($secname)) { |
|---|
| 252 | redirect_header("index.php", 2, _MD_ERRORSECNAME); |
|---|
| 253 | } |
|---|
| 254 | $image = !empty($_POST['image']) ? $myts->stripSlashesGPC($_POST['image']) : ''; |
|---|
| 255 | $xoopsDB->query("update ".$xoopsDB->prefix("sections")." set secname=".$xoopsDB->quoteString($secname).", image=".$xoopsDB->quoteString($image)." where secid=$secid"); |
|---|
| 256 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 257 | break; |
|---|
| 258 | case "secarticleadd": |
|---|
| 259 | if ($secid <= 0) { |
|---|
| 260 | redirect_header("index.php?op=sections",2,_MD_DBNOTUPDATED); |
|---|
| 261 | } |
|---|
| 262 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 263 | $title = !empty($_POST['title']) ? $myts->stripSlashesGPC($_POST['title']) : ''; |
|---|
| 264 | $content = !empty($_POST['content']) ? $myts->stripSlashesGPC($_POST['content']) : ''; |
|---|
| 265 | $newid = $xoopsDB->genId($xoopsDB->prefix("seccont")."_artid_seq"); |
|---|
| 266 | $success = $xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("seccont")." (artid, secid, title, content, counter) VALUES ($newid, $secid, ".$xoopsDB->quoteString($title).", ".$xoopsDB->quoteString($content).", 0)"); |
|---|
| 267 | if ( !$success ) { |
|---|
| 268 | xoops_cp_header(); |
|---|
| 269 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
|---|
| 270 | echo "<a href='./index.php'><h4>"._AM_SECCONF."</h4></a>"; |
|---|
| 271 | echo _MD_DBNOTUPDATED; |
|---|
| 272 | echo"</td></tr></table>"; |
|---|
| 273 | xoops_cp_footer(); |
|---|
| 274 | exit(); |
|---|
| 275 | } |
|---|
| 276 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 277 | break; |
|---|
| 278 | case "secartedit": |
|---|
| 279 | $artid = !empty($_REQUEST['artid']) ? intval($_REQUEST['artid']) : 0; |
|---|
| 280 | if ($artid > 0) { |
|---|
| 281 | secartedit($artid); |
|---|
| 282 | } |
|---|
| 283 | break; |
|---|
| 284 | case "secartchange": |
|---|
| 285 | $artid = !empty($_POST['artid']) ? intval($_POST['artid']) : 0; |
|---|
| 286 | if ($artid <= 0) { |
|---|
| 287 | redirect_header("index.php?op=sections",2,_MD_DBNOTUPDATED); |
|---|
| 288 | } |
|---|
| 289 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 290 | $title = !empty($_POST['title']) ? $myts->stripSlashesGPC($_POST['title']) : ''; |
|---|
| 291 | $content = !empty($_POST['content']) ? $myts->stripSlashesGPC($_POST['content']) : ''; |
|---|
| 292 | $xoopsDB->query("update ".$xoopsDB->prefix("seccont")." set secid=$secid, title=".$xoopsDB->quoteString($title).", content=".$xoopsDB->quoteString($content)." where artid=$artid"); |
|---|
| 293 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 294 | break; |
|---|
| 295 | case "sectiondelete": |
|---|
| 296 | xoops_cp_header(); |
|---|
| 297 | echo "<h4>"._AM_SECCONF."</h4>"; |
|---|
| 298 | xoops_confirm(array('op' => 'sectiondelete_ok', 'secid' => $secid), 'index.php', _MD_RUSUREDELSEC.'<br />'._MD_THISDELETESALL); |
|---|
| 299 | break; |
|---|
| 300 | case 'sectiondelete_ok': |
|---|
| 301 | $sql = sprintf("DELETE FROM %s WHERE secid = %u", $xoopsDB->prefix("seccont"), $secid); |
|---|
| 302 | $xoopsDB->query($sql); |
|---|
| 303 | $sql = sprintf("DELETE FROM %s WHERE secid = %u", $xoopsDB->prefix("sections"), $secid); |
|---|
| 304 | $xoopsDB->query($sql); |
|---|
| 305 | redirect_header("index.php?op=sections",2,_MD_DBUPDATED); |
|---|
| 306 | break; |
|---|
| 307 | default: |
|---|
| 308 | sections(); |
|---|
| 309 | break; |
|---|
| 310 | } |
|---|
| 311 | xoops_cp_footer(); |
|---|
| 312 | ?> |
|---|