Пример #1
0
 static function CheckCreateForErrors($username, $packageid, $groupid, $email, $password = "")
 {
     global $zdbh;
     $username = strtolower(str_replace(' ', '', $username));
     // Check to make sure the username is not blank or exists before we go any further...
     if (!fs_director::CheckForEmptyValue($username)) {
         $sql = "SELECT COUNT(*) FROM x_accounts WHERE UPPER(ac_user_vc)=:user AND ac_deleted_ts IS NULL";
         $numrows = $zdbh->prepare($sql);
         $user = strtoupper($username);
         $numrows->bindParam(':user', $user);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() != 0) {
                 self::$alreadyexists = true;
                 return false;
             }
         }
         if (!self::IsValidUserName($username)) {
             self::$badname = true;
             return false;
         }
     } else {
         self::$userblank = true;
         return false;
     }
     // Check to make sure the packagename is not blank and exists before we go any further...
     if (!fs_director::CheckForEmptyValue($packageid)) {
         $sql = "SELECT COUNT(*) FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL";
         $numrows = $zdbh->prepare($sql);
         $numrows->bindParam(':packageid', $packageid);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() == 0) {
                 self::$packageblank = true;
                 return false;
             }
         }
     } else {
         self::$packageblank = true;
         return false;
     }
     // Check to make sure the groupname is not blank and exists before we go any further...
     if (!fs_director::CheckForEmptyValue($groupid)) {
         $sql = "SELECT COUNT(*) FROM x_groups WHERE ug_id_pk=:groupid";
         $numrows = $zdbh->prepare($sql);
         $numrows->bindParam(':groupid', $groupid);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() == 0) {
                 self::$groupblank = true;
                 return;
             }
         }
     } else {
         self::$groupblank = true;
         return false;
     }
     // Check for invalid characters in the email and that it exists...
     if (!fs_director::CheckForEmptyValue($email)) {
         if (!self::IsValidEmail($email)) {
             self::$bademail = true;
             return false;
         }
     } else {
         self::$emailblank = true;
         return false;
     }
     // Check that the email address is unique to the user's table
     if (!fs_director::CheckForEmptyValue($email)) {
         if (ctrl_users::CheckUserEmailIsUnique($email)) {
             self::$not_unique_email = false;
             return true;
         } else {
             self::$not_unique_email = true;
             return false;
         }
     } else {
         self::$not_unique_email = true;
         return false;
     }
     // Check for password length...
     if (!fs_director::CheckForEmptyValue($password)) {
         if (strlen($password) < ctrl_options::GetSystemOption('password_minlength')) {
             self::$badpassword = true;
             return false;
         }
     } else {
         self::$passwordblank = true;
         return false;
     }
     return true;
 }