Page 1 of 1

What is the correct Syntex for the following Logic.

Posted: Mon Jul 19, 2004 12:25 pm
by NewfieBilko
Hi guys. I want to do a selcetion. I want to say that (Pseudo):

IF basename($_SERVER['PHP_SELF']); = edita.php OR edit1.php OR articles.php OR index.php OR mark.php OR ryan.php THEN

setvar $templates="/afolder/"
setvar $test2="/afolder2/"

ELSE

setvar $templates="../afolder/"
setvar $test2="../afolder2/"

END IF


If someone could make that into a good working php code i'd be thankful :) 8)

Posted: Mon Jul 19, 2004 12:29 pm
by kettle_drum

Code: Select all

$files = array('edita.php', 'edit1.php', 'articles.php', 'index.php', 'mark.php', 'ryan.php');

if(in_array(basename($_SERVER['PHP_SELF']), $files)){
   $templates='/afolder/';
   $test2='/afolder2/';
}else{
   $templates='../afolder/';
   $test2='../afolder2/'; 
}

Posted: Mon Jul 19, 2004 12:43 pm
by NewfieBilko
right, thanks

Posted: Mon Jul 19, 2004 1:10 pm
by NewfieBilko
Hey, could I get another example up in hur?

This code works in an Included file from the PHP_SELF. So when PHP_self goes i dont know if it sees any addy in the bar yet, EITHER that, or my class is having trouble with the inheritance of $files and does not like that.

So maybe i could get some example that either tests each one by OR's without a variable, OR uses another method on finding the $_SERVER address?

Posted: Mon Jul 19, 2004 1:20 pm
by NewfieBilko
The 2 options are:
If the page is being loaded from root/admin/ then it loads /admin/_config.php, which requires root/Setup/Setup.php (where the logic should go)

If the page is bering loaded from just root/, then it loads root/_config.php, which requires root/Setup/Setup.php

In this setup.php we need this logic where tlaking about to figure out which _config.php the application came from. if you catch me

Posted: Mon Jul 19, 2004 1:43 pm
by NewfieBilko
I made a variable in each _config. One for Admin ($configer="admin") and one in the main _config ($configer="main")

What should my logic be in Setup? I tried this to no eval:

Code: Select all

if($configer == "admin"){
    var $template_dir    =  '../templates';       // name of directory for templates
    var $compile_dir     =  '../templates_c';     // name of directory for compiled templates
	var $config_dir      =  '../configs';         // directory where config files are located
}else($configer == "main"){
    var $template_dir    =  'templates';       // name of directory for templates
    var $compile_dir     =  'templates_c';     // name of directory for compiled templates
	var $config_dir      =  'configs';         // directory where config files are located
}

Posted: Mon Jul 19, 2004 1:46 pm
by feyd
you could use $_SERVER['DOCUMENT_ROOT'], so all your includes start from a base directory.. that's if you aren't allowed to adjust the include_path..

Posted: Wed Jul 21, 2004 6:03 am
by NewfieBilko
Hey fyed, if i wanted to adjust the "include_path", where would I go about finding that? in my php.ini? I can't seem to find it anywhere!!! :(

Posted: Wed Jul 21, 2004 6:08 am
by feyd
the default is stored in your php.ini.. also you can manipulate it through [php_man]set_include_path[/php_man]()

Posted: Wed Jul 21, 2004 6:17 am
by NewfieBilko
i see. Yea i am right next to my linux server.
ok, looking at it now i see:

UNIX: "/path1:/path2"
include_path= ".:/php/includes"

Windows: "\path1;\path2"
include_path= ".;c:\php\includes"

My website is located at http://php2.domain.biz

On my root the files are located at: var/usr/www/php2

Can i go ahead and delete the windows reference? and should i change that unix include?

Posted: Wed Jul 21, 2004 6:28 am
by NewfieBilko
what will changing this do and affect my application? It points to directorys that arn't even there.. someone wanna give me a tutorial on include_path? LOL :D

Posted: Wed Jul 21, 2004 12:05 pm
by feyd
from what I remember, those paths are the defaults that are stored in php.ini in the respective distros. I think they intended for you to change them to your own locations ;)

Posted: Thu Jul 22, 2004 6:30 am
by NewfieBilko
what should i change them to?

my absolut paths? lol /var/www/php2/

?

Posted: Thu Jul 22, 2004 10:26 am
by feyd
you can do that if you like..