This blob has been accessed 308 times via Git panel.
- <?php
- $maj_data_directory = "data";
- $maj_default_title = file_get_contents("$maj_data_directory/title.txt");
- $maj_admin_username = file_get_contents("$maj_data_directory/username.txt");
- if (isset($_SESSION['logged_in'])) {
- $maj_logged_in_username = $_SESSION['logged_in'];
- }
- if (isset($maj_logged_in_username) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
- header("Location: login.php");
- }
- 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 (isset($_REQUEST['entry']) and !empty($_REQUEST['entry'])) {
- $maj_req_entry = trim($_REQUEST['entry']);
- }
- if (isset($_REQUEST['show']) and !empty($_REQUEST['show'])) {
- $maj_req_show = trim($_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 = 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 = strip_tags($maj_req_category);
- }
- if (isset($_REQUEST['archive']) and !empty($_REQUEST['archive'])) {
- $maj_req_archive = trim($_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 = strip_tags($maj_req_author);
- }
- if (file_exists("$maj_data_directory/offset.txt")) {
- $maj_offset = file_get_contents("$maj_data_directory/offset.txt");
- }
- else {
- $maj_offset = 0;
- }
- if (file_exists("$maj_data_directory/increase.txt")) {
- $maj_increase = file_get_contents("$maj_data_directory/increase.txt");
- }
- else {
- $maj_increase = 5;
- }
- if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/avatar.txt")) {
- $maj_wside = "160";
- $maj_wmain = "600";
- }
- else {
- $maj_wside = "200";
- $maj_wmain = "520";
- }
- $maj_wspace = "10";
- $maj_wtable = $maj_wspace + $maj_wside + $maj_wspace + $maj_wmain + $maj_wspace + $maj_wside + $maj_wspace;
- $maj_default_blog_title = "My Activity Journal";
- $maj_default_username = "maj";
- $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/.htaccess")) {
- $maj_htaccess = "Order deny,allow\nDeny from all";
- }
- if (!file_exists("$maj_data_directory/title.txt")) {
- }
- if (!file_exists("$maj_data_directory/username.txt")) {
- }
- if (!file_exists("$maj_data_directory/password.txt")) {
- $maj_default_password = sha1($maj_default_password);
- $maj_default_password = md5($maj_default_password);
- $maj_default_password = crypt($maj_default_password,$maj_default_password);
- }
- if (!file_exists("$maj_data_directory/profile.php")) {
- }
- if (!file_exists("$maj_data_directory/author.txt")) {
- }
- function str_rand($length = 8,$seeds = 'abcdefghijklmnopqrstuvwxyz0123456789') {
- $str = '';
- 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,$count - 1)};
- }
- return $str;
- }
- function rmdirr($dir) {
- if (!file_exists($dir)) {
- return false;
- }
- if (is_file($dir)) {
- return unlink($dir);
- }
- $recurse = dir($dir);
- while (false !== $entry = $recurse->read()) {
- if ($entry == '.' || $entry == '..') {
- continue;
- }
- rmdirr("$dir/$entry");
- }
- $recurse->close();
- return rmdir($dir);
- }
- function return_bytes($val) {
- $val = trim($val);
- switch ($last) {
- case 'k':
- case 'K':
- return(int)$val * 1024;
- break;
- case 'm':
- case 'M':
- return(int)$val * 1048576;
- break;
- default:
- return $val;
- }
- }
- $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;
- }
- if ($server_post_max_size > $server_memory_limit) {
- $max_file_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);
- }
- function reformat_html($data) {
- $store_0 = split("<html>", $data);
- $data = "";
- $data .= $store_0[0];
- foreach ($store_0 as $item_0 => $ref_0) {
- if (eregi("</html>", $ref_0)) {
- $store_1 = split("</html>", $ref_0);
- $store_1[0] = eregi_replace("\n", "", $store_1[0]);
- foreach ($store_1 as $item_1 => $ref_1) {
- if ($item_1 == 0) {
- $ref_1 = "<!-- html -->$ref_1<!-- /html -->";
- }
- $data .= $ref_1;
- }
- }
- }
- return $data;
- }
- function reformat_code($data) {
- $store_0 = 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);
- foreach ($store_1 as $item_1 => $ref_1) {
- if ($item_1 == 0) {
- $ref_1 = "<code>$ref_1</code>";
- }
- $data .= $ref_1;
- }
- }
- }
- return $data;
- }
- function format_title_put($data) {
- // 20100113 - auto-captialize title except articles, prepositions and conjunctions less tha 4 letters, and particle "to"
- $data = ucwords($data);
- $data = str_replace('<', '<', $data);
- $data = str_replace('>', '>', $data);
- $data = str_replace(' A ', ' a ', $data);
- $data = str_replace(' An ', ' an ', $data);
- $data = str_replace(' And ', ' and ', $data);
- $data = str_replace(' As ', ' as ', $data);
- $data = str_replace(' At ', ' at ', $data);
- $data = str_replace(' But ', ' but ', $data);
- $data = str_replace(' By ', ' by ', $data);
- $data = str_replace(' For ', ' for ', $data);
- $data = str_replace(' In ', ' in ', $data);
- $data = str_replace(' Of ', ' of ', $data);
- $data = str_replace(' On ', ' on ', $data);
- $data = str_replace(' Or ', ' or ', $data);
- $data = str_replace(' The ', ' the ', $data);
- $data = str_replace(' To ', ' to ', $data);
- return $data;
- }
- function format_body_put($data) {
- $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('[code]', '<code>', $data);
- $data = str_replace('[/code]', '</code>', $data);
- $data = reformat_code($data);
- $data = str_replace("\n", '<br />', $data);
- $data = str_replace('[b]', '<b>', $data);
- $data = str_replace('[/b]', '</b>', $data);
- $data = str_replace('[i]', '<i>', $data);
- $data = str_replace('[/i]', '</i>', $data);
- $data = str_replace('[u]', '<u>', $data);
- $data = str_replace('[/u]', '</u>', $data);
- $data = str_replace('[strike]', '<strike>', $data);
- $data = str_replace('[/strike]', '</strike>', $data);
- $data = str_replace('[sup]', '<sup>', $data);
- $data = str_replace('[/sup]', '</sup>', $data);
- $data = str_replace('[sub]', '<sub>', $data);
- $data = str_replace('[/sub]', '</sub>', $data);
- $data = str_replace('[highlight]', '<highlight>', $data);
- $data = str_replace('[/highlight]', '</highlight>', $data);
- $data = str_replace('<highlight>', '<span style="background-color: #ffff00;">', $data);
- $data = str_replace('</highlight>', '</span>', $data);
- $data = preg_replace("/<([_\.0-9a-z-]+)@([0-9a-z][0-9a-z-]+)\.([_\.0-9a-z-]+)>/", '<$1@$2.$3>', $data);
- return $data;
- }
- function show_maj_avatar_image($author_username,$max_img_width=80) {
- global $maj_admin_username;
- 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 (file_exists("images/avatar.gif")) {
- $avatar_gif_image_size = getimagesize("images/avatar.gif");
- $avatar_gif_image_width = $avatar_gif_image_size[0];
- $avatar_gif_image_height = $avatar_gif_image_size[1];
- if ($avatar_gif_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_gif_image_width) ;
- $avatar_gif_image_width = (int) ($avatar_gif_image_width * $sizefactor);
- $avatar_gif_image_height = (int) ($avatar_gif_image_height * $sizefactor);
- if (file_exists("$maj_data_directory/avatar-resize-gif.txt")) {
- $avatar_gif_image_resize = imagecreatetruecolor($avatar_gif_image_width,$avatar_gif_image_height);
- imagealphablending($avatar_gif_image_resize, false);
- imagesavealpha($avatar_gif_image_resize, true);
- $avatar_gif_image_original = imagecreatefromgif("images/avatar.gif");
- $avatar_gif_transparent_index = imagecolortransparent($avatar_gif_image_original);
- if ($avatar_gif_transparent_index >= 0) {
- $avatar_gif_transparent_color = imagecolorsforindex($avatar_gif_image_original, $avatar_gif_transparent_index);
- $avatar_gif_transparent_index = imagecolorallocate($avatar_gif_image_resize, $avatar_gif_transparent_color['red'], $avatar_gif_transparent_color['green'], $avatar_gif_transparent_color['blue']);
- imagefill($avatar_gif_image_resize, 0, 0, $avatar_gif_transparent_index);
- imagecolortransparent($avatar_gif_image_resize, $avatar_gif_transparent_index);
- }
- 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");
- imagegif($avatar_gif_image_resize,"images/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\">";
- }
- if (file_exists("images/avatar.jpg")) {
- $avatar_jpg_image_size = getimagesize("images/avatar.jpg");
- $avatar_jpg_image_width = $avatar_jpg_image_size[0];
- $avatar_jpg_image_height = $avatar_jpg_image_size[1];
- if ($avatar_jpg_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_jpg_image_width) ;
- $avatar_jpg_image_width = (int) ($avatar_jpg_image_width * $sizefactor);
- $avatar_jpg_image_height = (int) ($avatar_jpg_image_height * $sizefactor);
- 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");
- 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");
- imagejpeg($avatar_jpg_image_resize,"images/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\">";
- }
- if (file_exists("images/avatar.png")) {
- $avatar_png_image_size = getimagesize("images/avatar.png");
- $avatar_png_image_width = $avatar_png_image_size[0];
- $avatar_png_image_height = $avatar_png_image_size[1];
- if ($avatar_png_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_png_image_width) ;
- $avatar_png_image_width = (int) ($avatar_png_image_width * $sizefactor);
- $avatar_png_image_height = (int) ($avatar_png_image_height * $sizefactor);
- if (file_exists("$maj_data_directory/avatar-resize-png.txt")) {
- $avatar_png_image_resize = imagecreatetruecolor($avatar_png_image_width,$avatar_png_image_height);
- imagealphablending($avatar_png_image_resize, false);
- imagesavealpha($avatar_png_image_resize, true);
- $avatar_png_image_original = imagecreatefrompng("images/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");
- imagepng($avatar_png_image_resize,"images/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 "<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")) {
- if (file_exists("images/members/$author_username/avatar.gif")) {
- $avatar_gif_image_size = getimagesize("images/members/$author_username/avatar.gif");
- $avatar_gif_image_width = $avatar_gif_image_size[0];
- $avatar_gif_image_height = $avatar_gif_image_size[1];
- if ($avatar_gif_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_gif_image_width) ;
- $avatar_gif_image_width = (int) ($avatar_gif_image_width * $sizefactor);
- $avatar_gif_image_height = (int) ($avatar_gif_image_height * $sizefactor);
- if (file_exists("$maj_data_directory/avatar-resize-gif.txt")) {
- $avatar_gif_image_resize = imagecreatetruecolor($avatar_gif_image_width,$avatar_gif_image_height);
- 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_transparent_index = imagecolortransparent($avatar_gif_image_original);
- if ($avatar_gif_transparent_index >= 0) {
- $avatar_gif_transparent_color = imagecolorsforindex($avatar_gif_image_original, $avatar_gif_transparent_index);
- $avatar_gif_transparent_index = imagecolorallocate($avatar_gif_image_resize, $avatar_gif_transparent_color['red'], $avatar_gif_transparent_color['green'], $avatar_gif_transparent_color['blue']);
- imagefill($avatar_gif_image_resize, 0, 0, $avatar_gif_transparent_index);
- imagecolortransparent($avatar_gif_image_resize, $avatar_gif_transparent_index);
- }
- 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");
- imagegif($avatar_gif_image_resize,"images/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\">";
- }
- if (file_exists("images/members/$author_username/avatar.jpg")) {
- $avatar_jpg_image_size = getimagesize("images/members/$author_username/avatar.jpg");
- $avatar_jpg_image_width = $avatar_jpg_image_size[0];
- $avatar_jpg_image_height = $avatar_jpg_image_size[1];
- if ($avatar_jpg_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_jpg_image_width) ;
- $avatar_jpg_image_width = (int) ($avatar_jpg_image_width * $sizefactor);
- $avatar_jpg_image_height = (int) ($avatar_jpg_image_height * $sizefactor);
- 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");
- 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");
- imagejpeg($avatar_jpg_image_resize,"images/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\">";
- }
- if (file_exists("images/members/$author_username/avatar.png")) {
- $avatar_png_image_size = getimagesize("images/members/$author_username/avatar.png");
- $avatar_png_image_width = $avatar_png_image_size[0];
- $avatar_png_image_height = $avatar_png_image_size[1];
- if ($avatar_png_image_width > $max_img_width) {
- $sizefactor = (double) ($max_img_width / $avatar_png_image_width) ;
- $avatar_png_image_width = (int) ($avatar_png_image_width * $sizefactor);
- $avatar_png_image_height = (int) ($avatar_png_image_height * $sizefactor);
- if (file_exists("$maj_data_directory/avatar-resize-png.txt")) {
- $avatar_png_image_resize = imagecreatetruecolor($avatar_png_image_width,$avatar_png_image_height);
- imagealphablending($avatar_png_image_resize, false);
- imagesavealpha($avatar_png_image_resize, true);
- $avatar_png_image_original = imagecreatefrompng("images/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");
- imagepng($avatar_png_image_resize,"images/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 "<br>";
- }
- echo "<b>$author_username</b></a><br>";
- if (($maj_admin_username == $author_username) and file_exists("$maj_data_directory/rank.txt")) {
- echo "administrator<br>";
- }
- elseif (file_exists("$maj_data_directory/members/active/$author_username/rank.txt") and file_exists("$maj_data_directory/rank.txt")) {
- $rank = file_get_contents("$maj_data_directory/members/active/$author_username/rank.txt");
- echo "$rank<br>";
- }
- elseif (!file_exists("$maj_data_directory/members/active/$author_username/rank.txt") and file_exists("$maj_data_directory/rank.txt")) {
- echo "member<br>";
- }
- }
- ?>