get rid of xmlschema
This commit is contained in:
		
							parent
							
								
									64fb261b87
								
							
						
					
					
						commit
						44ac62e1ae
					
				@ -104,14 +104,14 @@ class EventLog implements Extension {
 | 
				
			|||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if($config->get_int("ext_event_log_version", 0) < 1) {
 | 
							if($config->get_int("ext_event_log_version", 0) < 1) {
 | 
				
			||||||
			$database->Execute("CREATE TABLE event_log (
 | 
								$database->create_table("event_log", "
 | 
				
			||||||
				id int(11) NOT NULL auto_increment primary key,
 | 
									id SCORE_AIPK,
 | 
				
			||||||
				owner_id int(11) NOT NULL,
 | 
									owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
				owner_ip char(15) NOT NULL,
 | 
									owner_ip SCORE_INET NOT NULL,
 | 
				
			||||||
				date datetime NOT NULL,
 | 
									date DATETIME NOT NULL,
 | 
				
			||||||
				event varchar(32) NOT NULL,
 | 
									event VARCHAR(32) NOT NULL,
 | 
				
			||||||
				entry varchar(255) NOT NULL
 | 
									entry TEXT NOT NULL
 | 
				
			||||||
			)");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_event_log_version", 1);
 | 
								$config->set_int("ext_event_log_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -116,13 +116,12 @@ class ImageBan implements Extension {
 | 
				
			|||||||
	protected function install() {
 | 
						protected function install() {
 | 
				
			||||||
		global $database;
 | 
							global $database;
 | 
				
			||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
		$database->Execute("CREATE TABLE image_bans (
 | 
							$database->create_table("image_bans", "
 | 
				
			||||||
			id int(11) NOT NULL auto_increment,
 | 
								id SCORE_AIPK,
 | 
				
			||||||
			   hash char(32) default NULL,
 | 
								hash CHAR(32) NOT NULL,
 | 
				
			||||||
			   date datetime default NULL,
 | 
								date DATETIME DEFAULT now(),
 | 
				
			||||||
			   reason varchar(255) default NULL,
 | 
								reason TEXT NOT NULL,
 | 
				
			||||||
			   PRIMARY KEY (id)
 | 
							");
 | 
				
			||||||
				   )");
 | 
					 | 
				
			||||||
		$config->set_int("ext_imageban_version", 1);
 | 
							$config->set_int("ext_imageban_version", 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -103,15 +103,13 @@ class IPBan implements Extension {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// shortcut to latest
 | 
							// shortcut to latest
 | 
				
			||||||
		if($config->get_int("ext_ipban_version") < 1) {
 | 
							if($config->get_int("ext_ipban_version") < 1) {
 | 
				
			||||||
			$database->execute("
 | 
								$database->create_table("bans", "
 | 
				
			||||||
				CREATE TABLE bans (
 | 
									id SCORE_AIPK,
 | 
				
			||||||
					id {$database->engine->auto_increment},
 | 
									banner_id INTEGER NOT NULL,
 | 
				
			||||||
					banner_id INTEGER NOT NULL,
 | 
									ip SCORE_INET NOT NULL,
 | 
				
			||||||
					ip VARCHAR(15) NOT NULL,
 | 
									end_timestamp INTEGER,
 | 
				
			||||||
					end_timestamp INTEGER,
 | 
									reason TEXT NOT NULL,
 | 
				
			||||||
					reason TEXT NOT NULL,
 | 
									INDEX (end_timestamp)
 | 
				
			||||||
					INDEX (end_timestamp)
 | 
					 | 
				
			||||||
				) {$database->engine->create_table_extras};
 | 
					 | 
				
			||||||
			");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_ipban_version", 6);
 | 
								$config->set_int("ext_ipban_version", 6);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,21 +31,21 @@ class Notes implements Extension {
 | 
				
			|||||||
	protected function install() {
 | 
						protected function install() {
 | 
				
			||||||
		global $database;
 | 
							global $database;
 | 
				
			||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
		$database->Execute("CREATE TABLE image_notes (
 | 
							$database->create_table("image_notes", "
 | 
				
			||||||
			id int(11) NOT NULL auto_increment PRIMARY KEY,
 | 
								id SCORE_AIPK,
 | 
				
			||||||
			image_id int(11) NOT NULL,
 | 
								image_id INTEGER NOT NULL,
 | 
				
			||||||
			user_id int(11) NOT NULL,
 | 
								user_id INTEGER NOT NULL,
 | 
				
			||||||
			owner_ip char(15) NOT NULL,
 | 
								owner_ip SCORE_INET NOT NULL,
 | 
				
			||||||
			created_at datetime NOT NULL,
 | 
								created_at DATETIME NOT NULL,
 | 
				
			||||||
			updated_at datetime NOT NULL,
 | 
								updated_at DATETIME NOT NULL,
 | 
				
			||||||
			version int(11) DEFAULT 1 NOT NULL,
 | 
								version INTEGER DEFAULT 1 NOT NULL,
 | 
				
			||||||
			is_active enum('Y', 'N') DEFAULT 'Y' NOT NULL,
 | 
								is_active SCORE_BOOL DEFAULT SCORE_BOOL_Y NOT NULL,
 | 
				
			||||||
			x int(11) NOT NULL,
 | 
								x INTEGER NOT NULL,
 | 
				
			||||||
			y int(11) NOT NULL,
 | 
								y INTEGER NOT NULL,
 | 
				
			||||||
			w int(11) NOT NULL,
 | 
								w INTEGER NOT NULL,
 | 
				
			||||||
			h int(11) NOT NULL,
 | 
								h INTEGER NOT NULL,
 | 
				
			||||||
			body text NOT NULL
 | 
								body TEXT NOT NULL
 | 
				
			||||||
		)");
 | 
							");
 | 
				
			||||||
		$config->set_int("ext_notes_version", 1);
 | 
							$config->set_int("ext_notes_version", 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -92,14 +92,12 @@ class NumericScore implements Extension {
 | 
				
			|||||||
		if($config->get_int("ext_numeric_score_version") < 1) {
 | 
							if($config->get_int("ext_numeric_score_version") < 1) {
 | 
				
			||||||
			$database->Execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0");
 | 
								$database->Execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0");
 | 
				
			||||||
			$database->Execute("CREATE INDEX images__numeric_score ON images(numeric_score)");
 | 
								$database->Execute("CREATE INDEX images__numeric_score ON images(numeric_score)");
 | 
				
			||||||
			$database->Execute("
 | 
								$database->create_table("numeric_score_votes", "
 | 
				
			||||||
				CREATE TABLE numeric_score_votes (
 | 
									image_id INTEGER NOT NULL REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
					image_id INTEGER NOT NULL,
 | 
									user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
					user_id INTEGER NOT NULL,
 | 
									score INTEGER NOT NULL,
 | 
				
			||||||
					score INTEGER NOT NULL,
 | 
									UNIQUE(image_id, user_id),
 | 
				
			||||||
					UNIQUE(image_id, user_id),
 | 
									INDEX(image_id)
 | 
				
			||||||
					INDEX(image_id)
 | 
					 | 
				
			||||||
				)
 | 
					 | 
				
			||||||
			");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_numeric_score_version", 1);
 | 
								$config->set_int("ext_numeric_score_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -121,18 +121,16 @@ class PM implements Extension {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// shortcut to latest
 | 
							// shortcut to latest
 | 
				
			||||||
		if($config->get_int("pm_version") < 1) {
 | 
							if($config->get_int("pm_version") < 1) {
 | 
				
			||||||
			$database->execute("
 | 
								$database->create_table("private_message", "
 | 
				
			||||||
				CREATE TABLE private_message (
 | 
									id SCORE_AIPK,
 | 
				
			||||||
					id {$database->engine->auto_increment},
 | 
									from_id INTEGER NOT NULL,
 | 
				
			||||||
					from_id INTEGER NOT NULL,
 | 
									from_ip SCORE_INET NOT NULL,
 | 
				
			||||||
					from_ip VARCHAR(15) NOT NULL,
 | 
									to_id INTEGER NOT NULL,
 | 
				
			||||||
					to_id INTEGER NOT NULL,
 | 
									sent_date DATETIME NOT NULL,
 | 
				
			||||||
					sent_date DATETIME NOT NULL,
 | 
									subject VARCHAR(64) NOT NULL,
 | 
				
			||||||
					subject VARCHAR(64) NOT NULL,
 | 
									message TEXT NOT NULL,
 | 
				
			||||||
					message TEXT NOT NULL,
 | 
									is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
 | 
				
			||||||
					is_read ENUM('Y', 'N') NOT NULL DEFAULT 'N',
 | 
									INDEX (to_id)
 | 
				
			||||||
					INDEX (to_id)
 | 
					 | 
				
			||||||
				) {$database->engine->create_table_extras};
 | 
					 | 
				
			||||||
			");
 | 
								");
 | 
				
			||||||
			$config->set_int("pm_version", 1);
 | 
								$config->set_int("pm_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -115,12 +115,12 @@ class ReportImage implements Extension {
 | 
				
			|||||||
		global $database;
 | 
							global $database;
 | 
				
			||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
		if($config->get_int("ext_report_image_version") < 1) {
 | 
							if($config->get_int("ext_report_image_version") < 1) {
 | 
				
			||||||
			$database->Execute("CREATE TABLE image_reports (
 | 
								$database->create_table("image_reports", "
 | 
				
			||||||
				id {$database->engine->auto_increment},
 | 
									id SCORE_AIPK,
 | 
				
			||||||
				image_id INTEGER NOT NULL,
 | 
									image_id INTEGER NOT NULL REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
				reporter_id INTEGER NOT NULL,
 | 
									reporter_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
				reason TEXT NOT NULL
 | 
									reason TEXT NOT NULL
 | 
				
			||||||
			)");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_report_image_version", 1);
 | 
								$config->set_int("ext_report_image_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -67,12 +67,11 @@ class Tag_History implements Extension {
 | 
				
			|||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if($config->get_int("ext_tag_history_version") < 1) {
 | 
							if($config->get_int("ext_tag_history_version") < 1) {
 | 
				
			||||||
			$database->Execute("CREATE TABLE tag_histories
 | 
								$database->create_table("tag_histories", "
 | 
				
			||||||
			(
 | 
						    		id SCORE_AIPK,
 | 
				
			||||||
	    		id integer NOT NULL auto_increment PRIMARY KEY,
 | 
						    		image_id INTEGER NOT NULL REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
	    		image_id integer NOT NULL,
 | 
						    		tags TEXT NOT NULL
 | 
				
			||||||
	    		tags text NOT NULL
 | 
								");
 | 
				
			||||||
			)");
 | 
					 | 
				
			||||||
			$config->set_int("ext_tag_history_version", 1);
 | 
								$config->set_int("ext_tag_history_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
				
			|||||||
@ -81,14 +81,12 @@ class TextScore implements Extension {
 | 
				
			|||||||
		if($config->get_int("ext_text_score_version") < 1) {
 | 
							if($config->get_int("ext_text_score_version") < 1) {
 | 
				
			||||||
			$database->Execute("ALTER TABLE images ADD COLUMN text_score INTEGER NOT NULL DEFAULT 0");
 | 
								$database->Execute("ALTER TABLE images ADD COLUMN text_score INTEGER NOT NULL DEFAULT 0");
 | 
				
			||||||
			$database->Execute("CREATE INDEX images__text_score ON images(text_score)");
 | 
								$database->Execute("CREATE INDEX images__text_score ON images(text_score)");
 | 
				
			||||||
			$database->Execute("
 | 
								$database->create_table("text_score_votes", "
 | 
				
			||||||
				CREATE TABLE text_score_votes (
 | 
									image_id INTEGER NOT NULL REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
					image_id INTEGER NOT NULL,
 | 
									user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
					user_id INTEGER NOT NULL,
 | 
									score INTEGER NOT NULL,
 | 
				
			||||||
					score INTEGER NOT NULL,
 | 
									UNIQUE(image_id, user_id),
 | 
				
			||||||
					UNIQUE(image_id, user_id),
 | 
									INDEX(image_id)
 | 
				
			||||||
					INDEX(image_id)
 | 
					 | 
				
			||||||
				)
 | 
					 | 
				
			||||||
			");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_text_score_version", 1);
 | 
								$config->set_int("ext_text_score_version", 1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -147,17 +147,18 @@ class Wiki implements Extension {
 | 
				
			|||||||
		global $config;
 | 
							global $config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if($config->get_int("ext_wiki_version", 0) < 1) {
 | 
							if($config->get_int("ext_wiki_version", 0) < 1) {
 | 
				
			||||||
			$database->Execute("CREATE TABLE wiki_pages (
 | 
								$database->create_table("wiki_pages", "
 | 
				
			||||||
				id int(11) NOT NULL auto_increment,
 | 
									id SCORE_AIPK,
 | 
				
			||||||
				owner_id int(11) NOT NULL,
 | 
									owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
				owner_ip char(15) NOT NULL,
 | 
									owner_ip SCORE_INET NOT NULL,
 | 
				
			||||||
				date datetime default NULL,
 | 
									date DATETIME DEFAULT NULL,
 | 
				
			||||||
				title varchar(255) NOT NULL,
 | 
									title VARCHAR(255) NOT NULL,
 | 
				
			||||||
				revision int(11) NOT NULL default 1,
 | 
									revision INTEGER NOT NULL DEFAULT 1,
 | 
				
			||||||
				body text NOT NULL,
 | 
									locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
 | 
				
			||||||
				PRIMARY KEY (id), UNIQUE (title, revision)
 | 
									body TEXT NOT NULL,
 | 
				
			||||||
			)");
 | 
									UNIQUE (title, revision)
 | 
				
			||||||
			$config->set_int("ext_wiki_version", 1);
 | 
								");
 | 
				
			||||||
 | 
								$config->set_int("ext_wiki_version", 2);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if($config->get_int("ext_wiki_version") < 2) {
 | 
							if($config->get_int("ext_wiki_version") < 2) {
 | 
				
			||||||
			$database->Execute("ALTER TABLE wiki_pages ADD COLUMN
 | 
								$database->Execute("ALTER TABLE wiki_pages ADD COLUMN
 | 
				
			||||||
 | 
				
			|||||||
@ -53,22 +53,45 @@ class ImgQuerylet {
 | 
				
			|||||||
class DBEngine {
 | 
					class DBEngine {
 | 
				
			||||||
	var $name = null;
 | 
						var $name = null;
 | 
				
			||||||
	var $auto_increment = null;
 | 
						var $auto_increment = null;
 | 
				
			||||||
 | 
						var $inet = null;
 | 
				
			||||||
	var $create_table_extras = "";
 | 
						var $create_table_extras = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function create_table_sql($name, $data) {
 | 
				
			||||||
 | 
							return "CREATE TABLE $name ($data)";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
class MySQL extends DBEngine {
 | 
					class MySQL extends DBEngine {
 | 
				
			||||||
	var $name = "mysql";
 | 
						var $name = "mysql";
 | 
				
			||||||
	var $auto_increment = "INTEGER PRIMARY KEY auto_increment";
 | 
					 | 
				
			||||||
	var $create_table_extras = "TYPE=INNODB DEFAULT CHARSET='utf8'";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function init($db) {
 | 
						public function init($db) {
 | 
				
			||||||
		$db->Execute("SET NAMES utf8;");
 | 
							$db->Execute("SET NAMES utf8;");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function create_table_sql($name, $data) {
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_AIPK", "INTEGER PRIMARY KEY auto_increment");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_INET", "CHAR(15)");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL", "ENUM('Y', 'N')");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL_Y", "'Y'");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL_N", "'N'");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_NOW", "now()");
 | 
				
			||||||
 | 
							$ctes = "TYPE=InnoDB DEFAULT CHARSET='utf8'";
 | 
				
			||||||
 | 
							return "CREATE TABLE $name ($data) $ctes";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
class PostgreSQL extends DBEngine {
 | 
					class PostgreSQL extends DBEngine {
 | 
				
			||||||
	var $name = "pgsql";
 | 
						var $name = "pgsql";
 | 
				
			||||||
	var $auto_increment = "SERIAL PRIMARY KEY";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function init($db) {
 | 
						public function init($db) {
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function create_table_sql($name, $data) {
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_AIPK", "SERIAL PRIMARY KEY");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_INET", "INET");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL", "BOOL",);
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL_Y", "'t'");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_BOOL_N", "'f'");
 | 
				
			||||||
 | 
							$data = str_replace($data, "SCORE_NOW", "current_time");
 | 
				
			||||||
 | 
							return "CREATE TABLE $name ($data)";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
// }}}
 | 
					// }}}
 | 
				
			||||||
@ -180,7 +203,6 @@ class Database {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// safety wrapping {{{
 | 
					 | 
				
			||||||
	public function execute($query, $args=array()) {
 | 
						public function execute($query, $args=array()) {
 | 
				
			||||||
		$result = $this->db->Execute($query, $args);
 | 
							$result = $this->db->Execute($query, $args);
 | 
				
			||||||
		if($result === False) {
 | 
							if($result === False) {
 | 
				
			||||||
@ -220,9 +242,7 @@ class Database {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function create_table($name, $data) {
 | 
						public function create_table($name, $data) {
 | 
				
			||||||
		$data = str_replace($data, "SCORE_AIPK", $this->engine->auto_increment);
 | 
							$this->execute($this->engine->create_table_sql($name, $data));
 | 
				
			||||||
		$ctes = $this->engine->create_table_extras;
 | 
					 | 
				
			||||||
		$this->execute("CREATE TABLE $name ($data) $ctes");
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function upgrade_schema($filename) {
 | 
						public function upgrade_schema($filename) {
 | 
				
			||||||
@ -248,6 +268,5 @@ class Database {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		$config->set_bool("in_upgrade", false);
 | 
							$config->set_bool("in_upgrade", false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
// }}}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
 | 
				
			|||||||
@ -160,17 +160,17 @@ class CommentList implements Extension {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// shortcut to latest
 | 
							// shortcut to latest
 | 
				
			||||||
		if($config->get_int("ext_comments_version") < 1) {
 | 
							if($config->get_int("ext_comments_version") < 1) {
 | 
				
			||||||
			$database->Execute("CREATE TABLE comments (
 | 
								$database->create_table("comments", "
 | 
				
			||||||
				id {$database->engine->auto_increment},
 | 
									id SCORE_AIPK,
 | 
				
			||||||
				image_id INTEGER NOT NULL,
 | 
									image_id INTEGER NOT NULL REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
				owner_id INTEGER NOT NULL,
 | 
									owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
				owner_ip CHAR(16) NOT NULL,
 | 
									owner_ip SCORE_INET NOT NULL,
 | 
				
			||||||
				posted DATETIME DEFAULT NULL,
 | 
									posted DATETIME DEFAULT NULL,
 | 
				
			||||||
				comment TEXT NOT NULL,
 | 
									comment TEXT NOT NULL,
 | 
				
			||||||
				INDEX (image_id),
 | 
									INDEX (image_id),
 | 
				
			||||||
				INDEX (owner_ip),
 | 
									INDEX (owner_ip),
 | 
				
			||||||
				INDEX (posted)
 | 
									INDEX (posted)
 | 
				
			||||||
			) {$database->engine->create_table_extras}");
 | 
								");
 | 
				
			||||||
			$config->set_int("ext_comments_version", 2);
 | 
								$config->set_int("ext_comments_version", 2);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,68 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0"?>
 | 
					 | 
				
			||||||
<schema version="0.3">
 | 
					 | 
				
			||||||
	<!-- FIXME: mysql utf8ness -->
 | 
					 | 
				
			||||||
	<table name="aliases">
 | 
					 | 
				
			||||||
		<field name="oldtag" type="C" size="128"><key/><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="newtag" type="C" size="128"><notnull/></field>
 | 
					 | 
				
			||||||
		<index name="aliases__unique"><col>oldtag</col><col>newtag</col><unique/></index>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	<table name="config">
 | 
					 | 
				
			||||||
		<field name="name" type="C" size="128"><key/><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="value" type="X" size="4000"></field>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<table name="images">
 | 
					 | 
				
			||||||
		<field name="id" type="I"><key/><autoincrement/></field>
 | 
					 | 
				
			||||||
		<field name="owner_id" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="owner_ip" type="C" size="15"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="filename" type="C" size="64"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="filesize" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="hash" type="C" size="32"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="ext" type="C" size="4"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="source" type="C" size="249"></field>
 | 
					 | 
				
			||||||
		<field name="width" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="height" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="posted" type="T"><notnull/></field>
 | 
					 | 
				
			||||||
		<index name="images__owner_id"><col>owner_id</col></index>
 | 
					 | 
				
			||||||
		<index name="images__hash"><col>hash</col><unique/></index>
 | 
					 | 
				
			||||||
		<index name="images__width"><col>width</col></index>
 | 
					 | 
				
			||||||
		<index name="images__height"><col>height</col></index>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<table name="users">
 | 
					 | 
				
			||||||
		<field name="id" type="I"><key/><autoincrement/></field>
 | 
					 | 
				
			||||||
		<field name="name" type="C" size="32"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="pass" type="C" size="32"></field>
 | 
					 | 
				
			||||||
		<field name="joindate" type="T"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="admin" type="C" size="1"><notnull/><default value="N"/></field>
 | 
					 | 
				
			||||||
		<field name="email" type="C" size="249"></field>
 | 
					 | 
				
			||||||
		<index name="users__name"><col>name</col><unique/></index>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<table name="tags">
 | 
					 | 
				
			||||||
		<field name="id" type="I"><key/><autoincrement/></field>
 | 
					 | 
				
			||||||
		<field name="tag" type="C" size="64"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="count" type="I"><notnull/><default value="0"/></field>
 | 
					 | 
				
			||||||
		<index name="tags__tag"><col>tag</col><unique/></index>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<table name="image_tags">
 | 
					 | 
				
			||||||
		<field name="image_id" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<field name="tag_id" type="I"><notnull/></field>
 | 
					 | 
				
			||||||
		<index name="image_tags__image_id"><col>image_id</col></index>
 | 
					 | 
				
			||||||
		<index name="image_tags__tag_id"><col>tag_id</col></index>
 | 
					 | 
				
			||||||
		<index name="image_tags__key"><col>image_id</col><col>tag_id</col><unique/></index>
 | 
					 | 
				
			||||||
		<opt platform="mysql">DEFAULT CHARSET='utf8'</opt>
 | 
					 | 
				
			||||||
	</table>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<sql>
 | 
					 | 
				
			||||||
		<query>DELETE FROM config WHERE name='db_version'</query>
 | 
					 | 
				
			||||||
		<query>INSERT INTO config(name, value) VALUES('db_version', 6)</query>
 | 
					 | 
				
			||||||
	</sql>
 | 
					 | 
				
			||||||
</schema>
 | 
					 | 
				
			||||||
							
								
								
									
										66
									
								
								install.php
									
									
									
									
									
								
							
							
						
						
									
										66
									
								
								install.php
									
									
									
									
									
								
							@ -53,8 +53,7 @@ if(is_readable("config.php")) {
 | 
				
			|||||||
	exit;
 | 
						exit;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
require_once "core/compat.inc.php";
 | 
					require_once "core/compat.inc.php";
 | 
				
			||||||
require_once "lib/adodb/adodb.inc.php";
 | 
					require_once "core/database.class.php";
 | 
				
			||||||
require_once "lib/adodb/adodb-xmlschema03.inc.php";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
do_install();
 | 
					do_install();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -143,15 +142,62 @@ function create_tables($dsn) { // {{{
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		if(substr($dsn, 0, 5) == "mysql") {
 | 
							if(substr($dsn, 0, 5) == "mysql") {
 | 
				
			||||||
			$db->Execute("SET NAMES utf8");
 | 
								$engine = new MySQL();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		$schema = new adoSchema($db);
 | 
							else if(substr($dsn, 0, 5) == "pgsql") {
 | 
				
			||||||
		$sql = $schema->ParseSchema("ext/upgrade/schema.xml");
 | 
								$engine = new PostgreSQL();
 | 
				
			||||||
		$result = $schema->ExecuteSchema();
 | 
							}
 | 
				
			||||||
 | 
							$engine->init($db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(!$result) {
 | 
							$db->execute($engine->create_table_sql("aliases", "
 | 
				
			||||||
			die("Error creating tables from XML schema");
 | 
								oldtag VARCHAR(128) NOT NULL PRIMARY KEY,
 | 
				
			||||||
		}
 | 
								newtag VARCHAR(128) NOT NULL,
 | 
				
			||||||
 | 
								UNIQUE(oldtag, newtag)
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute($engine->create_table_sql("config", "
 | 
				
			||||||
 | 
								name VARCHAR(128) NOT NULL PRIMARY KEY,
 | 
				
			||||||
 | 
								value TEXT
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute($engine->create_table_sql("images", "
 | 
				
			||||||
 | 
								id SCORE_AIPK,
 | 
				
			||||||
 | 
								owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 | 
				
			||||||
 | 
								owner_ip SCORE_INET NOT NULL,
 | 
				
			||||||
 | 
								filename VARCHAR(64) NOT NULL,
 | 
				
			||||||
 | 
								filesize INTEGER NOT NULL,
 | 
				
			||||||
 | 
								hash CHAR(32) NOT NULL,
 | 
				
			||||||
 | 
								ext CHAR(4) NOT NULL,
 | 
				
			||||||
 | 
								source VARCHAR(255),
 | 
				
			||||||
 | 
								width INTEGER NOT NULL,
 | 
				
			||||||
 | 
								height INTEGER NOT NULL,
 | 
				
			||||||
 | 
								posted TIMESTAMP NOT NULL DEFAULT SCORE_NOW,
 | 
				
			||||||
 | 
								INDEX(owner_id),
 | 
				
			||||||
 | 
								INDEX(hash),
 | 
				
			||||||
 | 
								INDEX(width),
 | 
				
			||||||
 | 
								INDEX(height)
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute($engine->create_table_sql("users", "
 | 
				
			||||||
 | 
								id SCORE_AIPK,
 | 
				
			||||||
 | 
								name VARCHAR(32) NOT NULL,
 | 
				
			||||||
 | 
								pass CHAR(32),
 | 
				
			||||||
 | 
								joindate DATATIME NOT NULL DEFAULT SCORE_NOW,
 | 
				
			||||||
 | 
								admin SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
 | 
				
			||||||
 | 
								email VARCHAR(128),
 | 
				
			||||||
 | 
								INDEX(name)
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute($engine->create_table_sql("tags", "
 | 
				
			||||||
 | 
								id SCORE_AIPK,
 | 
				
			||||||
 | 
								tag VARCHAR(64) NOT NULL,
 | 
				
			||||||
 | 
								count NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
								INDEX(tag)
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute($engine->create_table_sql("image_tags", "
 | 
				
			||||||
 | 
								image_id INTEGER REFERENCES images(id) ON DELETE CASCADE,
 | 
				
			||||||
 | 
								tag_id INTEGER REFERENCES tags(id) ON DELETE CASCADE,
 | 
				
			||||||
 | 
								INDEX(image_id),
 | 
				
			||||||
 | 
								INDEX(tag_id),
 | 
				
			||||||
 | 
								INDEX(image_id, tag_id)
 | 
				
			||||||
 | 
							"));
 | 
				
			||||||
 | 
							$db->execute("INSERT INTO config(name, value) VALUES('db_version', 7)");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	$db->Close();
 | 
						$db->Close();
 | 
				
			||||||
} // }}}
 | 
					} // }}}
 | 
				
			||||||
@ -220,7 +266,7 @@ function write_config($dsn) { // {{{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		<p><textarea cols="80" rows="2">$file_content</textarea>
 | 
							<p><textarea cols="80" rows="2">$file_content</textarea>
 | 
				
			||||||
						
 | 
											
 | 
				
			||||||
		<p>One done, <a href='index.php?q=setup'>Continue</a>
 | 
							<p>One done, <a href='index.php'>Continue</a>
 | 
				
			||||||
EOD;
 | 
					EOD;
 | 
				
			||||||
		exit;
 | 
							exit;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user