Skip to content

Commit

Permalink
PHP 7.3 fixes and bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Crawford committed Jul 31, 2019
1 parent ae17d14 commit 2b6b207
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
5 changes: 0 additions & 5 deletions dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
</div>
</div>

<script type="text/javascript">
var timeString = "<?=str_replace("-","/",$systemTime['datetime']);?>";
var startTime = new Date(timeString);
</script>

<div class="row-fluid sortable">
<div class="box span4">
<div class="box-header well">
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/BackupRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function build_archive() {

// Modules (non-core / add-ons)
$non_core_modules = $this->Modules->get_non_core_modules_path();
if ( count($non_core_modules)>0 ) {
if ( isset($non_core_modules) ) {
$mod_build_dir = $this->archive_build_dir . 'mod_build/modules';
if (!file_exists($mod_build_dir)) { mkdir($mod_build_dir, 0777, true); }

Expand Down
9 changes: 5 additions & 4 deletions includes/classes/BoardPresets.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
class BoardPresets {

public $documentRoot;
public $boardPresetArray;
public $selectedBoardArray;
public $boardManufacturerArray;
public $boardPresetArray = [];
public $selectedBoardArray = [];
public $boardManufacturerArray = [];



public function __construct() {
$board_definitions = [];
$this->documentRoot = rtrim($_SERVER['DOCUMENT_ROOT'], '/');

include_once($this->documentRoot . '/includes/board_definitions.php');
Expand Down Expand Up @@ -138,7 +139,7 @@ public function load_board_settings($id = null) {
if (isset($this->selectedBoardArray['modules'])) {
foreach ($this->selectedBoardArray['modules'] as $current_module_name => $curr_module_values) {
$build_module_table[] = [
'moduleName' => $current_module_name,
'moduleKey' => $current_module_name,
'moduleOptions' => serialize($curr_module_values)
];

Expand Down
20 changes: 10 additions & 10 deletions includes/classes/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function select_all($table_name, $custom_sql) {
// SELECT KEY/VALUE PAIR - Return table as key/value associative array
public function select_key_value($sql, $keyCol = NULL, $valueCol = NULL) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$result = $db->query($sql) or die('Query failed');
$result = $db->query($sql) or die('Unable to select key/value pair.');

// Return key/value pairs as associative array
while ($rowArray = $result->fetchArray()) {
Expand All @@ -58,22 +58,22 @@ public function select_key_value($sql, $keyCol = NULL, $valueCol = NULL) {
// SELECT SINGLE - Return single
public function select_single($sql) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$results = $db->querySingle($sql, true) or die('Query failed');
$results = $db->querySingle($sql, true) or die('Unable to select single record from database');
return $results;
}

// VALUE EXISTS - Return True/False
public function exists($table, $column, $value) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$sql = 'SELECT COUNT(*) FROM "'.$table.'" WHERE "'.$column.'" = "'.$value.'";';
$result = $db->querySingle($sql, true) or die('Query failed');
$result = $db->querySingle($sql, true) or die('Unable to locate value in database');
if ( $result['COUNT(*)'] > 0 ) { return true; } else { return false; }
}

// INSERT ROW - Return True/False
public function insert($sql) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$results = $db->query($sql) or die('Query failed');
$results = $db->query($sql) or die('Unable to insert record into database.');
if ( $db->changes() > 0 ) {
$this->set_update_flag(true);
return true;
Expand All @@ -85,7 +85,7 @@ public function insert($sql) {
// UPDATE - Return True/False
public function update($sql) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$results = $db->query($sql) or die('Query failed');
$results = $db->query($sql) or die('Unable to update database.');
if ( $db->changes() > 0 ) {
$this->set_update_flag(true);
return true;
Expand All @@ -97,7 +97,7 @@ public function update($sql) {
// DELETE ROW - Return True/False
public function delete_row($sql) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
$results = $db->query($sql) or die('Query failed');
$results = $db->query($sql) or die('Unable to delete from database.');
if ( $db->changes() > 0 ) { return true; } else { return false; }
}

Expand Down Expand Up @@ -226,7 +226,7 @@ public function deactive_module($id = NULL) {

public function update_preset_modules( $input_array = array() ) {
foreach($input_array as $moduleArray){
$sql = "UPDATE modules SET moduleEnabled='1', moduleOptions='".$moduleArray['moduleOptions']."' WHERE moduleName='".$moduleArray['moduleName']."';";
$sql = "UPDATE modules SET moduleEnabled='1', moduleOptions='".$moduleArray['moduleOptions']."' WHERE moduleKey='".$moduleArray['moduleKey']."';";
$results = $this->insert($sql);
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public function db_import($db_tables, $sql_file) {
$db = new SQLite3($this->db_loc) or die('Unable to open database');
// Loop through each table
foreach ($db_tables as $cur_table) {
$db->query("DELETE FROM $cur_table;") or die('Query failed');
$db->query("DELETE FROM $cur_table;") or die('Unable to delete current record.');
}
$db->close();

Expand All @@ -311,9 +311,9 @@ public function set_update_flag($flag) {
$memcached_obj = new Memcached;
$memcached_obj->addServer('localhost', 11211);
if($flag == true) {
$memcached_obj->set('update_settings_flag', 1, false, 0); // Set Flag
$memcached_obj->set('update_settings_flag', 1); // Set Flag
} else {
$memcached_obj->set('update_settings_flag', 0, false, 0); // Clear Flag
$memcached_obj->set('update_settings_flag', 0); // Clear Flag
}
}

Expand Down
8 changes: 4 additions & 4 deletions includes/classes/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ private function getCPU_Type() {


private function getCPU_Speed() {
$frequency = number_format($this->orp_helper_call('info','cpu_speed') / 1000);
return $frequency . 'MHz';
$frequency = number_format( floatval( $this->orp_helper_call('info','cpu_speed') ) / 1000 );
return $frequency . 'MHz';
}


Expand All @@ -86,7 +86,7 @@ private function getCPU_Load() {
private function getCPU_Temp($unit) {
if(!$unit) { $unit = 'F'; }

$celsius = round($this->orp_helper_call('info','cpu_temp') / 1000, 1);
$celsius = round( floatval( $this->orp_helper_call('info','cpu_temp') ) / 1000, 1);
$fahrenheit = $celsius * 1.8 + 32;

if ($unit == 'C') {
Expand Down Expand Up @@ -215,7 +215,7 @@ public function disk_usage() {


private function capacity($raw_size) {
$clean_size = trim($raw_size);
$clean_size = floatval( trim($raw_size) );

if ($clean_size > 1024000000 ) {
$capacity = number_format(($clean_size * .000000001024), 2, '.', ',') . " PB";
Expand Down
5 changes: 2 additions & 3 deletions includes/js/page-ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ function updateDB() {
}

function loadBoardPreset() {
document.getElementById('loadBoardPreset').submit();

alert('submit form');
// document.getElementById('loadBoardPreset').submit();
console.log('submit form');
}


Expand Down
2 changes: 1 addition & 1 deletion ports.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Cancel</button>
<button class="btn btn-success" onclick="loadBoardPreset();"><i class="icon-circle-arrow-up icon-white"></i> Load</button>
<button class="btn btn-success" onclick="loadBoardPreset()"><i class="icon-circle-arrow-up icon-white"></i> Load</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
Expand Down

0 comments on commit 2b6b207

Please sign in to comment.