Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

LoadaCMS - MySQLI - Object oriented PHP

Status
Not open for further replies.
Newbie Spellweaver
Joined
Aug 1, 2013
Messages
6
Reaction score
0
Loada is a powerful and open-sourced cms(content managment system)
that is being developed and executed in
PHP OOP(Object oriented programming), MySQLi, CSS, HTML and JavaScript. And the shortcut to all of that is LoadaCMS.


The main developer of LoadaCMS is me Eymen Plaiterentire. However other developers can be involved in this project.
Developers who continues on developing this project are highly appreciated. Loada has nothing to do with
sulakes habbo swf files or emulator-servers! users are responsible for any illegal acts that breaks
against the copyright law. Loada is being developed for educational purpose and are totally free!
you can allways download the latest version for free, and if you are a developer that continues
developing loada and are planning to sell it, it's all on your responsibility. The config file is powerful and you can manage stuff like defualt motto, credits, pixels and you can also turn of the register page. This will be done and released within the next moth. A language file will also be included in the configuration map, you just have to rewrite the titles to translate :) easy! this is alot easier than opening the damn page in notepad and translating everything -.- agh..

Here are some code snippets from register/login/registeroff objects:
PHP:
class inreg{

   public function Create_user(){
   
   include "Configuration/Language.php";
   
   if(isset($_POST['create'])){
   
   if(empty($_POST['username']) or empty($_POST['password']) or empty($_POST['c_password']) or empty($_POST['email'])){
    
    echo "<div class='error'>".$convert['reg_empty']."</div>";
    
   }else{
    
    include "Configuration/Config.php";
    
    $mysqli = new mysqli($localhost,$root,$password,$database);
    $username = $mysqli->real_escape_string(strip_tags($_POST['username']));
    $password = $mysqli->real_escape_string(strip_tags($_POST['password']));
    $email = $mysqli->real_escape_string(strip_tags($_POST['email']));
    
    $check_username = $mysqli->query("SELECT * From users WHERE username='$username'");
    $check_email = $mysqli->query("SELECT * From users WHERE mail='$email'");
    
    if(mysqli_num_rows($check_username) > 0){
     echo "<div class='error'>".$convert['username_busy']."</div>";
    }elseif(mysqli_num_rows($check_email) > 0){
     echo "<div class='error'>".$convert['email_busy']."</div>";
    }elseif(strlen($username) > 15){
     echo "<div class='error'>".$convert['username_long']."</div>";
    }elseif(strlen($username) < 3){
      echo "<div class='error'>".$convert['username_short']."</div>";
    }elseif(strlen($password) < 6){
     echo "<div class='error'>".$convert['password_short']."</div>";
    }elseif( preg_match('/\s/',$username)){
     echo "<div class='error'>".$convert['username_whitespace']."</div>";
    }else{
    
      if($password == $_POST['c_password']){
     $password = $mysqli->real_escape_string(strip_tags(md5(sha1($_POST['password']))));
     $mysqli->query("INSERT INTO users (username,password,mail,activity_points,motto,credits,look) VALUES ('$username','$password','$email','$pixels','$motto','$credits','$look')");
     $mysqli->query("UPDATE users SET online='1' WHERE username='$username'");
     $_SESSION['user'] = $username;
     header("location: home.php");
     }else{
      echo "<div class='error'>".$convert['password_nomatch']."</div>";
     }
    }
    
    
   }
   
   }
   }

   Public function Login_user(){
   
   include "Configuration/Language.php";
   
   include "Configuration/Config.php";
   
   
   If(isset($_POST['login'])){
   #Checking for empty fields
   
   if( empty($_POST['username']) && empty($_POST['password']) ){
    
    echo "<div class='error'>".$convert['error_emptyall']."</div>";
   
   }elseif(empty($_POST['username']) && $_POST['password']){
    
    echo "<div class='error'>".$convert['error_emptyusername']."</div>";
    
   }elseif(empty($_POST['password']) && $_POST['username']){
   
    echo "<div class='error'>".$convert['error_emptypassword']."</div>";
   }else{
   
    $mysqli = new mysqli($localhost,$root,$password,$database);
    
    $username = $mysqli->real_escape_string(htmlspecialchars($_POST['username']));
    $password = $mysqli->real_escape_string(htmlspecialchars(md5(sha1($_POST['password']))));
    
    $catchUser = $mysqli->query("SELECT * From users WHERE username='$username' AND password='$password'");
    
    if(mysqli_num_rows($catchUser) > 0){
    
     $_SESSION['user'] = $username;
     $mysqli->query("UPDATE users SET online='1' WHERE username='$username'");
     header("location: home.php");
     
     }else{
      echo "<div class='error'>".$convert['error_incorrect']."</div>";
     }
   }
   
   
   }
   
   if(isset($_POST['register'])){
   
    if($registration == false){
    
      echo "<div class='error'>".$convert['register_off']."</div>";
      
    }elseif($registration == true){
    $_SESSION['reg'] = true;
    header("location: register.php");
    }
   }
    
    }

}

[UPDATES] some image of design:

index:
CodeFreak - LoadaCMS - MySQLI - Object oriented PHP - RaGEZONE Forums


Register:

CodeFreak - LoadaCMS - MySQLI - Object oriented PHP - RaGEZONE Forums


Home:

CodeFreak - LoadaCMS - MySQLI - Object oriented PHP - RaGEZONE Forums
 
Last edited:
Junior Spellweaver
Joined
Dec 24, 2011
Messages
125
Reaction score
39
Why you use if($var == true) you can do if($var) if(!$var)
 
Last edited:
Newbie Spellweaver
Joined
Aug 1, 2013
Messages
6
Reaction score
0
Why you use if($var == true) you can do if($var) if(!$var)

I dunno, i don't feel so secure about !$var. Users defines the true och false variable via config, so i just made it == true or == false. It's the same thing, dont worry :)
 
Joined
Jun 2, 2012
Messages
765
Reaction score
294
You should use prepared statements, either PDO or MySQLi.



I tend to do
PHP:
if($var != false) && if($var != true)
I don't know why just do.

That doesn't really makes sence mate :/
why would you have !=false when you can do == true or == false

That doesn't really makes sence mate :/
why would you have !=false when you can do == true or == false

Thats from years back when you could do that without $var being in the script, wouldn't chuck errors.
 
Last edited by a moderator:
Junior Spellweaver
Joined
Dec 24, 2011
Messages
125
Reaction score
39
I think it is just the way how you like it to do
some people use 'is_null($var);' i do '$var == null;'
 
Newbie Spellweaver
Joined
Aug 1, 2013
Messages
6
Reaction score
0
I think it is just the way how you like it to do
some people use 'is_null($var);' i do '$var == null;'

== true / false is common for every programming language. I think it's better to learn the proper way than just the "PHP way" for doing it.
 
The one and only!
Loyal Member
Joined
Nov 24, 2008
Messages
2,529
Reaction score
1,435
== true / false is common for every programming language. I think it's better to learn the proper way than just the "PHP way" for doing it.
It doesn't matter how you do it.

if($var) and if($var == true) both get the same result. There is no "proper way". It's all down to your preference.
 
Status
Not open for further replies.
Back
Top