<?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
*
* About text coding in the database
* This script will convert the text before inserting into the dabase as follow:
*
* 1) stripslashes
* 2) htmlspecialchar($text,ENT_QUOTES) <>&"' are converted to html
* 3) bbcodes remain UNCHANGED (they are converted while displayed)
*/
session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanAccess('MUV',6) ) die($L['R_member']);
if ( !isset($_POST['action']) ) die('Missing parameters: action');
if ( !in_array($_POST['action'],array('nt','re','ed','qu','de')) ) die('Missing parameters A');
// INITIALISE
$s = -1;
if ( isset($_POST['section']) ) $s = intval($_POST['section']);
if ( $s<0 ) die('Missing parameters: section id');
$intBehalf=-1;
$strBehalf='';
$intNotified=-1;
$strNotified='';
$wisheddate='0';
$now = date('Y-m-d H:i:s');
$oVIP->selfname = $L['Post_reply'];
$oSEC = new cSection($s);
$oTopic = new cTopic();
$oPost = new cPost();
$oPost->userid = $oVIP->id;
$oPost->username = $oVIP->username;
$oPost->type = 'R';
$oPost->issuedate = $now;
// CHECK SUBMITTED
if ( isset($_POST['post']) ) { $oPost->id = intval($_POST['post']); }
if ( isset($_POST['icon']) ) { $oPost->icon = $_POST['icon']; }
if ( isset($_POST['title']) ) { $oPost->title = trim($_POST['title']); if ( get_magic_quotes_gpc() ) $oPost->title = stripslashes($oPost->title); }
if ( isset($_POST['text']) ) { $oPost->text = trim($_POST['text']); if ( get_magic_quotes_gpc() ) $oPost->text = stripslashes($oPost->text); }
if ( isset($_POST['oldattach']) ) { $oPost->attach = $_POST['oldattach']; }
if ( isset($_POST['behalf']) ) { $strBehalf = trim($_POST['behalf']); if ( get_magic_quotes_gpc() ) $strBehalf = stripslashes($strBehalf); }
// complete if missing behalf name
if ( $strBehalf!='' )
{
$arrNames = GetUsers('name',$strBehalf);
if ( !empty($arrNames) ) { foreach ( $arrNames as $intKey => $strValue ) { $intBehalf = $intKey; } }
if ( $intBehalf<0 ) $qti_error = $L['Send_on_behalf'].S.$L['E_invalid'];
$oPost->userid = $intBehalf;
$oPost->username = $strBehalf;
}
if ( isset($_POST['notifiedname']) ) { $strNotified = trim($_POST['notifiedname']); if ( get_magic_quotes_gpc() ) $strNotified = stripslashes($strNotified); }
// complete if missing behalf name
if ( $strNotified!='' )
{
$arrNames = GetUsers('name',$strNotified);
if ( !empty($arrNames) ) { foreach ( $arrNames as $intKey => $strValue ) { $intNotified = $intKey; } }
}
if ( $intNotified<0 && $strNotified!='' ) $qti_error = $L['Notify_also'].S.$L['E_invalid'];
if ( $oSEC->notifycc=='2' && $intNotified<0 && $_POST['action']=='nt' ) $qti_error = $L['Notify_also'].': '.$L['E_mandatory'];
if ( $oSEC->wisheddate=='2' && empty($_POST['wisheddate']) && $_POST['action']=='nt' ) $qti_error = $L['Wishddate'].': '.$L['E_mandatory'];
$oPost->title = QTbbc($oPost->title,'deepdrop',' ',50,null,null,' ');
if ( $_POST['action']=='nt' && $oPost->title=='' && $oSEC->titlefield==2 ) $qti_error = $L['E_no_title'];
if ( $_POST['action']=='nt' && $oPost->title=='' && $oSEC->titlefield!=2 ) $oPost->title = QTbbc($oPost->text,'deepdrop',' ',50,null,null,' ');
if ( strlen($oPost->text)>$_SESSION[QT]['chars_per_post'] ) $qti_error = $L['E_too_long'].S.sprintf($L['E_char_max'], $_SESSION[QT]['chars_per_post']);
if ( substr_count($oPost->text,"\n")>$_SESSION[QT]['lines_per_post'] ) $qti_error = $L['E_too_long'].S.sprintf($L['E_line_max'], $_SESSION[QT]['lines_per_post']);
$oPost->text = substr( QTconv($oPost->text,'3',QTI_CONVERT_AMP), 0, $_SESSION[QT]['chars_per_post'] );
if ($oPost->text=='') $qti_error = $L['Message'].S.$L['E_invalid'];
// PREPARE DISPLAY
if ( $_POST['action']=='nt' ) { $oVIP->selfname = $L['Post_new_topic']; $oPost->type = 'P'; }
if ( $_POST['action']=='ed' ) $oVIP->selfname = $L['Edit_message'];
// get user info
$oDB->Query('SELECT signature,avatar,location,role FROM '.TABUSER.' WHERE id='.$oPost->userid);
$row = $oDB->Getrow();
$oPost->userloca = $row['location'];
$oPost->useravat = $row['avatar'];
$oPost->usersign = $row['signature'];
$oPost->userrole = $row['role'];
// --------
// HTML START
// --------
HtmlDtd();
HtmlHead();
echo '
<body>
';
HtmlPageCtrl(0,'90%');
echo '
<div class="div_page_empty">
<h2>',$L['Preview'],'</h2>
';
if ( !empty($qti_error) ) echo '<p><span class="error">',$qti_error,'</span></p>';
$oPost->Show($oSEC,$oTopic,true,'','',$_SESSION[QT]['skin_dir'],'1');
echo '
<script type="text/javascript">
<!--
document.write(\'<a href="#" onclick="window.close();">',$L['Close'],' [x]</a>\')
-->
</script>
</div>
';
HtmlPageCtrl(1);
echo '
</body>
</html>';
?>