include("../inc/fh.inc.php");
switch ($cmd) {
case "submit":
add_link($email, $sitename, $siteurl);
break;
default:
show_header();
show_reg_form();
show_footer();
break;
}
function show_reg_form($error_msg="", $error_field="", $email="", $sitename="", $siteurl="http://") {
global $PHP_SELF;
if ($error_msg!="") {
echo("
".$error_msg."
");
} else {
?>
Add Your Link
Do you own a quality humor site? If so, please read on...
- We're always looking for humor sites to exchange links with!
Swapping links a great way of mutually
exchanging traffic and increasing the exposure of your site. It also
helps your ranking in search engines like Google (we link directly
to you). If you would like to see your link on FunnyHumor.com,
simply complete this form. Then simply add a link to www.funnyhumor.com and we'll
automatically start counting the number of referrers you send us. In return, your link will be shown on our
links page as well as our prominant "Top Referrers" boxes within our site.
- Webmasters sending us the most visitors can
expect more traffic from us in return!
Because we're able to count each visitor you send us, we can
reward you based on how much traffic you provide us. Sites sending
us the most traffic will be shown on high-profile spots on our home
page and category pages.
Please complete the following form:
}
?>
}
function show_thank_you($link_id) {
?>
Thank You
Your site has been submitted and will automatically be displayed once you we track enough visitors from your site. Please use the HTML code below to link to us.
| Link to FunnyHumor.com using this URL: |
http://www.funnyhumor.com |
| And here is your complete HTML code: |
|
| Alternatives links: |
Here are some other linking methods for you to use:
|
Please do not use blind, misleading or popup links.
If you have any questions or comments, email us at
webmaster@funnyhumor.com. Thanks!
}
function add_link($email, $sitename, $siteurl) {
$valid = 1;
$email = trim($email);
if ($email == "") {
$valid = 0;
$error_field["email"] = 1;
$message .= "
• You must specify your email address.";
} elseif ((strlen($email) > 70) || (strlen($email) < 5)) {
$valid = 0;
$error_field["email"] = 1;
$message .= "
• Your email needs to have between 5 and 70 characters.";
} elseif (!(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email))) {
$valid = 0;
$error_field["email"] = 1;
$message .= "
• Your email address is in an invalid format.";
}
$sitename = trim($sitename);
if ($sitename == "") {
$valid = 0;
$error_field["sitename"] = 1;
$message .= "
• You must specify the name of your site.";
} elseif (strlen($sitename) > 22) {
$valid = 0;
$error_field["sitename"] = 1;
$message .= "
• Your site name cannot contain more than than 22 characters.";
}
$siteurl = trim($siteurl);
if ($siteurl == "") {
$valid = 0;
$error_field["siteurl"] = 1;
$message .= "
• You must specify the URL of your site.";
} elseif (strlen($siteurl) > 255) {
$valid = 0;
$error_field["siteurl"] = 1;
$message .= "
• Your site URL cannot contain more than 255 characters.";
} elseif (!(eregi("^((ht|f)tp://)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$", $siteurl))) {
$valid = 0;
$error_field["siteurl"] = 1;
$message .= "
• Your website URL is in an invalid format.";
}
$message = "Your submission is not complete because...".$message;
$date_added = date("Y-m-d");
if ($valid) {
$query = "INSERT INTO fh_links (email, title, url, status, date_added) ";
$query .= "VALUES('$email', '$sitename', '$siteurl', 'i', '$date_added')";
if (sql_query($query)) {
$link_id = mysql_insert_id();
send_welcome_email($email, $sitename, $siteurl, $link_id);
show_header();
show_thank_you($link_id);
show_footer();
//send_nofication_email($email, $sitename, $siteurl, $link_id);
} else {
show_header();
show_reg_form("Sorry, an internal error has occurred.", $error_field, $email, $sitename, $siteurl);
show_footer();
}
} else {
show_header("Oops!", $message);
show_reg_form($message, $error_field, $email, $sitename, $siteurl);
show_footer();
}
}
function show_header() {
?>
FunnyHumor.com - Add Your Link
include("../templates/fh_header.html");
?>
include("../templates/fh_footer.html");
?>
}
function send_welcome_email($email, $sitename, $siteurl, $link_id) {
$subject = "FunnyHumor.com Linking Code";
$body .= "Hi $email,\r\n";
$body .= "\r\n";
$body .= "Thanks for submitting your link to FunnyHumor.com. Your link will automatically appear on FunnyHumor.com once you begin sending traffic. The more traffic you send, the higher your link will be shown.\r\n";
$body .= "\r\n";
$body .= "Here is your linking code to add to your site:\r\n";
$body .= "Funny Humor\r\n";
$body .= "\r\n";
$body .= "Regards,\r\n";
$body .= "\r\n";
$body .= "Webmaster\r\n";
$body .= "webmaster@funnyhumor.com\r\n";
$headers .= "From: FunnyHumor.com \n";
$headers .= "Reply-To: FunnyHumor.com \n";
$headers .= "X-Sender: \n";
$headers .= "X-Mailer: PHP\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: \n";
$headers .= "Content-Type: text/plain";
@mail($email,$subject,$body,$headers);
}
function send_nofication_email($email, $sitename, $siteurl, $link_id) {
$subject = "FunnyHumor.com: Link Swap Request";
$body .= "The following site has requested a link swap:\r\n";
$body .= "\r\n";
$body .= "Email: $email\r\n";
$body .= "Site Title: $sitename\r\n";
$body .= "Site URL: $siteurl\r\n";
$body .= "Link ID: $link_id\r\n";
$body .= "\r\n";
$body .= "Click here to approve this site:\r\n";
$body .= "http://admin.laughshare.com/fh_admin.php?cmd=approve_link&id=$link_id\r\n";
$body .= "\r\n";
$headers .= "From: FunnyHumor.com \n";
$headers .= "Reply-To: FunnyHumor.com \n";
$headers .= "X-Sender: \n";
$headers .= "X-Mailer: PHP\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: \n";
$headers .= "Content-Type: text/plain";
@mail("webmaster@laughshare.com",$subject,$body,$headers);
}
function get_field_html($error, $field_name) {
if ($error) {
return "$field_name";
} else {
return $field_name;
}
}
?>