/**
  * @see Cronjob::execute()
  */
 public function execute($data)
 {
     // read settings ***********************************
     $this->atSettings = AdminTools::getSettings();
     // check last execution time
     $this->atSettings['cronLastRun'] = intval($this->atSettings['cronLastRun']);
     if ($this->atSettings['cronLastRun'] < TIME_NOW - 3600) {
         $sql = "UPDATE wcf" . WCF_N . "_admin_tool_setting" . "\n   SET atse_value = '" . TIME_NOW . "'" . "\n WHERE atse_name = 'cronLastRun'";
         WCF::getDB()->sendQuery($sql);
     } else {
         return;
     }
     // WBB-LOG *****************************************
     if (!empty($this->atSettings['cronDelLogDays'])) {
         WCF::getDB()->sendQuery("DELETE FROM wcf" . WCF_N . "_cronjobs_log WHERE execTime < " . (time() - $this->atSettings['cronDelLogDays'] * 86400));
     }
     // delete PNs **************************************
     if (!empty($this->atSettings['cronDelPmDays'])) {
         $dPMs = $cnt = 0;
         $sql = "SELECT pmID" . "\n  FROM wcf" . WCF_N . "_pm" . "\n WHERE time < " . (time() - $this->atSettings['cronDelPmDays'] * 86400);
         if (!empty($this->atSettings['cronDelPmDaysExclUgrps'])) {
             $sql .= "\n   AND userID NOT IN (SELECT userID FROM wcf" . WCF_N . "_user_to_groups WHERE groupID IN (" . $this->atSettings['cronDelPmDaysExclUgrps'] . "))";
         }
         if (!empty($this->atSettings['cronDelPmDaysExclUser'])) {
             $sql .= "\n   AND userID NOT IN (" . $this->atSettings['cronDelPmDaysExclUser'] . ")";
         }
         if (!empty($this->atSettings['cronDelPmDaysExclFolder'])) {
             $sql .= "\n   AND pmID NOT IN (SELECT pmID FROM wcf" . WCF_N . "_pm_to_user WHERE folderID > 0)";
         }
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $cnt++;
             $this->pmDelCnt++;
             $dPMs .= ',' . $row['pmID'];
             if ($cnt % 50 == 0) {
                 AdminTools::deletePMs($dPMs);
                 $cnt = 0;
                 $dPMs = 0;
             }
         }
         if (!empty($dPMs)) {
             AdminTools::deletePMs($dPMs);
         }
     }
     // delete inactive user ****************************
     if (!empty($this->atSettings['cronDelInactiveUserDays']) && $this->atSettings['cronDelInactiveUserDays'] > 0) {
         AdminTools::deleteInactiveUser($this->atSettings['cronDelInactiveUserDays'], $this->atSettings['cronDelInactiveUserExcl'], $this->atSettings['cronDelInactiveUserExclUgrps']);
     }
     // check moved threads
     AdminTools::cronCheckMovedThreads(intval($this->atSettings['cronDelMovedThreadDays']));
     // archive
     AdminTools::cronThreadArchive($this->atSettings);
     // cleanup subscriptions
     if (!empty($this->atSettings['cronCleanUpSubscriptions'])) {
         AdminTools::cronCleanUpSubscriptions();
     }
     // spider ******************************************
     AdminTools::syncSpider();
     // journal *****************************************
     AdminTools::cronRunJournal($this->pmDelCnt, $this->atSettings['cronLogEnabled'], $this->atSettings['cronStatEnabled'], $this->atSettings['cronLogUseAdminEmail']);
     // DB **********************************************
     AdminTools::cronRunDB($this->atSettings['cronDbAnalyze'], $this->atSettings['cronDbOptimize'], $this->atSettings['cronDbBackup']);
 }
 private function importSpider()
 {
     if (!empty($_FILES['importSpider']['tmp_name']) && is_uploaded_file($_FILES['importSpider']['tmp_name'])) {
         $csv = file($_FILES['importSpider']['tmp_name']);
         $spiders = array();
         $i = 0;
         if (count($csv)) {
             foreach ($csv as $line) {
                 $line = trim($line);
                 if (preg_match('/^"/', $line)) {
                     $spiderIdentifier = $spiderName = $spiderURL = '';
                     list($spiderIdentifier, $spiderName, $spiderURL) = preg_split('/";"/', $line, 3);
                     $spiderIdentifier = preg_replace('/^"/', '', $spiderIdentifier);
                     if ($spiderURL) {
                         $spiderURL = preg_replace('/"$/', '', $spiderURL);
                     }
                     if (!empty($spiderIdentifier) && !empty($spiderName)) {
                         $spiders[$i]['spiderIdentifier'] = $spiderIdentifier;
                         $spiders[$i]['spiderName'] = $spiderName;
                         $spiders[$i]['spiderURL'] = $spiderURL;
                         $i++;
                     }
                 }
             }
         }
         if (count($spiders)) {
             $sql = "TRUNCATE TABLE wcf" . WCF_N . "_admin_tool_spider";
             WCF::getDB()->sendQuery($sql);
             foreach ($spiders as $k => $v) {
                 $sql = "INSERT INTO wcf" . WCF_N . "_admin_tool_spider" . "\n       (spiderIdentifier, spiderName, spiderURL)" . "\nVALUES ('" . WCF::getDB()->escapeString($v['spiderIdentifier']) . "', '" . WCF::getDB()->escapeString($v['spiderName']) . "', '" . WCF::getDB()->escapeString($v['spiderURL']) . "')";
                 WCF::getDB()->sendQuery($sql);
             }
         }
         AdminTools::syncSpider(true);
     }
 }