First Push

This commit is contained in:
2022-11-02 22:16:03 -04:00
commit 8a635f669d
2054 changed files with 307783 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
<?php
$dbadminusername = "ENTERUSERNAME";
$dbadminpassword = "ENTERPASSWORD";
?>

31
BackendServer/index.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
print '<!-- GETTING TRACKERPHP -->';
require_once('/var/www/bin/inventorytrackconnector.php');
print '<!-- MAKING NEW DB -->';
$database_instance = new Database();
print '<!-- DONE SETUP -->';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Inventory Track</title>
<meta http-equiv="Content-Type" content="charset=utf-8" >
<meta name="description" content="Inventory Tracking Software" >
<meta name="author" content="Noah Backus" >
<!-- <link href='resume.css' rel='stylesheet' type='text/css' media='screen'/>
<link href='print.css' rel='stylesheet' type='text/css' media='print'/>
<link rel="icon" type="image/svg+xml" href="favicon.svg"> -->
</head>
<body id="resume">
<p>
<?php print '<!-- RUNNING DB -->'; print $database_instance->test_con()[0]['name']; print '<!-- RUN IS DONE -->';?>
</p>
<p> should be something above </p>
</body>
</html>

View File

@@ -0,0 +1,62 @@
<?php
// This script functions as the hidden connection to the postgresql db
// Clients never directly contact this script, it is only contacted by the inventorytrack index page
// The index page will call functions from here to get data, and then return it to clients that requested it
// All requests from the index page will need to be authenticated by a session number (except logins, which will then add session keys to then authenticate further requests)
class Database {
public $db;
public function __construct() {
print '<!-- CONSTRUCTING DATABASE -->';
$this->$db = null;
$this->connect();
print '<!-- DONE CONSTRUCTING DATABASE -->';
}
// public function __destructor() {
// if ($this->$db) {
// pg_close($this->$db);
// }
// }
// Establish connection to the db
private function connect() {
print '<!-- CONNECTING DATABASE -->';
// Get credentials
print '<!-- getting creds -->';
require('command.php');
print '<!-- got creds -->';
// Credentials String
$creds = "host=localhost port=5432 user=" . $dbadminusername . " password=" . $dbadminpassword . " dbname=inventorytrackdb";
print '<!-- running connect -->';
if (!$this->$db) {
//$this->$db = new PDO('pgsql:host=localhost;port=5432;dbname=inventorytrackdb', $dbadminusername, $dbadminpassword);
$this->$db = pg_connect($creds);
}
if (!$this->$db) {
echo '<p> NOT ACTUALLY CONNECTED TO DB WTHHH </p>';
}
print '<!-- DONE CONNECTING DATABASE -->';
}
public function test_con() {
print '<!-- TESTING CONNECTION -->';
$result = pg_query($this->$db, "SELECT * FROM users_table;");
// $result = $this->$db->prepare("SELECT * FROM users_table;");
// $result->execute();
// $recordset = $result->fetchAll();
// $result->closeCursor();
print '<!-- DONE TESTING CONNECTION -->';
return pg_fetch_all($result);
}
}
?>