473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

where can ini_set('include_path','.:..'); see?

I am taking over an existing app and having trouble understanding their
references.

They have encapsulated Pear packages in the directory structure like:
/site
/site/html/Pear.php
/site/html/Sigma.php
/site/html/Common.php
/site/html/Quickform.php
/site/html/Quickform/
/site/Mail/mail.php
/pages/page1.php

At the top of /site/html/Quickform.php they put:
ini_set('include_path','.:..');
...
require_once('HTML/Common.php');

And it throws an error trying to find 'HTML/Common.php' which is in the same
directory but referenced from the directory above it.

I have tried every configuration in the apache conf file and changing the
code itself.

So, can ini_set('include_path','.:..'); see the directory above it? If not,
how can I change it to see the directory above it?

Any ideas are MUCH appreciated!
Mar 30 '07 #1
24 5305

"Paul" <lo*@invalid.comwrote in message
news:8h******************@bignews3.bellsouth.net.. .
|I am taking over an existing app and having trouble understanding their
| references.
|
| They have encapsulated Pear packages in the directory structure like:
| /site
| /site/html/Pear.php
| /site/html/Sigma.php
| /site/html/Common.php
| /site/html/Quickform.php
| /site/html/Quickform/
| /site/Mail/mail.php
| /pages/page1.php
|
| At the top of /site/html/Quickform.php they put:
| ini_set('include_path','.:..');
| ...
| require_once('HTML/Common.php');

dude paul, i could have sworn i gave you a fix for this! just edit the php
ini file. you need to create a file called 'relative.path.php'. and put it
in your php include path (that you are soon to quick fucking around with
using ini_set). that file has this code in it:

<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>

then i'd put this at the beginning of *EVERY* php file your site has:

<?
require_once 'relative.path.php';
?>

i'd remove every instance of ini_set('include_path', '.:..') that i saw.
that is a horrible way to get the desired effect and the programmer should
summarily be drawn and quartered. this method requires that the file
*always* be a relative distance for what you're including. it could also
severly fuck up a script that includes another and then tries to include
another...because each is setting the include_path! further, it doesn't
allow you to reuse the known relativity to call other folders for inclusion
like classes, common functions, whatever. this scenario requires *all*
includes to be in one folder. not very flexible, is it!

you'll notice that 'relative.path.php' creates a variable called
$relativePath. you'll also notice that it is compatible with all versions of
php...such that you can use it on a server that runs both php 4 or php 5.
the variable points to the root of your web application. once you know that,
you can merrily jump about. anyway, your code would become:

<?
require_once 'relative.path.php';
require_once $relativePath . 'HTML/Common.php';
?>

now it doesn't matter where your script is put in your directory structure.
as it is, your code doesn't work because ini_set('include_path','.:..')
isn't setting a valid path. the best solution would be to further abstract
your directory structure. here's what i put at the top of *EVERY* script of
my own:

<?
$pageTitle = "Welcome";
$fullHeader = true;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';
?>

notice the use of the static site::$includeDirectory interface?
'site.cfg.php' configures the path. if i had a common header that should be
shown on a page (as i have in the above ficticious page), i could now
include it no matter where either the header nor the including page existed.
get the idea?

i have a configuration script called 'site.cfg.php'. it sets paths into
variables. so, when you implement the site, you can put your files all over
the gawd damned place and manage it all in one spot. the rest of your
scripts couldn't care less how crazy you go. they reference variables.
here's my site.cfg.php script:

<?
ini_set('display_errors' , true );
ini_set('error_reporting' , E_ALL & E_ERROR & E_WARNING );
ini_set('max_execution_time' , 0 );
ini_set('memory_limit' , '100M' );

session_start();

// site basic information

$rootDirectory = '/var/www/html/dev/';

require_once $rootDirectory . 'classes/site.class.php';

site::initialize();

site::$rootDirectory = $rootDirectory;
site::$uri = 'http' . ($securityEnabled ? 's' : '') .
'://' . $_SERVER['HTTP_HOST'];
site::$uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
site::$uploadBaseDirectory = site::$rootDirectory . 'data/';
site::$mailDropDirectory = site::$rootDirectory . 'data/mail/';
site::$adminEmail = Web Site Administrator <no****@example.com>';

site::$title = 'SAMPLE WEB SITE;
site::$description = 'A SIMPLE PROVING GROUND';

site::$currentPage = basename($_SERVER['PHP_SELF']);

site::$classDirectory = site::$rootDirectory . 'classes/';
site::$cssDirectory = site::$uri . 'css/';
site::$host = 'tccc';
site::$errorLogFile = site::$rootDirectory . site::$host .
'.errors.log';
site::$fontDirectory = '/var/www/fonts/';
site::$homePage = site::$uri . 'index.php';
site::$htdocsDirectory = site::$rootDirectory;
site::$imagesDirectory = site::$uri . 'images/';
site::$includeDirectory = site::$rootDirectory . 'inc/';
site::$jscriptDirectory = site::$uri . 'jscript/';
site::$logo = site::$imagesDirectory . 'logo.jpg';
site::$popUpAttributes = 'addressbar=0, channelmode=0, dependent=1,
directories=0, fullscreen=0, location=0, menubar=0, resizable=1, status=0,
titlebar=0, toolbar=0';

// common php functionality

require_once site::$includeDirectory . 'functions.inc.php';

// source code security (disables 'view source' from right-click)

$enableContextMenu = true;

// site database information

require_once site::$classDirectory . 'db.class.php';
try
{
db::connect('localhost', 'user', 'password', 'db');
} catch (exception $ex) {
print "<pre>\r\n" . $ex->getMessage() . "\r\n" .
' in file ' . $ex->getFile() . "\r\n" .
' on line ' . $ex->getLine() . "\r\n" .
'</pre>';
}

// site notifcations

$emailNotify['TO'] = site::$adminEmail;
$emailNotify['CC'] = site::$adminEmail;
$emailNotify['BCC'] = '';

// get relative font sizes for the browser

require_once site::$classDirectory . 'browser.class.php';

$browser = browser::getInstance();
$sessionFonts = $browser->getFonts();

// user interaction

require_once site::$classDirectory . 'user.class.php';

$logOut = isset($_REQUEST['logOut']);

if ($logOut)
{
user::reset();
session_unset();
session_destroy();
header('location:' . site::$uri);
exit;
}
?>

i'm using php 5, so if you are using a prior version, just adjust the static
interfaces on the site class appropriately. don't know what i mean? post
that as another question here. here is my site object:

<?
class site
{
public static $adminEmail = '';
public static $classDirectory = '';
public static $cssDirectory = '';
public static $currentPage = '';
public static $description = '';
public static $errorLogFile = '';
public static $fontDirectory = '';
public static $homePage = '';
public static $host = '';
public static $htdocsDirectory = '';
public static $imagesDirectory = '';
public static $includeDirectory = '';
public static $jscriptDirectory = '';
public static $lastSecurityCode = '';
public static $logo = '';
public static $mailDropDirectory = '';
public static $popUpAttributes = '';
public static $rootDirectory = '';
public static $securityCode = '';
public static $title = '';
public static $uploadBaseDirectory = '';
public static $uri = '';

private function __clone(){}

private function __construct(){}

private static function getSecurityCode()
{
$alphabet = '2347ACEFHJKLMNPRTWXYZ'; // removed those that
look too similar
$alphabetLength = strlen($alphabet) - 1;
self::$securityCode = '';
for ($i = 0; $i < 6; $i++)
{
self::$securityCode .= $alphabet[mt_rand(0, $alphabetLength)];
}
$_SESSION['securityCode'] = self::$securityCode;
if (!self::$lastSecurityCode){ self::$lastSecurityCode =
self::$securityCode; }
}

public static function initialize()
{
self::$lastSecurityCode = $_SESSION['securityCode'];
self::getSecurityCode();
}
}
?>

the other classes mentioned in the site.cfg.php are one's that i won't get
in to. i included this one so you could see how i set my important paths and
how easy this all is to maintain. it is light-weight, manageable, scaleable,
and highly flexible.

hth,

me

Mar 30 '07 #2
Paul wrote:
/site/html/Common.php
Lowercase
require_once('HTML/Common.php');
Uppercase

OS?

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 30 '07 #3
btw, don't top post.

your post shows 3.30.2007 12.38 PM.
my response (which is the correct time) was 3.30.2007 10.57 AM.

man, i've got to start checking that before i feed the idiots!
Mar 30 '07 #4
"Steve" <no****@example.comwrote in message
news:ut*****************@newsfe04.lga...
btw, don't top post.

your post shows 3.30.2007 12.38 PM.
my response (which is the correct time) was 3.30.2007 10.57 AM.

man, i've got to start checking that before i feed the idiots!
I can't remember if it was you I was explaining this to or not, but I do not
purposely manipulate the time on my machine, When I post it is the correct
time for my time zone.

I do appreciate your help!
Mar 30 '07 #5

"Paul" <lo*@invalid.comwrote in message
news:FO*******************@bignews4.bellsouth.net. ..
| "Steve" <no****@example.comwrote in message
| news:ut*****************@newsfe04.lga...
| btw, don't top post.
| >
| your post shows 3.30.2007 12.38 PM.
| my response (which is the correct time) was 3.30.2007 10.57 AM.
| >
| man, i've got to start checking that before i feed the idiots!
|
| I can't remember if it was you I was explaining this to or not, but I do
not
| purposely manipulate the time on my machine, When I post it is the
correct
| time for my time zone.

as i've said, the clock on YOUR computer IS OFF ... no matter the
timezone!!! fix it, or i'll plonk you.

| I do appreciate your help!

not a problem. why did you completely ignore the help the FIRST time i
explained this all to you? it was the exact same problem and the exact same
solution. if you have nothing better to do, i sure have.

fix your clock.
Mar 30 '07 #6
"Steve" <no****@example.comwrote in message
news:iV**************@newsfe12.lga...
>
"Paul" <lo*@invalid.comwrote in message
news:FO*******************@bignews4.bellsouth.net. ..
| "Steve" <no****@example.comwrote in message
| news:ut*****************@newsfe04.lga...
| btw, don't top post.
| >
| your post shows 3.30.2007 12.38 PM.
| my response (which is the correct time) was 3.30.2007 10.57 AM.
| >
| man, i've got to start checking that before i feed the idiots!
|
| I can't remember if it was you I was explaining this to or not, but I do
not
| purposely manipulate the time on my machine, When I post it is the
correct
| time for my time zone.

as i've said, the clock on YOUR computer IS OFF ... no matter the
timezone!!! fix it, or i'll plonk you.

| I do appreciate your help!

not a problem. why did you completely ignore the help the FIRST time i
explained this all to you? it was the exact same problem and the exact
same
solution. if you have nothing better to do, i sure have.

fix your clock.
You were right - I was in the wrong time zone - my huge apologies. I just
set this laptop up and thought I had done that.
Mar 30 '07 #7
| fix your clock.
|
| You were right - I was in the wrong time zone - my huge apologies. I just
| set this laptop up and thought I had done that.

no big since i believe you that it wasn't intentional.

let me know if the scripts i posted are hard to work out...otherwise, the
simple suggestion of using $relativePath (first two scripts posted) should
solve your immediate problem.

cheers
Mar 31 '07 #8
"Steve" <no****@example.comwrote in message
news:tt************@newsfe12.lga...
>
"Paul" <lo*@invalid.comwrote in message
news:8h******************@bignews3.bellsouth.net.. .
|I am taking over an existing app and having trouble understanding their
| references.
|
| They have encapsulated Pear packages in the directory structure like:
| /site
| /site/html/Pear.php
| /site/html/Sigma.php
| /site/html/Common.php
| /site/html/Quickform.php
| /site/html/Quickform/
| /site/Mail/mail.php
| /pages/page1.php
|
| At the top of /site/html/Quickform.php they put:
| ini_set('include_path','.:..');
| ...
| require_once('HTML/Common.php');

dude paul, i could have sworn i gave you a fix for this! just edit the php
ini file. you need to create a file called 'relative.path.php'. and put it
in your php include path (that you are soon to quick fucking around with
using ini_set). that file has this code in it:

<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>

then i'd put this at the beginning of *EVERY* php file your site has:

<?
require_once 'relative.path.php';
?>

i'd remove every instance of ini_set('include_path', '.:..') that i saw.
that is a horrible way to get the desired effect and the programmer should
summarily be drawn and quartered. this method requires that the file
*always* be a relative distance for what you're including. it could also
severly fuck up a script that includes another and then tries to include
another...because each is setting the include_path! further, it doesn't
allow you to reuse the known relativity to call other folders for
inclusion
like classes, common functions, whatever. this scenario requires *all*
includes to be in one folder. not very flexible, is it!

you'll notice that 'relative.path.php' creates a variable called
$relativePath. you'll also notice that it is compatible with all versions
of
php...such that you can use it on a server that runs both php 4 or php 5.
the variable points to the root of your web application. once you know
that,
you can merrily jump about. anyway, your code would become:

<?
require_once 'relative.path.php';
require_once $relativePath . 'HTML/Common.php';
?>

now it doesn't matter where your script is put in your directory
structure.
as it is, your code doesn't work because ini_set('include_path','.:..')
isn't setting a valid path. the best solution would be to further abstract
your directory structure. here's what i put at the top of *EVERY* script
of
my own:

<?
$pageTitle = "Welcome";
$fullHeader = true;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';
?>

notice the use of the static site::$includeDirectory interface?
'site.cfg.php' configures the path. if i had a common header that should
be
shown on a page (as i have in the above ficticious page), i could now
include it no matter where either the header nor the including page
existed.
get the idea?

i have a configuration script called 'site.cfg.php'. it sets paths into
variables. so, when you implement the site, you can put your files all
over
the gawd damned place and manage it all in one spot. the rest of your
scripts couldn't care less how crazy you go. they reference variables.
here's my site.cfg.php script:

<?
ini_set('display_errors' , true );
ini_set('error_reporting' , E_ALL & E_ERROR & E_WARNING );
ini_set('max_execution_time' , 0 );
ini_set('memory_limit' , '100M' );

session_start();

// site basic information

$rootDirectory = '/var/www/html/dev/';

require_once $rootDirectory . 'classes/site.class.php';

site::initialize();

site::$rootDirectory = $rootDirectory;
site::$uri = 'http' . ($securityEnabled ? 's' : '') .
'://' . $_SERVER['HTTP_HOST'];
site::$uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
site::$uploadBaseDirectory = site::$rootDirectory . 'data/';
site::$mailDropDirectory = site::$rootDirectory . 'data/mail/';
site::$adminEmail = Web Site Administrator
<no****@example.com>';

site::$title = 'SAMPLE WEB SITE;
site::$description = 'A SIMPLE PROVING GROUND';

site::$currentPage = basename($_SERVER['PHP_SELF']);

site::$classDirectory = site::$rootDirectory . 'classes/';
site::$cssDirectory = site::$uri . 'css/';
site::$host = 'tccc';
site::$errorLogFile = site::$rootDirectory . site::$host .
'.errors.log';
site::$fontDirectory = '/var/www/fonts/';
site::$homePage = site::$uri . 'index.php';
site::$htdocsDirectory = site::$rootDirectory;
site::$imagesDirectory = site::$uri . 'images/';
site::$includeDirectory = site::$rootDirectory . 'inc/';
site::$jscriptDirectory = site::$uri . 'jscript/';
site::$logo = site::$imagesDirectory . 'logo.jpg';
site::$popUpAttributes = 'addressbar=0, channelmode=0, dependent=1,
directories=0, fullscreen=0, location=0, menubar=0, resizable=1, status=0,
titlebar=0, toolbar=0';

// common php functionality

require_once site::$includeDirectory . 'functions.inc.php';

// source code security (disables 'view source' from right-click)

$enableContextMenu = true;

// site database information

require_once site::$classDirectory . 'db.class.php';
try
{
db::connect('localhost', 'user', 'password', 'db');
} catch (exception $ex) {
print "<pre>\r\n" . $ex->getMessage() . "\r\n" .
' in file ' . $ex->getFile() . "\r\n" .
' on line ' . $ex->getLine() . "\r\n" .
'</pre>';
}

// site notifcations

$emailNotify['TO'] = site::$adminEmail;
$emailNotify['CC'] = site::$adminEmail;
$emailNotify['BCC'] = '';

// get relative font sizes for the browser

require_once site::$classDirectory . 'browser.class.php';

$browser = browser::getInstance();
$sessionFonts = $browser->getFonts();

// user interaction

require_once site::$classDirectory . 'user.class.php';

$logOut = isset($_REQUEST['logOut']);

if ($logOut)
{
user::reset();
session_unset();
session_destroy();
header('location:' . site::$uri);
exit;
}
?>

i'm using php 5, so if you are using a prior version, just adjust the
static
interfaces on the site class appropriately. don't know what i mean? post
that as another question here. here is my site object:

<?
class site
{
public static $adminEmail = '';
public static $classDirectory = '';
public static $cssDirectory = '';
public static $currentPage = '';
public static $description = '';
public static $errorLogFile = '';
public static $fontDirectory = '';
public static $homePage = '';
public static $host = '';
public static $htdocsDirectory = '';
public static $imagesDirectory = '';
public static $includeDirectory = '';
public static $jscriptDirectory = '';
public static $lastSecurityCode = '';
public static $logo = '';
public static $mailDropDirectory = '';
public static $popUpAttributes = '';
public static $rootDirectory = '';
public static $securityCode = '';
public static $title = '';
public static $uploadBaseDirectory = '';
public static $uri = '';

private function __clone(){}

private function __construct(){}

private static function getSecurityCode()
{
$alphabet = '2347ACEFHJKLMNPRTWXYZ'; // removed those that
look too similar
$alphabetLength = strlen($alphabet) - 1;
self::$securityCode = '';
for ($i = 0; $i < 6; $i++)
{
self::$securityCode .= $alphabet[mt_rand(0, $alphabetLength)];
}
$_SESSION['securityCode'] = self::$securityCode;
if (!self::$lastSecurityCode){ self::$lastSecurityCode =
self::$securityCode; }
}

public static function initialize()
{
self::$lastSecurityCode = $_SESSION['securityCode'];
self::getSecurityCode();
}
}
?>

the other classes mentioned in the site.cfg.php are one's that i won't get
in to. i included this one so you could see how i set my important paths
and
how easy this all is to maintain. it is light-weight, manageable,
scaleable,
and highly flexible.

hth,

me
Steve:

Can I just put 'relative.path.php' in php.ini for the auto_prepend_file?
That would save a lot of time.
Apr 2 '07 #9
"Steve" <no****@example.comwrote in message
news:tt************@newsfe12.lga...
>
"Paul" <lo*@invalid.comwrote in message
news:8h******************@bignews3.bellsouth.net.. .
|I am taking over an existing app and having trouble understanding their
| references.
|
| They have encapsulated Pear packages in the directory structure like:
| /site
| /site/html/Pear.php
| /site/html/Sigma.php
| /site/html/Common.php
| /site/html/Quickform.php
| /site/html/Quickform/
| /site/Mail/mail.php
| /pages/page1.php
|
| At the top of /site/html/Quickform.php they put:
| ini_set('include_path','.:..');
| ...
| require_once('HTML/Common.php');

dude paul, i could have sworn i gave you a fix for this! just edit the php
ini file. you need to create a file called 'relative.path.php'. and put it
in your php include path (that you are soon to quick fucking around with
using ini_set). that file has this code in it:

<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>

then i'd put this at the beginning of *EVERY* php file your site has:

<?
require_once 'relative.path.php';
?>

i'd remove every instance of ini_set('include_path', '.:..') that i saw.
that is a horrible way to get the desired effect and the programmer should
summarily be drawn and quartered. this method requires that the file
*always* be a relative distance for what you're including. it could also
severly fuck up a script that includes another and then tries to include
another...because each is setting the include_path! further, it doesn't
allow you to reuse the known relativity to call other folders for
inclusion
like classes, common functions, whatever. this scenario requires *all*
includes to be in one folder. not very flexible, is it!

you'll notice that 'relative.path.php' creates a variable called
$relativePath. you'll also notice that it is compatible with all versions
of
php...such that you can use it on a server that runs both php 4 or php 5.
the variable points to the root of your web application. once you know
that,
you can merrily jump about. anyway, your code would become:

<?
require_once 'relative.path.php';
require_once $relativePath . 'HTML/Common.php';
?>

now it doesn't matter where your script is put in your directory
structure.
as it is, your code doesn't work because ini_set('include_path','.:..')
isn't setting a valid path. the best solution would be to further abstract
your directory structure. here's what i put at the top of *EVERY* script
of
my own:

<?
$pageTitle = "Welcome";
$fullHeader = true;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';
?>

notice the use of the static site::$includeDirectory interface?
'site.cfg.php' configures the path. if i had a common header that should
be
shown on a page (as i have in the above ficticious page), i could now
include it no matter where either the header nor the including page
existed.
get the idea?

i have a configuration script called 'site.cfg.php'. it sets paths into
variables. so, when you implement the site, you can put your files all
over
the gawd damned place and manage it all in one spot. the rest of your
scripts couldn't care less how crazy you go. they reference variables.
here's my site.cfg.php script:

<?
ini_set('display_errors' , true );
ini_set('error_reporting' , E_ALL & E_ERROR & E_WARNING );
ini_set('max_execution_time' , 0 );
ini_set('memory_limit' , '100M' );

session_start();

// site basic information

$rootDirectory = '/var/www/html/dev/';

require_once $rootDirectory . 'classes/site.class.php';

site::initialize();

site::$rootDirectory = $rootDirectory;
site::$uri = 'http' . ($securityEnabled ? 's' : '') .
'://' . $_SERVER['HTTP_HOST'];
site::$uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
site::$uploadBaseDirectory = site::$rootDirectory . 'data/';
site::$mailDropDirectory = site::$rootDirectory . 'data/mail/';
site::$adminEmail = Web Site Administrator
<no****@example.com>';

site::$title = 'SAMPLE WEB SITE;
site::$description = 'A SIMPLE PROVING GROUND';

site::$currentPage = basename($_SERVER['PHP_SELF']);

site::$classDirectory = site::$rootDirectory . 'classes/';
site::$cssDirectory = site::$uri . 'css/';
site::$host = 'tccc';
site::$errorLogFile = site::$rootDirectory . site::$host .
'.errors.log';
site::$fontDirectory = '/var/www/fonts/';
site::$homePage = site::$uri . 'index.php';
site::$htdocsDirectory = site::$rootDirectory;
site::$imagesDirectory = site::$uri . 'images/';
site::$includeDirectory = site::$rootDirectory . 'inc/';
site::$jscriptDirectory = site::$uri . 'jscript/';
site::$logo = site::$imagesDirectory . 'logo.jpg';
site::$popUpAttributes = 'addressbar=0, channelmode=0, dependent=1,
directories=0, fullscreen=0, location=0, menubar=0, resizable=1, status=0,
titlebar=0, toolbar=0';

// common php functionality

require_once site::$includeDirectory . 'functions.inc.php';

// source code security (disables 'view source' from right-click)

$enableContextMenu = true;

// site database information

require_once site::$classDirectory . 'db.class.php';
try
{
db::connect('localhost', 'user', 'password', 'db');
} catch (exception $ex) {
print "<pre>\r\n" . $ex->getMessage() . "\r\n" .
' in file ' . $ex->getFile() . "\r\n" .
' on line ' . $ex->getLine() . "\r\n" .
'</pre>';
}

// site notifcations

$emailNotify['TO'] = site::$adminEmail;
$emailNotify['CC'] = site::$adminEmail;
$emailNotify['BCC'] = '';

// get relative font sizes for the browser

require_once site::$classDirectory . 'browser.class.php';

$browser = browser::getInstance();
$sessionFonts = $browser->getFonts();

// user interaction

require_once site::$classDirectory . 'user.class.php';

$logOut = isset($_REQUEST['logOut']);

if ($logOut)
{
user::reset();
session_unset();
session_destroy();
header('location:' . site::$uri);
exit;
}
?>

i'm using php 5, so if you are using a prior version, just adjust the
static
interfaces on the site class appropriately. don't know what i mean? post
that as another question here. here is my site object:

<?
class site
{
public static $adminEmail = '';
public static $classDirectory = '';
public static $cssDirectory = '';
public static $currentPage = '';
public static $description = '';
public static $errorLogFile = '';
public static $fontDirectory = '';
public static $homePage = '';
public static $host = '';
public static $htdocsDirectory = '';
public static $imagesDirectory = '';
public static $includeDirectory = '';
public static $jscriptDirectory = '';
public static $lastSecurityCode = '';
public static $logo = '';
public static $mailDropDirectory = '';
public static $popUpAttributes = '';
public static $rootDirectory = '';
public static $securityCode = '';
public static $title = '';
public static $uploadBaseDirectory = '';
public static $uri = '';

private function __clone(){}

private function __construct(){}

private static function getSecurityCode()
{
$alphabet = '2347ACEFHJKLMNPRTWXYZ'; // removed those that
look too similar
$alphabetLength = strlen($alphabet) - 1;
self::$securityCode = '';
for ($i = 0; $i < 6; $i++)
{
self::$securityCode .= $alphabet[mt_rand(0, $alphabetLength)];
}
$_SESSION['securityCode'] = self::$securityCode;
if (!self::$lastSecurityCode){ self::$lastSecurityCode =
self::$securityCode; }
}

public static function initialize()
{
self::$lastSecurityCode = $_SESSION['securityCode'];
self::getSecurityCode();
}
}
?>

the other classes mentioned in the site.cfg.php are one's that i won't get
in to. i included this one so you could see how i set my important paths
and
how easy this all is to maintain. it is light-weight, manageable,
scaleable,
and highly flexible.

hth,

me
Steve - this seems to be working on files EXCEPT those deeper in
directories, for example, files within:
/site/html/Quickform/

throw the error:
"Warning: main(HTML/Common.php) [function.main]: failed to open stream: No
such file or directory in C:\site\HTML\QuickForm\element.php on line 22"

Line 22 is:
require_once('HTML/Common.php');

There are also directoryies under /site/html/Quickform/, like
/site/html/Quickform/Renderer/
/site/html/Quickform/Rules/

So I need it work for those as well.

Any ideas? I think I/you/we am very close!
Apr 2 '07 #10
| Steve:
|
| Can I just put 'relative.path.php' in php.ini for the auto_prepend_file?
| That would save a lot of time.

i don't see why not other than you may not have access to the php.ini file
on every system/host...whereas you usually do have access to the inc
directory. it's not a bad idea though.

you may also want to think about chaning the $relativePath variable to a
$_SERVER variable. not a big deal either, but it makes it seem more of an
application/server product rather than some abstract variable that comes
from apparently nowhere (from other developer's perspectives who may later
work on the code as well).
Apr 2 '07 #11
| Steve - this seems to be working on files EXCEPT those deeper in
| directories, for example, files within:
| /site/html/Quickform/
|
| throw the error:
| "Warning: main(HTML/Common.php) [function.main]: failed to open stream: No
| such file or directory in C:\site\HTML\QuickForm\element.php on line 22"
|
| Line 22 is:
| require_once('HTML/Common.php');
|
| There are also directoryies under /site/html/Quickform/, like
| /site/html/Quickform/Renderer/
| /site/html/Quickform/Rules/
|
| So I need it work for those as well.
|
| Any ideas? I think I/you/we am very close!

yes. as someone else pointed out, most systems on which you place this web
application are case-sensitive. as a rule for myself, i always lower-case
all directory and file names. as you have probably guessed by now, i do
things very methodically...so much so that i type using lower case. ;^) i
only use proper casing when i do formal writing.

anyway, your problem now stems on the fact that you are requiring
HTML/Common.php, yet on your file system, you only have html/common.php.
make sense? in addition, your line 22 should be:

require_once $relativePath . 'html/common.php'

in order to make use of relative.path.php. also, i am assuming that your web
root is /site.

have you also thought about using something similar to site.cfg.php in order
to define your directory structure literally, such that your scripts refer
to paths via variables?
Apr 2 '07 #12
>| Steve - this seems to be working on files EXCEPT those deeper in
| directories, for example, files within:
| /site/html/Quickform/
|
| throw the error:
| "Warning: main(HTML/Common.php) [function.main]: failed to open stream:
No
| such file or directory in C:\site\HTML\QuickForm\element.php on line 22"
|
| Line 22 is:
| require_once('HTML/Common.php');
|
| There are also directoryies under /site/html/Quickform/, like
| /site/html/Quickform/Renderer/
| /site/html/Quickform/Rules/
|
| So I need it work for those as well.
|
| Any ideas? I think I/you/we am very close!

yes. as someone else pointed out, most systems on which you place this web
application are case-sensitive. as a rule for myself, i always lower-case
all directory and file names. as you have probably guessed by now, i do
things very methodically...so much so that i type using lower case. ;^) i
only use proper casing when i do formal writing.

anyway, your problem now stems on the fact that you are requiring
HTML/Common.php, yet on your file system, you only have html/common.php.
make sense? in addition, your line 22 should be:

require_once $relativePath . 'html/common.php'

in order to make use of relative.path.php. also, i am assuming that your
web
root is /site.

have you also thought about using something similar to site.cfg.php in
order
to define your directory structure literally, such that your scripts refer
to paths via variables?
I can actually put the following in /site/pages/page1.php and it works fine:
require_once $relativePath.'HTML/Common.php';

But when put in:
/site/html/Quickform/Element.php

it throws:
"Notice: Undefined variable: relativePath in
C:\...\site\HTML\QuickForm\element.php on line 22"

Despite the auto_prepend_file working in that file - I have checked.

I think I need help making your code snippet go deeper in the directory
settings. Instead of going up one level, it needs to go up another level
but that will vary depending on where the file. Does that make sense?

Here's what's happening. When you open:
/site/pages/page1.php

it calls:
/site/HTML/Quickform.php properly

That file calls:
/site/HTML/Quickform/elements.php, and THAT is where the error iccurs. The
%relativepath is not defined in /site/HTML/Quickform/elements.php despite
the relative.path.php being included in that file. I can only conclude that
the dept to which the directory structure is being walked up or down is not
enough.

Any ideas? Your help is MUCH appreciated!
Apr 2 '07 #13
In addition to previous post:

I add this to the top of site/HTML/Quickform/element.php
echo ini_get('auto_prepend_file');

echo $relativePath;

exit;

And this is the error it throws:

C:\site\inc\relative.path.php
Notice: Undefined variable: relativePath in
C:\site\HTML\QuickForm\element.php on line 3

So, the relative path is being included.
Apr 2 '07 #14

"Paul" <lo*@invalid.comwrote in message
news:CS******************@bignews8.bellsouth.net.. .
|>| Steve - this seems to be working on files EXCEPT those deeper in
| | directories, for example, files within:
| | /site/html/Quickform/
| |
| | throw the error:
| | "Warning: main(HTML/Common.php) [function.main]: failed to open
stream:
| No
| | such file or directory in C:\site\HTML\QuickForm\element.php on line
22"
| |
| | Line 22 is:
| | require_once('HTML/Common.php');
| |
| | There are also directoryies under /site/html/Quickform/, like
| | /site/html/Quickform/Renderer/
| | /site/html/Quickform/Rules/
| |
| | So I need it work for those as well.
| |
| | Any ideas? I think I/you/we am very close!
| >
| yes. as someone else pointed out, most systems on which you place this
web
| application are case-sensitive. as a rule for myself, i always
lower-case
| all directory and file names. as you have probably guessed by now, i do
| things very methodically...so much so that i type using lower case. ;^)
i
| only use proper casing when i do formal writing.
| >
| anyway, your problem now stems on the fact that you are requiring
| HTML/Common.php, yet on your file system, you only have html/common.php.
| make sense? in addition, your line 22 should be:
| >
| require_once $relativePath . 'html/common.php'
| >
| in order to make use of relative.path.php. also, i am assuming that your
| web
| root is /site.
| >
| have you also thought about using something similar to site.cfg.php in
| order
| to define your directory structure literally, such that your scripts
refer
| to paths via variables?
|
| I can actually put the following in /site/pages/page1.php and it works
fine:
| require_once $relativePath.'HTML/Common.php';
|
| But when put in:
| /site/html/Quickform/Element.php
|
| it throws:
| "Notice: Undefined variable: relativePath in
| C:\...\site\HTML\QuickForm\element.php on line 22"
|
| Despite the auto_prepend_file working in that file - I have checked.
|
| I think I need help making your code snippet go deeper in the directory
| settings. Instead of going up one level, it needs to go up another level
| but that will vary depending on where the file. Does that make sense?

it already DOES all that. it looks for '/' and replaces it with ''. the
difference between the original string and the replaced result (the path
minus the '/'s) is the number of directories to the current directory.
$relativePath simply creates a string by repeating '../' with the number of
replacements made. so:

/site/pages/somedir

would result in:

sitepagessomedir

that's three dir's shorter.

str_repeat would produce:

'../../../'

and if you were in 'somedir' and wanted to get to the root dir from the
command-line, that's exactly what you'd type. cd ../../../

same with php.
| Here's what's happening. When you open:
| /site/pages/page1.php
|
| it calls:
| /site/HTML/Quickform.php properly
|
| That file calls:
| /site/HTML/Quickform/elements.php, and THAT is where the error iccurs.
The
| %relativepath is not defined in /site/HTML/Quickform/elements.php despite
| the relative.path.php being included in that file. I can only conclude
that
| the dept to which the directory structure is being walked up or down is
not
| enough.
|
| Any ideas? Your help is MUCH appreciated!

debug. why not go to a directory that is deeply nested, create a new php
script like this:

<?
echo '<pre>' . $relativePath . '</pre>';
?>

does it produce the correct path for that directory to your root?
Apr 2 '07 #15

"Paul" <lo*@invalid.comwrote in message
news:qW******************@bignews8.bellsouth.net.. .
| In addition to previous post:
|
| I add this to the top of site/HTML/Quickform/element.php
| echo ini_get('auto_prepend_file');
|
| echo $relativePath;
|
| exit;
|
| And this is the error it throws:
|
| C:\site\inc\relative.path.php
| Notice: Undefined variable: relativePath in
| C:\site\HTML\QuickForm\element.php on line 3
|
| So, the relative path is being included.

so, NO, it is NOT being included. 'NOTICE: UNDEFINED VARIABLE: relativePath
....'

i'd forget about using the auto_prepend_file until you got it working AT ALL
first. get fancy only AFTER.
Apr 2 '07 #16
| <?
| echo '<pre>' . $relativePath . '</pre>';
| ?>
|
| does it produce the correct path for that directory to your root?

and that's only IF you get relative.path.php to work as an
auto_prepend_file. otherwise, do as i have suggested and just plop the
script in php's include path. in that case, your debugging script would look
like:

<?
require_once 'relative.path.php';
echo '<pre>' . $relativePath . '</pre>';
?>
Apr 2 '07 #17
lol. i was just looking on the net to see if there were any unknows (to me)
that would cause auto prepend file not to work. it doesn't seem like it but,
i came across this link:

http://www.webmasterworld.com/forum88/421.htm

notice the example is trying to accomplish the same thing we are? it's
funny! you can also see they explode to find out the number of directories
where i use str_replace. i assume that if he were going to finish the code,
it would involve, you guessed it, str_repeat - his would be
str_repeat('../', count($hisExplosion).

i don't know why, after so many years of development going into php, why
there is NOT a $_SERVER variable for the current path, even if it is a
relative one.
Apr 2 '07 #18
| I add this to the top of site/HTML/Quickform/element.php
| echo ini_get('auto_prepend_file');
|
| echo $relativePath;
|
| exit;
|
| And this is the error it throws:
|
| C:\site\inc\relative.path.php
| Notice: Undefined variable: relativePath in
| C:\site\HTML\QuickForm\element.php on line 3
|
| So, the relative path is being included.

so, NO, it is NOT being included. 'NOTICE: UNDEFINED VARIABLE:
relativePath
...'

i'd forget about using the auto_prepend_file until you got it working AT
ALL
first. get fancy only AFTER.
It actually is auto-prepending to
/site/pages/page1.php

but not prepending to
/site/html/Quickform/elements.php

When I add:
echo ini_get('auto_prepend_file');
echo "rel path: ".$relativePath;
exit;

to elements.php, it displays:
C:\site\inc\relative.path.php
Notice: Undefined variable: relativePath in
C:\site\HTML\QuickForm\element.php on line 3
rel path:

So it appears to be "seeing" where the relative.path.php is but not
executing it. It does see and execute the script in /site/pages/page1.php
Apr 2 '07 #19
| It actually is auto-prepending to
| /site/pages/page1.php
|
| but not prepending to
| /site/html/Quickform/elements.php
|
| When I add:
| echo ini_get('auto_prepend_file');
| echo "rel path: ".$relativePath;
| exit;
|
| to elements.php, it displays:
| C:\site\inc\relative.path.php
| Notice: Undefined variable: relativePath in
| C:\site\HTML\QuickForm\element.php on line 3
| rel path:
|
| So it appears to be "seeing" where the relative.path.php is but not
| executing it. It does see and execute the script in /site/pages/page1.php

hmmm. i don't know what to say, other than don't use auto prepend file just
yet. put relative.path.php in your include path. then require_once
'relative.path.php' in your /site/html/quickform/element.php script...THEN
run the same test. while you're at it, add another echo for debugging:

echo ini_get('include_path');

make sure that relative.path.php, for this test, is in your include
path...which may or may not actually be c:/site/inc/

let me know how that one goes.
Apr 2 '07 #20
I add this to the botoom of relative.path.php:
echo "######## $relativePath ########";
I add the following to /site/HTML/Quickform/elements.php:
require_once('relative.path.php');
echo ini_get('include_path');
echo "rel path: ".$relativePath;
exit;

and it displays:
######## ../ ########
..;C:\site\inc
Notice: Undefined variable: relativePath in
C:\site\HTML\QuickForm\element.php on line 4
rel path:

So, it IS accessing the relative.path.php file, but not executing it. If I
add the code into that file, it works fine. The file relative.path.php is
in c:\site\inc directory.
Apr 2 '07 #21
To Steve and everyone else who helped. I finally got it working.

Many many thanks to all!!
Apr 2 '07 #22

"Paul" <lo*@invalid.comwrote in message
news:7Z******************@bignews8.bellsouth.net.. .
|I add this to the botoom of relative.path.php:
| echo "######## $relativePath ########";
|
|
| I add the following to /site/HTML/Quickform/elements.php:
| require_once('relative.path.php');
| echo ini_get('include_path');
| echo "rel path: ".$relativePath;
| exit;
|
| and it displays:
| ######## ../ ########
| .;C:\site\inc
| Notice: Undefined variable: relativePath in
| C:\site\HTML\QuickForm\element.php on line 4
| rel path:
|
| So, it IS accessing the relative.path.php file, but not executing it. If
I
| add the code into that file, it works fine. The file relative.path.php is
| in c:\site\inc directory.

but it only works if the raw code in relative.path.php is pasted directly
into the elements.php page? is c:/site/inc in the php.ini as one of the
include_paths? have you tried storing $relativePath as
$_SERVER['RELATIVE_PATH'] in the site.cfg.php and then echoing out the first
test again to see if the results are more favorable? you'd just change the
"rel path: " . $_SERVER['RELATIVE_PATH'] line for the test.

let me know how it goes. btw, are you still running this test in prepend
mode? it may be that the prepended relative.path.php is not being parsed by
php which would explain why you could require it in prepend mode yet still
not have $relativePath defined.
Apr 3 '07 #23
got it working!

Many thanks for your help!!
Apr 3 '07 #24

"Paul" <lo*@invalid.comwrote in message
news:Zy******************@bignews6.bellsouth.net.. .
| got it working!
|
| Many thanks for your help!!
no problem.
Apr 3 '07 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ramprasad A Padmanabhan | last post by:
I know it is a dummies question, But I am not able to find it on the php manual. Can anyone tell me How to set the include_path in php thanks Ram
1
by: webguynow | last post by:
I recently read a forum posting on codewalkers.com regarding PEAR on a shared host and the poster, mentioned 3 methods to assign an include_path using htaccess. ( Only the 2nd I'm familiar with -...
2
by: Chuck Anderson | last post by:
My shared host used to have Php configured such that I could place a php.ini file into any directory on my site and that was the php.ini file that the Php cgi would use when it ran scripts. ...
0
by: Bastien Continsouzas | last post by:
I am trying to set the include path for SimpleTest under Eclipse I have the following config : Eclipse : 3.2.0 PHPEclipse 1.1.8 SimpleTest plugin : 0.2.1 I ran a test I found on the...
9
by: Charles Crume | last post by:
Hello Everyone; My site was hacked the other day -- someone was able to rename my index.shtml file and put their own index.html file on my server. Not sure how it was done, but looking through...
2
by: Rob Wilkerson | last post by:
Hey all - I'm trying to create a developer-friendly environment on my production server. By that, I mean an environment where developers don't need to worry about certain things. Among those...
0
by: JRough | last post by:
I have this at the top of the file include './includes/config.inc.php'; include $include_path.'dates.inc.php'; include $include_path.'auction_types.inc.php'; include...
4
by: Gordon | last post by:
Is it possible in, say, a .htaccess file, to append additional paths to the php include_path without knowing what the value of include_path is beforehand? I want to add an absolute path to a...
0
by: mukeshrasm | last post by:
Hi! I want to use phpmailer class to send mail using smtp.I have downloaded the phpmailer and then i followed it's README file where it is mentioned that "Copy class.phpmailer.php into your php.ini...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.