[pLog-svn] r589 - plog/branches/plog-0.3.2

oscar at devel.plogworld.net oscar at devel.plogworld.net
Tue Dec 28 13:41:54 GMT 2004


Author: oscar
Date: 2004-12-28 13:41:53 +0000 (Tue, 28 Dec 2004)
New Revision: 589

Added:
   plog/branches/plog-0.3.2/wizard.php
Log:
the wizard.php script was somehow missing from this branch...


Added: plog/branches/plog-0.3.2/wizard.php
===================================================================
--- plog/branches/plog-0.3.2/wizard.php	2004-12-28 02:28:46 UTC (rev 588)
+++ plog/branches/plog-0.3.2/wizard.php	2004-12-28 13:41:53 UTC (rev 589)
@@ -0,0 +1,1136 @@
+<?php
+
+	if (!defined( "PLOG_CLASS_PATH" )) {
+    	define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+    }
+	
+    // many hosts don't have this enabled and we, for the time being, need it...
+    ini_set("arg_seperator.output", "&amp;");
+    ini_set("magic_quotes_runtime", 0 ); 
+    ini_set("magic_quotes_gpc", 1 );	
+
+	include_once( PLOG_CLASS_PATH."class/controller/controller.class.php" );
+    include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
+    include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
+    include_once( PLOG_CLASS_PATH."class/template/template.class.php" );
+    include_once( PLOG_CLASS_PATH."class/view/view.class.php" );
+    include_once( PLOG_CLASS_PATH."class/database/adodb/adodb.inc.php" );
+    include_once( PLOG_CLASS_PATH."class/data/stringvalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/emailvalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
+    include_once( PLOG_CLASS_PATH."class/net/httpvars.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+    include_once( PLOG_CLASS_PATH."class/misc/version.class.php" );
+    include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
+	include_once( PLOG_CLASS_PATH."class/misc/filefinder.class.php" );
+	include_once( PLOG_CLASS_PATH."class/gallery/resizers/gddetector.class.php" );
+
+    define( "TEMP_FOLDER", "./tmp" );
+
+    // sql querys used to create the tables
+
+    // maps used to map requests with actions
+    $_actionMap["Default"] = "WizardIntro";
+    $_actionMap["Intro"] = "WizardIntro";
+    $_actionMap["Step1"] = "WizardStepOne";
+    $_actionMap["Step2"] = "WizardStepTwo";
+    $_actionMap["Step3"] = "WizardStepThree";
+    $_actionMap["Step4"] = "WizardStepFour";
+    $_actionMap["Step5"] = "WizardStepFive";
+    $_actionMap["Update1"] = "UpdateStepOne";
+    $_actionMap["Update2"] = "UpdateStepTwo";
+    $_actionMap["Update3"] = "UpdateStepThree";
+
+
+    $Tables[0]["desc"] = "Articles";
+    $Tables[0]["code"] = "CREATE TABLE {dbprefix}articles (
+  id int(10) unsigned NOT NULL auto_increment,
+  category_id int(10) unsigned NOT NULL default '0',
+  topic text NOT NULL,
+  text text NOT NULL,
+  date timestamp(14) NOT NULL,
+  user_id int(10) unsigned NOT NULL default '0',
+  blog_id int(10) unsigned NOT NULL default '0',
+  status enum('published','draft','deleted') NOT NULL default 'published',
+  num_reads int(10) default '0',
+  properties TEXT NOT NULL default '',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[1]["desc"] = "Article categories";
+	$Tables[1]["code"] = "CREATE TABLE {dbprefix}articles_categories (
+  id int(10) unsigned NOT NULL auto_increment,
+  name varchar(255) NOT NULL default '',
+  url varchar(255) NOT NULL default '',
+  blog_id int(10) unsigned NOT NULL default '0',
+  last_modification timestamp(14) NOT NULL,
+  in_main_page TINYINT(1) NOT NULL DEFAULT '1',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[2]["desc"] = "Comments";
+	$Tables[2]["code"] = "CREATE TABLE {dbprefix}articles_comments (
+  id int(10) unsigned NOT NULL auto_increment,
+  article_id int(10) unsigned NOT NULL default '0',
+  topic text NOT NULL,
+  text text,
+  date timestamp(14) NOT NULL,
+  user_email varchar(255) default '',
+  user_url varchar(255) default '',
+  user_name varchar(255) NOT NULL default 'Anonymous',
+  parent_id int(10) unsigned default '0',
+  client_ip varchar(15) default '0.0.0.0',
+  send_notification tinyint(1) default '0',
+  status tinyint(2) default '1',
+  spam_rate float default '0',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[3]["desc"] = "Notifications";
+	$Tables[3]["code"] = "CREATE TABLE {dbprefix}articles_notifications (
+  id int(10) NOT NULL auto_increment,
+  blog_id int(10) NOT NULL default '0',
+  user_id int(10) NOT NULL default '0',
+  article_id int(10) NOT NULL default '0',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[4]["desc"] = "Blogs";
+	$Tables[4]["code"] = "CREATE TABLE {dbprefix}blogs (
+  id int(10) unsigned NOT NULL auto_increment,
+  blog varchar(50) NOT NULL default '',
+  owner_id int(10) unsigned NOT NULL default '0',
+  about text,
+  settings text NOT NULL,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[5]["desc"] = "MyLinks";
+    $Tables[5]["code"] = "CREATE TABLE {dbprefix}mylinks (
+  id int(10) unsigned NOT NULL auto_increment,
+  category_id int(10) unsigned NOT NULL default '0',
+  url varchar(255) NOT NULL default '',
+  name varchar(100) default '',
+  description text NOT NULL,
+  blog_id int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[6]["desc"] = "MyLinks Categories";
+    $Tables[6]["code"] = "CREATE TABLE {dbprefix}mylinks_categories (
+  id int(10) NOT NULL auto_increment,
+  name varchar(100) NOT NULL default '',
+  blog_id int(10) NOT NULL default '0',
+  last_modification timestamp(14) NOT NULL,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[7]["desc"] = "MyRecent";
+    $Tables[7]["code"] = "CREATE TABLE {dbprefix}myrecent (
+  id int(10) unsigned NOT NULL auto_increment,
+  category_id int(10) unsigned NOT NULL default '0',
+  name varchar(255) NOT NULL default '',
+  text text NOT NULL,
+  user_id int(10) unsigned NOT NULL default '0',
+  blog_id int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[8]["desc"] = "MyRecent categories";
+    $Tables[8]["code"] = "CREATE TABLE {dbprefix}myrecent_categories (
+  id int(10) unsigned NOT NULL auto_increment,
+  name varchar(255) NOT NULL default '',
+  blog_id int(10) unsigned NOT NULL default '0',
+  last_modification timestamp(14) NOT NULL,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[9]["desc"] = "Permissions";
+    $Tables[9]["code"] = "CREATE TABLE {dbprefix}permissions (
+  id int(10) unsigned NOT NULL auto_increment,
+  permission varchar(25) NOT NULL default '',
+  description varchar(100) NOT NULL default '',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[10]["desc"] = "Referers";
+    $Tables[10]["code"] = "CREATE TABLE {dbprefix}referers (
+  id int(10) NOT NULL auto_increment,
+  url text NOT NULL,
+  article_id int(10) NOT NULL default '0',
+  blog_id int(10) NOT NULL default '0',
+  hits int(10) default '1',
+  last_date timestamp(14),
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[11]["desc"] = "Trackbacks";
+	$Tables[11]["code"] = "CREATE TABLE {dbprefix}trackbacks (
+  id int(10) NOT NULL auto_increment,
+  url text NOT NULL,
+  title varchar(255) default '',
+  article_id int(10) NOT NULL default '0',
+  excerpt varchar(255) default '',
+  blog_name varchar(255) default '',
+  date timestamp(14) NOT NULL,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[12]["desc"] = "Users";
+    $Tables[12]["code"] = "CREATE TABLE {dbprefix}users (
+  id int(10) unsigned NOT NULL auto_increment,
+  user varchar(15) NOT NULL default '' UNIQUE,
+  password varchar(32) NOT NULL default '',
+  email varchar(255) NOT NULL default '',
+  about text,
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+	$Tables[13]["desc"] = "Permissions";
+    $Tables[13]["code"] = "CREATE TABLE {dbprefix}users_permissions (
+  id int(10) unsigned NOT NULL auto_increment,
+  user_id int(10) unsigned NOT NULL default '0',
+  blog_id int(10) unsigned NOT NULL default '0',
+  permission_id int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;";
+
+
+   $Tables[14]["desc"] = "Configuration";
+   $Tables[14]["code"] = "CREATE TABLE {dbprefix}config (
+   id int(10) NOT NULL auto_increment,
+   config_key varchar(255) NOT NULL default '',
+   config_value text NOT NULL,
+   value_type int(3) default '0',
+   PRIMARY KEY  (id,config_key)
+   ) TYPE=MyISAM;";
+
+   $Tables[15]["desc"] = "Blocked hosts";
+   $Tables[15]["code"] = "CREATE TABLE {dbprefix}filtered_content (
+   id int(10) NOT NULL auto_increment,
+   reg_exp text,
+   blog_id int(10) NOT NULL default '0',
+   reason text,
+   date timestamp(14) NOT NULL,
+   PRIMARY KEY  (id)
+   ) TYPE=MyISAM;";
+
+   $Tables[16]["desc"] = "Blocked content";
+   $Tables[16]["code"] = "CREATE TABLE {dbprefix}host_blocking_rules (
+   id int(10) NOT NULL auto_increment,
+   reason text,
+   date timestamp(14) NOT NULL,
+   blog_id int(10) NOT NULL default '0',
+   block_type int(1) default '1',
+   list_type int(1) default '1',
+   mask int(2) default '0',
+   host varchar(15) default '0.0.0.0',
+   PRIMARY KEY  (id)
+   ) TYPE=MyISAM;";
+
+   $Tables[17]["desc"] = "Gallery Resources";
+   $Tables[17]["code"] = "CREATE TABLE {dbprefix}gallery_resources (
+   id int(10) NOT NULL auto_increment,
+   owner_id int(10) NOT NULL default '0',
+   album_id int(10) NOT NULL default '0',
+   description text,
+   date timestamp(14) NOT NULL,
+   flags int(10) default '0',
+   resource_type int(3) default NULL,
+   file_path varchar(255) default '',
+   file_name varchar(255) default '',
+   metadata text,
+   thumbnail_format varchar(4) not null default 'same',
+   PRIMARY KEY  (id)
+   ) TYPE=MyISAM;";
+
+   $Tables[18]["desc"] = "Gallery Albums";
+   $Tables[18]["code"] = "CREATE TABLE {dbprefix}gallery_albums (
+   id int(10) NOT NULL auto_increment,
+   owner_id int(10) NOT NULL default '0',
+   description text NOT NULL,
+   name varchar(255) NOT NULL default '',
+   flags int(10) NOT NULL default '0',
+   parent_id int(10) NOT NULL default '0',
+   date timestamp(14) NOT NULL,
+   properties text NOT NULL DEFAULT '',
+   show_album TINYINT(1) DEFAULT 1,
+   PRIMARY KEY  (id)
+   ) TYPE=MyISAM;";
+
+   $Tables[19]["desc"] = "Bayesian Filter data table";
+   $Tables[19]["code"] = "CREATE TABLE {dbprefix}bayesian_filter_info (
+   id int(10) unsigned NOT NULL auto_increment,
+   blog_id int(10) unsigned default NULL,
+   total_spam int(10) unsigned default NULL,
+   total_nonspam int(10) unsigned default NULL,
+   PRIMARY KEY  (id)
+   ) TYPE=MyISAM;";
+
+   $Tables[20]["desc"] = "Bayesian Filter Information";
+   $Tables[20]["code"] = "CREATE TABLE {dbprefix}bayesian_tokens (
+   id int(10) unsigned NOT NULL auto_increment,
+   blog_id int(10) unsigned default NULL,
+   token char(100) default NULL,
+   spam_occurrences int(10) unsigned default NULL,
+   nonspam_occurrences int(10) unsigned default NULL,
+   prob float default NULL,
+   PRIMARY KEY  (id),
+   KEY blog_id (blog_id),
+   KEY token (token)
+   ) TYPE=MyISAM;";
+
+   // ---
+   // changes needed to update from 0.2 to 0.3
+   // ---
+   $Changes02_03[0]["desc"] = "Articles";
+   $Changes02_03[0]["code"] = "ALTER TABLE {dbprefix}articles ADD COLUMN properties TEXT NOT NULL default ''";
+
+   $Changes02_03[1]["desc"] = "Article Categories";
+   $Changes02_03[1]["code"] = "ALTER TABLE {dbprefix}articles_categories ADD COLUMN in_main_page TINYINT(1) default '1'";
+
+   $Changes02_03[2]["desc"] = "User Comments";
+   $Changes02_03[2]["code"] = "ALTER TABLE {dbprefix}articles_comments ADD COLUMN status TINYINT(2) default '0'";
+
+   $Changes02_03[3]["desc"] = "User Comments";
+   $Changes02_03[3]["code"] = "ALTER TABLE {dbprefix}articles_comments ADD COLUMN spam_rate FLOAT default '0'";
+
+
+   // ---
+   // end of changes needed in 0.3
+   // ---
+
+$Inserts[0] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('comments_enabled','1',1);";
+$Inserts[1] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('rdf_enabled','1',1);";
+$Inserts[2] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('temp_folder','./tmp',3);";
+$Inserts[3] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('base_url','{plog_base_url}',3);";
+$Inserts[4] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('show_posts_max','15',1);";
+$Inserts[5] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('recent_posts_max','10',1);";
+$Inserts[6] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('default_template','blueish',3);";
+$Inserts[7] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('template_folder','./templates',3);";
+$Inserts[8] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('default_blog_id','1',1);";
+$Inserts[9] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('default_locale','en_UK',3);";
+$Inserts[10] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('html_allowed_tags_in_comments','<a><i><br><br/><b>',3);";
+$Inserts[11] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('referer_tracker_enabled','1',1);";
+$Inserts[12] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('rss_parser_enabled','1',1);";
+$Inserts[13] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('show_more_enabled','1',1);";
+$Inserts[14] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('show_more_threshold','150',1);";
+$Inserts[15] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('update_article_reads','1',1);";
+$Inserts[16] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('email_service_enabled','1',1);";
+$Inserts[17] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('post_notification_source_address','noreply at your.host.com',3);";
+$Inserts[18] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('request_format_mode','1',1);";
+$Inserts[19] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('xmlrpc_ping_hosts','a:2:{i:0;s:27:\"http://rpc.weblogs.com/RPC2\";i:1;s:0:\"\";}',5);";
+$Inserts[20] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('trackback_server_enabled','1',1);";
+$Inserts[21] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('htmlarea_enabled','1',1);";
+$Inserts[22] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('plugin_manager_enabled','1',1);";
+$Inserts[23] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('check_email_address_validity','0',1);";
+$Inserts[24] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('summary_page_show_max','15',1);";
+$Inserts[25] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('minimum_password_length','4',1);";
+$Inserts[26] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('templates','a:3:{i:0;s:7:\"blueish\";i:1;s:4:\"grey\";i:2;s:6:\"lemons\";}',5);";
+$Inserts[27] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('locales','a:7:{i:0;s:5:\"en_UK\";i:1;s:5:\"es_ES\";i:2;s:5:\"ja_JP\";i:3;s:5:\"nl_BE\";i:4;s:5:\"zh_TW\";i:5;s:5:\"ca_ES\";i:6;s:5:\"fr_FR\";}',5)";
+$Inserts[28] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('email_service_type','php',3);";
+$Inserts[29] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('smtp_host','your.smtp.host.com',3);";
+$Inserts[30] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('smtp_port','25',1);";
+$Inserts[31] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('smtp_use_authentication','0',1);";
+$Inserts[32] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('smtp_username','',3);";
+$Inserts[33] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('smtp_password','',3);";
+$Inserts[34] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('locale_folder','./locale',3);";
+$Inserts[35] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('xmlrpc_ping_enabled','0',1);";
+$Inserts[36] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_tar','{path_to_tar}',3);";
+$Inserts[37] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_gzip','{path_to_gzip}',3);";
+$Inserts[38] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_bz2','{path_to_bz2}',3);";
+$Inserts[39] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_unzip','{path_to_unzip}',3);";
+$Inserts[40] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('users_can_add_templates',1,1);";
+$Inserts[41] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('maximum_file_upload_size', 2000000, 1);";
+$Inserts[42] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('upload_forbidden_files', '*.php *.php3 *.php4 *.phtml', 3);";
+$Inserts[43] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('comments_order', 1, 1);";
+// ---
+// new config settings added in 0.3
+// ---
+$Inserts[44] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('security_pipeline_enabled', 1, 1);";
+$Inserts[45] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('maximum_comment_size', 0, 1 );";
+$Inserts[46] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('resources_enabled', 1, 1 );";
+$Inserts[47] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_method', 'gd', 3);";
+$Inserts[48] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_convert', '{path_to_convert}', 3);";
+$Inserts[49] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_height', 120, 1);";
+$Inserts[50] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_width', 120, 1);";
+$Inserts[51] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnails_keep_aspect_ratio', 1, 1);";
+$Inserts[52] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('xmlrpc_api_enabled', 1, 1);";
+$Inserts[53] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('uploads_enabled', 1, 1);";
+$Inserts[54] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('default_rss_profile', 'rss090', 3);";
+// ---
+// config settings for the bayesian filter added in 0.3
+// ---
+$Inserts[55] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_enabled', 1, 2);";
+$Inserts[56] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_spam_probability_treshold', '0.9', 6);";
+$Inserts[57] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_nonspam_probability_treshold', '0.2', 6);";
+$Inserts[58] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_min_length_token', '3', 1);";
+$Inserts[59] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_max_length_token', '100', 1);";
+$Inserts[60] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_number_significant_tokens', 15, 1);";
+$Inserts[61] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('bayesian_filter_spam_comments_action', 0, 1 );";
+$Inserts[62] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('ip_address_filter_enabled', 1, 1 );";
+$Inserts[63] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('content_filter_enabled', 0, 1 );";
+$Inserts[64] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('thumbnail_format','same',3);";
+$Inserts[65] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('resources_folder','./gallery/',3);";
+$Inserts[66] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('beautify_comments_text', '1', 1);";
+// ---
+// some other settings added in 0.3.1
+// ---
+$Inserts[67] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('disable_apache_error_handler', '0', 1);";
+$Inserts[68] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('show_future_posts_in_calendar', '0', 1);";
+
+
+     function connectDb( $ignoreError = false )
+     {
+     	$config = new ConfigFileStorage();
+		// open a connection to the database
+		$db = NewADOConnection( 'mysql' );
+		$res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $config->getValue( "db_database" ));
+		
+		// return error
+		if( $ignoreError )
+			return $db;
+			
+		if( !$res )
+			return false;
+
+        return $db;
+	}
+
+    /**
+     * Renders a template file.
+     */
+	class WizardView extends View {
+
+    	var $_templateName;
+
+    	function WizardView( $templateName )
+        {
+        	$this->View();
+            $this->_templateName = $templateName;
+        }
+
+        function render()
+        {
+            // build the file name
+            $templateFileName = "wizard/".$this->_templateName.".template";
+
+            //$t = new Template( $templateFileName, "" );
+            $t = new Smarty();
+            $this->_params->setValue( "version", new Version());
+            $t->assign( $this->_params->getAsArray());
+            $t->template_dir    = "./templates";
+            $t->compile_dir     = TEMP_FOLDER;
+	    $t->cache_dir       = TEMP_FOLDER;
+            $t->use_sub_dirs    = false;
+	    $t->caching = false;
+
+            print $t->fetch( $templateFileName );
+        }
+    }
+
+    /**
+     * Gets the information about the database from the user.
+     */
+    class WizardIntro extends Action {
+
+        function perform()
+        {
+        	$this->_view = new WizardView( "intro" );
+        }
+    }
+
+    /**
+     * Represents the first step
+     */
+    class WizardStepOne extends Action {
+
+    	var $_dbServer;
+        var $_dbUser;
+        var $_dbPassword;
+        var $_dbName;
+        var $_dbPrefix;
+
+    	function validate()
+        {
+        	$this->_dbServer   = $this->_request->getValue( "dbServer" );
+            $this->_dbUser     = $this->_request->getValue( "dbUser" );
+            $this->_dbPassword = $this->_request->getValue( "dbPassword" );
+            $this->_dbName     = $this->_request->getValue( "dbName" );
+            $this->_skipThis   = $this->_request->getValue( "skipDbInfo" );
+            $this->_dbPrefix   = $this->_request->getValue( "dbPrefix", DEFAULT_DB_PREFIX );
+
+            // we can ignore everything here, since the user wanted
+            // to skip this step...
+            if( $this->_skipThis == "yes" )
+            	return true;
+
+            // otherwise, continue with the normal process
+            $errors = false;
+
+            // validate the data
+            $val1 = new StringValidator( $this->_dbServer );
+            if( !$val1->validate()) {
+            	$message .= "Incorrect database server.<br/>";
+            	$errors = true;
+            }
+
+            $val2 = new StringValidator( $this->_dbUser );
+            if( !$val2->validate()) {
+            	$message .= "Incorrect database user.<br/>";
+            	$errors = true;
+            }
+
+			// empty passwords should be allowed!
+			if( $this->_dbPassword != "" ) {
+				$val3 = new StringValidator( $this->_dbPassword );
+				if( !$val3->validate()) {
+					$message .= "Incorrect database password.<br/>";
+					$errors = true;
+				}
+			}
+
+            $val4 = new StringValidator( $this->_dbName );
+            if( !$val4->validate()) {
+            	$message .= "Incorrect database name.<br/>";
+            	$errors = true;
+            }
+
+            $val5 = new StringValidator( $this->_dbPrefix );
+            if( !$val5->validate()) {
+            	$message .= "Incorrect database prefix.<br/>";
+                $errors = true;
+            }
+
+            // we should show the same page again but with some information about the
+            // errors
+            if( $errors ) {
+            	$this->_view = new WizardView( "intro" );
+                $this->_view->setValue( "errors", true );
+                $this->_view->setValue( "message", $message );
+            	return false;
+            }
+
+            return true;
+        }
+
+    	function perform()
+        {
+        	// we should now save the data to the configuration file, just before
+            // we read it
+        	$configFile = new ConfigFileStorage();
+			
+            if( $this->_skipThis != "yes" ) {
+			
+				// before doing anything, we should check of the configuration file is 
+				// writable by this script, or else, throw an error and bail out gracefully
+				$configFileName = $configFile->getConfigFileName();
+				if( !File::isWritable( $configFileName )) {
+					$this->_view = new WizardView( "error" );
+					$message = "Please make sure that the file $configFileName can be written by this script during
+					            the installation process. It is needed to store the database configuration settings. Once the
+								installation is complete, please revert the permissions to no writing possible.";
+					$this->_view->setValue( "message", $message );
+					return false;
+				}
+				
+				// continue if everything went fine
+            	if( !$configFile->saveValue( "db_username", $this->_dbUser )) {
+                	$this->_view = new WizardView( "error" );
+                    $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                    return false;
+                }
+            	if( !$configFile->saveValue( "db_password", $this->_dbPassword )) {
+                    $this->_view = new WizardView( "error" );
+                    $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                    return false;
+                }
+            	if( !$configFile->saveValue( "db_host", $this->_dbServer )) {
+                	$this->_view = new WizardView( "error" );
+                    $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                    return false;
+                }
+            	if( !$configFile->saveValue( "db_database", $this->_dbName )) {
+                	$this->_view = new WizardView( "error" );
+                    $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                    return false;
+                }
+                if( !$configFile->saveValue( "db_prefix", $this->_dbPrefix )) {
+                	$this->_view = new WizardView( "error" );
+                    $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                    return false;
+                }
+            }
+
+        	$this->_view = new WizardView( "step1" );
+
+            // now we better read the information from the config file to make sure that
+            // it has been correctly saved
+            $configFile->reload();
+            $this->_view->setValue( "username", $configFile->getValue( "db_username" ));
+            $this->_view->setValue( "password", $configFile->getValue( "db_password" ));
+            $this->_view->setValue( "host", $configFile->getValue( "db_host" ));
+            $this->_view->setValue( "database", $configFile->getValue( "db_database" ));
+            $this->_view->setValue( "prefix", $configFile->getValue( "db_prefix" ));
+
+            return true;
+        }
+    }
+
+    /**
+     * Second step where we connect to the database and create the tables.
+     */
+    class WizardStepTwo extends Action {
+
+    	var $_db;
+        var $_database;
+        var $_createDatabase;
+
+        function validate()
+        {
+        	$createDb = $this->_request->getValue( "createDatabase" );
+            if( $createDb == "on" )
+            	$this->_createDatabase = true;
+            else
+            	$this->_createDatabase = false;
+
+            return true;
+        }
+
+    	function perform()
+        {
+        	global $Tables;
+            global $Inserts;
+			
+			// only check for errors in case the database table should already exist!
+			if( !$this->_createDatabase ) {
+				$this->_db = connectDb();			
+				if( !$this->_db ) {
+					$this->_view = new WizardView( "error" );
+					$this->_view->setValue( "message", "There was an error connecting to the database. Please check your settings." );
+					return false;
+				}
+			}
+			else
+				$this->_db = connectDb( true );
+			
+     		$config = new ConfigFileStorage();
+			$this->_database = $config->getValue( "db_database" );
+            $this->_dbPrefix = $config->getValue( "db_prefix" );
+
+            // create the database
+            if( $this->_createDatabase ) {
+            	if( !$this->_db->Execute( "CREATE DATABASE ".$this->_database )) {
+            		$message .= "Error creating the database: ".$this->_db->ErrorMsg();
+                	$this->_view = new WizardView( "error" );
+                	$this->_view->setValue( "message", $message );
+                	return false;
+            	}
+            	else
+            		$message .= "Database created successfully.<br/>";
+            }
+
+            // reconnect using the new database.
+            $config = new ConfigFileStorage();
+            $this->_db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $this->_database );
+
+            // create the tables
+            $errors = false;
+            foreach( $Tables as $table ) {
+            	$query = str_replace( "{dbprefix}", $this->_dbPrefix, $table["code"] );
+            	if( $this->_db->Execute( $query ))
+                	$message .= "Table ".$table["desc"]." created successfully.<br/>";
+                else {
+                	$message .= "Error creating table: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+            }
+
+            if( $errors ) {
+            	$message = "There was an error creating the tables in the database. Please make sure that the user chosen to connect to the database has enough permissions to create tables.<br/><br/>$message";
+            	$this->_view = new WizardView( "error" );
+            	$this->_view->setValue( "message", $message );
+
+                return false;
+            }
+
+            // try to guess the url where plog is running
+            $httpHost = $_SERVER["HTTP_HOST"];
+            $requestUrl = $_SERVER["REQUEST_URI"];
+            $requestUrl = str_replace( "/wizard.php", "", $requestUrl );
+            $plogUrl = "http://".$httpHost.$requestUrl;
+			
+			// Find some of the tools we are going to need (last one is for os x, with fink installed)
+			$folders = Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" );
+			$finder = new FileFinder( $folders );
+			$pathToUnzip = $finder->find( "unzip" );
+			$pathToTar = $finder->find( "tar" );
+			$pathToGzip = $finder->find( "gzip" );
+			$pathToBzip2 = $finder->find( "bzip2" );
+			$pathToConvert = $finder->find( "convert" );
+
+            // and execute some insert's
+            foreach( $Inserts as $insert ) {
+            	$query = str_replace( "{dbprefix}", $this->_dbPrefix, $insert );
+                $query = str_replace( "{plog_base_url}", $plogUrl, $query );
+				// replace also the placeholders for the paths to the tools
+				$query = str_replace( "{path_to_tar}", $pathToTar, $query );
+				$query = str_replace( "{path_to_unzip}", $pathToUnzip, $query );
+				$query = str_replace( "{path_to_bz2}", $pathToBzip2, $query );
+				$query = str_replace( "{path_to_gzip}", $pathToGzip, $query );
+				$query = str_replace( "{path_to_convert}", $pathToConvert, $query );
+				$query = str_replace( "{path_to_convert}", $pathToConvert, $query );
+            	if( !$this->_db->Execute( $query )) {
+                	$message .= "Error executing code: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+            }
+
+			//
+			// show some information regarding the helper tools we're going to need
+			// and wether they were found or not
+			//
+			$message .= "<br/><b>-- Helper tools --</b><br/>";
+			if( $pathToTar == "" )
+				$message .= "The helper tool 'tar' was not found<br/>";
+			else
+				$message .= "The helper tool 'tar' was found in $pathToTar<br/>";
+			if( $pathToGzip == "" )
+				$message .= "The helper tool 'gzip' was not found<br/>";
+			else
+				$message .= "The helper tool 'gzip' was found in $pathToGzip<br/>";
+			if( $pathToUnzip == "" )
+				$message .= "The helper tool 'unzip' was not found<br/>";
+			else
+				$message .= "The helper tool 'unzip' was found in $pathToUnzip<br/>";
+			if( $pathToBzip2 == "" )
+				$message .= "The helper tool 'bzip2' was not found<br/>";
+			else
+				$message .= "The helper tool 'bzip2' was found in $pathToTar<br/>";
+			if( $pathToConvert == "" )
+				$message .= "The helper tool 'convert' (from the ImageMagick package) was not found<br/>";
+			else
+				$message .= "The helper tool 'convert' (from the ImageMagick package) was found in $pathToConvert<br/>";
+
+            if( $errors ) {
+            	$this->_view = new WizardView( "error" );
+                $message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>$message";
+            }
+            else
+            	$this->_view = new WizardView( "step2" );
+
+            $this->_view->setValue( "message", $message );
+        }
+    }
+
+    class WizardStepThree extends Action {
+
+    	function perform()
+        {
+        	$this->_view = new WizardView( "step3" );
+        }
+    }
+
+    class WizardStepFour extends Action {
+
+    	var $_userName;
+        var $_userPassword;
+        var $_confirmPassword;
+        var $_userEmail;
+
+        function validate()
+        {
+        	$this->_userName = $this->_request->getValue( "userName" );
+            $this->_userPassword = $this->_request->getValue( "userPassword" );
+            $this->_confirmPassword = $this->_request->getValue( "userPasswordCheck" );
+            $this->_userEmail = $this->_request->getValue( "userEmail" );
+            $errors = false;
+
+            // validate the information
+            $userVal = new StringValidator( $this->_userName );
+            if( !$userVal->validate()) {
+            	$message .= "Incorrect user name, please try again.<br/>";
+                $errors  = true;
+            }
+
+            $passVal = new StringValidator( $this->_userPassword );
+            if( !$passVal->validate()) {
+            	$message .= "Incorrect password, please try again. <br/>";
+                $errors = true;
+            }
+
+            $emailVal = new EmailValidator( $this->_userEmail );
+            if( !$emailVal->validate()) {
+            	$message .= "Incorrect email address, please try again. <br/>";
+                $errors = true;
+            }
+
+            if( $this->_userPassword != $this->_confirmPassword ) {
+            	$message .= "Passwords do not match, please try again. <br/>";
+                $errors = true;
+            }
+
+            if( $errors ) {
+            	$this->_view = new WizardView( "step3" );
+                $this->_view->setValue( "message", $message );
+                $this->_view->setValue( "errors", $errors );
+                return false;
+            }
+
+            return true;
+        }
+
+        // creates the user
+        function perform()
+        {
+        	$db = connectDb();
+			
+			if( !$db ) {
+				$this->_view = new WizardView( "error" );
+				$this->_view->setValue( "message", "There was an error connecting to the database. Please check your settings." );
+				
+				return false;
+			}
+			
+
+            $config = new Config();
+            $dbPrefix = $config->getValue( "db_prefix" );
+
+            $users = new Users();
+            $userId = $users->addUser( $this->_userName, $this->_userPassword, $this->_userEmail);
+            if( !$userId ) {
+            	$this->_view = new WizardView( "error" );
+                $message = "There was an error adding the user. Make sure that the user does not already exist in the database (".$users->DbError().")";
+                $this->_view->setValue( "message", $message );
+                return false;
+            }
+
+            // we also have to execute the code to give administrator privileges to this user
+            $userPerms = "INSERT INTO {dbprefix}users_permissions(user_id,blog_id,permission_id) VALUES(
+                      $userId, 0, 1 );";
+            $query = str_replace( "{dbprefix}", $dbPrefix, $userPerms );
+            $result = $db->Execute( $query );
+
+            $this->_view = new Wizardview( "step4" );
+            $this->_view->setValue( "ownerid", $userId );
+            return true;
+        }
+
+    }
+
+    class WizardStepFive extends Action {
+
+    	var $_blogName;
+        var $_ownerId;
+
+        function validate()
+        {
+        	$this->_blogName = $this->_request->getValue( "blogName" );
+            $this->_ownerId  = $this->_request->getValue( "ownerId" );
+
+            $errors = false;
+            $val = new StringValidator( $this->_blogName );
+            if( !$val->validate()) {
+            	$errors = true;
+                $this->_view = new WizardView( "step4" );
+                $this->_view->setValue( "message", "You should choose a better name for the blog." );
+                $this->_view->setValue( "errors", true );
+                // this value has to be put in the template again
+                $this->_view->setValue( "ownerid", $this->_ownerId );
+                return false;
+            }
+
+            return true;
+        }
+
+        function perform()
+        {
+        	$db = connectDb();
+			
+			if( !$db ) {
+				$this->_view = new WizardView( "error" );
+				$this->_view->setValue( "message", "There was an error connecting to the database. Please check your settings." );
+				
+				return false;
+			}
+						
+
+            $blogs = new Blogs();
+            $newblogId = $blogs->addBlog( $this->_blogName, $this->_ownerId );
+            if( !$newblogId ) {
+            	$this->_view = new WizardView( "error" );
+                $this->_view->setValue( "message", "There was an error creating the new blog: ".$db->ErrorMsg());
+                return false;
+            }
+
+            // if the blog was created, we can add some basic information
+            // add a category
+            $articleCategories = new ArticleCategories();
+            $articleCategory = new ArticleCategory( "General", "", $newblogId, true );
+            $catId = $articleCategories->addArticleCategory( $articleCategory );
+
+            // add an article based on that category
+            $articleTopic = "Congratulations, it worked!";
+            $articleText  = "Welcome to pLog! If you can read this, it means that your pLog installation is ready and that you can start blogging.";
+            $article = new Article( $articleTopic, $articleText, $catId, $this->_ownerId, $newblogId, 'Published', 0 );
+            $t = new Timestamp();
+            $article->setDateObject( $t );
+            $articles = new Articles();
+            $articles->addArticle( $article );
+
+            // and finally set the default_blog_id setting in the config.properties.php file
+            // to the identifier of the blog we've just created
+            $config = new Config();
+            if( !$config->saveValue( "default_blog_id", (int)$newblogId )) {
+                $this->_view = new WizardView( "error" );
+                $this->_view->setValue( "message", "Could not save values to the configuration file. Please make sure it is available and that has write permissions for the user under your web server is running.");
+                return false;
+            }
+			
+			//
+			// detect wether we have GD available and set the blog to use it
+			//
+			if( GdDetector::detectGd()) {
+				$config->saveValue( "thumbnail_method", "gd" );
+				$message = "GD has been detected and set as the backend for dealing with images.";
+			}
+			else {
+				$pathToConvert = $config->getValue( "path_to_convert" );
+				if( $pathToConvert ) {
+					$config->saveValue( "thumbnail_method", "imagemagick" );
+					$message = "ImageMagick has been detected and set as the backend for dealing with images.";
+				}
+				else {	
+					// nothing was found, so we'll have to do away with the 'null' resizer...
+					$config->saveValue( "thumbnail_method", "null" );
+					$message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images.";
+				}
+			}
+
+            $this->_view = new WizardView( "step5" );
+			$this->_view->setValue( "message", $message );
+            return true;
+        }
+    }
+
+    //
+    // the following classes take care of updating the database to the last release
+    //
+    class UpdateStepOne extends Action {
+
+    	function perform()
+        {
+        	$config = new ConfigFileStorage();
+
+            $this->_view = new WizardView( "update1" );
+            $this->_view->setValue( "dbServer", $config->getValue( "db_host" ));
+            $this->_view->setValue( "dbUser", $config->getValue( "db_username" ));
+            $this->_view->setValue( "dbPassword", $config->getValue( "db_password" ));
+            $this->_view->setValue( "dbName", $config->getValue( "db_database" ));
+            $this->_view->setValue( "dbPrefix", $config->getValue( "db_prefix" ));
+        }
+    }
+
+    class UpdateStepTwo extends Action {
+
+    	var $_db;
+        var $_dbPrefix;
+
+    	function validate()
+        {
+            // otherwise, continue with the normal process
+            $errors = false;
+
+        	$configFile = new ConfigFileStorage();
+            $this->_dbPrefix = $configFile->getValue( "db_prefix" );
+
+            return true;
+        }
+
+        function perform()
+        {
+        	// we need to create the new tables here
+            $newTables = Array( 15, 16, 17, 18, 19, 20 );
+
+            global $Tables;
+            global $Changes02_03;
+            global $Inserts;
+
+            // connect to the db
+            $this->_db = connectDb();
+
+			if( !$this->_db ) {
+				$this->_view = new WizardView( "error" );
+				$this->_view->setValue( "message", "There was an error connecting to the database. Please check your settings." );
+				
+				return false;
+			}
+			
+            // ---
+            // create the new tables in 0.3
+            // ---
+            // loop only through the new tables
+            foreach( $newTables as $tableId ) {
+            	// get info about the table we'd like to use
+            	$table = $Tables[$tableId];
+                // and run the query
+            	$query = str_replace( "{dbprefix}", $this->_dbPrefix, $table["code"] );
+            	if( $this->_db->Execute( $query ))
+                	$message .= "New table ".$table["desc"]." created successfully.<br/>";
+                else {
+                	$message .= "Error creating table: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+            }
+            if( !$errors ) {
+            	$message .= "** New tables created successfully **<br/><br/>";
+            }
+
+            // ---
+            // make changes to the tables that need changes
+            // ---
+            foreach( $Changes02_03 as $change ) {
+
+                // and run the query
+            	$query = str_replace( "{dbprefix}", $this->_dbPrefix, $change["code"] );
+            	if( $this->_db->Execute( $query ))
+                	$message .= "Changes to table ".$change["desc"]." executed successfully.<br/>";
+                else {
+                	$message .= "Error modifying table: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+            }
+            if( !$errors ) {
+            	$message .= "** Modifications to old tables carried out successfully **<br/><br/>";
+            }
+
+            // ---
+            // add the new configuration settings
+            // ---
+            $newSettings = Array( 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 );
+            foreach( $newSettings as $settingId ) {
+				// find where the user is running the convert binary from the ImageMagick package
+				$pathToConvert = FileFinder::find( "convert", Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" ));
+            	// get info about the table we'd like to use
+                $setting = $Inserts[$settingId];
+            	$query = str_replace( "{dbprefix}", $this->_dbPrefix, $setting );
+				$query = str_replace( "{path_to_convert}", $pathToConvert, $query );
+            	if( !$this->_db->Execute( $query )) {
+                	$message .= "There was an error executing: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+            }
+			
+			// give some more information to the user
+			$message .= "** Helper Tools **<br/>";
+			if( $pathToConvert == "" )
+				$message .= "The helper tool 'convert' (from the ImageMagick package) could not be found.<br/>";
+			else
+				$message .= "The helper tool 'convert' (from the ImageMagick package) was found in $pathToConvert<br/><br/>";
+            
+			if( !$errors ) {
+            	$message .= "** New configuration settings added successfully **<br/>";
+            }
+			
+			// finally, we have to create a row in the plog_bayesian_filter_info table
+			// for every blog, since it will be used to keep information such as 
+			// the number of spam and non-spam tokents
+			$blogs = new Blogs();
+			$siteBlogs = $blogs->getAllBlogs();
+			foreach( $siteBlogs as $siteBlog ) {
+				// we have run a very simple sql query
+				$query = "INSERT INTO ".$this->_dbPrefix."bayesian_filter_info (blog_id, total_spam, total_nonspam) VALUES (".$siteBlog->getId().", 0, 0 )";
+						  
+				if( !$this->_db->Execute( $query )) {
+					$errors = true;
+					$message .= "There was an error adding the bayesian filter info for blog \"".$siteBlog->getBlog()."\"<br/>";
+				}
+				else {
+					$message .= "Bayesian filter info for blog \"".$siteBlog->getBlog()."\" added successfully.<br/>";
+				}
+			}
+			
+			// finally, since the 'default' and 'grey-sf' template sets are not included anymore, we should remove
+			// them from the list of available templates
+			$config =& Config::getConfig();
+			$availableTemplates = $config->getValue( "templates" );
+            $newTemplateList = TemplateService::_removeTemplateFromArray( $availableTemplates, "default" );
+			$newTemplateList = TemplateService::_removeTemplateFromArray( $newTemplateList, "grey-sf" );
+			array_push( $newTemplateList, "blueish" );
+			//$config->saveValue( "templates", $templates );
+            $config->saveValue( "templates", $newTemplateList );
+
+            //
+            // there's nothing left to do so we can quit now!!
+            //
+            if( !$errors ) {
+            	$this->_view = new WizardView( "update2" );
+                $this->_view->setValue( "message", $message );
+            }
+            else {
+            	$this->_view = new WizardView( "error" );
+                $this->_view->setValue( "message", $message );
+            }
+        }
+    }
+
+    class UpdateStepThree extends Action {
+
+    	var $_userId;
+
+        function validate()
+        {
+        	$this->_userId = $this->_request->getValue( "adminUserId" );
+
+            return true;
+        }
+
+        function perform()
+        {
+        	$userPermissions = new UserPermissions();
+            $userPermissions->setSiteAdmin( $this->_userId );
+
+			//
+			// detect wether we have GD available and set the blog to use it
+			//
+			$config =& Config::getConfig();
+			if( GdDetector::detectGd()) {
+				$config->saveValue( "thumbnail_method", "gd" );
+				$message = "GD has been detected and set as the backend for dealing with images.";
+			}
+			else {
+				$pathToConvert = $config->getValue( "path_to_convert" );
+				if( $pathToConvert ) {
+					$config->saveValue( "thumbnail_method", "imagemagick" );
+					$message = "ImageMagick has been detected and set as the backend for dealing with images.";
+				}
+				else {	
+					// nothing was found, so we'll have to do away with the 'null' resizer...
+					$config->saveValue( "thumbnail_method", "null" );
+					$message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images.";
+				}
+			}
+
+            $this->_view = new WizardView( "update3" );
+			$this->_view->setValue( "message", $message );
+        }
+
+    }
+
+    // check if the "./tmp" folder is writable by us, otherwise
+    // throw an error before the user gets countless errors
+    // from Smarty
+    if( !File::isWritable( TEMP_FOLDER ) || !File::isDir( TEMP_FOLDER )) {
+    	print("<span style=\"color:red; font-size: 14px;\">Error</span><br/><br/>This wizard needs the ".TEMP_FOLDER." folder to be writable by the web server user.<br/><br/>Please correct that and try again.");
+        die();
+    }
+
+    //// main part ////
+    $controller = new Controller( $_actionMap, "nextStep", false );
+    $controller->process( HttpVars::getRequest());
+?>




More information about the pLog-svn mailing list