Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. could search the form.. change $target_path = $target_path . basename( $_FILES['imgfile']['name']); to <?php $ext = false; switch($_FILES['imgfile']['type']) { case "image/pjpeg": case "image/jpeg": case "image/jpg": $ext = ".jpg"; break; case "image/png": $ext = ".png"; break; case "image/gif": $ext = ".gif"; break; } if($ext === false) die("Bad File Type"); $target_path = $target_path ."NewName".$ext; ?> EDIT: written live, so just a quick untested script also $target_path = $target_path ."NewName".$ext; might need to be $target_path = $target_path ."NewName.".$ext; //Note the extra dot(.)
  2. post what you have.. also reading the manual helps Chapter 38. Handling file uploads
  3. check your xml output.. is it correct/as expected ?
  4. try this User Contributed Notes from php.net http://php.net/manual/en/function.imagecolortransparent.php#78379
  5. isn't Verizon outgoing mail server: outgoing.verizon.net ? 2. your need to setup an email with someone and use their settings
  6. well heres the short version <?php $check = "http://home.google.com"; if(CheckURL($check)) { echo "allowed"; }else{ echo "deny"; } function CheckURL($check) { $allowstr= "http://localhost,http://www.gimppro.co.uk,http://www.test.gimppro.co.uk/img_test.php?foo=bar,http://home.google.com"; $denystr = "http://localhost/private,http://mail.google.com"; $allow = explode(",", strtolower($allowstr)); $deny = explode(",", strtolower($denystr)); $check = strtolower($check); return (in_array($check, $allow) && !in_array($check, $deny)); } ?>
  7. Try this ran a few tests seams okay <?php $check = "http://localhos"; if(CheckURL($check, false)) { echo "allowed"; }else{ echo "deny"; } function CheckURL($check, $full = true) { $allowstr= "http://localhost,http://www.gimppro.co.uk,http://www.test.gimppro.co.uk/img_test.php?foo=bar"; $denystr = "http://localhost/private"; $allow = explode(",", strtolower($allowstr)); $deny = explode(",", strtolower($denystr)); $check = strtolower($check); if($full) { return (in_array($check, $allow) && !in_array($check, $deny)); }else{ $check = preg_quote($check,"/"); $valid = false; foreach($allow as $V) { if(preg_match("%^$check%i", $V)) { $valid = true; foreach($deny as $D) { if(preg_match("%^$check%i", $D)) { $valid = false; } } if($valid) break; } } return $valid; } } ?> of course tweak $full option.. for more advanced searching EDIT: quick correction
  8. can you var_dump($row['banned_urls'], $row['valid_urls']) so i can see what your working with.. and to sum up.. urls MUST be in the valid_urls but NOT in the banned_urls
  9. noted another problem full script .. note the path (as your using the path you need to keep it as a string) <?php $dir = "../backup"; $DirOpen = opendir($dir); while(false !== ($file = readdir($DirOpen))) { $ext = strtolower(strrchr($file,'.')); switch($ext) { case ".tgz": echo '<a href="'.$dir.'/'.$file.'">Download tgz version of '.$file.'</a><br>'; break; case ".gz": echo '<a href="'.$dir.'/'.$file.'">Download gz version of '.$file.'</a><br>'; break; } } ?> as a side note i prefer readdir to glob.. (just do) i think its quicker may test later
  10. right track.. i would probably code like this.. (you could use an array for valid ext's but it depends on what your doing) <?php $dir = opendir("../backup"); while(false !== ($file = readdir($dir))){ $ext = strtolower(strrchr($file,'.')); switch($ext) { case ".tgz": echo '<a href="'.$dir.'/'.$file.'">Download tgz version of '.$file.'</a><br>'; break; case ".gz": echo '<a href="'.$dir.'/'.$file.'">Download gz version of '.$file.'</a><br>'; break; } } ?> EDIT: sorry for bad formatting (not tabs) typed it live, thus untested LOL spelt switch wrong (fixed)
  11. why not try the other way around.. check to see if the banned url exists in the current one.. <?php $bad = preg_quote($row['banned_urls'], '/') if (!preg_match('%$bad%i', $url)) { //Not banned } ?>
  12. ok try this if (preg_match('%\b(^http://[-A-Z0-9.]+)(?:/)?%i', $url, $regs)) or better still if (preg_match('%\b^((?:http://)?(?:[-A-Z0-9.]+))(?:/)?%i', $url, $regs))
  13. Really..! did you even test it ?
  14. http://www.google.co.uk/search?q=php+CMS
  15. try this if($url == $_SERVER['REQUEST_URI']){ //makes sure $url isn't the current file return false; } if (preg_match('%\b^http://([-A-Z0-9.]+)(?:/)?%i', $url, $regs)) { $url= $regs[1]; }
  16. $data = "test_er"; if (preg_match('/_/i', $data )) { die("error _ detected"); }
  17. erm.. change to static ip, erm.. maybe use JS to write to a form.. var ax = new ActiveXObject("WScript.Network"); document.write(ax.UserName + '<br />'); document.write(ax.ComputerName + '<br />'); of course your need to change the security setting on the client machines or maybe a login system.. depends what your using it for..
  18. well you can do <a href="mailto:test@hotmail.com?subject=test">test</a> and <a href="mailto:test@hotmail.com?body=test">test</a> but no idea if <a href="mailto:test@hotmail.com?subject=test&body=hello">test</a> will work.. it should but i have never tried.. hope this helps
  19. i think you maybe able to do <a href="mailto:test@hotmail.com?subject=test">test</a> but why not just email from the site ?
  20. you don't need to leave a site to open another one, the new site will just be the active one.. if you close the browser then fine.... i really wouldn't worry your not opening a security hole
  21. correct.. but after you leave the site your session is gone..
  22. Yep.. see update (3 lines).. <?php if(isset($_POST['submit']))//ADD { //ADD $make = $_POST['make']; $view = $_POST['view']; // Query for insert $sql = "INSERT INTO $table2 (make, view) VALUES ('$make', '$view')"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); // sorts out the uploaded images $upload_dir = "../images/man/"; $insert_id = mysql_insert_id() or die("Unable to get insert id for image name.<br>" . mysql_error()); if (!empty($imageOne)) { // we have an image in image one check we have a valid type (jpeg only ?) if ($_FILES['imageOne']['type'] != "image/jpeg" && $_FILES['imageOne']['type'] != "image/pjpeg") { die("Image type is not allowed for Image One. Type found : " . $_FILES['imageOne']['type']); } else { // valid image make up a new filename $new_image_name = $insert_id . "one.jpg"; if (!copy($_FILES['imageOne']['tmp_name'], $upload_dir . $new_image_name)) { // file uploaded add to table row die("Unable to upload Image One"); } } } // end of code } //ADD ?>
  23. Ahh i see change <?php //Set Post Values ADD 2 lines below $make = $_POST['make']; $view = $_POST['view']; // fixed query for insert, the above one looks like an update $sql = "INSERT INTO $table2 (make, view) VALUES ('$make', '$view')"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); ?> to <?php if(isset($_POST['submit'])) { $make = $_POST['make']; $view = $_POST['view']; // fixed query for insert, the above one looks like an update $sql = "INSERT INTO $table2 (make, view) VALUES ('$make', '$view')"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); } ?>
  24. if the submit button is nameless then don't add that into the field list (array $postfields)..!
  25. personally i think its pointless unsetting them as you need them.. theirs not really a security risk... your just setting a check nothing more
×
×
  • 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.