home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / admin.php next >
Encoding:
PHP Script  |  2002-09-16  |  14.6 KB  |  353 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Advanced Content Management System                         */
  5. /* ============================================                         */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 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. require_once("mainfile.php");
  16. get_lang(admin);
  17.  
  18. function create_first($name, $url, $email, $pwd, $user_new) {
  19.     global $prefix, $dbi, $user_prefix;
  20.     $first = sql_num_rows(sql_query("select * from ".$prefix."_authors", $dbi),$dbi);
  21.     if ($first == 0) {
  22.     $pwd = md5($pwd);
  23.     $the_adm = "God";
  24.     $result = sql_query("insert into ".$prefix."_authors values ('$name', '$the_adm', '$url', '$email', '$pwd', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '')", $dbi);
  25.     if ($user_new == 1) {
  26.         $user_regdate = date("M d, Y");
  27.         $user_avatar = "blank.gif";
  28.         $commentlimit = 4096;
  29.         $result = sql_query("insert into ".$user_prefix."_users values (NULL,'','$name','$email','','$url','$user_avatar','$user_regdate','','','','','','0','','','','','$pwd',10,'','0','0','0','','0','','$Default_Theme','$commentlimit','0','0','0','0','0','1','1','0')", $dbi);
  30.     }
  31.     login();
  32.     }
  33. }
  34.  
  35. $the_first = sql_num_rows(sql_query("select * from ".$prefix."_authors", $dbi), $dbi);
  36. if ($the_first == 0) {
  37.     if (!$name) {
  38.     include("header.php");
  39.     title("$sitename: "._ADMINISTRATION."");
  40.     OpenTable();
  41.     echo "<center><b>"._NOADMINYET."</b></center><br><br>"
  42.     ."<form action=\"admin.php\" method=\"post\">"
  43.     ."<table border=\"0\">"
  44.     ."<tr><td><b>"._NICKNAME.":</b></td><td><input type=\"text\" name=\"name\" size=\"30\" maxlength=\"25\"></td></tr>"
  45.     ."<tr><td><b>"._HOMEPAGE.":</b></td><td><input type=\"text\" name=\"url\" size=\"30\" maxlength=\"255\" value=\"http://\"></td></tr>"
  46.     ."<tr><td><b>"._EMAIL.":</b></td><td><input type=\"text\" name=\"email\" size=\"30\" maxlength=\"255\"></td></tr>"
  47.     ."<tr><td><b>"._PASSWORD.":</b></td><td><input type=\"password\" name=\"pwd\" size=\"11\" maxlength=\"10\"></td></tr>"
  48.     ."<tr><td colspan=\"2\">"._CREATEUSERDATA."  <input type=\"radio\" name=\"user_new\" value=\"1\" checked>"._YES."  <input type=\"radio\" name=\"user_new\" value=\"0\">"._NO."</td></tr>"
  49.     ."<tr><td><input type=\"hidden\" name=\"fop\" value=\"create_first\">"
  50.     ."<input type=\"submit\" value=\""._SUBMIT."\">"
  51.     ."</td></tr></table></form>";
  52.     CloseTable();
  53.     include("footer.php");
  54.     }
  55.     switch($fop) {
  56.     case "create_first":
  57.     create_first($name, $url, $email, $pwd, $user_new);
  58.     break;
  59.     }
  60.     die();
  61. }
  62.  
  63. require("auth.php");
  64.  
  65. if(!isset($op)) { $op = "adminMain"; }
  66. $pagetitle = "- "._ADMINMENU."";
  67.  
  68. /*********************************************************/
  69. /* Login Function                                        */
  70. /*********************************************************/
  71.  
  72. function login() {
  73.     include ("header.php");
  74.     OpenTable();
  75.     echo "<center><font class=\"title\"><b>"._ADMINLOGIN."</b></font></center>";
  76.     CloseTable();
  77.     echo "<br>";
  78.     OpenTable();
  79.     echo "<form action=\"admin.php\" method=\"post\">"
  80.         ."<table border=\"0\">"
  81.     ."<tr><td>"._ADMINID."</td>"
  82.     ."<td><input type=\"text\" NAME=\"aid\" SIZE=\"20\" MAXLENGTH=\"25\"></td></tr>"
  83.     ."<tr><td>"._PASSWORD."</td>"
  84.     ."<td><input type=\"password\" NAME=\"pwd\" SIZE=\"20\" MAXLENGTH=\"18\"></td></tr>"
  85.     ."<tr><td>"
  86.     ."<input type=\"hidden\" NAME=\"op\" value=\"login\">"
  87.     ."<input type=\"submit\" VALUE=\""._LOGIN."\">"
  88.     ."</td></tr></table>"
  89.     ."</form>";
  90.     CloseTable();
  91.     include ("footer.php");
  92. }
  93.  
  94. function deleteNotice($id, $table, $op_back) {
  95.     global $dbi;
  96.     sql_query("delete from $table WHERE id = '$id'", $dbi);
  97.     Header("Location: admin.php?op=$op_back");
  98. }
  99.  
  100. /*********************************************************/
  101. /* Administration Menu Function                          */
  102. /*********************************************************/
  103.  
  104. function adminmenu($url, $title, $image) {
  105.     global $counter, $admingraphic, $Default_Theme;
  106.     $ThemeSel = get_theme();
  107.     if (file_exists("themes/$ThemeSel/images/admin/$image")) {
  108.     $image = "themes/$ThemeSel/images/admin/$image";
  109.     } else {
  110.     $image = "images/admin/$image";
  111.     }
  112.     if ($admingraphic == 1) {
  113.     $img = "<img src=\"$image\" border=\"0\" alt=\"$title\" title=\"$title\"></a><br>";
  114.     $close = "";
  115.     } else {
  116.     $image = "";
  117.     $close = "</a>";
  118.     }
  119.     echo "<td align=\"center\"><font class=\"content\"><a href=\"$url\">$img<b>$title</b>$close<br><br></font></td>";
  120.     if ($counter == 5) {
  121.     echo "</tr><tr>";
  122.     $counter = 0;
  123.     } else {
  124.     $counter++;
  125.     }
  126. }
  127.  
  128. function GraphicAdmin() {
  129.     global $aid, $admingraphic, $language, $admin, $prefix, $dbi;
  130.     $result = sql_query("SELECT qid FROM ".$prefix."_queue", $dbi);
  131.     $newsubs = sql_num_rows($result, $dbi);
  132.     $result = sql_query("select radminarticle,radmintopic,radminuser,radminsurvey,radminsection,radminlink,radminephem,radminfaq,radmindownload,radminreviews,radminnewsletter,radminforum,radmincontent,radminency,radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  133.     list($radminarticle,$radmintopic,$radminuser,$radminsurvey,$radminsection,$radminlink,$radminephem,$radminfaq,$radmindownload,$radminreviews,$radminnewsletter,$radminforum,$radmincontent,$radminency,$radminsuper) = sql_fetch_array($result, $dbi);
  134.     OpenTable();
  135.     echo "<center><a href=\"admin.php\"><font class='title'>"._ADMINMENU."</font></a>";
  136.     echo "<br><br>";
  137.     echo"<table border=\"0\" width=\"100%\" cellspacing=\"1\"><tr>";
  138.     $linksdir = dir("admin/links");
  139.     while($func=$linksdir->read()) {
  140.         if(substr($func, 0, 6) == "links.") {
  141.             $menulist .= "$func ";
  142.     }
  143.     }
  144.     closedir($linksdir->handle);
  145.     $menulist = explode(" ", $menulist);
  146.     sort($menulist);
  147.     for ($i=0; $i < sizeof($menulist); $i++) {
  148.     if($menulist[$i]!="") {
  149.         $counter = 0;
  150.         include($linksdir->path."/$menulist[$i]");
  151.     }
  152.     }
  153.     adminmenu("admin.php?op=logout", ""._ADMINLOGOUT."", "logout.gif");
  154.     echo"</tr></table></center>";
  155.     CloseTable();
  156.     echo "<br>";
  157. }
  158.  
  159. /*********************************************************/
  160. /* Administration Main Function                          */
  161. /*********************************************************/
  162.  
  163. function adminMain() {
  164.     global $language, $admin, $aid, $prefix, $file, $dbi, $sitename, $user_prefix;
  165.     include ("header.php");
  166.     $dummy = 0;
  167.     $Today = getdate();
  168.     $month = $Today['month'];
  169.     $mday = $Today['mday'];
  170.     $year = $Today['year'];
  171.     $pmonth = $Today['month'];
  172.     $pmday = $Today['mday'];
  173.     $pmday = $mday-1;
  174.     $pyear = $Today['year'];
  175.     if ($pmonth=="January") { $pmonth=1; } else
  176.     if ($pmonth=="February") { $pmonth=2; } else
  177.     if ($pmonth=="March") { $pmonth=3; } else
  178.     if ($pmonth=="April") { $pmonth=4; } else
  179.     if ($pmonth=="May") { $pmonth=5; } else
  180.     if ($pmonth=="June") { $pmonth=6; } else
  181.     if ($pmonth=="July") { $pmonth=7; } else
  182.     if ($pmonth=="August") { $pmonth=8; } else
  183.     if ($pmonth=="September") { $pmonth=9; } else
  184.     if ($pmonth=="October") { $pmonth=10; } else
  185.     if ($pmonth=="November") { $pmonth=11; } else
  186.     if ($pmonth=="December") { $pmonth=12; };
  187.     $test = mktime (0,0,0,$pmonth,$pmday,$pyear,1);
  188.     $curDate2 = "%".$month[0].$month[1].$month[2]."%".$mday."%".$year."%";
  189.     $preday = strftime ("%d",$test);
  190.     $premonth = strftime ("%B",$test);
  191.     $preyear = strftime ("%Y",$test);
  192.     $curDateP = "%".$premonth[0].$premonth[1].$premonth[2]."%".$preday."%".$preyear."%";
  193.     GraphicAdmin();
  194.     $result2 = sql_query("select radminarticle, radminsuper, admlanguage from ".$prefix."_authors where aid='$aid'", $dbi);
  195.     list($radminarticle, $radminsuper, $admlanguage) = sql_fetch_row($result2, $dbi);
  196.     if ($admlanguage != "" ) {
  197.     $queryalang = "WHERE alanguage='$admlanguage' ";
  198.     } else {
  199.     $queryalang = "";
  200.     }
  201.     $main_m = sql_query("select main_module from ".$prefix."_main", $dbi);
  202.     list($main_module) = sql_fetch_row($main_m, $dbi);
  203.     OpenTable();
  204.     echo "<center><b>$sitename: "._DEFHOMEMODULE."</b><br><br>"
  205.     .""._MODULEINHOME." <b>$main_module</b><br>[ <a href=\"admin.php?op=modules\">"._CHANGE."</a> ]</center>";
  206.     CloseTable();
  207.     echo "<br>";
  208.     OpenTable();
  209.     $result = sql_query("SELECT username FROM ".$prefix."_session where guest='1'", $dbi);
  210.     $guest_online_num = sql_num_rows($result, $dbi);
  211.     $result = sql_query("SELECT username FROM ".$prefix."_session where guest='0'", $dbi);
  212.     $member_online_num = sql_num_rows($result, $dbi);
  213.     $who_online_num = $guest_online_num + $member_online_num;
  214.     $who_online = "<center><font class=\"option\">"._WHOSONLINE."</font><br><br><font class=\"content\">"._CURRENTLY." $guest_online_num "._GUESTS." $member_online_num "._MEMBERS."<br>";
  215.     $result2 = sql_query("SELECT COUNT(UID) AS userCount from $user_prefix"._users." WHERE user_regdate LIKE '$curDate2'", $dbi);
  216.     list($userCount) = sql_fetch_row($result2, $dbi);
  217.     $result3 = sql_query("SELECT COUNT(UID) AS userCount from $user_prefix"._users." WHERE user_regdate LIKE '$curDateP'", $dbi);
  218.     list($userCount2) = sql_fetch_row($result3, $dbi);
  219.     echo "<center>$who_online<br>"
  220.     .""._BTD.": <b>$userCount</b> - "._BYD.": <b>$userCount2</b></center>";
  221.     CloseTable();
  222.     echo "<br>";
  223.     OpenTable();
  224.     echo "<center><b>"._AUTOMATEDARTICLES."</b></center><br>";
  225.     $count = 0;
  226.     $result = sql_query("select anid, aid, title, time, alanguage from ".$prefix."_autonews $queryalang order by time ASC", $dbi);
  227.     while(list($anid, $said, $title, $time, $alanguage) = sql_fetch_row($result, $dbi)) {
  228.     if ($alanguage == "") {
  229.         $alanguage = ""._ALL."";
  230.     }
  231.     if ($anid != "") {
  232.         if ($count == 0) {
  233.         echo "<table border=\"1\" width=\"100%\">";
  234.         $count = 1;
  235.         }
  236.         $time = ereg_replace(" ", "@", $time);
  237.         if (($radminarticle==1) OR ($radminsuper==1)) {
  238.         if (($radminarticle==1) AND ($aid == $said) OR ($radminsuper==1)) {
  239.                 echo "<tr><td nowrap> (<a href=\"admin.php?op=autoEdit&anid=$anid\">"._EDIT."</a>-<a href=\"admin.php?op=autoDelete&anid=$anid\">"._DELETE."</a>) </td><td width=\"100%\"> $title </td><td align=\"center\"> $alanguage </td><td nowrap> $time </td></tr>"; /* Multilingual Code : added column to display language */
  240.         } else {
  241.             echo "<tr><td> ("._NOFUNCTIONS.") </td><td width=\"100%\"> $title </td><td align=\"center\"> $alanguage </td><td nowrap> $time </td></tr>"; /* Multilingual Code : added column to display language */
  242.         }
  243.         } else {
  244.         echo "<tr><td width=\"100%\"> $title </td><td align=\"center\"> $alanguage </td><td nowrap> $time </td></tr>"; /* Multilingual Code : added column to display language */
  245.         }
  246.     }
  247.     }
  248.     if (($anid == "") AND ($count == 0)) {
  249.     echo "<center><i>"._NOAUTOARTICLES."</i></center>";
  250.     }
  251.     if ($count == 1) {
  252.         echo "</table>";
  253.     }
  254.     CloseTable();
  255.     echo "<br>";
  256.     OpenTable();
  257.     echo "<center><b>"._LAST." 20 "._ARTICLES."</b></center><br>";
  258.     $result = sql_query("select sid, aid, title, time, topic, informant, alanguage from ".$prefix."_stories $queryalang order by time desc limit 0,20", $dbi);
  259.     echo "<center><table border=\"1\" width=\"100%\" bgcolor=\"$bgcolor1\">";
  260.     while(list($sid, $said, $title, $time, $topic, $informant, $alanguage) = sql_fetch_row($result, $dbi)) {
  261.     $ta = sql_query("select topicname from ".$prefix."_topics where topicid='$topic'", $dbi);
  262.     list($topicname) = sql_fetch_row($ta, $dbi);
  263.     if ($alanguage == "") {
  264.         $alanguage = ""._ALL."";
  265.     }
  266.     formatTimestamp($time);
  267.     echo "<tr><td align=\"right\"><b>$sid</b>"
  268.         ."</td><td align=\"left\" width=\"100%\"><a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a>"
  269.         ."</td><td align=\"center\">$alanguage"
  270.         ."</td><td align=\"right\">$topicname";
  271.     if (($radminarticle==1) OR ($radminsuper==1)) {
  272.         if (($radminarticle==1) AND ($aid == $said) OR ($radminsuper==1)) {
  273.         echo "</td><td align=\"right\" nowrap>(<a href=\"admin.php?op=EditStory&sid=$sid\">"._EDIT."</a>-<a href=\"admin.php?op=RemoveStory&sid=$sid\">"._DELETE."</a>)"
  274.             ."</td></tr>";
  275.         } else {
  276.         echo "</td><td align=\"right\" nowrap><font class=\"content\"><i>("._NOFUNCTIONS.")</i></font>"
  277.             ."</td></tr>";
  278.         }
  279.     } else {
  280.         echo "</td></tr>";
  281.     }
  282.     }
  283.     echo "</table>";
  284.     if (($radminarticle==1) OR ($radminsuper==1)) {
  285.     echo "<center>"
  286.         ."<form action=\"admin.php\" method=\"post\">"
  287.         .""._STORYID.": <input type=\"text\" NAME=\"sid\" SIZE=\"10\">"
  288.         ."<select name=\"op\">"
  289.         ."<option value=\"EditStory\" SELECTED>"._EDIT."</option>"
  290.         ."<option value=\"RemoveStory\">"._DELETE."</option>"
  291.         ."</select>"
  292.         ."<input type=\"submit\" value=\""._GO."\">"
  293.         ."</form></center>";
  294.     }
  295.     CloseTable();
  296.     $result = sql_query("SELECT pollID, pollTitle FROM ".$prefix."_poll_desc WHERE artid='0' ORDER BY pollID DESC limit 1", $dbi);
  297.     $object = sql_fetch_object($result, $dbi);
  298.     $pollID = $object->pollID;
  299.     $pollTitle = $object->pollTitle;
  300.     echo "<br>";
  301.     OpenTable();
  302.     echo "<center><b>"._CURRENTPOLL.":</b> $pollTitle [ <a href=\"admin.php?op=polledit&pollID=$pollID\">"._EDIT."</a> | <a href=\"admin.php?op=create\">"._ADD."</a> ]</center>";
  303.     CloseTable();
  304.     include ("footer.php");
  305. }
  306.  
  307. if($admintest) {
  308.  
  309.     switch($op) {
  310.  
  311.     case "deleteNotice":
  312.     deleteNotice($id, $table, $op_back);
  313.     break;
  314.  
  315.     case "GraphicAdmin":
  316.         GraphicAdmin();
  317.         break;
  318.  
  319.     case "adminMain":
  320.     adminMain();
  321.     break;
  322.  
  323.     case "logout":
  324.     setcookie("admin");
  325.     include("header.php");
  326.     OpenTable();
  327.     echo "<center><font class=\"title\"><b>"._YOUARELOGGEDOUT."</b></font></center>";
  328.     CloseTable();
  329.     include("footer.php");
  330.     break;
  331.  
  332.     case "login";
  333.     unset($op);
  334.  
  335.     default:
  336.     $casedir = dir("admin/case");
  337.     while($func=$casedir->read()) {
  338.         if(substr($func, 0, 5) == "case.") {
  339.         include($casedir->path."/$func");
  340.         }
  341.     }
  342.     closedir($casedir->handle);
  343.     break;
  344.  
  345.     }
  346.  
  347. } else {
  348.  
  349.     login();
  350.  
  351. }
  352.  
  353. ?>