All this sexy code being released lately, should really help!
If I knew PHP, I'd refer to this- Thankyou though.
This is a discussion on Core [DEV, IMPROVED] within the Habbo Releases forums, part of the Habbo Hotel category; Haidere, as you all know, I'm currently developing MacroCMS r2, and here's my core.php, some may understand some may not, ...

Haidere, as you all know, I'm currently developing MacroCMS r2, and here's my core.php, some may understand some may not, I'm releasing this so that people can get bits out of it and learn.
break it down beginners.PHP Code:<?php
//---------------------------------\\
//-- MACRO CMS ULTIMATE --\\
//-- DEVELOPED BY POWAHALERT --\\
//---------------------------------\\
class MacroCore
{
function Connect($host, $user, $password, $database)
{
mysql_connect("$host", "$user", "$password") or die ("<h1>ERROR</h1>");
mysql_select_db("$database") or die ("<h1>ERROR</h1>");
}
function MacroHash($input)
{
return md5($input);
}
function MacroClean($input)
{
return mysql_real_escape_string($input);
}
function MacroDefine()
{
echo "MacroCMS Ultimate Edition - R2, BUILD: R63";
}
function CreateSSO($username)
{
$rand1 = rand(100000, 999999);
$rand2 = rand(10000, 99999);
$rand3 = rand(10000, 99999);
$rand4 = rand(10000, 99999);
$rand5 = rand(10000, 99999);
$rand6 = rand(1, 9);
$ip=@$REMOTE_ADDR;
$ticket = "ST-".$rand1."-".$rand2.$rand3."-".$rand4.$rand5."-otaku-".$rand6;
mysql_query("UPDATE users SET auth_ticket = '" . $ticket . "' WHERE username = '" . $username . "'");
mysql_query("UPDATE users SET last_ip = '$ip' WHERE username = '$username'");
return $ticket;
}
function MacroInfo($username, $row)
{
$query = @mysql_result(mysql_query("SELECT $row FROM users WHERE username = '$username' LIMIT 1"), 0);
return $query;
}
function CheckLogin()
{
if(!isset($_SESSION['M_USER']))
{
return false;
}
else
{
return true;
}
}
function MacroLogin()
{
$username = $this->MacroClean($_POST['username']);
$password = $this->MacroHash($_POST['password']);
$correct_password = $this->MacroInfo($username, 'password');
if($correct_password == $password)
{
$_SESSION['M_USER'] = $username;
$_SESSION['M_PASS'] = $password;
DEFINE(LOGGED_IN, true);
Header("Location: $Hotel_URL/me.php");
}
else
{
$_SESSION['ERROR'] = "Password is invalid";
}
if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE username = '$username'")) == 0)
{
$_SESSION['ERROR'] = "Username is not existant!";
}
}
}
?>
All this sexy code being released lately, should really help!
If I knew PHP, I'd refer to this- Thankyou though.
It's nothing hard Jak, just break it down.
Thought I'd try something different.
No harm in being different, eh?![]()
Login functions in a core?
Code you can see in the majority, if not all, OOP CMS'?
You still need to learn so much, beginner.
Creating a function for something that could've been a variable, why?
And I'd like if you'd put a little more "structure" into your coding I mean you do
I really like it when it's something like this:PHP Code:function blabla()
{
echo "blabla";
}
But if you like it the way your doing, then continue on it :PPHP Code:function blabla(){
echo 'blabla';
}
Good luck. I liked the first version.
Also Manuel coding improves over time.
Everyone starts of as a noob.
Put in this version a Housekeeping with full functions and not only the Hotel Name ..
For the ip, do not use $_SERVER['REMOTE_ADDR'] because sites with security need to bypass the security proxy.
Use:
Sent from my mobile via Tapatalk.PHP Code:if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{ $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
very good for beginners to learn from.. Just pick it apart.