JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
use preg instead of ereg
[wfpl.git] / upload.php
index 8beca1c..e9ff5db 100644 (file)
@@ -111,10 +111,10 @@ function generate_filename($path, $mime = 'text/plain') {
        }
 
        # replace symbols with underscores
-       $filename = ereg_replace('[^a-z0-9_.]', '_', $filename);
+       $filename = preg_replace('|[^a-z0-9_.]|', '_', $filename);
 
        # remove dots from the beginning (no invisible files)
-       $filename = ereg_replace('^\.*', '', $filename);
+       $filename = preg_replace('|^\.*|', '', $filename);
 
        if(strlen($filename > 80)) {
                $filename = substr($filename, -80);
@@ -181,8 +181,8 @@ function save_uploaded_file($key, $path) {
 # standard places (like /usr/bin or /usr/local bin) and PHP's PATH environment
 # variable is not set appropriately.
 function path_to($prog, $or_die = true) {
-       $prog = ereg_replace('[^a-zA-Z0-9_.-]', '', $prog);
-       $prog = ereg_replace('^[-.]*', '', $prog);
+       $prog = preg_replace('|[^a-z0-9_.-]|i', '', $prog);
+       $prog = preg_replace('|^[-.]*|', '', $prog);
        if($prog == '') {
                die('Invalid argument to path_to()');
        }
@@ -258,7 +258,7 @@ function make_thumbnail($filename, $max_width = '70', $max_height = '70') {
 function exec_or_die($command, $doing_what) {
        exec($command, $dummy, $ret);
        if($ret != 0) {
-               $base = basename(ereg_replace(' .*', '', $command));
+               $base = basename(preg_replace('| .*|', '', $command));
                die("$doing_what failed. $base called exit($ret)");
        }
 }
@@ -280,7 +280,7 @@ function imagemagick_mogrify($in_filename, $args, $doing_what = "Image conversio
 }
 
 function format_int_70($str) {
-       $str = ereg_replace('[^0-9]', '', $str);
+       $str = preg_replace('|[^0-9]|', '', $str);
        if($str == '') {
                $str = '70';
        }
@@ -352,7 +352,7 @@ function image_w_h_or_die($filename) {
 # and names, call convert_uploaded_image().
 function save_uploaded_image($key, $path, $image_width = 0, $image_height = 0, $thumbnail_width = 0, $thumbnail_height = 0) {
      $image_w_h_thumb_w_h = convert_uploaded_image($key, $path, $image_width, $image_height, $thumbnail_width, $thumbnail_height);
-     return ereg_replace(' .*', '', $image_w_h_thumb_w_h);
+     return preg_replace('| .*|', '', $image_w_h_thumb_w_h);
 }
 
 function ext_to_web_image_ext($in) {