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
|
||||
~~~~~~~~~~~~
|
||||
MySQL 5.1+ (with experimental support for PostgreSQL 8+ and SQLite 3)
|
||||
PHP 5.2+
|
||||
PHP 5.2.6+
|
||||
GD or ImageMagick
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ class AdminPage extends Extension {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function dump_database() {
|
||||
private function database_dump() {
|
||||
global $page;
|
||||
|
||||
$matches = array();
|
||||
@ -150,11 +150,17 @@ class AdminPage extends Extension {
|
||||
$hostname = $matches['host'];
|
||||
$database = $matches['dbname'];
|
||||
|
||||
// TODO: Support more than just MySQL..
|
||||
switch($software) {
|
||||
case 'mysql':
|
||||
$cmd = "mysqldump -h$hostname -u$username -p$password $database";
|
||||
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");
|
||||
|
@ -23,12 +23,10 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
|
||||
$this->get_page('admin');
|
||||
$this->assert_title("Admin Tools");
|
||||
$this->set_field("action", "lowercase all tags");
|
||||
$this->click("Go");
|
||||
$this->click("All tags to lowercase");
|
||||
|
||||
$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->log_out();
|
||||
@ -39,8 +37,7 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page('admin');
|
||||
$this->assert_title("Admin Tools");
|
||||
$this->set_field("action", "recount tag use");
|
||||
$this->click("Go");
|
||||
$this->click("Recount tag use");
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
@ -48,8 +45,7 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page('admin');
|
||||
$this->assert_title("Admin Tools");
|
||||
$this->set_field("action", "purge unused tags");
|
||||
$this->click("Go");
|
||||
$this->click("Purge unused tags");
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
@ -57,8 +53,28 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page('admin');
|
||||
$this->assert_title("Admin Tools");
|
||||
$this->set_field("action", "database dump");
|
||||
$this->click("Go");
|
||||
$this->click("Download database contents");
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
@ -54,47 +54,50 @@ class Artists extends Extension {
|
||||
public function try_install() {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_artists_version") < 1)
|
||||
{
|
||||
$database->create_table("artists",
|
||||
"id SCORE_AIPK
|
||||
, user_id INTEGER NOT NULL
|
||||
, name VARCHAR(255) NOT NULL
|
||||
, created DATETIME NOT NULL
|
||||
, updated DATETIME NOT NULL
|
||||
, notes TEXT
|
||||
, INDEX(id)
|
||||
");
|
||||
$database->create_table("artist_members",
|
||||
"id SCORE_AIPK
|
||||
, artist_id INTEGER NOT NULL
|
||||
, user_id INTEGER NOT NULL
|
||||
, name VARCHAR(255) NOT NULL
|
||||
, created DATETIME NOT NULL
|
||||
, updated DATETIME NOT NULL
|
||||
, INDEX (id)
|
||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
$database->create_table("artist_alias",
|
||||
"id SCORE_AIPK
|
||||
, artist_id INTEGER NOT NULL
|
||||
, user_id INTEGER NOT NULL
|
||||
, created DATETIME
|
||||
, updated DATETIME
|
||||
, alias VARCHAR(255)
|
||||
, INDEX (id)
|
||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
$database->create_table("artist_urls",
|
||||
"id SCORE_AIPK
|
||||
, artist_id INTEGER NOT NULL
|
||||
, user_id INTEGER NOT NULL
|
||||
, created DATETIME NOT NULL
|
||||
, updated DATETIME NOT NULL
|
||||
, url VARCHAR(1000) NOT NULL
|
||||
, INDEX (id)
|
||||
, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
if ($config->get_int("ext_artists_version") < 1) {
|
||||
$database->create_table("artists", "
|
||||
id SCORE_AIPK,
|
||||
user_id INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
created DATETIME NOT NULL,
|
||||
updated DATETIME NOT NULL,
|
||||
notes TEXT,
|
||||
INDEX(id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
$database->create_table("artist_members", "
|
||||
id SCORE_AIPK,
|
||||
artist_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
created DATETIME NOT NULL,
|
||||
updated DATETIME NOT NULL,
|
||||
INDEX (id),
|
||||
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", "
|
||||
id SCORE_AIPK,
|
||||
artist_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created DATETIME,
|
||||
updated DATETIME,
|
||||
alias VARCHAR(255),
|
||||
INDEX (id),
|
||||
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", "
|
||||
id SCORE_AIPK,
|
||||
artist_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created DATETIME NOT NULL,
|
||||
updated DATETIME NOT NULL,
|
||||
url VARCHAR(1000) NOT NULL,
|
||||
INDEX (id),
|
||||
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());
|
||||
|
||||
$config->set_int("artistsPerPage", 20);
|
||||
|
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) {
|
||||
$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(){
|
||||
@ -11,7 +19,7 @@ class ArtistsTheme extends Themelet {
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
|
||||
//$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
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_form_url = make_link('post/list/{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
|
||||
$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)");
|
||||
|
||||
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 CONSTRAINT user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(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 FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;");
|
||||
$config->set_int("ext_favorites_version", 2);
|
||||
}
|
||||
}
|
||||
|
@ -9,42 +9,48 @@
|
||||
*/
|
||||
|
||||
class Forum extends Extension {
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
|
||||
if ($config->get_int("forum_version") < 1)
|
||||
{
|
||||
$database->create_table("forum_threads", "
|
||||
id SCORE_AIPK,
|
||||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
uptodate DATETIME NOT NULL,
|
||||
INDEX (date)
|
||||
");
|
||||
|
||||
$database->create_table("forum_posts",
|
||||
" id SCORE_AIPK,
|
||||
thread_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
message TEXT,
|
||||
INDEX (date),
|
||||
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
if ($config->get_int("forum_version") < 1) {
|
||||
$database->create_table("forum_threads", "
|
||||
id SCORE_AIPK,
|
||||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
uptodate DATETIME NOT NULL,
|
||||
INDEX (date),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT
|
||||
");
|
||||
|
||||
$config->set_int("forum_version", 1);
|
||||
$config->set_int("forumTitleSubString", 25);
|
||||
$config->set_int("forumThreadsPerPage", 15);
|
||||
$config->set_int("forumPostsPerPage", 15);
|
||||
|
||||
$config->set_int("forumMaxCharsPerPost", 512);
|
||||
|
||||
log_info("forum", "extension installed");
|
||||
}
|
||||
$database->create_table("forum_posts", "
|
||||
id SCORE_AIPK,
|
||||
thread_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
message TEXT,
|
||||
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
|
||||
");
|
||||
|
||||
$config->set_int("forum_version", 2);
|
||||
$config->set_int("forumTitleSubString", 25);
|
||||
$config->set_int("forumThreadsPerPage", 15);
|
||||
$config->set_int("forumPostsPerPage", 15);
|
||||
|
||||
$config->set_int("forumMaxCharsPerPost", 512);
|
||||
|
||||
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) {
|
||||
|
@ -159,6 +159,11 @@ class IPBan extends Extension {
|
||||
$database->execute("ALTER TABLE bans CHANGE ip ip VARCHAR(15)");
|
||||
$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 {{{
|
||||
|
@ -3,6 +3,10 @@ class LogDatabaseTest extends SCoreWebTestCase {
|
||||
function testLog() {
|
||||
$this->log_in_as_admin();
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class NotATag extends Extension {
|
||||
public function get_priority() {return 30;} // before ImageUploadEvent and tag_history
|
||||
|
||||
public function onImageAddition(ImageAdditionEvent $event) {
|
||||
$this->scan($event->image->tags);
|
||||
$this->scan($event->image->get_tag_array());
|
||||
}
|
||||
|
||||
public function onTagSet(TagSetEvent $event) {
|
||||
|
@ -27,6 +27,7 @@ class Notes extends Extension {
|
||||
width INTEGER NOT NULL,
|
||||
note TEXT NOT NULL,
|
||||
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
|
||||
");
|
||||
|
||||
@ -36,6 +37,7 @@ class Notes extends Extension {
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
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
|
||||
");
|
||||
|
||||
@ -54,6 +56,7 @@ class Notes extends Extension {
|
||||
width INTEGER NOT NULL,
|
||||
note TEXT NOT NULL,
|
||||
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
|
||||
");
|
||||
|
||||
|
@ -61,7 +61,7 @@ class PrivMsg extends Extension {
|
||||
FOREIGN KEY (from_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");
|
||||
}
|
||||
|
||||
@ -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 from_id not in (select id from users);");
|
||||
$database->Execute("ALTER TABLE private_message
|
||||
ADD CONSTRAINT foreign_private_message_from_id 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 (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
ADD FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;");
|
||||
$config->set_int("pm_version", 2);
|
||||
log_info("pm", "extension installed");
|
||||
}
|
||||
|
@ -35,12 +35,15 @@ class Pools extends Extension {
|
||||
description TEXT,
|
||||
date DATETIME NOT NULL,
|
||||
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", "
|
||||
pool_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", "
|
||||
id SCORE_AIPK,
|
||||
@ -50,7 +53,9 @@ class Pools extends Extension {
|
||||
images TEXT,
|
||||
count INTEGER NOT NULL DEFAULT 0,
|
||||
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
|
||||
|
@ -4,8 +4,8 @@
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* Description: A JSON interface to shimmie data [WARNING]
|
||||
* Documentation:
|
||||
* <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
|
||||
* <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><u>Usage:</b></u>
|
||||
* <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>
|
||||
|
@ -330,13 +330,13 @@ class Tag_History extends Extension {
|
||||
|
||||
// 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));
|
||||
if($entries == 0){
|
||||
/* We have no tag history for this image, so we will use the new_tags as the starting tags for this image. */
|
||||
if($entries == 0 && !empty($old_tags)) {
|
||||
/* 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 */
|
||||
$database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
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++;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class Wiki extends Extension {
|
||||
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
body TEXT NOT NULL,
|
||||
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);
|
||||
}
|
||||
|
@ -967,10 +967,9 @@ class Tag {
|
||||
// do nothing
|
||||
//}
|
||||
|
||||
$tags = array_map("trim", $tags);
|
||||
|
||||
$tag_array = array();
|
||||
foreach($tags as $tag) {
|
||||
$tag = trim($tag, ", \t\n\r\0\x0B");
|
||||
if(is_string($tag) && !empty($tag)) {
|
||||
$tag_array[] = $tag;
|
||||
}
|
||||
|
@ -907,12 +907,7 @@ $_load_start = microtime(true);
|
||||
function get_debug_info() {
|
||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||
|
||||
if(function_exists('memory_get_usage')) {
|
||||
$i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
|
||||
}
|
||||
else {
|
||||
$i_mem = "???";
|
||||
}
|
||||
$i_mem = sprintf("%5.2f", ((memory_get_peak_usage(true)+512)/1024)/1024);
|
||||
|
||||
if($config->get_string("commit_hash", "unknown") == "unknown"){
|
||||
$commit = "";
|
||||
@ -1276,7 +1271,7 @@ function _end_coverage() {
|
||||
$n = 0;
|
||||
$t = time();
|
||||
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) {
|
||||
$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 CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
||||
$database->Execute("ALTER TABLE comments ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE");
|
||||
$database->Execute("ALTER TABLE comments ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
||||
}
|
||||
|
||||
// FIXME: add foreign keys, bump to v3
|
||||
|
@ -57,7 +57,7 @@ class Upgrade extends Extension {
|
||||
$config->set_int("db_version", 10);
|
||||
|
||||
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");
|
||||
$config->set_bool("in_upgrade", false);
|
||||
|
@ -287,6 +287,11 @@ class UserPage extends Extension {
|
||||
$pass = $_POST['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);
|
||||
if(!is_null($duser)) {
|
||||
$user = $duser;
|
||||
|
@ -100,6 +100,8 @@ try {
|
||||
$page->display();
|
||||
|
||||
$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();
|
||||
ctx_log_endok();
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ function create_tables() { // {{{
|
||||
INDEX(owner_id),
|
||||
INDEX(width),
|
||||
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", "
|
||||
id SCORE_AIPK,
|
||||
@ -345,8 +345,8 @@ function create_tables() { // {{{
|
||||
INDEX(image_id),
|
||||
INDEX(tag_id),
|
||||
UNIQUE(image_id, tag_id),
|
||||
CONSTRAINT foreign_image_tags_image_id 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 (image_id) REFERENCES images(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)");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user