BrainCMS [PHP, From Scratch]
BrainCMS
something...
Introduction
BrainCMS is a CMS designed to improve my PHP knowledge and is classes a CMS Base. BrainCMS is not intended for live hotel use.
NOTE: I am still learning PHP, this is to release my Versions and see what you guys think ;)
Features
- MySQL Connection - 100%
- Design - 15% (new style)
- Login - 50%
- Register - 0%
- Account Submitting - 0%
- Housekeeping - 0%
- $_POST & $_GET Filtering - 0% (because their is none yet :P)
- Rewrite in OOP - 0% (starting to learning OOP once I have basic knowledge of PHP)
To-do List
- Cleanup
- Global.php cleanup
- Definitions sort out
- Template grabbing (instead of all the HTML in the one file)
Contributors
Jupos(nobrain)
Nominal(Jak)
Question
What type of error reporting shall I use as default? E_ALL, E_STRICT, E_RECOVERABLE_ERROR or E_DEPRECATED.
Specify if you know any more.
Image(s)
http://localhostr.com/file/cXIuBDo/brain-config.png
http://localhostr.com/file/nVkoVrA/brain-global.png
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Roper
Looking nice dude, fancy sharing a few more snippets please? I'm intrigued!!!
The MySQL Connection is pretty simple...
PHP Code:
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("<center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br /><center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db($mysql_data) or die("<center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br /><center>Unable to connect to database '" . $mysql_data . "'</center>");
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Jupos
The MySQL Connection is pretty simple...
PHP Code:
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("<center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br /><center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db($mysql_data) or die("<center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br /><center>Unable to connect to database '" . $mysql_data . "'</center>");
Should have something like this for Errors
PHP Code:
define('Err', <center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br />);
Which would result in..
PHP Code:
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die(Err."<center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db($mysql_data) or die(Err."<center>Unable to connect to database '" . $mysql_data . "'</center>")
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Tr0ll.™
Should have something like this for Errors
PHP Code:
define('Err', <center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br />);
Which would result in..
PHP Code:
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die(Err."<center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db($mysql_data) or die(Err."<center>Unable to connect to database '" . $mysql_data . "'</center>")
Taking that, it looks alot cleaner. I will post an image once I've done it ;)
Re: BrainCMS [PHP, From Scratch]
Re: BrainCMS [PHP, From Scratch]
Way are you making a variable from a constant?
It unnessesery and useless
Posted via Mobile Device
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
joopie
Way are you making a variable from a constant?
It unnessesery and useless
Posted via Mobile Device
It needs cleaning up, I know.
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Jupos
You don't need any of those 'variables'
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Tr0ll.™
You don't need any of those 'variables'
I'm cleaning it up as we speak...
Cleaned up 'global.php':
PHP Code:
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* BrainCMS - Habbo CMS designed for BrainProject *
* * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copright (c) 2011, nobrain *
* http://mmodev.co.uk *
* * * * * * * * * * * * * * * * * * * * * * * * * * *
* This program is free software: you can *
* redistribute it and/or modify *
* it under the terms of the GNU General Public *
* License as published by *
* the Free Software Foundation, either version 3 *
* of the License, or (at your option) any later *
* version. *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
require_once 'includes/configuration.php';
// Hotel Configuration Definitions (configuration.php)
define(LINK, $config['Site']['Link']);
define(SHORTNAME, $config['Hotel']['Shortname']);
define(LONGNAME, $config['Hotel']['Longname']);
define(WEBBUILD, $config['Hotel']['Webbuild']);
define(VARS, $config['Client']['Variables']);
define(TEXTS, $config['Client']['Flash_texts']);
define(HABBO_SWF, $config['Client']['Habbo_swf']);
define(HOST, $config['MySQL']['Host']);
define(USER, $config['MySQL']['User']);
define(PASS, $config['MySQL']['Pass']);
define(DATA, $config['MySQL']['Data']);
define(ERROR_REPORTING, $config['Brain']['Error_reporting']);
define(MySQL_ERROR, '<center><font size=+4><bold>BrainCMS - MySQL Error</body></font></center><br />');
// Variables
// Error reporting
error_reporting(ERROR_REPORTING); // You can change this in the configuration
// MySQL Connection (Credits to Tr0ll™)
mysql_connect(HOST, USER, PASS) or die(MySQL_ERROR . "<center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db(DATA) or die(MySQL_ERROR . "<center>Unable to connect to database '" . DATA . "'</center>")
?>
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Jupos
I'm cleaning it up as we speak...
Cleaned up 'global.php':
PHP Code:
// MySQL Connection (Credits to Tr0ll™)
mysql_connect(HOST, USER, PASS) or die(MySQL_ERROR . "<center>Unable to connect to your MySQL Connection Information</center>");
mysql_select_db(DATA) or die(MySQL_ERROR . "<center>Unable to connect to database '" . DATA . "'</center>")
?>
... lol
PHP: mysql_connect - Manual
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Kryptos
He was talking about the definitions, get off your ego trip..
Re: BrainCMS [PHP, From Scratch]
Its not recommend to use constants or definitions because its slower for the server... Lots of constants can create a loading time of 1 or 2 seconds by just loading the php code
Explanation:
In computer programming languages like C# or C++ a constant will be replaced by his value by the compiler. Php don't have any compilers so it will be replaced by the server before running the script. So the callback from the server takes longer then just using a variable.
So... in your case like mysql data etc. its bad to use constants because of the preformance
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
blackpol
Its not recommend to use constants or definitions because its slower for the server... Lots of constants can create a loading time of 1 or 2 seconds by just loading the php code
Explanation:
In computer programming languages like C# or C++ a constant will be replaced by his value by the compiler. Php don't have any compilers so it will be replaced by the server before running the script. So the callback from the server takes longer then just using a variable.
So... in your case like mysql data etc. its bad to use constants because of the preformance
A variable will run at exactly the same speed rather than putting the data in automatically.:closedeyes:
Re: BrainCMS [PHP, From Scratch]
Quote:
Originally Posted by
Roper
Jupos, I think you should code this in OOP and create a database class - makes life much easier.
I don't know OOP bro :(
Re: BrainCMS [PHP, From Scratch]