Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Using include with certain domains

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,789
Reaction score
334
Hi, Just wondering if anyone can help. I am using 1 index.php file that has all domains parked on it, i am also using the following code to show what domain name is in the browser header
<?
$domainstart = $_SERVER['HTTP_HOST'];
$domainname = str_replace("www.", "", "$domainstart");
?>

then in the index.php file i have <? echo "$domainname"; ?> where the domain name is shown.

What i am trying to do is if a certain domain name is shown then it also displays an include file, for example is domainname.co.uk is in the browser address bar i can also include the file contents from a file called domainname.php.

Is this possible and if so any ideas how to achieve this.

Thanks in advance.
 
As you know I'm not even a beginner, but can't you just put in another include, but with the echo in it.

Eg <?php include("your php echo code"); ?>

Is an echo allowed within, only wrote it as it sounded the simplest :)
 
I used something like

Code:
$dom = explode('.',substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1));
	include("./" . $dom[0] . ".inc.php");

You should really clean sanitize the server var just to form a habit, but that should work.
 
Thank skinner but if the .inc.php file does not exist it shows errors so would need code to work if inc.php exists then show it, if it does not exist then dont show any errors.
 
also what do yo mean clean sanitize the server var just to form a habit,? (sorry if sounds a stupid question)

Pass it through something like this I think to stop injection I think this works

Code:
function check_input($data)
{
    $data = htmlspecialchars($data);
    return $data;
}
$dom = check_input(explode('.',substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1)));
 
Actually might have to do something like this

Code:
function check_input($data)
{
    $data = htmlspecialchars($data);
    return $data;
}
//Get Page URL
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return check_input($pageURL);
}
dom = curPageURL()
 
I was a lil bored while waiting for a data migration so worked this lil script out, I've kept it simple and added a bunch of comments, so its should be easy to follow.




Code:
<?php 
function domain($url){
      $obj=parse_url($url); //parse the url.
      $domain=$obj['path']; // extract just the url not subdirs/dirs/files
      if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $reg)) { //test it conforms to common known structure of names.
		$dom = explode('.',$reg['domain']); // explode it to cut off sld/tld
		return $dom[0]; //return only domain name,
      }
      return false;
}

$path = domain($_SERVER['HTTP_HOST']) . ".inc.php"; // take host name and create filename.
//echo $path; //show file name for debug
if(file_exists($path)){ // test if filename exists.
	include("$path"); //yay it does, show it.
}else{ // rut ro not found.
	include("./default.inc.php"); //show this instead.
}
?>
 
No probs, If you need any tweaks let me know, if you don't wanna include a default, just comment that line out.
 
sorry to hijack the thread a tad, off the top of your head, do you know how asp (vbscript/IIS) compares to php on apache for handling super high traffic.

just popped into my head..

No probs, If you need any tweaks let me know, if you don't wanna include a default, just comment that line out.
 
For super-high traffic, surely you want to use something like nginx rather than Apache?
 
IIS is pointless it buckles under very heavy load unless its majorly optimised with near unlimited resources but even then it buckles under stress I'm sure there are ways to solve it but my experience is IIS can't hack it.

I'm all about litespeed at the moment, but def down to nginx for a free option or litespeed free or paid, if I had dollar in my pocket I'd go litespeed otherwise nginx.

I've not seen anyone using hiphop on litespeed or nginx but I'd imagine well formed mysql with caching, nginx/litespeed with hiphop would be a pretty mean config for super heavy loads.
 
presumably IIS 7+ running .NET would be better - what about all these corp monsters tied up with using MS products. IIS can't be that bad.. can it? :eek:
 
Its like facebook developing hiphop to enable php to run fast enough to handle it. You dont know what these monsters have developed in iis.

They also could be running a cluster of servers behind load balancers with a bunch of custom extensions / componants, and just keep adding more and more servers to power it.

im sure with enough money and skill you could do anything.


presumably IIS 7+ running .NET would be better - what about all these corp monsters tied up with using MS products. IIS can't be that bad.. can it? :eek:
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

Sponsors

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel

Sponsors

Acorn Domains Merch
MariaBuy Marketplace

Shiny Nuts

Perfect
Service
Laskos
URL Shortener
*the exceptional businesses of our esteemed moderators
Top Bottom