<?php

    
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    | Scriptname : Info Sender's PHP Sidekick v1.0
    | Author     : appel [-at-] nr78.net
    | Website    : http://nr78.net
    * ----------------------------------------------------------------

      This script stores the song title sent by Info Sender into a
      flatfile, and forms a link to an external site (like Google
      or Musicmoz) accordingly. Simply include this file on the spot
      where you want it to appear. Set $maxchar to the maximum
      amount of characters you want to show, set $search_url and
      $search_name to the external site you want the link to point
      to. Also, be sure to create a flatfile (winamp.txt) and chmod
      it 777, or it will choke.
      
      This script is obviously free, so use/modify it anyway you want,
      just let me in on any changes so i can update this puppy.
      A link to nr78.net is ofcourse appreciated, but not mandatory.
      Contact me if you like to change something, but don't know how.

      Tested with Info Sender for Winamp 1.1. For more information
      on Info Sender, check out the author's website at:
      http://www.neuro-tech.net/infosender.html

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

    
$filename = 'winamp.txt';
    
$maxchar = 50;
    
$search_name = 'musicmoz.org'; // google.org
    
$search_url = 'http://musicmoz.org/search/search.cgi?search='; // http://www.google.com/search?q=
    
        // check if Info Sender is calling the script
        
if(isset($_GET['song'])) {

            
// check if text file is writeable
            
if(is_writable($filename)) {

                
// check if we can open the text file
                
if(!$handle = fopen($filename, 'w')) {
                     print
'Cannot open file ('.$filename.')';
                     exit;
                }

                
// check if we can wite to the text file
                
if(!fwrite($handle, htmlentities(stripslashes($_GET['song'])))) {
                    print
'Cannot write to file ('.$filename.')';
                    exit;
                }

            
// close the door behind you
            
fclose($handle);

            }

        } else {

            
// grab song title from text file
            
$songname = @implode('',@file($filename));

            
// construct and print song title with link
            
print('<a href="'.$search_url.urlencode($songname).'" title="search '.$search_name.' for \''.$songname.'\'" target="_blank">');
            print((
strlen($songname)>=$maxchar) ? substr($songname,0,($maxchar-2))."&#8230;" : $songname);
            print(
'</a>');

        }

?>