errors since i removed register_globals_on

Started on the old forum in February 2010 · view the original in the archive · old links redirect here

4 replies · 387 views · started 16 years ago · 1 min read

3 participants
nclemale36 Lead · 537 posts #1

i have this error in class.upload.php

Deprecated: Function ereg() is deprecated in /home/sexywap/public_html/web/class.upload.php on line 1690

Deprecated: Function ereg_replace() is deprecated in /home/sexywap/public_html/web/class.upload.php on line 1856

if ($this->uploaded) {
                $this->log .= '- ' . _("file name OK") . '<br />';
1690  >>>>>>>              ereg('\.([^\.]*$)', $this->file_src_name, $extension);    <<<<<<<<
                if (is_array($extension)) {
                    $this->file_src_name_ext      = strtolower($extension[1]);
                    $this->file_src_name_body     = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext)))-1);

and

if ($this->file_safe_name) { // formats the name
                $this->file_dst_name_body = str_replace(array(' ', '-'), array('_','_'), $this->file_dst_name_body) ;
 1856 >>>>>>               $this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body) ;
                $this->log .= '- ' . _("file name safe format") . '<br />';

never come across an error like that before .

djlee Developer · 224 posts #2

depricated means it is no longer in use, generally functions become depricated 1 or 2 main releases of PHP before they are removed. Shows how old your yourscript is lol. ereg and eregi have been replaced with preg_match for a while

ereg('.([^.]*$)', $this->file_src_name, $extension);

becomes

preg_match('/.([^.]*$)/', $this->file_src_name, $extension);

note however the array returned by the function may be different so print_r the extensions array when u first use it and check that [1] is still the file extension string (it should be but u never know)

you could however use a more basic code for file extension from a filename such as

$ext = substr(strrpos($filename,".")+1)

which is just as good and takes less resources. I wouldnt rely on file extensions though, for added security its always better to use mimetypes with a whitelist as mimetypes are more accurate.

for your second code you could use a preg_replace (google it)

nclemale36 Lead · 537 posts #3

lol yeah it is kinda old script cheers anyway but i just downloaded a newer version of it to save me messing around .and its fine now .

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close