Geek Time! : PHP coding question.

As the forum title implies: This is the forum for "anything else" which doesn't fit into one of the other forums.
User avatar
fnordboy
Ed Zwick Wannabe
Posts: 1954
Joined: Sep 25th 2002, 10:29 am
Location: Exit 16E, NJ
Contact:

Post by fnordboy » Jul 23rd 2003, 10:08 am

Now just remember guys, I am not the one making the SciFi movie and such references :D

User avatar
starbug
Lifehead
Posts: 1082
Joined: Jun 25th 2002, 4:51 am
Location: UK

Post by starbug » Jul 23rd 2003, 12:01 pm

but you acknowledge your status as the unreserved geek king of the forum, right? :wink:

'ahhhh, but it hasn't happen happened, has it? I mean it could will have been going to have happened, but it hasn't actually happen happened, has it?'

---------------------------------------------
http://www.urban-hills.blogspot.com
---------------------------------------------

User avatar
fnordboy
Ed Zwick Wannabe
Posts: 1954
Joined: Sep 25th 2002, 10:29 am
Location: Exit 16E, NJ
Contact:

Post by fnordboy » Jul 23rd 2003, 12:05 pm

starbug wrote:but you acknowledge your status as the unreserved geek king of the forum, right? :wink:
Actually no, I am just a mere runner up according to this thread

Me: 42.40631% - Major Geek

MGlenn: 68.44181% - Geek God

:D :D

User avatar
starbug
Lifehead
Posts: 1082
Joined: Jun 25th 2002, 4:51 am
Location: UK

Post by starbug » Jul 23rd 2003, 12:07 pm

Damn it. I forgot about actually checking that thread - but yeah, I'd forgotten about Mglenn and his amazing capacity for all things tiny-and-communication-based.

Sorry Mglenn... :D

---------------------------------------------
http://www.urban-hills.blogspot.com
---------------------------------------------

User avatar
Natasha (candygirl)
MSCL.com Team
MSCL.com Team
Posts: 5374
Joined: Dec 7th 2001, 3:05 am
Location: California

Post by Natasha (candygirl) » Jul 23rd 2003, 1:19 pm

sab wrote:
Nostradamus wrote: Well, that clears it up! Candygirl was right, you need the LMNOP.
Hm, I don't see how the "Lake Merritt Neighbors Organized for Peace" could be of any help here. :wink:
Hey, KMA!

:x

:mrgreen:
Natasha aka candygirl :: MSCL.com

Look, if this is weird for you, being tutored? I don't mind helping you a little longer.
You could have sex with me if you really want to help...I guess that's a "no"?

User avatar
Natasha (candygirl)
MSCL.com Team
MSCL.com Team
Posts: 5374
Joined: Dec 7th 2001, 3:05 am
Location: California

Post by Natasha (candygirl) » Jul 23rd 2003, 1:23 pm

Nothingman wrote:Perhaps you just need more fuel for the flux capacitor, or maybe your matter, anitimatter injectors aren't calibrated correctly.

(I know, I'm not helping :P )
Marty McFly: So does it run on regular unleaded gasoline?
Dr. Emmett Brown: Unfortunately no, it needs something with a little more kick - plutonium.
Marty McFly: Plutonium... wait, are you telling me that this sucker is nuclear?!
Dr. Emmett Brown: No no no, this sucker's electrical, but it requires a nuclear reaction to generate the 1.21 gigawatts of electricity I need.
Marty McFly: Doc, you don't just walk into a store and buy plutonium... did you rip that off??
Dr. Emmett Brown: Shhhhhh!! Of course. From a group of Libyan nationalists. They wanted me to build them a bomb, so I took their plutonium and in turn, gave them a shiny bomb-casing filled with used pinball machine parts!
(later, or earlier depending on how you look at it)
Dr. Emmett Brown: I'm sure in 1985, plutonium is available at every corner drugstore, but in 1955 it's a little hard to come by!
Natasha aka candygirl :: MSCL.com

Look, if this is weird for you, being tutored? I don't mind helping you a little longer.
You could have sex with me if you really want to help...I guess that's a "no"?

User avatar
Nothingman
Liberty High Graduate
Posts: 704
Joined: Feb 26th 2003, 3:39 pm
Location: Hockey Falls, USA
Contact:

Post by Nothingman » Jul 23rd 2003, 1:30 pm

candygirl wrote:Marty McFly: So does it run on regular unleaded gasoline?
Dr. Emmett Brown: Unfortunately no, it needs something with a little more kick - plutonium.
Marty McFly: Plutonium... wait, are you telling me that this sucker is nuclear?!
Dr. Emmett Brown: No no no, this sucker's electrical, but it requires a nuclear reaction to generate the 1.21 gigawatts of electricity I need.
Marty McFly: Doc, you don't just walk into a store and buy plutonium... did you rip that off??
Dr. Emmett Brown: Shhhhhh!! Of course. From a group of Libyan nationalists. They wanted me to build them a bomb, so I took their plutonium and in turn, gave them a shiny bomb-casing filled with used pinball machine parts!
(later, or earlier depending on how you look at it)
Dr. Emmett Brown: I'm sure in 1985, plutonium is available at every corner drugstore, but in 1955 it's a little hard to come by!
Thanks for the BTTF quotes. That made my day. I have to go listen to Huey Lewis - "Power of Love" now. :D
"To come to your senses, you must first go out of your mind." - Alan Watts

User avatar
mglenn
MSCL.com Team
MSCL.com Team
Posts: 552
Joined: May 25th 1999, 4:46 pm
Location: Butler, PA ( AKA: Three Rivers, PA )
Contact:

Post by mglenn » Jul 23rd 2003, 1:57 pm

starbug wrote:Damn it. I forgot about actually checking that thread - but yeah, I'd forgotten about Mglenn and his amazing capacity for all things tiny-and-communication-based.

Sorry Mglenn... :D
No harm! I've already written my Content Management System(CMS) in Java, using XML, JDOM, JDBC and Velocity Template Engine. I'm currently writting the management tools using Swing and AWT. Then theres my mp3 player in my car, cause how many people can say the can compile a linux kernel while they are driving. And which I'm currently trying to get voice recognition to work with (road noise is a bitch, and I don't have enough processor to do realtime phase shift cancelation!) And ofcourse who can forget about AZN, which was my custom cable modem management software I wrote back in 98-99, and then didn't patent...(I'd be rich now damnit!) and the JAS server that lets techtools (I didn't write techtools) connect and get data from our AS400 mainframe....and... gawd I'm a geek!!! :robot:

"Any normal person would have stopped at this point, but for better or worse I'm not a normal person! I'm a geek! A geek beyond reason!"
"When I disagree with a rational man, I let reality be our final arbiter; if I am right, he will learn; if I am wrong, I will; one of us will win, but both will profit." - Ayn Rand

User avatar
Nothingman
Liberty High Graduate
Posts: 704
Joined: Feb 26th 2003, 3:39 pm
Location: Hockey Falls, USA
Contact:

Post by Nothingman » Jul 23rd 2003, 2:05 pm

Ok everyone, we are going to smile and nod on three as if we understood what mglenn just said.

:admire: :turn-l:
"To come to your senses, you must first go out of your mind." - Alan Watts

User avatar
GaryEA
So-Called Addict
Posts: 773
Joined: Oct 30th 2002, 6:45 pm
Location: Exit 15W, NJ
Contact:

Post by GaryEA » Jul 23rd 2003, 9:42 pm

:huh:

User avatar
Natasha (candygirl)
MSCL.com Team
MSCL.com Team
Posts: 5374
Joined: Dec 7th 2001, 3:05 am
Location: California

Post by Natasha (candygirl) » Jul 23rd 2003, 9:55 pm

Yeah, because all I heard was blah blah blah, blah blah blah.

Words.

:D
Natasha aka candygirl :: MSCL.com

Look, if this is weird for you, being tutored? I don't mind helping you a little longer.
You could have sex with me if you really want to help...I guess that's a "no"?

User avatar
fnordboy
Ed Zwick Wannabe
Posts: 1954
Joined: Sep 25th 2002, 10:29 am
Location: Exit 16E, NJ
Contact:

now for something completely different...

Post by fnordboy » Jul 24th 2003, 1:25 am

Sascha (or anyone else who can answer me),

Ok, I actually didn't end up going with your code :oops: , but I might. I wanted to get your opinion on something first. I started searching around through some tutorials for a secure include script. I found one that made sense to me and went with it. Then I kinda decided to kill two birds with one stone and take the existing $page variable and drop it into my title tag, you will see in the code below:

This is what I am including on the wallpapers.php page:

Code: Select all

<?php require_once( "safewallpapers.php");?>

<?php
$include = $_GET['page'];
if ( in_array( $page, $acceptable_pages ) )
{
require_once( "wallpapers/$page.html" );
}
else
{
require_once( "wallpapers/error.html" );
}
?>
The content of safewallpapers.php is this:

Code: Select all

<?php
$acceptable_pages = array(
'Menu',
'Ah My Goddess',
'Ai Yori Aoshi',
'Akihabara Dennou Gumi',
'Azumanga Daioh',
'Bakuretsu Hunters',
'Blood',
'Boogiepop Phantom',
'Cardcaptor Sakura',
'Chobits',
'Comic Party',
'Cowboy Bebop',
'Devil Hunter Yohko',
'Di Gi Charat',
'dot hack',
'El Hazard',
'Escaflowne'
);
?>
Those are the names of the shows that have wallpapers (there will be more, that is just all I added to the list so far). Now in the < title > I did this:

Code: Select all

<title>animeGlitch > Wallpapers > <?php echo "$page"; ?></title>
I figured by linking to wallpapers.php?page=Ah%20My%20Goddess I can load the content securely AND fill in the title tag.

Now, three questions, do you think the above code is kosher? It all seems to work fine for me so far. Do you think it will be too much of a load on the server to have to process the safewallpapers.php page each time the page is loading, especially when the list is double or triple its size right now? And, finally, will I run into a problem with using the spaces between the names of the html includes and is it search friendly?

Sorry to bombard you but I am just a bit confused at this point lol :oops:

Maybe it would be easier to just keep the pages named as shortend versions: "puni.html" instead of "Puni Puni Poemi.html" and figure out an easier way to define the title tag.... maybe an If/Then type deal (if $page='puni' then $title='Puni Puni Poemi') and then echo $title in the title tag?

Thanks in advance. I know this isn't as interesting as dating advice threads but bear with me ;) :lol:

Oh yeah you can see it working at: http://www.animeglitch.com/wallpapers.p ... %20Goddess

or

http://www.animeglitch.com/wallpapers.php?page=Menu (menu links do not work)

User avatar
Sascha
MSCL.com Team
MSCL.com Team
Posts: 1562
Joined: Jun 10th 1999, 5:20 pm
Location: Switzerland
Contact:

Re: now for something completely different...

Post by Sascha » Jul 24th 2003, 5:06 am

Okay, if you're willing to list all allowed pages in your code, then this is a good way to go. But don't use spaces in filenames on a linux machine (or on any webserver). Some browsers don't understand it. I modified your code a little bit:

Code: Select all

<?php require_once( "safewallpapers.php");

$include = $_GET['page'];
if (array_key_exists($include, $acceptable_pages))
{
require_once( "wallpapers/$include.html" );
}
else
{
require_once( "wallpapers/error.html" );
}
?>
The content of safewallpapers.php is this:

Code: Select all

<?php
$acceptable_pages = array(
   'menu' => 'Menu',
   'ahmygoddess' => 'Ah My Goddess',
   'aiyoriaoshi' => 'Ai Yori Aoshi',
   [and so on]
); 

?>

<title>animeGlitch > Wallpapers > <?php echo $acceptable_pages[$include]; ?></title>
You can now link to wallpapers.php?page=ahmygoddess
Now, three questions, do you think the above code is kosher?
Yes, this is perfectly safe.
Do you think it will be too much of a load on the server to have to process the safewallpapers.php page each time the page is loading, especially when the list is double or triple its size right now?
Absolutely no problem if you're not running a webserver on a 1990'ish 486-PC. This array could hold tenthousands of entries and you would only note a tiny delay (we're talking microseconds here).
And, finally, will I run into a problem with using the spaces between the names of the html includes and is it search friendly?
As mentioned above, yes you'd run into problems. But the new code should work even for searchengines. (at least google crawls the first variable in an url)
Last edited by Sascha on Jul 24th 2003, 10:03 am, edited 1 time in total.

User avatar
mglenn
MSCL.com Team
MSCL.com Team
Posts: 552
Joined: May 25th 1999, 4:46 pm
Location: Butler, PA ( AKA: Three Rivers, PA )
Contact:

Post by mglenn » Jul 24th 2003, 8:17 am

Just thought I should post this considering where this is going:

http://www.pclinuxonline.com/modules.ph ... e&sid=7258

:D
"When I disagree with a rational man, I let reality be our final arbiter; if I am right, he will learn; if I am wrong, I will; one of us will win, but both will profit." - Ayn Rand

User avatar
Sascha
MSCL.com Team
MSCL.com Team
Posts: 1562
Joined: Jun 10th 1999, 5:20 pm
Location: Switzerland
Contact:

Post by Sascha » Jul 24th 2003, 11:29 am

mglenn wrote:Just thought I should post this considering where this is going:

http://www.pclinuxonline.com/modules.ph ... e&sid=7258

:D
Yeah, PHP is really good stuff and pretty cheap and easy to get here in Europe. I used ASP before, but you had to pay lots of $$$ to experience something at all (and I didn't like their main dealer, "Big Bill"). All my complicated C sh!t became clear after one puff of PHP. Some of my friends are now using XML-RPC and XSL in addition to PHP and feel pretty good (the secret scene code name is "SOAP"). But I tend more to pure PHP-OO recently, with some CSS, RSS and even SSL when I'm up for it. And I heard that the scene is really excited about a new import from Asia, called "rubY", but I haven't tried that myself yet.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests