half migration thing
This commit is contained in:
parent
7c83d5c78d
commit
82b15483c3
25 changed files with 612 additions and 24 deletions
3
cron.php
3
cron.php
|
@ -17,9 +17,6 @@ if (function_exists('posix_getuid')) {
|
||||||
// Define that this page won't require templating
|
// Define that this page won't require templating
|
||||||
define('SAKURA_NO_TPL', true);
|
define('SAKURA_NO_TPL', true);
|
||||||
|
|
||||||
// To prevent the CLI from showing up
|
|
||||||
define('SAKURA_CRON', true);
|
|
||||||
|
|
||||||
// Include components
|
// Include components
|
||||||
require_once 'sakura.php';
|
require_once 'sakura.php';
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ class Application extends \CLIFramework\Application
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
// Execute the original init function
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
|
// Add commands with class reference because the autoloader is retarded
|
||||||
|
$this->command('serve', Command\ServeCommand::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
libraries/Console/Command/ServeCommand.php
Normal file
23
libraries/Console/Command/ServeCommand.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the serve command controller.
|
||||||
|
*
|
||||||
|
* @package Sakura
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Sakura\Console\Command;
|
||||||
|
|
||||||
|
use CLIFramework\Command;
|
||||||
|
|
||||||
|
class ServeCommand extends Command
|
||||||
|
{
|
||||||
|
public function brief()
|
||||||
|
{
|
||||||
|
return 'Sets up a local development server.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
exec(PHP_BINDIR . '\php -S localhost:8000 -t ' . addslashes(ROOT . 'public/') . ' ' . addslashes(ROOT . 'server.php'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Sakura\Controllers;
|
namespace Sakura\Controllers;
|
||||||
|
|
||||||
use Sakura\Config;
|
use Sakura\Config;
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\Forum;
|
use Sakura\Forum;
|
||||||
use Sakura\Perms\Forum as ForumPerms;
|
use Sakura\Perms\Forum as ForumPerms;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Sakura\Controllers;
|
namespace Sakura\Controllers;
|
||||||
|
|
||||||
use Sakura\Config;
|
use Sakura\Config;
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\News;
|
use Sakura\News;
|
||||||
use Sakura\Template;
|
use Sakura\Template;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Sakura\Controllers;
|
namespace Sakura\Controllers;
|
||||||
|
|
||||||
use Sakura\Config;
|
use Sakura\Config;
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\News;
|
use Sakura\News;
|
||||||
use Sakura\Template;
|
use Sakura\Template;
|
||||||
use Sakura\User;
|
use Sakura\User;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Sakura\Controllers;
|
namespace Sakura\Controllers;
|
||||||
|
|
||||||
use Sakura\Config;
|
use Sakura\Config;
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\Rank;
|
use Sakura\Rank;
|
||||||
use Sakura\Template;
|
use Sakura\Template;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace Sakura\Forum;
|
namespace Sakura\Forum;
|
||||||
|
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\Users;
|
use Sakura\Users;
|
||||||
use Sakura\User;
|
use Sakura\User;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Sakura\Forum;
|
namespace Sakura\Forum;
|
||||||
|
|
||||||
use Sakura\Utils;
|
use Sakura\Utils;
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\User;
|
use Sakura\User;
|
||||||
use Sakura\BBcode;
|
use Sakura\BBcode;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace Sakura\Forum;
|
namespace Sakura\Forum;
|
||||||
|
|
||||||
use Sakura\Database;
|
|
||||||
use Sakura\DB;
|
use Sakura\DB;
|
||||||
use Sakura\Utils;
|
use Sakura\Utils;
|
||||||
|
|
||||||
|
|
27
libraries/Migration/IMigration.php
Normal file
27
libraries/Migration/IMigration.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the database migration interface.
|
||||||
|
*
|
||||||
|
* @package Sakura
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Sakura\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migration interface.
|
||||||
|
*
|
||||||
|
* @package Sakura
|
||||||
|
* @author Julian van de Groep <me@flash.moe>
|
||||||
|
*/
|
||||||
|
interface IMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Upgrade the database to a newer version.
|
||||||
|
*/
|
||||||
|
public function up();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downgrade the database to an older version.
|
||||||
|
*/
|
||||||
|
public function down();
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ class Utils
|
||||||
$errfile = str_replace(ROOT, '', $errfile);
|
$errfile = str_replace(ROOT, '', $errfile);
|
||||||
|
|
||||||
// Attempt to log the error to the database
|
// Attempt to log the error to the database
|
||||||
if (Database::$database !== null) {
|
if (DB::$db !== null) {
|
||||||
// Encode backtrace data
|
// Encode backtrace data
|
||||||
$backtrace = base64_encode(json_encode(debug_backtrace()));
|
$backtrace = base64_encode(json_encode(debug_backtrace()));
|
||||||
|
|
||||||
|
|
34
mahou
Normal file
34
mahou
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Sakura Mahou
|
||||||
|
* Get it, because Sakura is a magical girl in that one anime?
|
||||||
|
* Kill me.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Declare Namespace
|
||||||
|
namespace Sakura;
|
||||||
|
|
||||||
|
// Uses
|
||||||
|
use Sakura\Console\Application;
|
||||||
|
use GetOptionKit\Exception\InvalidOptionException;
|
||||||
|
|
||||||
|
// Define that this page won't require templating
|
||||||
|
define('SAKURA_NO_TPL', true);
|
||||||
|
|
||||||
|
// Include components
|
||||||
|
require_once 'sakura.php';
|
||||||
|
|
||||||
|
// Check if we're using console
|
||||||
|
if (php_sapi_name() === 'cli') {
|
||||||
|
// Create an instance
|
||||||
|
$console = new Application;
|
||||||
|
|
||||||
|
// Attempt to run
|
||||||
|
try {
|
||||||
|
$console->run($argv);
|
||||||
|
} catch (InvalidOptionException $e) {
|
||||||
|
die($e->getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo 'Why would you even try to run a console app through a browser?';
|
||||||
|
}
|
185
migrations/2015_03_08_104200_initial_structure.php
Normal file
185
migrations/2015_03_08_104200_initial_structure.php
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class InitialStructure implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Create API key table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}apikeys` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`owner` bigint(128) unsigned NOT NULL,
|
||||||
|
`apikey` varchar(32) COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create bans table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}bans` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`uid` bigint(128) unsigned NOT NULL,
|
||||||
|
`ip` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`type` tinyint(1) unsigned NOT NULL,
|
||||||
|
`timestamp` int(64) unsigned NOT NULL,
|
||||||
|
`bannedtill` int(64) unsigned NOT NULL,
|
||||||
|
`modid` bigint(128) unsigned NOT NULL,
|
||||||
|
`modip` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create config table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}config` (
|
||||||
|
`config_name` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`config_value` varchar(255) COLLATE utf8_bin NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create groups table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}groups` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`groupname` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`colour` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`description` text COLLATE utf8_bin NOT NULL',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create messages table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}messages` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`fromUser` bigint(128) unsigned NOT NULL,
|
||||||
|
`toUsers` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`readBy` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`deletedBy` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`date` int(64) unsigned NOT NULL,
|
||||||
|
`title` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`content` text COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create news table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}news` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`uid` bigint(128) unsigned NOT NULL,
|
||||||
|
`date` int(64) unsigned NOT NULL,
|
||||||
|
`title` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`content` text COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create registration codes table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}regcodes` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`code` varchar(32) COLLATE utf8_bin NOT NULL,
|
||||||
|
`created_by` bigint(128) unsigned NOT NULL,
|
||||||
|
`used_by` bigint(128) unsigned NOT NULL,
|
||||||
|
`key_used` tinyint(1) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create sessions table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}sessions` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`userip` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`useragent` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
||||||
|
`userid` bigint(128) unsigned NOT NULL,
|
||||||
|
`skey` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`started` int(64) unsigned NOT NULL,
|
||||||
|
`expire` int(64) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create users table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}users` (
|
||||||
|
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`username` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`username_clean` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`password_hash` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`password_salt` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`password_algo` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`password_iter` int(16) unsigned NOT NULL,
|
||||||
|
`password_chan` int(16) unsigned NOT NULL,
|
||||||
|
`password_new` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
||||||
|
`email` varchar(32) COLLATE utf8_bin NOT NULL,
|
||||||
|
`group_main` mediumint(4) unsigned NOT NULL,
|
||||||
|
`groups` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '0',
|
||||||
|
`name_colour` varchar(255) COLLATE utf8_bin DEFAULT NULL DEFAULT '[0]',
|
||||||
|
`register_ip` varchar(16) COLLATE utf8_bin NOT NULL,
|
||||||
|
`last_ip` varchar(16) COLLATE utf8_bin NOT NULL,
|
||||||
|
`usertitle` varchar(64) COLLATE utf8_bin NOT NULL,
|
||||||
|
`profile_md` text COLLATE utf8_bin,
|
||||||
|
`avatar_url` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`background_url` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`regdate` int(16) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`lastdate` int(16) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`lastunamechange` int(16) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`birthday` varchar(16) COLLATE utf8_bin DEFAULT NULL,
|
||||||
|
`profile_data` text COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `username_clean` (`username_clean`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create warnings table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}warnings` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`uid` bigint(128) unsigned NOT NULL,
|
||||||
|
`mod` bigint(128) unsigned NOT NULL,
|
||||||
|
`issued` int(64) unsigned NOT NULL,
|
||||||
|
`expire` int(64) unsigned NOT NULL,
|
||||||
|
`reason` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT 'Reason for the warning.',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop API keys table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}apikeys`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop bans table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}bans`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop config table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}config`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop groups table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}groups`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop messages table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}messages`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop news table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}news`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop registration codes table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}regcodes`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop sessions table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}sessions`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop users table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}users`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop warnings table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}warnings`")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
48
migrations/2015_04_01_172649_info_pages_and_nulls.php
Normal file
48
migrations/2015_04_01_172649_info_pages_and_nulls.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class InfoPagesAndNulls implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Add multi column to the groups table
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}groups` ADD `multi` tinyint(1) unsigned NOT NULL DEFAULT '0'")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create info pages table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}infopages` (
|
||||||
|
`shorthand` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`pagetitle` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`content` text COLLATE utf8_bin NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Make certain fields in the users table nullable
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `usertitle` DEFAULT NULL')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `avatar_url` DEFAULT NULL')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `background_url` DEFAULT NULL')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop the multi column from the groups table
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}groups` DROP COLUMN `multi`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop info pages table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}infopages`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Revert the null
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `usertitle` NOT NULL')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `avatar_url` NOT NULL')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `background_url` NOT NULL')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
32
migrations/2015_04_06_200332_rename_groups_to_ranks.php
Normal file
32
migrations/2015_04_06_200332_rename_groups_to_ranks.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class RenameGroupsToRanks implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Rename groups table to ranks
|
||||||
|
DB::prepare("RENAME TABLE `{prefix}groups` TO `{prefix}ranks`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Rename group* columns to rank* in the users table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `group_main` `rank_main` mediumint(4)')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `groups` `ranks` varchar(255)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Rename ranks table to groups
|
||||||
|
DB::prepare("RENAME TABLE `{prefix}ranks` TO `{prefix}groups`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Rename rank* columns to group* in the users table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `rank_main` `group_main` mediumint(4)')
|
||||||
|
->execute();
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `ranks` `groups` varchar(255)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
41
migrations/2015_04_12_015057_tenshi_and_profile_fields.php
Normal file
41
migrations/2015_04_12_015057_tenshi_and_profile_fields.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class TenshiAndProfileFields implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Create the profile fields table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}profilefields` (
|
||||||
|
`id` int(64) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`formtype` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`description` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`additional` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Create the tenshi table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}tenshi` (
|
||||||
|
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`uid` bigint(255) unsigned NOT NULL,
|
||||||
|
`startdate` int(64) unsigned NOT NULL,
|
||||||
|
`expiredate` int(64) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop the profile fields table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}profilefields`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop the tenshi table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}tenshi`")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
27
migrations/2015_04_19_125809_action_codes.php
Normal file
27
migrations/2015_04_19_125809_action_codes.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class ActionCodes implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Create the profile fields table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}actioncodes` (
|
||||||
|
`id` bigint(255) NOT NULL AUTO_INCREMENT,
|
||||||
|
`action` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`userid` bigint(255) NOT NULL,
|
||||||
|
`actkey` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`instruction` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop the profile fields table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}actioncodes`")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
28
migrations/2015_04_27_003820_add_profile_field_types.php
Normal file
28
migrations/2015_04_27_003820_add_profile_field_types.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class AddProfileFieldTypes implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Add islink
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}profilefields` ADD `islink` tinyint(1) unsigned NOT NULL")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Add linkformat
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}profilefields` ADD `linkformat` varchar(255) COLLATE utf8_bin NOT NULL")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop islink
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}profilefields` DROP COLUMN `islink`")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Drop linkformat
|
||||||
|
DB::prepare("ALTER TABLE `{prefix}profilefields` DROP COLUMN `linkformat`")
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
110
migrations/2015_05_05_061836_faq_forum_and_socks.php
Normal file
110
migrations/2015_05_05_061836_faq_forum_and_socks.php
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class FaqForumAndSocks implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Add faq table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}faq` (
|
||||||
|
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`short` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`question` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`answer` text COLLATE utf8_bin NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Add forums table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}forums` (
|
||||||
|
`forum_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`forum_name` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`forum_desc` text COLLATE utf8_bin NOT NULL,
|
||||||
|
`forum_link` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`forum_category` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_type` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_posts` bigint(128) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_topics` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_last_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_last_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`forum_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Add posts table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}posts` (
|
||||||
|
`post_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`topic_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forum_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`poster_ip` varchar(40) COLLATE utf8_bin NOT NULL,
|
||||||
|
`post_time` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`enable_markdown` tinyint(1) unsigned NOT NULL DEFAULT '1',
|
||||||
|
`enable_sig` tinyint(1) unsigned NOT NULL DEFAULT '1',
|
||||||
|
`post_subject` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`post_text` text COLLATE utf8_bin NOT NULL,
|
||||||
|
`post_edit_time` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`post_edit_reason` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`post_edit_user` int(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`post_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Add sock_perms table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}sock_perms` (
|
||||||
|
`rid` bigint(128) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`uid` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`perms` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '1,0,0,0,0,0'
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Add topics table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}topics` (
|
||||||
|
`topic_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`forum_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_hidden` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_title` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`topic_time` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_time_limit` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_last_reply` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_views` bigint(64) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_replies` bigint(128) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_status` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_status_change` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_type` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_first_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_first_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_last_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`topic_last_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`topic_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Change mod to iid in warnings table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `mod` `iid` bigint(128)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop the faq table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}faq`")->execute();
|
||||||
|
|
||||||
|
// Drop the forums table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}forums`")->execute();
|
||||||
|
|
||||||
|
// Drop the posts table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}posts`")->execute();
|
||||||
|
|
||||||
|
// Drop the sock_perms table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}sock_perms`")->execute();
|
||||||
|
|
||||||
|
// Drop the topics table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}topics`")->execute();
|
||||||
|
|
||||||
|
// Change iid to mod in warnings table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `iid` `mod` bigint(128)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
38
migrations/2015_05_08_174736_notifications_table.php
Normal file
38
migrations/2015_05_08_174736_notifications_table.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
|
||||||
|
class NotificationsTable implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Add notifications table
|
||||||
|
DB::prepare("CREATE TABLE `{prefix}notifications` (
|
||||||
|
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`uid` bigint(255) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`timestamp` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`notif_read` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`notif_title` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`notif_text` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`notif_link` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
||||||
|
`notif_img` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||||
|
`notif_timeout` int(16) unsigned NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
// Change mod to iid in warnings table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `mod` `iid` bigint(128)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Drop the notifications table
|
||||||
|
DB::prepare("DROP TABLE `{prefix}notifications`")->execute();
|
||||||
|
|
||||||
|
// Change iid to mod in warnings table
|
||||||
|
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `iid` `mod` bigint(128)')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
14
migrations/2015_05_24_143425_bread_of_the_future.php
Normal file
14
migrations/2015_05_24_143425_bread_of_the_future.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
use Sakura\Migration\IMigration;
|
||||||
|
use Sakura\DB;
|
||||||
|
//https://github.com/flashwave/sakura/commit/0264bbd574ff5a0e701b4331e1fbf55ca3d95ee0
|
||||||
|
class BreadOfTheFuture implements IMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,13 +70,6 @@ DB::open(
|
||||||
Config::local('database', 'prefix')
|
Config::local('database', 'prefix')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if we're using console
|
|
||||||
if (php_sapi_name() === 'cli' && !defined('SAKURA_CRON')) {
|
|
||||||
$console = new Console\Application;
|
|
||||||
$console->run($argv);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we the system has a cron service
|
// Check if we the system has a cron service
|
||||||
if (Config::get('no_cron_service')) {
|
if (Config::get('no_cron_service')) {
|
||||||
// If not do an "asynchronous" call to the cron.php script
|
// If not do an "asynchronous" call to the cron.php script
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
@echo off
|
|
||||||
echo This script assumes php.exe is in the PATH variable
|
|
||||||
php -S localhost:8000 -t public/ server.php
|
|
3
serve.sh
3
serve.sh
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
echo 'This script assumes php is in the PATH variable'
|
|
||||||
php -S localhost:8000 -t public/ server.php
|
|
Reference in a new issue