home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / admin / users.php < prev   
PHP Script  |  2000-12-05  |  9KB  |  194 lines

  1. <?PHP
  2.  
  3. ######################################################################
  4. # PHP-NUKE: Web Portal System
  5. # ===========================
  6. #
  7. # Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
  8. # http://phpnuke.org
  9. #
  10. # This modules is the main administration part
  11. #
  12. # This program is free software. You can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License.
  15. ######################################################################
  16.  
  17. if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
  18. $hlpfile = "manual/users.html";
  19. $result = mysql_query("select radminuser, radminsuper from authors where aid='$aid'");
  20. list($radminuser, $radminsuper) = mysql_fetch_row($result);
  21. if (($radminuser==1) OR ($radminsuper==1)) {
  22.  
  23. /*********************************************************/
  24. /* Users Functions                                       */
  25. /*********************************************************/
  26.  
  27. function displayUsers() {
  28.     global $hlpfile, $admin;
  29.         include("header.php");
  30.     GraphicAdmin($hlpfile);
  31.     OpenTable();
  32.         echo "
  33.     <font size=4><b><center>".translate("Edit Users")."<br><br></b></font></center>";
  34.     echo "<form method=post action=\"admin.php\">";
  35.         echo "<b>".translate("Handle/UserID").": </b> <input class=textbox type=text name=\"chng_uid\" size=10>\n";
  36.         echo "<select class=textbox name=\"op\">";
  37.         echo "<option value=\"modifyUser\">".translate("Modify User")."</option>\n";
  38.         echo "<option value=\"delUser\">".translate("Delete User")."</option></select>\n";
  39.         echo "<input type=\"submit\" value=\"".translate("Go!")."\"></form>";
  40. ?>
  41. <form action="admin.php" method="post">
  42. <table cols=2 border=0 width=100%>
  43. <tr><td width=100><?php echo ""; ?><?php echo translate("Handle");?>*</td>
  44.     <td><?php echo ""; ?> <input class=textbox type="text" name="add_uname" size=30 maxlength=25></td></tr>
  45. <tr><td><?php echo ""; ?><?php echo translate("Name");?></td>
  46.     <td><?php echo ""; ?><input class=textbox type="text" name="add_name" size=30 maxlength=50></td></tr>
  47. <tr><td><?php echo ""; ?><?php echo translate("Email");?>*</td>
  48.     <td><?php echo ""; ?> <input class=textbox type="text" name="add_email" size=30 maxlength=60></td></tr>
  49. <tr><td><?php echo ""; ?><?php echo translate("Fake Email");?></td>
  50.     <td><?php echo ""; ?> <input class=textbox type="text" name="add_femail" size=30 maxlength=60></td></tr>
  51. <tr><td><?php echo ""; ?><?php echo translate("URL");?></td>
  52.     <td><?php echo ""; ?> <input class=textbox type="text" name="add_url" size=30 maxlength=60></td></tr>
  53. <tr><td><?php echo ""; ?><?php echo translate("Password");?>*</td>
  54.     <td><?php echo ""; ?> <input class=textbox type="text" name="add_pass" size=12 maxlength=12></td></tr>
  55. <input type="hidden" name="op" value="addUser">
  56. <tr><td colspan=2><?php echo ""; ?><input type=submit value="<?php echo translate("Add User");?>"></form></td></tr>
  57. </table>
  58. <?php echo "<center><font color=Red> ".translate("* indicates compulsory fields")." "; ?></font>
  59. </td></tr></table></td></tr></table>
  60. <?php
  61.  
  62.         include("footer.php");
  63. }
  64.  
  65. function modifyUser($chng_user) {
  66.         include("header.php");
  67.     GraphicAdmin($hlpfile);
  68.         $result = mysql_query("select uid, uname, name, url, email, femail, pass from users where uid='$chng_user' or uname='$chng_user'");
  69.         if(mysql_num_rows($result) > 0) {
  70.                 while(list($chng_uid, $chng_uname, $chng_name, $chng_url, $chng_email, $chng_femail, $chng_pass) = mysql_fetch_row($result)) {
  71.                 echo "
  72.         <b><center>
  73.         ".translate("Update User").": $chng_uname
  74.         <br><br></b></center>";
  75. OpenTable();
  76. ?>
  77. <form action="admin.php" method="get">
  78. <table border=0>
  79. <tr><td><?php echo ""; ?><?php echo translate("User ID");?></td>
  80.     <td><?php echo ""; ?><?php echo $chng_uid ?></td></tr>
  81. <tr><td><?php echo ""; ?><?php echo translate("Handle");?>*</td>
  82.     <td><?php echo ""; ?><input class=textbox type="text" name="chng_uname" value="<?php echo $chng_uname ?>"></td></tr>
  83. <tr><td width=100><?php echo ""; ?><?php echo translate("Name");?></td>
  84.     <td><?php echo ""; ?><input class=textbox type="text" name="chng_name" value="<?php echo $chng_name ?>"></td></tr>
  85. <tr><td><?php echo ""; ?><?php echo translate("URL");?></td>
  86.     <td><?php echo ""; ?> <input class=textbox type="text" name="chng_url" value="<?php echo $chng_url ?>" size=30 maxlength=60></td></tr>
  87. <tr><td><?php echo ""; ?><?php echo translate("Email");?>*</td>
  88.     <td><?php echo ""; ?> <input class=textbox type="text" name="chng_email" value="<?php echo $chng_email ?>" size=30 maxlength=60></td></tr>
  89. <tr><td><?php echo ""; ?><?php echo translate("Fake Email");?></td>
  90.     <td><?php echo ""; ?> <input class=textbox type="text" name="chng_femail" value="<?php echo $chng_femail ?>" size=30 maxlength=60></td></tr>
  91. <tr><td><?php echo ""; ?><?php echo translate("Password")?></td>
  92.     <td><?php echo ""; ?> <input class=textbox type="password" name="chng_pass"  size=12 maxlength=12></td></tr>
  93. <tr><td><?php echo ""; ?><?php echo translate("Retype Password");?></td>
  94.     <td><?php echo ""; ?> <input class=textbox type="password" name="chng_pass2" size=12 maxlength=12> <?php echo translate("(for changes only)");?></td></tr>
  95. <input type="hidden" name="chng_uid" value="<?php echo $chng_uid; ?>">
  96. <input type="hidden" name="op" value="updateUser">
  97. <tr><td colspan=2><?php echo ""; ?><input type="submit" value="<?php echo translate("Update User");?>"></form></td></tr>
  98. </table>
  99. <?php
  100.                 }
  101.                 echo "<center><font color=Red>".translate("* indicates compulsory fields")."</font>";
  102.         echo "</td></tr></table></td></tr></table>";
  103.         } else {
  104.                 echo "<center>";
  105.         echo translate("User doesn't exist!");
  106.         echo "</center>";
  107.         }
  108.         include("footer.php");
  109. }
  110.  
  111. function updateUser($chng_uid, $chng_uname, $chng_name, $chng_url, $chng_email, $chng_femail, $chng_pass, $chng_pass2) {
  112.     global $system;
  113.         $tmp = 0;
  114.     if ($chng_pass2 != "") {
  115.                 if($chng_pass != $chng_pass2) {
  116.                         $titlebar = "<b>".translate("bad pass")."</b>";
  117.                         include("header.php");
  118.             GraphicAdmin($hlpfile);
  119.                         echo "
  120.             <center>".translate("Sorry, the new passwords do not match. Click back and try again")."</center>";
  121.                         include("footer.php");
  122.                         exit;
  123.                 }
  124.             $tmp = 1;
  125.         }
  126.     if ($tmp == 0) {
  127.         mysql_query("update users set uname='$chng_uname', name='$chng_name', email='$chng_email', femail='$chng_femail', url='$chng_url' where uid='$chng_uid'");
  128.     }
  129.     if ($tmp == 1) {
  130.         if (!$system) {
  131.         $cpass = crypt($chng_pass);
  132.         } else {
  133.         $cpass = $chng_pass;
  134.         }
  135.         mysql_query("update users set uname='$chng_uname', name='$chng_name', email='$chng_email', femail='$chng_femail', url='$chng_url', pass='$cpass' where uid='$chng_uid'");    
  136.     }
  137.     header("Location: admin.php?op=adminMain");
  138. }
  139.  
  140. switch($op) {
  141.  
  142.                 case "mod_users":
  143.                         displayUsers();
  144.                         break;
  145.  
  146.                 case "modifyUser":
  147.                         modifyUser($chng_uid);
  148.                         break;
  149.  
  150.                 case "updateUser":
  151.                         updateUser($chng_uid, $chng_uname, $chng_name, $chng_url, $chng_email, $chng_femail, $chng_pass, $chng_pass2);
  152.                         break;
  153.  
  154.                 case "delUser":
  155.                         include("header.php");
  156.                         $titlebar = "<h3>".translate("Delete User")."</h3>";
  157.                         echo $titlebar;
  158.                         echo translate("Are you sure you want to delete") . " " . translate("user") . " $chng_uid? ";
  159.                         echo "[ <a href=\"admin.php?op=delUserConf&del_uid=$chng_uid\">".translate("Yes")."</a> | <a href=\"admin.php?op=adminMain\">".translate("No")."</a> ]";
  160.                         include("footer.php");
  161.                         break;
  162.  
  163.                 case "delUserConf":
  164.                         mysql_query("delete from users where uid='$del_uid' or uname='$del_uid'");
  165.                         Header("Location: admin.php?op=adminMain");
  166.                         echo mysql_error();
  167.                         break;
  168.  
  169.                 case "addUser":
  170.             if ($system==1) {
  171.             } else {
  172.                 $add_pass = crypt($add_pass);
  173.             }
  174.                         if (!($add_uname && $add_email && $add_pass)) {
  175.                             echo translate("You must complete all compulsory fields");
  176.                             return;
  177.                         }
  178.             $sql    = "insert into users ";
  179.                         $sql    .= "(uid,name,uname,email,femail,url,pass) ";
  180.                         $sql    .= "values (NULL,'$add_name','$add_uname','$add_email','$add_femail','$add_url','$add_pass')";
  181.                         $result = mysql_query($sql);
  182.                         if (!$result) {
  183.                                 echo mysql_errno(). ": ".mysql_error(). "<br>"; return;
  184.                         }
  185.                         Header("Location: admin.php?op=adminMain");
  186.                         break;
  187.             
  188. }
  189.  
  190. } else {
  191.     echo "Access Denied";
  192. }
  193.  
  194. ?>