Location: PHPKode > projects > QuickTicket > quickticket/qti_unregister.php
<?php

/**
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to hide@address.com so we can mail you a copy immediately.
 *
 * @package    QuickTicket
 * @author     Philippe Vandenberghe <hide@address.com>
 * @copyright  2008-2012 The PHP Group
 * @version    2.5 build:20101222
 */

session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanView('U') ) die(Error(11));

// --------
// INITIALISE
// --------

$id = -1;
if (isset($_GET['id'])) $id = intval(strip_tags($_GET['id']));
if (isset($_POST['id'])) $id = intval(strip_tags($_POST['id']));
if ($id<0) die('Missing parameters');
if ($oVIP->id!=$id ) die(Error(11));

include('bin/qt_lib_smtp.php');
include(Translate('qti_reg.php'));

$oVIP->selfurl = 'qti_unregister.php';
$oVIP->selfname = $L['Unregister'];
$oVIP->exitname = $L['Exit'];


// --------
// SUBMITTED
// --------

if ( isset($_POST['ok']) )
{
  // check password
  $oDB->Query('SELECT count(id) as countid FROM '.TABUSER.' WHERE id='.$id.' AND pwd="'.sha1($_POST['title']).'"');
  $row = $oDB->Getrow();
  if ($row['countid']==0) $error=$L['Password'].' '.$L['E_invalid'];

  // execute and exit
  if ( empty($error) )
  {
    $oDB->Query('SELECT * FROM '.TABUSER.' WHERE id='.$id);
    $row = $oDB->Getrow();
    $oVIP->Unregister($row);
    $oVIP->EndMessage(NULL,$L['S_delete'],$_SESSION[QT]['skin_dir'],2);
  }
}

// --------
// HTML START
// --------

$oDB->Query('SELECT * FROM '.TABUSER.' WHERE id='.$id);
$row = $oDB->Getrow();

$strHeadScript = '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
  if (theForm.title.value.length==0) { alert(html_entity_decode("'.$L['Missing'].': '.$L['Password'].'")); return false; }
  return null;
}
-->
</script>
';

include('qti_p_header.php');

echo '
<table class="hidden" cellspacing="0">
<tr class="hidden">
<td class="hidden" style="width:175px;"><br />',AsImgBox(AsImg(AsAvatarScr($row['photo']),'',$row['name']),'picbox','',$row['name']),'</td>
<td class="hidden">
';

$oHtml->Msgbox($oVIP->selfname);

$str = $L['H_Unregister'].'
<form method="post" action="'.$oVIP->selfurl.'" onsubmit="return ValidateForm(this);">
<input type="hidden" name="id" value="'.$id.'" />
<p>'.$L['Password'].' <input type="password" id="title" name="title" size="20" maxlength="32" /> <input type="submit" name="ok" value="'.$L['Ok'].'" /> <span id="title_err" class="error"></span></p>
</form>
';
if ( $row['role']!='U' ) $str = '<p>'.$row['name'].' is a Staff member.<br />To unregister a staff member, an administrator must first change role to User, or use the delete function.</p>';
if ( $id<2 ) $str = '<p>Admin and Visitor cannot be removed...</p>';

if ( !empty($error) ) echo '<p id="infomessage" class="error">',$error,'</p>';
echo '<h2>',$row['name'],'</h2>
',$str,'
<p><a href="',$oVIP->exiturl,'">',$oVIP->exitname,'</a></p>
';

$oHtml->Msgbox();

echo '
</td>
</tr>
</table>
';

// --------
// HTML END
// --------

include('qti_p_footer.php');

?>
Return current item: QuickTicket