[ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 3 /************************************************************************/ 4 /* PHP-NUKE: Web Portal System */ 5 /* =========================== */ 6 /* */ 7 /* Copyright (c) 2005 by Francisco Burzi */ 8 /* http://phpnuke.org */ 9 /* */ 10 /* This program is free software. You can redistribute it and/or modify */ 11 /* it under the terms of the GNU General Public License as published by */ 12 /* the Free Software Foundation; either version 2 of the License. */ 13 /************************************************************************/ 14 15 if (!defined('ADMIN_FILE')) { 16 die ("Access Denied"); 17 } 18 19 global $prefix, $db, $admin_file; 20 $aid = substr("$aid", 0,25); 21 $row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Topics'")); 22 $row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'")); 23 $admins = explode(",", $row['admins']); 24 $auth_user = 0; 25 for ($i=0; $i < sizeof($admins); $i++) { 26 if ($row2['name'] == "$admins[$i]" AND !empty($row['admins'])) { 27 $auth_user = 1; 28 } 29 } 30 31 if ($row2['radminsuper'] == 1 || $auth_user == 1) { 32 33 /*********************************************************/ 34 /* Topics Manager Functions */ 35 /*********************************************************/ 36 37 function topicsmanager() { 38 global $prefix, $db, $admin_file, $tipath; 39 include ("header.php"); 40 GraphicAdmin(); 41 OpenTable(); 42 echo "<center><span class=\"title\"><b>"._TOPICSMANAGER . "</b></span></center>"; 43 CloseTable(); 44 echo "<br>"; 45 OpenTable(); 46 echo "<center><span class=\"option\"><b>"._CURRENTTOPICS . "</b></span><br>"._CLICK2EDIT . "</span></center><br>" 47 ."<table border=\"0\" width=\"100%\" align=\"center\" cellpadding=\"2\">"; 48 $count = 0; 49 $result = $db->sql_query("SELECT topicid, topicname, topicimage, topictext from " . $prefix . "_topics order by topicname"); 50 while ($row = $db->sql_fetchrow($result)) { 51 $topicid = intval($row['topicid']); 52 $topicname = filter($row['topicname'], "nohtml"); 53 $topicimage = filter($row['topicimage'], "nohtml"); 54 $topictext = filter($row['topictext'], "nohtml"); 55 echo "<td align=\"center\">" 56 ."<a href=\"".$admin_file.".php?op=topicedit&topicid=$topicid\"><img src=\"$tipath/$topicimage\" border=\"0\" alt=\"\"></a><br>" 57 ."<span class=\"content\"><b>$topictext</td>"; 58 $count++; 59 if ($count == 5) { 60 echo "</tr><tr>"; 61 $count = 0; 62 } 63 } 64 echo "</table>"; 65 CloseTable(); 66 echo "<br><a name=\"Add\">"; 67 OpenTable(); 68 echo "<center><span class=\"option\"><b>"._ADDATOPIC . "</b></span></center><br>" 69 ."<form action=\"".$admin_file.".php\" method=\"post\">" 70 ."<b>"._TOPICNAME . ":</b><br><span class=\"tiny\">"._TOPICNAME1 . "<br>" 71 .""._TOPICNAME2 . "</span><br>" 72 ."<input type=\"text\" name=\"topicname\" size=\"20\" maxlength=\"20\"><br><br>" 73 ."<b>"._TOPICTEXT . ":</b><br><span class=\"tiny\">"._TOPICTEXT1 . "<br>" 74 .""._TOPICTEXT2 . "</span><br>" 75 ."<input type=\"text\" name=\"topictext\" size=\"40\" maxlength=\"40\"><br><br>" 76 ."<b>"._TOPICIMAGE . ":</b><br>" 77 ."<select name=\"topicimage\">"; 78 $path1 = explode ("/", "$tipath"); 79 $path = "$path1[0]/$path1[1]"; 80 $handle=opendir($path); 81 while ($file = readdir($handle)) { 82 if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "AllTopics.gif") { 83 $tlist .= "$file "; 84 } 85 } 86 closedir($handle); 87 $tlist = explode(" ", $tlist); 88 sort($tlist); 89 for ($i=0; $i < sizeof($tlist); $i++) { 90 if(!empty($tlist[$i])) { 91 echo "<option name=\"topicimage\" value=\"$tlist[$i]\">$tlist[$i]\n"; 92 } 93 } 94 echo "</select><br><br>" 95 ."<input type=\"hidden\" name=\"op\" value=\"topicmake\">" 96 ."<input type=\"submit\" value=\""._ADDTOPIC . "\">" 97 ."</form>"; 98 CloseTable(); 99 include ("footer.php"); 100 } 101 102 function topicedit($topicid) { 103 global $prefix, $db, $admin_file, $tipath; 104 include ("header.php"); 105 GraphicAdmin(); 106 OpenTable(); 107 echo "<center><span class=\"title\"><b>"._TOPICSMANAGER . "</b></span></center>"; 108 CloseTable(); 109 echo "<br>"; 110 OpenTable(); 111 $topicid = intval($topicid); 112 $row = $db->sql_fetchrow($db->sql_query("SELECT topicid, topicname, topicimage, topictext from ".$prefix . "_topics where topicid='$topicid'")); 113 $topicid = intval($row['topicid']); 114 $topicname = filter($row['topicname'], "nohtml"); 115 $topicimage = filter($row['topicimage'], "nohtml"); 116 $topictext = filter($row['topictext'], "nohtml"); 117 echo "<img src=\"$tipath/$topicimage\" border=\"0\" align=\"right\" alt=\"$topictext\">" 118 ."<span class=\"option\"><b>"._EDITTOPIC . ": $topictext</b></span>" 119 ."<br><br>" 120 ."<form action=\"".$admin_file.".php\" method=\"post\"><br>" 121 ."<b>"._TOPICNAME . ":</b><br><span class=\"tiny\">"._TOPICNAME1 . "<br>" 122 .""._TOPICNAME2 . "</span><br>" 123 ."<input type=\"text\" name=\"topicname\" size=\"20\" maxlength=\"20\" value=\"$topicname\"><br><br>" 124 ."<b>"._TOPICTEXT . ":</b><br><span class=\"tiny\">"._TOPICTEXT1 . "<br>" 125 .""._TOPICTEXT2 . "</span><br>" 126 ."<input type=\"text\" name=\"topictext\" size=\"40\" maxlength=\"40\" value=\"$topictext\"><br><br>" 127 ."<b>"._TOPICIMAGE . ":</b><br>" 128 ."<select name=\"topicimage\">"; 129 $path1 = explode ("/", "$tipath"); 130 $path = "$path1[0]/$path1[1]"; 131 $handle=opendir($path); 132 while ($file = readdir($handle)) { 133 if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "AllTopics.gif") { 134 $tlist .= "$file "; 135 } 136 } 137 closedir($handle); 138 $tlist = explode(" ", $tlist); 139 sort($tlist); 140 for ($i=0; $i < sizeof($tlist); $i++) { 141 if(!empty($tlist[$i])) { 142 if ($topicimage == $tlist[$i]) { 143 $sel = "selected"; 144 } else { 145 $sel = ""; 146 } 147 echo "<option name=\"topicimage\" value=\"$tlist[$i]\" $sel>$tlist[$i]\n"; 148 } 149 } 150 echo "</select><br><br>" 151 ."<b>"._ADDRELATED . ":</b><br>" 152 .""._SITENAME . ": <input type=\"text\" name=\"name\" size=\"30\" maxlength=\"30\"><br>" 153 .""._URL . ": <input type=\"text\" name=\"url\" value=\"http://\" size=\"50\" maxlength=\"200\"><br><br>" 154 ."<b>"._ACTIVERELATEDLINKS . ":</b><br>" 155 ."<table width=\"100%\" border=\"0\">"; 156 $res = $db->sql_query("SELECT rid, name, url from ".$prefix . "_related where tid='$topicid'"); 157 $num = $db->sql_numrows($res); 158 if ($num == 0) { 159 echo "<tr><td><span class=\"tiny\">"._NORELATED . "</span></td></tr>"; 160 } 161 while($row2 = $db->sql_fetchrow($res)) { 162 $rid = intval($row2['rid']); 163 $name = filter($row2['name'], "nohtml"); 164 $url = filter($row2['url'], "nohtml"); 165 echo "<tr><td align=\"left\"><span class=\"content\"><strong><big>·</big></strong> <a href=\"$url\">$name</a></td>" 166 ."<td align=\"center\"><span class=\"content\"><a href=\"$url\">$url</a></td><td align=\"right\"><span class=\"content\">[ <a href=\"".$admin_file.".php?op=relatededit&tid=$topicid&rid=$rid\">"._EDIT . "</a> | <a href=\"".$admin_file.".php?op=relateddelete&tid=$topicid&rid=$rid\">"._DELETE . "</a> ]</td></tr>"; 167 } 168 echo "</table><br><br>" 169 ."<input type=\"hidden\" name=\"topicid\" value=\"$topicid\">" 170 ."<input type=\"hidden\" name=\"op\" value=\"topicchange\">" 171 ."<INPUT type=\"submit\" value=\""._SAVECHANGES . "\"> <span class=\"content\">[ <a href=\"".$admin_file.".php?op=topicdelete&topicid=$topicid\">"._DELETE . "</a> ]</span>" 172 ."</form>"; 173 CloseTable(); 174 include ("footer.php"); 175 } 176 177 function relatededit($tid, $rid) { 178 global $prefix, $db, $admin_file, $tipath; 179 include ("header.php"); 180 GraphicAdmin(); 181 OpenTable(); 182 echo "<center><span class=\"title\"><b>"._TOPICSMANAGER . "</b></span></center>"; 183 CloseTable(); 184 echo "<br>"; 185 $rid = intval($rid); 186 $tid = intval($tid); 187 $row = $db->sql_fetchrow($db->sql_query("SELECT name, url from ".$prefix . "_related where rid='$rid'")); 188 $name = filter($row['name'], "nohtml"); 189 $url = filter($row['url'], "nohtml"); 190 $row2 = $db->sql_fetchrow($db->sql_query("SELECT topictext, topicimage from ".$prefix . "_topics where topicid='$tid'")); 191 $topicimage = filter($row2['topicimage'], "nohtml"); 192 $topictext = filter($row2['topictext'], "nohtml"); 193 OpenTable(); 194 echo "<center>" 195 ."<img src=\"$tipath/$topicimage\" border=\"0\" alt=\"$topictext\" align=\"right\">" 196 ."<span class=\"option\"><b>"._EDITRELATED . "</b></span><br>" 197 ."<b>"._TOPIC . ":</b> $topictext</center>" 198 ."<form action=\"".$admin_file.".php\" method=\"post\">" 199 .""._SITENAME . ": <input type=\"text\" name=\"name\" value=\"$name\" size=\"30\" maxlength=\"30\"><br><br>" 200 .""._URL . ": <input type=\"text\" name=\"url\" value=\"$url\" size=\"60\" maxlength=\"200\"><br><br>" 201 ."<input type=\"hidden\" name=\"op\" value=\"relatedsave\">" 202 ."<input type=\"hidden\" name=\"tid\" value=\"$tid\">" 203 ."<input type=\"hidden\" name=\"rid\" value=\"$rid\">" 204 ."<input type=\"submit\" value=\""._SAVECHANGES . "\"> "._GOBACK . "" 205 ."</form>"; 206 CloseTable(); 207 include ("footer.php"); 208 } 209 210 function relatedsave($tid, $rid, $name, $url) { 211 global $prefix, $db, $admin_file; 212 $rid = intval($rid); 213 $name = filter($name, "nohtml", 1); 214 $url = filter($url, "nohtml", 1); 215 $db->sql_query("update ".$prefix . "_related set name='$name', url='$url' where rid='$rid'"); 216 Header("Location: ".$admin_file.".php?op=topicedit&topicid=$tid"); 217 } 218 219 function relateddelete($tid, $rid) { 220 global $prefix, $db, $admin_file; 221 $rid = intval($rid); 222 $db->sql_query("delete from ".$prefix . "_related where rid='$rid'"); 223 Header("Location: ".$admin_file.".php?op=topicedit&topicid=$tid"); 224 } 225 226 function topicmake($topicname, $topicimage, $topictext) { 227 global $prefix, $db, $admin_file; 228 $topicname = filter($topicname, "nohtml", 1); 229 $topicimage = filter($topicimage, "nohtml", 1); 230 $topictext = filter($topictext, "nohtml", 1); 231 $db->sql_query("INSERT INTO ".$prefix . "_topics VALUES (NULL,'$topicname','$topicimage','$topictext','0')"); 232 Header("Location: ".$admin_file.".php?op=topicsmanager#Add"); 233 } 234 235 function topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url) { 236 global $prefix, $db, $admin_file; 237 $topicname = filter($topicname, "nohtml", 1); 238 $topicimage = filter($topicimage, "nohtml", 1); 239 $topictext = filter($topictext, "nohtml", 1); 240 $name = filter($name, "nohtml", 1); 241 $url = filter($url, "nohtml", 1); 242 $topicid = intval($topicid); 243 $db->sql_query("update ".$prefix . "_topics set topicname='$topicname', topicimage='$topicimage', topictext='$topictext' where topicid='$topicid'"); 244 if (!$name) { 245 } else { 246 $db->sql_query("insert into ".$prefix . "_related VALUES (NULL, '$topicid','$name','$url')"); 247 } 248 Header("Location: ".$admin_file.".php?op=topicedit&topicid=$topicid"); 249 } 250 251 function topicdelete($topicid, $ok=0) { 252 global $prefix, $db, $admin_file, $tipath; 253 $topicid = intval($topicid); 254 if ($ok==1) { 255 $row = $db->sql_fetchrow($db->sql_query("SELECT sid from " . $prefix . "_stories where topic='$topicid'")); 256 $sid = intval($row['sid']); 257 $db->sql_query("delete from " . $prefix . "_stories where topic='$topicid'"); 258 $db->sql_query("delete from " . $prefix . "_topics where topicid='$topicid'"); 259 $db->sql_query("delete from " . $prefix . "_related where tid='$topicid'"); 260 $row2 = $db->sql_fetchrow($db->sql_query("SELECT sid from " . $prefix . "_comments where sid='$sid'")); 261 $sid = intval($row2['sid']); 262 $db->sql_query("delete from " . $prefix . "_comments where sid='$sid'"); 263 Header("Location: ".$admin_file.".php?op=topicsmanager"); 264 } else { 265 global $topicimage; 266 include ("header.php"); 267 GraphicAdmin(); 268 OpenTable(); 269 echo "<center><span class=\"title\"><b>" . _TOPICSMANAGER . "</b></span></center>"; 270 CloseTable(); 271 echo "<br>"; 272 $row3 = $db->sql_fetchrow($db->sql_query("SELECT topicimage, topictext from " . $prefix . "_topics where topicid='$topicid'")); 273 $topicimage = filter($row3['topicimage'], "nohtml"); 274 $topictext = filter($row3['topictext'], "nohtml"); 275 OpenTable(); 276 echo "<center><img src=\"$tipath$topicimage\" border=\"0\" alt=\"$topictext\"><br><br>" 277 ."<b>" . _DELETETOPIC . " $topictext</b><br><br>" 278 ."" . _TOPICDELSURE . " <i>$topictext</i>?<br>" 279 ."" . _TOPICDELSURE1 . "<br><br>" 280 ."[ <a href=\"".$admin_file.".php?op=topicsmanager\">" . _NO . "</a> | <a href=\"".$admin_file.".php?op=topicdelete&topicid=$topicid&ok=1\">" . _YES . "</a> ]</center><br><br>"; 281 CloseTable(); 282 include ("footer.php"); 283 } 284 } 285 286 switch ($op) { 287 288 case "topicsmanager": 289 topicsmanager(); 290 break; 291 292 case "topicedit": 293 topicedit($topicid); 294 break; 295 296 case "topicmake": 297 topicmake($topicname, $topicimage, $topictext); 298 break; 299 300 case "topicdelete": 301 topicdelete($topicid, $ok); 302 break; 303 304 case "topicchange": 305 topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url); 306 break; 307 308 case "relatedsave": 309 relatedsave($tid, $rid, $name, $url); 310 break; 311 312 case "relatededit": 313 relatededit($tid, $rid); 314 break; 315 316 case "relateddelete": 317 relateddelete($tid, $rid); 318 break; 319 320 } 321 322 } else { 323 include ("header.php"); 324 GraphicAdmin(); 325 OpenTable(); 326 echo "<center><b>"._ERROR."</b><br><br>You do not have administration permission for module \"$module_name\"</center>"; 327 CloseTable(); 328 include ("footer.php"); 329 } 330 331 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |