From ca9c0471b608195a6937d112381262f8ed4dc6b4 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 31 Dec 2023 08:03:19 +0000 Subject: [PATCH 1/2] Update handling of filePath argument --- ajax/system/sys_get_logfile.php | 5 +++-- app/js/custom.js | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ajax/system/sys_get_logfile.php b/ajax/system/sys_get_logfile.php index 92309696..7652092e 100644 --- a/ajax/system/sys_get_logfile.php +++ b/ajax/system/sys_get_logfile.php @@ -3,9 +3,10 @@ require '../../includes/csrf.php'; require_once '../../includes/config.php'; -$filePath = $_GET['filePath']; +$tempDir = sys_get_temp_dir(); +$filePath = $tempDir . DIRECTORY_SEPARATOR . RASPI_DEBUG_LOG; -if (isset($filePath) && strpos($filePath, RASPI_DEBUG_LOG) !== false) { +if (isset($filePath)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($filePath)); header('Expires: 0'); diff --git a/app/js/custom.js b/app/js/custom.js index d305ae89..7c874fd6 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -270,8 +270,7 @@ function setDHCPToggles(state) { $('#debugModal').on('shown.bs.modal', function (e) { var csrfToken = $('meta[name=csrf_token]').attr('content'); $.post('ajax/system/sys_debug.php',{'csrf_token': csrfToken},function(data){ - var filePath = JSON.parse(data); - window.location.replace('/ajax/system/sys_get_logfile.php?filePath='+filePath); + window.location.replace('/ajax/system/sys_get_logfile.php'); $('#debugModal').modal('hide'); }); }); From ebfb1384a4350cc46925311f9afd29a9c800737f Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 31 Dec 2023 08:04:09 +0000 Subject: [PATCH 2/2] Remove file (deprecated) --- ajax/networking/save_net_dev_config.php | 93 ------------------------- 1 file changed, 93 deletions(-) delete mode 100644 ajax/networking/save_net_dev_config.php diff --git a/ajax/networking/save_net_dev_config.php b/ajax/networking/save_net_dev_config.php deleted file mode 100644 index de28a548..00000000 --- a/ajax/networking/save_net_dev_config.php +++ /dev/null @@ -1,93 +0,0 @@ -0,'output'=>['Successfully saved mobile data settings']]; - } else { - $jsonData = ['return'=>1,'output'=>['Error saving mobile data settings']]; - } - } else if ( preg_match("/netdevices/",$int)) { - if(!isset($_POST['opts']) ) { - $jsonData = ['return'=>0,'output'=>['No valid data to add/delete udev rule ']]; - echo json_encode($jsonData); - return; - } else { - $opts=explode(" ",$_POST['opts'] ); - $dev=$opts[0]; - $vid=$_POST["int-vid-".$dev]; - $pid=$_POST["int-pid-".$dev]; - $mac=$_POST["int-mac-".$dev]; - $name=trim($_POST["int-name-".$dev]); - // limit device name to letters and numbers. Total length max 20 - $name=preg_replace("/[^a-z0-9]/", "", strtolower($name)); - $name=substr($name, 0, min(strlen($name),20)); - $type=$_POST["int-type-".$dev]; - $newtype=$_POST["int-new-type-".$dev]; - $udevfile=$_SESSION["udevrules"]["udev_rules_file"]; // default file /etc/udev/rules.d/80-net-devices.rules"; - - // find the rule prototype and prefix - $rule = ""; - foreach($_SESSION["udevrules"]["network_devices"] as $devt) { - if($devt["type"]==$newtype) { - $rulenew = $devt["udev_rule"]; - $prefix = $devt["name_prefix"]; - } - } - - // check for an existing rule and delete lines with same MAC or same VID/PID - if (!empty($vid) && !empty($pid)) { - $rule = '^.*ATTRS{idVendor}==\"' . $vid . '\".*ATTRS{idProduct}==\"' . $pid . '\".*$'; - exec('sudo sed -i "/'.escapeshellarg($rule).'/Id" '.escapeshellarg($udevfile)); // clear all entries with this VID/PID - $rule = '^.*ATTRS{idProduct}==\"' . $pid . '\".*ATTRS{idVendor}==\"' . $vid . '\".*$'; - exec('sudo sed -i "/'.escapeshellarg($rule).'/Id" '.escapeshellarg($udevfile)); // clear all entries with this VID/PID - } - if (!empty($mac)) { - exec('sudo sed -i "/^.*'.escapeshellarg($mac).'.*$/d" '.escapeshellarg($udevfile)); // clear all entries with same MAC - } - // create new entry - if ( ($type != $newtype) || !empty($name) ) { // new device type or new name - if (empty($name)) $name = $prefix."%n"; - if (!empty($mac)) $rule = preg_replace("/\\\$MAC\\\$/i", $mac, $rulenew); - if (!empty($vid)) $rule = preg_replace("/\\\$IDVENDOR\\\$/i", $vid, $rule); - if (!empty($pid)) $rule = preg_replace("/\\\$IDPRODUCT\\\$/i", $pid, $rule); - if (!empty($name)) $rule = preg_replace("/\\\$DEVNAME\\\$/i",$name,$rule); - if (!empty($rule)) exec('echo \''.$rule.'\' | sudo /usr/bin/tee -a '.$udevfile); - } - $jsonData = ['return'=>0,'output'=>['Settings changed for device '.$dev. '
Changes will only be in effect after reconnecting the device' ] ]; - } - } else { - $jsonData = ['return'=>1,'output'=>['Unknown network configuration']]; - } -} else { - $jsonData = ['return'=>2,'output'=>'Unable to detect interface']; -} - -echo json_encode($jsonData);