Location: PHPKode > projects > QT-registrations > qtregistrations/qtr_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.
*
* @package    QT-registerations
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.4 build:20100313
*/

session_start();
require_once('bin/qtr_init.php');
include(Translate('qtr_adm.php'));

if ( $oVIP->role!='A' ) die(Error(13));

// INITIALISE

$oVIP->selfurl = 'qtr_adm_skin.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_settings'].'</span><br/>'.$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) )
  {
    $error = $L['Site_width'].' ['.$str.'] '.Error(1).' (500-1024, 50%-100%)';
  }
  else
  {
    if ( $procent=='%' )
    {
    if ( !QTisbetween($str,50,100) ) $error = $L['Site_width'].' ['.$str.'] '.Error(1).' (500-1024, 50%-100%)';
    }
    else
    {
    if ( !QTisbetween($str,500,1024) ) $error = $L['Site_width'].' ['.$str.'] '.Error(1).' (500-1024, 50%-100%)';
    }
  }
  $str .= $procent;
  if ( empty($error) )
  {
  $_SESSION[QT]['site_width'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['site_width'].'" WHERE param="site_width"');
  }

  // check skin
  if ( empty($error) )
  {
    if ( !file_exists('skin/'.$_POST['skin'].'/qtr_main.css') )
    {
    $error = $L['Board_skin'].' '.Error(1).' (qtr_main.css not found)';
    }
  }

  // check banner/welcome/legend/home
  if ( empty($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]['topics_per_page'] = $_POST['topics_per_page'];
    $_SESSION[QT]['replies_per_page'] = $_POST['replies_per_page'];
    $_SESSION[QT]['news_on_top'] = $_POST['news_on_top'];
    $_SESSION[QT]['show_quick_reply'] = $_POST['show_quick_reply'];
    $_SESSION[QT]['bbc']=$_POST['bbc'];
  }

  // check homename
  if ( $_SESSION[QT]['home_menu']=='1' )
  {
    if ( empty($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 { $error = $L['Home_website_name'].' '.Error(1); }
    }
    if ( empty($error) )
    {
      $str = substr(trim($_POST['homeurl']),0,255);
      if ( !empty($str) ) { $_SESSION[QT]['home_url'] = $str; } else { $error = $L['Site_url'].': '.Error(1); }
      if ( !preg_match('/^(http:\/\/|https:\/\/)/',$str) ) $warning = $L['Home_website_url'].': '.$L['E_missing_http'];
      $_SESSION[QT]['home_url'] = $str;
    }
  }

  // save value
  if ( empty($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="'.$_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]['bbc'].'" WHERE param="bbc"');
  }

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

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

// WARNINGS

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

include('qtr_adm_p_header.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(qtHtmldecode("',$L['Missing'],': ',$L['Site_width'],'")); return false; }
  if (theForm.topics_per_page.value.length<1) { alert(qtHtmldecode("',$L['Missing'],': ',$L['Topics_per_section_page'],'")); return false; }
  if (theForm.replies_per_page.value.length<1) { alert(qtHtmldecode("',$L['Missing'],': ',$L['Replies_per_topic_page'],'")); return false; }
  return null;
}
-->
</script>
';

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table class="data_o" cellspacing="0">
<colgroup span="2"><col width="250"></col><col></col></colgroup>
';
echo '<tr class="data_o">
<td class="th_o th_o_all" colspan="2">',$L['Skin'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Board_skin'],'">
<td class="th_o th_o_first"><label for="skin">',$L['Board_skin'],'</label></td>
<td class="td_o">
<select id="skin" name="skin" onchange="bEdited=true;">',QTasTag($arrFiles,$strDfltskin),'</select>
</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Show_banner'],'">
<td class="th_o th_o_first"><label for="banner">',$L['Show_banner'],'</label></td>
<td class="td_o"><select id="banner" name="banner" onchange="bEdited=true;">
<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="data_o" title="',$L['H_Show_legend'],'">
<td class="th_o th_o_first"><label for="legend">',$L['Show_legend'],'</label></td>
<td class="td_o"><select id="legend" name="legend" onchange="bEdited=true;">
<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="data_o">
<td class="th_o th_o_all" colspan="2">',$L['Layout'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Site_width'],'">
<td class="th_o th_o_first"><label for="width">',$L['Site_width'],'</label></td>
<td class="td_o"><input type="text" id="width" name="width" size="4" maxlength="4" value="',$_SESSION[QT]['site_width'],'" onchange="bEdited=true;"/>
</tr>
';
$arr = array('10'=>'10','20'=>'20','30'=>'30','40'=>'40','50'=>'50','100'=>'100');
echo '<tr class="data_o" title="',$L['H_Topics_per_section_page'],'">
<td class="th_o th_o_first"><label for="topics_per_page">',$L['Topics_per_section_page'],'</label></td>
<td class="td_o"><select id="topics_per_page" name="topics_per_page" onchange="bEdited=true;">
',QTasTag($arr,$_SESSION[QT]['topics_per_page'],array('format'=>'%s / '.strtolower($L['Page']))),'
</select></td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Replies_per_topic_page'],'">
<td class="th_o th_o_first"><label for="replies_per_page">',$L['Replies_per_topic_page'],'</label></td>
<td class="td_o"><select id="replies_per_page" name="replies_per_page" onchange="bEdited=true;">
',QTasTag($arr,$_SESSION[QT]['replies_per_page'],array('format'=>'%s / '.strtolower($L['Page']))),'
</select></td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Show_welcome'],'">
<td class="th_o th_o_first"><label for="welcome">',$L['Show_welcome'],'</label></td>
<td class="td_o"><select id="welcome" name="welcome" onchange="bEdited=true;">
<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="data_o">
<td class="th_o th_o_all" colspan="2">',$L['Your_website'],'</td>
</tr>
';
$str = QTconv($_SESSION[QT]['home_name'],'I');
echo '<tr class="data_o" title="',$L['H_Home_website_name'],'">
<td class="th_o th_o_first"><label for="home">',$L['Add_home'],'</label></td>
<td class="td_o"><select id="home" name="home"  onchange="homedisabled(this.value); bEdited=true;">
<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 : ''),' onchange="bEdited=true;"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['home_name'].'</span>' : ''),'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Website'],'">
<td class="th_o th_o_first"><label for="homeurl">',$L['Home_website_url'],'</label></td>
<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 : ''),' onchange="bEdited=true;"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_all" colspan="2">',$L['Display_options'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Repeat_section_description'],'">
<td class="th_o th_o_first"><label for="section_desc">',$L['Repeat_section_description'],'</label></td>
<td class="td_o">
<select id="section_desc" name="section_desc" onchange="bEdited=true;">
<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="data_o" title="',$L['H_Show_news_on_top'],'">
<td class="th_o th_o_first"><label for="news_on_top">',$L['Show_news_on_top'],'</label></td>
<td class="td_o"><select id="news_on_top" name="news_on_top" onchange="bEdited=true;">
<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'],'">
<td class="th_o th_o_first"><label for="show_quick_reply">',$L['Show_quick_reply'],'</label></td>
<td class="td_o"><select id="show_quick_reply" name="show_quick_reply" onchange="bEdited=true;">
<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 class="data_o" title="',$L['Allow_bbc'],'">
<td class="th_o th_o_first"><label for="bbc">',$L['Allow_bbc'],'</label></td>
<td class="td_o"><select id="bbc" name="bbc" onchange="bEdited=true;">
<option value="0"',($_SESSION[QT]['bbc']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['bbc']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first" colspan="2" style="padding:6px; text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';

// HTML END

include('qtr_adm_p_footer.php');

?>
Return current item: QT-registrations