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)
-   -   PHP include question (https://gfy.com/showthread.php?t=710194)

BSleazy 02-27-2007 05:02 PM

PHP include question
 
How would I make a little file that I can add links to that shows up on 100's of sites.

The purpose is to just be able to update one file instead of 100's. Get it?

BradM 02-27-2007 05:03 PM

include("filename.php");

fris 02-27-2007 05:03 PM

i do this with a lot of my sites i just edit 1 link file say links.inc

<?include "http://www.domain.com/links.inc"?>

on any site you want to do it, and all you have to do is update that one links.inc file

BSleazy 02-27-2007 05:29 PM

Alright sweat. Thanks guys.

Nookster 02-27-2007 05:36 PM

Yep, the above examples will work for what you need. But I advise that if you use a database in said include do NOT use .inc for the file extension, and like always keep the dbase connection info out of the domain root directory. :2 cents:

u-Bob 02-27-2007 05:48 PM

readfile();

k0nr4d 02-27-2007 09:50 PM

Quote:

Originally Posted by Fris (Post 11984288)
i do this with a lot of my sites i just edit 1 link file say links.inc

<?include "http://www.domain.com/links.inc"?>

on any site you want to do it, and all you have to do is update that one links.inc file

That works...
...if you want your sites to all load really slowly and use more system resources then they need to...

Theres lots of methods, best one being
@include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.

tenderobject 02-27-2007 10:02 PM

Quote:

Originally Posted by k0nr4d (Post 11985345)
That works...
...if you want your sites to all load really slowly and use more system resources then they need to...

Theres lots of methods, best one being
@include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.

so whats thebest suntax fo include? iom using this ins some of my sites and it lags it sometimes.

k0nr4d 02-27-2007 10:19 PM

include('/absolute/path/to/file'); is the best syntax. You can put a @ in front of the include if you want to supress warnings if the file doesn't exist or is unreadable from that location due to open_base_dir restrictions.

pornpf69 02-27-2007 10:56 PM

Quote:

Originally Posted by k0nr4d (Post 11985345)
That works...
...if you want your sites to all load really slowly and use more system resources then they need to...

Theres lots of methods, best one being
@include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.

very informative!! thank you for your input!!

spasmo 02-27-2007 10:59 PM

I use:

<? include("$_SERVER[DOCUMENT_ROOT]/includes/include_filename.php"); ?>

or in cases where it's an absolute path (as stated above) I omit the $_SERVER[DOCUMENT_ROOT].

PHP-CODER-FOR-HIRE 02-27-2007 11:28 PM

Really only useful if all the sites are on the same server

k0nr4d 02-27-2007 11:32 PM

Quote:

Originally Posted by spasmo (Post 11985531)
I use:

<? include("$_SERVER[DOCUMENT_ROOT]/includes/include_filename.php"); ?>

or in cases where it's an absolute path (as stated above) I omit the $_SERVER[DOCUMENT_ROOT].

That works too, but keep in mind (im not POSITIVE of this, but 90% sure) that the $_SERVER variables don't work if you are coding for CLI

spasmo 02-27-2007 11:38 PM

Quote:

Originally Posted by k0nr4d (Post 11985659)
That works too, but keep in mind (im not POSITIVE of this, but 90% sure) that the $_SERVER variables don't work if you are coding for CLI

I think you're right. The $_SERVER variables are passed by Apache, aren't they?

k0nr4d 02-28-2007 02:01 AM

yeah i believe so

u-Bob 02-28-2007 08:07 AM

Guys, when including static files (without php code), use readfile() instead of include(). </2 cents>

d00t 02-28-2007 09:14 AM

Quote:

Originally Posted by u-Bob (Post 11987241)
Guys, when including static files (without php code), use readfile() instead of include(). </2 cents>

why is that?

borked 02-28-2007 11:06 AM

just add this to a header file:
<?php
$pathArr = pathinfo(__FILE__);
ini_set('include_path', ini_get('include_path').':'.$pathArr['dirname'].'/includes');
?>

then you're all set - you can forget about worrying to add the full pathname -
add any file to includes/ directory then include them simply with
include('filename.php');

u-Bob 02-28-2007 12:11 PM

Quote:

Originally Posted by d00t (Post 11987510)
why is that?

cuz it's 15 times faster and uses alot less resources.

k0nr4d 02-28-2007 01:09 PM

readfile() is actually alot more then 15 times faster, uses far far far less ram, but like he said only works on static files with no php code in them

HomeFry 02-28-2007 01:30 PM

Just use an iframe.

k0nr4d 02-28-2007 02:01 PM

Quote:

Originally Posted by HomeFry (Post 11988883)
Just use an iframe.

they dotn get indexed by google


All times are GMT -7. The time now is 03:00 PM.

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