->addOption('database', null, InputOption::VALUE_REQUIRED, 'Supported database type', 'sqlite')
->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'Name of the database')
->addOption('database-host', null, InputOption::VALUE_REQUIRED, 'Hostname of the database', 'localhost')
- ->addOption('database-port', null, InputOption::VALUE_OPTIONAL, 'Port the database is listening on')
+ ->addOption('database-port', null, InputOption::VALUE_REQUIRED, 'Port the database is listening on')
->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'User name to connect to the database')
->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null)
->addOption('database-table-prefix', null, InputOption::VALUE_OPTIONAL, 'Prefix for all tables (default: oc_)', null)
public function setupDatabase($username) {
$e_host = addslashes($this->dbHost);
- // adding slashes for security reasons
- $e_port = addslashes($this->dbPort);
+ // casting to int to avoid malicious input
+ $e_port = (int)$this->dbPort;
$e_dbname = addslashes($this->dbName);
//check if the database user has admin right
if ($e_host == '') {
// adding port support through installer
if(!empty($this->dbPort)) {
- // adding slashes for security reasons
- $port = addslashes($this->dbPort);
+ // casting to int to avoid malicious input
+ $port = (int)$this->dbPort;
} else if(strpos($e_host, ':')) {
list($e_host, $port)=explode(':', $e_host, 2);
} else {