function lxEditLink() { global $DB, $C, $L, $t; $v = new Validator(); // Make sure user is allowed to edit this link $link = $DB->Row('SELECT * FROM lx_links JOIN lx_link_fields USING (link_id) WHERE lx_links.link_id=?', array($_REQUEST['link_id'])); if ($_REQUEST['noaccount']) { if (!empty($link['username']) || $link['site_url'] != $_REQUEST['login_site_url'] || $link['password'] != sha1($_REQUEST['login_password']) || $link['email'] != $_REQUEST['login_email']) { $t->assign('error', $L['LINK_EDIT_REFUSED']); $t->display('error-nice.tpl'); return; } } else { $account = ValidUserLogin(); if (!$account || $account['username'] != $link['username']) { $t->assign('error', $L['LINK_EDIT_REFUSED']); $t->display('error-nice.tpl'); return; } } $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']); $v->Register($_REQUEST['site_url'], V_URL, "{$L['INVALID_URL']}: {$L['SITE_URL']}"); $v->Register($_REQUEST['title'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['TITLE']}"); $v->Register($_REQUEST['description'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['DESCRIPTION']}"); $v->Register($_REQUEST['keywords'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['KEYWORDS']}"); $v->Register($_REQUEST['name'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['NAME']}"); $v->Register($_REQUEST['description'], V_LENGTH, sprintf($L['DESCRIPTION_LENGTH'], $C['min_desc_length'], $C['max_desc_length']), "{$C['min_desc_length']},{$C['max_desc_length']}"); $v->Register($_REQUEST['title'], V_LENGTH, sprintf($L['TITLE_LENGTH'], $C['min_title_length'], $C['max_title_length']), "{$C['min_title_length']},{$C['max_title_length']}"); // Format keywords and check number $_REQUEST['keywords'] = FormatKeywords($_REQUEST['keywords']); $keywords = explode(' ', $_REQUEST['keywords']); $v->Register(count($keywords), V_LESS, sprintf($L['MAXIMUM_KEYWORDS'], $C['max_keywords']), $C['max_keywords']); if (!empty($_REQUEST['password'])) { $v->Register($_REQUEST['password'], V_EQUALS, $L['NO_PASSWORD_MATCH'], $_REQUEST['confirm_password']); } // See if URL already exists if ($DB->Count('SELECT COUNT(*) FROM lx_links WHERE site_url=? AND link_id!=?', array($_REQUEST['site_url'], $link['link_id']))) { $v->SetError($L['DUPLICATE_URL']); } // Validation of user defined fields $fields =& GetUserLinkFields(); foreach ($fields as $field) { if ($field['on_edit']) { if ($field['required']) { $v->Register($_REQUEST[$field['name']], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$field['label']}"); } if ($field['validation']) { $v->Register($_REQUEST[$field['name']], $field['validation'], $field['validation_message'], $field['validation_extras']); } } } $_REQUEST['allow_redirect'] = $link['allow_redirect']; $_REQUEST['recip_required'] = $link['recip_required']; // Scan link $scan_result =& ScanLink($_REQUEST); // Make sure site URL is working if (!$scan_result['site_url']['working']) { $v->SetError(sprintf($L['BROKEN_URL'], $L['SITE_URL'], $scan_result['site_url']['error'])); } // Setup HTML code for blacklist check $_REQUEST['html'] = $scan_result['site_url']['html']; if (!empty($_REQUEST['recip_url'])) { $_REQUEST['html'] .= ' ' . $scan_result['recip_url']['html']; // Make sure recip URL is working if (!$scan_result['recip_url']['working']) { $v->SetError(sprintf($L['BROKEN_URL'], $L['RECIP_URL'], $scan_result['recip_url']['error'])); } } // Verify recip link was found if ($_REQUEST['recip_required'] && !$scan_result['has_recip']) { $v->SetError($L['NO_RECIP_FOUND']); } // Check blacklist $blacklisted = CheckBlacklistLink($_REQUEST); if ($blacklisted !== FALSE) { $v->SetError(sprintf($L['BLACKLIST_MATCHED'], $blacklisted[0]['match'], $blacklisted[0]['reason'])); } if (!$v->Validate()) { $errors = join('<br />', $v->GetErrors()); lxShEdit($errors); return; } if ($C['approve_link_edits']) { $_REQUEST['submit_ip'] = $_SERVER['REMOTE_ADDR']; $DB->Update('UPDATE lx_links SET is_edited=1,edit_data=? WHERE link_id=?', array(base64_encode(serialize($_REQUEST)), $link['link_id'])); } else { // Update password, if necessary $password = $link['password']; if ($_REQUEST['noaccount'] && !empty($_REQUEST['password'])) { $password = sha1($_REQUEST['password']); } // Update link data $DB->Update('UPDATE lx_links SET ' . 'site_url=?, ' . 'recip_url=?, ' . 'title=?, ' . 'description=?, ' . 'name=?, ' . 'email=?, ' . 'submit_ip=?, ' . 'keywords=?, ' . 'date_modified=?, ' . 'password=?, ' . 'has_recip=? ' . 'WHERE link_id=?', array($_REQUEST['site_url'], $_REQUEST['recip_url'], $_REQUEST['title'], $_REQUEST['description'], $_REQUEST['name'], $_REQUEST['email'], $_SERVER['REMOTE_ADDR'], $_REQUEST['keywords'], MYSQL_NOW, $password, $scan_result['has_recip'], $link['link_id'])); // Update user defined fields UserDefinedUpdate('lx_link_fields', 'lx_link_field_defs', 'link_id', $_REQUEST['link_id'], $_REQUEST, FALSE); } // Get category information $categories = array(); $result = $DB->Query('SELECT * FROM lx_categories JOIN lx_link_cats USING (category_id) WHERE link_id=?', array($link['link_id'])); while ($category = $DB->NextRow($result)) { $category['path_parts'] = unserialize($category['path_parts']); $categories[] = $category; } $DB->Free($result); // Show confirmation page $t->assign_by_ref('categories', $categories); $t->assign_by_ref('user_fields', $fields); $t->assign_by_ref('link', $_REQUEST); $t->display('submit-edited.tpl'); flush(); // Send e-mail to appropriate administrators $result = $DB->Query('SELECT * FROM lx_administrators'); while ($admin = $DB->NextRow($result)) { if ($admin['notifications'] & E_LINK_EDIT) { SendMail($admin['email'], 'email-admin-link-edit.tpl', $t); } } $DB->Free($result); }
function lxShScanLink() { global $DB, $C; VerifyPrivileges(P_LINK); $link = $DB->Row('SELECT * FROM lx_links WHERE link_id=?', array($_REQUEST['link_id'])); $results =& ScanLink($link); $link['html'] = $results['site_url']['html']; if (is_array($results['recip_url'])) { $link['html'] .= ' ' . $results['recip_url']['html']; } $blacklisted = CheckBlacklistLink($link, TRUE); $DB->Update('UPDATE lx_links SET date_scanned=?,has_recip=? WHERE link_id=?', array(MYSQL_NOW, $results['has_recip'], $link['link_id'])); include_once 'includes/link-scan.php'; }
if (!empty($scan_result['site_url']['status'])) { if (preg_match('~^3\\d\\d~', $scan_result['site_url']['status'])) { $exception = $exceptions['forward']; } else { $exception = $exceptions['broken']; } } else { $exception = $exceptions['connect']; } } else { // No reciprocal link found if ($link['recip_required'] && !$scan_result['site_url']['has_recip'] && !$scan_result['recip_url']['has_recip']) { $exception |= $exceptions['norecip']; } // Check the blacklist if (($blacklisted = CheckBlacklistLink($link)) !== FALSE) { $exception |= $exceptions['blacklist']; $scan_result['blacklist_item'] = $blacklisted[0]['match']; } $parser = new PageParser(); $parser->parse($scan_result['site_url']['html']); $extracted_title = html_entity_decode(trim($parser->title)); $extracted_description = html_entity_decode(trim($parser->description)); $extracted_keywords = trim(FormatKeywords(html_entity_decode($parser->keywords))); if ($configuration['process_get_title'] && IsEmptyString($link['title'])) { $updates['placeholders'][] = '#=?'; $updates['binds'][] = 'title'; $updates['binds'][] = $extracted_title; } if ($configuration['process_get_description'] && IsEmptyString($link['description'])) { $updates['placeholders'][] = '#=?';