<?
/*
KISGB - a Guest Book script written in PHP.
Copyright (C) 2001-2002 Gaylen Fraley
hide@address.com
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
License file for more details.
*/
$cgi_id = $HTTP_POST_VARS['cgi_id'];
$cgi_pw = $HTTP_POST_VARS['cgi_pw'];
require("config.php");
$auth_id = $admin_id;
$auth_pw = $admin_pw;
$theme_keep = $theme;
$lang_keep = $language;
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
$tmp_theme = $HTTP_GET_VARS['tmp_theme'];
$tmp_lang = $HTTP_GET_VARS['tmp_lang'];
if ($tmp_theme>'') $theme = $tmp_theme;
if ($tmp_lang>'') $language = $tmp_lang;
$action = $HTTP_GET_VARS['action'];
require("$path_to_themes/$theme");
require("$path_to_languages/$language");
$theme = $theme_keep;
$language = $lang_keep;
if ($use_filter_file) require("filters.inc.php");
require("authenticate.php");
require("functions.php");
metaTags();
?>
<style type="text/css">
<?@include("style-sheet-view.php");?>
TD {
color: <?echo $Vwindow_text_color2; ?>;
background-color : <?echo $Vwindow_background_color2; ?>;
text-align:left;
}
</style>
<? js_getPointer(); ?>
<script type="text/javascript">
var _name_="";
</script>
<?
include("versionclient.php");
echo "<p><center><input id=\"btn\" onMouseOver=\"this.style.cursor=get_pointer();\" type=\"button\" value=\"$label_themebuilder\" onClick=\"window.open('$path_to_themes/theme_builder/index.php','');\" /></center></p>";
$handle=opendir("logs");
$log_sb = "";
$cnt = 0;
while (($file = readdir($handle))!==false) {
if ($file == '.'||$file == '..') continue;
$log = explode('.',$file);
if (chop($log[0]) == "default") continue;
if (chop($log[1]) != "logdef") continue;
$cnt++;
$logfile = "logs/".chop($log[0]).".".chop($log[1]).".php";
if ($cnt==1) {
$log_sb = "<select name=\"log\" onChange=\"if (this.options[this.selectedIndex].value!='$label_select') window.open(this.options[this.selectedIndex].value)\">\n";
$log_sb .= "<option value='$label_select' selected>- $label_select -</option>\n";
}
$log_sb .= "<option value=\"$logfile\">$log[0]</option>\n";
}
if ($cnt>0) $log_sb .= "</select>\n";
closedir($handle);
if ($cnt>0) {
$log_sb .= "</select>\n";
$log_sb = "<p><center>$log_sb</center><p>";
}
$config = file($path_to_user_prefs);
$number_of_lines = count($config);
$handle=opendir($path_to_themes);
$theme_sb = "";
$selected_theme = explode('.',$theme);
$cnt = 0;
while (($file = readdir($handle))!==false) {
if ($file == '.'||$file == '..') continue;
$thm = explode('.',$file);
if (chop($thm[1]) != "thm") continue;
$themes[] = $thm[0];
}
sort($themes);
$num_options = count($themes);
if ($num_options>0) {
for ($cnt=0;$cnt<$num_options;$cnt++) {
if ($cnt==0) {
$theme_sb = "<select name=theme>\n";
}
$selected = "";
if ($themes[$cnt] == $selected_theme[0]) $selected = "selected";
$theme_sb .= "<option value=\"$themes[$cnt].thm.php\" $selected>$themes[$cnt]</option>\n";
}
$theme_sb .= "</select>\n";
}
closedir($handle);
$handle=opendir($path_to_languages);
$lang_sb = "";
$selected_lang = explode('.',$language);
$cnt = 0;
while (($file = readdir($handle))!==false) {
if ($file == '.'||$file == '..') continue;
$lang = explode('.',$file);
if (chop($lang[1]) != "lang") continue;
$langs[] = $lang[0];
}
sort($langs);
$num_options = count($langs);
if ($num_options>0) {
for ($cnt=0;$cnt<$num_options;$cnt++) {
if ($cnt==0) {
$lang_sb = "<select name=language>\n";
}
$selected = "";
if ($langs[$cnt] == $selected_lang[0]) $selected = "selected";
$lang_sb .= "<option value=\"$langs[$cnt].lang.php\" $selected>$langs[$cnt]</option>\n";
}
$lang_sb .= "</select>\n";
}
closedir($handle);
if ($action != "update") {
?>
<html>
<head>
</head>
<body>
<form name=kisgb_color action="<?="$PHP_SELF?action=update&tmp_theme=$tmp_theme&tmp_lang=$tmp_lang" ?>" method=post>
<input type="hidden" name="cgi_id" value="<?=$cgi_id?>" /><input type="hidden" name="cgi_pw" value="<?=$cgi_pw?>" />
<?=$log_sb;?>
<table align="center" border="2" rules="none" cellspacing="0" cellpadding="0">
<tr>
<td align="left">[<a onClick="if (blur) self.blur();" href="<?=$path_to_docs?>/config.explain.html" target=_help><?=$label_help?></a>]</td>
<?if ($allow_msg_lvl_edit_by_admin||$allow_msg_lvl_edit_by_user) echo "<td></td>";?>
<td align="center">[<a href="<?=$root_document?>?action=view&tmp_theme=<?=$tmp_theme?>&tmp_lang=<?=$tmp_lang?>"><?=$label_view_gb?></a>]</td>
<?if ($allow_msg_lvl_edit_by_admin||$allow_msg_lvl_edit_by_user); else echo "<td align=\"right\">[<a href=\"admin.php?action=admin&tmp_theme=$tmp_theme&tmp_lang=$tmp_lang\">$label_back</a>]</td>";?>
<tr><td colspan="3"><hr size="1" /></td></tr>
<tr>
<td align="left">Setting</td>
<td align="left" colspan="2">Value</td>
</tr>
<?
for ($i=0; $i<$number_of_lines; $i++) {
if (substr($config[$i],0,2) == '<?'||substr($config[$i],0,2) == '?>') continue;
if (substr($config[$i],0,21)== '######### DO NOT EDIT') continue;
if (substr($config[$i],0,15)== 'if (file_exists') continue;
$t_checked = "";
$f_checked = "";
$color_b = "";
$line = explode("=",str_replace(';','',$config[$i]),2);
if (trim($line[1])=='true') $t_checked = 'checked';
if (trim($line[1])=='false') $f_checked = 'checked';
if (substr($line[0],0,1)!="$") $comment=true;
else $comment=false;
if ($comment) {
$tag = "<td colspan=\"3\"> $line[0]</td>";
}
else if (trim($line[0])=='$guestbook_signature'||trim($line[0])=='$admin_email_msg'||trim($line[0])=='$guest_email_msg') {
$_name_ = trim(substr($line[0],1));
$_line_ = trim($line[1]);
if (strpos(trim($line[0]),"_color")===false);
else $color_b="<input id=\"btn\" onMouseOver=\"this.style.cursor=get_pointer();\" type=\"button\" value=\"Colors\" onClick=\"_name_='$_name_';open('colorwheel.php','','width=256,height=350');\" />";
$tag = "<td> ".substr($line[0],1)." </td><td>$color_b<textarea name=\"$_name_\" rows=4 cols=50 >".substr($_line_,1,strlen($_line_)-2)."</textarea></td><td> </td></tr>";
}
else if (trim($line[0])=='$language') $tag = "<td> ".substr($line[0],1)." </td><td>$lang_sb</td><td> </td></tr>";
else if (trim($line[0])=='$theme') $tag = "<td> ".substr($line[0],1)." </td><td>$theme_sb</td><td> </td></tr>";
else if (trim($line[1])=='true'||trim($line[1])=='false') {$tag = "<td> ".substr($line[0],1)." </td><td><input type=\"radio\" name=\"".trim(substr($line[0],1))."\" $t_checked value=\"true\" />true <input type=\"radio\" name=\"".trim(substr($line[0],1))."\" $f_checked value=\"false\" />false</td><td> </td></tr>";}
else {
$_name_ = trim(substr($line[0],1));
if (strpos(trim($line[0]),"_color")===false);
else $color_b="<input id=\"btn\" onMouseOver=\"this.style.cursor=get_pointer();\" type=\"button\" value=\"Colors\" onClick=\"_name_='$_name_';open('colorwheel.php','','width=256,height=350');\" />";
$tag = "<td> ".substr($line[0],1)." </td><td>$color_b<input name=\"$_name_\" value=$line[1] size=40 /></td><td> </td></tr>";
}
?>
<tr><?=$tag;?>
<?
}
echo "<tr><td colspan=\"3\"> <tr><td align=\"center\" colspan=\"3\"><center><input id=\"btn\" onMouseOver=\"this.style.cursor=get_pointer();\" type=\"submit\" value=\"$label_update\"></center></td></tr>";
?>
</table>
</form>
</body>
</html>
<?
}
else if ($admin_from_web==true) {
reset ($HTTP_POST_VARS);
$ns=fopen($path_to_user_prefs,'w') or die("$unable_to_access_file_msg"." new $path_to_user_prefs.");
$row = 0;
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$val = str_replace('\n','{{{~}}}',$val); //used to preserve \n
$val = stripslashes($val);
$val = str_replace('{{{~}}}','\n',$val); //used to preserve \n
while (substr($config[$row],0,1)!='$'&&substr($config[$row],0,1)>' ') {
fwrite($ns,trim($config[$row])."\n");
$row++;
}
for ($i=0; $i<$number_of_lines; $i++) {
$line = explode("=",$config[$i]);
$val = $val==$line[1]?$line[1]:$val;
if (strtolower($val)=="true"||strtolower($val)=="false"||strtolower($val)=="on"||strtolower($val)=="off"||is_numeric($val)||is_numeric(preg_replace('(\+|\-|\*|\/)','',$val))) $quotes='';
else $quotes='"';
if (!strpos($val,'"')==FALSE) $quotes = ''; //used to preserve concantonated text
if (trim(substr($line[0],1))==trim($key)) {
fwrite($ns,$line[0]."= $quotes".$val."$quotes;\n");
$row++;
break;
}
}
}
fwrite($ns,"?>\n");
fclose($ns);
?>
<html>
<table border="1" align="center"><tr><td align="center"><center><?=$submit?> <?=$label_successful?></center></td></tr></table>
<p><center><a href="<?="$PHP_SELF?action=&cgi_id=$cgi_id&cgi_pw=$cgi_pw"?>"><?=$label_back?></a> <a href="<?=$root_document?>?action=view&tmp_theme=<?=$tmp_theme?>&tmp_lang=<?=$tmp_lang?>"><?=$label_view_gb?></a></center></p>
<? require("footer.php"); ?>
</html>
<?
}
else {
echo "<table border=\"1\" align=\"center\"><tr><td align=center><center>DEMO - $label_successful</center></td></tr></table><p><center><a href='$PHP_SELF?action=&tmp_theme=$tmp_theme&tmp_lang=$tmp_lang'>$label_back</a> <a href='$root_document?action=view&tmp_theme=$tmp_theme&tmp_lang=$tmp_lang'>$label_view_gb</a></center></p>";
require("footer.php");
exit;
}
?>