SetFields('url', '1','regex','The URL must be a link to a torrent on the site.',array('regex'=>$URLRegex)); $Err = $Val->ValidateForm($_POST); // Validate the form if ($Err) { // if something didn't validate error($Err); header('Location: '.$_SERVER['HTTP_REFERER']); exit; } // Get torrent ID $URLRegex = '/torrents\.php\?id=([0-9]+)$/i'; preg_match($URLRegex, $URL, $Matches); $GroupID = $Matches[1]; if (empty($GroupID) || !is_number($GroupID)) { error(404); } $DB->query("INSERT INTO torrents_recommended (GroupID, UserID, Time) VALUES ('".db_string($GroupID)."', $LoggedUser[ID], '".sqltime()."')"); Torrents::freeleech_groups($GroupID, 2, 3); $Cache->delete_value('recommend'); header('Location: '.$_SERVER['HTTP_REFERER']); ?>