<?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_skin='admin';
$pg_name=$L['Multiple_edits'];
$pg_url='qtg_adm_medit.php';
$intYear = intval(date('Y')); if ( intval(date('n'))<2 ) $intYear--; // year filter
// --------
// SUBMITTED
// --------
if (isset($_POST['ok']))
{
// Check form value
$intYear = intval($_POST['y']);
$intMonth = intval($_POST['m']);
$strIp = strip_tags(trim($_POST['ip']));
$a = $_POST['a'];
// Count impacted rows
$str = strval($intYear); if ( $intMonth>0 ) $str = strval($intYear*100+$intMonth);
switch(substr($oDB->type,0,5))
{
case 'mysql':$strWhere = 'SUBSTRING(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'mssql':$strWhere = 'SUBSTRING(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'pg': $strWhere = 'SUBSTRING(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'ibase':$strWhere = 'SUBSTRING(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'sqlit':$strWhere = 'SUBSTR(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'db2': $strWhere = 'SUBSTR(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'oci': $strWhere = 'SUBSTR(issuedate,1,'.strlen($str).')="'.$str.'"'; break;
case 'file': $strWhere = ''; break;
default: die('Unknown db type '.$oDB->type);
}
if ( is_a($oDB,'cDT') )
{
if ( !empty($strIp) ) $strWhere .= $strIp;
if ( $a=='Hide' ) $strWhere .= '-y';
if ( $a=='Unhide' ) $strWhere .= '-n';
$intCount = $oDB->FilesCount($strWhere,0,$str,$str,false);
}
else
{
if ( !empty($strIp) ) $strWhere .= ' AND ip="'.$strIp.'"';
if ( $a=='Hide' ) $strWhere .= ' AND visible="Y"';
if ( $a=='Unhide' ) $strWhere .= ' AND visible="N"';
$oDB->Query( 'SELECT count(id) as countid FROM '.TABMESSAGE.' WHERE id>=0 AND '.$strWhere );
$row = $oDB->Getrow();
$intCount = intval($row['countid']);
}
// Execute
if ( $intCount>0 )
{
if ( $a=='Export' || $a=='Hide' || $a=='Unhide' || $a=='Delete' )
{
include('qtg_p_header.php');
echo '<a id="exiturl" href="qtg_adm_medit_exe.php?y=',$intYear,'&m=',$intMonth,'&ip=',$strIp,'&a=',$a,'&n=',$intCount,'">Execute action ',$a,'...</a>';
echo '
<script type="text/javascript">
<!--
setTimeout(\'window.location=document.getElementById("exiturl").href\',0);
-->
</script>
';
include('qtg_p_footer.php');
exit;
}
}
else
{
$strInfo = $L['E_no_selection'];
if ( $a=='Unhide' ) $strInfo = '[0 hidden message]... '.$L['E_no_selection'];
}
}
// --------
// HTML START
// --------
include('qtg_p_header.php');
include('qtg_adm_menu.php');
// first year
if ( is_a($oDB,'cDT') )
{
$oDB->FilesCount('',0,date('Ym'),'0',true);
$firstyear = substr($oDB->firstfile,0,4);
}
else
{
$oDB->Query( 'SELECT MIN(issuedate) as firstdate FROM '.TABMESSAGE.' WHERE id>=0 AND issuedate>="2000"' );
$row = $oDB->Getrow();
$firstyear = intval(substr($row['firstdate'],0,4));
}
$arrYears = array();
for ($i=$firstyear;$i<=date('Y');$i++) $arrYears[$i]=$i;
echo '<div class="inputbox">
<form method="post" action="',Href('qtg_adm_medit.php'),'">
<p class="inputbox">',$L['Messages_posted_in'],'
<select name="y">',QTasTag($arrYears,$intYear),'</select>
<br/><br/>',$L['Month'],' <select name="m"><option value="0">',$L['All'],'</option>',QTasTag($L['dateMMM']),'</select>
<br/><br/>',$L['From_IP'],' <input type="text" name="ip" size="16" maxlength="24"/>
<br/><span class="small">',$L['HFrom_IP'],'</span><br/></p>
<hr>
<p class="inputbox"> ',$L['Action'],' <select name="a">
<option value="Hide">',$L['Hide'],'</option>
<option value="Unhide">',$L['Unhide'],'</option>
<option value="Delete">',$L['Delete'],'</option>
<option value="Export">',$L['Export'],'</option>
</select>
<input type="submit" name="ok" value="',$L['Next'],' >"/> <br/>
</p>
</form>
</div>
';
// --------
// HTML END
// --------
include('qtg_p_footer.php');
?>