Ok i have a tinyurl service: http://dd1.us/ but i want to block links from Rapidshare.com Rapidshare.de megaupload.com Here are all the files that would be necessary to be edited to do this: Index.html <img src="http://dd1.us/img/logo1.png"><br> <h1>Free Short Url Redirection</h1> <div class="spacer"><span></span></div> <form method="post" action="create.php"> <p> <label title="Enter Long Url Here | http:// To Make It Work"> <input type="text" name="url" size="40" value="http://" /></label><br /> <label title="Submit URL To Make A Tinyurl"> <input type="submit" name="send" value="Make It Short!" class="submit" /></label></p> <div class="spacer"><span></span></div> </form> Code (markup): .htaccess RewriteEngine on RewriteRule ^([0-9]+)/?$ /go.php?id=$1 [L] Code (markup): Create.php include("config.php"); if (strstr($_SERVER['HTTP_REFERER'], $root)); else { header ("Location: $rooturl"); } $ip = $_SERVER['REMOTE_ADDR']; $url = $_POST['url']; if(preg_match('|^http(s)?://[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) { $query = "INSERT INTO $table (ip,url) VALUES ('$ip','$url')" or die('MySQL error: '.mysql_error()); mysql_query($query); $qs = mysql_insert_id(); $link = $destination . $qs; require 'create_template.php'; } else { echo 'Your URL is invalid'; } ?> PHP: Create_template.php <? echo "<center>Your New Short URL: <a href=$rooturl" . $qs . " target=_blank>$rooturl" . $qs . "</a></center><br />"; ?> <div id="content"> PHP: go.php ob_start(); include("config.php"); ?> <? $id = $_GET['id']; if($id){ $qs = mysql_query("SELECT url FROM $table WHERE id = $id") or die('MySQL error: '.mysql_error()); mysql_query("UPDATE url SET count=(count + 1) WHERE id = $id"); while($data = mysql_fetch_array($qs)){ if ($frame == 1) { echo include("frame.php"); echo "<iframe name=\"pagetext\" height=\"100%\" frameborder=\"no\" width=\"100%\" src=\"$data[0]\"></iframe>"; } else if ($frame == 0) { echo header("Location: $data[0]"); } } }else{ ?> <?} ob_flush(); ?> PHP: These Are The Major Files IF there is way to block certain urls please let me know
$parts = pars_url($url); $host = strtolower($parts['host']); $host = preg_replace('~^www\.~', null, $host); $blocked = array('rapidshare.com', 'rapidshare.de', 'megaupload.com'); if (in_array($host, $blocked)) { // Blocked } else { // Ok } PHP:
^^^^^^ And if you get errors, you gotta come a bit more specific than that. How am I supposed to help if you tell me "I get errors"?
In Create_Template.php --- The error is: Fatal error: Call to undefined function pars_url() in /home/duffy0/public_html/dd1.us/create_template.php on line 38 Line 38 is: $parts = pars_url($url); ------------------------------------------------ In Create.php -- The error is: Fatal error: Call to undefined function pars_url() in /home/duffy0/public_html/dd1.us/create.php on line 27 Line 27: $parts = pars_url($url); ----------------------------------------------- In Index.php -- The Error is: Fatal error: Call to undefined function pars_url() in /home/duffy0/public_html/dd1.us/index.php on line 28 Line 28: $parts = pars_url($url);
ok i added it to create.php but it just ignores it acts like it is not even there no errors just runs hte regular script normal