Jump to content

dwees

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

About dwees

  • Birthday 09/15/1975

Profile Information

  • Gender
    Male
  • Location
    United Kingdom

dwees's Achievements

Member

Member (2/5)

0

Reputation

  1. Avoid use of the word JavaScript in your href's. Instead, use an href like #, and put your code for the function in the onclick attribute of your link. To answer your question, what you are suggesting will work, except you need to use <a href="#" onclick="return freak_new(<?php echo $number ?>)">Click me</a> If you use something like this format, you can return false, and cancel the link (if you need to). If you return true, the link goes through. Dave
  2. Use the function file_exists. What you do is use the same technique as you are doing, except save the image to a specific directory, and use something like $filename = md5($params) . '/' . $imagemime; to generate the code for your filename. Somewhere at the top of the script you create a string that contains the parameters for the picture, and also what type of image it is (png etc... but realistically this can generally be hardwired for your purposes. Then you check for the existence of the file, and if it does exist, just open the file and return it, using the appropriate headers, otherwise, return the constructed image. When you construct the image you make sure to save it. To save a little bit more CPU you could, instead of returning the image itself each time, return the image location and put a <?php include("myimagegenerator.php") ?> in the src of the image, and then have this script echo back the location of the newly generated image. This way, you won't even need to open up the image with php, and you can get rid of any fussy headers at the beginning of your output. I've done this type of thing many, many times before. Dave
  3. Try this: $var1 = ($var1 <= $var2) ? $var1 : $var2; $var2 = ($var2 > $var1) ? $var2 : $var1;
  4. Probably a good idea to tell him why its insecure, he did mention he's a newbie. Anyway, you use a $_GET variable which is available for the user to alter in their address bar (but $_POST variables are only slightly harder to spook) and so they can enter whatever they want for the variable. So as a result, you need to consider that variable to be user entered, and strip it of any bad content.
  5. if (round($x/5) == $x/5) { // Do your stuff } or if ($x % 5 == 0 ) { // Do your stuff }
  6. First test your script in a different directory to make sure it works as expected. I'd put 20 throw-away files in a different directory and run a version of this script below, where you specify the files you want in an array called $result. ie. $result = array("filename1.txt", "filename2.txt", "filename3.txt"); and confirm that those are the only files that are deleted using the script below. Then use something like this to delete the extra files and adding this to the script you already have. foreach ($result as $key => $filename) { if (file_exists($filename)) { unlink($filename); } }
  7. One thing I assume you've done already is used print_r of your various arrays to make sure they contain the values you want them to. It will definitely print A LOT of stuff to your browser, but you only have to check a few items. Another option is to randomly select 20 or so files from the $result array and check to see if they are in the $num222 array. If they are not in the database, then chances are extremely good that you have set up your stuff correctly (let's suppose you want to delete 50% of the files then the probability that you have randomly chosen 20 files that are just randomly outside of your dataset is 1/2^20 which is a VERY SMALL number). Once you've established that you have the right files, you can use the file functions at www.php.net to delete the files. My other suggestion is, create a new database and populate it with 10 file names, and put 20 files in a new directory, and repeat the process you've done already with that much smaller subset until you perfect the appropriate deletion of exactly the files you want deleted. This way you can make mistakes with many fewer files, that are essentially expendable.
  8. My suggestion is convert your menus from using tables for layout and look up the 'Son of Suckerfish' menu structure. It works remarkable well. You can then have the same background images as you do now, but you can have those nice drop-down menus that everyone always likes. Basically the 'Son of Suckerfish' menu drop-downs use CSS for browsers that like that kind of stuff, and JavaScript for Internet Explorer. Dave
  9. It's my understanding that ImageMagick has some functions to do perspective transformations of an image, similar to what I did with Gimp and this image - http://www.unitorganizer.com/download/images/google-transformed.png. Is there anyway to access these perspective transformations from within PHP? Failing that, has anyone seen a script which can handle this? Thanks, Dave [attachment deleted by admin]
  10. Change the onclick attribute to an onsubmit attribute and place it as an attribute of the form element. Make sure the onsubmit function returns false if the validation of your form fails. Dave
  11. I'd check to make sure your code is being called at all. Put <?php if (isset($_POST)) { echo 'Yes, my code is working!'; } ?> where you currently have your function and see if the script is being called at all.  I assume that the name of the file this form is in is 'page1.php'?
  12. Isn't there a php function that converts HTML entities back into the characters you'd like to see?  If so, then you can just run the $data through that function first. Dave
  13. You basically want to take a look in your spam filter of your current email client, and actually look at some of those messages, and write down some of the common words that are used in the messages, that are not typically used in regular messages. Some common words to look for are 'viagra' 'cialis', etc...  Then you perform a preg_match('/(bad|words|in|here|separated|by|or|operators)/', $text); and if the results are successful, then store the spam mail somewhere for 30 days (perhaps using a cron job to automatically delete it every 30 days) or so - in case there is some legitimate email which for some reason uses one of the bad words quoted. You may want to do a $test = preg_replace(" ", "", $text); first to strip all of the spaces from the $text first because spammers usually try to 'trick' the spam filter by p u t t i n g some spaces in the middle of their words.  You may also want to remove all the numbers, underscores, dashes, parenthesis, etc... as well (remembering to work on a copy of the email string rather than the original), before you do any validation. Hope this is correct, and helps. Dave
  14. This is exactly the same problem I'm having.  The person who replied last said something about using the object buffer, but I'm really not sure exactly how this helps.  I know I call the image using the php script that creates the image as the image source, but I'd like the saveas option to have a .png instead of .php (for browsers like Firefox that don't check the filetype when doing the saveas, and instead just check the src="image.php"). How do I do this?
  15. Here's my validation function, will this strip the code enough that it will be safe for an eval ? I think that the last two replaces [i]should[/i] be handled with the first replacement, but better safe than sorry I guess. [code] function validate($input) { $input = strtolower($input); $input = preg_replace("/[^a-z0-9()\*\/\\\^\+-\s]+/", "", $input); $input = preg_replace("/[fd]/","", $input); // Just in case, strip BAD php commands $input = preg_replace("/(post|get|request|server|global|cookie|env|files|exec|shell|file|passthru|escapeshellcmd|popen|pcntl_exec)/", "", $input); $input = preg_replace("/'/","",$input); $input = preg_replace('/"/','',$input); return $input; } [/code]
×
×
  • 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.