Results 1 to 5 of 5

Thread: PHP Stuff idk ;x

  1. #1
    (。◕‿‿◕。) Recognized Member Jojee's Avatar
    Join Date
    Dec 1999
    Posts
    9,611
    Contributions
    • Former Cid's Knight

    Moogle PHP Stuff idk ;x

    I'm using Toxic Goblin referrer script.

    This is the code of the click.php:

    Code:
    if(isset($_REQUEST["id"]) || isset($_REQUEST["site"]))
    {
    	include('config.php');
    	include($full_path.'functions.php');
    	
    	$tgdb = mysql_connect($tgdbHost, $tgdbUser, $tgdbPass) or die(mysql_error());
    	mysql_select_db($tgdbName, $tgdb);
    		
    	if(preg_match('!^[0-9]+$!', $_REQUEST["id"]))
    	{
    		$click_result = mysql_query("select hit_id, url from tg_ref_hits where hit_id='".$_REQUEST["id"]."'");
    	}
    	elseif(!empty($_REQUEST["site"]))
    	{
    		$url = addslashes($_REQUEST["site"]);
    		$click_result = mysql_query("select hit_id, url from tg_ref_hits where url='$url' order by hit_id desc limit 1");
    	}
    	else
    	{
    		$click_result = null;
    	}
    
    	$click = mysql_fetch_object($click_result);
    	if(is_object($click))
    	{
    		mysql_query("update tg_ref_hits set hits_out = hits_out+1 where hit_id = '".$click->hit_id."'");
    		$url = stripslashes($click->url);
    
    		$forward_result = mysql_query("select forward from tg_ref_approved where url = '$url'");
    		$forward_row = mysql_fetch_array($forward_result);
    		if ($forward_row['forward'] != "")
    		{
    			$url = $forward_row['forward'];
    		}
    	}
    	else
    	{
    		if (isset($_REQUEST["site"])) 
    		{
    			$url = $_REQUEST["site"];    
    		}
    		else
    		{
    			$url = &$_SERVER['SERVER_NAME'];
    		}
    	}
    }
    else
    {
    	$url = &$_SERVER['SERVER_NAME'];
    }
    
    header("Location: http://$url");
    exit;
    ?>
    It works great - when you click out from my top links, it goes to where it's supposed to. Example:
    Your Cute Design Resource ~ Neskaya.Net

    But I have my top links section also in subdomains, and it tries to access subdomain.neskaya.net/click.php?id=whatever instead of neskaya.net/click.php?id=whatever, and then it doesn't work.
    Example:
    88x31 Cute Pixel Bunny Button Maker [88 x 31]

    If you click under top links there, it doesn't work.

    How do I fix the code so that it always goes to http://neskaya.net/referrers/click.php?id=whatev and doesn't include the subdomain?

    Thanks :3


    Wat
    is
    going
    on
    wtf
    rawr

  2. #2
    i n v i s i b l e Tech Admin o_O's Avatar
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    2,957
    Blog Entries
    1

    FFXIV Character

    Humphrey Squibbles (Sargatanas)

    Default

    Ok, basically, here's what's happening. neskaya.net and subdomain.neskaya.net use separate virtual hosts in the configuration of the webserver. Each virtual host has its own "DocumentRoot" directive, which means that / refers to a different folder on the server, depending on whether it's called from the subdomain or otherwise. Example:

    Code:
    NameVirtualHost *
    <VirtualHost *>
        ServerName "neskaya.net"
        DocumentRoot "C:/htdocs/neskaya"
    </VirtualHost>
    
    <VirtualHost *>
        ServerName "subdomain.neskaya.net"
        DocumentRoot "C:/neskaya/subdomain"
    </VirtualHost>
    Let say you have a link with the href attribute: "/referrers/click.php". In the main site, the webserver will serve the file from C:/htdocs/neskaya, while in the subdomain it will try to serve from C:/neskaya/subdomain. I can think of a couple of solutions for the problem, though neither is particularly elegant.

    The first and most obvious of the two is to include a full path in the href attribute of the links in the subdomain, i.e. have href="http://neskaya.net/referrers/click.php" in the problematic anchor tags. This way, you're disregarding the domain it comes from, but the potential drawback is that it makes it easier to be called from any domain. Why someone would want to do that is totally beyond me though and by looking at the current source, one can fairly easily figure out where the actual click.php file is hosted if they use their heads a little, so it's pretty much irrelevant.

    The second solution is to write yourself a little redirect script and host it on the subdomain. You'd need to handle the referrer based on GET or POST variables and fairly heavily modify that referrer script, so it's probably not even worth it.

  3. #3
    (。◕‿‿◕。) Recognized Member Jojee's Avatar
    Join Date
    Dec 1999
    Posts
    9,611
    Contributions
    • Former Cid's Knight

    Default

    I want to do the first solution, but I don't know where to replace it at. xD Which part of the code should I be replacing with neskaya.net/referrers ? *.*


    Wat
    is
    going
    on
    wtf
    rawr

  4. #4
    i n v i s i b l e Tech Admin o_O's Avatar
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    2,957
    Blog Entries
    1

    FFXIV Character

    Humphrey Squibbles (Sargatanas)

    Default

    In the PHP document which contains the code for the "Top links" section of your site you should change the href attribute of all of the links so that they point to neskaya.net/referrers/click.php?id=[id].

  5. #5
    (。◕‿‿◕。) Recognized Member Jojee's Avatar
    Join Date
    Dec 1999
    Posts
    9,611
    Contributions
    • Former Cid's Knight

    Moogle

    Oooh, it's in a different file, that makes so much more sense. xD I was trying to find it in this one and getting all confused. Fixed now! Thanks.


    Wat
    is
    going
    on
    wtf
    rawr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •