diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..d5177a5 --- /dev/null +++ b/.htaccess @@ -0,0 +1,13 @@ + + RewriteEngine On + + # Tell PHP that the mod_rewrite module is ENABLED. + SetEnv HTTP_MOD_REWRITE On + + # Dont redirect direct links to files or directories to the index.php + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + + # Rewrite all other URLs to index.php/URL + RewriteRule ^(.*)$ index.php?url=$1 [PT,L] + \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..faa69b3 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +This is a test version of the upcoming SuperSmash Framework +This is a simple framework that works for everyone \ No newline at end of file diff --git a/SuperSmash_Framework.pdf b/SuperSmash_Framework.pdf new file mode 100644 index 0000000..b617ac1 Binary files /dev/null and b/SuperSmash_Framework.pdf differ diff --git a/applications/.htaccess b/applications/.htaccess new file mode 100644 index 0000000..fea6261 --- /dev/null +++ b/applications/.htaccess @@ -0,0 +1,14 @@ +RewriteEngine on + +# disable directory browsing +Options All -Indexes + + + Order Allow,Deny + Deny from all + + +# turn off magic_quotes_gpc for PHP enabled servers + + php_flag magic_quotes_gpc off + \ No newline at end of file diff --git a/applications/start/.htaccess b/applications/start/.htaccess new file mode 100644 index 0000000..fea6261 --- /dev/null +++ b/applications/start/.htaccess @@ -0,0 +1,14 @@ +RewriteEngine on + +# disable directory browsing +Options All -Indexes + + + Order Allow,Deny + Deny from all + + +# turn off magic_quotes_gpc for PHP enabled servers + + php_flag magic_quotes_gpc off + \ No newline at end of file diff --git a/applications/start/cache/.htaccess b/applications/start/cache/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/applications/start/cache/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/applications/start/configuration/.htaccess b/applications/start/configuration/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/applications/start/configuration/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/applications/start/configuration/SuperSmashconfiguration.php b/applications/start/configuration/SuperSmashconfiguration.php new file mode 100644 index 0000000..bc63ce7 --- /dev/null +++ b/applications/start/configuration/SuperSmashconfiguration.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/applications/start/configuration/configuration.php b/applications/start/configuration/configuration.php new file mode 100644 index 0000000..ee0c489 --- /dev/null +++ b/applications/start/configuration/configuration.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/applications/start/configuration/databaseconfiguration.php b/applications/start/configuration/databaseconfiguration.php new file mode 100644 index 0000000..2c511a7 --- /dev/null +++ b/applications/start/configuration/databaseconfiguration.php @@ -0,0 +1,10 @@ + 'mysql', + 'host' => 'localhost', + 'database' => 'framework', + 'username' => 'root', + 'password' => '', + 'port' => '3306' +); +?> \ No newline at end of file diff --git a/applications/start/controllers/index.html b/applications/start/controllers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/start/controllers/introduction.php b/applications/start/controllers/introduction.php new file mode 100644 index 0000000..75d103f --- /dev/null +++ b/applications/start/controllers/introduction.php @@ -0,0 +1,28 @@ +load->model('introduction'); + + // Load the data for the introduction model + $data = $this->IntroductionModel->introduction(); + + // Load the view and add the data + $this->load->view('introduction', $data); + } + + function _afterAction() { + + } +} +?> \ No newline at end of file diff --git a/applications/start/helpers/index.html b/applications/start/helpers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/start/library/index.html b/applications/start/library/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/start/models/index.html b/applications/start/models/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/start/models/introduction.php b/applications/start/models/introduction.php new file mode 100644 index 0000000..d4517f4 --- /dev/null +++ b/applications/start/models/introduction.php @@ -0,0 +1,17 @@ + + 'Hello and welcome to the SuperSmash Framework!
+ This framework will help you while developing your application

+ '); + } +} +?> \ No newline at end of file diff --git a/applications/start/portal.png b/applications/start/portal.png new file mode 100644 index 0000000..a08902d Binary files /dev/null and b/applications/start/portal.png differ diff --git a/applications/start/views/introduction/css/style.css b/applications/start/views/introduction/css/style.css new file mode 100644 index 0000000..05c814d --- /dev/null +++ b/applications/start/views/introduction/css/style.css @@ -0,0 +1,85 @@ +body +{ + margin:0 auto; + background-color:#000000; +} + +h1 { + font-family: SuperSmash, serif; + text-transform: uppercase; + letter-spacing: 1px; + padding:10px; +} + +#container +{ + width:600px; + margin: 0 auto; + background: #F0C74D; + border: 1px solid #999; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; +} + +#header +{ + width: auto; + height:100px; + text-align: center; + color : #F0C74D; +} + +#content +{ + width:600px; + padding: 20px 10px 20px 10px; + margin:0 auto; + text-align: center; +} + +#footer +{ + width:600px; + margin: 0 auto; + background: #F0C74D; + border: 1px solid #999; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; + text-align: center; +} + +#dynamic{ + text-align: center; +} + +#html5{ + position:fixed; + top:20px; + right:5px; + } + +#twitter{ + position:fixed; + top:60px; + right:5px; + } + +#w3c{ + position:fixed; + top:100px; + right:5px; + } + +pre +{ + font-size: 12px; + padding-top: 10px; + background: #f0f0f0; + border: 1px solid #999; + width:400px; + margin: 0 auto; +} \ No newline at end of file diff --git a/applications/start/views/introduction/images/favicon.ico b/applications/start/views/introduction/images/favicon.ico new file mode 100644 index 0000000..8ca31d1 Binary files /dev/null and b/applications/start/views/introduction/images/favicon.ico differ diff --git a/applications/start/views/introduction/images/html5.png b/applications/start/views/introduction/images/html5.png new file mode 100644 index 0000000..f565bbd Binary files /dev/null and b/applications/start/views/introduction/images/html5.png differ diff --git a/applications/start/views/introduction/images/logo.png b/applications/start/views/introduction/images/logo.png new file mode 100644 index 0000000..1aff464 Binary files /dev/null and b/applications/start/views/introduction/images/logo.png differ diff --git a/applications/start/views/introduction/images/mvc.png b/applications/start/views/introduction/images/mvc.png new file mode 100644 index 0000000..d39530f Binary files /dev/null and b/applications/start/views/introduction/images/mvc.png differ diff --git a/applications/start/views/introduction/images/twitter.png b/applications/start/views/introduction/images/twitter.png new file mode 100644 index 0000000..8e9cad8 Binary files /dev/null and b/applications/start/views/introduction/images/twitter.png differ diff --git a/applications/start/views/introduction/images/w3c.png b/applications/start/views/introduction/images/w3c.png new file mode 100644 index 0000000..1acc235 Binary files /dev/null and b/applications/start/views/introduction/images/w3c.png differ diff --git a/applications/start/views/introduction/index.php b/applications/start/views/introduction/index.php new file mode 100644 index 0000000..7265389 --- /dev/null +++ b/applications/start/views/introduction/index.php @@ -0,0 +1,49 @@ + + + + <?php echo configuration('websiteTitle');?> + /images/favicon.ico" rel="shortcut icon" type="image/x-icon"/> + /css/style.css"/> + + + + +
+
+
+ You can edit the Model by going here: +
applications/start/models/welcome.php
+                    
+
+ + You can edit the View by going here: +
applications/start/views/welcome.php
+                
+
+ + You can edit the Controller by going here: +
applications/start/controllers/welcome.php
+                
+ + +
/images/mvc.png" alt="MVC Model" />
+ +
+


+ + + + /images/html5.png" alt="HTML5" /> + /images/twitter.png" alt="Twitter" /> + + \ No newline at end of file diff --git a/applications/taskmanager/.htaccess b/applications/taskmanager/.htaccess new file mode 100644 index 0000000..fea6261 --- /dev/null +++ b/applications/taskmanager/.htaccess @@ -0,0 +1,14 @@ +RewriteEngine on + +# disable directory browsing +Options All -Indexes + + + Order Allow,Deny + Deny from all + + +# turn off magic_quotes_gpc for PHP enabled servers + + php_flag magic_quotes_gpc off + \ No newline at end of file diff --git a/applications/taskmanager/cache/.htaccess b/applications/taskmanager/cache/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/applications/taskmanager/cache/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/applications/taskmanager/configuration/.htaccess b/applications/taskmanager/configuration/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/applications/taskmanager/configuration/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/applications/taskmanager/configuration/SuperSmashconfiguration.php b/applications/taskmanager/configuration/SuperSmashconfiguration.php new file mode 100644 index 0000000..55cd5a0 --- /dev/null +++ b/applications/taskmanager/configuration/SuperSmashconfiguration.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/applications/taskmanager/configuration/configuration.php b/applications/taskmanager/configuration/configuration.php new file mode 100644 index 0000000..7d1b9d2 --- /dev/null +++ b/applications/taskmanager/configuration/configuration.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/applications/taskmanager/configuration/databaseconfiguration.php b/applications/taskmanager/configuration/databaseconfiguration.php new file mode 100644 index 0000000..1f48189 --- /dev/null +++ b/applications/taskmanager/configuration/databaseconfiguration.php @@ -0,0 +1,10 @@ + 'mysql', + 'host' => 'localhost', + 'database' => 'taskmanager', + 'username' => 'root', + 'password' => '', + 'port' => '3306' +); +?> \ No newline at end of file diff --git a/applications/taskmanager/controllers/index.html b/applications/taskmanager/controllers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/taskmanager/controllers/login.php b/applications/taskmanager/controllers/login.php new file mode 100644 index 0000000..610df1f --- /dev/null +++ b/applications/taskmanager/controllers/login.php @@ -0,0 +1,39 @@ +load->model('login'); + + // Load the data for the login model + $data = $this->LoginModel->login($error); + + // Load the view and add the data + $this->load->view('login', $data); + } + + function check(){ + // Load the login Model + $this->load->model('login'); + + if ($this->LoginModel->check()){ + die("ingelogd"); + } else { + $this->start(true); + } + } + + function _afterAction() { + + } +} +?> \ No newline at end of file diff --git a/applications/taskmanager/helpers/index.html b/applications/taskmanager/helpers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/taskmanager/library/index.html b/applications/taskmanager/library/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/taskmanager/models/index.html b/applications/taskmanager/models/index.html new file mode 100644 index 0000000..e69de29 diff --git a/applications/taskmanager/models/login.php b/applications/taskmanager/models/login.php new file mode 100644 index 0000000..8dc4cfd --- /dev/null +++ b/applications/taskmanager/models/login.php @@ -0,0 +1,58 @@ + + 'Use this form to login into the application.' + ); + + if ($error) { + $error = array('errorMessage' => + 'Invalid username or password.' + ); + + $array = array_merge($array, $error); + } + return $array; + } + + public function check(){ + if ($_SERVER['REQUEST_METHOD'] == "POST"){ + if (isset($_POST['username']) && isset($_POST['password'])){ + + // Get the database connection + $database = \System\SuperSmash\SuperSmash::database(); + + $password = $_POST['password']; + + // Check if the username and password are valid + $query = $database->prepare("SELECT * FROM login WHERE username = ? LIMIT 1"); + $query->execute(array($_POST['username'])); + $result = $query->fetch(); + $password = md5(sha1($password . $result['salt'])); + $password = $this->encrypt_login($password, $result['salt']); + return $password == $result['password']; + } + } + } + + private function encrypt_login($string, $key){ + $r = 0; + for ($i = 0; $i < strlen($string); $i++) + $r .= substr((md5($key)), ($i % strlen(md5($key))), + 1) . $string[$i]; + for ($i = 1; $i < strlen($r); $i++) + $string[$i - 1] = chr(ord($r[$i - 1]) + ord(substr(md5 + ($key), ($i % strlen(md5($key))) - 1, 1))); + $value = 0; + $value = urlencode(base64_encode($string)); + return stripslashes($value); + } + } +?> \ No newline at end of file diff --git a/applications/taskmanager/views/login/css/login.css b/applications/taskmanager/views/login/css/login.css new file mode 100644 index 0000000..c93f9d3 --- /dev/null +++ b/applications/taskmanager/views/login/css/login.css @@ -0,0 +1,128 @@ +body +{ + margin:0 auto; + background-color:#000000; +} + +#container +{ + width:600px; + margin: 0 auto; +} + +#header +{ + margin: 0 auto; + height:100px; + text-align: center; + color : #FFFFFF; + font: bold 20px "SuperSmash", Arial; +} + +#footer +{ + width:600px; + margin: 0 auto; + background: #F0C74D; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; + text-align: center; +} + + +#login-box { + width:333px; + height: 352px; + padding: 58px 76px 0 76px; + margin: 0 auto; + color: #ebebeb; + font: 12px Arial, Helvetica, sans-serif; + background: url("../images/background.png") no-repeat left top; +} + +.loginButton{ + margin-left:90px; + background: url("../images/button.png") no-repeat left top; + width:103px; + height:42px; + border:0px; +} + +#login-box img { + border:none; +} + +#login-box h2 { + padding:0; + margin:0; + color: #ebebeb; + font: bold 44px "Calibri", Arial; +} + + +#login-box-username { + float: left; + display:inline; + width:80px; + text-align: right; + padding: 14px 10px 0 0; + margin:0 0 7px 0; +} + +#login-box-usernamefield { + float: left; + display:inline; + width:230px; + margin:0; + margin:0 0 7px 0; +} + +#login-box-password { + float: left; + display:inline; + width:80px; + text-align: right; + padding: 14px 10px 0 0; + margin:0 0 7px 0; +} + +#login-box-passwordfield { + float: left; + display:inline; + width:230px; + margin:0; + margin:0 0 7px 0; +} + +.form-login { + width: 205px; + padding: 10px 4px 6px 3px; + border: 1px solid #0d2c52; + background-color:#1e4f8a; + font-size: 16px; + color: #ebebeb; +} + + +.login-box-options { + clear:both; + padding-left:87px; + font-size: 11px; +} + +.login-box-options a { + color: #ebebeb; + font-size: 11px; +} + +pre +{ + font-size: 12px; + padding-top: 10px; + background: #f0f0f0; + border: 1px solid #999; + width:400px; + margin: 0 auto; +} \ No newline at end of file diff --git a/applications/taskmanager/views/login/images/background.png b/applications/taskmanager/views/login/images/background.png new file mode 100644 index 0000000..1259cce Binary files /dev/null and b/applications/taskmanager/views/login/images/background.png differ diff --git a/applications/taskmanager/views/login/images/button.png b/applications/taskmanager/views/login/images/button.png new file mode 100644 index 0000000..9cd2421 Binary files /dev/null and b/applications/taskmanager/views/login/images/button.png differ diff --git a/applications/taskmanager/views/login/images/favicon.ico b/applications/taskmanager/views/login/images/favicon.ico new file mode 100644 index 0000000..8ca31d1 Binary files /dev/null and b/applications/taskmanager/views/login/images/favicon.ico differ diff --git a/applications/taskmanager/views/login/index.php b/applications/taskmanager/views/login/index.php new file mode 100644 index 0000000..05e7ee8 --- /dev/null +++ b/applications/taskmanager/views/login/index.php @@ -0,0 +1,43 @@ + + + + <?php echo configuration('websiteTitle');?> + /images/favicon.ico" rel="shortcut icon" type="image/x-icon"/> + /css/login.css"/> + + + + +
+
+
" method="post"> +
+ +
+ " . $errorMessage . "
"; ?> +
Username:
+
+ +
+ +
Password:
+ +
+ +
+ +
+ + +
+
+
+
+ + + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..8b609ae --- /dev/null +++ b/index.php @@ -0,0 +1,22 @@ +start(); +?> \ No newline at end of file diff --git a/system/SuperSmash/SuperSmash.php b/system/SuperSmash/SuperSmash.php new file mode 100644 index 0000000..c8f59c1 --- /dev/null +++ b/system/SuperSmash/SuperSmash.php @@ -0,0 +1,108 @@ +Router = loadClass('Router'); + + // get the URL information to be used by the router + $routes = $this->Router->getUrlInformation(); + + // initialise some important routing variables + $controller = $GLOBALS['controller'] = $routes['controller']; + $action = $GLOBALS['action'] = $routes['action']; + $queryString = $GLOBALS['querystring'] = $routes['querystring']; + + // Include the application controller + if(file_exists(settings::getFilePath() . DS . settings::getApp() . DS . 'controllers' . DS . strtolower($controller) . '.php')) + { + require_once (settings::getFilePath() . DS . settings::getApp() . DS . 'controllers' . DS . strtolower($controller) . '.php'); + } + else + { + show_404(); + } + + // Create a new object for the controller + $this->dispatch = new $controller(); + + // Create a database connection object + if (configuration('useDatabase')) + { + if (self::$database == null) + { + self::$database = loadClass('Database','SuperSmash',configuration('database')); + self::$database = self::$database->open(); + } + } + + // Check if we need to put the session in the database + if (configuration('sessionDatabase')) + { + $config['database'] = self::$database; + new Session($config); + } + + // After loading the controller, make sure the method exists, or we have a 404 + if(method_exists($controller, $action)) + { + // Call the beforeAction method in the controller. + $this->performAction($controller, "_beforeAction", $queryString); + + // Call the actual action + $this->performAction($controller, $action, $queryString); + + // Call the afterAction method in the controller. + $this->performAction($controller, "_afterAction", $queryString); + } + else + { + // If the method did not exist, then we have a 404 + show_404(); + } + } + + // This function will perform an action on the specified controller + protected function performAction($controller, $action, $queryString = null) + { + if(method_exists($controller, $action)) + { + return call_user_func_array( array($this->dispatch, $action), $queryString ); + } + return false; + } + + public static function database() + { + return self::$database; + } + + public static function language() + { + // Load the language + $language = loadClass('Language'); + $language->setLanguage(configuration('language', 'SuperSmash')); + $language->load('SuperSmash_errors'); + $language->load('page_errors'); + return $language; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/.htaccess b/system/SuperSmash/applicationchooser/.htaccess new file mode 100644 index 0000000..fea6261 --- /dev/null +++ b/system/SuperSmash/applicationchooser/.htaccess @@ -0,0 +1,14 @@ +RewriteEngine on + +# disable directory browsing +Options All -Indexes + + + Order Allow,Deny + Deny from all + + +# turn off magic_quotes_gpc for PHP enabled servers + + php_flag magic_quotes_gpc off + \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/cache/.htaccess b/system/SuperSmash/applicationchooser/cache/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/system/SuperSmash/applicationchooser/cache/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/configuration/.htaccess b/system/SuperSmash/applicationchooser/configuration/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/system/SuperSmash/applicationchooser/configuration/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/configuration/SuperSmashconfiguration.php b/system/SuperSmash/applicationchooser/configuration/SuperSmashconfiguration.php new file mode 100644 index 0000000..665569f --- /dev/null +++ b/system/SuperSmash/applicationchooser/configuration/SuperSmashconfiguration.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/configuration/configuration.php b/system/SuperSmash/applicationchooser/configuration/configuration.php new file mode 100644 index 0000000..b8881da --- /dev/null +++ b/system/SuperSmash/applicationchooser/configuration/configuration.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/configuration/databaseconfiguration.php b/system/SuperSmash/applicationchooser/configuration/databaseconfiguration.php new file mode 100644 index 0000000..2c511a7 --- /dev/null +++ b/system/SuperSmash/applicationchooser/configuration/databaseconfiguration.php @@ -0,0 +1,10 @@ + 'mysql', + 'host' => 'localhost', + 'database' => 'framework', + 'username' => 'root', + 'password' => '', + 'port' => '3306' +); +?> \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/controllers/chooser.php b/system/SuperSmash/applicationchooser/controllers/chooser.php new file mode 100644 index 0000000..d424a92 --- /dev/null +++ b/system/SuperSmash/applicationchooser/controllers/chooser.php @@ -0,0 +1,34 @@ +load->model('chooser'); + + // Load the data for the chooser model + $data = array_merge($this->ChooserModel->denyList()); + $data += $this->ChooserModel->chooser(); + + // Load the view and add the data + $this->load->view('chooser', $data); + } + + function _afterAction() + { + + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/controllers/index.html b/system/SuperSmash/applicationchooser/controllers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/system/SuperSmash/applicationchooser/helpers/index.html b/system/SuperSmash/applicationchooser/helpers/index.html new file mode 100644 index 0000000..e69de29 diff --git a/system/SuperSmash/applicationchooser/library/index.html b/system/SuperSmash/applicationchooser/library/index.html new file mode 100644 index 0000000..e69de29 diff --git a/system/SuperSmash/applicationchooser/models/chooser.php b/system/SuperSmash/applicationchooser/models/chooser.php new file mode 100644 index 0000000..fbed4ff --- /dev/null +++ b/system/SuperSmash/applicationchooser/models/chooser.php @@ -0,0 +1,26 @@ + + 'This portal contains several websites
+ Please click on the website that you would like to visit

+ '); + } + + public function denyList() + { + return array('denyList' => + '.htaccess'); + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/models/index.html b/system/SuperSmash/applicationchooser/models/index.html new file mode 100644 index 0000000..e69de29 diff --git a/system/SuperSmash/applicationchooser/portal.png b/system/SuperSmash/applicationchooser/portal.png new file mode 100644 index 0000000..dcff5f5 Binary files /dev/null and b/system/SuperSmash/applicationchooser/portal.png differ diff --git a/system/SuperSmash/applicationchooser/views/chooser/css/style.css b/system/SuperSmash/applicationchooser/views/chooser/css/style.css new file mode 100644 index 0000000..ea0db34 --- /dev/null +++ b/system/SuperSmash/applicationchooser/views/chooser/css/style.css @@ -0,0 +1,93 @@ +body +{ + margin:0 auto; +} + +h1 { + font-family: SuperSmash, serif; + text-transform: uppercase; + letter-spacing: 1px; + padding:10px; +} + +#container +{ + width:600px; + margin: 0 auto; + background: gray; + border: 1px solid #999; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; +} + +.button{ + font-size:16px; + font-family:Arial,sans-serif; + height:100px; + width:100px; + border-width:0px; + cursor:pointer; +} + +#header +{ + width: auto; + height:100px; + text-align: center; + color : #F0C74D; +} + +#content +{ + width:600px; + padding: 20px 10px 20px 10px; + margin:0 auto; + text-align: center; +} + +#footer +{ + width:600px; + margin: 0 auto; + background: white; + border: 1px solid #999; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; + text-align: center; +} + +#dynamic{ + text-align: center; +} + +#html5{ + position:fixed; + top:20px; + right:5px; + } + +#twitter{ + position:fixed; + top:60px; + right:5px; + } + +#w3c{ + position:fixed; + top:100px; + right:5px; + } + +pre +{ + font-size: 12px; + padding-top: 10px; + background: #f0f0f0; + border: 1px solid #999; + width:400px; + margin: 0 auto; +} \ No newline at end of file diff --git a/system/SuperSmash/applicationchooser/views/chooser/images/background.png b/system/SuperSmash/applicationchooser/views/chooser/images/background.png new file mode 100644 index 0000000..c9ba2e2 Binary files /dev/null and b/system/SuperSmash/applicationchooser/views/chooser/images/background.png differ diff --git a/system/SuperSmash/applicationchooser/views/chooser/images/favicon.ico b/system/SuperSmash/applicationchooser/views/chooser/images/favicon.ico new file mode 100644 index 0000000..8ca31d1 Binary files /dev/null and b/system/SuperSmash/applicationchooser/views/chooser/images/favicon.ico differ diff --git a/system/SuperSmash/applicationchooser/views/chooser/index.php b/system/SuperSmash/applicationchooser/views/chooser/index.php new file mode 100644 index 0000000..b5615e9 --- /dev/null +++ b/system/SuperSmash/applicationchooser/views/chooser/index.php @@ -0,0 +1,43 @@ + + + + <?php echo configuration('websiteTitle');?> + + + + + + +
+
+
+ 0) + { + continue; + } + + echo "
"; + if (file_exists(ROOT . "/applications/$application/portal.png")){ + echo ""; + } else { + echo ""; + } + echo "
$application +
+
"; + }; + ?> +
+


+ + + \ No newline at end of file diff --git a/system/SuperSmash/benchmark.php b/system/SuperSmash/benchmark.php new file mode 100644 index 0000000..3714f2c --- /dev/null +++ b/system/SuperSmash/benchmark.php @@ -0,0 +1,69 @@ +start[$key] = microtime(true); + } + + // This function will stop the specified timer + public function stop($key) + { + $this->stop[$key] = microtime(true); + } + + // This function will show the specified timer + public function elapsed($key, $round = 3, $stop = false) + { + if(!isset($this->start[$key])) + { + return false; + } + else + { + if(!isset($this->stop[$key]) && $stop == true) + { + $this->stop[$key] = microtime(true); + } + return round((microtime(true) - $this->start[$key]), $round); + } + } + + // This function will return the amount of memory the page uses while loading + public function usage() + { + $returnValue = ''; + $usage = memory_get_usage(true); + + if($usage < 1024) + { + $returnValue = $usage." bytes"; + } + elseif($usage < 1048576) + { + $returnValue = round($usage/1024, 2)." kilobytes"; + } + else + { + $returnValue = round($usage/1048576, 2)." megabytes"; + } + return $returnValue; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/boot/applications.php b/system/SuperSmash/boot/applications.php new file mode 100644 index 0000000..50c7534 --- /dev/null +++ b/system/SuperSmash/boot/applications.php @@ -0,0 +1,135 @@ + \ No newline at end of file diff --git a/system/SuperSmash/boot/bootstrap.php b/system/SuperSmash/boot/bootstrap.php new file mode 100644 index 0000000..911dd8d --- /dev/null +++ b/system/SuperSmash/boot/bootstrap.php @@ -0,0 +1,25 @@ +start('system'); + +// Load the SuperSmash Framework +$SuperSmash = loadClass('SuperSmash'); + +?> \ No newline at end of file diff --git a/system/SuperSmash/configuration.php b/system/SuperSmash/configuration.php new file mode 100644 index 0000000..bb2d791 --- /dev/null +++ b/system/SuperSmash/configuration.php @@ -0,0 +1,176 @@ +load(settings::getFilePath() . DS . settings::getApp() . DS . 'configuration' . DS . 'configuration.php', 'SuperSmash'); + } + + // This function will get the specified variable from the configuration file + public function get($key, $type = 'SuperSmash') + { + // Check if the variable exists + if(isset($this->data[$type][$key])) + { + return $this->data[$type][$key]; + } + return null; + } + + // This function will return all the variables that where set in the data array + public function getAll($type = 'SuperSmash') + { + // Check if the variable exists + if(isset($this->data[$type])) + { + return $this->data[$type]; + } + return null; + } + + // This function will set a variable in the data array + public function set($key, $value = false, $name = 'SuperSmash') + { + // If we have array, loop through and set each + if(is_array($item)) + { + foreach($item as $key => $value) + { + $this->data[$name][$key] = $value; + } + } + else + { + $this->data[$name][$item] = $value; + } + } + + // This function will load a specific configuration file and will add its defined variables to the array + public function load($file, $name, $array = false) + { + // Include file and add it to the $files array + if(!file_exists($file)) + { + return; + } + + require_once ($file); + $this->files[$name]['filePath'] = $file; + $this->files[$name]['config_key'] = $array; + + if($array) + { + $variables = $variables[$array]; + } + else + { + $variables = get_defined_vars(); + } + + // Unset the passed variables + unset($variables['file'], $variables['name'], $variables['array']); + + // Add the variables to the $data[$name] array + if(count($variables) > 0) + { + foreach($variables as $key => $value) + { + if($key != 'this' && $key != 'data') + { + $this->data[$name][$key] = $value; + } + } + } + return; + } + + // This function will save all config variables to the config file, + // and makes a backup of the current config file + public function save($name) + { + // Convert everything to lowercase + $name = strtolower($name); + + // Check to see if we need to put this in an array + $configKey = $this->files[$name]['config_key']; + + if($configKey != false) + { + $Old_Data = $this->data[$name]; + $this->data[$name] = array("$configKey" => $this->data[$name]); + } + + // Create the new configuration file + $configurationContent = "data[$name] as $key => $value) + { + if(is_numeric($value)) + { + $configurationContent .= "\$$key = " . $value . ";\n"; + } + elseif(is_array($value)) + { + $val = var_export($value, true); + $configurationContent .= "\$$key = " . $value . ";\n"; + } + else + { + $configurationContent .= "\$$key = '" . addslashes( $value ) . "';\n"; + } + } + + // Close the php tag + $configurationContent .= "?>"; + + // Add the back to non array if we did put it in one + if($configKey != false) + { + $this->data[$name] = $Old_Data; + } + + // Copy the current config file for backup, + // and write the new config values to the new config + copy($this->files[$name]['filePath'], $this->files[$name]['filePath'].'.bak'); + return file_put_contents($this->files[$name]['filePath'], $configurationContent); + } + + // This function will revert the last saved configurationFile + public function restore($name) + { + // Copy the backup config file nd write the config values to the current config + return copy($this->files[$name]['filePath'].'bak', $this->files[$name]['filePath']); + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/controller.php b/system/SuperSmash/controller.php new file mode 100644 index 0000000..cec8c81 --- /dev/null +++ b/system/SuperSmash/controller.php @@ -0,0 +1,84 @@ +controller = $GLOBALS['controller']; + $this->action = $GLOBALS['action']; + $this->queryString = $GLOBALS['querystring']; + + // Initiate the loader + $this->load = loadClass('Loader'); + + // Initiate the autoloader Helpers + $helpers = configuration('helpers', 'SuperSmash'); + if(count($helpers) > 0) + { + foreach($helpers as $helper) + { + $this->load->helpers($helper); + } + } + + // Intiate the autoloader Libraries + $libraries = configuration('libraries', 'SuperSmash'); + if(count($libraries) > 0) + { + foreach($libraries as $library) + { + $this->load->libraries($library); + } + } + } + + // This function will get the controller instance + public static function getInstance() + { + return self::$instance; + } + + // This function will be called before an action is taken + public function _beforeAction() + { + // We can write some custom code here that will be taken before an action is made + } + + // This function will be called after an action is taken + public function _afterAction() + { + // We can write some custom code here that will be taken after an action is made + } + +} +?> \ No newline at end of file diff --git a/system/SuperSmash/cookie.php b/system/SuperSmash/cookie.php new file mode 100644 index 0000000..84b87dd --- /dev/null +++ b/system/SuperSmash/cookie.php @@ -0,0 +1,106 @@ + (4 * 1024)) + { + trigger_error( "The cookie {$name} exceeds the specification for the maximum cookie size. Some data may be lost", E_USER_WARNING ); + } + } + + // Force value into superglobal + if ($force) + { + $_COOKIE[$name] = $value; + } + + // Set the cookie + return setcookie($name, $value, (($expire) ? (time() + (int) $expire) : self::$expire), ($path) ? $path : self::$path, ($domain) ? $domain : self::$domain, ($secure) ? $secure : self::$secure, ($httponly) ? $httponly : self::$httponly); + } + + // Check if the cookie exists + public static function exists($name) + { + return isset($_COOKIE[$name]); + } + + + // Get a cookie value + public static function get($name) + { + return (isset($_COOKIE[$name])) ? unserialize(base64_decode($_COOKIE[$name])) : NULL; + } + + // Remove a cookie + public static function remove($name, $force = false) + { + // Check if the cookie isset + if (isset($_COOKIE[$name])) + { + // Remove from superglobal + if ($force) + { + unset($_COOKIE[$name]); + } + + // Remove the cookie + return setcookie($name, '', time() - (3600 * 25), self::$path, self::$domain, self::$secure, self::$httponly); + } + } +} +Cookie::init(); +?> \ No newline at end of file diff --git a/system/SuperSmash/database.php b/system/SuperSmash/database.php new file mode 100644 index 0000000..7c8fcc9 --- /dev/null +++ b/system/SuperSmash/database.php @@ -0,0 +1,852 @@ +getError(); + * + * Execute a query to the database: + * + * $database->query("SELECT * FROM databaseName WHERE id = '1'";) + * + * You can also get the inserted ID of the query you executed: + * + * $insertedId = $database->insert("TABLE", "record1,record2,record3", "value1,value2,value3";) + * Example: INSERT INTO USERS,firstname,lastname,VALUES('Amber','Heard') WHERE ADDRESS = 'Dark avenue 2'; + * Example: $insertedID = $database->insert("USERS","ADDRESS='Dark avenue 2','Amber',Heard'"); + * + * Get the rowCount of an execute query + * + * echo $database->rowcount(); + * + * Delete a row in the database + * + * $database->query("DELETE FROM USERS WHERE ID=1;"); + * + * Get the affected rows affected by the delete statement + * + * $affectedRows = $database->delete("USERS", "ID=1"); + * + * Update rows in the database + * + * Example: $database->query("UPDATE USERS SET firstname='Joyce' WHERE ID=1;"); + * Example 2: $affectedRows = $database->update("USERS", "FIRSTNAME='Joyce'", "ID=1"); + * + * Get the ID that was inserted last in the database + * + * $lastID = $database->getLatestId("Table","recordName"); + * + * Example: $lastID = $database->getLatestId("USERS","Firstname"); + * + * Create a Anti-SQL injection statement to the database + * + * $parameters = array(":id@0@INT", ":firstname@amber@STR"); + * $ID = $database->query_secure("INSERT INTO USERS (id,firstname) VALUES(:id,:firstname);", $parameters, false); + * (If the last false statement in the query above is set to true the class will return the resultset of the record) + * (else if the last false statement in the query above is set to false you will get a true of false idenitifying if * the query was executed successfully to the database). + * + * The $ID variable will now hold the last inserted ID. + * + * Show all the table that are in your database + * + * $result = $database->ShowTables("databaseName"); + * Example: $result = $database->ShowTables("school"); + * + * Output the result to the screen in a clean way: + * + * foreach($result as $row){ + * $i++; + * echo "$row[$i]" . "
"; + * + * Show all the databases this class holds (get all the databases you got permissions for) + * + * $result = $database->showDatabases(); + * + * Output the result to the screen in a clean way: + * + * foreach($result as $row){ + * $i++; + * echo "$row[$i]" . "
"; + * + * close the database connection; + * + * $database->close(); + */ + +class Database +{ + + // Create an array with all the database types this class can connect to + private $database_types = array("databaselibrary", // Database Library (used by PHP) + "firebird", // firebird + "ibm", // IBM + "informix", // Informix + "mssql", // Microsoft SQL (<= 2000) + "mysql", // mysql + "odbc", // Open database connectivity (Microsoft Access) + "oracle", // Oracle + "postgre", // Postgre SQL + "sqlite2", // SQLite 2 + "sqlite3", // SQLite 3 + "sql", // Microsoft SQL + ); + + private $server; // This variable holds the host name of the server (serverName) used by the application + private $database; // This variable holds the databaseName of the database used by the application + private $user; // This variable holds the userName of the database used by the application + private $password; // This variable holds the password of the database used by the application + private $port; // This variable holds the port of the database used by the application + private $database_type; // This variable holds the database type of the database used by the application + private $root_mdb; // This variable holds the root mdb of the database used by the application + private $debug = false; // This variable holds the debugging state of the class + + private $sql; // This variable holds all the sql connection parameters + private $con; // This variable holds the connection of the database used by the application + private $err_msg = ""; // This variable holds the error message that was trown by the database (if exists) + + /** + * Create the constructor + * @param string $database_types (specify the database connection) + * + * These are the database connection that are accepted by this class: + * + * connection name - connection description + * -------------------------------------------- + * databaselibrary Database Library database (used by PHP) + * firebird firebird database + * ibm IBM database + * informix Informix database + * mssql Microsoft SQL Server database (V. 2000 and lower) + * mysql mysql database + * odbc Open database connectivity (Microsoft Access) + * oracle Oracle database + * postgre postgre SQL database + * sqlite2 SQLite 2 database + * sqlite3 SQLite 3 database + * sql Microsoft SQL + * + * @param string $server (The server where the database is located) + * @param string $database (The name of the database) + * @param string $user (The userName of the connection to the database) + * @param string $password (The password of the connection to the database) + * + */ + + // Create the constructor and initialise the connection to the specified server + public function __construct($database_type,$server,$database,$user,$password,$port) + { + $this->database_type = strtolower($database_type); + $this->server = $server; + $this->database = $database; + $this->user = $user; + $this->password = $password; + $this->port = $port; + } + + // initialise class and connects to the database + public function open() + { + if(in_array($this->database_type, $this->database_types)) + { + try { + switch ($this->database_type) + { + + // Database Library connection + + case "databaselibrary": // default port used by database => 10060 + $this->con = new PDO("dblib:host=".$this->server. + ":".$this->port."; + dbname=".$this->database,$this->user,$this->password + ); + break; + + // firebird connection + + case "firebird": // default port used by database => 3050 + $this->con = new PDO("firebird:dbname=".$this->server. + ":".$this->database, $this->user, $this->password + ); + break; + + // ibm connection + + case "ibm": + $this->con = new PDO("ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=".$this->database."; HOSTNAME=".$this->host."; + PORT=".$this->port."; + PROTOCOL=TCPIP;", + $this->user, $this->password + ); + break; + + // informix connection + + case "informix": + $this->con = new PDO("informix:DSN=InformixDB", $this->user, $this->password); + break; + + // mssql connection + + case "mssql": + $this->con = new PDO("mssql:host=".$this->server."; + dbname=".$this->database, $this->user, $this->password + ); + break; + + // mysql connection + + case "mysql": + if ($this->port != "") { + $this->con = new PDO("mysql:host=".$this->server."; + port=".$this->port."; + dbname=".$this->database, $this->user, $this->password + ); + }else{ + $this->con = new PDO("mysql:host=".$this->server."; + dbname=".$this->database, $this->user, $this->password + ); + } + break; + + // open database connectivity + + case "odbc": + $this->con = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)}; + Dbq=C:\accounts.mdb;Uid=".$this->user + ); + break; + + // oracle connection + + case "oracle": + $this->con = new PDO("OCI:dbname=".$this->database."; + charset=UTF-8", $this->user, $this->password + ); + break; + + // postgre connection + + case "postgre": + + if($this->port!="") + { + $this->con = new PDO("pgsql:dbname=".$this->database."; + port=".$this->port."; + host=".$this->server, $this->user, $this->password + ); + } + else + { + $this->con = new PDO("pgsql:dbname=".$this->database."; + host=".$this->server, $this->user, $this->password + ); + } + break; + + // sqlite2 connection + + case "sqlite2": + $this->con = new PDO("sqlite:".$this->server); + break; + + // sqlite3 connection + + case "sqlite3": + $this->con = new PDO("sqlite::memory"); + break; + + // sql connection + + case "sql": + $this->con = new PDO("sqlsrv:server=".$this->server."; + database=".$this->database, $this->user, $this->password + ); + } + + if ($this->debug) + { + $this->showDebugInformation(); + } + else + { + // Create the exception that will be thrown by the PDO if there is an error + $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + return $this->con; + } + catch(PDOException $e) + { + $this->log ("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("The parameters that are given are invalid.
+ Possible reasons:

+ 1. The parameters that are given are invalid for the class.
+ 2. The database connection is not supported by the class.

+ Please contact the administrator of the application. => info@SuperSmash.nl" + ); + return false; + } + } + + private function log($message) + { + $this->err_msg = "SuperSmash Database Connection class:
+ =====================================

+ $message"; + } + + private function showDebugInformation(){ + + // Create the exception that will be thrown by the PDO if there is an error + $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // The following extra attributes will only be shown in debugging mode + + // Create the exception that will be thrown by the PDO if there is a warning + $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + + // Create the exception that will be thrown by the PDO if there is an error (silent mode) + $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); + + // Log all database connection information (for debugging) + echo "SuperSmash Database debug information:
+ ============================

"; + echo "Status: " . $this->con->getAttribute(PDO::ATTR_CONNECTION_STATUS) . "
"; + echo "Drivername: " . $this->con->getAttribute(PDO::ATTR_DRIVER_NAME) . "
"; + echo "Serverversion: " . $this->con->getAttribute(PDO::ATTR_SERVER_VERSION) . "
"; + echo "Clientversion: " . $this->con->getAttribute(PDO::ATTR_CLIENT_VERSION) . "
"; + echo "Serverinfo: " . $this->con->getAttribute(PDO::ATTR_SERVER_INFO) . "
"; + die(); + + } + + // Print all the available drivers to the screen (for instant debugging off supported drivers) + public function drivers() + { + print_r(PDO::getAvailableDrivers()); + } + + //Execute the query to the database + public function query($sql_statement) + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $this->sql=$sql_statement; + return $this->con->query($this->sql); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Execute queries with Anti SQL injection + public function query_secure($sql_statement, $params, $fetch_rows=false) + { + $this->err_msg = ""; + if($this->con!=null) + { + $obj = $this->con->prepare($sql_statement); + for($i=0;$ibindParam($params_split[0], $params_split[1], PDO::PARAM_INT); + else + $obj->bindParam($params_split[0], $params_split[1], PDO::PARAM_STR); + } + try + { + $obj->execute(); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + if($fetch_rows) + return $obj->fetchAll(); + if(is_numeric($this->con->lastInsertId())) + return $this->con->lastInsertId(); + return true; + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Get the first row of a query in the database + public function query_first($sql_statement) + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $sttmnt = $this->con->prepare($sql_statement); + $sttmnt->execute(); + return $sttmnt->fetch(); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Get the first tableCell from a query in the database + public function query_single($sql_statement) + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $sttmnt = $this->con->prepare($sql_statement); + $sttmnt->execute(); + return $sttmnt->fetchColumn(); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Return the rowcount of a query in the database + public function rowcount() + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $stmnt_tmp = $this->stmntCount($this->sql); + if($stmnt_tmp!=false && $stmnt_tmp!="") + { + return $this->query_single($stmnt_tmp); + } + else + { + $this->log("Error: A few data required."); + return -1; + } + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return -1; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Return all the colum names in the database (as an array) + public function columns($table) + { + $this->err_msg = ""; + $this->sql="Select * From $table"; + if($this->con!=null) + { + try + { + $q = $this->con->query($this->sql); + $column = array(); + foreach($q->fetch(PDO::FETCH_ASSOC) as $key=>$val) + { + $column[] = $key; + } + return $column; + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Insert the query and get the new ID from the database + public function insert($table, $data){ + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $texto = "Insert Into $table ("; + $texto_extra = ") Values ("; + $texto_close = ")"; + $data_column = explode(",", $data); + for($x=0;$xcon->exec("$texto $texto_extra $texto_close"); + return $this->con->lastInsertId(); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Update the tables in the database + public function update($table, $data, $condition="") + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + return (trim($condition)!="") ? $this->con->exec("update $table set $data where $condition") : $this->con->exec("update $table set $data"); + } + catch(PDOException $e) + { + $this->err_msg = "Error: ". $e->getMessage(); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Delete a record from the database + public function delete($table, $condition="") + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + return (trim($condition)!="") ? $this->con->exec("delete from $table where $condition") : $this->con->exec("delete from $table"); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Execute Store Procedures + public function execute($sp_query) + { + $this->err_msg = ""; + if($this->con!=null) + { + try + { + $this->con->exec("$sp_query"); + return true; + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + // Get the latest ID from the specified table in the database + public function getLatestId($db_table, $table_field) + { + $this->err_msg = ""; + $sql_statement = ""; + $dbtype = $this->database_type; + + if($dbtype=="sql" || $dbtype=="mssql" || $dbtype=="ibm" || $dbtype=="databaselibrary" || $dbtype=="odbc") + { + $sql_statement = "select top 1 $table_field from $db_table order by $table_field desc"; + } + if($dbtype=="oracle") + { + $sql_statement = "select $table_field from $db_table where ROWNUM<=1 order by $table_field desc"; + } + if($dbtype=="informix" || $dbtype=="firebird") + { + $sql_statement = "select first 1 $table_field from $db_table order by $table_field desc"; + } + if($dbtype=="mysql" || $dbtype=="sqlite2" || $dbtype=="sqlite3") + { + $sql_statement = "select $table_field from $db_table order by $table_field desc limit 1"; + } + if($dbtype=="postgre") + { + $sql_statement = "select $table_field from $db_table order by $table_field desc limit 1 offset 0"; + } + + if($this->con!=null) + { + try + { + return $this->query_single($sql_statement); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Get all the tables from a specified database + public function ShowTables($database) + { + $this->err_msg = ""; + $complete = ""; + $sql_statement = ""; + $dbtype = $this->database_type; + + if($dbtype=="sql" || $dbtype=="mssql" || $dbtype=="ibm" || $dbtype=="databaselibrary" || $dbtype=="odbc" || $dbtype=="sqlite2" || $dbtype=="sqlite3") + { + $sql_statement = "select name from sysobjects where xtype='U'"; + } + if($dbtype=="oracle") + { + //If the query statement fail, try with uncomment the next line: + //$sql_statement = "SELECT table_name FROM tabs"; + $sql_statement = "SELECT table_name FROM cat"; + } + if($dbtype=="informix" || $dbtype=="firebird") + { + $sql_statement = "SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NULL ORDER BY RDB$RELATION_NAME"; + } + if($dbtype=="mysql") + { + if($database!="") + { + $complete = " from $database"; + } + $sql_statement = "show tables $complete"; + } + if($dbtype=="postgre") + { + $sql_statement = "select relname as name from pg_stat_user_tables order by relname"; + } + + if($this->con!=null) + { + try + { + $this->sql=$sql_statement; + return $this->con->query($this->sql); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Get all databases that exists on the server (and where you got permission to use them) + public function showDatabases() + { + $this->err_msg = ""; + $sql_statement = ""; + $dbtype = $this->database_type; + + if($dbtype=="sql" || $dbtype=="mssql" || $dbtype=="ibm" || $dbtype=="databaselibrary" || $dbtype=="odbc" || $dbtype=="sqlite2" || $dbtype=="sqlite3") + { + $sql_statement = "SELECT name FROM sys.Databases"; + } + if($dbtype=="oracle") + { + //If the query statement fail, try with uncomment the next line: + //$sql_statement = "select * from user_tablespaces"; + $sql_statement = "select * from v$database"; + } + if($dbtype=="informix" || $dbtype=="firebird") + { + $sql_statement = ""; + } + if($dbtype=="mysql") + { + $sql_statement = "SHOW DATABASES"; + } + if($dbtype=="postgre") + { + $sql_statement = "select datname as name from pg_database"; + } + + if($this->con!=null) + { + try + { + $this->sql=$sql_statement; + return $this->con->query($this->sql); + } + catch(PDOException $e) + { + $this->log("Error: ". $e->getMessage()); + return false; + } + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Get the latest error ocurred in the connection + public function getError() + { + return trim($this->err_msg)!="" ? "".$this->err_msg."
" : ""; + } + + //Disconnect from database + public function close() + { + $this->err_msg = ""; + if($this->con) + { + $this->con = null; + return true; + } + else + { + $this->log("Error: Connection to database lost."); + return false; + } + } + + //Build the query neccesary for the count(*) in rowcount method + private function stmntCount($query_stmnt) + { + if(trim($query_stmnt)!="") + { + $query_stmnt = trim($query_stmnt); + $query_split = explode(" ",$query_stmnt); + $query_flag = false; + $query_final = ""; + + for($x=0;$x \ No newline at end of file diff --git a/system/SuperSmash/debug.php b/system/SuperSmash/debug.php new file mode 100644 index 0000000..c259698 --- /dev/null +++ b/system/SuperSmash/debug.php @@ -0,0 +1,419 @@ +logErrors = configuration('logErrors', 'SuperSmash'); + $this->development = configuration('development', 'SuperSmash'); + + // Save our original settings incase we change them midscript + $this->originalSettings['logErrors'] = $this->logErrors; + $this->originalSettings['development'] = $this->development; + + // Get our URL info + $this->urlInformation = getUrlInformation(); + } + + // This function will trigger the error + public function triggerError($errorNumber, $message = '', $file = '', $line = 0, $backtrace = null) + { + // Language setup + $this->language = strtolower(configuration('language', 'SuperSmash')); + + // fill in the attributes + $this->errorMessage = $message; + $this->errorFile = $file; + $this->errorLine = $line; + $this->errorTrace = $backtrace; + + // Get the error Level + switch($errorNumber) + { + case E_USER_ERROR: + $this->errorLevel = 'Error'; + $severity = 2; + break; + + case E_USER_WARNING: + $this->errorLevel = 'Warning'; + $severity = 1; + break; + + case E_USER_NOTICE: + $this->errorLevel = 'Notice'; + $severity = 1; + break; + + case E_ERROR: + $this->errorLevel = 'Error'; + $severity = 2; + break; + + case E_WARNING: + $this->errorLevel = 'Warning'; + $severity = 1; + break; + + case E_NOTICE: + $this->errorLevel = 'Notice'; + $severity = 1; + break; + + case E_STRICT: + $this->errorLevel = 'Strict'; + $severity = 1; + break; + + default: + $this->errorLevel = 'Error Code: '.$errorNumber; + $severity = 2; + break; + } + + // Check if the error Logging is enabled + if ($this->logErrors) + { + $this->logError(); + } + + // Check if the error is important or the development environment is active + if($this->development || $severity == 2) + { + // create the error page + $this->createErrorPage(); + } + } + + // This function will show a specific error page + public function showError($type) + { + if (ob_get_level() != 0) + { + ob_end_clean(); + } + + // Get the language + $language = strtolower (configuration('language', 'SuperSmash')); + + // Get the site url + $websiteURL = $this->urlInformation['websiteURL']; + + // See if there is a custom page in the app folder + if(file_exists(settings::getFilePath() . DS . settings::getApp() . 'pages' . DS . $this->language . DS . $type .'.php')) + { + ob_start(); + require_once(settings::getFilePath() . DS . settings::getApp() . 'pages' . DS . $this->language . DS . $type .'.php'); + $page = ob_get_contents(); + $page = str_replace(""," + + " + ,$page); + // Replace some footer values + $Benchmark = loadClass('Benchmark'); + $page = str_replace('{elapsed}', $Benchmark->elapsed('system', 4), $page); + $page = str_replace('{usage}', $Benchmark->usage(), $page); + ob_end_clean(); + die($page); + } + else + { + ob_start(); + require_once(SYSTEM . DS . "SuperSmash" . DS . 'pages' . DS . $this->language . DS . $type .'.php'); + $page = ob_get_contents(); + $page = str_replace(""," + + " + ,$page); + // Replace some footer values + $Benchmark = loadClass('Benchmark'); + $page = str_replace('{elapsed}', $Benchmark->elapsed('system', 4), $page); + $page = str_replace('{usage}', $Benchmark->usage(), $page); + ob_end_clean(); + die($page); + } + } + + // This function will log the error to the log file + protected function logError() + { + + // Get the site url + $url = $this->urlInformation; + + // Create the log message + $err_message = "| Logging started at: ". date('Y-m-d H:i:s') ."\n"; + $err_message .= "| Error Level: ".$this->errorLevel ."\n"; + $err_message .= "| Message: ".$this->errorMessage ."\n"; + $err_message .= "| Reporting File: ".$this->errorFile."\n"; + $err_message .= "| Error Line: ".$this->errorLine."\n"; + $err_message .= "| URL When Error Occured: ". $url['websiteURL'] ."/". $url['uri'] ."\n\n"; + $err_message .= "--------------------------------------------------------------------\n\n"; + + // Write to the log file + $log = @fopen(SYSTEM . DS . 'editable' . DS . 'logs' . DS . ERROR, 'a'); + @fwrite($log, $err_message); + @fclose($log); + } + + // This function will log the message to the debugging log + public function log($message, $filename = DEBUG) + { + + // Create the log message + $logMessage = "(".date('Y-m-d H:i:s') .") ".$message ."\n"; + + // Write to the log file + if (file_exists(settings::getFilePath() . DS . settings::getApp() . DS . "logs")) + { + $log = @fopen(settings::getFilePath() . DS . settings::getApp() . DS . "logs" . DS . $filename, 'a'); + } + else + { + $log = @fopen(SYSTEM . DS . 'editable' . DS . 'logs' . DS . $filename, 'a'); + } + @fwrite($log, $logMessage); + @fclose($log); + } + + // This function will enable or disable errorReporting + public function errorReporting($report = true) + { + if($report) + { + // Set the error reporting back to the original state + $this->logErrors = $this->originalSettings['logErrors']; + $this->development = $this->originalSettings['development']; + } + else + { + // Use the custom error reporting + $this->logErrors = 0; + $this->development = 0; + } + return true; + } + + // This function will build the error page + protected function createErrorPage() + { + if (ob_get_level() != 0) + { + ob_end_clean(); + } + + // Get the site url + $websiteURL = $this->urlInformation['websiteURL']; + + // Get the correct error message + ob_start(); + if(!$this->development) + { + require_once(SYSTEM . DS . "SuperSmash" . DS . 'pages' . DS . 'error.php'); + } + else + { + require_once(SYSTEM . DS . "SuperSmash" . DS . 'pages' . DS . 'debug_error.php'); + } + + $page = ob_get_contents(); + + // Replace some footer values + $Benchmark = loadClass('Benchmark'); + $page = str_replace('{elapsed}', $Benchmark->elapsed('system', 4), $page); + $page = str_replace('{usage}', $Benchmark->usage(), $page); + + ob_end_clean(); + + // If we are debugging, build the debug block + if($this->development) + { + // Create the regex, and search for it + $regex = "{DEBUG}(.*){/DEBUG}"; + while(preg_match("~". $regex ."~iUs", $page, $match)) + { + $blocks = ''; + + // We dont need the first trace because its in the error message + unset($this->errorTrace[0]); + $i = 1; + + // Make sure we have at least 1 backtrace! + if(count($this->errorTrace) > 0) + { + // Loop through each level and add it to the $blocks var. + foreach($this->errorTrace as $key => $value) + { + $block = $match[1]; + $block = str_replace('{#}', $key++, $block); + + // Loop though each variable in the Trace level + foreach($value as $key => $value) + { + + // Upper case the key + $key = strtoupper($key); + + // If $v is an object, then go to next loop + if(is_object($value)) + { + continue; + } + + // If $v is an array, we need to dump it + if(is_array($value)) + { + $value = "
" . $this->var_dump($value, $key) . "
"; + } + + $block = str_replace("{".$key."}", $value, $block); + } + + // Add to blocks + $blocks .= $block; + + // We only want to do this no more then 3 times + if($i == 2) + { + break; + } + $i++; + } + } + + // Finally replace the whole thing with $blocks + $page = str_replace($match[0], $blocks, $page); + } + } + + // add the error information to the page + $page = str_replace("{ERROR_COPYRIGHT}", "SuperSmash Framework ©" . date("Y") . " SuperSmash", $page); + $page = str_replace("{ERROR_LEVEL}", $this->errorLevel, $page); + $page = str_replace("{MESSAGE}", $this->errorMessage, $page); + $page = str_replace("{FILE}", $this->errorFile, $page); + $page = str_replace("{LINE}", $this->errorLine, $page); + + die($page); + } + + // This function will create a var dump + protected function var_dump($variable, $var_name = null, $indent = null) + { + // create an empty html variable + $html = ''; + + // Create the tabIndentation style + $tab_line = "|      "; + + + // Grab our variable type and get our text color + $type = ucfirst(gettype($variable)); + + switch($type) + { + case "Array": + // Count our number of keys in the array + $count = count($variable); + $html .= "$indent" . ($var_name ? "$var_name => ":"") . "$type ($count)
$indent(
"; + $keys = array_keys($variable); + + // Foreach array key, we need to get the value. + foreach($keys as $name) + { + $value = $variable[$name]; + $html .= $this->var_dump($value, "['$name']", $indent.$tab_line); + } + $html .= "$indent)
"; + break; + + case "String": + $type_color = ""; + $html .= "$indent$var_name = $type(".strlen($variable).") $type_color\"$variable\"
"; + break; + + case "Integer": + $type_color = ""; + $html .= "$indent$var_name = $type(".strlen($variable).") $type_color$variable
"; + break; + + case "Double": + $type_color = ""; + $type = "Float"; + $html .= "$indent$var_name = $type(".strlen($variable).") $type_color$variable
"; + break; + + case "Boolean": + $type_color = ""; + $html .= "$indent$var_name = $type(".strlen($variable).") $type_color".($variable == 1 ? "true":"false")."
"; + break; + + case "null": + $type_color = ""; + $html .= "$indent$var_name = $type(".strlen($variable).") ".$type_color."null
"; + break; + + case "Object": + $type_color = ""; + $html .= "$indent$var_name = $type
"; + break; + + case "Resource": + $type_color = ""; + $html .= "$indent$var_name = $type ".$type_color."Resource
"; + break; + + default: + $html .= "$indent$var_name = $type(".@strlen($variable).") $variable
"; + break; + } + return $html; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/global.php b/system/SuperSmash/global.php new file mode 100644 index 0000000..05b35ca --- /dev/null +++ b/system/SuperSmash/global.php @@ -0,0 +1,281 @@ +triggerError($errorNumber, $errorMessage, $errorFile, $errorLine, debug_backtrace()); + + // Don't execute PHP internal error handler + return true; + } + + // This function will show the errorMessage + function showError($errorMessage = 'none', $arguments = null, $level = E_ERROR) + { + // Let get a backtrace for deep debugging + $backtrace = debug_backtrace(); + $calling = $backtrace[0]; + + $language = system\SuperSmash\SuperSmash::language(); + $message = $language->get($errorMessage); + + // Allow custom messages + if(!$message) + { + $message = $errorMessage; + } + + // check if there are any arguments + if(is_array($arguments)) + { + // Add the arguments to the message + $message = vsprintf($message, $arguments); + } + + // Get the debug instance + $debug = loadClass('Debug'); + + // Add a break to the errorMessage + $message = "
" . $message; + + // Trigger the error + $debug->triggerError($level, $message, $calling['file'], $calling['line'], $backtrace); + } + + // This function will show an 404 error page + function show_404() + { + // Get the debug instance + $debug = loadClass('Debug'); + + // Show the error + $debug->showError(404); + } + + // This function will log a message to a specified filename log + function logMessage($message, $filename = DEBUG) + { + // Get the debug instance + $debug = loadClass('Debug'); + + // Log the error + $debug->log($message, $filename); + } + + // This function returns an item of the configuration file + function configuration($item, $type = 'SuperSmash') + { + // Get the config instance + $configuration = loadClass('Configuration'); + + // Return the specific item + return $configuration->get($item, $type); + } + + // This function will set an item in the configuration file + function configurationSet($item, $value, $name = 'SuperSmash') + { + // Get the config instance + $configuration = loadClass('Configuration'); + + // Set the specific configuration item in the configuration file + $configuration->set($item, $value, $name); + } + + // This function will save a configuration to the configuration.php file + function configurationSave($name) + { + // Get the config instance + $configuration = loadClass('Configuration'); + + // Save the configuration to the configuration.php file + return $configuration->save($name); + } + + // This function will load the specific configuration in the configuration.php + function configurationLoad($file, $name, $array = false) + { + $configuration = loadClass('Configuration'); + $configuration->load($file, $name, $array); + } + + // This function will get an instance of the controller + function getInstance() + { + if (class_exists('application\\SuperSmash\\Controller', false)) + { + return application\SuperSmash\Controller::getInstance(); + } + elseif (class_exists('system\\SuperSmash\\Controller', false)) + { + return system\SuperSmash\Controller::getInstance(); + } + else + { + return false; + } + } + + // This function will return the website URL and the URL information + function getUrlInformation() + { + return loadClass('Router')->getUrlInformation(); + } + + // This function will load a specific className + function loadClass($className, $type = 'SuperSmash', $parameters = array()) + { + // We need to create a className path for the correct class + if(strpos($className, '\\') === false) + { + $className = $type . DS . $className; + } + + // We will need to lowercase everything + $class = strtolower($className); + + // We will need to change the SuperSmash directory to its capital case + $class = str_replace('supersmash', 'SuperSmash', $class); + + // Create a storageName for the class + $store_name = str_replace('\\', '_', $class); + + // Check if the class exists in the registry + $loaded = \system\SuperSmash\Registry::singleton()->load($store_name); + if($loaded !== null) + { + return $loaded; + } + + // The class was not found in the registry so we need to look for the classFile ourself + // Split the class path in parts + $parts = explode('\\', $class); + // Build our filepath + $file = str_replace('\\', DS, implode('\\', $parts)); + + // If we dont have the full path, we need to create it + if($parts[0] !== 'system' && $parts[0] !== 'application') + { + // Check for needed classes in the Application library folder + if(file_exists(settings::getFilePath() . DS . settings::getApp() . DS . $file . '.php')) + { + $file = settings::getFilePath() . DS . settings::getApp() . DS . $file .'.php'; + $className = DS . 'application' . DS . $className; + } + else + { + $file = SYSTEM . DS . $file .'.php'; + $className = DS .'system' . DS . $className; + } + } + else + { + $file = ROOT . $file .'.php'; + } + + require_once ($file); + + if (!class_exists($className)) + { + // We only want the className and dont need the parent paths + if (strlen(strstr($className, DS . "system" . DS . "SuperSmash" . DS))>0) $className = str_replace(DS . "system" . DS . "SuperSmash" . DS, "", $className); + + // Check if the class needs parameters + if (!empty($parameters)) + { + try + { + $newClass = new ReflectionClass($className); + $newClass = $newClass->newInstanceArgs($parameters); + } + catch (Exception $exception) + { + die("The class $className could not be loaded >>>

$exception"); + } + } + else + { + // Create an object of the new class + $newClass = '\system\\SuperSmash\\' . $className; + $newClass = new $newClass; + } + } + + // Store the new object in the registry + \system\SuperSmash\Registry::singleton()->store($store_name, $newClass); + + // return the new class. + return $newClass; + } + + // This function will redirect you to a specified URL after a specified waiting time + function redirect($url, $wait = 0) + { + // Check if the URL is valid. If not then add our current websiteURL to it. + if(!preg_match('@^(mailto|ftp|http(s)?)://@i', $url)) + { + $websiteURL = getUrlInformation(); + $url = $websiteURL['websiteURL'] .'/'. $url; + } + + // Check if we need to wait a few seconds before we can redirect the user + if($wait >= 1) + { + header("Refresh:". $wait .";url=". $url); + } + else + { + header("Location: ".$url); + die(); + } + } +?> \ No newline at end of file diff --git a/system/SuperSmash/input.php b/system/SuperSmash/input.php new file mode 100644 index 0000000..d376d57 --- /dev/null +++ b/system/SuperSmash/input.php @@ -0,0 +1,463 @@ +time = ( time() + (60 * 60 * 24 * 365) ); // Default: 1 year + $this->cookiePath = "/"; + $this->cookieDomain = rtrim($_SERVER['HTTP_HOST'], '/'); + } + + // This function will return the post variable + public function post($var, $xss = false) + { + if(isset($_POST[$var])) + { + if(!$xss) + { + return $_POST[$var]; + } + return $this->clean($_POST[$var]); + } + return false; + } + + // This function will return the get variable + public function get($var, $xss = false) + { + if(isset($_GET[$var])) + { + if(!$xss) + { + return $this->cleanElement($_GET[$var]); + } + return $this->cleanElement($this->clean($_GET[$var])); + } + return false; + } + + public function cleanElement($variable) + { + if(!is_array($variable)) + $variable = htmlentities($variable,ENT_QUOTES,"UTF-8"); + else + foreach ($variable as $key => $value) + $variable[$key] = $this->clean($value); + return $variable; + } + + // This function will return the cookie variable + public function cookie($name, $xss = false) + { + if (\system\SuperSmash\Cookie::exists($name)){ + if(!$xss) { + return \system\SuperSmash\Cookie::get($name); + } + return $this->clean(\system\SuperSmash\Cookie::get($name)); + } + return false; + } + + // This function will set the cookie variable + function setCookie($cookieName, $cookieValue, $cookieTime = null) + { + if($cookieTime === null) + { + $cookieTime = $this->time; + } + \system\SuperSmash\Cookie::set($cookieName, $cookieValue, false, $cookieTime,$this->cookiePath); + } + + // This function will return the user agent of the user + public function userAgent() + { + if(!$this->userAgent) + { + $this->userAgent = (isset($_SERVER['HTTP_userAgent']) ? $_SERVER['HTTP_userAgent'] : false); + } + return $this->userAgent; + } + + // This function will return the ipAddress of the user + public function ipAddress() + { + + // Return it if we already determined the IP + if(!$this->ipAddress) + { + + // Check to see if the server has the IP address + if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != '') + { + $this->ipAddress = $_SERVER['REMOTE_ADDR']; + } + elseif(isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != '') + { + $this->ipAddress = $_SERVER['HTTP_CLIENT_IP']; + } + + // If we still have a false IP address, then set to 0's + if (!$this->ipAddress) + { + $this->ipAddress = '0.0.0.0'; + } + } + return $this->ipAddress; + } + + // This function will set the cleaning rules + public function setRules($tagsArray = array(), $attributesArray = array(), $tagsMethod = 0, $attributesMethod = 0, $xssAuto = 1) + { + // Count how many are in each for out loops + $countTags = count($tagsArray); + $countAttributes = count($attributesArray); + + // Loop through and lowercase all Tags + for($i = 0; $i < $countTags; $i++) + { + $tagsArray[$i] = strtolower($tagsArray[$i]); + } + + // Loop through and lowercase all attributes + for($i = 0; $i < $countAttributes; $i++) + { + $attributesArray[$i] = strtolower($attributesArray[$i]); + } + + // Set the class variables + $this->tagsArray = $tagsArray; + $this->attributesArray = $attributesArray; + $this->tagsMethod = $tagsMethod; + $this->attributesMethod = $attributesMethod; + $this->xssAuto = $xssAuto; + } + + // This function will clean the given input + public function clean($source) + { + + // If in array, clean each value + if(is_array($source)) + { + foreach($source as $key => $value) + { + if(is_string($value)) + { + // filter element for XSS and other 'bad' code etc. + $source[$key] = $this->remove($this->decode($value)); + } + } + return $source; + } + elseif(is_string($source)) + { + // filter element for XSS and other 'bad' code etc. + return $this->remove($this->decode($source)); + } + return $source; + } + + // This function will remove unwanted tags + protected function remove($source) + { + $loopCounter = 0; + while($source != $this->filterTags($source)) + { + $source = $this->filterTags($source); + $loopCounter++; + } + return $source; + } + + // This function will strip certain tags of the string + protected function filterTags($source) + { + $preTag = null; + $postTag = $source; + + // find initial tag's position + $tagOpen_start = strpos($source, '<'); + + // interate through string until no tags left + while($tagOpen_start !== false) + { + // process tag interatively + $preTag .= substr($postTag, 0, $tagOpen_start); + $postTag = substr($postTag, $tagOpen_start); + $fromTagOpen = substr($postTag, 1); + $tagOpen_end = strpos($fromTagOpen, '>'); + if($tagOpen_end === false) + { + break; + } + + // next start of tag (for nested tag assessment) + $tagOpen_nested = strpos($fromTagOpen, '<'); + if(($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) + { + $preTag .= substr($postTag, 0, ($tagOpen_nested + 1)); + $postTag = substr($postTag, ($tagOpen_nested + 1)); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start + 1); + $currentTag = substr($fromTagOpen, 0, $tagOpen_end); + $tagLength = strlen($currentTag); + + if(!$tagOpen_end) + { + $preTag .= $postTag; + $tagOpen_start = strpos($postTag, '<'); + } + + // iterate through tag finding attribute pairs - setup + $tagLeft = $currentTag; + $attributeSet = array(); + $currentSpace = strpos($tagLeft, ' '); + + // is end tag + if(substr($currentTag, 0, 1) == "/") + { + $isCloseTag = true; + list($tagName) = explode(' ', $currentTag); + $tagName = substr($tagName, 1); + } + else + { + $isCloseTag = false; + list($tagName) = explode(' ', $currentTag); + } + + // excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted + if((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), + $this->tagBlackList)) && ($this->xssAuto))) + { + + $postTag = substr($postTag, ($tagLength + 2)); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // this while is needed to support attribute values with spaces in! + while($currentSpace !== false) + { + $fromSpace = substr($tagLeft, ($currentSpace+1)); + $nextSpace = strpos($fromSpace, ' '); + $openQuotes = strpos($fromSpace, '"'); + $closeQuotes = strpos(substr($fromSpace, ($openQuotes+1)), '"') + $openQuotes + 1; + + // another equals exists + if(strpos($fromSpace, '=') !== false) + { + // opening and closing quotes exists + if(($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes+1)), '"') !== false)) + { + $attr = substr($fromSpace, 0, ($closeQuotes+1)); + } + else + { + $attr = substr($fromSpace, 0, $nextSpace); + } + } + else + { + $attr = substr($fromSpace, 0, $nextSpace); + } + + if(!$attr) + { + $attr = $fromSpace; + } + + // add to attribute pairs array + $attributeSet[] = $attr; + + // next inc + $tagLeft = substr($fromSpace, strlen($attr)); + $currentSpace = strpos($tagLeft, ' '); + } + + // appears in array specified by user + $tagFound = in_array(strtolower($tagName), $this->tagsArray); + + // remove this tag on condition + if((!$tagFound && $this->tagsMethod) || ($tagFound && !$this->tagsMethod)) + { + // reconstruct tag with allowed attributes + if(!$isCloseTag) + { + $attributeSet = $this->filterAttribute($attributeSet); + $preTag .= '<' . $tagName; + for($i = 0; $i < count($attributeSet); $i++) + { + $preTag .= ' ' . $attributeSet[$i]; + } + + // reformat single tags to XHTML + if(strpos($fromTagOpen, "'; + } + else + { + $preTag .= ' />'; + } + } + else + { + $preTag .= ''; + } + } + + // find next tag's start + $postTag = substr($postTag, ($tagLength + 2)); + $tagOpen_start = strpos($postTag, '<'); + } + + // append any code after end of tags + $preTag .= $postTag; + return $preTag; + } + + // This function will strip certain tags off attributes + protected function filterAttribute($attributeSet) + { + $newSet = array(); + + // process attributes + for($i = 0; $i xssAuto) && ((in_array(strtolower($attrSubSet[0]), + $this->attributesBlackList)) || (substr($attrSubSet[0], 0, 2) == 'on')))) + { + continue; + } + + // xss attr value filtering + if($attrSubSet[1]) + { + // strips unicode, hex, etc + $attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]); + + // strip normal newline within attr value + $attrSubSet[1] = preg_replace('/\s+/', '', $attrSubSet[1]); + + // strip double quotes + $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); + + // [requested feature] convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value) + if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) + { + $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); + } + + // strip slashes + $attrSubSet[1] = stripslashes($attrSubSet[1]); + } + + // auto strip attr's with "javascript: + if(((strpos(strtolower($attrSubSet[1]), 'expression') !== false) && (strtolower($attrSubSet[0]) == 'style')) + || (strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) + || (strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) + || (strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) + || (strpos(strtolower($attrSubSet[1]), 'mocha:') !== false) + || (strpos(strtolower($attrSubSet[1]), 'livescript:') !== false) + ) continue; + + // if matches user defined array + $attrFound = in_array(strtolower($attrSubSet[0]), $this->attributesArray); + + // keep this attr on condition + if((!$attrFound && $this->attributesMethod) || ($attrFound && !$this->attributesMethod)) + { + // attr has value + if($attrSubSet[1]) + { + $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] . '"'; + } + + // attr has decimal zero as value + elseif($attrSubSet[1] == "0") + { + $newSet[] = $attrSubSet[0] . '="0"'; + } + + // reformat single attributes to XHTML + else + { + $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[0] . '"'; + } + } + } + return $newSet; + } + + // This function will decode the source to a clean string + protected function decode($source) + { + $source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1"); + $source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source); + $source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source); + return $source; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/language.php b/system/SuperSmash/language.php new file mode 100644 index 0000000..0c77f2c --- /dev/null +++ b/system/SuperSmash/language.php @@ -0,0 +1,181 @@ +scanLanguageFolders(); + + // Set the default Language + $this->language = configuration('language', 'SuperSmash'); + } + + // This function will set the specified language + public function setLanguage($language) + { + // Check if the language exists + $language = strtolower($language); + if(in_array($language, $this->languages['application']) || in_array($language, $this->languages['system'])) + { + $this->language = $language; + return true; + } + return false; + } + + // This function will load the specified language + public function load($file, $language = null) + { + // Set the language if specified + if($language != null) + { + $this->setLanguage($language); + } + + // Add the extension, and create our tag + $language = $this->language; + $key = $file .'_'. $language; + $file = $file . '.php'; + + // Make sure we havent loaded this already + if(isset($this->supportedLanguages[$key])) + { + return $this->supportedLanguages[$key]; + } + + // Init our empty variable arrays + $vars = array(); + $vars2 = array(); + + // Load the core language file if it exists + if(file_exists(SYSTEM . DS . 'editable' . DS . 'languages' . DS . $language . DS . $file)) + { + $vars = include(SYSTEM . DS . 'editable' . DS . 'languages' . DS . $language . DS . $file); + if(!is_array($vars)) + { + return false; + } + } + + // Next we load the application file, allows overriding of the core one + if(file_exists(settings::getFilePath() . DS . settings::getApp() . DS . 'languages' . DS . $language . DS . $file)) + { + $vars2 = include(settings::getFilePath() . DS . settings::getApp() . DS . 'languages' . DS . $language . DS . $file); + if(!is_array($vars2)) + { + return false; + } + } + + // Merge if both the app and core had the same filename + $vars = array_merge($vars, $vars2); + + // Without a return, we need to store what we have here. + $this->loadedLanguages[] = $file; + $this->supportedLanguages[$key] = $vars; + + // Init the return + return (!empty($vars)) ? $vars : false; + } + + // This function gets the specified variable of the configuration array + public function get($variable, $file = null) + { + // Check to see that we loaded something first + if(empty($this->supportedLanguages)) + { + return false; + } + + // Determine our language variable filename if not givin + if($file == null) + { + foreach ($this->loadedLanguages as $key => $value) { + $file = $value; + + // Build the language key (strip the .php extension) + $key = preg_replace('/\.php$/','',$file) . '_' . $this->language; + + // check to see if our var is set... if not, try to load it first + if(!isset($this->supportedLanguages[$key])) + { + $this->load($file); + } + + // Attempt to load the actual language var now + if(isset($this->supportedLanguages[$key][$variable])) + { + return $this->supportedLanguages[$key][$variable]; + } + } + } + return false; + } + + // This function will return an array of all the languages that where found in the language folder + public function getLanguages($type = null) + { + if($type == 'system') + { + return $this->languages['system']; + } + elseif($type == 'application') + { + return $this->languages['application']; + } + return $this->languages; + } + + // This function will scan and find all the installed languages + protected function scanLanguageFolders() + { + // Load the system languages first + $path = SYSTEM . DS . 'editable' . DS . 'languages'; + $list = opendir( $path ); + while($file = readdir($list)) + { + if($file[0] != "." && is_dir($path . DS . $file)) + { + $this->languages['system'][] = $file; + } + } + closedir($list); + + // Finally, Load app languages + $path = settings::getFilePath() . DS . settings::getApp() . DS . 'languages'; + $list = opendir( $path ); + while($file = readdir($list)) + { + if($file[0] != "." && is_dir($path . DS . $file)) + { + $this->languages['application'][] = $file; + } + } + closedir($list); + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/library/cache.php b/system/SuperSmash/library/cache.php new file mode 100644 index 0000000..3a7c619 --- /dev/null +++ b/system/SuperSmash/library/cache.php @@ -0,0 +1,107 @@ +path = settings::getFilePath() . DS . settings::getApp() . DS . 'cache'; + } + + // This function will set the cache path + public function set_path($path) + { + // Remove any trailing slashes + $path = rtrim($path, '/'); + $this->path = str_replace( array('\\', '/'), DS, $path ); + } + + // This function will read and returns the contents of the cached file + public function get($id) + { + // Define a file path + $file = $this->path . DS . $id . '.cache'; + + // check if our file exists + if(file_exists($file)) + { + // Get our file contents and Unserialize our data + $data = file_get_contents($file); + $data = unserialize($data); + + // Check out expire time, if expired, remove the file + if($data['expire_time'] < time()) + { + unlink($file); + return false; + } + return $data['data']; + } + return false; + } + + // This function will save the contents into the given file id. + public function save($id, $contents, $expire = 86400) + { + // Define a file path + $file = $this->path . DS . $id . '.cache'; + + // Create the files contents + $data = array( + 'expire_time' => (time() + $expire), + 'data' => $contents + ); + + // Save file and contents + if(file_put_contents( $file, serialize($data) )) + { + // Try to put read/write permissions on the new file + @chmod($file, 0777); + return true; + } + return false; + } + + // This function will delete a cached file + public function delete($id) + { + // Define a file path + $file = $this->path . DS . $id . '.cache'; + + // Return the direct result of the deleting + return unlink($file); + } + + // This function will delete all the cached files + public function clear() + { + // get a list of all files and directories + $files = scandir($this->path); + foreach($files as $file) + { + // Define a file path + $file = $this->path . DS . $file; + + // We only want to delete the the cache files, not subfolders + if($file[0] != "." && $file != 'index.html') + { + unlink($file); //Remove the file + } + } + return true; + } +} \ No newline at end of file diff --git a/system/SuperSmash/library/email.php b/system/SuperSmash/library/email.php new file mode 100644 index 0000000..d18a8fa --- /dev/null +++ b/system/SuperSmash/library/email.php @@ -0,0 +1,280 @@ +boundary = uniqid(time()); + } + + // This function will send the email + public function send() + { + $this->build_header(); + return mail($this->to, $this->subject, $this->message, $this->header); + } + + // This function will add a to recipient to the email message + public function to($email, $name = null) + { + // Check if the email is valid before adding it + if(!$this->validate($email)) + { + return false; + } + + if($name == null) + { + $this->to = $email; + } + else + { + $this->to = $name." <".$email.">"; + } + return true; + } + + // This function will add a to sender to the email message + public function from($email, $name = null) + { + // Check if the email is valid before adding it + if(!$this->validate($email)) + { + return false; + } + + if($name == null) + { + $this->header .= "From: ".$email."\r\n"; + } + else + { + $this->header .= "From: ".$name." <".$email.">\r\n"; + } + return true; + } + + // This function will add a reply to to the email message + public function reply_to($email, $name = null) + { + // Check if the email is valid before adding it + if(!$this->validate($email)) + { + return false; + } + + if($name == null) + { + $this->header .= "Reply-to: ".$email."\r\n"; + } + else + { + $this->header .= "Reply-to: ".$name." <".$email.">\r\n"; + } + return true; + } + + // This function will add a cc to to the email message + public function cc($email) + { + // Check if the email is valid before adding it + if(!$this->validate($email)) + { + return false; + } + + $this->cc[] = $email; + return true; + } + + // This function will add a bcc to to the email message + public function bcc($email) + { + // Check if the email is valid before adding it + if(!$this->validate($email)) + { + return false; + } + + $this->bcc[] = $email; + return true; + } + + // This function will set the email subject + public function subject($subject) + { + $this->subject = strip_tags(trim($subject)); + return true; + } + + // This function will add the message to the headers so we can actually send the email + public function message($message = '', $type = 'html') + { + $textboundary = uniqid('textboundary'); + $this->textheader = "Content-Type: multipart/alternative; boundary=\"".$textboundary."\"\r\n\r\n"; + $this->message .= "--". $textboundary ."\r\n"; + $this->message .= "Content-Type: text/plain; charset=\"". $this->charset ."\"\r\n"; + $this->message .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n"; + $this->message .= strip_tags($message) ."\r\n\r\n"; + $this->message .= "--". $textboundary ."\r\n"; + $this->message .= "Content-Type: text/html; charset=\"".$this->charset ."\"\r\n"; + $this->message .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n"; + $this->message .= $message ."\r\n\r\n"; + $this->message .= "--". $textboundary ."--\r\n\r\n"; + } + + // This function will add an attachment to the email message + public function attachment($file) + { + // Make sure we are dealing with a real file here + if(is_file($file)) + { + $basename = basename($file); + $attachmentheader = "--". $this->boundary ."\r\n"; + $attachmentheader .= "Content-Type: ".$this->mime_type($file)."; name=\"".$basename."\"\r\n"; + $attachmentheader .= "Content-Transfer-Encoding: base64\r\n"; + $attachmentheader .= "Content-Disposition: attachment; filename=\"".$basename."\"\r\n\r\n"; + $attachmentheader .= chunk_split(base64_encode(fread(fopen($file,"rb"),filesize($file))),72)."\r\n"; + $this->attachment[] = $attachmentheader; + } + else + { + return false; + } + } + + // This function builds the email header before being sent + protected function build_header() + { + // Add out Cc's + $count = count($this->cc); + if($count > 0) + { + $this->header .= "Cc: "; + for($i=0; $i < $count; $i++) + { + // Add a comma if we are not on our first! + if($i > 0) + { + $this->header .= ','; + } + $this->header .= $this->cc[$i]; + } + $this->header .= "\r\n"; + } + + // Add out Bcc's + $count = count($this->bcc); + if($count > 0) + { + $this->header .= "Bcc: "; + for($i=0; $i < $count; $i++) + { + // Add comma if we are not on our first! + if($i > 0) + { + $this->header .= ','; + } + $this->header .= $this->bcc[$i]; + } + $this->header .= "\r\n"; + } + + // Add our MINE version and X-Mailer + $this->header .= "X-Mailer: SuperSmash Framework\r\n"; + $this->header .= "MIME-Version: 1.0\r\n"; + + // Add attachments + $attachcount = count($this->attachment); + if($attachcount > 0) + { + $this->header .= "Content-Type: multipart/mixed; boundary=\"". $this->boundary ."\"\r\n\r\n"; + $this->header .= "--". $this->boundary ."\r\n"; + $this->header .= $this->textheader; + + if($attachcount > 0) + { + $this->header .= implode("", $this->attachment); + } + $this->header .= "--". $this->boundary ."--\r\n\r\n"; + } + else + { + $this->header .= $this->textheader; + } + } + + // This function will check if the emailAddress specified is a valid email address + public function validate($email) + { + // Use PHP's built in email validator + if(!filter_var($email, FILTER_VALIDATE_EMAIL)) + { + $this->errors[] = "Invalid Email: <". $email .">"; + return false; + } + return true; + } + + // This function will get the mime type of a file for attachments + public function mime_type($file) + { + $fileInfo = new finfo(); + return $fileInfo->file($file, FILEINFO_MIME); + } + + // This function will clear the current email + public function clear() + { + $this->header = null; + $this->to = null; + $this->subject = null; + return true; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/library/validation.php b/system/SuperSmash/library/validation.php new file mode 100644 index 0000000..0e0939c --- /dev/null +++ b/system/SuperSmash/library/validation.php @@ -0,0 +1,193 @@ +fields = $_POST; + $this->field_rules = array(); + $this->errors = array(); + } + + // This function is used to set the rules of certain $_POST vars + public function set($rules) + { + if(!is_array($rules)) + { + showError('no_array', array('rules', 'Validation::set'), E_ERROR); + } + + // Add the current rules + $this->field_rules = array_merge($this->field_rules, $rules); + + // Allow chaining here + return $this; + } + + // This function validates all the POST data that has rules set + public function validate($debug = false) + { + // before we begin, make sure we have post data + if(!empty($this->field_rules)) + { + // Set our debugging + $this->debug = $debug; + + // Validate each of the fields that have rules + foreach($this->field_rules as $field => $rules) + { + // Get our array of rules to process + $rules = explode('|', $rules); + + // Make sure that the field we are looking at exists + if(isset($this->fields[$field])) + { + // Process each rule for this post var + foreach($rules as $rule) + { + $result = null; + + // We will define the param as false, if preg_match + // finds a second value, then it will overwrite this + $param = false; + + if (preg_match("/^(.*?)\[(.*?)\]$/", $rule, $match)) + { + $rule = $match[1]; + $param = $match[2]; + } + + // Call the function that corresponds to the rule + if (!empty($rule)) + { + $result = $this->$rule($this->fields[$field], $param); + } + + // Handle errors + if ($result === false) + { + $this->set_error($field, $rule); + } + } + } + } + return (empty($this->errors)); + } + } + + // This function returns an array of all the errors by field name + public function get_errors() { + if(count($this->errors) == 0) + { + return array(); + } + return $this->errors; + } + + // This function sets an error for the $field + protected function set_error($field, $rule) + { + // If debugging, we want an array of all failed validations + if($this->debug) + { + if(isset($this->errors[$field])) + { + $this->errors[$field] .= "|".$rule; + return; + } + $this->errors[$field] = $rule; + return; + } + $this->errors[$field] = true; + } + + // This function determines if the string passed has any values + public function required($string, $value = false) + { + if (!is_array($string)) + { + // Trim white space and see if its still empty + $string = trim($string); + } + return (!empty($string)); + } + + // This function determines if the string is a valid email + public function email($string) + { + if(filter_var($string, FILTER_VALIDATE_EMAIL)) + { + return true; + } + return false; + } + + // This function determines if the string passed is numeric + public function number($string) + { + return (is_numeric($string)); + } + + // This function determines if the string passed is valid URL + public function url($string) + { + return (!preg_match('@^(mailto|ftp|http(s)?)://(.*)$@i', $string)) ? false : true; + } + + // This function determines if the string passed is a float + public function float($string) + { + return (is_float($string)); + } + + // This function determines if the string passed has a minimum value of $value + public function min($string, $value) + { + if(!is_numeric($string)) + { + return (strlen($string) >= $value); + } + return ($string >= $value); + } + + // This function determines if the string passed has a maximum value of $value + public function max($string, $value) + { + if(!is_numeric($string)) + { + return (strlen($string) <= $value); + } + return ($string <= $value); + } + + // This function determines if the string passed contains the specified pattern + public function pattern($string, $pattern) + { + return (!preg_match("/".$pattern."/", $string)) ? false : true; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/loader.php b/system/SuperSmash/loader.php new file mode 100644 index 0000000..0bc16eb --- /dev/null +++ b/system/SuperSmash/loader.php @@ -0,0 +1,211 @@ +$additionalInstanceName = $object; + } + else + { + getInstance()->$class = $object; + } + return $object; + } + + // This function will load the view file and display it + public function view($viewName, $data, $displayView = false) + { + // Make sure our data is in an array format + if(!is_array($data)) + { + showError('no_array', array('data', 'Loader::view'), E_WARNING); + $data = array(); + } + + // Set the filePath for the view + $filePath = settings::getFilePath() . DS . settings::getApp() . DS . 'views' . DS . $viewName . DS . 'index.php'; + + // Set the viewPath for the view + $viewPath = array('viewPath' => DS . 'views' . DS . $viewName); + + // Get the websiteURL for the view + $websiteInformation = getUrlInformation(); + $websiteInformation = array('websiteURL' => $websiteInformation['websiteURL']); + + // Set the websitePath + $websitePath = array('websitePath' => $websiteInformation['websiteURL'] . settings::getApplicationPath() . "/" . settings::getApp()); + + // Get all the applications for the view + $applications = settings::getApps(); + + $data = array_merge($data,$viewPath, $websiteInformation, $websitePath, $applications); + + // extract variables + extract($data); + + // Get our page contents + if(file_exists($filePath)) + { + ob_start(); + include($filePath); + $page = ob_get_contents(); + $page = str_replace(""," + + " + ,$page); + ob_end_clean(); + + // Replace some Global values + $Benchmark = loadClass("Benchmark"); + $page = str_replace("{elapsed}", $Benchmark->elapsed('system', 4), $page); + $page = str_replace("{usage}", $Benchmark->usage(), $page); + $page = str_replace("", "\t\n", $page); + preg_match('/]*?[^>]*>/i', $page, $body); + $page = str_replace("$body[0]", "$body[0]\n
", $page); + $page = str_replace("", "
\n", $page); + $page = str_replace("\n", "\t\t
\n\t\t

Running on SuperSmash Framework © " . date("Y") . ", SuperSmash

\n\t\n\t", $page); + + // Spit out the page + if(!$displayView) + { + echo $page; + } + return $page; + } + else + { + showError('view', array($viewName), E_ERROR); + return false; + } + } + +// This function will be used to call in a class from either the APP library, or the system library folders + public function library($name, $instance = true) + { + // Make sure periods are replaced with slahes if there is any + if(strpos($name, ".")) + { + $name = str_replace('.', '\\', $name); + } + + // Load the Class + $class = loadClass($name, 'Library'); + + // Do we instance this class? + if($instance) + { + // Allow for custom class naming + (!$instance) ? $name = $instance : ''; + + // Instance + $FB = getInstance(); + if($FB) + { + (!isset($FB->$name)) ? $FB->$name = $class : ''; + } + } + return $class; + } + + // This function will be used to setup a database connection + public function database($arguments, $instance = true) + { + // Load our connection settings. We can allow custom connection arguments + if(!is_array($arguments)) + { + // Check our registry to see if we already loaded this connection + $object = \Registry::singleton()->load("database".$arguments); + if($object != null) + { + // Skip to the instancing part unless we set instance to false + if($instance) + { + goto Instance; + } + return $object; + } + + // Get the DB connection information + $info = configuration($arguments, 'database'); + if($info === null) + { + showError('db_key_not_found', array($arguments), E_ERROR); + } + } + + // Not in the registry, so establish a new connection + $dispatch = $first ."Database\\Driver"; + $object = new $dispatch($info); + + // Store the connection in the registry + \Registry::singleton()->store("DBC_".$arguments, $object); + + // Here is our instance goto + Instance: + { + // If user wants to instance this, then we do that + if($instance && !is_numeric($arguments)) + { + if($instance) $instance = $arguments; + + // Easy way to instance the connection is like this + $FB = getInstance(); + if($FB) + { + (!isset($FB->$instance)) ? $FB->$instance = $object : ''; + } + } + } + return $object; + } + + // This function is used to load in a helper file from either the application/helpers, or the SuperSmash/helpers folders + public function helper($name) + { + // Check the application/helpers folder + if(file_exists(settings::getFilePath() . DS . settings::getApp() . DS . 'helpers' . DS . $name . '.php')) + { + require_once(settings::getFilePath() . DS . settings::getApp() . DS . 'helpers' . DS . $name . '.php'); + } + // Check the core/helpers folder + else + { + require_once(SYSTEM . DS . 'helpers' . DS . $name . '.php'); + } + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/model.php b/system/SuperSmash/model.php new file mode 100644 index 0000000..ba83ccf --- /dev/null +++ b/system/SuperSmash/model.php @@ -0,0 +1,21 @@ +load = loadClass('Loader'); + } +} +?> diff --git a/system/SuperSmash/pages/404.php b/system/SuperSmash/pages/404.php new file mode 100644 index 0000000..6621e90 --- /dev/null +++ b/system/SuperSmash/pages/404.php @@ -0,0 +1,29 @@ + + + + <?php echo configuration('websiteTitle');?> 404 - Not Found + + + + + +
+ + 404 error +
get('notFoundTitle'); ?>
+
+ get('notFoundMessage'); ?> get('notFoundEmail'); ?> .

+
+ +
+

+ + + \ No newline at end of file diff --git a/system/SuperSmash/pages/css/footer.css b/system/SuperSmash/pages/css/footer.css new file mode 100644 index 0000000..beeef11 --- /dev/null +++ b/system/SuperSmash/pages/css/footer.css @@ -0,0 +1,47 @@ + +/**************************************/ +/**** SuperSmash Framework ****/ +/**** Created By SuperSmash ****/ +/**** Started on: 25-04-2012 ****/ +/**************************************/ + +html, +body { + margin:0; + padding:0; + height:100%; +} + +#header{ + padding:10px; +} + +.SuperSmashFrameworkWrapper { + min-height:10%; + height:100%; +} + +.SuperSmashFramework { + position:relative; + float:bottom; + bottom:0px; + width:100%; + height:55px; + background: url(../images/footer.png) repeat-x; + background-position:center; + color: #fff; + font: 0.8em helvetica,arial,sans-serif; +} + +.SuperSmashFramework a { + color: #fff; +} + +.SuperSmashFramework p { + margin-bottom:10px; + font: 0.8em helvetica,arial,sans-serif; + position: absolute; + bottom: 15px; + width: 100%; + text-align:center; +} \ No newline at end of file diff --git a/system/SuperSmash/pages/css/main.css b/system/SuperSmash/pages/css/main.css new file mode 100644 index 0000000..a85705d --- /dev/null +++ b/system/SuperSmash/pages/css/main.css @@ -0,0 +1,126 @@ +body +{ + background: #CCCCCC; + padding: 30px; + margin: 0; + font-family: "SuperSmash"; + src: url(./font/SuperSmash.ttf) +} + +#error-box +{ + width: 800px; + background-color: #f8f8f8; + margin-left: auto; + margin-right: auto; + border: 1px solid #111; + border-radius: 6px; + box-shadow: 0 0 5px 5px #888; +} + +div.error-copyright +{ + text-align: center; +} + +div.error-header +{ + margin: 10px; + font-weight: bold; + font-size: 24px; + color: #CC0000; + border-bottom: 1px solid #666666; +} + +div.error-message +{ + margin:10px; + font-size: 16px; +} + +div.debug-error-message +{ + margin:10px; + font-size: 16px; +} + +img.error +{ + display: block; + margin-left: auto; + margin-right: auto; +} + +div.header +{ + margin: 10px; + font-weight: bold; + font-size: 24px; + color: #000000; + text-align: center; + padding-bottom: 5px; + border-bottom: 1px solid #666666; +} +div.links +{ + border-top: 1px solid #666666; + padding-top: 3px; + margin:10px; + text-align: center; + font-size: 12px; +} +div.message +{ + margin:10px; + text-align: center; + font-size: 14px; +} + +#footer +{ + width:600px; + margin: 0 auto; + background: #f8f8f8; + border: 1px solid #999; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-left-radius: 15px; + border-bottom-right-radius: 15px; + box-shadow: 0 0 5px 5px #888; + text-align: center; +} + +pre +{ + margin: 0px 0px 10px 0px; + display: block; + background: white; + color: black; + font-family: Verdana; + border: 1px solid #CC0000; + padding: 5px; + font-size: 11px; + line-height: 14px; + overflow:auto; +} + +* +{ + margin: 0; +} + +html, body +{ + height: 100%; +} +.wrapper +{ + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */ +} +.SuperSmashFramework, .bottom +{ + height: 142px; /* .bottom must be the same height as .footer */ +} \ No newline at end of file diff --git a/system/SuperSmash/pages/debug_error.php b/system/SuperSmash/pages/debug_error.php new file mode 100644 index 0000000..59ea879 --- /dev/null +++ b/system/SuperSmash/pages/debug_error.php @@ -0,0 +1,39 @@ + + + + <?php echo configuration('websiteTitle');?> >> {ERROR_LEVEL} + + + + + +
+ + +
{ERROR_LEVEL}
+
+ get('debugMessage'); ?> {MESSAGE}

+ get('debugFile'); ?>
{FILE}

+ get('debugLine'); ?> {LINE}

+
+ +
+ {DEBUG} +
get('debugTrace'); ?> {#}:
+ get('debugFile'); ?>
{FILE}

+ get('debugClass'); ?> {CLASS}
+ get('debugLine'); ?> {LINE}

+ get('debugFunction'); ?> {FUNCTION}
+ get('debugFunctionArguments'); ?> {ARGS}


+ {/DEBUG} +
+
+

+ + + \ No newline at end of file diff --git a/system/SuperSmash/pages/error.php b/system/SuperSmash/pages/error.php new file mode 100644 index 0000000..acd3459 --- /dev/null +++ b/system/SuperSmash/pages/error.php @@ -0,0 +1,29 @@ + + + + <?php echo configuration('websiteTitle');?> >> {ERROR_LEVEL} + + + + + +
+ + +
{ERROR_LEVEL}
+
+

+ get('notFoundErrorMessage'); ?> get('notFoundEmail'); ?>.

+

+ get('errorMessage'); ?> {MESSAGE} +
+
+

+ + + \ No newline at end of file diff --git a/system/SuperSmash/pages/font/SuperSmash.ttf b/system/SuperSmash/pages/font/SuperSmash.ttf new file mode 100644 index 0000000..388739c Binary files /dev/null and b/system/SuperSmash/pages/font/SuperSmash.ttf differ diff --git a/system/SuperSmash/pages/images/404.png b/system/SuperSmash/pages/images/404.png new file mode 100644 index 0000000..57dcaf5 Binary files /dev/null and b/system/SuperSmash/pages/images/404.png differ diff --git a/system/SuperSmash/pages/images/favicon.ico b/system/SuperSmash/pages/images/favicon.ico new file mode 100644 index 0000000..8ca31d1 Binary files /dev/null and b/system/SuperSmash/pages/images/favicon.ico differ diff --git a/system/SuperSmash/pages/images/footer.png b/system/SuperSmash/pages/images/footer.png new file mode 100644 index 0000000..ab38a41 Binary files /dev/null and b/system/SuperSmash/pages/images/footer.png differ diff --git a/system/SuperSmash/registry.php b/system/SuperSmash/registry.php new file mode 100644 index 0000000..36a03db --- /dev/null +++ b/system/SuperSmash/registry.php @@ -0,0 +1,67 @@ +get($key); + } + + // This function will store an object as a singleton + static function store($key, $instance) + { + return self::singleton()->set($key,$instance); + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/router.php b/system/SuperSmash/router.php new file mode 100644 index 0000000..2ffcfdd --- /dev/null +++ b/system/SuperSmash/router.php @@ -0,0 +1,202 @@ +input = loadClass('Input'); + + // Start routing + $this->checkRoutingUrl(); + } + + // This function will check how the url should be loaded + protected function checkRoutingUrl() + { + // Determine our http hostname, and site directory + $this->hostName = rtrim($_SERVER['HTTP_HOST'], '/'); + $this->websiteDir = dirname( $_SERVER['PHP_SELF'] ); + + // Detect our protocol + if(isset($_SERVER['HTTPS'])) + { + if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') + { + $this->protocol = 'https'; + } + else + { + $this->protocol = 'http'; + } + } + else + { + $this->protocol = 'http'; + } + + // Build our Full Base URL + $websiteURL = str_replace('//', '/', $this->hostName .'/'. $this->websiteDir); + + $this->websiteURL = $this->protocol .'://' . rtrim($websiteURL, '/'); + + // Process the site URI + if (!configuration('urlParameters', 'SuperSmash')) + { + // Get our current url, which is passed on by the 'url' param + $this->uri = (isset($_GET['url']) ? $this->input->get('url', true) : ''); + } + else + { + // Define our needed vars + $controllerParameter = configuration('controllerParameter', 'SuperSmash'); + $actionParameter = configuration('actionParameter', 'SuperSmash'); + + // Make sure we have a controller at least + $controller = $this->input->get($controllerParameter, true); + + if (!$controller) + { + $this->uri = ''; + } + else + { + // Get our action + $action = $this->input->get($actionParameter, true); + if(!$action) $action = configuration('defaultAction', 'SuperSmash'); // Default Action + + // initialise the uri + $this->uri = $controller .'/'. $action; + + // Clean the query string + $queryString = $this->input->clean($_SERVER['QUERY_STRING']); + $queryString = explode('&', $queryString); + foreach($queryString as $string) + { + // Convert this segment to an array + $string = explode('=', $string); + + // Dont add the controller / action twice ;) + if($string[0] == $controllerParameter || $string[0] == $actionParameter) + { + continue; + } + + // Append the uri vraiable + $this->uri .= '/'. $string[1]; + } + } + } + + // If the URI is empty, then load defaults + if (empty($this->uri)) + { + // Set our Controller / Action to the defaults + $controller = configuration('defaultController', 'SuperSmash'); // Default Controller + $action = configuration('defaultAction', 'SuperSmash'); // Default Action + $queryString = array(); // Default query string + } + // There is a URI, Lets load our controller and action + else + { + // Remove any left slashes or double slashes + $this->uri = ltrim( str_replace('//', '/', $this->uri), '/'); + + // We will start by bulding our controller, action, and querystring + $urlArray = array(); + $urlArray = explode("/", $this->uri); + $controller = $urlArray[0]; + + // If there is an action, then lets set that in a variable + array_shift($urlArray); + if(isset($urlArray[0]) && !empty($urlArray[0])) + { + $action = $urlArray[0]; + array_shift($urlArray); + } + + // If there is no action, load the default action. + else + { + $action = configuration('defaultAction', 'SuperSmash'); // Default Action + } + + // $queryString is what remains + $queryString = $urlArray; + } + + // Make sure the first character of the controller is not an _ ! + if( strncmp($controller, '_', 1) == 0 || strncmp($action, '_', 1) == 0 ) + { + show_404(); + } + + // Set static Variables + $this->controller = $controller; + $this->action = $action; + $this->queryString = $queryString; + } + + // This function returns all the url information + public function getUrlInformation() + { + $array = array( + 'protocol' => $this->protocol, + 'hostName' => $this->hostName, + 'websiteURL' => $this->websiteURL, + 'websiteDir' => $this->websiteDir, + 'uri' => $this->uri, + 'controller' => $this->controller, + 'action' => $this->action, + 'querystring' => $this->queryString + ); + return $array; + } + + // This function returns the specified URI segment + public function getUriSegment($index) { + // Return the URI + if(isset($this->uri[$index])) + { + return $this->uri[$index]; + } + return false; + } +} +?> \ No newline at end of file diff --git a/system/SuperSmash/session.php b/system/SuperSmash/session.php new file mode 100644 index 0000000..b06bcce --- /dev/null +++ b/system/SuperSmash/session.php @@ -0,0 +1,606 @@ +_cookie_name = settings::getApp() . $this->_cookie_name; + + // Sets user configuration + $this->_setConfig($config); + + // Runs the session mechanism + if ($this->_read()) + { + $this->_update(); + } + else + { + $this->_create(); + } + + // Cleans expired sessions if necessary and writes cookie + $this->_cleanExpired(); + $this->_setCookie(); + } + + /** + * @description Regenerates a new session ID for the current session. + * @access public + * @return void + * */ + public function regenerateId() + { + // Acquires a new session ID + $old_session_id = $this->_session_id; + $this->_session_id = $this->_generateId(); + + // Updates session ID in the database + $stmt = $this->_db->prepare("UPDATE {$this->_table_name} SET time_updated = ?, session_id = ? WHERE session_id = ?"); + $stmt->execute(array(time(), $this->_session_id, $old_session_id)); + + // Updates cookie + $this->_setCookie(); + } + + /** + * @description Sets a specific item to the session data array. + * @access public + * @param string - session data array key + * @param string - data value + * @return void + * */ + public function setData($key, $value) + { + $this->_data[$key] = $value; + $this->_write(); // Writes to database + } + + /** + * @description Unsets a specific item from the session data array. + * @access public + * @param string - session data array key + * @return void + * */ + public function unsetData($key) + { + if (isset($this->_data[$key])) unset($this->_data[$key]); + } + + /** + * @description Returns a specific item from the session data array. + * @access public + * @param string - session data array key + * @return string - data value/FALSE + * */ + public function getData($key) + { + return isset($this->_data[$key]) ? $this->_data[$key] : FALSE; + } + + /** + * @description Returns all items in the session data array. + * @access public + * @return array + * */ + public function getAllData() + { + return $this->_data; + } + + /** + * @description Destroys the current session. + * @access public + * @return void + * */ + public function destroy() + { + // Deletes session from the database + if (isset($this->_session_id)) + { + $stmt = $this->_db->prepare("DELETE FROM {$this->_table_name} WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + } + + // Destroy the cookie + \system\SuperSmash\Cookie::set($this->_cookie_name, '', false, time() - 31500000, NULL,NULL,NULL,NULL); + + } + + /** + * @description The main session mechanism: + * - Reads session cookie and retreives session data + * - Checks session expiration + * - Verifies IP address (if enabled) + * - Verifies user agent (if enabled) + * @access private + * @return void + * */ + private function _read() + { + // Fetches session cookie + $session_id = \system\SuperSmash\Cookie::exists($this->_cookie_name) ? \system\SuperSmash\Cookie::get($this->_cookie_name) : FALSE; + + // Cookie doesn't exist! + if (! $session_id) { + return FALSE; + } + + $this->_session_id = $session_id; + + // Fetches the session from the database + $stmt = $this->_db->prepare("SELECT data, time_updated, user_agent, ip_address FROM {$this->_table_name} WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + + $result = $stmt->fetch(); + + // Did a session exist? + if ($result !== FALSE && count($result) > 0) + { + // Checks if the session has expired in the database + if (! $this->_expire_on_close) + { + if (($result['time_updated'] + $this->_seconds_till_expiration) < time()) + { + $this->destroy(); + return FALSE; + } + } + + // Checks if the user's IP address matches the one saved in the database + if ($this->_ip_address) + { + if ($result['ip_address'] != $this->_ip_address) + { + $this->_flagForUpdate(); + return FALSE; + } + } + + // Checks if the user's user agent matches the one saved in the database + if ($this->_user_agent) + { + if ($result['user_agent'] != $this->_user_agent) + { + $this->_flagForUpdate(); + return FALSE; + } + } + + // Checks if the session has been requested to regenerate a new ID (hack attempt) + $this->_checkUpdateFlag(); + + // Checks if the session ID needs to be renewed (time exceeded) + $this->_checkIdRenewal(); + + // Sets user data + $user_data = unserialize($result['data']); + + if ($user_data) + { + $this->_data = $user_data; + unset($user_data); + } + + // All good! + return TRUE; + } + + // No session found + return FALSE; + } + + /** + * @description Creates a session. + * @access private + * @return void + * */ + private function _create() + { + // Generates session ID + $this->_session_id = $this->_generateId(); + // Inserts session into database + $stmt = $this->_db->prepare("INSERT INTO {$this->_table_name} (session_id, user_agent, ip_address, time_updated) VALUES (?, ?, ?, ?)"); + $stmt->execute(array($this->_session_id, $_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR'], time())); + } + + /** + * @description Updates a current session. + * @access private + * @return void + * */ + private function _update() + { + // Updates session in database + $stmt = $this->_db->prepare("UPDATE {$this->_table_name} SET time_updated = ? WHERE session_id = ?"); + $stmt->execute(array(time(), $this->_session_id)); + } + + /** + * @description Writes session data to the database. + * @access private + * @return void + * */ + private function _write() + { + // Custom data doesn't exist + if (count($this->_data) == 0) + { + $custom_data = ''; + } + else + { + $custom_data = serialize($this->_data); + } + + // Writes session data to database + $stmt = $this->_db->prepare("UPDATE {$this->_table_name} SET data = ?, time_updated = ? WHERE session_id = ?"); + $stmt->execute(array($custom_data, time(), $this->_session_id)); + } + + /** + * @description Sets session cookie. + * @access private + * @return void + * */ + private function _setCookie() + { + \system\SuperSmash\Cookie::set($this->_cookie_name, $this->_session_id, false, ($this->_expire_on_close) ? 0 : time() + $this->_seconds_till_expiration,NULL,NULL,$this->_secure_cookie,TRUE); + } + + /** + * @description Removes expired sessions from the database. + * @access private + * @return void + * */ + private function _cleanExpired() + { + // 0.1 % chance to clean the database of expired sessions + if (mt_rand(1, 1000) == 1) + { + $stmt = $this->_db->prepare("DELETE FROM {$this->_table_name} WHERE (time_updated + {$this->_seconds_till_expiration}) < ?"); + $stmt->execute(array(time())); + } + } + + /** + * @description Creates a unique session ID. + * @access private + * @return string + * */ + private function _generateId() + { + $salt = 'S34U7^%^&%P@%57E6F3R&*(+S_!@M#-AKOS++_-&^H'; + $random_number = mt_rand(0, mt_getrandmax()); + $ip_address_fragment = md5(substr($_SERVER['REMOTE_ADDR'], 0, 5)); + $timestamp = md5(microtime(TRUE) . time()); + + $hash_data = $random_number . $ip_address_fragment . $salt . $timestamp; + $hash = hash('sha256', $hash_data); + return $hash; + } + + /** + * @description Checks if the session ID needs to be regenerated and does so if necessary. + * @access private + * @return void + * */ + private function _checkIdRenewal() + { + // Gets the last time the session was updated + $stmt = $this->_db->prepare("SELECT time_updated FROM {$this->_table_name} WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + + $result = $stmt->fetch(); + + if ($result !== FALSE && count($result) > 0) + { + // Checks if the session ID has exceeded it's permitted lifespan. + if ((time() - $this->_renewal_time) > $result['time_updated']) + { + // Regenerates a new session ID + $this->regenerateId(); + } + } + } + + /** + * @description Flags a session so that it will receive a new ID on the next subsequent request. + * @access private + * @return void + * */ + private function _flagForUpdate() + { + $stmt = $this->_db->prepare("UPDATE {$this->_table_name} SET flagged_for_update = '1' WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + } + + /** + * @description Checks if the session has been requested to regenerate a new ID and does so if necessary. + * @access private + * @return void + * */ + private function _checkUpdateFlag() + { + // Gets flagged status + $stmt = $this->_db->prepare("SELECT flagged_for_update FROM {$this->_table_name} WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + + $result = $stmt->fetch(); + + if ($result !== FALSE && count($result) > 0) + { + // Flagged? + if ($result['flagged_for_update']) + { + // Creates a new session ID + $this->regenerateId(); + + // Updates database + $stmt = $this->_db->prepare("UPDATE {$this->_table_name} SET flagged_for_update = '0' WHERE session_id = ?"); + $stmt->execute(array($this->_session_id)); + } + } + } + + /** + * @description Sets configuration. + * @access private + * @param array - configuration options + * @return void + * */ + private function _setConfig(array $config) + { + // Sets database handle + + if (isset($config['database']) && $config['database']) + { + $this->_db = $config['database']; + } + else + { + showError('sessionTable'); + } + + // -------------------------------------------- + + // Cookie name + if (isset($config['cookie_name'])) + { + // Checks if alpha-numeric + if (! ctype_alnum(str_replace(array('-', '_'), '', $config['cookie_name']))) + { + showError('invalidCookieName'); + } + + $this->_cookie_name = $config['cookie_name']; + } + + // -------------------------------------------- + + // Database table name + if (isset($config['table_name'])) + { + // Checks if alpha-numeric + if (! ctype_alnum(str_replace(array('-', '_'), '', $config['table_name']))) + { + showError('invalidTableName'); + } + + $this->_table_name = $config['table_name']; + } + + // -------------------------------------------- + + // Expiration time in seconds + if (isset($config['seconds_till_expiration'])) + { + // Anything else than digits? + if (! is_int($config['seconds_till_expiration']) || ! preg_match('#[0-9]#', $config['seconds_till_expiration'])) + { + showError('invalidExpirationTime'); + } + + // Negative number or zero? + if ($config['seconds_till_expiration'] < 1) + { + showError('invalidSecondsTime'); + } + + $this->_seconds_till_expiration = (int) $config['seconds_till_expiration']; + } + + // -------------------------------------------- + + // End the session when the browser is closed? + if (isset($config['expire_on_close'])) + { + // Not TRUE or FALSE? + if (! is_bool($config['expire_on_close'])) + { + showError('invalidExpirationOnClose'); + } + + $this->_expire_on_close = $config['expire_on_close']; + } + + // -------------------------------------------- + + // How often should the session be renewed? + if (isset($config['renewal_time'])) + { + // Anything else than digits? + if (! is_int($config['renewal_time']) || ! preg_match('#[0-9]#', $config['renewal_time'])) + { + showError('invalidSessionRenewalTimeNumber'); + } + + // Negative number or zero? + if ($config['renewal_time'] < 1) + { + showError('invalidSessionRenewalTime'); + } + + $this->_renewal_time = (int) $config['renewal_time']; + } + + // -------------------------------------------- + + // Check IP addresses? + if (isset($config['check_ip_address'])) + { + // Not a string? + if (! is_string($config['check_ip_address'])) + { + showError('invalidIPAddressFormat'); + } + + // Invalid IP? + if (! preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', $config['check_ip_address'])) + { + showError('invalidIPAddress'); + } + + $this->_ip_address = $config['check_ip_address']; + } + + // -------------------------------------------- + + // Check user agent? + if (isset($config['check_user_agent'])) + { + $this->_user_agent = substr($config['check_user_agent'], 0, 999); + } + + // -------------------------------------------- + + // Send cookie only when HTTPS is enabled? + if (isset($config['secure_cookie'])) + { + if (! is_bool($config['secure_cookie'])) + { + showError('invalidSecureCookie'); + } + + $this->_secure_cookie = $config['secure_cookie']; + } + } +} \ No newline at end of file diff --git a/system/editable/constants.php b/system/editable/constants.php new file mode 100644 index 0000000..e4ba3ff --- /dev/null +++ b/system/editable/constants.php @@ -0,0 +1,63 @@ + "Autoload failed to load class: %s", + 'view' => "Unable to locate the view file \"%s\". Please make sure a view page is created and is correctly named.", + 'no_array' => "Variable \$%s passed is a non-array format in method %s", + 'db_key_not_found' => "The database key was not found", + 'sessionTable' => "The session database does not exist
Please run the session SQL script", + 'invalidCookieName' => "Invalid cookie name!", + 'invalidTableName' => "Invalid table name!", + 'invalidExpirationTime.' => "Seconds till expiration must be a valid number.", + 'invalidSecondsTime' => "Seconds till expiration can not be zero or less. Enable session expiration when the browser closes instead.", + 'invalidExpirationOnClose' => "Expire on close must be either TRUE or FALSE.", + 'invalidSessionRenewalTimeNumber' => "Session renewal time must be a valid number.", + 'invalidSessionRenewalTime' => "Session renewal time can not be zero or less.", + 'invalidIPAddressFormat' => "The IP address must be a string similar to this: '192.168.10.200'", + 'invalidIPAddress' => "Invalid IP address.", + 'invalidSecureCookie' => "The secure cookie option must be either TRUE or FALSE.", +); \ No newline at end of file diff --git a/system/editable/languages/english/page_errors.php b/system/editable/languages/english/page_errors.php new file mode 100644 index 0000000..f7d92f2 --- /dev/null +++ b/system/editable/languages/english/page_errors.php @@ -0,0 +1,25 @@ + "Message:", + 'debugFile' => "File that reports the error:", + 'debugLine' => "Line:", + 'debugTrace' => "Trace:", + 'debugClass' => "Class:", + 'debugFunction' => "Function:", + 'debugFunctionArguments' => "Function arguments:", + 'footerRendered' => "Page rendered in", + 'footerSeconds' => "seconds, using", + + 'notFoundTitle' => "The page you are looking for is not at this location", + 'notFoundMessage' => "The page you are looking for cannot be located. You may have mis-typed the URL, or the page was deleted. + Please check your spelling and try again. If you feel you have reached this page in an error, please", + 'notFoundEmail' => "email us", + 'startPage' => "Return to index", + 'previousPage' => "Previous page", + 'notFoundErrorMessage' => "We are sorry for the inconvenience, but an unrecoverable error has occured.
+ If the problem persists, please", + 'errorMessage' => "Error message:", +); \ No newline at end of file