$configuration = unserialize($config['configuration']); // See if another instance of this scanner configuration is already running if ($config['pid'] != 0 && $config['status_updated'] > time() - 300) { echo "This scanner configuration is already running\n"; exit; } // Clear previous scan results $DB->Update('DELETE FROM `tlx_scanner_results` WHERE `config_id`=?', array($config_id)); // Set the last run time, pid, and status $DB->Update('UPDATE `tlx_scanner_configs` SET `current_status`=?,`status_updated`=?,`date_last_run`=?,`pid`=? WHERE `config_id`=?', array('Starting...', time(), MYSQL_NOW, getmypid(), $config_id)); // Setup the MySQL query $s =& GenerateQuery(); // Get the galleries to scan $result = $DB->Query($s->Generate(), $s->binds); $current_account = 0; $total_accounts = $DB->NumRows($result); // Create history entry $DB->Update('INSERT INTO `tlx_scanner_history` VALUES (?,?,?,?,?,?,?,?,?,?)', array(null, $config_id, MYSQL_NOW, null, $total_accounts, 0, 0, 0, 0, 0)); $history_id = $DB->InsertID(); if ($total_accounts == 0) { $DB->Update('UPDATE `tlx_scanner_configs` SET `current_status`=?,`status_updated`=? WHERE `config_id`=?', array("No accounts to scan - exiting", time(), $config_id)); sleep(10); } while ($account = $DB->NextRow($result)) { $exception = 0x0; $current_account++; // Exit if stopped (pid set to 0) $pid = $DB->Count('SELECT `pid` FROM `tlx_scanner_configs` WHERE `config_id`=?', array($config_id)); if ($pid == 0) { break; }
$configuration = unserialize($config['configuration']); // See if another instance of this scanner configuration is already running if ($config['pid'] != 0 && $config['status_updated'] > time() - 300) { echo "This scanner configuration is already running\n"; exit; } // Clear previous scan results $DB->Update('DELETE FROM lx_scanner_results WHERE config_id=?', array($config_id)); // Set the last run time, pid, and status $DB->Update('UPDATE lx_scanner_configs SET current_status=?,status_updated=?,date_last_run=?,pid=? WHERE config_id=?', array('Starting...', time(), MYSQL_NOW, getmypid(), $config_id)); // Setup the MySQL query qualifier $qualifier = SetupQualifier(); // Get the links to scan $result = $DB->Query("SELECT * FROM lx_links JOIN lx_link_cats USING (link_id) {$qualifier}"); $current_link = 0; $total_links = $DB->NumRows($result); while ($link = $DB->NextRow($result)) { $updates = array('placeholders' => array(), 'binds' => array()); $exception = 0x0; $current_link++; // Exit if stopped (pid set to 0) $pid = $DB->Count('SELECT pid FROM lx_scanner_configs WHERE config_id=?', array($config_id)); if ($pid == 0) { break; } // Update scanner status $DB->Update('UPDATE lx_scanner_configs SET current_status=?,status_updated=? WHERE config_id=?', array("Scanning link {$current_link} of {$total_links}", time(), $config_id)); // Mark last scan time of the link $DB->Update('UPDATE lx_links SET date_scanned=? WHERE link_id=?', array(MYSQL_NOW, $link['link_id'])); // Scan the link $scan_result =& ScanLink($link);
/** * Write Session data to DB * * @param $ses_id string * @param $data string * @return bool */ public function write($ses_id, $data) { global $db; // If the $db object is not on the page any more recreate it. if (!is_object($db)) { $db = new DB(); $db->Connect(); } if (!isset($this->ses_start)) { $this->ses_start = time(); } $session_sql = 'SELECT * FROM `' . $this->table . '` WHERE `ses_id` = \'' . $ses_id . '\' LIMIT 1'; $res = $db->Query($session_sql, $this->db, false); if ($db->NumRows($res) == 0) { $type = 'insert'; $extra = ''; $info = array('ses_id' => $ses_id, 'last_access' => time(), 'ses_start' => $this->ses_start, 'ses_value' => serialize($data)); } else { $type = 'update'; $extra = '`ses_id` = \'' . $ses_id . '\''; $info = array('last_access' => time(), 'ses_value' => serialize($data)); } // Do the Operation $session_res = $db->Perform($this->table, $info, $type, $extra, $this->db, false); if (!$session_res) { return false; } return true; }
// Clear previous scan results $DB->Update('DELETE FROM `tx_scanner_results` WHERE `config_id`=?', array($config_id)); // Make sure safe_mode is disabled if (ini_get('safe_mode')) { $DB->Update('UPDATE `tx_scanner_configs` SET `current_status`=?,`status_updated`=?,`date_last_run`=?,`pid`=? WHERE `config_id`=?', array('ERROR: The CLI version of PHP is running with safe_mode enabled', time(), MYSQL_NOW, getmypid(), $config_id)); echo "ERROR: The CLI version of PHP is running with safe_mode enabled\n"; exit; } // Set the last run time, pid, and status $DB->Update('UPDATE `tx_scanner_configs` SET `current_status`=?,`status_updated`=?,`date_last_run`=?,`pid`=? WHERE `config_id`=?', array('Starting...', time(), MYSQL_NOW, getmypid(), $config_id)); // Import galleries from RSS before starting the scan if ($configuration['import_rss']) { // Update scanner status $DB->Update('UPDATE `tx_scanner_configs` SET `current_status`=?,`status_updated`=? WHERE `config_id`=?', array("Importing galleries from RSS", time(), $config_id)); $result = $DB->Query('SELECT * FROM `tx_rss_feeds`'); $total_feeds = $DB->NumRows($result); $current_feed = 0; while ($feed = $DB->NextRow($result)) { $current_feed++; $DB->Update('UPDATE `tx_scanner_configs` SET `current_status`=?,`status_updated`=? WHERE `config_id`=?', array("Importing galleries from RSS feed {$current_feed} of {$total_feeds}", time(), $config_id)); ImportFromRss($feed); } $DB->Free($result); } // Setup the MySQL query $s =& GenerateQuery(); // Get the galleries to scan $result = $DB->Query($s->Generate(), $s->binds); $current_gallery = 0; $total_galleries = $DB->NumRows($result); // Create history entry