Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-06-2011, 01:18 PM   #1
IllTestYourGirls
Ah My Balls
 
IllTestYourGirls's Avatar
 
Industry Role:
Join Date: Feb 2007
Location: Under the gold leaf ICQ 388-454-421
Posts: 14,311
"if anchor" Help Any Ideas? Coders Inside

I am trying to show a set of ads for a group of about 20 sites or so and another set of sites another ad but show a different set of ads for everyone else. This is what I have for a code

Code:
<?
$ref = getenv('HTTP_REFERER');
 $anchor = preg_replace("/http:\/\//i", "", $ref);
 $anchor = preg_replace("/^www\./i", "", $anchor);
 $anchor = preg_replace("/\/.*/i", "", $anchor);

if ($anchor=="domain.com")
{ ?>ads<?}

if (($anchor === "domain1.com") OR ($anchor === "domain2.com") OR ($anchor === "domain3.com")) 
{ ?>ad space here<?}

else { ?>other ad here<?}
?>
Problem is the code is showing both the if and the else ads. Any ideas how to fix it?
__________________
IllTestYourGirls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 01:29 PM   #2
Nembrionic
Confirmed User
 
Join Date: Feb 2003
Posts: 2,424
try elseif
Nembrionic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 01:31 PM   #3
Nembrionic
Confirmed User
 
Join Date: Feb 2003
Posts: 2,424
Also, what is "===" doing there? There's one too many.
Should be "=="
Nembrionic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 01:31 PM   #4
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
try == ;)
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 02:27 PM   #5
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Code:
<?php

	$ad = 'default';

	$ref = (isset($_SERVER['HTTP_REFERER']) ? strtolower($_SERVER['HTTP_REFERER']) : '');

	if( $ref != '' ){

		$info = parse_url($ref);

		if( $info !== false && isset($info['host']) ){

			$domain = preg_replace('/^(www\.)+/', '', $info['host']);

			if( in_array($domain, array('domain1.com', 'domain2.com')) ){

				$ad = 'ad1';

			}elseif( in_array($domain, array('domain3.com', 'domain4.com')) ){

				$ad = 'ad2';
			}
		}
	}

	echo $ad;
?>
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 02:56 PM   #6
IllTestYourGirls
Ah My Balls
 
IllTestYourGirls's Avatar
 
Industry Role:
Join Date: Feb 2007
Location: Under the gold leaf ICQ 388-454-421
Posts: 14,311
Quote:
Originally Posted by Nembrionic View Post
try elseif
Tried this, it seems to only work when I have

Code:
elseif ($anchor=="")
But I want the else if to be all other traffic. Not broken down by referring domains. Any suggestions for that?

Quote:
Originally Posted by Nembrionic View Post
Also, what is "===" doing there? There's one too many.
Should be "=="
Quote:
Originally Posted by grumpy View Post
try == ;)
Ok took out the extra "=" 's.
__________________
IllTestYourGirls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:19 PM   #7
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Code:
<?php
$ref = getenv('HTTP_REFERER');
$anchor = preg_replace("/http:\/\//i", "", $ref);
$anchor = preg_replace("/^www\./i", "", $anchor);
$anchor = preg_replace("/\/.*/i", "", $anchor);

if( $anchor=="domain.com" ){

?>ads<?

}elseif( $anchor == "domain1.com" || $anchor == "domain2.com" || $anchor == "domain3.com" ){

?>ad space here<?

}else{

?>other ad here<?

}
?>
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:26 PM   #8
IllTestYourGirls
Ah My Balls
 
IllTestYourGirls's Avatar
 
Industry Role:
Join Date: Feb 2007
Location: Under the gold leaf ICQ 388-454-421
Posts: 14,311
Quote:
Originally Posted by Tempest View Post
Code:
<?php
$ref = getenv('HTTP_REFERER');
$anchor = preg_replace("/http:\/\//i", "", $ref);
$anchor = preg_replace("/^www\./i", "", $anchor);
$anchor = preg_replace("/\/.*/i", "", $anchor);

if( $anchor=="domain.com" ){

?>ads<?

}elseif( $anchor == "domain1.com" || $anchor == "domain2.com" || $anchor == "domain3.com" ){

?>ad space here<?

}else{

?>other ad here<?

}
?>
hmmm not showing it.
__________________
IllTestYourGirls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:33 PM   #9
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by IllTestYourGirls View Post
hmmm not showing it.
Not sure.. Tested both things I posted and they worked perfectly for me.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:36 PM   #10
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,254
If (used PERL) {
x= "you'd be through already";
}

__________________
Make Money with Porn
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:41 PM   #11
IllTestYourGirls
Ah My Balls
 
IllTestYourGirls's Avatar
 
Industry Role:
Join Date: Feb 2007
Location: Under the gold leaf ICQ 388-454-421
Posts: 14,311
Quote:
Originally Posted by Tempest View Post
Not sure.. Tested both things I posted and they worked perfectly for me.
Strange it is working now, must have been a cache issue. Thanks
__________________
IllTestYourGirls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 03:43 PM   #12
IllTestYourGirls
Ah My Balls
 
IllTestYourGirls's Avatar
 
Industry Role:
Join Date: Feb 2007
Location: Under the gold leaf ICQ 388-454-421
Posts: 14,311
Quote:
Originally Posted by blackmonsters View Post
If (used PERL) {
x= "you'd be through already";
}

If I knew what the fuck I was doing Id be done too

I know just enough to get myself into trouble.
__________________
IllTestYourGirls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 04:40 PM   #13
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
Here is a different way to do it. Not saying it's better, just different ;p

Code:
<?php
// Housekeeping

// Initialize stuff
$domain=array();
$ads=array();

// define the ad that will be shown if the domain is not in your list 
$ad2use="defaultad";

// define the various ads you will use for domains in your list
$ad1="ad 1 code goes here";
$ad2="ad 2 code goes here";
$ad3="ad 3 code goes here";

// for each domain that you want an ad for define the domain in $domain[] and the ad in $ad[]
// I store everything like this lower case 

// site group 1
$domain[1]="domain1";
$ads[1]=$ad1;
$domain[2]="domain2";
$ads[2]=$ad1;

//site group 2
$domain[3]="domain3";
$ads[3]=$ad2;
$domain[4]="domain4";
$ads[4]=$ad2;

// site group 3
$domain[5]="domain5";
$ads[5]=$ad3;

// etc etc for as many site-ad groups as you want

// End of Housekeeping

// Mainline

// check to see if there is anything in referer
if(isset($_SERVER['HTTP_REFERER']))
{
  // loop through the domain list
  for($domcnt=1;$domcnt<=count($domain);$domcnt++)
  {
    // is the domain name in the referer string?  Checking lowercase because I have the domain list lowercased  
    if(substr_count(strtolower($_SERVER['HTTP_REFERER']),$domain[$domcnt])>0)
    {
      // if the domain was in the referer string then grab the associated ad
      $ad2use=$ads[$domcnt];
      // break out of the for... loop
      $break;
    }
  }
}

// put the selected ad up there
echo $ad2use;

// end of Mainline

?>
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 04:47 PM   #14
Nembrionic
Confirmed User
 
Join Date: Feb 2003
Posts: 2,424
Quote:
Originally Posted by sarettah View Post
Here is a different way to do it. Not saying it's better, just different ;p

Code:
<?php
// Housekeeping

// Initialize stuff
$domain=array();
$ads=array();

// define the ad that will be shown if the domain is not in your list 
$ad2use="defaultad";

// define the various ads you will use for domains in your list
$ad1="ad 1 code goes here";
$ad2="ad 2 code goes here";
$ad3="ad 3 code goes here";

// for each domain that you want an ad for define the domain in $domain[] and the ad in $ad[]
// I store everything like this lower case 

// site group 1
$domain[1]="domain1";
$ads[1]=$ad1;
$domain[2]="domain2";
$ads[2]=$ad1;

//site group 2
$domain[3]="domain3";
$ads[3]=$ad2;
$domain[4]="domain4";
$ads[4]=$ad2;

// site group 3
$domain[5]="domain5";
$ads[5]=$ad3;

// etc etc for as many site-ad groups as you want

// End of Housekeeping

// Mainline

// check to see if there is anything in referer
if(isset($_SERVER['HTTP_REFERER']))
{
  // loop through the domain list
  for($domcnt=1;$domcnt<=count($domain);$domcnt++)
  {
    // is the domain name in the referer string?  Checking lowercase because I have the domain list lowercased  
    if(substr_count(strtolower($_SERVER['HTTP_REFERER']),$domain[$domcnt])>0)
    {
      // if the domain was in the referer string then grab the associated ad
      $ad2use=$ads[$domcnt];
      // break out of the for... loop
      $break;
    }
  }
}

// put the selected ad up there
echo $ad2use;

// end of Mainline

?>
Not very efficient ;)
Nembrionic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-06-2011, 05:50 PM   #15
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Code:
<?php
  header( 'Location: http://exxxpired.com' );
  exit();
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.