<?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.
*
* @category Troubleticket
* @package QuickTicket
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @license http://www.php.net/license PHP License 3.0
* @version 1.9.0.3 build:20081001
* @link http://www.qt-cute.org/doc/package/qti
* @since File available since Release 1.0.0
* @deprecated File deprecated in Release 2.0.0
*
*/
session_start();
require_once('bin/qti_init.php');
include(Translate('qti_lang_adm.inc'));
if ( $oVIP->role!='A' ) die($L['E_admin']);
if ( !isset($_GET['a'])) die('Wrong action');
// INITIALISE
$a = strip_tags($_GET['a']); // mandatory action
$s = -1; // section
$t = -1; // topic
$p = -1; // post
$v = ''; // value
if (isset($_GET['s'])) $s = intval($_GET['s']);
if (isset($_GET['t'])) $t = intval($_GET['t']);
if (isset($_GET['p'])) $p = intval($_GET['p']);
if (isset($_GET['v'])) $v = strip_tags($_GET['v']);
$oVIP->selfurl = 'qti_adm_cmd.php';
$oVIP->selfname = 'QuickTicket command';
// --------
// EXECUTE COMMAND
// --------
switch($a)
{
// --------------
case 'deletedomain':
// --------------
if ( $s<1 ) die('Wrong id '.$s);
$oVIP->selfname = $L['Domain_del'];
$oVIP->exiturl = 'qti_adm_sections.php';
$oVIP->exitname = '«'.S.$L['Section_man'];
// ask destination
if ( !isset($_GET['ok']) )
{
$strTitle = $_SESSION['qtiDomains'][$s];
$arrSections = GetSectionTitles($oVIP->role,$s);
// list the domain content
if ( count($arrSections)==0 )
{
$strDcont = '<span class="small">0 '.$L['Section'].'</span>';
}
else
{
$strDcont = '';
foreach ($arrSections as $intKey => $strValue)
{
$strDcont .= '<span class="small">'.$L['Section'].': '.$strValue.'</span><br/>';
}
}
// list of domain destination
if ( count($arrSections)>0 )
{
$arrDdest = array(); // array_diff_key() not supported in php<5.1
foreach ($_SESSION['qtiDomains'] as $intKey => $strValue) { if ( $intKey!=$s ) $arrDdest[$intKey] = $strValue; }
$strDdest = '<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Sections'].'</th>
<td class="td_o">
<select name="t" size="1" class="small">'.QTastags($arrDdest,$L['Move_to'].': %s').'</select>
</td>
</tr>';
}
else
{
$strDdest = '';
}
// form
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'">
<table class="ta" cellspacing="0">
<tr class="tr tr_o">
<th class="th_o th_o_first" style="width:150px">'.$L['Title'].'</th>
<td class="td_o"><b>'.$strTitle.'</b></td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Containing'].'</th>
<td class="td_o">'.$strDcont.'</td>
</tr>'.N.$strDdest.'
<tr class="tr tr_o">
<th class="th_o th_o_first"> </th>
<td class="td_o"><input type="hidden" name="a" value="'.$a.'"/><input type="hidden" name="s" value="'.$s.'"/><input type="submit" name="ok" value="'.$L['Delete'].'"/></td>
</tr>
</table>
</form>',
'admin',
0,
'600px'
);
exit;
}
// delete domain
if ( $t>=0) $oDB->Query('UPDATE '.TABSECTION." SET domainid=$t WHERE domainid=$s");
$oDB->Query('DELETE FROM '.TABDOMAIN." WHERE id=$s");
cLang::Delete('domain','d'.$s);
Unset($_SESSION['qtiGoto']);
// exit
$oVIP->EndMessage(NULL,$L['S_delete'],'admin',2);
exit;
break;
// --------------
case 'deletesection':
// --------------
if ( $s<1 ) die('Wrong id '.$s);
$oVIP->selfname = $L['Section_del'];
$oVIP->exiturl = 'qti_adm_sections.php';
$oVIP->exitname = '«'.S.$L['Section_man'];
$oSEC = new cSection($s);
// ask confirmation
if ( !isset($_GET['ok']) )
{
// list topics
if ( $oSEC->topics>0 )
{
$strList = '<tr class="tr tr_o"><th class="th_o"> </th><td class="td_o"><i><b>'.$L['H_Topics_delete'].'</b></i> <a href="qti_adm_cmd.php?a=topicmoveall&s='.$s.'&d=10">'.$L['Adm_topics_move'].' »</a></td></tr>';
}
else
{
$strList = '';
}
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'">
<table class="ta ta_o" cellspacing="0">
<tr class="tr tr_o">
<th class="th_o th_o_first" style="width:150px">'.$L['Section'].'</th>
<td class="td_o">'.$oSEC->name.'</td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Containing'].'</th>
<td class="td_o">'.LangS('Topic',$oSEC->topics).', '.LangS('Reply',$oSEC->replies).'</td>
</tr>
'.$strList.'
<tr class="tr tr_o">
<th class="th_o th_o_first"> </th>
<td class="td_o"><input type="hidden" name="a" value="'.$a.'"/><input type="hidden" name="s" value="'.$s.'"/><input type="submit" name="ok" value="'.$L['Delete'].'"/>
</td>
</tr>
</table>
</form>',
'admin',
0,
'600px'
);
exit;
}
// delete forum
$oSEC->DeleteTopics($s);
$oDB->Query('DELETE FROM '.TABSECTION.' WHERE id='.$s);
cLang::Delete('sec','s'.$s);
cLang::Delete('secdesc','s'.$s);
Unset($_SESSION[QT]['sys_topics']);
Unset($_SESSION[QT]['sys_messages']);
Unset($_SESSION['qtiGoto']);
// exit
$oVIP->EndMessage(NULL,$L['S_delete'],'admin',2);
exit;
break;
// --------------
case 'status_del':
// --------------
if ( $v=='A' || $v=='Z' ) die('Wrong id '.$v);
$oVIP->selfname = $L['Status_del'];
$oVIP->exiturl = 'qti_adm_statuses.php';
$oVIP->exitname = '«'.S.$L['Status_man'];
// ask confirmation
if ( !isset($_GET['ok']) || !isset($_GET['to']) )
{
// list of status destination
$strSdest = '';
foreach ( $_SESSION['qtiTstatus'] as $strKey => $arrDef)
{
if ( $strKey!=$v ) $strSdest .= '<option value="'.$strKey.'"/>'.$strKey.' - '.$arrDef['statusname'].'</option>';
}
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'">
<table cellspacing="0" class="ta">
<tr>
<th class="th_o th_o_first" style="width:150px;">'.$L['Status'].'</th>
<td class="td_o"><b>'.$v.' '.AsImg($_SESSION[QT]['skin_dir'].'/'.$_SESSION['qtiTstatus'][$v]['icon'],'-',$_SESSION['qtiTstatus'][$v]['statusname'],'ico ico_status').' '.$_SESSION['qtiTstatus'][$v]['name'].'</b></td>
</tr>
<tr>
<th class="th_o th_o_first">'.$L['Description'].'</th>
<td class="td_o">'.$_SESSION['qtiTstatus'][$v]['statusdesc'].'</td>
</tr>
<tr>
<th class="th_o th_o_first">'.$L['Move'].'</th>
<td class="td_o">'.$L['H_Status_move'].' <select name="to" size="1" class="small">'.$strSdest.'</select></td>
</tr>
<tr>
<th class="th_o th_o_first"> </th>
<td class="td_o">
<input type="hidden" name="a" value="'.$a.'"/>
<input type="hidden" name="v" value="'.$v.'"/>
<input type="submit" name="ok" value="'.$L['Delete'].'"/></td>
</tr>
</table>
</form><br/>',
'admin',
0,
'600px'
);
exit;
}
// delete status
cStatus::Delete($v,substr($_GET['to'],0,1));
// exit
$oVIP->EndMessage(NULL,$L['S_delete'],'admin',2);
exit;
break;
// --------------
case 'topicdeleteall':
// --------------
if ( $s<0 ) die('Wrong id '.$s);
$days = $_GET['d'];
$oVIP->selfname = $L['Adm_topics_delete'];
$oVIP->exiturl = 'qti_adm_topic.php?d='.$days;
$oVIP->exitname = '«'.S.$L['Topic_man'];
$oSEC = new cSection($s);
$intClosed = $oSEC->Count('closed');
$intNews= $oSEC->Count('news');
// ask confirmation
if ( !isset($_GET['ok']) )
{
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'">
<table cellspacing="0" class="ta">
<tr>
<th class="th_o th_o_first" style="width:150px;">'.$L['Section'].'</th>
<td class="td_o">'.$oSEC->name.'</td>
</tr>
<tr>
<th class="th_o th_o_first">'.$L['Containing'].'</th>
<td class="td_o">'.LangS('Topic',$oSEC->topics).' ('.LangS('News',$intNews).', '.LangS('Reply',$oSEC->replies).')</td>
</tr>
<tr>
<th class="th_o th_o_first"> </th>
<td class="td_o"><i><b>'.$L['H_Topics_delete'].'</b></i></td>
</tr>
<tr>
<th class="th_o th_o_first"> </th>
<td class="td_o">
<input type="hidden" name="a" value="'.$a.'"/>
<input type="hidden" name="s" value="'.$s.'"/>
<input type="hidden" name="d" value="'.$days.'"/>
<input type="submit" name="ok" value="'.$L['Delete'].'"/> <span class="small">('.$oSEC->topics.')</span> '.( $intClosed>0 ? ' <input type="submit" name="ok" value="'.$L['Delete_closed'].'"/> <span class="small">('.$intClosed.')</span>' : '').'</td>
</tr>
</table>
</form><br/>',
'admin',
0,
'600px'
);
exit;
}
// delete topics
if ( $_GET['ok']==$L['Delete'] )
{
$oSEC->DeleteTopics($s);
}
else
{
$oSEC->DeleteTopics($s,true);
}
// exit
$oVIP->EndMessage(NULL,$L['S_delete'],'admin',2);
exit;
break;
// --------------
case 'topicmoveall':
// --------------
if ( $s<0 ) die('Wrong id '.$s);
$days = $_GET['d'];
$oVIP->selfname = $L['Adm_topics_move'];
$oVIP->exiturl = 'qti_adm_topic.php?d='.$days;
$oVIP->exitname = '«'.S.$L['Topic_man'];
$oSEC = new cSection($s);
$intClosed = $oSEC->Count('closed');
$intNews = $oSEC->Count('news');
$arrSections = GetSectionTitles($oVIP->role,-1,$s);
// ask confirmation
if ( !isset($_GET['ok']) || $p<0 )
{
// list destinations
$strFdest = QTastags($arrSections);
// form
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'">
<table cellspacing="0" class="ta">
<tr>
<th class="th_o th_o_first" style="width:150px;">'.$L['Section'].'</th>
<td class="td_o">'.$oSEC->name.'</td>
</tr>
<tr>
<th class="th_o th_o_first">'.$L['Containing'].'</th>
<td class="td_o">'.LangS('Topic',$oSEC->topics).' ('.LangS('News',$intNews).', '.LangS('Reply',$oSEC->replies).')</td>
</tr>
<tr>
<th class="th_o th_o_first">'.$L['Move_to'].'</th>
<td class="td_o"><select name="p" size="1">'.$strFdest.'</select></td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Ref'].'</th>
<td class="td_o"><select name="v" size="1">
<option value="1">'.$L['Move_keep'].'</option>
<option value="0">'.$L['Move_reset'].'</option>
<option value="2">'.$L['Move_follow'].'</option>
</select></td>
</tr>
<tr>
<th class="th_o th_o_first"> </th>
<td class="td_o"><input type="hidden" name="a" value="'.$a.'"/>
<input type="hidden" name="s" value="'.$s.'"/>
<input type="hidden" name="d" value="'.$days.'"/>
<input type="submit" name="ok" value="'.$L['Move'].'"/> <span class="small">('.$oSEC->topics.')</span> '.( $intClosed>0 ? ' <input type="submit" name="ok" value="'.$L['Move_closed'].'"/> <span class="small">('.$intClosed.')</span>' : '').'</td>
</tr>
</table>
</form><br/>',
'admin',
0,
'600px'
);
exit;
}
// move topics
if ( $s<0 ) die('Wrong parameters: missing forum id');
if ( $_GET['ok']==$L['Move'] )
{
$oSEC->MoveTopics($s,$p,intval($v));
}
else
{
$oSEC->MoveTopics($s,$p,intval($v),-1,true);
}
// exit
$oVIP->EndMessage(NULL,$L['S_update'],'admin',2);
exit;
break;
// --------------
case 'topicprune':
// --------------
if ( $s<0 ) die('Wrong id '.$s);
$d = 10; if ( isset($_GET['d']) ) $d = intval($_GET['d']);
if ( $d<1 ) die('Wrong day '.$d);
$intTopics = 0;
$intNews = 0;
if ( isset($_GET['tt']) ) $intTopics = $_GET['tt'];
if ( isset($_GET['ta']) ) $intNews = $_GET['ta'];
include('bin/qti_fn_limitsql.php');
$intU = cSection::Count('unreplied',$s,$d);
$intUN = cSection::Count('unrepliednews',$s,$d);
$oVIP->selfname = $L['Adm_topics_prune'];
$oVIP->exiturl = 'qti_adm_topic.php?d='.$d;
$oVIP->exitname = '«'.S.$L['Topic_man'];
// ask confirmation
if ( !isset($_GET['ok']) || ($intTopics+$intNews)==0 )
{
if ( isset($_GET['ok']) )
{
$qti_error = '<span class="error">'.$L['E_nothing_selected'].'</span><br/>';
}
else
{
$qti_error = '';
}
$oVIP->EndMessage
(
NULL,
'<form method="get" action="'.$oVIP->selfurl.'"><table class="ta" cellspacing="0">
<tr class="tr tr_o">
<th class="th_o th_o_first" style="width:150px;">'.$L['Section'].'</th>
<td class="td_o"><b>'.ObjTrans('sec',$s,"Section $s").'</b></td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Containing'].'</th>
<td class="td_o">'.LangS('Unreplied_topic',$intU).' ('.LangS('News',$intUN).')</td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first">'.$L['Delete'].'</th>
<td class="td_o">
<input type="checkbox" id="tt" name="tt" value="'.$intU.'"'.($intU==0 ? QDIS : '').'/> <label for="t">'.LangS('Topic',$intU).'</label><br/>
<input type="checkbox" id="ta" name="ta" value="'.$intUN.'"'.($intUN==0 ? QDIS : '').'/> <label for="a">'.LangS('News',$intUN).'</label></td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first"> </th>
<td class="td_o"><i><b>'.sprintf($L['H_Topics_prune'],$d).'</b></i></td>
</tr>
<tr class="tr tr_o">
<th class="th_o th_o_first"> </th>
<td class="td_o">
<input type="hidden" name="a" value="'.$a.'"/>
<input type="hidden" name="d" value="'.$d.'"/>
<input type="hidden" name="s" value="'.$s.'"/>
<input type="submit" name="ok" value="'.$L['Delete'].'"/>
</td></tr>
</table></form>'.$qti_error,
'admin',
0,
'600px'
);
exit;
}
// dflt topics
if ( $intTopics>0 )
{
$oDB->Query( 'SELECT t.id FROM '.TABTOPIC.' t WHERE t.forum='.$s.' AND t.replies=0 AND t.type="T" AND t.firstpostdate<"'.DateAdd(date('Ymd His'),-$d,'day').'"' );
$strId = '';
while ($row = $oDB->Getrow())
{
$strId .= $row['id'].',';
}
if ( !empty($strId) )
{
$strId = substr($strId,0,-1);
// delete posts and topics
$oDB->Query( 'DELETE FROM '.TABPOST.' WHERE topic IN ('.$strId.')' );
$oDB->Query( 'DELETE FROM '.TABTOPIC.' WHERE id IN ('.$strId.')' );
}
}
// news topics
if ( $intNews>0 )
{
$oDB->Query( 'SELECT t.id FROM '.TABTOPIC.' t WHERE t.forum='.$s.' AND t.replies=0 AND t.type="A" AND t.firstpostdate<"'.DateAdd(date('Ymd His'),-$d,'day').'"' );
$strId = '';
while ($row = $oDB->Getrow())
{
$strId .= $row['id'].',';
}
if ( !empty($strId) )
{
$strId = substr($strId,0,-1);
// delete posts and topics
$oDB->Query( 'DELETE FROM '.TABPOST.' WHERE topic IN ('.$strId.')' );
$oDB->Query( 'DELETE FROM '.TABTOPIC.' WHERE id IN ('.$strId.')' );
}
}
// count topics this forum
UpdateSectionStats($s);
// exit
$oVIP->EndMessage(NULL,$L['S_delete'],'admin',2);
exit;
break;
// --------------
default:
// --------------
echo 'Unknown action';
break;
// --------------
}
$oVIP->EndMessage('!','Command ['.$a.'] failled...',$_SESSION[QT]['skin_dir'],2);
?>