#!/usr/bin/perl # # csRecommend - v1.1 - 052101 ##################################################################### # # # Copyright © 1999-2000 CGISCRIPT.NET - All Rights Reserved # # # ##################################################################### # # # THIS COPYRIGHT INFORMATION MUST REMAIN INTACT # # AND MAY NOT BE MODIFIED IN ANY WAY # # # ##################################################################### # # When you downloaded this script you agreed to accept the terms # of this Agreement. This Agreement is a legal contract, which # specifies the terms of the license and warranty limitation between # you and CGISCRIPT.NET. You should carefully read the following # terms and conditions before installing or using this software. # Unless you have a different license agreement obtained from # CGISCRIPT.NET, installation or use of this software indicates # your acceptance of the license and warranty limitation terms # contained in this Agreement. If you do not agree to the terms of this # Agreement, promptly delete and destroy all copies of the Software. # # Versions of the Software # Only one copy of the registered version of CGISCRIPT.NET # may used on one web site. # # License to Redistribute # Distributing the software and/or documentation with other products # (commercial or otherwise) or by other than electronic means without # CGISCRIPT.NET's prior written permission is forbidden. # All rights to the CGISCRIPT.NET software and documentation not expressly # granted under this Agreement are reserved to CGISCRIPT.NET. # # Disclaimer of Warranty # THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND # WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER # WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE # AND SOFTWARE ENVIRONMENTS INTO WHICH CGISCRIPT.NET MAY BE USED, NO WARRANTY # OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE # ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF CGISCRIPT.NET WILL BE # LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. # IN NO CASE SHALL CGISCRIPT.NET BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR # CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS # OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE # BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT, # NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF # CGISCRIPT.NET IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL # CGISCRIPT.NET' LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID # BY LICENSEE TO CGISCRIPT.NET. # # Credits: # Andy Angrick - Programmer - angrick@cgiscript.net # Mike Barone - Design - mbarone@cgiscript.net # # For information about this script or other scripts see # http://www.cgiscript.net # # Thank you for trying out our script. # If you have any suggestions or ideas for a new innovative script # please direct them to suggest@cgiscript.net. Thanks. # ######################################################################## # Config Variables # ######################################################################## (! -e "setup.cgi")?($nosetup=1):(require("setup.cgi")); (-e "prolib.cgi")?(require ("prolib.cgi")):(require ("demolib.cgi")); ######################################################################## # End Config Variables # ######################################################################## require("libs.cgi"); $in{'cgiurl'} = $cgiurl; (!$htmlurl)&&($htmlurl=$cgiurl); (!$htmlpath)&&($htmlpath=$cgipath); $in{'cgiurl'} = $cgiurl . '/csRecommend.cgi'; $in{'htmlurl'} = $htmlurl; $dd="default"; $in{'cinfo'} = qq|
Powered by csRecommend - © 2000,2001 CGIScript.net |; $| = 1; eval { &main; }; if ($@) { &cgierr("fatal error: $@"); } exit; sub main{ &getdata; print "Content-type: text/html\n\n"; ($in{'command'} eq '')&&($nosetup)&&(&Setup); ($in{'command'} eq 'login')&&(&Login); ($in{'command'} eq 'savesetup')&&(($nosetup)?(&SaveSetup):(&PError("Error. Permission denied."))); ($in{'command'} eq 'send')&&(&Send); ($in{'command'} eq 'showrecommend')&&(&ShowRecommend); ($in{'command'} eq 'showrecommend2')&&(&ShowRecommend2); &GetLogin; ($in{'command'} eq '')&&(&Manage); ($in{'command'} eq 'manage')&&(&Manage); ($in{'command'} eq 'save')&&(&Save); ($in{'command'} eq 'showlinks')&&(&ShowLinks); ($in{'command'} eq 'viewexport')&&(&ViewExport); ($in{'command'} eq 'export')&&(&Export); ($in{'command'} eq 'clearexport')&&(&ClearExport); } sub Login{ &PageOut("$htmlpath/t_login.htm"); exit; } sub GetLogin{ &GetCookies; $in{'UserName'} = $cookie{'UserName'}; $in{'PassWord'} = $cookie{'PassWord'}; if(!$in{'UserName'}){ &PageOut("$htmlpath/t_login.htm"); exit; } else{ (($in{'UserName'} ne $username)||(($in{'PassWord'} ne $password)))&&(&PError("Error. Invalid username or password")); } } sub Manage{ (-e "$htmlpath/dat.cgi")&&(require "$htmlpath/dat.cgi"); (!$in{'saveemail'})?($in{'seNO'} = 'checked'):($in{'se'.$in{'saveemail'}} = 'checked'); (!$in{'html'})?($in{'htmlNO'} = 'checked'):($in{'html'.$in{'html'}} = 'checked'); (!$in{'copyemail'})?($in{'cpNO'} = 'checked'):($in{'cp'.$in{'copyemail'}} = 'checked'); (!$in{'subject'})&&($in{'subject'} = 'FORM(yourname) recommends this site!'); &PageOut("$htmlpath/t_manage.htm"); exit; } sub ShowLinks{ $in{'disurl'} = qq|
|; $in{'linkurl'} = qq| Recommend This Site! |; $in{'ssi'} = $in{'cgiurl'}; $in{'ssi'} =~ s/http:\/\/.*?\//\//i; $in{'linkssi'} = qq| |; $in{'linkjs'} = qq| |; &PageOut("$htmlpath/t_showlinks.htm"); exit; } sub ShowRecommend{ &PageOut("$htmlpath/t_recommend.htm"); exit; } sub ShowRecommend2{ if($in{'t'} eq 'j'){ &PageOutJS("$htmlpath/t_email.htm"); } else{ &PageOut("$htmlpath/t_email.htm"); } exit; } sub CheckVars{ (!$in{'youremail'})&&(&PError("Error. Your email address is required")); (!$in{'addemail1'})&&(&PError("Error. Please enter at least 1 of your friend's email address")); ($in{'youremail'} !~ /\S+\@\S+\.\S+/)&&(&PError("Error. Your email address appears to be invalid")); ($in{'addemail1'} !~ /\S+\@\S+\.\S+/)&&(&PError("Error. Your friend's email address appears to be invalid")); } sub Setup{ ($in{'command'} ne 'reinstall')&&(print "Content-type: text/html\n\n"); $cgipath = `pwd`;chomp $cgipath; $cgiurl = "$ENV{'HTTP_HOST'}/$ENV{'SCRIPT_NAME'}"; $cgiurl =~ s/\/csRecommend\.cgi//i; $cgiurl =~ s/\/\//\//g; $cgiurl = "http://".$cgiurl; $rooturl = "http://$ENV{'HTTP_HOST'}"; $rootpath = $ENV{'DOCUMENT_ROOT'}; $setup = "\$cgiurl = '$cgiurl'; \$cgipath = '$cgipath'; \$sendmail = '/usr/sbin/sendmail'; \$username='demo'; \$password='demo'; 1; "; print <<"EOF"; csRecommend SetupDefinitions:
\$cgiurl = Full URL to the csRecommend DIRECTORY
\$cgipath = Full PATH to the csRecommend DIRECTORY
\$sendmail= full path to your sendmail program
\$username = username to enter management screens
\$password = password to enter management screens
Normal Installation Instructions:
In most cases, the script is already configured. Change the \$username and \$password variables to your liking and click 'Save'. If the setup portion of the script cannot find your sites variables automatically, you will might have to enter those in the above text area.
CGI-BIN Installation Instructions:
If your hosting service will not let you run scripts outside your cgi-bin directory, then follow these procedures:
Copy all the *.cgi files to a directory in your cgi-bin directory, making sure they are chmod'd to 755. For example, you could create a /cgi-bin/csRecommend/ directory and place csRecommend.cgi, libs.cgi, and setup.cgi if this file exists.
Create a directory outside your cgi-bin directory and copy all the remaining files and subdirectories there. For example, you could create a /cgi-script/csRecommend and place the files there.
Edit the above variables (or manually edit
setup.cgi) to the following:
\$cgiurl = URL to the csRecommend directory INSIDE your cgi-bin directory (where
the script is installed).
\$cgipath = FULL PATH to the csRecommend directory INSIDE your cgi-bin directory
(where the script is installed).
\$sendmail = Full path to your sendmail program
ADD THE FOLLOWING VARIABLES TO THE ABOVE CONFIGURATION OR MANUALLY EDIT
setup.cgi:
\$htmlurl = FULL URL to the csRecommend directory OUTSIDE your cgi-bin
directory (where the remaining files where installed)
\$htmlpath = FULL PATH to the csRecommend directory OUTSIDE your cgi-bin
directory (where the remaining files where installed)
For Example, your new setup.cgi file might look something like this:
\$cgiurl='http://www.cgiscript.net/cgi-bin/csRecommend';
\$cgipath='/www/vhosts/cgiscript.net/cgi-bin/csRecommend';
\$sendmail='/usr/sbin/sendmail';
\$htmlurl='http://www.cgiscript.net/cgi-script/csRecommend';
\$htmlpath='/www/vhosts/cgiscript.net/cgi-script/csRecommend';
\$username='myusername';
\$password='mypassword';
1;
(note: the '1' at the end is to prevent errors from perl if \$password was left empty)
NOTE: If you continually get this setup screen even after trying to save it, then most likely your webserver doesn't have write access to your directories. To work around this problem, chmod the csRecommend directory to '777'. EOF exit; } sub SaveSetup{ (-e "$basepath/setup.cgi")&&(&PError("Error. Access Denied")); $in{'setup'} =~ s/\r*\n/\n/g; open(SETUP,">setup.cgi"); print SETUP $in{'setup'}; print SETUP "\n"; close SETUP; print <<"EOF"; EOF exit; } sub PageOutJS{ local($file) = @_; open(OUT,"<$file")||print "$!: $file