Lamez Posted October 9, 2008 Share Posted October 9, 2008 ok, I am working on my link checker, and I want it to see if the URL is a link to a youtube video, and if so then I want it to embed it. here is what I have so far, do you guys see any mistakes? <?php $link = parse_url($url); $youtube = $link['host'].$link['path']; $watch = "www.youtube.com/watch"; $watch_2 = "youtube.com/watch"; $watch_3 = "http://www.youtube.com/watch"; $watch_4 = "http://youtube.com/watch"; if($youtube == $watch || $watch_2 || $watch_3 || $watch_4){ print'<object width="425" height="344"><param name="movie" value="'.$link['host'].'/v/'.$link['query'].'=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="'.$link['host'].'/v/'.$link['query'].'=en&fs=1 type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted October 9, 2008 Share Posted October 9, 2008 do you guys see any mistakes? The most obvious is this... if($youtube == $watch || $watch_2 || $watch_3 || $watch_4){ should be.... if ($youtube == $watch || $youtube == $watch_2 || $youtube == $watch_3 || $youtube == $watch_4) { providing you are indeed trying to compare $youtube with all those vars. What exactly is the problem? Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 well the link checker is suppose to check the link for "youtube.com/watch" or something around that, and if the URL does equal that, then show the embedded video on the page. Well no videos shows up. Here is the entire code: <?php ob_start(); $back_address = 'http://www.krazypicks.com'; if(isset($_SESSION['over_title'])){ $title = $_SESSION['over_title']; }else{ $title = "KrazyPicks"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="http://www.krazypicks.com/main/style/img/favicon.ico" /> <title>External Link Checker</title> </head> <body bgcolor="#336699"> <table width="100%" border="0"> <tr> <td width="28%"> </td> <td width="46%" align="center" valign="middle"><font face="Tahoma" color="#FFFFFF" size="30pt"><?php echo $title; ?></font></td> <td width="26%"> </td> </tr> <tr> <td> </td> <td rowspan="9" align="center" valign="middle" bgcolor="#FFFFFF"> <font face="Arial, Helvetica, sans-serif"> <?php $links = "<a href=\"http://www.krazypicks.com\">".$title."</a> or <a href=\"?\">Enter URL</a>"; $switch = md5("fladkfkladhfhjkasdfhjkasdhfjkhasjkgfjkasdhfljaskldj///****////***/4564645647978979749899894949494a8df49ad//***/*/*/**/*/*/*/*/*/*/*/*/*//*////****fklajsdkl;fhasdgfjkasdjkfasdflk;jkldsfjklasdhfjkgasjkdfhjkas-----------------fffffd"); if($_GET['url'] == ($switch)){ echo $links; }else{ $url = htmlspecialchars($_GET["url"]); if(empty($url)){ //header("Location: ".$back_address); print' Enter URL<br> <form id="form1" name="form1" method="get" action="?"> <label> <input name="url" type="text" id="url" size="50" maxlength="100" /> </label> <input type="submit" name="'.md5("go_s").'" id="'.md5("go_s").'" value="Go!" /> </form><br> <a href="http://www.krazypicks.com">'.$title.'</a> :: <a href="http://www.servage.net/?coupon=cust33591">Hosted by Servage</a>'; }else{ $url = $_GET['url']; $form = $url; if ($form != '' && strpos(strtolower($form), 'http://') !== 0) $form = 'http://'.$form; $url = $form; } $churl = @fopen($url,'r'); if (!$churl && !empty($url)) { echo "<br><center>The URL does not exist, or the server is down.<br>".$links."</center>"; }else{ if (!isset($_GET["url"])){ //header("Location: http://www.krazypicks.com"); }else{ $link = parse_url($url); $youtube = $link['host'].$link['path']; $watch = "www.youtube.com/watch"; $watch_2 = "youtube.com/watch"; $watch_3 = "http://www.youtube.com/watch"; $watch_4 = "http://youtube.com/watch"; if ($youtube == $watch || $youtube == $watch_2 || $youtube == $watch_3 || $youtube == $watch_4) { print'<object width="425" height="344"><param name="movie" value="'.$link['host'].'/v/'.$link['query'].'=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="'.$link['host'].'/v/'.$link['query'].'=en&fs=1 type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'; } echo "<BR> <BR>"; echo "<center>You are about to leave ".$title." to an external link. <br>Do you want to continue?"; echo "<br>External Link: ".$url."</center>"; ?> <br> <center> <form id="form1" name="form1" method="post" action=""> Yes <label> <input type="radio" name="con_tin" id="radio" value="yes" /> </label> No <label> <input type="radio" name="con_tin" id="radio2" value="no" /> </label> <label> <input type="submit" name="button" id="button" value="Continue" /> </label> </form> </center> <?php } } if (isset($_POST['con_tin'])){ if ($_POST['con_tin'] == ("yes")){ header("Location: ".$url); }else{ //header("Location: ".$back_address); header("Location: ?url=".$switch); } } } ?> </font> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
trq Posted October 9, 2008 Share Posted October 9, 2008 Sorry man but that code is all over the place. Your using $_GET['url'] in many places then suddenly about half way down the script you decide to check if it exists. I would suggest the problem you describe is not the only issue with this script. Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 lol I thought that was coming up. I will clean it up, and if I am stilling having a problem I will post back. Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 here it is, but a bit cleaner. No luck either. <?php ob_start(); $connection = mysql_connect("server", "****", "****"); mysql_select_db("****", $connection); $results = mysql_query("SELECT * FROM `site`")or die(mysql_error()); $row = mysql_fetch_array($results)or die(mysql_error()); $title = $row['name']; $back_address = 'http://www.krazypicks.com'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="http://www.krazypicks.com/main/style/img/favicon.ico" /> <title>External Link Checker</title> </head> <body bgcolor="#336699"> <table width="100%" border="0"> <tr> <td width="28%"> </td> <td width="46%" align="center" valign="middle"><font face="Tahoma" color="#FFFFFF" size="30pt"><?php echo $title; ?></font></td> <td width="26%"> </td> </tr> <tr> <td> </td> <td rowspan="9" align="center" valign="middle" bgcolor="#FFFFFF"> <font face="Arial, Helvetica, sans-serif"> <?php $links = "<a href=\"http://www.krazypicks.com\">".$title."</a> or <a href=\"?\">Enter URL</a>"; $switch = md5("fladkfkladhfhjkasdfhjkasdhfjkhasjkgfjkasdhfljaskldj///****////***/4564645647978979749899894949494a8df49ad//***/*/*/**/*/*/*/*/*/*/*/*/*//*////****fklajsdkl;fhasdgfjkasdjkfasdflk;jkldsfjklasdhfjkgasjkdfhjkas-----------------fffffd"); $url = $_GET['url']; $url = htmlspecialchars($url); if($url == ($switch)){ echo $links; }else{ if(empty($url)){ //header("Location: ".$back_address); print' Enter URL<br> <form id="form1" name="form1" method="get" action="?"> <label> <input name="url" type="text" id="url" size="50" maxlength="100" /> </label> <input type="submit" name="'.md5("go_s").'" id="'.md5("go_s").'" value="Go!" /> </form><br> <a href="http://www.krazypicks.com">'.$title.'</a> :: <a href="http://www.servage.net/?coupon=cust33591">Hosted by Servage</a>'; }else{ $url = $_GET['url']; $form = $url; if($form != '' && strpos(strtolower($form), 'http://') !== 0){ $form = 'http://'.$form; $url = $form; } $churl = @fopen($url,'r'); if (!$churl && !empty($url)){ echo "<br><center>The URL does not exist, or the server is down.<br>".$links."</center>"; }else{ if (!isset($url)){ header("Location: ?");//do I really need this? }else{ $link = parse_url($url); $youtube = $link['host'].$link['path']; $watch = "www.youtube.com/watch"; $watch_2 = "youtube.com/watch"; $watch_3 = "http://www.youtube.com/watch"; $watch_4 = "http://youtube.com/watch"; if ($youtube == $watch || $youtube == $watch_2 || $youtube == $watch_3 || $youtube == $watch_4) { print'<object width="425" height="344"><param name="movie" value="'.$link['host'].'/v/'.$link['query'].'=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="'.$link['host'].'/v/'.$link['query'].'=en&fs=1 type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'; } echo "<BR> <BR>"; echo "<center>You are about to leave ".$title." to an external link. <br>Do you want to continue?"; echo "<br>External Link: ".$url."</center>"; ?> <br> <center> <form id="form1" name="form1" method="post" action=""> Yes <label> <input type="radio" name="con_tin" id="radio" value="yes" /> </label> No <label> <input type="radio" name="con_tin" id="radio2" value="no" /> </label> <label> <input type="submit" name="button" id="button" value="Continue" /> </label> </form> </center> <?php } } } if (isset($_POST['con_tin'])){ if ($_POST['con_tin'] == ("yes")){ header("Location: ".$url); }else{ //header("Location: ".$back_address); header("Location: ?url=".$switch); } } }//end first else, about swtich. ?> </font> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 ok, I have figured out the problem, the query string it coming out like this: v=HciEQwPu3xY it needs to be this v/HciEQwPu3xY so how can I take off the v= ? -Thanks Guys! Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 fixed <?php $link = parse_url($url); $youtube = $link['host'].$link['path']; $watch = "www.youtube.com/watch"; $watch_2 = "youtube.com/watch"; $watch_3 = "http://www.youtube.com/watch"; $watch_4 = "http://youtube.com/watch"; $qu = $link['query']; $string = $qu; $qu = str_replace("v=", "", $string ); if ($youtube == $watch || $youtube == $watch_2 || $youtube == $watch_3 || $youtube == $watch_4) { print'<object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/'.$qu.'&hl=en&fs=1&color1=0x006699&color2=0x54abd6&border=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/'.$qu.'&hl=en&fs=1&color1=0x006699&color2=0x54abd6&border=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="349"></embed></object>'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.