GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   "if anchor" Help Any Ideas? Coders Inside (https://gfy.com/showthread.php?t=1044682)

IllTestYourGirls 11-06-2011 01:18 PM

"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?

Nembrionic 11-06-2011 01:29 PM

try elseif

Nembrionic 11-06-2011 01:31 PM

Also, what is "===" doing there? There's one too many.
Should be "=="

grumpy 11-06-2011 01:31 PM

try == ;)

Tempest 11-06-2011 02:27 PM

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;
?>


IllTestYourGirls 11-06-2011 02:56 PM

Quote:

Originally Posted by Nembrionic (Post 18540708)
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 (Post 18540712)
Also, what is "===" doing there? There's one too many.
Should be "=="

Quote:

Originally Posted by grumpy (Post 18540718)
try == ;)

Ok took out the extra "=" 's.

Tempest 11-06-2011 03:19 PM

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<?

}
?>


IllTestYourGirls 11-06-2011 03:26 PM

Quote:

Originally Posted by Tempest (Post 18540902)
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.

Tempest 11-06-2011 03:33 PM

Quote:

Originally Posted by IllTestYourGirls (Post 18540913)
hmmm not showing it.

Not sure.. Tested both things I posted and they worked perfectly for me.

blackmonsters 11-06-2011 03:36 PM

If (used PERL) {
x= "you'd be through already";
}

:1orglaugh

IllTestYourGirls 11-06-2011 03:41 PM

Quote:

Originally Posted by Tempest (Post 18540917)
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 :thumbsup

IllTestYourGirls 11-06-2011 03:43 PM

Quote:

Originally Posted by blackmonsters (Post 18540924)
If (used PERL) {
x= "you'd be through already";
}

:1orglaugh

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

I know just enough to get myself into trouble.

sarettah 11-06-2011 04:40 PM

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

?>


Nembrionic 11-06-2011 04:47 PM

Quote:

Originally Posted by sarettah (Post 18540993)
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 ;)

Brujah 11-06-2011 05:50 PM

Code:

<?php
  header( 'Location: http://exxxpired.com' );
  exit();



All times are GMT -7. The time now is 05:48 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123