Location: PHPKode > projects > wawp > wawp/administration/users.delete.php
<?php
/********************** WEB AUTHENTICATION with PHP **************************
This package provide a set of tools for web authentication with php and mysql.


GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

WEB AUTHENTICATION with PHP

Copyright (C) 2005-2006  Naldi Stefano

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


CONTACT

Please send any question, bug or communication to the author:


Naldi Stefano


ITALY

e-mail: hide@address.com

*****************************************************************************/

$infi = str_replace ("\\", "/", get_included_files());
if(!in_array(stripslashes(dirname($_SERVER['DOCUMENT_ROOT'])."/wawp_admin/admin.php"), $infi)
   || !in_array(stripslashes(dirname($_SERVER['DOCUMENT_ROOT'])."/wawp_admin/config.php"), $infi))
  {
    require (dirname($_SERVER['DOCUMENT_ROOT'])."/wawp_admin/php_pages_header.php");
  }

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

if ((isset($_POST['un'])) && ($_POST['un'] != "")) {
  $deleteSQL = sprintf("DELETE FROM users_and_groups WHERE name=%s",
                       GetSQLValueString($_POST['un'], "text"));

  mysql_select_db($mydbname, $mylink);
  $Result1 = mysql_query($deleteSQL, $mylink) or die(mysql_error());

  $deleteGoTo = "users.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Web Authentication with PHP</title>
<style type="text/css">
<!--
.style4 {
	color: #FFFF00;
	font-weight: bold;
}
.style5 {color: #FF0000}
-->
</style>
</head>

<body>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="100%" height="50" align="center" valign="middle" bgcolor="#0000FF"><div align="center" class="style4">Web Authentication with PHP  &nbsp;    v. 1.1<br>
    <small><small style="font-style: italic;">
	<span style="color: rgb(255, 255, 0);">Released under the GNU General Public License</span></small></small><br>
      </div></td>
  </tr>
  <tr>
    <td height="50" align="center" valign="middle" bgcolor="#FFCC33"><div align="center" class="style5">
      <table width="80%" cellspacing="1" bgcolor="#0000FF">
        <tr align="center" bgcolor="#FFCC33">
          <td width="20%" bgcolor="#FFCC33"><a href="../index.php">Administration</a></td>
          <td width="20%"><a href="../setup/setup.php">Setup</a></td>
          <td width="20%" bgcolor="#FFFFFF"><a href="users.php">Users</a></td>
          <td width="20%"><a href="groups.php">Groups</a></td>
          <td width="20%"><a href="locations.php">Locations</a></td>
        </tr>
      </table>
    </div></td>
  </tr>
  <tr>
    <td height="350" align="center" valign="top"><br>
      <br>
      <br>
      <br>
      <form action="users.delete.php" method="post" enctype="multipart/form-data" name="form1">
        Confirm delete user&nbsp;&nbsp;
        <input name="un" type="text" id="un" value="<?php echo $_POST['dun']; ?>" readonly="true">
&nbsp;&nbsp;?<br>
<br>
<br>
<input type="submit" name="Submit" value="CONFIRM DELETE">
      </form>
      <br>
      <br>

      <form action="users.php" method="post" enctype="multipart/form-data" name="form2">
        <input type="submit" name="Submit" value="DO NOT DELETE !">
      </form>
    <br>    </td>
  </tr>
</table>
</body>
</html>

Return current item: wawp