[advanced search]
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-10-2006, 05:47 PM   · #1
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
include and index.php/?contact

hey
I am working on a site and i want to use includes statements to make it easy for the pplz who will manage tht site later on [i m doing it for someone else]

now i dont want to make 100 pages with includes statements of 100 files tht need to be included
so i need a dynamic way of doing this

this is wt i am trying to do

I want to put all the include statements in the index page [for that part of the code] and i want it to make it true when the statement comes true
for example something like

if site url has "index.php/?contact"
include('contact.txt');

elseif site url has "index.php/?about us"
include('about-us.txt');

and so on....

and then when making the navigation bar i can just type in "index.php/?contact" etc...


Thanks


Please register or log-in into NamePros to hide ads
unknowngiver is offline   Reply With Quote
Old 04-10-2006, 05:57 PM   · #2
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
PHP Code:
<?php

//<a href="?page=contact">Contact</a>

$page = trim(strip_tags($_GET['page']));

if(
file_exists($page.'.php'))
{
  include(
$page.'.php');
}
else
{
  include(
'default.php');
}
?>
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!

Last edited by SecondVersion : 04-10-2006 at 06:45 PM.
SecondVersion is offline   Reply With Quote
Old 04-10-2006, 06:07 PM   · #3
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
can i use the elseif command later on?
and SV ur a GENIUS!!! u deserve to kick billgates ass lol
unknowngiver is offline   Reply With Quote
Old 04-10-2006, 06:44 PM   · #4
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
No need. Just make sure the page you're passing it exists. I.E: if you do ?page=about, it will try to find about.php, if it exists, it is included. If not, shows the default page..such as the main index.
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 04-10-2006, 07:08 PM   · #5
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
o can i make it so it looks for about.txt instead of about.php and it looks for that in the "includes" folder?
unknowngiver is offline   Reply With Quote
Old 04-10-2006, 07:10 PM   · #6
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
PHP Code:
<?php

//<a href="?page=contact">Contact</a>

$page = trim(strip_tags($_GET['page']));

if(
file_exists('includes/'.$page.'.txt'))
{
  include(
'includes/'.$page.'.txt');
}
else
{
  include(
'includes/default.txt');
}
?>
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 04-10-2006, 07:20 PM   · #7
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
greattttttttttt u rockkkk
but dont wrry i will be back soon with more questions lol
anyway Namepros is so mean
Quote:
We're glad that you're fond of this member, but please give some rep points to some other members before giving it to SecondVersion again.


lol
unknowngiver is offline   Reply With Quote
Old 04-11-2006, 12:21 PM   · #8
nasaboy007
NamePros Regular
 
Location: mysitememberships.com
Trader Rating: (32)
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (Donate)
nasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to behold
hey secondversion, question for you:

u trim and strip_tags the GET variable. is that to ensure that ppl cant put http://www.abc.com?page=http://www....illawebsite.php as the link and run malicious codes? or is there another reason?

bcuz all the posts/articles i read on this include method, everyone always brought up the point that ppl cud run malicious codes like that and u use use a switch block instead.
__________________
nasaboy007 is offline   Reply With Quote
Old 04-11-2006, 05:37 PM   · #9
BillyConnite
 
BillyConnite's Avatar
 
Name: Rhett
Location: Coffs H, Australia
Trader Rating: (77)
Join Date: Jul 2005
Posts: 3,106
NP$: 47.00 (Donate)
BillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant future
Wildlife Parkinson's Disease Parkinson's Disease
Originally Posted by nasaboy007
hey secondversion, question for you:

u trim and strip_tags the GET variable. is that to ensure that ppl cant put http://www.abc.com?page=http://www....illawebsite.php as the link and run malicious codes? or is there another reason?

bcuz all the posts/articles i read on this include method, everyone always brought up the point that ppl cud run malicious codes like that and u use use a switch block instead.


Hey nasaboy, I might be able to answer that one for you .

The include function in the later default settings of php do not allow the website to include pages from other websites for that very reason!.

The 'strip_tags' function simply edits out any tags from the $page function that may have been included in the URL (someone could be trying to parse php code through the URL). So strip_tags will remove any '<?php' or '<?' etc from the variable.

Hope that helps,
Rhett.
__________________
<?php if(1===1){ $computer="fine."; }else{ $computer="broken."; } echo "Your computer is ".$computer; ?>
BillyConnite is offline   Reply With Quote
Old 04-11-2006, 05:37 PM   · #10
CreedFeed
NamePros Member
 
CreedFeed's Avatar
 
Trader Rating: (1)
Join Date: Apr 2006
Posts: 175
NP$: 160.00 (Donate)
CreedFeed is on a distinguished road
Yes, the strip_tags and trim functions can help ensure you don't have someone trying to run malicious code via your include functions. You can use a switch block instead and it'll basically be the same as what SecondVersion posted. In SecondVersion's code, he has a "file_exists()" call to ensure the file actually exists on your server in your includes folder before actually including it. This helps protect from malicious code as well, unless someone hacks into your account and places a file in your include folder.
CreedFeed is offline   Reply With Quote
Old 04-12-2006, 01:35 PM   · #11
nasaboy007
NamePros Regular
 
Location: mysitememberships.com
Trader Rating: (32)
Join Date: Jul 2005
Posts: 925
NP$: 4800.90 (Donate)
nasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to beholdnasaboy007 is a splendid one to behold
ah ok i get it thanks guys.


Quote:
This helps protect from malicious code as well, unless someone hacks into your account and places a file in your include folder.



if they hack ur account, wut wud be the point of running malicious code? XD
__________________
nasaboy007 is offline   Reply With Quote
Old 04-12-2006, 01:50 PM   · #12
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
Thanks Billy and Creed for explaining
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
RealTechNetwork Buy Flash Arcade Game Script RealTechNetwork
Advertise your business at NamePros
All times are GMT -7. The time now is 09:11 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0