Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
4c0b2dcb39
@ -26,7 +26,7 @@ because the feature doesn't work yet :P
|
|||||||
Requirements
|
Requirements
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
MySQL 5.1+ (with experimental support for PostgreSQL 8+ and SQLite 3)
|
MySQL 5.1+ (with experimental support for PostgreSQL 8+ and SQLite 3)
|
||||||
PHP 5.2+
|
PHP 5.2.6+
|
||||||
GD or ImageMagick
|
GD or ImageMagick
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class AdminPage extends Extension {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function dump_database() {
|
private function database_dump() {
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
@ -150,11 +150,17 @@ class AdminPage extends Extension {
|
|||||||
$hostname = $matches['host'];
|
$hostname = $matches['host'];
|
||||||
$database = $matches['dbname'];
|
$database = $matches['dbname'];
|
||||||
|
|
||||||
// TODO: Support more than just MySQL..
|
|
||||||
switch($software) {
|
switch($software) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$cmd = "mysqldump -h$hostname -u$username -p$password $database";
|
$cmd = "mysqldump -h$hostname -u$username -p$password $database";
|
||||||
break;
|
break;
|
||||||
|
case 'pgsql':
|
||||||
|
putenv("PGPASSWORD=$password");
|
||||||
|
$cmd = "pg_dump -h $hostname -U $username $database";
|
||||||
|
break;
|
||||||
|
case 'sqlite':
|
||||||
|
$cmd = "sqlite3 $database .dump";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
|
@ -23,12 +23,10 @@ class AdminPageTest extends ShimmieWebTestCase {
|
|||||||
|
|
||||||
$this->get_page('admin');
|
$this->get_page('admin');
|
||||||
$this->assert_title("Admin Tools");
|
$this->assert_title("Admin Tools");
|
||||||
$this->set_field("action", "lowercase all tags");
|
$this->click("All tags to lowercase");
|
||||||
$this->click("Go");
|
|
||||||
|
|
||||||
$this->get_page("post/view/$image_id_1");
|
$this->get_page("post/view/$image_id_1");
|
||||||
// FIXME: doesn't work?
|
$this->assert_title("Image $image_id_1: testcase$ts");
|
||||||
//$this->assert_title("Image $image_id_1: testcase$ts");
|
|
||||||
|
|
||||||
$this->delete_image($image_id_1);
|
$this->delete_image($image_id_1);
|
||||||
$this->log_out();
|
$this->log_out();
|
||||||
@ -39,8 +37,7 @@ class AdminPageTest extends ShimmieWebTestCase {
|
|||||||
$this->log_in_as_admin();
|
$this->log_in_as_admin();
|
||||||
$this->get_page('admin');
|
$this->get_page('admin');
|
||||||
$this->assert_title("Admin Tools");
|
$this->assert_title("Admin Tools");
|
||||||
$this->set_field("action", "recount tag use");
|
$this->click("Recount tag use");
|
||||||
$this->click("Go");
|
|
||||||
$this->log_out();
|
$this->log_out();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,8 +45,7 @@ class AdminPageTest extends ShimmieWebTestCase {
|
|||||||
$this->log_in_as_admin();
|
$this->log_in_as_admin();
|
||||||
$this->get_page('admin');
|
$this->get_page('admin');
|
||||||
$this->assert_title("Admin Tools");
|
$this->assert_title("Admin Tools");
|
||||||
$this->set_field("action", "purge unused tags");
|
$this->click("Purge unused tags");
|
||||||
$this->click("Go");
|
|
||||||
$this->log_out();
|
$this->log_out();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +53,28 @@ class AdminPageTest extends ShimmieWebTestCase {
|
|||||||
$this->log_in_as_admin();
|
$this->log_in_as_admin();
|
||||||
$this->get_page('admin');
|
$this->get_page('admin');
|
||||||
$this->assert_title("Admin Tools");
|
$this->assert_title("Admin Tools");
|
||||||
$this->set_field("action", "database dump");
|
$this->click("Download database contents");
|
||||||
$this->click("Go");
|
$this->assert_response(200);
|
||||||
|
$this->log_out();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testDBQ() {
|
||||||
|
$this->log_in_as_user();
|
||||||
|
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test");
|
||||||
|
$image_id_2 = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "test2");
|
||||||
|
$image_id_3 = $this->post_image("ext/simpletest/data/favicon.png", "test");
|
||||||
|
|
||||||
|
$this->get_page("post/list/test/1");
|
||||||
|
$this->click("Delete All These Images");
|
||||||
|
|
||||||
|
$this->get_page("post/view/$image_id_1");
|
||||||
|
$this->assert_response(404);
|
||||||
|
$this->get_page("post/view/$image_id_2");
|
||||||
|
$this->assert_response(200);
|
||||||
|
$this->get_page("post/view/$image_id_3");
|
||||||
|
$this->assert_response(404);
|
||||||
|
|
||||||
|
$this->delete_image($image_id_2);
|
||||||
$this->log_out();
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,46 +54,49 @@ class Artists extends Extension {
|
|||||||
public function try_install() {
|
public function try_install() {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
|
|
||||||
if ($config->get_int("ext_artists_version") < 1)
|
if ($config->get_int("ext_artists_version") < 1) {
|
||||||
{
|
$database->create_table("artists", "
|
||||||
$database->create_table("artists",
|
id SCORE_AIPK,
|
||||||
"id SCORE_AIPK
|
user_id INTEGER NOT NULL,
|
||||||
, user_id INTEGER NOT NULL
|
name VARCHAR(255) NOT NULL,
|
||||||
, name VARCHAR(255) NOT NULL
|
created DATETIME NOT NULL,
|
||||||
, created DATETIME NOT NULL
|
updated DATETIME NOT NULL,
|
||||||
, updated DATETIME NOT NULL
|
notes TEXT,
|
||||||
, notes TEXT
|
INDEX(id),
|
||||||
, INDEX(id)
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->create_table("artist_members",
|
$database->create_table("artist_members", "
|
||||||
"id SCORE_AIPK
|
id SCORE_AIPK,
|
||||||
, artist_id INTEGER NOT NULL
|
artist_id INTEGER NOT NULL,
|
||||||
, user_id INTEGER NOT NULL
|
user_id INTEGER NOT NULL,
|
||||||
, name VARCHAR(255) NOT NULL
|
name VARCHAR(255) NOT NULL,
|
||||||
, created DATETIME NOT NULL
|
created DATETIME NOT NULL,
|
||||||
, updated DATETIME NOT NULL
|
updated DATETIME NOT NULL,
|
||||||
, INDEX (id)
|
INDEX (id),
|
||||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->create_table("artist_alias",
|
$database->create_table("artist_alias", "
|
||||||
"id SCORE_AIPK
|
id SCORE_AIPK,
|
||||||
, artist_id INTEGER NOT NULL
|
artist_id INTEGER NOT NULL,
|
||||||
, user_id INTEGER NOT NULL
|
user_id INTEGER NOT NULL,
|
||||||
, created DATETIME
|
created DATETIME,
|
||||||
, updated DATETIME
|
updated DATETIME,
|
||||||
, alias VARCHAR(255)
|
alias VARCHAR(255),
|
||||||
, INDEX (id)
|
INDEX (id),
|
||||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->create_table("artist_urls",
|
$database->create_table("artist_urls", "
|
||||||
"id SCORE_AIPK
|
id SCORE_AIPK,
|
||||||
, artist_id INTEGER NOT NULL
|
artist_id INTEGER NOT NULL,
|
||||||
, user_id INTEGER NOT NULL
|
user_id INTEGER NOT NULL,
|
||||||
, created DATETIME NOT NULL
|
created DATETIME NOT NULL,
|
||||||
, updated DATETIME NOT NULL
|
updated DATETIME NOT NULL,
|
||||||
, url VARCHAR(1000) NOT NULL
|
url VARCHAR(1000) NOT NULL,
|
||||||
, INDEX (id)
|
INDEX (id),
|
||||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->execute("ALTER TABLE images ADD COLUMN author VARCHAR(255) NULL", array());
|
$database->execute("ALTER TABLE images ADD COLUMN author VARCHAR(255) NULL", array());
|
||||||
|
|
||||||
|
8
contrib/artists/test.php
Normal file
8
contrib/artists/test.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
class ArtistTest extends ShimmieWebTestCase {
|
||||||
|
function testSearch() {
|
||||||
|
# FIXME: check that the results are there
|
||||||
|
$this->get_page("post/list/author=bob/1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -3,7 +3,15 @@ class ArtistsTheme extends Themelet {
|
|||||||
|
|
||||||
public function get_author_editor_html(/*string*/ $author) {
|
public function get_author_editor_html(/*string*/ $author) {
|
||||||
$h_author = html_escape($author);
|
$h_author = html_escape($author);
|
||||||
return "<tr><td>Author</td><td><input class='editor_author' type='text' name='tag_edit__author' value='$h_author'></td></tr>";
|
return "
|
||||||
|
<tr>
|
||||||
|
<td>Author</td>
|
||||||
|
<td>
|
||||||
|
<span class='view'>$h_author</span>
|
||||||
|
<input class='edit' type='text' name='tag_edit__author' value='$h_author'>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display_artists(){
|
public function display_artists(){
|
||||||
|
2
contrib/browser_search/main.php
Executable file → Normal file
2
contrib/browser_search/main.php
Executable file → Normal file
@ -34,7 +34,7 @@ class BrowserSearch extends Extension {
|
|||||||
$search_title = $config->get_string('title');
|
$search_title = $config->get_string('title');
|
||||||
$search_form_url = make_link('post/list/{searchTerms}');
|
$search_form_url = make_link('post/list/{searchTerms}');
|
||||||
$suggenton_url = make_link('browser_search/')."{searchTerms}";
|
$suggenton_url = make_link('browser_search/')."{searchTerms}";
|
||||||
$icon_b64 = base64_encode(file_get_contents("favicon.ico"));
|
$icon_b64 = base64_encode(file_get_contents("lib/static/favicon.ico"));
|
||||||
|
|
||||||
// Now for the XML
|
// Now for the XML
|
||||||
$xml = "
|
$xml = "
|
||||||
|
26
contrib/danbooru_api/test.php
Normal file
26
contrib/danbooru_api/test.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
class DanbooruApiTest extends ShimmieWebTestCase {
|
||||||
|
function testSearch() {
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
|
||||||
|
$image_id = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "data");
|
||||||
|
|
||||||
|
$this->get_page("post/list/md5:17fc89f372ed3636e28bd25cc7f3bac1/1");
|
||||||
|
$this->assert_title(new PatternExpectation("/^Image \d+: data/"));
|
||||||
|
$this->click("Delete");
|
||||||
|
|
||||||
|
$this->get_page("api/danbooru/find_posts");
|
||||||
|
$this->get_page("api/danbooru/find_posts?id=$image_id");
|
||||||
|
$this->get_page("api/danbooru/find_posts?md5=17fc89f372ed3636e28bd25cc7f3bac1");
|
||||||
|
|
||||||
|
$this->get_page("api/danbooru/find_tags");
|
||||||
|
$this->get_page("api/danbooru/find_tags?id=1");
|
||||||
|
$this->get_page("api/danbooru/find_tags?name=data");
|
||||||
|
|
||||||
|
$this->get_page("api/danbooru/post/show/$image_id");
|
||||||
|
$this->assert_response(302);
|
||||||
|
|
||||||
|
$this->log_out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -161,8 +161,8 @@ class Favorites extends Extension {
|
|||||||
$database->Execute("DELETE FROM user_favorites WHERE image_id NOT IN (SELECT id FROM images)");
|
$database->Execute("DELETE FROM user_favorites WHERE image_id NOT IN (SELECT id FROM images)");
|
||||||
|
|
||||||
log_info("favorites", "Adding foreign keys to user favourites");
|
log_info("favorites", "Adding foreign keys to user favourites");
|
||||||
$database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;");
|
$database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;");
|
||||||
$database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;");
|
$database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;");
|
||||||
$config->set_int("ext_favorites_version", 2);
|
$config->set_int("ext_favorites_version", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ class Forum extends Extension {
|
|||||||
|
|
||||||
// shortcut to latest
|
// shortcut to latest
|
||||||
|
|
||||||
if ($config->get_int("forum_version") < 1)
|
if ($config->get_int("forum_version") < 1) {
|
||||||
{
|
|
||||||
$database->create_table("forum_threads", "
|
$database->create_table("forum_threads", "
|
||||||
id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||||
@ -23,20 +22,22 @@ class Forum extends Extension {
|
|||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
uptodate DATETIME NOT NULL,
|
uptodate DATETIME NOT NULL,
|
||||||
INDEX (date)
|
INDEX (date),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT
|
||||||
");
|
");
|
||||||
|
|
||||||
$database->create_table("forum_posts",
|
$database->create_table("forum_posts", "
|
||||||
" id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
thread_id INTEGER NOT NULL,
|
thread_id INTEGER NOT NULL,
|
||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
message TEXT,
|
message TEXT,
|
||||||
INDEX (date),
|
INDEX (date),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
||||||
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE
|
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
|
|
||||||
$config->set_int("forum_version", 1);
|
$config->set_int("forum_version", 2);
|
||||||
$config->set_int("forumTitleSubString", 25);
|
$config->set_int("forumTitleSubString", 25);
|
||||||
$config->set_int("forumThreadsPerPage", 15);
|
$config->set_int("forumThreadsPerPage", 15);
|
||||||
$config->set_int("forumPostsPerPage", 15);
|
$config->set_int("forumPostsPerPage", 15);
|
||||||
@ -45,6 +46,11 @@ class Forum extends Extension {
|
|||||||
|
|
||||||
log_info("forum", "extension installed");
|
log_info("forum", "extension installed");
|
||||||
}
|
}
|
||||||
|
if ($config->get_int("forum_version") < 2) {
|
||||||
|
$database->execute("ALTER TABLE forum_threads ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT");
|
||||||
|
$database->execute("ALTER TABLE forum_posts ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT");
|
||||||
|
$config->set_int("forum_version", 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
|
@ -159,6 +159,11 @@ class IPBan extends Extension {
|
|||||||
$database->execute("ALTER TABLE bans CHANGE ip ip VARCHAR(15)");
|
$database->execute("ALTER TABLE bans CHANGE ip ip VARCHAR(15)");
|
||||||
$config->set_int("ext_ipban_version", 6);
|
$config->set_int("ext_ipban_version", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($config->get_int("ext_ipban_version") == 6) {
|
||||||
|
$database->Execute("ALTER TABLE bans ADD FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE");
|
||||||
|
$config->set_int("ext_ipban_version", 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// deal with banned person {{{
|
// deal with banned person {{{
|
||||||
|
@ -3,6 +3,10 @@ class LogDatabaseTest extends SCoreWebTestCase {
|
|||||||
function testLog() {
|
function testLog() {
|
||||||
$this->log_in_as_admin();
|
$this->log_in_as_admin();
|
||||||
$this->get_page("log/view");
|
$this->get_page("log/view");
|
||||||
|
$this->get_page("log/view?module=core-image");
|
||||||
|
$this->get_page("log/view?time=2012-03-01");
|
||||||
|
$this->get_page("log/view?user=demo");
|
||||||
|
$this->get_page("log/view?priority=10");
|
||||||
$this->log_out();
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class NotATag extends Extension {
|
|||||||
public function get_priority() {return 30;} // before ImageUploadEvent and tag_history
|
public function get_priority() {return 30;} // before ImageUploadEvent and tag_history
|
||||||
|
|
||||||
public function onImageAddition(ImageAdditionEvent $event) {
|
public function onImageAddition(ImageAdditionEvent $event) {
|
||||||
$this->scan($event->image->tags);
|
$this->scan($event->image->get_tag_array());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onTagSet(TagSetEvent $event) {
|
public function onTagSet(TagSetEvent $event) {
|
||||||
|
@ -27,6 +27,7 @@ class Notes extends Extension {
|
|||||||
width INTEGER NOT NULL,
|
width INTEGER NOT NULL,
|
||||||
note TEXT NOT NULL,
|
note TEXT NOT NULL,
|
||||||
INDEX (image_id),
|
INDEX (image_id),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ class Notes extends Extension {
|
|||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
INDEX (image_id),
|
INDEX (image_id),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ class Notes extends Extension {
|
|||||||
width INTEGER NOT NULL,
|
width INTEGER NOT NULL,
|
||||||
note TEXT NOT NULL,
|
note TEXT NOT NULL,
|
||||||
INDEX (image_id),
|
INDEX (image_id),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
|
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class PrivMsg extends Extension {
|
|||||||
FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$config->set_int("pm_version", 1);
|
$config->set_int("pm_version", 2);
|
||||||
log_info("pm", "extension installed");
|
log_info("pm", "extension installed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ class PrivMsg extends Extension {
|
|||||||
$database->Execute("delete from private_message where to_id not in (select id from users);");
|
$database->Execute("delete from private_message where to_id not in (select id from users);");
|
||||||
$database->Execute("delete from private_message where from_id not in (select id from users);");
|
$database->Execute("delete from private_message where from_id not in (select id from users);");
|
||||||
$database->Execute("ALTER TABLE private_message
|
$database->Execute("ALTER TABLE private_message
|
||||||
ADD CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
ADD FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
ADD CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;");
|
ADD FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;");
|
||||||
$config->set_int("pm_version", 2);
|
$config->set_int("pm_version", 2);
|
||||||
log_info("pm", "extension installed");
|
log_info("pm", "extension installed");
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,15 @@ class Pools extends Extension {
|
|||||||
description TEXT,
|
description TEXT,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
posts INTEGER NOT NULL DEFAULT 0,
|
posts INTEGER NOT NULL DEFAULT 0,
|
||||||
INDEX (id)
|
INDEX (id),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->create_table("pool_images", "
|
$database->create_table("pool_images", "
|
||||||
pool_id INTEGER NOT NULL,
|
pool_id INTEGER NOT NULL,
|
||||||
image_id INTEGER NOT NULL,
|
image_id INTEGER NOT NULL,
|
||||||
image_order INTEGER NOT NULL DEFAULT 0
|
image_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$database->create_table("pool_history", "
|
$database->create_table("pool_history", "
|
||||||
id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
@ -50,7 +53,9 @@ class Pools extends Extension {
|
|||||||
images TEXT,
|
images TEXT,
|
||||||
count INTEGER NOT NULL DEFAULT 0,
|
count INTEGER NOT NULL DEFAULT 0,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
INDEX (id)
|
INDEX (id),
|
||||||
|
FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
|
|
||||||
// Set the defaults for the pools extension
|
// Set the defaults for the pools extension
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
* Description: A JSON interface to shimmie data [WARNING]
|
* Description: A JSON interface to shimmie data [WARNING]
|
||||||
* Documentation:
|
* Documentation:
|
||||||
* <b>Admin Warning:</b> this exposes private data, eg IP addresses
|
* <b>Admin Warning -</b> this exposes private data, eg IP addresses
|
||||||
* <p><b>Developer Warning:</b> the API is unstable; notably, private data may get hidden
|
* <p><b>Developer Warning -</b> the API is unstable; notably, private data may get hidden
|
||||||
* <p><b><u>Usage:</b></u>
|
* <p><b><u>Usage:</b></u>
|
||||||
* <p><b>get_tags</b> - List of all tags. (May contain unused tags)
|
* <p><b>get_tags</b> - List of all tags. (May contain unused tags)
|
||||||
* <br><ul>tags - <i>Optional</i> - Search for more specific tags (Searchs TAG*)</ul>
|
* <br><ul>tags - <i>Optional</i> - Search for more specific tags (Searchs TAG*)</ul>
|
||||||
|
@ -330,13 +330,13 @@ class Tag_History extends Extension {
|
|||||||
|
|
||||||
// if the image has no history, make one with the old tags
|
// if the image has no history, make one with the old tags
|
||||||
$entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
$entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||||
if($entries == 0){
|
if($entries == 0 && !empty($old_tags)) {
|
||||||
/* We have no tag history for this image, so we will use the new_tags as the starting tags for this image. */
|
/* We have no tag history for this image, so we will use the old_tags as the starting tags for this image. */
|
||||||
/* these two queries could probably be combined */
|
/* these two queries could probably be combined */
|
||||||
$database->execute("
|
$database->execute("
|
||||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||||
VALUES (?, ?, ?, ?, now())",
|
VALUES (?, ?, ?, ?, now())",
|
||||||
array($image->id, $new_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id
|
array($image->id, $old_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id
|
||||||
$entries++;
|
$entries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class Wiki extends Extension {
|
|||||||
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||||
body TEXT NOT NULL,
|
body TEXT NOT NULL,
|
||||||
UNIQUE (title, revision),
|
UNIQUE (title, revision),
|
||||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||||
");
|
");
|
||||||
$config->set_int("ext_wiki_version", 2);
|
$config->set_int("ext_wiki_version", 2);
|
||||||
}
|
}
|
||||||
|
@ -967,10 +967,9 @@ class Tag {
|
|||||||
// do nothing
|
// do nothing
|
||||||
//}
|
//}
|
||||||
|
|
||||||
$tags = array_map("trim", $tags);
|
|
||||||
|
|
||||||
$tag_array = array();
|
$tag_array = array();
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
|
$tag = trim($tag, ", \t\n\r\0\x0B");
|
||||||
if(is_string($tag) && !empty($tag)) {
|
if(is_string($tag) && !empty($tag)) {
|
||||||
$tag_array[] = $tag;
|
$tag_array[] = $tag;
|
||||||
}
|
}
|
||||||
|
@ -907,12 +907,7 @@ $_load_start = microtime(true);
|
|||||||
function get_debug_info() {
|
function get_debug_info() {
|
||||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||||
|
|
||||||
if(function_exists('memory_get_usage')) {
|
$i_mem = sprintf("%5.2f", ((memory_get_peak_usage(true)+512)/1024)/1024);
|
||||||
$i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$i_mem = "???";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($config->get_string("commit_hash", "unknown") == "unknown"){
|
if($config->get_string("commit_hash", "unknown") == "unknown"){
|
||||||
$commit = "";
|
$commit = "";
|
||||||
@ -1276,7 +1271,7 @@ function _end_coverage() {
|
|||||||
$n = 0;
|
$n = 0;
|
||||||
$t = time();
|
$t = time();
|
||||||
while(file_exists("$absolute_path/$t.$n.log")) $n++;
|
while(file_exists("$absolute_path/$t.$n.log")) $n++;
|
||||||
file_put_contents("$absolute_path/$t.$n.log", serialize(xdebug_get_code_coverage()));
|
file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -111,8 +111,8 @@ class CommentList extends Extension {
|
|||||||
|
|
||||||
if($config->get_int("ext_comments_version") == 2) {
|
if($config->get_int("ext_comments_version") == 2) {
|
||||||
$config->set_int("ext_comments_version", 3);
|
$config->set_int("ext_comments_version", 3);
|
||||||
$database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE");
|
$database->Execute("ALTER TABLE comments ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE");
|
||||||
$database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
$database->Execute("ALTER TABLE comments ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: add foreign keys, bump to v3
|
// FIXME: add foreign keys, bump to v3
|
||||||
|
@ -57,7 +57,7 @@ class Upgrade extends Extension {
|
|||||||
$config->set_int("db_version", 10);
|
$config->set_int("db_version", 10);
|
||||||
|
|
||||||
log_info("upgrade", "Adding foreign keys to images");
|
log_info("upgrade", "Adding foreign keys to images");
|
||||||
$database->Execute("ALTER TABLE images ADD CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
$database->Execute("ALTER TABLE images ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
||||||
|
|
||||||
log_info("upgrade", "Database at version 10");
|
log_info("upgrade", "Database at version 10");
|
||||||
$config->set_bool("in_upgrade", false);
|
$config->set_bool("in_upgrade", false);
|
||||||
|
@ -287,6 +287,11 @@ class UserPage extends Extension {
|
|||||||
$pass = $_POST['pass'];
|
$pass = $_POST['pass'];
|
||||||
$hash = md5(strtolower($name) . $pass);
|
$hash = md5(strtolower($name) . $pass);
|
||||||
|
|
||||||
|
if(empty($name) || empty($pass)) {
|
||||||
|
$this->theme->display_error(400, "Error", "Username or password left blank");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$duser = User::by_name_and_hash($name, $hash);
|
$duser = User::by_name_and_hash($name, $hash);
|
||||||
if(!is_null($duser)) {
|
if(!is_null($duser)) {
|
||||||
$user = $duser;
|
$user = $duser;
|
||||||
|
@ -100,6 +100,8 @@ try {
|
|||||||
$page->display();
|
$page->display();
|
||||||
|
|
||||||
$database->db->commit();
|
$database->db->commit();
|
||||||
|
// saving cache data and profiling data to disk can happen later
|
||||||
|
if(function_exists("fastcgi_finish_request")) fastcgi_finish_request();
|
||||||
_end_cache();
|
_end_cache();
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ function create_tables() { // {{{
|
|||||||
INDEX(owner_id),
|
INDEX(owner_id),
|
||||||
INDEX(width),
|
INDEX(width),
|
||||||
INDEX(height),
|
INDEX(height),
|
||||||
CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||||
");
|
");
|
||||||
$db->create_table("tags", "
|
$db->create_table("tags", "
|
||||||
id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
@ -345,8 +345,8 @@ function create_tables() { // {{{
|
|||||||
INDEX(image_id),
|
INDEX(image_id),
|
||||||
INDEX(tag_id),
|
INDEX(tag_id),
|
||||||
UNIQUE(image_id, tag_id),
|
UNIQUE(image_id, tag_id),
|
||||||
CONSTRAINT foreign_image_tags_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||||
CONSTRAINT foreign_image_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||||
");
|
");
|
||||||
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 11)");
|
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 11)");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user