/** * Change the status of a link */ function lxStatusLink() { global $json, $DB; VerifyPrivileges(P_LINK_MODIFY, TRUE); if (!is_array($_REQUEST['link_id'])) { $_REQUEST['link_id'] = array($_REQUEST['link_id']); } $new_status = $_REQUEST['w'] == 'activate' ? 'active' : 'disabled'; foreach ($_REQUEST['link_id'] as $link_id) { $DB->Update('UPDATE lx_links SET status=? WHERE link_id=?', array($new_status, $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_id)); while ($category = $DB->NextRow($result)) { UpdateLinkCount($category['category_id']); } $DB->Free($result); } echo $json->encode(array('status' => JSON_SUCCESS, 'message' => 'The selected links have had their status updated')); }
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; }
function lxMoveLink() { global $DB, $C; VerifyPrivileges(P_LINK_MODIFY); $_REQUEST['link_id'] = explode(',', $_REQUEST['link_id']); $v = new Validator(); $v->Register($_REQUEST['category_id'], V_EMPTY, 'Please select at least one category'); if (!$v->Validate()) { $GLOBALS['errstr'] = join('<br />', $v->GetErrors()); lxShMoveLink(); return; } $categories = explode(',', $_REQUEST['category_id']); foreach ($_REQUEST['link_id'] as $link_id) { $link_cats =& $DB->FetchAll('SELECT * FROM lx_link_cats WHERE link_id=?', array($link_id)); $DB->Update('DELETE FROM lx_link_cats WHERE link_id=?', array($link_id)); foreach ($link_cats as $link_cat) { UpdateLinkCount($link_cat['category_id']); ClearCategoryCache($link_cat['category_id']); } foreach ($categories as $category_id) { $DB->Update('INSERT INTO lx_link_cats VALUES (?,?,?)', array($link_id, $category_id, null)); UpdateLinkCount($category_id); ClearCategoryCache($category_id); } } $message = 'The selected links have been moved to their new categories'; include_once 'includes/message.php'; }
// distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. define('LINKX', TRUE); require_once '../includes/common.php'; require_once "{$GLOBALS['BASE_DIR']}/includes/mysql.class.php"; require_once "{$GLOBALS['BASE_DIR']}/admin/includes/functions.php"; $DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']); $DB->Connect(); echo "Re-counting sub-categories and links per category..."; flush(); $result = $DB->Query('SELECT * FROM lx_categories'); while ($category = $DB->NextRow($result)) { UpdateSubcategoryCount($category['category_id']); UpdateLinkCount($category['category_id']); } $DB->Free($result); echo "done<br />"; flush(); echo "Re-counting comments..."; flush(); $result = $DB->Query('SELECT * FROM lx_links'); while ($link = $DB->NextRow($result)) { $comments = $DB->Count('SELECT COUNT(*) FROM lx_link_comments WHERE link_id=?', array($link['link_id'])); $DB->Update('UPDATE lx_links SET comments=? WHERE link_id=?', array($comments, $link['link_id'])); } $DB->Free($result); echo "done<br />"; flush(); echo "Re-counting links per account...";