|
|
@@ -16,29 +16,25 @@ class Database
|
|
|
$this->assistant_table = "assistant";
|
|
|
$this->group_table = "`group`";
|
|
|
$this->customer_template_table = "customer_template";
|
|
|
- $this->ready = false;
|
|
|
+ $this->ready = False;
|
|
|
}
|
|
|
|
|
|
function connectToDb()
|
|
|
{
|
|
|
-
|
|
|
$host = getenv('CLOUDRON_MYSQL_HOST');
|
|
|
$user = getenv('CLOUDRON_MYSQL_USERNAME');
|
|
|
$password = getenv('CLOUDRON_MYSQL_PASSWORD');
|
|
|
$db = getenv('CLOUDRON_MYSQL_DATABASE');
|
|
|
$port = getenv('CLOUDRON_MYSQL_PORT');
|
|
|
|
|
|
- $this->db_link = mysqli_connect($host, $user, $password);
|
|
|
+ $this->db_link = mysqli_connect($host, $user, $password, $db, $port);
|
|
|
|
|
|
if(!$this->db_link)
|
|
|
exit("Error: ".mysqli_connect_error());
|
|
|
|
|
|
- if(!mysqli_select_db($this->db_link, $db))
|
|
|
- exit("Error: selecting db");
|
|
|
-
|
|
|
mysqli_set_charset($this->db_link, "latin1");
|
|
|
|
|
|
- $this->ready = TRUE;
|
|
|
+ $this->ready = True;
|
|
|
}
|
|
|
|
|
|
function query($query)
|
|
|
@@ -64,34 +60,6 @@ class Database
|
|
|
|
|
|
return $all_rows;
|
|
|
}
|
|
|
-
|
|
|
- function writeToFile($path, $data)
|
|
|
- {
|
|
|
- $file_access_ok = true;
|
|
|
- $file_open = false;
|
|
|
-
|
|
|
- clearstatcache();
|
|
|
-
|
|
|
- if (file_exists($path))
|
|
|
- if (!is_writable($path))
|
|
|
- $file_access_ok = false;
|
|
|
-
|
|
|
- if ($file_access_ok and (!$file_handle = fopen($path, "w+b")))
|
|
|
- $file_access_ok = false;
|
|
|
-
|
|
|
- if ($file_access_ok)
|
|
|
- {
|
|
|
- if (!fwrite($file_handle, $data) and ($data != ''))
|
|
|
- $file_access_ok = false;
|
|
|
- else
|
|
|
- $file_open = true;
|
|
|
- }
|
|
|
-
|
|
|
- if ($file_open)
|
|
|
- fclose($file_handle);
|
|
|
-
|
|
|
- return $file_access_ok;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
?>
|