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 1372 times via Git panel.

commit e72805553c344dc907a849d010a3936fe053dadd
tree fb84a8dac1e3e0c3fe449241982d40bfeb380cbc
parent d7f17aa258773e9a244eec522258cd9656e52689
author Engels Antonio <engels@majcms.org> 1310638389 +0800
committer Engels Antonio <engels@majcms.org> 1310638389 +0800

    Aggregate recurring functions

diff --git a/add.php b/add.php
index 70f092f..88dd8f8 100644
--- a/add.php
+++ b/add.php
@@ -1,160 +1,60 @@
 <?php
-  session_start();
-  
-  header("Cache-control: private");
-  
-  error_reporting(E_ERROR);
-  
+
   require("core.php");
   
-  if (isset($_SESSION['logged_in']) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
-      header("Location: login.php");
-  }
-  
   if (isset($_POST['title_input']) and isset($_POST['body_input']) and !empty($_POST['title_input']) and !empty($_POST['body_input'])) {
       header("Location: index.php");
   }
   
-  if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
-      $login_username = file_get_contents("data/username.txt");
+  if ($maj_logged_in_username == $maj_admin_username) {
+      $login_username = $maj_admin_username;
   }
   
-  if ($_SESSION['logged_in'] != file_get_contents("data/username.txt")) {
-      if (file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt")) {
-          $bb_cat = file_get_contents("data/members/active/{$_SESSION['logged_in']}/category.txt");
+  if ($maj_logged_in_username != $maj_admin_username) {
+      if (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/category.txt")) {
+          $bb_cat = file_get_contents("$maj_data_directory/members/active/$maj_logged_in_username/category.txt");
           
-          if (!file_exists("data/categories/$bb_cat") or ($bb_cat == "")) {
-              unlink("data/members/active/{$_SESSION['logged_in']}/category.txt");
+          if (!file_exists("$maj_data_directory/categories/$bb_cat") or ($bb_cat == "")) {
+              unlink("$maj_data_directory/members/active/$maj_logged_in_username/category.txt");
           }
       }
       
-      if ((file_exists("data/members/active/{$_SESSION['logged_in']}/bb-rw.txt") or file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt")) and file_exists("data/bb.txt") and !file_exists("data/noadd.txt")) {
-          $login_username = $_SESSION['logged_in'];
+      if ((file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-rw.txt") or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/category.txt")) and file_exists("$maj_data_directory/bb.txt") and !file_exists("$maj_data_directory/noadd.txt")) {
+          $login_username = $maj_logged_in_username;
       }
   }
   
-  if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
+  if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $login_username)) {
       exit();
   }
-?>
-
-<title>Add</title>
-
-<style>
-
-body {
-  color: #666666;
-  margin: 10px;
-  padding: 0px;
-  text-align: left;
-  font-family: <?php
-  if (file_exists("data/fonts/body.txt")) {
-      $font_body = file_get_contents("data/fonts/body.txt");
-      echo "$font_body,";
-  }
-?> arial, helvetica, sans-serif;
-  background-color: #FFFFFF;
-}
-
-p, td {
-  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_title {  
-  color: #666666;
-  background: #ffffff;
-  border: #999999 solid 1px;
-  width: 512px;
-  font-family: <?php
-  if (file_exists("data/fonts/panel-title.txt")) {
-      $font_panel_title = file_get_contents("data/fonts/panel-title.txt");
-      echo "$font_panel_title,";
-  }
-?> arial, helvetica, sans-serif;
-  font-size: 11px;
-  font-weight: bold
-}
-
-.input_body {  
-  color: #666666;
-  background: #ffffff;
-  border: #999999 solid 1px;
-  width: 512px;
-  font-family: <?php
-  if (file_exists("data/fonts/panel-body.txt")) {
-      $font_panel_body = file_get_contents("data/fonts/panel-body.txt");
-      echo "$font_panel_body,";
-  }
-?> arial, helvetica, sans-serif;
-  font-size: 11px
-}
-
-</style>
-
-<?php
-  if (file_exists("data/offset.txt")) {
-      $offset = file_get_contents("data/offset.txt");
-  } else {
-      $offset = 0;
-  }
-  
-  $entry_year = date("Y", time() + $offset);
-  $entry_month = date("m", time() + $offset);
-  $entry_day = date("d", time() + $offset);
-  $entry_hour = date("H", time() + $offset);
-  $entry_min = date("i", time() + $offset);
-  $entry_sec = date("s", time() + $offset);
-  
-  $server_upload_max_filesize = return_bytes(ini_get('upload_max_filesize'));
-  $server_post_max_size = return_bytes(ini_get('post_max_size'));
-  $server_memory_limit = return_bytes(ini_get('memory_limit'));
-  
-  $max_file_size = $server_upload_max_filesize;
   
-  if ($server_upload_max_filesize > $server_post_max_size) {
-      $max_file_size = $server_post_max_size;
-  }
+  $entry_year = date("Y", time() + $maj_offset);
+  $entry_month = date("m", time() + $maj_offset);
+  $entry_day = date("d", time() + $maj_offset);
+  $entry_hour = date("H", time() + $maj_offset);
+  $entry_min = date("i", time() + $maj_offset);
+  $entry_sec = date("s", time() + $maj_offset);
+
+  include("css.php");
   
-  if ($server_post_max_size > $server_memory_limit) {
-      $max_file_size = $server_memory_limit;
-  }
+echo "\n<style>body { margin: {$maj_wspace}px; } .input, .click { width: 520px; }</style>\n";
+
 ?>
 
+<title>Add</title>
+
 <form enctype="multipart/form-data" action="add.php" method="post">
 <p>
 
 <?php
-  if ($_SESSION['logged_in'] != file_get_contents("data/username.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/members/active/{$_SESSION['logged_in']}/bb-ul.txt")) {
+  if ($maj_logged_in_username != $maj_admin_username and file_exists("$maj_data_directory/members/active/$maj_logged_in_username") and file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-ul.txt")) {
 ?>
 
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php
-      echo $max_file_size;
-?>">
+<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
 <input autocomplete="off" type="file" name="image_input"> Upload optional GIF, JPG, or PNG entry image.</p>
 
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php
-      echo $max_file_size;
-?>">
-<input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php
-      echo($max_file_size / (1024 * 1024));
-?>MB.</p>
+<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
+<input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php echo($max_file_size / (1024 * 1024)); ?>MB.</p>
 
 <?php
   }
@@ -162,7 +62,7 @@ a:active {
 
 
 <?php
-  if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
+  if ($maj_logged_in_username == $maj_admin_username) {
 ?>
 
 <select name="select_year">
@@ -367,22 +267,14 @@ a:active {
 <option>59
 </select>   Enter antedate value in YYYY-MM-DD-HH-MM format.</p>
 
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php
-      echo $max_file_size;
-?>">
+<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
 <input autocomplete="off" type="file" name="image_input"> Upload optional GIF, JPG, or PNG entry image.</p>
-
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php
-      echo $max_file_size;
-?>">
-<input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php
-      echo($max_file_size / (1024 * 1024));
-?>MB.</p>
+<input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php echo($max_file_size / (1024 * 1024)); ?>MB.</p>
 <p><input autocomplete="off" type="password" name="passwd"> Enter optional password.</p>
 
 <?php
-      if (file_exists("data/categories")) {
-          if ($dh_cat = opendir("data/categories")) {
+      if (file_exists("$maj_data_directory/categories")) {
+          if ($dh_cat = opendir("$maj_data_directory/categories")) {
               while (($entry_cat = readdir($dh_cat)) !== false) {
                   if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
                       $show_cat[] = $entry_cat;
@@ -400,13 +292,13 @@ a:active {
               
               foreach ($show_cat as $category) {
                   echo "<option value=\"";
-                  echo strtolower($category);
+                  echo mb_strtolower($category);
                   echo "\">";
                   
-                  if (file_exists("data/categories/$category/title.txt")) {
-                      readfile("data/categories/$category/title.txt");
+                  if (file_exists("$maj_data_directory/categories/$category/title.txt")) {
+                      readfile("$maj_data_directory/categories/$category/title.txt");
                   } else {
-                      echo strtolower($category);
+                      echo mb_strtolower($category);
                   }
               }
               
@@ -417,27 +309,18 @@ a:active {
 
 <p><input type="checkbox" name="sticky">Put entry title in Quick Links box.<br>
 <input type="checkbox" name="display">Always display. If this is not a private entry, it will be displayed even if its category is hidden or isolated.<br>
-<input type="checkbox" name="private" <?php
-      if (file_exists("data/ml.txt")) {
-          echo checked;
-      }
-?>>Private entry. This entry will unconditionally be invisible to visitors<?php
-      if (file_exists("data/ml.txt")) {
-          echo " and to the mailing list";
-      }
-?>, even if always display is set.
+<input type="checkbox" name="private" <?php if (file_exists("$maj_data_directory/ml.txt")) { echo checked; } ?>>Private entry. This entry will unconditionally be invisible to visitors<?php if (file_exists("$maj_data_directory/ml.txt")) { echo " and to the mailing list"; } ?>, even if always display is set.
 
 <?php
-      if (file_exists("data/bb.txt")) {
-?>
-<br>
-<input type="checkbox" name="member" <?php
-          if (file_exists("data/member.txt")) {
-              echo checked;
-          }
-?>>Only registered members can view this entry.
+      if (file_exists("$maj_data_directory/bb.txt")) {
 
-<?php
+               echo "<br><input type=\"checkbox\" name=\"member\"";
+              
+               if (file_exists("$maj_data_directory/member.txt")) {
+                       echo " checked";
+               }
+
+               echo ">Only registered members can view this entry.";
       }
 ?>
 
@@ -450,29 +333,29 @@ a:active {
 <table border="0" cellspacing="0" cellpadding="0"><tr><td>
 
 <table border="0" cellspacing="2" cellpadding="0">
-<tr><td><input autocomplete="off" class="input_title" type="text" name="title_input" autofocus required></td></tr>
-<tr><td><textarea class="input_body" name="body_input" rows="15" required></textarea></td></tr>
-<tr><td><input class="input_body" type="submit" value="click here to post this new entry"></td></tr>
+<tr><td><input autocomplete="off" class="input" type="text" name="title_input" autofocus required></td></tr>
+<tr><td><textarea class="input" name="body_input" rows="15" required></textarea></td></tr>
+<tr><td><input class="click" type="submit" value="click here to post this new entry"></td></tr>
 </form>
 
 <form enctype="multipart/form-data" action="index.php" method="post">
-<tr><td><input class=input_body type=submit value="click here to go to the index page"></td></tr>
+<tr><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
 </form>
 </table>
 
 </td><td width="10"></td><td>
 
 <table border="0" cellspacing="1" cellpadding="2">
-<tr><td><img src="images/smileys/crying.png" border="0"></td><td><p>:((</p></td><td ><p>crying</p></td></tr>
-<tr><td><img src="images/smileys/frown.png" border="0"></td><td><p>:(</p></td><td><p>frown</p></td></tr>
-<tr><td><img src="images/smileys/indifferent.png" border="0"></td><td><p>:|</p></td><td><p>indifferent</p></td></tr>
-<tr><td><img src="images/smileys/laughing.png" border="0"></td><td><p>:D</p></td><td><p>laughing</p></td></tr>
-<tr><td><img src="images/smileys/lick.png" border="0"></td><td><p>:P</p></td><td><p>lick</p></td></tr>
-<tr><td><img src="images/smileys/ohno.png" border="0"></td><td><p>:O</p></td><td><p>oh no!</p></td></tr>
-<tr><td><img src="images/smileys/smile.png" border="0"></td><td><p>:)</p></td><td><p>smile</p></td></tr>
-<tr><td><img src="images/smileys/surprised.png" border="0"></td><td><p>=)</p></td><td><p>surprised</p></td></tr>
-<tr><td><img src="images/smileys/undecided.png" border="0"></td><td><p>:\</p></td><td><p>undecided</p></td></tr>
-<tr><td><img src="images/smileys/wink.png" border="0"></td><td><p>;)</p></td><td><p>wink</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/crying.png" border="0"></td><td><p>:((</p></td><td ><p>crying</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/frown.png" border="0"></td><td><p>:(</p></td><td><p>frown</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/indifferent.png" border="0"></td><td><p>:|</p></td><td><p>indifferent</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/laughing.png" border="0"></td><td><p>:D</p></td><td><p>laughing</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/lick.png" border="0"></td><td><p>:P</p></td><td><p>lick</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/ohno.png" border="0"></td><td><p>:O</p></td><td><p>oh no!</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/smile.png" border="0"></td><td><p>:)</p></td><td><p>smile</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/surprised.png" border="0"></td><td><p>=)</p></td><td><p>surprised</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/undecided.png" border="0"></td><td><p>:\</p></td><td><p>undecided</p></td></tr>
+<tr><td><img src="<?php echo $maj_image_directory; ?>/smileys/wink.png" border="0"></td><td><p>;)</p></td><td><p>wink</p></td></tr>
 </td></tr>
 </table>
 
@@ -484,128 +367,117 @@ a:active {
   }
   
   if (!isset($_POST['select_year']) or !isset($_POST['select_month']) or !isset($_POST['select_day']) or !isset($_POST['select_hour']) or !isset($_POST['select_min']) or empty($_POST['select_year']) or empty($_POST['select_month']) or empty($_POST['select_day']) or empty($_POST['select_hour']) or empty($_POST['select_min'])) {
-      $entry = date("YmdHis", time() + $offset);
-      $timestamp = date("l, M j, Y, g:i A", time() + $offset);
+      $entry = date("YmdHis", time() + $maj_offset);
+      $timestamp = date("l, M j, Y, g:i A", time() + $maj_offset);
   } else {
       $entry = $_POST['select_year'] . $_POST['select_month'] . $_POST['select_day'] . $_POST['select_hour'] . $_POST['select_min'] . $entry_sec;
       $timestamp = date("l, M j, Y, g:i A", mktime($_POST['select_hour'], $_POST['select_min'], $entry_sec, $_POST['select_month'], $_POST['select_day'], $_POST['select_year']));
   }
   
-  if (!file_exists("data/items")) {
-      mkdir("data/items");
+  if (!file_exists("$maj_data_directory/items")) {
+      mkdir("$maj_data_directory/items");
   }
   
-  $dir = "data/items/";
-  $item_dir = $dir . $entry;
-  
   if (!file_exists("images")) {
       mkdir("images");
   }
-  
-  $image_dir = 'images/' . $entry;
-  $file_dir = $item_dir . '/filedrop';
-  
-  mkdir($item_dir);
+
+  mkdir("$maj_data_directory/items/$entry");
   
   $title_write_content = format_title_put($_POST['title_input']);
   $body_write_content = format_body_put($_POST['body_input']);
   
-  $title_file = $item_dir . '/title.txt';
-  $fp_title_txt = fopen($title_file, "w");
+  $fp_title_txt = fopen("$maj_data_directory/items/$entry/title.txt", "w");
   fwrite($fp_title_txt, $title_write_content);
   fclose($fp_title_txt);
   
-  $author_file = $item_dir . '/author.txt';
-  $fp_author_txt = fopen($author_file, "w");
-  fwrite($fp_author_txt, $_SESSION['logged_in']);
+  $fp_author_txt = fopen("$maj_data_directory/items/$entry/author.txt", "w");
+  fwrite($fp_author_txt, $maj_logged_in_username);
   fclose($fp_author_txt);
   
-  if (file_get_contents("data/username.txt") == $_SESSION['logged_in']) {
-      $post_file = "data/lastpost.txt";
-  } elseif (file_exists("data/members/active/{$_SESSION['logged_in']}")) {
-      $post_file = "data/members/active/{$_SESSION['logged_in']}/bb-post.txt";
+  if ($maj_admin_username == $maj_logged_in_username) {
+      $post_file = "$maj_data_directory/lastpost.txt";
+  } elseif (file_exists("$maj_data_directory/members/active/$maj_logged_in_username")) {
+      $post_file = "$maj_data_directory/members/active/$maj_logged_in_username/bb-post.txt";
   }
   
   $fp_post_txt = fopen($post_file, "w");
   fwrite($fp_post_txt, $entry);
   fclose($fp_post_txt);
   
-  $date_file = $item_dir . '/date.txt';
-  $fp_date_txt = fopen($date_file, "w");
+  $fp_date_txt = fopen($maj_data_directory/items/$entry/date.txt, "w");
   fwrite($fp_date_txt, $timestamp);
   fclose($fp_date_txt);
   
-  if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
-      if (is_uploaded_file($_FILES['image_input']['tmp_name'])) {
-          if ($_FILES['image_input']['size'] <= $max_file_size) {
-              if (($_FILES['image_input']['type'] == "image/gif") || ($_FILES['image_input']['type'] == "image/pjpeg") || ($_FILES['image_input']['type'] == "image/jpeg") || ($_FILES['image_input']['type'] == "image/png")) {
-                  if (!file_exists($image_dir)) {
-                      mkdir($image_dir);
-                  }
+if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
+
+       if (is_uploaded_file($_FILES['image_input']['tmp_name'])) {
+
+               if ($_FILES['image_input']['size'] <= $max_file_size) {
+
+                       if (($_FILES['image_input']['type'] == "image/gif") || ($_FILES['image_input']['type'] == "image/pjpeg") || ($_FILES['image_input']['type'] == "image/jpeg") || ($_FILES['image_input']['type'] == "image/png")) {
+
+                               if (!file_exists("$maj_image_directory/$entry")) {
+                                       mkdir("$maj_image_directory/$entry");
+                               }
                   
-                  $image_input_name = str_replace(" ", "_", $_FILES['image_input']['name']);
+                               $image_input_name = str_replace(" ", "_", $_FILES['image_input']['name']);
                   
-                  if (!file_exists("$image_dir/$image_input_name")) {
-                      $res = copy($_FILES['image_input']['tmp_name'], "$image_dir/$image_input_name");
-                      unlink($_FILES['image_input']['tmp_name']);
-                  } else {
-                      unlink($_FILES['image_input']['tmp_name']);
-                  }
-              } else {
-                  unlink($_FILES['image_input']['tmp_name']);
-              }
-          } else {
-              unlink($_FILES['image_input']['tmp_name']);
-          }
-      } else {
-          unlink($_FILES['image_input']['tmp_name']);
-      }
-  }
+                               if (!file_exists("$maj_image_directory/$entry/$image_input_name")) {
+                                       copy($_FILES['image_input']['tmp_name'], "$maj_image_directory/$entry/$image_input_name");
+                                       unlink($_FILES['image_input']['tmp_name']);
+                               }
+                               else {
+                                       unlink($_FILES['image_input']['tmp_name']);
+                               }
+                       }
+                       else {
+                               unlink($_FILES['image_input']['tmp_name']);
+                       }
+               }
+               else {
+                       unlink($_FILES['image_input']['tmp_name']);
+               }
+       }
+       else {
+               unlink($_FILES['image_input']['tmp_name']);
+       }
+}
   
-  if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
-      if (is_uploaded_file($_FILES['file_input']['tmp_name'])) {
-          if ($_FILES['file_input']['size'] <= $max_file_size) {
-              $filedrop_dir = "$item_dir/filedrop";
-              
-              if (!file_exists($filedrop_dir)) {
-                  mkdir($filedrop_dir);
-              }
-              
-              $file_dir = "$filedrop_dir/files";
+if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
+
+       if (is_uploaded_file($_FILES['file_input']['tmp_name'])) {
+
+               if ($_FILES['file_input']['size'] <= $max_file_size) {
               
-              if (!file_exists($file_dir)) {
-                  mkdir($file_dir);
-              }
+                       if (!file_exists($maj_data_directory/items/$entry/filedrop)) {
+                               mkdir("$maj_data_directory/items/$entry/filedrop/files",0700,true);
+                       }
               
-              $file_input_name = str_replace(" ", "_", $_FILES['file_input']['name']);
+                       $file_input_name = str_replace(" ", "_", $_FILES['file_input']['name']);
               
-              if (!file_exists("$file_dir/$file_input_name")) {
-                  $res = copy($_FILES['file_input']['tmp_name'], "$file_dir/$file_input_name");
-                  unlink($_FILES['file_input']['tmp_name']);
-                  
-                  
-                  $fp_file_txt = fopen("$filedrop_dir/{$file_input_name}.txt", "w");
-                  fwrite($fp_file_txt, "$file_dir/$file_input_name");
-                  fclose($fp_file_txt);
-              } else {
-                  unlink($_FILES['file_input']['tmp_name']);
-              }
-          } else {
-              unlink($_FILES['file_input']['tmp_name']);
-          }
-      } else {
-          unlink($_FILES['file_input']['tmp_name']);
-      }
-  }
-  
-  
-  $body_file = "$item_dir/body.txt";
+                       if (!file_exists("$maj_data_directory/items/$entry/filedrop/files/$file_input_name")) {
+                               copy($_FILES['file_input']['tmp_name'], "$maj_data_directory/items/$entry/filedrop/files/$file_input_name");
+                               unlink($_FILES['file_input']['tmp_name']);
+                       }
+                       else {
+                               unlink($_FILES['file_input']['tmp_name']);
+                       }
+               }
+               else {
+                       unlink($_FILES['file_input']['tmp_name']);
+               }
+       }
+       else {
+               unlink($_FILES['file_input']['tmp_name']);
+       }
+}
   
-  $fp_body_txt = fopen($body_file, "w");
+  $fp_body_txt = fopen("$maj_data_directory/items/$entry/body.txt", "w");
   
   if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
-      if (file_exists("$image_dir/$image_input_name")) {
-          $entry_image_size = getimagesize("$image_dir/$image_input_name");
+      if (file_exists("$maj_image_directory/$entry/$image_input_name")) {
+          $entry_image_size = getimagesize("$maj_image_directory/$entry/$image_input_name");
           $entry_image_width = $entry_image_size[0];
           $entry_image_height = $entry_image_size[1];
           
@@ -617,98 +489,94 @@ a:active {
               $entry_image_height = (int)($entry_image_height * $sizefactor);
           }
           
-          $body_write_content = "<img src=\"$image_dir/$image_input_name\" border=\"0\" width=\"$entry_image_width\" height=\"$entry_image_height\"><br>$body_write_content";
+          $body_write_content = "<img src=\"$maj_image_directory/$entry/$image_input_name\" border=\"0\" width=\"$entry_image_width\" height=\"$entry_image_height\"><br>$body_write_content";
       }
   }
   
   fwrite($fp_body_txt, $body_write_content);
   fclose($fp_body_txt);
   
-  $sticky_sem = "data/sticky/$entry";
-  
   if (isset($_POST['sticky']) and !empty($_POST['sticky']) and ($_POST['sticky'] == "on")) {
-      if (!file_exists("data/sticky")) {
-          mkdir("data/sticky");
+      if (!file_exists("$maj_data_directory/sticky")) {
+          mkdir("$maj_data_directory/sticky");
       }
-      if (!file_exists($sticky_sem)) {
-          touch($sticky_sem);
+      if (!file_exists("$maj_data_directory/sticky/$entry")) {
+          touch("$maj_data_directory/sticky/$entry");
       }
   }
   
-  $display_sem = "data/items/$entry/cat.txt";
   if (isset($_POST['display']) and !empty($_POST['display']) and ($_POST['display'] == "on")) {
-      if (!file_exists($display_sem)) {
-          touch($display_sem);
+      if (!file_exists("$maj_data_directory/items/$entry/cat.txt")) {
+          touch("$maj_data_directory/items/$entry/cat.txt");
       }
   }
   
-  $private_sem = "data/items/$entry/private.txt";
   if (isset($_POST['private']) and !empty($_POST['private']) and ($_POST['private'] == "on")) {
-      if (!file_exists($private_sem)) {
-          touch($private_sem);
+      if (!file_exists("$maj_data_directory/items/$entry/private.txt")) {
+          touch("$maj_data_directory/items/$entry/private.txt");
       }
   }
   
-  if (file_exists("data/bb.txt") and file_exists("data/member.txt") and (($_SESSION['logged_in'] != file_get_contents("data/username.txt")) or (isset($_POST['member']) and !empty($_POST['member']) and ($_POST['member'] == "on")))) {
-      touch("data/items/$entry/member.txt");
+  if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/member.txt") and (($maj_logged_in_username != $maj_admin_username) or (isset($_POST['member']) and !empty($_POST['member']) and ($_POST['member'] == "on")))) {
+      touch("$maj_data_directory/items/$entry/member.txt");
   }
   
-  if (file_exists("data/members/active") and file_exists("data/ml.txt") and file_exists("data/email.txt") and !file_exists($private_sem)) {
-      if (file_exists("data/ml-reply2.txt")) {
-          $ml_reply2 = file_get_contents("data/ml-reply2.txt");
+  if (file_exists("$maj_data_directory/members/active") and file_exists("$maj_data_directory/ml.txt") and file_exists("$maj_data_directory/email.txt") and !file_exists("$maj_data_directory/items/$entry/private.txt")) {
+      if (file_exists("$maj_data_directory/ml-reply2.txt")) {
+          $ml_reply2 = file_get_contents("$maj_data_directory/ml-reply2.txt");
       }
       
-      if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
-          $ml_author = file_get_contents("data/author.txt");
+      if ($maj_logged_in_username == $maj_admin_username) {
+          $ml_author = file_get_contents("$maj_data_directory/author.txt");
           
-          if (file_exists("data/ml-from.txt")) {
+          if (file_exists("$maj_data_directory/ml-from.txt")) {
               $ml_from = $ml_reply2;
           } else {
-              $ml_from = file_get_contents("data/email.txt");
+              $ml_from = file_get_contents("$maj_data_directory/email.txt");
           }
           
-          $ml_from = '"' . $ml_author . '" <' . $ml_from . '>';
+          $ml_from = "\"$ml_author\" <$ml_from>";
       }
       
-      if ($_SESSION['logged_in'] != file_get_contents("data/username.txt")) {
-          if (file_exists("data/members/active/{$_SESSION['logged_in']}/bb-rw.txt") and file_exists("data/bb.txt")) {
-              $ml_from_firstname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/firstname.txt");
-              $ml_from_lastname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/lastname.txt");
+      if ($maj_logged_in_username != $maj_admin_username) {
+          if (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-rw.txt") and file_exists("$maj_data_directory/bb.txt")) {
+              $ml_from_firstname = file_get_contents("$maj_data_directory/members/active/$maj_logged_in_username/firstname.txt");
+              $ml_from_lastname = file_get_contents("$maj_data_directory/members/active/$maj_logged_in_username/lastname.txt");
               
-              if (file_exists("data/ml-from.txt")) {
+              if (file_exists("$maj_data_directory/ml-from.txt")) {
                   $ml_from = $ml_reply2;
               } else {
-                  $ml_from = file_get_contents("data/members/active/{$_SESSION['logged_in']}/email.txt");
+                  $ml_from = file_get_contents("$maj_data_directory/members/active/$maj_logged_in_username/email.txt");
               }
               
-              $ml_from = '"' . "$ml_from_firstname $ml_from_lastname" . '" <' . $ml_from . '>';
+              $ml_from = "\"$ml_from_firstname $ml_from_lastname\" <$ml_from>";
           }
       }
       
       $ml_subject = ucfirst($_POST['title_input']);
-      if (file_exists("data/ml-prepend.txt")) {
-          $ml_subject = file_get_contents("data/ml-prepend.txt") . " " . $ml_subject;
+      if (file_exists("$maj_data_directory/ml-prepend.txt")) {
+          $ml_subject = file_get_contents("$maj_data_directory/ml-prepend.txt") . " " . $ml_subject;
       }
       
       $ml_mailer = 'MAJ/2.0 (PHP/' . phpversion() . ')';
       $ml_body = ucfirst($_POST['body_input']);
       $ml_body = str_replace('<br />', "\n", $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/crying.png" border="0">', ':((', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/frown.png" border="0">', ':(', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/indifferent.png" border="0">', ':|', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/laughing.png" border="0">', ':D', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/lick.png" border="0">', ':P', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/ohno.png" border="0">', ':O', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/smile.png" border="0">', ':)', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/surprised.png" border="0">', '=)', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/undecided.png" border="0">', ':\\', $ml_body);
-      $ml_body = str_replace('<img src="images/smileys/wink.png" border="0">', ';)', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/crying.png\" border=\"0\">", ':((', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/frown.png\" border=\"0\">", ':(', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/indifferent.png\" border=\"0\">", ':|', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/laughing.png\" border=\"0\">", ':D', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/lick.png\" border=\"0\">", ':P', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/ohno.png\" border=\"0\">", ':O', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/smile.png\" border=\"0\">", ':)', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/surprised.png\" border=\"0\">", '=)', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/undecided.png\" border=\"0\">", ':\\', $ml_body);
+      $ml_body = str_replace("<img src=\"$maj_image_directory/smileys/wink.png\" border=\"0\">", ';)', $ml_body);
       $ml_body = str_replace('&amp;', '&', $ml_body);
       $ml_body = str_replace('&reg;', '(R)', $ml_body);
       $ml_body = strip_tags($ml_body);
       
-      if (file_exists("data/ml-header.txt")) {
-          $ml_header = file_get_contents("data/ml-header.txt");
+      if (file_exists("$maj_data_directory/ml-header.txt")) {
+          $ml_header = file_get_contents("$maj_data_directory/ml-header.txt");
           $ml_body = $ml_header . "\n\n" . $ml_body;
       }
       
@@ -718,36 +586,36 @@ a:active {
       
       $ml_body = $ml_body . "\n\nPlease visit the following URL for the online version of this message:\n\n" . $ml_url;
       
-      if (file_exists("data/items/$entry/member.txt")) {
+      if (file_exists("$maj_data_directory/items/$entry/member.txt")) {
           $ml_body = $ml_body . "\n\nYou need to login first to view the entry or to add a comment.";
       }
       
-      if (file_exists("data/ml-footer.txt")) {
-          $ml_footer = file_get_contents("data/ml-footer.txt");
+      if (file_exists("$maj_data_directory/ml-footer.txt")) {
+          $ml_footer = file_get_contents("$maj_data_directory/ml-footer.txt");
           $ml_body = $ml_body . "\n\n" . $ml_footer;
       }
       
-      if ($dh_ml_member = opendir("data/members/active")) {
+      if ($dh_ml_member = opendir("$maj_data_directory/members/active")) {
           while (($ml_member = readdir($dh_ml_member)) !== false) {
               if ($ml_member != "." && $ml_member != ".." && fnmatch("*", $ml_member)) {
           
-                  if (file_exists("data/members/active/$ml_member/bb-noml.txt")) {
+                  if (file_exists("$maj_data_directory/members/active/$ml_member/bb-noml.txt")) {
                       continue;
                   }
                   
-                  if (file_exists("data/members/active/$ml_member/bb-vacation.txt")) {
+                  if (file_exists("$maj_data_directory/members/active/$ml_member/bb-vacation.txt")) {
                       continue;
                   }
                   
-                  $ml_to_firstname = file_get_contents("data/members/active/$ml_member/firstname.txt");
-                  $ml_to_lastname = file_get_contents("data/members/active/$ml_member/lastname.txt");
-                  $ml_to = file_get_contents("data/members/active/$ml_member/email.txt");
+                  $ml_to_firstname = file_get_contents("$maj_data_directory/members/active/$ml_member/firstname.txt");
+                  $ml_to_lastname = file_get_contents("$maj_data_directory/members/active/$ml_member/lastname.txt");
+                  $ml_to = file_get_contents("$maj_data_directory/members/active/$ml_member/email.txt");
                   $ml_to = '"' . "$ml_to_firstname $ml_to_lastname" . '" <' . $ml_to . '>';
                   
-                  if (file_exists("data/ml-reply2.txt")) {
-                      mail($ml_to, $ml_subject, $ml_body, "From: $ml_from\r\n" . "Reply-To: $ml_reply2\r\n" . "References: $entry\r\n" . "X-Mailer: $ml_mailer");
+                  if (file_exists("$maj_data_directory/ml-reply2.txt")) {
+                      mb_send_mail($ml_to, $ml_subject, $ml_body, "From: $ml_from\r\n" . "Reply-To: $ml_reply2\r\n" . "References: $entry\r\n" . "X-Mailer: $ml_mailer");
                   } else {
-                      mail($ml_to, $ml_subject, $ml_body, "From: $ml_from\r\n" . "References: $entry\r\n" . "X-Mailer: $ml_mailer");
+                      mb_send_mail($ml_to, $ml_subject, $ml_body, "From: $ml_from\r\n" . "References: $entry\r\n" . "X-Mailer: $ml_mailer");
                   }
               }
           }
@@ -755,53 +623,57 @@ a:active {
       }
   }
   
-  if (isset($_POST['category']) and !empty($_POST['category']) and file_exists("data/categories/{$_POST['category']}")) {
-      if (!file_exists("data/items/$entry/categories")) {
-          mkdir("data/items/$entry/categories");
+  if (isset($_POST['category']) and !empty($_POST['category']) and file_exists("$maj_data_directory/categories/{$_POST['category']}")) {
+      if (!file_exists("$maj_data_directory/items/$entry/categories")) {
+          mkdir("$maj_data_directory/items/$entry/categories");
       }
       
-      if (!file_exists("data/items/$entry/categories/{$_POST['category']}")) {
-          mkdir("data/items/$entry/categories/{$_POST['category']}");
+      if (!file_exists("$maj_data_directory/items/$entry/categories/{$_POST['category']}")) {
+          mkdir("$maj_data_directory/items/$entry/categories/{$_POST['category']}");
       }
   }
   
   
-  if (file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt") and file_exists("data/bb.txt")) {
-      $bb_cat = file_get_contents("data/members/active/{$_SESSION['logged_in']}/category.txt");
+  if (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/category.txt") and file_exists("$maj_data_directory/bb.txt")) {
+      $bb_cat = file_get_contents("$maj_data_directory/members/active/$maj_logged_in_username/category.txt");
       
-      if (file_exists("data/categories/$bb_cat")) {
-          if (!file_exists("data/items/$entry/categories")) {
-              mkdir("data/items/$entry/categories");
+      if (file_exists("$maj_data_directory/categories/$bb_cat")) {
+          if (!file_exists("$maj_data_directory/items/$entry/categories")) {
+              mkdir("$maj_data_directory/items/$entry/categories");
           }
           
-          if (!file_exists("data/items/$entry/categories/$bb_cat")) {
-              mkdir("data/items/$entry/categories/$bb_cat");
+          if (!file_exists("$maj_data_directory/items/$entry/categories/$bb_cat")) {
+              mkdir("$maj_data_directory/items/$entry/categories/$bb_cat");
           }
       }
   }
   
-  if (isset($_POST['passwd']) and !empty($_POST['passwd'])) {
-      if (($_POST['passwd'] == "password") or empty($_POST['passwd'])) {
-          unlink("data/items/$entry/passwd.txt");
-      } else {
-          $passwd_crypt = sha1($_POST['passwd']);
-          $passwd_crypt = md5($passwd_crypt);
-          $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
+if (isset($_POST['passwd']) and !empty($_POST['passwd'])) {
+
+       if (empty($_POST['passwd'])) {
+               unlink("$maj_data_directory/items/$entry/passwd.txt");
+       }
+       else {
+               $passwd_crypt = sha1($_POST['passwd']);
+               $passwd_crypt = md5($passwd_crypt);
+               $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
           
-          $fp_passwd_txt = fopen("data/items/$entry/passwd.txt", "w");
-          fwrite($fp_passwd_txt, $passwd_crypt);
-          fclose($fp_passwd_txt);
-      }
-  }
+               $fp_passwd_txt = fopen("$maj_data_directory/items/$entry/passwd.txt", "w");
+               fwrite($fp_passwd_txt, $passwd_crypt);
+               fclose($fp_passwd_txt);
+       }
+}
   
-  if (file_exists("data/ping.txt")) {
-      $ping_urls = file_get_contents("data/ping.txt");
+if (file_exists("$maj_data_directory/ping.txt")) {
+
+       $ping_urls = file_get_contents("$maj_data_directory/ping.txt");
       
-      $get_ping_urls = explode("|", $ping_urls);
+       $get_ping_urls = explode("|", $ping_urls);
       
-      foreach ($get_ping_urls as $ping_url) {
-          $ping = file_get_contents($ping_url);
-          unset($ping);
-      }
-  }
+       foreach ($get_ping_urls as $ping_url) {
+               $ping = file_get_contents($ping_url);
+               unset($ping);
+       }
+}
+
 ?>
diff --git a/album.php b/album.php
index d803def..1cf8012 100644
--- a/album.php
+++ b/album.php
@@ -1,81 +1,66 @@
 <?php
 
-session_start();
-
-header("Cache-control: private");
-
-error_reporting(E_ERROR);
-
 require("core.php");
 
-if (isset($_SESSION['logged_in']) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
-       header("Location: login.php");
-}
-
-if (!isset($_REQUEST['entry']) or empty($_REQUEST['entry'])) {
+if (!isset($maj_req_entry) or empty($maj_req_entry)) {
        exit();
 }
 
-if (!isset($_REQUEST['show']) or empty($_REQUEST['show'])) {
+if (!isset($maj_req_show) or empty($maj_req_show)) {
        exit();
 }
 
-if (!file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
+if (!file_exists("images/$maj_req_entry/album/$maj_req_show")) {
        exit();
 }
 
-$login_username = file_get_contents("data/username.txt");
-
-//if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
-//     exit();
-//}
-
-if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "delete")) {
+if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username) and isset($_POST['edit']) and ($_POST['edit'] == "delete")) {
 
-       unlink("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
+       unlink("images/$maj_req_entry/album/$maj_req_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/$maj_req_entry/album/captions/{$maj_req_show}.txt")) {
+               unlink("data/items/$maj_req_entry/album/captions/{$maj_req_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 (file_exists("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt")) {
+               unlink("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt");
        }
 
-       if (count(glob("images/{$_REQUEST['entry']}/album/*")) < 1) {
-               header("Location: index.php?entry={$_REQUEST['entry']}");
+       if (count(glob("images/$maj_req_entry/album/*")) < 1) {
+               header("Location: index.php?entry=$maj_req_entry");
        }
       
-       header("Location: album.php?entry={$_REQUEST['entry']}&show={$_REQUEST['next']}");
+       header("Location: album.php?entry=$maj_req_entry&show={$_REQUEST['next']}");
 }
 
-if (isset($_POST['filename']) and !empty($_POST['filename']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "rename") and !file_exists("images/{$_REQUEST['entry']}/album/{$_POST['filename']}")) {
+if (isset($_POST['filename']) and !empty($_POST['filename']) and isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username) and isset($_POST['edit']) and ($_POST['edit'] == "rename") and !file_exists("images/$maj_req_entry/album/{$_POST['filename']}")) {
 
-       $filename = strtolower($_POST['filename']);
+       $filename = strip_tags($_POST['filename']);
+       $filename = mb_strtolower($_POST['filename']);
        $filename = str_replace(" ","_",$filename);
        $filename = trim($filename);
 
-       rename("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}","images/{$_REQUEST['entry']}/album/{$filename}");
+       rename("images/$maj_req_entry/album/$maj_req_show","images/$maj_req_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/$maj_req_entry/album/captions/{$maj_req_show}.txt")) {
+               rename("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt","data/items/$maj_req_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 (file_exists("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt")) {
+               rename("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt","data/items/$maj_req_entry/album/views/{$filename}.txt");
        }
       
-       header("Location: album.php?entry={$_REQUEST['entry']}&show=$filename");
+       header("Location: album.php?entry=$maj_req_entry&show=$filename");
 }
 
-if ((!isset($_POST['caption']) or empty($_POST['caption'])) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "caption")) {
+if ((!isset($_POST['caption']) or empty($_POST['caption'])) and isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username) and isset($_POST['edit']) and ($_POST['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 (file_exists("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt")) {
+               unlink("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt");
        }
 }
 
-if (isset($_POST['caption']) and !empty($_POST['caption']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "caption")) {
+if (isset($_POST['caption']) and !empty($_POST['caption']) and isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username) and isset($_POST['edit']) and ($_POST['edit'] == "caption")) {
        $caption_put = ucfirst($_POST['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);
@@ -107,81 +92,29 @@ if (isset($_POST['caption']) and !empty($_POST['caption']) and isset($_SESSION['
        $caption_put = str_replace('<highlight>', '<span style="background-color: #ffff00;">', $caption_put);
        $caption_put = str_replace('</highlight>', '</span>', $caption_put);
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/album")) {
-               mkdir("data/items/{$_REQUEST['entry']}/album");
+       if (!file_exists("data/items/$maj_req_entry/album")) {
+               mkdir("data/items/$maj_req_entry/album");
        }
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/album/captions")) {
-               mkdir("data/items/{$_REQUEST['entry']}/album/captions");
+       if (!file_exists("data/items/$maj_req_entry/album/captions")) {
+               mkdir("data/items/$maj_req_entry/album/captions");
        }
 
-       $open_caption_txt_file = fopen("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt","w");
+       $open_caption_txt_file = fopen("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt","w");
        fwrite($open_caption_txt_file,$caption_put);
        fclose($open_caption_txt_file);
 }
 
-echo "<title>{$_REQUEST['show']}</title>";
-
-?>
-
-<style>
-
-body {
-       color: #666666;
-       margin: 10px;
-       padding: 0px;
-       text-align: left;
-       font-family: <?php
-                               if (file_exists("data/fonts/body.txt")) {
-                                       $font_body = file_get_contents("data/fonts/body.txt");
-                                       echo "{$font_body},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       background-color: #FFFFFF;
-}
-
-p,td {
-       font-size: 11px;
-}
-
-a {
-       font-weight: bold;
-       text-decoration: none;
-}
+include("css.php");
 
-a:link, a:visited {
-       color: #666666;
-}
+echo "\n<style>body { margin: {$maj_wspace}px; } .input, .click { width: 100%; }</style>\n";
 
-a:hover {
-       color: #336699;
-}
-
-a:active {
-       color: #336699;
-}
+echo "\n<title>$maj_req_show</title>\n";
 
-.input {      
-       color: #666666;
-       background: #FFFFFF;
-       border: #999999 solid 1px;
-       width: 100%;
-       font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-}
-</style>
-
-<?php
-
-if (file_exists("images/{$_REQUEST['entry']}/album")) {
-       if ($dh_album = opendir("images/{$_REQUEST['entry']}/album")) {
+if (file_exists("images/$maj_req_entry/album")) {
+       if ($dh_album = opendir("images/$maj_req_entry/album")) {
                while (($entry_album = readdir($dh_album)) !== false) {
-                       if ($entry_album != "." && $entry_album != ".." && fnmatch("*", $entry_album)) {
+                       if ($entry_album != "." && $entry_album != "..") {
                                $sort_album[] = $entry_album;
                        }
                }
@@ -192,7 +125,7 @@ if (file_exists("images/{$_REQUEST['entry']}/album")) {
        reset($sort_album);
 }
 
-$key_view = array_search($_REQUEST['show'],$sort_album);
+$key_view = array_search($maj_req_show,$sort_album);
 
 $key_prev = $key_view - 1;
 $key_next = $key_view + 1;
@@ -204,48 +137,46 @@ $count_album_entry = count($sort_album);
 
 $album_image_colspan = 4;
 
-// echo "$count_album_entry -> $key_prev | $key_view | $key_next";
-
-if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
+if (file_exists("images/$maj_req_entry/album/$maj_req_show")) {
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/album/views")) {
-               mkdir("data/items/{$_REQUEST['entry']}/album/views");
+       if (!file_exists("data/items/$maj_req_entry/album/views")) {
+               mkdir("data/items/$maj_req_entry/album/views");
        }
 
-       if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
-               $fp_image_views_txt = fopen("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","r");
-               $image_views_value = fread($fp_image_views_txt,filesize("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt"));
+       if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
+               $fp_image_views_txt = fopen("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt","r");
+               $image_views_value = fread($fp_image_views_txt,filesize("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt"));
                fclose($fp_image_views_txt);
                $image_views_value = $image_views_value + 1;
-               $fp_image_views_txt = fopen("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","w");
+               $fp_image_views_txt = fopen("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt","w");
                fwrite($fp_image_views_txt, $image_views_value);
                fclose($fp_image_views_txt);
        }
 
-       echo "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" bgcolor=\"#ffffff\"><tr><td valign=\"top\">";
+       echo "\n<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\"><tr><td valign=\"top\">";
 
-       echo "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" bgcolor=\"#cccccc\"><tr bgcolor=\"#ffffff\">";
+       echo "\n<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" bgcolor=\"#cccccc\"><tr bgcolor=\"#ffffff\">";
 
        if ($key_prev >= 0) {
 
                $album_image_colspan = $album_image_colspan + 1;
       
-               echo "<td align=\"left\" width=\"11\"><a href=\"album.php?entry={$_REQUEST['entry']}&show=$show_prev\"><img src=\"images/widget.back.png\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
+               echo "<td align=\"left\" width=\"11\"><a href=\"album.php?entry=$maj_req_entry&show=$show_prev\"><img src=\"images/widget.back.png\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
        }
 
-       echo "<td align=\"center\"><b>{$_REQUEST['show']}</b></td><td align=\"center\">";
+       echo "<td align=\"center\"><b>$maj_req_show</b></td><td align=\"center\">";
 
-       $album_image_size = getimagesize("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}",$album_image_info);
+       $album_image_size = getimagesize("images/$maj_req_entry/album/$maj_req_show",$album_image_info);
        $album_image_width = $album_image_size[0];
        $album_image_height = $album_image_size[1];
 
        echo "$album_image_width x $album_image_height pixels";
 
-       $size = filesize("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
+       $size = filesize("images/$maj_req_entry/album/$maj_req_show");
        $size_string = ($size > 512)?(  ($size/1024 > 512)  ?sprintf("%.02f MB",($size/1024)/1024)  :sprintf("%.02f KB",$size/1024))  :sprintf("%d B",$size);
        echo "</td><td align=\"center\">$size_string</td><td align=\"center\">";
 
-       $album_image_views = file_get_contents("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt");
+       $album_image_views = file_get_contents("data/items/$maj_req_entry/album/views/{$maj_req_show}.txt");
        echo "$album_image_views view";
 
        if ($album_image_views > 1) {
@@ -258,37 +189,37 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
 
                $album_image_colspan = $album_image_colspan + 1;
 
-               echo "<td align=\"right\" width=\"11\"><a href=\"album.php?entry={$_REQUEST['entry']}&show=$show_next\"><img src=\"images/widget.move.png\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
+               echo "<td align=\"right\" width=\"11\"><a href=\"album.php?entry=$maj_req_entry&show=$show_next\"><img src=\"images/widget.move.png\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
        }
 
        echo "</tr>";
 
        echo "<tr bgcolor=\"#ffffff\"><td colspan=\"$album_image_colspan\" align=\"center\">";
-       echo "<img src=images/{$_REQUEST['entry']}/album/{$_REQUEST['show']} width=$album_image_width height=$album_image_height border=0>";
+       echo "<img src=images/$maj_req_entry/album/$maj_req_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)) {
+       if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username)) {
                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=entry value=$maj_req_entry>";
+               echo "<input type=hidden name=show value=$maj_req_show>";
                echo "<input type=hidden name=next value=$show_next>";
                echo "<input type=hidden name=edit value=delete>";             
-               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=submit class=input value=\"click here to delete image\"></td></tr>";
+               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=submit class=click 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=entry value=$maj_req_entry>";
+               echo "<input type=hidden name=show value=$maj_req_show>";
                echo "<input type=hidden name=edit value=rename>";
-               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=text autocomplete=off class=input name=filename value={$_REQUEST['show']}></td></tr>";
-               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=submit class=input value=\"click here to rename image\"></td></tr>";
+               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=text autocomplete=off class=input name=filename value=$maj_req_show></td></tr>";
+               echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\"><input type=submit class=click 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=entry value=$maj_req_entry>";
+               echo "<input type=hidden name=show value=$maj_req_show>";
                echo "<input type=hidden name=edit value=caption>";
                echo "<tr bgcolor=#ffffff><td colspan=\"$album_image_colspan\">";
                echo "<textarea class=input name=caption rows=3 autofocus required>";
-               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");
+               if (file_exists("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt")) {
+                       $caption_get = file_get_contents("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt");
                        $caption_get = str_replace('<br />', "\n", $caption_get);
                        $caption_get = str_replace('<img src="images/smileys/crying.png" border="0">', ':((', $caption_get);
                        $caption_get = str_replace('<img src="images/smileys/frown.png" border="0">', ':(', $caption_get);
@@ -305,13 +236,13 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
                        echo $caption_get;
                }
                echo "</textarea>";
-               echo "<input type=submit class=input value=\"click here to update caption\">";
+               echo "<input type=submit class=click 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")) {
+       if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
+               if (file_exists("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt")) {
                        echo "<tr bgcolor=\"#ffffff\"><td colspan=\"$album_image_colspan\" width=\"$album_image_width\">";
-                       $caption_get = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
+                       $caption_get = file_get_contents("data/items/$maj_req_entry/album/captions/{$maj_req_show}.txt");
                        echo $caption_get;
                        echo "</td></tr>";
                }
@@ -335,7 +266,7 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
        //      }
        //}
 
-       $album_image_exif = exif_read_data("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}", 0, true);
+       $album_image_exif = exif_read_data("images/$maj_req_entry/album/$maj_req_show", 0, true);
       
        foreach ($album_image_exif as $album_image_exif_key => $album_image_exif_section) {
               
@@ -352,13 +283,13 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
        echo "</td></tr></table>";
       
       
-       if (file_exists("data/fb.txt") and file_exists("data/items/{$_REQUEST['entry']}/fb.txt")) {
+       if (file_exists("data/fb.txt") and file_exists("data/items/$maj_req_entry/fb.txt")) {
       
                if (isset($_SERVER['HTTPS'])) {
-                       $entry_url = "https://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), "/\\") . "/album.php?entry={$_REQUEST['entry']}&show={$_REQUEST['show']}";
+                       $entry_url = "https://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), "/\\") . "/album.php?entry=$maj_req_entry&show=$maj_req_show";
                }
                else {
-                       $entry_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), "/\\") . "/album.php?entry={$_REQUEST['entry']}&show={$_REQUEST['show']}";
+                       $entry_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), "/\\") . "/album.php?entry=$maj_req_entry&show=$maj_req_show";
                }
 
                echo "<div style=\"margin: 4px;\"><div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script><fb:like href=\"$entry_url\" send=\"false\" width=\"$album_image_width\" show_faces=\"true\" font=\"\"></fb:like></div>";
@@ -369,13 +300,13 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
 
        echo "<table cellspacing=1 cellpadding=2 border=0 bgcolor=#cccccc><tr bgcolor=#ffffff><td width=100%><p><b>Album</b></p></td></tr><tr bgcolor=#ffffff><td width=100%>";
 
-       if (file_exists("images/{$_REQUEST['entry']}/thumbnails")) {
-               if ($dh_album = opendir("images/{$_REQUEST['entry']}/thumbnails")) {
+       if (file_exists("images/$maj_req_entry/thumbnails")) {
+               if ($dh_album = opendir("images/$maj_req_entry/thumbnails")) {
                        while (($thumbnail_album = readdir($dh_album)) !== false) {
                                if ($thumbnail_album != "." && $thumbnail_album != ".." && fnmatch("*",$thumbnail_album)) {
-                                       $current_thumbnail = "images/{$_REQUEST['entry']}/thumbnails/$thumbnail_album";
+                                       $current_thumbnail = "images/$maj_req_entry/thumbnails/$thumbnail_album";
                                        $parent_image = str_replace("-thumbnail.jpg","",$thumbnail_album);
-                                       $parent_image = "images/{$_REQUEST['entry']}/album/$parent_image";
+                                       $parent_image = "images/$maj_req_entry/album/$parent_image";
                                        if (file_exists($current_thumbnail) and !file_exists($parent_image)) {
                                                unlink($current_thumbnail);
                                        }
@@ -385,12 +316,12 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
        }
       
        if ($count_album_entry < 1) {
-               rmdirr("images/{$_REQUEST['entry']}/album");
-               rmdirr("images/{$_REQUEST['entry']}/thumbnails");                              
+               rmdirr("images/$maj_req_entry/album");
+               rmdirr("images/$maj_req_entry/thumbnails");                            
        }
        else {
                foreach($sort_album as $album_entry) {
-                       $current_image = "images/{$_REQUEST['entry']}/album/$album_entry";
+                       $current_image = "images/$maj_req_entry/album/$album_entry";
                        $current_image_size = getimagesize($current_image);
                        $current_width = $current_image_size[0];
                        $current_height = $current_image_size[1];
@@ -414,7 +345,7 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
                                $new_height = $current_height;
                        }
 
-                       if (!file_exists("images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg")) {
+                       if (!file_exists("images/$maj_req_entry/thumbnails/{$album_entry}-thumbnail.jpg")) {
       
                                $work_thumb = imagecreatetruecolor($new_width,$new_height);
                                $get_mimetype = image_type_to_mime_type(exif_imagetype($current_image));
@@ -434,28 +365,28 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
       
                                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");
+                               if (!file_exists("images/$maj_req_entry/thumbnails")) {
+                                       mkdir("images/$maj_req_entry/thumbnails");
                                }
       
-                               imagejpeg($work_thumb,"images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg",80);
+                               imagejpeg($work_thumb,"images/$maj_req_entry/thumbnails/{$album_entry}-thumbnail.jpg",80);
 
                                imagedestroy($work_thumb);
                                imagedestroy($work_image);
                        }
 
-                       echo "<a href=\"album.php?entry={$_REQUEST['entry']}&show=$album_entry\">";
+                       echo "<a href=\"album.php?entry=$maj_req_entry&show=$album_entry\">";
 
-                       if (!file_exists("images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg")) {
-                               echo "<img src=\"images/{$_REQUEST['entry']}/album/$album_entry\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
+                       if (!file_exists("images/$maj_req_entry/thumbnails/{$album_entry}-thumbnail.jpg")) {
+                               echo "<img src=\"images/$maj_req_entry/album/$album_entry\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
                        }
                        else {
-                               echo "<img src=\"images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
+                               echo "<img src=\"images/$maj_req_entry/thumbnails/{$album_entry}-thumbnail.jpg\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
                        }
 
-                       if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$album_entry}.txt")) {
+                       if (file_exists("data/items/$maj_req_entry/album/captions/{$album_entry}.txt")) {
                                echo ' alt="';
-                               $img_alt = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$album_entry}.txt");
+                               $img_alt = file_get_contents("data/items/$maj_req_entry/album/captions/{$album_entry}.txt");
                                $img_alt = strip_tags($img_alt);
                                echo $img_alt;
                                echo '"';
@@ -464,17 +395,17 @@ if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
                }
        }      
 
-       echo "</td></tr><form method=post action=index.php?entry={$_REQUEST['entry']}&show=album><tr bgcolor=#ffffff><td><input class=input type=submit value=\"click here to go to the main entry\"></td></tr></form><form method=post action=index.php><tr bgcolor=#ffffff><td><input class=input type=submit value=\"click here to go to the index page\"></td></tr></form></table>";
+       echo "</td></tr><form method=post action=index.php?entry=$maj_req_entry&show=album><tr bgcolor=#ffffff><td><input class=click type=submit value=\"click here to go to the main entry\"></td></tr></form><form method=post action=index.php><tr bgcolor=#ffffff><td><input class=click type=submit value=\"click here to go to the index page\"></td></tr></form></table>";
 
        echo "</td></tr></table>";
 }
 
 if ($key_prev >= 0) {
-       echo "\n\n<script>\n\tvar img_prev = new Image();\n\timg_prev.src = \"images/{$_REQUEST['entry']}/album/$show_prev\";\n</script>";
+       echo "\n\n<script>\n\tvar img_prev = new Image();\n\timg_prev.src = \"images/$maj_req_entry/album/$show_prev\";\n</script>";
 }
 
 if ($key_next < $count_album_entry) {
-       echo "\n\n<script>\n\tvar img_next = new Image();\n\timg_next.src = \"images/{$_REQUEST['entry']}/album/$show_next\";\n</script>";
+       echo "\n\n<script>\n\tvar img_next = new Image();\n\timg_next.src = \"images/$maj_req_entry/album/$show_next\";\n</script>";
 }
 
 ?>
diff --git a/cat.php b/cat.php
index 979ea7d..73ed1c4 100644
--- a/cat.php
+++ b/cat.php
@@ -1,47 +1,35 @@
 <?php
 
-session_start();
-
-header("Cache-control: private");
-
-error_reporting(E_ERROR);
-
 require("core.php");
 
-if (isset($_SESSION['logged_in']) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
-       header("Location: login.php");
-}
-
-$login_username = file_get_contents("data/username.txt");
-
-if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
+if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
        exit();
 }
 
-if (file_exists("data/items")) {
+if (file_exists("$maj_data_directory/items")) {
 
-       if ($dh_cat_txt = opendir("data/items")) {
+       if ($dh_cat_txt = opendir("$maj_data_directory/items")) {
 
                while (($entry_cat_txt = readdir($dh_cat_txt)) !== false) {
 
                        if ($entry_cat_txt != "." && $entry_cat_txt != "..") {
 
-                               if (file_exists("data/items/$entry_cat_txt/category.txt")) {
+                               if (file_exists("$maj_data_directory/items/$entry_cat_txt/category.txt")) {
 
-                                       $category_txt = file_get_contents("data/items/$entry_cat_txt/category.txt");
-                                       $category_txt = strtolower($category_txt);
+                                       $category_txt = file_get_contents("$maj_data_directory/items/$entry_cat_txt/category.txt");
+                                       $category_txt = mb_strtolower($category_txt);
                                        $category_txt = str_replace(" ","_",$category_txt);
                                        $category_txt = trim($category_txt);
 
-                                       if (!file_exists("data/items/$entry_cat_txt/categories")) {
-                                               mkdir("data/items/$entry_cat_txt/categories");
+                                       if (!file_exists("$maj_data_directory/items/$entry_cat_txt/categories")) {
+                                               mkdir("$maj_data_directory/items/$entry_cat_txt/categories");
                                        }
 
-                                       if (!file_exists("data/items/$entry_cat_txt/categories/$category_txt")) {
-                                               mkdir("data/items/$entry_cat_txt/categories/$category_txt");
+                                       if (!file_exists("$maj_data_directory/items/$entry_cat_txt/categories/$category_txt")) {
+                                               mkdir("$maj_data_directory/items/$entry_cat_txt/categories/$category_txt");
                                        }
 
-                                       unlink("data/items/$entry_cat_txt/category.txt");
+                                       unlink("$maj_data_directory/items/$entry_cat_txt/category.txt");
                                }
                        }
                }
@@ -51,19 +39,19 @@ if (file_exists("data/items")) {
 
 if (isset($_POST['new_id']) and !empty($_POST['new_id'])) {
 
-       if (!file_exists("data/categories")) {
-               mkdir("data/categories");
+       if (!file_exists("$maj_data_directory/categories")) {
+               mkdir("$maj_data_directory/categories");
        }
 
-       $new_id = trim(strip_tags(strtolower(str_replace(" ", "_", $_POST['new_id']))));
+       $new_id = trim(strip_tags(mb_strtolower(str_replace(" ", "_", $_POST['new_id']))));
 
-       if (!file_exists("data/categories/$new_id")) {
-               mkdir("data/categories/$new_id");
+       if (!file_exists("$maj_data_directory/categories/$new_id")) {
+               mkdir("$maj_data_directory/categories/$new_id");
        }
 
        if (isset($_POST['new_title']) and !empty($_POST['new_title'])) {
                $new_title = ucfirst(strip_tags(trim($_POST['new_title'])));
-               $open_title_file = fopen("data/categories/$new_id/title.txt","w");
+               $open_title_file = fopen("$maj_data_directory/categories/$new_id/title.txt","w");
                fwrite($open_title_file,$new_title);
                fclose($open_title_file);
        }
@@ -71,18 +59,18 @@ if (isset($_POST['new_id']) and !empty($_POST['new_id'])) {
 
 if (isset($_POST['cat_del']) and !empty($_POST['cat_del']) and ($_POST['cat_del'] == "on")) {
 
-       rmdirr("data/categories/{$_POST['cat_id']}");
+       rmdirr("$maj_data_directory/categories/{$_POST['cat_id']}");
 
-       if (file_exists("data/items")) {
+       if (file_exists("$maj_data_directory/items")) {
       
-               if ($dh_cat_del = opendir("data/items")) {
+               if ($dh_cat_del = opendir("$maj_data_directory/items")) {
       
                        while (($entry_cat_del = readdir($dh_cat_del)) !== false) {
       
                                if ($entry_cat_del != "." && $entry_cat_del != "..") {
       
-                                       if (file_exists("data/items/$entry_cat_del/categories/{$_POST['cat_id']}")) {
-                                               rmdirr("data/items/$entry_cat_del/categories/{$_POST['cat_id']}");
+                                       if (file_exists("$maj_data_directory/items/$entry_cat_del/categories/{$_POST['cat_id']}")) {
+                                               rmdirr("$maj_data_directory/items/$entry_cat_del/categories/{$_POST['cat_id']}");
                                        }
                                }
                        }
@@ -92,29 +80,29 @@ if (isset($_POST['cat_del']) and !empty($_POST['cat_del']) and ($_POST['cat_del'
 }
 
 if ((!isset($_POST['cat_hide']) or !empty($_POST['cat_hide'])) and ($_POST['cat_edit'] == "on")) {
-       if (file_exists("data/categories/{$_POST['cat_id']}/private.txt")) {
-               unlink("data/categories/{$_POST['cat_id']}/private.txt");
+       if (file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/private.txt")) {
+               unlink("$maj_data_directory/categories/{$_POST['cat_id']}/private.txt");
        }
 }
 
 if (isset($_POST['cat_hide']) and !empty($_POST['cat_hide']) and ($_POST['cat_hide'] == "on")) {
-       if (file_exists("data/categories/{$_POST['cat_id']}/members")) {
-               rmdirr("data/categories/{$_POST['cat_id']}/members");
+       if (file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/members")) {
+               rmdirr("$maj_data_directory/categories/{$_POST['cat_id']}/members");
        }
-       if (!file_exists("data/categories/{$_POST['cat_id']}/private.txt")) {
-               touch("data/categories/{$_POST['cat_id']}/private.txt");
+       if (!file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/private.txt")) {
+               touch("$maj_data_directory/categories/{$_POST['cat_id']}/private.txt");
        }
 }
 
 if ((!isset($_POST['cat_book']) or !empty($_POST['cat_book'])) and ($_POST['cat_edit'] == "on")) {
-       if (file_exists("data/categories/{$_POST['cat_id']}/book.txt")) {
-               unlink("data/categories/{$_POST['cat_id']}/book.txt");
+       if (file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/book.txt")) {
+               unlink("$maj_data_directory/categories/{$_POST['cat_id']}/book.txt");
        }
 }
 
 if (isset($_POST['cat_book']) and !empty($_POST['cat_book']) and ($_POST['cat_book'] == "on")) {
-       if (!file_exists("data/categories/{$_POST['cat_id']}/book.txt")) {
-               touch("data/categories/{$_POST['cat_id']}/book.txt");
+       if (!file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/book.txt")) {
+               touch("$maj_data_directory/categories/{$_POST['cat_id']}/book.txt");
        }
 }
 
@@ -122,42 +110,42 @@ if (isset($_POST['cat_title']) and !empty($_POST['cat_title'])) {
 
        $cat_title = ucfirst(strip_tags(trim($_POST['cat_title'])));
 
-       if ($cat_title != file_get_contents("data/categories/{$_POST['cat_id']}/title.txt")) {
-               $edit_title_file = fopen("data/categories/{$_POST['cat_id']}/title.txt","w");
+       if ($cat_title != file_get_contents("$maj_data_directory/categories/{$_POST['cat_id']}/title.txt")) {
+               $edit_title_file = fopen("$maj_data_directory/categories/{$_POST['cat_id']}/title.txt","w");
                fwrite($edit_title_file,$cat_title);
                fclose($edit_title_file);
        }
 }
 
-if (empty($_POST['cat_title']) and file_exists("data/categories/{$_POST['cat_id']}/title.txt")) {
-       unlink("data/categories/{$_POST['cat_id']}/title.txt");
+if (empty($_POST['cat_title']) and file_exists("$maj_data_directory/categories/{$_POST['cat_id']}/title.txt")) {
+       unlink("$maj_data_directory/categories/{$_POST['cat_id']}/title.txt");
 }
 
 if (isset($_POST['cat_ren']) and !empty($_POST['cat_ren'])) {
 
-       $cat_rename = strtolower($_POST['cat_ren']);
+       $cat_rename = mb_strtolower($_POST['cat_ren']);
        $cat_rename = str_replace(" ","_",$cat_rename);
        $cat_rename = trim($cat_rename);
 
-       $cat_oldname = strtolower($_POST['cat_id']);
+       $cat_oldname = mb_strtolower($_POST['cat_id']);
        $cat_oldname = str_replace(" ","_",$cat_oldname);
        $cat_oldname = trim($cat_oldname);
 
-       if (($cat_rename != $cat_oldname) and !file_exists("data/categories/$cat_rename")) {
-               rename("data/categories/$cat_oldname","data/categories/$cat_rename");
+       if (($cat_rename != $cat_oldname) and !file_exists("$maj_data_directory/categories/$cat_rename")) {
+               rename("$maj_data_directory/categories/$cat_oldname","$maj_data_directory/categories/$cat_rename");
        }
 
 
-       if (file_exists("data/items")) {
+       if (file_exists("$maj_data_directory/items")) {
       
-               if ($dh_cat_ren = opendir("data/items")) {
+               if ($dh_cat_ren = opendir("$maj_data_directory/items")) {
       
                        while (($entry_cat_ren = readdir($dh_cat_ren)) !== false) {
       
                                if ($entry_cat_ren != "." && $entry_cat_ren != "..") {
       
-                                       if (file_exists("data/items/$entry_cat_ren/categories/$cat_oldname") and !file_exists("data/items/$entry_cat_ren/categories/$cat_rename")) {
-                                               rename("data/items/$entry_cat_ren/categories/$cat_oldname","data/items/$entry_cat_ren/categories/$cat_rename");
+                                       if (file_exists("$maj_data_directory/items/$entry_cat_ren/categories/$cat_oldname") and !file_exists("$maj_data_directory/items/$entry_cat_ren/categories/$cat_rename")) {
+                                               rename("$maj_data_directory/items/$entry_cat_ren/categories/$cat_oldname","$maj_data_directory/items/$entry_cat_ren/categories/$cat_rename");
                                        }
                                }
                        }
@@ -166,90 +154,13 @@ if (isset($_POST['cat_ren']) and !empty($_POST['cat_ren'])) {
        }
 }
 
-?>
-
-<title>Categories</title>
-
-<style>
-
-body {
-       color: #666666;
-       margin: 10px;
-       padding: 0px;
-       text-align: left;
-       font-family: <?php
-                               if (file_exists("data/fonts/body.txt")) {
-                                       $font_body = file_get_contents("data/fonts/body.txt");
-                                       echo "{$font_body},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-       background-color: #FFFFFF;
-}
-
-p, td {
-       font-size: 11px;
-}
-
-a {
-       font-weight: bold;
-       text-decoration: none;
-}
-
-a:link, a:visited {
-       color: #666666;
-}
-
-a:hover {
-       color: #336699;
-}
+include("css.php");
 
-a:active {
-       color: #336699;
-}
+echo "\n<style>body { margin: {$maj_wspace}px; }</style>\n";
 
-.input {      
-       color: #666666;
-       background: #ffffff;
-       border: #999999 solid 1px;
-       width: 300px;
-       font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-}
-
-.id {  
-       color: #666666;
-       background: #ffffff;
-       border: #999999 solid 1px;
-       width: 150px;
-       font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-}
+?>
 
-.submit {      
-       color: #666666;
-       background: #ffffff;
-       border: #999999 solid 1px;
-       width: 100px;
-       font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px
-}
-</style>
+<title>Categories</title>
 
 <p><b>Add Category</b><br>Enter a unique category ID and optional title or description.</p>
 
@@ -257,16 +168,16 @@ a:active {
 <form enctype="multipart/form-data" action="cat.php" method="post">
 <tr><td>category id*</td><td><input type="text" class="input" name="new_id" autocomplete="off" maxlength="30" autofocus required></td></tr>
 <tr><td>title or description</td><td><input type="text" class="input" name="new_title" autocomplete="off" maxlength="90"></td></tr>
-<tr><td></td><td><input type="submit" class="input" value="click here to add a new category"></td></tr>
+<tr><td></td><td><input type="submit" class="click" value="click here to add a new category"></td></tr>
 </form>
 <form enctype="multipart/form-data" action="index.php" method="post">
-<tr><td></td><td><input class="input" type="submit" value="click here to go to the index page"></td></tr>
+<tr><td></td><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
 </form>
 </table>
 
 <?php
-       if (file_exists("data/categories")) {
-               if ($dh_cat = opendir("data/categories")) {
+       if (file_exists("$maj_data_directory/categories")) {
+               if ($dh_cat = opendir("$maj_data_directory/categories")) {
                        while (($entry_cat = readdir($dh_cat)) !== false) {
 
                                if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
@@ -286,7 +197,7 @@ a:active {
 
                        echo "<br>Booking a category, for lack of a better term, will unconditionally display all associated entries from ";
                       
-                       if (!file_exists("data/old.txt")) {
+                       if (!file_exists("$maj_data_directory/old.txt")) {
                               
                                echo "oldest to newest";
                        }
@@ -303,13 +214,13 @@ a:active {
 
                        foreach ($show_cat as $category) {
                                echo "<form enctype=\"multipart/form-data\" action=\"cat.php\" method=\"post\">";
-                               echo "<tr><td><input type=\"text\" class=\"id\" name=\"cat_ren\" value=\"$category\" maxlength=\"30\" autocomplete=\"off\" required></td>";
+                               echo "<tr><td><input type=\"text\" class=\"input\" style=\"width: 200px;\" name=\"cat_ren\" value=\"$category\" maxlength=\"30\" autocomplete=\"off\" required></td>";
                                echo "<td><input type=\"text\" class=\"input\" name=\"cat_title\" value=\"";
-                               readfile("data/categories/$category/title.txt");
+                               readfile("$maj_data_directory/categories/$category/title.txt");
                                echo "\" autocomplete=\"off\" maxlength=\"90\"></td>";
                                echo "<td align=\"center\"><input type=\"checkbox\" name=\"cat_hide\"";
 
-                               if (file_exists("data/categories/$category/private.txt")) {
+                               if (file_exists("$maj_data_directory/categories/$category/private.txt")) {
                                        echo " checked";
                                }
 
@@ -317,13 +228,13 @@ a:active {
 
                                echo "<td align=\"center\"><input type=\"checkbox\" name=\"cat_book\"";
 
-                               if (file_exists("data/categories/$category/book.txt")) {
+                               if (file_exists("$maj_data_directory/categories/$category/book.txt")) {
                                        echo " checked";
                                }
                                echo "></td>";
 
                                echo "<td align=\"center\"><input type=\"checkbox\" name=\"cat_del\"></td>";
-                               echo "<td><input type=\"hidden\" name=\"cat_id\" value=\"$category\"><input type=\"hidden\" name=\"cat_edit\" value=\"on\"><input type=\"submit\" class=\"submit\" value=\"submit\"></td>";
+                               echo "<td><input type=\"hidden\" name=\"cat_id\" value=\"$category\"><input type=\"hidden\" name=\"cat_edit\" value=\"on\"><input type=\"submit\" class=\"click\" style=\"width: 100px;\" value=\"submit\"></td>";
                                echo "</tr></form>";
                        }
                        echo "</table>";
diff --git a/colors.php b/colors.php
index 60e3e09..11314c3 100644
--- a/colors.php
+++ b/colors.php
@@ -59,10 +59,10 @@ if (isset($_POST['target']) and !empty($_POST['target']) and (!isset($_POST['col
 if (isset($_POST['target']) and !empty($_POST['target']) and isset($_POST['color']) and !empty($_POST['color'])) {
 
        $color_value = str_replace("%23", "#", $_POST['color']);
-       $color_value = strtolower($color_value);
+       $color_value = mb_strtolower($color_value);
        $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) or ((strlen($color_value) == 7) and strstr($color_value,"#"))) {
+       if (in_array($color_value, $valid_colors) or ((mb_strlen($color_value) == 7) and strstr($color_value,"#"))) {
                $color_file = str_replace("_", "-", $_POST['target']);
                $color_file = "data/colors/{$color_file}.txt";
                $color_txt = fopen($color_file,"w");
@@ -72,7 +72,7 @@ if (isset($_POST['target']) and !empty($_POST['target']) and isset($_POST['color
 }
 
 if (isset($_POST['id']) and !empty($_POST['id']) and !file_exists("data/schemes/colors/{$_POST['id']}")) {
-       $id = strtolower($_POST['id']);
+       $id = mb_strtolower($_POST['id']);
        $id = trim($id);
        $id = str_replace(" ","_",$id);
 
@@ -161,7 +161,7 @@ if (isset($_POST['id']) and !empty($_POST['id']) and !file_exists("data/schemes/
 
 if (isset($_POST['scheme']) and !empty($_POST['scheme'])) {
 
-       $scheme = strtolower($_POST['scheme']);
+       $scheme = mb_strtolower($_POST['scheme']);
        $scheme = trim($scheme);
        $scheme = str_replace(" ","_",$scheme);
 
@@ -469,7 +469,7 @@ if (isset($_FILES['upload']) and !empty($_FILES['upload']) and @function_exists(
                                mkdir("data/schemes/tmp");
                        }
 
-                       $package_name = strtolower($_FILES['upload']['name']);
+                       $package_name = mb_strtolower($_FILES['upload']['name']);
                        $package_name = str_replace(".zip","",$package_name);
 
                        if (!file_exists("data/schemes/colors/$package_name")) {
diff --git a/core.php b/core.php
index b9d6f18..b98f415 100644
--- a/core.php
+++ b/core.php
@@ -1,6 +1,24 @@
 <?php
 
+header('Content-Type: text/html; charset=UTF-8');
+header('Cache-Control: private');
+
+ini_set("session.use_trans_sid","0");
+ini_set("mbstring.language","Neutral");
+ini_set("mbstring.internal_encoding","UTF-8");
+ini_set("mbstring.encoding_translation","On");
+ini_set("mbstring.http_input","auto");
+ini_set("mbstring.http_output","UTF-8");
+ini_set("mbstring.detect_order","auto");
+ini_set("mbstring.substitute_character","none");
+ini_set("default_charset","UTF-8");
+
+error_reporting(E_ERROR);
+
+session_start();
+
 $maj_data_directory = "data";
+$maj_image_directory = "images";
 
 $maj_default_title = file_get_contents("$maj_data_directory/title.txt");
 $maj_admin_username = file_get_contents("$maj_data_directory/username.txt");
@@ -42,14 +60,14 @@ if (isset($_REQUEST['show']) and !empty($_REQUEST['show'])) {
 if (isset($_REQUEST['find']) and !empty($_REQUEST['find'])) {
        $maj_req_find = trim($_REQUEST['find']);
        $maj_req_find = str_replace(" ","-",$maj_req_find);
-       $maj_req_find = strtolower($maj_req_find);
+       $maj_req_find = mb_strtolower($maj_req_find);
        $maj_req_find = strip_tags($maj_req_find);
 }
 
 if (isset($_REQUEST['category']) and !empty($_REQUEST['category'])) {
        $maj_req_category = trim($_REQUEST['category']);
        $maj_req_category = str_replace(" ","-",$maj_req_category);
-       $maj_req_category = strtolower($maj_req_category);
+       $maj_req_category = mb_strtolower($maj_req_category);
        $maj_req_category = strip_tags($maj_req_category);
 }
 
@@ -60,7 +78,7 @@ if (isset($_REQUEST['archive']) and !empty($_REQUEST['archive'])) {
 if (isset($_REQUEST['author']) and !empty($_REQUEST['author'])) {
        $maj_req_author = trim($_REQUEST['author']);
        $maj_req_author = str_replace(" ","-",$maj_req_author);
-       $maj_req_author = strtolower($maj_req_author);
+       $maj_req_author = mb_strtolower($maj_req_author);
        $maj_req_author = strip_tags($maj_req_author);
 }
 
@@ -97,8 +115,8 @@ $maj_default_password = "php";
 $maj_default_blog_profile = 'This cool site is powered by My Activity Journal (<a href="http://majcms.org/" target="_maj">MAJ</a>), a simple <a href="http://php.net/" target="_maj">PHP</a>-based, <a href="http://opensource.org/" target="_maj">Open Source</a> content management system (CMS) that can be deployed as a blog, bulletin board (Internet forum or message board), and wiki.';
 $maj_default_blog_author = "My Activity Journal";
 
-if (!file_exists("data")) {
-       mkdir("data");
+if (!file_exists($maj_data_directory)) {
+       mkdir($maj_data_directory);
 }
 
 if (!file_exists("$maj_data_directory/.htaccess")) {
@@ -144,7 +162,7 @@ if (!file_exists("$maj_data_directory/author.txt")) {
 function str_rand($length = 8,$seeds = 'abcdefghijklmnopqrstuvwxyz0123456789') {
 
        $str = '';
-       $count = strlen($seeds);
+       $count = mb_strlen($seeds);
 
        list($usec,$sec) = explode(' ',microtime());
 
@@ -186,7 +204,7 @@ function rmdirr($dir) {
 function return_bytes($val) {
       
        $val = trim($val);
-       $last = $val{strlen($val) - 1};
+       $last = $val{mb_strlen($val) - 1};
       
        switch ($last) {
                case 'k':
@@ -218,28 +236,28 @@ if ($server_post_max_size > $server_memory_limit) {
   
 function entry2date($entry) {
 
-       $year = substr($entry, 0, 4);
-       $month = substr($entry, 4, 2);
-       $day = substr($entry, 6, 2);
-       $hour = substr($entry, 8, 2);
-       $min = substr($entry, 10, 2);
-       $sec = substr($entry, 12, 2);
+       $year = mb_substr($entry, 0, 4);
+       $month = mb_substr($entry, 4, 2);
+       $day = mb_substr($entry, 6, 2);
+       $hour = mb_substr($entry, 8, 2);
+       $min = mb_substr($entry, 10, 2);
+       $sec = mb_substr($entry, 12, 2);
       
        echo date("l, M j, Y, g:i A", mktime($hour, $min, $sec, $month, $day, $year));
 }
 
 function reformat_html($data) {
 
-       $store_0 = split("<html>", $data);
+       $store_0 = mb_split("<html>", $data);
        $data = "";
        $data .= $store_0[0];
       
        foreach ($store_0 as $item_0 => $ref_0) {
           
-               if (eregi("</html>", $ref_0)) {
+               if (mb_eregi("</html>", $ref_0)) {
               
-                       $store_1 = split("</html>", $ref_0);
-                       $store_1[0] = eregi_replace("\n", "", $store_1[0]);
+                       $store_1 = mb_split("</html>", $ref_0);
+                       $store_1[0] = mb_eregi_replace("\n", "", $store_1[0]);
               
                        foreach ($store_1 as $item_1 => $ref_1) {
                   
@@ -255,26 +273,28 @@ function reformat_html($data) {
 
 function reformat_code($data) {
 
-       $store_0 = split("<code>", $data);
+       global $maj_image_directory;
+
+       $store_0 = mb_split("<code>", $data);
        $data = "";
        $data .= $store_0[0];
       
        foreach ($store_0 as $item_0 => $ref_0) {
           
-               if (eregi("</code>", $ref_0)) {
-
-                       $store_1 = split("</code>", $ref_0);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/crying.png" border="0">', ':((', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/frown.png" border="0">', ':(', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/indifferent.png" border="0">', ':|', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/laughing.png" border="0">', ':D', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/lick.png" border="0">', ':P', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/ohno.png" border="0">', ':O', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/smile.png" border="0">', ':)', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/surprised.png" border="0">', '=)', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/undecided.png" border="0">', ':\\', $store_1[0]);
-                       $store_1[0] = eregi_replace('<img src="images/smileys/wink.png" border="0">', ';)', $store_1[0]);
-                       $store_1[0] = htmlentities($store_1[0], ENT_NOQUOTES);
+               if (mb_eregi("</code>", $ref_0)) {
+
+                       $store_1 = mb_split("</code>", $ref_0);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/crying.png\" border=\"0\">", ':((', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/frown.png\" border=\"0\">", ':(', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/indifferent.png\" border=\"0\">", ':|', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/laughing.png\" border=\"0\">", ':D', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/lick.png\" border=\"0\">", ':P', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/ohno.png\" border=\"0\">", ':O', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/smile.png\" border=\"0\">", ':)', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/surprised.png\" border=\"0\">", '=)', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/undecided.png\" border=\"0\">", ':\\', $store_1[0]);
+                       $store_1[0] = mb_eregi_replace("<img src=\"$maj_image_directory/smileys/wink.png\" border=\"0\">", ';)', $store_1[0]);
+                       $store_1[0] = htmlentities($store_1[0], ENT_QUOTES, 'UTF-8');
               
                        foreach ($store_1 as $item_1 => $ref_1) {
 
@@ -313,21 +333,23 @@ function format_title_put($data) {
 }
   
 function format_body_put($data) {
+
+       global $maj_image_directory;
       
        $data = ucfirst($data);
        $data = str_replace("[html]", '<html>', $data);
        $data = str_replace("[/html]", '</html>', $data);
        $data = reformat_html($data);
-       $data = str_replace(':((', '<img src="images/smileys/crying.png" border="0">', $data);
-       $data = str_replace(':(', '<img src="images/smileys/frown.png" border="0">', $data);
-       $data = str_replace(':|', '<img src="images/smileys/indifferent.png" border="0">', $data);
-       $data = str_replace(':D', '<img src="images/smileys/laughing.png" border="0">', $data);
-       $data = str_replace(':P', '<img src="images/smileys/lick.png" border="0">', $data);
-       $data = str_replace(':O', '<img src="images/smileys/ohno.png" border="0">', $data);
-       $data = str_replace(':)', '<img src="images/smileys/smile.png" border="0">', $data);
-       $data = str_replace('=)', '<img src="images/smileys/surprised.png" border="0">', $data);
-       $data = str_replace(':\\', '<img src="images/smileys/undecided.png" border="0">', $data);
-       $data = str_replace(';)', '<img src="images/smileys/wink.png" border="0">', $data);
+       $data = str_replace(':((', "<img src=\"$maj_image_directory/smileys/crying.png\" border=\"0\">", $data);
+       $data = str_replace(':(', "<img src=\"$maj_image_directory/smileys/frown.png\" border=\"0\">", $data);
+       $data = str_replace(':|', "<img src=\"$maj_image_directory/smileys/indifferent.png\" border=\"0\">", $data);
+       $data = str_replace(':D', "<img src=\"$maj_image_directory/smileys/laughing.png\" border=\"0\">", $data);
+       $data = str_replace(':P', "<img src=\"$maj_image_directory/smileys/lick.png\" border=\"0\">", $data);
+       $data = str_replace(':O', "<img src=\"$maj_image_directory/smileys/ohno.png\" border=\"0\">", $data);
+       $data = str_replace(':)', "<img src=\"$maj_image_directory/smileys/smile.png\" border=\"0\">", $data);
+       $data = str_replace('=)', "<img src=\"$maj_image_directory/smileys/surprised.png\" border=\"0\">", $data);
+       $data = str_replace(':\\', "<img src=\"$maj_image_directory/smileys/undecided.png\" border=\"0\">", $data);
+       $data = str_replace(';)', "<img src=\"$maj_image_directory/smileys/wink.png\" border=\"0\">", $data);
        $data = str_replace('[code]', '<code>', $data);
        $data = str_replace('[/code]', '</code>', $data);
        $data = reformat_code($data);
@@ -353,17 +375,19 @@ function format_body_put($data) {
        return $data;
 }
 
-function show_maj_avatar_image($author_username,$max_img_width=80) {
+function maj_avatar_image($author_username,$max_img_width=80) {
 
        global $maj_admin_username;
+       global $maj_data_directory;
+       global $maj_image_directory;
 
        echo "<a href=\"member.php?id=$author_username\">";
 
-       if (($maj_admin_username == $author_username) and (file_exists("images/avatar.jpg") or file_exists("images/avatar.gif") or file_exists("images/avatar.png"))) {
+       if (($maj_admin_username == $author_username) and (file_exists("$maj_image_directory/avatar.jpg") or file_exists("$maj_image_directory/avatar.gif") or file_exists("$maj_image_directory/avatar.png"))) {
 
-               if (file_exists("images/avatar.gif")) {
+               if (file_exists("$maj_image_directory/avatar.gif")) {
 
-                       $avatar_gif_image_size = getimagesize("images/avatar.gif");
+                       $avatar_gif_image_size = getimagesize("$maj_image_directory/avatar.gif");
                        $avatar_gif_image_width = $avatar_gif_image_size[0];
                        $avatar_gif_image_height = $avatar_gif_image_size[1];
 
@@ -380,7 +404,7 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                        imagealphablending($avatar_gif_image_resize, false);
                                        imagesavealpha($avatar_gif_image_resize, true);
 
-                                       $avatar_gif_image_original = imagecreatefromgif("images/avatar.gif");
+                                       $avatar_gif_image_original = imagecreatefromgif("$maj_image_directory/avatar.gif");
                                        $avatar_gif_transparent_index = imagecolortransparent($avatar_gif_image_original);
 
                                        if ($avatar_gif_transparent_index >= 0) {
@@ -394,20 +418,20 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
 
                                        imagecopyresampled($avatar_gif_image_resize,$avatar_gif_image_original,0,0,0,0,$avatar_gif_image_width,$avatar_gif_image_height,$avatar_gif_image_size[0],$avatar_gif_image_size[1]);
 
-                                       unlink("images/avatar.gif");
+                                       unlink("$maj_image_directory/avatar.gif");
 
-                                       imagegif($avatar_gif_image_resize,"images/avatar.gif",100);
+                                       imagegif($avatar_gif_image_resize,"$maj_image_directory/avatar.gif",100);
 
                                        imagedestroy($avatar_gif_image_resize);
                                        imagedestroy($avatar_gif_image_original);
                                }
                        }
-                       echo "<img src=\"images/avatar.gif\" border=\"0\" width=\"$avatar_gif_image_width\" height=\"$avatar_gif_image_height\">";
+                       echo "<img src=\"$maj_image_directory/avatar.gif\" border=\"0\" width=\"$avatar_gif_image_width\" height=\"$avatar_gif_image_height\">";
                }
 
-               if (file_exists("images/avatar.jpg")) {
+               if (file_exists("$maj_image_directory/avatar.jpg")) {
 
-                       $avatar_jpg_image_size = getimagesize("images/avatar.jpg");
+                       $avatar_jpg_image_size = getimagesize("$maj_image_directory/avatar.jpg");
                        $avatar_jpg_image_width = $avatar_jpg_image_size[0];
                        $avatar_jpg_image_height = $avatar_jpg_image_size[1];
                       
@@ -420,24 +444,24 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                if (file_exists("$maj_data_directory/avatar-resize-jpg.txt")) {
 
                                        $avatar_jpg_image_resize = imagecreatetruecolor($avatar_jpg_image_width,$avatar_jpg_image_height);
-                                       $avatar_jpg_image_original = imagecreatefromjpeg("images/avatar.jpg");
+                                       $avatar_jpg_image_original = imagecreatefromjpeg("$maj_image_directory/avatar.jpg");
 
                                        imagecopyresampled($avatar_jpg_image_resize,$avatar_jpg_image_original,0,0,0,0,$avatar_jpg_image_width,$avatar_jpg_image_height,$avatar_jpg_image_size[0],$avatar_jpg_image_size[1]);
 
-                                       unlink("images/avatar.jpg");
+                                       unlink("$maj_image_directory/avatar.jpg");
 
-                                       imagejpeg($avatar_jpg_image_resize,"images/avatar.jpg",100);
+                                       imagejpeg($avatar_jpg_image_resize,"$maj_image_directory/avatar.jpg",100);
 
                                        imagedestroy($avatar_jpg_image_resize);
                                        imagedestroy($avatar_jpg_image_original);
                                }
                        }
-                       echo "<img src=\"images/avatar.jpg\" border=\"0\" width=\"$avatar_jpg_image_width\" height=\"$avatar_jpg_image_height\">";
+                       echo "<img src=\"$maj_image_directory/avatar.jpg\" border=\"0\" width=\"$avatar_jpg_image_width\" height=\"$avatar_jpg_image_height\">";
                }
 
-               if (file_exists("images/avatar.png")) {
+               if (file_exists("$maj_image_directory/avatar.png")) {
 
-                       $avatar_png_image_size = getimagesize("images/avatar.png");
+                       $avatar_png_image_size = getimagesize("$maj_image_directory/avatar.png");
                        $avatar_png_image_width = $avatar_png_image_size[0];
                        $avatar_png_image_height = $avatar_png_image_size[1];
                       
@@ -454,27 +478,27 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                        imagealphablending($avatar_png_image_resize, false);
                                        imagesavealpha($avatar_png_image_resize, true);
 
-                                       $avatar_png_image_original = imagecreatefrompng("images/avatar.png");
+                                       $avatar_png_image_original = imagecreatefrompng("$maj_image_directory/avatar.png");
 
                                        imagecopyresampled($avatar_png_image_resize,$avatar_png_image_original,0,0,0,0,$avatar_png_image_width,$avatar_png_image_height,$avatar_png_image_size[0],$avatar_png_image_size[1]);
 
-                                       unlink("images/avatar.png");
+                                       unlink("$maj_image_directory/avatar.png");
 
-                                       imagepng($avatar_png_image_resize,"images/avatar.png",100);
+                                       imagepng($avatar_png_image_resize,"$maj_image_directory/avatar.png",100);
 
                                        imagedestroy($avatar_png_image_resize);
                                        imagedestroy($avatar_png_image_original);
                                }
                        }
-                       echo "<img src=\"images/avatar.png\" border=\"0\" width=\"$avatar_png_image_width\" height=\"$avatar_png_image_height\">";
+                       echo "<img src=\"$maj_image_directory/avatar.png\" border=\"0\" width=\"$avatar_png_image_width\" height=\"$avatar_png_image_height\">";
                }
                echo "<br>";
        }
-       elseif (file_exists("images/members/$author_username/avatar.jpg") or file_exists("images/members/$author_username/avatar.gif") or file_exists("images/members/$author_username/avatar.png")) {
+       elseif (file_exists("$maj_image_directory/members/$author_username/avatar.jpg") or file_exists("$maj_image_directory/members/$author_username/avatar.gif") or file_exists("$maj_image_directory/members/$author_username/avatar.png")) {
 
-               if (file_exists("images/members/$author_username/avatar.gif")) {
+               if (file_exists("$maj_image_directory/members/$author_username/avatar.gif")) {
 
-                       $avatar_gif_image_size = getimagesize("images/members/$author_username/avatar.gif");
+                       $avatar_gif_image_size = getimagesize("$maj_image_directory/members/$author_username/avatar.gif");
                        $avatar_gif_image_width = $avatar_gif_image_size[0];
                        $avatar_gif_image_height = $avatar_gif_image_size[1];
 
@@ -491,7 +515,7 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                        imagealphablending($avatar_gif_image_resize, false);
                                        imagesavealpha($avatar_gif_image_resize, true);
 
-                                       $avatar_gif_image_original = imagecreatefromgif("images/members/$author_username/avatar.gif");
+                                       $avatar_gif_image_original = imagecreatefromgif("$maj_image_directory/members/$author_username/avatar.gif");
                                        $avatar_gif_transparent_index = imagecolortransparent($avatar_gif_image_original);
 
                                        if ($avatar_gif_transparent_index >= 0) {
@@ -505,20 +529,20 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
 
                                        imagecopyresampled($avatar_gif_image_resize,$avatar_gif_image_original,0,0,0,0,$avatar_gif_image_width,$avatar_gif_image_height,$avatar_gif_image_size[0],$avatar_gif_image_size[1]);
 
-                                       unlink("images/members/$author_username/avatar.gif");
+                                       unlink("$maj_image_directory/members/$author_username/avatar.gif");
 
-                                       imagegif($avatar_gif_image_resize,"images/members/$author_username/avatar.gif",100);
+                                       imagegif($avatar_gif_image_resize,"$maj_image_directory/members/$author_username/avatar.gif",100);
 
                                        imagedestroy($avatar_gif_image_resize);
                                        imagedestroy($avatar_gif_image_original);
                                }
                        }
-                       echo "<img src=\"images/members/$author_username/avatar.gif\" border=\"0\" width=\"$avatar_gif_image_width\" height=\"$avatar_gif_image_height\">";
+                       echo "<img src=\"$maj_image_directory/members/$author_username/avatar.gif\" border=\"0\" width=\"$avatar_gif_image_width\" height=\"$avatar_gif_image_height\">";
                }
 
-               if (file_exists("images/members/$author_username/avatar.jpg")) {
+               if (file_exists("$maj_image_directory/members/$author_username/avatar.jpg")) {
 
-                       $avatar_jpg_image_size = getimagesize("images/members/$author_username/avatar.jpg");
+                       $avatar_jpg_image_size = getimagesize("$maj_image_directory/members/$author_username/avatar.jpg");
                        $avatar_jpg_image_width = $avatar_jpg_image_size[0];
                        $avatar_jpg_image_height = $avatar_jpg_image_size[1];
                       
@@ -531,24 +555,24 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                if (file_exists("$maj_data_directory/avatar-resize-jpg.txt")) {
 
                                        $avatar_jpg_image_resize = imagecreatetruecolor($avatar_jpg_image_width,$avatar_jpg_image_height);
-                                       $avatar_jpg_image_original = imagecreatefromjpeg("images/members/$author_username/avatar.jpg");
+                                       $avatar_jpg_image_original = imagecreatefromjpeg("$maj_image_directory/members/$author_username/avatar.jpg");
 
                                        imagecopyresampled($avatar_jpg_image_resize,$avatar_jpg_image_original,0,0,0,0,$avatar_jpg_image_width,$avatar_jpg_image_height,$avatar_jpg_image_size[0],$avatar_jpg_image_size[1]);
 
-                                       unlink("images/members/$author_username/avatar.jpg");
+                                       unlink("$maj_image_directory/members/$author_username/avatar.jpg");
 
-                                       imagejpeg($avatar_jpg_image_resize,"images/members/$author_username/avatar.jpg",100);
+                                       imagejpeg($avatar_jpg_image_resize,"$maj_image_directory/members/$author_username/avatar.jpg",100);
 
                                        imagedestroy($avatar_jpg_image_resize);
                                        imagedestroy($avatar_jpg_image_original);
                                }
                        }
-                       echo "<img src=\"images/members/$author_username/avatar.jpg\" border=\"0\" width=\"$avatar_jpg_image_width\" height=\"$avatar_jpg_image_height\">";
+                       echo "<img src=\"$maj_image_directory/members/$author_username/avatar.jpg\" border=\"0\" width=\"$avatar_jpg_image_width\" height=\"$avatar_jpg_image_height\">";
                }
 
-               if (file_exists("images/members/$author_username/avatar.png")) {
+               if (file_exists("$maj_image_directory/members/$author_username/avatar.png")) {
 
-                       $avatar_png_image_size = getimagesize("images/members/$author_username/avatar.png");
+                       $avatar_png_image_size = getimagesize("$maj_image_directory/members/$author_username/avatar.png");
                        $avatar_png_image_width = $avatar_png_image_size[0];
                        $avatar_png_image_height = $avatar_png_image_size[1];
                       
@@ -564,19 +588,19 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
                                        imagealphablending($avatar_png_image_resize, false);
                                        imagesavealpha($avatar_png_image_resize, true);
 
-                                       $avatar_png_image_original = imagecreatefrompng("images/members/$author_username/avatar.png");
+                                       $avatar_png_image_original = imagecreatefrompng("$maj_image_directory/members/$author_username/avatar.png");
 
                                        imagecopyresampled($avatar_png_image_resize,$avatar_png_image_original,0,0,0,0,$avatar_png_image_width,$avatar_png_image_height,$avatar_png_image_size[0],$avatar_png_image_size[1]);
 
-                                       unlink("images/members/$author_username/avatar.png");
+                                       unlink("$maj_image_directory/members/$author_username/avatar.png");
 
-                                       imagepng($avatar_png_image_resize,"images/members/$author_username/avatar.png",100);
+                                       imagepng($avatar_png_image_resize,"$maj_image_directory/members/$author_username/avatar.png",100);
 
                                        imagedestroy($avatar_png_image_resize);
                                        imagedestroy($avatar_png_image_original);
                                }
                        }
-                       echo "<img src=\"images/members/$author_username/avatar.png\" border=\"0\" width=\"$avatar_png_image_width\" height=\"$avatar_png_image_height\">";
+                       echo "<img src=\"$maj_image_directory/members/$author_username/avatar.png\" border=\"0\" width=\"$avatar_png_image_width\" height=\"$avatar_png_image_height\">";
                }
                echo "<br>";
        }
@@ -595,4 +619,46 @@ function show_maj_avatar_image($author_username,$max_img_width=80) {
        }
 }
 
+function maj_download_file($file_name,$file_dir,$count_dir) {
+
+       $file_size = filesize("$file_dir/$file_name");
+
+       header("Cache-Control: ");
+       header("Pragma: ");
+       header("Content-Type: application/octet-stream");
+       header("Content-Disposition: attachment; filename=$file_name");
+       header("Content-Length: $file_size");
+
+       $fp_file = fopen("$file_dir/$file_name","rb");
+
+       while (!feof($fp_file)) {
+               $file_buffer = fread($fp_file,4096);
+               echo $file_buffer;
+               $file_sent += strlen($file_buffer);
+               flush();
+       }
+
+       fclose($fp_file);
+
+       if (($file_sent == $file_size) and isset($count_dir)) {
+
+               if (!file_exists($count_dir)) {
+                       mkdir($count_dir,0700,true);
+               }
+
+               if (file_exists("$count_dir/{$file_name}.txt")) {
+                       $file_downloads = file_get_contents("$count_dir/{$file_name}.txt");
+               }
+               else {
+                       $file_downloads = "0";
+               }
+
+               $file_downloads = $file_downloads + 1;
+
+               $fp_downloads = fopen("$count_dir/{$file_name}.txt","w");
+               fwrite($fp_downloads,$file_downloads);
+               fclose($fp_downloads);
+       }
+}
+
 ?>
diff --git a/dig.php b/dig.php
index 90ca003..cb6d56d 100644
--- a/dig.php
+++ b/dig.php
@@ -1,24 +1,7 @@
 <?php
 
-session_start();
-
-header("Cache-control: private");
-
-error_reporting(E_ERROR);
-
 require("core.php");
 
-if (isset($_SESSION['logged_in']) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
-       header("Location: login.php");
-}
-
-if (file_exists("data/offset.txt")) {
-       $offset = file_get_contents("data/offset.txt");
-}
-else {
-       $offset = 0;
-}
-
 ?>
 
 <title>Dig!</title>
@@ -30,8 +13,8 @@ body {
        padding: 0px;
        text-align: left;
        font-family: <?php
-                               if (file_exists("data/fonts/body.txt")) {
-                                       $font_body = file_get_contents("data/fonts/body.txt");
+                               if (file_exists("$maj_data_directory/fonts/body.txt")) {
+                                       $font_body = file_get_contents("$maj_data_directory/fonts/body.txt");
                                        echo "{$font_body},";
                                }
        ?> arial, helvetica, sans-serif;
@@ -62,32 +45,25 @@ a:active {
 
 <?php
 
-$username_file = 'data/username.txt';
-$open_username_file = fopen($username_file,"r");
-$login_username = fread($open_username_file,filesize($username_file));
-fclose($open_username_file);
-
 if (!isset($_POST['search'])) {
        exit();
 }
 
 if (empty($_POST['search'])) {
-       echo "<p>Search string required. Click <a href=index.php>here</a> to go to the index page.</p>";
+       echo "<p>Search string required. Click <a href=\"index.php\">here</a> to go to the index page.</p>";
        exit();
 }
 
-$search = trim(strip_tags(strtolower($_POST['search'])));
+$search = trim(strip_tags(mb_strtolower($_POST['search'])));
 
 $google = str_replace(" ", "+", $search);
 
-if (strlen($search) < 3) {
-       echo "<p>Search string must be composed of 3 or more characters. Click <a href=index.php>here</a> to go to the index page.</p>";
+if (mb_strlen($search) < 3) {
+       echo "<p>Search string must be composed of 3 or more characters. Click <a href=\"index.php\">here</a> to go to the index page.</p>";
        exit();
 }
 
-$dir = "data/items";
-
-if (file_exists("data/bb.txt") and file_exists("data/members/active") and ($dh_search_members = opendir("data/members/active"))) {
+if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/members/active") and ($dh_search_members = opendir("$maj_data_directory/members/active"))) {
 
        $start_time_member = round(microtime(), 3);
 
@@ -97,7 +73,7 @@ if (file_exists("data/bb.txt") and file_exists("data/members/active") and ($dh_s
                        $total_members[] = $entry_search_members;
                }
 
-               if ($entry_search_members != "." && $entry_search_members != ".." && (preg_match("/\b$search\b/i", file_get_contents("data/members/active/$entry_search_members/firstname.txt")) or preg_match("/\b$search\b/i", file_get_contents("data/members/active/$entry_search_members/lastname.txt")) or preg_match("/\b$search\b/i", file_get_contents("data/members/active/$entry_search_members/rank.txt")) or ($search == $entry_search_members))) {
+               if ($entry_search_members != "." && $entry_search_members != ".." && (preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/firstname.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/lastname.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/rank.txt")) or ($search == $entry_search_members))) {
                        $show_search_members[] = $entry_search_members;
                }
        }
@@ -132,16 +108,16 @@ if (file_exists("data/bb.txt") and file_exists("data/members/active") and ($dh_s
 
                $search_ucfirst = ucfirst($search);
                $search_ucwords = ucwords($search);
-               $search_strtoupper = strtoupper($search);
+               $search_strtoupper = mb_strtoupper($search);
 
                foreach ($show_search_members as $match_member) {
-                       $match_member_firstname = file_get_contents("data/members/active/$match_member/firstname.txt");
+                       $match_member_firstname = file_get_contents("$maj_data_directory/members/active/$match_member/firstname.txt");
                        $match_member_firstname = str_replace($search, "<span style=\"background-color: #ffff00;\">$search</span>", $match_member_firstname);
                        $match_member_firstname = str_replace($search_ucfirst, "<span style=\"background-color: #ffff00;\">$search_ucfirst</span>", $match_member_firstname);
                        $match_member_firstname = str_replace($search_ucwords, "<span style=\"background-color: #ffff00;\">$search_ucwords</span>", $match_member_firstname);
                        $match_member_firstname = str_replace($search_strtoupper, "<span style=\"background-color: #ffff00;\">$search_strtoupper</span>", $match_member_firstname);
 
-                       $match_member_lastname = file_get_contents("data/members/active/$match_member/lastname.txt");
+                       $match_member_lastname = file_get_contents("$maj_data_directory/members/active/$match_member/lastname.txt");
                        $match_member_lastname = str_replace($search, "<span style=\"background-color: #ffff00;\">$search</span>", $match_member_lastname);
                        $match_member_lastname = str_replace($search_ucfirst, "<span style=\"background-color: #ffff00;\">$search_ucfirst</span>", $match_member_lastname);
                        $match_member_lastname = str_replace($search_ucwords, "<span style=\"background-color: #ffff00;\">$search_ucwords</span>", $match_member_lastname);
@@ -157,7 +133,7 @@ if (file_exists("data/bb.txt") and file_exists("data/members/active") and ($dh_s
        }
 }
 
-if ($dh_search_items = opendir($dir)) {
+if ($dh_search_items = opendir("$maj_data_directory/items")) {
 
        $start_time_item = round(microtime(), 3);
 
@@ -165,21 +141,21 @@ if ($dh_search_items = opendir($dir)) {
 
                $today = date("YmdHis", time() + $offset);
 
-               if (($entry_search_items > $today) and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
+               if (($entry_search_items > $today) and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
                        continue;
                }
 
                $private = "0";
 
-               if (file_exists("data/items/$entry_search_items/categories")) {
+               if (file_exists("$maj_data_directory/items/$entry_search_items/categories")) {
                       
-                       if ($dh_cat_dig = opendir("data/items/$entry_search_items/categories")) {
+                       if ($dh_cat_dig = opendir("$maj_data_directory/items/$entry_search_items/categories")) {
                       
                                while (($entry_cat_dig = readdir($dh_cat_dig)) !== false) {
                       
                                        if ($entry_cat_dig != "." && $entry_cat_dig != "..") {
                       
-                                               if (file_exists("data/categories/$entry_cat_dig/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
+                                               if (file_exists("$maj_data_directory/categories/$entry_cat_dig/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
                                                        $private = $private + 1;
                                                }
                                        }
@@ -188,19 +164,19 @@ if ($dh_search_items = opendir($dir)) {
                        }
                }
 
-               if (($private > 0) and !file_exists("data/items/$entry_search_items/cat.txt")) {
+               if (($private > 0) and !file_exists("$maj_data_directory/items/$entry_search_items/cat.txt")) {
                        continue;
                }
 
-               if (file_exists("data/items/$entry_search_items/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
+               if (file_exists("$maj_data_directory/items/$entry_search_items/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
                        continue;
                }
 
-               if (file_exists("data/items/$entry_search_items/passwd.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
+               if (file_exists("$maj_data_directory/items/$entry_search_items/passwd.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
                        continue;
                }
 
-               if (file_exists("data/items/$entry_search_items/member.txt") and !isset($_SESSION['logged_in'])) {
+               if (file_exists("$maj_data_directory/items/$entry_search_items/member.txt") and !isset($_SESSION['logged_in'])) {
                        continue;
                }
 
@@ -208,19 +184,19 @@ if ($dh_search_items = opendir($dir)) {
                        $total_entries[] = $entry_search_items;
                }
 
-               if ($entry_search_items != "." && $entry_search_items != ".." && (preg_match("/\b$search\b/i", file_get_contents("data/items/$entry_search_items/title.txt")) or preg_match("/\b$search\b/i", file_get_contents("data/items/$entry_search_items/body.txt")))) {
+               if ($entry_search_items != "." && $entry_search_items != ".." && (preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/title.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/body.txt")))) {
                        $show_search_items[] = $entry_search_items;
                }
 
-               if ($entry_search_items != "." && $entry_search_items != ".." && file_exists("data/items/$entry_search_items/comments/live")) {
-                       if ($dh_comment_items = opendir("data/items/$entry_search_items/comments/live")) {
+               if ($entry_search_items != "." && $entry_search_items != ".." && file_exists("$maj_data_directory/items/$entry_search_items/comments/live")) {
+                       if ($dh_comment_items = opendir("$maj_data_directory/items/$entry_search_items/comments/live")) {
                                while (($entry_comment_items = readdir($dh_comment_items)) !== false) {
 
                                        if ($entry_comment_items != "." && $entry_comment_items != "..") {
                                                $total_comments[] = $entry_comment_items;
                                        }
 
-                                       if ($entry_comment_items != "." && $entry_comment_items != ".." && preg_match("/\b$search\b/i", file_get_contents("data/items/$entry_search_items/comments/live/$entry_comment_items/comment.txt"))) {
+                                       if ($entry_comment_items != "." && $entry_comment_items != ".." && preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/comments/live/$entry_comment_items/comment.txt"))) {
                                                $show_search_items[] = $entry_search_items;
                                        }
                                }
@@ -284,27 +260,27 @@ if (($count_search_items > 0) and ($count_total_items > 0)) {
 
                echo "<p><a href=$link";
 
-               if (file_exists("data/items/$show_search_items[$increment_search_entries]/comments/live") and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/title.txt")) and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/body.txt"))) {
+               if (file_exists("$maj_data_directory/items/$show_search_items[$increment_search_entries]/comments/live") and !preg_match("/\b$search\b/i",file_get_contents("$maj_data_directory/items/$show_search_items[$increment_search_entries]/title.txt")) and !preg_match("/\b$search\b/i",file_get_contents("$maj_data_directory/items/$show_search_items[$increment_search_entries]/body.txt"))) {
                        echo "&show=comments";
                }
 
                echo ">";
-               readfile("data/items/$show_search_items[$increment_search_entries]/title.txt");
+               readfile("$maj_data_directory/items/$show_search_items[$increment_search_entries]/title.txt");
                echo "</a><br>";
-               readfile("data/items/$show_search_items[$increment_search_entries]/date.txt");
+               readfile("$maj_data_directory/items/$show_search_items[$increment_search_entries]/date.txt");
                echo "<br>";
 
-               $body = file_get_contents("data/items/$show_search_items[$increment_search_entries]/body.txt");
+               $body = file_get_contents("$maj_data_directory/items/$show_search_items[$increment_search_entries]/body.txt");
                $body = strip_tags($body);
                $body = trim($body);
                // comment out next line for _long_ quote
                $body = str_replace(".","<br />", $body);
 
-               if (file_exists("data/pf.txt") and file_exists("data/pf-badwords.txt")) {
-                       $badwords = file_get_contents("data/pf-badwords.txt");
+               if (file_exists("$maj_data_directory/pf.txt") and file_exists("$maj_data_directory/pf-badwords.txt")) {
+                       $badwords = file_get_contents("$maj_data_directory/pf-badwords.txt");
 
-                       if (file_exists("data/pf-censor.txt")) {
-                               $censor = file_get_contents("data/pf-censor.txt");
+                       if (file_exists("$maj_data_directory/pf-censor.txt")) {
+                               $censor = file_get_contents("$maj_data_directory/pf-censor.txt");
                        }
                        else {
                                $censor = "[expletive]";
@@ -320,7 +296,7 @@ if (($count_search_items > 0) and ($count_total_items > 0)) {
                                $ucfirst_line = ucfirst($search);
                                $line = str_replace($ucfirst_line, "<span style=\"background-color: #ffff00;\">$ucfirst_line</span>", $line);
 
-                               $strtoupper_line = strtoupper($search);
+                               $strtoupper_line = mb_strtoupper($search);
                                $line = str_replace($strtoupper_line, "<span style=\"background-color: #ffff00;\">$strtoupper_line</span>", $line);
 
                                $ucwords_line = ucwords($search);
@@ -332,7 +308,7 @@ if (($count_search_items > 0) and ($count_total_items > 0)) {
 
                echo str_replace("http://","",$link);
 
-               $size = filesize("data/items/$show_search_items[$increment_search_entries]/body.txt");
+               $size = filesize("$maj_data_directory/items/$show_search_items[$increment_search_entries]/body.txt");
                $size_string = ($size > 512)?(  ($size/1024 > 512)  ?sprintf("%.02f MB",($size/1024)/1024)  :sprintf("%.02f KB",$size/1024))  :sprintf("%d B",$size);
                echo " - $size_string";
                echo "</p>";
diff --git a/edit.php b/edit.php
index 4d2745f..04e47fd 100644
--- a/edit.php
+++ b/edit.php
@@ -1,9 +1,4 @@
 <?php
-  session_start();
-  
-  header("Cache-control: private");
-  
-  error_reporting(E_ERROR);
   
   require("core.php");
   
@@ -46,17 +41,15 @@
   $date_file = "$maj_data_directory/items/$maj_req_entry/date.txt";
   $img_file = "$maj_data_directory/items/$maj_req_entry/image.txt";
   $revisions_file = "$maj_data_directory/items/$maj_req_entry/revisions.txt";
-  
-?>
-
-<title>Edit</title>
-
-<?php
 
   include("css.php");
   
+  echo "\n<style>body { margin: {$maj_wspace}px; } .input, .click { width: 520px; }</style>\n";
+    
 ?>
 
+<title>Edit</title>
+
 <?php
   if (isset($_POST['auth_member']) and !empty($_POST['auth_member']) and isset($_POST['auth_toggle']) and !empty($_POST['auth_toggle'])) {
       if (($_POST['auth_toggle'] == "ack") and file_exists("$maj_data_directory/members/active/{$_POST['auth_member']}")) {
@@ -186,7 +179,7 @@
           exit();
       }
 ?>
-  <table border="0" cellspacing="0" cellpadding="0" bgcolor="#cccccc"><tr><td width="520">
+  <table border="0" cellspacing="0" cellpadding="0"><tr><td width="520">
   <div class="panel_title"><?php
       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/firstname.txt");
 ?>&nbsp;<?php
@@ -195,19 +188,29 @@
       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/email.txt");
 ?>&gt;</div>
   <div class="panel_body"><?php
+  
+  echo "<font style=\"font-size: $maj_font_Spx; color: #999999;\">";
+
+  if (file_exists("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/author.txt")) {
+      readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/author.txt");
+      echo " - ";
+  }
+  
+  entry2date($_REQUEST['comment']);
+  
+  if (file_exists($revisions_file)) {
+      echo ' (Revision ';
+      readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/revisions.txt");
+      echo " - ";
+      echo date("l, M j, Y, g:i A", filemtime("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt"));
+      echo ')';
+  }
+
+  echo "</font><div style=\"height: {$maj_wspace}px;\"></div>";  
+
       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt");
 ?></div>
-  <div class="panel_footer"><font style="font-size: 10px; color: #999999;">
-  <?php
-      entry2date($_REQUEST['comment']);
-      
-      if (file_exists("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/revisions.txt")) {
-          echo " (Revision ";
-          readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/revisions.txt");
-          echo ")";
-      }
-?>
-  </font></div>
+
   </td></tr></table>
 
   <table border="0" cellspacing="2" cellpadding="0">
@@ -241,17 +244,17 @@
   <tr><td><input type="hidden" name="type" value="<?php
       echo $_REQUEST['type'];
 ?>"></td></tr>
-  <tr><td><input class="click" style="width: 520px;" type="submit" value="click here to update this comment"></td></tr>
+  <tr><td><input class="click" type="submit" value="click here to update this comment"></td></tr>
   </form>
 
   <form enctype="multipart/form-data" action="index.php?entry=<?php
       echo $maj_req_entry;
 ?>&show=comments" method="post">
-  <tr><td><input class="click" style="width: 520px;" type="submit" value="click here to view posted entry"></td></tr>
+  <tr><td><input class="click" type="submit" value="click here to view posted entry"></td></tr>
   </form>
 
   <form enctype="multipart/form-data" action="index.php" method="post">
-  <tr><td><input class="click" style="width: 520px;" type="submit" value="click here to go to the index page"></td></tr>
+  <tr><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
   </form>
   </table>
 
@@ -262,12 +265,6 @@
 
 <table border="0" cellspacing="0" cellpadding="0">
 
-<tr>
-<td rowspan="2" width="<?php echo $maj_wspace; ?>"><div style="width: <?php echo $maj_wspace; ?>px;"></div></td>
-<td colspan="3" height="<?php echo $maj_wspace; ?>"><div style="height: <?php echo $maj_wspace; ?>px;"></div></td>
-<td rowspan="2" width="<?php echo $maj_wspace; ?>"><div style="width: <?php echo $maj_wspace; ?>px;"></div></td>
-</tr>
-
 <tr><td valign="top">
 
 <table border="0" cellspacing="0" cellpadding="0"><tr><td width="520">
@@ -304,7 +301,7 @@
 
 <form enctype="multipart/form-data" action="edit.php" method="post">
 
-<table border="0" cellspacing="2" cellpadding="0" bgcolor="#ffffff">
+<table border="0" cellspacing="2" cellpadding="0">
 
 <?php
   if (($maj_logged_in_username == $maj_admin_username) or (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-ul.txt") and file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-rw.txt"))) {
@@ -322,8 +319,8 @@
       echo($max_file_size / (1024 * 1024));
 ?>MB.</td></tr>
 
-<tr><td><input autocomplete="off" type="file" name="album_image_input"> Upload optional album image.</td></tr>
-<tr><td><input autocomplete="off" type="text" name="caption" class="input"> Enter optional album image caption.</td></tr>
+<tr><td><input autocomplete="off" type="file" name="album_image_input"> Upload optional album image. Enter optional caption below.</td></tr>
+<tr><td><input autocomplete="off" type="text" name="caption" class="input"></td></tr>
 <tr><td><input type="hidden" name="max_file_size" value="<?php
       echo $max_file_size;
 ?>"></td></tr>
@@ -518,8 +515,8 @@ if (file_exists("images/$maj_req_entry/album")) {
 <table border="0" cellspacing="0" cellpadding="0"><tr><td>
 
 <table border="0" cellspacing="2" cellpadding="0">
-<tr><td><input required autocomplete="off" class="input" style="width: 520px; font-size: <?php echo $maj_font_Lpx; ?>; font-weight: bold;" type="text" name="title_input" value="<?php readfile($title_file); ?>"></td></tr>
-<tr><td><textarea class="input" style="width: 520px; font-size: <?php echo $maj_font_Mpx; ?>;" name="body_input" rows="15" required>
+<tr><td><input required autocomplete="off" class="input" style="font-size: <?php echo $maj_font_Lpx; ?>; font-weight: bold;" type="text" name="title_input" value="<?php readfile($title_file); ?>"></td></tr>
+<tr><td><textarea class="input" style="font-size: <?php echo $maj_font_Mpx; ?>;" name="body_input" rows="15" required>
 <?php
   $open_body_file = fopen($body_file, "r");
   $read_body_file = fread($open_body_file, filesize($body_file));
@@ -544,15 +541,15 @@ if (file_exists("images/$maj_req_entry/album")) {
   echo $body_read_content;
 ?>
 </textarea></td></tr>
-<tr><td><input class="click" style="width: 520px;" type="submit" value="click here to update this entry"></td></tr>
+<tr><td><input class="click" type="submit" value="click here to update this entry"></td></tr>
 </form>
 
 <form enctype="multipart/form-data" action="index.php?entry=<?php echo $maj_req_entry; ?>" method="post">
-<tr><td><input class="click" style="width: 520px;" type="submit" value="click here to view posted entry"></td></tr>
+<tr><td><input class="click" type="submit" value="click here to view posted entry"></td></tr>
 </form>
 
 <form enctype="multipart/form-data" action="index.php" method="post">
-<tr><td><input class="click" style="width: 520px;" type="submit" value="click here to go to the index page"></td></tr>
+<tr><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
 </form>
 
 </table>
@@ -950,13 +947,7 @@ if (file_exists("images/$maj_req_entry/album")) {
               mkdir("$maj_data_directory/items/$maj_req_entry/wiki/delta");
           }
           
-          if (file_exists("$maj_data_directory/offset.txt")) {
-              $offset = file_get_contents("$maj_data_directory/offset.txt");
-          } else {
-              $offset = 0;
-          }
-          
-          $ddate = date("YmdHis", time() + $offset);
+          $ddate = date("YmdHis", time() + $maj_offset);
           
           if (!file_exists("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate")) {
               mkdir("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate");
@@ -1184,7 +1175,7 @@ if (file_exists("images/$maj_req_entry/album")) {
       
       $passwd_file = "$maj_data_directory/items/$maj_req_entry/passwd.txt";
       
-      if (isset($_POST['passwd']) and !empty($_POST['passwd']) and ($_POST['passwd'] != "password")) {
+      if (isset($_POST['passwd']) and !empty($_POST['passwd'])) {
           $fp_passwd_txt = fopen("$passwd_file", "w");
           $passwd_crypt = sha1($_POST['passwd']);
           $passwd_crypt = md5($passwd_crypt);
diff --git a/fonts.php b/fonts.php
index 164e36e..d5b4352 100644
--- a/fonts.php
+++ b/fonts.php
@@ -27,7 +27,7 @@ if (isset($_POST['reset']) and !empty($_POST['reset']) and ($_POST['reset'] == "
 }
 
 if (isset($_POST['body']) and !empty($_POST['body']) and (file_get_contents("data/fonts/body.txt") != $_POST['body'])) {
-       $body_write_content = strtolower($_POST['body']);
+       $body_write_content = mb_strtolower($_POST['body']);
        $body_write_content = trim($body_write_content);
        $body_write_content = str_replace(", ",",",$body_write_content);
        $body_write_content = str_replace(" ,",",",$body_write_content);
@@ -50,7 +50,7 @@ if (!isset($_POST['body']) or empty($_POST['body'])) {
 }
 
 if (isset($_POST['input']) and !empty($_POST['input']) and (file_get_contents("data/fonts/input.txt") != $_POST['input'])) {
-       $input_write_content = strtolower($_POST['input']);
+       $input_write_content = mb_strtolower($_POST['input']);
        $input_write_content = trim($input_write_content);
        $input_write_content = str_replace(", ",",",$input_write_content);
        $input_write_content = str_replace(" ,",",",$input_write_content);
@@ -73,7 +73,7 @@ if (!isset($_POST['input']) or empty($_POST['input'])) {
 }
 
 if (isset($_POST['panel_title']) and !empty($_POST['panel_title']) and (file_get_contents("data/fonts/panel-title.txt") != $_POST['panel_title'])) {
-       $panel_title_write_content = strtolower($_POST['panel_title']);
+       $panel_title_write_content = mb_strtolower($_POST['panel_title']);
        $panel_title_write_content = trim($panel_title_write_content);
        $panel_title_write_content = str_replace(", ",",",$panel_title_write_content);
        $panel_title_write_content = str_replace(" ,",",",$panel_title_write_content);
@@ -96,7 +96,7 @@ if (!isset($_POST['panel_title']) or empty($_POST['panel_title'])) {
 }
 
 if (isset($_POST['panel_body']) and !empty($_POST['panel_body']) and (file_get_contents("data/fonts/panel-body.txt") != $_POST['panel_body'])) {
-       $panel_body_write_content = strtolower($_POST['panel_body']);
+       $panel_body_write_content = mb_strtolower($_POST['panel_body']);
        $panel_body_write_content = trim($panel_body_write_content);
        $panel_body_write_content = str_replace(", ",",",$panel_body_write_content);
        $panel_body_write_content = str_replace(" ,",",",$panel_body_write_content);
@@ -119,7 +119,7 @@ if (!isset($_POST['panel_body']) or empty($_POST['panel_body'])) {
 }
 
 if (isset($_POST['panel_footer']) and !empty($_POST['panel_footer']) and (file_get_contents("data/fonts/panel-footer.txt") != $_POST['panel_footer'])) {
-       $panel_footer_write_content = strtolower($_POST['panel_footer']);
+       $panel_footer_write_content = mb_strtolower($_POST['panel_footer']);
        $panel_footer_write_content = trim($panel_footer_write_content);
        $panel_footer_write_content = str_replace(", ",",",$panel_footer_write_content);
        $panel_footer_write_content = str_replace(" ,",",",$panel_footer_write_content);
diff --git a/function_unzip.php b/function_unzip.php
index c2105cb..30ebb20 100644
--- a/function_unzip.php
+++ b/function_unzip.php
@@ -45,7 +45,7 @@
     
         if ($destination_folder == '') die ('The path you specified is empty!');
     
-        if (substr($destination_folder, -1) != '/') {
+        if (mb_substr($destination_folder, -1) != '/') {
                                                           
             $destination_folder = $destination_folder .'/';
                                                           
@@ -66,9 +66,9 @@
                   
                       $to_create = $destination_folder . $new_path;
                       
-                          if (substr($to_create, -1) == '/') {
+                          if (mb_substr($to_create, -1) == '/') {
                           
-                            $to_create = substr($to_create, 0, strlen($to_create)-1);
+                            $to_create = mb_substr($to_create, 0, mb_strlen($to_create)-1);
                           
                           }
                       
diff --git a/index.php b/index.php
index af3bfa2..cf00288 100644
--- a/index.php
+++ b/index.php
@@ -1,13 +1,5 @@
 <?php
 
-ini_set("session.use_trans_sid","0");
-
-session_start();
-
-header("Cache-control: private");
-
-error_reporting(E_ERROR);
-
 require("core.php");
 
 if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
@@ -26,7 +18,7 @@ if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_us
        fclose($maj_global_hits_file);
 }
 
-if (@ereg("Google",$_SERVER['HTTP_USER_AGENT'])) {
+if (@mb_ereg("Google",$_SERVER['HTTP_USER_AGENT'])) {
 
        if (file_exists("$maj_data_directory/google.txt")) {
                $maj_google_hits_count = file_get_contents("$maj_data_directory/google.txt");
@@ -42,61 +34,21 @@ if (@ereg("Google",$_SERVER['HTTP_USER_AGENT'])) {
        fclose($maj_google_hits_file);
 }
 
-if (isset($_REQUEST['download']) and !empty($_REQUEST['download'])) {
-       ini_set("zlib.output_compression","off");
-       $maj_dl_file = str_replace("../","",@$_REQUEST['download']);
-       go_download($maj_dl_file);
-       die();
-}
-
-function go_download($maj_dl_file) {
-
-       $maj_req_entry = trim($_REQUEST['entry']);
-
-       if (isset($_REQUEST['type']) and !empty($_REQUEST['type']) and ($_REQUEST['type'] == "filedrop")) {
-               $maj_dl_path = "$maj_data_directory/items/$maj_req_entry/filedrop/files";
-               $maj_count_path = "$maj_data_directory/items/$maj_req_entry/filedrop/count";
-               $maj_count_file = "{$maj_dl_file}.txt";
-       }
-
-       $maj_dl_file_size = filesize("$maj_dl_path/$maj_dl_file");
-
-       header("Cache-Control: ");
-       header("Pragma: ");
-       header("Content-type: application/octet-stream");
-       header("Content-Disposition: attachment; filename=$maj_dl_file");
-       header("Content-length: $maj_dl_file_size");
-
-       $maj_get_it = fopen("$maj_dl_path/$maj_dl_file","rb");
+if (isset($_REQUEST['download']) and !empty($_REQUEST['download']) and isset($_REQUEST['type']) and !empty($_REQUEST['type'])) {
 
-       while (!feof($maj_get_it)) {
-               $maj_buf = fread($maj_get_it,4096);
-               echo $maj_buf;
-               $maj_bytes_sent += strlen($maj_buf);
-               flush();
-       }
-
-       fclose($maj_get_it);
-
-       if ($maj_bytes_sent == $maj_dl_file_size) {
-
-               if (!file_exists($maj_count_path)) {
-                       mkdir($maj_count_path);
-               }
+       ini_set("zlib.output_compression","off");
 
-               if (file_exists("$maj_count_path/$maj_count_file")) {
-                       $maj_count_unique_downloads = file_get_contents("$maj_count_path/$maj_count_file");
+       if (($_REQUEST['type'] == "filedrop") and isset($maj_req_entry) and file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/files")) {
+      
+               if ($maj_logged_in_username == $maj_admin_username) {
+                       maj_download_file(str_replace("../","",@$_REQUEST['download']),"$maj_data_directory/items/$maj_req_entry/filedrop/files");
                }
                else {
-                       $maj_count_unique_downloads = "0";
-               }
-
-               $maj_count_unique_downloads = $maj_count_unique_downloads + 1;
-
-               $maj_fp_unique_downloads = fopen("$maj_count_path/$maj_count_file","w");
-               fwrite($maj_fp_unique_downloads,$maj_count_unique_downloads);
-               fclose($maj_fp_unique_downloads);
+                       maj_download_file(str_replace("../","",@$_REQUEST['download']),"$maj_data_directory/items/$maj_req_entry/filedrop/files","$maj_data_directory/items/$maj_req_entry/filedrop/count");
+               }                      
        }
+      
+       die();
 }
 
 if (isset($maj_req_entry) and !empty($maj_req_entry) and isset($_REQUEST['comment']) and !empty($_REQUEST['comment']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and isset($_REQUEST['action']) and !empty($_REQUEST['action'])) {
@@ -289,14 +241,14 @@ if (isset($maj_req_entry) and !empty($maj_req_entry) and isset($_REQUEST['commen
                                                                $maj_ml_to = '"' . "$maj_ml_to_firstname $maj_ml_to_lastname" . '" <'. $maj_ml_to . '>';
 
                                                                if (file_exists("$maj_data_directory/ml-reply2.txt")) {
-                                                                       mail($maj_ml_to,$maj_ml_subject,$maj_ml_body,
+                                                                       mb_send_mail($maj_ml_to,$maj_ml_subject,$maj_ml_body,
                                                                        "From: $maj_ml_from\r\n" .
                                                                        "Reply-To: $maj_ml_reply2\r\n" .
                                                                        "References: $maj_req_entry\r\n" .
                                                                        "X-Mailer: $maj_ml_mailer");
                                                                }
                                                                else {
-                                                                       mail($maj_ml_to,$maj_ml_subject,$maj_ml_body,
+                                                                       mb_send_mail($maj_ml_to,$maj_ml_subject,$maj_ml_body,
                                                                        "From: $maj_ml_from\r\n" .
                                                                        "References: $maj_req_entry\r\n" .
                                                                        "X-Mailer: $maj_ml_mailer");
@@ -356,7 +308,7 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        fclose($maj_fp_views);
                }
               
-               if (isset($maj_req_show) and !empty($maj_req_show) and isset($_POST['captcha_put']) and !empty($_REQUEST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['new_comment']) and !empty($_POST['new_comment']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_REQUEST['captcha_get'] == sha1($_POST['captcha_put'])) and (ereg("@",$_POST['email'])) and (ereg("\.",$_POST['email']))) {
+               if (isset($maj_req_show) and !empty($maj_req_show) and isset($_POST['captcha_put']) and !empty($_REQUEST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['new_comment']) and !empty($_POST['new_comment']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_REQUEST['captcha_get'] == sha1($_POST['captcha_put'])) and (mb_ereg("@",$_POST['email'])) and (mb_ereg("\.",$_POST['email']))) {
               
                        if (!file_exists("$maj_data_directory/items/$maj_req_entry/comments")) {
                                mkdir("$maj_data_directory/items/$maj_req_entry/comments");
@@ -377,7 +329,7 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        mkdir("$maj_data_directory/items/$maj_req_entry/comments/pending/$maj_comment_entry_dir");
       
                        $maj_body_content = ucfirst($_POST['new_comment']);
-                       $maj_body_content = htmlentities($maj_body_content,ENT_NOQUOTES);
+                       $maj_body_content = htmlentities($maj_body_content,ENT_QUOTES, 'UTF-8');
                        $maj_body_content = str_replace("\n",'<br />',$maj_body_content);
                        $maj_body_content = trim($maj_body_content);
                        $maj_body_content = str_replace(':((','<img src="images/smileys/crying.png" border="0">',$maj_body_content);
@@ -400,11 +352,11 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        fclose($maj_fp_timestamp_txt);
 
                        $maj_fp_firstname_txt = fopen("$maj_data_directory/items/$maj_req_entry/comments/pending/$maj_comment_entry_dir/firstname.txt","w");
-                       $maj_firstname = htmlentities($_POST['firstname'],ENT_NOQUOTES);
+                       $maj_firstname = htmlentities($_POST['firstname'],ENT_QUOTES, 'UTF-8');
                        $maj_firstname = trim($maj_firstname);
                       
                        if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
-                               $maj_firstname = strtolower($maj_firstname);
+                               $maj_firstname = mb_strtolower($maj_firstname);
                        }
 
                        $maj_firstname = ucwords($maj_firstname);
@@ -412,11 +364,11 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        fclose($maj_fp_firstname_txt);
 
                        $maj_fp_lastname_txt = fopen("$maj_data_directory/items/$maj_req_entry/comments/pending/$maj_comment_entry_dir/lastname.txt","w");
-                       $maj_lastname = htmlentities($_POST['lastname'],ENT_NOQUOTES);
+                       $maj_lastname = htmlentities($_POST['lastname'],ENT_QUOTES, 'UTF-8');
                        $maj_lastname = trim($maj_lastname);
 
                        if (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) {
-                               $maj_lastname = strtolower($maj_lastname);
+                               $maj_lastname = mb_strtolower($maj_lastname);
                        }
                       
                        $maj_lastname = ucwords($maj_lastname);
@@ -424,28 +376,28 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        fclose($maj_fp_lastname_txt);
 
                        $maj_fp_email_txt = fopen("$maj_data_directory/items/$maj_req_entry/comments/pending/$maj_comment_entry_dir/email.txt","w");
-                       $maj_email = strtolower($_POST['email']);
+                       $maj_email = mb_strtolower($_POST['email']);
                        $maj_email = trim($maj_email);
-                       $maj_email = htmlentities($maj_email,ENT_NOQUOTES);
+                       $maj_email = htmlentities($maj_email,ENT_QUOTES, 'UTF-8');
                        fwrite($maj_fp_email_txt,$maj_email);
                        fclose($maj_fp_email_txt);
 
                        if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username) and !file_exists("$maj_data_directory/email.txt")) {
                                $maj_fp_email_root = fopen("$maj_data_directory/email.txt","w");
-                               $maj_email_root = strtolower($_POST['email']);
+                               $maj_email_root = mb_strtolower($_POST['email']);
                                $maj_email_root = trim($maj_email_root);
-                               $maj_email_root = htmlentities($maj_email_root,ENT_NOQUOTES);
+                               $maj_email_root = htmlentities($maj_email_root,ENT_QUOTES, 'UTF-8');
                                fwrite($maj_fp_email_root,$maj_email_root);
                                fclose($maj_fp_email_root);
                        }
 
-                       if (isset($_POST['url']) and !empty($_POST['url']) and (ereg("\.",$_POST['url']))) {
+                       if (isset($_POST['url']) and !empty($_POST['url']) and (mb_ereg("\.",$_POST['url']))) {
                                $maj_fp_url_txt = fopen("$maj_data_directory/items/$maj_req_entry/comments/pending/$maj_comment_entry_dir/url.txt","w");
                                $maj_url = str_replace("http://","",$_POST['url']);
-                               $maj_url = strtolower($maj_url);
+                               $maj_url = mb_strtolower($maj_url);
                                $maj_url = trim($maj_url);
                                $maj_url = "http://" . $maj_url;
-                               $maj_url = htmlentities($maj_url,ENT_NOQUOTES);
+                               $maj_url = htmlentities($maj_url,ENT_QUOTES, 'UTF-8');
                                fwrite($maj_fp_url_txt,$maj_url);
                                fclose($maj_fp_url_txt);
                        }
@@ -469,7 +421,7 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        $maj_sig_url = str_replace('//','/',$maj_sig_url);
                        $maj_sig_url = "http://" . $maj_sig_url;
 
-                       $maj_email_to = strtolower($_POST['email']);
+                       $maj_email_to = mb_strtolower($_POST['email']);
                        $maj_email_to = '"' . "$maj_firstname $maj_lastname" . '" <' . $maj_email_to . '>';
 
                        if (file_exists("$maj_data_directory/email.txt")) {
@@ -485,9 +437,9 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        if (!file_exists("$maj_data_directory/nak.txt") and file_exists("$maj_data_directory/email.txt")) {
 
                                $maj_comment_thanks = "Hi $maj_firstname,\n\nThanks for submitting the following comment last $maj_timestamp:\n\n\"$maj_comment_quote\"\n\nIt will be e-mailed to me first for approval. Please visit the following URL to see if it has been posted:\n\n{$maj_sig_url}index.php?entry=$maj_req_entry&show=comments\n\nThanks again! =)\n\n--\n$maj_sig_author\n$maj_sig_url\n";
-                               $maj_comment_thanks = wordwrap($maj_comment_thanks);
+                               //$maj_comment_thanks = wordwrap($maj_comment_thanks);
 
-                               mail($maj_email_to,"Thanks for sharing your thoughts!",$maj_comment_thanks,
+                               mb_send_mail($maj_email_to,"Thanks for sharing your thoughts!",$maj_comment_thanks,
                                        "From: $maj_from_email\r\n" .
                                        "Reply-To: $maj_from_email\r\n" .
                                        "X-Mailer: $maj_mailer");
@@ -496,9 +448,9 @@ if (isset($maj_req_entry) and !empty($maj_req_entry)) {
                        if (file_exists("$maj_data_directory/email.txt") and !file_exists("$maj_data_directory/xscreen.txt")) {
 
                                $maj_comment_notice = "The following comment was submitted by $maj_email_to last $maj_timestamp for the entry \"$maj_commented_entry_title\":\n\n\"$maj_comment_quote\"\n\nVisit the link below to approve and post this pending comment:\n\n{$maj_sig_url}index.php?entry=$maj_req_entry&comment={$maj_comment_entry_dir}&key={$maj_key_rand}&action=approve\n\nVisit the link below to disapprove and delete this pending comment:\n\n{$maj_sig_url}index.php?entry=$maj_req_entry&comment={$maj_comment_entry_dir}&key={$maj_key_rand}&action=delete\n\nYou can also approve or disapprove pending comments at a later time by logging on to your blog.";
-                               $maj_comment_notice = wordwrap($maj_comment_notice);
+                               //$maj_comment_notice = wordwrap($maj_comment_notice);
       
-                               mail($maj_from_email,"Pending Comment",$maj_comment_notice,
+                               mb_send_mail($maj_from_email,"Pending Comment",$maj_comment_notice,
                                        "From: $maj_from_email\r\n" .
                                        "Reply-To: $maj_from_email\r\n" .
                                        "X-Mailer: $maj_mailer");
@@ -626,8 +578,8 @@ if (isset($maj_req_entry) and !empty($maj_req_entry) and file_exists("$maj_data_
                                $maj_description = str_replace(chr(10)," ",$maj_description);
                                $maj_description = str_replace(chr(13)," ",$maj_description);
                                $maj_description = trim($maj_description);
-                               $maj_description = substr($maj_description,0,210);
-                               $maj_description = htmlentities($maj_description,ENT_NOQUOTES);
+                               $maj_description = mb_substr($maj_description,0,210);
+                               $maj_description = htmlentities($maj_description,ENT_QUOTES, 'UTF-8');
 
                                if (file_exists("$maj_data_directory/pf.txt") and file_exists("$maj_data_directory/pf-badwords.txt") and (!isset($maj_logged_in_username) or empty($maj_logged_in_username) or (isset($maj_logged_in_username) and ($maj_logged_in_username != $maj_admin_username)))) {
 
@@ -1390,7 +1342,7 @@ if ($maj_dh_items = opendir("$maj_data_directory/items")) {
 
                                $maj_random[] = $maj_item;                     
 
-                               $maj_archives[] = substr($maj_item,0,6);
+                               $maj_archives[] = mb_substr($maj_item,0,6);
                        }
                        else {
 
@@ -1444,7 +1396,7 @@ if ($maj_dh_items = opendir("$maj_data_directory/items")) {
                                }
 
                                $maj_random[] = $maj_item;
-                               $maj_archives[] = substr($maj_item,0,6);
+                               $maj_archives[] = mb_substr($maj_item,0,6);
 
                                if (file_exists("$maj_data_directory/nocat.txt") and file_exists("$maj_data_directory/items/$maj_item/categories") and !file_exists("$maj_data_directory/items/$maj_item/cat.txt") and (!isset($maj_req_category) or empty($maj_req_category)) and (!isset($maj_req_entry) or empty($maj_req_entry)) and (!isset($maj_req_author) or empty($maj_req_author))) {
                                        continue;
@@ -1590,18 +1542,18 @@ if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directo
 
                        if ($maj_summary_comments < 1) {
 
-                               $maj_iso_year = substr($maj_latest[$maj_increment_latest],0,4);
-                               $maj_iso_month = substr($maj_latest[$maj_increment_latest],4,2);
-                               $maj_iso_day = substr($maj_latest[$maj_increment_latest],6,2);
+                               $maj_iso_year = mb_substr($maj_latest[$maj_increment_latest],0,4);
+                               $maj_iso_month = mb_substr($maj_latest[$maj_increment_latest],4,2);
+                               $maj_iso_day = mb_substr($maj_latest[$maj_increment_latest],6,2);
                                $maj_iso_last = $maj_iso_year . "-" . $maj_iso_month . "-" . $maj_iso_day;
 
                                echo "<td bgcolor=\"#ffffff\" align=\"right\">0</td>";
                                echo "<td bgcolor=\"#ffffff\" align=\"right\">$maj_iso_last</td>";
                        }
                        else {
-                               $maj_iso_year = substr($maj_items_summary_comments[0],0,4);
-                               $maj_iso_month = substr($maj_items_summary_comments[0],4,2);
-                               $maj_iso_day = substr($maj_items_summary_comments[0],6,2);
+                               $maj_iso_year = mb_substr($maj_items_summary_comments[0],0,4);
+                               $maj_iso_month = mb_substr($maj_items_summary_comments[0],4,2);
+                               $maj_iso_day = mb_substr($maj_items_summary_comments[0],6,2);
                                $maj_iso_last = $maj_iso_year . "-" . $maj_iso_month . "-" . $maj_iso_day;
 
                                echo "<td bgcolor=\"#ffffff\" align=\"right\">$maj_summary_comments</td>";
@@ -2055,7 +2007,7 @@ foreach ($maj_disp as $maj_d) {
 
                $maj_author = file_get_contents("$maj_data_directory/items/$maj_d/author.txt");
 
-               show_maj_avatar_image($maj_author,80);
+               maj_avatar_image($maj_author,80);
 
                if ($maj_dh_author_posts = opendir("$maj_data_directory/items")) {
 
@@ -2226,9 +2178,7 @@ foreach ($maj_disp as $maj_d) {
                        $entry_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), "/\\") . "/index.php?entry=$maj_d";
                }
 
-               //$entry_url = rawurlencode($entry_url);
-
-                               echo "<br><br><div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script><fb:like href=\"$entry_url\" send=\"false\" width=\"510\" show_faces=\"false\" font=\"\"></fb:like>";
+               echo "<br><br><div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script><fb:like href=\"$entry_url\" send=\"false\" width=\"510\" show_faces=\"false\" font=\"\"></fb:like>";
        }
 
        if (isset($maj_d_text_b)) {
@@ -2934,7 +2884,7 @@ foreach ($maj_disp as $maj_d) {
 
                                        if ($maj_dl_count != "." && $maj_dl_count != "..") {
 
-                                               $maj_dl_match = substr("$maj_dl_count",0,-4);
+                                               $maj_dl_match = mb_substr("$maj_dl_count",0,-4);
 
                                                if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count") and !file_exists("$maj_data_directory/items/$maj_d/filedrop/files/$maj_dl_match")) {
                                                        unlink("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count");
@@ -3056,7 +3006,7 @@ foreach ($maj_disp as $maj_d) {
                               
                                        $maj_c_author = file_get_contents("$maj_data_directory/items/$maj_d/comments/live/$maj_comment/author.txt");
 
-                                       show_maj_avatar_image($maj_c_author,80);
+                                       maj_avatar_image($maj_c_author,80);
                                       
                                        if ($maj_c_dh_posts = opendir("$maj_data_directory/items")) {
                                                while (($maj_c_entry_posts = readdir($maj_c_dh_posts)) !== false) {
@@ -3188,7 +3138,7 @@ foreach ($maj_disp as $maj_d) {
 
                        if (!isset($maj_logged_in_username) or (isset($maj_logged_in_username) and ($maj_logged_in_username != $maj_admin_username and file_exists("$maj_data_directory/members/active/$maj_logged_in_username")))) {
       
-                               if (isset($maj_req_show) and !empty($maj_req_show) and isset($_POST['captcha_put']) and !empty($_REQUEST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['new_comment']) and !empty($_POST['new_comment']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_REQUEST['captcha_get'] == $_POST['captcha_put']) and (ereg("@",$_POST['email'])) and (ereg("\.",$_POST['email']))) {
+                               if (isset($maj_req_show) and !empty($maj_req_show) and isset($_POST['captcha_put']) and !empty($_REQUEST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['new_comment']) and !empty($_POST['new_comment']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_REQUEST['captcha_get'] == $_POST['captcha_put']) and (mb_ereg("@",$_POST['email'])) and (mb_ereg("\.",$_POST['email']))) {
                                        echo "<font style=\"font-size: $maj_font_Lpx;\"><b>Thanks!</b></font><p>Your comment has been submitted for approval. Please check back soon to see if it has been posted.</p>";
                                }
                        }
@@ -3436,7 +3386,7 @@ foreach ($maj_disp as $maj_d) {
       
                                        $maj_pc_author = file_get_contents("$maj_data_directory/items/$maj_d/comments/pending/$maj_pending_comment/author.txt");
                                       
-                                       show_maj_avatar_image($maj_pc_author,80);
+                                       maj_avatar_image($maj_pc_author,80);
       
                                        if ($maj_pc_dh_posts = opendir("$maj_data_directory/items")) {
       
@@ -3930,15 +3880,15 @@ if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_us
                        }
                        echo "<br>";
                        $maj_pending_email = file_get_contents("$maj_data_directory/members/confirmed/$maj_pending_list_entry/email.txt");
-                       $maj_pending_email = wordwrap($maj_pending_email,30);
+                       //$maj_pending_email = wordwrap($maj_pending_email,30);
                        echo $maj_pending_email;
                        if (file_exists("$maj_data_directory/members/confirmed/$maj_pending_list_entry/timestamp.txt")) {
                                $maj_confirmed = file_get_contents("$maj_data_directory/members/confirmed/$maj_pending_list_entry/timestamp.txt");
-                               $maj_confirmed_year = substr($maj_confirmed,0,4);
-                               $maj_confirmed_month = substr($maj_confirmed,4,2);
-                               $maj_confirmed_day = substr($maj_confirmed,6,2);
-                               $maj_confirmed_hh = substr($maj_confirmed,8,2);
-                               $maj_confirmed_mm = substr($maj_confirmed,10,2);
+                               $maj_confirmed_year = mb_substr($maj_confirmed,0,4);
+                               $maj_confirmed_month = mb_substr($maj_confirmed,4,2);
+                               $maj_confirmed_day = mb_substr($maj_confirmed,6,2);
+                               $maj_confirmed_hh = mb_substr($maj_confirmed,8,2);
+                               $maj_confirmed_mm = mb_substr($maj_confirmed,10,2);
                                $maj_email_confirmed = date("d M Y H:i",mktime($maj_confirmed_hh,$maj_confirmed_mm,0,$maj_confirmed_month,$maj_confirmed_day,$maj_confirmed_year));
                                echo "<br>$maj_email_confirmed";
                        }
@@ -4003,7 +3953,7 @@ if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directo
                                }
       
                                if ($maj_entry_mempost_list != "." && $maj_entry_mempost_list != "..") {
-                                       $maj_entry_mempost_list = substr("$maj_entry_mempost_list",0,6);
+                                       $maj_entry_mempost_list = mb_substr("$maj_entry_mempost_list",0,6);
                                        $maj_show_mempost_list[] = $maj_entry_mempost_list;
                                }
                        }
@@ -4239,11 +4189,11 @@ if (($maj_count_archives > 0) and ($maj_count_latest > $maj_increase) and ($maj_
 
        foreach ($maj_unique_archive_list as $maj_archive_list_entry) {
 
-               $maj_archive_list_value = substr($maj_archive_list_entry,0,6);
-               $maj_archive_list_year = substr($maj_archive_list_entry,0,4);
-               $maj_archive_list_month = substr($maj_archive_list_entry,4,2);
+               $maj_archive_list_value = mb_substr($maj_archive_list_entry,0,6);
+               $maj_archive_list_year = mb_substr($maj_archive_list_entry,0,4);
+               $maj_archive_list_month = mb_substr($maj_archive_list_entry,4,2);
                $maj_archive_list_month = date("F",mktime(0,0,0,$maj_archive_list_month));
-               $maj_archive_list_num = substr_count($maj_archive_entries,$maj_archive_list_entry);
+               $maj_archive_list_num = mb_substr_count($maj_archive_entries,$maj_archive_list_entry);
 
                echo "<tr><td><a class=\"navlink\" href=\"index.php?archive=$maj_archive_list_value\"><nobr>$maj_archive_list_month $maj_archive_list_year</nobr></a></td><td align=right>$maj_archive_list_num</td></tr>";
        }
diff --git a/login.php b/login.php
index 8ad4cd1..42979a0 100644
--- a/login.php
+++ b/login.php
@@ -1,14 +1,4 @@
 <?php
-       session_start();
-      
-       session_regenerate_id(TRUE);
-
-       header("Cache-control: private");
-
-       error_reporting(E_ERROR);
-      
-       require("core.php");
-
        if (isset($_POST['go']) and ($_POST['go'] == "index")) {
                header("Location: .");
        }
@@ -16,71 +6,13 @@
        if (isset($_POST['go']) and ($_POST['go'] == "reset")) {
                header("Location: reset.php");
        }
-?>
 
-<title>Login</title>
-
-<style>
+       require("core.php");
 
-body {
-       color: #666666;
-       margin: 10px;
-       padding: 0px;
-       text-align: left;
-       font-size: 11px;
-       font-family:
-<?php
-       if (file_exists("data/fonts/body.txt")) {
-               $font_body = file_get_contents("data/fonts/body.txt");
-               echo "{$font_body},";
-       }
-?>
-       arial, helvetica, sans-serif;
-       background-color: #FFFFFF;
-}
-
-p, td {
-       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,.click {       
-       color: #666666;
-       background: #ffffff;
-       border: #999999 solid 1px;
-       width: 250px;
-       font-family:
-<?php
-       if (file_exists("data/fonts/input.txt")) {
-               $font_input = file_get_contents("data/fonts/input.txt");
-               echo "{$font_input},";
-       }
+       session_regenerate_id(TRUE);
 ?>
-       arial, helvetica, sans-serif;
-       font-size: 11px;
-}
-
-.input:focus {
-      background: #ffffcc;
-}
 
-</style>
+<title>Login</title>
 
 <?php
        if (!isset($_POST['username']) or empty($_POST['username']) or !isset($_POST['password']) or empty($_POST['password'])) {
@@ -88,7 +20,7 @@ a:active {
                session_destroy();
        }
        else {
-               $put_username = trim($_POST['username']);
+               $put_username = trim(strip_tags($_POST['username']));
 
                /* Fun with crypt! */
                $put_password = sha1($_POST['password']);
@@ -98,26 +30,26 @@ a:active {
                $err_username = "1";
                $err_password = "1";
 
-               if ($put_username == file_get_contents("data/username.txt")) {
-                       $get_password = file_get_contents("data/password.txt");
-                       $last_login = "data/lastlog.txt";
-                       $logins = "data/logins.txt";
+               if ($put_username == $maj_admin_username) {
+                       $get_password = file_get_contents("$maj_data_directory/password.txt");
+                       $last_login = "$maj_data_directory/lastlog.txt";
+                       $logins = "$maj_data_directory/logins.txt";
                        $err_username = "0";
                }
                else {
-                       if (file_exists("data/members/active/$put_username") and file_exists("data/bb.txt") and !file_exists("data/members/active/$put_username/bb-lockout.txt")) {
+                       if (file_exists("$maj_data_directory/members/active/$put_username") and file_exists("$maj_data_directory/bb.txt") and !file_exists("$maj_data_directory/members/active/$put_username/bb-lockout.txt")) {
 
-                               $get_password = file_get_contents("data/members/active/$put_username/password.txt");
-                               $last_login = "data/members/active/$put_username/bb-last.txt";
-                               $logins = "data/members/active/$put_username/bb-logins.txt";
+                               $get_password = file_get_contents("$maj_data_directory/members/active/$put_username/password.txt");
+                               $last_login = "$maj_data_directory/members/active/$put_username/bb-last.txt";
+                               $logins = "$maj_data_directory/members/active/$put_username/bb-logins.txt";
                                $err_username = "0";
 
-                               if (($get_password != $put_password) and (file_exists("data/bb-invalid.txt"))) {
+                               if (($get_password != $put_password) and (file_exists("$maj_data_directory/bb-invalid.txt"))) {
                               
-                                       $max_invalid = file_get_contents("data/bb-invalid.txt");
+                                       $max_invalid = file_get_contents("$maj_data_directory/bb-invalid.txt");
 
-                                       if (file_exists("data/members/active/$put_username/bb-invalid.txt")) {
-                                               $count_invalid = file_get_contents("data/members/active/$put_username/bb-invalid.txt");
+                                       if (file_exists("$maj_data_directory/members/active/$put_username/bb-invalid.txt")) {
+                                               $count_invalid = file_get_contents("$maj_data_directory/members/active/$put_username/bb-invalid.txt");
                                        }
                                        else {
                                                $count_invalid = "0";
@@ -125,12 +57,12 @@ a:active {
                                       
                                        $count_invalid = $count_invalid + 1;
                                       
-                                       $fp_invalid_txt = fopen("data/members/active/$put_username/bb-invalid.txt", "w");
+                                       $fp_invalid_txt = fopen("$maj_data_directory/members/active/$put_username/bb-invalid.txt", "w");
                                        fwrite($fp_invalid_txt, $count_invalid);
                                        fclose($fp_invalid_txt);
                                       
                                        if ($count_invalid >= $max_invalid) {
-                                               touch("data/members/active/$put_username/bb-lockout.txt");
+                                               touch("$maj_data_directory/members/active/$put_username/bb-lockout.txt");
                                        }
                                }
                        }
@@ -138,7 +70,7 @@ a:active {
               
                if ($get_password == $put_password) {
 
-                       $_SESSION['logged_in'] = $_POST['username'];
+                       $_SESSION['logged_in'] = $put_username;
                        $_SESSION['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
                        $_SESSION['maj_server'] = sha1($_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']));
 
@@ -148,8 +80,8 @@ a:active {
                        fwrite($fp_lastlog_txt, $lastlog);
                        fclose($fp_lastlog_txt);
 
-                       if (file_exists("data/bb.txt") and ($_SESSION['logged_in'] != file_get_contents("data/username.txt"))) {
-                               $fp_latest_login_txt = fopen("data/bb-last.txt", "w");
+                       if (file_exists("$maj_data_directory/bb.txt") and ($_SESSION['logged_in'] != $maj_admin_username)) {
+                               $fp_latest_login_txt = fopen("$maj_data_directory/bb-last.txt", "w");
                                fwrite($fp_latest_login_txt, $_SESSION['logged_in']);
                                fclose($fp_latest_login_txt);
                        }
@@ -163,8 +95,8 @@ a:active {
 
                        $err_password = "0";
                       
-                       if (file_exists("data/members/active/$put_username/bb-invalid.txt")) {
-                               unlink("data/members/active/$put_username/bb-invalid.txt");
+                       if (file_exists("$maj_data_directory/members/active/$put_username/bb-invalid.txt")) {
+                               unlink("$maj_data_directory/members/active/$put_username/bb-invalid.txt");
                        }
 
                        header("Location: index.php");
@@ -174,15 +106,19 @@ a:active {
                        session_destroy();
                }
        }
+      
+       include("css.php");
+
+       echo "\n<style> body { margin: {$maj_wspace}px; } </style>\n";
 ?>
 
 <table border="0" cellspacing="1" cellpadding="1">
 
 <form enctype="multipart/form-data" action="login.php" method="post">
 
-<tr><td>Username</td><td><input required autofocus class="input" type="text" maxlength="30" name="username"<?php if (!file_exists("data/autocomplete.txt")) { echo " autocomplete=\"off\""; } if ($err_username == "0") { echo " value=\"{$_POST['username']}\""; } ?>></td><?php if ($err_username == "0") { echo "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The username you entered is correct.</td>"; } if ($err_username == "1") { echo "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The username you entered is invalid.</td>"; } ?></tr>
+<tr><td>Username</td><td><input required autofocus class="input" type="text" maxlength="30" name="username"<?php if (!file_exists("$maj_data_directory/autocomplete.txt")) { echo " autocomplete=\"off\""; } if ($err_username == "0") { echo " value=\"$put_username\""; } ?>></td><?php if ($err_username == "0") { echo "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The username you entered is correct.</td>"; } if ($err_username == "1") { echo "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The username you entered is invalid.</td>"; } ?></tr>
 
-<tr><td>Password</td><td><input required class="input" type="password" maxlength="128" name="password"<?php if (!file_exists("data/autocomplete.txt")) { echo " autocomplete=\"off\""; } ?>></td><?php if ($err_password == "1") { echo "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The password you entered is invalid.</td>"; } ?></tr>
+<tr><td>Password</td><td><input required class="input" type="password" maxlength="128" name="password"<?php if (!file_exists("$maj_data_directory/autocomplete.txt")) { echo " autocomplete=\"off\""; } ?>></td><?php if ($err_password == "1") { echo "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>The password you entered is invalid.</td>"; } ?></tr>
 
 <tr><td></td><td><input class="click" type="submit" value="click here to login"></td></tr>
 
@@ -193,7 +129,7 @@ a:active {
 <tr><td></td><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
 </form>
 
-<?php if (!file_exists("data/lite.txt") and file_exists("data/reset.txt")) { ?>
+<?php if (!file_exists("$maj_data_directory/lite.txt") and file_exists("$maj_data_directory/reset.txt")) { ?>
 
 <form enctype="multipart/form-data" action="login.php" method="post">
 <input type="hidden" name="go" value="reset">
diff --git a/member.php b/member.php
index 8dadcb2..d71e925 100644
--- a/member.php
+++ b/member.php
@@ -219,7 +219,7 @@ if ($id == "all") {
                        }
                }
 
-               if (isset($_POST['rank']) and !empty($_POST['rank']) and (strtolower($_POST['rank']) != "member")) {
+               if (isset($_POST['rank']) and !empty($_POST['rank']) and (mb_strtolower($_POST['rank']) != "member")) {
                        $rank_file = "data/members/active/{$_POST['username']}/rank.txt";
                        $fp_rank_txt = fopen($rank_file,"w");
                        fwrite($fp_rank_txt,$_POST['rank']);
@@ -230,7 +230,7 @@ if ($id == "all") {
                        unlink("data/members/active/{$_POST['username']}/rank.txt");
                }
       
-               if (isset($_POST['category']) and !empty($_POST['category']) and (strtolower($_POST['category']) != "none") and (file_exists("data/categories/{$_POST['category']}"))) {
+               if (isset($_POST['category']) and !empty($_POST['category']) and (mb_strtolower($_POST['category']) != "none") and (file_exists("data/categories/{$_POST['category']}"))) {
                        $category_file = "data/members/active/{$_POST['username']}/category.txt";
                        $fp_category_txt = fopen($category_file,"w");
                        fwrite($fp_category_txt,$_POST['category']);
@@ -370,9 +370,9 @@ if (file_exists("data/members/active")) {
 
                        if (file_exists("data/members/active/$member_list_entry") and ($member_list_entry != $maj_admin_username) and file_exists("data/members/active/$member_list_entry/timestamp.txt")) {
                                $joined = file_get_contents("data/members/active/$member_list_entry/timestamp.txt");
-                               $joined_year = substr($joined,0,4);
-                               $joined_month = substr($joined,4,2);
-                               $joined_day = substr($joined,6,2);
+                               $joined_year = mb_substr($joined,0,4);
+                               $joined_month = mb_substr($joined,4,2);
+                               $joined_day = mb_substr($joined,6,2);
                                $member_since = date("d M Y", mktime(0, 0, 0, $joined_month, $joined_day, $joined_year));
                                echo "<td bgcolor=#ffffff align=center><nobr><code>$member_since</code></nobr></td>";
                        }
@@ -522,7 +522,7 @@ if (file_exists("data/members/active")) {
                                                        }
 
                                                        echo ">";
-                                                       echo strtolower($category);
+                                                       echo mb_strtolower($category);
                                                        unset($show_cat);
                                                }
                                        }
@@ -589,7 +589,7 @@ else {
 
 <?php
 
-show_maj_avatar_image($id,80);
+maj_avatar_image($id,80);
 
 ?>
 
@@ -609,62 +609,62 @@ elseif (file_exists("data/members/active/$id/url.txt") and isset($maj_logged_in_
 
 if (file_exists("data/members/active/$id/bday.txt") and ($maj_logged_in_username == $maj_admin_username)) {
        $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_year = mb_substr($bday,0,4);
+       $bday_month = mb_substr($bday,4,2);
+       $bday_day = mb_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>birthdate</td><td><code>$bday</code></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);
-       $joined_month = substr($joined,4,2);
-       $joined_day = substr($joined,6,2);
-       $joined_hh = substr($joined,8,2);
-       $joined_mm = substr($joined,10,2);
+       $joined_year = mb_substr($joined,0,4);
+       $joined_month = mb_substr($joined,4,2);
+       $joined_day = mb_substr($joined,6,2);
+       $joined_hh = mb_substr($joined,8,2);
+       $joined_mm = mb_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 "<tr><td width=90>member since</td><td><code>$member_since</code></td></tr>";
 }
 
 if (($maj_admin_username == $id) and file_exists("data/lastlog.txt")) {
        $lastlog = file_get_contents("data/lastlog.txt");
-       $lastlog_year = substr($lastlog,0,4);
-       $lastlog_month = substr($lastlog,4,2);
-       $lastlog_day = substr($lastlog,6,2);
-       $lastlog_hh = substr($lastlog,8,2);
-       $lastlog_mm = substr($lastlog,10,2);
+       $lastlog_year = mb_substr($lastlog,0,4);
+       $lastlog_month = mb_substr($lastlog,4,2);
+       $lastlog_day = mb_substr($lastlog,6,2);
+       $lastlog_hh = mb_substr($lastlog,8,2);
+       $lastlog_mm = mb_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 "<tr><td width=90>last login</td><td><code>$last_login</code></td></tr>";
 }
 elseif (file_exists("data/members/active/$id/bb-last.txt")) {
        $lastlog = file_get_contents("data/members/active/$id/bb-last.txt");
-       $lastlog_year = substr($lastlog,0,4);
-       $lastlog_month = substr($lastlog,4,2);
-       $lastlog_day = substr($lastlog,6,2);
-       $lastlog_hh = substr($lastlog,8,2);
-       $lastlog_mm = substr($lastlog,10,2);
+       $lastlog_year = mb_substr($lastlog,0,4);
+       $lastlog_month = mb_substr($lastlog,4,2);
+       $lastlog_day = mb_substr($lastlog,6,2);
+       $lastlog_hh = mb_substr($lastlog,8,2);
+       $lastlog_mm = mb_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 "<tr><td width=90>last login</td><td><code>$last_login</code></td></tr>";
 }
 
 if (($maj_admin_username == $id) and file_exists("data/lastpost.txt")) {
        $lastpost = file_get_contents("data/lastpost.txt");
-       $lastpost_year = substr($lastpost,0,4);
-       $lastpost_month = substr($lastpost,4,2);
-       $lastpost_day = substr($lastpost,6,2);
-       $lastpost_hh = substr($lastpost,8,2);
-       $lastpost_mm = substr($lastpost,10,2);
+       $lastpost_year = mb_substr($lastpost,0,4);
+       $lastpost_month = mb_substr($lastpost,4,2);
+       $lastpost_day = mb_substr($lastpost,6,2);
+       $lastpost_hh = mb_substr($lastpost,8,2);
+       $lastpost_mm = mb_substr($lastpost,10,2);
        $last_post = date("d M Y H:i", mktime($lastpost_hh, $lastpost_mm, 0, $lastpost_month, $lastpost_day, $lastpost_year));
        echo "<tr><td width=90>last post</td><td><code>$last_post</code></td></tr>";
 }
 elseif (file_exists("data/members/active/$id/bb-post.txt")) {
        $lastpost = file_get_contents("data/members/active/$id/bb-post.txt");
-       $lastpost_year = substr($lastpost,0,4);
-       $lastpost_month = substr($lastpost,4,2);
-       $lastpost_day = substr($lastpost,6,2);
-       $lastpost_hh = substr($lastpost,8,2);
-       $lastpost_mm = substr($lastpost,10,2);
+       $lastpost_year = mb_substr($lastpost,0,4);
+       $lastpost_month = mb_substr($lastpost,4,2);
+       $lastpost_day = mb_substr($lastpost,6,2);
+       $lastpost_hh = mb_substr($lastpost,8,2);
+       $lastpost_mm = mb_substr($lastpost,10,2);
        $last_post = date("d M Y H:i", mktime($lastpost_hh, $lastpost_mm, 0, $lastpost_month, $lastpost_day, $lastpost_year));
        echo "<tr><td width=90>last post</td><td><code>$last_post</code></td></tr>";
 }
diff --git a/options.php b/options.php
index 111f841..94e5c18 100644
--- a/options.php
+++ b/options.php
@@ -128,18 +128,18 @@ if (!file_exists("data/members/active/{$_SESSION['logged_in']}")) {
        exit();
 }
 
-if (isset($_POST['email']) and !empty($_POST['email']) and (file_get_contents("data/members/active/{$_SESSION['logged_in']}/email.txt") != $_POST['email']) and (ereg("@", $_POST['email'])) and (ereg("\.", $_POST['email']))) {
-       $email_write_content = strtolower($_POST['email']);
+if (isset($_POST['email']) and !empty($_POST['email']) and (file_get_contents("data/members/active/{$_SESSION['logged_in']}/email.txt") != $_POST['email']) and (mb_ereg("@", $_POST['email'])) and (mb_ereg("\.", $_POST['email']))) {
+       $email_write_content = mb_strtolower($_POST['email']);
        $email_write_content = trim($email_write_content);
        $email_write_content = str_replace(" ","",$email_write_content);
-       $email_write_content = htmlentities($email_write_content, ENT_NOQUOTES);
+       $email_write_content = htmlentities($email_write_content, ENT_QUOTES, 'UTF-8');
        $fp_email_txt = fopen("data/members/active/{$_SESSION['logged_in']}/new-email.txt","w");
        fwrite($fp_email_txt,$email_write_content);
        fclose($fp_email_txt);
 
        function str_rand($length = 8, $seeds = 'abcdefghijklmnopqrstuvwxyz0123456789') {
                $str = '';
-               $seeds_count = strlen($seeds);
+               $seeds_count = mb_strlen($seeds);
       
                list($usec, $sec) = explode(' ', microtime());
                $seed = (float) $sec + ((float) $usec * 100000);
@@ -173,13 +173,12 @@ if (isset($_POST['email']) and !empty($_POST['email']) and (file_get_contents("d
        $from_email = file_get_contents("data/email.txt");
 
        $confirm_change = "Hi $firstname,\n\nWe have received an e-mail address modification request ($old_email to $email_write_content) at $sig_url. To confirm this, simply visit this link:\n\n{$sig_url}options.php?username={$_SESSION['logged_in']}&key=$key_email\n\nIf you have any questions, send them to $from_email.\n\nThanks!\n\n--\n$sig_author\n$sig_url\n";
-
-       $confirm_change = wordwrap($confirm_change);
+       //$confirm_change = wordwrap($confirm_change);
 
        $email_to = '"' . "$firstname $lastname" . '" <' . $email_write_content . '>';
        $email_from = '"' . $sig_author . '" <' . $from_email . '>';
 
-       mail($email_to, "confirm $key_email", $confirm_change,
+       mb_send_mail($email_to, "confirm $key_email", $confirm_change,
                "From: $email_from\r\n" .
                "Reply-To: $email_from\r\n" .
                "X-Mailer: $mailer");
@@ -191,13 +190,13 @@ if ((!isset($_POST['url']) or empty($_POST['url'])) and isset($_POST['edit']) an
        unlink("data/members/active/{$_SESSION['logged_in']}/url.txt");
 }
 
-if (isset($_POST['url']) and !empty($_POST['url']) and (ereg("\.", $_POST['url']))) {
+if (isset($_POST['url']) and !empty($_POST['url']) and (mb_ereg("\.", $_POST['url']))) {
        $url = str_replace('http://', '', $_POST['url']);
-       $url = strtolower($url);
+       $url = mb_strtolower($url);
        $url = trim($url);
        $url = 'http://' . $url;
        $url = str_replace(" ","",$url);
-       $url = htmlentities($url, ENT_NOQUOTES);
+       $url = htmlentities($url, ENT_QUOTES, 'UTF-8');
        $fp_url_txt = fopen("data/members/active/{$_SESSION['logged_in']}/url.txt","w");
        fwrite($fp_url_txt,$url);
        fclose($fp_url_txt);
@@ -205,8 +204,8 @@ if (isset($_POST['url']) and !empty($_POST['url']) and (ereg("\.", $_POST['url']
 
 if (isset($_POST['country']) and !empty($_POST['country'])) {
        $country = trim($_POST['country']);
-       $country = strtoupper($country);
-       $country = htmlentities($country, ENT_NOQUOTES);
+       $country = mb_strtoupper($country);
+       $country = htmlentities($country, ENT_QUOTES, 'UTF-8');
        $fp_country_txt = fopen("data/members/active/{$_SESSION['logged_in']}/country.txt","w");
        fwrite($fp_country_txt,$country);
        fclose($fp_country_txt);
@@ -215,7 +214,7 @@ if (isset($_POST['country']) and !empty($_POST['country'])) {
 if (isset($_POST['city']) and !empty($_POST['city'])) {
        $city = trim($_POST['city']);
        $city = ucwords($city);
-       $city = htmlentities($city, ENT_NOQUOTES);
+       $city = htmlentities($city, ENT_QUOTES, 'UTF-8');
        $fp_city_txt = fopen("data/members/active/{$_SESSION['logged_in']}/city.txt","w");
        fwrite($fp_city_txt,$city);
        fclose($fp_city_txt);
@@ -336,7 +335,7 @@ if (file_exists("data/members/active/{$_SESSION['logged_in']}/key.txt") and !fil
 }
 
 
-if (isset($_POST['bday']) and !empty($_POST['bday']) and (strlen($_POST['bday']) == "8") and is_numeric($_POST['bday']) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) <= $maxage)) {
+if (isset($_POST['bday']) and !empty($_POST['bday']) and (mb_strlen($_POST['bday']) == "8") and is_numeric($_POST['bday']) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) <= $maxage)) {
 
        $fp_bday_txt = fopen("data/members/active/{$_SESSION['logged_in']}/bday.txt","w");
        fwrite($fp_bday_txt,$_POST['bday']);
@@ -357,7 +356,7 @@ if (isset($_POST['current_passwd']) and !empty($_POST['current_passwd']) and iss
        $new_passwd = trim($_POST['new_passwd']);
        $confirm_passwd = trim($_POST['confirm_passwd']);
 
-       if ((strlen($new_passwd) < $pass_len) or (strlen($confirm_passwd) < $pass_len)) {
+       if ((mb_strlen($new_passwd) < $pass_len) or (mb_strlen($confirm_passwd) < $pass_len)) {
                echo "<p>Passwords must be composed of at least $pass_len characters.</p>";
        }
        else {
@@ -471,31 +470,31 @@ 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_year = mb_substr($bday,0,4);
+       $bday_month = mb_substr($bday,4,2);
+       $bday_day = mb_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);
-       $joined_month = substr($joined,4,2);
-       $joined_day = substr($joined,6,2);
-       $joined_hh = substr($joined,8,2);
-       $joined_mm = substr($joined,10,2);
+       $joined_year = mb_substr($joined,0,4);
+       $joined_month = mb_substr($joined,4,2);
+       $joined_day = mb_substr($joined,6,2);
+       $joined_hh = mb_substr($joined,8,2);
+       $joined_mm = mb_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 "member since<code>&nbsp;$member_since&nbsp;</code><br>";
 }
 
 if (file_exists("data/members/active/{$_SESSION['logged_in']}/bb-last.txt")) {
        $lastlog = file_get_contents("data/members/active/{$_SESSION['logged_in']}/bb-last.txt");
-       $lastlog_year = substr($lastlog,0,4);
-       $lastlog_month = substr($lastlog,4,2);
-       $lastlog_day = substr($lastlog,6,2);
-       $lastlog_hh = substr($lastlog,8,2);
-       $lastlog_mm = substr($lastlog,10,2);
+       $lastlog_year = mb_substr($lastlog,0,4);
+       $lastlog_month = mb_substr($lastlog,4,2);
+       $lastlog_day = mb_substr($lastlog,6,2);
+       $lastlog_hh = mb_substr($lastlog,8,2);
+       $lastlog_mm = mb_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 "last login<code>&nbsp;$last_login&nbsp;</code>";
 }
diff --git a/panels.php b/panels.php
index bc80051..361b839 100644
--- a/panels.php
+++ b/panels.php
@@ -24,7 +24,7 @@ if (isset($_POST['new_id']) and !empty($_POST['new_id']) and isset($_POST['new_t
                mkdir("data/panels");
        }
 
-       $new_id = trim(strip_tags(strtolower(str_replace(" ", "_", $_POST['new_id']))));
+       $new_id = trim(strip_tags(mb_strtolower(str_replace(" ", "_", $_POST['new_id']))));
 
        if (!file_exists("data/panels/$new_id")) {
                mkdir("data/panels/$new_id");
@@ -327,7 +327,7 @@ if (isset($_POST['panel_content']) and !empty($_POST['panel_content'])) {
 
 if (isset($_POST['move_id']) and !empty($_POST['move_id']) and isset($_POST['old_id']) and !empty($_POST['old_id']) and isset($_POST['panel_edit']) and !empty($_POST['panel_edit']) and ($_POST['panel_edit'] == "on")) {
 
-       $move_id = trim(strip_tags(strtolower(str_replace(" ", "_", $_POST['move_id']))));
+       $move_id = trim(strip_tags(mb_strtolower(str_replace(" ", "_", $_POST['move_id']))));
        $move_id = str_replace(",","_",$move_id);
 
        if (!file_exists("data/panels/$move_id")) {
@@ -445,7 +445,7 @@ a:active {
                                echo "<form enctype=\"multipart/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
 
                                echo "<tr><td colspan=\"2\"><a name=\"";
-                               echo strtolower(str_replace("_", " ", $panel));
+                               echo mb_strtolower(str_replace("_", " ", $panel));
                                echo "\"></a></td></tr>";
 
                                echo "<tr><td><input type=\"text\" class=\"input\" name=\"move_id\" value=\"$panel\" autocomplete=\"off\" maxlength=\"30\" required></td>";
diff --git a/reg.php b/reg.php
index 86dc782..0911fed 100644
--- a/reg.php
+++ b/reg.php
@@ -1,55 +1,35 @@
 <?php
 
-if (file_exists("data/lite.txt")) {
-       exit();
-}
+require("core.php");
 
-if (!file_exists("data/reg.txt")) {
+if (file_exists("$maj_data_directory/lite.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("$maj_data_directory/reg.txt")) {
+       exit();
 }
 
 if (isset($_POST['go']) and ($_POST['go'] == "index")) {
        header("Location: .");
 }
 
-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");
+if (file_exists("$maj_data_directory/bb-min-age.txt")) {
+       $minage = file_get_contents("$maj_data_directory/bb-min-age.txt");
 }
 else {
        $minage = 5;
 }
 
-if (file_exists("data/bb-max-age.txt")) {
-       $maxage = file_get_contents("data/bb-max-age.txt");
+if (file_exists("$maj_data_directory/bb-max-age.txt")) {
+       $maxage = file_get_contents("$maj_data_directory/bb-max-age.txt");
 }
 else {
        $maxage = 125;
 }
 
+include("css.php");
+
 ?>
 
 <title>Register</title>
@@ -57,53 +37,11 @@ else {
 <style>
 
 body {
-       color: #666666;
        margin: 10px;
-       padding: 0px;
-       text-align: left;
-       font-family: <?php
-                               if (file_exists("data/fonts/body.txt")) {
-                                       $font_body = file_get_contents("data/fonts/body.txt");
-                                       echo "{$font_body},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       background-color: #FFFFFF;
-}
-
-* {
-       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: 300px;
-       font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "$font_input,";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-       font-weight: normal;
 }
 
 .bd {  
@@ -112,8 +50,8 @@ a:active {
        border: #999999 solid 1px;
        width: 98px;
        font-family: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
+                               if (file_exists("$maj_data_directory/fonts/input.txt")) {
+                                       $font_input = file_get_contents("$maj_data_directory/fonts/input.txt");
                                        echo "$font_input,";
                                }
        ?> arial, helvetica, sans-serif;
@@ -125,61 +63,21 @@ a:active {
 
 <?php
 
-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;
-}
-
-function rmdirr($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()) {
-
-               if ($recurse_entry == '.' || $recurse_entry == '..') {
-                       continue;
-               }
-
-               rmdirr("$recurse_dirname/$recurse_entry");
-       }
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and isset($_REQUEST['action']) and !empty($_REQUEST['action']) and mb_ereg('^[^./][^/]*$', $_REQUEST['username'])) {
 
-       $recurse_dir->close();
-       return rmdir($recurse_dirname);
-}
+       $username = trim(strip_tags($_REQUEST['username']));
 
-if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and isset($_REQUEST['action']) and !empty($_REQUEST['action']) and ereg('^[^./][^/]*$', $_REQUEST['username'])) {
-
-       $username = $_REQUEST['username'];
-
-       if (file_exists("data/members/confirmed/$username") and ($_REQUEST['key'] == file_get_contents("data/members/confirmed/$username/key.txt"))) {
+       if (file_exists("$maj_data_directory/members/confirmed/$username") and ($_REQUEST['key'] == file_get_contents("$maj_data_directory/members/confirmed/$username/key.txt"))) {
                if ($_REQUEST['action'] == "approve") {
-                       unlink("data/members/confirmed/$username/key.txt");
-                       $timestamp = date("YmdHis", time() + $offset);
-                       $fp_timestamp_txt = fopen("data/members/confirmed/$username/timestamp.txt","w");
+                       unlink("$maj_data_directory/members/confirmed/$username/key.txt");
+                       $timestamp = date("YmdHis", time() + $maj_offset);
+                       $fp_timestamp_txt = fopen("$maj_data_directory/members/confirmed/$username/timestamp.txt","w");
                        fwrite($fp_timestamp_txt,$timestamp);
                        fclose($fp_timestamp_txt);
-                       if (!file_exists("data/members/active")) {
-                               mkdir("data/members/active");
+                       if (!file_exists("$maj_data_directory/members/active")) {
+                               mkdir("$maj_data_directory/members/active");
                        }
-                       rename("data/members/confirmed/$username","data/members/active/$username");
+                       rename("$maj_data_directory/members/confirmed/$username","$maj_data_directory/members/active/$username");
 
                        $password = str_rand(16);
                       
@@ -188,73 +86,72 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
                        $passwd = md5($passwd);
                        $passwd = crypt($passwd, $passwd);
 
-                       $fp_passwd_txt = fopen("data/members/active/$username/password.txt","w");
+                       $fp_passwd_txt = fopen("$maj_data_directory/members/active/$username/password.txt","w");
                        fwrite($fp_passwd_txt,$passwd);
                        fclose($fp_passwd_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");
+                       $firstname = file_get_contents("$maj_data_directory/members/active/$username/firstname.txt");
+                       $lastname = file_get_contents("$maj_data_directory/members/active/$username/lastname.txt");
+                       $email = file_get_contents("$maj_data_directory/members/active/$username/email.txt");
+                       $from_email = file_get_contents("$maj_data_directory/email.txt");
 
                        $mailer = 'MAJ/2.0 (PHP/' . phpversion() . ')';
 
-                       $sig_author = file_get_contents("data/author.txt");
+                       $sig_author = file_get_contents("$maj_data_directory/author.txt");
 
                        $sig_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/";
                        $sig_url = str_replace('//', '/', $sig_url);
                        $sig_url = "http://" . $sig_url;
 
                        $registered_notice = "$firstname $lastname ($email), AKA $username, has been successfully registered at {$sig_url}.";
-                       $registered_notice = wordwrap($registered_notice);
+                       //$registered_notice = wordwrap($registered_notice);
 
                        $password_notice = "Hi $firstname,\n\nYour membership at $sig_url has been activated.\n\nThe initial 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\nIf you need further assistance, please send email to $from_email.\n\nThanks!\n\n--\n$sig_author\n$sig_url\n";
-
-                       $password_notice = wordwrap($password_notice);
+                       //$password_notice = wordwrap($password_notice);
 
                        $email_from = '"' . $sig_author . '" <' . $from_email . '>';
                        $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
 
-                       mail($email_from, "registration notice ($email)", $registered_notice,
+                       mb_send_mail($email_from, "registration notice ($email)", $registered_notice,
                                "From: $email_from\r\n" .
                                "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
 
-                       mail($email_to, "password notice ($username)", $password_notice,
+                       mb_send_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");
+                       $fp_new_txt = fopen("$maj_data_directory/bb-new.txt","w");
                        fwrite($fp_new_txt,$username);
                        fclose($fp_new_txt);
 
-                       echo "<p><font style=\"font-size: 12px;\"><b>Approved</b></font></p><p>The e-mail address ";
-                       readfile("data/members/active/$username/email.txt");
-                       echo " has been registered.<br>Click <a href=index.php>here</a> to go to the index page.</p>";
+                       echo "<font style=\"font-size: 12px;\"><b>Approved</b></font><br>The e-mail address ";
+                       readfile("$maj_data_directory/members/active/$username/email.txt");
+                       echo " has been registered.<br>Click <a href=index.php>here</a> to go to the index page.";
                }
 
                if ($_REQUEST['action'] == "deny") {
-                       rmdirr("data/members/confirmed/$username");
-                       echo "<p><font style=\"font-size: 12px;\"><b>Denied</b></font></p><p>The e-mail address ";
-                       readfile("data/members/active/$username/email.txt");
-                       echo " will not be registered.<br>Registration request deleted.<br>Click <a href=index.php>here</a> to go to the index page.</p>";
+                       rmdirr("$maj_data_directory/members/confirmed/$username");
+                       echo "<font style=\"font-size: 12px;\"><b>Denied</b></font><br>The e-mail address ";
+                       readfile("$maj_data_directory/members/active/$username/email.txt");
+                       echo " will not be registered.<br>Registration request deleted.<br>Click <a href=index.php>here</a> to go to the index page.";
                }
 
        }
        exit();
 }
 
-if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and ereg('^[^./][^/]*$', $_REQUEST['username'])) {
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and mb_ereg('^[^./][^/]*$', $_REQUEST['username'])) {
 
-       $username = $_REQUEST['username'];
+       $username = trim(strip_tags($_REQUEST['username']));
 
-       if (file_exists("data/members/pending/$username") and ($_REQUEST['key'] == file_get_contents("data/members/pending/$username/key.txt"))) {
+       if (file_exists("$maj_data_directory/members/pending/$username") and ($_REQUEST['key'] == file_get_contents("$maj_data_directory/members/pending/$username/key.txt"))) {
 
-               $firstname = file_get_contents("data/members/pending/$username/firstname.txt");
-               $lastname = file_get_contents("data/members/pending/$username/lastname.txt");
-               $email = file_get_contents("data/members/pending/$username/email.txt");
-               $from_email = file_get_contents("data/email.txt");
+               $firstname = file_get_contents("$maj_data_directory/members/pending/$username/firstname.txt");
+               $lastname = file_get_contents("$maj_data_directory/members/pending/$username/lastname.txt");
+               $email = file_get_contents("$maj_data_directory/members/pending/$username/email.txt");
+               $from_email = file_get_contents("$maj_data_directory/email.txt");
 
                $mailer = 'MAJ/2.0 (PHP/' . phpversion() . ')';
 
@@ -262,49 +159,49 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
                $sig_url = str_replace('//', '/', $sig_url);
                $sig_url = "http://" . $sig_url;
 
-               $sig_author = file_get_contents("data/author.txt");
+               $sig_author = file_get_contents("$maj_data_directory/author.txt");
 
-               unlink("data/members/pending/$username/key.txt");
+               unlink("$maj_data_directory/members/pending/$username/key.txt");
 
-               $timestamp = date("YmdHis", time() + $offset);
+               $timestamp = date("YmdHis", time() + $maj_offset);
 
-               $fp_timestamp_txt = fopen("data/members/pending/$username/timestamp.txt","w");
+               $fp_timestamp_txt = fopen("$maj_data_directory/members/pending/$username/timestamp.txt","w");
                fwrite($fp_timestamp_txt,$timestamp);
                fclose($fp_timestamp_txt);
 
-               if (!file_exists("data/xapp.txt")) {
-                       if (!file_exists("data/members/confirmed")) {
-                               mkdir("data/members/confirmed");
+               if (!file_exists("$maj_data_directory/xapp.txt")) {
+                       if (!file_exists("$maj_data_directory/members/confirmed")) {
+                               mkdir("$maj_data_directory/members/confirmed");
                        }
-                       rename("data/members/pending/$username","data/members/confirmed/$username");
+                       rename("$maj_data_directory/members/pending/$username","$maj_data_directory/members/confirmed/$username");
 
                        $key = str_rand(40);
 
-                       $fp_key_txt = fopen("data/members/confirmed/$username/key.txt","w");
+                       $fp_key_txt = fopen("$maj_data_directory/members/confirmed/$username/key.txt","w");
                        fwrite($fp_key_txt,$key);
                        fclose($fp_key_txt);
 
                        $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);
+                       //$confirmation_notice = wordwrap($confirmation_notice);
 
                        $email_from = '"' . $sig_author . '" <' . $from_email . '>';
 
-                       mail($email_from, "confirmation notice ($email)", $confirmation_notice,
+                       mb_send_mail($email_from, "confirmation notice ($email)", $confirmation_notice,
                                "From: $email_from\r\n" .
                                "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
                }
                else {
-                       if (!file_exists("data/members/active")) {
-                               mkdir("data/members/active");
+                       if (!file_exists("$maj_data_directory/members/active")) {
+                               mkdir("$maj_data_directory/members/active");
                        }
-                       rename("data/members/pending/$username","data/members/active/$username");
+                       rename("$maj_data_directory/members/pending/$username","$maj_data_directory/members/active/$username");
                        $registered_notice = "$firstname $lastname ($email), AKA $username, has been successfully registered at {$sig_url}.";
-                       $registered_notice = wordwrap($registered_notice);
+                       //$registered_notice = wordwrap($registered_notice);
 
                        $email_from = '"' . $sig_author . '" <' . $from_email . '>';
 
-                       mail($email_from, "registration notice ($email)", $registered_notice,
+                       mb_send_mail($email_from, "registration notice ($email)", $registered_notice,
                                "From: $email_from\r\n" .
                                "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
@@ -316,51 +213,50 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
                        $passwd = md5($passwd);
                        $passwd = crypt($passwd, $passwd);
 
-                       $fp_passwd_txt = fopen("data/members/active/$username/password.txt","w");
+                       $fp_passwd_txt = fopen("$maj_data_directory/members/active/$username/password.txt","w");
                        fwrite($fp_passwd_txt,$passwd);
                        fclose($fp_passwd_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");
+                       $firstname = file_get_contents("$maj_data_directory/members/active/$username/firstname.txt");
+                       $lastname = file_get_contents("$maj_data_directory/members/active/$username/lastname.txt");
+                       $email = file_get_contents("$maj_data_directory/members/active/$username/email.txt");
+                       $from_email = file_get_contents("$maj_data_directory/email.txt");
 
                        $mailer = 'MAJ/2.0 (PHP/' . phpversion() . ')';
 
-                       $sig_author = file_get_contents("data/author.txt");
+                       $sig_author = file_get_contents("$maj_data_directory/author.txt");
 
                        $sig_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/";
                        $sig_url = str_replace('//', '/', $sig_url);
                        $sig_url = "http://" . $sig_url;
 
                        $password_notice = "Hi $firstname,\n\nYour membership at $sig_url has been activated.\n\nThe initial 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\nIf you need further assistance, please send email to $from_email.\n\nThanks!\n\n--\n$sig_author\n$sig_url\n";
-
-                       $password_notice = wordwrap($password_notice);
+                       //$password_notice = wordwrap($password_notice);
 
                        $email_from = '"' . $sig_author . '" <' . $from_email . '>';
                        $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
 
-                       mail($email_to, "password notice ($username)", $password_notice,
+                       mb_send_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");
+                       $fp_new_txt = fopen("$maj_data_directory/bb-new.txt","w");
                        fwrite($fp_new_txt,$username);
                        fclose($fp_new_txt);
                       
                }
 
-               echo "<p><font style=\"font-size: 12px;\"><b>Thanks!</b></font></p><p>You have successfully verified your e-mail address.<br>";
+               echo "<font style=\"font-size: 12px;\"><b>Thanks!</b></font>You have successfully verified your e-mail address.<br>";
 
-               if (file_exists("data/xapp.txt")) {
+               if (file_exists("$maj_data_directory/xapp.txt")) {
                        echo "You are now a registered member on this site.";
                }
                else {
                        echo "Your membership will be activated as soon as your registration is approved.";
                }
 
-               echo "<br>Click <a href=index.php>here</a> to go to the index page.</p>";
+               echo "<br>Click <a href=index.php>here</a> to go to the index page.";
 
        }
 
@@ -369,7 +265,7 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
 
 if ($_POST['submit'] == "1") {
 
-       $check_members = array_merge(glob("data/members/active/*"),glob("data/members/confirmed/*"),glob("data/members/pending/*"));
+       $check_members = array_merge(glob("$maj_data_directory/members/active/*"),glob("$maj_data_directory/members/confirmed/*"),glob("$maj_data_directory/members/pending/*"));
       
        $err_reg = "0";
 
@@ -380,26 +276,26 @@ if ($_POST['submit'] == "1") {
        }
        else {
                $username = strip_tags($_REQUEST['username']);
-               $username = htmlentities($username, ENT_NOQUOTES);
+               $username = htmlentities($username, ENT_QUOTES, 'UTF-8');
                $username = trim($username);
                $username = str_replace(" ","_",$username);
-               $username = strtolower($username);
+               $username = mb_strtolower($username);
               
                $err_username = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$username</td>";
       
-               if (($username == "all") or ereg('^\.', $username) or ereg('\.$', $username) or ereg('@', $username)) {
+               if (($username == "all") or mb_ereg('^\.', $username) or mb_ereg('\.$', $username) or mb_ereg('@', $username)) {
                        $err_reg = $err_reg + 1;
                        $err_username = "The username $username is not allowed on this site.";
                        $err_username = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_username</td>";
                }
 
-               if (preg_match("/\b$username\b/i", file_get_contents("data/bb-reserved.txt"))) {
+               if (preg_match("/\b$username\b/i", file_get_contents("$maj_data_directory/bb-reserved.txt"))) {
                        $err_reg = $err_reg + 1;
                        $err_username = "The username $username is reserved, please try again.";
                        $err_username = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_username</td>";
                }
 
-               if (file_exists("data/members/pending/$username") or file_exists("data/members/confirmed/$username") or file_exists("data/members/active/$username") or ($username == file_get_contents("data/username.txt"))) {
+               if (file_exists("$maj_data_directory/members/pending/$username") or file_exists("$maj_data_directory/members/confirmed/$username") or file_exists("$maj_data_directory/members/active/$username") or ($username == file_get_contents("$maj_data_directory/username.txt"))) {
                        $err_reg = $err_reg + 1;
                        $err_username = "The username $username is already taken, please try again.";
                        $err_username = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_username</td>";
@@ -413,9 +309,9 @@ if ($_POST['submit'] == "1") {
        }
        else {
                $firstname = strip_tags($_POST['firstname']);
-               $firstname = htmlentities($firstname, ENT_NOQUOTES);
+               $firstname = htmlentities($firstname, ENT_QUOTES, 'UTF-8');
                $firstname = trim($firstname);
-               $firstname = strtolower($firstname);           
+               $firstname = mb_strtolower($firstname);        
                $firstname = ucwords($firstname);
               
                $err_firstname = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$firstname</td>";
@@ -428,9 +324,9 @@ if ($_POST['submit'] == "1") {
        }
        else {
                $lastname = strip_tags($_POST['lastname']);
-               $lastname = htmlentities($lastname, ENT_NOQUOTES);
+               $lastname = htmlentities($lastname, ENT_QUOTES, 'UTF-8');
                $lastname = trim($lastname);
-               $lastname = strtolower($lastname);
+               $lastname = mb_strtolower($lastname);
                $lastname = ucwords($lastname);
 
                $err_lastname = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$lastname</td>";
@@ -438,7 +334,7 @@ if ($_POST['submit'] == "1") {
       
        if (isset($firstname) and isset($lastname)) {
       
-               if ((strtolower($firstname) . " " . strtolower($lastname)) == strtolower(file_get_contents("data/author.txt"))) {
+               if ((mb_strtolower($firstname) . " " . mb_strtolower($lastname)) == mb_strtolower(file_get_contents("$maj_data_directory/author.txt"))) {
                        $err_reg = $err_reg + 1;
                        $err_firstname = "$firstname $lastname is already registered.";
                        $err_firstname = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_firstname</td>";
@@ -447,7 +343,7 @@ if ($_POST['submit'] == "1") {
       
                foreach ($check_members as $check_member) {
               
-                       if ((strtolower($firstname) == strtolower(file_get_contents("$check_member/firstname.txt"))) and (strtolower($lastname) == strtolower(file_get_contents("$check_member/lastname.txt")))) {
+                       if ((mb_strtolower($firstname) == mb_strtolower(file_get_contents("$check_member/firstname.txt"))) and (mb_strtolower($lastname) == mb_strtolower(file_get_contents("$check_member/lastname.txt")))) {
                                $err_reg = $err_reg + 2;
                                $err_firstname = "$firstname $lastname is already registered.";
                                $err_firstname = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_firstname</td>";
@@ -463,26 +359,26 @@ if ($_POST['submit'] == "1") {
        }
        else { 
                $email = strip_tags($_POST['email']);
-               $email = htmlentities($email, ENT_NOQUOTES);
+               $email = htmlentities($email, ENT_QUOTES, 'UTF-8');
                $email = trim($email);
-               $email = strtolower($email);
+               $email = mb_strtolower($email);
                $email = str_replace(" ","",$email);
 
                $err_email = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$email</td>";
 
-               if (!ereg("@", $email) or !ereg("\.", $email) or ereg('^\.', $email) or ereg('\.$', $email)) {
+               if (!mb_ereg("@", $email) or !mb_ereg("\.", $email) or mb_ereg('^\.', $email) or mb_ereg('\.$', $email)) {
                        $err_reg = $err_reg + 1;
                        $err_email = "The email address $email is invalid.";
                        $err_email = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_email</td>";
                }
 
-               if (preg_match("/\b$email\b/i", file_get_contents("data/bb-banned.txt"))) {
+               if (preg_match("/\b$email\b/i", file_get_contents("$maj_data_directory/bb-banned.txt"))) {
                        $err_reg = $err_reg + 1;
                        $err_email = "The email address $email is not allowed on this site.";
                        $err_email = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_email</td>";
                }
               
-               if ($email == file_get_contents("data/email.txt")) {
+               if ($email == file_get_contents("$maj_data_directory/email.txt")) {
                        $err_reg = $err_reg + 1;
                        $err_email = "The email address $email is already in use.";
                        $err_email = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_email</td>";
@@ -498,26 +394,26 @@ if ($_POST['submit'] == "1") {
                }
        }
 
-       if (!isset($_POST['bd_year']) or empty($_POST['bd_year']) or !isset($_POST['bd_month']) or empty($_POST['bd_month']) or !isset($_POST['bd_day']) or empty($_POST['bd_day']) or !is_numeric($_POST['bd_year']) or !is_numeric($_POST['bd_month']) or !is_numeric($_POST['bd_day'])or (strlen($_POST['bd_year']) > "4") or (strlen($_POST['bd_month']) > "2") or (strlen($_POST['bd_day']) > "2") or ($_POST['bd_month'] < 1) or ($_POST['bd_month'] > 12) or ($_POST['bd_day'] < 1) or ($_POST['bd_day'] > 31) or (date("Y", time() + $offset) < $_POST['bd_year']) or ((date("Y", time() + $offset) == $_POST['bd_year']) and (date("m", time() + $offset) < $_POST['bd_month'])) or ((date("Y", time() + $offset) == $_POST['bd_year']) and (date("m", time() + $offset) == $_POST['bd_month']) and (date("d", time() + $offset) < $_POST['bd_day']))) {
+       if (!isset($_POST['bd_year']) or empty($_POST['bd_year']) or !isset($_POST['bd_month']) or empty($_POST['bd_month']) or !isset($_POST['bd_day']) or empty($_POST['bd_day']) or !is_numeric($_POST['bd_year']) or !is_numeric($_POST['bd_month']) or !is_numeric($_POST['bd_day'])or (mb_strlen($_POST['bd_year']) > "4") or (mb_strlen($_POST['bd_month']) > "2") or (mb_strlen($_POST['bd_day']) > "2") or ($_POST['bd_month'] < 1) or ($_POST['bd_month'] > 12) or ($_POST['bd_day'] < 1) or ($_POST['bd_day'] > 31) or (date("Y", time() + $maj_offset) < $_POST['bd_year']) or ((date("Y", time() + $maj_offset) == $_POST['bd_year']) and (date("m", time() + $maj_offset) < $_POST['bd_month'])) or ((date("Y", time() + $maj_offset) == $_POST['bd_year']) and (date("m", time() + $maj_offset) == $_POST['bd_month']) and (date("d", time() + $maj_offset) < $_POST['bd_day']))) {
                $err_reg = $err_reg + 1;
                $err_bday = "The date you entered is invalid.";
                $err_bday = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_bday</td>";
        }
        else {
-               if ((date("m", time() + $offset) == $_POST['bd_month']) and (date("d", time() + $offset) == $_POST['bd_day'])) {
+               if ((date("m", time() + $maj_offset) == $_POST['bd_month']) and (date("d", time() + $maj_offset) == $_POST['bd_day'])) {
                        $err_bday = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>Happy Birthday!</td>";
                }
                else {
                        $err_bday = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>{$_POST['bd_year']} {$_POST['bd_month']} {$_POST['bd_day']}</td>";
                }
               
-               if ((date("Y", time() + $offset) - $_POST['bd_year']) > $maxage) {
+               if ((date("Y", time() + $maj_offset) - $_POST['bd_year']) > $maxage) {
                        $err_reg = $err_reg + 1;
                        $err_bday = "You are too old.";
                        $err_bday = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_bday</td>";
                }
       
-               if ((date("Y", time() + $offset) - $_POST['bd_year']) < $minage) {
+               if ((date("Y", time() + $maj_offset) - $_POST['bd_year']) < $minage) {
                        $err_reg = $err_reg + 1;
                        $err_bday = "You are too young.";
                        $err_bday = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_bday</td>";
@@ -530,8 +426,8 @@ if ($_POST['submit'] == "1") {
                $err_country = "<td><img src=\"images/widget.x.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$err_country</td>";
        }
        else {
-               $country = trim($_POST['country']);
-               $country = strtoupper($country);
+               $country = trim(strip_tags($_POST['country']));
+               $country = mb_strtoupper($country);
                $err_country = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$country</td>";
        }
 
@@ -542,9 +438,9 @@ if ($_POST['submit'] == "1") {
        }
        else {
                $city = strip_tags($_POST['city']);
-               $city = htmlentities($city, ENT_NOQUOTES);
+               $city = htmlentities($city, ENT_QUOTES, 'UTF-8');
                $city = trim($city);
-               $city = strtolower($city);
+               $city = mb_strtolower($city);
                $city = ucwords($city);
 
                $err_city = "<td><img src=\"images/widget.ok.png\" border=\"0\" width=\"14\" height=\"14\"></td><td>$city</td>";
@@ -560,7 +456,7 @@ if ($_POST['submit'] == "1") {
 
                        $err_reg = $err_reg + 1;
               
-                       if (file_exists("data/scaptcha.txt")) {
+                       if (file_exists("$maj_data_directory/scaptcha.txt")) {
                                $err_captcha = "The solution you entered is incorrect.";
                        }
                        else {
@@ -577,56 +473,56 @@ if ($_POST['submit'] == "1") {
 
        if ($err_reg < 1) {
 
-               if (!file_exists("data/members")) {
-                       mkdir("data/members");
+               if (!file_exists("$maj_data_directory/members")) {
+                       mkdir("$maj_data_directory/members");
                }
 
-               if (!file_exists("data/members/pending")) {
-                       mkdir("data/members/pending");
+               if (!file_exists("$maj_data_directory/members/pending")) {
+                       mkdir("$maj_data_directory/members/pending");
                }
       
-               mkdir("data/members/pending/$username");
+               mkdir("$maj_data_directory/members/pending/$username");
 
-               $fp_firstname_txt = fopen("data/members/pending/$username/firstname.txt","w");
+               $fp_firstname_txt = fopen("$maj_data_directory/members/pending/$username/firstname.txt","w");
                fwrite($fp_firstname_txt,$firstname);
                fclose($fp_firstname_txt);
 
-               $fp_lastname_txt = fopen("data/members/pending/$username/lastname.txt","w");
+               $fp_lastname_txt = fopen("$maj_data_directory/members/pending/$username/lastname.txt","w");
                fwrite($fp_lastname_txt,$lastname);
                fclose($fp_lastname_txt);
 
-               $fp_email_txt = fopen("data/members/pending/$username/email.txt","w");
+               $fp_email_txt = fopen("$maj_data_directory/members/pending/$username/email.txt","w");
                fwrite($fp_email_txt,$email);
                fclose($fp_email_txt);
 
                $bday = $_POST['bd_year'] . $_POST['bd_month'] . $_POST['bd_day'];
-               $fp_bday_txt = fopen("data/members/pending/$username/bday.txt","w");
+               $fp_bday_txt = fopen("$maj_data_directory/members/pending/$username/bday.txt","w");
                fwrite($fp_bday_txt,$bday);
                fclose($fp_bday_txt);
 
-               if (isset($_POST['url']) and !empty($_POST['url']) and (ereg("\.", $_POST['url']))) {
+               if (isset($_POST['url']) and !empty($_POST['url']) and (mb_ereg("\.", $_POST['url']))) {
                        $url = str_replace('http://', '', $_POST['url']);
-                       $url = strtolower($url);
+                       $url = mb_strtolower($url);
                        $url = trim($url);
                        $url = 'http://' . $url;
                        $url = str_replace(" ","",$url);
-                       $url = htmlentities($url, ENT_NOQUOTES);
-                       $fp_url_txt = fopen("data/members/pending/$username/url.txt","w");
+                       $url = htmlentities($url, ENT_QUOTES, 'UTF-8');
+                       $fp_url_txt = fopen("$maj_data_directory/members/pending/$username/url.txt","w");
                        fwrite($fp_url_txt,$url);
                        fclose($fp_url_txt);
                }
 
-               $fp_country_txt = fopen("data/members/pending/$username/country.txt","w");
+               $fp_country_txt = fopen("$maj_data_directory/members/pending/$username/country.txt","w");
                fwrite($fp_country_txt,$country);
                fclose($fp_country_txt);
 
-               $fp_city_txt = fopen("data/members/pending/$username/city.txt","w");
+               $fp_city_txt = fopen("$maj_data_directory/members/pending/$username/city.txt","w");
                fwrite($fp_city_txt,$city);
                fclose($fp_city_txt);
 
                $key = str_rand(40);
 
-               $fp_key_txt = fopen("data/members/pending/$username/key.txt","w");
+               $fp_key_txt = fopen("$maj_data_directory/members/pending/$username/key.txt","w");
                fwrite($fp_key_txt,$key);
                fclose($fp_key_txt);
 
@@ -636,17 +532,16 @@ if ($_POST['submit'] == "1") {
                $sig_url = str_replace('//', '/', $sig_url);
                $sig_url = "http://" . $sig_url;
 
-               $sig_author = file_get_contents("data/author.txt");
-               $from_email = file_get_contents("data/email.txt");
+               $sig_author = file_get_contents("$maj_data_directory/author.txt");
+               $from_email = file_get_contents("$maj_data_directory/email.txt");
 
                $confirm_thanks = "Hi $firstname,\n\nWe have received a registration request for $email to $sig_url. To confirm this, simply visit this link:\n\n{$sig_url}reg.php?username=$username&key=$key\n\nIf you do not wish to be a member, please disregard this message. If you think you are being maliciously registered, or have any other questions, send them to $from_email.\n\nThanks!\n\n--\n$sig_author\n$sig_url\n";
-
-               $confirm_thanks = wordwrap($confirm_thanks);
+               //$confirm_thanks = wordwrap($confirm_thanks);
 
                $email_from = '"' . $sig_author . '" <' . $from_email . '>';
                $email_to =  '"' . "$firstname $lastname" . '" <' . $email . '>';
 
-               mail($email_to, "confirm $key", $confirm_thanks,
+               mb_send_mail($email_to, "confirm $key", $confirm_thanks,
                                "From: $email_from\r\n" .
                                "Reply-To: $email_from\r\n" .
                                "X-Mailer: $mailer");
@@ -660,21 +555,21 @@ if ($_POST['submit'] == "1") {
                unset($err_city);
                unset($err_captcha);
               
-               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>";
+               echo "<font style=\"font-size: 12px;\"><b>Thanks!</b></font><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>";
        }
 }
 
 ?>
 
-<p><b>Register</b></p><p>
+<b>Register</b>
 
 <?php
 
-if (!file_exists("data/scaptcha.txt")) {
+if (!file_exists("$maj_data_directory/scaptcha.txt")) {
 
        $captcha_rand = str_rand(7);
 
-       echo "Complete all required fields and enter <b>$captcha_rand</b> as your registration code below.";
+       echo "<p>Complete all required fields and enter <b>$captcha_rand</b> as your registration code below.</p>";
 }
 else {
        $scaptcha_x = rand(1,10);
@@ -683,38 +578,36 @@ else {
 
        $captcha_rand = $scaptcha_x + $scaptcha_y + $scaptcha_z;
 
-       echo "Complete all required fields and solve the simple equation below.";
+       echo "<p>Complete all required fields and solve the simple equation below.</p>";
 }
 
 if ($err_reg == 1) {
-       echo " $err_reg error detected, please try again.";
+       echo "<p>$err_reg error detected, please try again.</p>";
 }
 
 if ($err_reg > 1) {
-       echo " $err_reg errors detected, please try again.";
+       echo "</p>$err_reg errors detected, please try again.</p>";
 }
 
-echo "</p>";
-
-if (file_exists("data/bb-disclaimer.txt")) {
+if (file_exists("$maj_data_directory/bb-disclaimer.txt")) {
        echo "<p>";
-       readfile("data/bb-disclaimer.txt");
+       readfile("$maj_data_directory/bb-disclaimer.txt");
        echo "</p>";
 }
 
 ?>
 
 <table border="0" cellspacing="2" cellpadding="0">
-<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<form enctype="multipart/form-data" method="post">
 <input type=hidden name=captcha_get value="<?php echo $captcha_rand; ?>">
-<tr><td width=100><p>Username</p></td><td colspan=3><input required autofocus class=input type=text autocomplete=off name=username maxlength=30></td><?php echo $err_username; ?></tr>
-<tr><td width=100><p>First Name</p></td><td width=300 colspan=3><input required class=input type=text autocomplete=off name=firstname maxlength=30></td><?php echo $err_firstname; ?></tr>
-<tr><td width=100><p>Last Name</p></td><td colspan=3><input required class=input type=text autocomplete=off name=lastname maxlength=30></td><?php echo $err_lastname; ?></tr>
-<tr><td width=100><p>E-mail Address</p></td><td colspan=3><input required class=input type=email autocomplete=off name=email maxlength=60></td><?php echo $err_email; ?></tr>
-<tr><td width=100><p>Birthdate</p></td><td><input required class=bd type=text autocomplete=off name=bd_year maxlength=4 value=YYYY></td><td><input required class=bd type=text autocomplete=off name=bd_month maxlength=2 value=MM></td><td><input required class=bd type=text autocomplete=off name=bd_day maxlength=2 value=DD></td><?php echo $err_bday; ?></tr>
-<tr><td width=100><p>Website (optional)</p></td><td colspan=3><input class=input type=url autocomplete=off name=url maxlength=300></td></tr>
+<tr><td width="100">Username</td><td colspan="3"><input required autofocus class="input" type="text" autocomplete="off" name="username" maxlength="30"></td><?php echo $err_username; ?></tr>
+<tr><td width="100">First Name</td><td width="300" colspan="3"><input required class="input" type="text" autocomplete="off" name="firstname" maxlength="30"></td><?php echo $err_firstname; ?></tr>
+<tr><td width="100">Last Name</td><td colspan="3"><input required class="input" type="text" autocomplete="off" name="lastname" maxlength="30"></td><?php echo $err_lastname; ?></tr>
+<tr><td width="100">E-mail Address</td><td colspan="3"><input required class="input" type="email" autocomplete="off" name="email" maxlength="60"></td><?php echo $err_email; ?></tr>
+<tr><td width="100">Birthdate</td><td><input required class="bd" type="text" autocomplete="off" name="bd_year" maxlength="4" value="YYYY"></td><td><input required class="bd" type="text" autocomplete="off" name="bd_month" maxlength="2" value="MM"></td><td><input required class="bd" type="text" autocomplete="off" name="bd_day" maxlength="2" value="DD"></td><?php echo $err_bday; ?></tr>
+<tr><td width="100">Website (optional)</td><td colspan="3"><input class="input" type="url" autocomplete="off" name="url" maxlength="300"></td></tr>
 
-<tr><td width=100><p>Country</p></td><td colspan=3>
+<tr><td width="100">Country</td><td colspan=3>
 
 <select class="input" name="country" required>
 <option value=""></option>
@@ -965,20 +858,20 @@ if (file_exists("data/bb-disclaimer.txt")) {
 
 </td><?php echo $err_country; ?></tr>
 
-<tr><td width=100><p>City or Municipality</p></td><td colspan=3><input required class=input type=text autocomplete=off name=city maxlength=100></td><?php echo $err_city; ?></tr>
+<tr><td width="100">City or Municipality</td><td colspan="3"><input required class="input" type="text" autocomplete="off" name="city" maxlength="100"></td><?php echo $err_city; ?></tr>
 
-<tr><td width=100><p><?php
+<tr><td width="100"><?php
 
-if (!file_exists("data/scaptcha.txt")) {
+if (!file_exists("$maj_data_directory/scaptcha.txt")) {
        echo "Registration Code";
 }
 else {
        echo "$scaptcha_x + $scaptcha_y + $scaptcha_z =";
 }
 
-?></p></td><td colspan=3><input required class=input type=text autocomplete=off name=captcha_put maxlength=7></td><?php echo $err_captcha; ?></tr>
-<tr><td><p></p></td><td colspan=3><input type=hidden name=submit value=1><input class=input type=submit value="click here to submit your registration"></td></tr>
+?></td><td colspan="3"><input required class="input" type="text" autocomplete="off" name="captcha_put" maxlength="7"></td><?php echo $err_captcha; ?></tr>
+<tr><td></td><td colspan="3"><input type="hidden" name="submit" value="1"><input class="click" type="submit" value="click here to submit your registration"></td></tr>
 </form>
 <form enctype="multipart/form-data" method="post">
-<tr><td><p></p></td><td colspan=3><input type="hidden" name="go" value="index"><input class=input type=submit value="click here to go to the index page"></td></tr>
+<tr><td></td><td colspan="3"><input type="hidden" name="go" value="index"><input class="click" type="submit" value="click here to go to the index page"></td></tr>
 </form>
diff --git a/reset.php b/reset.php
index 834b189..c4e096b 100644
--- a/reset.php
+++ b/reset.php
@@ -1,126 +1,49 @@
 <?php
 
-session_start();
-
-header("Cache-control: private");
+require("core.php");
 
-if (file_exists("data/lite.txt")) {
+if (file_exists("$maj_data_directory/lite.txt")) {
        exit();
 }
 
-if (!file_exists("data/reset.txt")) {
+if (!file_exists("$maj_data_directory/reset.txt")) {
        exit();
 }
 
-error_reporting(E_ERROR);
-
-require("core.php");
-
-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");
+if (file_exists("$maj_data_directory/bb-min-age.txt")) {
+       $minage = file_get_contents("$maj_data_directory/bb-min-age.txt");
 }
 else {
        $minage = 5;
 }
 
-if (file_exists("data/bb-max-age.txt")) {
-       $maxage = file_get_contents("data/bb-max-age.txt");
+if (file_exists("$maj_data_directory/bb-max-age.txt")) {
+       $maxage = file_get_contents("$maj_data_directory/bb-max-age.txt");
 }
 else {
        $maxage = 125;
 }
 
-?>
+include("css.php");
 
-<title>Reset</title>
+echo "\n<style> body { margin: {$maj_wspace}px; } .input, .click { width: 200px; } </style>\n";
 
-<style>
-
-body {
-       color: #666666;
-       margin: 10px;
-       padding: 0px;
-       text-align: left;
-       font-family: <?php
-                               if (file_exists("data/fonts/body.txt")) {
-                                       $font_body = file_get_contents("data/fonts/body.txt");
-                                       echo "{$font_body},";
-                               }
-       ?> arial, 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: <?php
-                               if (file_exists("data/fonts/input.txt")) {
-                                       $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
-                               }
-       ?> arial, helvetica, sans-serif;
-       font-size: 11px;
-}
-</style>
+<title>Reset</title>
 
-<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<form enctype="multipart/form-data" method="post">
 <input required autofocus autocomplete="off" class="input" type="text" name="username">
 <input required autocomplete="off" class="input" type="email" name="addr">
 <input required autocomplete="off" class="input" type="text" name="bday">
-<input class="input" type="submit" value="reset">
+<input class="click" type="submit" value="reset">
 </form>
 
 <?php
 
-if (isset($_POST['username']) and !empty($_POST['username']) and isset($_POST['addr']) and !empty($_POST['addr']) and file_exists("data/members/active/{$_POST['username']}") and file_exists("data/bb.txt") and (trim(strtolower($_POST['addr'])) == file_get_contents("data/members/active/{$_POST['username']}/email.txt")) and isset($_POST['bday']) and !empty($_POST['bday']) and file_exists("data/members/active/{$_POST['username']}/bday.txt") and (strlen($_POST['bday']) == "8") and is_numeric($_POST['bday']) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $offset) - $_POST['bday']) * 0.0001)) <= $maxage) and ($_POST['bday'] == file_get_contents("data/members/active/{$_POST['username']}/bday.txt"))) {
-
-       $username = $_POST['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;
-       }
+if (isset($_POST['username']) and !empty($_POST['username']) and isset($_POST['addr']) and !empty($_POST['addr']) and file_exists("$maj_data_directory/members/active/{$_POST['username']}") and file_exists("$maj_data_directory/bb.txt") and (trim(mb_strtolower($_POST['addr'])) == file_get_contents("$maj_data_directory/members/active/{$_POST['username']}/email.txt")) and isset($_POST['bday']) and !empty($_POST['bday']) and file_exists("$maj_data_directory/members/active/{$_POST['username']}/bday.txt") and (mb_strlen($_POST['bday']) == "8") and is_numeric($_POST['bday']) and ((round((date("Ymd", time() + $maj_offset) - $_POST['bday']) * 0.0001)) >= $minage) and ((round((date("Ymd", time() + $maj_offset) - $_POST['bday']) * 0.0001)) <= $maxage) and ($_POST['bday'] == file_get_contents("$maj_data_directory/members/active/{$_POST['username']}/bday.txt"))) {
 
+       $username = trim(strip_tags($_POST['username']));
        $password = str_rand(16);
       
        /* Fun with crypt! */
@@ -128,12 +51,12 @@ if (isset($_POST['username']) and !empty($_POST['username']) and isset($_POST['a
        $passwd = md5($passwd);
        $passwd = crypt($passwd, $passwd);
 
-       $fp_passwd_txt = fopen("data/members/active/$username/password.txt","w");
+       $fp_passwd_txt = fopen("$maj_data_directory/members/active/$username/password.txt","w");
        fwrite($fp_passwd_txt,$passwd);
        fclose($fp_passwd_txt);
       
-       if (file_exists("data/members/active/$username/bb-resetx.txt")) {
-               $resetx = file_get_contents("data/members/active/$username/bb-resetx.txt");
+       if (file_exists("$maj_data_directory/members/active/$username/bb-resetx.txt")) {
+               $resetx = file_get_contents("$maj_data_directory/members/active/$username/bb-resetx.txt");
        }
        else {
                $resetx = 0;
@@ -141,23 +64,23 @@ if (isset($_POST['username']) and !empty($_POST['username']) and isset($_POST['a
 
        $resetx = $resetx + 1;
 
-       $fp_resetx_txt = fopen("data/members/active/$username/bb-resetx.txt","w");
+       $fp_resetx_txt = fopen("$maj_data_directory/members/active/$username/bb-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/bb-resetl.txt","w");
+       $resetl = date("Ymd", time() + $maj_offset);
+       $fp_resetl_txt = fopen("$maj_data_directory/members/active/$username/bb-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");
+       $firstname = file_get_contents("$maj_data_directory/members/active/$username/firstname.txt");
+       $lastname = file_get_contents("$maj_data_directory/members/active/$username/lastname.txt");
+       $email = file_get_contents("$maj_data_directory/members/active/$username/email.txt");
+       $from_email = file_get_contents("$maj_data_directory/email.txt");
 
        $mailer = 'MAJ/2.0 (PHP/' . phpversion() . ')';
 
-       $sig_author = file_get_contents("data/author.txt");
+       $sig_author = file_get_contents("$maj_data_directory/author.txt");
 
        $from_email = '"' . $sig_author . '" <' . $from_email . '>';
        $email = '"' . "$firstname $lastname" . '" <' . $email . '>';
@@ -167,28 +90,27 @@ if (isset($_POST['username']) and !empty($_POST['username']) and isset($_POST['a
        $sig_url = "http://" . $sig_url;
 
        $reset_notice = "Password for $username at $sig_url reset by $firstname $lastname.";
-       $reset_notice = wordwrap($reset_notice);
+       //$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);
 
-       $password_notice = wordwrap($password_notice);
-
-       mail($from_email, "password reset notice ($username)", $reset_notice,
+       mb_send_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,
+       mb_send_mail($email, "password reset notice ($username)", $password_notice,
                "From: $from_email\r\n" .
                "Reply-To: $from_email\r\n" .
                "X-Mailer: $mailer");
 
-       if (file_exists("data/members/active/$username/bb-lockout.txt")) {
-               unlink("data/members/active/$username/bb-lockout.txt");
+       if (file_exists("$maj_data_directory/members/active/$username/bb-lockout.txt")) {
+               unlink("$maj_data_directory/members/active/$username/bb-lockout.txt");
        }
 
        echo "<p><font style=\"font-size: 12px;\"><b>Password Reset</b></font></p><p>Check your ";
-       readfile("data/members/active/$username/email.txt");
+       readfile("$maj_data_directory/members/active/$username/email.txt");
        echo " account for your new password.";
 }
 else {
@@ -197,4 +119,4 @@ else {
 
 ?>
 
-<br>Click <a href=login.php>here</a> to login. Click <a href=index.php>here</a> to go to the index page.</p>
+<br>Click <a href="login.php">here</a> to login. Click <a href=".">here</a> to go to the index page.</p>
diff --git a/settings.php b/settings.php
index fd9fe98..114b510 100644
--- a/settings.php
+++ b/settings.php
@@ -34,10 +34,10 @@ if (isset($_POST['author']) and !empty($_POST['author']) and (file_get_contents(
        fclose($fp_author_txt);
 }
 
-if (isset($_POST['email']) and !empty($_POST['email']) and (file_get_contents("data/email.txt") != $_POST['email']) and (ereg("@", $_POST['email'])) and (ereg("\.", $_POST['email']))) {
-       $email_write_content = strtolower($_POST['email']);
+if (isset($_POST['email']) and !empty($_POST['email']) and (file_get_contents("data/email.txt") != $_POST['email']) and (mb_ereg("@", $_POST['email'])) and (mb_ereg("\.", $_POST['email']))) {
+       $email_write_content = mb_strtolower($_POST['email']);
        $email_write_content = trim($email_write_content);
-       $email_write_content = htmlentities($email_write_content, ENT_NOQUOTES);
+       $email_write_content = htmlentities($email_write_content, ENT_QUOTES, 'UTF-8');
        $fp_email_txt = fopen("data/email.txt","w");
        fwrite($fp_email_txt,$email_write_content);
        fclose($fp_email_txt);
@@ -80,10 +80,10 @@ if (!isset($_POST['offset']) or empty($_POST['offset']) or !is_numeric($_POST['o
        }
 }
 
-if (isset($_POST['ping']) and !empty($_POST['ping']) and (file_get_contents("data/ping.txt") != $_POST['ping']) and (ereg("\.", $_POST['ping'])) and (ereg("http://", $_POST['ping']))) {
-       $ping_write_content = strtolower($_POST['ping']);
+if (isset($_POST['ping']) and !empty($_POST['ping']) and (file_get_contents("data/ping.txt") != $_POST['ping']) and (mb_ereg("\.", $_POST['ping'])) and (mb_ereg("http://", $_POST['ping']))) {
+       $ping_write_content = mb_strtolower($_POST['ping']);
        $ping_write_content = trim($ping_write_content);
-       $ping_write_content = htmlentities($ping_write_content, ENT_NOQUOTES);
+       $ping_write_content = htmlentities($ping_write_content, ENT_QUOTES, 'UTF-8');
        $fp_ping_txt = fopen("data/ping.txt","w");
        fwrite($fp_ping_txt,$ping_write_content);
        fclose($fp_ping_txt);
@@ -390,7 +390,7 @@ if (!isset($_POST['pf']) or empty($_POST['pf'])) {
 }
 
 if (isset($_POST['pf_badwords']) and !empty($_POST['pf_badwords']) and (file_get_contents("data/pf-badwords.txt") != $_POST['pf_badwords'])) {
-       $pf_badwords_write_content = strtolower($_POST['pf_badwords']);
+       $pf_badwords_write_content = mb_strtolower($_POST['pf_badwords']);
        $pf_badwords_write_content = str_replace("\n","|",$pf_badwords_write_content);
        $pf_badwords_write_content = str_replace("\r","|",$pf_badwords_write_content);
        $pf_badwords_write_content = str_replace("||","|",$pf_badwords_write_content);
@@ -409,7 +409,7 @@ if (!isset($_POST['pf_badwords']) or empty($_POST['pf_badwords'])) {
 }
 
 if (isset($_POST['pf_censor']) and !empty($_POST['pf_censor']) and (file_get_contents("data/pf-censor.txt") != $_POST['pf_censor'])) {
-       $pf_censor_write_content = strtolower($_POST['pf_censor']);
+       $pf_censor_write_content = mb_strtolower($_POST['pf_censor']);
        $pf_censor_write_content = trim($pf_censor_write_content);
        $fp_pf_censor_txt = fopen("data/pf-censor.txt","w");
        fwrite($fp_pf_censor_txt,$pf_censor_write_content);
@@ -717,7 +717,7 @@ if (!isset($_POST['bb_invalid']) or empty($_POST['bb_invalid']) or !is_numeric($
 }
 
 if (isset($_POST['bb_reserved']) and !empty($_POST['bb_reserved']) and (file_get_contents("data/bb-reserved.txt") != $_POST['bb_reserved'])) {
-       $bb_reserved_write_content = strtolower($_POST['bb_reserved']);
+       $bb_reserved_write_content = mb_strtolower($_POST['bb_reserved']);
        $bb_reserved_write_content = trim($bb_reserved_write_content);
        $fp_bb_reserved_txt = fopen("data/bb-reserved.txt","w");
        fwrite($fp_bb_reserved_txt,$bb_reserved_write_content);
@@ -733,7 +733,7 @@ if (!isset($_POST['bb_reserved']) or empty($_POST['bb_reserved'])) {
 }
 
 if (isset($_POST['bb_banned']) and !empty($_POST['bb_banned']) and (file_get_contents("data/bb-banned.txt") != $_POST['bb_banned'])) {
-       $bb_banned_write_content = strtolower($_POST['bb_banned']);
+       $bb_banned_write_content = mb_strtolower($_POST['bb_banned']);
        $bb_banned_write_content = trim($bb_banned_write_content);
        $fp_bb_banned_txt = fopen("data/bb-banned.txt","w");
        fwrite($fp_bb_banned_txt,$bb_banned_write_content);
@@ -777,10 +777,10 @@ if (!isset($_POST['ml_from']) or empty($_POST['ml_from'])) {
        }
 }
 
-if (isset($_POST['ml_reply2']) and !empty($_POST['ml_reply2']) and (file_get_contents("data/ml-reply2.txt") != $_POST['ml_reply2']) and (ereg("@", $_POST['ml_reply2'])) and (ereg("\.", $_POST['ml_reply2']))) {
-       $ml_reply2_write_content = strtolower($_POST['ml_reply2']);
+if (isset($_POST['ml_reply2']) and !empty($_POST['ml_reply2']) and (file_get_contents("data/ml-reply2.txt") != $_POST['ml_reply2']) and (mb_ereg("@", $_POST['ml_reply2'])) and (mb_ereg("\.", $_POST['ml_reply2']))) {
+       $ml_reply2_write_content = mb_strtolower($_POST['ml_reply2']);
        $ml_reply2_write_content = trim($ml_reply2_write_content);
-       $ml_reply2_write_content = htmlentities($ml_reply2_write_content, ENT_NOQUOTES);
+       $ml_reply2_write_content = htmlentities($ml_reply2_write_content, ENT_QUOTES, 'UTF-8');
        $fp_ml_reply2_txt = fopen("data/ml-reply2.txt","w");
        fwrite($fp_ml_reply2_txt,$ml_reply2_write_content);
        fclose($fp_ml_reply2_txt);
@@ -1123,7 +1123,7 @@ if (isset($_FILES['background']) and !empty($_FILES['background'])) {
        }
 }
 
-if (file_exists("data/css.txt") and (strlen("data/css.txt") < 1)) {
+if (file_exists("data/css.txt") and (mb_strlen("data/css.txt") < 1)) {
        unlink("data/css.txt");
 }
 
@@ -1132,7 +1132,7 @@ if (isset($_POST['css']) and !empty($_POST['css'])) {
        $css_write_content = str_replace("</style>","",$css_write_content);
        $css_write_content = trim($css_write_content);
 
-       if (strlen($css_write_content) > 0) {
+       if (mb_strlen($css_write_content) > 0) {
                $fp_css_txt = fopen("data/css.txt","w");
                fwrite($fp_css_txt,$css_write_content);
                fclose($fp_css_txt);
diff --git a/unzip.lib.php b/unzip.lib.php
index cc87850..590d048 100644
--- a/unzip.lib.php
+++ b/unzip.lib.php
@@ -252,11 +252,11 @@
             $aE = explode("\x50\x4b\x05\x06", $vZ);
 
             // Easiest way, but not sure if format changes
-            //$this->Comment = substr($aE[1], 18);
+            //$this->Comment = mb_substr($aE[1], 18);
 
             // Normal way
             $aP = unpack('x16/v1CL', $aE[1]);
-            $this->Comment = substr($aE[1], 18, $aP['CL']);
+            $this->Comment = mb_substr($aE[1], 18, $aP['CL']);
 
             // Translates end of line from other operating systems
             $this->Comment = strtr($this->Comment, array("\r\n" => "\n",
@@ -283,19 +283,19 @@
 
                 // Special case : value block after the compressed data
                 if ($aP['GPF'] & 0x0008) {
-                    $aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
+                    $aP1 = unpack('V1CRC/V1CS/V1UCS', mb_substr($vZ, -12));
 
                     $aP['CRC'] = $aP1['CRC'];
                     $aP['CS']  = $aP1['CS'];
                     $aP['UCS'] = $aP1['UCS'];
 
-                    $vZ = substr($vZ, 0, -12);
+                    $vZ = mb_substr($vZ, 0, -12);
                 }
 
                 // Getting stored filename
-                $aI['N'] = substr($vZ, 26, $nF);
+                $aI['N'] = mb_substr($vZ, 26, $nF);
 
-                if (substr($aI['N'], -1) == '/') {
+                if (mb_substr($aI['N'], -1) == '/') {
                     // is a directory entry - will be skipped
                     continue;
                 }
@@ -305,9 +305,9 @@
                 $aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
                 $aI['N'] = basename($aI['N']);
 
-                $vZ = substr($vZ, 26 + $nF);
+                $vZ = mb_substr($vZ, 26 + $nF);
 
-                if (strlen($vZ) != $aP['CS']) {
+                if (mb_strlen($vZ) != $aP['CS']) {
                   $aI['E']  = 1;
                   $aI['EM'] = 'Compressed size is not equal with the value in header information.';
                 } else {
@@ -327,7 +327,7 @@
                             case 12: // BZIP2
 // 2003-12-02 - HB >
                                 if (! extension_loaded('bz2')) {
-                                    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+                                    if (mb_strtoupper(mb_substr(PHP_OS, 0, 3)) == 'WIN') {
                                       @dl('php_bz2.dll');
                                     } else {
                                       @dl('bz2.so');
@@ -358,7 +358,7 @@
                                 $aI['E']  = 2;
                                 $aI['EM'] = 'Decompression of data failed.';
                             } else {
-                                if (strlen($vZ) != $aP['UCS']) {
+                                if (mb_strlen($vZ) != $aP['UCS']) {
                                     $aI['E']  = 3;
                                     $aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
                                 } else {
diff --git a/wiki.php b/wiki.php
index 63c4056..8eff463 100644
--- a/wiki.php
+++ b/wiki.php
@@ -233,12 +233,12 @@ del {
                                $prev = str_replace("\n", " ", $prev);
                                $prev = str_replace("\r", " ", $prev);
                                $prev = preg_replace("/<img[^>]+src[\s='\"]+([^\"'>\s]+)[^>]*>/is", "[\\1]", $prev);
-                               $prev = htmlentities($prev, ENT_QUOTES);
+                               $prev = htmlentities($prev, ENT_QUOTES, 'UTF-8');
                                $body = str_replace("<br />", "<br>", $body);
                                $body = str_replace("\n", " ", $body);
                                $body = str_replace("\r", " ", $body);
                                $body = preg_replace("/<img[^>]+src[\s='\"]+([^\"'>\s]+)[^>]*>/is", "[\\1]", $body);
-                               $body = htmlentities($body, ENT_QUOTES);
+                               $body = htmlentities($body, ENT_QUOTES, 'UTF-8');
                                $prev_array = explode(" ", $prev);
                                $body_array = explode(" ", $body);
                                if (count($prev_array) <= count($body_array))
diff --git a/zipstream.php b/zipstream.php
index 1fe72dd..e4e59cc 100644
--- a/zipstream.php
+++ b/zipstream.php
@@ -198,8 +198,8 @@ class ZipStream {
 
     # calculate header attributes
     $crc  = crc32($data);
-    $zlen = strlen($zdata);
-    $len  = strlen($data);
+    $zlen = mb_strlen($zdata);
+    $len  = mb_strlen($data);
     $meth = 0x08;
 
     # send file header
@@ -282,7 +282,7 @@ class ZipStream {
   #
   function add_file_header($name, $opt, $meth, $crc, $zlen, $len) {
     # calculate name length
-    $nlen = strlen($name);
+    $nlen = mb_strlen($name);
 
     # create dos timestamp
     $opt['time'] = $opt['time'] ? $opt['time'] : time();
@@ -304,7 +304,7 @@ class ZipStream {
 
     # pack fields and calculate "total" length
     $ret = $this->pack_fields($fields);
-    $cdr_len = strlen($ret) + $nlen + $zlen;
+    $cdr_len = mb_strlen($ret) + $nlen + $zlen;
 
     # print header and filename
     $this->send($ret . $name);
@@ -343,7 +343,7 @@ class ZipStream {
       while ($data = fgets($fh, $block_size)) {
         hash_update($hash_ctx, $data);
         $data = gzdeflate($data);
-        $zlen += strlen($data);
+        $zlen += mb_strlen($data);
       }
 
       # close file and finalize crc
@@ -412,9 +412,9 @@ class ZipStream {
       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', mb_strlen($name)),        # filename length
       array('v', 0),                    # extra data len
-      array('v', strlen($comment)),     # file comment length
+      array('v', mb_strlen($comment)),     # file comment length
       array('v', 0),                    # disk number start
       array('v', 0),                    # internal file attributes
       array('V', 32),                   # external file attributes
@@ -427,7 +427,7 @@ class ZipStream {
     $this->send($ret);
 
     # increment cdr offset
-    $this->cdr_ofs += strlen($ret);
+    $this->cdr_ofs += mb_strlen($ret);
   }
 
   #
@@ -451,7 +451,7 @@ class ZipStream {
       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
+      array('v', mb_strlen($comment)),   # zip file comment length
     );
 
     $ret = $this->pack_fields($fields) . $comment;
 
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
32977 downloads
MAJ 1.0
26 files
13132 downloads
MAJ 0.14
45 files
35010 downloads