Errors in 0.0.11

Want to share what MODs you've gotten to work with EM? Happy about all the time your're saving? Want to say "thanks"? Here's the place.
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
Nuttzy99
Registered User
Posts: 927
Joined: Fri Aug 03, 2001 7:09 am
Contact:

Re: Errors in 0.0.11

Post by Nuttzy99 »

hrmmm.... permissions must have been altered on this forum. No one was supposed to be able to post in here other me. Oh well, I'll fix it when too many n00bs starting posting here ;)

-Nuttzy :cool:
SpellingCow.com - Free spell check service for your forums or any web form!
My Other Site

User avatar
GPHemsley
Registered User
Posts: 1617
Joined: Fri Apr 18, 2003 4:01 am
Location: Long Beach, NY
Contact:

Re: Errors in 0.0.11

Post by GPHemsley »

Nuttzy99 wrote:hrmmm.... permissions must have been altered on this forum. No one was supposed to be able to post in here other me.
I thought so too, but it didn't give me any errors, so I figured, what the heck. :P

Nuttzy99
Registered User
Posts: 927
Joined: Fri Aug 03, 2001 7:09 am
Contact:

Re: Errors in 0.0.11

Post by Nuttzy99 »

0.0.11a will becoming soon and should fix most of these. Be sure to tell me which ones it doesn't ;)

-Nuttzy :cool:
SpellingCow.com - Free spell check service for your forums or any web form!
My Other Site

User avatar
GPHemsley
Registered User
Posts: 1617
Joined: Fri Apr 18, 2003 4:01 am
Location: Long Beach, NY
Contact:

Re: Errors in 0.0.11

Post by GPHemsley »

Check -=ET=-'s post. I posted them there. ;)

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

I've found a bug that you haven't found and probably won't by yourself :) I actually found it accidentally on my own code and it's in yours, too.

File: em_modio.php
Line: 127

Code: Select all

else if (!file_exists($dir_path))
If for some lame or diabolic reason there is a FILE or a LINK which is named as a directory you want to create, the script will believe it already exists (because file_exists() matches anything) and move on and when you try to create the next subdirectory you'll get errors floating. Imagine that you want to create the path ./profilcp/def/ and for some reason there is a file named 'profilcp'. Do you expect it to create the subdir def/ ? Where? On a file? :)
Weird heh? Well, it happened to me!

Suggestion: change the script to detect if the 'existing' file is not a directory and if so just stop there, because there is nothing else you can do :(

User avatar
GPHemsley
Registered User
Posts: 1617
Joined: Fri Apr 18, 2003 4:01 am
Location: Long Beach, NY
Contact:

Re: Errors in 0.0.11

Post by GPHemsley »

iliasch wrote:File: em_modio.php
Line: 127

Code: Select all

else if (!file_exists($dir_path))
In other words, you can change it to:

Code: Select all

elseif( !( file_exists( $dir_path ) ) || !( is_dir( $dir_path ) ) )
(Pardon the fact that I translated it into the way I code PHP. :mrgreen: )

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

GPHemsley wrote:
iliasch wrote:File: em_modio.php
Line: 127

Code: Select all

else if (!file_exists($dir_path))
In other words, you can change it to:

Code: Select all

elseif( !( file_exists( $dir_path ) ) || !( is_dir( $dir_path ) ) )
(Pardon the fact that I translated it into the way I code PHP. :mrgreen: )
No that's not correct. file_exists() is equal to all three others (is_file,is_dir,is_link). If !file_exists() then it's 100% certain that it's !is_dir and !is_file and !is_link.

IMO something like this would work better:

Code: Select all

elseif ( is_file($dir_path) || is_link($dir_path) ) return FALSE; // get out
elseif ( !file_exists( $dir_path ) ) ... // mkdir
In simple words, we need to check if a file or a link with that name exists, to stop trying to create the directory and get back with an error. Ok now?

User avatar
GPHemsley
Registered User
Posts: 1617
Joined: Fri Apr 18, 2003 4:01 am
Location: Long Beach, NY
Contact:

Re: Errors in 0.0.11

Post by GPHemsley »

Actually, you should just check it like this:

Code: Select all

elseif( !( is_dir( $dir_path ) ) )
Because that way, if it's the name of a file or a link, it doesn't matter--it can stay there. Only if it's a directory does it matter.

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

GPHemsley wrote:Actually, you should just check it like this:

Code: Select all

elseif( !( is_dir( $dir_path ) ) )
Because that way, if it's the name of a file or a link, it doesn't matter--it can stay there. Only if it's a directory does it matter.
Actually it does matter, that's the problem. After you check if it's a file or a link, you can either you file_exists() as it is now, or is_dir() as you say above and this is what I use, but left it file_exists() to show Nuttzy that he doesn't have to change a lot.

In the original code, if a file (not a dir) by that name exists file_exists() will be true and the script will believe the part of the path already exists and try to create the next subdir on the file (error pops up).

Ok, to clear this up I'll paste here the part of the function as it should be IMO:

Code: Select all

// create dirs for processing the file (server)
if ( $this->move_method == 'copy')
{
	$dir_path = '' ;
	$splitarray = explode('/', $copy_path) ;
	for ($idir=0; $idir<count($splitarray)-1; $idir++)
	{
		$dir_path .= trim($splitarray[$idir]) ;
		// don't bother making ../  ;-)
		if ($splitarray[$idir] == '..')
		{
			// do nothing
		}
		elseif ( is_file($dir_path) || is_link($dir_path) )
		{
			return false;
			// return because we can't bypass the problem
		}
		else if ( !is_dir($dir_path) )
		{
			// use the mkdir command
			mkdir($dir_path, 0777);
			chmod($dir_path, 0777);
		}
		$dir_path .= '/' ;
	}
}
I don't know how to make this more clear guys. For a demonstration of the problem try this: on your system create a file named 'dummy' and then try to create a directory named 'dummy'. You get error. That's what php will give you when the script tries to create ./dummy/test/ (the error will occur in 'test'). The important thing to remember is that file_exists() matches anything, not just files.
If you still can't understand, maybe you'll see in action in Qmod, by the end of this week probably.

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: Errors in 0.0.11

Post by Ptirhiik_ »

Do you realise you test here 3 times the file for his status although only one already known interests you ? :) You just didn't sat the problem as it should be :).

Locked