Esempio n. 1
0
 public function Tick_Match_30_Minutes_05_Hours_Handler()
 {
     // every night
     // 1. Clean-up temp uploads
     $KeepThis = array('README');
     $MonthAgo = strtotime('30 days ago');
     $Directory = 'uploads/tmp';
     if (!file_exists($Directory)) {
         return;
     }
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Directory)) as $File) {
         if (in_array($File->GetFilename(), $KeepThis)) {
             continue;
         }
         $Pathname = $File->GetPathname();
         if ($MonthAgo > $File->GetMTime()) {
             unlink($Pathname);
         }
         Console::Message('Removed: ^3%s', $Pathname);
     }
 }
Esempio n. 2
0
    //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);
            Console::Message('Garbaged thank comment: %s', GetValue('CommentID', $Fields));
        }
    }
}
/* LUM_ThankfulPeople
	CommentID
	UserID
*/
 if (strpos($Pathname, '__') !== False) {
     continue;
 }
 if (pathinfo($Pathname, PATHINFO_EXTENSION) != 'php') {
     continue;
 }
 $Path = substr($Pathname, strlen(PATH_ROOT) + 1);
 $PathArray = explode('/', $Path);
 if (in_array($PathArray[0], array('themes', '_notes'))) {
     continue;
 }
 $Codes = GetTranslationFromFile($Pathname);
 if (count($Codes) == 0) {
     continue;
 }
 Console::Message('^3%s ^1(%s)', $Path, count($Codes));
 $StoreDirectory = 'applications/dashboard';
 if (in_array($PathArray[0], array('applications', 'plugins'))) {
     $StoreDirectory = $PathArray[0] . '/' . $PathArray[1];
 }
 if ($Type == 'near') {
     $DefinitionsFile = dirname(__FILE__) . '/dummy-locale/' . $StoreDirectory . "/locale/{$LocaleName}.php";
 } elseif ($Type == 'pack') {
     $PackFile = ArrayValue(1, explode('/', $StoreDirectory));
     $DefinitionsFile = dirname(__FILE__) . "/dummy-locale/{$LocaleName}/{$PackFile}.php";
 }
 $FileHash = md5_file($File->GetRealPath());
 $FileUndefinedTranslation =& $UndefinedTranslation[$DefinitionsFile];
 if (!is_array($FileUndefinedTranslation)) {
     $FileUndefinedTranslation = array();
 }
Esempio n. 4
0
                try {
                    $PluginManager->CallEventHandlers($Handler, 'Tick', $Event);
                    //K('#'.$Event, (int)K('#'.$Event) + 1);
                } catch (Exception $Exception) {
                }
                Console::Message('Tick: %s', $Event);
            }
        }
    }
    if ($Exception) {
        throw $Exception;
    }
    if ($bLoop != False) {
        $LastYearSeconds = $YearSeconds;
        $SleepSeconds = 60 - YearSeconds() % 60;
        Console::Message('Sleep (%s %s)', $SleepSeconds, Plural($SleepSeconds, 'second', 'seconds'));
        // prevent tick in second while in loop
        sleep($SleepSeconds);
    }
} while ($bLoop);
$Database = Gdn::Database();
if ($Database != Null) {
    $Database->CloseConnection();
}
unlink($InTickFile);
/* Example:


class ExamplePlugin implements Gdn_IPlugin {

	public function Tick_Every_5_Minutes_Handler() {
Esempio n. 5
0
<?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);
}
Esempio n. 6
0
<?php

require_once implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', '..', 'plugins', 'UsefulFunctions', 'bootstrap.console.php'));
$Directory = new RecursiveDirectoryIterator('cache/ps');
foreach (new RecursiveIteratorIterator($Directory) as $File) {
    $CachedFile = $File->GetPathName();
    unlink($CachedFile);
    Console::Message('Removed ^3%s', $CachedFile);
}
// + DtCss
$DirectoryAry = array(PATH_APPLICATIONS, PATH_PLUGINS, PATH_THEMES);
foreach ($DirectoryAry as $DirectoryPath) {
    $Directory = new RecursiveDirectoryIterator($DirectoryPath);
    foreach (new RecursiveIteratorIterator($Directory) as $File) {
        $Basename = $File->GetBasename();
        $Extension = pathinfo($Basename, 4);
        $Filename = pathinfo($Basename, 8);
        if ($Extension != 'css') {
            continue;
        }
        if (!preg_match('/^[\\.\\w\\-]+\\-c\\-[a-z0-9]{5,7}$/', $Filename)) {
            continue;
        }
        $CachedFile = $File->GetPathName();
        unlink($CachedFile);
        Console::Message('Removed ^3%s', $CachedFile);
    }
}