Jump to content

I want to re-design the way my games website fetches game info


hedgehog90

Recommended Posts

Hi,

 

I own a website called www.gpstudios.com,  a flash games site.

I didn't design it myself, but since having it built a year ago, I understand pretty much all of the inne workings. I'm a game coder so php makes good sense to me.

 

Anyway, i woudl like to change the way a game info (instructions, description) is fetched.

Currently, we have 650 games in our database. The way all the info is gotten is through mySQL.

So, what I would like to do is take these lengthy instructions/description strings and put them each into a text file, within the folder destination of the game.

 

Currently though, we don't even have a folder destination for each game, which is also a problem. Some games have extra files, which our site-developers didn't account for. There are several games that we've had to manually put into folders because of this problem (two .xml files cannot be named the same in the same folder)

 

Also, if you go onto my website and click on a game, you get sent to playgame.php?id=xxx

The main thing I would like to change though (which I have attempted before, but not succeeded with) would be to change the url adress of the games to something more like: www.gpstudios.com/games/game_name/

This is how most game websites do it.

 

When I tried to do this myself, what I did was to simply create an index.php within the folder of one of the aforementioned games, and within this folder I wrote something as simple as:

 

include("../../../playgame.php?id=xxx");

 

But upon loading this page, I would receive a load of error messages regarding all the other includes and requires in the playgame.php.

So by inserting playgame.php?id=xxx in this deep folder, it destroys all other directory links elsewhere.

I investigated and found that inserting set_include_path($_SERVER['DOCUMENT_ROOT']) would fix the problem with all these links, but it didnt - while the page loads, it appears to ignore anything that isn't in the root directory, including images.

I tried the include method with loads of different files, and they just wouldn't load correctly if they used anything outside the root directory.

 

And my final wish would be to do all of this automatically.

To simply write a php file that I would run once and it would generate all the directories for me.

It would need to copy every single description and instructions from mySQL and put them within text files within directories which are named after the game.

I would then need to automatically create a load of index.phps for each individual game with some simple code similar to: include("../../../playgame.php?id=xxx");

Obviously it would be silly to create a load of unique index files with a hard copy of playgame.php, incase I want to give my site a makeover at some stage.

 

 

I'm asking alot aren't I?

Well I know that if I was given the code from another games website, I would understand it and it would be easy to implement, but unfortunately, despite searching, downloading and installing over 10 Flash Game arcade scripts, none of them used this method... despite their demo page showing that they do.

 

 

Mainly, all I need to know is how to is how to generate a php/text file, and then I need to know what method I would use for getting the playgame.php running correctly from  within a different folder.

I'm pretty sure I could do the rest on my own then.

 

Thanks!

Link to comment
Share on other sites

I'm far too tired to puzzle my way through your first problem, sounds like you just want to iterate through your db and dump info into text files in custom/specific directories... Most intro to PHP programming tutorials hold that info.  Start off in the File System section of the PHP manual if unsure.

 

Anyway your second problem isn't a PHP one its an Apache one, more specifically mod_rewrite.  If I understand what you want correctly the solution you need is to rewrite your URL's with mod_rewrite.

Link to comment
Share on other sites

Sorry, I gave the details in a bit of a backwards order - see what originally brought all this about were these several games that required more than an swf file, they needed xml files and the like.

I then discovered that this didn't even work with some of them, because some games are made of several swf files. Now for some bizarre reason, when a flash object loads another local flash object, they need to be in the same destination as the display page.

If this sounds weird, I agree, but it's 100% true.

I have only got a few games that do this, so I wasn't too bothered about it... But it then ocurred to me that it would be a good idea to store the descritpion and instructions within a game folder for each game.

The mySQL server for our website is showing signs of stress, so this seems a good way of relieving it.

 

I just need to know how to load a root directory file while still maintaining it's links to relative files.

Would changing all the filepaths to absolutes heklp? (removing ../ and replacing with server document root)

 

Help will be much appreciated

Link to comment
Share on other sites

Since I last posted I've looked into mod_rewrite, and I'm pretty sure what I'm trying to do is not the way to go about it.

 

I finally found some web arcade script that displayed it's pages like this.

After much searching I found that it was using a RewriteEngine in the .htaccess file.

 

Looking at other sites, I think they probably use this method as well, but I'm doubtful that large game portals like newgrounds and kongregate use it, probably due to sheer amount of games.

 

Anyway, I thought I'd give it a go on my playgame.php file:

 

RewriteEngine on

RewriteRule ^play/([0-9]+) playgame.php?gameid=$1

 

But if I type http://www.gpstudios.com/play/200 I have returned to the original white page situation, with no images loading.

Also, I thought through this technique it would work both ways, but when I type in http://www.gpstudios.com/playgame.php?gameid=200 and load the page, the address doesn't change. How do I make it so that the address converts http://www.gpstudios.com/playgame.php?gameid=200 into http://www.gpstudios.com/play/200 ???

 

I am very confused.

 

Please, someone help :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.