diff --git a/includes/admin.php b/includes/admin.php index 68fec422..e3227db3 100755 --- a/includes/admin.php +++ b/includes/admin.php @@ -5,7 +5,7 @@ require_once 'includes/status_messages.php'; function DisplayAuthConfig($username) { $status = new StatusMessages(); - $auth = new \RaspAP\Authenticate\HTTPAuth; + $auth = new \RaspAP\Auth\HTTPAuth; $config = $auth->getAuthConfig(); $password = $config['admin_pass']; diff --git a/includes/authenticate.php b/includes/authenticate.php index 3f676be5..bceac97d 100755 --- a/includes/authenticate.php +++ b/includes/authenticate.php @@ -4,7 +4,7 @@ if (RASPI_AUTH_ENABLED) { $user = $_SERVER['PHP_AUTH_USER'] ?? ''; $pass = $_SERVER['PHP_AUTH_PW'] ?? ''; - $auth = new \RaspAP\Authenticate\HTTPAuth; + $auth = new \RaspAP\Auth\HTTPAuth; if (!$auth->isLogged()) { if ($auth->login($user, $pass)) { diff --git a/includes/autoload.php b/includes/autoload.php new file mode 100755 index 00000000..d39bd0c9 --- /dev/null +++ b/includes/autoload.php @@ -0,0 +1,41 @@ +set_max_file_size(64*KB); $upload->set_allowed_mime_types(array('ovpn' => 'text/plain')); $upload->file($file); diff --git a/includes/sysstats.php b/includes/sysstats.php index 5122c91c..2f567a8b 100755 --- a/includes/sysstats.php +++ b/includes/sysstats.php @@ -1,7 +1,5 @@ hostname(); diff --git a/includes/system.php b/includes/system.php index 3babf0c5..26822ae8 100755 --- a/includes/system.php +++ b/includes/system.php @@ -3,64 +3,6 @@ require_once 'includes/status_messages.php'; require_once 'includes/functions.php'; require_once 'config.php'; -require_once 'app/lib/system.php'; - -/** - * Find the version of the Raspberry Pi - * Currently only used for the system information page but may useful elsewhere - */ - -function RPiVersion() -{ - // Lookup table from http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ - $revisions = array( - '0002' => 'Model B Revision 1.0', - '0003' => 'Model B Revision 1.0 + ECN0001', - '0004' => 'Model B Revision 2.0 (256 MB)', - '0005' => 'Model B Revision 2.0 (256 MB)', - '0006' => 'Model B Revision 2.0 (256 MB)', - '0007' => 'Model A', - '0008' => 'Model A', - '0009' => 'Model A', - '000d' => 'Model B Revision 2.0 (512 MB)', - '000e' => 'Model B Revision 2.0 (512 MB)', - '000f' => 'Model B Revision 2.0 (512 MB)', - '0010' => 'Model B+', - '0013' => 'Model B+', - '0011' => 'Compute Module', - '0012' => 'Model A+', - 'a01041' => 'a01041', - 'a21041' => 'a21041', - '900092' => 'PiZero 1.2', - '900093' => 'PiZero 1.3', - '9000c1' => 'PiZero W', - 'a02082' => 'Pi 3 Model B', - 'a22082' => 'Pi 3 Model B', - 'a32082' => 'Pi 3 Model B', - 'a52082' => 'Pi 3 Model B', - 'a020d3' => 'Pi 3 Model B+', - 'a220a0' => 'Compute Module 3', - 'a020a0' => 'Compute Module 3', - 'a02100' => 'Compute Module 3+', - 'a03111' => 'Model 4B Revision 1.1 (1 GB)', - 'b03111' => 'Model 4B Revision 1.1 (2 GB)', - 'c03111' => 'Model 4B Revision 1.1 (4 GB)' - ); - - $cpuinfo_array = ''; - exec('cat /proc/cpuinfo', $cpuinfo_array); - $rev = trim(array_pop(explode(':', array_pop(preg_grep("/^Revision/", $cpuinfo_array))))); - if (array_key_exists($rev, $revisions)) { - return $revisions[$rev]; - } else { - exec('cat /proc/device-tree/model', $model); - if (isset($model[0])) { - return $model[0]; - } else { - return 'Unknown Device'; - } - } -} /** * @@ -134,7 +76,7 @@ function DisplaySystem(&$extraFooterScripts) // define locales $arrLocales = getLocales(); - #fetch system status variables. + // fetch system status variables $system = new \RaspAP\System\Sysinfo; $hostname = $system->hostname(); @@ -143,7 +85,8 @@ function DisplaySystem(&$extraFooterScripts) $os = $system->operatingSystem(); $kernel = $system->kernelVersion(); $systime = $system->systime(); - + $revision = $system->rpiRevision(); + // mem used $memused = $system->usedMemory(); $memused_status = "primary"; @@ -215,6 +158,7 @@ function DisplaySystem(&$extraFooterScripts) "hostname", "uptime", "systime", + "revision", "cores", "os", "kernel", diff --git a/includes/wireguard.php b/includes/wireguard.php index dfe04d5c..547dd048 100755 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -112,7 +112,7 @@ function SaveWireGuardUpload($status, $file, $optRules) throw new RuntimeException('Invalid parameters'); } - $upload = \RaspAP\Uploader\Upload::factory('wg',$tmp_destdir); + $upload = \RaspAP\Uploader\FileUpload::factory('wg',$tmp_destdir); $upload->set_max_file_size(64*KB); $upload->set_allowed_mime_types(array('text/plain')); $upload->file($file); diff --git a/index.php b/index.php index 1da42e06..83e2916d 100755 --- a/index.php +++ b/index.php @@ -27,7 +27,7 @@ require 'includes/csrf.php'; ensureCSRFSessionToken(); require_once 'includes/config.php'; -require_once 'app/lib/Auth.php'; +require_once 'includes/autoload.php'; require_once 'includes/defaults.php'; require_once 'includes/locale.php'; require_once 'includes/functions.php'; diff --git a/app/lib/Auth.php b/src/RaspAP/Auth/HTTPAuth.php old mode 100644 new mode 100755 similarity index 99% rename from app/lib/Auth.php rename to src/RaspAP/Auth/HTTPAuth.php index 5e85d3df..9751075f --- a/app/lib/Auth.php +++ b/src/RaspAP/Auth/HTTPAuth.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace RaspAP\Authenticate; +namespace RaspAP\Auth; class HTTPAuth { diff --git a/app/lib/system.php b/src/RaspAP/System/Sysinfo.php old mode 100644 new mode 100755 similarity index 52% rename from app/lib/system.php rename to src/RaspAP/System/Sysinfo.php index 676c2201..7a45728e --- a/app/lib/system.php +++ b/src/RaspAP/System/Sysinfo.php @@ -1,7 +1,7 @@ @@ -92,5 +92,62 @@ class Sysinfo $kernel = shell_exec("uname -r"); return $kernel; } + + /* + * Returns RPi Model and PCB Revision from Pi Revision Code (cpuinfo) + * @see http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ + */ + public function rpiRevision() + { + $revisions = array( + '0002' => 'Model B Revision 1.0', + '0003' => 'Model B Revision 1.0 + ECN0001', + '0004' => 'Model B Revision 2.0 (256 MB)', + '0005' => 'Model B Revision 2.0 (256 MB)', + '0006' => 'Model B Revision 2.0 (256 MB)', + '0007' => 'Model A', + '0008' => 'Model A', + '0009' => 'Model A', + '000d' => 'Model B Revision 2.0 (512 MB)', + '000e' => 'Model B Revision 2.0 (512 MB)', + '000f' => 'Model B Revision 2.0 (512 MB)', + '0010' => 'Model B+', + '0013' => 'Model B+', + '0011' => 'Compute Module', + '0012' => 'Model A+', + 'a01041' => 'a01041', + 'a21041' => 'a21041', + '900092' => 'PiZero 1.2', + '900093' => 'PiZero 1.3', + '9000c1' => 'PiZero W', + 'a02082' => 'Pi 3 Model B', + 'a22082' => 'Pi 3 Model B', + 'a32082' => 'Pi 3 Model B', + 'a52082' => 'Pi 3 Model B', + 'a020d3' => 'Pi 3 Model B+', + 'a220a0' => 'Compute Module 3', + 'a020a0' => 'Compute Module 3', + 'a02100' => 'Compute Module 3+', + 'a03111' => 'Model 4B Revision 1.1 (1 GB)', + 'b03111' => 'Model 4B Revision 1.1 (2 GB)', + 'c03111' => 'Model 4B Revision 1.1 (4 GB)' + ); + + $cpuinfo_array = ''; + exec('cat /proc/cpuinfo', $cpuinfo_array); + $info = preg_grep("/^Revision/", $cpuinfo_array); + $tmp = explode(':', array_pop($info)); + $rev = trim(array_pop($tmp)); + if (array_key_exists($rev, $revisions)) { + return $revisions[$rev]; + } else { + exec('cat /proc/device-tree/model', $model); + if (isset($model[0])) { + return $model[0]; + } else { + return 'Unknown Device'; + } + } + } } diff --git a/app/lib/uploader.php b/src/RaspAP/Uploader/FileUpload.php old mode 100644 new mode 100755 similarity index 99% rename from app/lib/uploader.php rename to src/RaspAP/Uploader/FileUpload.php index e15e451c..03cd0012 --- a/app/lib/uploader.php +++ b/src/RaspAP/Uploader/FileUpload.php @@ -3,8 +3,6 @@ /** * Simple PHP upload class * - * Adapted from aivis/PHP-file-upload-class - * * @description File upload class for RaspAP * @author Bill Zimmerman * @author Aivis Silins @@ -14,7 +12,7 @@ namespace RaspAP\Uploader; -class Upload +class FileUpload { /** @@ -110,7 +108,7 @@ class Upload */ public static function factory($destination, $root = false) { - return new Upload($destination, $root); + return new FileUpload($destination, $root); } /** diff --git a/templates/system/basic.php b/templates/system/basic.php index e231c216..81adb6d2 100644 --- a/templates/system/basic.php +++ b/templates/system/basic.php @@ -14,7 +14,7 @@ include('includes/sysstats.php');
-
+