$MaxUserID = $SQL->Select('UserID', 'max', 'MaxUserID')->From('User')->Get()->FirstRow()->MaxUserID; if ($Argument == 'structure') { $ThankfulPeoplePlugin = new ThankfulPeoplePlugin(); $Drop = Console::Argument('drop') !== False; $ThankfulPeoplePlugin->Structure($Drop); } elseif ($Argument == 'calc') { ThanksLogModel::RecalculateUserReceivedThankCount(); //ThanksLogModel::RecalculateCommentThankCount(); //ThanksLogModel::RecalculateDiscussionThankCount(); } elseif ($Argument == 'garbage') { $Limit = Console::Argument('limit'); if (!$Limit) { $Limit = 10; } $CommentDataSet = $SQL->Select('CommentID, DiscussionID, InsertUserID')->From('Comment')->OrderBy('DateInserted', 'desc')->Limit($Limit)->Get(); $Loop = Console::Argument('loop'); if (!is_numeric($Loop) || $Loop <= 0) { $Loop = 1; } for ($i = 0; $i < $Loop; $i++) { foreach ($CommentDataSet as $Comment) { $InsertUserID = mt_rand(1, $MaxUserID); $Fields = array('CommentID' => $Comment->CommentID); $Fields['UserID'] = $Comment->InsertUserID; $Fields['InsertUserID'] = $InsertUserID; $Fields['DateInserted'] = Gdn_Format::ToDateTime(); if ($InsertUserID % 5 == 0) { unset($Fields['CommentID']); $Fields['DiscussionID'] = $Comment->DiscussionID; } $SQL->Insert('ThanksLog', $Fields);
<?php # Add this line to cron task file, 'crontab -e' # */5 * * * * /usr/local/bin/php -q /path/to/plugins/UsefulFunctions/bin/tick.php $InTickFile = dirname(__FILE__) . '/.tick'; if (file_exists($InTickFile)) { $ModificationTime = filemtime($InTickFile); if (strtotime('55 minutes ago') > $ModificationTime) { unlink($InTickFile); } else { return; } } touch($InTickFile); require dirname(__FILE__) . '/../bootstrap.console.php'; $bLoop = Console::Argument('loop', False) !== False; ini_set('memory_limit', '512M'); $Handler = new StdClass(); $Handler->Returns = array(); $Handler->EventArguments = array(); $PluginManager = Gdn::PluginManager(); $Ticks = array(60 => 'Minute', 3600 => 'Hour', 86400 => 'Day'); $Matches = array('Minutes' => 'i', 'Hours' => 'H', 'Day' => 'j', 'Month' => 'n'); $Events = array(); $Exception = Null; $LastYearSeconds = 0; do { $YearSeconds = (int) (YearSeconds() / 60) * 60; // rewind to begining of the minute $Event = ''; foreach ($Matches as $Name => $Token) {
$MaxScanFiles = 0; } $SkipTranslated = Console::Argument('skiptranslated') !== False; $LocaleName = Console::Argument('locale'); if (!$LocaleName) { $LocaleName = 'zz-ZZ'; } $Type = Console::Argument('type'); switch ($Type) { case 'near': break; case 'pack': default: $Type = 'pack'; } $TestFile = Console::Argument('test'); if (file_exists($TestFile)) { if (is_dir($TestFile)) { $DigDirectory = $TestFile; } else { // TODO: cleanup here $Codes = GetTranslationFromFile($TestFile); d('TODO: cleanup here', $Codes); } } else { $TestFile = False; } $Applications = array('Dashboard', 'Vanilla', 'Conversations'); $Applications = array_combine($Applications, array_map('strtolower', $Applications)); $T = Gdn::FactoryOverwrite(True); $DefaultLocale = new Gdn_Locale('en-CA', $Applications, array());
<?php require_once dirname(__FILE__) . '/../../../plugins/UsefulFunctions/bootstrap.console.php'; $SQL = Gdn::SQL(); $Px = $SQL->Database->DatabasePrefix; $ChunkModel = new ChunkModel(); $Limit = Console::Argument('limit', 5); if (!is_numeric($Limit) || $Limit <= 0) { $Limit = 5; } Gdn::Config()->Set('Plugins.UsefulFunctions.LoremIpsum.Language', 'noIpsum', True, False); /** * Examples: * */ Console::Message("Start."); for ($i = 0; $i < $Limit; $i++) { $Format = 'xHtml'; $Name = LoremIpsum(2); $Body = LoremIpsum('p' . rand(2, 3)); $InsertUserID = rand(1, 5); $Fields = compact('Format', 'Name', 'Body', 'InsertUserID'); $ChunkID = $ChunkModel->Save($Fields); if (!$ChunkID) { Console::Message('^1Error: %s', VarDump($ChunkModel->Validation->Results())); return; } Console::Message("Saved ^3%s (%s)", $ChunkID, $Name); }