<?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
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @version 2.5 build:20100924
*/
session_start();
require_once('bin/qtf_init.php');
include(Translate('qtf_adm.php'));
include(Translate('qtf_reg.php'));
if ( $oVIP->role!='A' ) die(Error(13));
// ---------
// INITIALISE
// ---------
$s = -1; QThttpvar('s','int'); if ( $s<0 ) die('Missing parameters');
$oSEC = new cSection($s);
$intWidth = 50;
$intSize = 10;
$oVIP->selfurl = 'qtf_adm_section_img.php';
$oVIP->selfname = 'Logo';
$oVIP->exiturl = 'qtf_adm_section.php?tt=1&s='.$s;
// --------
// SUBMITTED FOR DELETE
// --------
if ( isset($_POST['del']) )
{
unlink('upload/section/'.$oSEC->d_logo);
$oSEC->SaveOptions( QTarradd(QTexplode($oSEC->options),'logo','0') );
$oVIP->selfname = $L['Section_upd'];
$oVIP->EndMessage(NULL,$L['S_delete'],$_SESSION[QT]['skin_dir'],2);
}
// --------
// SUBMITTED FOR UPLOAD
// --------
if ( isset($_POST['ok']) )
{
// Check uploaded document
$error = InvalidUpload($_FILES['title'],'gif,jpg,jpeg,png','',0,50,50);
// Upload
if ( empty($error) )
{
$strExt = strtolower(substr(strrchr($_FILES['title']['name'],'.'),1));
if ( !copy($_FILES['title']['tmp_name'],'upload/section/'.$s.'.'.$strExt) ) $error='Problem to copy the uploaded file in the application directory (upload/section/).';
unlink($_FILES['title']['tmp_name']);
}
// Update section
if ( empty($error) )
{
$oSEC->SaveOptions( QTarradd(QTexplode($oSEC->options),'logo',$s.'.'.$strExt) );
$oVIP->selfname = $L['Section_upd'];
$oVIP->EndMessage(NULL,$L['S_update'],$_SESSION[QT]['skin_dir'],2);
}
else
{
$oVIP->EndMessage(NULL,$error,$_SESSION[QT]['skin_dir'],0);
}
}
// --------
// HTML START
// --------
$strHeadScript = '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
if (theForm.title.value.length==0) { alert("'.$L['Missing'].': File"); return false; }
return null;
}
-->
</script>
';
include('qtf_adm_p_header.php');
$str='';
if ( file_exists('upload/section/'.$s.'.gif') ) $str = 'upload/section/'.$s.'.gif';
if ( file_exists('upload/section/'.$s.'.jpg') ) $str = 'upload/section/'.$s.'.jpg';
if ( file_exists('upload/section/'.$s.'.png') ) $str = 'upload/section/'.$s.'.png';
if ( file_exists('upload/section/'.$s.'.jpeg') ) $str = 'upload/section/'.$s.'.jpeg';
echo '<table class="hidden" cellspacing="0">
<tr class="hidden">
<td class="hidden" style="width:175px;"><br/>',AsImgBox(AsImg($str),'picbox'),'</td>
<td class="hidden" style="width:360px;">
';
HtmlMsg(0,'400px','',$L['Add'].' logo');
echo '<form method="post" action="',$oVIP->selfurl,'" enctype="multipart/form-data" onsubmit="return ValidateForm(this);">',N;
if ( !empty($error) ) echo '<span class="error">',$error,'</span>',N;
echo '<p style="text-align:right">32x32 pixels (max ',$intWidth,'x',$intWidth,' pixels)<br/><br/>
<input type="hidden" name="max_file_size" value="',($intSize*1024),'"/>
<input type="hidden" name="s" value="',$s,'"/>
<input type="file" id="title" name="title" size="32"/>
<input type="submit" name="ok" value="',$L['Save'],'"/></p>
</form>
';
HtmlMsg(1);
if ( !empty($str) )
{
HtmlMsg(0,'400px','',$L['Remove'].' logo');
echo '<form method="post" action="',$oVIP->selfurl,'">
<p style="text-align:right">
<input type="hidden" name="s" value="',$s,'"/>
<input type="submit" name="del" value="',$L['Delete'],'"/></p>
</form>
';
HtmlMsg(1);
}
echo '
</td>
</tr>
</table>
<p><a href="',$oVIP->exiturl,'">« ',$oVIP->exitname,'</a></p>
';
// --------
// HTML END
// --------
include('qtf_adm_p_footer.php');
?>