--- mambo/branches/4.6/index.php 2006/01/26 20:11:56 194 +++ mambo/branches/4.6/index.php 2006/01/27 15:37:12 199 @@ -607,15 +607,38 @@ } function createDirectory ($dir) { + list($upDirectory, $count) = $this->containingDirectory($dir); + if ($count > 1 AND !file_exists($upDirectory)) $this->createDirectory($upDirectory); mkdir($dir); } + + function containingDirectory ($dir) { + $dirs = preg_split('*[/|\\\]*', $dir); + for ($i = count($dirs)-1; $i >= 0; $i--) { + $text = trim($dirs[$i]); + unset($dirs[$i]); + if ($text) break; + } + return array(implode('/',$dirs), count($dirs)); + } + function forceCopy ($from, $to) { $todir = dirname($to); if (!file_exists($todir)) $this->createDirectory($todir); - $name = mamboCore::getLastPart('/', $from); + if (!file_exists($todir)) return false; + $name = basename($from); $this->deleteFile($to.$name); - copy($from, $to); + return @copy($from, $to); + } + + function lightCopy ($from, $to) { + $name = basename($from); + if (file_exists($to.$name)) return false; + $todir = dirname($to); + if (!file_exists($todir)) $this->createDirectory($todir); + if (!file_exists($todir)) return false; + return @copy($from, $to); } @@ -1377,23 +1400,23 @@ */ function check() { $this->_error = ''; - if ($this->name == '') $this->_error = T_('Please enter your name.'); - elseif ($this->username == '') $this->_error = T_('Please enter a user name.'); - elseif (strlen($this->username) < 3 OR preg_match("/[\\<\\>\\\"\\'\\%\\;\\(\\)\\&\\+\\-]/", $this->username)) $this->_error = sprintf( T_("Please enter a valid %s. No spaces, more than %d characters and containing only the characters 0-9,a-z, or A-Z"), T_('Username:'), 2 ); - elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = T_('Please enter a valid e-mail address.'); + if ($this->name == '') $this->_error = _REGWARN_NAME; + elseif ($this->username == '') $this->_error = _REGWARN_UNAME; + elseif (strlen($this->username) < 3 OR preg_match("/[\\<\\>\\\"\\'\\%\\;\\(\\)\\&\\+\\-]/", $this->username)) $this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 ); + elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; else { // check for existing username $username = strtolower($this->username); $this->_db->setQuery( "SELECT COUNT(id) FROM #__users " . "\nWHERE LOWER(username)='$username' AND id!='$this->id'" ); - if ($this->_db->loadResult()) $this->_error = T_('This username/password is already in use. Please try another.'); + if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; elseif (mamboCore::get('mosConfig_uniquemail')) { // check for existing email $this->_db->setQuery( "SELECT COUNT(id) FROM #__users " . "\nWHERE email='$this->email' AND id!='$this->id'" ); - if ($this->_db->loadResult()) $this->_error = T_('This e-mail is already registered. If you forgot the password click on "Password Reminder" and new password will be sent to you.'); + if ($this->_db->loadResult()) $this->_error = _REGWARN_EMAIL_INUSE; } } if ($this->_error) return false;