-
4 Attachment(s)
[pre-release] dev cms
I had this lying around that I was working on at one point, this ain't a full release, there are things that need to be finished on, but maybe you guys want to finish it, or rip some of the pages to add to your own? Everything is my own coding, except the template system that was from UberCMS, although the structure system is a lot better.
Attachments are below
Some code:
PHP Code:
<?php
if (!defined('IN_PAGES'))
{
die ('<h1>Access denied</h1><p>You do not have the privileges to access this webpage.</p>');
}
class html
{
public static function meta ()
{
GLOBAL $config;
return ('<meta name="description" content="Check into the world\'s largest virtual hotel for FREE! Meet and make friends, play games, chat with others, create your avatar, design rooms and more..." />
<meta name="keywords" content="'.strtolower($config['www']['name']).' hotel, virtual, world, social network, free, community, avatar, chat, online, teen, roleplaying, join, social, groups, forums, safe, play, games, online, friends, teens, rares, rare furni, collecting, create, collect, connect, furni, furniture, pets, room design, sharing, expression, badges, hangout, music, celebrity, celebrity visits, celebrities, mmo, mmorpg, massively multiplayer">');
}
public static function header ()
{
GLOBAL $config;
$colour = array();
if (isset($_GET['p']))
{
if ($_GET['p'] == 'me')
{
$colour[0] = ' white';
}
else if ($_GET['p'] == 'home')
{
$colour[1] = ' class="white"';
}
else if ($_GET['p'] == 'account')
{
$colour[2] = ' class="white"';
}
else if ($_GET['p'] == 'news')
{
$colour[3] = ' class="white"';
}
else if ($_GET['p'] == 'staff')
{
$colour[4] = ' class="white"';
}
else if ($_GET['p'] == 'shop')
{
$colour[5] = ' class="white"';
}
else
{
$colour = NULL;
}
}
return ('<div id="container-header">
<div id="backdrop"></div>
<div class="container">
<div id="container-navigation">
<a href="'.$config['www']['url'].'/?p=me" target="_self" id="logo"></a>
<ul class="navigation">
<li><a href="'.$config['www']['url'].'/?p=me" target="_self" class="first'.$colour[0].'">Predict</a></li>
<li><a href="'.$config['www']['url'].'/?p=home" target="_self"'.$colour[1].'>Home</a></li>
<li><a href="'.$config['www']['url'].'/?p=account" target="_self"'.$colour[2].'>Account</a></li>
<li><a href="'.$config['www']['url'].'/?p=news" target="_self"'.$colour[3].'>News</a></li>
<li><a href="'.$config['www']['url'].'/?p=staff" target="_self"'.$colour[4].'>Staff</a></li>
<li><a href="'.$config['www']['url'].'/?p=shop" target="_self"'.$colour[5].'>Shop</a></li>
<li><a href="'.$config['www']['url'].'/?p=logout" target="_self" class="last">Logout</a></li>
</ul>
<ul class="navigation">
<li><a href="'.$config['www']['url'].'/?p=client" target="_self" class="first green">Enter '.$config['www']['name'].' Hotel</a></li>
<li><a href="'.$config['www']['url'].'/?p=users" target="_self" class="last white">0 users online</a></li>
</ul>
</div>
</div>
</div>');
}
public static function advertisement ()
{
return ('<div id="container-column-03" class="container-column">
<div class="container-title orange">Advertisement</div>
<div class="container-body"></div>
</div>');
}
public static function footer ()
{
GLOBAL $config;
return ('<div id="container-footer">
<a href="'.$config['www']['url'].'/" target="_self" class="link">Homepage</a> |
<a href="'.$config['www']['url'].'/?p=paper&sub=1" target="_self" class="link">Terms of use</a> |
<a href="'.$config['www']['url'].'/?p=paper&sub=2" target="_self" class="link">Privacy policy</a> |
<a href="'.$config['www']['url'].'/?p=paper&sub=3" target="_self" class="link">'.$config['www']['name'].' way</a>
</div>');
}
}
?>
PHP Code:
<?php
define ('IN_PAGES', true);
require_once ('private/application/bootstrap.php');
$page = NULL;
if (isset($_POST['p']) || isset($_GET['p']))
{
$initial = NULL;
if ($_POST['p'])
{
$initial = $_POST['p'];
}
else if ($_GET['p'])
{
$initial = $_GET['p'];
}
$page = strtolower(trim(htmlentities($initial)));
}
if (isset($_SESSION['username']) && isset($_SESSION['password']))
{
if ($usr->user_login($_SESSION['username'], $_SESSION['password']))
{
define ('LOGGED_IN', true);
}
else
{
define ('LOGGED_IN', false);
}
}
else
{
define ('LOGGED_IN', false);
}
if ($page == NULL)
{
$initial = NULL;
if (LOGGED_IN)
{
$initial = 'me';
}
else
{
$initial = 'login';
}
header ('Location: '.$config['www']['url'].'/?p='.$initial);
exit;
}
switch($page)
{
case 'logout':
unset ($_SESSION['username']);
unset ($_SESSION['password']);
header ('Location: '.$config['www']['url'].'/?p=login');
exit;
break;
case 'ase';
if (!LOGGED_IN) // CHANGE
{
require_once ('private/application/theme/public/housekeeping/dash.php');
}
else
{
require_once ('private/application/theme/public/error.php');
}
break;
default:
if (file_exists('private/application/theme/public/'.$page.'.php'))
{
require_once ('private/application/theme/public/'.$page.'.php');
}
else
{
require_once ('private/application/theme/public/error.php');
}
break;
}
?>
PHP Code:
<?php
if (!defined('IN_PAGES'))
{
die ('<h1>Access denied</h1><p>You do not have the privileges to access this webpage.</p>');
}
if(isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
// error_reporting(0);
date_default_timezone_set('Europe/London');
require_once ('private/application/config/config.php');
require_once ('private/application/library/class.mysqli.php');
$db = new db_mysqli($config['mysqli']['hostname'], $config['mysqli']['username'], $config['mysqli']['password'], $config['mysqli']['database']);
require_once ('private/application/library/class.template.php');
$tpl = new template();
require_once ('private/application/library/class.user.php');
$usr = new user();
require_once ('private/application/library/class.html.php');
session_start();
?>
-
Re: [pre-release] dev cms
It looks nice. You should have started this in the development section. Although you're releasing it, it's not finished. Would have been a better idea to make a thread regarding the development of this CMS and then work on it until it's fully built.
-
Re: [pre-release] dev cms
I am not so keen on it myself needs a little be more worked added to it. 5/10
-
Re: [pre-release] dev cms
Too bad its not finished, Love the design
-
Re: [pre-release] dev cms
Testing this out and I'm receiving "Please enter a username that does not already exist." I'm testing this out on a clean database with no users registered, so... What exactly is the problem?
Besides that it looks good, good work.
-
Re: [pre-release] dev cms
Looks nice. Reminds me of Louis (Lazarus)'s CMS' though.
-
Re: [pre-release] dev cms
Yes it uses some graphics from HabJoy / WabboCMS//
Nice release Predict. Sucks you never finished it. Always loved you developments :)
Cheers!
-
Re: [pre-release] dev cms
I liked it, but you should put more specifications though...
-
Re: [pre-release] dev cms
So, what makes this CMS better then the one you made before?
-
Re: [pre-release] dev cms
IDK why but I don't really like the PHP.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Tha
IDK why but I don't really like the PHP.
How is that relevant at all?
As for this CMS the presentation of the code could use some work, design is OKAY but not the best.
-
Re: [pre-release] dev cms
Nice release! You're definitely a tits lover :D:
-
Re: [pre-release] dev cms
I don't like the header function. You're going to get e_notices because you're using keys in the array that aren't there if you're not on that page. Other than that I like the design
if ($_POST['p']) -> Why not just if (isset($_POST['p']))? Wouldn't the first thing throw a notice if it isn't set? Same thing for the GET btw
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
ησвяαιη
How is that relevant at all?
As for this CMS the presentation of the code could use some work, design is OKAY but not the best.
Just saying. Nothing special besides just telling. But it's my opinion.
-
Re: [pre-release] dev cms
Thanks guys, if there anything that can be improved upon, don't hesitate to post patches/updates to improve the bases of things
jaja
-
Re: [pre-release] dev cms
lol so thats where my co-owner found that index page
-
Re: [pre-release] dev cms
no your index is wabbo index someone released it along with the register page :P
-
Re: [pre-release] dev cms
PHP Code:
if (isset($_GET['p']))
{
if ($_GET['p'] == 'me')
{
$colour[0] = ' white';
}
else if ($_GET['p'] == 'home')
{
$colour[1] = ' class="white"';
}
else if ($_GET['p'] == 'account')
{
$colour[2] = ' class="white"';
}
else if ($_GET['p'] == 'news')
{
$colour[3] = ' class="white"';
}
else if ($_GET['p'] == 'staff')
{
$colour[4] = ' class="white"';
}
else if ($_GET['p'] == 'shop')
{
$colour[5] = ' class="white"';
}
else
{
$colour = NULL;
}
}
Start using switch statements man...
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
TR10G33K
PHP Code:
if (isset($_GET['p']))
{
if ($_GET['p'] == 'me')
{
$colour[0] = ' white';
}
else if ($_GET['p'] == 'home')
{
$colour[1] = ' class="white"';
}
else if ($_GET['p'] == 'account')
{
$colour[2] = ' class="white"';
}
else if ($_GET['p'] == 'news')
{
$colour[3] = ' class="white"';
}
else if ($_GET['p'] == 'staff')
{
$colour[4] = ' class="white"';
}
else if ($_GET['p'] == 'shop')
{
$colour[5] = ' class="white"';
}
else
{
$colour = NULL;
}
}
Start using switch statements man...
They are if statements.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Quackster
They are if statements.
You didn't read my comment, I said that he should start using Switch statements for the code i showed...
-
Re: [pre-release] dev cms
Dan, I'm surprised you even came back! Hit me up.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
TR10G33K
You didn't read my comment, I said that he should start using Switch statements for the code i showed...
My mistake, I read that as stop.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
TR10G33K
PHP Code:
if (isset($_GET['p']))
{
if ($_GET['p'] == 'me')
{
$colour[0] = ' white';
}
else if ($_GET['p'] == 'home')
{
$colour[1] = ' class="white"';
}
else if ($_GET['p'] == 'account')
{
$colour[2] = ' class="white"';
}
else if ($_GET['p'] == 'news')
{
$colour[3] = ' class="white"';
}
else if ($_GET['p'] == 'staff')
{
$colour[4] = ' class="white"';
}
else if ($_GET['p'] == 'shop')
{
$colour[5] = ' class="white"';
}
else
{
$colour = NULL;
}
}
Start using switch statements man...
Array or something dynamic would be better, I don't like having 20 ifs/switches for different pages
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
azaidi
Array or something dynamic would be better, I don't like having 20 ifs/switches for different pages
To solve this method I would put the pages names into a table and fetch each field from a loop to make it dynamic and with doing so I would fetch each field with $_GET to see if the page is active or not with doing so will add a class. Something like that anyway
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Predict
To solve this method I would put the pages names into a table and fetch each field from a loop to make it dynamic and with doing so I would fetch each field with $_GET to see if the page is active or not with doing so will add a class. Something like that anyway
Here is for whoever wanted the header dynamic, there are some flaws making it dynamic, mainly a .CSS class and naming the first page appropriately, but anyway.
PHP Code:
public static function header ()
{
GLOBAL $config, $db;
$query = 'SELECT page_name FROM www_header ORDER BY ID LIMIT 10'; // LIMIT IS 10 SO IT DONT RUIN STYLE
$statement = $db->prepare($query);
if($statement)
{
$statement->execute();
$statement->bind_result($page_name);
while($statement->fetch())
{
if (strtolower($page_name) == $_GET['p'])
{
$result .= '<li><a href="'.$config['www']['url'].'/?p='.strtolower($page_name).'" target="_self" class="white">'.$page_name.'</a></li>';
}
else
{
$result .= '<li><a href="'.$config['www']['url'].'/?p='.strtolower($page_name).'" target="_self">'.$page_name.'</a></li>';
}
}
$statement->close();
}
return ('<div id="container-header">
<div id="backdrop"></div>
<div class="container">
<div id="container-navigation">
<a href="'.$config['www']['url'].'/?p=me" target="_self" id="logo"></a>
<ul class="navigation">
'.$result.'
<li><a href="'.$config['www']['url'].'/?p=logout" target="_self" class="last">Logout</a></li>
</ul>
<ul class="navigation">
<li><a href="'.$config['www']['url'].'/?p=client" target="_self" class="first green">Enter '.$config['www']['name'].' Hotel</a></li>
<li><a href="'.$config['www']['url'].'/?p=users" target="_self" class="last white">0 users online</a></li>
</ul>
</div>
</div>
</div>');
}
Code:
-- phpMyAdmin SQL Dump
-- version 3.5.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 30, 2013 at 12:59 PM
-- Server version: 5.1.69
-- PHP Version: 5.3.17
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `barneyx1_x1`
--
-- --------------------------------------------------------
--
-- Table structure for table `www_header`
--
CREATE TABLE IF NOT EXISTS `www_header` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`page_name` text NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `ID_2` (`ID`),
KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `www_header`
--
INSERT INTO `www_header` (`ID`, `page_name`) VALUES
(1, 'Me'),
(2, 'Home'),
(3, 'Account'),
(4, 'News'),
(5, 'Staff'),
(6, 'Shop');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-
Re: [pre-release] dev cms
I've done two more functions to be added to the html class, two being generic for me.php (personal) and one being dynamic for all pages (adverts).
PHP Code:
public static function personal_campaign ()
{
GLOBAL $config, $db;
$query = 'SELECT hyperlink, directory, paragraph FROM www_campaign ORDER BY ID LIMIT 10';
if($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
if ($statement->num_rows > 0)
{
$statement->bind_result($hyperlink, $directory, $paragraph);
while ($statement->fetch())
{
$class = ($x % 2 == 0) ? 'odd' : 'even';
$result .= ('<a href="'.$hyperlink.'" target="_self" class="'.$class.'">
<div class="campaign-image"><img src="'.$config['www']['url'].'/'.$directory.'" alt="" /></div>
<div class="campaign-p">'.$paragraph.'</div>
</a>');
$x++;
}
}
else
{
$result = ('No campaign(s) to display.');
}
$statement->close();
}
return ($result);
}
public static function personal_news ()
{
GLOBAL $config, $db;
$query = 'SELECT ID, directory, header FROM www_news ORDER BY ID LIMIT 3';
if($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
$statement->bind_result($ID, $directory, $header);
if ($statement->num_rows == 1)
{
if ($statement->fetch())
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="container-news">
<a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
</div>
</div>');
}
}
else if ($statement->num_rows == 2)
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="container-news">
');
while ($statement->fetch())
{
$result .= (' <a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
');
}
$result .= (' </div>
</div>
</div>');
}
else if ($statement->num_rows >= 3)
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
<li><a href="#news-03" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="news-03">
<div id="container-news">
');
while ($statement->fetch())
{
$result .= (' <a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
');
}
$result .= (' </div>
</div>
</div>
</div>');
}
else
{
$result = ('No news(s) to display.');
}
$statement->close();
}
return ($result);
}
public static function advertisement ()
{
GLOBAL $config, $db;
$query = 'SELECT hyperlink, directory FROM www_advert ORDER BY RAND() LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
if ($statement->num_rows > 0)
{
$statement->bind_result($hyperlink, $directory);
if ($statement->fetch())
{
$result = ('<a href="'.$hyperlink.'" target="_blank"><img src="'.$config['www']['url'].'/'.$directory.'" alt="" /></a>');
}
}
else
{
$result = ('No ADS to display.');
}
$statement->close();
}
return ('<div id="container-column-03" class="container-column">
<div class="container-title orange">Advertisement</div>
<div class="container-body" align="center">'.$result.'</div>
</div>');
}
I'll release a second patch in a download to make things easier, plus the extra tables required. If the variables look out of place it's because I wanted the code look normalised in the source code.
While I'm still on here, before I sleep. Last function I'll be doing for tonight. I'll post the patch release tomorrow.
PHP Code:
public static function paper ($ID)
{
GLOBAL $config, $db;
$query = 'SELECT paragraph FROM www_paper WHERE ID = ? LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->bind_param('s', $ID);
$statement->execute();
$statement->bind_result($paragraph);
if ($statement->fetch())
{
return ($paragraph);
$statement->close();
}
else
{
return false;
}
}
}
-
1 Attachment(s)
Re: [pre-release] dev cms
The updated version is on the attachment below.
I've updated a few pieces of the code from class.html and other various pages inside theme/public/
I'm assuming this is better than the one below:
New:
PHP Code:
public static function personal_news ()
{
GLOBAL $config, $db;
$query = 'SELECT ID, directory, header FROM www_news ORDER BY ID LIMIT 3';
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
if ($statement->num_rows >= 1)
{
$statement->bind_result($ID, $directory, $header);
while ($statement->fetch())
{
$results .= ('<a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
');
}
}
if ($statement->num_rows == 1)
{
$result = ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="container-news">
'.$results.'
</div>
</div>');
}
else if ($statement->num_rows == 2)
{
$result = ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="container-news">
'.$results.'
</div>
</div>
</div>');
}
else if ($statement->num_rows == 3)
{
$result = ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
<li><a href="#news-03" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="news-03">
<div id="container-news">
'.$results.'
</div>
</div>
</div>
</div>');
}
else
{
$result = ('<div id="container-news">
<a href="'.$config['www']['url'].'/?p=news" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/public/images/content/content-news-page-image-error-bg.png" alt="No news articles!" title="No news articles!" />
<div class="news-container-title">No news articles!</div>
</a>
</div>');
}
$statement->close();
}
return ($result);
}
Old:
PHP Code:
public static function personal_news ()
{
GLOBAL $config, $db;
$query = 'SELECT ID, directory, header FROM www_news ORDER BY ID LIMIT 3';
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
$statement->bind_result($ID, $directory, $header);
if ($statement->num_rows == 1)
{
if ($statement->fetch())
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="container-news">
<a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
</div>
</div>');
}
}
else if ($statement->num_rows == 2)
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="container-news">
');
while ($statement->fetch())
{
$result .= (' <a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
');
}
$result .= (' </div>
</div>
</div>');
}
else if ($statement->num_rows < 0)
{
$result .= ('<ul id="container-news-button">
<li><a href="#news-01" target="_self" class="news-button"></a></li>
<li><a href="#news-02" target="_self" class="news-button"></a></li>
<li><a href="#news-03" target="_self" class="news-button"></a></li>
</ul>
<div id="news-01">
<div id="news-02">
<div id="news-03">
<div id="container-news">
');
while ($statement->fetch())
{
$result .= (' <a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/'.$directory.'" alt="'.$header.'" title="'.$header.'" />
<div class="news-container-title">'.$header.'</div>
</a>
');
}
$result .= (' </div>
</div>
</div>
</div>');
}
else
{
$result = ('<div id="container-news">
<a href="'.$config['www']['url'].'/?p=news" target="_self" class="news-page">
<div class="news-button-active"></div>
<img src="'.$config['www']['url'].'/public/images/content/content-news-page-image-error-bg.png" alt="No news articles!" title="No news articles!" />
<div class="news-container-title">No news articles!</div>
</a>
</div>');
}
$statement->close();
}
return ($result);
}
-
Re: [pre-release] dev cms
I've updated a few things from the last patch ^
PHP Code:
public static function paper ($ID)
{
GLOBAL $db;
$query = 'SELECT paragraph FROM www_paper WHERE ID = ? LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->bind_param('i', $ID);
$statement->execute();
$statement->bind_result($paragraph);
if ($statement->fetch())
{
return ($paragraph);
$statement->close();
}
else
{
return ('<p><strong>Page error</strong></p><p>Sorry, but we can\'t find the page you requested.<br /><br />Please try typing the URL again. If you end up back here, please use the \'Back\' button to get back to where you started.</p>');
}
}
}
I was looking back at the source and noticed that I binded a string instead of a integer, so that was fixed. You could say I returned a error message if the pages existing in the database are not there, save being a blank document. I do the same normalisation between other functions, such as the home(s) and news.
PHP Code:
// Function home is inside the user class
public static function news ($ID = NULL)
{
GLOBAL $db;
if ($ID == NULL)
{
$statement = $db->prepare('SELECT header, paragraph FROM www_news ORDER BY ID DESC LIMIT 1');
}
else
{
$statement = $db->prepare('SELECT header, paragraph FROM www_news WHERE ID = ? LIMIT 1');
$statement->bind_param('i', $ID);
}
$statement->execute();
$statement->bind_result($header, $paragraph);
if ($statement->fetch())
{
return ('<div class="container-title orange">'.$header.'</div>
<div class="container-body">
<p>'.$paragraph.'</p>
</div>');
$statement->close();
}
else
{
return ('<div class="container-title orange">Page error</div>
<div class="container-body">
<p>Sorry, but we can\'t find the page you requested.<br /><br />Please try typing the URL again. If you end up back here, please use the \'Back\' button to get back to where you started.</p>
</div>');
}
}
Two more things, haha......................
For good practice I've assigned all queries that were being ordered with ASCending and DESCending.
I haven't got a layout for the staff page, like I have a good idea how to lay the boxes out, and stuff, but I'm curious if anyone has any good looking layouts to order staff members? Like I don't want to pick one out of my own preference (unless I have too), but ye. Contributions would be great XD
-
1 Attachment(s)
Re: [pre-release] dev cms
Seeing as I haven't got a layout (order) for staff members, I added the user table to make sure my home function worked...
PHP Code:
public function user_home ($ID)
{
GLOBAL $db;
$query = 'SELECT username, look FROM users WHERE ID = ? LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->bind_param('i', $this->user_id($ID));
$statement->execute();
$statement->bind_result($username, $look);
if ($statement->fetch())
{
return ('<img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=4&head_direction=4.gif" alt="'.$username.'" align="right" />
<strong>My Profile</strong><br /><br />
<b><u>'.$username.'</u></b>');
$statement->close();
}
else
{
return false; // shit
}
}
return ($result);
}
-
Re: [pre-release] dev cms
I was reviewing the functions for when either pages do not exist or users, regardless I came up with just putting the error page as return false. I had to make sure that the template global variables were inside the function also.
PHP Code:
public function user_home ($ID)
{
GLOBAL $db, $tpl;
$query = 'SELECT username, look FROM users WHERE ID = ? LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->bind_param('i', $this->user_id($ID));
$statement->execute();
$statement->bind_result($username, $look);
if ($statement->fetch())
{
return ('<img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=4&head_direction=4.gif" alt="'.$username.'" align="right" />
<strong>My Profile</strong><br /><br />
<b><u>'.$username.'</u></b>');
$statement->close();
}
else
{
require_once ('private/application/theme/public/error.php');
die;
}
}
return ($result);
}
PHP Code:
public static function paper ($ID)
{
GLOBAL $db, $tpl;
$query = 'SELECT paragraph FROM www_paper WHERE ID = ? LIMIT 1';
if ($statement = $db->prepare($query))
{
$statement->bind_param('i', $ID);
$statement->execute();
$statement->bind_result($paragraph);
if ($statement->fetch())
{
return ($paragraph);
$statement->close();
}
else
{
require_once ('private/application/theme/public/error.php');
die;
}
}
}
public static function news ($ID = NULL)
{
GLOBAL $db, $tpl;
if ($ID == NULL)
{
$statement = $db->prepare('SELECT header, paragraph FROM www_news ORDER BY ID DESC LIMIT 1');
}
else
{
$statement = $db->prepare('SELECT header, paragraph FROM www_news WHERE ID = ? LIMIT 1');
$statement->bind_param('i', $ID);
}
$statement->execute();
$statement->bind_result($header, $paragraph);
if ($statement->fetch())
{
return ('<div class="container-title orange">'.$header.'</div>
<div class="container-body">
<p>'.$paragraph.'</p>
</div>');
$statement->close();
}
else
{
require_once ('private/application/theme/public/error.php');
die;
}
}
I've also reviewed how my functions would be handled inside the actual pages where the functions were being used and I came up with...
PHP Code:
$page = isset ($_GET['sub']) ? $_GET['sub'] : 0;
if ($page == NULL || $page)
{
$initial = NULL;
if ($page == NULL)
{
$initial = $_SESSION['username'];
}
else if ($page)
{
$initial = $page;
}
$home->SetParam ('HOME', $usr->user_home ($initial));
}
else
{
require_once ('error.php');
die;
}
So basically if you're logged in you won't require you use the sub $_GET as the page will already load your data, whereas if you wanted to search for someone you would.
Uhm, I'm working on the news navigation, so you can direct yourself to each page that exists and possibly do the staff page... Would have been nice if someone given me a layout on how to form the staff members, but eh! That's okay XD
-
1 Attachment(s)
Re: [pre-release] dev cms
Added the navigation for the news within a new function. What are your thoughts are the size of the navigation panel? Too big? Just right? Give more space for the news panel?
PHP Code:
public static function news_navigation ()
{
GLOBAL $config, $db;
$query = 'SELECT ID, header FROM www_news ORDER BY ID DESC LIMIT 25';
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
if ($statement->num_rows > 0)
{
$statement->bind_result($ID, $header);
while ($statement->fetch())
{
if ($ID == $_GET['sub'] || $_GET['sub'] == NULL && $ID == $statement->num_rows)
{
$result .= ($header.'<br /><br />');
}
else
{
$result .= ('<a href="'.$config['www']['url'].'/?p=news&sub='.$ID.'" target="_self">'.$header.'</a><br /><br />');
}
}
}
$statement->close();
}
return ($result);
}
-
Re: [pre-release] dev cms
I am dutch and the cms doesn't works for me
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Erik Rouw
I am dutch and the cms doesn't works for me
These current releases are just patches, they're not a stable release. It's just something that you can either work on, rip or contribute until I release a stable patch that'll allow the user to work with a functional CMS.
If you look at the index.php you'll notice that some of the code is missing, e.g. staff permissions. You'll also notice that you can freely view every page without having a session because I've commented the define() to stop redirecting you.
Although thanks for trying it out, just keep checking back to see if a stable release has been made, or help with contributions on how to make the CMS better. (:
To get the CMS up and running you need to put some configurations into your config.php to enable database activity. (/private/application/config/config.php)
Secondly to see the classes you can view (/private/application/library/)
Thirdly if you want to see the HTML or PHP that's being displayed on your web browser you can go to (/private/application/theme/public/ or /private/application/theme/private)
Public folder is .php and private folder is .tpl (html)
While I was checking for errors on the login page, I found that I made a mistake or two when I was writing out the variables.
Old:
PHP Code:
if (count($errors) == 0)
{
define('LOGGED_IN', true);
if (isset($_POST['login']) || isset($_GET['register']))
{
$initial1 = NULL;
$initial2 = NULL;
if ($_POST['login'])
{
$initial1 = $_POST['log_username'];
$initial1 = $_POST['log_password'];
}
if ($_POST['register'])
{
$initial1 = $_POST['reg_username'];
$initial1 = $_POST['reg_password1'];
}
$_SESSION['username'] = $initial1;
$_SESSION['password'] = $initial2;
}
header ('Location '.$config['www']['url'].'/?p=me');
exit;
}
New:
PHP Code:
if (count($errors) == 0)
{
if (isset($_POST['login']) || isset($_POST['register']))
{
$initial1 = NULL;
$initial2 = NULL;
if ($_POST['login'])
{
$initial1 = $_POST['log_username'];
$initial2 = $_POST['log_password'];
}
else if ($_POST['register'])
{
$initial1 = $_POST['reg_username'];
$initial2 = $_POST['reg_password1'];
}
$_SESSION['username'] = $initial1;
$_SESSION['password'] = md5($initial2);
require_once ('me.php');
die;
}
}
The register page works, it's just that the insert function to actually create the fields has not been made, as of yet. So you have to manually place a user field into your user table.
-
1 Attachment(s)
Re: [pre-release] dev cms
I kinda started creating the register function to create accounts, but I think I'm missing a table to insert into or possibly some fields, who knows. Uhm
PHP Code:
public function user_register($username, $password, $email)
{
GLOBAL $db;
$query = 'INSERT INTO users (username, password, mail, auth_ticket, rank, look, gender, motto, credits, activity_points, last_online, account_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
if ($statement = $db->prepare($query))
{
$statement->bind_param('ssssisssiiii', $username, md5($password), $email, '', 1, 'sh-290-80.ch-210-66.hd-180-1.lg-285-82.hr-100-61', 'M', '', '500', '500', time(), time());
$statement->execute();
if($statement->fetch())
{
return true;
$statement->close();
}
else
{
return false;
}
}
}
I've also assigned the user data to the personal page when you're logged in (attachment is below).
The things I need to tick off now for the front end to be complete are.. Account, Staff, Users (online), client, finish off maintenance page and I'll just do the layout for shop, coding can be implemented by yourself.
I'm going to rework the layout for the housekeeping, I noticed that the code ain't compatible for I.E. I'll try to keep the ids and classes normalised with the styling.
-
2 Attachment(s)
Re: [pre-release] dev cms
Alright I started the layout for users (online) and I came up with this. I also added the search function to the personal page.
Any contributions to the project would be great, you all have the markup if you want to create any pages jajaa
-
Re: [pre-release] dev cms
Oh ye I would like to credit HabbCrazy (habbo fansite) for the backdrop on the skyscrappers, clouds and some various images used. Secondly I would like to credit Habbo for some images being used.
Here is the markup for the me.tpl small ain't it? :P
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>%NAME%: </title>
<link rel="shortcut icon" href="%URL%/public/images/ico/favicon.ico" />
<link rel="stylesheet" href="%URL%/public/css/bootstrap.css" type="text/css">
<link rel="stylesheet" href="%URL%/public/css/style.css" type="text/css">
%META%
</head>
<body>
%HEADER%
<div class="container">
<div id="container-column-01" class="container-column">
<div id="container-body-personal">
%PERSONAL%
</div>
<div class="container-title orange">Hot campaigns</div>
<div class="container-body">
%CAMPAIGN%
</div>
<div class="container-title orange">%NAME% search</div>
<form action="%URL%/p?=users" method="get" autocomplete="off" class="container-body">
<div class="container-body-form">
<label>%NAME% name <input type="text" name="users" /></label>
<p>Enter a username with 3 characters or more.</p>
</div>
<input type="submit" value="Submit" class="submit" />
</form>
</div>
<div id="container-column-02" class="container-column">
<div id="container-body-news">
%NEWS%
</div>
</div>
%ADVERT%
%FOOTER%
</div>
</body>
</html>
me.php
PHP Code:
<?php
if (!defined('IN_PAGES'))
{
die ('<h1>Access denied</h1><p>You do not have the privileges to access this webpage.</p>');
}
//if (LOGGED_IN)
//{
// header('Location: '.$config['www']['url'].'/?p=me');
// exit;
//}
$tpl->Init();
$me = new setTemplate('me');
$me->SetParam('PERSONAL', $usr->user_personal ($_SESSION['username']));
$me->SetParam('CAMPAIGN', html::personal_campaign ());
$me->SetParam('NEWS', html::personal_news ());
$tpl->AddTemplate($me);
$tpl->Output();
?>
-
Re: [pre-release] dev cms
Just funny to see how you do return first and then close the statement. which ofcouse, will never be closed like that!
And nice to see you use mysqli, but keep in mind that fetch isn't something you can use with a insert query :)
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Joopie
Just funny to see how you do return first and then close the statement. which ofcouse, will never be closed like that!
And nice to see you use mysqli, but keep in mind that fetch isn't something you can use with a insert query :)
True true, I knew something was wrong with the insert jaajaja
FEEL FREE TO IMPROVE THE SOURCE!
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Joopie
Just funny to see how you do return first and then close the statement. which ofcouse, will never be closed like that!
And nice to see you use mysqli, but keep in mind that fetch isn't something you can use with a insert query :)
I've looked over each function and placed the close() statement appropriately and alterted some functions that didn't require a return on true and false. E.G.
PHP Code:
public function user_id ($username)
{
GLOBAL $db;
$query = ('SELECT ID FROM users WHERE username = ? LIMIT 1');
if ($statement = $db->prepare($query))
{
$statement->bind_param('s', $username);
$statement->execute();
$statement->bind_result($ID);
$statement->fetch();
$statement->close();
return ($ID);
}
}
I've also sorted the register function out with the insert.
PHP Code:
public function user_register($username, $password, $email)
{
GLOBAL $db;
$query = ('INSERT INTO users (username, password, mail, auth_ticket, rank, look, gender, motto, credits, activity_points, last_online, account_created) VALUES (?, ?, ?, "", "1", "sh-290-80.ch-210-66.hd-180-1.lg-285-82.hr-100-61", "M", "", "500", "500", "'.time().'", "'.time().'")');
if ($statement = $db->prepare($query))
{
$statement->bind_param('sss', $username, md5($password), $email);
$statement->execute();
$statement->close();
}
}
If I feel up to it, I'll finish up off the users (online) page with added functions. Be sure to review my code and help improve, thanks!
-
1 Attachment(s)
Re: [pre-release] dev cms
Anyway, staff page is here at last.
PHP Code:
public static function staff ()
{
GLOBAL $config, $db;
$query = ('SELECT username, rank, look FROM users WHERE rank >= 4 ORDER BY rank ASC');
$ranks = array(4 => "Silver Hobba", 5 => "Gold Hobba" , 6 => "Moderator", 7 => "Administrator");
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->store_result();
if ($statement->num_rows > 0)
{
$statement->bind_result($username, $rank, $look);
while ($statement->fetch())
{
$class = ($x % 2 == 0) ? 'odd' : 'even';
$result = ('<a href="'.$config['www']['url'].'/?=home&sub='.$username.'" target="_self" class="'.$class.'">
<div class="users-image"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="" /></div>
<div class="users-p"><b>'.$username.'</b><br />'.$ranks[$rank].'</div>
</a>');
$x++;
}
$statement->close();
}
else
{
$result = ('<p>We have no staff members managing '.$config['www']['name'].' Hotel.</p>');
}
}
return ($result);
}
-
Re: [pre-release] dev cms
Alright, I didn't do anything last night cause I went out. ANYWAY.
I've created the function to show people who are online, including a pagination to limit the number of people shown, per page.
PHP Code:
public static function users ($ID = NULL)
{
GLOBAL $config, $db;
$query = ('SELECT count(ID) FROM users WHERE online = "1"');
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->bind_result($id);
$rows = array();
while ($statement->fetch())
{
$rows[] = array('id' => $id);
}
$statement->close();
$rows = $id;
$pages = ceil($rows / 10);
for ($i = 1; $i <= $pages; $i++)
{
$result2 .= '<a href="'.$config['www']['url'].'?p=users&sub='.$i.'" target="_self">'.$i.'</a>';
}
}
$query = ('SELECT username, look FROM users WHERE online = "1" ORDER BY username ASC LIMIT '.(($ID - 1) * 10).', 10');
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->bind_result($username, $look);
while ($statement->fetch())
{
$class = ($x % 2 == 0) ? 'odd' : 'even';
$result1 .= ('<a href="'.$config['www']['url'].'?p=home&sub='.$username.'" target="_self" class="'.$class.'">
<div class="users-image"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="'.$username.'" /></div>
<div class="users-p"><b>'.$username.'</b><br />Online</div>
</a>');
$x++;
}
$statement->close();
}
return ('<div class="container-title orange">'.$config['www']['name'].'s online</div>
<div class="container-body">
'.$result1.'
<div class="container-body-form">Pages: '.$result2.'</div>
</div>');
}
I'm probably going to review the code for this, but in the mean time, it is what it is.
Quick review of the code and I've added the latest member function inside, I was planning to do this already. I just wanted to make sure the first part of the code was correct (and working)
PHP Code:
public static function users ($ID = NULL)
{
GLOBAL $config, $db;
if ($ID == NULL) // LATEST MEMBER
{
$query = ('SELECT username, look FROM users ORDER BY ID DESC LIMIT 1');
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->bind_result($username, $look);
$statement->fetch();
$statement->close();
}
return ('<a href="'.$config['www']['url'].'?p=home&sub='.$username.'" target="_self" class="odd">
<div class="users-image" style="width: 80px;"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="'.$username.'" /></div>
<div class="users-p" style="width: 178px;"><b>'.$username.'</b><br />Latest Member</div>
</a>');
}
else // USERS ONLINE
{
$query = ('SELECT username, look FROM users WHERE online = "1" ORDER BY username ASC LIMIT '.(($ID - 1) * 10).', 10');
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->bind_result($username, $look);
while ($statement->fetch())
{
$class = ($x % 2 == 0) ? 'odd' : 'even';
$result1 .= ('<a href="'.$config['www']['url'].'?p=home&sub='.$username.'" target="_self" class="'.$class.'">
<div class="users-image"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="'.$username.'" /></div>
<div class="users-p"><b>'.$username.'</b><br />Online</div>
</a>');
$x++;
}
$statement->close();
}
$query = ('SELECT count(ID) FROM users WHERE online = "1"');
$count = array();
if ($statement = $db->prepare($query))
{
$statement->execute();
$statement->bind_result($id);
while ($statement->fetch())
{
$count[] = array('id' => $id);
}
$statement->close();
$pages = ceil($count = $id / 10);
for ($i = 1; $i <= $pages; $i++)
{
$result2 .= '<a href="'.$config['www']['url'].'?p=users&sub='.$i.'" target="_self">'.$i.'</a>';
}
}
return ('<div class="container-title orange">'.$config['www']['name'].'s online</div>
<div class="container-body">
'.$result1.'
<div class="container-body-form">Pages: '.$result2.'</div>
</div>');
}
}
-
Re: [pre-release] dev cms
Do you mind to explain this peace of code, by code I mean the $count part?
PHP Code:
$statement->bind_result($id);
while ($statement->fetch())
{
$count[] = array('id' => $id);
}
$statement->close();
$pages = ceil($count = $id / 10);
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Joopie
Do you mind to explain this peace of code, by code I mean the $count part?
PHP Code:
$statement->bind_result($id);
while ($statement->fetch())
{
$count[] = array('id' => $id);
}
$statement->close();
$pages = ceil($count = $id / 10);
I created the array above the loop (while()) to first set up the appropriate condition because of variable scoping, then with the variable that has [] adds a new element to the array, just like the push(), but without the overhead of calling a function.
http://us1.php.net/array_push
PHP Code:
public static function users_search ()
{
GLOBAL $db;
$query = ('SELECT username, look FROM users WHERE username LIKE = ?'); // ADD PAGINATION WITH COUNT(ID) on USERS
if ($statement = $db->prepare($query))
{\
$statement->bind_param('s', $user);
$statement->execute();
$statement->bind_result($username, $look);
while ($statement->fetch())
{
$result .= ('<a href="#" target="_self"><img src="'.$look.'" alt="'.$username.'" /></a>'); //assuming we have our markup
}
$statement->close();
}
return ($result);
}
I haven't fully finalised the user_search function, as of yet because I didn't have the markup language when I was coding this. I'll implement it and give you guys a heads up on the final result.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Predict
PHP Code:
public static function users_search ()
{
GLOBAL $db;
$query = ('SELECT username, look FROM users WHERE username LIKE = ?'); // ADD PAGINATION WITH COUNT(ID) on USERS
if ($statement = $db->prepare($query))
{\
$statement->bind_param('s', $user);
$statement->execute();
$statement->bind_result($username, $look);
while ($statement->fetch())
{
$result .= ('<a href="#" target="_self"><img src="'.$look.'" alt="'.$username.'" /></a>'); //assuming we have our markup
}
$statement->close();
}
return ($result);
}
Why are you using GLOBAL and not something like a static core class like this:
PHP Code:
<?php
class Core {
private static $configuration;
private static $database;
private static $settings;
public static function includeClasses() {
foreach(glob('includes/classes/class.*.php') as $file) {
if ($file == 'includes/classes/class.core.php') {
continue;
}
include($file);
}
}
public static function initialize() {
self::$configuration = new Configuration();
self::$database = new Database();
self::$settings = new Settings();
}
public static function getConfiguration() {
return self::$configuration;
}
public static function getDatabase() {
return self::$database;
}
public static function getSettings() {
return self::$settings;
}
}
?>
default.php:
PHP Code:
<?php
include('includes/classes/class.core.php');
Core::includeClasses();
Core::initialize();
?>
(TO BE IMPROVED I KNOW, JUST GIVING EXAMPLE)
-
Re: [pre-release] dev cms
I think you didn't notice it but I'll tell you why I asked:
PHP Code:
$pages = ceil($count = $id / 10);
You create a array $count send some random values in a array and then suddenly, you use it as a int/float.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Tha
Why are you using GLOBAL and not something like a static core class like this:
PHP Code:
<?php
class Core {
private static $configuration;
private static $database;
private static $settings;
public static function includeClasses() {
foreach(glob('includes/classes/class.*.php') as $file) {
if ($file == 'includes/classes/class.core.php') {
continue;
}
include($file);
}
}
public static function initialize() {
self::$configuration = new Configuration();
self::$database = new Database();
self::$settings = new Settings();
}
public static function getConfiguration() {
return self::$configuration;
}
public static function getDatabase() {
return self::$database;
}
public static function getSettings() {
return self::$settings;
}
}
?>
default.php:
PHP Code:
<?php
include('includes/classes/class.core.php');
Core::includeClasses();
Core::initialize();
?>
(TO BE IMPROVED I KNOW, JUST GIVING EXAMPLE)
They introduce global state into a program. Most programmers should be familiar with why global state is bad.
They introduce tight coupling between the singleton and any class that uses it. This means you can't reuse the classes in question without reusing the singleton too.
They make unit testing of classes that depend on the singleton problematic because you can't easily replace the singleton with a mock.
They encourage a coding style where classes attempt to resolve their own dependencies. This is bad because it can reduce clarity regarding what dependencies the class has.
PHP has a Share Nothing Architecture, meaning that PHP singletons aren't really singletons at all, there can be multiple instances alive at any one time (one per open request).
What happens if you suddenly discover at some later date that you actually need more than one of the resource that's being provided by the singleton? It's a more common scenario than you might think
A few reasons why Singleton is bad
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
Predict
They introduce global state into a program. Most programmers should be familiar with why global state is bad.
They introduce tight coupling between the singleton and any class that uses it. This means you can't reuse the classes in question without reusing the singleton too.
They make unit testing of classes that depend on the singleton problematic because you can't easily replace the singleton with a mock.
They encourage a coding style where classes attempt to resolve their own dependencies. This is bad because it can reduce clarity regarding what dependencies the class has.
PHP has a Share Nothing Architecture, meaning that PHP singletons aren't really singletons at all, there can be multiple instances alive at any one time (one per open request).
What happens if you suddenly discover at some later date that you actually need more than one of the resource that's being provided by the singleton? It's a more common scenario than you might think
A few reasons why Singleton is bad
Could be, but global aint 'awesome' too. Why not concider using it as a parameter of the function? Would be still better than either singleton or global.
-
1 Attachment(s)
Re: [pre-release] dev cms
PHP Code:
public static function users_search ($user)
{
GLOBAL $config, $db;
$query = ('SELECT username, look FROM users WHERE username LIKE = ?');
if ($statement = $db->prepare($query))
{
$statement->bind_param('s', '%'.$user.'%');
$statement->execute();
$statement->bind_result($username, $look);
while ($statement->fetch())
{
$class = ($x % 2 == 0) ? 'odd' : 'even';
$result .= ('<a href="'.$config['www']['url'].'?p=home&sub='.$username.'" target="_self" class="'.$class.'">
<div class="users-image"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='.$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="'.$username.'" /></div>
<div class="users-p"><b>'.$username.'</b></div>
</a>');
$x++;
}
$statement->close();
}
return ($result);
}
Uhm, can someone tell me what's wrong with this code? Mainly the part for the the query and bind_param (wildcard). Can't seem to get it working x.x
Besides this, I think I'm going to move on with the project. I haven't been active within the pre-release/dev because I've had other stuff to do.
Release on the current patch is in the attachments.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
TR10G33K
PHP Code:
if (isset($_GET['p']))
{
if ($_GET['p'] == 'me')
{
$colour[0] = ' white';
}
else if ($_GET['p'] == 'home')
{
$colour[1] = ' class="white"';
}
else if ($_GET['p'] == 'account')
{
$colour[2] = ' class="white"';
}
else if ($_GET['p'] == 'news')
{
$colour[3] = ' class="white"';
}
else if ($_GET['p'] == 'staff')
{
$colour[4] = ' class="white"';
}
else if ($_GET['p'] == 'shop')
{
$colour[5] = ' class="white"';
}
else
{
$colour = NULL;
}
}
Start using switch statements man...
There are no real benefits to using switch case, other than looking prettier.
-
Re: [pre-release] dev cms
What a troll (in a good way).
PHP Code:
SELECT `username`, `look` FROM `users` WHERE `username` LIKE ? LIMIT 30
-
Re: [pre-release] dev cms
ok, um isn't this wabbo/wubbo cms if not then nice edit I guess?
-
Re: [pre-release] dev cms
TrueCluez, It's devCMS
[Pre-release]
Many thanks
- ValorAngel
-
Re: [pre-release] dev cms
Well, i'm not expert in this area... But i did a little code to verify if email is already registered... Isn't a GREAT fix, but... :)
1° Go to private/application/library and open the class.user.php, then search for this public function user_name($username), then add this after void founded:
PHP Code:
public function user_mail($username)
{
GLOBAL $db;
$query = ('SELECT mail FROM users WHERE mail = ? LIMIT 1');
if ($statement = $db->prepare($query))
{
$statement->bind_param('s', $username);
$statement->execute();
$statement->bind_result($username);
$statement->fetch();
$statement->close();
return ($username);
}
}
2° Go to private/application/theme/public and open the login.php, then search for this:
PHP Code:
else if ($usr->user_name($_POST['reg_username']))
{
$errors[] = 'Please enter an username that does not already exist.';
}
After of found, add this:
PHP Code:
else if ($usr->user_mail($_POST['reg_email']))
{
$errors[] = 'Please enter an email that does not already exist.';
}
Now you will have a verification of email!
If have something wrong with code, tell me, i'm new in PHP :p
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
rafa95123
Well, i'm not expert in this area... But i did a little code to verify if email is already registered... Isn't a GREAT fix, but... :)
...
Great work (:
Sorry I haven't been active with the project, recently.
What I've done since the last update, I've changed, renamed, removed and updated the directories, I somewhat like the new folder structure and when you get chance, please give feedback.
I've modified some of the code inside the library.html.php (previously class.html.php) that I saw a few flaws inside. The users_search function doesn't want to play ball, so I'm going to leave the function as it is and move onto something else. Moreover to Housekeeping, infact. I really need to recode the .CSS for the layout because it doesn't work properly in some browsers, I'm hoping to keep the code the same.
-
Re: [pre-release] dev cms
Well man, tell me one thing... to do the client, is hard? xD
-
Re: [pre-release] dev cms
Not 100% sure of this as i just skimmed through ur code. I believe this line:
$statement->bind_param('s', '%'.$user.'%');
need to be
$statement->bind_param($query, '%'.$user.'%');
Due to the fact that its calling ur query to select users then selecting the user as follows.
-
Re: [pre-release] dev cms
Quote:
Originally Posted by
PythoneX12
Not 100% sure of this as i just skimmed through ur code. I believe this line:
$statement->bind_param('s', '%'.$user.'%');
need to be
$statement->bind_param($query, '%'.$user.'%');
Due to the fact that its calling ur query to select users then selecting the user as follows.
PHP: mysqli_stmt::bind_param - Manual
http://i500.listal.com/image/3170273/500full.jpg
Fuck, where's the dislike button when you need it.
-
Re: [pre-release] dev cms
Oh hes using it differently. If u use it the way im using its the way i posted lol
-
Re: [pre-release] dev cms
He uses the MySQLi library without a wrapper arround it. I assume you do. Look better before you post things like that. It looks like you're a idiot.
-
Re: [pre-release] dev cms
Oh ya sorry didnt notice that now that i looked at his code lol
-
Re: [pre-release] dev cms
I've been pretty busy for the past week, but here's the new template class that'll I'll be using from now on. Basically I didn't like the fact that the template class (original) was using two classes and that there were functions inside the class that weren't needed etc.
PHP Code:
<?php
if (!defined('INDEX'))
{
exit ('<h1>Access denied</h1><p>You do not have the privileges to access this webpage.</p>');
}
class template
{
private $template = NULL;
private $input = array ();
private $output;
public function template ($string)
{
$this->template = $string;
}
public function template_page ()
{
extract ($this->input);
$input = ('resources/resources_private/private_template/template_private/'.$this->template.'.tpl');
if (file_exists($input))
{
ob_start ();
include ($input);
$output = ob_get_contents ();
ob_end_clean ();
return $this->template_filter_input ($output);
}
else
{
exit ('<h1>Access denied</h1><p>Template ('.$this->template.') does not have the privileges to access this webpage.</p>');
}
}
private function template_filter_input ($string)
{
foreach ($this->input as $input => $output)
{
if (is_object($output))
{
continue;
}
$string = str_ireplace ('%'.$input.'%', $output, $string);
}
return $string;
}
public function template_input ($input, $output)
{
$this->input[$input] = is_object ($output) ? $output->fetch () : $output;
}
public function template_output ()
{
$this->output .= $this->template_page ();
echo $this->template_filter_input ($this->output);
}
}
?>
-
Re: [pre-release] dev cms
-
Re: [pre-release] dev cms
Quote:
Notice: Undefined index: p in C:\xampp2\htdocs\xabbo2\index.php on line 12
Notice: Undefined variable: result in C:\xampp2\htdocs\xabbo2\private\application\library\class.html.php on line 44
Notice: Undefined variable: result in C:\xampp2\htdocs\xabbo2\private\application\library\class.html.php on line 392
Notice: Undefined variable: errors in C:\xampp2\htdocs\xabbo2\private\application\theme\public\login.php on line 89
I get those errors, and can we please have the database file? prefer if its compatible with Butterstorm