Location: PHPKode > projects > QuickTicket > quickticket/quickticket/qti_adm_site.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_site.php';
$oVIP->selfname = $L['Adm_general'];

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

if ( isset($_POST['ok']) )
{
  // check sitename
  $str = $_POST['sitename']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
  $str = substr(QTconv($str,'3',false),0,64);
  if ( !empty($str) ) { $_SESSION[QT]['site_name'] = $str; } else { $qti_error = $L['Site_name'].S.$L['E_invalid']; }

  // check siteurl
  if ( empty($qti_error) )
  {
    $str = QTconv($_POST['siteurl'],'2');
    if ( substr($str,-1,1)=='/' ) $str = substr($str,0,-1);
    if ( !empty($str) ) { $_SESSION[QT]['site_url'] = $str; } else { $qti_error = $L['Site_url'].': '.$L['E_invalid']; }
    if ( !ereg("^(http://|https://)",$str) ) $qti_warning = $L['Site_url'].': '.$L['E_missing_http'];
  }

  // check indexname
  if ( empty($qti_error) )
  {
    $str = $_POST['title']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
    $str = substr(QTconv($str,'3',false),0,64);
    if ( !empty($str) ) { $_SESSION[QT]['index_name'] = $str; } else { $qti_error = $L['Name_of_index'].S.$L['E_invalid']; }
  }

  // check adminemail
  if ( empty($qti_error) )
  {
    $str = trim($_POST['adminmail']);
    if ( QTismail($str) ) { $_SESSION[QT]['admin_email'] = $str; } else { $qti_error = $L['Adm_e_mail'].S.$L['E_invalid']; }
  }

  // check others
  if ( empty($qti_error) )
  {
    $_SESSION[QT]['use_smtp'] = $_POST['smtp'];
    if ( $_SESSION[QT]['use_smtp']=='1' )
    {
    $_SESSION[QT]['smtp_host'] = $_POST['smtphost'];
    $_SESSION[QT]['smtp_username'] = $_POST['smtpusr'];
    $_SESSION[QT]['smtp_password'] = $_POST['smtppwd'];
    if ( empty($_SESSION[QT]['smtp_host']) ) $qti_error = 'Smtp host '.$L['E_invalid'];
    }
  }

  // save value
  if ( empty($qti_error) )
  {
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($_SESSION[QT]['site_name']).'" WHERE param="site_name"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['site_url'].'"WHERE param="site_url"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($_SESSION[QT]['index_name']).'" WHERE param="index_name"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['admin_email'].'" WHERE param="admin_email"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['use_smtp'].'" WHERE param="use_smtp"');
    if ( $_SESSION[QT]['smtp_host']=='1' )
    {
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['smtp_host'].'" WHERE param="smtp_host"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['smtp_username'].'" WHERE param="smtp_username"');
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['smtp_password'].'" WHERE param="smtp_password"');
    }
    $str = trim($_POST['adminfax']); if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
      $str = QTconv($str,'3',false);
      if ( strlen($str)>255 ) $str = substr($str,0,255);
      $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($str).'" WHERE param="admin_fax"');
      $_SESSION[QT]['admin_fax'] = $str;
    $str = trim($_POST['adminname']); if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
      $str = QTconv($str,'3',false);
      if ( strlen($str)>255 ) $str = substr($str,0,255);
      $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($str).'" WHERE param="admin_name"');
      $_SESSION[QT]['admin_name'] = $str;
    $str = trim($_POST['adminaddr']); if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
      $str = QTconv($str,'3',false);
      if ( strlen($str)>255 ) $str = substr($str,0,255);
      $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.addslashes($str).'" WHERE param="admin_addr"');
      $_SESSION[QT]['admin_addr'] = $str;

    // save lang

    cLang::Delete('index','i');
    foreach ($_POST as $strKey => $strTranslation)
    {
      if ( substr($strKey,0,1)=='T' )
      {
        if ( !empty($strTranslation) )
        {
        if ( get_magic_quotes_gpc() ) $strTranslation = stripslashes($strTranslation);
        cLang::Add('index',substr($strKey,1),'i',$strTranslation);
        }
      }
    }

    // register lang

    $_SESSION['L']['index'] = cLang::GetName('index',$_SESSION[QT]['lang_iso'],'*');

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

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

// WARNINGS

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

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

// FORM

echo '
<script type="text/javascript">
<!--
function smtpdisabled(str)
{
  if (str=="0")
  {
  document.getElementById("smtphost").disabled=true;
  document.getElementById("smtpusr").disabled=true;
  document.getElementById("smtppwd").disabled=true;
  }
  else
  {
  document.getElementById("smtphost").disabled=false;
  document.getElementById("smtpusr").disabled=false;
  document.getElementById("smtppwd").disabled=false;
  }
  return null;
}
function PassInLink()
{
  strHost = document.getElementById("smtphost").value;
  strUser = document.getElementById("smtpusr").value;
  strPass = document.getElementById("smtppwd").value;
  document.getElementById("smtplink").href="qti_adm_smtp.php?h=" + strHost + "&u=" + strUser + "&p=" + strPass;
  document.getElementById("smtplink").target="_blank";
  return null;
}
function ValidateForm(theForm)
{
  if (theForm.sitename.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Site_name'],'")); return false; }
  if (theForm.siteurl.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Site_url'],'")); return false; }
  if (theForm.siteurl.value.substr(0,4) != "http") { alert(html_entity_decode("http:// or https:// required in ',$L['Site_url'],'")); return false; }
  if (theForm.title.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Name_of_index'],'")); return false; }
  if (theForm.adminmail.value.length < 1) { alert(html_entity_decode("',$L['E_mandatory'],': ',$L['Adm_e_mail'],'")); return false; }
  return null;
}
-->
</script>
';

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table class="ta" cellspacing="0">
<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['General_site'],'</th>
</tr>
';
$str = QTconv($_SESSION[QT]['site_name'],'I');
echo '<tr class="tr_t" title="',$L['H_Site_name'],'">
<th class="th_o th_o_first" style="width:200px;"><label for="sitename">',$L['Site_name'],'</label></th>
<td class="td_o"><input type="text" id="sitename" name="sitename" size="50" maxlength="64" value="',$str,'"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['site_name'].'</span>' : ''),'</td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Site_url'],'">
<th class="th_o th_o_first"><label for="siteurl">',$L['Site_url'],'</label></th>
<td class="td_o"><input type="text" id="siteurl" name="siteurl" size="50" maxlength="255" value="',$_SESSION[QT]['site_url'],'"/></td>
</tr>
';
$str = QTconv($_SESSION[QT]['index_name'],'I');
echo '<tr class="tr_t" title="',$L['H_Name_of_index'],'">
<th class="th_o th_o_first"><label for="title">',$L['Name_of_index'],'</label></th>
<td class="td_o">
<input type="text" id="title" name="title" size="50" maxlength="64" value="',$str,'" style="background-color:#FFFF99"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['index_name'].'</span>' : ''),'</td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Contact'],'</th>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Admin_e_mail'],'">
<th class="th_o th_o_first"><label for="adminmail">',$L['Adm_e_mail'],'</label></th>
<td class="td_o"><input type="text" id="adminmail" name="adminmail" size="50" maxlength="255" value="',$_SESSION[QT]['admin_email'],'"/></td>
</tr>
';
$str = QTconv($_SESSION[QT]['admin_fax'],'I');
echo '<tr class="tr_t" title="',$L['H_Admin_fax'],'">
<th class="th_o th_o_first"><label for="adminfax">',$L['Adm_fax'],'</label></th>
<td class="td_o"><input type="text" id="adminfax" name="adminfax" size="50" maxlength="255" value="',$str,'"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['admin_fax'].'</span>' : ''),'</td>
</tr>
';
$str = QTconv($_SESSION[QT]['admin_name'],'I');
echo '<tr class="tr_t" title="',$L['Adm_name'],'">
<th class="th_o th_o_first"><label for="adminname">',$L['Adm_name'],'</label></th>
<td class="td_o"><input type="text" id="adminname" name="adminname" size="50" maxlength="255" value="',$str,'"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['admin_name'].'</span>' : ''),'</td>
</tr>
';
$str = QTconv($_SESSION[QT]['admin_addr'],'I');
echo '<tr class="tr_t" title="',$L['Adm_addr'],'">
<th class="th_o th_o_first"><label for="adminaddr">',$L['Adm_addr'],'</label></th>
<td class="td_o"><input type="text" id="adminaddr" name="adminaddr" size="50" maxlength="255" value="',$str,'"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$_SESSION[QT]['admin_addr'].'</span>' : ''),'</td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o th_o_all" colspan="2">',$L['Email_settings'],'</th>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Use_smtp'],'">
<th class="th_o th_o_first"><label for="smtp">',$L['Use_smtp'],'</label></th>
<td class="td_o">
<select id="smtp" name="smtp" onchange="smtpdisabled(this.value)">
<option value="0"',($_SESSION[QT]['use_smtp']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['use_smtp']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select></td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Use_smtp'],'">
<th class="th_o th_o_first"><label for="smtphost">Smtp host</label></th>
<td class="td_o"><input type="text" id="smtphost" name="smtphost" size="28" maxlength="64" value="',$_SESSION[QT]['smtp_host'],'"'.($_SESSION[QT]['use_smtp']=='0' ? QDIS : '').'/></td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Use_smtp'],'">
<th class="th_o th_o_first"><label for="smtpusr">Smtp username</label></th>
<td class="td_o"><input type="text" id="smtpusr" name="smtpusr" size="28" maxlength="64" value="',$_SESSION[QT]['smtp_username'],'"'.($_SESSION[QT]['use_smtp']=='0' ? QDIS : '').'/></td>
</tr>
';
echo '<tr class="tr_t" title="',$L['H_Use_smtp'],'">
<th class="th_o th_o_first"><label for="smtppwd">Smtp password</label></th>
<td class="td_o"><input type="text" id="smtppwd" name="smtppwd" size="28" maxlength="64" value="',$_SESSION[QT]['smtp_password'],'"'.($_SESSION[QT]['use_smtp']=='0' ? QDIS : '').'/> <a id="smtplink" href="qti_adm_smtp.php" onclick="PassInLink()">test smtp</a></td>
</tr>
';
echo '<th class="th_o th_o_all" colspan="3">',$L['Translations'],'</th>
<tr class="tr tr_o">
<th class="th_o th_o_first">',$L['Name_of_index'],'</th>
<td class="td_o" colspan="2">
<p class="help">',sprintf($L['E_no_translation'],$_SESSION[QT]['index_name']),'</p>
<table cellspacing="0" class="ta_hidden">';
$arrTrans = cLang::GetTrans('index','i');
include('bin/qti_lang.php'); // this creates $arrLang
foreach ($arrLang as $strIso => $arr)
{
  $str = '';
  if ( isset($arrTrans[$strIso]) ) {
  if ( !empty($arrTrans[$strIso]) ) {
    $str = QTconv($arrTrans[$strIso],'I');
  }}
  echo '
  <tr>
  <td class="td_hidden" style="width:30px"><span title="',$arr[1],'">',$arr[0],'</span></td>
  <td class="td_hidden"><input class="small" title="',$L['Name_of_index'],' (',$strIso,')" type="text" id="T',$strIso,'" name="T',$strIso,'" size="45" maxlength="64" value="',$str,'"/>',(strstr($str,'&amp;') ?  ' <span class="small">'.$arrTrans[$strIso].'</span>' : ''),'</td>
  </tr>
  ';
}
echo '</table>
</td>
</tr>
';
echo '<tr class="tr_t">
<th class="th_o" colspan="2" style="padding:6px; text-align:center"><input type="submit" name="ok" value="',$L['Save'],'"/></th>
</tr>
';
echo '</table>
</form>
';

// HTML END

include('qti_adm_p_footer.php');

?>
Return current item: QuickTicket