Installation is now made using CLI.
This commit is contained in:
parent
be797d2a17
commit
0e8359ba89
@ -13,15 +13,5 @@
|
|||||||
"railsphp/willpaginate": "dev-master",
|
"railsphp/willpaginate": "dev-master",
|
||||||
"railsphp/actsasversioned": "dev-master",
|
"railsphp/actsasversioned": "dev-master",
|
||||||
"michelf/php-markdown": "1.3.*"
|
"michelf/php-markdown": "1.3.*"
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"ApplicationInstaller\\": "install/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"post-install-cmd": [
|
|
||||||
"ApplicationInstaller\\CompileAssets::compile"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
37
db/seeds.php
37
db/seeds.php
@ -1,2 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* These seeds are the minimum required data for proper
|
||||||
|
* system funtionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rows for table_data
|
||||||
|
*/
|
||||||
|
$queries = [
|
||||||
|
'INSERT INTO `table_data` VALUES (\'posts\', 0)',
|
||||||
|
'INSERT INTO `table_data` VALUES (\'users\', 1)',
|
||||||
|
'INSERT INTO `table_data` VALUES (\'non-explicit_posts\', 0)'
|
||||||
|
];
|
||||||
|
foreach ($queries as $query) {
|
||||||
|
Rails\ActiveRecord\ActiveRecord::connection()->executeSql($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job tasks rows
|
||||||
|
*/
|
||||||
|
JobTask::create([
|
||||||
|
'task_type' => 'external_data_search',
|
||||||
|
'data_as_json' => '{}',
|
||||||
|
'status' => 'pending',
|
||||||
|
'repeat_count' => -1
|
||||||
|
]);
|
||||||
|
JobTask::create([
|
||||||
|
'task_type' => "upload_batch_posts",
|
||||||
|
'data_as_json' => '{}',
|
||||||
|
'status' => "pending",
|
||||||
|
'repeat_count' => -1
|
||||||
|
]);
|
||||||
|
JobTask::create([
|
||||||
|
'task_type' => "periodic_maintenance",
|
||||||
|
'data_as_json' => '{}',
|
||||||
|
'status' => "pending",
|
||||||
|
'repeat_count' => -1
|
||||||
|
]);
|
||||||
|
130
install.php
Executable file
130
install.php
Executable file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
use Zend\Console\ColorInterface as Color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot Rails
|
||||||
|
*/
|
||||||
|
require __DIR__ . '/config/boot.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create console and migrator
|
||||||
|
*/
|
||||||
|
$c = new Rails\Console\Console();
|
||||||
|
$migrator = new Rails\ActiveRecord\Migration\Migrator();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show splash
|
||||||
|
*/
|
||||||
|
$txColor = Color::LIGHT_WHITE;
|
||||||
|
$bgColor = Color::GREEN;
|
||||||
|
$c->put();
|
||||||
|
$c->put("====================", $txColor, $bgColor);
|
||||||
|
$c->put(" MyImouto installer ", $txColor, $bgColor);
|
||||||
|
$c->put("====================", $txColor, $bgColor);
|
||||||
|
$c->put();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data for admin account
|
||||||
|
*/
|
||||||
|
$c->put("Admin account", null, Color::BLUE);
|
||||||
|
$c->put("Please enter a name and password for the admin account.");
|
||||||
|
$c->write("Note: ", Color::RED);
|
||||||
|
$c->put("the password will be shown.");
|
||||||
|
list($adminName, $adminPass) = getAdminData($c);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database
|
||||||
|
*/
|
||||||
|
$c->put("Database", null, Color::BLUE);
|
||||||
|
|
||||||
|
# Install database
|
||||||
|
$c->write("Creating tables......");
|
||||||
|
$migrator->loadSchema();
|
||||||
|
$c->put('done');
|
||||||
|
|
||||||
|
# Run migrations
|
||||||
|
$c->write("Running migrations...");
|
||||||
|
$migrator->run();
|
||||||
|
$c->put('done');
|
||||||
|
|
||||||
|
# Run seeds
|
||||||
|
$c->write("Seeding..............");
|
||||||
|
$migrator->runSeeds();
|
||||||
|
$c->put('done');
|
||||||
|
|
||||||
|
# Create user in database
|
||||||
|
$c->write("Creating admin account...");
|
||||||
|
Rails\ActiveRecord\ActiveRecord::connection()->executeSql(
|
||||||
|
'INSERT INTO users (created_at, name, password_hash, level, show_advanced_editing) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
date('Y-m-d H:i:s'), $adminName, User::sha1($adminPass), 50, 1
|
||||||
|
);
|
||||||
|
Rails\ActiveRecord\ActiveRecord::connection()->executeSql(
|
||||||
|
'INSERT INTO user_blacklisted_tags VALUES (?, ?)',
|
||||||
|
1, implode("\r\n", CONFIG()->default_blacklists)
|
||||||
|
);
|
||||||
|
$c->put("done");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile assets
|
||||||
|
*/
|
||||||
|
$c->put("\n");
|
||||||
|
$c->put("Compiling assets", null, Color::BLUE);
|
||||||
|
|
||||||
|
# Set console to assets
|
||||||
|
Rails::assets()->setConsole($c);
|
||||||
|
|
||||||
|
# Compile files
|
||||||
|
Rails::assets()->compileAll();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create /public/data folders
|
||||||
|
*/
|
||||||
|
$c->put("\n");
|
||||||
|
$c->write("Creating /public/data folders...");
|
||||||
|
$dataPath = Rails::publicPath() . '/data';
|
||||||
|
$dirs = [
|
||||||
|
'avatars',
|
||||||
|
'image',
|
||||||
|
'import',
|
||||||
|
'jpeg',
|
||||||
|
'preview',
|
||||||
|
'sample'
|
||||||
|
];
|
||||||
|
if (!is_dir($dataPath)) {
|
||||||
|
mkdir($dataPath);
|
||||||
|
}
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
$path = $dataPath . '/' . $dir;
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$c->put("done");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish
|
||||||
|
*/
|
||||||
|
$c->put();
|
||||||
|
$c->put("Installation finished.", Color::GREEN);
|
||||||
|
$c->put("You may delete this install.php file.");
|
||||||
|
$c->put();
|
||||||
|
|
||||||
|
|
||||||
|
function getAdminData($c)
|
||||||
|
{
|
||||||
|
$adminName = $c->input("Account name: ");
|
||||||
|
$adminPass = $c->input("Password: ");
|
||||||
|
|
||||||
|
if ($c->confirm("Is the information correct? (y/n) ")) {
|
||||||
|
return [$adminName, $adminPass];
|
||||||
|
} else {
|
||||||
|
$c->put();
|
||||||
|
return getAdminData($c);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller\Action;
|
|
||||||
|
|
||||||
abstract class Base
|
|
||||||
{
|
|
||||||
abstract public function commit();
|
|
||||||
|
|
||||||
protected function renameIndex()
|
|
||||||
{
|
|
||||||
rename(\Rails::publicPath() . '/index', \Rails::publicPath() . '/index.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function root()
|
|
||||||
{
|
|
||||||
return __DIR__ . '/../..';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller\Action;
|
|
||||||
|
|
||||||
use Rails\ActiveRecord\ActiveRecord;
|
|
||||||
use ApplicationInstaller\Exception;
|
|
||||||
use User;
|
|
||||||
use JobTask;
|
|
||||||
|
|
||||||
class Install extends Base
|
|
||||||
{
|
|
||||||
private $adminName;
|
|
||||||
|
|
||||||
private $adminPassword;
|
|
||||||
|
|
||||||
public function __construct($adminName, $adminPassword)
|
|
||||||
{
|
|
||||||
$this->adminName = $adminName;
|
|
||||||
$this->adminPassword = $adminPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function commit()
|
|
||||||
{
|
|
||||||
$this->createTables();
|
|
||||||
$this->insertData();
|
|
||||||
$this->setLoginCookies();
|
|
||||||
$this->createPublicDataDirs();
|
|
||||||
$this->renameIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createTables()
|
|
||||||
{
|
|
||||||
$queries = require $this->root() . '/structure.php';
|
|
||||||
|
|
||||||
foreach ($queries as $query) {
|
|
||||||
ActiveRecord::connection()->executeSql($query);
|
|
||||||
if ($err = ActiveRecord::lastError()) {
|
|
||||||
throw new Exception\RuntimeException(
|
|
||||||
"Error when creating tables.\nQuery:\n$query\nError info:\n" . var_export($err, true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function insertData()
|
|
||||||
{
|
|
||||||
|
|
||||||
# Create admin user
|
|
||||||
ActiveRecord::connection()->executeSql(
|
|
||||||
'INSERT INTO users (created_at, name, password_hash, level, show_advanced_editing) VALUES (?, ?, ?, ?, ?)',
|
|
||||||
date('Y-m-d H:i:s'), $this->adminName, User::sha1($this->adminPassword), 50, 1
|
|
||||||
);
|
|
||||||
|
|
||||||
ActiveRecord::connection()->executeSql(
|
|
||||||
'INSERT INTO user_blacklisted_tags VALUES (?, ?)',
|
|
||||||
1, implode("\r\n", CONFIG()->default_blacklists)
|
|
||||||
);
|
|
||||||
|
|
||||||
# Queries for table_data
|
|
||||||
$queries = [
|
|
||||||
'INSERT INTO `table_data` VALUES (\'posts\', 0)',
|
|
||||||
'INSERT INTO `table_data` VALUES (\'users\', 1)',
|
|
||||||
'INSERT INTO `table_data` VALUES (\'non-explicit_posts\', 0)'
|
|
||||||
];
|
|
||||||
foreach ($queries as $query) {
|
|
||||||
ActiveRecord::connection()->executeSql($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create JobTasks
|
|
||||||
JobTask::create([
|
|
||||||
'task_type' => 'external_data_search',
|
|
||||||
'data_as_json' => '{}',
|
|
||||||
'status' => 'pending',
|
|
||||||
'repeat_count' => -1
|
|
||||||
]);
|
|
||||||
JobTask::create([
|
|
||||||
'task_type' => "upload_batch_posts",
|
|
||||||
'data_as_json' => '{}',
|
|
||||||
'status' => "pending",
|
|
||||||
'repeat_count' => -1
|
|
||||||
]);
|
|
||||||
JobTask::create([
|
|
||||||
'task_type' => "periodic_maintenance",
|
|
||||||
'data_as_json' => '{}',
|
|
||||||
'status' => "pending",
|
|
||||||
'repeat_count' => -1
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setLoginCookies()
|
|
||||||
{
|
|
||||||
setcookie('login', $this->adminName, time() + 31556926, '/');
|
|
||||||
setcookie('pass_hash', User::sha1($this->adminPassword), time() + 31556926, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createPublicDataDirs()
|
|
||||||
{
|
|
||||||
$dataPath = \Rails::publicPath() . '/data';
|
|
||||||
|
|
||||||
$dirs = [
|
|
||||||
'avatars',
|
|
||||||
'export',
|
|
||||||
'image',
|
|
||||||
'import',
|
|
||||||
'jpeg',
|
|
||||||
'preview',
|
|
||||||
'sample'
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!is_dir($dataPath)) {
|
|
||||||
mkdir($dataPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
$path = $dataPath . '/' . $dir;
|
|
||||||
|
|
||||||
if (!is_dir($path)) {
|
|
||||||
mkdir($path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,258 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller\Action;
|
|
||||||
|
|
||||||
use Rails\ActiveRecord\ActiveRecord;
|
|
||||||
use User;
|
|
||||||
use Post;
|
|
||||||
use History;
|
|
||||||
use HistoryChange;
|
|
||||||
use Tag;
|
|
||||||
use Pool;
|
|
||||||
use PoolPost;
|
|
||||||
use Moebooru;
|
|
||||||
|
|
||||||
class Update extends Base
|
|
||||||
{
|
|
||||||
public function commit()
|
|
||||||
{
|
|
||||||
$this->executeQueries();
|
|
||||||
$this->createHistory();
|
|
||||||
$this->renameIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function executeQueries()
|
|
||||||
{
|
|
||||||
$queries = [
|
|
||||||
"ALTER TABLE `table_data` CHANGE `name` `name` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL",
|
|
||||||
"UPDATE `table_data` SET `name` = 'non-explicit-posts' WHERE `table_data`.`name` = 'non-explici' LIMIT 1",
|
|
||||||
|
|
||||||
# Post tag histories table
|
|
||||||
"CREATE TABLE `post_tag_histories` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`tags` text NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`ip_addr` varchar(39) NOT NULL,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8",
|
|
||||||
|
|
||||||
"CREATE TABLE `histories` (
|
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` DATETIME NOT NULL,
|
|
||||||
`user_id` int(11) DEFAULT NULL,
|
|
||||||
`group_by_id` int(11) NOT NULL,
|
|
||||||
`group_by_table` varchar(12) NOT NULL,
|
|
||||||
`aux_as_json` text DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB",
|
|
||||||
|
|
||||||
"CREATE TABLE `history_changes` (
|
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`column_name` char(24) NOT NULL,
|
|
||||||
`remote_id` bigint(20) NOT NULL,
|
|
||||||
`table_name` char(24) NOT NULL,
|
|
||||||
`value` text,
|
|
||||||
`history_id` bigint(20) unsigned NOT NULL,
|
|
||||||
`previous_id` bigint(20) DEFAULT NULL,
|
|
||||||
`value_index` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `previous_id` (`previous_id`)
|
|
||||||
) ENGINE=InnoDB",
|
|
||||||
|
|
||||||
"ALTER TABLE history_changes ADD CONSTRAINT fk_history_changes__history_id FOREIGN KEY (history_id) REFERENCES histories(id) ON DELETE CASCADE",
|
|
||||||
|
|
||||||
"ALTER TABLE `pools_posts` ADD `active` BOOLEAN NOT NULL DEFAULT '1'",
|
|
||||||
|
|
||||||
"ALTER TABLE post_tag_histories ADD CONSTRAINT fk_post_tag_histories__post_id FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE",
|
|
||||||
|
|
||||||
"ALTER TABLE `pools` CHANGE `description` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL",
|
|
||||||
|
|
||||||
'DROP TRIGGER IF EXISTS `pools_posts_update_trg`',
|
|
||||||
'CREATE TRIGGER `pools_posts_update_trg` BEFORE UPDATE ON `pools_posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
IF (OLD.active <> NEW.active) THEN
|
|
||||||
IF (NEW.active) THEN
|
|
||||||
UPDATE pools SET post_count = post_count + 1 WHERE id = NEW.pool_id;
|
|
||||||
ELSE
|
|
||||||
UPDATE pools SET post_count = post_count - 1 WHERE id = NEW.pool_id;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
END',
|
|
||||||
|
|
||||||
# cached tags queries
|
|
||||||
"ALTER TABLE `posts` ADD `cached_tags` TEXT NOT NULL DEFAULT '' AFTER `source`",
|
|
||||||
|
|
||||||
"UPDATE posts SET cached_tags = (
|
|
||||||
SELECT GROUP_CONCAT(t.name SEPARATOR ' ')
|
|
||||||
FROM posts_tags pt
|
|
||||||
JOIN tags t ON pt.tag_id = t.id
|
|
||||||
WHERE
|
|
||||||
pt.post_id = posts.id
|
|
||||||
GROUP BY pt.post_id
|
|
||||||
)",
|
|
||||||
|
|
||||||
"UPDATE posts SET cached_tags = 'tagme' WHERE cached_tags = ''",
|
|
||||||
|
|
||||||
# Reset note versions table, which might already be empty.
|
|
||||||
"DELETE FROM note_versions",
|
|
||||||
"ALTER TABLE note_versions AUTO_INCREMENT = 1",
|
|
||||||
"INSERT INTO note_versions (SELECT 0, NOW(), NOW(), x, y, width, height, body, version, ip_addr, is_active, id, post_id, user_id FROM notes)"
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($queries as $query) {
|
|
||||||
ActiveRecord::connection()->executeSql($query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createHistory()
|
|
||||||
{
|
|
||||||
$user = User::where('level = ?', CONFIG()->user_levels['Admin'])->first();
|
|
||||||
if (!$user) {
|
|
||||||
$user = User::order('id ASC')->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Tag::all() as $tag) {
|
|
||||||
$history = History::create([
|
|
||||||
'group_by_id' => $tag->id,
|
|
||||||
'group_by_table' => 'tags',
|
|
||||||
'user_id' => $user->id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$attrs = [
|
|
||||||
'remote_id' => $tag->id,
|
|
||||||
'table_name' => 'tags',
|
|
||||||
'history_id' => $history->id
|
|
||||||
];
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'tag_type',
|
|
||||||
'value' => $tag->tag_type
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if ($tag->is_ambiguous)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_ambiguous',
|
|
||||||
'value' => 1,
|
|
||||||
], $attrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (PoolPost::all() as $pp) {
|
|
||||||
$history = History::create([
|
|
||||||
'group_by_id' => $pp->pool->id,
|
|
||||||
'group_by_table' => 'pools',
|
|
||||||
'user_id' => $pp->post->user_id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$attrs = [
|
|
||||||
'remote_id' => $pp->id,
|
|
||||||
'table_name' => 'pools_posts',
|
|
||||||
'history_id' => $history->id
|
|
||||||
];
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'sequence',
|
|
||||||
'value' => $pp->sequence
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'active',
|
|
||||||
'value' => true
|
|
||||||
], $attrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Pool::all() as $pool) {
|
|
||||||
$history = History::create([
|
|
||||||
'group_by_id' => $pool->id,
|
|
||||||
'group_by_table' => 'pools',
|
|
||||||
'user_id' => $pool->user_id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$attrs = [
|
|
||||||
'remote_id' => $pool->id,
|
|
||||||
'table_name' => 'pools',
|
|
||||||
'history_id' => $history->id
|
|
||||||
];
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'name',
|
|
||||||
'value' => $pool->name
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if ($pool->description)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'description',
|
|
||||||
'value' => $pool->description
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if (!$pool->is_public)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_public',
|
|
||||||
'value' => false
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if (!$pool->is_active)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_active',
|
|
||||||
'value' => false
|
|
||||||
], $attrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
$n = new Moebooru\Versioning\Versioning();
|
|
||||||
$n->import_note_history();
|
|
||||||
|
|
||||||
foreach (Post::all() as $post) {
|
|
||||||
$history = History::create([
|
|
||||||
'group_by_id' => $post->id,
|
|
||||||
'group_by_table' => 'posts',
|
|
||||||
'user_id' => $post->user->id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$attrs = [
|
|
||||||
'remote_id' => $post->id,
|
|
||||||
'table_name' => 'posts',
|
|
||||||
'history_id' => $history->id
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($post->source)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'source',
|
|
||||||
'value' => $post->source,
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'cached_tags',
|
|
||||||
'value' => $post->cached_tags
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'rating',
|
|
||||||
'value' => $post->rating,
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if (!$post->is_shown_in_index)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_shown_in_index',
|
|
||||||
'value' => 0,
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if ($post->is_rating_locked)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_rating_locked',
|
|
||||||
'value' => true,
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if ($post->is_note_locked)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'is_note_locked',
|
|
||||||
'value' => true,
|
|
||||||
], $attrs));
|
|
||||||
|
|
||||||
if ($post->parent_id)
|
|
||||||
HistoryChange::create(array_merge([
|
|
||||||
'column_name' => 'parent_id',
|
|
||||||
'value' => $post->parent_id,
|
|
||||||
], $attrs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller;
|
|
||||||
|
|
||||||
use Rails;
|
|
||||||
|
|
||||||
abstract class Base
|
|
||||||
{
|
|
||||||
static protected $instance;
|
|
||||||
|
|
||||||
static protected $step;
|
|
||||||
|
|
||||||
static public function instance()
|
|
||||||
{
|
|
||||||
if (!self::$instance) {
|
|
||||||
self::initialize();
|
|
||||||
}
|
|
||||||
return self::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
static protected function initialize()
|
|
||||||
{
|
|
||||||
Rails::loader()->addPath(dirname(__DIR__));
|
|
||||||
self::$instance = new Installer();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function root()
|
|
||||||
{
|
|
||||||
return dirname(__DIR__);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function request()
|
|
||||||
{
|
|
||||||
return Rails::application()->dispatcher()->request();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function refreshPage()
|
|
||||||
{
|
|
||||||
$urlFor = new Rails\Routing\UrlFor('root');
|
|
||||||
header('Location: ' . $urlFor->url());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function step()
|
|
||||||
{
|
|
||||||
return self::$step;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller;
|
|
||||||
|
|
||||||
use Composer\Script\Event;
|
|
||||||
use Rails;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Post-install script ran when installing the system
|
|
||||||
* using Composer to compile assets.
|
|
||||||
*/
|
|
||||||
class CompileAssets
|
|
||||||
{
|
|
||||||
static public function compile(Event $event)
|
|
||||||
{
|
|
||||||
$railsRoot = __DIR__ . '/../..';
|
|
||||||
|
|
||||||
# Create temporary config/config.php file
|
|
||||||
$file = $railsRoot . '/config/config.php.example';
|
|
||||||
$target = $railsRoot . '/config/config.php';
|
|
||||||
copy($file, $target);
|
|
||||||
|
|
||||||
# Load rails
|
|
||||||
require $railsRoot . '/config/boot.php';
|
|
||||||
|
|
||||||
# Reset configuration to production, because Rails will load
|
|
||||||
# development by default when ran from CGI, and Assets won't
|
|
||||||
# set environment to production itself. Fix this later.
|
|
||||||
Rails::resetConfig('production');
|
|
||||||
|
|
||||||
# Load console
|
|
||||||
$console = new Console($event->getIO());
|
|
||||||
|
|
||||||
# Warn about compiling
|
|
||||||
$console->write("[Compiling assets]");
|
|
||||||
|
|
||||||
# Set console to assets
|
|
||||||
Rails::assets()->setConsole($console);
|
|
||||||
|
|
||||||
# Compile files
|
|
||||||
Rails::assets()->compileAll();
|
|
||||||
|
|
||||||
# Delete temporary config file.
|
|
||||||
unlink($target);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Console used by CompileAssets.
|
|
||||||
*/
|
|
||||||
class Console extends \Rails\Console\Console
|
|
||||||
{
|
|
||||||
private $io;
|
|
||||||
|
|
||||||
public function __construct($io)
|
|
||||||
{
|
|
||||||
$this->io = $io;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function write($message, $n = 1)
|
|
||||||
{
|
|
||||||
$this->io->write($message . str_repeat("\n", $n));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller\Exception;
|
|
||||||
|
|
||||||
interface ExceptionInterface
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller\Exception;
|
|
||||||
|
|
||||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ApplicationInstaller;
|
|
||||||
|
|
||||||
use Rails;
|
|
||||||
|
|
||||||
class Installer extends Base
|
|
||||||
{
|
|
||||||
static private $ACCESS_DENIED_MESSAGE = "Access denied for %s";
|
|
||||||
|
|
||||||
static private $PLEASE_WAIT_MESSAGE = "Under maintenance - Please wait a little while";
|
|
||||||
|
|
||||||
private $newVersion = '1.0.6';
|
|
||||||
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
public function dispatch()
|
|
||||||
{
|
|
||||||
$this->loadConfig();
|
|
||||||
|
|
||||||
if ($this->request()->path() == '/') {
|
|
||||||
if (!$this->validateSafeIps()) {
|
|
||||||
# Client not allowed
|
|
||||||
if ($this->dataDirExists()) {
|
|
||||||
# Updating message
|
|
||||||
$this->renderMessage(self::$PLEASE_WAIT_MESSAGE);
|
|
||||||
} else {
|
|
||||||
# Installing message
|
|
||||||
$this->renderMessage(sprintf(self::$ACCESS_DENIED_MESSAGE, $_SERVER['REMOTE_ADDR']));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
# Client allowed; serve forms/commit actions
|
|
||||||
try {
|
|
||||||
# To make things nice, check write permissions
|
|
||||||
# on some paths.
|
|
||||||
$this->checkWriteablePaths();
|
|
||||||
|
|
||||||
if ($this->request()->isGet()) {
|
|
||||||
# Serve forms
|
|
||||||
if ($this->dataDirExists()) {
|
|
||||||
# Update form
|
|
||||||
$this->renderUpdateForm();
|
|
||||||
} else {
|
|
||||||
# Install form
|
|
||||||
$this->renderInstallForm();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
# Commit actions
|
|
||||||
if ($this->dataDirExists()) {
|
|
||||||
# Update
|
|
||||||
$this->commitUpdate();
|
|
||||||
} else {
|
|
||||||
# Install
|
|
||||||
$this->commitInstall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception\ExceptionInterface $e) {
|
|
||||||
$this->renderMessage($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
# Load application and let it serve the request.
|
|
||||||
$appClass = get_class(Rails::application());
|
|
||||||
$appClass::dispatchRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function checkWriteablePaths()
|
|
||||||
{
|
|
||||||
$paths = [
|
|
||||||
'/log',
|
|
||||||
'/tmp',
|
|
||||||
'/public'
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
|
||||||
$fullpath = Rails::root() . $path;
|
|
||||||
if (!is_writable($fullpath)) {
|
|
||||||
throw new Exception\RuntimeException(
|
|
||||||
sprintf('File or path "%s" is not writeable; please make sure you have permissions', $fullpath)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function commitInstall()
|
|
||||||
{
|
|
||||||
$action = new Action\Install($_POST['admin_name'], $_POST['admin_password']);
|
|
||||||
$action->commit();
|
|
||||||
setcookie('notice', "Installation completed", time() + 10, '/');
|
|
||||||
header('Location: /post');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function commitUpdate()
|
|
||||||
{
|
|
||||||
$action = new Action\Update();
|
|
||||||
$action->commit();
|
|
||||||
setcookie('notice', "Upgrade completed", time() + 10, '/');
|
|
||||||
header('Location: /history');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function renderInstallForm()
|
|
||||||
{
|
|
||||||
$this->renderForm('install');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function renderUpdateForm()
|
|
||||||
{
|
|
||||||
$this->renderForm('update', ['newVersion' => $this->newVersion]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function renderForm($name, array $locals = [])
|
|
||||||
{
|
|
||||||
$file = $this->root() . '/views/' . $name . '.php';
|
|
||||||
|
|
||||||
$template = new Rails\ActionView\Template(['file' => $file], ['layout' => $this->layoutFile()], $locals);
|
|
||||||
$template->renderContent();
|
|
||||||
echo $template->content();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function renderMessage($message)
|
|
||||||
{
|
|
||||||
$template = new Rails\ActionView\Template(['lambda' => function() use ($message) {
|
|
||||||
echo $this->contentTag('div', $message, ['style' => 'text-align: center;margin-top: 85px;']);
|
|
||||||
}], ['layout' => $this->layoutFile()]);
|
|
||||||
$template->renderContent();
|
|
||||||
echo $template->content();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function installDatabase()
|
|
||||||
{
|
|
||||||
$installer = new DatabaseInstaller();
|
|
||||||
try {
|
|
||||||
$installer->install();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->renderError($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function installApp()
|
|
||||||
{
|
|
||||||
$installer = new AppInstaller();
|
|
||||||
try {
|
|
||||||
$installer->install();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->renderError($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function layoutFile()
|
|
||||||
{
|
|
||||||
return $this->root() . '/views/layout.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
private function dataDirExists()
|
|
||||||
{
|
|
||||||
return is_dir(Rails::publicPath() . '/data');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function validateSafeIps()
|
|
||||||
{
|
|
||||||
return in_array($_SERVER['REMOTE_ADDR'], $this->config['safe_ips']);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function loadConfig()
|
|
||||||
{
|
|
||||||
$this->config = require __DIR__ . '/../config.php';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'safe_ips' => [
|
|
||||||
'127.0.0.1',
|
|
||||||
'::1',
|
|
||||||
]
|
|
||||||
];
|
|
@ -1,521 +0,0 @@
|
|||||||
<?php
|
|
||||||
return array (
|
|
||||||
0 => 'CREATE TABLE IF NOT EXISTS `artists` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`alias_id` int(11) DEFAULT NULL,
|
|
||||||
`group_id` int(11) DEFAULT NULL,
|
|
||||||
`name` varchar(128) NOT NULL,
|
|
||||||
`updated_at` datetime NOT NULL,
|
|
||||||
`updater_id` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_artists__updater_id` (`updater_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
1 => 'CREATE TABLE IF NOT EXISTS `artists_urls` (
|
|
||||||
`artist_id` int(11) NOT NULL,
|
|
||||||
`url` varchar(256) NOT NULL,
|
|
||||||
`normalized_url` varchar(256) NOT NULL,
|
|
||||||
KEY `artist_id` (`artist_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
2 => 'CREATE TABLE IF NOT EXISTS `bans` (
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`reason` text NOT NULL,
|
|
||||||
`expires_at` datetime NOT NULL,
|
|
||||||
`banned_by` int(11) NOT NULL,
|
|
||||||
`old_level` int(11) NOT NULL,
|
|
||||||
KEY `user_id` (`user_id`),
|
|
||||||
KEY `fk_bans__banned_by` (`banned_by`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
3 => 'CREATE TABLE IF NOT EXISTS `batch_uploads` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`ip` varchar(15) NOT NULL,
|
|
||||||
`url` varchar(512) NOT NULL,
|
|
||||||
`tags` text NOT NULL,
|
|
||||||
`active` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`status` varchar(32) NOT NULL DEFAULT \'pending\',
|
|
||||||
`created_at` datetime DEFAULT NULL,
|
|
||||||
`data_as_json` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_batch_uploads__user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
4 => 'CREATE TABLE IF NOT EXISTS `comments` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`ip_addr` varchar(16) NOT NULL,
|
|
||||||
`created_at` datetime DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`updated_at` datetime NOT NULL,
|
|
||||||
`is_spam` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_comments__user_id` (`user_id`),
|
|
||||||
KEY `fk_comments__post_id` (`post_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
5 => 'CREATE TABLE IF NOT EXISTS `dmails` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`from_id` int(11) NOT NULL,
|
|
||||||
`to_id` int(11) NOT NULL,
|
|
||||||
`title` text NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`created_at` datetime DEFAULT NULL,
|
|
||||||
`has_seen` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`parent_id` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `from_id` (`from_id`,`to_id`),
|
|
||||||
KEY `fk_dmails__to_id` (`to_id`),
|
|
||||||
KEY `fk_dmails__parent_id` (`parent_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
6 => 'CREATE TABLE IF NOT EXISTS `favorites` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `post_id__user_id` (`post_id`,`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
7 => 'CREATE TABLE IF NOT EXISTS `flagged_post_details` (
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`reason` varchar(512) NOT NULL,
|
|
||||||
`is_resolved` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
KEY `post_id` (`post_id`),
|
|
||||||
KEY `fk_flag_post_details__user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
8 => 'CREATE TABLE IF NOT EXISTS `forum_posts` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`updated_at` datetime NOT NULL,
|
|
||||||
`title` text NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`creator_id` int(11) NOT NULL,
|
|
||||||
`parent_id` int(11) DEFAULT NULL,
|
|
||||||
`last_updated_by` int(11) DEFAULT NULL,
|
|
||||||
`is_sticky` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`response_count` int(11) NOT NULL DEFAULT \'0\',
|
|
||||||
`is_locked` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`text_search_index` text,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_forum_posts__creator_id` (`creator_id`),
|
|
||||||
KEY `fk_forum_posts__last_updated_by` (`last_updated_by`),
|
|
||||||
KEY `fk_forum_posts__parent_id` (`parent_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
9 => 'CREATE TABLE IF NOT EXISTS `histories` (
|
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`user_id` int(11) DEFAULT NULL,
|
|
||||||
`group_by_id` int(11) NOT NULL,
|
|
||||||
`group_by_table` varchar(12) NOT NULL,
|
|
||||||
`aux_as_json` text,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
10 => 'CREATE TABLE IF NOT EXISTS `history_changes` (
|
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`column_name` char(24) NOT NULL,
|
|
||||||
`remote_id` bigint(20) NOT NULL,
|
|
||||||
`table_name` char(24) NOT NULL,
|
|
||||||
`value` text,
|
|
||||||
`history_id` bigint(20) unsigned NOT NULL,
|
|
||||||
`previous_id` bigint(20) DEFAULT NULL,
|
|
||||||
`value_index` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `previous_id` (`previous_id`),
|
|
||||||
KEY `fk_history_changes__history_id` (`history_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
11 => 'CREATE TABLE IF NOT EXISTS `ip_bans` (
|
|
||||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`expires_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`ip_addr` varchar(15) NOT NULL,
|
|
||||||
`reason` text NOT NULL,
|
|
||||||
`banned_by` int(11) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_ip_bans__banned_by` (`banned_by`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
12 => 'CREATE TABLE IF NOT EXISTS `job_tasks` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`task_type` varchar(64) NOT NULL,
|
|
||||||
`data_as_json` text,
|
|
||||||
`status` varchar(64) NOT NULL,
|
|
||||||
`status_message` text,
|
|
||||||
`repeat_count` int(11) NOT NULL DEFAULT \'0\',
|
|
||||||
`created_at` datetime DEFAULT NULL,
|
|
||||||
`updated_at` datetime DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
13 => 'CREATE TABLE IF NOT EXISTS `notes` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`updated_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`x` int(11) NOT NULL,
|
|
||||||
`y` int(11) NOT NULL,
|
|
||||||
`width` int(11) NOT NULL,
|
|
||||||
`height` int(11) NOT NULL,
|
|
||||||
`ip_addr` varchar(64) NOT NULL,
|
|
||||||
`version` int(11) NOT NULL DEFAULT \'1\',
|
|
||||||
`is_active` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `post_id` (`post_id`),
|
|
||||||
KEY `user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
14 => 'CREATE TABLE IF NOT EXISTS `note_versions` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`updated_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`x` int(11) NOT NULL,
|
|
||||||
`y` int(11) NOT NULL,
|
|
||||||
`width` int(11) NOT NULL,
|
|
||||||
`height` int(11) NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`version` int(11) NOT NULL,
|
|
||||||
`ip_addr` varchar(64) NOT NULL,
|
|
||||||
`is_active` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`note_id` int(11) NOT NULL,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `user_id` (`user_id`),
|
|
||||||
KEY `fk_note_versions__note_id` (`note_id`),
|
|
||||||
KEY `fk_note_versions__post_id` (`post_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
15 => 'CREATE TABLE IF NOT EXISTS `pools` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(128) NOT NULL,
|
|
||||||
`description` text NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`is_active` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`updated_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`post_count` int(3) NOT NULL DEFAULT \'0\',
|
|
||||||
`is_public` binary(1) NOT NULL DEFAULT \'1\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `pool_name` (`name`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
16 => 'CREATE TABLE IF NOT EXISTS `pools_posts` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`pool_id` int(11) NOT NULL,
|
|
||||||
`sequence` varchar(16) NOT NULL,
|
|
||||||
`next_post_id` int(11) DEFAULT NULL,
|
|
||||||
`prev_post_id` int(11) DEFAULT NULL,
|
|
||||||
`active` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `post_id` (`post_id`),
|
|
||||||
KEY `fk_pools_posts__next_post_id` (`next_post_id`),
|
|
||||||
KEY `fk_pools_posts__prev_post_id` (`prev_post_id`),
|
|
||||||
KEY `fk_pools_posts__pool_id` (`pool_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
17 => 'DROP TRIGGER IF EXISTS `pools_posts_insert_trg`',
|
|
||||||
18 => 'CREATE TRIGGER `pools_posts_insert_trg` BEFORE INSERT ON `pools_posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE pools SET post_count = post_count + 1 WHERE id = NEW.pool_id;
|
|
||||||
END',
|
|
||||||
19 => 'DROP TRIGGER IF EXISTS `pools_posts_update_trg`',
|
|
||||||
20 => 'CREATE TRIGGER `pools_posts_update_trg` BEFORE UPDATE ON `pools_posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
IF (OLD.active <> NEW.active) THEN
|
|
||||||
IF (NEW.active) THEN
|
|
||||||
UPDATE pools SET post_count = post_count + 1 WHERE id = NEW.pool_id;
|
|
||||||
ELSE
|
|
||||||
UPDATE pools SET post_count = post_count - 1 WHERE id = NEW.pool_id;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
END',
|
|
||||||
|
|
||||||
|
|
||||||
'DROP TRIGGER IF EXISTS `pools_posts_delete_trg`',
|
|
||||||
25 => 'CREATE TRIGGER `pools_posts_delete_trg` BEFORE DELETE ON `pools_posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE pools SET post_count = post_count - 1 WHERE id = OLD.pool_id;
|
|
||||||
END',
|
|
||||||
26 => 'CREATE TABLE IF NOT EXISTS `posts` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`user_id` int(11) DEFAULT NULL,
|
|
||||||
`ip_addr` varchar(64) NOT NULL,
|
|
||||||
`file_size` int(11) NOT NULL,
|
|
||||||
`md5` varchar(32) NOT NULL,
|
|
||||||
`last_commented_at` datetime DEFAULT NULL,
|
|
||||||
`file_ext` varchar(4) NOT NULL,
|
|
||||||
`last_noted_at` datetime DEFAULT NULL,
|
|
||||||
`source` varchar(249) DEFAULT NULL,
|
|
||||||
`cached_tags` text NOT NULL,
|
|
||||||
`width` int(11) NOT NULL,
|
|
||||||
`height` int(11) NOT NULL,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`rating` char(1) NOT NULL DEFAULT \'q\',
|
|
||||||
`preview_width` int(3) NOT NULL,
|
|
||||||
`preview_height` int(3) NOT NULL,
|
|
||||||
`actual_preview_width` int(3) NOT NULL,
|
|
||||||
`actual_preview_height` int(3) NOT NULL,
|
|
||||||
`score` int(3) NOT NULL DEFAULT \'0\',
|
|
||||||
`is_shown_in_index` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`is_held` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`has_children` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`status` enum(\'deleted\',\'flagged\',\'pending\',\'active\') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT \'active\',
|
|
||||||
`is_rating_locked` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`is_note_locked` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`parent_id` int(11) DEFAULT NULL,
|
|
||||||
`sample_width` int(5) DEFAULT NULL,
|
|
||||||
`sample_height` int(5) DEFAULT NULL,
|
|
||||||
`sample_size` int(11) DEFAULT NULL,
|
|
||||||
`index_timestamp` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`jpeg_width` int(11) DEFAULT NULL,
|
|
||||||
`jpeg_height` int(11) DEFAULT NULL,
|
|
||||||
`jpeg_size` int(11) DEFAULT NULL,
|
|
||||||
`random` int(11) NOT NULL,
|
|
||||||
`approver_id` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `md5` (`md5`),
|
|
||||||
KEY `fk_posts__parent_id` (`parent_id`),
|
|
||||||
KEY `posts__approver_id` (`approver_id`),
|
|
||||||
KEY `fk_posts__user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
27 => 'DROP TRIGGER IF EXISTS `trg_posts__insert`',
|
|
||||||
28 => 'CREATE TRIGGER `trg_posts__insert` AFTER INSERT ON `posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE table_data SET row_count = row_count + 1 WHERE name = \'posts\';
|
|
||||||
END',
|
|
||||||
29 => 'DROP TRIGGER IF EXISTS `trg_posts__delete`',
|
|
||||||
30 => 'CREATE TRIGGER `trg_posts__delete` AFTER DELETE ON `posts`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE table_data SET row_count = row_count - 1 WHERE name = \'posts\';
|
|
||||||
END',
|
|
||||||
31 => 'CREATE TABLE IF NOT EXISTS `posts_tags` (
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`tag_id` int(11) NOT NULL,
|
|
||||||
UNIQUE KEY `post_id` (`post_id`,`tag_id`),
|
|
||||||
KEY `fk_posts_tags__post_id` (`post_id`),
|
|
||||||
KEY `fk_posts_tags__tag_id` (`tag_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
32 => 'DROP TRIGGER IF EXISTS `trg_posts_tags__insert`',
|
|
||||||
33 => 'CREATE TRIGGER `trg_posts_tags__insert` AFTER INSERT ON `posts_tags`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE tags SET post_count = post_count + 1 WHERE tags.id = NEW.tag_id;
|
|
||||||
END',
|
|
||||||
34 => 'DROP TRIGGER IF EXISTS `trg_posts_tags__delete`',
|
|
||||||
35 => 'CREATE TRIGGER `trg_posts_tags__delete` AFTER DELETE ON `posts_tags`
|
|
||||||
FOR EACH ROW BEGIN
|
|
||||||
UPDATE tags SET post_count = post_count - 1 WHERE tags.id = OLD.tag_id;
|
|
||||||
END',
|
|
||||||
36 => 'CREATE TABLE IF NOT EXISTS `post_tag_histories` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`tags` text NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`ip_addr` varchar(39) NOT NULL,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_post_tag_histories__post_id` (`post_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
37 => 'CREATE TABLE IF NOT EXISTS `post_votes` (
|
|
||||||
`post_id` int(11) NOT NULL,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`score` int(1) DEFAULT \'0\',
|
|
||||||
`updated_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
UNIQUE KEY `post_id` (`post_id`,`user_id`),
|
|
||||||
KEY `score` (`score`),
|
|
||||||
KEY `fk_user_id__users_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
38 => 'CREATE TABLE IF NOT EXISTS `table_data` (
|
|
||||||
`name` varchar(32) NOT NULL,
|
|
||||||
`row_count` int(11) NOT NULL DEFAULT \'0\',
|
|
||||||
KEY `name` (`name`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
39 => 'CREATE TABLE IF NOT EXISTS `tags` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
|
||||||
`post_count` int(11) NOT NULL DEFAULT \'0\',
|
|
||||||
`cached_related` text,
|
|
||||||
`cached_related_expires_on` datetime DEFAULT NULL,
|
|
||||||
`tag_type` smallint(6) NOT NULL,
|
|
||||||
`is_ambiguous` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `name` (`name`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
40 => 'CREATE TABLE IF NOT EXISTS `tag_aliases` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(64) NOT NULL,
|
|
||||||
`alias_id` int(11) NOT NULL,
|
|
||||||
`is_pending` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`reason` varchar(128) DEFAULT NULL,
|
|
||||||
`creator_id` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `alias_unique` (`name`,`alias_id`),
|
|
||||||
KEY `name` (`name`),
|
|
||||||
KEY `fk_tag_aliases__alias_id` (`alias_id`),
|
|
||||||
KEY `fk_tag_aliases__creator_id` (`creator_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
41 => 'CREATE TABLE IF NOT EXISTS `tag_implications` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`predicate_id` int(11) NOT NULL,
|
|
||||||
`consequent_id` int(11) NOT NULL,
|
|
||||||
`is_pending` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`reason` varchar(128) DEFAULT NULL,
|
|
||||||
`creator_id` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `predicate_id__consequent_id` (`predicate_id`,`consequent_id`),
|
|
||||||
KEY `fk_tag_implications__consequent_id` (`consequent_id`),
|
|
||||||
KEY `fk_tag_implications__creator_id` (`creator_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
42 => 'CREATE TABLE IF NOT EXISTS `tag_subscriptions` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`tag_query` text CHARACTER SET latin1 NOT NULL,
|
|
||||||
`cached_post_ids` text CHARACTER SET latin1 NOT NULL,
|
|
||||||
`name` varchar(32) CHARACTER SET latin1 NOT NULL,
|
|
||||||
`is_visible_on_profile` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `user_id` (`user_id`),
|
|
||||||
KEY `name` (`name`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
43 => 'CREATE TABLE IF NOT EXISTS `users` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(32) NOT NULL,
|
|
||||||
`password_hash` varchar(40) DEFAULT NULL,
|
|
||||||
`created_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`level` int(11) NOT NULL DEFAULT \'20\',
|
|
||||||
`email` varchar(249) DEFAULT NULL,
|
|
||||||
`avatar_post_id` int(11) DEFAULT NULL,
|
|
||||||
`avatar_width` double DEFAULT NULL,
|
|
||||||
`avatar_height` double DEFAULT NULL,
|
|
||||||
`avatar_top` double DEFAULT NULL,
|
|
||||||
`avatar_bottom` double DEFAULT NULL,
|
|
||||||
`avatar_left` double DEFAULT NULL,
|
|
||||||
`avatar_right` double DEFAULT NULL,
|
|
||||||
`avatar_timestamp` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`my_tags` text,
|
|
||||||
`invite_count` int(11) NOT NULL DEFAULT \'0\',
|
|
||||||
`invited_by` int(11) DEFAULT NULL,
|
|
||||||
`show_samples` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`show_advanced_editing` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`pool_browse_mode` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`use_browser` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`always_resize_images` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`last_logged_in_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`last_forum_topic_read_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`last_comment_read_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`last_deleted_post_seen_at` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
|
|
||||||
`language` text,
|
|
||||||
`secondary_languages` text,
|
|
||||||
`receive_dmails` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`has_mail` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `name` (`name`),
|
|
||||||
KEY `fk_users__avatar_post_id` (`avatar_post_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
44 => 'CREATE TABLE IF NOT EXISTS `user_blacklisted_tags` (
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`tags` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
|
||||||
UNIQUE KEY `user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
45 => 'CREATE TABLE IF NOT EXISTS `user_records` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
||||||
`user_id` int(11) NOT NULL,
|
|
||||||
`reported_by` int(11) NOT NULL,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`is_positive` tinyint(1) NOT NULL DEFAULT \'1\',
|
|
||||||
`body` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `fk_user_records__user_id` (`user_id`),
|
|
||||||
KEY `fk_user_records__reported_by` (`reported_by`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
46 => 'CREATE TABLE IF NOT EXISTS `wiki_pages` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`updated_at` datetime NOT NULL,
|
|
||||||
`version` int(11) NOT NULL DEFAULT \'1\',
|
|
||||||
`title` varchar(64) NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`user_id` int(11) DEFAULT NULL,
|
|
||||||
`ip_addr` varchar(15) NOT NULL,
|
|
||||||
`is_locked` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`text_search_index` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `user_id` (`user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
47 => 'CREATE TABLE IF NOT EXISTS `wiki_page_versions` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created_at` datetime NOT NULL,
|
|
||||||
`updated_at` datetime NOT NULL,
|
|
||||||
`version` int(11) NOT NULL DEFAULT \'1\',
|
|
||||||
`title` varchar(64) NOT NULL,
|
|
||||||
`body` text NOT NULL,
|
|
||||||
`user_id` int(11) DEFAULT NULL,
|
|
||||||
`ip_addr` varchar(15) NOT NULL,
|
|
||||||
`wiki_page_id` int(11) NOT NULL,
|
|
||||||
`is_locked` tinyint(1) NOT NULL DEFAULT \'0\',
|
|
||||||
`text_search_index` text NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `user_id` (`user_id`),
|
|
||||||
KEY `fk_wiki_page_versions__wiki_page` (`wiki_page_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
|
|
||||||
48 => 'ALTER TABLE `artists`
|
|
||||||
ADD CONSTRAINT `fk_artists__updater_id` FOREIGN KEY (`updater_id`) REFERENCES `users` (`id`) ON DELETE SET NULL',
|
|
||||||
49 => 'ALTER TABLE `artists_urls`
|
|
||||||
ADD CONSTRAINT `fk_artists_urls__artist_id` FOREIGN KEY (`artist_id`) REFERENCES `artists` (`id`) ON DELETE CASCADE',
|
|
||||||
50 => 'ALTER TABLE `bans`
|
|
||||||
ADD CONSTRAINT `fk_bans__banned_by` FOREIGN KEY (`banned_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_bans__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
51 => 'ALTER TABLE `batch_uploads`
|
|
||||||
ADD CONSTRAINT `fk_batch_uploads__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
52 => 'ALTER TABLE `comments`
|
|
||||||
ADD CONSTRAINT `fk_comments__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_comments__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
53 => 'ALTER TABLE `dmails`
|
|
||||||
ADD CONSTRAINT `fk_dmails__from_id` FOREIGN KEY (`from_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_dmails__parent_id` FOREIGN KEY (`parent_id`) REFERENCES `dmails` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_dmails__to_id` FOREIGN KEY (`to_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
54 => 'ALTER TABLE `flagged_post_details`
|
|
||||||
ADD CONSTRAINT `fk_flag_post_details__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
|
|
||||||
ADD CONSTRAINT `fk_flag_post_det__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE',
|
|
||||||
55 => 'ALTER TABLE `forum_posts`
|
|
||||||
ADD CONSTRAINT `fk_forum_posts__creator_id` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_forum_posts__last_updated_by` FOREIGN KEY (`last_updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
|
|
||||||
ADD CONSTRAINT `fk_forum_posts__parent_id` FOREIGN KEY (`parent_id`) REFERENCES `forum_posts` (`id`) ON DELETE CASCADE',
|
|
||||||
56 => 'ALTER TABLE `history_changes`
|
|
||||||
ADD CONSTRAINT `fk_history_changes__history_id` FOREIGN KEY (`history_id`) REFERENCES `histories` (`id`) ON DELETE CASCADE',
|
|
||||||
57 => 'ALTER TABLE `ip_bans`
|
|
||||||
ADD CONSTRAINT `fk_ip_bans__banned_by` FOREIGN KEY (`banned_by`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
58 => 'ALTER TABLE `notes`
|
|
||||||
ADD CONSTRAINT `fk_notes__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE',
|
|
||||||
59 => 'ALTER TABLE `note_versions`
|
|
||||||
ADD CONSTRAINT `fk_note_versions__note_id` FOREIGN KEY (`note_id`) REFERENCES `notes` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_note_versions__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE',
|
|
||||||
60 => 'ALTER TABLE `pools_posts`
|
|
||||||
ADD CONSTRAINT `fk_pools_posts__next_post_id` FOREIGN KEY (`next_post_id`) REFERENCES `posts` (`id`) ON DELETE SET NULL,
|
|
||||||
ADD CONSTRAINT `fk_pools_posts__pool_id` FOREIGN KEY (`pool_id`) REFERENCES `pools` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_pools_posts__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_pools_posts__prev_post_id` FOREIGN KEY (`prev_post_id`) REFERENCES `posts` (`id`) ON DELETE SET NULL',
|
|
||||||
61 => 'ALTER TABLE `posts`
|
|
||||||
ADD CONSTRAINT `fk_parent_id__posts_id` FOREIGN KEY (`parent_id`) REFERENCES `posts` (`id`) ON DELETE SET NULL,
|
|
||||||
ADD CONSTRAINT `fk_posts__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
|
|
||||||
ADD CONSTRAINT `posts__approver_id` FOREIGN KEY (`approver_id`) REFERENCES `users` (`id`) ON DELETE SET NULL',
|
|
||||||
62 => 'ALTER TABLE `posts_tags`
|
|
||||||
ADD CONSTRAINT `fk_posts_tags__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_posts_tags__tag_id` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE',
|
|
||||||
63 => 'ALTER TABLE `post_tag_histories`
|
|
||||||
ADD CONSTRAINT `fk_post_tag_histories__post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE',
|
|
||||||
64 => 'ALTER TABLE `post_votes`
|
|
||||||
ADD CONSTRAINT `fk_post_id__posts_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_user_id__users_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
65 => 'ALTER TABLE `tag_aliases`
|
|
||||||
ADD CONSTRAINT `fk_tag_aliases__alias_id` FOREIGN KEY (`alias_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_tag_aliases__creator_id` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
66 => 'ALTER TABLE `tag_implications`
|
|
||||||
ADD CONSTRAINT `fk_consequent_id` FOREIGN KEY (`consequent_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_tag_implications__consequent_id` FOREIGN KEY (`consequent_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_tag_implications__creator_id` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_tag_implications__predicate_id` FOREIGN KEY (`predicate_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE',
|
|
||||||
67 => 'ALTER TABLE `user_blacklisted_tags`
|
|
||||||
ADD CONSTRAINT `fk_user_bl_tags__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
68 => 'ALTER TABLE `user_records`
|
|
||||||
ADD CONSTRAINT `fk_user_records__reported_by` FOREIGN KEY (`reported_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
|
||||||
ADD CONSTRAINT `fk_user_records__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE',
|
|
||||||
69 => 'ALTER TABLE `wiki_pages`
|
|
||||||
ADD CONSTRAINT `fk_wiki_pages__user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL',
|
|
||||||
70 => 'ALTER TABLE `wiki_page_versions`
|
|
||||||
ADD CONSTRAINT `fk_wiki_page_versions__wiki_page` FOREIGN KEY (`wiki_page_id`) REFERENCES `wiki_pages` (`id`) ON DELETE CASCADE',
|
|
||||||
);
|
|
@ -1,177 +0,0 @@
|
|||||||
<?php
|
|
||||||
if (function_exists('imagecreatetruecolor')) {
|
|
||||||
$gd2 = "Enabled";
|
|
||||||
$gd2_class = "good";
|
|
||||||
} else {
|
|
||||||
$gd2 = "Not enabled";
|
|
||||||
$gd2_class = "bad important";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists('Imagick', false)) {
|
|
||||||
$imagick = "Enabled";
|
|
||||||
$imagick_class = "good";
|
|
||||||
} else {
|
|
||||||
$imagick = "Not enabled";
|
|
||||||
$imagick_class = "bad";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (function_exists('curl_init')) {
|
|
||||||
$curl = "Enabled";
|
|
||||||
$curl_class = "good";
|
|
||||||
} else {
|
|
||||||
$curl = "Not enabled";
|
|
||||||
$curl_class = "bad";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists('PDO', false)) {
|
|
||||||
$pdo = "Enabled";
|
|
||||||
$pdo_class = "good";
|
|
||||||
} else {
|
|
||||||
$pdo = "Not enabled";
|
|
||||||
$pdo_class = "bad important";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
.center_box{
|
|
||||||
width:550px;
|
|
||||||
margin-left:auto;
|
|
||||||
margin-right:auto;
|
|
||||||
margin-bottom:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.good{color:#0f0;}
|
|
||||||
.okay{color:orange;}
|
|
||||||
.bad{color:red;}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="center_box"><h5>PHP.ini directives</h5></div>
|
|
||||||
<table class="form" style="margin-left:auto; margin-right:auto; width:550px; text-align:center;"><tbody>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th style="text-align:center; background-color:#555;">Name</th>
|
|
||||||
<th style="text-align:center; background-color:#555;">Current value</th>
|
|
||||||
<th style="text-align:center; background-color:#555;">Recommended min. value</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>memory_limit</th>
|
|
||||||
<td><?= ini_get('memory_limit') ?></td>
|
|
||||||
<td>128M+</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>post_max_size</th>
|
|
||||||
<td><?= ini_get('post_max_size') ?></td>
|
|
||||||
<td>6M</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>upload_max_filesize</th>
|
|
||||||
<td><?= ini_get('upload_max_filesize') ?></td>
|
|
||||||
<td>5M</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>GD2</th>
|
|
||||||
<td class="<?= $gd2_class ?>"><?= $gd2 ?></td>
|
|
||||||
<td>Must be enabled</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>PDO</th>
|
|
||||||
<td class="<?= $pdo_class ?>"><?= $pdo ?></td>
|
|
||||||
<td>Must be enabled</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>Imagick</th>
|
|
||||||
<td class="<?= $imagick_class ?>"><?= $imagick ?></td>
|
|
||||||
<td>Recommended</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>cURL</th>
|
|
||||||
<td class="<?= $curl_class ?>"><?= $curl ?></td>
|
|
||||||
<td>Should be enabled</td>
|
|
||||||
</tr>
|
|
||||||
</tbody></table>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="center_box"><h5>Admin account</h5></div>
|
|
||||||
<form action="" method="post" name="install_form">
|
|
||||||
<table class="form" style="margin-left:auto; margin-right:auto; width:550px;">
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<td width="60%"><input type="text" name="admin_name" id="name" style="width:65%;" /></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>Password</th>
|
|
||||||
<td><input type="password" name="admin_password" id="pw" style="width:65%;" /></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>Confirm password</th>
|
|
||||||
<td><input type="password" name="confirm_pw" id="pwc" style="width:65%;" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<label for="show_db_errors">Show database errors</label>
|
|
||||||
<p>Only enable if you have problems when creating the database.</p>
|
|
||||||
</th>
|
|
||||||
<td style="vertical-align:middle;">
|
|
||||||
<input type="hidden" name="show_db_errors" value="0" />
|
|
||||||
<input type="checkbox" name="show_db_errors" id="show_db_errors" value="1" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2"><input type="submit" value="Install" id="install-commit" /></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
(function($) {
|
|
||||||
$('#install-commit').on('click', function() {
|
|
||||||
if ($('.bad.important').length) {
|
|
||||||
notice('System requirements not met');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pw = $('#pw').val();
|
|
||||||
var pwc = $('#pwc').val();
|
|
||||||
var name = $('#name').val();
|
|
||||||
|
|
||||||
if ( name == '' ) {
|
|
||||||
notice("Enter a name");
|
|
||||||
$('#name').focus();
|
|
||||||
return false;
|
|
||||||
} else if ( name.length < 2 ) {
|
|
||||||
notice("Name must be at least 2 characters long");
|
|
||||||
return false;
|
|
||||||
} else if ( pw == '' ) {
|
|
||||||
notice("Enter a password");
|
|
||||||
$('#pw').focus();
|
|
||||||
return false;
|
|
||||||
} else if ( pw.length < 5 ) {
|
|
||||||
notice("Password must be at least 5 characters long");
|
|
||||||
$('#pw').focus();
|
|
||||||
return false;
|
|
||||||
} else if ( pw != pwc ) {
|
|
||||||
notice("Passwords don't match");
|
|
||||||
$('#pwc').focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var text = Cookie.get("notice");
|
|
||||||
if (text) {
|
|
||||||
notice(text, true);
|
|
||||||
Cookie.remove("notice");
|
|
||||||
}
|
|
||||||
})(jQuery);
|
|
||||||
</script>
|
|
@ -1,25 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title><?= CONFIG()->app_name ?></title>
|
|
||||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
|
|
||||||
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css">
|
|
||||||
<script src="/assets/application.js" type="text/javascript"></script>
|
|
||||||
<script src="/assets/moe-legacy/application.js" type="text/javascript"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="overlay-notice-container" id="notice-container" style="display: none;">
|
|
||||||
<table cellspacing="0" cellpadding="0"> <tbody>
|
|
||||||
<tr> <td>
|
|
||||||
<div id="notice">
|
|
||||||
</div>
|
|
||||||
</td> </tr>
|
|
||||||
</tbody> </table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
<h1 id="static-index-header" style="margin-bottom:50px;"><a href="/"><?= CONFIG()->app_name ?></a></h1>
|
|
||||||
<?= $this->content() ?>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||||||
<div class="center_box" style="text-align:center;">
|
|
||||||
<div class="center_box">
|
|
||||||
<h5 style="">Update to version <?= $this->newVersion ?></h5>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
<form action="" method="post" name="install_form">
|
|
||||||
<input type="hidden" name="update" value="1" />
|
|
||||||
<p style="margin:50px 0px;"><button style="font-size:2em;">Update</button></p>
|
|
||||||
<p style="margin:50px 0px;">(To show the installation form, the public/data folder must not exist)</p>
|
|
||||||
</form>
|
|
||||||
<p style="text-align:left;"></p>
|
|
||||||
</div>
|
|
@ -1,3 +0,0 @@
|
|||||||
<?php
|
|
||||||
require __DIR__ . '/../config/boot.php';
|
|
||||||
MyImouto\Application::dispatchRequest();
|
|
@ -1,5 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
require dirname(__DIR__) . '/config/boot.php';
|
require __DIR__ . '/../config/boot.php';
|
||||||
require dirname(__DIR__) . '/install/ApplicationInstaller/Base.php';
|
MyImouto\Application::dispatchRequest();
|
||||||
|
|
||||||
ApplicationInstaller\Base::instance()->dispatch();
|
|
||||||
|
Reference in New Issue
Block a user