data_dir)) { createDirectory($this->data_dir); } if (!file_exists($this->temp_dir)) { createDirectory($this->temp_dir); createDirectory($this->temp_dir . "/thumbs"); } } function writeToFile($content, $filename) { if(file_exists($filename)) copy($filename, $filename . ".bak"); $handle = fopen($filename, "w"); fwrite($handle, $content); fclose($handle); chmod($filename, 0777); } function createDirectory($directory) { mkdir($directory, 0777); chmod($directory, 0777); } function loadData($filename) { if(file_exists($this->data_dir . "/$filename")) { $records=file($this->data_dir . "/$filename"); return $records; } else { return null; } } function getPreferences() { if($this->preferences == null) { // load from file $records = $this->loadData("pref.db"); $count = count($records); $this->prefereces = array(); // set defaults $this->preferences["password"] = "none"; $this->preferences["name"] = "guest"; $this->preferences["sitename"] = "my blog"; $this->preferences["title_bar_color"] = "#325696"; $this->preferences["title_font_color"] = "#FFFFFF"; $this->preferences["link_color"] = "#325696"; $this->preferences["max_single_upload"] = "10"; $this->preferences["max_total_upload"] = "100"; $this->preferences["posts_per_page"] = "10"; $this->preferences["glib"] = "unset"; $this->preferences["quality"] = "75"; $this->preferences["email_content_default"] = "html"; $this->preferences["language"] = "0"; // English by default $this->preferences["disable_software_update"] = "false"; $this->preferences["hide_subscribers"] = "false"; for ($i=0;$i<$count;$i++) { $record = rtrim($records[$i]); if(strpos($record,'#') === false || strpos($record,'#') != 0) { $record = explode("=",$record); $key = stripslashes($record[0]); $value = stripslashes($record[1]); if($key == "bgcolor") { $this->preferences["title_bar_color"] = $value; $this->preferences["link_color"] = $value; } else if($key == "fgcolor") { $this->preferences["title_font_color"] = $value; } else { $this->preferences[$key] = $value; } } } } return $this->preferences; } function getPreference($aKey) { $this->getPreferences(); // load return $this->preferences[$aKey]; } function setPreference($key, $value) { $this->getPreferences(); // load $this->preferences[$key] = $value; $file = $this->data_dir . "/pref.db"; $outstring = "# FORMAT: key=value\n"; foreach ($this->preferences as $key => $value) { $outstring .= "$key=$value\n"; } writeToFile($outstring, $file); } function getSubscribers() { if($this->subscribers == null) { // load from file $records = $this->loadData("subscribers.db"); $count = count($records); $this->subscribers = array(); for ($i=0;$i<$count;$i++) { $record = rtrim($records[$i]); if(strpos($record,'#') === false || strpos($record,'#') != 0) { $Subscriber = new Subscriber(); $Subscriber->parseRecord($record); if($Subscriber->getContent()== null) $Subscriber->setContent($this->preferences["email_content_default"]); $this->subscribers[$Subscriber->getPrimaryKey()] = $Subscriber; } } } return $this->subscribers; } function subscribe($email, $name, $content) { $this->getSubscribers(); // load $Subscriber = new Subscriber(); $Subscriber->parseRecord("$email=$name=$content"); $this->subscribers[$email] = $Subscriber; $file = $this->data_dir . "/subscribers.db"; $outstring = "# FORMAT: email=name=format\n"; foreach ($this->subscribers as $key => $value) { if(strlen($key) > 0) { $email = $value->getEmail(); $name = $value->getName(); $content = $value->getContent(); $outstring .= "$email=$name=$content\n"; } } writeToFile($outstring, $file); } function unsubscribe($remove) { $this->getSubscribers(); // load $file = $this->data_dir . "/subscribers.db"; $outstring = "# FORMAT: email=name\n"; foreach ($this->subscribers as $key => $value) { if($key != $remove) { $email = $value->getEmail(); $name = $value->getName(); $content = $value->getContent(); $outstring .= "$email=$name=$content\n"; } } writeToFile($outstring, $file); $this->subscribers = null; } function getPosts() { if($this->posts == null) { // load from file $records = $this->loadData("posts.db"); $count = count($records); $this->posts = array(); for ($i=0;$i<$count;$i++) { $record = rtrim($records[$i]); if(strpos($record,'#') === false || strpos($record,'#') != 0) { $Post = new Post($this); $Post->parseRecord($record); $this->posts[$Post->getPrimaryKey()] = $Post; } } } return $this->posts; } function loadPhotos($Post) { // load from file $file = $Post->getId() . "/pics.txt"; $records = $this->loadData($file); $count = count($records); $photos = array(); $index = 0; for ($i=0;$i<$count;$i++) { $record = rtrim($records[$i]); if(strpos($record,'#') === false || strpos($record,'#') != 0) { $Photo = new Photo(); $Photo->parseRecord($record); $photos["$index"] = $Photo; $index++; } } return $photos; } function savePhotos($Post) { // make photo directories if(!file_exists($Post->getDir())) { createDirectory($Post->getDir()); createDirectory($Post->getDir() . "/thumbs"); } $photos = $Post->getPhotos(); $file = $Post->getDir() . "/pics.txt"; $outstring = "# FORMAT: id;description\n"; foreach ($photos as $photo) { $name = $photo->getId(); if(file_exists($this->temp_dir . "/$name")) { copy($this->temp_dir . "/$name", $Post->getDir() . "/$name"); copy($this->temp_dir . "/thumbs/$name", $Post->getDir() . "/thumbs/$name"); } $rec = $photo->getRecordString(); if($rec != null) { $outstring .= "$rec\n"; } } writeToFile($outstring, $file); } function deleteTempDir() { $this->deleteDir($this->temp_dir); } function addPost($NewPost) { $this->getPosts(); // make sure we loaded them... $file = $this->data_dir . "/posts.db"; $outstring = "# FORMAT: id | timestamp | status | type | title | description | thumbnail\n"; $outstring .= $NewPost->getRecordString() . "\n"; foreach ($this->posts as $post) { $rec = $post->getRecordString(); if($rec != null && (strpos($rec,"|||") == false || strpos($rec,"|||") == -1)) { $outstring .= "$rec\n"; } } writeToFile($outstring, $file); $this->posts = null; $this->getPosts(); } function updatePost($NewPost) { $this->getPosts(); // make sure we loaded them... $file = $this->data_dir . "/posts.db"; $outstring = "# FORMAT: id | timestamp | status | type | title | description | thumbnail\n"; foreach ($this->posts as $post) { $id = $post->getId(); if($id == $NewPost->getId()){ $rec = $NewPost->getRecordString(); } else { $rec = $post->getRecordString(); } if($rec != null && (strpos($rec,"|||") == false || strpos($rec,"|||") == -1)) { $outstring .= "$rec\n"; } } writeToFile($outstring, $file); $this->posts = null; $this->getPosts(); $NewPost->savePhotos(); } function deletePost($id) { if($id == null || $id == "") return; $this->getPosts(); // load unset($this->posts[$id]); $file = $this->data_dir . "/posts.db"; $outstring = "# FORMAT: id | timestamp | status | type | title | description | thumbnail\n"; foreach ($this->posts as $post) { $rec = $post->getRecordString(); if($rec != null && (strpos($rec,"|||") == false || strpos($rec,"|||") == -1)) { $outstring .= "$rec\n"; } } writeToFile($outstring, $file); $this->posts = null; $this->getPosts(); $dir = $this->data_dir . "/" . $id; $this->deleteDir($dir); } function deleteDir($dir) { if ($handle = @opendir($dir)) { while (($file = readdir($handle)) !== false) { if (($file == ".") || ($file == "..")) { continue; } if (is_dir($dir . '/' . $file)) { // call self for this directory $this->deleteDir($dir . '/' . $file); } else { unlink($dir . '/' . $file); // remove this file } } @closedir($handle); chmod($dir, 0777); rmdir ($dir); } } } // class Blogger class Blogger { var $DataAccess; function Blogger($da) { $this->DataAccess = $da; } function getPosts() { return $this->DataAccess->getPosts(); } function deleteTempDir() { return $this->DataAccess->deleteTempDir(); } function getPreference($key) { return $this->DataAccess->getPreference($key); } function setPreference($key, $value) { return $this->DataAccess->setPreference($key,$value); } function getSubscribers() { return $this->DataAccess->getSubscribers(); } function subscribe($email, $name, $content) { return $this->DataAccess->subscribe($email, $name, $content); } function unsubscribe($email) { return $this->DataAccess->unsubscribe($email); } function getPost($id) { $posts = $this->getPosts(); return $posts["$id"]; } function addPost($NewPost) { $NewPost->setDataAccess($this->DataAccess); $this->DataAccess->addPost($NewPost); return $NewPost; } function deletePost($id) { $this->DataAccess->deletePost($id); } function updatePost($OldPost) { $OldPost->setDataAccess($this->DataAccess); $this->DataAccess->updatePost($OldPost); } function hasSlideshow() { $Posts = $this->getPosts(); foreach($Posts as $Post) { if($Post->isTypeSlideshow()) return true; } return false; } } // class Subscriber class Subscriber { var $email; var $name; var $content; function Subscriber() { } function parseRecord($photo_string) { $record = explode("=", $photo_string); $this->setEmail($record[0]); $this->setName($record[1]); $this->setContent($record[2]); } function getEmail() { return $this->email; } function getName() { return $this->name; } function getContent() { return $this->content; } function setEmail($anEmailAddress) { $this->email = $anEmailAddress; } function setName($aName) { $this->name = $aName; } function setContent($aContent) { $this->content = $aContent; } function getRecordString() { return $this->email . "=" . $this->name . "=" . $this->content; } function getPrimaryKey() { return $this->email; } } // class Photo class Photo { var $id; var $description; function Photo() { } function parseRecord($photo_string) { $record = explode(";", $photo_string); $this->setId($record[0]); // iterate in case there are ";" chars in description for($i=1;$isetDescription($tmp); } function getId() { return $this->id; } function getDescription() { return $this->description; } function setId($anId) { $this->id = $anId; } function setDescription($aDescription) { $this->description = $aDescription; } function getRecordString() { return $this->id . ";" . $this->description; } function getPrimaryKey() { return $this->id; } } // class Post class Post { var $DataAccess; var $id; var $timestamp; var $status; var $type; var $title; var $description; var $thumbnail; var $photos; function Post($da) { $this->DataAccess = $da; // default values $curr_time = time(); $this->setId($curr_time); $this->setTimestamp($curr_time); $this->setStatusPending(); $this->setTypeNews(); } function parseRecord($record_string) { $record = explode("|", $record_string); $this->setId($record[0]); $this->setTimestamp($record[1]); $this->setStatus($record[2]); $this->setType($record[3]); $this->setTitle($record[4]); $this->setDescription($record[5]); $this->setThumbnail($record[6]); } function getPhotos() { if($this->photos == null) { // load from file $this->photos = $this->DataAccess->loadPhotos($this); } return $this->photos; } function savePhotos() { // save to file $this->DataAccess->savePhotos($this); } function getId() { return $this->id; } function getTimestamp() { return $this->timestamp; } function getDir() { return $this->DataAccess->data_dir . "/" . $this->id; } function getDate() { if(strpos($this->timestamp,' ') != false && strpos($this->timestamp,' ') != -1) { return $this->timestamp; } else { return date("F jS, Y", $this->timestamp); } } function getStatus() { return $this->status; } function isStatusActive() { return strcmp($this->status,"A") == 0; } function isStatusPending() { return strcmp($this->status,"P") == 0; } function getType() { return $this->type; } function isTypeSlideshow() { return strcmp($this->type,"slideshow") == 0; } function isTypeNews() { return strcmp($this->type,"news") == 0; } function getTitle() { return $this->title; } function getDescription() { return $this->description; } function getThumbnail() { return $this->thumbnail; } function setDataAccess($aDataAccess) { $this->DataAccess = $aDataAccess; } function setId($anId) { $this->id = $anId; } function setTimestamp($aTimestamp) { $this->timestamp = $aTimestamp; } function setStatus($aStatus) { $this->status = $aStatus; } function setStatusActive() { $this->status = "A"; } function setStatusPending() { $this->status = "P"; } function setType($aType) { $this->type = $aType; } function setTypeSlideshow() { $this->type = "slideshow"; } function setTypeNews() { $this->type = "news"; } function setTitle($aTitle) { $this->title = $aTitle; } function setDescription($aDescription) { $this->description = $aDescription; } function setThumbnail($aThumbnail) { $this->thumbnail = $aThumbnail; } function setPhotos($somePhotos) { $this->photos = $somePhotos; } function addPhoto($id,$description) { $number_pics = 0; if($this->photos != null) $number_pics = count($this->photos); $NewPhoto = new Photo(); $NewPhoto->setId($id); $NewPhoto->setDescription($description); $this->photos["$number_pics"] = $NewPhoto; return $NewPhoto; } function getRecordString() { return $this->id . "|" . $this->timestamp . "|" . $this->status . "|" . $this->type . "|" . $this->title . "|" . $this->description . "|" . $this->thumbnail; } function getPrimaryKey() { return $this->id; } } ####################################################################################### ### ENGLISH/TRANSLATIONS ############################################################## ####################################################################################### $copy = array(); // 0 = English // 1 = Dutch $copy['HEADER_LINK_HOME'] = array( "home", "home"); $copy['HEADER_LINK_SUBSCRIBE'] = array( "subscribe", "aanmelden"); $copy['HEADER_LINK_CONTACT'] = array( "contact", "contact"); $copy['HEADER_LINK_ADMIN'] = array( "admin", "administratie"); $copy['FOOTER_SCRIPT_BY'] = array( "script by", "vertaling"); $copy['EMAIL_GREETING1'] = array( "Hi everyone!", "Hi everyone!"); $copy['EMAIL_GREETING2'] = array( "This is just a note to let you know there are new photos on my site:", "This is just a note to let you know there are new photos on my site:"); $copy['EMAIL_GREETING3'] = array( "Come by and visit...", "Come by and visit..."); $copy['EMAIL_GREETING4'] = array( "Here is what was just posted:", "Here is what was just posted:"); $copy['EMAIL_SIGNATURE1'] = array( "Reminder: You subscribed to receive these notices.", "Reminder: You subscribed to receive these notices."); $copy['EMAIL_SIGNATURE2'] = array( "To be removed from this email list, please go to", "To be removed from this email list, please go to"); $copy['POST_SLIDESHOW'] = array( "Post Slideshow", "Post Slideshow"); $copy['UPLOAD_PICTURES'] = array( "Upload pictures.", "Upload pictures."); $copy['SELECT_THUMBNAIL'] = array( "Select thumbnail, title and description for blog entry.", "Select thumbnail, title and description for blog entry."); $copy['SEND_EMAIL'] = array( "Send email.", "Send email."); $copy['PLEASE_ATTACH'] = array( "Please attach at least one picture.", "Please attach at least one picture."); $copy['JPEG_ONLY'] = array( "Picture file extension must be .jpeg or .jpg!", "Picture file extension must be .jpeg or .jpg!"); $copy['PICTURE'] = array( "Picture", "Photo"); $copy['DESCRIPTION'] = array( "Description", "Description"); $copy['UPLOAD'] = array( "Upload", "Upload"); $copy['PAGE_NOT_FOUND'] = array( "Page Not Found", "Page Not Found"); $copy['APPARENTLY_REMOVED'] = array( "Apparently this post has been removed.", "Apparently this post has been removed."); $copy['CLICK_HERE'] = array( "Click here to return to the home page.", "Click here to return to the home page."); $copy['NO_NEWS_YET'] = array( "No News Yet", "No News Yet"); $copy['CHECK_BACK_LATER'] = array( "Nothing has been posted yet... please check back later.", "Nothing has been posted yet... please check back later."); $copy['NEWER_POSTS'] = array( "newer posts", "newer posts"); $copy['OLDER_POSTS'] = array( "older posts", "older posts"); $copy['NEWS'] = array( "news", "news"); $copy['LIST'] = array( "list", "list"); $copy['SHUFFLE'] = array( "shuffle", "shuffle"); $copy['INDEX'] = array( "index", "index"); $copy['EDIT'] = array( "edit", "edit"); $copy['DELETE'] = array( "delete", "delete"); $copy['EMAIL'] = array( "email", "email"); $copy['CONFIRM_DELETE'] = array( "Are you sure you want to delete the post: ", "Are you sure you want to delete the post: "); $copy['POSTS'] = array( "Posts", "Posts"); $copy['POST_NEWS'] = array( "Post News", "Post News"); $copy['POST_SLIDESHOW'] = array( "Post Slideshow", "Post Slideshow"); $copy['EDIT_OR_DELETE'] = array( "Edit or Delete", "Edit or Delete"); $copy['PREFERENCES'] = array( "Preferences", "Preferences"); $copy['GENERAL_PREFERENCES'] = array( "General Preferences", "General Preferences"); $copy['CHANGE_PASSWORD'] = array( "Change Password", "Change Password"); $copy['HEADER_FOOTER'] = array( "Header & Footer", "Header & Footer"); $copy['EMAIL_FORMAT'] = array( "Email Format", "Email Format"); $copy['STATS'] = array( "Stats", "Stats"); $copy['VERSION'] = array( "Version", "Version"); $copy['SUBSCRIBERS'] = array( "Subscribers", "Subscribers"); $copy['BLOG_SIZE'] = array( "Blog Size", "Blog Size"); $copy['GRAPHICS_LIB'] = array( "Graphis Lib", "Graphics Lib"); $copy['STEP'] = array( "Step", "Step"); $copy['CREATE_NEWS_POST'] = array( "Create News Post", "Create News Post"); $copy['POST_NEWS_WITH'] = array( "Post news with a single (optional) picture", "Post news with a single (optional) picture"); function getCopy($key) { global $copy, $language; return $copy["$key"][$language]; } ####################################################################################### ### RE-USABLE FUNCTIONS ############################################################### ####################################################################################### // write to file and make sure it can be removed function writeToFile($content, $filename) { $handle = fopen($filename, "w"); fwrite($handle, $content); fclose($handle); chmod($filename, 0777); } // gd version function gdVersion() { if (! extension_loaded('gd')) { return; } ob_start(); phpinfo(8); $info=ob_get_contents(); ob_end_clean(); $info=stristr($info, 'gd version'); preg_match('/\d/', $info, $gd); return $gd[0]; } // default graphics lib function getDefaultGraphicsLib() { if(gdVersion() && gdVersion() >= 2) { return "GD"; } exec("mogrify",$output,$rc); if($rc == 0) return "Mogrify"; return "none"; } // authentication function isAuthenticated($logon) { global $password; $key = getCookieValue('key'); if(strcmp($password,$key) == 0) { return true; } else { if($logon) logon(); return false; } } // create directory with correct permissions function createDirectory($directory) { mkdir($directory, 0777); chmod($directory, 0777); } // resize jpg images function resizeImage($img, $height){ global $glib, $quality; $imagedata = getimagesize($img); $oldwidth = $imagedata[0]; $oldheight = $imagedata[1]; if($height < $oldheight) { $width = ($height/$oldheight)*$oldwidth; } else { $width = $oldwidth; $height = $oldheight; } //echo "OLDWIDTH: $oldwidth OLDHEIGHT: $oldheight
"; //echo "WIDTH: $width HEIGHT: $height
"; if("$glib" == "GD") { $thumb = imagecreatetruecolor($width, $height); $image = ImageCreateFromJpeg($img); imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, $oldwidth, $oldheight); imagejpeg($thumb, $img, $quality); } if("$glib" == "Mogrify") { $command = "mogrify -resize x$height -quality $quality $img"; exec($command); } } function resizeBig($img) { resizeImage($img,"480"); } function resizeSmall($img) { resizeImage($img,"96"); } function containsHtml($value) { // not a perfect check... if(substr_count($value, "<") > 0) return true; if(substr_count($value, ">") > 0) return true; return false; } function moveAndResize($tmp, $dir, $name) { move_uploaded_file($tmp,"$dir/$name"); copy("$dir/$name","$dir/thumbs/$name"); resizeBig("$dir/$name"); resizeSmall("$dir/thumbs/$name"); } function imageName($old_name) { $new_name = $old_name; $new_name = str_replace(" ", "_", $new_name); return $new_name; } function getValue($key) { global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $myglobals; if($myglobals == null) $myglobals = array(); $value = $myglobals[$key]; if($value != null && $value != "") return formatValue($value); $value = $HTTP_GET_VARS[$key]; if($value != null && $value != "") return formatValue($value); $value = $HTTP_POST_VARS[$key]; if($value != null && $value != "") return formatValue($value); $value = $HTTP_COOKIE_VARS[$key]; if($value != null && $value != "") return formatValue($value); return null; } function formatValue($oldString) { $newString = $oldString; $newString = str_replace('\\"', '\'', $newString); $newString = str_replace("\n", "
", $newString); return stripslashes($newString); } function setValue($key, $value) { global $HTTP_GET_VARS, $HTTP_POST_VARS, $myglobals; if($myglobals == null) $myglobals = array(); $myglobals[$key] = $value; $HTTP_GET_VARS[$key] = $value; $HTTP_POST_VARS[$key] = $value; } function getPostFiles($key) { global $HTTP_POST_FILES; return $HTTP_POST_FILES[$key]; } function getCookieValue($key) { global $HTTP_COOKIE_VARS; return $HTTP_COOKIE_VARS[$key]; } function setCookieValue($key, $value) { global $HTTP_COOKIE_VARS; $HTTP_COOKIE_VARS[$key] = $value; echo ""; } // print a blog item function getBlogItem($post) { global $path, $path_dir, $host; $id = $post->getId(); $dir = $post->getDir(); $date = $post->getDate(); $title = $post->getTitle(); $description = $post->getDescription(); $thumbnail = $post->getThumbnail(); $item = "
\n"; $item .= "\n"; $item .= ""; if($post->isTypeSlideshow()) { $url = "http://$host$path?page=slideshow&id=$id"; } else { $url = "http://$host$path?page=news_photo&id=$id"; } if($thumbnail != null && file_exists("$dir/thumbs/$thumbnail")) { $img = ""; $item .= ""; } $item .= "
"; $item .= "
"; $item .= "$img"; $item .= "
"; $item .= "
$title  ($date)
"; $item .= "$description"; $item .= "
"; $item .= "
"; return $item; } // print a text item function getTextItem($post) { global $host, $path, $path_dir; $id = $post->getId(); $dir = $post->getDir(); $date = $post->getDate(); $title = $post->getTitle(); $description = $post->getDescription(); $thumbnail = $post->getThumbnail(); $description = str_replace("
", "\n", $description); if($thumbnail != null && file_exists("$dir/thumbs/$thumbnail")) { $url = "Picture: http://$host$path?page=news_photo&id=$id"; if($post->isTypeSlideshow()) { $url = "Slideshow: http://$host$path?page=slideshow&id=$id"; } } else { $url = "http://$host$path"; } $item = "========================================================================\n\n"; $item .= "$title ($date)\n\n"; $item .= "$description\n\n"; $item .= "$url\n\n"; $item .= "========================================================================\n\n"; return $item; } function sendPostEmail($post, $subject, $greeting, $signature, $recipients) { global $Blogger, $email, $sitename, $name, $host, $path, $email_content_default; // headers $headers = "From: $email\n"; $headers .= "Reply-To: $email\n"; $body = "$greeting\n"; $body .= getTextItem($post); $body .= "$signature\n"; // html wrappers $html_headers = $headers . "MIME-Version: 1.0\n"; $html_headers .= "Content-Type: text/html; charset=iso-8859-1\n"; $html_body = "$sitename\n"; $html_body .= getStylesheet(); $html_body .= "\n"; $html_body .= "
\n"; $html_body .= formatValue($greeting); $html_body .= "
\n"; $html_body .= getBlogItem($post); $html_body .= "
\n"; $html_body .= formatValue($signature); $html_body .= "
\n"; $html_body .= "\n"; // send it $subscribers = $Blogger->getSubscribers(); $size=count($recipients); for ($i=0; $i < $size; $i++) { $content = $email_content_default; $to = trim($recipients[$i]); $subscriber = $subscribers[$to]; if($subscriber != null && $subscriber->getContent() != null) { $content = $subscriber->getContent(); } if($content == "html") { mail($to, $subject, $html_body, $html_headers); } else { mail($to, $subject, $body, $headers); } } } function indexRedirect() { global $path; echo "\n"; } function adminRedirect() { global $path; echo "\n"; } function emailRedirect($id) { global $path; echo "\n"; } function printSlideshowUploadHeader($step) { global $max_single_upload, $path; if(strcmp($step,"1") == 0) { $content .= "
"; } if(strcmp($step,"2") == 0) { $content .= ""; } $content .= "step 1:  " . getCopy('UPLOAD_PICTURES') . "
"; $content .= "step 2:  " . getCopy('SELECT_THUMBNAIL') . "
"; $content .= "step 3:  " . getCopy('SEND_EMAIL') . "
"; printSubHeader(getCopy('POST_SLIDESHOW'),$content); } function printSlideshowUploadFooter($start) { global $max_single_upload; $copyPleaseAttach = getCopy('PLEASE_ATTACH'); print <<< HERE HERE; for($i=0;$i<$max_single_upload;$i++) { $idx = $i+$start; $copyPicture = getCopy('PICTURE'); $copyDescription = getCopy('DESCRIPTION'); $copyUpload = getCopy('UPLOAD'); print <<< HERE HERE; } print <<< HERE
$idx.
$copyPicture
$copyDescription
HERE; } function printSubHeader($title, $subtext) { print <<< HERE
$title
$subtext
HERE; } function fsize($file){ $size; if(is_dir($file)) if ($dh = opendir($file)) while (($filecnt = readdir($dh)) !== false) { if($filecnt == "." || $filecnt == "..")continue; if(is_dir($file."/".$filecnt)) $size += fsize($file."/".$filecnt); else $size += filesize($file."/".$filecnt); } else return false; else $size = filesize($file); return $size; } function postNotFound() { global $host, $path; printSubHeader(getCopy('PAGE_NOT_FOUND'),getCopy('APPARENTLY_REMOVED')); echo "
" . getCopy('APPARENTLY_REMOVED') . "

"; echo "" . getCopy('CLICK_HERE') . "


"; } ####################################################################################### ### PAGES ############################################################################# ####################################################################################### ////////////////////////////////// // PAGE: index ////////////////////////////////// function index() { global $Blogger, $path, $posts_per_page, $name; $posts = $Blogger->getPosts(); $number_posts = count($posts); if($posts == null || count(posts) == 0) { printSubHeader(getCopy('NO_NEWS_YET'),""); echo "

" . getCopy('CHECK_BACK_LATER') . "




"; } else { $start = getValue('start'); if($start == null) $start=0; $count=0; echo ""; $news = getCopy('NEWS'); $list = getCopy('LIST'); $shuffle = getCopy('SHUFFLE'); $newerPosts = getCopy('NEWER_POSTS'); $olderPosts = getCopy('OLDER_POSTS'); print <<< HERE
 $news HERE; if($start > 0) { $oldstart = $start - $posts_per_page; if($oldstart < 0) $oldstart = 0; echo "« $newerPosts »"; } print <<< HERE  |  HERE; if($Blogger->hasSlideshow()) { echo "$shuffle | "; } print <<< HERE $list | 
HERE; foreach ($posts as $post) { if($count >= ($start + $posts_per_page)) break; if($count >= $start && $post->isStatusActive()) { echo getBlogItem($post); } $count++; } if($count < $number_posts) { print <<< HERE
« $olderPosts »
HERE; } } } ////////////////////////////////// // PAGE: post list ////////////////////////////////// function post_list() { global $Blogger, $path, $name; $posts = $Blogger->getPosts(); if($posts == null || count($posts) == 0) { printSubHeader(getCopy('NO_NEWS_YET'),""); echo "

" . getCopy('CHECK_BACK_LATER') . "




"; } else { $news = getCopy('NEWS'); $index = getCopy('INDEX'); $confirmDelete = getCopy('CONFIRM_DELETE'); print <<< HERE
 $news  | $index | 
HERE; $edit = getCopy('EDIT'); $delete = getCopy('DELETE'); $email = getCopy('EMAIL'); echo ""; $count = 0; foreach ($posts as $post) { if($post->isStatusActive()) { $count++; $title = $post->getTitle(); $title2 = addslashes($title); $date = $post->getDate(); $id = $post->getId(); $type = $post->getType(); echo ""; if(isAuthenticated(false)) { echo ""; echo ""; echo ""; } echo ""; if($post->isTypeSlideshow()) { echo ""; } else { echo ""; } echo ""; echo ""; } } echo "
[$edit][$delete][$email]$count.$title$title$type$date
"; } } ////////////////////////////////// // PAGE: post delete ////////////////////////////////// function delete_post() { global $Blogger, $data_dir; $id = getValue("id"); if($id != null && $id != "") { $Blogger->deletePost($id); } post_list(); } ////////////////////////////////// // PAGE: admin ////////////////////////////////// function admin() { global $path, $Blogger, $host, $version, $glib, $disable_software_update; printSubHeader("Admin Panel","Post news or modify preferences."); // remove tmp images from prior post $Blogger->deleteTempDir(); $size = number_format(fsize("data")/(1024*1024)); $posts = count($Blogger->getPosts()); $subscribers = $Blogger->getSubscribers(); $subscribersCount = count($subscribers); $postsTitle = getCopy('POSTS'); $postNews = getCopy('POST_NEWS'); $postSlideshow = getCopy('POST_SLIDESHOW'); $editOrDelete = getCopy('EDIT_OR_DELETE'); $preferences = getCopy('PREFERENCES'); $generalPreferences = getCopy('GENERAL_PREFERENCES'); $changePassword = getCopy('CHANGE_PASSWORD'); $headerFooter = getCopy('HEADER_FOOTER'); $emailFormat = getCopy('EMAIL_FORMAT'); $stats = getCopy('STATS'); $versionCopy = getCopy('VERSION'); $postsCopy = getCopy('POSTS'); $subscribersCopy = getCopy('SUBSCRIBERS'); $blogSize = getCopy('BLOG_SIZE'); $graphicsLib = getCopy('GRAPHICS_LIB'); print <<< HERE
$postsTitle
$postNews
$postSlideshow
$editOrDelete
$preferences
$generalPreferences
$changePassword
$headerFooter
$emailFormat
HERE; foreach ($subscribers as $subscriber) { $name = $subscriber->getName(); $content = $subscriber->getContent(); $email = $subscriber->getEmail(); echo ""; } print <<< HERE
$subscribersCopy
$name [$content]
$stats
$postsCopy$posts
$subscribersCopy$subscribersCount
$blogSize$size MB
$graphicsLib$glib
$versionCopy$version
HERE; if($disable_software_update != "true") { echo ""; } else { print <<< HERE
HERE; } print <<< HERE
HERE; } ////////////////////////////////// // PAGE: slideshow index ////////////////////////////////// function slideshow_index() { global $Blogger, $path, $path_dir, $id; $Post = $Blogger->getPost("$id"); //$id = $Post->getId(); $dir = $Post->getDir(); $date = $Post->getDate(); $title = $Post->getTitle(); $description = $Post->getDescription(); $Photos = $Post->getPhotos(); $number_pics = count($Photos); print <<< HERE
  $title fullscreen | splitscreen  
HERE; $pos = 0; $index = 0; foreach ($Photos as $Photo) { $photo_id = $Photo->getId(); $photo_description = $Photo->getDescription(); if($pos == 0) echo ""; echo ""; if($pos == 3) { echo ""; $pos = 0; } else { $pos = $pos + 1; } $index++; } while($pos < 4) { echo ""; $pos = $pos + 1; } echo "
$photo_description
 
"; } ////////////////////////////////// // PAGE: slideshow ////////////////////////////////// function slideshow() { global $Blogger, $path, $path_dir; $id = getValue('id'); $photo = getValue('photo'); if($photo == null) $photo = 0; $Post = $Blogger->getPost($id); if($Post == null) { postNotFound(); return; } $dir = $Post->getDir(); $date = $Post->getDate(); $title = $Post->getTitle(); $description = $Post->getDescription(); $Photos = $Post->getPhotos(); $number_pics = count($Photos); print <<< HERE HERE; $photo_index_first = ($photo + 1) . " of " . $number_pics; $stylesheet = str_replace("\n", "", getStylesheet()); print <<< HERE
«prev [next» fullscreen | index  
$photo_description
HERE; } ///////////////////////////////////// // PAGE: slideshow fullscreen ///////////////////////////////////// function slideshow_fullscreen() { global $Blogger, $path, $path_dir, $backgroundcolor; $number_pics = 0; $auto = "true"; $id = getValue('id'); if($id == "shuffle") { $Posts = $Blogger->getPosts(); $photos = array(); foreach($Posts as $Post) { if($Post->isTypeSlideshow()) { $dir = $Post->getDir(); $date = $Post->getDate(); $title = str_replace("|", "-", str_replace("+", " ", str_replace("\"", "\'", urldecode($Post->getTitle())))); $Photos = $Post->getPhotos(); foreach($Photos as $Photo) { $id = $Photo->getId(); $desc = str_replace("|", "-", str_replace("+", " ", str_replace("\"", "\'", urldecode($Photo->getDescription())))); $photos[$number_pics] = "$dir/$id|$desc|$date|$title"; $number_pics++; } } } for ($i=1; $i<$number_pics; $i++) { $d = mt_rand(0, $i); $tmp = $photos[$i]; $photos[$i] = $photos[$d]; $photos[$d] = $tmp; } } else { $Post = $Blogger->getPost($id); $dir = $Post->getDir(); $date = $Post->getDate(); $title = str_replace("|", "-", str_replace("+", " ", str_replace("\"", "\'", urldecode($Post->getTitle())))); $Photos = $Post->getPhotos(); foreach($Photos as $Photo) { $id = $Photo->getId(); $desc = str_replace("|", "-", str_replace("+", " ", str_replace("\"", "\'", urldecode($Photo->getDescription())))); $photos[$number_pics] = "$dir/$id|$desc|$date|$title"; $number_pics++; } } echo ""; echo getStylesheet(); print <<< HERE HERE; $photo_index_first = "1 of " . $number_pics; $stylesheet = str_replace("\n", "", getStylesheet()); print <<< HERE
«prev [next» «slower [faster»  start | stop | quit  


$photo_desc_first
HERE; } ////////////////////////////////// // PAGE: news photo ////////////////////////////////// function news_photo() { global $Blogger, $path, $path_dir; $id = getValue('id'); $photo = getValue('photo'); $Post = $Blogger->getPost($id); if($Post == null) { postNotFound(); return; } $dir = $Post->getDir(); $date = $Post->getDate(); $title = $Post->getTitle(); $thumbnail = $Post->getThumbnail(); $description = $Post->getDescription(); printSubHeader("$title","$description"); if($thumbnail != null && file_exists("$dir/thumbs/$thumbnail")) { print <<< HERE
HERE; } } ////////////////////////////////// // PAGE: edit news ////////////////////////////////// function edit_news() { global $Blogger, $path, $path_dir; $id = getValue('id'); $Post = $Blogger->getPost($id); $dir = $Post->getDir(); $date = $Post->getDate(); $title = $Post->getTitle(); $thumb = $Post->getThumbnail(); $description = $Post->getDescription(); echo ""; printSubHeader("Edit News Post", "Edit the title, description or picture for this news post."); print <<< HERE
Title
Description
Picture
HERE; } ////////////////////////////////// // PAGE: edit slideshow ////////////////////////////////// function edit_slideshow() { global $Blogger, $path, $path_dir, $max_single_upload, $max_total_upload; $id = getValue('id'); $Post = $Blogger->getPost($id); $folder = $Post->getDir(); $date = $Post->getDate(); $title = $Post->getTitle(); $thumb = $Post->getThumbnail(); $description = $Post->getDescription(); $Photos = $Post->getPhotos(); $number_pics = count($Photos); echo ""; printSubHeader("Edit Slideshow Post", "Edit the title, description and pictures for this slideshow post."); print <<< HERE
Title
Description


HERE; $i = 0; foreach ($Photos as $Photo) { $photo_id = $Photo->getId(); $photo_description = $Photo->getDescription(); $index=$i+1; print <<< HERE HERE; $i++; } $start = $i; $can_upload_more = ($start + $max_single_upload) <= $max_total_upload; if($can_upload_more) { for($x=0;$x<$max_single_upload;$x++) { $i = $start+$x; $idx = $i+1; print <<< HERE HERE; } } print <<< HERE
$index.
Change Picture
Description
Delete
$idx.
Picture
Description
HERE; } ////////////////////////////////// // PAGE: new slideshow ////////////////////////////////// function new_slideshow() { global $max_single_upload; printSlideshowUploadHeader("1"); printSlideshowUploadFooter(1); } ////////////////////////////////// // PAGE: new slideshow upload ////////////////////////////////// function new_slideshow_upload() { global $Blogger, $max_single_upload, $max_total_upload, $temp_dir, $path, $path_dir; printSlideshowUploadHeader("1"); $id = time(); echo ""; echo ""; $Photos = array(); $index = 0; $max = $max_total_upload - $max_single_upload; for($i=0;$i<$max;$i++) { $name = getValue("uploaded_pic$i"); if($name != null) { $Names[$index] = $name; $Descs[$index] = getValue("uploaded_desc$i"); $index++; } else { break; } } for($i=0;$i<$max_single_upload;$i++) { $file = getPostFiles("pic$i"); $desc = getValue("desc$i"); $tmp = $file['tmp_name']; $name = imageName($file['name']); if($tmp != null && is_uploaded_file($tmp)) { moveAndResize($tmp, $temp_dir, $name); $Names[$index] = "$name"; $Descs[$index] = "$desc"; $index++; } } $pos = 0; for($i = 0; $i < $index; $i++) { $name = $Names[$i]; $desc = $Descs[$i]; if($pos == 0) echo ""; echo ""; if($pos == 3) { echo ""; $pos = 0; } else { $pos = $pos + 1; } } while($pos < 4) { echo ""; $pos = $pos + 1; } $can_upload_more = ($index + $max_single_upload) <= $max_total_upload; print <<< HERE
" . ($i+1) . ".
$desc
 
 
   HERE; if($can_upload_more) echo " Or attach and upload additional pictures below
"; print <<< HERE
 
HERE; if($can_upload_more) printSlideshowUploadFooter($index+1); } ////////////////////////////////// // PAGE: new slideshow thumbnail ////////////////////////////////// function new_slideshow_thumbnail() { global $max_total_upload, $temp_dir, $path_dir; $id = getValue('id'); printSlideshowUploadHeader("2"); print <<< HERE
Title
Description
 
   After selecting a thumbnail by clicking on an image below
 
HERE; echo "
"; $Photos = array(); $index = 0; for($i=0;$i<$max_total_upload;$i++) { $name = getValue("uploaded_pic$i"); if($name != null) { $Names[$index] = $name; $Descs[$index] = getValue("uploaded_desc$i"); $index++; } else { break; } } $pos = 0; for($i = 0; $i < $index; $i++) { $name = $Names[$i]; $desc = $Descs[$i]; if($pos == 0) echo ""; echo ""; if($pos == 3) { echo ""; $pos = 0; } else { $pos = $pos + 1; } } while($pos < 4) { echo ""; $pos = $pos + 1; } echo "
$desc
 
"; } ////////////////////////////////// // PAGE: new slideshow post ////////////////////////////////// function new_slideshow_post() { global $Blogger, $max_total_upload, $temp_dir, $path_dir; $id = getValue('id'); $thumb = getValue('thumb'); $title = getValue('title'); $description = getValue('description'); $NewPost = new Post(null); $NewPost->setId($id); $NewPost->setTimestamp($id); $NewPost->setStatusActive(); $NewPost->setTypeSlideshow(); $NewPost->setTitle($title); $NewPost->setDescription($description); $NewPost->setThumbnail($thumb); $NewPost = $Blogger->addPost($NewPost); for($i=0;$i<$max_total_upload;$i++) { $name = getValue("uploaded_pic$i"); if($name != null) { $desc = getValue("uploaded_desc$i"); $NewPost->addPhoto($name,$desc); } else { break; } } $NewPost->savePhotos(); emailRedirect($id); } ////////////////////////////////// // PAGE: email ////////////////////////////////// function email() { global $Blogger, $path, $email_content_default, $email; $id = getValue("id"); $Post = $Blogger->getPost($id); if($email_content_default == "html") { $thepost = getBlogItem($Post); } else { $thepost = "
" . getTextItem($Post) . "
"; } $title = $Post->getTitle(); $email_greeting = getEmailGreeting(); $email_signature = getEmailSignature(); echo "\n"; echo "\n"; printSubHeader("Send Email","Email your post to subscriber list."); print <<< HERE
Subject
Email Greeting
Text Only
The Post $thepost
Email Signature
Text Only
Subscribers HERE; $subscribers = $Blogger->getSubscribers(); $count = 0; $recipients = "$email"; $total = count($subscribers); if($total == 0) echo "No subscribers yet.
"; foreach ($subscribers as $key => $value) { if(isset($value)) { $name = $value->getName(); $content = $value->getContent(); $remail = $value->getEmail(); $recipients .= ", "; $recipients .= $remail; if(!isset($content) || $content == "") $content = $email_content_default; echo "$name  [$content]  $email
"; $count++; } } print <<< HERE
Send To Comma delimited list of email addresses. (i.e. joe@aol.com, ann@earthlink.net, jim@netzero.net)
 

HERE; } ////////////////////////////////// // PAGE: logout_submit ////////////////////////////////// function logout_submit() { setCookieValue("key",""); indexRedirect(); } ////////////////////////////////// // PAGE: email_submit ////////////////////////////////// function email_submit() { global $Blogger, $HTTP_POST_VARS; $id = getValue("id"); $Post = $Blogger->getPost($id); $subject = getValue("subject"); $greeting = stripslashes(trim($HTTP_POST_VARS["greeting"])); $signature = stripslashes(trim($HTTP_POST_VARS["signature"])); $recipients = explode(",",trim($HTTP_POST_VARS["recipients"])); sendPostEmail($Post, $subject, $greeting, $signature, $recipients); indexRedirect(); } ////////////////////////////////// // PAGE: password ////////////////////////////////// function password($new) { global $path, $password, $goto_page; $error = getValue('error'); echo ""; if($new) { printSubHeader("PHP-Blogger Installation Successful!","To get started, please set your password."); $goto_page = "preferences"; } else { printSubHeader("Change Password","Please enter and confirm your new password."); } print <<< HERE HERE; if($error != null) echo ""; if(!$new) echo ""; print <<< HERE
$error
Old Password
New Password must be at least 4 characters
Confirm Password
HERE; } ////////////////////////////////// // PAGE: preferences ////////////////////////////////// function preferences() { global $path, $password, $name, $email, $sitename, $title_bar_color, $title_font_color, $link_color, $max_single_upload, $max_total_upload, $posts_per_page, $glib, $quality, $email_content_default, $hide_subscribers, $disable_software_update; $old_password = ""; $dglib = getDefaultGraphicsLib(); if(strcmp($password,"none") != 0) $old_password = $password; echo ""; printSubHeader("Set Preferences","Please set your blog site preferences."); print <<< HERE
General
User Name first name or nickname
Email contact email address
Site Name name of site to appear in header and email
Hide Subscribers check this box to hide subscriber names on subscribe/unsubscribe page
Disable Update check this box to disable notification on admin panel when a new version is availalbe
Look and Feel
Title Bar Color for example: 'darkblue' or '#325696'
Title Font Color for example: 'white' or '#FFFFFF'
Link Color for example: 'darkblue' or '#325696'
Slideshow
Max Single Upload maximum number of pictures that can be uploaded at one time
Max Total Upload total number of pictures that can be uploaded for a single slideshow
Posts Per Page max number of posts to be shown on a single page
Image Resizing
Graphics Library make sure whatever you select is actually installed! (restore default)
Image Quality Higher value means less compression, better quality. (restore default)


HERE; } ////////////////////////////////// // PAGE: header_footer ////////////////////////////////// function header_footer() { global $path; $header = getHeader(); $footer = getFooter(); echo ""; printSubHeader("Customize Header & Footer","Create your own custom header and footer. You may include PHP code."); print <<< HERE
Custom Header
Custom Footer
 

HERE; } ////////////////////////////////// // PAGE: email_format ////////////////////////////////// function email_format() { global $path, $password, $name, $email, $sitename, $email_content_default; $email_greeting = getEmailGreeting(); $email_signature = getEmailSignature(); echo ""; printSubHeader("Customize Email Format","Please set your email format preferences."); print <<< HERE
Email Content Type
Email Content Type Default This setting is only the default and can be overridden by the subscriber.
Email Greeting
Email Greeting
Text Only
Email Signature
Email Signature
Text Only
 

HERE; } ////////////////////////////////// // PAGE: logon ////////////////////////////////// function logon() { global $path, $name; $page = getValue('page'); $error = getValue('error'); echo ""; printSubHeader("Enter Your Password","Welcome Back $name!  Please enter your password to continue."); print <<< HERE HERE; if($error != null) echo ""; print <<< HERE
$error
Password
HERE; } ////////////////////////////////// // PAGE: password submit ////////////////////////////////// function password_submit() { global $Blogger, $password; // password $password = $Blogger->getPreference("password"); $can_change = false; $new_user = false; $new_password = getValue('new_password'); $old_password = getValue('old_password'); if(strcmp($password,"none") == 0) { $can_change = true; $new_user = true; } else { if(strcmp($password,md5($old_password)) == 0) { $can_change = true; } else { setValue("error","Old Password Entered Is Not Correct"); return "password"; } } if($new_password == null || strlen($new_password) < 4) { $can_change = false; setValue("error","New Password Is Invalid"); return "password"; } if($can_change) { $password = md5($new_password); $Blogger->setPreference("password",$password); setCookie("key","$password"); setCookieValue("key","$password"); if($new_user) return "preferences"; } return "admin"; } ////////////////////////////////// // PAGE: preferences submit ////////////////////////////////// function preferences_submit() { global $Blogger; $Blogger->setPreference("email",getValue("new_email")); $Blogger->setPreference("name",getValue("new_name")); $Blogger->setPreference("sitename",getValue("new_sitename")); $Blogger->setPreference("title_bar_color",getValue("new_title_bar_color")); $Blogger->setPreference("title_font_color",getValue("new_title_font_color")); $Blogger->setPreference("link_color",getValue("new_link_color")); $Blogger->setPreference("max_single_upload",getValue("new_max_single_upload")); $Blogger->setPreference("max_total_upload",getValue("new_max_total_upload")); $Blogger->setPreference("posts_per_page",getValue("new_posts_per_page")); $Blogger->setPreference("glib",getValue("new_glib")); $Blogger->setPreference("quality",getValue("new_quality")); $Blogger->setPreference("hide_subscribers",getValue("new_hide_subscribers")); $Blogger->setPreference("disable_software_update",getValue("new_disable_software_update")); } ////////////////////////////////// // PAGE: header_footer_submit ////////////////////////////////// function header_footer_submit() { global $HTTP_POST_VARS, $header_file, $footer_file; // header $custom_header = stripslashes(trim($HTTP_POST_VARS["new_custom_header"])); if($custom_header != "") { writeToFile($custom_header, $header_file); } else { unlink($header_file); } // footer $custom_footer = stripslashes(trim($HTTP_POST_VARS["new_custom_footer"])); if($custom_footer != "") { writeToFile($custom_footer, $footer_file); } else { unlink($footer_file); } } ////////////////////////////////// // PAGE: email_format submit ////////////////////////////////// function email_format_submit() { global $Blogger, $HTTP_POST_VARS, $email_greeting_file, $email_signature_file; // content type $Blogger->setPreference("email_content_default",getValue("new_email_content_default")); // greeting $email_greeting = stripslashes(trim($HTTP_POST_VARS["new_email_greeting"])); if($email_greeting != "") { writeToFile($email_greeting, $email_greeting_file); } else { unlink($email_greeting_file); } // signature $email_signature = stripslashes(trim($HTTP_POST_VARS["new_email_signature"])); if($email_signature != "") { writeToFile($email_signature, $email_signature_file); } else { unlink($email_signature_file); } } ////////////////////////////////// // PAGE: subscribe submit ////////////////////////////////// function subscribe_submit() { global $Blogger, $name; $subscribe_email = getValue("subscribe_email"); $subscribe_name = getValue("subscribe_name"); $subscribe_content = getValue("subscribe_content"); if(!containsHtml($subscribe_email) && !containsHtml($subscribe_name)) { $Blogger->subscribe($subscribe_email,$subscribe_name,$subscribe_content); printSubHeader("Subscribe", "Subscribe to start receiving posts from $name via email."); echo "

Welcome! You will now recieve posts from $name via email.

"; } else { indexRedirect(); } } ////////////////////////////////// // PAGE: unsubscribe submit ////////////////////////////////// function unsubscribe_submit() { global $Blogger, $name; $unsubscribe_email = getValue("unsubscribe_email"); $Blogger->unsubscribe($unsubscribe_email); printSubHeader("Unsubscribe", "Unsubscribe to stop receiving posts from $name via email."); echo "

Goodbye. You will no longer receive posts from $name via email.

"; } ////////////////////////////////// // PAGE: logon submit ////////////////////////////////// function logon_submit() { global $Blogger; $password = $Blogger->getPreference("password"); $goto_page = getValue("goto_page"); $logon_password = getValue("logon_password"); $enc_logon_password = md5($logon_password); if(strcmp($password,$enc_logon_password) == 0) { setCookie("key","$password"); setCookieValue("key",$password); return $goto_page; } else { setValue("error","Password Entered Is Not Correct"); setValue("page","$goto_page"); return $goto_page; } } ////////////////////////////////// // PAGE: subscribe ////////////////////////////////// function subscribe() { global $path, $Blogger, $name, $email_content_default, $hide_subscribers; echo ""; echo ""; printSubHeader("Subscribe", "Subscribe to start receiving posts from $name via email."); print <<< HERE
Your Email Address
Your Name
Email Content Type
HERE; printSubHeader("Unsubscribe", "Unsubscribe to stop receiving posts from $name via email."); print <<< HERE
Your Email Address
HERE; if($hide_subscribers != "true") { printSubHeader("Current Subscribers", ""); echo ""; $subscribers = $Blogger->getSubscribers(); $count = count($subscribers); if($count == 0) { echo ""; } else { foreach ($subscribers as $key => $value) { if(isset($value)) { $name = $value->getName(); $content = $value->getContent(); if(!isset($content) || $content == "") $content = $email_content_default; echo ""; } } } echo "
No Current Subscribers
   $name  [$content]
"; } } ////////////////////////////////// // PAGE: contact ////////////////////////////////// function contact() { global $name, $path; echo ""; printSubHeader("Contact Me", "Send $name an email message."); print <<< HERE
Your Name
Your Email Address
Your Message
HERE; } ////////////////////////////////// // PAGE: contact_submit ////////////////////////////////// function contact_submit() { global $name, $email; $contact_name = getValue("contact_name"); $contact_email = getValue("contact_email"); $contact_message = getValue("contact_message"); $title = "message from: $contact_name"; $body = $contact_message; // headers $headers = "From: $contact_email\n"; $headers .= "Reply-To: $contact_email\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; // send it mail($email, $title, $body, $headers); printSubHeader("Thanks", "Your mesage has been delivered to $name."); } ////////////////////////////////// // PAGE: new news ////////////////////////////////// function new_news() { global $path; echo ""; $step = getCopy('STEP'); $title = getCopy('CREATE_NEWS_POST'); $subtitle = $step . " 1: " . getCopy('POST_NEWS_WITH') . "
" . $step . " 2: " . getCopy('SEND_EMAIL') . "
"; printSubHeader($title, $subtitle); print <<< HERE
Title
Description
Picture
HERE; } ////////////////////////////////// // PAGE: new news submit ////////////////////////////////// function new_news_submit() { global $Blogger, $data_dir, $path; $id = time(); $folder = $data_dir . "/" . $id; createDirectory("$folder"); createDirectory("$folder/thumbs"); $title = getValue("title"); $description = getValue("description"); $file = getPostFiles("pic"); $tmp = $file['tmp_name']; $name = imageName($file['name']); if($tmp != null && is_uploaded_file($tmp)) { moveAndResize($tmp, $folder, $name); } $NewPost = new Post(null); $NewPost->setId($id); $NewPost->setTimestamp($id); $NewPost->setStatusActive(); $NewPost->setTypeNews(); $NewPost->setTitle($title); $NewPost->setDescription($description); $NewPost->setThumbnail($name); $NewPost = $Blogger->addPost($NewPost); emailRedirect($id); } ////////////////////////////////// // PAGE: edit news submit ////////////////////////////////// function edit_news_submit() { global $Blogger; $id = getValue('id'); $Post = $Blogger->getPost($id); $folder = $Post->getDir(); $thumb = $Post->getThumbnail(); $title = getValue("title"); $description = getValue("description"); $file = getPostFiles("pic"); $tmp = $file['tmp_name']; $name = imageName($file['name']); if($tmp != null && is_uploaded_file($tmp)) { moveAndResize($tmp, $folder, $name); $Post->setThumbnail($name); // remove old pictures to preserve diskspace if(file_exists("$folder/thumbs/$thumb")) unlink("$folder/thumbs/$thumb"); if(file_exists("$folder/$thumb")) unlink("$folder/$thumb"); } $Post->setTitle($title); $Post->setDescription($description); $Blogger->updatePost($Post); indexRedirect(); } ////////////////////////////////// // PAGE: edit slideshow submit ////////////////////////////////// function edit_slideshow_submit() { global $Blogger, $temp_dir, $max_single_upload; $id = getValue("id"); $title = getValue("title"); $thumb_index = getValue("thumb_index"); $description = getValue("description"); $Post = $Blogger->getPost($id); $folder = $Post->getDir(); $Post->setTitle($title); $Post->setDescription($description); $Photos = $Post->getPhotos(); $Post->setPhotos(null); $i = 0; foreach($Photos as $Photo) { $old_name = $Photo->getId(); $old_desc = $Photo->getDescription(); $delete = getValue("delete$i"); if("$delete" == "on") { $name = getValue("name$i"); unlink("$folder/thumbs/$name"); unlink("$folder/$name"); } else { $desc = getValue("desc$i"); $file = getPostFiles("pic$i"); $tmp = $file['tmp_name']; $name = imageName($file['name']); if($tmp != null && is_uploaded_file($tmp)) { moveAndResize($tmp, $temp_dir, $name); } else { $name = $old_name; } $Post->addPhoto("$name","$desc"); if($i == $thumb_index) $Post->setThumbnail($name); } $i++; } $count = $i; for($i=$count;$i<($count+$max_single_upload);$i++) { $desc = getValue("desc$i"); $file = getPostFiles("pic$i"); $tmp = $file['tmp_name']; $name = imageName($file['name']); if($tmp != null && is_uploaded_file($tmp)) { moveAndResize($tmp, $temp_dir, $name); $Post->addPhoto("$name","$desc"); if($i == $thumb_index) $Post->setThumbnail($name); } } $Blogger->updatePost($Post); slideshow(); } ####################################################################################### ### GLOBAL VARIABLES ################################################################## ####################################################################################### $path = empty($HTTP_SERVER_VARS['PATH_INFO'])?$HTTP_SERVER_VARS['PHP_SELF']:$HTTP_SERVER_VARS['PATH_INFO']; $host = empty($HTTP_SERVER_VARS['SERVER_NAME'])?$HTTP_ENV_VARS['SERVER_NAME']:$HTTP_SERVER_VARS['SERVER_NAME']; $path_dir = ""; $header_file = "data/header.php"; $footer_file = "data/footer.php"; $email_greeting_file = "data/email_greeting.txt"; $email_signature_file = "data/email_signature.txt"; $idx = strrpos($path,"/"); if($idx > 0) $path_dir = substr($path,0,$idx); // verify write access if (!file_exists("data")) { mkdir("data", 0777) or die("
PHP-Blogger installation failed!
  • Please run \"chmod 777 {install_dir}\"
  • install instructions"); } else { chmod("data", 0777); } $DataAccess = new DataAccess; $Blogger = new Blogger($DataAccess); $password = $Blogger->getPreference("password"); $glib = $Blogger->getPreference("glib"); // verify image libraries installed if($glib == "unset" || $glib == "") { $glib = getDefaultGraphicsLib(); if($glib == "none") echo "
    INSTALLATION WARNING!
  • Please verify either GD or Mogrify are installed.
  • install instructions"; $Blogger->setPreference("glib",$glib); } // these must happen before setting global variables or html // since they set cookies and modify global variables $page = getValue("page"); $type = getValue("type"); if($page == "logon_submit") { $page = logon_submit(); } else if($page == "password_submit" && ($password == "none" || isAuthenticated(true))) { $page = password_submit(); } else if($page == "preferences_submit" && isAuthenticated(true)) { preferences_submit(); adminRedirect(); } else if($page == "header_footer_submit" && isAuthenticated(true)) { header_footer_submit(); adminRedirect(); } else if($page == "email_format_submit" && isAuthenticated(true)) { email_format_submit(); adminRedirect(); } // preferences $email = $Blogger->getPreference("email"); $name = $Blogger->getPreference("name"); $sitename = $Blogger->getPreference("sitename"); $title_bar_color = $Blogger->getPreference("title_bar_color"); $title_font_color = $Blogger->getPreference("title_font_color"); $link_color = $Blogger->getPreference("link_color"); $max_single_upload = $Blogger->getPreference("max_single_upload"); $max_total_upload = $Blogger->getPreference("max_total_upload"); $posts_per_page = $Blogger->getPreference("posts_per_page"); $glib = $Blogger->getPreference("glib"); $quality = $Blogger->getPreference("quality"); $email_content_default = $Blogger->getPreference("email_content_default"); $language = $Blogger->getPreference("language"); $disable_software_update = $Blogger->getPreference("disable_software_update"); $hide_subscribers = $Blogger->getPreference("hide_subscribers"); // TODO: more stylesheet control $bordercolor = "#000000"; $backgroundcolor = "#E5E5E5"; $errorcolor = "red"; $data_dir = $DataAccess->data_dir; $temp_dir = $DataAccess->temp_dir; // fullscreen slideshow does not use header/footer if($page == "slideshow_fullscreen") { slideshow_fullscreen(); return; } ####################################################################################### ### THE HTML BODY ##################################################################### ####################################################################################### echo "$sitename\n"; echo getStylesheet(); echo "\n"; getHeader(); include 'data/header.php'; echo "
    \n"; if(strcmp($password,"none") == 0) { password(true); } else if ($page == "slideshow_index") { slideshow_index(); } else if ($page == "slideshow") { slideshow(); } else if ($page == "news_photo") { news_photo(); } else if ($page == "subscribe" || $page == "unsubscribe") { subscribe(); } else if ($page == "subscribe_submit") { subscribe_submit(); } else if ($page == "unsubscribe_submit") { unsubscribe_submit(); } else if ($page == "contact") { contact(); } else if ($page == "contact_submit") { contact_submit(); } else if ($page == "list") { post_list(); } else if ($page == "post_list" && isAuthenticated(true)) { post_list(); } else if ($page == "admin" && isAuthenticated(true)) { admin(); } else if ($page == "new_news" && isAuthenticated(true)) { new_news(); } else if ($page == "email" && isAuthenticated(true)) { email(); } else if ($page == "email_submit" && isAuthenticated(true)) { email_submit(); } else if ($page == "logout_submit" && isAuthenticated(true)) { logout_submit(); } else if ($page == "new_news_submit" && isAuthenticated(true)) { new_news_submit(); } else if ($page == "new_slideshow" && isAuthenticated(true)) { new_slideshow(); } else if ($page == "new_slideshow_upload" && isAuthenticated(true)) { new_slideshow_upload(); } else if ($page == "new_slideshow_thumbnail" && isAuthenticated(true)) { new_slideshow_thumbnail(); } else if ($page == "new_slideshow_post" && isAuthenticated(true)) { new_slideshow_post(); } else if($page == "delete_post" && isAuthenticated(true)) { delete_post(); } else if ($page == "edit_post" && $type == "news" && isAuthenticated(true)) { edit_news(); } else if ($page == "edit_post" && $type == "slideshow" && isAuthenticated(true)) { edit_slideshow(); } else if ($page == "edit_news_submit" && isAuthenticated(true)) { edit_news_submit(); } else if ($page == "edit_slideshow_submit" && isAuthenticated(true)) { edit_slideshow_submit(); } else if ($page == "preferences" && isAuthenticated(true)) { preferences(); } else if ($page == "header_footer" && isAuthenticated(true)) { header_footer(); } else if ($page == "email_format" && isAuthenticated(true)) { email_format(); } else if ($page == "password" && isAuthenticated(true)) { password(false); } else if ($page == "" || $page == "home" || $page == "index") { index(); } echo "
    \n"; getFooter(); include 'data/footer.php'; echo "\n"; ####################################################################################### ### HEADER & FOOTER & STYLESHEET ###################################################### ####################################################################################### function getStylesheet() { global $title_bar_color, $title_font_color, $link_color, $bordercolor, $backgroundcolor, $errorcolor; $style = "\n"; return $style; } function getHeader() { global $sitename, $path, $header_file, $copy; if(file_exists($header_file)) { $handle = fopen($header_file, "r"); $contents = fread($handle, filesize($header_file)); fclose($handle); return $contents; } else { $header = "\n"; $header .= " \n"; $header .= "   "; $header .= '$sitename'; $header .= "\n"; $header .= "   |\n"; $header .= "  " . getCopy("HEADER_LINK_HOME") . " |\n"; $header .= "  " . getCopy("HEADER_LINK_SUBSCRIBE") . " |\n"; $header .= "  " . getCopy("HEADER_LINK_CONTACT") . " |\n"; $header .= "  " . getCopy("HEADER_LINK_ADMIN") . " |\n"; $header .= "   \n"; $header .= " \n"; $header .= "HERE;\n"; $header .= " echo date('l, F jS');\n"; $header .= "print <<< HERE\n"; $header .= "   \n"; $header .= " \n"; $header .= "\n"; $header .= "HERE;\n"; $header .= "?>\n"; writeToFile($header, $header_file); return $header; } } function getFooter() { global $footer_file; if(file_exists($footer_file)) { $handle = fopen($footer_file, "r"); $contents = fread($handle, filesize($footer_file)); fclose($handle); return $contents; } else { $footer = "\n"; $footer .= "" . getCopy("FOOTER_SCRIPT_BY") . " phpblogger.com\n"; $footer .= "
  • \n"; $footer .= "HERE;\n"; $footer .= "?>\n"; writeToFile($footer, $footer_file); return $footer; } } ####################################################################################### ### EMAIL GREETING & SIGNATURE ######################################################## ####################################################################################### function getEmailGreeting() { global $email_greeting_file, $sitename, $name, $host, $path; if(file_exists($email_greeting_file)) { $handle = fopen($email_greeting_file, "r"); $contents = fread($handle, filesize($email_greeting_file)); fclose($handle); return $contents; } else { $greeting = getCopy("EMAIL_GREETING1") . "\n"; $greeting .= getCopy("EMAIL_GREETING2") . "\n"; $greeting .= "-> http://$host$path\n"; $greeting .= getCopy("EMAIL_GREETING3") . "\n"; $greeting .= "$name\n\n"; $greeting .= getCopy("EMAIL_GREETING4") . "\n"; writeToFile($greeting, $email_greeting_file); return $greeting; } } function getEmailSignature() { global $email_signature_file, $sitename, $name, $host, $path; if(file_exists($email_signature_file)) { $handle = fopen($email_signature_file, "r"); $contents = fread($handle, filesize($email_signature_file)); fclose($handle); return $contents; } else { $signature = getCopy("EMAIL_SIGNATURE1") . "\n"; $signature .= getCopy("EMAIL_SIGNATURE2") . " http://$host$path?page=unsubscribe.\n"; writeToFile($signature, $email_signature_file); return $signature; } } ?>