Index: wp-includes/comment-functions.php
===================================================================
--- wp-includes/comment-functions.php	(revision 3465)
+++ wp-includes/comment-functions.php	(working copy)
@@ -277,10 +277,10 @@
 function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
 	global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
 	global $comment_count_cache;
-	
+
 	if (! is_single() && ! is_page()) {
 	if ( !isset($comment_count_cache[$id]) )
-		$comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
+		$comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = '$id' AND comment_approved = '1';");
 	
 	$number = $comment_count_cache[$id];
 	
Index: wp-includes/wp-sqlite.php
===================================================================
--- wp-includes/wp-sqlite.php	(revision 0)
+++ wp-includes/wp-sqlite.php	(revision 0)
@@ -0,0 +1,675 @@
+<?php
+
+//  ORIGINAL CODE FROM:
+//  Justin Vincent (justin@visunet.ie)
+//	http://php.justinvincent.com
+
+
+define("EZSQL_VERSION","1.26");
+define("OBJECT","OBJECT",true);
+define("ARRAY_A","ARRAY_A",true);
+define("ARRAY_N","ARRAY_N",true);
+
+if (!defined('SAVEQUERIES'))
+	define('SAVEQUERIES', false);
+
+	// ==================================================================
+	//	The Main Class
+
+class wpdb {
+
+	var $show_errors = true;
+	var $num_queries = 0;	
+	var $last_query;
+	var $col_info;
+	var $queries;
+
+	// Our tables
+	var $posts;
+	var $users;
+	var $categories;
+	var $post2cat;
+	var $comments;
+	var $links;
+	var $linkcategories;
+	var $options;
+	var $optiontypes;
+	var $optionvalues;
+	var $optiongroups;
+	var $optiongroup_options;
+	var $postmeta;
+		
+	// ==================================================================
+	//	DB Constructor - connects to the server and selects a database
+
+	function wpdb($dbpath, $dbname)	{
+		$this->dbh = sqlite_open($dbpath.$dbname);
+		if ( ! $this->dbh ) {
+			$this->print_error("Error","<ol><b>Error establishing a database!</b><li>Are you sure you have the correct path?<li>Are you sure that you have typed the correct database instance name?<li>Are you sure that the database is installed?</ol>");
+		}
+		
+		sqlite_query($this->dbh, 'PRAGMA short_column_names = 1');
+		
+		// User defined functions to use in SQLite
+		sqlite_create_function($this->dbh, 'trim', 'trim', 1);		
+
+	}
+
+	// ==================================================================
+	//	Select a DB instance (if another one needs to be selected)
+
+	function select($dbpath, $dbname) {
+		$this->wpdb($dbpath, $dbname);
+	}
+
+	// ====================================================================
+	//	Format a string correctly for safe insert under all PHP conditions
+
+	function escape($str) {
+		return str_replace("'","''",str_replace("''","'",stripslashes($str)));
+	}
+
+	// ==================================================================
+	//	Print SQL/DB error.
+
+	function print_error($title = "SQL/DB Error", $str = "") {
+
+		// All erros go to the global error array $EZSQL_ERROR..
+		global $EZSQL_ERROR;
+
+		// If no error string then you're SOL
+		if ( !$str ) {
+			$str = "An error occured, quick go tell someone!";
+		}
+
+		// Log this error to the global array..
+		$EZSQL_ERROR[] = array
+						(
+							"query" => $this->last_query,
+							"error_str"  => $str
+						);
+
+		// Is error output turned on or not..
+		if ( $this->show_errors ) {
+			// If there is an error then take note of it
+			print "<div id='error'>
+			<p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
+			<code>$this->last_query</code></p>
+			</div>";
+		}
+		else {
+			return false;
+		}
+	}
+
+	// ==================================================================
+	//	Turn error handling on or off..
+
+	function show_errors() {
+		$this->show_errors = true;
+	}
+
+	function hide_errors() {
+		$this->show_errors = false;
+	}
+
+	// ==================================================================
+	//	Kill cached query results
+
+	function flush() {
+
+		// Get rid of these
+		$this->last_result = null;
+		$this->col_info = null;
+		$this->last_query = null;
+
+	}
+
+	// ==================================================================
+	//	Basic Query	- see docs for more detail
+
+	function query($query) {
+
+		// For reg expressions
+		$query = trim($query); 
+
+		// Flush cached values..
+		$this->flush();
+		
+		// Parse query to be used in SQLite
+		$query = $this->parse($query);
+
+		// Log how the function was called
+		$this->func_call = "\$wpdb->query(\"$query\")";
+		
+		// Keep track of the last query for debug..
+		$this->last_query = $query;
+
+		if (SAVEQUERIES)
+			$this->timer_start();
+
+		$handle = @sqlite_query($this->dbh,$query);
+		
+			
+		if (SAVEQUERIES)
+			$this->queries[] = array( $query, $this->timer_stop() );
+			
+		// If there was an insert, delete or update see how many rows were affected
+		// (Also, If there there was an insert take note of the insert_id
+		$query_type = array("insert","delete","update","replace");
+
+		// loop through the above array
+		foreach ( $query_type as $word ) {
+			// This is true if the query starts with insert, delete or update
+			if ( preg_match("/^$word\s+/i",$query) ) {
+				$this->rows_affected = sqlite_changes($this->dbh);
+
+				// This gets the insert ID
+				if ( $word == "insert" || $word == "replace" ) {
+					$this->insert_id = sqlite_last_insert_rowid($this->dbh);
+						
+					// If insert id then return it - true evaluation
+					return $this->insert_id;
+				}
+
+				// Set to false if there was no insert id
+				$this->result = false;
+
+			}
+
+		}
+
+		if ( ! $handle ) {
+
+			// If there is an error then take note of it..
+			if ( $php_errormsg ) {
+				$this->print_error($php_errormsg,$query);
+			} else {
+				$this->print_error("Invalid Query",$query);
+			}
+
+		} else {
+
+
+				$i=0;
+				while ( $row = sqlite_fetch_object($handle) ) {
+					$this->last_result[$i++] = $row;
+				}
+
+				// Log number of rows the query returned
+				$this->num_rows = $i;
+
+				// If debug ALL queries
+				$this->debug_all ? $this->debug() : null ;
+
+				// If there were results then return true for $db->query
+				if ( $i ) {
+					return true;
+				} else {
+					return false;
+				}
+
+		}
+	}
+	
+	// ==================================================================
+	//	Parse statement and make it SQLite friendly
+	//	original code from tikiwiki project
+
+	function parse($stmt) {
+
+		// variable for statements that have to be appended
+		global $poststmt;
+		$poststmt = "\n\n";
+		
+		// SQLite don't support 'SHOW TABLES'
+		$stmt = preg_replace("/SHOW TABLES/", "SELECT name FROM sqlite_master WHERE type='table'", $stmt);
+		
+
+		$stmt = preg_replace("/COUNT[(]DISTINCT([^)]*)[)] FROM ([^'']*) (.*)/","COUNT(*) FROM (SELECT DISTINCT $1 FROM $2 $3)",$stmt);
+		
+		// Date and time functions
+		$stmt = preg_replace("/YEAR[(]([^)]*)[)]/","strftime(\"%Y\", $1)",$stmt);
+		$stmt = preg_replace("/MONTH[(]([^)]*)[)]/","strftime(\"%m\", $1)",$stmt);
+		$stmt = preg_replace("/DAY[(]([^)]*)[)]/","strftime(\"%d\", $1)",$stmt);
+		$stmt = preg_replace("/NOW[(][)]/","date('now')",$stmt);
+		$stmt = preg_replace("/INTERVAL ([0-9]*)([^)]*)/","\"+$1 $2\"",$stmt);
+		$stmt = preg_replace("/DATE_ADD[(]([^,]*),([^)]*)[)]/","datetime($1, $2)",$stmt);
+		$stmt = preg_replace("/UNIX_TIMESTAMP[(]([^)]*)[)]/","strftime('%s',$1)",$stmt);
+		
+		$stmt = preg_replace("/[`]/","'",$stmt);
+		
+		// MD5
+		$stmt = preg_replace("/MD5[(][']([^']*)['][)]/e", "'\''.md5('$1').'\''" ,$stmt);
+		
+		// Enum
+		$stmt = preg_replace("/enum[(][^)]*[)]/","varchar(255)",$stmt);
+	
+		// Random function
+		$stmt = preg_replace("/rand[(][)]/","random()",$stmt);
+
+		// IF statement ##FIXME not a good way to do this		
+		$stmt = preg_replace("/IF [(](.*)[,] [0-1][,][0-1][)]/","$1",$stmt);
+
+		//replace comments
+		$stmt = preg_replace("/#/","--",$stmt);
+		
+		$stmt = preg_replace("/TYPE=MyISAM/","",$stmt);
+		//$stmt = preg_replace("/AUTO_INCREMENT=1/","",$stmt);
+		
+		//postgres cannot DROP TABLE IF EXISTS ( sqlite?? )
+		$stmt = preg_replace("/DROP TABLE IF EXISTS/","DROP TABLE",$stmt);
+		
+		//auto_increment things
+		$stmt = preg_replace("/(big)int\(.\) (unsigned )*NOT NULL auto_increment/","INTEGER",$stmt);
+		$stmt = preg_replace("/(big)int\(..\) (unsigned )*NOT NULL auto_increment/","INTEGER",$stmt);
+		
+		// integer types
+		$stmt = preg_replace("/tinyint\([1-4]\)/","smallint",$stmt);
+		$stmt = preg_replace("/int\([1-4]\)/","smallint",$stmt);
+		$stmt = preg_replace("/int\([5-9]\)/","integer",$stmt);
+		$stmt = preg_replace("/int\(..\)/","bigint",$stmt);
+	
+		// timestamps
+		$stmt = preg_replace("/timestamp\([^\)]+\)/","timestamp(3)",$stmt);
+		
+		// blobs
+		$stmt = preg_replace("/longblob|tinyblob|blob/","bytea",$stmt);
+		
+		// ##FIXME quote column names, not sure if needed...
+		//$stmt = preg_replace("/\n[ \t]+([a-zA-Z0-9_]+)/","\n  \"$1\"",$stmt);
+
+		// quote and record table names
+		$stmt = preg_replace("/(DROP TABLE |CREATE TABLE )([a-zA-Z0-9_]+)( \()*/e","record_tablename('$1','$2','$3')",$stmt);
+		
+		// unquote the PRIMARY and other Keys
+		$stmt = preg_replace("/\n[ \t]+\"(PRIMARY|KEY|FULLTEXT|UNIQUE)\"/","\n  $1",$stmt);
+		
+		// convert enums
+		$stmt = preg_replace("/\n[ \t]+(\"[a-zA-Z0-9_]+\") enum\(([^\)]+)\)/e","convert_enums('$1','$2')",$stmt);
+		// quote column names in primary keys
+		$stmt = preg_replace("/\n[ \t]+(PRIMARY KEY)  \((.+)\),*/e","quote_prim_cols('$1','$2')",$stmt);
+		
+		// create indexes from KEY ...
+		$stmt = preg_replace("/\n[ \t]+KEY ([a-zA-Z0-9_]+) \((.+)\),*/e","create_index('$1','$2')",$stmt);
+		$stmt = preg_replace("/\n[ \t]+FULLTEXT KEY ([a-zA-Z0-9_]+) \((.+)\),*/e","create_index('$1','$2')",$stmt);
+		$stmt = preg_replace("/\n[ \t]+(UNIQUE) KEY ([a-zA-Z0-9_]+) \((.+)\),*/e","create_index('$2','$3','$1')",$stmt);
+		
+		// handle inserts
+		$stmt = preg_replace("/INSERT INTO ([a-zA-Z0-9_]*).*\(([^\)]+)\) VALUES (.*)/e","do_inserts('$1','$2','$3')",$stmt);
+		$stmt = preg_replace("/INSERT IGNORE INTO ([a-zA-Z0-9_]*).*\(([^\)]+)\) VALUES (.*)/e","do_inserts('$1','$2','$3')",	$stmt);
+		
+		// why does i modifier not work???
+		$stmt = preg_replace("/insert into ([a-zA-Z0-9_]*).*\(([^\)]+)\) values(.*)/e","do_inserts('$1','$2','$3')",$stmt);
+		
+		// the update
+		$stmt = preg_replace("/update ([a-zA-Z0-9_]+) set (.*)/e","do_updates('$1','$2')",$stmt);
+		$stmt = preg_replace("/UPDATE ([a-zA-Z0-9_]+) set (.*)/e","do_updates('$1','$2')",$stmt);
+		
+		// Ignore 'IGNORE' 
+		$stmt = preg_replace("/IGNORE/","",$stmt);
+
+		// clean cases where UNIQUE was alone at the end
+		$stmt = preg_replace("/,(\s*)\)/","$1)",$stmt);
+		return $stmt.";".$poststmt;
+	}
+
+
+
+	// ==================================================================
+	//	Get one variable from the DB - see docs for more detail
+
+	function get_var($query=null,$x=0,$y=0) {
+		
+		// Log how the function was called
+		$this->func_call = "\$wpdb->get_var(\"$query\",$x,$y)";
+
+		// If there is a query then perform it if not then use cached results..
+		if ( $query ) {
+			$this->query($query);
+		}
+
+		// Extract var out of cached results based x,y vals
+		if ( $this->last_result[$y] ) {
+			$values = array_values(get_object_vars($this->last_result[$y]));
+		}
+
+		// If there is a value return it else return null
+		return (isset($values[$x]) && $values[$x]!=='')?$values[$x]:null;
+	}
+
+	// ==================================================================
+	//	Get one row from the DB - see docs for more detail
+
+	function get_row($query=null,$output=OBJECT,$y=0) {
+
+		// Log how the function was called
+		$this->func_call = "\$wpdb->get_row(\"$query\",$output,$y)";
+
+		// If there is a query then perform it if not then use cached results..
+		if ( $query ) {
+			$this->query($query);
+		}
+
+		// If the output is an object then return object using the row offset..
+		if ( $output == OBJECT ) {
+			return $this->last_result[$y]?$this->last_result[$y]:null;
+		}
+		// If the output is an associative array then return row as such..
+		elseif ( $output == ARRAY_A ) {
+			return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null;
+		}
+		// If the output is an numerical array then return row as such..
+		elseif ( $output == ARRAY_N ) {
+			return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null;
+		}
+		// If invalid output type was specified..
+		else {
+			$this->print_error(" \$wpdb->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
+		}
+
+	}
+
+	// ==================================================================
+	//	Function to get 1 column from the cached result set based in X index
+	// se docs for usage and info
+
+	function get_col($query=null,$x=0) {
+
+		// If there is a query then perform it if not then use cached results..
+		if ( $query ) {
+			$this->query($query);
+		}
+
+		// Extract the column values
+		for ( $i=0; $i < count($this->last_result); $i++ ) {
+			$new_array[$i] = $this->get_var(null,$x,$i);
+		}
+
+		return $new_array;
+	}
+
+	// ==================================================================
+	// Return the the query as a result set - see docs for more details
+
+	function get_results($query=null, $output = OBJECT) {
+
+		// Log how the function was called
+		$this->func_call = "\$dwpb->get_results(\"$query\", $output)";
+
+		// If there is a query then perform it if not then use cached results..
+		if ( $query ) {
+			$this->query($query);
+		}
+
+		// Send back array of objects. Each row is an object
+		if ( $output == OBJECT ) {
+			return $this->last_result;
+		}
+		elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
+			if ( $this->last_result ) {
+				$i=0;
+				foreach( $this->last_result as $row ) {
+
+					$new_array[$i] = get_object_vars($row);
+
+					if ( $output == ARRAY_N ) {
+						$new_array[$i] = array_values($new_array[$i]);
+					}
+
+					$i++;
+				}
+
+				return $new_array;
+			} else {
+				return null;
+			}
+		}
+	}
+
+	// ==================================================================
+	// Function to get column meta data info pertaining to the last query
+	// see docs for more info and usage
+
+	function get_col_info($info_type="name",$col_offset=-1) {
+
+		if ( $this->col_info ) {
+			if ( $col_offset == -1 ) {
+				$i=0;
+				foreach($this->col_info as $col ) {
+					$new_array[$i] = $col->{$info_type};
+					$i++;
+				}
+				return $new_array;
+			} else {
+				return $this->col_info[$col_offset]->{$info_type};
+			}
+
+		}
+
+	}
+
+	function timer_start() {
+		$mtime = microtime();
+		$mtime = explode(' ', $mtime);
+		$this->time_start = $mtime[1] + $mtime[0];
+		return true;
+	}
+	
+	function timer_stop($precision = 3) {
+		$mtime = microtime();
+		$mtime = explode(' ', $mtime);
+		$time_end = $mtime[1] + $mtime[0];
+		$time_total = $time_end - $this->time_start;
+		return $time_total;
+	}
+
+	// ==================================================================
+	// Dumps the contents of any input variable to screen in a nicely
+	// formatted and easy to understand way - any type: Object, Var or Array
+
+	function vardump($mixed='') {
+
+		echo "<p><table><tr><td bgcolor=ffffff><blockquote><font color=000090>";
+		echo "<pre><font face=arial>";
+
+		if ( ! $this->vardump_called ) {
+			echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n";
+		}
+
+		$var_type = gettype ($mixed);
+		print_r(($mixed?$mixed:"<font color=red>No Value / False</font>"));
+		echo "\n\n<b>Type:</b> " . ucfirst($var_type) . "\n";
+		echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query?$this->last_query:"NULL")."\n";
+		echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n";
+		echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n";
+		echo "</font></pre></font></blockquote></td></tr></table>".$this->donation();
+		echo "\n<hr size=1 noshade color=dddddd>";
+
+		$this->vardump_called = true;
+
+	}
+
+	// Alias for the above function
+	function dumpvar($mixed) {
+		$this->vardump($mixed);
+	}
+
+	// ==================================================================
+	// Displays the last query string that was sent to the database & a
+	// table listing results (if there were any).
+	// (abstracted into a seperate file to save server overhead).
+
+	function debug() {
+
+		echo "<blockquote>";
+
+		// Only show ezSQL credits once..
+		if ( ! $this->debug_called ) {
+			echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n";
+		}
+		echo "<font face=arial size=2 color=000099><b>Query</b> [$this->num_queries] <b>--</b> ";
+		echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>";
+
+			echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>";
+			echo "<blockquote>";
+
+		if ( $this->col_info ) {
+
+			// =====================================================
+			// Results top rows
+
+			echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>";
+			echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>";
+
+
+			for ( $i=0; $i < count($this->col_info); $i++ ) {
+				echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}</font><br><span style='font-family: arial; font-size: 10pt; font-weight: bold;'>{$this->col_info[$i]->name}</span></td>";
+			}
+
+			echo "</tr>";
+
+			// ======================================================
+			// print main results
+
+		if ( $this->last_result ) {
+
+			$i=0;
+			foreach ( $this->get_results(null,ARRAY_N) as $one_row ) {
+				$i++;
+				echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>";
+
+				foreach ( $one_row as $item ) {
+					echo "<td nowrap><font face=arial size=2>$item</font></td>";
+				}
+
+				echo "</tr>";
+			}
+
+		} // if last result
+		else {
+			echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>";
+		}
+
+		echo "</table>";
+
+		} // if col_info
+		else {
+			echo "<font face=arial size=2>No Results</font>";
+		}
+
+		echo "</blockquote></blockquote>".$this->donation()."<hr noshade color=dddddd size=1>";
+
+
+		$this->debug_called = true;
+	}
+
+
+}
+
+	function record_tablename($stmt,$tabnam,$tail) {
+	
+		global $table_name;
+		$table_name = $tabnam;
+		return ($stmt."\"".$tabnam."\"".$tail);
+	}
+
+	function create_index($name,$content,$type=""){
+	
+		global $table_name;
+		global $poststmt;
+		$poststmt.="CREATE $type INDEX \"".$table_name."_".$name."\" ON \"".$table_name."\"(";
+		$cols=split(",",$content);
+		$allvals="";
+
+		foreach ($cols as $vals) {
+			$vals=preg_replace("/\(.*\)/","",$vals);
+			$vals=preg_replace("/([a-zA-Z0-9_]+)/","\"$1\"",$vals);
+			$allvals.=$vals;
+		}
+
+		$allvals=preg_replace("/\"\"/","\",\"",$allvals);
+		$poststmt.=$allvals.");\n";
+	}
+
+	function do_updates($tab,$content) {
+	
+		$ret="UPDATE \"".$tab."\" SET ";
+		$cols=split(",",$content);
+
+		foreach ($cols as $vals) {
+			$vals=preg_replace("/([a-zA-Z0-9_]+)=([a-zA-Z0-9_]+)/","\"$1\"=\"$2\"",$vals);
+			$ret.=$vals;
+		}
+		
+		$ret=preg_replace("/\"\"/","\",\"",$ret);
+		$ret=preg_replace("/`/","",$ret);
+		
+		return($ret);
+	}
+
+	function do_inserts($tab,$content,$tail) {
+	
+		// for some reason are the quotes in $tail addslashed. i dont know why
+		$tail=preg_replace('/\\\"/','"',$tail);
+		$ret="INSERT INTO \"".$tab."\" (";
+		$cols=split(",",$content);
+
+		foreach ($cols as $vals) {
+			$vals=preg_replace("/ /","",$vals);
+			$ret.="\"$vals\"";
+		}
+	
+		$ret=preg_replace("/\"\"/","\",\"",$ret);
+		$ret.=")";
+  
+		$tail=preg_replace("/md5\(\'(.+)\'\)/e","quotemd5('$1')",$tail);
+		return $ret." VALUES ".$tail;
+	}
+
+	function quotemd5($a) {
+		return ("'".md5($a)."'");
+	}
+
+	function quote_prim_cols($key,$content) {
+	
+		$ret="\n  $key (";
+		$cols=split(",",$content);
+
+		foreach ($cols as $vals) {
+			$vals=preg_replace("/\(.*\)/","",$vals);
+			$ret.="\"".trim($vals)."\"";
+		}
+		
+		$ret=preg_replace("/\"\"/","\",\"",$ret);
+		$ret.=")";
+
+		return $ret;
+	}
+
+	function convert_enums($colname,$content) {
+	
+		$enumvals=split(",",$content);
+		$isnum=true;
+		$length=0;
+		$colname=stripslashes($colname);
+		$ret="\n  $colname ";
+		foreach ($enumvals as $vals) {
+			if (!is_int($vals)) $isnum=false;
+			if (strlen($vals)>$length) $length=strlen($vals);
+		}
+		if ($isnum) {
+			if ($length < 4) $ret.="smallint ";
+			elseif ($length < 9) $ret.="integer ";
+				else $ret.="bigint ";
+		} else {
+			$ret.="varchar($length) ";
+		}
+		$ret.="CHECK ($colname IN ($content))";
+		
+		return $ret;
+	}
+
+$wpdb = new wpdb( DB_PATH, DB_NAME );
+
+?>

Property changes on: wp-includes/wp-sqlite.php
___________________________________________________________________
Name: svn:executable
   + *

Index: wp-config.php.sample
===================================================================
--- wp-config.php.sample	(revision 0)
+++ wp-config.php.sample	(revision 0)
@@ -0,0 +1,26 @@
+<?php
+// ** MySQL settings ** //
+define('DB_NAME', 'moro');    // The name of the database
+define('DB_USER', 'username');     // Your MySQL username
+define('DB_PASSWORD', 'password'); // ...and password
+define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
+
+// ** SQLite settings ** //
+define('USE_SQLITE', 1);
+define('DB_PATH', '/home/tume/public_html/wordpress/trunk/');
+// DB_NAME same as above
+
+// You can have multiple installations in one database if you give each a unique prefix
+$table_prefix  = 'wp_';   // Only numbers, letters, and underscores please!
+
+// Change this to localize WordPress.  A corresponding MO file for the
+// chosen language must be installed to wp-includes/languages.
+// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
+// to enable German language support.
+define ('WPLANG', '');
+
+/* That's all, stop editing! Happy blogging. */
+
+define('ABSPATH', dirname(__FILE__).'/');
+require_once(ABSPATH.'wp-settings.php');
+?>

Property changes on: wp-config.php.sample
___________________________________________________________________
Name: svn:executable
   + *

Index: wp-settings.php
===================================================================
--- wp-settings.php	(revision 3465)
+++ wp-settings.php	(working copy)
@@ -50,7 +50,7 @@
 if ( !(phpversion() >= '4.1') )
 	die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
 
-if ( !extension_loaded('mysql') )
+if ( !extension_loaded('mysql') && !USE_SQLITE )
 	die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
 
 function timer_start() {
@@ -68,10 +68,14 @@
 // For an advanced caching plugin to use, static because you would only want one
 if ( defined('WP_CACHE') )
 	require (ABSPATH . 'wp-content/advanced-cache.php');
-
+;
 define('WPINC', 'wp-includes');
-require_once (ABSPATH . WPINC . '/wp-db.php');
+if ( extension_loaded('mysql') && !USE_SQLITE )
+	require_once (ABSPATH . WPINC . '/wp-db.php');
 
+if ( USE_SQLITE )
+	require_once (ABSPATH . WPINC . '/wp-sqlite.php');
+
 // Table names
 $wpdb->posts            = $table_prefix . 'posts';
 $wpdb->users            = $table_prefix . 'users';
@@ -120,7 +124,9 @@
 require_once (ABSPATH . WPINC . '/wp-l10n.php');
 
 $wpdb->hide_errors();
+
 $db_check = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
+
 if ( !$db_check && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
 	if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
 		$link = 'install.php';
@@ -228,4 +234,4 @@
 // Everything is loaded and initialized.
 do_action('init');
 
-?>
\ No newline at end of file
+?>
Index: wp-admin/upgrade-functions.php
===================================================================
--- wp-admin/upgrade-functions.php	(revision 3465)
+++ wp-admin/upgrade-functions.php	(working copy)
@@ -336,6 +336,7 @@
             return true;
         }
     }
+
     //didn't find it try to create it.
     $q = $wpdb->query($create_ddl);
     // we cannot directly tell that whether this succeeded!
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revision 3465)
+++ wp-admin/admin-functions.php	(working copy)
@@ -575,11 +575,15 @@
 	if (!$categories)
 		$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
 
+
 	if ($categories) {
+		
 		foreach ($categories as $category) {
+			
 			if ($category->category_parent == $parent) {
 				$category->cat_name = wp_specialchars($category->cat_name);
 				$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
+				
 				$pad = str_repeat('&#8212; ', $level);
 				if ( current_user_can('manage_categories') ) {
 					$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
@@ -1249,9 +1253,7 @@
 		return $title;
 	}
 
-	$hook = get_plugin_page_hook($plugin_page, $pagenow);
-
-	$parent = $parent1 = get_admin_page_parent();
+	$parent = get_admin_page_parent();
 	if (empty ($parent)) {
 		foreach ($menu as $menu_array) {
 			if (isset ($menu_array[3])) {
@@ -1259,7 +1261,7 @@
 					$title = $menu_array[3];
 					return $menu_array[3];
 				} else
-					if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) {
+					if (isset ($plugin_page) && ($plugin_page == $menu_array[2])) {
 						$title = $menu_array[3];
 						return $menu_array[3];
 					}
@@ -1273,7 +1275,7 @@
 						$title = $submenu_array[3];
 						return $submenu_array[3];
 					} else
-						if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) {
+						if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) {
 							$title = $submenu_array[3];
 							return $submenu_array[3];
 						}
@@ -1721,7 +1723,7 @@
 		return $upload_error_handler($file, __('File is empty. Please upload something more substantial.'));
 
 	// A properly uploaded file will pass this test. There should be no reason to override this one.
-	if (! @ is_uploaded_file($file['tmp_name']) )
+	if (! is_uploaded_file($file['tmp_name']) )
 		return $upload_error_handler($file, __('Specified file failed upload test.'));
 
 	// A correct MIME type will pass this test.
@@ -1750,6 +1752,10 @@
 	} else {
 		$number = '';
 		$filename = str_replace('#', '_', $file['name']);
+<<<<<<< .mine
+		while ( file_exists($uploads['path'] . "/$filename") )
+			$filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
+=======
 		$filename = str_replace(array('\\', "'"), '', $filename);
 		if ( empty($ext) )
 			$ext = '';
@@ -1761,11 +1767,12 @@
 			else
 				$filename = str_replace("$number$ext", ++$number . $ext, $filename);
 		}
+>>>>>>> .r3465
 	}
 
 	// Move the file to the uploads dir
 	$new_file = $uploads['path'] . "/$filename";
-	if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
+	if ( false === move_uploaded_file($file['tmp_name'], $new_file) )
 		die(printf(__('The uploaded file could not be moved to %s.'), $file['path']));
 
 	// Set correct file permissions
Index: wp-admin/install.php
===================================================================
--- wp-admin/install.php	(revision 3465)
+++ wp-admin/install.php	(working copy)
@@ -1,5 +1,6 @@
 <?php
 define('WP_INSTALLING', true);
+
 if (!file_exists('../wp-config.php')) 
     die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
 
@@ -14,6 +15,7 @@
 else
 	$step = 0;
 header( 'Content-Type: text/html; charset=utf-8' );
+
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -76,6 +78,8 @@
 <body>
 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
 <?php
+
+
 // Let's check to make sure WP isn't already installed.
 $wpdb->hide_errors();
 $installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
@@ -156,15 +160,13 @@
 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
 
 // Default category
-$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
+$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('1', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
 
 // First post
 $now = date('Y-m-d H:i:s');
 $now_gmt = gmdate('Y-m-d H:i:s');
 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
 
-$wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
-
 // Default comment
 $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
 
@@ -182,6 +184,9 @@
 $admin_caps = serialize(array('administrator' => true));
 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');");
 
+
+$wpdb->query( "INSERT INTO $wpdb->post2cat (rel_id, post_id, category_id) VALUES (1, 1, 1)" );
+
 $message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
 $message = sprintf(__("Your new WordPress blog has been successfully set up at:
 
Index: wp-admin/admin-db.php
===================================================================
--- wp-admin/admin-db.php	(revision 3465)
+++ wp-admin/admin-db.php	(working copy)
@@ -106,7 +106,7 @@
 		$category_parent = 0;
 
 	if (!$update) {
-		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
+		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('1', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
 		$cat_ID = $wpdb->insert_id;
 	} else {
 		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");

