Jump to content

dk1983

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dk1983's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wow, thats a lot of code. Remember this: Semantics and Standards Compliance are your friends. A quick roll-your-own-solution: Insert that code I posted above into the top of your file. Place it between an IF statement that checks whether the page has recieved any POST data... <?php if($_POST) { // That code above } // Carry on as normal... ?> <html> <head></head> <body> <form>... Then, below all that you've got your HTML <head>, <body> followed by your form. Have your form's "action" set as the name of this your the same page - when the user submits the form, it will send the data back to itself. Dave
  2. I just tried another method without the loop - i tried to copy() the entire 'folder' of dynamic pages into the static folder with one copy() statement. The script has been running for 20 minutes and it should only be 'saving' 5 pages. I think its definately a timeout thing; maybe the server doesnt like having 5 page requests all at the same time, i dont know. Thanks, your help is appreciated. Dave.
  3. ...But seriously, listen to Naez. (and add yourself a TIMESTAMP in there so you can ORDER BY it, not id).
  4. Thanks for the suggestion; its a good idea but unfortunately I dont want to do that either. The thing is, sometimes I actually want pages to be displayed dynamically every time i reload them. If they have the 'save' code inside them, they'll get saved the first time round and the static page will be displayed after that. At the moment, I can simply delete a static html file to force its corresponding database page to be displayed instead. If I then do want that page to be displayed as static; I just click a button and I run the script mentioned above. But copy() doesnt work when I try to loop that script - a 'Rebuild all' button. Dave
  5. I'll give you a bit of code that looks like PHP but probably has minor errors: <?php // Loop through POSTed data and stick it in a string foreach($_POST as $key=>$value) { // Should probably do some validation checks on those $values here $string .= $key . ": " . $value . "\n"; } // Add the users IP address to the string $string .= "IP: " . $_SERVER['REMOTE_ADDR'] . "\n"; // Stick the string into a file file_put_contents("/your_textfile_path/your_textfile.txt", $string); ?> Once any syntax errors are removed; in theory, that should get you a fairly straightforward text file. Obviously you'll need to change the path to your intended text / log file. Dave
  6. I could do that, however thats not how I want it to work. Basically, the static pages are saved into a 'static' subfolder. I've got my htaccess file directing all requests to 'index.php'. 'index.php' then looks to see if the requested file exists in the static folder. If it does, fetch it. If not, fetch the page from the DB. What im after is automation at the backend. I want a single button to 'rebuild all static html files'. Dave.
  7. Hi there, I've created a database driven web site and am trying to implement a script to go through the dynamic pages and save them statically. Ive got something that almost works - basically i just loop through the pages I want to 'save' and copy the source dynamic page to a new html file. This does work, the copy() command seems to read the source URL as if a user had visited it; the content is pulled from the DB; everything is fine and the static page is 'saved'. The trouble is, copy() seems to choke when its in this loop. I'tll copy the first couple of pages, then just stop. I reckon its timing out; so I tried inserting a sleep(3) within the loop to give the copy process some time - this helped a little; but obviously this could make the script take forever - ie. number of pages * 3 seconds. Any ideas how I can get these dynamic pages saved? Dave.
  8. Hi there, Thanks very much for your reply. It is most helpful! Its funny, but on the drive home from work today I thought of your 'Application Controller' method; having separate pages to do the different things. I just didn't have a name for it I think that is all the help I need for now. I'm going to do some more research on the methods you described and have a go at implementing one. Thanks again, David.
  9. Hi, I know how to code Object Oriented applications but I do not know how to write them! Basically, I've built a blog with HTML/PHP/MySQL. It's made up of functions that each do a specific task. I've then got a switch case structure that calls these functions depending on the value of a $_GET parameter. Pretty simple stuff. However, I'd really like to re write this blog with OO. The thing is, I don't know what classes I should define, what they should do, and how they should interface with each other. I was hoping some expert application designer could help me out here? I don't know if this will help, but here is a list of the functions in my blog. Their names pretty much explain their function. viewCategory(); // This queries the db to display a list of posts in the specified category. Outputs HTML. viewPost(); // Query the db and display one post as HTML viewComment(); // View a single comment belonging to a specific post. Called repeatedly for every comment for that post. Outputs HTML. addComment(); // Add a comment to db. Only called if validateComment returns true (comment is good). validateComment(); // This makes sure a submitted comment (HTML form submit) isn't empty or full of code etc. There are also numerous functions that just output HTML code, i.e: displayAddCommentForm(); // Display comment form displayCategoryList(); // Query db and output an unordered list of the categories Perhaps someone can offer me some advice? Thanks very much, David.
  10. I guess I'll go with the mod_rewrite; possibly have a seperate php script to handle all URL parsing within the site. Thanks for the advice! Dave.
  11. Hi there, First off, apologies if this is in the wrong board. Basically I would like to know if it is feasible to use session variables to handle persistent data instead of passing data via $_GET in the URL string. I'm not keen on the url string mess that I get with $_GET, and I don't want to replace everything in my site with form buttons so I can use $_POST. Can anyone advise me on any issues (security, performance etc) that I need to consider? Thankyou, Dave.
  12. Thanks very much for your help frost110. You too, taith!
  13. Hi, Thanks for your input frost110. I've followed your advice and have made sure that each variable is named explicitly. I dont really understand what you mean by: In my script, adminMode is a boolean value. Why did you test 'if greater than 3'? Also, the adminMode variable isnt stored in the db; it is assigned a value in a password protected admin.php file. Just want to make sure im not missing anything! Thanks, Dave.
  14. Hi again, I just checked, and REGISTER_GLOBALS is turned on. Ive done a bit of reading on the security issues surrounding this and I think I might have a solution. Instead of the $adminMode variable, could I instead create a class with an $adminMode variable and a getter / setter method. Then, all references to the variable would be via: IF (adminClassInstance->getAdminMode()) This way (I'm assuming), no one can spoof the adminMode variable (like create a new global one). Am I correct? Will this ever be safe with REGISTER_GLOBALS turned on? Thanks much, Dave.
  15. Thanks for your reply. Unfortunately, the server I'm working on is not mine, and I'm not sure if register globals is turned on or not. I guess I can write a script to check. I'll also change the variable to an array. I'm already validating all input so once I make the changes you suggested, there shouldn't be any more security holes I hope! Thanks, Dave.
×
×
  • 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.