Location: PHPKode > projects > QuickTicket > quickticket/quickticket/qti_adm_skin.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.
 *
 * @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']);

// INITIALISE

$oVIP->selfurl = 'qti_adm_skin.php';
$oVIP->selfname = $L['Adm_layout'];

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

if ( isset($_POST['ok']) )
{
  $str = strip_tags(trim($_POST['width']));
  if ( substr($str,-1,1)=='%' ) { $procent = '%'; } else { $procent = ''; }
  $str = str_replace('%','',$str);
  if ( !is_numeric($str) )
  {
    $qti_error = $L['Site_width'].S.$L['E_invalid'].S.'(500-1024, 50%-100%)';
  }
  else
  {
    if ( $procent=='%' )
    {
    if ( !QTisbetween($str,50,100) ) $qti_error = $L['Site_width'].S.$L['E_invalid'].S.'(500-1024 or 50%-100%)';
    }
    else
    {
    if ( !QTisbetween($str,500,1024) ) $qti_error = $L['Site_width'].S.$L['E_invalid'].S.'(500-1024, 50%-100%)';
    }
  }
  $str .= $procent;
  if ( empty($qti_error) )
  {
  $_SESSION[QT]['site_width'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['site_width'].'" WHERE param="site_width"');
  }

  if ( empty($qti_error) )
  {
  $str = strip_tags(trim($_POST['topics_per_page']));
  if ( !QTisbetween($str,10,100) ) $qti_error = "{$L['Topics_per_section_page']} {$L['E_invalid']} (10-100)";
  }
  if ( empty($qti_error) )
  {
  $_SESSION[QT]['topics_per_page'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['topics_per_page'].'" WHERE param="topics_per_page"');
  }
  if ( empty($qti_error) )
  {
  $str = strip_tags(trim($_POST['replies_per_page']));
  if ( !QTisbetween($str,10,100) ) $qti_error = "{$L['Replies_per_topic_page']} {$L['E_invalid']} (10-100)";
  }
  if ( empty($qti_error) )
  {
  $_SESSION[QT]['replies_per_page'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['replies_per_page'].'" WHERE param="replies_per_page"');
  }

  // check skin
  if ( empty($qti_error) )
  {
    if ( !file_exists('skin/'.$_POST['skin'].'/qti_main.css') )
    {
    $qti_error = $L['Board_skin'].S.$L['E_invalid'].S.'(qti_main.css not found)';
    }
  }

  // check banner/welcome/legend/home
  if ( empty($qti_error) )
  {
    $_SESSION[QT]['skin_dir'] = 'skin/'.$_POST['skin'];
    $_SESSION[QT]['sys_welcome'] = $_POST['welcome'];
    $_SESSION[QT]['show_legend'] = $_POST['legend'];
    $_SESSION[QT]['show_banner'] = $_POST['banner'];
    $_SESSION[QT]['home_menu'] = $_POST['home'];
    $_SESSION[QT]['section_desc'] = $_POST['section_desc'];
    $_SESSION[QT]['news_on_top'] = $_POST['news_on_top'];
    $_SESSION[QT]['show_quick_reply'] = $_POST['show_quick_reply'];
    $_SESSION[QT]['show_calendar'] = $_POST['show_calendar'];
    $_SESSION[QT]['show_stats'] = $_POST['show_stats'];
  }

  // check homename
  if ( $_SESSION[QT]['home_menu']=='1' )
  {
    if ( empty($qti_error) )
    {
      $str = $_POST['homename']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
      $str = QTconv($str,'3',false);
      if ( !empty($str) ) { $_SESSION[QT]['home_name'] = $str; } else { $qti_error = $L['Home_website_name'].S.$L['E_invalid']; }
    }
    if ( empty($qti_error) )
    {
      $str = QTconv($_POST['homeurl'],'2');
      if ( !empty($str) ) { $_SESSION[QT]['home_url'] = $str; } else { $qti_error = $L['Site_url'].': '.$L['E_invalid']; }
      if ( !ereg('^(http://|https://)',$str) ) $qti_warning = $L['Home_website_url'].': '.$L['E_missing_http'];
      $_SESSION[QT]['home_url'] = $str;
    }
  }

  // save value
  if ( empty($qti_error) )
  {
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_POST['skin'].'" WHERE param="skin_dir"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['sys_welcome'].'" WHERE param="sys_welcome"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_banner'].'" WHERE param="show_banner"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_legend'].'" WHERE param="show_legend"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['home_menu'].'" WHERE param="home_menu"');
    if ( $_SESSION[QT]['home_menu']=='1' )
    {
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($_SESSION[QT]['home_name']).'" WHERE param="home_name"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['home_url'].'" WHERE param="home_url"');
    }
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['topics_per_page'].'" WHERE param="topics_per_page"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['replies_per_page'].'" WHERE param="replies_per_page"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['section_desc'].'" WHERE param="section_desc"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['news_on_top'].'" WHERE param="news_on_top"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_quick_reply'].'" WHERE param="show_quick_reply"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_calendar'].'" WHERE param="show_calendar"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_stats'].'" WHERE param="show_stats"');

  }

  // exit
  if ( empty($qti_error) ) $strInfo = $L['S_save'];
}

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

// WARNINGS

if ( !ereg('^(http://|https://)',$_SESSION[QT]['home_url']) ) $qti_warning = $L['Home_website_url'].': '.$L['E_missing_http'];

include('qti_adm_p_header.php');
include('qti_adm_p_title.php');

// Read directory in language

$intHandle = opendir('skin');
$arrFiles = array();
while ( false!==($strFile = readdir($intHandle)) )
{
if ( $strFile!='.' && $strFile!='..' ) $arrFiles[$strFile]=ucfirst($strFile);
}
closedir($intHandle);
asort($arrFiles);

// Current skin
$strDfltskin = substr($_SESSION[QT]['skin_dir'],5);

// FORM

echo '
<script type="text/javascript">
<!--
function homedisabled(str)
{
  if(str=="0")
  {
  document.getElementById("homename").disabled=true;
  document.getElementById("homeurl").disabled=true;
  }
  else
  {
  document.getElementById("homename").disabled=false;
  document.getElementById("homeurl").disabled=false;
  }
  return;
}
function ValidateForm(theForm)
{
  if (theForm.width.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Site_width'],'")); return false; }
  if (theForm.topics_per_page.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Topics_per_section_page'],'")); return false; }
  if (theForm.replies_per_page.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Replies_per_topic_page'],'")); return false; }
  return null;
}
-->
</script>
';

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table class="ta" cellspacing="0">
<colgroup span="2"><col width="250"></col><col></col></colgroup>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Skin'],'</th>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Board_skin'],'">
<th class="th_o th_o_first"><label for="skin">',$L['Board_skin'],'</label></th>
<td class="td_o">
<select id="skin" name="skin">',QTastags($arrFiles,null,$strDfltskin),'</select>
</td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Show_banner'],'">
<th class="th_o th_o_first"><label for="banner">',$L['Show_banner'],'</label></th>
<td class="td_o"><select id="banner" name="banner">
<option value="0"',($_SESSION[QT]['show_banner']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['show_banner']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Show_legend'],'">
<th class="th_o th_o_first"><label for="legend">',$L['Show_legend'],'</label></th>
<td class="td_o"><select id="legend" name="legend">
<option value="0"',($_SESSION[QT]['show_legend']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['show_legend']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Layout'],'</th>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Site_width'],'">
<th class="th_o th_o_first"><label for="width">',$L['Site_width'],'</label></th>
<td class="td_o"><input type="text" id="width" name="width" size="4" maxlength="4" value="',$_SESSION[QT]['site_width'],'"/>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Topics_per_section_page'],'">
<th class="th_o th_o_first"><label for="topics_per_page">',$L['Topics_per_section_page'],'</label></th>
<td class="td_o"><input type="text" id="topics_per_page" name="topics_per_page" size="3" maxlength="3" value="',$_SESSION[QT]['topics_per_page'],'"/>/',$L['Page'],'</td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Replies_per_topic_page'],'">
<th class="th_o th_o_first"><label for="replies_per_page">',$L['Replies_per_topic_page'],'</label></th>
<td class="td_o"><input type="text" id="replies_per_page" name="replies_per_page" size="3" maxlength="3" value="',$_SESSION[QT]['replies_per_page'],'"/>/',$L['Page'],'</td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Show_welcome'],'">
<th class="th_o th_o_first"><label for="welcome">',$L['Show_welcome'],'</label></th>
<td class="td_o"><select id="welcome" name="welcome">
<option value="2"',($_SESSION[QT]['sys_welcome']=='2' ? QSEL : ''),'>',$L['Y'],'</option>
<option value="0"',($_SESSION[QT]['sys_welcome']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['sys_welcome']=='1' ? QSEL : ''),'>',$L['While_unlogged'],'</option>
</select></td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Your_website'],'</th>
</tr>
';
$str = QTconv($_SESSION[QT]['home_name'],'I');
echo '<tr class="tr_t" title="',$L['H_Home_website_name'],'">
<th class="th_o th_o_first"><label for="home">',$L['Add_home'],'</label></th>
<td class="td_o"><select id="home" name="home"  onchange="homedisabled(this.value)">
<option value="0"',($_SESSION[QT]['home_menu']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['home_menu']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select>&nbsp;<input type="text" id="homename" name="homename" size="10" maxlength="24" value="',$str,'"',($_SESSION[QT]['home_menu']=='0' ? QDIS : ''),'/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['home_name'].'</span>' : ''),'</td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Website'],'">
<th class="th_o th_o_first"><label for="homeurl">',$L['Home_website_url'],'</label></th>
<td class="td_o"><input type="text" id="homeurl" name="homeurl" size="30" maxlength="100" value="',$_SESSION[QT]['home_url'],'"',($_SESSION[QT]['home_menu']=='0' ? QDIS : ''),'/></td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Display_options'],'</th>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Repeat_section_description'],'">
<th class="th_o th_o_first"><label for="section_desc">',$L['Repeat_section_description'],'</label></th>
<td class="td_o">
<select id="section_desc" name="section_desc">
<option value="0" ',($_SESSION[QT]['section_desc']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1" ',($_SESSION[QT]['section_desc']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Show_news_on_top'],'">
<th class="th_o th_o_first"><label for="news_on_top">',$L['Show_news_on_top'],'</label></th>
<td class="td_o"><select id="news_on_top" name="news_on_top">
<option value="0"',($_SESSION[QT]['news_on_top']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['news_on_top']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr title="',$L['H_Show_quick_reply'],'">
<th class="th_o th_o_first"><label for="show_quick_reply">',$L['Show_quick_reply'],'</label></th>
<td class="td_o"><select id="show_quick_reply" name="show_quick_reply">
<option value="0"',($_SESSION[QT]['show_quick_reply']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['show_quick_reply']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr title="',$L['H_Show_calendar'],'">
<th class="th_o th_o_first"><label for="show_calendar">',$L['Show_calendar'],'</label></th>
<td class="td_o">
<select id="show_calendar" name="show_calendar">',QTastags($L['Userroles'],null,$_SESSION[QT]['show_calendar']),'</select>
</td>
</tr>
';
echo '<tr title="',$L['H_Show_statistics'],'">
<th class="th_o th_o_first"><label for="show_stats">',$L['Show_statistics'],'</label></th>
<td class="td_o">
<select id="show_stats" name="show_stats">',QTastags($L['Userroles'],null,$_SESSION[QT]['show_stats']),'</select>
</td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_first" colspan="2" style="padding:6px; text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></th>
</tr>
';
echo '</table>
</form><br/>',N,N;

// HTML END

include('qti_adm_p_footer.php');

?>
Return current item: QuickTicket