/**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     ACPSessionEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
     SessionEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
     SessionVirtualEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $sql = "UPDATE\twcf" . WCF_N . "_user user_table,\n\t\t\t\twcf" . WCF_N . "_session session\n\t\t\tSET\tuser_table.lastActivityTime = session.lastActivityTime\n\t\t\tWHERE\tuser_table.userID = session.userID\n\t\t\t\tAND session.userID <> 0";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute();
 }
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $list = new NewsList();
     $list->getConditionBuilder()->add('isDisabled = ?', array(1));
     $list->getConditionBuilder()->add('time <= ?', array(TIME_NOW));
     $list->readObjects();
     $list = $list->getObjects();
     $action = new NewsAction($list, 'publish');
     $action->executeAction();
 }
Esempio n. 4
0
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $userIDs = array();
     $sql = "SELECT\tuserID\n\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\tWHERE\tquitStarted > ?\n\t\t\t\tAND quitStarted < ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, TIME_NOW - 7 * 24 * 3600));
     while ($row = $statement->fetchArray()) {
         $userIDs[] = $row['userID'];
     }
     if (!empty($userIDs)) {
         $action = new UserAction($userIDs, 'delete');
         $action->executeAction();
     }
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // disable expired paid subscriptions
     if (MODULE_PAID_SUBSCRIPTION) {
         $subscriptionUserList = new PaidSubscriptionUserList();
         $subscriptionUserList->getConditionBuilder()->add('isActive = ?', array(1));
         $subscriptionUserList->getConditionBuilder()->add('endDate > 0 AND endDate < ?', array(TIME_NOW));
         $subscriptionUserList->readObjects();
         if (count($subscriptionUserList->getObjects())) {
             $action = new PaidSubscriptionUserAction($subscriptionUserList->getObjects(), 'revoke');
             $action->executeAction();
         }
     }
 }
 /**
  * @see	wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $statementList = new UserJcoinsStatementList();
     $statementList->getConditionBuilder()->add('user_jcoins_statement.time < ?', array(TIME_NOW - 86400 * JCOINS_STATEMENTS_DELETEAFTER));
     if (JCOINS_STATEMENTS_DELETEONLYTRASHED) {
         $statementList->getConditionBuilder()->add('user_jcoins_statement.isTrashed = ?', array(1));
     }
     $statementList->readObjects();
     if (!$statementList->count()) {
         return;
     }
     $statementAction = new UserJcoinsStatementAction($statementList->getObjects(), 'delete');
     $statementAction->executeAction();
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // delete orphaned attachments
     $attachmentIDs = array();
     $sql = "SELECT\tattachmentID\n\t\t\tFROM\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\tobjectID = ?\n\t\t\t\tAND uploadTime < ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, TIME_NOW - 86400));
     while ($row = $statement->fetchArray()) {
         $attachmentIDs[] = $row['attachmentID'];
     }
     if (!empty($attachmentIDs)) {
         AttachmentEditor::deleteAll($attachmentIDs);
     }
 }
 /**
  * @see wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // 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));
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $assignments = UserGroupAssignmentCacheBuilder::getInstance()->getData();
     $usersToGroup = array();
     foreach ($assignments as $assignment) {
         if (!isset($usersToGroup[$assignment->groupID])) {
             $usersToGroup[$assignment->groupID] = array();
         }
         $usersToGroup[$assignment->groupID] = array_merge($usersToGroup[$assignment->groupID], UserGroupAssignmentHandler::getInstance()->getUsers($assignment));
     }
     foreach ($usersToGroup as $groupID => $users) {
         $userAction = new UserAction(array_unique($users), 'addToGroups', array('addDefaultGroups' => false, 'deleteOldGroups' => false, 'groups' => array($groupID)));
         $userAction->executeAction();
     }
 }
Esempio n. 10
0
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // unban users
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tbanned = ?,\n\t\t\t\tbanExpires = ?\n\t\t\tWHERE\tbanned = ?\n\t\t\t\tAND banExpires <> ?\n\t\t\t\tAND banExpires <= ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, 0, 1, 0, TIME_NOW));
     // enable avatars
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tdisableAvatar = ?,\n\t\t\t\tdisableAvatarExpires = ?\n\t\t\tWHERE\tdisableAvatar = ?\n\t\t\t\tAND disableAvatarExpires <> ?\n\t\t\t\tAND disableAvatarExpires <= ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, 0, 1, 0, TIME_NOW));
     // enable signatures
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tdisableSignature = ?,\n\t\t\t\tdisableSignatureExpires = ?\n\t\t\tWHERE\tdisableSignature = ?\n\t\t\t\tAND disableSignatureExpires <> ?\n\t\t\t\tAND disableSignatureExpires <= ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, 0, 1, 0, TIME_NOW));
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     if (CMS_NEWS_EMPTY_RECYCLE_BIN_CYCLE) {
         $entryIDs = array();
         $sql = "SELECT\tentryID\n\t\t\t\tFROM\tcms" . WCF_N . "_news_entry\n\t\t\t\tWHERE\tisDeleted = ?\n\t\t\t\t\tAND deleteTime < ?";
         $statement = WCF::getDB()->prepareStatement($sql, 1000);
         $statement->execute(array(1, TIME_NOW - CMS_NEWS_EMPTY_RECYCLE_BIN_CYCLE * 86400));
         while ($row = $statement->fetchArray()) {
             $entryIDs[] = $row['entryID'];
         }
         if (!empty($entryIDs)) {
             $action = new EntryAction($entryIDs, 'delete');
             $action->executeAction();
         }
     }
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get date
     $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
     $d->setTimezone(new \DateTimeZone(TIMEZONE));
     $d->sub(new \DateInterval('P1D'));
     $d->setTime(0, 0);
     $date = $d->getTimestamp();
     // prepare insert statement
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_stat_daily\n\t\t\t\t\t\t(objectTypeID, date, counter, total)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     // get object types
     foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
         $data = $objectType->getProcessor()->getData($date);
         $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
     }
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $sql = "SELECT\tqueueID\n\t\t\tFROM\twcf" . WCF_N . "_moderation_queue\n\t\t\tWHERE\tstatus = ?\n\t\t\t\tAND lastChangeTime < ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(ModerationQueue::STATUS_DONE, TIME_NOW - 86400 * 30));
     $queueIDs = array();
     while ($row = $statement->fetchArray()) {
         $queueIDs[] = $row['queueID'];
     }
     if (!empty($queueIDs)) {
         $conditions = new PreparedStatementConditionBuilder();
         $conditions->add("queueID IN (?)", array($queueIDs));
         $sql = "DELETE FROM\twcf" . WCF_N . "_moderation_queue\n\t\t\t\t" . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         // reset moderation count for all users
         ModerationQueueManager::getInstance()->resetModerationCount();
     }
 }
Esempio n. 14
0
	/**
	 * @see	wcf\system\cronjob\ICronjob::execute()
	 */
	public function execute(Cronjob $cronjob) {
		parent::execute($cronjob);
		
		// clean up cronjob log
		$sql = "DELETE FROM	wcf".WCF_N."_cronjob_log
			WHERE		execTime < ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array(
			(TIME_NOW - (86400 * 7))
		));
		
		// clean up session access log
		$sql = "DELETE FROM	wcf".WCF_N."_acp_session_access_log
			WHERE		sessionLogID IN (
						SELECT	sessionLogID
						FROM	wcf".WCF_N."_acp_session_log
						WHERE	lastActivityTime < ?
					)";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array(
			(TIME_NOW - (86400 * 30))
		));
		
		// clean up session log
		$sql = "DELETE FROM	wcf".WCF_N."_acp_session_log
			WHERE		lastActivityTime < ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array(
			(TIME_NOW - (86400 * 30))
		));
		
		// clean up search data
		$sql = "DELETE FROM	wcf".WCF_N."_search
			WHERE		searchTime < ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array(
			(TIME_NOW - 86400)
		));
	}
 /**
  * @see	wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get delayed news
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.isPublished = 0');
     $newsList->getConditionBuilder()->add('news.publicationDate <= ?', array(TIME_NOW));
     $newsList->readObjects();
     if (count($newsList->getObjects())) {
         // publish news
         $action = new NewsAction($newsList->getObjects(), 'publish');
         $action->executeAction();
     }
     // get outdated news
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.isArchived = 0');
     $newsList->getConditionBuilder()->add('news.archivingDate != 0 AND news.archivingDate <= ?', array(TIME_NOW));
     $newsList->readObjects();
     if (count($newsList->getObjects())) {
         // archivate news
         $action = new NewsAction($newsList->getObjects(), 'archive');
         $action->executeAction();
     }
 }
 /**
  * @see	wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get delayed news
     $entryList = new EntryList();
     $entryList->getConditionBuilder()->add('news_entry.isPublished = 0');
     $entryList->getConditionBuilder()->add('news_entry.publicationDate <= ?', array(TIME_NOW));
     $entryList->readObjects();
     if (count($entryList->getObjects())) {
         // publish news
         $action = new EntryAction($entryList->getObjects(), 'publish');
         $action->executeAction();
     }
     // get outdated news
     $entryList = new EntryList();
     $entryList->getConditionBuilder()->add('news_entry.isArchived = 0');
     $entryList->getConditionBuilder()->add('news_entry.time <= ?', array(TIME_NOW - CMS_NEWS_DAYS_TO_ARCHIVE * 86400));
     $entryList->readObjects();
     if (count($entryList->getObjects())) {
         // archivate news
         $action = new EntryAction($entryList->getObjects(), 'archive');
         $action->executeAction();
     }
     // get outdated news in archive
     if (CMS_NEWS_DAYS_TO_DELETE_ARCHIVE) {
         $entryList = new NewsList();
         $entryList->getConditionBuilder()->add('news_entry.isArchived = 1');
         $entryList->getConditionBuilder()->add('news_entry.time <= ?', array(TIME_NOW - CMS_NEWS_DAYS_TO_ARCHIVE * 86400 - CMS_NEWS_DAYS_TO_DELETE_ARCHIVE * 86400));
         $entryList->readObjects();
         if (count($entryList->getObjects())) {
             // delete news
             $action = new EntryAction($entryList->getObjects(), 'delete');
             $action->executeAction();
         }
     }
 }
 /**
  * @see wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // TODO
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get user ids
     $userIDs = array();
     $sql = "SELECT\tDISTINCT userID\n\t\t\tFROM\twcf" . WCF_N . "_user_notification\n\t\t\tWHERE\tmailNotified = ?\n\t\t\t\tAND time < ?\n\t\t\t\tAND confirmTime = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, TIME_NOW - 3600 * 23, 0));
     while ($row = $statement->fetchArray()) {
         $userIDs[] = $row['userID'];
     }
     if (empty($userIDs)) {
         return;
     }
     // get users
     $userList = new UserList();
     $userList->setObjectIDs($userIDs);
     $userList->readObjects();
     $users = $userList->getObjects();
     // get notifications
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("notification.userID IN (?)", array($userIDs));
     $conditions->add("notification.mailNotified = ?", array(0));
     $conditions->add("notification.confirmTime = ?", array(0));
     $sql = "SELECT\t\tnotification.*, notification_event.eventID, object_type.objectType\n\t\t\tFROM\t\twcf" . WCF_N . "_user_notification notification\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_notification_event notification_event\n\t\t\tON\t\t(notification_event.eventID = notification.eventID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_object_type object_type\n\t\t\tON\t\t(object_type.objectTypeID = notification_event.objectTypeID)\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tnotification.time";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     // mark notifications as done
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("userID IN (?)", array($userIDs));
     $conditions->add("mailNotified = ?", array(0));
     $sql = "UPDATE\twcf" . WCF_N . "_user_notification\n\t\t\tSET\tmailNotified = 1\n\t\t\t" . $conditions;
     $statement2 = WCF::getDB()->prepareStatement($sql);
     $statement2->execute($conditions->getParameters());
     // collect data
     $eventsToUser = $objectTypes = $eventIDs = $notificationObjects = array();
     $availableObjectTypes = UserNotificationHandler::getInstance()->getAvailableObjectTypes();
     while ($row = $statement->fetchArray()) {
         if (!isset($eventsToUser[$row['userID']])) {
             $eventsToUser[$row['userID']] = array();
         }
         $eventsToUser[$row['userID']][] = $row['notificationID'];
         // cache object types
         if (!isset($objectTypes[$row['objectType']])) {
             $objectTypes[$row['objectType']] = array('objectType' => $availableObjectTypes[$row['objectType']], 'objectIDs' => array(), 'objects' => array());
         }
         $objectTypes[$row['objectType']]['objectIDs'][] = $row['objectID'];
         $eventIDs[] = $row['eventID'];
         $notificationObjects[$row['notificationID']] = new UserNotification(null, $row);
     }
     // load authors
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("notificationID IN (?)", array(array_keys($notificationObjects)));
     $sql = "SELECT\t\tnotificationID, authorID\n\t\t\tFROM\t\twcf" . WCF_N . "_user_notification_author\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\ttime ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $authorIDs = $authorToNotification = array();
     while ($row = $statement->fetchArray()) {
         if ($row['authorID']) {
             $authorIDs[] = $row['authorID'];
         }
         if (!isset($authorToNotification[$row['notificationID']])) {
             $authorToNotification[$row['notificationID']] = array();
         }
         $authorToNotification[$row['notificationID']][] = $row['authorID'];
     }
     // load authors
     $authors = UserProfile::getUserProfiles($authorIDs);
     $unknownAuthor = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
     // load objects associated with each object type
     foreach ($objectTypes as $objectType => $objectData) {
         $objectTypes[$objectType]['objects'] = $objectData['objectType']->getObjectsByIDs($objectData['objectIDs']);
     }
     // load required events
     $eventList = new UserNotificationEventList();
     $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", array($eventIDs));
     $eventList->readObjects();
     $eventObjects = $eventList->getObjects();
     foreach ($eventsToUser as $userID => $events) {
         if (!isset($users[$userID])) {
             continue;
         }
         $user = $users[$userID];
         // no notifications for disabled or banned users
         if ($user->activationCode) {
             continue;
         }
         if ($user->banned) {
             continue;
         }
         // add mail header
         $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', array('user' => $user));
         foreach ($events as $notificationID) {
             $notification = $notificationObjects[$notificationID];
             $className = $eventObjects[$notification->eventID]->className;
             $class = new $className($eventObjects[$notification->eventID]);
             $class->setObject($notification, $objectTypes[$notification->objectType]['objects'][$notification->objectID], isset($authors[$notification->authorID]) ? $authors[$notification->authorID] : $unknownAuthor, $notification->additionalData);
             $class->setLanguage($user->getLanguage());
             if (isset($authorToNotification[$notification->notificationID])) {
                 $eventAuthors = array();
                 foreach ($authorToNotification[$notification->notificationID] as $userID) {
                     if (!$userID) {
                         $eventAuthors[0] = $unknownAuthor;
                     } else {
                         if (isset($authors[$userID])) {
                             $eventAuthors[$userID] = $authors[$userID];
                         }
                     }
                 }
                 if (!empty($eventAuthors)) {
                     $class->setAuthors($eventAuthors);
                 }
             }
             $message .= "\n\n";
             $message .= $class->getEmailMessage('daily');
         }
         // append notification mail footer
         $token = $user->notificationMailToken;
         if (!$token) {
             // generate token if not present
             $token = mb_substr(StringUtil::getHash(serialize(array($user->userID, StringUtil::getRandomID()))), 0, 20);
             $editor = new UserEditor($user);
             $editor->update(array('notificationMailToken' => $token));
         }
         $message .= "\n\n";
         $message .= $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.footer', array('user' => $user, 'token' => $token));
         // build mail
         $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.subject', array('count' => count($events))), $message);
         $mail->setLanguage($user->getLanguage());
         $mail->send();
     }
 }
 /**
  * @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);
                 }
             }
         }
     }));
 }