Location: PHPKode > projects > Quick Guestbook > quicktalk/qtg_msg_del.php
<?php

/**
* PHP versions 4 and 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    QuickTalk Guestbook
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2009-2012 The PHP Group
* @version    2.5 build:20100731
*/

session_start();
require_once('bin/qtg_init.php');

// Check argument

$ok = '';
$id = '-1'; // in case of file system, id is a filename (hashed)
$page = 1;
QThttpvar('ok id page', 'str str int',true,true,false); //only Http Get
if ( $id<0 ) die('ID '.$L['E_invalid']);

$pg_name=$L['Delete_my_message'];
$pg_url='qtg_msg_del.php';

// Check if using the administration section

if ( isset($_GET['adm']) ) { $bAdm=true; } else { $bAdm=false; }
if ( $bAdm ) { if ( !isset($_SESSION['qtgAuth']) ) $bAdm=false; }
if ( $bAdm ) { if ( $_SESSION['qtgAuth']!='yes' ) $bAdm=false; }

// Setting for administration section

if ( $bAdm )
{
  include(GetLang().'qtg_adm.php');
  $qtg_skin = 'admin';
  $pg_name=$L['Delete'];
}

// Get the messages

$oPost = new cPost($id);

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

if ( !empty($ok) )
{
  if ( !$bAdm )
  {
    if ( $_SERVER['REMOTE_ADDR']!=$oPost->ip )
    {
    echo 'This is not your message...<br/>'.$qtg_back; 
    exit;
    }
    if ( !isset($_SESSION['qtg_beginedit']) || !isset($_SESSION['qtg_endedit']) )
    {
    echo 'Out of time...<br/>'.$qtg_back;
    exit;
    }
    if ( time()+0>$_SESSION['qtg_endedit'] )
    {
    echo 'Out of time...<br/>'.$qtg_back;
    exit;
    }
  }

  $oPost->Delete();

  if ( $bAdm ) { HtmlRedirect('qtg_adm_msg.php'); } else { HtmlRedirect(); } 
  exit;
}

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

include('qtg_p_header.php');
if ( $bAdm ) include('qtg_adm_menu.php');

echo '
<div id="msg_add">
';

if ( !$bAdm ) echo '<h2>',$pg_name,'</h2>
';

$oPost->x=0; // disable map
$oPost->y=0;
$qtg_show_size=null;
include('qtg_msg_inc.php');

echo '<div class="actionbutton"><span class="actionbutton"><a class="actionbutton bold" href="',Href('qtg_msg_del.php'),'?',($bAdm ? 'adm&amp;' : ''),'id=',$id,'&amp;page=',$page,'&amp;ok=delete">'.$L['Delete'].' !</a></span></div>
';

if ( !$bAdm) echo $qtg_back;

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

echo '</div>';
include('qtg_p_footer.php');

?>
Return current item: Quick Guestbook