Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_adm_region.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    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('bin/qtf_lang.php'); $arrLangDir = QTarrget($arrLang,2); // this creates an array with only the [iso]directories
include(Translate('qtf_adm.php'));
include(Translate('qtf_zone.php'));

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

// INITIALISE

$oVIP->selfurl = 'qtf_adm_region.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_settings'].'</span><br/>'.$L['Adm_region'];
$oVIP->exiturl = $oVIP->selfurl;
$oVIP->exitname = $oVIP->selfname;

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

if ( isset($_POST['ok']) )
{
  $_SESSION[QT]['time_zone'] = $_POST['timezone'];
  $_SESSION[QT]['show_time_zone'] = $_POST['showtimezone'];
  $_SESSION[QT]['userlang'] = $_POST['userlang'];
  $_SESSION[QT]['language'] = (isset($arrLangDir[$_POST['dfltlang']]) ? $arrLangDir[$_POST['dfltlang']] : 'english');

  // change language
  include(Translate('qtf_main.php'));
  include(Translate('qtf_adm.php'));
  include(Translate('qtf_zone.php'));
  $oVIP->selfname = $L['Adm_region'];
  $oVIP->exitname = $oVIP->selfname;

  // save
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['time_zone'].'" WHERE param="time_zone"');
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_time_zone'].'" WHERE param="show_time_zone"');
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['userlang'].'",loaded="1" WHERE param="userlang"');
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.(isset($arrLangDir[$_POST['dfltlang']]) ? $arrLangDir[$_POST['dfltlang']] : 'english').'" WHERE param="language"');

  // formatdate
  $str = trim($_POST['formatdate']); if ( get_magic_quotes_gpc() ) $str = stripslashes($_POST['formatdate']);
  if ( $str=='' ) $error = $L['E_invalid'].' '.$L['Date_format'];
  if ( empty($error) )
  {
  $_SESSION[QT]['formatdate'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['formatdate'].'" WHERE param="formatdate"');
  }

  // formattime
  $str = trim($_POST['formattime']); if ( get_magic_quotes_gpc() ) $str = stripslashes($_POST['formattime']);
  if ( $str=='' ) $error = $L['E_invalid'].' '.$L['Time_format'];
  if ( empty($error) )
  {
  $_SESSION[QT]['formattime'] = $str;
  $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['formattime'].'" WHERE param="formattime"');
  }

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

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

include('qtf_adm_p_header.php');

// Current language

$strCurrent = 'en';
  $arr = GetParam(false,'param="language"');
  $str = $arr['language'];
  $arr = array_flip($arrLangDir);
  if ( isset($arr[$str]) ) $strCurrent = $arr[$str];

// Check language subdirectories

$arrFiles = array();
foreach($arrLang as $strIso=>$arr)
{
  if ( is_dir('language/'.$arr[2]) ) $arrFiles[$strIso] = ucfirst($arr[1]);
}
asort($arrFiles);

// FORM

if ( PHP_VERSION_ID>=50200 ) echo '<p style="text-align:right">',$L['Time'],' ',date('H:i'), ' &middot; <a href="qtf_adm_time.php">',$L['Change_time'],'...</a>','</p>';

echo '
<form method="post" action="',$oVIP->selfurl,'">
<table class="data_o" cellspacing="0">
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="3">',$L['Language'],'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst" style="width:150px;"><label for="dfltlang">',$L['Dflt_language'],'</label></td>
<td class="colct" style="width:225px;"><select id="dfltlang" name="dfltlang" onchange="bEdited=true;">',QTasTag($arrFiles,$strCurrent),'</select></td>
<td class="colct"><span class="help">&nbsp;</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst" style="width:150px;"><label for="userlang">',$L['User_language'],'</label></td>
<td class="colct" style="width:200px;"><select id="userlang" name="userlang" onchange="bEdited=true;">
<option value="0"',($_SESSION[QT]['userlang']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['userlang']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
<td class="colct"><span class="help">',$L['H_User_language'],'</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="3">',$L['Date_time'],'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="formatdate">',$L['Date_format'],'</label></td>
<td class="colct"><input id="formatdate" name="formatdate" size="10" maxlength="24" value="',$_SESSION[QT]['formatdate'],'" onchange="bEdited=true;"/></td>
<td class="colct"><span class="help">',$L['H_Date_format'],'</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="formattime">',$L['Time_format'],'</label></td>
<td class="colct"><input id="formattime" name="formattime" size="10" maxlength="24" value="',$_SESSION[QT]['formattime'],'" onchange="bEdited=true;"/></td>
<td class="colct"><span class="help">',$L['H_Time_format'],'</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="3">',$L['Clock'],'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst">Application time</td>
<td class="colct">',date('H:i'),'</td>
<td class="colct"><span class="help">(Application gmt time ',gmdate('H:i'),')</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="timezone">',$L['Clock_setting'],'</label></td>
<td class="colct"><select id="timezone" name="timezone" onchange="bEdited=true;">',QTasTag($L['tz'],$_SESSION[QT]['time_zone']),'</select></td>
<td class="colct"><span class="help">&nbsp;</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst" style="width:150px;"><label for="showtimezone">',$L['Show_time_zone'],'</label></td>
<td class="colct" style="width:200px;"><select id="showtimezone" name="showtimezone" onchange="bEdited=true;">
<option value="0"',($_SESSION[QT]['show_time_zone']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['show_time_zone']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
<td class="colct"><span class="help">',$L['H_Show_time_zone'],'</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="3" style="padding:6px; text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';

echo '<h2>',$L['Format_preview'],'</h2>
<table class="data_o" style="width:350px;" cellspacing="0">
';
echo '<tr class="data_o">
<td class="colhd colhdfirst">',$L['Date'],'</td>
<td class="colct">',QTdatestr('now','$',''),'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst">',$L['Clock'],'</td>
<td class="colct">';
echo gmdate($_SESSION[QT]['formattime'],time()+(3600*$_SESSION[QT]['time_zone']));
if ( $_SESSION[QT]['show_time_zone']=='1' ) 
{
echo ' (gmt',($_SESSION[QT]['time_zone']>0 ? '+' : ''),($_SESSION[QT]['time_zone']==0 ? '' : $_SESSION[QT]['time_zone']),')';
}
echo '</td>
</tr>
</table>
';

// HTML END

include('qtf_adm_p_footer.php');

?>
Return current item: QuickTalk Forum