#!/usr/bin/perl #--------------------------------------------------------------------- # # WHAT THIS SCRIPT DOES: # ---------------------- # The Sheet Music Plus Web Services requires the use of frames, but frames are not # always the best approach for your website. This script allows you to create links from # non-framed pages that will load a framed page containing the Sheet Music Plus API # search results in the center (body) frame. In other words, you may put links anywhere # you want to pages that will show the Sheet Music Plus content. # # For example, you may create a non-framed page containing artist names and link each # artist to a page that will show the Sheet Music Plus search results in a frame. The # links would point to this script and include the search parameters (see the Sheet Music # Plus API reference document for info on these parameters). # # # HOW IT WORKS # ------------ # This script will take the link parameters that you specified and put them in the URL of # the body frame (this is how you will get the appropriate information the Sheet Music # Plus servers). # # Example: You create a link with URL 'frame-search.pl?wd=bach' # Result: The FRAME-SEARCH.PL script will create a frameset that loads your header and # left column pages in the frame. The body frame will load this URL: # # 'f_searchresults3.html?id=XXX&wd=bach' # # Notice that the parameters from the original link are transferred to the URL # calling the Sheet Music Plus API page. # # Since the URLs used in the frame are hardcoded into this script, you will need to make a # copy of this script if you want to have more than one version of the framed page. For # example, if you want to create links to both Sheet Music Plus searches (using the # F_SEARCHRESULTS3.HTML page) and titles (using the F_DETAIL.HTML page), then you will need # two copies of this scripts and change the URL that is loaded into the body frame. This # script (FRAME-SEARCH.PL) will load the F_SEARCHRESULTS3.HTML page in the body frame. The # FRAME-DETAIL.PL script will load the F_DETAIL.HTML page in the body frame. You may create # copies of these scripts and change the $bodyURL parameter to load a different Sheet Music # Plus Web Services page. # # # HOW TO MODIFY THIS SCRIPT FOR YOUR SERVER: # ------------------------------------------ # Step 1: Change the $affiliateID value below to your affiliate ID code # Step 2: Change the $headerURL and $leftcolURL to the page names you want to load in the # frame # Step 3: Copy this script to your server and set the appropriate permissions (your ISP can # help you with this step) # Step 4: Create links to this script and include whatever parameters you want to include in # the body frame URL. # # Optional: If you want to create a new page that loads a different Sheet Music Plus API page # in the center frame, then you must copy this script (using a new file name) and # edit the new copy. # #--------------------------------------------------------------------- # Change this value to your Sheet Music Plus affiliate ID $affiliateID="56560"; $headerURL="http://www.freesheetmusicguide.com/frame_header.htm"; $leftcolURL="http://www.freesheetmusicguide.com/frame_leftnav.htm"; $bodyURL="http://wwwa.sheetmusicplus.com/a/f_searchresults3.html"; # Initialize the parameter value string, starting with the affiliate ID $paramStr = "id=$affiliateID"; # Examine the parameters to make sure we don't have any "bad stuff" @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Stop people from using subshells to execute commands $value =~ s/~!/ ~!/g; # If value contains a comment or illegal chars, skip this value unless ($value =~ /\<\!--\#(.*)\s+(.*)\s?=\s?(.*)--\>/) { unless ($value =~ /[;><\*`\|]/) { $paramStr.="&$name=$value"; } } } # Create the web page with the search parameters in the body frame URL #print "HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n\n"; print "\n"; print "
\n"; print "