Location: PHPKode > projects > Quick Guestbook > quicktalk/qtg_adm_msg.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');
if ( !isset($_SESSION['qtgAuth']) ) HtmlRedirect('qtg_login.php'); // CHECK LOGIN
if ( $_SESSION['qtgAuth']!='yes' )  HtmlRedirect('qtg_login.php');

include(GetLang().'qtg_adm.php');

$qtg_bbctags = array('B'=>true,'I'=>true,'U'=>true,'A'=>true,'S'=>true); // administrator can view all the bbc

$qtg_skin='admin';
$pg_name=$L['Messages'];
$pg_url='qtg_adm_msg.php';
$bCompact=false;

// check view mode (C=compact)
if ( isset($_SESSION[QT]['view']) ) $bCompact=($_SESSION[QT]['view']=='C');
if ( isset($_GET['view']) ) $bCompact=($_GET['view']=='C');
if ( isset($_POST['view']) ) $bCompact=($_POST['view']=='C');
// store view mode
$_SESSION[QT]['view'] = ($bCompact ? 'C' : 'N');

if ( $bCompact && $qtg_page_size<100 ) $qtg_page_size=$qtg_page_size*2;

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

if ( isset($_GET['id']) )
{
  if ( isset($_GET['v']) )
  {
  $oPost = new cPost();
  $oPost->id=$_GET['id'];
  if ( is_a($oDB,'cDT') ) $oPost->id = cPost::UnHash($oPost->id);
  $oPost->SetStatus($_GET['v']);
  }
}

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

include('qtg_p_header.php');
include('qtg_adm_menu.php');

if ( $oDB->type=='file' ) 
{
echo '<p class="small disabled" style="margin:0 0 10px 0">Repository&nbsp; ',$oDB->root,'</p>';
}

if ( isset($_GET['page']) ) { $limit=($_GET['page']-1)*$qtg_page_size; $page=intval($_GET['page']); } else { $limit=0; $page=1; }

// count topics

$count = 0;
if ( is_a($oDB,'cDT') )
{  
  $count = $oDB->FilesCount();
}
else
{
  $oDB->Query( 'SELECT count(id) as countid FROM '.TABMESSAGE.' WHERE id>=0' );
  $row = $oDB->Getrow();
  $count = intval($row['countid']);
}

// ---------------
if ( $count>0 ) {
// ---------------

// pager

$pager = MakePager(Href('qtg_adm_msg.php'),$count,$qtg_page_size,$page);
if ( $pager!='' ) $pager = $L['Page'].$pager;

// compact menu
if ( $bCompact )
{
$strCompact = '<span title="'.$L['HView_C'].'">'.$L['View_C'].'</span> <a href="'.$pg_url.'?view=N" title="'.$L['HView_N'].'">'.$L['View_N'].'</a>'; // no page while comacting/expanding
}
else
{
$strCompact = '<a href="'.$pg_url.'?view=C" title="'.$L['HView_C'].'">'.$L['View_C'].'</a> <span title="'.$L['HView_N'].'">'.$L['View_N'].'<span>';
}

echo '
<!-- pager -->
<table class="pager" cellspacing="0" cellpadding="0">
<tr class="pager_top">
<td class="pager_top">',$strCompact,(empty($pager) ? '' : ' &middot; '.$pager),'</td>
</tr>
</table>
';

// query

if ( is_a($oDB,'cDT') )
{
  // $oDB->GetFiles();
  rsort($oDB->arrFiles);
  if ( count($oDB->arrFiles)>$qtg_page_size ) $oDB->arrFiles = array_slice($oDB->arrFiles, $limit, $qtg_page_size-1);
  $oDB->curFiles=0;
}
else
{
  $oDB->Query( LimitSQL($oDB->type,'* FROM '.TABMESSAGE.' WHERE id>=0','issuedate DESC',$limit,$qtg_page_size,$count) );
}

while($row=$oDB->Getrow())
{
  $oPost = new cPost($row);
 if ( is_a($oDB,'cDT') ) $oPost->id = cPost::Hash($oPost->id); // from here id is only used in url

  echo '<table class="admin',($bCompact ? '_c' : ''),($oPost->visible=='Y' ? '' : '_hidden'),'" cellspacing="0">',N;
  echo '<tr class="admin">',N;
  if ( $bCompact)
  {
    echo '<td class="admin_help" style="width:140px">',$oPost->name,'<br/>';    
    if ( !empty($oPost->postfrom) ) echo $oPost->postfrom,'<br/>';
    echo QTdatestr($oPost->issuedate,'$','$',true),'</td>',N;    
    echo '<td class="admin small">',IQTbbc($oPost,' ',180,null,null,$qtg_skin,$page),'<br/>';
    if ( !empty($oPost->useremail) ) echo $oPost->useremail,' ';
    if ( $oPost->userage>0 ) echo '<span title="',$L['Age'],'">(',$oPost->userage,')</span>';
    if ( !empty($oPost->postfrom) ) echo $oPost->postfrom;
    echo '</td>',N;
    echo '<td class="admin_help" style="width:180px; text-align:center;">';
    echo '<a class="small" href="qtg_msg_edit.php?adm&amp;id=',$oPost->id,'&amp;page=',$page,'">',$L['Edit'],'</a>&nbsp;|&nbsp;';
    echo '<a class="small" href="qtg_msg_del.php?adm&amp;id=',$oPost->id,'&amp;page=',$page,'">',$L['Delete'],'</a>&nbsp;|&nbsp';
    if ( $oPost->visible=='Y' )
    {
    echo '<a class="small" href="qtg_adm_msg.php?id=',$oPost->id,'&amp;v=N&amp;page=',$page,'">',$L['Hide'],'</a>';
    }
    else
    {
    echo '<a class="small" href="qtg_adm_msg.php?id=',$oPost->id,'&amp;v=Y&amp;page=',$page,'">',$L['Unhide'],'</a>';
    }
    echo '<br/><span class="small">ip ',$oPost->ip,'</span></td>',N;
  }
  else
  {
    echo '<td class="admin_top">';
    if ( !empty($oPost->postfrom) ) echo $oPost->postfrom.', ';
    echo QTdatestr($oPost->issuedate,'$','$',true).'</td>';
    echo '<td class="admin" style="width:200px; text-align:center;">';
    echo '<a href="qtg_msg_edit.php?adm&amp;id=',$oPost->id,'&amp;page=',$page,'">',$L['Edit'],'</a>&nbsp;|&nbsp;';
    echo '<a href="qtg_msg_del.php?adm&amp;id=',$oPost->id,'&amp;page=',$page,'">',$L['Delete'],'</a>&nbsp;|&nbsp';
    if ( $oPost->visible=='Y' )
    {
    echo '<a href="qtg_adm_msg.php?id=',$oPost->id,'&amp;v=N&amp;page=',$page,'">',$L['Hide'],'</a>';
    }
    else
    {
    echo '<a href="qtg_adm_msg.php?id=',$oPost->id,'&amp;v=Y&amp;page=',$page,'">',$L['Unhide'],'</a>';
    }
    echo '</td>';
    echo '</tr>',N;
    echo '<tr class="admin">',N;
    echo '<td class="admin"><span class="small">',IQTbbc($oPost,'<br/>',$qtg_show_size,null,null,$qtg_skin,$page),'</span><br/><b>',$oPost->name,'</b>';
    if ( $oPost->userage>0 ) echo ' <span title="',$L['Age'],'">(',$oPost->userage,')</span>';
    if ( !empty($oPost->useremail) ) echo '&nbsp;',$oPost->useremail;
    echo '</td>';
    echo '<td class="admin_help" style="width:200px; text-align:center;"><span class="small">visible <b>',$oPost->visible,'</b></span><br/><span class="small">ip <b>',$oPost->ip,'</b></span></td>';
  }
  echo '</tr>',N;
  echo '</table>',N;
}

echo '
<!-- pager -->
<table class="pager" cellspacing="0" cellpadding="0">
<tr class="pager_bot">
<td class="pager_bot">',$pager,'</td>
</tr>
</table>
';

// ---------------
}
else
{
// ---------------

echo '<p>',$count,' ',$L['Message'],'</p>';

// ---------------
}
// ---------------

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

include('qtg_p_footer.php');

?>
Return current item: Quick Guestbook