= 2 && $rDir[strlen($rDir) - 1] == "/") { $end = strlen($rDir) - 2; $rDir = substr($rDir, 0, $end); } if ($errorCount == 0) { // Security checks $ftp_password_db = escapeSQLStr($ftp_pass, $connection); $ftp_username_db = escapeSQLStr($ftp_username, $connection); $rDir = escapeSQLStr($rDir, $connection); $SQL = "SELECT id FROM ftpaccounts WHERE ftpusername = '$ftp_username_db'"; $Result = execSQL($SQL, $connection); if ($Result !== FALSE) { $count = countSQLResult($Result); if ($count > 0) { $errorCount++; $errors[] = "The FTP username supplied already exists!  Please enter another unique username!"; } else { // Make sure data enter is unique for homedir $SQL = "SELECT id FROM ftpaccounts WHERE homedir = '$rDir'"; $Result = execSQL($SQL, $connection); if ($Result !== FALSE) { $count = countSQLResult($Result); // Insert the data into the $SQL = "INSERT INTO ftpaccounts (ftpusername, password, homedir) VALUES ('$ftp_username_db', password('$ftp_password_db'), '$rDir')"; $Result = execSQL($SQL, $connection); if ($Result !== FALSE) { $success = 1; } else { $errorCount++; $errors[] = getSQLError($connection); } } else { $errorCount++; $errors[] = getSQLError($connection); } if ($errorCount > 0 && $success == 0) { unset($_POST['createFTP']); include 'admin/ftpCreateForm.php'; } } } else { $errorCount++; $errors[] = getSQLError($connection); } } } // Log errors if ($errorCount > 0) { addToLog($errors); } // Return value: echo $success; ?>