Jump to content

ravix76

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    West Yorkshire, United Kingdom

ravix76's Achievements

Member

Member (2/5)

0

Reputation

  1. I had a script which converted my dynamically produced pages into static HTML. This was to ease indexing and reduce server loads. Following a host move, to one which has PHP5, I can no longer get the script to work: <?php # Set Names for Static Build Pages $sourcepage = "http://www.mysitename.com/dynamicfiles/productpage.php?id=".$row['id']."; $tempfilename = "../dynamicfiles/temp_file.php"; $targetfilename = "../".$branddirectory.$productfilename; # Run PHP Conversion $htmldata = file_get_contents($sourcepage); ?> I get the error: "URL file-access is disabled in the server configuration" and after some hunting around, understand this is due to a change in PHP5, related to "allow_url_fopen". Can anyone recommend a work around or do I need to enable "allow_url_fopen"?
  2. I have a user inputted string which I which to refine for use as a filename. The string might include special characters such as £ % etc which I want to strip out or substitute. I'll then convert to lowercases, append a file extension and use it for the uploaded file / image. I having difficulty making the string safe for filename use. I essentially want to strip out any non a-z or 0-9 characters and strip out any spaces (or substitute with a dash). So "CrazyDave's Upload!" would become "crazydaves-upload.jpg" Do I need regular expressions? <-- seems like a deep topic! Thanks
  3. Thanks! New to this and thought I was going mad!
  4. I'm trying to add some Escaped Data to a MYSQL 5 Database. Variable when input is test"security I then escape it with mysql_real_escape_string (); As a test, I echo the variable before submitting to the db and it shows as test\"security But then when I view it in myPHPAdmin after submission, it appears as test"security i.e. not escaped I'm obviously wanting to protect against SQL injection and am a little baffled! Cheers Ravix
  5. Different thought! I've put term [sTATS] into the dynamic page and thus can str_replace it with "<?php virtual('/phpincs/stats.php'); ?>"
  6. I want to include the following text in a string for ultimate writing to a file. "<?php virtual('/phpincs/stats.php'); ?>" Trouble is, PHP sees the ?> even though it's inside quotes and stops processing php. How do I avoid this? Cheers Ravix
  7. Ok. I'm now outputting static files to filename.php using the following... $staticpagedata = file_get_contents($sourcepage); and then writing to a file. Thus $staticpagedata contains the outputted source of the page and not the dynamic source eg <-- Stats Start--> Static PHP outputted to browser (ie not dynamic) <--Stats End--> What I then want to do is replace all data in the $staticpagedata between "<--Stats Start-->" and "<--Stats End-->" with "<?php virtual('/stats.php'); ?>" In Summary Is there an easy way to cut / replace "EFG" from string "ABCDEFGHIJ" when you know point "D" and "H" but EFG might not always be EFG.... ie I can't use "Str_replace" because I don't know what I'll be replacing" erm... hope that makes sense! Many thanks!
  8. I've created a dynamic site using PHP and MYSQL which is working great. To save server load, I have an admin feature that dumps all the pages (static) to HTML for browsing. However, on the dynamic site, I have a php include with checks IP Address and records a hit if it is unique. As the HTML dumping simply reads the source of the outputted dynamic page and dumps to HTML, the IP Addresd feature doesn't work. Is there a way to call a PHP Include from HTML or do I need to dump all the static pages to php instead? Thanks
  9. Solved thanks to the above. I don't use nl2br for storing. I don't use nl2br for recalling into an editable text form box I do use nl2br for displaying the text as HTML. Love the feeling of solving a bug!
  10. I'm coding an Admin interface which uses the nl2br command to preserve <br>'s on entered text. I then have an edit function which pulls up the saved text into an editable text box (for editting by the admin if that makes sense?). Problem is that when the save text is displayed, it shows the <BR>'s as text (which is fine) but then when saved again, it doubles up on all the <BR>'s. Is there a kind of reverse NL2BR command that I can use to display the saved text so the admin doesn't see the <BR>'s as text? Or, as ever with PHP, is there an easier way? Cheers Rav
  11. Anyone got a pointers to tutorials for checking large chunks of text. I'm fine with the preg_replace command on smaller items (eg checking id's are numbers only etc) but my website requires product manufacturers to cut and paste large chunks of text into an uploadable form. I want to check this (SQL Injection) before inserting it into the SQL database but I'm running into probs with text containing " and `. Here's where I'm at... gotta be an easier way? $pattern="/[^A-Za-z0-9\-\%\.\,\!\(\)\[\]\{\}\:\;\'\"\$\/\^\&\<\>\?\@\_\+\=\ \ ]/"; // Pattern to validate against if (preg_match($pattern, $producttext)) { exit ("Error: Invalid Characters Found In Product Text"); // Stop Script } I believe my server / host has MagicQuotes turned on (if it matters)
  12. That is so much easier than I expected it to be! PHP rocks. Thanks!
  13. Is there a quick and easy way to get paragraphs of text from a webform multiline text box into MYSQL without losing all of the returns (ie 3 Paragraphs remains and can be echo'd as 3 paragraphs and doesn't become one big one). Thanks
  14. Can anyone tell me the best way to find out if a Record already exists in the Database. I'm using the following Code 27 $results = mysql_query("SELECT product FROM `products` WHERE `brand` = '$currentbrand' AND `product` = '$newproductname'"); 28 $nameexists = mysql_result ( $results,0 ); 29 if ($nameexists == $newproductname) $exists=1; However, If the product doesn't exist, the script returns No Rows and and displays a warning "Unable to jump to row 0 on MySQL result index 4" which in turn, I think (?) is causing a Header Error in Line 28. Object Buffering will work around it, but is there a more efficient method? Thanks
×
×
  • 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.