Index: branches/wb_devel/wb/CHANGELOG
===================================================================
--- branches/wb_devel/wb/CHANGELOG	(nonexistent)
+++ branches/wb_devel/wb/CHANGELOG	(revision 1149)
@@ -0,0 +1,20 @@
+Change Log
+===============================================================================
+Please note: This change log may not be accurate
+
+$Id: CHANGELOG 1146 2009-09-21 11:15:13Z aldus $
+
+Legend:
++ = Added
+- = Removed
+# = Bugfix
+! = Update/Change
+
+------------------------------------- 2.8.1 -------------------------------------
+22-Sep-2009	Dietrich Roland Pehlke
++	Add new Changelog to the project (maybe the place is inaccurate)
+!	Changes inside the class.database.php; e.g. Logfile-support, Error-Message-Template.
+	for future testings.
+-	Remove the empty config.php from the project.
+!	Installer files (index.php and save.php) to handle the //new// situation.
+!	Modify the PHP-Version Test up to PHP 5.1 (instead of php 4.1).
\ No newline at end of file

Property changes on: branches/wb_devel/wb/CHANGELOG
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/wb_devel/wb/framework/class.database.php
===================================================================
--- branches/wb_devel/wb/framework/class.database.php	(revision 1148)
+++ branches/wb_devel/wb/framework/class.database.php	(revision 1149)
@@ -5,7 +5,7 @@
 /*
 
  Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, Ryan Djurovich
+ Copyright (C) 2004-2008, Ryan Djurovich
 
  Website Baker is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -32,22 +32,58 @@
 
 */
 
-// Stop this file from being accessed directly
-if(!defined('WB_URL')) {
-	header('Location: ../index.php');
-	exit(0);
-}
+/**
+ *	Stop this file from being accessed directly
+ */
+if ( !defined('WB_URL') ) die (header('location: ../index.php') );
 
-if(!defined('DB_URL')) {
-	//define('DB_URL', DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME);
-}
 
+/**
+ *	Modifications on this file made by
+ *	- Dietrich Roland Pehlke (aldus)
+ *		
+ *	@version	2.2.2
+ *	@date		2009-01-09
+ *	@state		beta
+ *	@require	php 5.2.x
+ *	@package	Website Baker - framework: class.database
+ *
+ *	0.2.2	add "type" to mysql-fetchRow method
+ *
+ *	0.2.1	add new class functions "copy_content" and "fetch_query".
+ */
 define('DATABASE_CLASS_LOADED', true);
 
 class database {
 	
-	// Set DB_URL
-	function database($url = '') {
+	public $mySQL_handle	= 0;
+	public $db_handle		= 0;
+	public $connected		= 0;
+	public $status			= 0;
+	public $log_querys		= false;
+	public $log_filename	= "wb_querys.log";
+	public $log_path		= "";
+	public $last_query		= "";
+	public $last_jobnumber	= 0;
+	
+	public $error_tmpl  = "
+	<span style='font-family:Verdana, sans-serif;font-size:11px;display:block; width:400px;'>
+	An error has occured:<br />
+	Job: <b><font color='#990000'>{job}</font></b><br />
+	Message: <i><font color='#990000'>{message}</font></i><br />
+	</span>";
+	
+	public $error = 0;
+	
+	public function __construct ($url="") {
+		$this->database($url);
+		$this->mySQL_handle = new c_mysql();
+	}
+	
+	/**
+	 *	Set DB_URL
+	 */
+	public function database($url = '') {
 		// Connect to database
 		$this->connect();
 		// Check for database connection error
@@ -56,9 +92,11 @@
 		}
 	}
 	
-	// Connect to the database
-	function connect() {
-		$status = $this->db_handle = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);
+	/**
+	 *	Connect to the database
+	 */
+	public function connect() {
+		$this->status = $this->db_handle = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);
 		if(mysql_error()) {
 			$this->connected = false;
 			$this->error = mysql_error();
@@ -73,10 +111,12 @@
 		return $this->connected;
 	}
 	
-	// Disconnect from the database
-	function disconnect() {
+	/**
+	 *	Disconnect from the database
+	 */
+	public function disconnect() {
 		if($this->connected==true) {
-			mysql_close();
+			mysql_close( $this->db_handle );
 			return true;
 		} else {
 			return false;
@@ -83,20 +123,46 @@
 		}
 	}
 	
-	// Run a query
-	function query($statement) {
-		$mysql = new mysql();
-		$mysql->query($statement);
-		$this->set_error($mysql->error());
-		if($mysql->error()) {
+	/**
+	 *	Run a query
+	 */
+	public function query( $statement="", $aJobNumber = 0 ) {
+		$this->last_query = $statement;
+		$this->last_jobnumber = $aJobNumber;
+		if (true == $this->log_querys) $this->__write_log();
+		$this->mySQL_handle->query($statement);
+		$this->set_error($this->mySQL_handle->error());
+		if($this->mySQL_handle->error()) {
+			if (true == $this->log_querys) {
+				$this->last_query = "Error: ".$this->mySQL_handle->error();
+				$this->__write_log();
+			}
+			$this->__display_error();
 			return null;
 		} else {
-			return $mysql;
+			return clone $this->mySQL_handle;
 		}
 	}
 	
-	// Gets the first column of the first row
-	function get_one($statement) {
+	/**
+	 *
+	 *
+	 */
+	public function fetch_query ($aQuery="", $aNumber=0) {
+		$result = $this->query($aQuery, $aNumber);
+		if (!$result) return false;
+		
+		if ($result->numRows() > 0) {
+			return $result->fetchRow();
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 *	Gets the first column of the first row
+	 */
+	public function get_one($statement) {
 		$fetch_row = mysql_fetch_row(mysql_query($statement));
 		$result = $fetch_row[0];
 		$this->set_error(mysql_error());
@@ -107,8 +173,10 @@
 		}
 	}
 	
-	// Set the DB error
-	function set_error($message = null) {
+	/**
+	 *	Set the DB error
+	 */
+	public function set_error($message = null) {
 		global $TABLE_DOES_NOT_EXIST, $TABLE_UNKNOWN;
 		$this->error = $message;
 		if(strpos($message, 'no such table')) {
@@ -118,46 +186,128 @@
 		}
 	}
 	
-	// Return true if there was an error
-	function is_error() {
-		return (!empty($this->error)) ? true : false;
+	/**
+	 *	Return true if there was an error
+	 */
+	public function is_error() {
+		return ( 0 <> $this->error ) ? true : false;
 	}
 	
-	// Return the error
-	function get_error() {
+	/**
+	 *	Return the error
+	 */
+	public function get_error() {
 		return $this->error;
 	}
 	
+	/**
+	 *	Copy a content of a given table to another entry of the table
+	 *
+	 *	@param	string	The tablename
+	 *	@param	string	The source condition, e.g. "page_id=23"
+	 *	@param	string	The target condition, e.g. "page_id=33"
+	 *	@param	mixed	The exeptions, the field, that should not copied; e.g. "page_id". Could be also an array.
+	 *	@param	integer	An optional Jobnumber for debugging.
+	 *	@param	bool	Debugmode to display the final querys on screen instead of execute them
+	 *
+	 *	@return	bool	true if all's ok.
+	 *
+	 */
+	public function copy_content ($aTableName="", $aSourceCondition="", $aTargetCondition="", $aException="", $aJobNum=3100, $debug=false) {
+		if (!is_array($aException)) $aException = array ($aException);
+		$all_fields = mysql_list_fields( DB_NAME, $aTableName);
+		$n = mysql_num_fields($all_fields);
+		if ($n == 0) die ("Error: no fields found in ".$aTableName);
+		$i=0;
+		$all_names = array();
+		while($i < $n) {
+			$field_name = mysql_field_name($all_fields, $i++);
+			if (!in_array ($field_name, $aException) ) $all_names[] = $field_name; 
+		}
+		
+		$result = $this->query ("SELECT ".implode(", ",$all_names)." from ". $aTableName ." where ".$aSourceCondition, 3000 );
+		$data = $result->fetchRow();
+		if (false === $debug) {
+			foreach ($all_names as $c => $item) $this->query ("UPDATE ". $aTableName ." set ". $item ."='" .$data[ $item ]."' where ".$aTargetCondition, ($aJobNum + (integer)$c));
+		} else {
+			foreach ($all_names as $c => $item) echo "UPDATE ". $aTableName ." set ". $item ."='" .$data[ $item ]."' where ".$aTargetCondition."<br />";
+			die();
+		}
+		return true;
+	}
+	
+	/**
+	 *	Simple way to log the querys for debugging
+	 */
+	public function __write_log () {
+	
+		$path = ($this->log_path == "") ? WB_PATH."/framework/" : $this->log_path;
+		$fp = fopen($path.$this->log_filename, 'a');
+			
+		if ($fp) {
+			$str = "\n## ".DATE("Y-m-d H:i:s", TIME())." --------------\n".str_replace( array("\n", "\t", "\r"), array("", "", ""), $this->last_query);
+			$str .= "\n";
+			
+			fwrite($fp, $str, strlen($str) );
+			fclose($fp);
+		}
+	}
+	
+	public function __display_error() {
+		ob_end_flush();
+		if ($this->last_jobnumber == 0) $this->last_jobnumber = "0 (no job-number specified)";
+		$msg = str_replace (
+			array ('{job}', '{message}'), 
+			array ($this->last_jobnumber, $this->error), 
+			$this->error_tmpl 
+		);
+		
+		die ($msg);
+	}
+	
 }
 
-class mysql {
+class c_mysql {
 
-	// Run a query
-	function query($statement) {
+	public $result 	= 0;
+	public $error	= 0;
+	
+	/**
+	 *	Run a query
+	 */
+	public function query($statement) {
 		$this->result = mysql_query($statement);
 		$this->error = mysql_error();
 		return $this->result;
 	}
 	
-	// Fetch num rows
-	function numRows() {
+	/**
+	 *	Fetch num rows
+	 */
+	public function numRows() {
 		return mysql_num_rows($this->result);
 	}
-
-	// Fetch row  $typ = MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH
-	function fetchRow($typ = MYSQL_BOTH) {
-		return mysql_fetch_array($this->result, $typ);
+	
+	/**
+	 *	Fetch row
+	 *	
+	 *	@param string	typ	One of the following
+	 *						MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH
+	 */
+	public function fetchRow($typ = MYSQL_BOTH) {
+		return mysql_fetch_array($this->result);
 	}
-
-	// Get error
-	function error() {
-		if(isset($this->error)) {
+	
+	/**
+	 *	Get error
+	 */
+	public function error() {
+		if ( ( 0 <> $this->error ) AND (is_string($this->error) ) ) {
 			return $this->error;
 		} else {
 			return null;
 		}
 	}
-
 }
 
 ?>
\ No newline at end of file
Index: branches/wb_devel/wb/index.php
===================================================================
--- branches/wb_devel/wb/index.php	(revision 1148)
+++ branches/wb_devel/wb/index.php	(revision 1149)
@@ -25,13 +25,29 @@
 
 $starttime = array_sum(explode(" ",microtime()));
 
-// Include config file
-require_once(dirname(__FILE__).'/config.php');
-
-// Check if the config file has been set-up
-if(!defined('WB_PATH')) {
+/** 
+ *	looking for the config file
+ */
+if (!file_exists(dirname(__FILE__).'/config.php')) {
+	/**
+	 *	Config doesn't exists
+	 *	So we've try to run the installation
+	 */
 	header("Location: install/index.php");
 	exit(0);
+} else {
+	/**
+	 *	Config file exists
+	 */
+	require_once(dirname(__FILE__).'/config.php');
+
+	if (!defined(WB_PATH)) {
+		/**
+		 *	Ups ... config seems to be corrupt
+		 */
+		header("Location: install/index.php");
+		exit(0);
+	}
 }
 
 require_once(WB_PATH.'/framework/class.frontend.php');
Index: branches/wb_devel/wb/install/save.php
===================================================================
--- branches/wb_devel/wb/install/save.php	(revision 1148)
+++ branches/wb_devel/wb/install/save.php	(revision 1149)
@@ -91,8 +91,9 @@
 // Dummy class to allow modules' install scripts to call $admin->print_error
 class admin_dummy
 {
-	var $error='';
-	function print_error($message)
+	public  $error='';
+	
+	public function print_error($message)
 	{
 		$this->error=$message;
 	}
@@ -317,19 +318,32 @@
 
 $config_filename = '../config.php';
 
-// Check if the file exists and is writable first.
-if(file_exists($config_filename) AND is_writable($config_filename)) {
-	if(!$handle = fopen($config_filename, 'w')) {
-		set_error("Cannot open the configuration file ($config_filename)");
+/**
+ *	Looks a littel bit confuse, but in some circumstances
+ *	the config.php file could be corrupted - so the installer
+ *	is called even if the config.php file exists!
+ */
+if (file_exists($config_filename)) unlink($config_filename);
+
+/**
+ * Try to write the config file
+ */
+$fp = fopen($config_filename, 'w');
+if (!$fp ) {
+	set_error ("Can't create the config file.");
+} else {
+	if (fwrite($fp, $config_content, strlen($config_content) ) === FALSE) {
+		/**
+		 *	We have to close the file-pointer first, as
+		 *	the following function "die's" and keep the 
+		 *	file-handle //open//
+		 */
+		fclose( $fp );
+		set_error("Can't write to the configuration file [b]".$config_filename."[/b]!<br />Please check the permissions.");
+	
 	} else {
-		if (fwrite($handle, $config_content) === FALSE) {
-			set_error("Cannot write to the configuration file ($config_filename)");
-		}
-		// Close file
-		fclose($handle);
+		fclose($fp);
 	}
-} else {
-	set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
 }
 
 // Define configuration vars
Index: branches/wb_devel/wb/install/index.php
===================================================================
--- branches/wb_devel/wb/install/index.php	(revision 1148)
+++ branches/wb_devel/wb/install/index.php	(revision 1149)
@@ -137,16 +137,13 @@
 		</tr>
 		<?php } ?>
 		<tr>
-			<td width="160" style="color: #666666;">PHP Version > 4.1.0</td>
+			<td width="160" style="color: #666666;">PHP Version > 5.1.0</td>
 			<td width="60">
 				<?php
-				$phpversion = substr(PHP_VERSION, 0, 6);
-				if($phpversion > 4.1) {
-					?><font class="good">Yes</font><?php
-				} else {
-					?><font class="bad">No</font><?php
-				}
-				?>
+			echo ( true === version_compare( PHP_VERSION, "5.1", ">") )
+				? "<font class=\"good\">Yes</font>"
+				: "<font class=\"bad\">No</font>" ;
+			?>
 			</td>
 			<td width="140" style="color: #666666;">PHP Session Support</td>
 			<td width="105"><?php echo $session_support; ?></td>
@@ -186,7 +183,7 @@
 		</tr>
 		<tr>
 			<td style="color: #666666;">wb/config.php</td>
-			<td><?php if(is_writable('../config.php')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../config.php')) { echo '<font class="bad">File Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
+			<td><!--<?php if(is_writable('../config.php')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../config.php')) { echo '<font class="bad">File Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?>--></td>
 			<td style="color: #666666;">wb/pages/</td>
 			<td><?php if(is_writable('../pages/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../pages/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
 			<td style="color: #666666;">wb/media/</td>
