[SOLVED] What is the correct Syntex for the following Logic.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

What is the correct Syntex for the following Logic.

Post 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)
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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/'; 
}
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

right, thanks
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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?
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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!!! :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the default is stored in your php.ini.. also you can manipulate it through [php_man]set_include_path[/php_man]()
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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?
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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 ;)
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

what should i change them to?

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

?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can do that if you like..
Post Reply