Update scripts.php

This commit is contained in:
FusionPBX 2017-01-10 01:39:50 -07:00 committed by GitHub
parent 27e709f32d
commit fe00529fb1
1 changed files with 10 additions and 8 deletions

View File

@ -93,7 +93,7 @@ if (!class_exists('scripts')) {
* Copy the switch scripts from the web directory to the switch directory * Copy the switch scripts from the web directory to the switch directory
*/ */
public function copy_files() { public function copy_files() {
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { if (is_array($_SESSION['switch']['scripts'])) {
$dst_dir = $_SESSION['switch']['scripts']['dir']; $dst_dir = $_SESSION['switch']['scripts']['dir'];
if(strlen($dst_dir) == 0) { if(strlen($dst_dir) == 0) {
throw new Exception("Cannot copy scripts the 'script_dir' is empty"); throw new Exception("Cannot copy scripts the 'script_dir' is empty");
@ -122,7 +122,7 @@ if (!class_exists('scripts')) {
* Writes the config.lua * Writes the config.lua
*/ */
public function write_config() { public function write_config() {
if (is_dir($_SESSION['switch']['scripts']['dir'])) { if (is_array($_SESSION['switch']['scripts'])) {
//replace the backslash with a forward slash //replace the backslash with a forward slash
$this->db_path = str_replace("\\", "/", $this->db_path); $this->db_path = str_replace("\\", "/", $this->db_path);
@ -143,13 +143,15 @@ if (!class_exists('scripts')) {
$prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { if (is_array($result)) {
$this->dsn_name = $row["database_name"]; foreach ($result as &$row) {
$this->dsn_username = $row["database_username"]; $this->dsn_name = $row["database_name"];
$this->dsn_password = $row["database_password"]; $this->dsn_username = $row["database_username"];
break; //limit to 1 row $this->dsn_password = $row["database_password"];
break; //limit to 1 row
}
unset ($prep_statement);
} }
unset ($prep_statement);
} }
else { else {
$odbc_num_rows = '0'; $odbc_num_rows = '0';