Removed getter/setter methods in favour of property hooks and asymmetric visibility.
This commit is contained in:
parent
2cb2918533
commit
d103477fe1
149 changed files with 2169 additions and 3565 deletions
44
tools/cron
44
tools/cron
|
@ -75,7 +75,7 @@ msz_sched_task_sql('Synchronise forum_id.', true,
|
|||
'UPDATE msz_forum_posts AS p INNER JOIN msz_forum_topics AS t ON t.topic_id = p.topic_id SET p.forum_id = t.forum_id');
|
||||
|
||||
msz_sched_task_func('Recount forum topics and posts.', true, function() use ($msz) {
|
||||
$msz->getForumContext()->getCategories()->syncForumCounters();
|
||||
$msz->forumCtx->categories->syncForumCounters();
|
||||
});
|
||||
|
||||
msz_sched_task_sql('Clean up expired 2fa tokens.', false,
|
||||
|
@ -84,9 +84,6 @@ msz_sched_task_sql('Clean up expired 2fa tokens.', false,
|
|||
// very heavy stuff that should
|
||||
|
||||
msz_sched_task_func('Resync statistics counters.', true, function() use ($msz) {
|
||||
$dbConn = $msz->getDbConn();
|
||||
$counters = $msz->getCounters();
|
||||
|
||||
$stats = [
|
||||
'users:total' => 'SELECT COUNT(*) FROM msz_users',
|
||||
'users:active' => 'SELECT COUNT(*) FROM msz_users WHERE user_active IS NOT NULL AND user_deleted IS NULL',
|
||||
|
@ -144,27 +141,26 @@ msz_sched_task_func('Resync statistics counters.', true, function() use ($msz) {
|
|||
];
|
||||
|
||||
foreach($stats as $name => $query) {
|
||||
$result = $dbConn->query($query);
|
||||
$counters->set($name, $result->next() ? $result->getInteger(0) : 0);
|
||||
$result = $msz->dbConn->query($query);
|
||||
$msz->counters->set($name, $result->next() ? $result->getInteger(0) : 0);
|
||||
}
|
||||
});
|
||||
|
||||
msz_sched_task_func('Recalculate permissions (maybe)...', false, function() use ($msz) {
|
||||
$needsRecalc = $msz->getConfig()->getBoolean('perms.needsRecalc');
|
||||
$needsRecalc = $msz->config->getBoolean('perms.needsRecalc');
|
||||
if(!$needsRecalc)
|
||||
return;
|
||||
|
||||
$msz->getConfig()->removeValues('perms.needsRecalc');
|
||||
$msz->getPerms()->precalculatePermissions($msz->getForumContext()->getCategories());
|
||||
$msz->config->removeValues('perms.needsRecalc');
|
||||
$msz->perms->precalculatePermissions($msz->forumCtx->categories);
|
||||
});
|
||||
|
||||
msz_sched_task_func('Omega disliking comments...', true, function() use ($msz) {
|
||||
$commentIds = $msz->getConfig()->getArray('comments.omegadislike');
|
||||
$commentIds = $msz->config->getArray('comments.omegadislike');
|
||||
if(!is_array($commentIds))
|
||||
return;
|
||||
|
||||
$dbConn = $msz->getDbConn();
|
||||
$stmt = $dbConn->prepare('REPLACE INTO msz_comments_votes (comment_id, user_id, comment_vote) SELECT ?, user_id, -1 FROM msz_users');
|
||||
$stmt = $msz->dbConn->prepare('REPLACE INTO msz_comments_votes (comment_id, user_id, comment_vote) SELECT ?, user_id, -1 FROM msz_users');
|
||||
foreach($commentIds as $commentId) {
|
||||
$stmt->addParameter(1, $commentId);
|
||||
$stmt->execute();
|
||||
|
@ -172,14 +168,13 @@ msz_sched_task_func('Omega disliking comments...', true, function() use ($msz) {
|
|||
});
|
||||
|
||||
msz_sched_task_func('Announcing random topics...', true, function() use ($msz) {
|
||||
$categoryIds = $msz->getConfig()->getArray('forum.rngannounce');
|
||||
$categoryIds = $msz->config->getArray('forum.rngannounce');
|
||||
if(!is_array($categoryIds))
|
||||
return;
|
||||
|
||||
$dbConn = $msz->getDbConn();
|
||||
$stmtRevert = $dbConn->prepare('UPDATE msz_forum_topics SET topic_type = 0 WHERE forum_id = ? AND topic_type = 2');
|
||||
$stmtRandom = $dbConn->prepare('SELECT topic_id FROM msz_forum_topics WHERE forum_id = ? AND topic_deleted IS NULL ORDER BY RAND() LIMIT 1');
|
||||
$stmtAnnounce = $dbConn->prepare('UPDATE msz_forum_topics SET topic_type = 2 WHERE topic_id = ?');
|
||||
$stmtRevert = $msz->dbConn->prepare('UPDATE msz_forum_topics SET topic_type = 0 WHERE forum_id = ? AND topic_type = 2');
|
||||
$stmtRandom = $msz->dbConn->prepare('SELECT topic_id FROM msz_forum_topics WHERE forum_id = ? AND topic_deleted IS NULL ORDER BY RAND() LIMIT 1');
|
||||
$stmtAnnounce = $msz->dbConn->prepare('UPDATE msz_forum_topics SET topic_type = 2 WHERE topic_id = ?');
|
||||
foreach($categoryIds as $categoryId) {
|
||||
$stmtRevert->addParameter(1, $categoryId);
|
||||
$stmtRevert->execute();
|
||||
|
@ -196,18 +191,15 @@ msz_sched_task_func('Announcing random topics...', true, function() use ($msz) {
|
|||
});
|
||||
|
||||
msz_sched_task_func('Changing category icons...', false, function() use ($msz) {
|
||||
$config = $msz->getConfig();
|
||||
$categoryIds = $config->getArray('forum.rngicon');
|
||||
$categoryIds = $msz->config->getArray('forum.rngicon');
|
||||
if(!is_array($categoryIds))
|
||||
return;
|
||||
|
||||
$dbConn = $msz->getDbConn();
|
||||
|
||||
$stmtIcon = $dbConn->prepare('UPDATE msz_forum_categories SET forum_icon = COALESCE(?, forum_icon), forum_name = COALESCE(?, forum_name), forum_colour = ((ROUND(RAND() * 255) << 16) | (ROUND(RAND() * 255) << 8) | ROUND(RAND() * 255)) WHERE forum_id = ?');
|
||||
$stmtUnlock = $dbConn->prepare('UPDATE msz_forum_topics SET topic_locked = IF(?, NULL, COALESCE(topic_locked, NOW())) WHERE topic_id = ?');
|
||||
$stmtIcon = $msz->dbConn->prepare('UPDATE msz_forum_categories SET forum_icon = COALESCE(?, forum_icon), forum_name = COALESCE(?, forum_name), forum_colour = ((ROUND(RAND() * 255) << 16) | (ROUND(RAND() * 255) << 8) | ROUND(RAND() * 255)) WHERE forum_id = ?');
|
||||
$stmtUnlock = $msz->dbConn->prepare('UPDATE msz_forum_topics SET topic_locked = IF(?, NULL, COALESCE(topic_locked, NOW())) WHERE topic_id = ?');
|
||||
|
||||
foreach($categoryIds as $categoryId) {
|
||||
$scoped = $config->scopeTo(sprintf('forum.rngicon.fc%d', $categoryId));
|
||||
$scoped = $msz->config->scopeTo(sprintf('forum.rngicon.fc%d', $categoryId));
|
||||
|
||||
$icons = $scoped->getArray('icons');
|
||||
$icon = $icons[array_rand($icons)];
|
||||
|
@ -242,8 +234,6 @@ msz_sched_task_func('Changing category icons...', false, function() use ($msz) {
|
|||
|
||||
echo 'Running ' . count($schedTasks) . ' tasks...' . PHP_EOL;
|
||||
|
||||
$dbConn = $msz->getDbConn();
|
||||
|
||||
foreach($schedTasks as $task) {
|
||||
echo '=> ' . $task->name . PHP_EOL;
|
||||
$success = true;
|
||||
|
@ -251,7 +241,7 @@ foreach($schedTasks as $task) {
|
|||
try {
|
||||
switch($task->type) {
|
||||
case 'sql':
|
||||
$affected = $dbConn->execute($task->command);
|
||||
$affected = $msz->dbConn->execute($task->command);
|
||||
echo $affected . ' rows affected. ' . PHP_EOL;
|
||||
break;
|
||||
|
||||
|
|
|
@ -21,24 +21,21 @@ function mkv_log(string $string): void {
|
|||
|
||||
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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_roles WHERE role_id > 1');
|
||||
$msz->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 (?, ?, ?, ?, ?, ?, ?)');
|
||||
$cr = $msz->dbConn->prepare('INSERT INTO msz_roles (role_hierarchy, role_name, role_title, role_description, role_hidden, role_can_leave, role_colour) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
||||
$cp = $msz->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();
|
||||
|
@ -62,7 +59,7 @@ $cr->addParameter(6, 0);
|
|||
$cr->addParameter(7, 1693465);
|
||||
$cr->execute();
|
||||
|
||||
$rIdMod = (int)$dbConn->getLastInsertId();
|
||||
$rIdMod = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Adding permissions for Global Moderator...');
|
||||
$cp->reset();
|
||||
|
@ -86,7 +83,7 @@ $cr->addParameter(6, 0);
|
|||
$cr->addParameter(7, 16711680);
|
||||
$cr->execute();
|
||||
|
||||
$rIdAdm = (int)$dbConn->getLastInsertId();
|
||||
$rIdAdm = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Adding permissions for Administrator...');
|
||||
$cp->reset();
|
||||
|
@ -110,7 +107,7 @@ $cr->addParameter(6, 0);
|
|||
$cr->addParameter(7, 10390951);
|
||||
$cr->execute();
|
||||
|
||||
$rIdBot = (int)$dbConn->getLastInsertId();
|
||||
$rIdBot = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Creating Tester role...');
|
||||
$cr->reset();
|
||||
|
@ -123,7 +120,7 @@ $cr->addParameter(6, 1);
|
|||
$cr->addParameter(7, 1073741824);
|
||||
$cr->execute();
|
||||
|
||||
$rIdTest = (int)$dbConn->getLastInsertId();
|
||||
$rIdTest = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Adding permissions for Tester...');
|
||||
$cp->reset();
|
||||
|
@ -158,7 +155,7 @@ $cr->addParameter(6, 0);
|
|||
$cr->addParameter(7, 7558084);
|
||||
$cr->execute();
|
||||
|
||||
$rIdDev = (int)$dbConn->getLastInsertId();
|
||||
$rIdDev = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Adding permissions for Developer...');
|
||||
$cp->reset();
|
||||
|
@ -182,7 +179,7 @@ $cr->addParameter(6, 0);
|
|||
$cr->addParameter(7, 15635456);
|
||||
$cr->execute();
|
||||
|
||||
$rIdTen = (int)$dbConn->getLastInsertId();
|
||||
$rIdTen = (int)$msz->dbConn->getLastInsertId();
|
||||
|
||||
mkv_log('Adding permissions for Tenshi...');
|
||||
$cp->reset();
|
||||
|
@ -215,12 +212,12 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_users');
|
||||
$msz->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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||
$ur = $dbConn->prepare('REPLACE INTO msz_users_roles (user_id, role_id) VALUES (?, ?)');
|
||||
$cu = $msz->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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||
$ur = $msz->dbConn->prepare('REPLACE INTO msz_users_roles (user_id, role_id) VALUES (?, ?)');
|
||||
|
||||
mkv_log('Creating admin user...');
|
||||
mkv_log('NOTICE: All passwords will be set to: ' . MKV_PASSWD);
|
||||
|
@ -279,7 +276,7 @@ for($i = 1; $i < 2000; ++$i) {
|
|||
$cu->addParameter(14, mt_rand(9, 18)); // display role
|
||||
$cu->execute();
|
||||
|
||||
$uId = $dbConn->getLastInsertId();
|
||||
$uId = $msz->dbConn->getLastInsertId();
|
||||
|
||||
for($j = 0; $j < mt_rand(1, 4); ++$j) {
|
||||
$brid = mt_rand(9, 18);
|
||||
|
@ -296,11 +293,11 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_changelog_tags');
|
||||
$msz->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 (?, ?)');
|
||||
$ct = $msz->dbConn->prepare('INSERT INTO msz_changelog_tags (tag_name, tag_description) VALUES (?, ?)');
|
||||
$cTagIds = [];
|
||||
|
||||
for($i = 0; $i < 20; ++$i) {
|
||||
|
@ -309,7 +306,7 @@ for($i = 0; $i < 20; ++$i) {
|
|||
$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();
|
||||
$cTagIds[] = $msz->dbConn->getLastInsertId();
|
||||
}
|
||||
|
||||
mkv_log('Opening changelog changes markov dictionaries...');
|
||||
|
@ -317,12 +314,12 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_changelog_changes');
|
||||
$msz->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 (?, ?)');
|
||||
$cc = $msz->dbConn->prepare('INSERT INTO msz_changelog_changes (user_id, change_action, change_created, change_log, change_text) VALUES (?, ?, FROM_UNIXTIME(?), ?, ?)');
|
||||
$ctt = $msz->dbConn->prepare('REPLACE INTO msz_changelog_change_tags (change_id, tag_id) VALUES (?, ?)');
|
||||
|
||||
$max = mt_rand(1000, 10000);
|
||||
mkv_log('Inserting ' . $max . ' changelog entries...');
|
||||
|
@ -339,7 +336,7 @@ for($i = 0; $i < $max; ++$i) {
|
|||
$cc->addParameter(5, mt_rand(0, 100) > 90 ? mb_substr($changeTexts->generate(), 0, 60000, 'utf-8') : null);
|
||||
$cc->execute();
|
||||
|
||||
$changeId = $dbConn->getLastInsertId();
|
||||
$changeId = $msz->dbConn->getLastInsertId();
|
||||
|
||||
for($j = 0; $j < mt_rand(1, 5); ++$j) {
|
||||
$btag = $cTagIds[array_rand($cTagIds)];
|
||||
|
@ -356,11 +353,11 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_news_categories');
|
||||
$msz->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 (?, ?, ?)');
|
||||
$nc = $msz->dbConn->prepare('INSERT INTO msz_news_categories (category_name, category_description, category_is_hidden) VALUES (?, ?, ?)');
|
||||
$ncIds = [];
|
||||
|
||||
for($i = 0; $i < 10; ++$i) {
|
||||
|
@ -370,7 +367,7 @@ for($i = 0; $i < 10; ++$i) {
|
|||
$nc->addParameter(2, mb_substr($newsCatsDescs->generate(), 0, 60000, 'utf-8'));
|
||||
$nc->addParameter(3, mt_rand(0, 1));
|
||||
$nc->execute();
|
||||
$ncIds[] = $dbConn->getLastInsertId();
|
||||
$ncIds[] = $msz->dbConn->getLastInsertId();
|
||||
}
|
||||
|
||||
mkv_log('Opening news post markov dictionaries...');
|
||||
|
@ -378,11 +375,11 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_news_posts');
|
||||
$msz->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 (?, ?, ?, ?, ?)');
|
||||
$np = $msz->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 . '...');
|
||||
|
@ -400,18 +397,18 @@ $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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_forum_categories');
|
||||
$msz->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 = $msz->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 = $msz->dbConn->prepare('INSERT INTO msz_forum_permissions (forum_id, forum_perms_allow) VALUES (?, 3)');
|
||||
$ip->addParameter(1, $i + 1);
|
||||
$ip->execute();
|
||||
}
|
||||
|
@ -422,23 +419,23 @@ 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 = $msz->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();
|
||||
$catIds[] = $msz->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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_forum_topics');
|
||||
$msz->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(?))');
|
||||
$ft = $msz->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...');
|
||||
|
@ -463,18 +460,18 @@ for($i = 0; $i < $topics; ++$i) {
|
|||
$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();
|
||||
$topIds[] = $msz->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');
|
||||
$msz->dbConn->execute('DELETE FROM msz_forum_posts');
|
||||
$msz->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(?))');
|
||||
$fp = $msz->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) {
|
||||
|
|
|
@ -4,5 +4,5 @@ namespace Misuzu;
|
|||
|
||||
require_once __DIR__ . '/../misuzu.php';
|
||||
|
||||
$msz->getConfig()->removeValues('perms.needsRecalc');
|
||||
$msz->getPerms()->precalculatePermissions($msz->getForumContext()->getCategories());
|
||||
$msz->config->removeValues('perms.needsRecalc');
|
||||
$msz->perms->precalculatePermissions($msz->forumCtx->categories);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue