function txGalleryBlacklistAuto() { global $DB, $json, $C; VerifyPrivileges(P_GALLERY_REMOVE, TRUE); $result = GetWhichGalleries(); $amount = $DB->NumRows($result); while ($gallery = $DB->NextRow($result)) { AutoBlacklist($gallery, $_REQUEST['ban_reason']); DeleteGallery($gallery['gallery_id'], $gallery); } $DB->Free($result); echo $json->encode(array('status' => JSON_SUCCESS, 'message' => "{$amount} galler" . ($amount == 1 ? 'y has' : 'ies have') . " been blacklisted and deleted")); }
function ProcessAccount(&$account, &$exception) { global $configuration, $exceptions, $penalties, $DB, $config_id, $history_id; $removed = FALSE; $message = ''; $penalty = 0x0; $reasons = array('connect' => "Connection error: {$account['http']->errstr}", 'forward' => "Redirecting URL: {$account['http']->response_headers['status']}", 'broken' => "Broken URL: {$account['http']->response_headers['status']}", 'blacklist' => "Blacklisted data: " . htmlspecialchars($account['blacklist_item'])); // Determine the most strict penalty based on the infractions that were found foreach ($exceptions as $key => $value) { if ($exception & $value && $configuration['action_' . $key] >= $penalty) { $message = $reasons[$key]; $penalty = intval($configuration['action_' . $key], 16); } } // Blacklist if ($penalty & $penalties['blacklist']) { $action = 'Blacklisted'; $removed = TRUE; AutoBlacklist($account); DeleteAccount($account['username'], $account); // Update history $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`blacklisted`=`blacklisted`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['delete']) { $action = 'Deleted'; $removed = TRUE; DeleteAccount($account['username'], $account); // Update history $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`deleted`=`deleted`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['disable']) { $action = 'Disabled'; // Disable account $DB->Update('UPDATE `tlx_accounts` SET `disabled`=1 WHERE `username`=?', array($account['username'])); // Update history $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`disabled`=`disabled`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['report']) { $action = 'Unchanged'; // Update history $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1 WHERE `history_id`=?', array($history_id)); } else { // Do nothing $exception = 0x0; return $removed; } } } } $DB->Update('INSERT INTO `tlx_scanner_results` VALUES (?,?,?,?,?,?,?)', array($config_id, $account['username'], $account['site_url'], $account['http']->response_headers['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message)); return $removed; }
function ProcessLink(&$link, &$scan_result, $exception) { global $configuration, $exceptions, $penalties, $DB, $config_id; $deleted = FALSE; $message = ''; $penalty = 0x0; $reasons = array('connect' => "Connection Error: {$scan_result['site_url']['error']}", 'forward' => "Redirecting URL: {$scan_result['site_url']['status']}", 'broken' => "Broken URL: {$scan_result['site_url']['status']}", 'blacklist' => "Blacklisted Data: " . htmlspecialchars($scan_result['blacklist_item']), 'norecip' => "No Reciprocal Link Found"); // Determine the most strict penalty based on the infractions that were found foreach ($exceptions as $key => $value) { if ($exception & $value && $configuration['action_' . $key] >= $penalty) { $message = $reasons[$key]; $penalty = intval($configuration['action_' . $key], 16); } } // Blacklist if ($penalty & $penalties['blacklist']) { $action = 'Blacklisted'; $deleted = TRUE; AutoBlacklist($link); DeleteLink($link['link_id'], TRUE, $link); } else { if ($penalty & $penalties['delete']) { $action = 'Deleted'; $deleted = TRUE; DeleteLink($link['link_id'], TRUE, $link); } else { if ($penalty & $penalties['disable']) { $action = 'Disabled'; // Don't re-disable a link if ($link['status'] != 'disabled') { $DB->Update('UPDATE lx_links SET status=? WHERE link_id=?', array('disabled', $link['link_id'])); // Update category link count $result = $DB->Query('SELECT category_id FROM lx_links JOIN lx_link_cats USING (link_id) WHERE lx_links.link_id=?', array($link['link_id'])); while ($category = $DB->NextRow($result)) { UpdateLinkCount($category['category_id']); } $DB->Free($result); } } else { if ($penalty & $penalties['report']) { $action = 'Unchanged'; } else { // Do nothing return FALSE; } } } } $DB->Update('INSERT INTO lx_scanner_results VALUES (?,?,?,?,?,?,?)', array($config_id, $link['link_id'], $link['site_url'], $scan_result['site_url']['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message)); return $deleted; }
/** * Process a bad link report */ function lxProcessReport() { global $DB, $json, $C; VerifyPrivileges(P_LINK_MODIFY, TRUE); if (!is_array($_REQUEST['report_id'])) { $_REQUEST['report_id'] = array($_REQUEST['report_id']); } foreach ($_REQUEST['report_id'] as $report_id) { $report = $DB->Row('SELECT * FROM lx_reports WHERE report_id=?', array($report_id)); if ($report) { $link = $DB->Row('SELECT * FROM lx_links WHERE link_id=?', array($report['link_id'])); switch ($_REQUEST['w']) { case 'delete': DeleteLink($report['link_id'], TRUE, $link); break; case 'blacklist': DeleteLink($report['link_id'], TRUE, $link); AutoBlacklist($link); break; } $DB->Update('DELETE FROM lx_reports WHERE report_id=?', array($report_id)); } } echo $json->encode(array('status' => JSON_SUCCESS, 'message' => 'The selected link reports have been processed')); }
function ProcessGallery(&$gallery, &$scan, &$exception) { global $configuration, $exceptions, $penalties, $DB, $config_id, $history_id; $removed = FALSE; $message = ''; $penalty = 0x0; $reasons = array('connect' => "Connection error: {$scan['errstr']}", 'forward' => "Redirecting URL: {$scan['status']}", 'broken' => "Broken URL: {$scan['status']}", 'blacklist' => "Blacklisted data: " . htmlspecialchars($scan['blacklist_item']), 'norecip' => "No reciprocal link found", 'no2257' => "No 2257 code found", 'excessivelinks' => "Too many links found on the gallery: {$scan['links']}", 'thumbchange' => "Thumbnail count has changed from {$gallery['thumbnails_old']} to {$scan['thumbnails']}", 'pagechange' => "Page content has changed", 'content_server' => 'The gallery content is not hosted on the same server as the gallery', 'badformat' => 'The gallery format is not allowed in this category'); // Determine the most strict penalty based on the infractions that were found foreach ($exceptions as $key => $value) { if ($exception & $value && $configuration['action_' . $key] >= $penalty) { $message = $reasons[$key]; $penalty = intval($configuration['action_' . $key], 16); } } // Blacklist if ($penalty & $penalties['blacklist']) { $action = 'Blacklisted'; $removed = TRUE; AutoBlacklist($gallery); DeleteGallery($gallery['gallery_id'], $gallery); // Update history $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`blacklisted`=`blacklisted`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['delete']) { $action = 'Deleted'; $removed = TRUE; DeleteGallery($gallery['gallery_id'], $gallery); // Update history $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`deleted`=`deleted`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['disable']) { $action = 'Disabled'; // Don't re-disable a gallery if ($gallery['status'] != 'disabled') { //$DB->Update('UPDATE `tx_galleries` SET `status`=?,`admin_comments`=? WHERE `gallery_id`=?', array('disabled', $message, $gallery['gallery_id'])); $gallery['previous_status'] = $gallery['status']; $gallery['status'] = 'disabled'; $gallery['admin_comments'] = $message; } // Update history $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`disabled`=`disabled`+1 WHERE `history_id`=?', array($history_id)); } else { if ($penalty & $penalties['report']) { $action = 'Unchanged'; // Update history $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1 WHERE `history_id`=?', array($history_id)); } else { // Do nothing $exception = 0x0; return $removed; } } } } $DB->Update('INSERT INTO `tx_scanner_results` VALUES (?,?,?,?,?,?,?)', array($config_id, $gallery['gallery_id'], $gallery['gallery_url'], $scan['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message)); return $removed; }