<?php
//===========================================================================
//* --    ~~                Crafty Syntax Live Help                ~~    -- *
//===========================================================================
//           URL:   http://www.craftysyntax.com/    EMAIL: eric@craftysyntax.com
//         Copyright (C) 2003-2005 Eric Gerdes   (http://www.craftysyntax.com )
// --------------------------------------------------------------------------
// $              CVS will be released with version 3.1.0                   $
// $    Please check http://www.craftysyntax.com/ or REGISTER your program for updates  $
// --------------------------------------------------------------------------
// NOTICE: Do NOT remove the copyright and/or license information any files. 
//         doing so will automatically terminate your rights to use program.
//         If you change the program you MUST clause your changes and note
//         that the original program is Crafty Syntax Live help or you will 
//         also be terminating your rights to use program and any segment 
//         of it.        
// --------------------------------------------------------------------------
// LICENSE:
//     This program is free software; you can redistribute it and/or
//     modify it under the terms of the GNU General Public License
//     as published by the Free Software Foundation; 
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with this program in a file named LICENSE.txt .
// --------------------------------------------------------------------------  
// BIG NOTE:
//     At the time of the release of this version of CSLH, Version 3.1.0 
//     which is a more modular, extendable , “skinable” version of CSLH
//     was being developed.. please visit http://www.craftysyntax.com to see if it was released! 
//===========================================================================
require_once("admin_common.php");
validate_session($identity);

// get the info of this user.. 
$query = "SELECT * FROM livehelp_users WHERE sessionid='".$identity['SESSIONID']."'";
$people = $mydatabase->query($query);
$people = $people->fetchRow(DB_FETCHMODE_ASSOC);
$myid = $people['user_id'];
$channel = $people['onchannel'];
$isadminsetting = $people['isadmin'];
if($isadminsetting != "Y"){
 print $lang['txt41'];
 $mydatabase->close_connect();
 exit;	
}
$lastaction = date("Ymdhis");
$startdate =  date("Ymd");

if(!(isset($UNTRUSTED['action']))){ $UNTRUSTED['action']=""; }
 
if($UNTRUSTED['action'] == "update"){
   $lastchar = substr($UNTRUSTED['newwebpath'],-1);
   if($lastchar != "/"){ $UNTRUSTED['newwebpath'] .= "/"; }
   $lastchar = substr($UNTRUSTED['news_webpath'],-1);
   if($lastchar != "/"){ $UNTRUSTED['news_webpath'] .= "/"; }    
   if(empty($UNTRUSTED['newmaxexe']))
   	 $UNTRUSTED['newmaxexe'] = 90;   	 
   if(empty($UNTRUSTED['newrefreshrate']))
   	 $UNTRUSTED['newrefreshrate'] = 1;    
   if( ($CSLH_Config['chatmode'] != $UNTRUSTED['new_chatmode']))    
       $newshow_typing = "Y";       
   $query = "UPDATE livehelp_config 
              SET 
                refreshrate='". filter_sql($UNTRUSTED['newrefreshrate'])."',
                maxexe=".intval($UNTRUSTED['newmaxexe']).",
                speaklanguage='".filter_sql($UNTRUSTED['newspeaklanguage'])."',
                s_webpath='".filter_sql($UNTRUSTED['news_webpath'])."',
                webpath='".filter_sql($UNTRUSTED['newwebpath'])."',
                show_typing='".filter_sql($UNTRUSTED['newshow_typing'])."',
                offset=".intval($UNTRUSTED['newoffset']).",
                chatmode='".filter_sql($UNTRUSTED['new_chatmode'])."',
                ignoreips='".filter_sql($UNTRUSTED['ignoreips'])."',
                tracking='".filter_sql($UNTRUSTED['tracking'])."',
                colorscheme='".filter_sql($UNTRUSTED['colorscheme'])."',
                gethostnames='".filter_sql($UNTRUSTED['gethostnames'])."',
                showgames='".filter_sql($UNTRUSTED['showgames'])."',
                usertracking='".filter_sql($UNTRUSTED['usertracking'])."',
                showdirectory='".filter_sql($UNTRUSTED['showdirectory'])."',  
                resetbutton='".filter_sql($UNTRUSTED['resetbutton'])."',  
                reftracking='".filter_sql($UNTRUSTED['reftracking'])."',
                keywordtrack='".filter_sql($UNTRUSTED['keywordtrack'])."', 
                rememberusers='".filter_sql($UNTRUSTED['rememberusers'])."',             
                site_title='".filter_sql($UNTRUSTED['newsite_title'])."'";
    $mydatabase->query($query);
    print "<font color=007700 size=+2>" . $lang['txt63'] . "</font>";  
    print "<SCRIPT> window.parent.location=\"admin.php?page=mastersettings.php&tab=settings\"; </SCRIPT>";
    print "<a href=admin.php?page=mastersettings.php&tab=settings>".$lang['txt186']."</a>";
    exit;   
 }
?>
<link title="new" rel="stylesheet" href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['charset']; ?>" >
<body bgcolor=<?php echo $color_background;?> ><center>
<?php
$query = "SELECT * FROM livehelp_config";
$data = $mydatabase->query($query);
$data = $data->fetchRow(DB_FETCHMODE_ASSOC);
$offset = $data['offset'];

if($data['use_flush'] == "YES"){
$continuous = " SELECTED ";
$refresh = "";
} else {
$continuous = "";
$refresh = " SELECTED ";	
}

if($data['show_typing'] == "N"){
  $typing_n = " CHECKED ";
  $typing_y = "";	 
} else {
  $typing_y = " CHECKED ";
  $typing_n = "";
}

if($data['gethostnames'] == "N"){
 $gethostnames_n = " CHECKED ";	
 $gethostnames_y = "  ";
} else {
 $gethostnames_y = " CHECKED ";	
 $gethostnames_n = "  ";
}

if($data['tracking'] == "N"){
 $tracking_n = " CHECKED ";	
 $tracking_y = "  ";
} else {
 $tracking_y = " CHECKED ";	
 $tracking_n = "  ";
}

if($data['showgames'] == "N"){
 $showgames_n = " CHECKED ";	
 $showgames_y = "  ";
} else {
 $showgames_y = " CHECKED ";	
 $showgames_n = "  ";
}

if($data['showdirectory'] == "N"){
 $showdirectory_n = " CHECKED ";	
 $showdirectory_y = "  ";
} else {
 $showdirectory_y = " CHECKED ";	
 $showdirectory_n = "  ";
} 

if($data['usertracking'] == "N"){
 $usertracking_n = " CHECKED ";	
 $usertracking_y = "  ";
} else {
 $usertracking_y = " CHECKED ";	
 $usertracking_n = "  ";
} 

if($data['resetbutton'] == "N"){
 $resetbutton_n = " CHECKED ";	
 $resetbutton_y = "  ";
} else {
 $resetbutton_y = " CHECKED ";	
 $resetbutton_n = "  ";
} 

if($data['keywordtrack'] == "N"){
 $keywordtrack_n = " CHECKED ";	
 $keywordtrack_y = "  ";
} else {
 $keywordtrack_y = " CHECKED ";	
 $keywordtrack_n = "  ";
} 

if($data['reftracking'] == "N"){
 $reftracking_n = " CHECKED ";	
 $reftracking_y = "  ";
} else {
 $reftracking_y = " CHECKED ";	
 $reftracking_n = "  ";
}     

if($data['rememberusers'] == "N"){
 $rememberusers_n = " CHECKED ";	
 $rememberusers_y = "  ";
} else {
 $rememberusers_y = " CHECKED ";	
 $rememberusers_n = "  ";
} 



?>
<table width=600<tr bgcolor=DDDDDD><td>
<b><?php echo $lang['settings']; ?>:</b></td></tr>
<tr bgcolor=FFFFFF><td>
<form action=mastersettings.php method=post name=configform>
<input type=hidden name=action value=update>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt74']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt75']; ?>
</td></tr></table>
<b>HTTP:</b><input type=text name=newwebpath value="<?php echo $CSLH_Config['webpath']; ?>" size=55><br>
<b>HTTPS:</b><input type=text name=news_webpath value="<?php echo $CSLH_Config['s_webpath']; ?>" size=55><br>


<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt187']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt188']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b><input type=radio value=Y name=reftracking <?php echo $reftracking_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=reftracking <?php echo $reftracking_n; ?> > <?php echo $lang['NO']; ?><br>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt189']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php $lang['txt190']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=tracking <?php echo $tracking_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=tracking <?php echo $tracking_n; ?> > <?php echo $lang['NO']; ?><br>
  
<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt191']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt192']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=usertracking <?php echo $usertracking_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=usertracking <?php echo $usertracking_n; ?> > <?php echo $lang['NO']; ?><br>
<?php echo $lang['txt210']; ?><br>
<b><?php echo $lang['txt211']; ?>:</b> <input type=radio value=Y name=rememberusers <?php echo $rememberusers_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=rememberusers <?php echo $rememberusers_n; ?> > <?php echo $lang['NO']; ?><br>


<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt193']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt194']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=keywordtrack <?php echo $keywordtrack_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=keywordtrack <?php echo $keywordtrack_n; ?> > <?php echo $lang['NO']; ?><br>
   
<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt195']?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt196']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=gethostnames <?php echo $gethostnames_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=gethostnames <?php echo $gethostnames_n; ?> > <?php echo $lang['NO']; ?><br>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<img src=images/games.gif width=25 height=25><b><?php echo $lang['txt197']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt198']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=showgames <?php echo $showgames_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=showgames <?php echo $showgames_n; ?> > <?php echo $lang['NO']; ?><br>
 
 <table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<img src=images/directory.gif width=25 height=25><b><?php echo $lang['txt199']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt200']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=showdirectory <?php echo $showdirectory_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=showdirectory <?php echo $showdirectory_n; ?> > <?php echo $lang['NO']; ?><br>
 
 <table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<img src=images/reset.gif width=25 height=25><b><?php echo $lang['txt201']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt202']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=resetbutton <?php echo $resetbutton_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=resetbutton <?php echo $resetbutton_n; ?> > <?php echo $lang['NO']; ?><br>
 
<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt203']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt204']; ?>:
</td></tr></table>
<b><?php echo $lang['color']; ?>:</b>:
<select name=colorscheme>
 <option value="yellow" <?php if($CSLH_Config['colorscheme']=="yellow") print " SELECTED "; ?>><?php echo $lang['Yellow']; ?></option>
 <option value="white" <?php if($CSLH_Config['colorscheme']=="white") print " SELECTED "; ?>><?php echo $lang['White']; ?></option>
 <option value="blue" <?php if($CSLH_Config['colorscheme']=="blue") print " SELECTED "; ?>><?php echo $lang['Blue']; ?></option>
 <option value="brown" <?php if($CSLH_Config['colorscheme']=="brown") print " SELECTED "; ?>><?php echo $lang['Brown']; ?></option> 
</select>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['Language']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt76']; ?>
</td></tr></table>
<b><?php echo $lang['Language']; ?>:</b>
<select name=newspeaklanguage>
<?php
// get list of installed langages..
$dir = "lang/";
$handle=opendir($dir);
	while($file=readdir($handle)){
	if (ereg("lang-",$file))
		{
		if ( (is_file("$dir/$file") && ($file!="lang-.php")))
			{
			$language = str_replace("lang-","",$file);
			$language = str_replace(".php","",$language);
			?><option value=<?php echo $language; ?> <?php if ($CSLH_Config['speaklanguage'] == $language){ print " SELECTED "; } ?> ><?php echo $language; ?> </option><?php
			}
		}
	}
?>
</select>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b>Chat Type:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt77']; ?>
</td></tr></table>
<b>Chat Type:</b><select name=new_chatmode>
<option value="xmlhttp-flush-refresh" <?php if ($CSLH_Config['chatmode'] == "xmlhttp-flush-refresh") print " SELECTED "; ?> > XML HTTP -&gt; Flush() -&gt; Refresh </option>
<option value="xmlhttp-refresh" <?php if ($CSLH_Config['chatmode'] == "xmlhttp-refresh") print " SELECTED "; ?> > XML HTTP -&gt; Refresh </option>
<option value="flush-xmlhttp-refresh" <?php if ($CSLH_Config['chatmode'] == "flush-xmlhttp-refresh") print " SELECTED "; ?> > Flush() -&gt; XML HTTP -&gt; Refresh </option>
<option value="flush-refresh" <?php if ($CSLH_Config['chatmode'] == "flush-refresh") print " SELECTED "; ?> > Flush() -&gt; Refresh </option>
<option value="refresh" <?php if ($CSLH_Config['chatmode'] == "refresh") print " SELECTED "; ?> > Refresh</option>
</select><br>

<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt159']; ?>
</td></tr></table>
<b>Flush() chatmode Refresh:</b>: <select name=newmaxexe>
<option value=14 <?php if ($CSLH_Config['maxexe'] == 14){ print " SELECTED "; } ?> > 15 Seconds </option>
<option value=30 <?php if ($CSLH_Config['maxexe'] == 30){ print " SELECTED "; } ?>> 30 Seconds </option>
<option value=60 <?php if ($CSLH_Config['maxexe'] == 60){ print " SELECTED "; } ?>> 60 Seconds </option>
<option value=90 <?php if ($CSLH_Config['maxexe'] == 90){ print " SELECTED "; } ?>> 90 Seconds </option>
<option value=180 <?php if ($CSLH_Config['maxexe'] == 180){ print " SELECTED "; } ?>> 180 Seconds </option>
<option value=300 <?php if ($CSLH_Config['maxexe'] == 300){ print " SELECTED "; } ?>> 300 Seconds </option>
<option value=600 <?php if ($CSLH_Config['maxexe'] == 600){ print " SELECTED "; } ?>> 600 Seconds </option>
<option value=900 <?php if ($CSLH_Config['maxexe'] == 900){ print " SELECTED "; } ?>> 900 Seconds </option>
<option value=1500 <?php if ($CSLH_Config['maxexe'] == 1500){ print " SELECTED "; } ?>> 1500 Seconds </option>
<option value=1000 <?php if ($CSLH_Config['maxexe'] == 2000){ print " SELECTED "; } ?>> 2000 Seconds </option>
<option value=4000 <?php if ($CSLH_Config['maxexe'] == 4000){ print " SELECTED "; } ?>> 4000 Seconds </option>
<option value=8000 <?php if ($CSLH_Config['maxexe'] == 8000){ print " SELECTED "; } ?>> 8000 Seconds </option>
</select>

<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt160']; ?>
</td></tr></table>
<b>Refresh chatmode Refresh</b>: <select name=newrefreshrate>
<option value=1 <?php if ($CSLH_Config['refreshrate'] == 1){ print " SELECTED "; } ?> > Auto Detect </option>
<option value=4 <?php if ($CSLH_Config['refreshrate'] == 3){ print " SELECTED "; } ?>> 3 Seconds </option>
<option value=5 <?php if ($CSLH_Config['refreshrate'] == 5){ print " SELECTED "; } ?>> 5 Seconds </option>
<option value=7 <?php if ($CSLH_Config['refreshrate'] == 7){ print " SELECTED "; } ?>> 7 Seconds </option>
<option value=10 <?php if ($CSLH_Config['refreshrate'] == 10){ print " SELECTED "; } ?>> 10 Seconds </option>
<option value=15 <?php if ($CSLH_Config['refreshrate'] == 15){ print " SELECTED "; } ?>> 15 Seconds </option>
</select>
<input type=hidden value=N name=newshow_typing>
<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt205']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt78']; ?>
</td></tr></table>
<b><?php echo $lang['txt205']; ?>:</b><select name=newoffset>
<option value=<?php echo $offset; ?>><?php echo $offset ?></option>
<option value=<?php echo $offset; ?>>---</option>
<?php 
for($i=-20;$i<20; $i++){ 
  print "<option value=$i>$i</option>\n";
} 
?>
</select><br>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['title']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt79']; ?>
</td></tr></table>
<b><?php echo $lang['title']; ?>:</b><input type=text name=newsite_title value="<?php echo $CSLH_Config['site_title']; ?>"><br>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['txt206']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt172']; ?>
</td></tr></table>
<textarea cols=45 rows=5 name=ignoreips><?php echo $CSLH_Config['ignoreips']; ?></textarea><br>

<table width=100% bgcolor=<?php echo $color_alt1;?>><tr><td>
<b><?php echo $lang['TYPINGPREVIEW']; ?>:</b>
</td></tr></table>
<table width=100% bgcolor=<?php echo $color_background;?>><tr><td>
<?php echo $lang['txt80']; ?>
</td></tr></table>
<b><?php echo $lang['Enable']; ?>:</b> <input type=radio value=Y name=newshow_typing <?php echo $typing_y; ?> > <?php echo $lang['YES']; ?> &nbsp;&nbsp;&nbsp;&nbsp;<input type=radio value=N name=newshow_typing <?php echo $typing_n; ?> > <?php echo $lang['NO']; ?><br>

<input type=submit value="<?php echo $lang['UPDATE']; ?>">
</body>
<?php
$mydatabase->close_connect();
?></td></tr></table>
<pre>


</pre>
<font size=-2>
<!-- Note if you remove this line you will be violating the license even if you have modified the program -->
<a href=http://www.craftysyntax.com/ target=_blank>Crafty Syntax Live Help</a> © 2003 - 2005 by <a href=http://www.craftysyntax.com/EricGerdes/ target=_blank>Eric Gerdes</a>  
<br>
CSLH is  Software released 
under the <a href=http://www.gnu.org/copyleft/gpl.html target=_blank>GNU/GPL license</a>  
</font>