#!/usr/bin/perl -- my $cwd="."; use lib "."; ################################################################ # DO NOT EDIT ANYTHING BELOW # ################################################################ ################################################################ # TITLE: Tell-a-Friend # # VERSION: 1.6 # # CREATED ON: August 13, 2000 # # LAST UPDATED: May 1, 2002 # # E-MAIL: support@cgibiz.com # # WEB SITE: http://www.cgibiz.com/ # ################################################################ # (C) 2000-2002 ARVYDAS STRAUSAS. ALL RIGHTS RESERVED. # ################################################################ # Copyright Notice # # ---------------- # # This script is not freeware. Any redistribution or # # modification of it without the written consent of Arvydas # # Strausas is strictly prohibited. Copying any of the code # # contained within the script and claiming it as your own is # # also prohibited. You may not remove any of the header # # notices, or any code that has been marked to be a copyright # # violation if removed. By using this code you agree to # # indemnify author from any liability that might arise from # # it's use. # ################################################################ use integer;use Socket;use cg;require"tell.ini";my$step=$cg::params{"step"};my$template;my%friends;cg::cookie("name",$cg::params{"name"},time()+2419200);cg::cookie("email",$cg::params{"email"},time()+2419200);$cg::params{de("wfstjpo")}=de("Qpxfsfe!cz!=b!ubshfu>`cmbol!isfg>#iuuq;00xxx/dhjcj{/dpn0").($ini::cbnick?de("hp/dhj\@tdsjqu>ufmm'qbsuofs>").$ini::cbnick:"").de("#?Ufmm.b.Gsjfoe!2/7=0b?");$cg::params{"referer"}=detect_referer();$cg::params{"name"}=$cg::params{"email"}if!$cg::params{"name"};$cg::params{"message"}=$ini::default_message if!$cg::params{"message"};$cg::params{"webmaster"}=$ini::webmaster;$cg::params{"newsletter"}=$ini::newsletter;$cg::params{"name"}=substr($cg::params{"name"},0,64);$cg::params{"email"}=substr($cg::params{"email"},0,64);if($ENV{"HTTP_HOST"}ne"localhost"){open(KEY,"$cwd/key.txt")or cg::error("$cwd/key.txt");my$key=;close(KEY);if(key(de("ufmm"),$ENV{"HTTP_HOST"})ne$key){cg::location("admin.cgi");exit;}}begin_page();step_1()if$step==1;step_0()if$step==0;end_page();sub step_1{for(my$i=0;defined($_=$cg::params{"friends_email$i"});$i++){if(cg::is_email($_)){$friends{substr($_,0,64)}=substr($cg::params{"friends_name$i"}?$cg::params{"friends_name$i"}:$_,0,64);}}if(!cg::is_email($cg::params{"email"})){error($ini::S_ER_NO_EMAIL);}elsif(!keys(%friends)){error($ini::S_ER_NO_FRIENDS);}else{my$now=time();my$mail=load_template("tell.txt");$cg::params{"message"}="\n$cg::params{'message'}\n"if$cg::params{"message"};open(LOG,">>$ini::stats_dir/tell.log")or cg::error("$ini::stats_dir/tell.log");foreach(keys(%friends)){$cg::params{"friends_name"}=$friends{$_};$cg::params{"friends_email"}=$_;$_=$mail;s/\$(\w+)/$cg::params{$1}/ges;mail($cg::params{"email"},$cg::params{"friends_email"},$_);print(LOG"$now\t$cg::params{'referer'}\t$cg::params{'name'}\t$cg::params{'friends_name'}\n");}close(LOG);mail($cg::params{"email"},$cg::params{"email"},parse_template("told.txt"))if$cg::params{"confirm"};mail($ini::newsletter,$ini::newsletter,parse_template("subscribe.txt"))if cg::is_email($ini::newsletter)&&$cg::params{"subscribe"};mail($ini::webmaster,$ini::webmaster,parse_template("notify.txt"))if cg::is_email($ini::webmaster);$template="told.html";}}sub step_0{$template="tell.html";}sub de{my$s=$_[0];$s=~s/([\!-\~])/chr(ord($1) - 1)/eg;return$s;}sub detect_referer{my$referer;if($ini::autodetect_referer){$referer=$cg::params{"referer"};$referer=$ENV{"HTTP_REFERER"}if!$referer;$referer=$ini::website if!$referer;}else{$referer=$ini::website;}return substr($referer,0,256);}sub load_template{my$template;open(TEMPLATE,"$ini::templates_dir/$_[0]")or cg::error("$ini::templates_dir/$_[0]");read(TEMPLATE,$template,-s TEMPLATE);close(TEMPLATE);return$template;}sub parse_template{my$s;my$template="";open(TEMPLATE,"$ini::templates_dir/$_[0]")or cg::error("$ini::templates_dir/$_[0]");while(defined($s=