|
Home
iRate! IceMelon IM Tutorials Headlines CoolSites PHP Functions |
Taking tutorial submissions! Please email them to dave[AT]icemelon[DOT]com for review. Thanks!
Latest Tutorials IceMelon IM: Add IM Functionality to phpBB [Misc] Want to add site-wide member IM to your phpBB community? Sure you do. Simple step-by-step instructions inside. IceMelon IM: Add IM Functionality to vBulletin [Misc] Want to add site-wide member IM to your vBulletin community? Simple step-by-step instructions inside. Crawl Your Site for PageRanks [PHP] So you know your site has a PageRank of 8. What about the PRs of all the inner pages? This tutorial will teach how you to automate the process of grabbing all these PRs. Create CAPTCHA images [PHP] Worried about bots? Then create CAPTCHA images to prevent bots from taking advantage of your site. Convert SHN and FLAC files to MP3 [Misc] Low on disk space and have an insensitive ear? Here are some steps to converting SHN and FLAC files to MP3 format. [View All] Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m. |
Awesome Tutorials
Prevent Hotlinking By dave
This is a cool tutorial. I have thoroughly tested the method outlined below on my flash videos site, HiBot [http://www.hibot.com]. I use it to prevent other webmasters to link to my files. In fact, it will also hide the the source urls to my files.
Ok, let us begin... Yes, let us begin... You will need to start a session and define an arbitrary session variable. (Check out the sessions tutorial if you're unfamiliar with sessions.) // e.g. session_start(); $_SESSION['arbitrary'] = 'twister'; The point of this is to later determine that the visitor is accessing your file from your server (i.e. from your site, not from Pablo's ripoff site).Let's say you want to embed a flash file. Do it like so.. <embed src=flashfile.php?file=$name quality=high type='application/x-shockwave-flash' pluginspace='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED> I left out some parameters, but what you should note is the flash file's source: "flashfile.php?file=$name." The magic lies in flashfile.php...flashfile.php <? session_start(); error_reporting(0); if(isset($_GET['file']) && $_SESSION['arbitrary'] == "twister") { Header("Content-type: application/x-shockwave-flash"); $open = "convolutedFilePath/$_GET[file].swf"; readfile( $open ); } ?> Yes, it is very concise. First, we must start a session to detect the variable we set earlier, $_SESSION['arbitrary']. This is done in the IF clause. If things check out alright in the IF clause, we will then... 1) send the appropriate header information, so that the visiting computer knows to expect flash file data, and 2) and read the requested file using readfile. Note also that error_reporting is set to 0, which means that no errors will be reported. This is done in case your visitors get sly and try probing around to download your flash files. Depending on your default PHP settings, they may be able to download flashfile.php and find an error message that will give away "convolutedFilePath." To prevent this from happening, set error_reporting to 0. Ok, that's a wrap. I'll leave you with some... related PHP functions... » getimagesize() » filesize() and header info for other file types... Header("Content-type: video/mpeg"); Header("Content-type: video/x-ms-wmv"); P.S. Check out my new site TheManWhoSoldtheWeb.com, where I publish guides and scripts on Internet Marketing and SEO. Here is a limited time freebie: the Rapid Google Indexer. |