2023-07-10 22:52:30 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
// Rewrite this script when everything has proper objects associated with it and use those objects
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../misuzu.php';
|
|
|
|
|
|
|
|
if(!MSZ_DEBUG)
|
|
|
|
die('Not running in debug mode. Are you sure you want to run this?' . PHP_EOL);
|
|
|
|
|
|
|
|
require_once MSZ_ROOT . '/devel/MarkovDictionary.php';
|
|
|
|
|
|
|
|
define('MKV_DICTS', MSZ_ROOT . '/devel/sample-dicts');
|
|
|
|
define('MKV_PASSWD', '123456');
|
|
|
|
define('MKV_MAIL', 'msz-%d@flash.moe');
|
|
|
|
define('MKV_ALPHA', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
|
|
|
define('MKV_ALPHA_LEN', strlen(MKV_ALPHA));
|
|
|
|
|
|
|
|
function mkv_log(string $string): void {
|
|
|
|
printf('[%s] %s%s', date('H:i:s'), $string, PHP_EOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Filling database with markov data...');
|
|
|
|
|
|
|
|
mkv_log('Yoinked Database instance from Misuzu...');
|
|
|
|
$dbConn = $msz->getDbConn();
|
|
|
|
|
|
|
|
mkv_log('Opening role dictionaries...');
|
|
|
|
$roleNames = new MarkovDictionary(MKV_DICTS . '/roles_names.fmk');
|
|
|
|
$roleDescs = new MarkovDictionary(MKV_DICTS . '/roles_descs.fmk');
|
|
|
|
$roleTitles = new MarkovDictionary(MKV_DICTS . '/roles_titles.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking roles table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_roles WHERE role_id > 1');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_roles AUTO_INCREMENT = 2');
|
|
|
|
|
|
|
|
mkv_log('Running slow cron to ensure main role exists...');
|
|
|
|
echo shell_exec(MSZ_ROOT . '/tools/cron slow');
|
|
|
|
|
|
|
|
mkv_log('Preparing role and permissions insert statements...');
|
|
|
|
$cr = $dbConn->prepare('INSERT INTO msz_roles (role_hierarchy, role_name, role_title, role_description, role_hidden, role_can_leave, role_colour) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
|
|
|
$cp = $dbConn->prepare('REPLACE INTO msz_permissions (role_id, general_perms_allow, user_perms_allow, changelog_perms_allow, news_perms_allow, forum_perms_allow, comments_perms_allow) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for main role...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, 1); // role id
|
|
|
|
$cp->addParameter(2, 0); // general
|
|
|
|
$cp->addParameter(3, 59); // user
|
|
|
|
$cp->addParameter(4, 0); // changelog
|
|
|
|
$cp->addParameter(5, 0); // news
|
|
|
|
$cp->addParameter(6, 0); // forum
|
|
|
|
$cp->addParameter(7, 137); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating Global Moderator role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 5);
|
|
|
|
$cr->addParameter(2, 'Global Moderator');
|
|
|
|
$cr->addParameter(3, 'Moderator');
|
|
|
|
$cr->addParameter(4, 'They are global and in moderation.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 1693465);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdMod = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for Global Moderator...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, $rIdMod); // role id
|
|
|
|
$cp->addParameter(2, 3); // general
|
|
|
|
$cp->addParameter(3, 25165887); // user
|
|
|
|
$cp->addParameter(4, 0); // changelog
|
|
|
|
$cp->addParameter(5, 0); // news
|
|
|
|
$cp->addParameter(6, 0); // forum
|
|
|
|
$cp->addParameter(7, 57); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating Administrator role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 10);
|
|
|
|
$cr->addParameter(2, 'Administrator');
|
|
|
|
$cr->addParameter(3, 'Administrator');
|
|
|
|
$cr->addParameter(4, 'Administration nation.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 16711680);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdAdm = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for Administrator...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, $rIdAdm); // role id
|
|
|
|
$cp->addParameter(2, 39); // general
|
|
|
|
$cp->addParameter(3, 28311615); // user
|
|
|
|
$cp->addParameter(4, 3); // changelog
|
|
|
|
$cp->addParameter(5, 3); // news
|
|
|
|
$cp->addParameter(6, 3); // forum
|
|
|
|
$cp->addParameter(7, 249); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating Bot role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 7);
|
|
|
|
$cr->addParameter(2, 'Bot');
|
|
|
|
$cr->addParameter(3, null);
|
|
|
|
$cr->addParameter(4, 'Service users.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 10390951);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdBot = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Creating Tester role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 1);
|
|
|
|
$cr->addParameter(2, 'Tester');
|
|
|
|
$cr->addParameter(3, null);
|
|
|
|
$cr->addParameter(4, 'Experimentalists.');
|
|
|
|
$cr->addParameter(5, 1);
|
|
|
|
$cr->addParameter(6, 1);
|
|
|
|
$cr->addParameter(7, 1073741824);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdTest = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for Tester...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, $rIdTest); // role id
|
|
|
|
$cp->addParameter(2, 16); // general
|
|
|
|
$cp->addParameter(3, 0); // user
|
|
|
|
$cp->addParameter(4, 0); // changelog
|
|
|
|
$cp->addParameter(5, 0); // news
|
|
|
|
$cp->addParameter(6, 0); // forum
|
|
|
|
$cp->addParameter(7, 0); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating OG role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 1);
|
|
|
|
$cr->addParameter(2, 'OG');
|
|
|
|
$cr->addParameter(3, null);
|
|
|
|
$cr->addParameter(4, 'Arbitrarily selected people that joined in 2013 and 2014.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 15740285);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating Developer role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 5);
|
|
|
|
$cr->addParameter(2, 'Developer');
|
|
|
|
$cr->addParameter(3, 'Developer');
|
|
|
|
$cr->addParameter(4, 'Moderators but without the requirement to moderate.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 7558084);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdDev = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for Developer...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, $rIdDev); // role id
|
|
|
|
$cp->addParameter(2, 3); // general
|
|
|
|
$cp->addParameter(3, 25165887); // user
|
|
|
|
$cp->addParameter(4, 3); // changelog
|
|
|
|
$cp->addParameter(5, 0); // news
|
|
|
|
$cp->addParameter(6, 0); // forum
|
|
|
|
$cp->addParameter(7, 57); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
mkv_log('Creating Tenshi role...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, 1);
|
|
|
|
$cr->addParameter(2, 'Tenshi');
|
|
|
|
$cr->addParameter(3, 'Supporter');
|
|
|
|
$cr->addParameter(4, 'Donators.');
|
|
|
|
$cr->addParameter(5, 0);
|
|
|
|
$cr->addParameter(6, 0);
|
|
|
|
$cr->addParameter(7, 15635456);
|
|
|
|
$cr->execute();
|
|
|
|
|
|
|
|
$rIdTen = (int)$dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
mkv_log('Adding permissions for Tenshi...');
|
|
|
|
$cp->reset();
|
|
|
|
$cp->addParameter(1, $rIdTen); // role id
|
|
|
|
$cp->addParameter(2, 0); // general
|
|
|
|
$cp->addParameter(3, 4); // user
|
|
|
|
$cp->addParameter(4, 0); // changelog
|
|
|
|
$cp->addParameter(5, 0); // news
|
|
|
|
$cp->addParameter(6, 0); // forum
|
|
|
|
$cp->addParameter(7, 0); // comments
|
|
|
|
$cp->execute();
|
|
|
|
|
|
|
|
for($i = 0; $i < 10; ++$i) {
|
|
|
|
mkv_log('Creating bogus role ' . $i . '...');
|
|
|
|
$cr->reset();
|
|
|
|
$cr->addParameter(1, mt_rand(1, 4));
|
|
|
|
$cr->addParameter(2, $roleNames->generate());
|
|
|
|
$cr->addParameter(3, (mt_rand(0, 100) > 50) ? $roleTitles->generate() : null);
|
|
|
|
$cr->addParameter(4, (mt_rand(0, 100) > 10) ? $roleDescs->generate() : null);
|
|
|
|
$cr->addParameter(5, mt_rand(0, 1));
|
|
|
|
$cr->addParameter(6, mt_rand(0, 1));
|
|
|
|
$cr->addParameter(7, ((mt_rand(0, 255) << 16) | (mt_rand(0, 255) << 8) | mt_rand(0, 255)));
|
|
|
|
$cr->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening user related markov dictionaries...');
|
|
|
|
$userNames = new MarkovDictionary(MKV_DICTS . '/users_names.fmk');
|
|
|
|
$userTitles = new MarkovDictionary(MKV_DICTS . '/users_titles.fmk');
|
|
|
|
$userSigs = new MarkovDictionary(MKV_DICTS . '/users_sigs.fmk');
|
|
|
|
$userAbouts = new MarkovDictionary(MKV_DICTS . '/users_abouts.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking users table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_users');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_users AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing user insert statements...');
|
|
|
|
$cu = $dbConn->prepare('INSERT INTO msz_users (username, password, email, register_ip, last_ip, user_super, user_country, user_about_content, user_about_parser, user_signature_content, user_signature_parser, user_birthdate, user_title, display_role) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
2023-07-27 13:09:22 +00:00
|
|
|
$ur = $dbConn->prepare('REPLACE INTO msz_users_roles (user_id, role_id) VALUES (?, ?)');
|
2023-07-10 22:52:30 +00:00
|
|
|
|
|
|
|
mkv_log('Creating admin user...');
|
|
|
|
mkv_log('NOTICE: All passwords will be set to: ' . MKV_PASSWD);
|
|
|
|
mkv_log('NOTICE: E-mail address will follow the format of: ' . MKV_MAIL);
|
|
|
|
$cu->reset();
|
|
|
|
$cu->addParameter(1, 'admin'); // username
|
|
|
|
$cu->addParameter(2, password_hash(MKV_PASSWD, PASSWORD_ARGON2ID)); // password
|
|
|
|
$cu->addParameter(3, sprintf(MKV_MAIL, 1)); // email
|
|
|
|
$cu->addParameter(4, "\x7f\0\0\1"); // reg ip
|
|
|
|
$cu->addParameter(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); // last ip
|
|
|
|
$cu->addParameter(6, 1); // super
|
|
|
|
$cu->addParameter(7, 'NL'); // country
|
|
|
|
$cu->addParameter(8, '# Default administrator account'); // about text
|
|
|
|
$cu->addParameter(9, 2); // about parser
|
|
|
|
$cu->addParameter(10, '[b]Administrative Signature[/b]'); // forum sig text
|
|
|
|
$cu->addParameter(11, 1); // forum sig parser
|
|
|
|
$cu->addParameter(12, '2013-01-27'); // birth date
|
|
|
|
$cu->addParameter(13, null); // user title
|
|
|
|
$cu->addParameter(14, $rIdAdm); // display role
|
|
|
|
$cu->execute();
|
|
|
|
|
|
|
|
mkv_log('Adding Global Moderator role to admin...');
|
|
|
|
$ur->reset();
|
|
|
|
$ur->addParameter(1, 1);
|
|
|
|
$ur->addParameter(2, $rIdMod);
|
|
|
|
$ur->execute();
|
|
|
|
|
|
|
|
mkv_log('Adding Administrator role to admin...');
|
|
|
|
$ur->reset();
|
|
|
|
$ur->addParameter(1, 1);
|
|
|
|
$ur->addParameter(2, $rIdAdm);
|
|
|
|
$ur->execute();
|
|
|
|
|
|
|
|
mkv_log('Adding Developer role to admin...');
|
|
|
|
$ur->reset();
|
|
|
|
$ur->addParameter(1, 1);
|
|
|
|
$ur->addParameter(2, $rIdDev);
|
|
|
|
$ur->execute();
|
|
|
|
|
|
|
|
for($i = 1; $i < 2000; ++$i) {
|
|
|
|
mkv_log('Creating bogus user ' . $i . '...');
|
|
|
|
$cu->reset();
|
|
|
|
$cu->addParameter(1, mb_substr($userNames->generate(), 0, 200, 'utf-8') . $i); // username
|
|
|
|
$cu->addParameter(2, password_hash(MKV_PASSWD, PASSWORD_ARGON2ID)); // password
|
|
|
|
$cu->addParameter(3, sprintf(MKV_MAIL, ($i + 1))); // email
|
|
|
|
$cu->addParameter(4, random_bytes(mt_rand(0, 1) ? 4 : 16)); // reg ip
|
|
|
|
$cu->addParameter(5, random_bytes(mt_rand(0, 1) ? 4 : 16)); // last ip
|
|
|
|
$cu->addParameter(6, 0); // super
|
|
|
|
$cu->addParameter(7, MKV_ALPHA[mt_rand(0, MKV_ALPHA_LEN - 1)] . MKV_ALPHA[mt_rand(0, MKV_ALPHA_LEN - 1)]); // country
|
|
|
|
$cu->addParameter(8, mb_substr($userAbouts->generate(), 0, 60000, 'utf-8')); // about text
|
|
|
|
$cu->addParameter(9, mt_rand(0, 2)); // about parser
|
|
|
|
$cu->addParameter(10, mb_substr($userSigs->generate(), 0, 1000, 'utf-8')); // forum sig text
|
|
|
|
$cu->addParameter(11, mt_rand(0, 2)); // forum sig parser
|
|
|
|
$cu->addParameter(12, date('Y-m-d', mt_rand(1, 0x7FFFFFFF))); // birth date
|
|
|
|
$cu->addParameter(13, mt_rand(0, 100) > 90 ? mb_substr($userTitles->generate(), 0, 64, 'utf-8') : null); // user title
|
|
|
|
$cu->addParameter(14, mt_rand(9, 18)); // display role
|
|
|
|
$cu->execute();
|
|
|
|
|
|
|
|
$uId = $dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
for($j = 0; $j < mt_rand(1, 4); ++$j) {
|
|
|
|
$brid = mt_rand(9, 18);
|
|
|
|
mkv_log('Adding role ' . $brid . ' to bogus user id ' . $uId . '...');
|
|
|
|
$ur->reset();
|
|
|
|
$ur->addParameter(1, $uId);
|
|
|
|
$ur->addParameter(2, $brid);
|
|
|
|
$ur->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening changelog tag markov dictionaries...');
|
|
|
|
$changeTagsNames = new MarkovDictionary(MKV_DICTS . '/changes_tags_names.fmk');
|
|
|
|
$changeTagsDescs = new MarkovDictionary(MKV_DICTS . '/changes_tags_descs.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking changelog tags table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_changelog_tags');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_changelog_tags AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing changelog insert statements...');
|
|
|
|
$ct = $dbConn->prepare('INSERT INTO msz_changelog_tags (tag_name, tag_description) VALUES (?, ?)');
|
|
|
|
$cTagIds = [];
|
|
|
|
|
|
|
|
for($i = 0; $i < 20; ++$i) {
|
|
|
|
mkv_log('Inserting bogus changelog tag...');
|
|
|
|
$ct->reset();
|
|
|
|
$ct->addParameter(1, mb_substr($changeTagsNames->generate(), 0, 200, 'utf-8') . $i);
|
|
|
|
$ct->addParameter(2, mb_substr($changeTagsDescs->generate(), 0, 60000, 'utf-8'));
|
|
|
|
$ct->execute();
|
|
|
|
$cTagIds[] = $dbConn->getLastInsertId();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening changelog changes markov dictionaries...');
|
|
|
|
$changeLogs = new MarkovDictionary(MKV_DICTS . '/changes_logs.fmk');
|
|
|
|
$changeTexts = new MarkovDictionary(MKV_DICTS . '/changes_texts.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking changelog changes tables...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_changelog_changes');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_changelog_changes AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing changelog changes statements...');
|
|
|
|
$cc = $dbConn->prepare('INSERT INTO msz_changelog_changes (user_id, change_action, change_created, change_log, change_text) VALUES (?, ?, FROM_UNIXTIME(?), ?, ?)');
|
|
|
|
$ctt = $dbConn->prepare('REPLACE INTO msz_changelog_change_tags (change_id, tag_id) VALUES (?, ?)');
|
|
|
|
|
|
|
|
$max = mt_rand(1000, 10000);
|
|
|
|
mkv_log('Inserting ' . $max . ' changelog entries...');
|
|
|
|
for($i = 0; $i < $max; ++$i) {
|
|
|
|
mkv_log('Inserting bogus change ' . $i . '...');
|
|
|
|
$userId = mt_rand(-100, 2000);
|
|
|
|
if($userId < 1)
|
|
|
|
$userId = null;
|
|
|
|
$cc->reset();
|
|
|
|
$cc->addParameter(1, $userId);
|
|
|
|
$cc->addParameter(2, mt_rand(0, 6));
|
|
|
|
$cc->addParameter(3, mt_rand(1, 0x7FFFFFFF));
|
|
|
|
$cc->addParameter(4, mb_substr($changeLogs->generate(), 0, 240, 'utf-8'));
|
|
|
|
$cc->addParameter(5, mt_rand(0, 100) > 90 ? mb_substr($changeTexts->generate(), 0, 60000, 'utf-8') : null);
|
|
|
|
$cc->execute();
|
|
|
|
|
|
|
|
$changeId = $dbConn->getLastInsertId();
|
|
|
|
|
|
|
|
for($j = 0; $j < mt_rand(1, 5); ++$j) {
|
|
|
|
$btag = $cTagIds[array_rand($cTagIds)];
|
|
|
|
mkv_log('Adding tag ' . $btag . ' to bogus change ' . $i . '...');
|
|
|
|
$ctt->reset();
|
|
|
|
$ctt->addParameter(1, $changeId);
|
|
|
|
$ctt->addParameter(2, $btag);
|
|
|
|
$ctt->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening news category markov dictionaries...');
|
|
|
|
$newsCatsNames = new MarkovDictionary(MKV_DICTS . '/news_cats_names.fmk');
|
|
|
|
$newsCatsDescs = new MarkovDictionary(MKV_DICTS . '/news_cats_descs.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking news categories table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_news_categories');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_news_categories AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing news categories insert statements...');
|
|
|
|
$nc = $dbConn->prepare('INSERT INTO msz_news_categories (category_name, category_description, category_is_hidden) VALUES (?, ?, ?)');
|
|
|
|
$ncIds = [];
|
|
|
|
|
|
|
|
for($i = 0; $i < 10; ++$i) {
|
|
|
|
mkv_log('Creating bogus news category ' . $i . '...');
|
|
|
|
$nc->reset();
|
|
|
|
$nc->addParameter(1, mb_substr($newsCatsNames->generate(), 0, 200, 'utf-8'));
|
|
|
|
$nc->addParameter(2, mb_substr($newsCatsDescs->generate(), 0, 60000, 'utf-8'));
|
|
|
|
$nc->addParameter(3, mt_rand(0, 1));
|
|
|
|
$nc->execute();
|
|
|
|
$ncIds[] = $dbConn->getLastInsertId();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening news post markov dictionaries...');
|
|
|
|
$newsPostsTitles = new MarkovDictionary(MKV_DICTS . '/news_posts_titles.fmk');
|
|
|
|
$newsPostsTexts = new MarkovDictionary(MKV_DICTS . '/news_posts_texts.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking news posts table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_news_posts');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_news_posts AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing news posts table...');
|
|
|
|
$np = $dbConn->prepare('INSERT INTO msz_news_posts (category_id, user_id, post_is_featured, post_title, post_text) VALUES (?, ?, ?, ?, ?)');
|
|
|
|
|
|
|
|
for($i = 0; $i < 200; ++$i) {
|
|
|
|
mkv_log('Creating bogus news post ' . $i . '...');
|
|
|
|
$np->reset();
|
|
|
|
$np->addParameter(1, $ncIds[array_rand($ncIds)]);
|
|
|
|
$np->addParameter(2, mt_rand(1, 2000));
|
|
|
|
$np->addParameter(3, mt_rand(0, 1));
|
|
|
|
$np->addParameter(4, mb_substr($newsPostsTitles->generate(), 0, 200, 'utf-8'));
|
|
|
|
$np->addParameter(5, mb_substr($newsPostsTexts->generate(), 0, 60000, 'utf-8'));
|
|
|
|
$np->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening forum category markov dictionaries...');
|
|
|
|
$forumCatsNames = new MarkovDictionary(MKV_DICTS . '/forums_cats_names.fmk');
|
|
|
|
$forumCatsDescs = new MarkovDictionary(MKV_DICTS . '/forums_cats_descs.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking forum category table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_forum_categories');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_forum_categories AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Inserting 5 root categories and permissions...');
|
|
|
|
for($i = 0; $i < 5; ++$i) {
|
|
|
|
mkv_log('Inserting bogus category ' . $i . '...');
|
|
|
|
$ic = $dbConn->prepare('INSERT INTO msz_forum_categories (forum_name, forum_type) VALUES (?, 1)');
|
|
|
|
$ic->addParameter(1, mb_substr($forumCatsNames->generate(), 0, 240, 'utf-8'));
|
|
|
|
$ic->execute();
|
|
|
|
|
|
|
|
mkv_log('Inserting permissions for bogus category ' . $i . '...');
|
|
|
|
$ip = $dbConn->prepare('INSERT INTO msz_forum_permissions (forum_id, forum_perms_allow) VALUES (?, 3)');
|
|
|
|
$ip->addParameter(1, $i + 1);
|
|
|
|
$ip->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
$categories = mt_rand(20, 40);
|
|
|
|
mkv_log('Inserting ' . $categories . ' forum sections...');
|
|
|
|
|
|
|
|
$catIds = [];
|
|
|
|
for($i = 0; $i < $categories; ++$i) {
|
|
|
|
mkv_log('Inserting bogus forum section ' . $i . '...');
|
|
|
|
$ic = $dbConn->prepare('INSERT INTO msz_forum_categories (forum_name, forum_type, forum_description, forum_parent) VALUES (?, 0, ?, ?)');
|
|
|
|
$ic->addParameter(1, mb_substr($forumCatsNames->generate(), 0, 240, 'utf-8'));
|
|
|
|
$ic->addParameter(2, mb_substr($forumCatsDescs->generate(), 0, 1200, 'utf-8'));
|
|
|
|
$ic->addParameter(3, mt_rand(1, 5));
|
|
|
|
$ic->execute();
|
|
|
|
$catIds[] = $dbConn->getLastInsertId();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening forum topic title markov dictionary...');
|
|
|
|
$forumTopicsTitles = new MarkovDictionary(MKV_DICTS . '/forums_topics_titles.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking forum topics table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_forum_topics');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_forum_topics AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing forum topic insertion statement...');
|
|
|
|
$ft = $dbConn->prepare('INSERT INTO msz_forum_topics (forum_id, user_id, topic_type, topic_title, topic_count_views, topic_created, topic_bumped, topic_deleted, topic_locked) VALUES (?, ?, ?, ?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?))');
|
|
|
|
|
|
|
|
$topics = mt_rand(200, 2000);
|
|
|
|
mkv_log('Creating ' . $topics . ' bogus forum topics...');
|
|
|
|
|
|
|
|
$topIds = [];
|
|
|
|
for($i = 0; $i < $topics; ++$i) {
|
|
|
|
mkv_log('Creating bogus topic ' . $i . '...');
|
|
|
|
$userId = mt_rand(-100, 2000);
|
|
|
|
if($userId < 1)
|
|
|
|
$userId = null;
|
|
|
|
$type = mt_rand(-1000, 2);
|
|
|
|
if($type < 1)
|
|
|
|
$type = 0;
|
|
|
|
$ft->reset();
|
|
|
|
$ft->addParameter(1, $catIds[array_rand($catIds)]);
|
|
|
|
$ft->addParameter(2, $userId);
|
|
|
|
$ft->addParameter(3, $type);
|
|
|
|
$ft->addParameter(4, mb_substr($forumTopicsTitles->generate(), 0, 240, 'utf-8'));
|
|
|
|
$ft->addParameter(5, mt_rand(0, 10000));
|
|
|
|
$ft->addParameter(6, mt_rand(1, 0x7FFFFFFF));
|
|
|
|
$ft->addParameter(7, mt_rand(1, 0x7FFFFFFF));
|
|
|
|
$ft->addParameter(8, mt_rand(0, 10000) > 9999 ? mt_rand(1, 0x7FFFFFFF) : null);
|
|
|
|
$ft->addParameter(9, mt_rand(0, 10000) > 9900 ? mt_rand(1, 0x7FFFFFFF) : null);
|
|
|
|
$ft->execute();
|
|
|
|
$topIds[] = $dbConn->getLastInsertId();
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Opening forum post text markov dictionary...');
|
|
|
|
$forumPostsTexts = new MarkovDictionary(MKV_DICTS . '/forums_posts_texts.fmk');
|
|
|
|
|
|
|
|
mkv_log('Nuking forum posts table...');
|
|
|
|
$dbConn->execute('DELETE FROM msz_forum_posts');
|
|
|
|
$dbConn->execute('ALTER TABLE msz_forum_posts AUTO_INCREMENT = 1');
|
|
|
|
|
|
|
|
mkv_log('Preparing forum post insertion statement...');
|
|
|
|
$fp = $dbConn->prepare('INSERT INTO msz_forum_posts (topic_id, forum_id, user_id, post_ip, post_text, post_parse, post_display_signature, post_created, post_edited, post_deleted) VALUES (?, 1, ?, ?, ?, ?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?))');
|
|
|
|
|
|
|
|
$topCount = count($topIds);
|
|
|
|
for($t = 0; $t < $topCount; ++$t) {
|
|
|
|
$posts = mt_rand(1, 600);
|
|
|
|
$topId = $topIds[$t];
|
|
|
|
|
|
|
|
mkv_log('Inserting ' . $posts . ' bogus forum posts for bogus topic ' . $topId . '...');
|
|
|
|
|
|
|
|
for($i = 0; $i < $posts; ++$i) {
|
|
|
|
mkv_log('Inserting bogus post ' . $i . ' into bogus topic ' . $topId . '...');
|
|
|
|
|
|
|
|
$userId = mt_rand(-100, 2000);
|
|
|
|
if($userId < 1)
|
|
|
|
$userId = null;
|
|
|
|
$fp->reset();
|
|
|
|
$fp->addParameter(1, $topId);
|
|
|
|
$fp->addParameter(2, $userId);
|
|
|
|
$fp->addParameter(3, random_bytes(mt_rand(0, 1) ? 4 : 16));
|
|
|
|
$fp->addParameter(4, mb_substr($forumPostsTexts->generate(), 0, 60000, 'utf-8'));
|
|
|
|
$fp->addParameter(5, mt_rand(0, 2));
|
|
|
|
$fp->addParameter(6, mt_rand(0, 1000) > 900 ? 0 : 1);
|
|
|
|
$fp->addParameter(7, mt_rand(1, 0x7FFFFFFF));
|
|
|
|
$fp->addParameter(8, mt_rand(0, 1000) > 900 ? mt_rand(1, 0x7FFFFFFF) : null);
|
|
|
|
$fp->addParameter(9, mt_rand(0, 10000) > 9000 ? mt_rand(1, 0x7FFFFFFF) : null);
|
|
|
|
$fp->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mkv_log('Running slow cron once more...');
|
|
|
|
echo shell_exec(MSZ_ROOT . '/tools/cron slow');
|
|
|
|
|
|
|
|
mkv_log('Done! Enjoy your garbage filled forum.');
|