<?php
/*================================================================+\
|| # CookieMS- An advanced CMS for habbo based private servers! ||
|+================================================================+|
|| # Copyright (C) 2012 CookieMonsta. All rights reserved. ||
|| # http://www.devbest.com/user/CookieMonsta ||
|| # This was a scratch development. Love to devbest for support! ||
|+================================================================+|
|| # CookieMS is provided "as is" and comes without ||
|| # warrenty of any kind. CookieMS is free software! ||
|| # License: GNU Public License 3.0 ||
|| # http://opensource.org/licenses/gpl-license.php ||
\+================================================================*/
/*
*
* CookieMS- Users Class
*
*/
class Users {
public $me;
public $info = Array();
public $idlogin;
public function User2id($var, $variable){
$user = mysql_fetch_array(mysql_query("SELECT id FROM users WHERE $var = '".$variable."' LIMIT 1") or die($db->error()));
return $user['id'];
}
public function Id2name($id, $news = false){
$user = mysql_query("SELECT username FROM users WHERE id = '".X($id)."' LIMIT 1") or die($db->error());
if(mysql_num_rows($user) < 1)
return '';
else {
$user = mysql_fetch_array($user);
if($news !== true)
return X($user['username']);
else
return X($user['username']).' & ';
}
}
public function login($login, $pass, $only = '', $bool = 0){
if($only == "name")
$search = mysql_query("SELECT * FROM users WHERE username = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error());
else if($only == "mail")
$search = mysql_query("SELECT * FROM users WHERE mail = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error());
else
$search = mysql_query("SELECT * FROM users WHERE username = '".$login."' OR mail = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error());
if(mysql_num_rows($search) > 0){
$found = true;
$user = mysql_fetch_array($search);
if(md5($pass) == X($user['password']) || sha1($pass) == X($user['password'])){
if($bool == 1)
$this->me = X($user['username']);
else
return true;
} else {
if($bool == 1)
header("Location: ../index?e=2");
else
return false;
}
} else {
if($bool == 1)
header("Location: ../index?e=1");
else
return false;
}
}
public function me($vars = 'username'){
global $_SESSION;
if(!isset($_SESSION['username'])){
return '-';
} else {
if(isset($this->info[$vars]))
return X($this->info[$vars]);
$varquery = mysql_query("SELECT * FROM users WHERE username = '".X($_SESSION['username'])."' LIMIT 1") or die($db->error());
$var = mysql_fetch_array($varquery);
$this->info = $var;
if(empty($var[$vars]))
return '';
return X($var[$vars]);
}
}
public function sso(){
function Random($length){
$chars = "0123456789abcdef";
$random = '';
for($s = 0; $s < $length; $s++){
$random .= $chars[mt_rand(0, strlen($chars)-1)];
}
return $random;
}
$ticket = Random("8")."-".Random("4")."-".Random("4")."-".Random("4")."-".Random("12")."-ID".$this->me('id');
//The id is just to make sure no duplicates will appear
if(isset($_SERVER['HTTP_CF_CONNECTING_IP']))
$_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_CF_CONNECTING_IP']);
if(isset($_SERVER['HTTP_CLIENT_IP']))
$_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_CLIENT_IP']);
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_X_FORWARDED_FOR']);
mysql_query("UPDATE users SET auth_ticket = '".$ticket."', ip_last = '".$_SERVER['REMOTE_ADDR']."' WHERE username = '".X($_SESSION['username'])."' LIMIT 1");
return $ticket;
}
function mailaccs($bool = false, $countdown = false){
$query = mysql_query("SELECT id FROM users WHERE mail = '".$this->me('mail')."' LIMIT 50") or die(mysql_error());
if($bool == false){
if(mysql_num_rows($query) > 49)
return false;
return true;
} else {
if($countdown == false)
return mysql_num_rows($query);
else {
$count = 50 - mysql_num_rows($query);
return $count;
}
}
}
function mailadd($username){
global $regmotto, $remoteip;
mysql_query("INSERT INTO users (username, password, mail, look, motto, ip_last, ip_reg, last_online, auth_ticket, account_created) VALUES ('".$username."', '".$this->me('password')."', '".$this->me('mail')."', 'hd-180-1.ch-210-66.lg-270-82.sh-290-91.hr-100-', '".$regmotto."', '".$remoteip."', '".$remoteip."', '".time()."', 'CookieMS-234232134-2342342', '".time()."')") or die($db->error());
}
function idexist($id){
$this->idlogin = mysql_query("SELECT * FROM users WHERE id = '".X($id)."' LIMIT 1") or die($db->error());
if(mysql_num_rows($this->idlogin) > 0)
return true;
return false;
}
function idmymail($id){
$this->idlogin = mysql_fetch_array($this->idlogin);
if($this->idlogin['mail'] == $this->me('mail'))
return true;
return false;
}
function idlogin(){
global $_SESSION;
mysql_query("UPDATE users SET last_online = '".time()."' WHERE username = '".$_SESSION['username']."' LIMIT 1") or die($db->error());
$name = $this->idlogin['username'];
$_SESSION['username'] = $name;
}
}
?>
<?php
/*================================================================+\
|| # CookieMS- An advanced CMS for habbo based private servers! ||
|+================================================================+|
|| # Copyright (C) 2012 CookieMonsta. All rights reserved. ||
|| # http://www.devbest.com/user/CookieMonsta ||
|| # This was a scratch development. Love to devbest for support! ||
|+================================================================+|
|| # CookieMS is provided "as is" and comes without ||
|| # warrenty of any kind. CookieMS is free software! ||
|| # License: GNU Public License 3.0 ||
|| # http://opensource.org/licenses/gpl-license.php ||
\+================================================================*/
/*
*
* CookieMS- MySQL manager
*
*/
class MySQL {
public function __construct($host, $user, $pass, $database){
error_reporting(0); //Error returning (configureable in the web-installer/ config file.
$connect = mysql_connect($host, $user, $pass) or die($this->error());
$select = mysql_select_db($database, $connect) or die($this->error());
error_reporting(E_ALL); //Maximize error format. (best for security issues)
}
#Start up MySQL filters......
public function fetch($query, $filter = 1){
$return = mysql_fetch_array(mysql_query($query) or die($db->error()));
if($filter !== 0){
foreach($return as $key => $value){
$return[$key] = mysql_real_escape_string($value);
}
}
return $return;
}
public static function error(){
ob_start();
include(base.'Application/Functions/Mysql_error.php');
$error = ob_get_contents();
ob_end_clean();
return $error;
}
}
?>
<?php
/*================================================================+\
|| # CookieMS- An advanced CMS for habbo based private servers! ||
|+================================================================+|
|| # Copyright (C) 2012 CookieMonsta. All rights reserved. ||
|| # http://www.devbest.com/user/CookieMonsta ||
|| # This was a scratch development. Love to devbest for support! ||
|+================================================================+|
|| # CookieMS is provided "as is" and comes without ||
|| # warrenty of any kind. CookieMS is free software! ||
|| # License: GNU Public License 3.0 ||
|| # http://opensource.org/licenses/gpl-license.php ||
\+================================================================*/
/*
*
* CookieMS- Phoenix Class
*
*/
class Core {
public $gameport = $CONFIG['Client']['Gameport'];
public $musport = $CONFIG['Client']['Musport'];
function setports($game, $mus){
$this->gameport = $game;
$this->musport = $mus;
}
function MUS($cmd, $value = ''){
$data = $cmd.chr(1).$value;
$mus = new Mus($data, "127.0.0.1", $this->musport);
}
static function filter($var, $mres = 1, $adds = 1, $strips = 1, $trim = 1, $htmlsc = 1, $striphtml = 1){
if($mres == 1) $var = mysql_real_escape_string($var);
if($adds == 1) $var = addslashes($var);
if($strips == 1) $var = stripslashes($var);
if($trim == 1) $var = trim($var);
if($htmlsc == 1) $var = htmlspecialchars($var);
if($striphtml == 1) $var = strip_tags($var);
return $var;
}
function checkemail($email){
if(preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email) > 0)
return true;
else
return false;
}
function checkname($nm){
if(preg_match('/^[a-z0-9]+$/i', $nm) && strlen($nm) >= 3 && strlen($nm) <= 32)
return true;
else
return false;
}
function checkpass($nm){
if(strlen($nm) >= 6 && strlen($nm) <= 32)
return true;
else
return false;
}
function onlineusers(){
return mysql_num_rows(mysql_query("SELECT online FROM users WHERE online = '1'"));
}
private function between($txt, $start, $end){
$txt = explode($start, $txt, 2);
if(isset($txt[1])){
$txt = explode($end, $txt[1], 2);
return $txt[0];
}
return '-';
}
function logintime($time){
if(date('H', $time) > 12)
$add = " PM";
else
$add = " AM";
return date('d/M/y H:i' ,$time).$add;
}
function swfsite($base){
global $site;
if(strpos(':', $base) !== false){
$site = explode('/', $base, 4);
if(!isset($site))
exit('Swf error, i think you need to check you external vars again ..');
return 'http://'.$site;
}
return $site;
}
}
?>
Looking good. Mind ranking me? I would just like to check out your housekeeping.Updates Of The Day
So, i finished MOST of the classes today that are required to make the cms function correctly.. Everyhting is loooking good.
Snippets of some shizzle::
Users Class
PHP:<?php /*================================================================+\ || # CookieMS- An advanced CMS for habbo based private servers! || |+================================================================+| || # Copyright (C) 2012 CookieMonsta. All rights reserved. || || # http://www.devbest.com/user/CookieMonsta || || # This was a scratch development. Love to devbest for support! || |+================================================================+| || # CookieMS is provided "as is" and comes without || || # warrenty of any kind. CookieMS is free software! || || # License: GNU Public License 3.0 || || # http://opensource.org/licenses/gpl-license.php || \+================================================================*/ /* * * CookieMS- Users Class * */ class Users { public $me; public $info = Array(); public $idlogin; public function User2id($var, $variable){ $user = mysql_fetch_array(mysql_query("SELECT id FROM users WHERE $var = '".$variable."' LIMIT 1") or die($db->error())); return $user['id']; } public function Id2name($id, $news = false){ $user = mysql_query("SELECT username FROM users WHERE id = '".X($id)."' LIMIT 1") or die($db->error()); if(mysql_num_rows($user) < 1) return ''; else { $user = mysql_fetch_array($user); if($news !== true) return X($user['username']); else return X($user['username']).' & '; } } public function login($login, $pass, $only = '', $bool = 0){ if($only == "name") $search = mysql_query("SELECT * FROM users WHERE username = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error()); else if($only == "mail") $search = mysql_query("SELECT * FROM users WHERE mail = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error()); else $search = mysql_query("SELECT * FROM users WHERE username = '".$login."' OR mail = '".$login."' ORDER BY last_online DESC LIMIT 1") or die($db->error()); if(mysql_num_rows($search) > 0){ $found = true; $user = mysql_fetch_array($search); if(md5($pass) == X($user['password']) || sha1($pass) == X($user['password'])){ if($bool == 1) $this->me = X($user['username']); else return true; } else { if($bool == 1) header("Location: ../index?e=2"); else return false; } } else { if($bool == 1) header("Location: ../index?e=1"); else return false; } } public function me($vars = 'username'){ global $_SESSION; if(!isset($_SESSION['username'])){ return '-'; } else { if(isset($this->info[$vars])) return X($this->info[$vars]); $varquery = mysql_query("SELECT * FROM users WHERE username = '".X($_SESSION['username'])."' LIMIT 1") or die($db->error()); $var = mysql_fetch_array($varquery); $this->info = $var; if(empty($var[$vars])) return ''; return X($var[$vars]); } } public function sso(){ function Random($length){ $chars = "0123456789abcdef"; $random = ''; for($s = 0; $s < $length; $s++){ $random .= $chars[mt_rand(0, strlen($chars)-1)]; } return $random; } $ticket = Random("8")."-".Random("4")."-".Random("4")."-".Random("4")."-".Random("12")."-ID".$this->me('id'); //The id is just to make sure no duplicates will appear if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) $_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_CF_CONNECTING_IP']); if(isset($_SERVER['HTTP_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_CLIENT_IP']); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = X($_SERVER['HTTP_X_FORWARDED_FOR']); mysql_query("UPDATE users SET auth_ticket = '".$ticket."', ip_last = '".$_SERVER['REMOTE_ADDR']."' WHERE username = '".X($_SESSION['username'])."' LIMIT 1"); return $ticket; } function mailaccs($bool = false, $countdown = false){ $query = mysql_query("SELECT id FROM users WHERE mail = '".$this->me('mail')."' LIMIT 50") or die(mysql_error()); if($bool == false){ if(mysql_num_rows($query) > 49) return false; return true; } else { if($countdown == false) return mysql_num_rows($query); else { $count = 50 - mysql_num_rows($query); return $count; } } } function mailadd($username){ global $regmotto, $remoteip; mysql_query("INSERT INTO users (username, password, mail, look, motto, ip_last, ip_reg, last_online, auth_ticket, account_created) VALUES ('".$username."', '".$this->me('password')."', '".$this->me('mail')."', 'hd-180-1.ch-210-66.lg-270-82.sh-290-91.hr-100-', '".$regmotto."', '".$remoteip."', '".$remoteip."', '".time()."', 'CookieMS-234232134-2342342', '".time()."')") or die($db->error()); } function idexist($id){ $this->idlogin = mysql_query("SELECT * FROM users WHERE id = '".X($id)."' LIMIT 1") or die($db->error()); if(mysql_num_rows($this->idlogin) > 0) return true; return false; } function idmymail($id){ $this->idlogin = mysql_fetch_array($this->idlogin); if($this->idlogin['mail'] == $this->me('mail')) return true; return false; } function idlogin(){ global $_SESSION; mysql_query("UPDATE users SET last_online = '".time()."' WHERE username = '".$_SESSION['username']."' LIMIT 1") or die($db->error()); $name = $this->idlogin['username']; $_SESSION['username'] = $name; } } ?>
MySQL Class
PHP:<?php /*================================================================+\ || # CookieMS- An advanced CMS for habbo based private servers! || |+================================================================+| || # Copyright (C) 2012 CookieMonsta. All rights reserved. || || # http://www.devbest.com/user/CookieMonsta || || # This was a scratch development. Love to devbest for support! || |+================================================================+| || # CookieMS is provided "as is" and comes without || || # warrenty of any kind. CookieMS is free software! || || # License: GNU Public License 3.0 || || # http://opensource.org/licenses/gpl-license.php || \+================================================================*/ /* * * CookieMS- MySQL manager * */ class MySQL { public function __construct($host, $user, $pass, $database){ error_reporting(0); //Error returning (configureable in the web-installer/ config file. $connect = mysql_connect($host, $user, $pass) or die($this->error()); $select = mysql_select_db($database, $connect) or die($this->error()); error_reporting(E_ALL); //Maximize error format. (best for security issues) } #Start up MySQL filters...... public function fetch($query, $filter = 1){ $return = mysql_fetch_array(mysql_query($query) or die($db->error())); if($filter !== 0){ foreach($return as $key => $value){ $return[$key] = mysql_real_escape_string($value); } } return $return; } public static function error(){ ob_start(); include(base.'Application/Functions/Mysql_error.php'); $error = ob_get_contents(); ob_end_clean(); return $error; } } ?>
Phoenix Class
PHP:<?php /*================================================================+\ || # CookieMS- An advanced CMS for habbo based private servers! || |+================================================================+| || # Copyright (C) 2012 CookieMonsta. All rights reserved. || || # http://www.devbest.com/user/CookieMonsta || || # This was a scratch development. Love to devbest for support! || |+================================================================+| || # CookieMS is provided "as is" and comes without || || # warrenty of any kind. CookieMS is free software! || || # License: GNU Public License 3.0 || || # http://opensource.org/licenses/gpl-license.php || \+================================================================*/ /* * * CookieMS- Phoenix Class * */ class Core { public $gameport = $CONFIG['Client']['Gameport']; public $musport = $CONFIG['Client']['Musport']; function setports($game, $mus){ $this->gameport = $game; $this->musport = $mus; } function MUS($cmd, $value = ''){ $data = $cmd.chr(1).$value; $mus = new Mus($data, "127.0.0.1", $this->musport); } static function filter($var, $mres = 1, $adds = 1, $strips = 1, $trim = 1, $htmlsc = 1, $striphtml = 1){ if($mres == 1) $var = mysql_real_escape_string($var); if($adds == 1) $var = addslashes($var); if($strips == 1) $var = stripslashes($var); if($trim == 1) $var = trim($var); if($htmlsc == 1) $var = htmlspecialchars($var); if($striphtml == 1) $var = strip_tags($var); return $var; } function checkemail($email){ if(preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email) > 0) return true; else return false; } function checkname($nm){ if(preg_match('/^[a-z0-9]+$/i', $nm) && strlen($nm) >= 3 && strlen($nm) <= 32) return true; else return false; } function checkpass($nm){ if(strlen($nm) >= 6 && strlen($nm) <= 32) return true; else return false; } function onlineusers(){ return mysql_num_rows(mysql_query("SELECT online FROM users WHERE online = '1'")); } private function between($txt, $start, $end){ $txt = explode($start, $txt, 2); if(isset($txt[1])){ $txt = explode($end, $txt[1], 2); return $txt[0]; } return '-'; } function logintime($time){ if(date('H', $time) > 12) $add = " PM"; else $add = " AM"; return date('d/M/y H:i' ,$time).$add; } function swfsite($base){ global $site; if(strpos(':', $base) !== false){ $site = explode('/', $base, 4); if(!isset($site)) exit('Swf error, i think you need to check you external vars again ..'); return 'http://'.$site; } return $site; } } ?>
I know its messy people, its just the structure. It will be neater and organized when i finish all classes. (below are only a few classes, not all lol)
So now ive been asked to put up a demo site..... Well sure! Here it is:You must be registered for see links
Cool, TheFallenSure, even though theres not much though Name?
Yes, id2 was from uber / And i plan on doing a rewrite. However, the X() was just something i made to make variables easier to use.That user class is really... really.. bad.. Also I see you took the user2id and id2user from Uber.
It also seems you took the function X() from somewhere and you have really faulty code, you may wanna do a complete rewrite.
Anyways, seeing what Kryptos said above is true. I find the classes a mess. So i think ill recode that stuff For now, the live demo will be down untill i re-write some stuff.Do you need the definition of scratch? You cant take anything from any cms including uber userid2,
Krpytos Why u hating on cookie monsta D;Ok ladies, shut up and move on.
Cookie your always welcome to have my users class im codding ;DAnyways, seeing what Kryptos said above is true. I find the classes a mess. So i think ill recode that stuff For now, the live demo will be down untill i re-write some stuff.
Template system guys?
Anyways, seeing what Kryptos said above is true. I find the classes a mess. So i think ill recode that stuff For now, the live demo will be down untill i re-write some stuff.
Template system guys?
Well i ment like just a template.class that parses the files for {keys} or a full on template system users can choose witch template they wanna see and all themes share content alot of the time stored over mysql or txt filesLike revcms with the skins chooserr
So.., should i make a skin system like revcms or just build on to the habbo theme?Well i ment like just a template.class that parses the files for {keys} or a full on template system users can choose witch template they wanna see and all themes share content alot of the time stored over mysql or txt files
Change it up make an advance template system :]So.., should i make a skin system like revcms or just build on to the habbo theme?