From 3355affd6c11b6ab32015bd1eed4306bd020b56b Mon Sep 17 00:00:00 2001 From: M Date: Sat, 21 Nov 2015 17:37:18 -0500 Subject: + Committing initial framework class definition --- app/class/framework.class.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/class/framework.class.php (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php new file mode 100644 index 0000000..452f0c3 --- /dev/null +++ b/app/class/framework.class.php @@ -0,0 +1,26 @@ + -- cgit v1.2.3 From c50a6be054db3ddb260585865df8341e1347ad73 Mon Sep 17 00:00:00 2001 From: M Date: Sat, 21 Nov 2015 20:53:44 -0500 Subject: * Framework def file is now condifionally including system-level app configuration --- app/class/framework.class.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index 452f0c3..e20be7f 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -1,5 +1,9 @@ Date: Sat, 21 Nov 2015 21:47:03 -0500 Subject: + Defined function to check if scrott.conf.php file exists --- app/class/framework.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index e20be7f..5232135 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -9,6 +9,15 @@ is_file("scrott.conf.php") && */ abstract class Framework { + /* + * 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 */ -- cgit v1.2.3 From debd679aa4e3d7eb2d216e57df859dd9e6427f5f Mon Sep 17 00:00:00 2001 From: M Date: Sun, 22 Nov 2015 00:24:37 -0500 Subject: * Implemented framework ar (app root) function --- app/class/framework.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index 5232135..11902d0 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -23,7 +23,7 @@ abstract class Framework */ function ar() { - /* TODO */ + return substr($_SERVER['PHP_SELF'], 0, -10); // 10 = length of "/index.php" } /* -- cgit v1.2.3 From 5a05468fe2d78641d3adb0ba5b83bf526f4f06de Mon Sep 17 00:00:00 2001 From: M Date: Sat, 5 Dec 2015 22:53:34 -0500 Subject: + Added framework function for getting current app path * Changed sysconf view to use new function ($mod->ar()/sysconf -> $mod->ap) --- app/class/framework.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index 11902d0..151ca8e 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -26,6 +26,14 @@ abstract class Framework 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 */ -- cgit v1.2.3 From 366e538edd1a63143ddc229679d3d8be285a9ec3 Mon Sep 17 00:00:00 2001 From: M Date: Sun, 6 Dec 2015 03:10:13 -0500 Subject: * Bug fix in framework class - redirectTo function -- http_redirect function I was using is part of an extension for PHP and therefore, non-standard --- app/class/framework.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index 151ca8e..7244220 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -39,7 +39,7 @@ abstract class Framework */ function redirectTo($url) { - http_redirect($url); + header("Location: " . $url); exit; } } -- cgit v1.2.3 From 886bc202b8debe29f0c3e70b027ad3202e78c263 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 17 Dec 2015 01:36:09 -0500 Subject: + Added function to framework class for getting (or creating) the app's singleton db connection object. If no connection is established, logic uses system-level configuration to decide how to connect before returning --- app/class/framework.class.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'app/class/framework.class.php') diff --git a/app/class/framework.class.php b/app/class/framework.class.php index 7244220..eea6c25 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -4,11 +4,15 @@ 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 */ @@ -42,6 +46,34 @@ abstract class Framework 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; + } } ?> -- cgit v1.2.3