commit 0016096c2e4d9f64a7b6f5bdad71510baa4d8fa9 Author: Skylar Ittner Date: Tue Jun 26 01:53:01 2018 -0600 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af3022d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +nbproject/private +database.mwb.bak +vendor +settings.php \ No newline at end of file diff --git a/assets/machinelabel-sample.svg b/assets/machinelabel-sample.svg new file mode 100644 index 0000000..02a2749 --- /dev/null +++ b/assets/machinelabel-sample.svg @@ -0,0 +1,3790 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..877a8b5 --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "name": "netsyms/pc-info", + "require": { + "catfan/medoo": "^1.5" + }, + "authors": [ + { + "name": "Skylar Ittner", + "email": "admin@netsyms.com" + } + ] +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..c29953f --- /dev/null +++ b/composer.lock @@ -0,0 +1,78 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "c80bb87dd0094978b34bdd28fbeb6413", + "content-hash": "e389a785f072eecc16c5846a620f50b8", + "packages": [ + { + "name": "catfan/medoo", + "version": "v1.5.7", + "source": { + "type": "git", + "url": "https://github.com/catfan/Medoo.git", + "reference": "8d90cba0e8ff176028847527d0ea76fe41a06ecf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/catfan/Medoo/zipball/8d90cba0e8ff176028847527d0ea76fe41a06ecf", + "reference": "8d90cba0e8ff176028847527d0ea76fe41a06ecf", + "shasum": "" + }, + "require": { + "ext-pdo": "*", + "php": ">=5.4" + }, + "suggest": { + "ext-pdo_dblib": "For MSSQL or Sybase database on Linux/UNIX platform", + "ext-pdo_mysql": "For MySQL or MariaDB database", + "ext-pdo_oci": "For Oracle database", + "ext-pdo_oci8": "For Oracle version 8 database", + "ext-pdo_pqsql": "For PostgreSQL database", + "ext-pdo_sqlite": "For SQLite database", + "ext-pdo_sqlsrv": "For MSSQL database" + }, + "type": "framework", + "autoload": { + "psr-4": { + "Medoo\\": "/src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Angel Lai", + "email": "angel@catfan.me" + } + ], + "description": "The lightest PHP database framework to accelerate development", + "homepage": "https://medoo.in", + "keywords": [ + "database", + "lightweight", + "mariadb", + "mssql", + "mysql", + "oracle", + "php framework", + "postgresql", + "sql", + "sqlite" + ], + "time": "2018-06-14 18:59:08" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/database.mwb b/database.mwb new file mode 100644 index 0000000..8801ccf Binary files /dev/null and b/database.mwb differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..75927b8 --- /dev/null +++ b/index.php @@ -0,0 +1,22 @@ + + + +<?php echo SITE_TITLE; ?> + + + + + + \ No newline at end of file diff --git a/machine.php b/machine.php new file mode 100644 index 0000000..4db1bc9 --- /dev/null +++ b/machine.php @@ -0,0 +1,62 @@ +has('machines', ['machineid' => $machineid])) { + $this->machineid = $machineid; + $this->machine = $database->get('machines', ['machineid', 'notes', 'model', 'condition', 'price'], ['machineid' => $machineid]); + $this->history = $database->select('history', ['[>]event_types' => 'eventid'], ['historyid', 'date', 'eventname', 'notes'], ['machineid' => $machineid]); + $this->components = $database->select('components', ['[>]component_types' => 'typeid'], ['compid', 'serial', 'typename', 'tested', 'notes', 'capacity', 'model'], ['machineid' => $machineid]); + } else { + throw new Exception("No machine with that ID number could be found."); + } + } + + public function getHistory() { + return $this->history; + } + + public function getMachineInfo() { + $info = []; + $info['machineid'] = $this->machineid; + if (!empty($this->machine['model'])) { + $info['model'] = $this->machine['model']; + } + if (!empty($this->machine['condition'])) { + $info['condition'] = $this->machine['condition']; + } + if (!empty($this->machine['price'])) { + $info['price'] = $this->machine['price']; + } + $info['notes'] = $this->machine['notes']; + return $info; + } + + public function getComponents() { + $info = []; + foreach ($this->components as $c) { + $info[$c['compid']] = [ + 'serial' => $c['serial'], + 'type' => $c['typename'], + 'notes' => $c['notes'] + ]; + if (!empty($c['tested'])) { + $info[$c['compid']]['tested'] = $c['tested']; + } + if (!empty($c['capacity'])) { + $info[$c['compid']]['capacity'] = $c['capacity']; + } + if (!empty($c['model'])) { + $info[$c['compid']]['model'] = $c['model']; + } + } + return $info; + } +} diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..911a7b8 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_70 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..bf40748 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + PCInfo + + + diff --git a/required.php b/required.php new file mode 100644 index 0000000..b47f949 --- /dev/null +++ b/required.php @@ -0,0 +1,28 @@ + DB_TYPE, + 'database_name' => DB_NAME, + 'server' => DB_SERVER, + 'username' => DB_USER, + 'password' => DB_PASS, + 'charset' => DB_CHARSET + ]); +} catch (Exception $ex) { + header('HTTP/1.1 500 Internal Server Error'); + die("Database error. Try again later. (" . $ex->getMessage() . ")"); +} \ No newline at end of file diff --git a/routes.php b/routes.php new file mode 100644 index 0000000..dc398e9 --- /dev/null +++ b/routes.php @@ -0,0 +1,18 @@ + "home.php", + "info" => "info.php" + ]; + + public static function getRoute($page = "home") { + if (array_key_exists($page, Routes::$ROUTES)) { + return Routes::$ROUTES[$page]; + } else { + return Routes::$ROUTES["home"]; + } + } + +} diff --git a/routes/home.php b/routes/home.php new file mode 100644 index 0000000..abe67fe --- /dev/null +++ b/routes/home.php @@ -0,0 +1,53 @@ + + +
+
+
+ Netsyms Technologies +
+
+ PC Info Finder +
+
+
+

+ Enter the machine ID number on the sticker. Click here if you can't find it. +

+
+ + + +
+
+
+
+
\ No newline at end of file diff --git a/routes/info.php b/routes/info.php new file mode 100644 index 0000000..6e7fb7b --- /dev/null +++ b/routes/info.php @@ -0,0 +1,136 @@ +
+
+
+ Netsyms Technologies +
+
+ Machine # +
+
+
+ getMachineInfo(); + + if (count($info) > 0) { + ?> +
Machine Info:
+
+ $val) { + if (empty($val)) { + continue; + } + $echo = ""; + switch ($key) { + case "model": + $echo = "Model: " . htmlspecialchars($val); + break; + case "condition": + $filled = floor($val); + $echo = "Condition: "; + $empty = 10; + while ($filled > 0) { + $filled--; + $empty--; + $echo .= " "; + } + if ($val - floor($val) > 0.75) { + $empty--; + $echo .= " "; + } else if ($val - floor($val) > 0.25) { + $empty--; + $echo .= " "; + } + while ($empty > 0) { + $empty--; + $echo .= " "; + } + break; + case "price": + $echo = "Sale Value: $" . number_format($val * 1.0, 2); + break; + case "notes": + $echo = "
" . htmlspecialchars($val) . "
"; + break; + } + if ($echo != "") { + echo "
\n$echo\n
\n"; + } + } + ?> +
+ getHistory(); + + if (count($history) > 0) { + ?> +
History:
+
+ \n"; + echo "$h[eventname] on " . date(DATETIME_FORMAT, strtotime($h['date'])) . "
\n"; + if (!empty($h['notes'])) { + echo "
" . htmlspecialchars($h['notes']) . "
"; + } + echo "\n
\n"; + } + ?> +
+ getComponents(); + + if (count($components) > 0) { + ?> +
Components:
+
+ \n"; + echo "$c[type]
\n"; + echo "Serial: $c[serial]
\n"; + if (!empty($c['tested'])) { + echo "Tested on: " . date(DATETIME_FORMAT, strtotime($c['tested'])) . "
\n"; + } + if (!empty($c['capacity'])) { + echo "Capacity: $c[capacity]
\n"; + } + if (!empty($c['model'])) { + echo "Model: $c[model]
\n"; + } + if (!empty($h['notes'])) { + echo "
" . htmlspecialchars($h['notes']) . "
"; + } + echo "\n
\n"; + } + ?> +
+ " . $ex->getMessage() . "

"; + } + ?> +
+
+

Look up another machine:

+
+ + + +
+
+
+ + \ No newline at end of file diff --git a/settings.template.php b/settings.template.php new file mode 100644 index 0000000..2d0c762 --- /dev/null +++ b/settings.template.php @@ -0,0 +1,12 @@ +