/** * Calls all init functions of the WCF and the WCFACP class. */ public function __construct() { // add autoload directory self::$autoloadDirectories['wcf'] = WCF_DIR . 'lib/'; // define tmp directory if (!defined('TMP_DIR')) define('TMP_DIR', FileUtil::getTempFolder()); // start initialization $this->initMagicQuotes(); $this->initDB(); $this->loadOptions(); $this->initPackage(); $this->initSession(); $this->initLanguage(); $this->initTPL(); $this->initCronjobs(); $this->initCoreObjects(); // prevent application loading during setup if (PACKAGE_ID) { $this->initApplications(); } $this->initBlacklist(); $this->initAuth(); }
/** * Calls all init functions of the WCF class. */ public function __construct() { // add autoload directory self::$autoloadDirectories['wcf'] = WCF_DIR . 'lib/'; // define tmp directory if (!defined('TMP_DIR')) { define('TMP_DIR', FileUtil::getTempFolder()); } // register additional autoloaders require_once WCF_DIR . 'lib/system/api/phpline/phpline.phar'; require_once WCF_DIR . 'lib/system/api/zend/Loader/StandardAutoloader.php'; $zendLoader = new ZendLoader(array(ZendLoader::AUTOREGISTER_ZF => true)); $zendLoader->register(); $argv = new ArgvParser(array('packageID=i' => '')); $argv->setOption(ArgvParser::CONFIG_FREEFORM_FLAGS, true); $argv->parse(); define('PACKAGE_ID', $argv->packageID ?: 1); // disable benchmark define('ENABLE_BENCHMARK', 0); // start initialization $this->initDB(); $this->loadOptions(); $this->initSession(); $this->initLanguage(); $this->initTPL(); $this->initCoreObjects(); $this->initApplications(); // the destructor registered in core.functions.php will only call the destructor of the parent class register_shutdown_function(array('wcf\\system\\CLIWCF', 'destruct')); $this->initArgv(); $this->initPHPLine(); $this->initAuth(); $this->checkForUpdates(); $this->initCommands(); }
/** * Calls all init functions of the WCF class. */ public function __construct() { // add autoload directory self::$autoloadDirectories['wcf'] = WCF_DIR . 'lib/'; // define tmp directory if (!defined('TMP_DIR')) { define('TMP_DIR', FileUtil::getTempFolder()); } // start initialization $this->initMagicQuotes(); $this->initDB(); $this->loadOptions(); $this->initSession(); $this->initLanguage(); $this->initTPL(); $this->initCronjobs(); $this->initCoreObjects(); $this->initApplications(); $this->initBlacklist(); EventHandler::getInstance()->fireAction($this, 'initialized'); }
protected function tarFiles() { $files = new DirectoryUtil(CMS_DIR . 'files/'); $tar = new TarWriter(FileUtil::getTempFolder() . 'files.tar'); $fileList = $files->getFiles(SORT_ASC, new Regex('^' . CMS_DIR . 'files/$'), true); $tar->add($fileList, '', CMS_DIR . 'files/'); $tar->create(); }
/** * @see \wcf\system\cronjob\ICronjob::execute() */ public function execute(Cronjob $cronjob) { parent::execute($cronjob); // clean up search keywords $sql = "SELECT\tAVG(searches) AS searches\n\t\t\tFROM\twcf" . WCF_N . "_search_keyword"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); if (($row = $statement->fetchArray()) !== false) { $sql = "DELETE FROM\twcf" . WCF_N . "_search_keyword\n\t\t\t\tWHERE\t\tsearches <= ?\n\t\t\t\t\t\tAND lastSearchTime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(floor($row['searches'] / 4), TIME_NOW - 86400 * 30)); } // clean up notifications $sql = "DELETE FROM\twcf" . WCF_N . "_user_notification\n\t\t\tWHERE\t\ttime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * USER_CLEANUP_NOTIFICATION_LIFETIME)); // clean up user activity events $sql = "DELETE FROM\twcf" . WCF_N . "_user_activity_event\n\t\t\tWHERE\t\ttime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * USER_CLEANUP_ACTIVITY_EVENT_LIFETIME)); // clean up profile visitors $sql = "DELETE FROM\twcf" . WCF_N . "_user_profile_visitor\n\t\t\tWHERE\t\ttime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * USER_CLEANUP_PROFILE_VISITOR_LIFETIME)); // tracked visits $sql = "DELETE FROM\twcf" . WCF_N . "_tracked_visit\n\t\t\tWHERE\t\tobjectTypeID = ?\n\t\t\t\t\tAND visitTime < ?"; $statement1 = WCF::getDB()->prepareStatement($sql); $sql = "DELETE FROM\twcf" . WCF_N . "_tracked_visit_type\n\t\t\tWHERE\t\tobjectTypeID = ?\n\t\t\t\t\tAND visitTime < ?"; $statement2 = WCF::getDB()->prepareStatement($sql); WCF::getDB()->beginTransaction(); foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.visitTracker.objectType') as $objectType) { // get lifetime $lifetime = $objectType->lifetime ?: VisitTracker::DEFAULT_LIFETIME; // delete data $statement1->execute(array($objectType->objectTypeID, $lifetime)); $statement2->execute(array($objectType->objectTypeID, $lifetime)); } WCF::getDB()->commitTransaction(); // clean up cronjob log $sql = "DELETE FROM\twcf" . WCF_N . "_cronjob_log\n\t\t\tWHERE\t\texecTime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * 7)); // clean up session access log $sql = "DELETE FROM\twcf" . WCF_N . "_acp_session_access_log\n\t\t\tWHERE\t\tsessionLogID IN (\n\t\t\t\t\t\tSELECT\tsessionLogID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\t\t\tWHERE\tlastActivityTime < ?\n\t\t\t\t\t)"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * 30)); // clean up session log $sql = "DELETE FROM\twcf" . WCF_N . "_acp_session_log\n\t\t\tWHERE\t\tlastActivityTime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * 30)); // clean up search data $sql = "DELETE FROM\twcf" . WCF_N . "_search\n\t\t\tWHERE\t\tsearchTime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400)); // clean up expired edit history entries if (MODULE_EDIT_HISTORY) { if (EDIT_HISTORY_EXPIRATION) { $sql = "DELETE FROM\twcf" . WCF_N . "_edit_history_entry\n\t\t\t\t\tWHERE\t\tobsoletedAt < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * EDIT_HISTORY_EXPIRATION)); } } else { // edit history is disabled, prune old versions $sql = "DELETE FROM\twcf" . WCF_N . "_edit_history_entry"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); } // clean up user authentication failure log if (ENABLE_USER_AUTHENTICATION_FAILURE) { $sql = "DELETE FROM\twcf" . WCF_N . "_user_authentication_failure\n\t\t\t\tWHERE\t\ttime < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(TIME_NOW - 86400 * USER_AUTHENTICATION_FAILURE_EXPIRATION)); } // clean up error logs $files = @glob(WCF_DIR . 'log/*.txt'); if (is_array($files)) { foreach ($files as $filename) { if (filectime($filename) < TIME_NOW - 86400 * 14) { @unlink($filename); } } } // clean up temporary folder $tempFolder = FileUtil::getTempFolder(); DirectoryUtil::getInstance($tempFolder)->executeCallback(new Callback(function ($filename, $object) use($tempFolder) { if ($filename === $tempFolder) { return; } if ($filename === $tempFolder . '.htaccess') { return; } if ($object->getMTime() < TIME_NOW - 86400) { if ($object->isDir()) { @rmdir($filename); } else { if ($object->isFile()) { @unlink($filename); } } } })); }