| 607 |
} |
} |
| 608 |
|
|
| 609 |
function createDirectory ($dir) { |
function createDirectory ($dir) { |
| 610 |
|
list($upDirectory, $count) = $this->containingDirectory($dir); |
| 611 |
|
if ($count > 1 AND !file_exists($upDirectory)) $this->createDirectory($upDirectory); |
| 612 |
mkdir($dir); |
mkdir($dir); |
| 613 |
} |
} |
| 614 |
|
|
| 615 |
|
function containingDirectory ($dir) { |
| 616 |
|
$dirs = preg_split('*[/|\\\]*', $dir); |
| 617 |
|
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 618 |
|
$text = trim($dirs[$i]); |
| 619 |
|
unset($dirs[$i]); |
| 620 |
|
if ($text) break; |
| 621 |
|
} |
| 622 |
|
return array(implode('/',$dirs), count($dirs)); |
| 623 |
|
} |
| 624 |
|
|
| 625 |
|
|
| 626 |
function forceCopy ($from, $to) { |
function forceCopy ($from, $to) { |
| 627 |
$todir = dirname($to); |
$todir = dirname($to); |
| 628 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 629 |
$name = mamboCore::getLastPart('/', $from); |
if (!file_exists($todir)) return false; |
| 630 |
|
$name = basename($from); |
| 631 |
$this->deleteFile($to.$name); |
$this->deleteFile($to.$name); |
| 632 |
copy($from, $to); |
return @copy($from, $to); |
| 633 |
|
} |
| 634 |
|
|
| 635 |
|
function lightCopy ($from, $to) { |
| 636 |
|
$name = basename($from); |
| 637 |
|
if (file_exists($to.$name)) return false; |
| 638 |
|
$todir = dirname($to); |
| 639 |
|
if (!file_exists($todir)) $this->createDirectory($todir); |
| 640 |
|
if (!file_exists($todir)) return false; |
| 641 |
|
return @copy($from, $to); |
| 642 |
} |
} |
| 643 |
|
|
| 644 |
|
|
| 1400 |
*/ |
*/ |
| 1401 |
function check() { |
function check() { |
| 1402 |
$this->_error = ''; |
$this->_error = ''; |
| 1403 |
if ($this->name == '') $this->_error = T_('Please enter your name.'); |
if ($this->name == '') $this->_error = _REGWARN_NAME; |
| 1404 |
elseif ($this->username == '') $this->_error = T_('Please enter a user name.'); |
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
| 1405 |
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 (strlen($this->username) < 3 OR preg_match("/[\\<\\>\\\"\\'\\%\\;\\(\\)\\&\\+\\-]/", $this->username)) $this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 ); |
| 1406 |
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.'); |
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
| 1407 |
else { |
else { |
| 1408 |
// check for existing username |
// check for existing username |
| 1409 |
$username = strtolower($this->username); |
$username = strtolower($this->username); |
| 1410 |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1411 |
. "\nWHERE LOWER(username)='$username' AND id!='$this->id'" |
. "\nWHERE LOWER(username)='$username' AND id!='$this->id'" |
| 1412 |
); |
); |
| 1413 |
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; |
| 1414 |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
| 1415 |
// check for existing email |
// check for existing email |
| 1416 |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1417 |
. "\nWHERE email='$this->email' AND id!='$this->id'" |
. "\nWHERE email='$this->email' AND id!='$this->id'" |
| 1418 |
); |
); |
| 1419 |
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; |
| 1420 |
} |
} |
| 1421 |
} |
} |
| 1422 |
if ($this->_error) return false; |
if ($this->_error) return false; |