Goodluck !
Printable View
Goodluck !
Your code isn't 100% great, I'll show you below. I'll put a #1 at the end of each line I change. :)
Also, on a side note INDENT YOUR CODEPHP Code:
<?php
//---------------------------------\\
//-- MACRO CMS ULTIMATE --\\
//-- DEVELOPED BY POWAHALERT --\\
//-- EDITED BY PURE --\\
//---------------------------------\\
class MacroCore
{
public function Connect($host, $user, $password, $database)
{
mysql_connect($host, $user, $password) or die ("<h1>ERROR</h1>");#1 UNNEEDED QUOTES ON PARAMS.
mysql_select_db($database) or die ("<h1>ERROR</h1>"); #1 same as above.
}
public function MacroHash($input)
{
return md5($input);
}
public function MacroClean($input)
{
return mysql_real_escape_string($input);
}
public function MacroDefine()
{
echo "MacroCMS Ultimate Edition - R2, BUILD: R63";
}
public function CreateSSO($username) #1 CHANGED MOST OF METHOD
{
$rand[0] = rand(100000, 999999); #1 USE ARRAYS. Better than multiply vars.
$rand[1] = rand(10000, 99999);
$rand[2] = rand(10000, 99999);
$rand[3] = rand(10000, 99999);
$rand[4] = rand(10000, 99999);
$rand[5] = rand(1, 9);
$ip = $_SERVER['REMOTE_ADDR'];
$ticket = "ST-".$rand[0]."-".$rand[1].$rand[2]."-".$rand[3].$rand[5]."-otaku-".$rand[5];
mysql_query("UPDATE users SET auth_ticket = '" . $ticket . "', last_ip = '".$ip."' WHERE username = '" . $username . "' LIMIT 1;");
#1 ABOVE Query changed to one query, and also limited to 1 row. You are only going to update one user.
return $ticket;
}
public function MacroInfo($username, $row = 'id')
{
$querqy = @mysql_result(mysql_query("SELECT $row FROM users WHERE username = '$username' LIMIT 1"), 0);
return $query;
}
public function CheckLogin()
{
return isset($_SESSION['M_USER']) ? true : false; //#1 Shorten.
}
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 null FROM users WHERE username = '$username' LIMIT 1;")) == 0) //LIMITED to 1
{
$_SESSION['ERROR'] = "Username is not existant!";
}
}
}
Nice to see your PHP skills, i want to learn some PHP so i could look at some at your codes to learn from. Thanks!
Since when could you code?
Since I'm still not the best at PHP, this is a good little piece you've released. Thanks •
Very nice mate, keep up the good work.
You're not even using classes properly.Quote:
break it down beginners.
The point of classes and OOP is to make your functions (in classes cases, objects) more organized and flow better. Your "Core" class is just a group of half-assed functions thrown together, which = beginner PHP scripting.
Who are you calling beginners again?
edit-
.. ah shit, stumbled upon the Habbo section. No wonder.
You seem to be lost, let me point you in the right direction...
da spammin s3ct10nz
Lol, Everyone can code, just many people havn't tried it.