Profile
MAJ is an Open Source, PHP-based content management system (CMS) that can be deployed as a blog, bulletin or message board, Internet forum, and wiki. It is extensible via PHP panels and is HTML5 and CSS3 ready.
Git
This commit has been accessed 1530 times via Git panel.

commit 52b4786704c102e06cc7ad3e542321ee732d6545
tree 4ec45a07124bbead20d3228d437a5230099855de
parent e7ff7a8105123767b478e4c848887d00164a73d0
author Engels Antonio <engels@majcms.org> 1277314189 +0800
committer Engels Antonio <engels@majcms.org> 1277314189 +0800

    maj-0.14-20071008-bb.zip

diff --git a/album.php b/album.php
index 4f1d3b3..d3f6131 100644
--- a/album.php
+++ b/album.php
@@ -39,13 +39,44 @@ $login_username = file_get_contents("data/username.txt");
 //     exit();
 //}
 
-if ((!isset($_REQUEST['caption']) or empty($_REQUEST['caption'])) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "delete")) {
+
+       unlink("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
+
        if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
                unlink("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
        }
+
+       if (file_exists("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt")) {
+               unlink("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt");
+       }
+}
+
+if (isset($_REQUEST['filename']) and !empty($_REQUEST['filename']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "rename") and !file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['filename']}")) {
+
+       $filename = strtolower($_REQUEST['filename']);
+       $filename = str_replace(" ","_",$filename);
+       $filename = trim($filename);
+
+       rename("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}","images/{$_REQUEST['entry']}/album/{$filename}");
+
+       if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
+               rename("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt","data/items/{$_REQUEST['entry']}/album/captions/{$filename}.txt");
+       }
+
+       if (file_exists("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt")) {
+               rename("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","data/items/{$_REQUEST['entry']}/album/views/{$filename}.txt");
+       }
 }
 
-if (isset($_REQUEST['caption']) and !empty($_REQUEST['caption']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+if ((!isset($_REQUEST['caption']) or empty($_REQUEST['caption'])) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "caption")) {
+
+       if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
+               unlink("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
+       }
+}
+
+if (isset($_REQUEST['caption']) and !empty($_REQUEST['caption']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "caption")) {
        $caption_put = ucfirst($_REQUEST['caption']);
        $caption_put = str_replace(':((', '<img src=images/smileys/crying.png border=0>', $caption_put);
        $caption_put = str_replace(':(', '<img src=images/smileys/frown.png border=0>', $caption_put);
@@ -80,9 +111,11 @@ if (isset($_REQUEST['caption']) and !empty($_REQUEST['caption']) and isset($_SES
        if (!file_exists("data/items/{$_REQUEST['entry']}/album")) {
                mkdir("data/items/{$_REQUEST['entry']}/album");
        }
+
        if (!file_exists("data/items/{$_REQUEST['entry']}/album/captions")) {
                mkdir("data/items/{$_REQUEST['entry']}/album/captions");
        }
+
        $open_caption_txt_file = fopen("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt","w");
        fwrite($open_caption_txt_file,$caption_put);
        fclose($open_caption_txt_file);
@@ -175,7 +208,24 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
        echo "<img src=images/{$_REQUEST['entry']}/album/{$_REQUEST['show']} width=$album_image_width height=$album_image_height border=0>";
        echo "</td></tr>";
        if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username)) {
-               echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\"><tr bgcolor=#ffffff><td colspan=4>";
+               echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
+               echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
+               echo "<input type=hidden name=show value={$_REQUEST['show']}>";
+               echo "<input type=hidden name=edit value=delete>";
+               echo "<tr bgcolor=#ffffff><td colspan=4><input type=submit class=input value=\"click here to delete image\"></td></tr>";
+               echo "</form>";
+               echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
+               echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
+               echo "<input type=hidden name=show value={$_REQUEST['show']}>";
+               echo "<input type=hidden name=edit value=rename>";
+               echo "<tr bgcolor=#ffffff><td colspan=4><input type=text class=input name=filename value={$_REQUEST['show']}></td></tr>";
+               echo "<tr bgcolor=#ffffff><td colspan=4><input type=submit class=input value=\"click here to rename image\"></td></tr>";
+               echo "</form>";
+               echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
+               echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
+               echo "<input type=hidden name=show value={$_REQUEST['show']}>";
+               echo "<input type=hidden name=edit value=caption>";
+               echo "<tr bgcolor=#ffffff><td colspan=4>";
                echo "<textarea class=input name=caption rows=3>";
                if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
                        $caption_get = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
@@ -195,7 +245,8 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
                        echo $caption_get;
                }
                echo "</textarea>";
-               echo "<input type=hidden name=entry value={$_REQUEST['entry']}><input type=hidden name=show value={$_REQUEST['show']}><input type=hidden name=edit value=on><input type=submit class=input value=\"click here to update caption\"></td></tr></form>";
+               echo "<input type=submit class=input value=\"click here to update caption\">";
+               echo "</td></tr></form>";
        }
        if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
                if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
@@ -258,21 +309,27 @@ if (file_exists("images/{$_REQUEST['entry']}/album")) {
                        $max_height = 73;
       
                        if (($current_width > $max_width) || ($current_height > $max_height)) {  
+
                                if ($current_height > $current_width) {
                                        $sizefactor = (double) ($max_height / $current_height);
                                }
                                else {
                                        $sizefactor = (double) ($max_width / $current_width) ;
                                }
-                       }
 
-                       $new_width = (int) ($current_width * $sizefactor);
-                       $new_height = (int) ($current_height * $sizefactor);
+                               $new_width = (int) ($current_width * $sizefactor);
+                               $new_height = (int) ($current_height * $sizefactor);
+                       }
+                       else {
+                               $new_width = $current_width;
+                               $new_height = $current_height;
+                       }
 
                        if (!file_exists("images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg")) {
       
                                $work_thumb = imagecreatetruecolor($new_width,$new_height);
                                $get_mimetype = image_type_to_mime_type(exif_imagetype($current_image));
+
                                switch($get_mimetype) {
                                        case "image/jpg":
                                        case "image/jpeg":
@@ -286,13 +343,13 @@ if (file_exists("images/{$_REQUEST['entry']}/album")) {
                                                break;
                                }
       
-                               imagecopyresampled($work_thumb, $work_image ,0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
+                               imagecopyresampled($work_thumb,$work_image,0,0,0,0,$new_width,$new_height,$current_width,$current_height);
       
                                if (!file_exists("images/{$_REQUEST['entry']}/thumbnails")) {
                                        mkdir("images/{$_REQUEST['entry']}/thumbnails");
                                }
       
-                               imagejpeg($work_thumb, "images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg", 80);
+                               imagejpeg($work_thumb,"images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg",80);
       
                        }
 
diff --git a/colors.php b/colors.php
index 959ac82..9b24d94 100644
--- a/colors.php
+++ b/colors.php
@@ -37,33 +37,46 @@ if (!file_exists("data/colors")) {
        mkdir("data/colors");
 }
 
-if (isset($_REQUEST['reset']) and ($_REQUEST['reset'] == "go")) {
-       function rmdirr($recurse_dirname)
-       {
+if (!file_exists("data/schemes")) {
+       mkdir("data/schemes");
+}
+
+if (!file_exists("data/schemes/colors")) {
+       mkdir("data/schemes/colors");
+}
 
-           if (!file_exists($recurse_dirname)) {
-               return false;
-           }
+function rmdirr($recurse_dirname) {
 
-           if (is_file($recurse_dirname)) {
-               return unlink($recurse_dirname);
-           }
+       if (!file_exists($recurse_dirname)) {
+               return false;
+       }
+
+       if (is_file($recurse_dirname)) {
+               return unlink($recurse_dirname);
+       }
 
-           $recurse_dir = dir($recurse_dirname);
-           while (false !== $recurse_entry = $recurse_dir->read()) {
+       $recurse_dir = dir($recurse_dirname);
 
-               if ($recurse_entry == '.' || $recurse_entry == '..') {
-                   continue;
-               }
+       while (false !== $recurse_entry = $recurse_dir->read()) {
 
-               rmdirr("$recurse_dirname/$recurse_entry");
-           }
+               if ($recurse_entry == '.' || $recurse_entry == '..') {
+                       continue;
+               }
 
-           $recurse_dir->close();
-           return rmdir($recurse_dirname);
+               rmdirr("$recurse_dirname/$recurse_entry");
        }
 
+       $recurse_dir->close();
+       return rmdir($recurse_dirname);
+}
+
+if (isset($_REQUEST['reset']) and ($_REQUEST['reset'] == "go")) {
+
        rmdirr("data/colors");
+
+       if (file_exists("data/schemes/current/color.txt")) {
+               unlink("data/schemes/current/color.txt");
+       }
 }
 
 
@@ -80,9 +93,9 @@ if (isset($_REQUEST['target']) and !empty($_REQUEST['target']) and isset($_REQUE
 
        $color_value = str_replace("%23", "#", $_REQUEST['color']);
        $color_value = strtolower($color_value);
-       $valid_colors = array("#000000","#000033","#000066","#000080","#00008b","#000099","#0000cc","#0000cd","#0000ff","#003300","#003333","#003366","#003399","#0033cc","#0033ff","#006400","#006600","#006633","#006666","#006699","#0066cc","#0066ff","#008000","#008080","#008b8b","#009900","#009933","#009966","#009999","#0099cc","#0099ff","#00bfff","#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#00ced1","#00fa9a","#00ff00","#00ff33","#00ff66","#00ff7f","#00ff99","#00ffcc","#00ffff","#191970","#1e90ff","#20b2aa","#228b22","#2e8b57","#2f4f4f","#32cd32","#330000","#330033","#330066","#330099","#3300cc","#3300ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff","#336600","#336633","#336666","#336699","#3366cc","#3366ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff","#33cc00","#33cc33","#33cc66","#33cc99","#33cccc","#33ccff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff","#3cb371","#40e0d0","#4169e1","#4682b4","#483d8b","#48d1cc","#4b0082","#556b2f","#5f9ea0","#6495ed","#660000","#660033","#660066","#660099","#6600cc","#6600ff","#663300","#663333","#663366","#663399","#6633cc","#6633ff","#666600","#666633","#666666","#666699","#6666cc","#6666ff","#669900","#669933","#669966","#669999","#6699cc","#6699ff","#66cc00","#66cc33","#66cc66","#66cc99","#66cccc","#66ccff","#66cdaa","#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#696969","#6a5acd","#6b8e23","#708090","#778899","#7b68ee","#7cfc00","#7fff00","#7fffd4","#800000","#800080","#808000","#808080","#8470ff","#87ceeb","#87cefa","#8a2be2","#8b0000","#8b008b","#8b4513","#8fbc8f","#90ee90","#9370d8","#9400d3","#98fb98","#990000","#990033","#990066","#990099","#9900cc","#9900ff","#9932cc","#993300","#993333","#993366","#993399","#9933cc","#9933ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff","#999900","#999933","#999966","#999999","#9999cc","#9999ff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff","#99ff00","#99ff33","#99ff66","#99ff99","#99ffcc","#99ffff","#9acd32","#a0522d","#a52a2a","#a9a9a9","#add8e6","#adff2f","#afeeee","aliceblue","antiquewhite","aqua","aquamarine","azure","#b0c4de","#b0e0e6","#b22222","#b8860b","#ba55d3","#bc8f8f","#bdb76b","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","#c0c0c0","#c71585","cadetblue","#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#cc3300","#cc3333","#cc3366","#cc3399","#cc33cc","#cc33ff","#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#cc9900","#cc9933","#cc9966","#cc9999","#cc99cc","#cc99ff","#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ccff00","#ccff33","#ccff66","#ccff99","#ccffcc","#ccffff","#cd5c5c","#cd853f","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","#d02090","#d19275","#d2691e","#d2b48c","#d3d3d3","#d87093","#d8bfd8","#da70d6","#daa520","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","#dc143c","#dcdcdc","#dda0dd","#deb887","deeppink","deepskyblue","dimgray","dodgerblue","#e0ffff","#e6e6fa","#e9967a","#ee82ee","#eee8aa","#f08080","#f0e68c","#f0f8ff","#f0fff0","#f0ffff","#f4a460","#f5deb3","#f5f5dc","#f5f5f5","#f5fffa","#f8f8ff","#fa8072","#faebd7","#faf0e6","#fafad2","#fdf5e6","feldspar","#ff0000","#ff0033","#ff0066","#ff0099","#ff00cc","#ff00ff","#ff1493","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff","#ff4500","#ff6347","#ff6600","#ff6633","#ff6666","#ff6699","#ff66cc","#ff66ff","#ff69b4","#ff7f50","#ff8c00","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff","#ffa07a","#ffa500","#ffb6c1","#ffc0cb","#ffcc00","#ffcc33","#ffcc66","#ffcc99","#ffcccc","#ffccff","#ffd700","#ffdab9","#ffdead","#ffe4b5","#ffe4c4","#ffe4e1","#ffebcd","#ffefd5","#fff0f5","#fff5ee","#fff8dc","#fffacd","#fffaf0","#fffafa","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffe0","#fffff0","#ffffff","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslateblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","violetred","wheat","white","whitesmoke","yellow","yellowgreen","transparent");
+       $valid_colors = array("aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","purple","red","silver","teal","white","yellow","transparent");
 
-       if (in_array($color_value, $valid_colors)) {
+       if (in_array($color_value, $valid_colors) or ((strlen($color_value) == 7) and strstr($color_value,"#"))) {
                $color_file = str_replace("_", "-", $_REQUEST['target']);
                $color_file = "data/colors/{$color_file}.txt";
                $color_txt = fopen($color_file,"w");
@@ -91,239 +104,300 @@ if (isset($_REQUEST['target']) and !empty($_REQUEST['target']) and isset($_REQUE
        }
 }
 
+if (isset($_REQUEST['id']) and !empty($_REQUEST['id']) and !file_exists("data/schemes/colors/{$_REQUEST['id']}")) {
+       $id = strtolower($_REQUEST['id']);
+       $id = trim($id);
+       $id = str_replace(" ","_",$id);
 
-?>
+       if (!file_exists("data/schemes/colors/$id")) {
+               mkdir("data/schemes/colors/$id");
+       }
+
+       if (file_exists("data/colors/bg.txt")) {
+               copy("data/colors/bg.txt","data/schemes/colors/$id/bg.txt");
+       }
+
+       if (file_exists("data/colors/border.txt")) {
+               copy("data/colors/border.txt","data/schemes/colors/$id/border.txt");
+       }
+
+       if (file_exists("data/colors/font.txt")) {
+               copy("data/colors/font.txt","data/schemes/colors/$id/font.txt");
+       }
 
-<script language="JavaScript">
-<!-- Begin
-function showColor(val) {
-document.colorform.color.value = val;
+       if (file_exists("data/colors/hover.txt")) {
+               copy("data/colors/hover.txt","data/schemes/colors/$id/hover.txt");
+       }
+
+       if (file_exists("data/colors/link.txt")) {
+               copy("data/colors/link.txt","data/schemes/colors/$id/link.txt");
+       }
+
+       if (file_exists("data/colors/pb-bg.txt")) {
+               copy("data/colors/pb-bg.txt","data/schemes/colors/$id/pb-bg.txt");
+       }
+
+       if (file_exists("data/colors/pb-font.txt")) {
+               copy("data/colors/pb-font.txt","data/schemes/colors/$id/pb-font.txt");
+       }
+
+       if (file_exists("data/colors/pf-bg.txt")) {
+               copy("data/colors/pf-bg.txt","data/schemes/colors/$id/pf-bg.txt");
+       }
+
+       if (file_exists("data/colors/pf-font.txt")) {
+               copy("data/colors/pf-font.txt","data/schemes/colors/$id/pf-font.txt");
+       }
+
+       if (file_exists("data/colors/pt-bg.txt")) {
+               copy("data/colors/pt-bg.txt","data/schemes/colors/$id/pt-bg.txt");
+       }
+
+       if (file_exists("data/colors/pt-font.txt")) {
+               copy("data/colors/pt-font.txt","data/schemes/colors/$id/pt-font.txt");
+       }
+
+       if (file_exists("data/colors/vlink.txt")) {
+               copy("data/colors/vlink.txt","data/schemes/colors/$id/vlink.txt");
+       }
+
+       if (count(glob("data/schemes/colors/*")) === 1) {
+               $first_scheme = fopen("data/schemes/current/color.txt","w");
+               fwrite($first_scheme,$id);
+               fclose($first_scheme);
+       }
 }
-//  End -->
-</script>
 
-<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="colorform" method="get">
-<map name="colmap">
-<area shape="rect" coords="1,1,7,10" href="javascript:showColor('#00FF00')">
-<area shape="rect" coords="9,1,15,10" href="javascript:showColor('#00FF33')">
-<area shape="rect" coords="17,1,23,10" href="javascript:showColor('#00FF66')">
-<area shape="rect" coords="25,1,31,10" href="javascript:showColor('#00FF99')">
-<area shape="rect" coords="33,1,39,10" href="javascript:showColor('#00FFCC')">
-<area shape="rect" coords="41,1,47,10" href="javascript:showColor('#00FFFF')">
-<area shape="rect" coords="49,1,55,10" href="javascript:showColor('#33FF00')">
-<area shape="rect" coords="57,1,63,10" href="javascript:showColor('#33FF33')">
-<area shape="rect" coords="65,1,71,10" href="javascript:showColor('#33FF66')">
-<area shape="rect" coords="73,1,79,10" href="javascript:showColor('#33FF99')">
-<area shape="rect" coords="81,1,87,10" href="javascript:showColor('#33FFCC')">
-<area shape="rect" coords="89,1,95,10" href="javascript:showColor('#33FFFF')">
-<area shape="rect" coords="97,1,103,10" href="javascript:showColor('#66FF00')">
-<area shape="rect" coords="105,1,111,10" href="javascript:showColor('#66FF33')">
-<area shape="rect" coords="113,1,119,10" href="javascript:showColor('#66FF66')">
-<area shape="rect" coords="121,1,127,10" href="javascript:showColor('#66FF99')">
-<area shape="rect" coords="129,1,135,10" href="javascript:showColor('#66FFCC')">
-<area shape="rect" coords="137,1,143,10" href="javascript:showColor('#66FFFF')">
-<area shape="rect" coords="145,1,151,10" href="javascript:showColor('#99FF00')">
-<area shape="rect" coords="153,1,159,10" href="javascript:showColor('#99FF33')">
-<area shape="rect" coords="161,1,167,10" href="javascript:showColor('#99FF66')">
-<area shape="rect" coords="169,1,175,10" href="javascript:showColor('#99FF99')">
-<area shape="rect" coords="177,1,183,10" href="javascript:showColor('#99FFCC')">
-<area shape="rect" coords="185,1,191,10" href="javascript:showColor('#99FFFF')">
-<area shape="rect" coords="193,1,199,10" href="javascript:showColor('#CCFF00')">
-<area shape="rect" coords="201,1,207,10" href="javascript:showColor('#CCFF33')">
-<area shape="rect" coords="209,1,215,10" href="javascript:showColor('#CCFF66')">
-<area shape="rect" coords="217,1,223,10" href="javascript:showColor('#CCFF99')">
-<area shape="rect" coords="225,1,231,10" href="javascript:showColor('#CCFFCC')">
-<area shape="rect" coords="233,1,239,10" href="javascript:showColor('#CCFFFF')">
-<area shape="rect" coords="241,1,247,10" href="javascript:showColor('#FFFF00')">
-<area shape="rect" coords="249,1,255,10" href="javascript:showColor('#FFFF33')">
-<area shape="rect" coords="257,1,263,10" href="javascript:showColor('#FFFF66')">
-<area shape="rect" coords="265,1,271,10" href="javascript:showColor('#FFFF99')">
-<area shape="rect" coords="273,1,279,10" href="javascript:showColor('#FFFFCC')">
-<area shape="rect" coords="281,1,287,10" href="javascript:showColor('#ffffff')">
-<area shape="rect" coords="1,12,7,21" href="javascript:showColor('#00CC00')">
-<area shape="rect" coords="9,12,15,21" href="javascript:showColor('#00CC33')">
-<area shape="rect" coords="17,12,23,21" href="javascript:showColor('#00CC66')">
-<area shape="rect" coords="25,12,31,21" href="javascript:showColor('#00CC99')">
-<area shape="rect" coords="33,12,39,21" href="javascript:showColor('#00CCCC')">
-<area shape="rect" coords="41,12,47,21" href="javascript:showColor('#00CCFF')">
-<area shape="rect" coords="49,12,55,21" href="javascript:showColor('#33CC00')">
-<area shape="rect" coords="57,12,63,21" href="javascript:showColor('#33CC33')">
-<area shape="rect" coords="65,12,71,21" href="javascript:showColor('#33CC66')">
-<area shape="rect" coords="73,12,79,21" href="javascript:showColor('#33CC99')">
-<area shape="rect" coords="81,12,87,21" href="javascript:showColor('#33CCCC')">
-<area shape="rect" coords="89,12,95,21" href="javascript:showColor('#33CCFF')">
-<area shape="rect" coords="97,12,103,21" href="javascript:showColor('#66CC00')">
-<area shape="rect" coords="105,12,111,21" href="javascript:showColor('#66CC33')">
-<area shape="rect" coords="113,12,119,21" href="javascript:showColor('#66CC66')">
-<area shape="rect" coords="121,12,127,21" href="javascript:showColor('#66CC99')">
-<area shape="rect" coords="129,12,135,21" href="javascript:showColor('#66CCCC')">
-<area shape="rect" coords="137,12,143,21" href="javascript:showColor('#66CCFF')">
-<area shape="rect" coords="145,12,151,21" href="javascript:showColor('#99CC00')">
-<area shape="rect" coords="153,12,159,21" href="javascript:showColor('#99CC33')">
-<area shape="rect" coords="161,12,167,21" href="javascript:showColor('#99CC66')">
-<area shape="rect" coords="169,12,175,21" href="javascript:showColor('#99CC99')">
-<area shape="rect" coords="177,12,183,21" href="javascript:showColor('#99CCCC')">
-<area shape="rect" coords="185,12,191,21" href="javascript:showColor('#99CCFF')">
-<area shape="rect" coords="193,12,199,21" href="javascript:showColor('#CCCC00')">
-<area shape="rect" coords="201,12,207,21" href="javascript:showColor('#CCCC33')">
-<area shape="rect" coords="209,12,215,21" href="javascript:showColor('#CCCC66')">
-<area shape="rect" coords="217,12,223,21" href="javascript:showColor('#CCCC99')">
-<area shape="rect" coords="225,12,231,21" href="javascript:showColor('#CCCCCC')">
-<area shape="rect" coords="233,12,239,21" href="javascript:showColor('#CCCCFF')">
-<area shape="rect" coords="241,12,247,21" href="javascript:showColor('#FFCC00')">
-<area shape="rect" coords="249,12,255,21" href="javascript:showColor('#FFCC33')">
-<area shape="rect" coords="257,12,263,21" href="javascript:showColor('#FFCC66')">
-<area shape="rect" coords="265,12,271,21" href="javascript:showColor('#FFCC99')">
-<area shape="rect" coords="273,12,279,21" href="javascript:showColor('#FFCCCC')">
-<area shape="rect" coords="281,12,287,21" href="javascript:showColor('#FFCCFF')">
-<area shape="rect" coords="1,23,7,32" href="javascript:showColor('#009900')">
-<area shape="rect" coords="9,23,15,32" href="javascript:showColor('#009933')">
-<area shape="rect" coords="17,23,23,32" href="javascript:showColor('#009966')">
-<area shape="rect" coords="25,23,31,32" href="javascript:showColor('#009999')">
-<area shape="rect" coords="33,23,39,32" href="javascript:showColor('#0099CC')">
-<area shape="rect" coords="41,23,47,32" href="javascript:showColor('#0099FF')">
-<area shape="rect" coords="49,23,55,32" href="javascript:showColor('#339900')">
-<area shape="rect" coords="57,23,63,32" href="javascript:showColor('#339933')">
-<area shape="rect" coords="65,23,71,32" href="javascript:showColor('#339966')">
-<area shape="rect" coords="73,23,79,32" href="javascript:showColor('#339999')">
-<area shape="rect" coords="81,23,87,32" href="javascript:showColor('#3399CC')">
-<area shape="rect" coords="89,23,95,32" href="javascript:showColor('#3399FF')">
-<area shape="rect" coords="97,23,103,32" href="javascript:showColor('#669900')">
-<area shape="rect" coords="105,23,111,32" href="javascript:showColor('#669933')">
-<area shape="rect" coords="113,23,119,32" href="javascript:showColor('#669966')">
-<area shape="rect" coords="121,23,127,32" href="javascript:showColor('#669999')">
-<area shape="rect" coords="129,23,135,32" href="javascript:showColor('#6699CC')">
-<area shape="rect" coords="137,23,143,32" href="javascript:showColor('#6699FF')">
-<area shape="rect" coords="145,23,151,32" href="javascript:showColor('#999900')">
-<area shape="rect" coords="153,23,159,32" href="javascript:showColor('#999933')">
-<area shape="rect" coords="161,23,167,32" href="javascript:showColor('#999966')">
-<area shape="rect" coords="169,23,175,32" href="javascript:showColor('#999999')">
-<area shape="rect" coords="177,23,183,32" href="javascript:showColor('#9999CC')">
-<area shape="rect" coords="185,23,191,32" href="javascript:showColor('#9999FF')">
-<area shape="rect" coords="193,23,199,32" href="javascript:showColor('#CC9900')">
-<area shape="rect" coords="201,23,207,32" href="javascript:showColor('#CC9933')">
-<area shape="rect" coords="209,23,215,32" href="javascript:showColor('#CC9966')">
-<area shape="rect" coords="217,23,223,32" href="javascript:showColor('#CC9999')">
-<area shape="rect" coords="225,23,231,32" href="javascript:showColor('#CC99CC')">
-<area shape="rect" coords="233,23,239,32" href="javascript:showColor('#CC99FF')">
-<area shape="rect" coords="241,23,247,32" href="javascript:showColor('#FF9900')">
-<area shape="rect" coords="249,23,255,32" href="javascript:showColor('#FF9933')">
-<area shape="rect" coords="257,23,263,32" href="javascript:showColor('#FF9966')">
-<area shape="rect" coords="265,23,271,32" href="javascript:showColor('#FF9999')">
-<area shape="rect" coords="273,23,279,32" href="javascript:showColor('#FF99CC')">
-<area shape="rect" coords="281,23,287,32" href="javascript:showColor('#FF99FF')">
-<area shape="rect" coords="1,34,7,43" href="javascript:showColor('#006600')">
-<area shape="rect" coords="9,34,15,43" href="javascript:showColor('#006633')">
-<area shape="rect" coords="17,34,23,43" href="javascript:showColor('#006666')">
-<area shape="rect" coords="25,34,31,43" href="javascript:showColor('#006699')">
-<area shape="rect" coords="33,34,39,43" href="javascript:showColor('#0066CC')">
-<area shape="rect" coords="41,34,47,43" href="javascript:showColor('#0066FF')">
-<area shape="rect" coords="49,34,55,43" href="javascript:showColor('#336600')">
-<area shape="rect" coords="57,34,63,43" href="javascript:showColor('#336633')">
-<area shape="rect" coords="65,34,71,43" href="javascript:showColor('#336666')">
-<area shape="rect" coords="73,34,79,43" href="javascript:showColor('#336699')">
-<area shape="rect" coords="81,34,87,43" href="javascript:showColor('#3366CC')">
-<area shape="rect" coords="89,34,95,43" href="javascript:showColor('#3366FF')">
-<area shape="rect" coords="97,34,103,43" href="javascript:showColor('#666600')">
-<area shape="rect" coords="105,34,111,43" href="javascript:showColor('#666633')">
-<area shape="rect" coords="113,34,119,43" href="javascript:showColor('#666666')">
-<area shape="rect" coords="121,34,127,43" href="javascript:showColor('#666699')">
-<area shape="rect" coords="129,34,135,43" href="javascript:showColor('#6666CC')">
-<area shape="rect" coords="137,34,143,43" href="javascript:showColor('#6666FF')">
-<area shape="rect" coords="145,34,151,43" href="javascript:showColor('#996600')">
-<area shape="rect" coords="153,34,159,43" href="javascript:showColor('#996633')">
-<area shape="rect" coords="161,34,167,43" href="javascript:showColor('#996666')">
-<area shape="rect" coords="169,34,175,43" href="javascript:showColor('#996699')">
-<area shape="rect" coords="177,34,183,43" href="javascript:showColor('#9966CC')">
-<area shape="rect" coords="185,34,191,43" href="javascript:showColor('#9966FF')">
-<area shape="rect" coords="193,34,199,43" href="javascript:showColor('#CC6600')">
-<area shape="rect" coords="201,34,207,43" href="javascript:showColor('#CC6633')">
-<area shape="rect" coords="209,34,215,43" href="javascript:showColor('#CC6666')">
-<area shape="rect" coords="217,34,223,43" href="javascript:showColor('#CC6699')">
-<area shape="rect" coords="225,34,231,43" href="javascript:showColor('#CC66CC')">
-<area shape="rect" coords="233,34,239,43" href="javascript:showColor('#CC66FF')">
-<area shape="rect" coords="241,34,247,43" href="javascript:showColor('#FF6600')">
-<area shape="rect" coords="249,34,255,43" href="javascript:showColor('#FF6633')">
-<area shape="rect" coords="257,34,263,43" href="javascript:showColor('#FF6666')">
-<area shape="rect" coords="265,34,271,43" href="javascript:showColor('#FF6699')">
-<area shape="rect" coords="273,34,279,43" href="javascript:showColor('#FF66CC')">
-<area shape="rect" coords="281,34,287,43" href="javascript:showColor('#FF66FF')">
-<area shape="rect" coords="1,45,7,54" href="javascript:showColor('#003300')">
-<area shape="rect" coords="9,45,15,54" href="javascript:showColor('#003333')">
-<area shape="rect" coords="17,45,23,54" href="javascript:showColor('#003366')">
-<area shape="rect" coords="25,45,31,54" href="javascript:showColor('#003399')">
-<area shape="rect" coords="33,45,39,54" href="javascript:showColor('#0033CC')">
-<area shape="rect" coords="41,45,47,54" href="javascript:showColor('#0033FF')">
-<area shape="rect" coords="49,45,55,54" href="javascript:showColor('#333300')">
-<area shape="rect" coords="57,45,63,54" href="javascript:showColor('#333333')">
-<area shape="rect" coords="65,45,71,54" href="javascript:showColor('#333366')">
-<area shape="rect" coords="73,45,79,54" href="javascript:showColor('#333399')">
-<area shape="rect" coords="81,45,87,54" href="javascript:showColor('#3333CC')">
-<area shape="rect" coords="89,45,95,54" href="javascript:showColor('#3333FF')">
-<area shape="rect" coords="97,45,103,54" href="javascript:showColor('#663300')">
-<area shape="rect" coords="105,45,111,54" href="javascript:showColor('#663333')">
-<area shape="rect" coords="113,45,119,54" href="javascript:showColor('#663366')">
-<area shape="rect" coords="121,45,127,54" href="javascript:showColor('#663399')">
-<area shape="rect" coords="129,45,135,54" href="javascript:showColor('#6633CC')">
-<area shape="rect" coords="137,45,143,54" href="javascript:showColor('#6633FF')">
-<area shape="rect" coords="145,45,151,54" href="javascript:showColor('#993300')">
-<area shape="rect" coords="153,45,159,54" href="javascript:showColor('#993333')">
-<area shape="rect" coords="161,45,167,54" href="javascript:showColor('#993366')">
-<area shape="rect" coords="169,45,175,54" href="javascript:showColor('#993399')">
-<area shape="rect" coords="177,45,183,54" href="javascript:showColor('#9933CC')">
-<area shape="rect" coords="185,45,191,54" href="javascript:showColor('#9933FF')">
-<area shape="rect" coords="193,45,199,54" href="javascript:showColor('#CC3300')">
-<area shape="rect" coords="201,45,207,54" href="javascript:showColor('#CC3333')">
-<area shape="rect" coords="209,45,215,54" href="javascript:showColor('#CC3366')">
-<area shape="rect" coords="217,45,223,54" href="javascript:showColor('#CC3399')">
-<area shape="rect" coords="225,45,231,54" href="javascript:showColor('#CC33CC')">
-<area shape="rect" coords="233,45,239,54" href="javascript:showColor('#CC33FF')">
-<area shape="rect" coords="241,45,247,54" href="javascript:showColor('#FF3300')">
-<area shape="rect" coords="249,45,255,54" href="javascript:showColor('#FF3333')">
-<area shape="rect" coords="257,45,263,54" href="javascript:showColor('#FF3366')">
-<area shape="rect" coords="265,45,271,54" href="javascript:showColor('#FF3399')">
-<area shape="rect" coords="273,45,279,54" href="javascript:showColor('#FF33CC')">
-<area shape="rect" coords="281,45,287,54" href="javascript:showColor('#FF33FF')">
-<area shape="rect" coords="1,56,7,65" href="javascript:showColor('#000000')">
-<area shape="rect" coords="9,56,15,65" href="javascript:showColor('#000033')">
-<area shape="rect" coords="17,56,23,65" href="javascript:showColor('#000066')">
-<area shape="rect" coords="25,56,31,65" href="javascript:showColor('#000099')">
-<area shape="rect" coords="33,56,39,65" href="javascript:showColor('#0000CC')">
-<area shape="rect" coords="41,56,47,65" href="javascript:showColor('#0000FF')">
-<area shape="rect" coords="49,56,55,65" href="javascript:showColor('#330000')">
-<area shape="rect" coords="57,56,63,65" href="javascript:showColor('#330033')">
-<area shape="rect" coords="65,56,71,65" href="javascript:showColor('#330066')">
-<area shape="rect" coords="73,56,79,65" href="javascript:showColor('#330099')">
-<area shape="rect" coords="81,56,87,65" href="javascript:showColor('#3300CC')">
-<area shape="rect" coords="89,56,95,65" href="javascript:showColor('#3300FF')">
-<area shape="rect" coords="97,56,103,65" href="javascript:showColor('#660000')">
-<area shape="rect" coords="105,56,111,65" href="javascript:showColor('#660033')">
-<area shape="rect" coords="113,56,119,65" href="javascript:showColor('#660066')">
-<area shape="rect" coords="121,56,127,65" href="javascript:showColor('#660099')">
-<area shape="rect" coords="129,56,135,65" href="javascript:showColor('#6600CC')">
-<area shape="rect" coords="137,56,143,65" href="javascript:showColor('#6600FF')">
-<area shape="rect" coords="145,56,151,65" href="javascript:showColor('#990000')">
-<area shape="rect" coords="153,56,159,65" href="javascript:showColor('#990033')">
-<area shape="rect" coords="161,56,167,65" href="javascript:showColor('#990066')">
-<area shape="rect" coords="169,56,175,65" href="javascript:showColor('#990099')">
-<area shape="rect" coords="177,56,183,65" href="javascript:showColor('#9900CC')">
-<area shape="rect" coords="185,56,191,65" href="javascript:showColor('#9900FF')">
-<area shape="rect" coords="193,56,199,65" href="javascript:showColor('#CC0000')">
-<area shape="rect" coords="201,56,207,65" href="javascript:showColor('#CC0033')">
-<area shape="rect" coords="209,56,215,65" href="javascript:showColor('#CC0066')">
-<area shape="rect" coords="217,56,223,65" href="javascript:showColor('#CC0099')">
-<area shape="rect" coords="225,56,231,65" href="javascript:showColor('#CC00CC')">
-<area shape="rect" coords="233,56,239,65" href="javascript:showColor('#CC00FF')">
-<area shape="rect" coords="241,56,247,65" href="javascript:showColor('#FF0000')">
-<area shape="rect" coords="249,56,255,65" href="javascript:showColor('#FF0033')">
-<area shape="rect" coords="257,56,263,65" href="javascript:showColor('#FF0066')">
-<area shape="rect" coords="265,56,271,65" href="javascript:showColor('#FF0099')">
-<area shape="rect" coords="273,56,279,65" href="javascript:showColor('#FF00CC')">
-<area shape="rect" coords="281,56,287,65" href="javascript:showColor('#FF00FF')">
-</map>
+if (isset($_REQUEST['scheme']) and !empty($_REQUEST['scheme'])) {
+
+       $scheme = strtolower($_REQUEST['scheme']);
+       $scheme = trim($scheme);
+       $scheme = str_replace(" ","_",$scheme);
+
+       if (file_exists("data/schemes/colors/$scheme")) {
+
+               switch ($_REQUEST['scheme_axn']) {
+      
+                       case 'click here to apply selected scheme':
+
+                               if (file_exists("data/colors/bg.txt")) {
+                                       unlink("data/colors/bg.txt");
+                               }
+              
+                               if (file_exists("data/colors/border.txt")) {
+                                       unlink("data/colors/border.txt");
+                               }
+              
+                               if (file_exists("data/colors/font.txt")) {
+                                       unlink("data/colors/font.txt");
+                               }
+              
+                               if (file_exists("data/colors/hover.txt")) {
+                                       unlink("data/colors/hover.txt");
+                               }
+              
+                               if (file_exists("data/colors/link.txt")) {
+                                       unlink("data/colors/link.txt");
+                               }
+              
+                               if (file_exists("data/colors/pb-bg.txt")) {
+                                       unlink("data/colors/pb-bg.txt");
+                               }
+              
+                               if (file_exists("data/colors/pb-font.txt")) {
+                                       unlink("data/colors/pb-font.txt");
+                               }
+              
+                               if (file_exists("data/colors/pf-bg.txt")) {
+                                       unlink("data/colors/pf-bg.txt");
+                               }
+              
+                               if (file_exists("data/colors/pf-font.txt")) {
+                                       unlink("data/colors/pf-font.txt");
+                               }
+              
+                               if (file_exists("data/colors/pt-bg.txt")) {
+                                       unlink("data/colors/pt-bg.txt");
+                               }
+              
+                               if (file_exists("data/colors/pt-font.txt")) {
+                                       unlink("data/colors/pt-font.txt");
+                               }
+              
+                               if (file_exists("data/colors/vlink.txt")) {
+                                       unlink("data/colors/vlink.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/bg.txt")) {
+                                       copy("data/schemes/colors/$scheme/bg.txt","data/colors/bg.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/border.txt")) {
+                                       copy("data/schemes/colors/$scheme/border.txt","data/colors/border.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/font.txt")) {
+                                       copy("data/schemes/colors/$scheme/font.txt","data/colors/font.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/hover.txt")) {
+                                       copy("data/schemes/colors/$scheme/hover.txt","data/colors/hover.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/link.txt")) {
+                                       copy("data/schemes/colors/$scheme/link.txt","data/colors/link.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pb-bg.txt")) {
+                                       copy("data/schemes/colors/$scheme/pb-bg.txt","data/colors/pb-bg.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pb-font.txt")) {
+                                       copy("data/schemes/colors/$scheme/pb-font.txt","data/colors/pb-font.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pf-bg.txt")) {
+                                       copy("data/schemes/colors/$scheme/pf-bg.txt","data/colors/pf-bg.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pf-font.txt")) {
+                                       copy("data/schemes/colors/$scheme/pf-font.txt","data/colors/pf-font.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pt-bg.txt")) {
+                                       copy("data/schemes/colors/$scheme/pt-bg.txt","data/colors/pt-bg.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pt-font.txt")) {
+                                       copy("data/schemes/colors/$scheme/pt-font.txt","data/colors/pt-font.txt");
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/vlink.txt")) {
+                                       copy("data/schemes/colors/$scheme/vlink.txt","data/colors/vlink.txt");
+                               }
+              
+                               if (!file_exists("data/schemes/current")) {
+                                       mkdir("data/schemes/current");
+                               }
+              
+                               $current_scheme = fopen("data/schemes/current/color.txt","w");
+                               fwrite($current_scheme,$scheme);
+                               fclose($current_scheme);
+                       break;
+      
+                       case 'click here to download selected scheme':
+
+                               require "zipstream.php";
+
+                               $zip = new ZipStream("{$scheme}.zip");
+
+                               if (file_exists("data/schemes/colors/$scheme/bg.txt")) {
+                                       $zip->add_file("bg.txt", file_get_contents("data/schemes/colors/$scheme/bg.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/border.txt")) {
+                                       $zip->add_file("border.txt", file_get_contents("data/schemes/colors/$scheme/border.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/font.txt")) {
+                                       $zip->add_file("font.txt", file_get_contents("data/schemes/colors/$scheme/font.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/hover.txt")) {
+                                       $zip->add_file("hover.txt", file_get_contents("data/schemes/colors/$scheme/hover.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/link.txt")) {
+                                       $zip->add_file("link.txt", file_get_contents("data/schemes/colors/$scheme/link.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pb-bg.txt")) {
+                                       $zip->add_file("pb-bg.txt", file_get_contents("data/schemes/colors/$scheme/pb-bg.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pb-font.txt")) {
+                                       $zip->add_file("pb-font.txt", file_get_contents("data/schemes/colors/$scheme/pb-font.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pf-bg.txt")) {
+                                       $zip->add_file("pf-bg.txt", file_get_contents("data/schemes/colors/$scheme/pf-bg.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pf-font.txt")) {
+                                       $zip->add_file("pf-font.txt", file_get_contents("data/schemes/colors/$scheme/pf-font.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pt-bg.txt")) {
+                                       $zip->add_file("pt-bg.txt", file_get_contents("data/schemes/colors/$scheme/pt-bg.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/pt-font.txt")) {
+                                       $zip->add_file("pt-font.txt", file_get_contents("data/schemes/colors/$scheme/pt-font.txt"));
+                               }
+              
+                               if (file_exists("data/schemes/colors/$scheme/vlink.txt")) {
+                                       $zip->add_file("vlink.txt", file_get_contents("data/schemes/colors/$scheme/vlink.txt"));
+                               }
+
+                               if (file_exists("data/schemes/colors/$scheme/README")) {
+                                       $zip->add_file("README", file_get_contents("data/schemes/colors/$scheme/README"));
+                               }
+
+                               $zip->finish();
+
+                       break;
+
+                       case 'click here to delete selected scheme':
+
+                               rmdirr("data/schemes/colors/$scheme");
+
+                               if (file_exists("data/schemes/current/color.txt") and (file_get_contents("data/schemes/current/color.txt") == $scheme)) {
+                                       unlink("data/schemes/current/color.txt");
+                                       rmdirr("data/colors");
+                               }
+                       break;
+               }
+       }
+}
+
+if (isset($_FILES['upload']) and !empty($_FILES['upload']) and @function_exists('gzinflate')) {
+
+       if (is_uploaded_file($_FILES['upload']['tmp_name'])) {
+
+               if ($_FILES['upload']['type']=="application/zip") {
+
+                       if (!file_exists("data/schemes/tmp")) {
+                               mkdir("data/schemes/tmp");
+                       }
+
+                       $package_name = strtolower($_FILES['upload']['name']);
+                       $package_name = str_replace(".zip","",$package_name);
+
+                       if (!file_exists("data/schemes/colors/$package_name")) {
+
+                               mkdir("data/schemes/colors/$package_name");
+                               include("function_unzip.php");
+                               require_once ('unzip.lib.php');
+                               unzipFile($_FILES['upload']['tmp_name'],"data/schemes/colors/$package_name/");
+                               unlink($_FILES['upload']['tmp_name']);
+                       }
+                       else {
+                               unlink($_FILES['upload']['tmp_name']);
+                       }
+               }
+               else {
+                       unlink($_FILES['upload']['tmp_name']);
+               }
+       }
+       else {
+               unlink($_FILES['upload']['tmp_name']);
+       }
+}
+
+?>
+
 <style>
-body
-{
+body {
        color: #666666;
        margin: 5px 5px;
        padding: 0px;
@@ -332,205 +406,208 @@ body
        background-color: #ffffff;
 }
 
-p, td
-{
+p, td {
        font-size: 11px;
 }
 
-a
-{
+a {
        font-weight: bold;
        text-decoration: none;
 }
 
-a:link
-{
+a:link {
        color: <?php
-if (file_exists("data/colors/link.txt")) {
-       $a_link_color = file_get_contents("data/colors/link.txt");
-       echo $a_link_color;
-}
-else {
-       echo "#666666";
-}
-?>;
+                       if (file_exists("data/colors/link.txt")) {
+                               readfile("data/colors/link.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
 }
 
-a:visited
-{
+a:visited {
        color: <?php
-if (file_exists("data/colors/vlink.txt")) {
-       $a_visited_color = file_get_contents("data/colors/vlink.txt");
-       echo $a_visited_color;
-}
-else {
-       echo "#666666";
-}
-?>;
+                       if (file_exists("data/colors/vlink.txt")) {
+                               readfile("data/colors/vlink.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
 }
 
-a:hover
-{
+a:hover {
        color: <?php
-if (file_exists("data/colors/hover.txt")) {
-       $a_hover_color = file_get_contents("data/colors/hover.txt");
-       echo $a_hover_color;
-}
-else {
-       echo "#336699";
-}
-?>;
+                       if (file_exists("data/colors/hover.txt")) {
+                               readfile("data/colors/hover.txt");
+                       }
+                       else {
+                               echo "#336699";
+                       }
+       ?>;
 }
 
 a:active {
        color: <?php
-if (file_exists("data/colors/hover.txt")) {
-       $a_active_color = file_get_contents("data/colors/hover.txt");
-       echo $a_active_color;
+                       if (file_exists("data/colors/hover.txt")) {
+                               readfile("data/colors/hover.txt");
+                       }
+                       else {
+                               echo "#336699";
+                       }
+       ?>;
 }
-else {
-       echo "#336699";
-}
-?>;
-}
-#panel_title
-{
+
+#panel_title {
        font-family: verdana, helvetica, sans-serif;
        font-size: 12px;
        font-weight: bold;
+
        color: <?php
-if (file_exists("data/colors/pt-font.txt")) {
-       $panel_title_font_color = file_get_contents("data/colors/pt-font.txt");
-       echo $panel_title_font_color;
-}
-else {
-       echo "#666666";
-}
-?>;
+               if (file_exists("data/colors/pt-font.txt")) {
+                       readfile("data/colors/pt-font.txt");
+               }
+               else {
+                       echo "#666666";
+               }
+       ?>;
+
        padding: 5px 5px 5px 5px;
+
        background-color: <?php
-if (file_exists("data/colors/pt-bg.txt")) {
-       $panel_title_background_color = file_get_contents("data/colors/pt-bg.txt");
-       echo $panel_title_background_color;
-}
-else {
-       echo "transparent";
-}
-?>;
+                               if (file_exists("data/colors/pt-bg.txt")) {
+                                       readfile("data/colors/pt-bg.txt");
+                               }
+                               else {
+                                       echo "transparent";
+                               }
+       ?>;
+
        margin: 0px;
+
        border-color: <?php
-if (file_exists("data/colors/border.txt")) {
-       $panel_title_border_color = file_get_contents("data/colors/border.txt");
-       echo $panel_title_border_color;
-}
-else {
-       echo "#CCCCCC";
-}
-?>;
+                       if (file_exists("data/colors/border.txt")) {
+                               readfile("data/colors/border.txt");
+                       }
+                       else {
+                               echo "#CCCCCC";
+                       }
+       ?>;
+
        border-width: 1px 1px 0px 1px;
        border-style: solid solid none solid;
        width: 277px;
 }
-#panel_body
-{
+
+#panel_body {
        font-family: verdana, helvetica, sans-serif;
        font-size: 11px;
+
        color: <?php
-if (file_exists("data/colors/pb-font.txt")) {
-       $panel_body_font_color = file_get_contents("data/colors/pb-font.txt");
-       echo $panel_body_font_color;
-}
-else {
-       echo "#666666";
-}
-?>;
+                       if (file_exists("data/colors/pb-font.txt")) {
+                               readfile("data/colors/pb-font.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
+
        padding: 5px 5px 5px 5px;
+
        background-color: <?php
-if (file_exists("data/colors/pb-bg.txt")) {
-       $panel_body_background_color = file_get_contents("data/colors/pb-bg.txt");
-       echo $panel_body_background_color;
-}
-else {
-       echo "transparent";
-}
-?>;
+                               if (file_exists("data/colors/pb-bg.txt")) {
+                                       readfile("data/colors/pb-bg.txt");
+                               }
+                               else {
+                                       echo "transparent";
+                               }
+       ?>;
+
        margin: 0px;
+
        border-color: <?php
-if (file_exists("data/colors/border.txt")) {
-       $panel_body_border_color = file_get_contents("data/colors/border.txt");
-       echo $panel_body_border_color;
-}
-else {
-       echo "#CCCCCC";
-}
-?>;
+                               if (file_exists("data/colors/border.txt")) {
+                                       readfile("data/colors/border.txt");
+                               }
+                               else {
+                                       echo "#CCCCCC";
+                               }
+       ?>;
+
        border-width: 1px 1px 1px 1px;
        border-style: solid solid solid solid;
        width: 277px;
 }
-#panel_footer
-{
+
+#panel_footer {
        font-family: verdana, helvetica, sans-serif;
        font-size: 11px;
+
        color: <?php
-if (file_exists("data/colors/pf-font.txt")) {
-       $panel_footer_font_color = file_get_contents("data/colors/pf-font.txt");
-       echo $panel_footer_font_color;
-}
-else {
-       echo "#666666";
-}
-?>;
+                       if (file_exists("data/colors/pf-font.txt")) {
+                               readfile("data/colors/pf-font.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
+
        padding: 5px 5px 5px 5px;
+
        background-color: <?php
-if (file_exists("data/colors/pf-bg.txt")) {
-       $panel_footer_background_color = file_get_contents("data/colors/pf-bg.txt");
-       echo $panel_footer_background_color;
-}
-else {
-       echo "transparent";
-}
-?>;
+                               if (file_exists("data/colors/pf-bg.txt")) {
+                                       readfile("data/colors/pf-bg.txt");
+                               }
+                               else {
+                                       echo "transparent";
+                               }
+       ?>;
+
        margin: 0px;
+
        border-color: <?php
-if (file_exists("data/colors/border.txt")) {
-       $panel_footer_border_color = file_get_contents("data/colors/border.txt");
-       echo $panel_footer_border_color;
-}
-else {
-       echo "#CCCCCC";
-}
-?>;
+                               if (file_exists("data/colors/border.txt")) {
+                                       readfile("data/colors/border.txt");
+                               }
+                               else {
+                                       echo "#CCCCCC";
+                               }
+       ?>;
+
        border-width: 0px 1px 1px 1px;
        border-style: none solid solid solid;
        width: 277px;
 }
+
 #panel_input {        
        color: <?php
-if (file_exists("data/colors/border.txt")) {
-       $input_color = file_get_contents("data/colors/border.txt");
-       echo $input_color;
-}
-else {
-       echo "#666666";
-}
-?>;
-       background: #ffffff;
+                       if (file_exists("data/colors/border.txt")) {
+                               readfile("data/colors/border.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
+
+       background: #ffffff;
+
        border: <?php
-if (file_exists("data/colors/border.txt")) {
-       $panel_footer_border_color = file_get_contents("data/colors/border.txt");
-       echo $panel_footer_border_color;
-}
-else {
-       echo "#999999";
-}
-?>     solid 1px;
+                       if (file_exists("data/colors/border.txt")) {
+                               readfile("data/colors/border.txt");
+                       }
+                       else {
+                               echo "#999999";
+                       }
+       ?> solid 1px;
+
        width: 277px;
        margin: 2px 0px 0px 0px;
        font-family: verdana,helvetica,sans-serif;
        font-size: 11px;
        padding: 2px 5px 2px 5px;
 }
+
 .input {      
        color: #666666;
        background: #ffffff;
@@ -539,69 +616,165 @@ else {
        font-family: verdana,helvetica,sans-serif;
        font-size: 11px
 }
-#panel_out
-{
+
+#panel_out {
        font-family: verdana, helvetica, sans-serif;
        font-size: 11px;
+
        color: <?php
-if (file_exists("data/colors/font.txt")) {
-       readfile("data/colors/font.txt");
-}
-else {
-       echo "#666666";
-}
-?>;
+                       if (file_exists("data/colors/font.txt")) {
+                               readfile("data/colors/font.txt");
+                       }
+                       else {
+                               echo "#666666";
+                       }
+       ?>;
+
        padding: 5px 5px 5px 5px;
+
        background-color: <?php
-if (file_exists("data/colors/bg.txt")) {
-       readfile("data/colors/bg.txt");
-}
-else {
-       echo "transparent";
-}
-?>;
+                       if (file_exists("data/colors/bg.txt") and !file_exists("images/background.gif") and !file_exists("images/background.jpg") and !file_exists("images/background.png")) {
+                               readfile("data/colors/bg.txt");
+                       }
+                       else {
+                               echo "transparent";
+                       }
+       ?>;
+
        margin: 0px;
        border-width: 0px 0px 0px 0px;
        border-style: solid solid solid solid;
 }
+
+.farbtastic {
+  position: relative;
+}
+.farbtastic * {
+  position: absolute;
+  cursor: crosshair;
+}
+.farbtastic, .farbtastic .wheel {
+  width: 195px;
+  height: 195px;
+}
+.farbtastic .color, .farbtastic .overlay {
+  top: 47px;
+  left: 47px;
+  width: 101px;
+  height: 101px;
+}
+.farbtastic .wheel {
+  background: url(images/color-wheel.png) no-repeat;
+  width: 195px;
+  height: 195px;
+}
+.farbtastic .overlay {
+  background: url(images/color-mask.png) no-repeat;
+}
+.farbtastic .marker {
+  width: 17px;
+  height: 17px;
+  margin: -8px 0 0 -8px;
+  overflow: hidden;
+  background: url(images/color-marker.png) no-repeat;
+}
+
 </style>
 
-<table border=0 cellspacing=0 cellpadding=2>
-<tr><td bgcolor=<?php
+<script type="text/javascript" src="js/jquery.js"></script>
+<script type="text/javascript" src="js/farbtastic.js"></script>
 
+<script type="text/javascript">
+  $(document).ready(function() {
+    $('#colorpicker').farbtastic('#color');
+  });
+</script>
 
-if (file_exists("data/colors/bg.txt")) {
-       readfile("data/colors/bg.txt");
-}
-else {
-       echo "#ffffff";
-}
+<p>&nbsp;</p>
+
+<table border=0 cellspacing=10 cellpadding=2>
+<tr><td valign=top>
+
+
+<table border=0 cellspacing=1 cellpadding=10 bgcolor=#cccccc>
+<tr><td<?php
+       if (file_exists("images/background.gif") or file_exists("images/background.jpg") or file_exists("images/background.png")) {
+               echo ' style="';
+       }
+
+       if (file_exists("images/background.gif") and !file_exists("images/background.jpg") and !file_exists("images/background.png")) { ?>background-image: url('images/background.gif');
+       background-attachment: <?php if (file_exists("data/bg-scroll.txt")) { echo scroll; } else { echo fixed; } ?>;
+       background-repeat: <?php if (file_exists("data/bg-repeat.txt")) { readfile("data/bg-repeat.txt"); } else { echo repeat; } ?>;
+       background-position: <?php if (file_exists("data/bg-position.txt")) { readfile("data/bg-position.txt"); } else { echo "top left"; } ?>;
+       <?php
+       }
+       if (!file_exists("images/background.gif") and file_exists("images/background.jpg") and !file_exists("images/background.png")) { ?>background-image: url('images/background.jpg');
+       background-attachment: <?php if (file_exists("data/bg-scroll.txt")) { echo scroll; } else { echo fixed; } ?>;
+       background-repeat: <?php if (file_exists("data/bg-repeat.txt")) { readfile("data/bg-repeat.txt"); } else { echo repeat; } ?>;
+       background-position: <?php if (file_exists("data/bg-position.txt")) { readfile("data/bg-position.txt"); } else { echo "top left"; } ?>;
+       <?php
+       }
+       if (!file_exists("images/background.gif") and !file_exists("images/background.jpg") and file_exists("images/background.png")) { ?>background-image: url('images/background.png');
+       background-attachment: <?php if (file_exists("data/bg-scroll.txt")) { echo scroll; } else { echo fixed; } ?>;
+       background-repeat: <?php if (file_exists("data/bg-repeat.txt")) { readfile("data/bg-repeat.txt"); } else { echo repeat; } ?>;
+       background-position: <?php if (file_exists("data/bg-position.txt")) { readfile("data/bg-position.txt"); } else { echo "top left"; } ?>;
+       <?php
+       }
+
+       if (file_exists("images/background.gif") or file_exists("images/background.jpg") or file_exists("images/background.png")) {
+               echo '"';
+       }
+
+       echo ' bgcolor="';
 
-?>><div id=panel_out><b>Colors</b> Preview</div>
+       if (file_exists("data/colors/bg.txt")) {
+               $bgcolor = file_get_contents("data/colors/bg.txt");
+               if ($bgcolor == "transparent") {
+                       echo "#ffffff";
+               }
+               else {
+                       echo $bgcolor;
+               }
+       }
+       else {
+               echo "#ffffff";
+       }
+
+       echo '">';
+
+ ?>
+
+<div id=panel_out><b>Colors</b> Preview</div>
 <div id=panel_title>Panel Title</div>
-<div id=panel_body><font style="font-size: 10px; color: #999999;">panel body</font><p>Enter any of the sixteen standard colors (<i>aqua</i>, <i>black</i>, <i>blue</i>, <i>fuchsia</i>, <i>gray</i>, <i>green</i>, <i>lime</i>, <i>maroon</i>, <i>navy</i>, <i>olive</i>, <i>purple</i>, <i>red</i>, <i>silver</i>, <i>teal</i>, <i>white</i>, <i>yellow</i>) in the field below. For more colors, click on a swatch from the palette. Use <i>transparent</i> for see-through backgrounds.</p><p>While this serves as a convenient preview, colors are actually applied immediately after submission.</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Hyperlink #1</a><br><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Hyperlink #2</a><br><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Hyperlink #3</a></p></div>
-<div id=panel_footer><font style="font-size: 10px; color: <?php if (file_exists("data/colors/pf-font.txt")) { readfile("data/colors/pf-font.txt"); } else { echo "#999999"; } ?>;">panel footer | <a href="<?php echo $_SERVER['PHP_SELF']; ?>">permalink</a></font></div>
+<div id=panel_body><font style="font-size: 10px; color: #999999;">panel body</font><p>Enter any of the sixteen standard colors (<i>aqua</i>, <i>black</i>, <i>blue</i>, <i>fuchsia</i>, <i>gray</i>, <i>green</i>, <i>lime</i>, <i>maroon</i>, <i>navy</i>, <i>olive</i>, <i>purple</i>, <i>red</i>, <i>silver</i>, <i>teal</i>, <i>white</i>, <i>yellow</i>) in the field under the color wheel. For more colors, click on the color wheel. Use <i>transparent</i> for see-through backgrounds.</p><p>While this serves as a convenient preview, colors are actually applied immediately after submission.</p><p><a href=none.php>Hyperlink #1</a><br><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Hyperlink #2</a><br><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Hyperlink #3</a></p></div>
+<div id=panel_footer><font style="font-size: 10px; color: <?php if (file_exists("data/colors/pf-font.txt")) { $color_pf_font = file_get_contents("data/colors/pf-font.txt"); if ($color_pf_font == "transparent") { echo "#ffffff"; } else { echo $color_pf_font; } } else { echo "#999999"; } ?>;">panel footer | <a href="<?php echo $_SERVER['PHP_SELF']; ?>">permalink</a></font></div>
 <div id=panel_input>text input field</div>
 <div id=panel_input><center>submit button</center></div>
-</td></tr>
-<tr><td><p>&nbsp;</p></td></tr>
-<tr><td><a><img usemap="#colmap" src="images/colortable.gif" border=0 width=289 height=67></a></td></tr>
-<tr><td><input type=text name=color class=input autocomplete=off></td></tr>
+</td></tr></table>
+
+</td><td valign=top>
+
+
+<table border=0 cellspacing=0 cellpadding=2>
+<tr><td align=center><div id=colorpicker></div></td></tr>
+<tr><td></td></tr>
+<tr><td></td></tr>
+<form action=colors.php method=post>
+<tr><td><input type=text id=color name=color value=#ffffff class=input autocomplete=off></td></tr>
 <tr><td>
 <table border=1 cellspacing=1 cellpadding=0 width=289>
 <tr><td colspan=3>body</td><td></td><td colspan=3>links</td></tr>
-<tr><td><input type=radio name=target value=font <?php if ($target == "font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/font.txt")) { readfile("data/colors/font.txt"); } else { echo "#666666"; } ?>></td><td>font (<?php if (file_exists("data/colors/font.txt")) { readfile("data/colors/font.txt"); } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=link <?php if ($target == "link") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/link.txt")) { readfile("data/colors/link.txt"); } else { echo "#666666"; } ?>></td><td>link (<?php if (file_exists("data/colors/link.txt")) { readfile("data/colors/link.txt"); } else { echo "#666666"; } ?>)</td></tr>
-<tr><td><input type=radio name=target value=border <?php if ($target == "border") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/border.txt")) { readfile("data/colors/border.txt"); } else { echo "#CCCCCC"; } ?>></td><td>border (<?php if (file_exists("data/colors/border.txt")) { readfile("data/colors/border.txt"); } else { echo "#CCCCCC"; } ?>)</td><td width=5></td><td><input type=radio name=target value=vlink <?php if ($target == "vlink") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/vlink.txt")) { readfile("data/colors/vlink.txt"); } else { echo "#666666"; } ?>></td><td>visited (<?php if (file_exists("data/colors/vlink.txt")) { readfile("data/colors/vlink.txt"); } else { echo "#666666"; } ?>)</td></tr>
-<tr><td><input type=radio name=target value=bg <?php if ($target == "bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/bg.txt")) { readfile("data/colors/bg.txt"); } else { echo "#ffffff"; } ?>></td><td>background (<?php if (file_exists("data/colors/bg.txt")) { readfile("data/colors/bg.txt"); } else { echo "#ffffff"; } ?>)</td><td width=5></td><td><input type=radio name=target value=hover <?php if ($target == "hover") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/hover.txt")) { readfile("data/colors/hover.txt"); } else { echo "#336699"; } ?>></td><td>hover (<?php if (file_exists("data/colors/hover.txt")) { readfile("data/colors/hover.txt"); } else { echo "#336699"; } ?>)</td></tr>
+<tr><td><input type=radio name=target value=font <?php if ($target == "font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/font.txt")) { $color_font = file_get_contents("data/colors/font.txt"); if ($color_font == "transparent") { echo "#ffffff"; } else { echo $color_font; } } else { echo "#666666"; } ?>></td><td>font (<?php if (file_exists("data/colors/font.txt")) { $color_font = file_get_contents("data/colors/font.txt"); if ($color_font == "transparent") { echo "#ffffff"; } else { echo $color_font; } } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=link <?php if ($target == "link") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/link.txt")) { $color_link = file_get_contents("data/colors/link.txt"); if ($color_link == "transparent") { echo "#ffffff"; } else { echo $color_link; } } else { echo "#666666"; } ?>></td><td>link (<?php if (file_exists("data/colors/link.txt")) { $color_link = file_get_contents("data/colors/link.txt"); if ($color_link == "transparent") { echo "#ffffff"; } else { echo $color_link; } } else { echo "#666666"; } ?>)</td></tr>
+<tr><td><input type=radio name=target value=border <?php if ($target == "border") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/border.txt")) { $color_border = file_get_contents("data/colors/border.txt"); if ($color_border == "transparent") { echo "#ffffff"; } else { echo $color_border; } } else { echo "#CCCCCC"; } ?>></td><td>border (<?php if (file_exists("data/colors/border.txt")) { $color_border = file_get_contents("data/colors/border.txt"); if ($color_border == "transparent") { echo "#ffffff"; } else { echo $color_border; } } else { echo "#CCCCCC"; } ?>)</td><td width=5></td><td><input type=radio name=target value=vlink <?php if ($target == "vlink") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/vlink.txt")) { $color_vlink = file_get_contents("data/colors/vlink.txt"); if ($color_vlink == "transparent") { echo "#ffffff"; } else { echo $color_vlink; } } else { echo "#666666"; } ?>></td><td>visited (<?php if (file_exists("data/colors/vlink.txt")) { $color_vlink = file_get_contents("data/colors/vlink.txt"); if ($color_vlink == "transparent") { echo "#ffffff"; } else { echo $color_vlink; } } else { echo "#666666"; } ?>)</td></tr>
+<tr><td><input type=radio name=target value=bg <?php if ($target == "bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/bg.txt")) { $color_bg = file_get_contents("data/colors/bg.txt"); if ($color_bg != "transparent") { echo $color_bg; } } ?>></td><td>background (<?php if (file_exists("data/colors/bg.txt")) { $color_bg = file_get_contents("data/colors/bg.txt"); if ($color_bg == "transparent") { echo "transparent"; } else { echo $color_bg; } } else { echo "transparent"; } ?>)</td><td width=5></td><td><input type=radio name=target value=hover <?php if ($target == "hover") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/hover.txt")) { $color_hover = file_get_contents("data/colors/hover.txt"); if ($color_hover == "transparent") { echo "#ffffff"; } else { echo $color_hover; } } else { echo "#336699"; } ?>></td><td>hover (<?php if (file_exists("data/colors/hover.txt")) { $color_hover = file_get_contents("data/colors/hover.txt"); if ($color_hover == "transparent") { echo "#ffffff"; } else { echo $color_hover; } } else { echo "#336699"; } ?>)</td></tr>
 <tr><td colspan=3>panel font</td><td></td><td colspan=3>panel background</td></tr>
-<tr><td><input type=radio name=target value=pt_font <?php if ($target == "pt_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pt-font.txt")) { readfile("data/colors/pt-font.txt"); } else { echo "#666666"; } ?>></td><td>title (<?php if (file_exists("data/colors/pt-font.txt")) { readfile("data/colors/pt-font.txt"); } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pt_bg <?php if ($target == "pt_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pt-bg.txt")) { readfile("data/colors/pt-bg.txt"); } else { echo "#ffffff"; } ?>></td><td>title (<?php if (file_exists("data/colors/pt-bg.txt")) { readfile("data/colors/pt-bg.txt"); } else { echo "#ffffff"; } ?>)</td></tr>
-<tr><td><input type=radio name=target value=pb_font <?php if ($target == "pb_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pb-font.txt")) { readfile("data/colors/pb-font.txt"); } else { echo "#666666"; } ?>></td><td>body (<?php if (file_exists("data/colors/pb-font.txt")) { readfile("data/colors/pb-font.txt"); } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pb_bg <?php if ($target == "pb_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pb-bg.txt")) { readfile("data/colors/pb-bg.txt"); } else { echo "#ffffff"; } ?>></td><td>body (<?php if (file_exists("data/colors/pb-bg.txt")) { readfile("data/colors/pb-bg.txt"); } else { echo "#ffffff"; } ?>)</td></tr>
-<tr><td><input type=radio name=target value=pf_font <?php if ($target == "pf_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pf-font.txt")) { readfile("data/colors/pf-font.txt"); } else { echo "#666666"; } ?>></td><td>footer (<?php if (file_exists("data/colors/pf-font.txt")) { readfile("data/colors/pf-font.txt"); } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pf_bg <?php if ($target == "pg_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pf-bg.txt")) { readfile("data/colors/pf-bg.txt"); } else { echo "#ffffff"; } ?>></td><td>footer (<?php if (file_exists("data/colors/pf-bg.txt")) { readfile("data/colors/pf-bg.txt"); } else { echo "#ffffff"; } ?>)</td></tr>
-</form>
+<tr><td><input type=radio name=target value=pt_font <?php if ($target == "pt_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pt-font.txt")) { $color_pt_font = file_get_contents("data/colors/pt-font.txt"); if ($color_pt_font == "transparent") { echo "#ffffff"; } else { echo $color_pt_font; } } else { echo "#666666"; } ?>></td><td>title (<?php if (file_exists("data/colors/pt-font.txt")) { $color_pt_font = file_get_contents("data/colors/pt-font.txt"); if ($color_pt_font == "transparent") { echo "#ffffff"; } else { echo $color_pt_font; } } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pt_bg <?php if ($target == "pt_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pt-bg.txt")) { $color_pt_bg = file_get_contents("data/colors/pt-bg.txt"); if ($color_pt_bg != "transparent") { echo $color_pt_bg; } } ?>></td><td>title (<?php if (file_exists("data/colors/pt-bg.txt")) { $color_pt_bg = file_get_contents("data/colors/pt-bg.txt"); if ($color_pt_bg == "transparent") { echo "transparent"; } else { echo $color_pt_bg; } } else { echo "transparent"; } ?>)</td></tr>
+<tr><td><input type=radio name=target value=pb_font <?php if ($target == "pb_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pb-font.txt")) { $color_pb_font = file_get_contents("data/colors/pb-font.txt"); if ($color_pb_font == "transparent") { echo "#ffffff"; } else { echo $color_pb_font; } } else { echo "#666666"; } ?>></td><td>body (<?php if (file_exists("data/colors/pb-font.txt")) { $color_pb_font = file_get_contents("data/colors/pb-font.txt"); if ($color_pb_font == "transparent") { echo "#ffffff"; } else { echo $color_pb_font; } } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pb_bg <?php if ($target == "pb_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pb-bg.txt")) { $color_pb_bg = file_get_contents("data/colors/pb-bg.txt"); if ($color_pb_bg != "transparent") { echo $color_pb_bg; } } ?>></td><td>body (<?php if (file_exists("data/colors/pb-bg.txt")) { $color_pb_bg = file_get_contents("data/colors/pb-bg.txt"); if ($color_pb_bg == "transparent") { echo "transparent"; } else { echo $color_pb_bg; } } else { echo "transparent"; } ?>)</td></tr>
+<tr><td><input type=radio name=target value=pf_font <?php if ($target == "pf_font") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pf-font.txt")) { $color_pf_font = file_get_contents("data/colors/pf-font.txt"); if ($color_pf_font == "transparent") { echo "#ffffff"; } else { echo $color_pf_font; } } else { echo "#666666"; } ?>></td><td>footer (<?php if (file_exists("data/colors/pf-font.txt")) { $color_pf_font = file_get_contents("data/colors/pf-font.txt"); if ($color_pf_font == "transparent") { echo "#ffffff"; } else { echo $color_pf_font; } } else { echo "#666666"; } ?>)</td><td width=5></td><td><input type=radio name=target value=pf_bg <?php if ($target == "pg_bg") { echo checked; } ?>></td><td width=15 bgcolor=<?php if (file_exists("data/colors/pf-bg.txt")) { $color_pf_bg = file_get_contents("data/colors/pf-bg.txt"); if ($color_pf_bg != "transparent") { echo $color_pf_bg; } } ?>></td><td>footer (<?php if (file_exists("data/colors/pf-bg.txt")) { $color_pf_bg = file_get_contents("data/colors/pf-bg.txt"); if ($color_pf_bg == "transparent") { echo "transparent"; } else { echo $color_pf_bg; } } else { echo "transparent"; } ?>)</td></tr>
 </table>
 </td></tr>
-<tr><td><input type=submit class=input value="click here to apply selected color"></td></tr>
-<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
+<tr><td><input type=submit class=input value="click here to apply selected color"></td></tr></form>
+<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 <input type=hidden name=reset value=go>
 <tr><td><input class=input type=submit value="click here to use default colors"></td></tr>
 </form>
@@ -609,3 +782,96 @@ else {
 <tr><td><input class=input type=submit value="click here to go to the index page"></td></tr>
 </form>
 </table>
+
+</td><td valign=top>
+
+<form action=colors.php method=post>
+<table border=0 cellspacing=1 cellpadding=1 width=290>
+<tr><td><p><b>Color Schemes</b></p>
+
+<p>You are currently using <?php
+
+
+if (!file_exists("data/colors") or (file_exists("data/colors") and (count(glob("data/colors/*")) === 0))) {
+       echo "the default colors of MAJ.";
+}
+
+if (file_exists("data/colors") and !file_exists("data/schemes/current/color.txt") and (count(glob("data/colors/*")) > 0)) {
+       echo "a customized color scheme which cannot be restored after a scheme change or color reset.";
+}
+
+if (file_exists("data/schemes/current/color.txt")) {
+       echo "the <b>";
+       echo str_replace("_"," ",file_get_contents("data/schemes/current/color.txt"));
+       echo "</b> color scheme. Be sure to save any modifications into a new scheme ID for later use.";
+}
+
+?></p>
+
+<p>Enter a unique ID below to save the current color scheme.</p></td></tr>
+<tr><td><input type=text class=input name=id autocomplete=off></td></tr>
+<tr><td><input type=submit class=input value="click here to save current color scheme"></td></tr>
+</table>
+</form>
+
+<p></p>
+
+<?php
+
+if ($dh_color_scheme = opendir("data/schemes/colors")) {
+       while (($color_scheme = readdir($dh_color_scheme)) !== false) {
+               if ($color_scheme != "." && $color_scheme != ".." && fnmatch("*", $color_scheme)) {
+                       $color_schemes[] = $color_scheme;
+               }
+       }
+       closedir($dh_color_scheme);
+}
+
+sort($color_schemes);
+
+if (count($color_schemes) > 0) {
+       echo "<form action=colors.php method=post>";
+       echo "<table border=0 cellspacing=1 cellpadding=1>";
+       echo "<tr><td><p>Select an existing color scheme to apply or delete below.</p></td></tr>";
+       echo "<tr><td><select name=scheme class=input>";
+       foreach ($color_schemes as $scheme_name) {
+               if (file_exists("data/schemes/current/color.txt") and (file_get_contents("data/schemes/current/color.txt") == $scheme_name)) {
+                       echo "<option selected>";
+               }
+               else {
+                       echo "<option>";
+               }
+               echo str_replace("_"," ",$scheme_name);
+       }
+       echo "</select></td></tr>";
+       echo "<tr><td><input type=submit name=scheme_axn class=input value=\"click here to apply selected scheme\"></td></tr>";
+       echo "<tr><td><input type=submit name=scheme_axn class=input value=\"click here to download selected scheme\"></td></tr>";
+       echo "<tr><td><input type=submit name=scheme_axn class=input value=\"click here to delete selected scheme\"></td></tr>";
+       echo "</table>";
+       echo "</form>";
+       echo "<p></p>";
+}
+
+?>
+
+<?php
+
+if (@function_exists('gzinflate')) {
+
+?>
+
+<form enctype="multipart/form-data" action=colors.php method=post>
+<table border=0 cellspacing=1 cellpadding=1>
+<tr><td><p>Select and upload a color scheme zip file below.</p></td></tr>
+<tr><td><input autocomplete=off type=file name=upload></td></tr>
+<tr><td><input type=submit class=input value="click here to upload scheme"></td></tr>
+</table>
+</form>
+
+<p></p>
+
+<?php
+}
+?>
+
+</td></tr></table>
diff --git a/edit.php b/edit.php
index 0ba13af..0d8e845 100644
--- a/edit.php
+++ b/edit.php
@@ -272,7 +272,7 @@ if (isset($_REQUEST['comment']) and !empty($_REQUEST['comment'])) { ?>
 <p><table border=0 cellspacing=0 cellpadding=0 bgcolor=#CCCCCC><tr><td width=525>
 
 <div id=panel_title><?php readfile($title_file); ?></div>
-<div id=panel_body><?php readfile($body_file); ?></div>
+<div id=panel_body><table border=0 cellspacing=0 cellpadding=0><tr><td><p><?php readfile($body_file); ?></p></td></tr></table></div>
 <div id=panel_footer><font style="font-size: 10px; color: #999999;"><?php
 
 if (file_exists("data/items/{$_REQUEST['entry']}/author.txt")) {
diff --git a/function_unzip.php b/function_unzip.php
new file mode 100644
index 0000000..8ae539a
--- /dev/null
+++ b/function_unzip.php
@@ -0,0 +1,91 @@
+<?php
+
+
+
+  function unzipFile($filename, $destination_folder) {
+  
+       /*========================================================
+       |
+       | unzip files using SimpleUnzip
+       |
+       | License: Use it, copy it, but leave my copyright where it is,
+       | otherwise, create your own code, thank you!
+       |
+       | coded by Vladimir Ghetau (c) 2007 pixeltomorrow.com
+       |
+       |
+       |
+       | http://www.vladimir.pixeltomorrow.com
+       |
+       |
+       |
+       | usage:
+       |
+       |  if (@function_exists('gzinflate')) {
+       |
+       |     $filename = 'uploads/zipped.zip';
+       |     $destionation_folder = 'unzipped/';
+       |     require_once ('unzip.lib.php');
+       |     unzipFile($filename, $destination_folder);
+       |
+       |  } else {
+       |
+       |     die ('gzinflate() is missing!');
+       |
+       |  }
+       |
+       |
+       | Enjoy!
+       |
+       |
+       ========================================================*/
+
+                                                    
+        if ($filename == '') die ('Please enter a file name first of all!');
+    
+        if ($destination_folder == '') die ('The path you specified is empty!');
+    
+        if (substr($destination_folder, -1) != '/') {
+                                                          
+            $destination_folder = $destination_folder .'/';
+                                                          
+        }
+                                                          
+                                                          
+     $vzip = new SimpleUnzip($filename);
+
+          foreach ($vzip->Entries as $extr) {
+          
+              $path = $extr->Path;
+              $path_folder = explode ('/', $path);
+              $new_path = '';
+              
+                  foreach ($path_folder as $folder) {
+                  
+                      $new_path .= $folder .'/';
+                  
+                      $to_create = $destination_folder . $new_path;
+                      
+                          if (substr($to_create, -1) == '/') {
+                          
+                            $to_create = substr($to_create, 0, strlen($to_create)-1);
+                          
+                          }
+                      
+                      @mkdir($to_create, 0777);
+                  
+                  }
+          
+              $new_path = '';
+              $filev = fopen ($destination_folder. $extr->Path .'/'. $extr->Name, 'w');
+              fwrite ($filev, $extr->Data);
+              fclose ($filev);
+                                                        
+          }
+          
+                                                        
+
+  }
+
+
+?>
\ No newline at end of file
diff --git a/images/color-marker.png b/images/color-marker.png
new file mode 100755
index 0000000..3929bbb
Binary files /dev/null and b/images/color-marker.png differ
diff --git a/images/color-mask.png b/images/color-mask.png
new file mode 100644
index 0000000..b0a4d40
Binary files /dev/null and b/images/color-mask.png differ
diff --git a/images/color-wheel.png b/images/color-wheel.png
new file mode 100644
index 0000000..97b343d
Binary files /dev/null and b/images/color-wheel.png differ
diff --git a/index.php b/index.php
index 170c02a..7d7fcfb 100644
--- a/index.php
+++ b/index.php
@@ -45,7 +45,7 @@ else {
 $default_blog_title = "My Activity Journal";
 $default_username = "maj";
 $default_password = "php";
-$default_blog_profile = "This cool site is powered by <a href=http://engels.mortega.net/index.php?entry=20050521000019 target=_maj>My Activity Journal</a>, a dead-simple, <a href=http://php.net/ target=_maj>PHP</a>-based, <a href=http://www.opensource.org/licenses/gpl-license.php target=_maj>GPL</a>'ed blog written from scratch as a spare time family project by <a href=http://engels.mortega.net/ target=_maj>Engels</a>, <a href=http://gaffud.com/ target=_maj>Magie</a>, and <a href=http://psylocke.org/ target=_maj>Psylocke</a> Antonio.";
+$default_blog_profile = "This cool site is powered by <a href=http://maj.sourceforge.net/ target=_maj>My Activity Journal</a>, a simple, <a href=http://php.net/ target=_maj>PHP</a>-based, <a href=http://www.opensource.org/licenses/gpl-license.php target=_maj>GPL</a>'ed blog written from scratch as a spare time family project by <a href=http://engels.mortega.net/ target=_maj>Engels</a>, <a href=http://gaffud.com/ target=_maj>Magie</a>, and <a href=http://psylocke.org/ target=_maj>Psylocke</a> Antonio.";
 $default_blog_author = "My Activity Journal";
 
 if (!file_exists("data")) {
@@ -646,7 +646,12 @@ body {
        background-color: <?php
                                if (file_exists("data/colors/bg.txt")) {
                                        $background_color = file_get_contents("data/colors/bg.txt");
-                                       echo $background_color;
+                                       if ($background_color == "transparent") {
+                                               echo "#ffffff";
+                                       }
+                                       else {
+                                               echo $background_color;
+                                       }
                                }
                                else {
                                        echo "#ffffff";
@@ -1368,6 +1373,10 @@ if (file_exists("data/panels")) {
                                        echo '<img src=images/widget.edit.png border=0 width=11 height=11 align=right></a>';
                                }
 
+                               if (file_exists("data/panels/$panel_list_entry/private.txt")) {
+                                       echo '<img src=images/widget.private.png border=0 width=11 height=11 align=right>';
+                               }
+
                                echo '</div><div id=panel_body>';
                        }
 
@@ -1501,7 +1510,24 @@ if ($count_latest_post_items > 0) {
        $show_latest_post_entries = 5;
 
        while ($increment_latest_post_entries <= $show_latest_post_entries) {
-               echo '<tr><td bgcolor=#ffffff><a href=' . $_SERVER['PHP_SELF'] . '?entry=' . $show_latest_post_items[$increment_latest_post_entries] . '>';
+               echo '<tr><td bgcolor=#ffffff><a href=' . $_SERVER['PHP_SELF'] . '?entry=' . $show_latest_post_items[$increment_latest_post_entries];
+
+               if ($dh_summary_comments = opendir("$dir/$show_latest_post_items[$increment_latest_post_entries]/comments/live")) {
+                       while (($entry_summary_comments = readdir($dh_summary_comments)) !== false) {
+                               if ($entry_summary_comments != "." && $entry_summary_comments != ".." && fnmatch("*", $entry_summary_comments)) {
+                                       $items_summary_comments[] = $entry_summary_comments;
+                               }
+                       }
+               closedir($dh_summary_comments);
+               }
+               rsort($items_summary_comments);
+               $summary_comments = count($items_summary_comments);
+
+               if ($summary_comments > 0) {
+                       echo '&show=comments';
+               }
+
+               echo '>';
                readfile("$dir/$show_latest_post_items[$increment_latest_post_entries]/title.txt");
                echo '</a></td>';
                echo '<td bgcolor=#ffffff><a href=member.php?id=';
@@ -1518,16 +1544,6 @@ if ($count_latest_post_items > 0) {
                }
                echo '</td>';
 
-               if ($dh_summary_comments = opendir("$dir/$show_latest_post_items[$increment_latest_post_entries]/comments/live")) {
-                       while (($entry_summary_comments = readdir($dh_summary_comments)) !== false) {
-                               if ($entry_summary_comments != "." && $entry_summary_comments != ".." && fnmatch("*", $entry_summary_comments)) {
-                                       $items_summary_comments[] = $entry_summary_comments;
-                               }
-                       }
-               closedir($dh_summary_comments);
-               }
-               rsort($items_summary_comments);
-               $summary_comments = count($items_summary_comments);
                if ($summary_comments < 1) {
                        echo "<td bgcolor=#ffffff align=right><p>0</p></td>";
                        echo "<td bgcolor=#ffffff align=right><p>";
@@ -2053,7 +2069,6 @@ foreach ($disp as $d) {
                echo $entry_body;
        }
 
-
        if ((file_get_contents("data/username.txt") == $author) and file_exists("data/sig.txt") and file_exists("data/bb.txt") and file_exists("data/bb-sig.txt")) {
                $sig = file_get_contents("data/sig.txt");
                echo "<br><br>--<br>$sig";
@@ -2435,25 +2450,31 @@ if (file_exists("data/panels")) {
                                                $current_height = $current_image_size[1];
                                                $max_width = 98;
                                                $max_height = 73;
-      
+
                                                if (($current_width > $max_width) || ($current_height > $max_height)) {  
+
                                                        if ($current_height > $current_width) {
                                                                $sizefactor = (double) ($max_height / $current_height);
                                                        }
                                                        else {
                                                                $sizefactor = (double) ($max_width / $current_width) ;
                                                        }
+
+                                                       $new_width = (int) ($current_width * $sizefactor);
+                                                       $new_height = (int) ($current_height * $sizefactor);
                                                }
-      
-                                               $new_width = (int) ($current_width * $sizefactor);
-                                               $new_height = (int) ($current_height * $sizefactor);
-      
+                                               else {
+                                                       $new_width = $current_width;
+                                                       $new_height = $current_height;
+                                               }
+
                                                /* auto-thumbnails (20060213) - In maj-0.14-20060131, album thumbnails were simply the original images displayed with smaller "width=" and "height=" values. Album index loading was painfully slow since the browser had to download the original images from the server. This should speed things up. We placed the "function" here instead of edit.php or add.php to make auto-thumbnail generation available for maj-0.14-20060131 users who may already have existing albums. */
       
                                                if (!file_exists("images/$d/thumbnails/{$album_entry}-thumbnail.jpg")) {
       
                                                        $work_thumb = imagecreatetruecolor($new_width,$new_height);
                                                        $get_mimetype = image_type_to_mime_type(exif_imagetype($current_image));
+
                                                        switch($get_mimetype) {
                                                                case "image/jpg":
                                                                case "image/jpeg":
@@ -2467,16 +2488,16 @@ if (file_exists("data/panels")) {
                                                                        break;
                                                        }
       
-                                                       imagecopyresampled($work_thumb, $work_image ,0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
+                                                       imagecopyresampled($work_thumb,$work_image,0,0,0,0,$new_width,$new_height,$current_width,$current_height);
       
                                                        if (!file_exists("images/$d/thumbnails")) {
                                                                mkdir("images/$d/thumbnails");
                                                        }
       
-                                                       imagejpeg($work_thumb, "images/$d/thumbnails/{$album_entry}-thumbnail.jpg", 80);
+                                                       imagejpeg($work_thumb,"images/$d/thumbnails/{$album_entry}-thumbnail.jpg",80);
       
                                                }
-//                                             echo "<a href=\"images/$d/album/$album_entry\">";
+
                                                echo "<a href=\"album.php?entry=$d&show=$album_entry\">";
 
                                                /* auto-thumbnails (20060519) - Just in case php-gd does not exist, do it the old way. */
@@ -3987,6 +4008,80 @@ if (file_exists("data/albums")) {
 ?>
 
 
+<?php
+
+if (!file_exists("data/xrand.txt")) {
+
+       if ($dh_random_post_items = opendir($dir)) {
+               while (($entry_random_post_items = readdir($dh_random_post_items)) !== false) {
+      
+                       if (file_exists("data/items/$entry_random_post_items/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
+                               continue;
+                       }
+      
+                       $cat_dir = file_get_contents("data/items/$entry_random_post_items/category.txt");
+      
+                       if (file_exists("data/categories/$cat_dir/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) and !file_exists("data/items/$entry_random_post_items/cat.txt")) {
+                               continue;
+                       }
+      
+                       if ($entry_random_post_items != "." && $entry_random_post_items != ".." && fnmatch("*", $entry_random_post_items)) {
+                               $show_random_post_items[] = $entry_random_post_items;
+                       }
+               }
+               closedir($dh_random_post_items);
+       }
+      
+       shuffle($show_random_post_items);
+       reset($show_random_post_items);
+       $count_random_post_items = count($show_random_post_items);
+      
+       if (file_exists("data/increase.txt")) {
+               $limit_random_post_entries = file_get_contents("data/increase.txt");
+       }
+       else {
+               $limit_random_post_entries = 5;
+       }
+      
+       if ($count_random_post_items > $limit_random_post_entries) {
+      
+               if (file_exists("data/round.txt")) {
+                       echo '<b class="rbtop"><b class="rb1t"></b><b class="rb2t"></b><b class="rb3t"></b><b class="rb4t"></b></b><div class="xtitle">';
+               }
+               else {
+                       echo '<div id=panel_title>';
+               }
+      
+               echo "Random Entries</div><div id=panel_body>";
+      
+               $increment_random_post_entries = 0;
+      
+               if ($count_random_post_items <= $limit_random_post_entries * 2) {
+                       $show_random_post_entries = $count_random_post_items - 1;
+               }
+               else {
+                       $show_random_post_entries = $limit_random_post_entries * 2 - 1;
+               }
+      
+               while ($increment_random_post_entries <= $show_random_post_entries) {
+                       echo "<a href=index.php?entry={$show_random_post_items[$increment_random_post_entries]}>";
+                       readfile("$dir/$show_random_post_items[$increment_random_post_entries]/title.txt");
+                       echo "</a><br>";
+      
+                       $increment_random_post_entries = $increment_random_post_entries + 1;
+               }
+       }
+      
+       if ($count_random_post_items > 0) {
+               echo "</div>";
+      
+               if (file_exists("data/round.txt")) {
+                       echo '<b class="rbbottom"><b class="rb4b"></b><b class="rb3b"></b><b class="rb2b"></b><b class="rb1b"></b></b>';
+               }
+       }
+}
+?>
+
 
 <?php
 if (file_exists("data/items")) {
@@ -4001,9 +4096,10 @@ if (file_exists("data/items")) {
                                continue;
                        }
 
-                       if (file_exists("data/items/$entry_archive_list/member.txt") and (!isset($_SESSION['logged_in']))) {
-                               continue;
-                       }
+                       // hide member
+                       //if (file_exists("data/items/$entry_archive_list/member.txt") and (!isset($_SESSION['logged_in']))) {
+                       //      continue;
+                       //}
 
                        $get_cat_dir = file_get_contents("data/items/$entry_archive_list/category.txt");
 
@@ -4057,7 +4153,6 @@ if (file_exists("data/items")) {
 ?>
 
 
-
 <?php
 
 if (file_exists("data/clustrmaps.php")) {
diff --git a/js/farbtastic.js b/js/farbtastic.js
new file mode 100644
index 0000000..24a3778
--- /dev/null
+++ b/js/farbtastic.js
@@ -0,0 +1,329 @@
+// $Id: farbtastic.js,v 1.2 2007/01/08 22:53:01 unconed Exp $
+// Farbtastic 1.2
+
+jQuery.fn.farbtastic = function (callback) {
+  $.farbtastic(this, callback);
+  return this;
+};
+
+jQuery.farbtastic = function (container, callback) {
+  var container = $(container).get(0);
+  return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
+}
+
+jQuery._farbtastic = function (container, callback) {
+  // Store farbtastic object
+  var fb = this;
+
+  // Insert markup
+  $(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
+  var e = $('.farbtastic', container);
+  fb.wheel = $('.wheel', container).get(0);
+  // Dimensions
+  fb.radius = 84;
+  fb.square = 100;
+  fb.width = 194;
+
+  // Fix background PNGs in IE6
+  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
+    $('*', e).each(function () {
+      if (this.currentStyle.backgroundImage != 'none') {
+        var image = this.currentStyle.backgroundImage;
+        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
+        $(this).css({
+          'backgroundImage': 'none',
+          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
+        });
+      }
+    });
+  }
+
+  /**
+   * Link to the given element(s) or callback.
+   */
+  fb.linkTo = function (callback) {
+    // Unbind previous nodes
+    if (typeof fb.callback == 'object') {
+      $(fb.callback).unbind('keyup', fb.updateValue);
+    }
+
+    // Reset color
+    fb.color = null;
+
+    // Bind callback or elements
+    if (typeof callback == 'function') {
+      fb.callback = callback;
+    }
+    else if (typeof callback == 'object' || typeof callback == 'string') {
+      fb.callback = $(callback);
+      fb.callback.bind('keyup', fb.updateValue);
+      if (fb.callback.get(0).value) {
+        fb.setColor(fb.callback.get(0).value);
+      }
+    }
+    return this;
+  }
+  fb.updateValue = function (event) {
+    if (this.value && this.value != fb.color) {
+      fb.setColor(this.value);
+    }
+  }
+
+  /**
+   * Change color with HTML syntax #123456
+   */
+  fb.setColor = function (color) {
+    var unpack = fb.unpack(color);
+    if (fb.color != color && unpack) {
+      fb.color = color;
+      fb.rgb = unpack;
+      fb.hsl = fb.RGBToHSL(fb.rgb);
+      fb.updateDisplay();
+    }
+    return this;
+  }
+
+  /**
+   * Change color with HSL triplet [0..1, 0..1, 0..1]
+   */
+  fb.setHSL = function (hsl) {
+    fb.hsl = hsl;
+    fb.rgb = fb.HSLToRGB(hsl);
+    fb.color = fb.pack(fb.rgb);
+    fb.updateDisplay();
+    return this;
+  }
+
+  /////////////////////////////////////////////////////
+
+  /**
+   * Retrieve the coordinates of the given event relative to the center
+   * of the widget.
+   */
+  fb.widgetCoords = function (event) {
+    var x, y;
+    var el = event.target || event.srcElement;
+    var reference = fb.wheel;
+
+    if (typeof event.offsetX != 'undefined') {
+      // Use offset coordinates and find common offsetParent
+      var pos = { x: event.offsetX, y: event.offsetY };
+
+      // Send the coordinates upwards through the offsetParent chain.
+      var e = el;
+      while (e) {
+        e.mouseX = pos.x;
+        e.mouseY = pos.y;
+        pos.x += e.offsetLeft;
+        pos.y += e.offsetTop;
+        e = e.offsetParent;
+      }
+
+      // Look for the coordinates starting from the wheel widget.
+      var e = reference;
+      var offset = { x: 0, y: 0 }
+      while (e) {
+        if (typeof e.mouseX != 'undefined') {
+          x = e.mouseX - offset.x;
+          y = e.mouseY - offset.y;
+          break;
+        }
+        offset.x += e.offsetLeft;
+        offset.y += e.offsetTop;
+        e = e.offsetParent;
+      }
+
+      // Reset stored coordinates
+      e = el;
+      while (e) {
+        e.mouseX = undefined;
+        e.mouseY = undefined;
+        e = e.offsetParent;
+      }
+    }
+    else {
+      // Use absolute coordinates
+      var pos = fb.absolutePosition(reference);
+      x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
+      y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
+    }
+    // Subtract distance to middle
+    return { x: x - fb.width / 2, y: y - fb.width / 2 };
+  }
+
+  /**
+   * Mousedown handler
+   */
+  fb.mousedown = function (event) {
+    // Capture mouse
+    if (!document.dragging) {
+      $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
+      document.dragging = true;
+    }
+
+    // Check which area is being dragged
+    var pos = fb.widgetCoords(event);
+    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
+
+    // Process
+    fb.mousemove(event);
+    return false;
+  }
+
+  /**
+   * Mousemove handler
+   */
+  fb.mousemove = function (event) {
+    // Get coordinates relative to color picker center
+    var pos = fb.widgetCoords(event);
+
+    // Set new HSL parameters
+    if (fb.circleDrag) {
+      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
+      if (hue < 0) hue += 1;
+      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
+    }
+    else {
+      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
+      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
+      fb.setHSL([fb.hsl[0], sat, lum]);
+    }
+    return false;
+  }
+
+  /**
+   * Mouseup handler
+   */
+  fb.mouseup = function () {
+    // Uncapture mouse
+    $(document).unbind('mousemove', fb.mousemove);
+    $(document).unbind('mouseup', fb.mouseup);
+    document.dragging = false;
+  }
+
+  /**
+   * Update the markers and styles
+   */
+  fb.updateDisplay = function () {
+    // Markers
+    var angle = fb.hsl[0] * 6.28;
+    $('.h-marker', e).css({
+      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
+      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
+    });
+
+    $('.sl-marker', e).css({
+      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
+      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
+    });
+
+    // Saturation/Luminance gradient
+    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
+
+    // Linked elements or callback
+    if (typeof fb.callback == 'object') {
+      // Set background/foreground color
+      $(fb.callback).css({
+        backgroundColor: fb.color,
+        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
+      });
+
+      // Change linked value
+      $(fb.callback).each(function() {
+        if (this.value && this.value != fb.color) {
+          this.value = fb.color;
+        }
+      });
+    }
+    else if (typeof fb.callback == 'function') {
+      fb.callback.call(fb, fb.color);
+    }
+  }
+
+  /**
+   * Get absolute position of element
+   */
+  fb.absolutePosition = function (el) {
+    var r = { x: el.offsetLeft, y: el.offsetTop };
+    // Resolve relative to offsetParent
+    if (el.offsetParent) {
+      var tmp = fb.absolutePosition(el.offsetParent);
+      r.x += tmp.x;
+      r.y += tmp.y;
+    }
+    return r;
+  };
+
+  /* Various color utility functions */
+  fb.pack = function (rgb) {
+    var r = Math.round(rgb[0] * 255);
+    var g = Math.round(rgb[1] * 255);
+    var b = Math.round(rgb[2] * 255);
+    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
+           (g < 16 ? '0' : '') + g.toString(16) +
+           (b < 16 ? '0' : '') + b.toString(16);
+  }
+
+  fb.unpack = function (color) {
+    if (color.length == 7) {
+      return [parseInt('0x' + color.substring(1, 3)) / 255,
+        parseInt('0x' + color.substring(3, 5)) / 255,
+        parseInt('0x' + color.substring(5, 7)) / 255];
+    }
+    else if (color.length == 4) {
+      return [parseInt('0x' + color.substring(1, 2)) / 15,
+        parseInt('0x' + color.substring(2, 3)) / 15,
+        parseInt('0x' + color.substring(3, 4)) / 15];
+    }
+  }
+
+  fb.HSLToRGB = function (hsl) {
+    var m1, m2, r, g, b;
+    var h = hsl[0], s = hsl[1], l = hsl[2];
+    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
+    m1 = l * 2 - m2;
+    return [this.hueToRGB(m1, m2, h+0.33333),
+        this.hueToRGB(m1, m2, h),
+        this.hueToRGB(m1, m2, h-0.33333)];
+  }
+
+  fb.hueToRGB = function (m1, m2, h) {
+    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
+    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
+    if (h * 2 < 1) return m2;
+    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
+    return m1;
+  }
+
+  fb.RGBToHSL = function (rgb) {
+    var min, max, delta, h, s, l;
+    var r = rgb[0], g = rgb[1], b = rgb[2];
+    min = Math.min(r, Math.min(g, b));
+    max = Math.max(r, Math.max(g, b));
+    delta = max - min;
+    l = (min + max) / 2;
+    s = 0;
+    if (l > 0 && l < 1) {
+      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
+    }
+    h = 0;
+    if (delta > 0) {
+      if (max == r && max != g) h += (g - b) / delta;
+      if (max == g && max != b) h += (2 + (b - r) / delta);
+      if (max == b && max != r) h += (4 + (r - g) / delta);
+      h /= 6;
+    }
+    return [h, s, l];
+  }
+
+  // Install mousedown handler (the others are set on the document on-demand)
+  $('*', e).mousedown(fb.mousedown);
+
+    // Init color
+  fb.setColor('#000000');
+
+  // Set linked elements/callback
+  if (callback) {
+    fb.linkTo(callback);
+  }
+}
\ No newline at end of file
diff --git a/js/jquery.js b/js/jquery.js
new file mode 100644
index 0000000..f364720
--- /dev/null
+++ b/js/jquery.js
@@ -0,0 +1,11 @@
+/*
+ * jQuery 1.1.3.1 - New Wave Javascript
+ *
+ * Copyright (c) 2007 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2007-07-05 00:43:24 -0400 (Thu, 05 Jul 2007) $
+ * $Rev: 2243 $
+ */
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7(1g 18.6=="I"){18.I=18.I;u 6=q(a,c){7(18==9||!9.3X)v 14 6(a,c);v 9.3X(a,c)};7(1g $!="I")6.1I$=$;u $=6;6.11=6.8r={3X:q(a,c){a=a||P;7(6.16(a))v 14 6(P)[6.11.1G?"1G":"1W"](a);7(1g a=="1s"){u m=/^[^<]*(<(.|\\s)+>)[^>]*$/.1V(a);7(m)a=6.31([m[1]]);B v 14 6(c).1L(a)}v 9.4E(a.15==2b&&a||(a.3C||a.C&&a!=18&&!a.1q&&a[0]!=I&&a[0].1q)&&6.2L(a)||[a])},3C:"1.1.3.1",7W:q(){v 9.C},C:0,1M:q(a){v a==I?6.2L(9):9[a]},1Z:q(a){u b=6(a);b.5q=9;v b},4E:q(a){9.C=0;[].R.O(9,a);v 9},F:q(a,b){v 6.F(9,a,b)},2p:q(a){u b=-1;9.F(q(i){7(9==a)b=i});v b},1b:q(f,d,e){u c=f;7(f.15==33)7(d==I)v 9.C&&6[e||"1b"](9[0],f)||I;B{c={};c[f]=d}v 9.F(q(a){E(u b V c)6.1b(e?9.T:9,b,6.4H(9,c[b],e,a,b))})},1f:q(b,a){v 9.1b(b,a,"2z")},2A:q(e){7(1g e=="1s")v 9.2Y().3e(P.66(e));u t="";6.F(e||9,q(){6.F(9.2S,q(){7(9.1q!=8)t+=9.1q!=1?9.5R:6.11.2A([9])})});v t},8b:q(){u a,1S=19;v 9.F(q(){7(!a)a=6.31(1S,9.2O);u b=a[0].3s(K);9.L.2K(b,9);1v(b.1d)b=b.1d;b.4g(9)})},3e:q(){v 9.2F(19,K,1,q(a){9.4g(a)})},5w:q(){v 9.2F(19,K,-1,q(a){9.2K(a,9.1d)})},5t:q(){v 9.2F(19,N,1,q(a){9.L.2K(a,9)})},5s:q(){v 9.2F(19,N,-1,q(a){9.L.2K(a,9.1X)})},2U:q(){v 9.5q||6([])},1L:q(t){u b=6.3k(9,q(a){v 6.1L(t,a)});v 9.1Z(/[^+>] [^+>]/.17(t)||t.J("..")>-1?6.5g(b):b)},7x:q(e){u d=9.1A(9.1L("*"));d.F(q(){9.1I$1a={};E(u a V 9.$1a)9.1I$1a[a]=6.1c({},9.$1a[a])}).3U();u r=9.1Z(6.3k(9,q(a){v a.3s(e!=I?e:K)}));d.F(q(){u b=9.1I$1a;E(u a V b)E(u c V b[a])6.S.1A(9,a,b[a][c],b[a][c].W);9.1I$1a=H});v r},1i:q(t){v 9.1Z(6.16(t)&&6.2s(9,q(b,a){v t.O(b,[a])})||6.2x(t,9))},4Y:q(t){v 9.1Z(t.15==33&&6.2x(t,9,K)||6.2s(9,q(a){v(t.15==2b||t.3C)?6.2w(a,t)<0:a!=t}))},1A:q(t){v 9.1Z(6.1T(9.1M(),t.15==33?6(t).1M():t.C!=I&&(!t.Q||t.Q=="6Z")?t:[t]))},37:q(a){v a?6.2x(a,9).C>0:N},6R:q(a){v a==I?(9.C?9[0].2v:H):9.1b("2v",a)},3F:q(a){v a==I?(9.C?9[0].27:H):9.2Y().3e(a)},2F:q(f,d,g,e){u c=9.C>1,a;v 9.F(q(){7(!a){a=6.31(f,9.2O);7(g<0)a.6E()}u b=9;7(d&&6.Q(9,"1r")&&6.Q(a[0],"2V"))b=9.3R("1z")[0]||9.4g(P.5h("1z"));6.F(a,q(){e.O(b,[c?9.3s(K):9])})})}};6.1c=6.11.1c=q(){u c=19[0],a=1;7(19.C==1){c=9;a=0}u b;1v((b=19[a++])!=H)E(u i V b)c[i]=b[i];v c};6.1c({6n:q(){7(6.1I$)$=6.1I$;v 6},16:q(a){v!!a&&1g a!="1s"&&!a.Q&&a.15!=2b&&/q/i.17(a+"")},40:q(a){v a.4z&&a.2O&&!a.2O.4y},Q:q(b,a){v b.Q&&b.Q.1D()==a.1D()},F:q(a,b,c){7(a.C==I)E(u i V a)b.O(a[i],c||[i,a[i]]);B E(u i=0,4x=a.C;i<4x;i++)7(b.O(a[i],c||[i,a[i]])===N)1F;v a},4H:q(c,b,d,e,a){7(6.16(b))b=b.3D(c,[e]);u f=/z-?2p|5Y-?8p|1e|5U|8i-?1u/i;v b&&b.15==3y&&d=="2z"&&!f.17(a)?b+"4o":b},12:{1A:q(b,c){6.F(c.2R(/\\s+/),q(i,a){7(!6.12.3w(b.12,a))b.12+=(b.12?" ":"")+a})},1E:q(b,c){b.12=c!=I?6.2s(b.12.2R(/\\s+/),q(a){v!6.12.3w(c,a)}).5M(" "):""},3w:q(t,c){v 6.2w(c,(t.12||t).3v().2R(/\\s+/))>-1}},4m:q(e,o,f){E(u i V o){e.T["2N"+i]=e.T[i];e.T[i]=o[i]}f.O(e,[]);E(u i V o)e.T[i]=e.T["2N"+i]},1f:q(e,p){7(p=="1u"||p=="29"){u b={},3r,3p,d=["83","81","80","7Y"];6.F(d,q(){b["7V"+9]=0;b["7T"+9+"7S"]=0});6.4m(e,b,q(){7(6(e).37(\':4f\')){3r=e.7Q;3p=e.7O}B{e=6(e.3s(K)).1L(":4b").5v("2B").2U().1f({48:"1y",3i:"7L",U:"2h",7K:"0",7I:"0"}).5o(e.L)[0];u a=6.1f(e.L,"3i")||"3n";7(a=="3n")e.L.T.3i="7G";3r=e.7E;3p=e.7D;7(a=="3n")e.L.T.3i="3n";e.L.3q(e)}});v p=="1u"?3r:3p}v 6.2z(e,p)},2z:q(e,a,d){u g;7(a=="1e"&&6.M.1h){g=6.1b(e.T,"1e");v g==""?"1":g}7(a.3t(/3x/i))a=6.1U;7(!d&&e.T[a])g=e.T[a];B 7(P.3f&&P.3f.3Y){7(a.3t(/3x/i))a="3x";a=a.1o(/([A-Z])/g,"-$1").2H();u b=P.3f.3Y(e,H);7(b)g=b.57(a);B 7(a=="U")g="1P";B 6.4m(e,{U:"2h"},q(){u c=P.3f.3Y(9,"");g=c&&c.57(a)||""})}B 7(e.3S){u f=a.1o(/\\-(\\w)/g,q(m,c){v c.1D()});g=e.3S[a]||e.3S[f]}v g},31:q(a,c){u r=[];c=c||P;6.F(a,q(i,b){7(!b)v;7(b.15==3y)b=b.3v();7(1g b=="1s"){u s=6.2C(b).2H(),1x=c.5h("1x"),1N=[];u a=!s.J("<1H")&&[1,"<2y>","</2y>"]||!s.J("<7g")&&[1,"<52>","</52>"]||(!s.J("<7c")||!s.J("<1z")||!s.J("<7a")||!s.J("<78"))&&[1,"<1r>","</1r>"]||!s.J("<2V")&&[2,"<1r><1z>","</1z></1r>"]||(!s.J("<75")||!s.J("<74"))&&[3,"<1r><1z><2V>","</2V></1z></1r>"]||!s.J("<73")&&[2,"<1r><4W>","</4W></1r>"]||[0,"",""];1x.27=a[1]+b+a[2];1v(a[0]--)1x=1x.1d;7(6.M.1h){7(!s.J("<1r")&&s.J("<1z")<0)1N=1x.1d&&1x.1d.2S;B 7(a[1]=="<1r>"&&s.J("<1z")<0)1N=1x.2S;E(u n=1N.C-1;n>=0;--n)7(6.Q(1N[n],"1z")&&!1N[n].2S.C)1N[n].L.3q(1N[n])}b=6.2L(1x.2S)}7(0===b.C&&(!6.Q(b,"34")&&!6.Q(b,"2y")))v;7(b[0]==I||6.Q(b,"34")||b.71)r.R(b);B r=6.1T(r,b)});v r},1b:q(c,d,a){u e=6.40(c)?{}:6.3H;7(e[d]){7(a!=I)c[e[d]]=a;v c[e[d]]}B 7(a==I&&6.M.1h&&6.Q(c,"34")&&(d=="70"||d=="6Y"))v c.6W(d).5R;B 7(c.4z){7(a!=I)c.6U(d,a);7(6.M.1h&&/4M|2u/.17(d)&&!6.40(c))v c.35(d,2);v c.35(d)}B{7(d=="1e"&&6.M.1h){7(a!=I){c.5U=1;c.1i=(c.1i||"").1o(/4L\\([^)]*\\)/,"")+(39(a).3v()=="6M"?"":"4L(1e="+a*4X+")")}v c.1i?(39(c.1i.3t(/1e=([^)]*)/)[1])/4X).3v():""}d=d.1o(/-([a-z])/6K,q(z,b){v b.1D()});7(a!=I)c[d]=a;v c[d]}},2C:q(t){v t.1o(/^\\s+|\\s+$/g,"")},2L:q(a){u r=[];7(1g a!="6I")E(u i=0,26=a.C;i<26;i++)r.R(a[i]);B r=a.51(0);v r},2w:q(b,a){E(u i=0,26=a.C;i<26;i++)7(a[i]==b)v i;v-1},1T:q(a,b){E(u i=0;b[i];i++)a.R(b[i]);v a},5g:q(a){u r=[],3P=6.1k++;E(u i=0,4G=a.C;i<4G;i++)7(3P!=a[i].1k){a[i].1k=3P;r.R(a[i])}v r},1k:0,2s:q(c,b,d){7(1g b=="1s")b=14 45("a","i","v "+b);u a=[];E(u i=0,30=c.C;i<30;i++)7(!d&&b(c[i],i)||d&&!b(c[i],i))a.R(c[i]);v a},3k:q(c,b){7(1g b=="1s")b=14 45("a","v "+b);u d=[];E(u i=0,30=c.C;i<30;i++){u a=b(c[i],i);7(a!==H&&a!=I){7(a.15!=2b)a=[a];d=d.6v(a)}}v d}});14 q(){u b=6u.6t.2H();6.M={4D:(b.3t(/.+(?:6s|6q|6o|6m)[\\/: ]([\\d.]+)/)||[])[1],20:/5l/.17(b),2a:/2a/.17(b),1h:/1h/.17(b)&&!/2a/.17(b),3j:/3j/.17(b)&&!/(6h|5l)/.17(b)};6.6g=!6.M.1h||P.6f=="6c";6.1U=6.M.1h?"1U":"5x",6.3H={"E":"68","67":"12","3x":6.1U,5x:6.1U,1U:6.1U,27:"27",12:"12",2v:"2v",2r:"2r",2B:"2B",65:"63",2T:"2T",62:"5Z"}};6.F({4v:"a.L",4p:"6.4p(a)",8o:"6.22(a,2,\'1X\')",8n:"6.22(a,2,\'4t\')",8k:"6.4q(a.L.1d,a)",8h:"6.4q(a.1d)"},q(i,n){6.11[i]=q(a){u b=6.3k(9,n);7(a&&1g a=="1s")b=6.2x(a,b);v 9.1Z(b)}});6.F({5o:"3e",8g:"5w",2K:"5t",8f:"5s"},q(i,n){6.11[i]=q(){u a=19;v 9.F(q(){E(u j=0,26=a.C;j<26;j++)6(a[j])[n](9)})}});6.F({5v:q(a){6.1b(9,a,"");9.8d(a)},8c:q(c){6.12.1A(9,c)},88:q(c){6.12.1E(9,c)},87:q(c){6.12[6.12.3w(9,c)?"1E":"1A"](9,c)},1E:q(a){7(!a||6.1i(a,[9]).r.C)9.L.3q(9)},2Y:q(){1v(9.1d)9.3q(9.1d)}},q(i,n){6.11[i]=q(){v 9.F(n,19)}});6.F(["5Q","5P","5O","5N"],q(i,n){6.11[n]=q(a,b){v 9.1i(":"+n+"("+a+")",b)}});6.F(["1u","29"],q(i,n){6.11[n]=q(h){v h==I?(9.C?6.1f(9[0],n):H):9.1f(n,h.15==33?h:h+"4o")}});6.1c({4n:{"":"m[2]==\'*\'||6.Q(a,m[2])","#":"a.35(\'2m\')==m[2]",":":{5P:"i<m[3]-0",5O:"i>m[3]-0",22:"m[3]-0==i",5Q:"m[3]-0==i",2Q:"i==0",2P:"i==r.C-1",5L:"i%2==0",5K:"i%2","2Q-3u":"a.L.3R(\'*\')[0]==a","2P-3u":"6.22(a.L.5J,1,\'4t\')==a","86-3u":"!6.22(a.L.5J,2,\'4t\')",4v:"a.1d",2Y:"!a.1d",5N:"(a.5H||a.85||\'\').J(m[3])>=0",4f:\'"1y"!=a.G&&6.1f(a,"U")!="1P"&&6.1f(a,"48")!="1y"\',1y:\'"1y"==a.G||6.1f(a,"U")=="1P"||6.1f(a,"48")=="1y"\',84:"!a.2r",2r:"a.2r",2B:"a.2B",2T:"a.2T||6.1b(a,\'2T\')",2A:"\'2A\'==a.G",4b:"\'4b\'==a.G",5F:"\'5F\'==a.G",4l:"\'4l\'==a.G",5E:"\'5E\'==a.G",4k:"\'4k\'==a.G",5D:"\'5D\'==a.G",5C:"\'5C\'==a.G",1J:\'"1J"==a.G||6.Q(a,"1J")\',5B:"/5B|2y|82|1J/i.17(a.Q)"},"[":"6.1L(m[2],a).C"},5A:[/^\\[ *(@)([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(\\[)\\s*(.*?(\\[.*?\\])?[^[]*?)\\s*\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,14 3o("^([:.#]*)("+(6.2J=6.M.20&&6.M.4D<"3.0.0"?"\\\\w":"(?:[\\\\w\\7Z-\\7X*1I-]|\\\\\\\\.)")+"+)")],2x:q(a,c,b){u d,1K=[];1v(a&&a!=d){d=a;u f=6.1i(a,c,b);a=f.t.1o(/^\\s*,\\s*/,"");1K=b?c=f.r:6.1T(1K,f.r)}v 1K},1L:q(t,l){7(1g t!="1s")v[t];7(l&&!l.1q)l=H;l=l||P;7(!t.J("//")){l=l.4h;t=t.2G(2,t.C)}B 7(!t.J("/")&&!l.2O){l=l.4h;t=t.2G(1,t.C);7(t.J("/")>=1)t=t.2G(t.J("/"),t.C)}u b=[l],2j=[],2P;1v(t&&2P!=t){u r=[];2P=t;t=6.2C(t).1o(/^\\/\\//,"");u k=N;u g=14 3o("^[/>]\\\\s*("+6.2J+"+)");u m=g.1V(t);7(m){u o=m[1].1D();E(u i=0;b[i];i++)E(u c=b[i].1d;c;c=c.1X)7(c.1q==1&&(o=="*"||c.Q.1D()==o.1D()))r.R(c);b=r;t=t.1o(g,"");7(t.J(" ")==0)7R;k=K}B{g=/^((\\/?\\.\\.)|([>\\/+~]))\\s*([a-z]*)/i;7((m=g.1V(t))!=H){r=[];u o=m[4],1k=6.1k++;m=m[1];E(u j=0,2e=b.C;j<2e;j++)7(m.J("..")<0){u n=m=="~"||m=="+"?b[j].1X:b[j].1d;E(;n;n=n.1X)7(n.1q==1){7(m=="~"&&n.1k==1k)1F;7(!o||n.Q.1D()==o.1D()){7(m=="~")n.1k=1k;r.R(n)}7(m=="+")1F}}B r.R(b[j].L);b=r;t=6.2C(t.1o(g,""));k=K}}7(t&&!k){7(!t.J(",")){7(l==b[0])b.4e();2j=6.1T(2j,b);r=b=[l];t=" "+t.2G(1,t.C)}B{u h=14 3o("^("+6.2J+"+)(#)("+6.2J+"+)");u m=h.1V(t);7(m){m=[0,m[2],m[3],m[1]]}B{h=14 3o("^([#.]?)("+6.2J+"*)");m=h.1V(t)}m[2]=m[2].1o(/\\\\/g,"");u f=b[b.C-1];7(m[1]=="#"&&f&&f.4d){u p=f.4d(m[2]);7((6.M.1h||6.M.2a)&&p&&1g p.2m=="1s"&&p.2m!=m[2])p=6(\'[@2m="\'+m[2]+\'"]\',f)[0];b=r=p&&(!m[3]||6.Q(p,m[3]))?[p]:[]}B{E(u i=0;b[i];i++){u a=m[1]!=""||m[0]==""?"*":m[2];7(a=="*"&&b[i].Q.2H()=="7P")a="2E";r=6.1T(r,b[i].3R(a))}7(m[1]==".")r=6.4c(r,m[2]);7(m[1]=="#"){u e=[];E(u i=0;r[i];i++)7(r[i].35("2m")==m[2]){e=[r[i]];1F}r=e}b=r}t=t.1o(h,"")}}7(t){u d=6.1i(t,r);b=r=d.r;t=6.2C(d.t)}}7(t)b=[];7(b&&l==b[0])b.4e();2j=6.1T(2j,b);v 2j},4c:q(r,m,a){m=" "+m+" ";u b=[];E(u i=0;r[i];i++){u c=(" "+r[i].12+" ").J(m)>=0;7(!a&&c||a&&!c)b.R(r[i])}v b},1i:q(t,r,h){u d;1v(t&&t!=d){d=t;u p=6.5A,m;E(u i=0;p[i];i++){m=p[i].1V(t);7(m){t=t.7N(m[0].C);m[2]=m[2].1o(/\\\\/g,"");1F}}7(!m)1F;7(m[1]==":"&&m[2]=="4Y")r=6.1i(m[3],r,K).r;B 7(m[1]==".")r=6.4c(r,m[2],h);B 7(m[1]=="@"){u g=[],G=m[3];E(u i=0,2e=r.C;i<2e;i++){u a=r[i],z=a[6.3H[m[2]]||m[2]];7(z==H||/4M|2u/.17(m[2]))z=6.1b(a,m[2])||\'\';7((G==""&&!!z||G=="="&&z==m[5]||G=="!="&&z!=m[5]||G=="^="&&z&&!z.J(m[5])||G=="$="&&z.2G(z.C-m[5].C)==m[5]||(G=="*="||G=="~=")&&z.J(m[5])>=0)^h)g.R(a)}r=g}B 7(m[1]==":"&&m[2]=="22-3u"){u e=6.1k++,g=[],17=/(\\d*)n\\+?(\\d*)/.1V(m[3]=="5L"&&"2n"||m[3]=="5K"&&"2n+1"||!/\\D/.17(m[3])&&"n+"+m[3]||m[3]),2Q=(17[1]||1)-0,d=17[2]-0;E(u i=0,2e=r.C;i<2e;i++){u j=r[i],L=j.L;7(e!=L.1k){u c=1;E(u n=L.1d;n;n=n.1X)7(n.1q==1)n.4a=c++;L.1k=e}u b=N;7(2Q==1){7(d==0||j.4a==d)b=K}B 7((j.4a+d)%2Q==0)b=K;7(b^h)g.R(j)}r=g}B{u f=6.4n[m[1]];7(1g f!="1s")f=6.4n[m[1]][m[2]];49("f = q(a,i){v "+f+"}");r=6.2s(r,f,h)}}v{r:r,t:t}},4p:q(c){u b=[];u a=c.L;1v(a&&a!=P){b.R(a);a=a.L}v b},22:q(a,e,c,b){e=e||1;u d=0;E(;a;a=a[c])7(a.1q==1&&++d==e)1F;v a},4q:q(n,a){u r=[];E(;n;n=n.1X){7(n.1q==1&&(!a||n!=a))r.R(n)}v r}});6.S={1A:q(d,e,c,b){7(6.M.1h&&d.3m!=I)d=18;7(!c.1Q)c.1Q=9.1Q++;7(b!=I){u f=c;c=q(){v f.O(9,19)};c.W=b;c.1Q=f.1Q}7(!d.$1a)d.$1a={};7(!d.$1p)d.$1p=q(){u a;7(1g 6=="I"||6.S.47)v a;a=6.S.1p.O(d,19);v a};u g=d.$1a[e];7(!g){g=d.$1a[e]={};7(d.46)d.46(e,d.$1p,N);B d.7M("5r"+e,d.$1p)}g[c.1Q]=c;7(!9.Y[e])9.Y[e]=[];7(6.2w(d,9.Y[e])==-1)9.Y[e].R(d)},1Q:1,Y:{},1E:q(b,c,a){u d=b.$1a,1Y,2p;7(d){7(c&&c.G){a=c.44;c=c.G}7(!c){E(c V d)9.1E(b,c)}B 7(d[c]){7(a)3l d[c][a.1Q];B E(a V b.$1a[c])3l d[c][a];E(1Y V d[c])1F;7(!1Y){7(b.43)b.43(c,b.$1p,N);B b.7J("5r"+c,b.$1p);1Y=H;3l d[c];1v(9.Y[c]&&((2p=6.2w(b,9.Y[c]))>=0))3l 9.Y[c][2p]}}E(1Y V d)1F;7(!1Y)b.$1p=b.$1a=H}},1t:q(c,b,d){b=6.2L(b||[]);7(!d)6.F(9.Y[c]||[],q(){6.S.1t(c,b,9)});B{u a,1Y,11=6.16(d[c]||H);b.5p(9.42({G:c,1O:d}));7(6.16(d.$1p)&&(a=d.$1p.O(d,b))!==N)9.47=K;7(11&&a!==N&&!6.Q(d,\'a\'))d[c]();9.47=N}},1p:q(b){u a;b=6.S.42(b||18.S||{});u c=9.$1a&&9.$1a[b.G],1S=[].51.3D(19,1);1S.5p(b);E(u j V c){1S[0].44=c[j];1S[0].W=c[j].W;7(c[j].O(9,1S)===N){b.2d();b.2D();a=N}}7(6.M.1h)b.1O=b.2d=b.2D=b.44=b.W=H;v a},42:q(c){u a=c;c=6.1c({},a);c.2d=q(){7(a.2d)v a.2d();a.7H=N};c.2D=q(){7(a.2D)v a.2D();a.7F=K};7(!c.1O&&c.5n)c.1O=c.5n;7(6.M.20&&c.1O.1q==3)c.1O=a.1O.L;7(!c.41&&c.4j)c.41=c.4j==c.1O?c.7C:c.4j;7(c.5k==H&&c.5j!=H){u e=P.4h,b=P.4y;c.5k=c.5j+(e&&e.5i||b.5i);c.7z=c.7y+(e&&e.5f||b.5f)}7(!c.3h&&(c.5e||c.5d))c.3h=c.5e||c.5d;7(!c.5c&&c.5b)c.5c=c.5b;7(!c.3h&&c.1J)c.3h=(c.1J&1?1:(c.1J&2?3:(c.1J&4?2:0)));v c}};6.11.1c({3g:q(c,a,b){v c=="3z"?9.3Z(c,a,b):9.F(q(){6.S.1A(9,c,b||a,b&&a)})},3Z:q(d,b,c){v 9.F(q(){6.S.1A(9,d,q(a){6(9).3U(a);v(c||b).O(9,19)},c&&b)})},3U:q(a,b){v 9.F(q(){6.S.1E(9,a,b)})},1t:q(a,b){v 9.F(q(){6.S.1t(a,b,9)})},1R:q(){u a=19;v 9.5a(q(e){9.4u=0==9.4u?1:0;e.2d();v a[9.4u].O(9,[e])||N})},7w:q(f,g){q 3W(e){u p=e.41;1v(p&&p!=9)2g{p=p.L}25(e){p=9};7(p==9)v N;v(e.G=="3V"?f:g).O(9,[e])}v 9.3V(3W).59(3W)},1G:q(f){7(6.3d)f.O(P,[6]);B 6.2q.R(q(){v f.O(9,[6])});v 9}});6.1c({3d:N,2q:[],1G:q(){7(!6.3d){6.3d=K;7(6.2q){6.F(6.2q,q(){9.O(P)});6.2q=H}7(6.M.3j||6.M.2a)P.43("58",6.1G,N);7(!18.7v.C)6(18).1W(q(){6("#3T").1E()})}}});14 q(){6.F(("7u,7t,1W,7s,7r,3z,5a,7q,"+"7p,7o,7n,3V,59,7m,2y,"+"4k,7l,7k,7j,2c").2R(","),q(i,o){6.11[o]=q(f){v f?9.3g(o,f):9.1t(o)}});7(6.M.3j||6.M.2a)P.46("58",6.1G,N);B 7(6.M.1h){P.7i("<7h"+"7f 2m=3T 7e=K "+"2u=//:><\\/3b>");u a=P.4d("3T");7(a)a.7d=q(){7(9.3a!="1n")v;6.1G()};a=H}B 7(6.M.20)6.3N=3m(q(){7(P.3a=="79"||P.3a=="1n"){3M(6.3N);6.3N=H;6.1G()}},10);6.S.1A(18,"1W",6.1G)};7(6.M.1h)6(18).3Z("3z",q(){u a=6.S.Y;E(u b V a){u c=a[b],i=c.C;7(i&&b!=\'3z\')77 c[i-1]&&6.S.1E(c[i-1],b);1v(--i)}});6.11.1c({76:q(c,b,a){9.1W(c,b,a,1)},1W:q(g,d,c,e){7(6.16(g))v 9.3g("1W",g);c=c||q(){};u f="3K";7(d)7(6.16(d)){c=d;d=H}B{d=6.2E(d);f="50"}u h=9;6.2Z({1C:g,G:f,W:d,2t:e,1n:q(a,b){7(b=="28"||!e&&b=="4V")h.1b("27",a.3c).3J().F(c,[a.3c,b,a]);B c.O(h,[a.3c,b,a])}});v 9},72:q(){v 6.2E(9)},3J:q(){v 9.1L("3b").F(q(){7(9.2u)6.4U(9.2u);B 6.3I(9.2A||9.5H||9.27||"")}).2U()}});6.F("4T,4I,4S,4R,4Q,4P".2R(","),q(i,o){6.11[o]=q(f){v 9.3g(o,f)}});6.1c({1M:q(e,c,a,d,b){7(6.16(c)){a=c;c=H}v 6.2Z({G:"3K",1C:e,W:c,28:a,3G:d,2t:b})},6X:q(d,b,a,c){v 6.1M(d,b,a,c,1)},4U:q(b,a){v 6.1M(b,H,a,"3b")},6V:q(c,b,a){v 6.1M(c,b,a,"4N")},6T:q(d,b,a,c){7(6.16(b)){a=b;b={}}v 6.2Z({G:"50",1C:d,W:b,28:a,3G:c})},6S:q(a){6.36.21=a},6Q:q(a){6.1c(6.36,a)},36:{Y:K,G:"3K",21:0,4O:"6P/x-6O-34-6N",4K:K,38:K,W:H},32:{},2Z:q(s){s=6.1c({},6.36,s);7(s.W){7(s.4K&&1g s.W!="1s")s.W=6.2E(s.W);7(s.G.2H()=="1M"){s.1C+=((s.1C.J("?")>-1)?"&":"?")+s.W;s.W=H}}7(s.Y&&!6.3L++)6.S.1t("4T");u f=N;u h=18.4Z?14 4Z("6L.6J"):14 4J();h.7b(s.G,s.1C,s.38);7(s.W)h.3Q("6H-6G",s.4O);7(s.2t)h.3Q("6F-3O-6D",6.32[s.1C]||"6C, 6B 6A 6z 4r:4r:4r 6y");h.3Q("X-6x-6w","4J");7(s.56)s.56(h);7(s.Y)6.S.1t("4P",[h,s]);u g=q(d){7(h&&(h.3a==4||d=="21")){f=K;7(i){3M(i);i=H}u c;2g{c=6.54(h)&&d!="21"?s.2t&&6.4F(h,s.1C)?"4V":"28":"2c";7(c!="2c"){u b;2g{b=h.3E("53-3O")}25(e){}7(s.2t&&b)6.32[s.1C]=b;u a=6.55(h,s.3G);7(s.28)s.28(a,c);7(s.Y)6.S.1t("4Q",[h,s])}B 6.2X(s,h,c)}25(e){c="2c";6.2X(s,h,c,e)}7(s.Y)6.S.1t("4S",[h,s]);7(s.Y&&!--6.3L)6.S.1t("4I");7(s.1n)s.1n(h,c);7(s.38)h=H}};u i=3m(g,13);7(s.21>0)4C(q(){7(h){h.6r();7(!f)g("21")}},s.21);2g{h.6p(s.W)}25(e){6.2X(s,h,H,e)}7(!s.38)g();v h},2X:q(s,a,b,e){7(s.2c)s.2c(a,b,e);7(s.Y)6.S.1t("4R",[a,s,e])},3L:0,54:q(r){2g{v!r.23&&7A.7B=="4l:"||(r.23>=5u&&r.23<6l)||r.23==5m||6.M.20&&r.23==I}25(e){}v N},4F:q(a,c){2g{u b=a.3E("53-3O");v a.23==5m||b==6.32[c]||6.M.20&&a.23==I}25(e){}v N},55:q(r,b){u c=r.3E("6k-G");u a=!b&&c&&c.J("4B")>=0;a=b=="4B"||a?r.6j:r.3c;7(b=="3b")6.3I(a);7(b=="4N")a=49("("+a+")");7(b=="3F")6("<1x>").3F(a).3J();v a},2E:q(a){u s=[];7(a.15==2b||a.3C)6.F(a,q(){s.R(2l(9.6i)+"="+2l(9.2v))});B E(u j V a)7(a[j]&&a[j].15==2b)6.F(a[j],q(){s.R(2l(j)+"="+2l(9))});B s.R(2l(j)+"="+2l(a[j]));v s.5M("&")},3I:q(a){7(18.4A)18.4A(a);B 7(6.M.20)18.4C(a,0);B 49.3D(18,a)}});6.11.1c({1m:q(b,a){v b?9.1w({1u:"1m",29:"1m",1e:"1m"},b,a):9.1i(":1y").F(q(){9.T.U=9.2i?9.2i:"";7(6.1f(9,"U")=="1P")9.T.U="2h"}).2U()},1j:q(b,a){v b?9.1w({1u:"1j",29:"1j",1e:"1j"},b,a):9.1i(":4f").F(q(){9.2i=9.2i||6.1f(9,"U");7(9.2i=="1P")9.2i="2h";9.T.U="1P"}).2U()},5G:6.11.1R,1R:q(a,b){v 6.16(a)&&6.16(b)?9.5G(a,b):a?9.1w({1u:"1R",29:"1R",1e:"1R"},a,b):9.F(q(){6(9)[6(9).37(":1y")?"1m":"1j"]()})},6e:q(b,a){v 9.1w({1u:"1m"},b,a)},6d:q(b,a){v 9.1w({1u:"1j"},b,a)},6b:q(b,a){v 9.1w({1u:"1R"},b,a)},6a:q(b,a){v 9.1w({1e:"1m"},b,a)},69:q(b,a){v 9.1w({1e:"1j"},b,a)},7U:q(c,a,b){v 9.1w({1e:a},c,b)},1w:q(d,h,f,g){v 9.1l(q(){u c=6(9).37(":1y"),1H=6.5z(h,f,g),5y=9;E(u p V d){7(d[p]=="1j"&&c||d[p]=="1m"&&!c)v 6.16(1H.1n)&&1H.1n.O(9);7(p=="1u"||p=="29"){1H.U=6.1f(9,"U");1H.2f=9.T.2f}}7(1H.2f!=H)9.T.2f="1y";9.2k=6.1c({},d);6.F(d,q(a,b){u e=14 6.2M(5y,1H,a);7(b.15==3y)e.2W(e.1K(),b);B e[b=="1R"?c?"1m":"1j":b](d)})})},1l:q(a,b){7(!b){b=a;a="2M"}v 9.F(q(){7(!9.1l)9.1l={};7(!9.1l[a])9.1l[a]=[];9.1l[a].R(b);7(9.1l[a].C==1)b.O(9)})}});6.1c({5z:q(b,a,c){u d=b&&b.15==64?b:{1n:c||!c&&a||6.16(b)&&b,1B:b,2I:c&&a||a&&a.15!=45&&a||(6.2I.4i?"4i":"4w")};d.1B=(d.1B&&d.1B.15==3y?d.1B:{61:60,89:5u}[d.1B])||8a;d.2N=d.1n;d.1n=q(){6.5I(9,"2M");7(6.16(d.2N))d.2N.O(9)};v d},2I:{4w:q(p,n,b,a){v b+a*p},4i:q(p,n,b,a){v((-5W.5X(p*5W.8e)/2)+0.5)*a+b}},1l:{},5I:q(b,a){a=a||"2M";7(b.1l&&b.1l[a]){b.1l[a].4e();u f=b.1l[a][0];7(f)f.O(b)}},3B:[],2M:q(f,e,g){u z=9;u y=f.T;z.a=q(){7(e.3A)e.3A.O(f,[z.2o]);7(g=="1e")6.1b(y,"1e",z.2o);B{y[g]=8m(z.2o)+"4o";y.U="2h"}};z.5V=q(){v 39(6.1f(f,g))};z.1K=q(){u r=39(6.2z(f,g));v r&&r>-8l?r:z.5V()};z.2W=q(c,b){z.4s=(14 5T()).5S();z.2o=c;z.a();6.3B.R(q(){v z.3A(c,b)});7(6.3B.C==1){u d=3m(q(){u a=6.3B;E(u i=0;i<a.C;i++)7(!a[i]())a.8j(i--,1);7(!a.C)3M(d)},13)}};z.1m=q(){7(!f.24)f.24={};f.24[g]=6.1b(f.T,g);e.1m=K;z.2W(0,9.1K());7(g!="1e")y[g]="8q";6(f).1m()};z.1j=q(){7(!f.24)f.24={};f.24[g]=6.1b(f.T,g);e.1j=K;z.2W(9.1K(),0)};z.3A=q(a,c){u t=(14 5T()).5S();7(t>e.1B+z.4s){z.2o=c;z.a();7(f.2k)f.2k[g]=K;u b=K;E(u i V f.2k)7(f.2k[i]!==K)b=N;7(b){7(e.U!=H){y.2f=e.2f;y.U=e.U;7(6.1f(f,"U")=="1P")y.U="2h"}7(e.1j)y.U="1P";7(e.1j||e.1m)E(u p V f.2k)6.1b(y,p,f.24[p])}7(b&&6.16(e.1n))e.1n.O(f);v N}B{u n=t-9.4s;u p=n/e.1B;z.2o=6.2I[e.2I](p,n,a,(c-a),e.1B);z.a()}v K}}})}',62,524,'||||||jQuery|if||this|||||||||||||||||function||||var|return||||||else|length||for|each|type|null|undefined|indexOf|true|parentNode|browser|false|apply|document|nodeName|push|event|style|display|in|data||global|||fn|className||new|constructor|isFunction|test|window|arguments|events|attr|extend|firstChild|opacity|css|typeof|msie|filter|hide|mergeNum|queue|show|complete|replace|handle|nodeType|table|string|trigger|height|while|animate|div|hidden|tbody|add|duration|url|toUpperCase|remove|break|ready|opt|_|button|cur|find|get|tb|target|none|guid|toggle|args|merge|styleFloat|exec|load|nextSibling|ret|pushStack|safari|timeout|nth|status|orig|catch|al|innerHTML|success|width|opera|Array|error|preventDefault|rl|overflow|try|block|oldblock|done|curAnim|encodeURIComponent|id||now|index|readyList|disabled|grep|ifModified|src|value|inArray|multiFilter|select|curCSS|text|checked|trim|stopPropagation|param|domManip|substr|toLowerCase|easing|chars|insertBefore|makeArray|fx|old|ownerDocument|last|first|split|childNodes|selected|end|tr|custom|handleError|empty|ajax|el|clean|lastModified|String|form|getAttribute|ajaxSettings|is|async|parseFloat|readyState|script|responseText|isReady|append|defaultView|bind|which|position|mozilla|map|delete|setInterval|static|RegExp|oWidth|removeChild|oHeight|cloneNode|match|child|toString|has|float|Number|unload|step|timers|jquery|call|getResponseHeader|html|dataType|props|globalEval|evalScripts|GET|active|clearInterval|safariTimer|Modified|num|setRequestHeader|getElementsByTagName|currentStyle|__ie_init|unbind|mouseover|handleHover|init|getComputedStyle|one|isXMLDoc|relatedTarget|fix|removeEventListener|handler|Function|addEventListener|triggered|visibility|eval|nodeIndex|radio|classFilter|getElementById|shift|visible|appendChild|documentElement|swing|fromElement|submit|file|swap|expr|px|parents|sibling|00|startTime|previousSibling|lastToggle|parent|linear|ol|body|tagName|execScript|xml|setTimeout|version|setArray|httpNotModified|fl|prop|ajaxStop|XMLHttpRequest|processData|alpha|href|json|contentType|ajaxSend|ajaxSuccess|ajaxError|ajaxComplete|ajaxStart|getScript|notmodified|colgroup|100|not|ActiveXObject|POST|slice|fieldset|Last|httpSuccess|httpData|beforeSend|getPropertyValue|DOMContentLoaded|mouseout|click|ctrlKey|metaKey|keyCode|charCode|scrollTop|unique|createElement|scrollLeft|clientX|pageX|webkit|304|srcElement|appendTo|unshift|prevObject|on|after|before|200|removeAttr|prepend|cssFloat|self|speed|parse|input|reset|image|password|checkbox|_toggle|textContent|dequeue|lastChild|odd|even|join|contains|gt|lt|eq|nodeValue|getTime|Date|zoom|max|Math|cos|font|maxLength|600|slow|maxlength|readOnly|Object|readonly|createTextNode|class|htmlFor|fadeOut|fadeIn|slideToggle|CSS1Compat|slideUp|slideDown|compatMode|boxModel|compatible|name|responseXML|content|300|ie|noConflict|ra|send|it|abort|rv|userAgent|navigator|concat|With|Requested|GMT|1970|Jan|01|Thu|Since|reverse|If|Type|Content|array|XMLHTTP|ig|Microsoft|NaN|urlencoded|www|application|ajaxSetup|val|ajaxTimeout|post|setAttribute|getJSON|getAttributeNode|getIfModified|method|FORM|action|options|serialize|col|th|td|loadIfModified|do|colg|loaded|tfoot|open|thead|onreadystatechange|defer|ipt|leg|scr|write|keyup|keypress|keydown|change|mousemove|mouseup|mousedown|dblclick|scroll|resize|focus|blur|frames|hover|clone|clientY|pageY|location|protocol|toElement|clientWidth|clientHeight|cancelBubble|relative|returnValue|left|detachEvent|right|absolute|attachEvent|substring|offsetWidth|object|offsetHeight|continue|Width|border|fadeTo|padding|size|uFFFF|Left|u0128|Right|Bottom|textarea|Top|enabled|innerText|only|toggleClass|removeClass|fast|400|wrap|addClass|removeAttribute|PI|insertAfter|prependTo|children|line|splice|siblings|10000|parseInt|prev|next|weight|1px|prototype'.split('|'),0,{}))
\ No newline at end of file
diff --git a/login.php b/login.php
index b877dfe..d2cfda3 100644
--- a/login.php
+++ b/login.php
@@ -1,4 +1,5 @@
 <?php
+
 session_start();
 session_regenerate_id();
 header("Cache-control: private");
@@ -100,7 +101,13 @@ $crypt_password = crypt($crypt_password, $crypt_password);
 if ($login_username != $_REQUEST['username'] || $login_password != $crypt_password) {
        $_SESSION = array();
        session_destroy();
-       echo '<p>Enter your login credentials above or click <a href=index.php>here</a> to go to the index page.</p>';
+       echo "<p>Enter your login credentials above or click <a href=index.php>here</a> to go to the index page.";
+
+       if (!file_exists("data/lite.txt") and file_exists("data/reset.txt")) {
+               echo "<br>Click <a href=reset.php>here</a> if you forgot your password.";
+       }
+
+       echo "</p>";
        exit();
 }
 
diff --git a/member.php b/member.php
index 7c0f75c..0e20e16 100644
--- a/member.php
+++ b/member.php
@@ -614,6 +614,15 @@ elseif (file_exists("data/members/active/$id/url.txt") and isset($_SESSION['logg
        echo "<tr><td width=90><p>website</p></td><td><p><a href=$member_url target=_majbb><code>$member_url</code></a></p></td></tr>";
 }
 
+if (file_exists("data/members/active/$id/bday.txt") and ($_SESSION['logged_in'] == file_get_contents("data/username.txt"))) {
+       $bday = file_get_contents("data/members/active/$id/bday.txt");
+       $bday_year = substr($bday,0,4);
+       $bday_month = substr($bday,4,2);
+       $bday_day = substr($bday,6,2);
+       $bday = date("d M Y [D]", mktime(0, 0, 0, $bday_month, $bday_day, $bday_year));
+       echo "<tr><td width=90><p>birthdate</p></td><td><p><code>$bday</code></p></td></tr>";
+}
+
 if (file_exists("data/members/active/$id/timestamp.txt")) {
        $joined = file_get_contents("data/members/active/$id/timestamp.txt");
        $joined_year = substr($joined,0,4);
diff --git a/options.php b/options.php
index d38b7a5..85c856c 100644
--- a/options.php
+++ b/options.php
@@ -29,6 +29,27 @@ if (!file_exists("data/bb.txt")) {
        exit();
 }
 
+if (file_exists("data/offset.txt")) {
+       $offset = file_get_contents("data/offset.txt");
+}
+else {
+       $offset = 0;
+}
+
+if (file_exists("data/bb-min-age.txt")) {
+       $minage = file_get_contents("data/bb-min-age.txt");
+}
+else {
+       $minage = 5;
+}
+
+if (file_exists("data/bb-max-age.txt")) {
+       $maxage = file_get_contents("data/bb-max-age.txt");
+}
+else {
+       $maxage = 125;
+}
+
 ?>
 
 <style>
@@ -130,6 +151,7 @@ if (isset($_REQUEST['email']) and !empty($_REQUEST['email']) and (file_get_conte
        fclose($fp_key_txt);
 
        $firstname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/firstname.txt");
+       $lastname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/lastname.txt");
 
        $old_email = file_get_contents("data/members/active/{$_SESSION['logged_in']}/email.txt");
 
@@ -146,9 +168,12 @@ if (isset($_REQUEST['email']) and !empty($_REQUEST['email']) and (file_get_conte
 
        $confirm_change = wordwrap($confirm_change);
 
-       mail($email_write_content, "confirm $key_email", $confirm_change,
-               "From: $from_email\r\n" .
-               "Reply-To: $from_email\r\n" .
+       $email_to = '"' . "$firstname $lastname" . '" <' . $email_write_content . '>';
+       $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+
+       mail($email_to, "confirm $key_email", $confirm_change,
+               "From: $email_from\r\n" .
+               "Reply-To: $email_from\r\n" .
                "X-Mailer: $mailer");
 
        echo "<p>Confirmation request sent. Check your $email_write_content inbox for details.</p>";
@@ -283,6 +308,15 @@ if (file_exists("data/members/active/{$_SESSION['logged_in']}/key.txt") and !fil
        touch("data/members/active/{$_SESSION['logged_in']}/vacation.txt");
 }
 
+
+if (isset($_REQUEST['bday']) and !empty($_REQUEST['bday']) and (strlen($_REQUEST['bday']) == "8") and is_numeric($_REQUEST['bday']) and ((round((date("Ymd", time() + $offset) - $_REQUEST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $offset) - $_REQUEST['bday']) * 0.0001)) <= $maxage)) {
+
+       $fp_bday_txt = fopen("data/members/active/{$_SESSION['logged_in']}/bday.txt","w");
+       fwrite($fp_bday_txt,$_REQUEST['bday']);
+       fclose($fp_bday_txt);
+
+}
+
 if (isset($_REQUEST['current_passwd']) and !empty($_REQUEST['current_passwd']) and isset($_REQUEST['new_passwd']) and !empty($_REQUEST['new_passwd']) and isset($_REQUEST['confirm_passwd']) and !empty($_REQUEST['confirm_passwd'])) {
 
        if (file_exists("data/bb-passlen.txt")) {
@@ -405,6 +439,18 @@ elseif (!file_exists("data/members/active/{$_SESSION['logged_in']}/rank.txt") an
        echo "<br>member";
 }
 
+echo "</p><p align=right>";
+
+if (file_exists("data/members/active/{$_SESSION['logged_in']}/bday.txt")) {
+
+       $bday = file_get_contents("data/members/active/{$_SESSION['logged_in']}/bday.txt");
+       $bday_year = substr($bday,0,4);
+       $bday_month = substr($bday,4,2);
+       $bday_day = substr($bday,6,2);
+       $bday = date("d M Y [D]", mktime(0, 0, 0, $bday_month, $bday_day, $bday_year));
+       echo "birthdate<code>&nbsp;$bday&nbsp;</code><br>";
+}
+
 if (file_exists("data/members/active/{$_SESSION['logged_in']}/timestamp.txt")) {
        $joined = file_get_contents("data/members/active/{$_SESSION['logged_in']}/timestamp.txt");
        $joined_year = substr($joined,0,4);
@@ -413,7 +459,7 @@ if (file_exists("data/members/active/{$_SESSION['logged_in']}/timestamp.txt")) {
        $joined_hh = substr($joined,8,2);
        $joined_mm = substr($joined,10,2);
        $member_since = date("d M Y H:i", mktime($joined_hh, $joined_mm, 0, $joined_month, $joined_day, $joined_year));
-       echo "<p align=right>member since<code>&nbsp;$member_since&nbsp;</code>";
+       echo "member since<code>&nbsp;$member_since&nbsp;</code><br>";
 }
 
 if (file_exists("data/members/active/{$_SESSION['logged_in']}/bb-last.txt")) {
@@ -424,7 +470,7 @@ if (file_exists("data/members/active/{$_SESSION['logged_in']}/bb-last.txt")) {
        $lastlog_hh = substr($lastlog,8,2);
        $lastlog_mm = substr($lastlog,10,2);
        $last_login = date("d M Y H:i", mktime($lastlog_hh, $lastlog_mm, 0, $lastlog_month, $lastlog_day, $lastlog_year));
-       echo "<br>last login<code>&nbsp;$last_login&nbsp;</code>";
+       echo "last login<code>&nbsp;$last_login&nbsp;</code>";
 }
 
 ?>
@@ -471,6 +517,11 @@ if (file_exists("images/members/{$_SESSION['logged_in']}/avatar.gif") or file_ex
 <?php } if (file_exists("data/ml.txt") and !file_exists("data/members/active/{$_SESSION['logged_in']}/key.txt")) { ?>
 <tr><td bgcolor=#ffffff><p></p></td><td bgcolor=#ffffff colspan=2><p><input type=checkbox name=vacation <?php if (file_exists("data/members/active/{$_SESSION['logged_in']}/vacation.txt")) { echo checked; } ?>>temporarily disable mailing list subscription</p></td></tr>
 <?php } ?>
+
+<?php if (!file_exists("data/members/active/{$_SESSION['logged_in']}/bday.txt")) { ?>
+<tr><td bgcolor=#ffffff><p>birthdate (YYYYMMDD)</p></td><td bgcolor=#ffffff colspan=2><input class=input type=text autocomplete=off name=bday maxlength=8 value=<?php echo date("Ymd", time() + $offset); ?>></td></tr>
+<?php } ?>
+
 <tr><td bgcolor=#ffffff><p>current password</p></td><td bgcolor=#ffffff colspan=2><input class=input type=password autocomplete=off name=current_passwd maxlength=30></td></tr>
 <tr><td bgcolor=#ffffff><p>new password</p></td><td bgcolor=#ffffff width=300><input class=input type=password autocomplete=off name=new_passwd maxlength=30></td></tr>
 <tr><td bgcolor=#ffffff><p>confirm password</p></td><td bgcolor=#ffffff><input class=input type=password autocomplete=off name=confirm_passwd maxlength=30></td></tr>
diff --git a/reg.php b/reg.php
index f6f6653..2f95fd8 100644
--- a/reg.php
+++ b/reg.php
@@ -190,14 +190,17 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
 
                        $password_notice = wordwrap($password_notice);
 
-                       mail($from_email, "registration notice ($email)", $registered_notice,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+                       $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+                       $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
+
+                       mail($email_from, "registration notice ($email)", $registered_notice,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
-                       mail($email, "password notice ($username)", $password_notice,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+                       mail($email_to, "password notice ($username)", $password_notice,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
                        $fp_new_txt = fopen("data/bb-new.txt","w");
@@ -262,9 +265,11 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
                        $confirmation_notice = "$firstname $lastname, AKA $username, successfully confirmed the e-mail address $email for registration at {$sig_url}.\n\nVisit the link below to approve this registration:\n\n{$sig_url}reg.php?username=$username&key=$key&action=approve\n\nVisit the link below to deny this registration:\n\n{$sig_url}reg.php?username=$username&key=$key&action=deny\n\nYou can also approve or deny pending registration requests at a later time by logging on to your blog.";
                        $confirmation_notice = wordwrap($confirmation_notice);
 
-                       mail($from_email, "confirmation notice ($email)", $confirmation_notice,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+                       $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+
+                       mail($email_from, "confirmation notice ($email)", $confirmation_notice,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
                }
                else {
@@ -275,9 +280,11 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
                        $registered_notice = "$firstname $lastname ($email), AKA $username, has been successfully registered at {$sig_url}.";
                        $registered_notice = wordwrap($registered_notice);
 
-                       mail($from_email, "registration notice ($email)", $registered_notice,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+                       $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+
+                       mail($email_from, "registration notice ($email)", $registered_notice,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
                        $password = str_rand(16);
@@ -308,9 +315,12 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
 
                        $password_notice = wordwrap($password_notice);
 
-                       mail($email, "password notice ($username)", $password_notice,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+                       $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+                       $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
+
+                       mail($email_to, "password notice ($username)", $password_notice,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
                        $fp_new_txt = fopen("data/bb-new.txt","w");
@@ -414,9 +424,12 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and ($_REQUES
 
                $confirm_thanks = wordwrap($confirm_thanks);
 
-               mail($email, "confirm $key", $confirm_thanks,
-                               "From: $from_email\r\n" .
-                               "Reply-To: $from_email\r\n" .
+               $email_from = '"' . $sig_author . '" <' . $from_email . '>';
+               $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
+
+               mail($email_to, "confirm $key", $confirm_thanks,
+                               "From: $email_from\r\n" .
+                               "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
                echo "<p><font style=\"font-size: 12px;\"><b>Thanks!</b></font></p><p>Your registration request was successfully submitted. Check your $email inbox for details.<br>You can register another e-mail address below or click <a href=index.php>here</a> to go to the index page.</p>";
diff --git a/reset.php b/reset.php
new file mode 100644
index 0000000..b595b26
--- /dev/null
+++ b/reset.php
@@ -0,0 +1,202 @@
+<?php
+
+session_start();
+session_regenerate_id();
+header("Cache-control: private");
+
+if (file_exists("data/lite.txt")) {
+       exit();
+}
+
+if (!file_exists("data/reset.txt")) {
+       exit();
+}
+
+error_reporting(E_ERROR);
+
+if (get_magic_quotes_gpc()) {
+       function stripslashes_array($data) {
+               if (is_array($data)){
+                        foreach ($data as $key => $value){
+                                 $data[$key] = stripslashes_array($value);
+                        }
+                        return $data;
+               }
+               else{
+                        return stripslashes($data);
+               }
+       }
+
+       $_REQUEST = stripslashes_array($_REQUEST);
+}
+
+if (file_exists("data/offset.txt")) {
+       $offset = file_get_contents("data/offset.txt");
+}
+else {
+       $offset = 0;
+}
+
+if (file_exists("data/bb-min-age.txt")) {
+       $minage = file_get_contents("data/bb-min-age.txt");
+}
+else {
+       $minage = 5;
+}
+
+if (file_exists("data/bb-max-age.txt")) {
+       $maxage = file_get_contents("data/bb-max-age.txt");
+}
+else {
+       $maxage = 125;
+}
+
+?>
+
+<style>
+body
+{
+       color: #666666;
+       margin: 10px;
+       padding: 0px;
+       text-align: left;
+       font-family: verdana, helvetica, sans-serif;
+       background-color: #FFFFFF;
+}
+
+p
+{
+       font-size: 11px;
+}
+
+a
+{
+       font-weight: bold;
+       text-decoration: none;
+}
+
+a:link, a:visited
+{
+       color: #666666;
+}
+
+a:hover
+{
+       color: #336699;
+}
+
+a:active {
+       color: #336699;
+}
+.input {      
+       color: #666666;
+       background: #ffffff;
+       border: #999999 solid 1px;
+       width: 125px;
+       font-family: verdana,helvetica,sans-serif;
+       font-size: 11px;
+}
+</style>
+
+<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<input autocomplete=off class=input type=text name=username>
+<input autocomplete=off class=input type=text name=addr>
+<input autocomplete=off class=input type=text name=bday>
+<input class=input type=submit value=reset>
+</form>
+
+<?php
+
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['addr']) and !empty($_REQUEST['addr']) and file_exists("data/members/active/{$_REQUEST['username']}") and file_exists("data/bb.txt") and (trim(strtolower($_REQUEST['addr'])) == file_get_contents("data/members/active/{$_REQUEST['username']}/email.txt")) and isset($_REQUEST['bday']) and !empty($_REQUEST['bday']) and file_exists("data/members/active/{$_REQUEST['username']}/bday.txt") and (strlen($_REQUEST['bday']) == "8") and is_numeric($_REQUEST['bday']) and ((round((date("Ymd", time() + $offset) - $_REQUEST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $offset) - $_REQUEST['bday']) * 0.0001)) <= $maxage) and ($_REQUEST['bday'] == file_get_contents("data/members/active/{$_REQUEST['username']}/bday.txt"))) {
+
+       $username = $_REQUEST['username'];
+
+       function str_rand($length = 8, $seeds = 'abcdefghijklmnopqrstuvwxyz0123456789') {
+               $str = '';
+               $seeds_count = strlen($seeds);
+              
+               list($usec, $sec) = explode(' ', microtime());
+               $seed = (float) $sec + ((float) $usec * 100000);
+               mt_srand($seed);
+              
+               for ($i = 0; $length > $i; $i++) {
+                       $str .= $seeds{mt_rand(0, $seeds_count - 1)};
+               }
+              
+               return $str;
+       }
+
+       $password = str_rand(16);
+      
+       /* Fun with crypt! */
+       $passwd = sha1($password);
+       $passwd = md5($passwd);
+       $passwd = crypt($passwd, $passwd);
+
+       $fp_passwd_txt = fopen("data/members/active/$username/password.txt","w");
+       fwrite($fp_passwd_txt,$passwd);
+       fclose($fp_passwd_txt);
+
+
+       if (file_exists("data/members/active/$username/resetx.txt")) {
+               $resetx = file_get_contents("data/members/active/$username/resetx.txt");
+       }
+       else {
+               $resetx = 0;
+       }
+
+       $resetx = $resetx + 1;
+
+       $fp_resetx_txt = fopen("data/members/active/$username/resetx.txt","w");
+       fwrite($fp_resetx_txt,$resetx);
+       fclose($fp_resetx_txt);
+
+       $resetl = date("Ymd", time() + $offset);
+       $fp_resetl_txt = fopen("data/members/active/$username/resetl.txt","w");
+       fwrite($fp_resetl_txt,$resetl);
+       fclose($fp_resetl_txt);
+
+       $firstname = file_get_contents("data/members/active/$username/firstname.txt");
+       $lastname = file_get_contents("data/members/active/$username/lastname.txt");
+       $email = file_get_contents("data/members/active/$username/email.txt");
+       $from_email = file_get_contents("data/email.txt");
+
+       $mailer = 'MAJ/0.14 (PHP/' . phpversion() . ')';
+
+       $sig_author = file_get_contents("data/author.txt");
+
+       $from_email = '"' . $sig_author . '" <' . $from_email . '>';
+       $email = '"' . "$firstname $lastname" . '" <' . $email . '>';
+
+       $sig_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/";
+       $sig_url = str_replace('//', '/', $sig_url);
+       $sig_url = "http://" . $sig_url;
+
+       $reset_notice = "Password for $username at $sig_url reset by $firstname $lastname.";
+       $reset_notice = wordwrap($reset_notice);
+
+       $password_notice = "Hi $firstname,\n\nYour password for $sig_url has been reset as requested.\n\nThe new password for \"$username\" is \"$password\" (case-sensitive). Please change this as soon as possible. For security reasons, your password on record is encrypted - you're the only one who knows what it is.\n\nPlease feel free to e-mail me if you need further assistance.\n\nThanks!\n\n--\n$sig_author\n$sig_url\n";
+
+       $password_notice = wordwrap($password_notice);
+
+       mail($from_email, "password reset notice ($username)", $reset_notice,
+               "From: $from_email\r\n" .
+               "Reply-To: $from_email\r\n" .
+               "X-Mailer: $mailer");
+
+       mail($email, "password reset notice ($username)", $password_notice,
+               "From: $from_email\r\n" .
+               "Reply-To: $from_email\r\n" .
+               "X-Mailer: $mailer");
+
+       echo "<p><font style=\"font-size: 12px;\"><b>Password Reset</b></font></p><p>Check your ";
+       readfile("data/members/active/$username/email.txt");
+       echo " account for your new password.";
+}
+else {
+       echo "<p>Enter your username, e-mail address, and birthdate (YYYYMMDD) above to reset your password.";
+}
+
+?>
+
+<br>Click <a href=login.php>here</a> to login. Click <a href=index.php>here</a> to go to the index page.</p>
diff --git a/settings.php b/settings.php
index 0105f35..a063545 100644
--- a/settings.php
+++ b/settings.php
@@ -153,6 +153,18 @@ if (!isset($_REQUEST['nopdf']) or empty($_REQUEST['nopdf'])) {
        }
 }
 
+if (isset($_REQUEST['xrand']) and !empty($_REQUEST['xrand']) and ($_REQUEST['xrand'] == "on") and !file_exists("data/xrand.txt")) {
+       touch("data/xrand.txt");
+}
+
+if (!isset($_REQUEST['xrand']) or empty($_REQUEST['xrand'])) {
+       if (isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+               if (file_exists("data/xrand.txt")) {
+                       unlink("data/xrand.txt");
+               }
+       }
+}
+
 if (isset($_REQUEST['xarc']) and !empty($_REQUEST['xarc']) and ($_REQUEST['xarc'] == "on") and !file_exists("data/xarc.txt")) {
        touch("data/xarc.txt");
 }
@@ -308,6 +320,18 @@ if (!isset($_REQUEST['xapp']) or empty($_REQUEST['xapp'])) {
        }
 }
 
+if (isset($_REQUEST['reset']) and !empty($_REQUEST['reset']) and ($_REQUEST['reset'] == "on") and !file_exists("data/reset.txt")) {
+       touch("data/reset.txt");
+}
+
+if (!isset($_REQUEST['reset']) or empty($_REQUEST['reset'])) {
+       if (isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+               if (file_exists("data/reset.txt")) {
+                       unlink("data/reset.txt");
+               }
+       }
+}
+
 if (isset($_REQUEST['member']) and !empty($_REQUEST['member']) and ($_REQUEST['member'] == "on") and !file_exists("data/member.txt")) {
        touch("data/member.txt");
 }
@@ -924,10 +948,10 @@ a:active {
 <tr><td><p>ping on content change</p></td><td><input autocomplete=off class=input type=text name=ping value="<?php readfile("data/ping.txt"); ?>"></td></tr>
 <tr><td rowspan=<?php
        if (file_exists("data/email.txt")) {
-               echo "9";
+               echo "10";
        }
        else {
-               echo "8";
+               echo "9";
        }
 ?>
 ><p>toggles</p></td><td><p><input type=checkbox name=nocomment <?php if (file_exists("data/nocomment.txt")) { echo checked; } ?>> Do not allow visitors to post comments.</p></td></tr>
@@ -935,6 +959,7 @@ a:active {
 <tr><td><p><input type=checkbox name=nak <?php if (file_exists("data/nak.txt")) { echo checked; } ?>> Do not acknowledge comment submissions via e-mail.</p></td></tr>
 <?php } ?>
 <tr><td><p><input type=checkbox name=nopdf <?php if (file_exists("data/nopdf.txt")) { echo checked; } ?>> Do not allow PDF generation for all entries.</p></td></tr>
+<tr><td><p><input type=checkbox name=xrand <?php if (file_exists("data/xrand.txt")) { echo checked; } ?>> Do not show random entries panel.</p></td></tr>
 <tr><td><p><input type=checkbox name=xarc <?php if (file_exists("data/xarc.txt")) { echo checked; } ?>> Do not show archives panel.</p></td></tr>
 <tr><td><p><input type=checkbox name=xcat <?php if (file_exists("data/xcat.txt")) { echo checked; } ?>> Do not show categories panel.</p></td></tr>
 <tr><td><p><input type=checkbox name=nocat <?php if (file_exists("data/nocat.txt")) { echo checked; } ?>> Do not show categorized items with unfiled entries.</p></td></tr>
@@ -1078,10 +1103,11 @@ if (file_exists("data/pf-censor.txt")) {
 
 <?php } ?>
 
-<tr><td <?php if (file_exists("data/bb.txt") and !file_exists("images/avatar.jpg") and !file_exists("images/avatar.gif") and !file_exists("images/avatar.png")) { echo "rowspan=9"; } if (file_exists("data/bb.txt") and (file_exists("images/avatar.jpg") or file_exists("images/avatar.gif") or file_exists("images/avatar.png"))) { echo "rowspan=10"; } ?>><p>bulletin board</p></td><td><p><input type=checkbox name=bb <?php if (file_exists("data/bb.txt")) { echo checked; } ?>> Enable simple bulletin board.</p></td></tr>
+<tr><td <?php if (file_exists("data/bb.txt") and !file_exists("images/avatar.jpg") and !file_exists("images/avatar.gif") and !file_exists("images/avatar.png")) { echo "rowspan=10"; } if (file_exists("data/bb.txt") and (file_exists("images/avatar.jpg") or file_exists("images/avatar.gif") or file_exists("images/avatar.png"))) { echo "rowspan=11"; } ?>><p>bulletin board</p></td><td><p><input type=checkbox name=bb <?php if (file_exists("data/bb.txt")) { echo checked; } ?>> Enable simple bulletin board.</p></td></tr>
 <?php if (file_exists("data/bb.txt")) { ?>
 <tr><td><p><input type=checkbox name=reg <?php if (file_exists("data/reg.txt")) { echo checked; } ?>> Enable new user registration.</p></td></tr>
 <tr><td><p><input type=checkbox name=xapp <?php if (file_exists("data/xapp.txt")) { echo checked; } ?>> Enable automatic activation of confirmed users.</p></td></tr>
+<tr><td><p><input type=checkbox name=reset <?php if (file_exists("data/reset.txt")) { echo checked; } ?>> Enable password reset requests.</p></td></tr>
 <tr><td><p><input type=checkbox name=member <?php if (file_exists("data/member.txt")) { echo checked; } ?>> Only members can view posts of other members.</p></td></tr>
 <tr><td><p><input type=checkbox name=stats <?php if (file_exists("data/bb-stats.txt")) { echo checked; } ?>> Enable statistics panel.</p></td></tr>
 <tr><td><p><input type=checkbox name=summary <?php if (file_exists("data/bb-summary.txt")) { echo checked; } ?>> Enable summary panel.</p></td></tr>
diff --git a/unzip.lib.php b/unzip.lib.php
new file mode 100644
index 0000000..cc87850
--- /dev/null
+++ b/unzip.lib.php
@@ -0,0 +1,492 @@
+<?PHP
+    /* $Id: unzip.lib.php,v 1.2 2006/01/17 17:02:31 cybot_tm Exp $ */
+
+    /**
+     *  ZIP file unpack classes. Contributed to the phpMyAdmin project.
+     *
+     *  @category   phpPublic
+     *  @package    File-Formats-ZIP
+     *  @subpackage Unzip
+     *  @filesource unzip.lib.php
+     *  @version    1.0.1
+     *
+     *  @author     Holger Boskugel <vbwebprofi@gmx.de>
+     *  @copyright  Copyright © 2003, Holger Boskugel, Berlin, Germany
+     *  @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+     *
+     *  @history
+     *  2003-12-02 - HB : Patched : naming bug : Time/Size of file
+     *                    Add   : ZIP file comment
+     *                    Add   : Check BZIP2 support of PHP
+     *  2003-11-29 - HB * Initial version
+     */
+
+    /**
+     *  Unzip class, which retrieves entries from ZIP files.
+     *
+     *  Supports only the compression modes
+     *  -  0 : Stored,
+     *  -  8 : Deflated and
+     *  - 12 : BZIP2
+     *
+     *  Based on :<BR>
+     *  <BR>
+     *  {@link http://www.pkware.com/products/enterprise/white_papers/appnote.html
+     *  * Official ZIP file format}<BR>
+     *  {@link http://msdn.microsoft.com/library/en-us/w98ddk/hh/w98ddk/storage_5l4m.asp
+     *  * Microsoft DOS date/time format}
+     *
+     *  @category   phpPublic
+     *  @package    File-Formats-ZIP
+     *  @subpackage Unzip
+     *  @version    1.0.1
+     *  @author     Holger Boskugel <vbwebprofi@gmx.de>
+     *  @uses       SimpleUnzipEntry
+     *  @example    example.unzip.php Two examples
+     */
+    class SimpleUnzip {
+// 2003-12-02 - HB >
+        /**
+         *  Array to store file entries
+         *
+         *  @var    string
+         *  @access public
+         *  @see    ReadFile()
+         *  @since  1.0.1
+         */
+        var $Comment = '';
+// 2003-12-02 - HB <
+
+        /**
+         *  Array to store file entries
+         *
+         *  @var    array
+         *  @access public
+         *  @see    ReadFile()
+         *  @since  1.0
+         */
+        var $Entries = array();
+
+        /**
+         *  Name of the ZIP file
+         *
+         *  @var    string
+         *  @access public
+         *  @see    ReadFile()
+         *  @since  1.0
+         */
+        var $Name = '';
+
+        /**
+         *  Size of the ZIP file
+         *
+         *  @var    integer
+         *  @access public
+         *  @see    ReadFile()
+         *  @since  1.0
+         */
+        var $Size = 0;
+
+        /**
+         *  Time of the ZIP file (unix timestamp)
+         *
+         *  @var    integer
+         *  @access public
+         *  @see    ReadFile()
+         *  @since  1.0
+         */
+        var $Time = 0;
+
+        /**
+         *  Contructor of the class
+         *
+         *  @param  string      File name
+         *  @return SimpleUnzip Instanced class
+         *  @access public
+         *  @uses   SimpleUnzip::ReadFile() Opens file on new if specified
+         *  @since  1.0
+         */
+        function SimpleUnzip($in_FileName = '')
+        {
+            if ($in_FileName !== '') {
+                SimpleUnzip::ReadFile($in_FileName);
+            }
+        } // end of the 'SimpleUnzip' constructor
+
+        /**
+         *  Counts the entries
+         *
+         *  @return integer Count of ZIP entries
+         *  @access public
+         *  @uses   $Entries
+         *  @since  1.0
+         */
+        function Count()
+        {
+            return count($this->Entries);
+        } // end of the 'Count()' method
+
+        /**
+         *  Gets data of the specified ZIP entry
+         *
+         *  @param  integer Index of the ZIP entry
+         *  @return mixed   Data for the ZIP entry
+         *  @uses   SimpleUnzipEntry::$Data
+         *  @access public
+         *  @since  1.0
+         */
+        function GetData($in_Index)
+        {
+            return $this->Entries[$in_Index]->Data;
+        } // end of the 'GetData()' method
+
+        /**
+         *  Gets an entry of the ZIP file
+         *
+         *  @param  integer             Index of the ZIP entry
+         *  @return SimpleUnzipEntry    Entry of the ZIP file
+         *  @uses   $Entries
+         *  @access public
+         *  @since  1.0
+         */
+        function GetEntry($in_Index)
+        {
+            return $this->Entries[$in_Index];
+        } // end of the 'GetEntry()' method
+
+        /**
+         *  Gets error code for the specified ZIP entry
+         *
+         *  @param  integer     Index of the ZIP entry
+         *  @return integer     Error code for the ZIP entry
+         *  @uses   SimpleUnzipEntry::$Error
+         *  @access public
+         *  @since   1.0
+         */
+        function GetError($in_Index)
+        {
+            return $this->Entries[$in_Index]->Error;
+        } // end of the 'GetError()' method
+
+        /**
+         *  Gets error message for the specified ZIP entry
+         *
+         *  @param  integer     Index of the ZIP entry
+         *  @return string      Error message for the ZIP entry
+         *  @uses   SimpleUnzipEntry::$ErrorMsg
+         *  @access public
+         *  @since  1.0
+         */
+        function GetErrorMsg($in_Index)
+        {
+            return $this->Entries[$in_Index]->ErrorMsg;
+        } // end of the 'GetErrorMsg()' method
+
+        /**
+         *  Gets file name for the specified ZIP entry
+         *
+         *  @param  integer     Index of the ZIP entry
+         *  @return string      File name for the ZIP entry
+         *  @uses   SimpleUnzipEntry::$Name
+         *  @access public
+         *  @since  1.0
+         */
+        function GetName($in_Index)
+        {
+            return $this->Entries[$in_Index]->Name;
+        } // end of the 'GetName()' method
+
+        /**
+         *  Gets path of the file for the specified ZIP entry
+         *
+         *  @param  integer     Index of the ZIP entry
+         *  @return string      Path of the file for the ZIP entry
+         *  @uses   SimpleUnzipEntry::$Path
+         *  @access public
+         *  @since  1.0
+         */
+        function GetPath($in_Index)
+        {
+            return $this->Entries[$in_Index]->Path;
+        } // end of the 'GetPath()' method
+
+        /**
+         *  Gets file time for the specified ZIP entry
+         *
+         *  @param  integer     Index of the ZIP entry
+         *  @return integer     File time for the ZIP entry (unix timestamp)
+         *  @uses   SimpleUnzipEntry::$Time
+         *  @access public
+         *  @since  1.0
+         */
+        function GetTime($in_Index)
+        {
+            return $this->Entries[$in_Index]->Time;
+        } // end of the 'GetTime()' method
+
+        /**
+         *  Reads ZIP file and extracts the entries
+         *
+         *  @param  string              File name of the ZIP archive
+         *  @return array               ZIP entry list (see also class variable {@link $Entries $Entries})
+         *  @uses   SimpleUnzipEntry    For the entries
+         *  @access public
+         *  @since  1.0
+         */
+        function ReadFile($in_FileName)
+        {
+            $this->Entries = array();
+
+            // Get file parameters
+            $this->Name = $in_FileName;
+            $this->Time = filemtime($in_FileName);
+            $this->Size = filesize($in_FileName);
+
+            // Read file
+            $oF = fopen($in_FileName, 'rb');
+            $vZ = fread($oF, $this->Size);
+            fclose($oF);
+
+// 2003-12-02 - HB >
+            // Cut end of central directory
+            $aE = explode("\x50\x4b\x05\x06", $vZ);
+
+            // Easiest way, but not sure if format changes
+            //$this->Comment = substr($aE[1], 18);
+
+            // Normal way
+            $aP = unpack('x16/v1CL', $aE[1]);
+            $this->Comment = substr($aE[1], 18, $aP['CL']);
+
+            // Translates end of line from other operating systems
+            $this->Comment = strtr($this->Comment, array("\r\n" => "\n",
+                                                         "\r"   => "\n"));
+// 2003-12-02 - HB <
+
+            // Cut the entries from the central directory
+            $aE = explode("\x50\x4b\x01\x02", $vZ);
+            // Explode to each part
+            $aE = explode("\x50\x4b\x03\x04", $aE[0]);
+            // Shift out spanning signature or empty entry
+            array_shift($aE);
+
+            // Loop through the entries
+            foreach ($aE as $vZ) {
+                $aI = array();
+                $aI['E']  = 0;
+                $aI['EM'] = '';
+                // Retrieving local file header information
+                $aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
+                // Check if data is encrypted
+                $bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
+                $nF = $aP['FNL'];
+
+                // Special case : value block after the compressed data
+                if ($aP['GPF'] & 0x0008) {
+                    $aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
+
+                    $aP['CRC'] = $aP1['CRC'];
+                    $aP['CS']  = $aP1['CS'];
+                    $aP['UCS'] = $aP1['UCS'];
+
+                    $vZ = substr($vZ, 0, -12);
+                }
+
+                // Getting stored filename
+                $aI['N'] = substr($vZ, 26, $nF);
+
+                if (substr($aI['N'], -1) == '/') {
+                    // is a directory entry - will be skipped
+                    continue;
+                }
+
+                // Truncate full filename in path and filename
+                $aI['P'] = dirname($aI['N']);
+                $aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
+                $aI['N'] = basename($aI['N']);
+
+                $vZ = substr($vZ, 26 + $nF);
+
+                if (strlen($vZ) != $aP['CS']) {
+                  $aI['E']  = 1;
+                  $aI['EM'] = 'Compressed size is not equal with the value in header information.';
+                } else {
+                    if ($bE) {
+                        $aI['E']  = 5;
+                        $aI['EM'] = 'File is encrypted, which is not supported from this class.';
+                    } else {
+                        switch($aP['CM']) {
+                            case 0: // Stored
+                                // Here is nothing to do, the file ist flat.
+                                break;
+
+                            case 8: // Deflated
+                                $vZ = gzinflate($vZ);
+                                break;
+
+                            case 12: // BZIP2
+// 2003-12-02 - HB >
+                                if (! extension_loaded('bz2')) {
+                                    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+                                      @dl('php_bz2.dll');
+                                    } else {
+                                      @dl('bz2.so');
+                                    }
+                                }
+
+                                if (extension_loaded('bz2')) {
+// 2003-12-02 - HB <
+                                    $vZ = bzdecompress($vZ);
+// 2003-12-02 - HB >
+                                } else {
+                                    $aI['E']  = 7;
+                                    $aI['EM'] = "PHP BZIP2 extension not available.";
+                                }
+// 2003-12-02 - HB <
+
+                                break;
+
+                            default:
+                              $aI['E']  = 6;
+                              $aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
+                        }
+
+// 2003-12-02 - HB >
+                        if (! $aI['E']) {
+// 2003-12-02 - HB <
+                            if ($vZ === FALSE) {
+                                $aI['E']  = 2;
+                                $aI['EM'] = 'Decompression of data failed.';
+                            } else {
+                                if (strlen($vZ) != $aP['UCS']) {
+                                    $aI['E']  = 3;
+                                    $aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
+                                } else {
+                                    if (crc32($vZ) != $aP['CRC']) {
+                                        $aI['E']  = 4;
+                                        $aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
+                                    }
+                                }
+                            }
+// 2003-12-02 - HB >
+                        }
+// 2003-12-02 - HB <
+                    }
+                }
+
+                $aI['D'] = $vZ;
+
+                // DOS to UNIX timestamp
+                $aI['T'] = mktime(($aP['FT']  & 0xf800) >> 11,
+                                  ($aP['FT']  & 0x07e0) >>  5,
+                                  ($aP['FT']  & 0x001f) <<  1,
+                                  ($aP['FD']  & 0x01e0) >>  5,
+                                  ($aP['FD']  & 0x001f),
+                                  (($aP['FD'] & 0xfe00) >>  9) + 1980);
+
+                $this->Entries[] = &new SimpleUnzipEntry($aI);
+            } // end for each entries
+
+            return $this->Entries;
+        } // end of the 'ReadFile()' method
+    } // end of the 'SimpleUnzip' class
+
+    /**
+     *  Entry of the ZIP file.
+     *
+     *  @category   phpPublic
+     *  @package    File-Formats-ZIP
+     *  @subpackage Unzip
+     *  @version    1.0
+     *  @author     Holger Boskugel <vbwebprofi@gmx.de>
+     *  @example    example.unzip.php Two examples
+     */
+    class SimpleUnzipEntry {
+        /**
+         *  Data of the file entry
+         *
+         *  @var    mixed
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $Data = '';
+
+        /**
+         *  Error of the file entry
+         *
+         *  - 0 : No error raised.<BR>
+         *  - 1 : Compressed size is not equal with the value in header information.<BR>
+         *  - 2 : Decompression of data failed.<BR>
+         *  - 3 : Uncompressed size is not equal with the value in header information.<BR>
+         *  - 4 : CRC32 checksum is not equal with the value in header information.<BR>
+         *  - 5 : File is encrypted, which is not supported from this class.<BR>
+         *  - 6 : De-/Compression method ... is not supported.<BR>
+         *  - 7 : PHP BZIP2 extension not available.
+         *
+         *  @var    integer
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $Error = 0;
+
+        /**
+         *  Error message of the file entry
+         *
+         *  @var    string
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $ErrorMsg = '';
+
+        /**
+         *  File name of the file entry
+         *
+         *  @var    string
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $Name = '';
+
+        /**
+         *  File path of the file entry
+         *
+         *  @var    string
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $Path = '';
+
+        /**
+         *  File time of the file entry (unix timestamp)
+         *
+         *  @var    integer
+         *  @access public
+         *  @see    SimpleUnzipEntry()
+         *  @since  1.0
+         */
+        var $Time = 0;
+
+        /**
+         *  Contructor of the class
+         *
+         *  @param  array               Entry datas
+         *  @return SimpleUnzipEntry    Instanced class
+         *  @access public
+         *  @since  1.0
+         */
+        function SimpleUnzipEntry($in_Entry)
+        {
+            $this->Data     = $in_Entry['D'];
+            $this->Error    = $in_Entry['E'];
+            $this->ErrorMsg = $in_Entry['EM'];
+            $this->Name     = $in_Entry['N'];
+            $this->Path     = $in_Entry['P'];
+            $this->Time     = $in_Entry['T'];
+        } // end of the 'SimpleUnzipEntry' constructor
+    } // end of the 'SimpleUnzipEntry' class
+?>
diff --git a/url.txt b/url.txt
new file mode 100644
index 0000000..df92025
--- /dev/null
+++ b/url.txt
@@ -0,0 +1 @@
+http://maj.sourceforge.net/
diff --git a/zipstream.php b/zipstream.php
new file mode 100644
index 0000000..1fe72dd
--- /dev/null
+++ b/zipstream.php
@@ -0,0 +1,570 @@
+<?php
+
+##########################################################################
+# ZipStream - Streamed, dynamically generated zip archives.              #
+# by Paul Duncan <pabs@pablotron.org>                                    #
+#                                                                        #
+# Copyright (C) 2007 Paul Duncan <pabs@pablotron.org>                    #
+#                                                                        #
+# Permission is hereby granted, free of charge, to any person obtaining  #
+# a copy of this software and associated documentation files (the        #
+# "Software"), to deal in the Software without restriction, including    #
+# without limitation the rights to use, copy, modify, merge, publish,    #
+# distribute, sublicense, and/or sell copies of the Software, and to     #
+# permit persons to whom the Software is furnished to do so, subject to  #
+# the following conditions:                                              #
+#                                                                        #
+# The above copyright notice and this permission notice shall be         #
+# included in all copies of the Software, its documentation and          #
+# marketing & publicity materials, and acknowledgment shall be given in  #
+# the documentation, materials and software packages that this Software  #
+# was used.                                                              #
+#                                                                        #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        #
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     #
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. #
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR      #
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,  #
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR  #
+# OTHER DEALINGS IN THE SOFTWARE.                                        #
+##########################################################################
+
+#
+# ZipStream - Streamed, dynamically generated zip archives.
+# by Paul Duncan <pabs@pablotron.org>
+#
+# Usage:
+#
+# Streaming zip archives is a simple, three-step process:
+#
+# 1.  Create the zip stream:
+#
+#     $zip = new ZipStream('example.zip');
+#
+# 2.  Add one or more files to the archive:
+#
+#     # add first file
+#     $data = file_get_contents('some_file.gif');
+#     $zip->add_file('some_file.gif', $data);
+#
+#     # add second file
+#     $data = file_get_contents('some_file.gif');
+#     $zip->add_file('another_file.png', $data);
+#
+# 3.  Finish the zip stream:
+#
+#     $zip->finish();
+#
+# You can also add an archive comment, add comments to individual files,
+# and adjust the timestamp of files.  See the API documentation for each
+# method below for additional information.
+#
+# Example:
+#
+#   # create a new zip stream object
+#   $zip = new ZipStream('some_files.zip');
+#
+#   # list of local files
+#   $files = array('foo.txt', 'bar.jpg');
+#
+#   # read and add each file to the archive
+#   foreach ($files as $path)
+#     $zip->add_file($path, file_get_contents($path));
+#
+#   # write archive footer to stream
+#   $zip->finish();
+#
+class ZipStream {
+  var $opt = array(),
+      $files = array(),
+      $cdr_ofs = 0,
+      $ofs = 0;
+
+  #
+  # Create a new ZipStream object.
+  #
+  # Parameters:
+  #
+  #   $name - Name of output file (optional).
+  #   $opt  - Hash of archive options (optional, see "Archive Options"
+  #           below).
+  #
+  # Archive Options:
+  #
+  #   comment             - Comment for this archive.
+  #   content_type        - HTTP Content-Type.  Defaults to 'application/x-zip'.
+  #   content_disposition - HTTP Content-Disposition.  Defaults to
+  #                         'attachment; filename=\"FILENAME\"', where
+  #                         FILENAME is the specified filename.
+  #   large_file_size     - Size, in bytes, of the largest file to try
+  #                         and load into memory (used by
+  #                         add_file_from_path()).  Large files may also
+  #                         be compressed differently; see the
+  #                         'large_file_method' option.
+  #   large_file_method   - How to handle large files.  Legal values are
+  #                         'store' (the default), or 'deflate'.  Store
+  #                         sends the file raw and is significantly
+  #                         faster, while 'deflate' compresses the file
+  #                         and is much, much slower.  Note that deflate
+  #                         must compress the file twice and extremely
+  #                         slow.
+  #   send_http_headers   - Boolean indicating whether or not to send
+  #                         the HTTP headers for this file.
+  #
+  # Note that content_type and content_disposition do nothing if you are
+  # not sending HTTP headers.
+  #
+  # Large File Support:
+  #
+  # By default, the method add_file_from_path() will send send files
+  # larger than 20 megabytes along raw rather than attempting to
+  # compress them.  You can change both the maximum size and the
+  # compression behavior using the large_file_* options above, with the
+  # following caveats:
+  #
+  # * For "small" files (e.g. files smaller than large_file_size), the
+  #   memory use can be up to twice that of the actual file.  In other
+  #   words, adding a 10 megabyte file to the archive could potentially
+  #   occupty 20 megabytes of memory.
+  #
+  # * Enabling compression on large files (e.g. files larger than
+  #   large_file_size) is extremely slow, because ZipStream has to pass
+  #   over the large file once to calculate header information, and then
+  #   again to compress and send the actual data.
+  #
+  # Examples:
+  #
+  #   # create a new zip file named 'foo.zip'
+  #   $zip = new ZipStream('foo.zip');
+  #
+  #   # create a new zip file named 'bar.zip' with a comment
+  #   $zip = new ZipStream('bar.zip', array(
+  #     'comment' => 'this is a comment for the zip file.',
+  #   ));
+  #
+  # Notes:
+  #
+  # If you do not set a filename, then this library _DOES NOT_ send HTTP
+  # headers by default.  This behavior is to allow software to send its
+  # own headers (including the filename), and still use this library.
+  #
+  function ZipStream($name = null, $opt = array()) {
+    # save options
+    $this->opt = $opt;
+
+    # set large file defaults: size = 20 megabytes, method = store
+    if (!$this->opt['large_file_size'])
+      $this->opt['large_file_size'] = 20 * 1024 * 1024;
+    if (!$this->opt['large_file_method'])
+      $this->opt['large_file_method'] = 'store';
+
+    $this->output_name = $name;
+    if ($name || $opt['send_http_headers'])
+      $this->need_headers = true;
+  }
+
+  #
+  # add_file - add a file to the archive
+  #
+  # Parameters:
+  #  
+  #  $name - path of file in archive (including directory).
+  #  $data - contents of file
+  #  $opt  - Hash of options for file (optional, see "File Options"
+  #          below).  
+  #
+  # File Options:
+  #  time     - Last-modified timestamp (seconds since the epoch) of
+  #             this file.  Defaults to the current time.
+  #  comment  - Comment related to this file.
+  #
+  # Examples:
+  #
+  #   # add a file named 'foo.txt'
+  #   $data = file_get_contents('foo.txt');
+  #   $zip->add_file('foo.txt', $data);
+  #
+  #   # add a file named 'bar.jpg' with a comment and a last-modified
+  #   # time of two hours ago
+  #   $data = file_get_contents('bar.jpg');
+  #   $zip->add_file('bar.jpg', $data, array(
+  #     'time'    => time() - 2 * 3600,
+  #     'comment' => 'this is a comment about bar.jpg',
+  #   ));
+  #
+  function add_file($name, $data, $opt = array()) {
+    # compress data
+    $zdata = gzdeflate($data);
+
+    # calculate header attributes
+    $crc  = crc32($data);
+    $zlen = strlen($zdata);
+    $len  = strlen($data);
+    $meth = 0x08;
+
+    # send file header
+    $this->add_file_header($name, $opt, $meth, $crc, $zlen, $len);
+
+    # print data
+    $this->send($zdata);
+  }
+
+  #
+  # add_file_from_path - add a file at path to the archive.
+  #
+  # Note that large files may be compresed differently than smaller
+  # files; see the "Large File Support" section above for more
+  # information.
+  #
+  # Parameters:
+  #  
+  #  $name - name of file in archive (including directory path).
+  #  $path - path to file on disk.
+  #  $opt  - Hash of options for file (optional, see "File Options"
+  #          below).  
+  #
+  # File Options:
+  #  time     - Last-modified timestamp (seconds since the epoch) of
+  #             this file.  Defaults to the current time.
+  #  comment  - Comment related to this file.
+  #
+  # Examples:
+  #
+  #   # add a file named 'foo.txt' from the local file '/tmp/foo.txt'
+  #   $zip->add_file_from_path('foo.txt', '/tmp/foo.txt');
+  #
+  #   # add a file named 'bigfile.rar' from the local file
+  #   # '/usr/share/bigfile.rar' with a comment and a last-modified
+  #   # time of two hours ago
+  #   $path = '/usr/share/bigfile.rar';
+  #   $zip->add_file_from_path('bigfile.rar', $path, array(
+  #     'time'    => time() - 2 * 3600,
+  #     'comment' => 'this is a comment about bar.jpg',
+  #   ));
+  #
+  function add_file_from_path($name, $path, $opt = array()) {
+    if ($this->is_large_file($path)) {
+      # file is too large to be read into memory; add progressively
+      $this->add_large_file($name, $path, $opt);
+    } else {
+      # file is small enough to read into memory; read file contents and
+      # handle with add_file()
+      $data = file_get_contents($path);
+      $this->add_file($name, $data, $opt);
+    }
+  }
+
+  #
+  # finish - Write zip footer to stream.
+  #
+  # Example:
+  #
+  #   # add a list of files to the archive
+  #   $files = array('foo.txt', 'bar.jpg');
+  #   foreach ($files as $path)
+  #     $zip->add_file($path, file_get_contents($path));
+  #
+  #   # write footer to stream
+  #   $zip->finish();
+  #
+  function finish() {
+    # add trailing cdr record
+    $this->add_cdr($this->opt);
+    $this->clear();
+  }
+
+  ###################
+  # PRIVATE METHODS #
+  ###################
+
+  #
+  # Create and send zip header for this file.
+  #
+  function add_file_header($name, $opt, $meth, $crc, $zlen, $len) {
+    # calculate name length
+    $nlen = strlen($name);
+
+    # create dos timestamp
+    $opt['time'] = $opt['time'] ? $opt['time'] : time();
+    $dts = $this->dostime($opt['time']);
+
+    # build file header
+    $fields = array(            # (from V.A of APPNOTE.TXT)
+      array('V', 0x04034b50),     # local file header signature
+      array('v', 0x14),           # version needed to extract
+      array('v', 0x00),           # general purpose bit flag
+      array('v', $meth),          # compresion method (deflate or store)
+      array('V', $dts),           # dos timestamp
+      array('V', $crc),           # crc32 of data
+      array('V', $zlen),          # compressed data length
+      array('V', $len),           # uncompressed data length
+      array('v', $nlen),          # filename length
+      array('v', 0),              # extra data len
+    );
+
+    # pack fields and calculate "total" length
+    $ret = $this->pack_fields($fields);
+    $cdr_len = strlen($ret) + $nlen + $zlen;
+
+    # print header and filename
+    $this->send($ret . $name);
+
+    # add to central directory record and increment offset
+    $this->add_to_cdr($name, $opt, $meth, $crc, $zlen, $len, $cdr_len);
+  }
+
+  #
+  # Add a large file from the given path.
+  #
+  function add_large_file($name, $path, $opt = array()) {
+    $st = stat($path);
+    $block_size = 1048576; # process in 1 megabyte chunks
+    $algo = 'crc32b';
+
+    # calculate header attributes
+    $zlen = $len = $st['size'];
+
+    $meth_str = $this->opt['large_file_method'];
+    if ($meth_str == 'store') {
+      # store method
+      $meth = 0x00;
+      $crc  = unpack('V', hash_file($algo, $path, true));
+      $crc = $crc[1];
+    } elseif ($meth_str == 'deflate') {
+      # deflate method
+      $meth = 0x08;
+
+      # open file, calculate crc and compressed file length
+      $fh = fopen($path, 'rb');
+      $hash_ctx = hash_init($algo);
+      $zlen = 0;
+
+      # read each block, update crc and zlen
+      while ($data = fgets($fh, $block_size)) {
+        hash_update($hash_ctx, $data);
+        $data = gzdeflate($data);
+        $zlen += strlen($data);
+      }
+
+      # close file and finalize crc
+      fclose($fh);
+      $crc = unpack('V', hash_final($hash_ctx, true));
+      $crc = $crc[1];
+    } else {
+      die("unknown large_file_method: $meth_str");
+    }
+
+    # send file header
+    $this->add_file_header($name, $opt, $meth, $crc, $zlen, $len);
+
+    # open input file
+    $fh = fopen($path, 'rb');
+
+    # send file blocks
+    while ($data = fgets($fh, $block_size)) {
+      if ($meth_str == 'deflate')
+        $data = gzdeflate($data);
+
+      # send data
+      $this->send($data);
+    }
+
+    # close input file
+    fclose($fh);
+  }
+
+  #
+  # Is this file larger than large_file_size?
+  #
+  function is_large_file($path) {
+    $st = stat($path);
+    return ($this->opt['large_file_size'] > 0) &&
+           ($st['size'] > $this->opt['large_file_size']);
+  }
+
+  #
+  # Save file attributes for trailing CDR record.
+  #
+  function add_to_cdr($name, $opt, $meth, $crc, $zlen, $len, $rec_len) {
+    $this->files[] = array($name, $opt, $meth, $crc, $zlen, $len, $this->ofs);
+    $this->ofs += $rec_len;
+  }
+
+  #
+  # Send CDR record for specified file.
+  #
+  function add_cdr_file($args) {
+    list ($name, $opt, $meth, $crc, $zlen, $len, $ofs) = $args;
+
+    # get attributes
+    $comment = $opt['comment'] ? $opt['comment'] : '';
+
+    # get dos timestamp
+    $dts = $this->dostime($opt['time']);
+
+    $fields = array(                  # (from V,F of APPNOTE.TXT)
+      array('V', 0x02014b50),           # central file header signature
+      array('v', 0x00),                 # version made by
+      array('v', 0x14),                 # version needed to extract
+      array('v', 0x00),                 # general purpose bit flag
+      array('v', $meth),                # compresion method (deflate or store)
+      array('V', $dts),                 # dos timestamp
+      array('V', $crc),                 # crc32 of data
+      array('V', $zlen),                # compressed data length
+      array('V', $len),                 # uncompressed data length
+      array('v', strlen($name)),        # filename length
+      array('v', 0),                    # extra data len
+      array('v', strlen($comment)),     # file comment length
+      array('v', 0),                    # disk number start
+      array('v', 0),                    # internal file attributes
+      array('V', 32),                   # external file attributes
+      array('V', $ofs),                 # relative offset of local header
+    );
+
+    # pack fields, then append name and comment
+    $ret = $this->pack_fields($fields) . $name . $comment;
+
+    $this->send($ret);
+
+    # increment cdr offset
+    $this->cdr_ofs += strlen($ret);
+  }
+
+  #
+  # Send CDR EOF (Central Directory Record End-of-File) record.
+  #
+  function add_cdr_eof($opt = null) {
+    $num = count($this->files);
+    $cdr_len = $this->cdr_ofs;
+    $cdr_ofs = $this->ofs;
+
+    # grab comment (if specified)
+    $comment = '';
+    if ($opt && $opt['comment'])
+      $comment = $opt['comment'];
+
+    $fields = array(                # (from V,F of APPNOTE.TXT)
+      array('V', 0x06054b50),         # end of central file header signature
+      array('v', 0x00),               # this disk number
+      array('v', 0x00),               # number of disk with cdr
+      array('v', $num),               # number of entries in the cdr on this disk
+      array('v', $num),               # number of entries in the cdr
+      array('V', $cdr_len),           # cdr size
+      array('V', $cdr_ofs),           # cdr ofs
+      array('v', strlen($comment)),   # zip file comment length
+    );
+
+    $ret = $this->pack_fields($fields) . $comment;
+    $this->send($ret);
+  }
+
+  #
+  # Add CDR (Central Directory Record) footer.
+  #
+  function add_cdr($opt = null) {
+    foreach ($this->files as $file)
+      $this->add_cdr_file($file);
+    $this->add_cdr_eof($opt);
+  }
+
+  #
+  # Clear all internal variables.  Note that the stream object is not
+  # usable after this.
+  #
+  function clear() {
+    $this->files = array();
+    $this->ofs = 0;
+    $this->cdr_ofs = 0;
+    $this->opt = array();
+  }
+
+  ###########################
+  # PRIVATE UTILITY METHODS #
+  ###########################
+
+  #
+  # Send HTTP headers for this stream.
+  #
+  function send_http_headers() {
+    # grab options
+    $opt = $this->opt;
+    
+    # grab content type from options
+    $content_type = 'application/x-zip';
+    if ($opt['content_type'])
+      $content_type = $this->opt['content_type'];
+
+    # grab content disposition
+    $disposition = 'attachment';
+    if ($opt['content_disposition'])
+      $disposition = $opt['content_disposition'];
+
+    if ($this->output_name)
+      $disposition .= "; filename=\"{$this->output_name}\"";
+
+    $headers = array(
+      'Content-Type'              => $content_type,
+      'Content-Disposition'       => $disposition,
+      'Pragma'                    => 'public',
+      'Cache-Control'             => 'public, must-revalidate',
+      'Content-Transfer-Encoding' => 'binary',
+    );
+
+    foreach ($headers as $key => $val)
+      header("$key: $val");
+  }
+
+  #
+  # Send string, sending HTTP headers if necessary.
+  #
+  function send($str) {
+    if ($this->need_headers)
+      $this->send_http_headers();
+    $this->need_headers = false;
+
+    echo $str;
+  }
+
+  #
+  # Convert a UNIX timestamp to a DOS timestamp.
+  #
+  function dostime($when = 0) {
+    # get date array for timestamp
+    $d = getdate($when);
+
+    # set lower-bound on dates
+    if ($d['year'] < 1980) {
+      $d = array('year' => 1980, 'mon' => 1, 'mday' => 1,
+                 'hours' => 0, 'minutes' => 0, 'seconds' => 0);
+    }
+
+    # remove extra years from 1980
+    $d['year'] -= 1980;
+
+    # return date string
+    return ($d['year'] << 25) | ($d['mon'] << 21) | ($d['mday'] << 16) |
+           ($d['hours'] << 11) | ($d['minutes'] << 5) | ($d['seconds'] >> 1);
+  }
+
+  #
+  # Create a format string and argument list for pack(), then call
+  # pack() and return the result.
+  #
+  function pack_fields($fields) {
+    list ($fmt, $args) = array('', array());
+
+    # populate format string and argument list
+    foreach ($fields as $field) {
+      $fmt .= $field[0];
+      $args[] = $field[1];
+    }
+
+    # prepend format string to argument list
+    array_unshift($args, $fmt);
+
+    # build output string from header and compressed data
+    return call_user_func_array('pack', $args);
+  }
+};
+
+?>
 
Credits
Sunday, Sep 18, 2005, 12:00 AM (Revision 11 - Thursday, Jul 14, 2011, 7:30 PM)
Open Source enables software developers to stand on the shoulders of giants instead of reinventing the wheel, so to speak. Kudos and many thanks to the folks who made their work freely available for reuse in MAJ.

read more
Bugs and Exploits
Friday, Aug 26, 2005, 12:00 AM (Revision 23 - Wednesday, May 29, 2013, 5:25 AM)
Although MAJ started as a family project, care has been taken to make it as "safe" as possible. With more people now working on MAJ, bugs and exploitable code may sometimes slip in. We invite you to poke around and see if you can find any. Generally, there are two things you can do when you find a MAJ or PHP-related bug or exploit:

1. Take advantage of it. But hey, what's so exciting about messing up someone's blog? Ho-hum, right?
2. Report it here so that we can work on a fix and make MAJ better.

read more
Search
Download
MAJ 2.0
75 files
33087 downloads
MAJ 1.0
26 files
13170 downloads
MAJ 0.14
45 files
35071 downloads