summaryrefslogtreecommitdiffstats
path: root/app/class/framework.class.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2015-12-18 23:18:33 -0500
committerMalf Furious <m@lfurio.us>2015-12-18 23:18:33 -0500
commit9068e6916ad68194fce2518ab5841af1c8949f3d (patch)
tree2f91e9e3be00c1492cdf4ce88d8e77a909c5c287 /app/class/framework.class.php
parent2ebdbaa48f10d6a6f5a1b78f4ef2c5433e50c8cf (diff)
parentb21251ef971d262dc414869fed83f52d0098bfe6 (diff)
downloadscrott-9068e6916ad68194fce2518ab5841af1c8949f3d.tar.gz
scrott-9068e6916ad68194fce2518ab5841af1c8949f3d.zip
Merge branch 'framework' into dev
Diffstat (limited to '')
-rw-r--r--app/class/framework.class.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/app/class/framework.class.php b/app/class/framework.class.php
new file mode 100644
index 0000000..eea6c25
--- /dev/null
+++ b/app/class/framework.class.php
@@ -0,0 +1,79 @@
+<?php
+
+/* Include the Scrott system-level configuration file if it exists */
+is_file("scrott.conf.php") &&
+ require_once "scrott.conf.php";
+
+require_once "class/mysql.class.php";
+
+/*
+ * Global functions / operations and access to contextual or session-based information
+ */
+abstract class Framework
+{
+ static $dbobj = null;
+
+ /*
+ * Check for the existence of Scrott's system-level config
+ */
+ function scrottConfExists()
+ {
+ global $_SCROTT;
+ return isset($_SCROTT['conf']);
+ }
+
+ /*
+ * Get the absolute path on this server for the root of this app
+ */
+ function ar()
+ {
+ return substr($_SERVER['PHP_SELF'], 0, -10); // 10 = length of "/index.php"
+ }
+
+ /*
+ * Get the absolute path to the current page
+ */
+ function ap()
+ {
+ return $this->ar() . $_REQUEST['path'];
+ }
+
+ /*
+ * Redirect to the given URL and die
+ */
+ function redirectTo($url)
+ {
+ header("Location: " . $url);
+ exit;
+ }
+
+ /*
+ * Get or create the app's database connection object (this is a singleton object and dependent on system-level config)
+ */
+ function getDbConnection()
+ {
+ global $_SCROTT;
+
+ if (self::$dbobj != null)
+ return self::$dbobj;
+
+ switch ($_SCROTT['dbEngine'])
+ {
+ case "mysql":
+ $host = $_SCROTT['dbAddress'];
+ $username = $_SCROTT['dbUser'];
+ $password = $_SCROTT['dbPass'];
+ $dbName = $_SCROTT['dbName'];
+ self::$dbobj = new Mysql($host, $username, $password, $dbName);
+ break;
+
+ default:
+ throw new Exception("Problem with Scrott Configuration. Invalid database engine specified.");
+ break;
+ }
+
+ return self::$dbobj;
+ }
+}
+
+?>