//####################################################################################
/*############################# uBlog!-Plugin ##########################################
| copyright: Markus Vetter | This version: V.0.86 |
| email: info@mv-web-design.de | 16.08.2007 |
| home: www.mv-web-design.de/?CMSimple/ | index.php |
-----------------------------------------------------------------------------------------
V.0.01 - 06.08.2006: release-Candidate No.1. first Steps in Plugin-Programming...
V.0.10 - 08.08.2006: release-Candidate No.2. nearly-ready-to-use-version..... :-)
New Features - captcha-Function integrated. switch on/off via config.php
- most of Design changeable via stylesheet.css (everything is
..)
every element with own class/id is listed in stylesheet.css, if css for
this element is used or not. So you will be able to change as you need.
- Failure-color can be changed via config.php (changes border-color of
unfilled/incorret filled input's of form and color of failure-description)
Possible entries: HTML-conform! e.g.: red, blue, green, #c0c0c0, #f00...
Just Open - write-Function makes no brakes at end of Line.
- images for ip-Adress, homepage...
- translation not available (en,dk,fr...). anyone out there?
- some text (e.g.:Absender, eingetragen...) should be kicked off into
variables in lang.php and also have to be translated... Detail work...
V.0.20 - 09.08.2006: release-Candidate No.3.
Made Changes - solved: write-Function makes no brakes at end of Line.
- if entry succesfull written it will be displayed in form by [form_success_text]
- cleantext active: in blog-Text now linebreak/html/javascript will be replaced
- upload of images added (incomplete...) and more text to kick off an translate...
Just Open - images for ip-Adress, homepage...
- translation not available (en,dk,fr...). anyone out there?
- some text (e.g.:Absender, eingetragen...) should be kicked off into
- if blog-file not exist, throws error. Must create file if not exist
V.0.30 - 11.08.2006: release-Candidate No.4.
Made Changes - new blog-file will be created if not exists
- upload of images completed. Images will be checked and resized
- images for ip-Adress, homepage... added. Can changed in images-directory
- blog can be turned on/off in first line of blog-file (Version;admin;closed;;;..)
- blog-file can now named as integer (automaticly changes to blog_0xx.txt) or string
(automaticly changes to blog_xxname.txt).
- many changes in style/css. more options available
- style/css-changes for compatibility with IE (document was written for FF)
- maximum-size for upload-image activated
- reload-prevention (via session) implemented
- text (e.g.:Absender, eingetragen...) kicked off into 'languages'.php
- picture-rename active. still uploaded images will no longer be overwritten but renamed
- simple validation for e-mail & web-adresses included.
Just Open - translation not available (en,dk,fr...). anyone out there?
- admin-Section can only handle on file yet
- plugin-help under help.htm to be written (de+en)...
V.0.40 - 15.08.2006: release-Candidat No.5.
Made Changes - plugin-help under help.htm to be written (de+en)...
- added to exclude cmsimple-scripting to ublog_cleantext()
Just Open - translation not available (en,dk,fr...). anyone out there?
- admin-Section can only handle on file yet
V.0.50 - 17.08.2006: release-Candidat No.5.
Made Changes - admin-Section can now handle multiple files
- admin-section now has it's own user-interface
- ip-adress can be canceled to show in blog
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
V.0.60 - 02.01.2007: release-Candidate No.6.
Made Changes - admin.php splitted into functions (tooo long code, now functions in include_admin.inc)
- more functions now in include.inc (email-/uri-check)...
- ip-adress can be canceled to show in blog
- fixed: homepage was written without automaic-prefix http://
- help.htm updated with new admin-section.
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.65 - 04.09.2006: release-Candidate No.7.
Made Changes - *.gif will be converted and saved as *.png (*.gif-Support not in all GD-Libraries available)
- images now will be deleted if entry/blog-file is deleted by admin
- filetype 'x-png' added to uploadable files
- error in modified plugin-loader corrected
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
- help-file needs to be updated on V.0.65
V.0.66 - 02.01.2007: renamed Version. New Name: uBlog!
Made Changes - new Name: uBlog!
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
- help-file needs to be updated on V.0.66
V.0.70 - 26.03.2007: nearly ready to publish
Made Changes - Killed separation of blog-files by '_'. Now blog-Files can be named anyhow.
- new Parameter ('show_empty_filds'): hides not filled Fields.
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
- help-file needs to be updated on V.0.7
V.0.80 - 02.04.2007: ...nearly ready to publish
Made Changes - functions for reading and writing from/to files pushed to include.inc
- all Functions now renamed to ublog_ ...
- help-file updated to V.0.81
- Download-Link added in admin.php
- included function:array_combine for PHP4 (is in PHP5!)
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.81 - 10.06.2007: ...nearly ready to publish
Made Changes - form now links to itself. If a field was incorrectly filled, site will
show form instead of top of the document
- Logging added: 0=off,1=new.entrys,2=pict.uplds+reloads,3=pict.fails,4=form.fails
- Debugging added. Can be activated for searching bugs. -> Slow's down your host!!
- strip-out pseudo-HTML-Tags like
'), because of Browser
interpret's this as a correct Tag ('', or '').
- img-Upload: if no min.size/width configured, original-image will be saved.
- Cleaned up code from some undefined variables.
- resolved bug, when deleting an entry when more than 9 entries existing -> file crashes
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
- Crashes sometimes after deleting an entry from a file.
V.0.82 - 20.06.2007: ....nearly ready to publish
Made Changes - Entries can be sorted by asc/desc. Standard = asc (newest entry on top)
- solved bug:(crashes after deleting an entry) -> wrong counting if more than 10 entries
- Logging: uses now correct filenames
- Entries now can be splitted in pages, configuration allows to display a variable
number of entries to display per page. Also navigation between pages is in three
ways configureable ( link(=1-5 6-10...)/ page(=1 2 3...)/ arrow(=|<< < 5-10 > >>|) )
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.83 - 05.07.2007: ....nearly ready to publish
Made Changes - Emoticons-Feature (can be activated/deactivated)
- logfiles now are size-controlled
- some corrections in log-writing-functions
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.84 - 31.07.2007: ....ready to publish?
Made Changes - some corrections in function rename_upload.
- corrections in function cleantext: stripslahes() deletes /
- corrections in split_pages: didn't work online
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.85 - 06.08.2007: ....ready to publish?
Made Changes - Button for creating new entries in Admin-Section added
- slovakian translation available (Thanx to: Dr.Martin Sereday - spisskepodhradie.sk)
- ip-adress made readonly in admin-mode
- timestamp will be displayed as date/time in admin-mode (readonly)
- links to entries in split-pages corrected (now uses #ublog_entries)
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
V.0.86 - 16.08.2007: ....ready to publish?
Made Changes - bugfix: regex doesn't allow URI's with '-'. Now uses preg_match() instead of ereg().
Just Open - translation not available (dk,fr...). anyone out there?
- tranlation (en) made byself with my humble english... anyone to correct?
- Testing of functionality under all conditions
-----------------------------------------------------------------------------------------
Listing of used variables and functions/classes:
Global Variables:
-----------------
$su : Titel of the (CMSimple-)Document
$sl : Language which is selected in CMSimple
$tx : array with CMSimple-Language-text
$plugin_cf : array with plugin-Configuration
$plugin_tx : array with plugin-Language-text
$pth : path of CMSimple
$plugin : name of plugin (=name of directory of plugin-> must be the same!!)
$plugin_pth : path of plugin.root
Plugin Variables:
-----------------
$ublog_version : version of this Script (will be written in new Blogfiles)
$mvwd_new_file_content : complete header which will be written in first line of each blogfile
$list_parameters : parameters, which will be read from blogfiles (array)
$entry_nr : number of entry in one blog-File
$entry : return-value of a completed entry
$new_entry_array : a new entry, generated by form->$_POST (array: associative, 1-dimensional)
$header : return-value of the complete head of the blog
$foot : return-value of the foot of the blog
$blog_nr : name (numbers or text) of blog-file which will returned to CMSimple
$blogfile : return-value of read blog-file
$fh : file-Handler (opened Blog-File)
$i : counter in if/for/while
$blog_array : contains all entry's of current blog-File (associative, 2-dimensional)
$blog_status : contains status of blog-File (associative, 2-dimensional)
$form_failure : when form was send, it'll be checked, if everything is correct filled
$form_failure_css : ...will be written in CMSimple, for do the red border on unfilled/incorrect input's
$form_failure_head : head of variable above.
$form_failure_style : style of variable above. Failure-Color can be changed in config.php
Functions:
----------
ublog() : Main-Function. Returns blog to CMSimple
ublog_check_form() : Function, which checks if all input's of a new entry filled correctly
ublog_header() : Head of Blog, which will appear in CMSimple.
ublog_entry() : Design of entry, which will appear in CMSimple.
ublog_foot() : Foot of Blog, which will appear in CMSimple.
ublog_get_file() : Returns the correct name and folder of blog-File
ublog_read_file() : Lists all entry's in blogfile and returns to main-Function
ublog_write_line() : writes a new entry in current blogfile
ublog_create_thumb() : checks and resizes the uploaded images to a size definded in config.php
ublog_rename_upload() : checks for existing image with same name and rename if necessary (xxx~001.gif)
ublog_cleantext() : Function to clean given blog-text from javascript/html-code/linebreaks
ublog_check_email() : checks for valid e-mail-adress (only pattern-check, no dns- or socket-check!!)
ublog_check_uri() : checks for valid web-adress (only pattern-check)
ublog_write_log() : write logging-infromations (new entry's, errors...)
array_combine() : for PHP<4.x without existing function array_combine()
ublog_get_emoticons() : returns html-
-tag for emoticons :-) :-( ...
ublog_recreate_file() : creates a new logfile if filesize is bigger than value in config
-----------------------------------------------------------------------------------------
/*#####################################################################################*/
include 'include.inc';
session_start(); //### start-session wg. reload-sperre + captcha
$ublog_version='ublog!_V.0.86'; //### Version: needed in new files!!
//### ublog main-Function #############################################################/
function ublog($blog_nr,$entry_start='')
{
global $pth, $plugin, $plugin_pth, $plugin_cf, $plugin_tx;
global $ublog_version, $mvwd_new_file_content;
//### Diagnosis ########################################################################################
if(($plugin_cf['ublog']['debugging']=='index'||$plugin_cf['ublog']['debugging']=='both')&&$plugin_cf['ublog']['debugging_filename']!='')
{
if($plugin_cf['ublog']['debugging_mode']=='vis'||$plugin_cf['ublog']['debugging_mode']=='both')
{ echo('
$_SESSION: ');
print_r($_SESSION);
echo('
$_POST: ');
print_r($_POST); }
if($plugin_cf['ublog']['debugging_mode']=='file'||$plugin_cf['ublog']['debugging_mode']=='both')
{ $debug_file=$plugin_pth.'/'.$plugin_cf['ublog']['logging_path'].'/'.$plugin_cf['ublog']['debugging_filename'];
error_log ("\n".'/*-----------------------------------------------------*/', 3, $debug_file);
error_log ("\n".time().' - Language: '.$sl.' - Source: index - Config: '.$plugin_cf['ublog']['debugging'], 3, $debug_file);
error_log ("\n".'$_SESSION: '.serialize($_SESSION), 3, $debug_file);
error_log ("\n".'$_POST: '.serialize($_POST), 3, $debug_file);
ini_set("error_reporting",E_ALL); // Aktiviert alle Error Meldungen
ini_set("display_errors",0); // Unterdrückt die Error Meldungen
ini_set("log_errors",1); // Aktiviert Logging
ini_set("error_log",$debug_file); /* Gibt Pfad zum LOG-File an */ }
}
//### END: Diagnosis ###################################################################################
$mvwd_new_file_content=$ublog_version.';admin;open;;;;;';
$list_parameters=array('title', 'user', 'email', 'homepage', 'ipadr', 'timestamp', 'img', 'blog_text');
$plugin=basename(dirname(__FILE__),"/");
$plugin_pth=$pth['folder']['plugins'].$plugin;
$form_failure='';
$form_failure_css='';
$blog_array = ublog_read_file($blog_nr, $list_parameters);
if (isset($_POST['ublog']))
{
$img_maxsize = $plugin_cf['ublog']['image_max_size'];
$img_maxwdt = $plugin_cf['ublog']['image_max_width'];
$img_maxhgt = $plugin_cf['ublog']['image_max_height'];
$upl_dir = $plugin_pth.'/upload/';
$img_qlty = $plugin_cf['ublog']['image_jpg_quality'];
$img_size = $_FILES['pic_upload']['size'];
$upl_picname = $_FILES['pic_upload']['name'];
$upl_pictmp = $_FILES['pic_upload']['tmp_name'];
$img_type = $_FILES['pic_upload']['type'];
$new_entry_array=ublog_check_form();
if(isset($_SESSION['reload'])) { if($_SESSION['reload'] == $_POST['reload']) { $new_entry_array='reload'; } }
$_SESSION['reload'] = $_POST['reload'];
if (gettype($new_entry_array)=='array')
{
$form_failure=2;
if ($plugin_cf['ublog']['image_allow_upload']==true&&$_FILES['pic_upload']['name'])
{
if ($img_size>$img_maxsize)
{ $form_failure=$plugin_tx['ublog']['form_failure_imagesize_text'].($img_size/1000).'kByte. Maximum: '.($img_maxsize/1000).'kByte.';
$new_entry_array['img']='false';
$ublog_log_array = array(time(),'picture_failure',$blog_nr,$form_failure);
ublog_write_log($ublog_log_array); }
else
{ $new_size = ublog_create_thumb ($upl_picname,$upl_pictmp,$img_maxwdt,$img_maxhgt,$upl_dir,$img_qlty,$img_type);
if (gettype($new_size)=='string')
{ $form_failure=$new_size; $new_entry_array['img']='false';
$ublog_log_array = array(time(),'picture_failure',$blog_nr,$form_failure);
ublog_write_log($ublog_log_array); }
if (gettype($new_size)=='array')
{ $form_failure=($plugin_tx['ublog']['form_success_with_image_text'].$new_size[0].'x'.$new_size[1]).'px.';
$new_entry_array['img']=$plugin_pth.'/upload/'.$new_size[2];
$ublog_log_array = array(time(),'picture_upload',$blog_nr,$new_entry_array['img']);
ublog_write_log($ublog_log_array); } }
}
ublog_write_line($blog_nr,'',$new_entry_array);
$ublog_log_array = array(time(),'new_entry',$blog_nr);
ublog_write_log($ublog_log_array);
}
elseif ($new_entry_array=='reload') { $form_failure=''; }
else { $form_failure_css=$new_entry_array; $form_failure=1; }
}
$blog_array = ublog_read_file($blog_nr, $list_parameters);
$blog_status = array_shift($blog_array);
if (($blog_status['user']=='admin')&&(($blog_status['email']=='closed')||($blog_status['email']=='close'))) { $blog_status='