Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_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   Forum
* @package    QuickTalk forum
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20100924
* @since      File available since Release 1.0.0
* @deprecated File deprecated in Release 3.0.0
*/

session_start();
require_once('bin/qtf_init.php');
include(Translate('qtf_adm.php'));

if ( $oVIP->role!='A' ) die($L['E_admin']);

// INITIALISE

$oVIP->selfurl = 'qtf_adm_skin.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_settings'].'</span><br/>'.$L['Adm_layout'];

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

if ( isset($_POST['ok']) )
{
  // CHECK INPUTS

  $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.'] '.$L['E_invalid'].' (500-1024, 50%-100%)';
    }
    else
    {
      if ( $procent=='%' )
      {
      if ( !QTisbetween($str,50,100) ) { $error = $L['Site_width'].' ['.$str.'] '.$L['E_invalid'].' (500-1024 or 50%-100%)'; }
      }
      else
      {
      if ( !QTisbetween($str,500,1024) ) { $error = $L['Site_width'].' ['.$str.'] '.$L['E_invalid'].' (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) )
  {
    $_SESSION[QT]['skin_dir'] = $_POST['skin'];
    if ( !file_exists('skin/'.$_POST['skin'].'/qtf_main.css') )
    {
    $error=$L['Section_skin'].' '.$L['E_invalid'].' (qtf_main.css not found)';
    $_SESSION[QT]['skin_dir'] = 'default';
    }
  }

  // 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]['news_on_top'] = $_POST['news_on_top'];
    $_SESSION[QT]['topics_per_page'] = $_POST['topics_per_page'];
    $_SESSION[QT]['replies_per_page'] = $_POST['replies_per_page'];
    $_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'].S.$L['E_invalid']; }
    }
    if ( empty($error) )
    {
      $str = substr(trim($_POST['homeurl']),0,255);
      if ( !empty($str) ) { $_SESSION[QT]['home_url'] = $str; } else { $error = $L['Site_url'].': '.$L['E_invalid']; }
      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="'.$_SESSION[QT]['skin_dir'].'" 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"');
    $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'];

$bJava=true;
include('qtf_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['E_mandatory'],': ',$L['Site_width'],'")); return false; }
  if (theForm.items_per_page.value.length < 1) { alert(qtHtmldecode("',$L['E_mandatory'],': ',$L['Topics_per_section_page'],'")); return false; }
  return null;
}
-->
</script>
';

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table class="data_o" cellspacing="0" summary="skin">
<colgroup span="2"><col width="250"></col><col></col></colgroup>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="2">',$L['Skin'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Forum_skin'],'">
<td class="colhd colhdfirst"><label for="skin">',$L['Section_skin'],'</label></td>
<td class="colct"><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="colhd colhdfirst"><label for="banner">',$L['Show_banner'],'</label></td>
<td class="colct">
<select id="banner" name="banner" onchange="bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['show_banner']),'</select>
</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Show_legend'],'">
<td class="colhd colhdfirst"><label for="legend">',$L['Show_legend'],'</label></td>
<td class="colct">
<select id="legend" name="legend" onchange="bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['show_legend']),'</select>
</td>
</tr>
';

echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="2">',$L['Layout'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Site_width'],'">
<td class="colhd colhdfirst"><label for="width">',$L['Site_width'],'</label></td>
<td class="colct"><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="colhd colhdfirst"><label for="topics_per_page">',$L['Topics_per_section_page'],'</label></td>
<td class="colct"><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="colhd colhdfirst"><label for="replies_per_page">',$L['Replies_per_topic_page'],'</label></td>
<td class="colct"><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="colhd colhdfirst"><label for="welcome">',$L['Show_welcome'],'</label></td>
<td class="colct"><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="colhd colhdgroup" 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="colhd colhdfirst"><label for="home">',$L['Add_home'],'</label></td>
<td class="colct">
<select id="home" name="home" onchange="homedisabled(this.value); bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['home_menu']),'</select>
&nbsp;<input type="text" id="homename" name="homename" size="12" 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="colhd colhdfirst"><label for="homeurl">',$L['Home_website_url'],'</label></td>
<td class="colct"><input type="text" id="homeurl" name="homeurl" size="30" maxlength="100" value="',QTconv($_SESSION[QT]['home_url'],'I'),'"',($_SESSION[QT]['home_menu']=='0' ? QDIS : ''),' onchange="bEdited=true;"/></td>
</tr>
';

echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="2">',$L['Display_options'],'</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Repeat_section_description'],'">
<td class="colhd colhdfirst"><label for="section_desc">',$L['Repeat_section_description'],'</label></td>
<td class="colct">
<select id="section_desc" name="section_desc" onchange="bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['section_desc']),'</select>
</td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Show_news_on_top'],'">
<td class="colhd colhdfirst"><label for="news_on_top">',$L['Show_news_on_top'],'</label></td>
<td class="colct">
<select id="news_on_top" name="news_on_top" onchange="bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['news_on_top']),'</select>
</td>
</tr>
';
echo '<tr title="',$L['H_Show_quick_reply'],'">
<td class="colhd colhdfirst"><label for="show_quick_reply">',$L['Show_quick_reply'],'</label></td>
<td class="colct">
<select id="show_quick_reply" name="show_quick_reply" onchange="bEdited=true;">',QTasTag(array($L['N'],$L['Y']),$_SESSION[QT]['show_quick_reply']),'</select>
</td>
</tr>
';

echo '<tr class="data_o" title="',$L['Allow_bbc'],'">
<td class="colhd colhdfirst"><label for="bbc">',$L['Allow_bbc'],'</label></td>
<td class="colct"><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="colhd" colspan="2" style="padding:6px; text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';

// HTML END

include('qtf_adm_p_footer.php');

?>
Return current item: QuickTalk Forum