function DeleteCategory($category_id, $category = null) { global $DB, $ROOT_CATEGORY; if ($category == null) { $category = $DB->Row('SELECT * FROM lx_categories WHERE category_id=?', array($category_id)); } // Remove cache files ClearCategoryCache($category['category_id'], $category['path']); ClearCategoryCache($category['parent_id']); // Delete all sub-categories $result = $DB->Query('SELECT * FROM lx_categories WHERE parent_id=?', array($category_id)); while ($subcategory = $DB->NextRow($result)) { DeleteCategory($subcategory['category_id'], $subcategory); } $DB->Free($result); // Delete all links in this category $result = $DB->Query('SELECT * FROM lx_links JOIN lx_link_cats USING (link_id) WHERE category_id=?', array($category_id)); while ($link = $DB->NextRow($result)) { DeleteLink($link['link_id'], FALSE, $link); } $DB->Free($result); // Delete this category $DB->Update('DELETE FROM lx_categories WHERE category_id=?', array($category_id)); // Update subcategory count for parent category if ($category['parent_id'] != $ROOT_CATEGORY['parent_id']) { UpdateSubcategoryCount($category['parent_id']); } }
function lxBlacklistLink() { global $DB, $C; VerifyPrivileges(P_LINK_REMOVE); foreach (array('url', 'email', 'domain_ip', 'submit_ip') as $type) { if (!empty($_REQUEST[$type])) { if (!$DB->Count('SELECT COUNT(*) FROM lx_blacklist WHERE type=? AND value=?', array($type, $_REQUEST[$type]))) { $DB->Update('INSERT INTO lx_blacklist VALUES (?,?,?,?,?)', array(null, $type, 0, $_REQUEST[$type], $_REQUEST['reason'])); } } } DeleteLink($_REQUEST['link_id']); $message = 'The specified items have been added to the blacklist and the link has been deleted'; $GLOBALS['added'] = TRUE; include_once 'includes/message.php'; }
/** * Process new user accounts (approve/reject) */ function lxNewUser() { global $json, $DB, $C; $t = new Template(); $t->assign_by_ref('config', $C); VerifyPrivileges(P_USER_MODIFY, TRUE); if (!is_array($_REQUEST['username'])) { $_REQUEST['username'] = array($_REQUEST['username']); } foreach ($_REQUEST['username'] as $username) { $account = $DB->Row('SELECT * FROM lx_users JOIN lx_user_fields USING (username) WHERE lx_users.username=?', array($username)); $t->assign_by_ref('account', $account); if ($_REQUEST['w'] == 'approve') { $account['status'] = 'active'; $DB->Update('UPDATE lx_users SET status=? WHERE username=?', array('active', $username)); // Send approval e-mail, if selected if ($_REQUEST['email'] == 'approval') { SendMail($account['email'], 'email-account-added.tpl', $t); } } else { if ($_REQUEST['w'] == 'reject') { // Remove this user's links $result = $DB->Query('SELECT * FROM lx_links WHERE username=?', array($username)); while ($link = $DB->NextRow($result)) { DeleteLink($link['link_id'], TRUE, $link); } $DB->Free($result); // Remove this user's comments $DB->Update('DELETE FROM lx_link_comments WHERE username=?', array($username)); // Remove this user $DB->Update('DELETE FROM lx_user_fields WHERE username=?', array($username)); $DB->Update('DELETE FROM lx_user_confirms WHERE username=?', array($username)); $DB->Update('DELETE FROM lx_users WHERE username=?', array($username)); // Send rejection e-mail, if selected if (!empty($_REQUEST['email']) && $_REQUEST['email'] != 'approval') { $rejection = $DB->Row('SELECT * FROM lx_rejections WHERE email_id=?', array($_REQUEST['email'])); if ($rejection) { SendMail($account['email'], $rejection['plain'], $t, FALSE); } } } } } echo $json->encode(array('status' => JSON_SUCCESS)); }
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; }