Welcome to the RaGEZONE - MMORPG development forums.

Core [DEV, IMPROVED]

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, ...

LyncusMU
Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Now 35% cooler!
    Rank
    Alpha Member
    Join Date
    Oct 2008
    Location
    United Kingdom
    Posts
    2,071
    Liked
    353

    Core [DEV, IMPROVED]

    Tabo Hotel
    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.
    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(100000999999); 
      
    $rand2 rand(1000099999); 
      
    $rand3 rand(1000099999); 
      
    $rand4 rand(1000099999); 
      
    $rand5 rand(1000099999); 
      
    $rand6 rand(19); 
      
    $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_INtrue);
      
    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!";
      }
      }

      }
      

      
    ?>
    break it down beginners.

  2. HostKey.com: Unmetered Dedicated servers in the Netherlands
  3. #2
    CF Web Developer
    Rank
    Member +
    Join Date
    Dec 2010
    Location
    Lincoln, UK
    Posts
    1,107
    Liked
    414

    Re: Core [DEV, IMPROVED]

    All this sexy code being released lately, should really help!

    If I knew PHP, I'd refer to this - Thankyou though.
    Livar likes this.

  4. #3
    Now 35% cooler!
    Rank
    Alpha Member
    Join Date
    Oct 2008
    Location
    United Kingdom
    Posts
    2,071
    Liked
    353

    Re: Core [DEV, IMPROVED]

    It's nothing hard Jak, just break it down.

  5. #4
    CF Web Developer
    Rank
    Member +
    Join Date
    Dec 2010
    Location
    Lincoln, UK
    Posts
    1,107
    Liked
    414

    Re: Core [DEV, IMPROVED]

    Quote Originally Posted by PowahAlert View Post
    It's nothing hard Jak, just break it down.
    Oh, it's not that I can't learn.

    I don't want to.
    Livar and AmirZ like this.

  6. #5
    Now 35% cooler!
    Rank
    Alpha Member
    Join Date
    Oct 2008
    Location
    United Kingdom
    Posts
    2,071
    Liked
    353

    Re: Core [DEV, IMPROVED]

    Quote Originally Posted by <Nominal /> View Post
    Oh, it's not that I can't learn.

    I don't want to.
    Beats me. That's your choice init.

  7. #6
    CF Web Developer
    Rank
    Member +
    Join Date
    Dec 2010
    Location
    Lincoln, UK
    Posts
    1,107
    Liked
    414

    Re: Core [DEV, IMPROVED]

    Thought I'd try something different.

    No harm in being different, eh?

  8. #7
    Developer & Designer
    Rank
    Member +
    Join Date
    Feb 2010
    Location
    Planet Earth
    Posts
    549
    Liked
    266

    Re: Core [DEV, IMPROVED]

    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.

  9. #8
    Now 35% cooler!
    Rank
    Alpha Member
    Join Date
    Oct 2008
    Location
    United Kingdom
    Posts
    2,071
    Liked
    353

    Re: Core [DEV, IMPROVED]

    Quote Originally Posted by Kryptos View Post
    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.
    Improved, is it not? So you'd class this as OOP?

  10. #9
    Works @Duck Hosts (siggy)
    Rank
    Member +
    Join Date
    Dec 2010
    Location
    Australia
    Posts
    1,252
    Liked
    529

    Re: Core [DEV, IMPROVED]

    Quote Originally Posted by Kryptos View Post
    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.
    Livar is doing absolutely fine, let him learn at his own pace. I'm sure Livar will get better as he seems determined :D
    Livar likes this.

  11. #10
    Developer & Designer
    Rank
    Member +
    Join Date
    Feb 2010
    Location
    Planet Earth
    Posts
    549
    Liked
    266

    Re: Core [DEV, IMPROVED]

    Quote Originally Posted by PowahAlert View Post
    Improved, is it not? So you'd class this as OOP?
    Yea, it's much better than the code in Macro r1. I would, but at your level I'd try and read basic OOP tutorials and OOP good practices. ( Will get you going in using keywords, organization, etc ).


    Quote Originally Posted by Quackster View Post
    Livar is doing absolutely fine, let him learn at his own pace. I'm sure Livar will get better as he seems determined :D
    I have no doubt.

  12. #11
    Law
    Garry's Mod is addictive!
    Rank
    Subscriber
    Join Date
    Dec 2009
    Location
    Norway
    Posts
    1,010
    Liked
    230

    Re: Core [DEV, IMPROVED]

    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
    PHP Code:
    function blabla()
    {
    echo 
    "blabla";

    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 :P

  13. #12
    TopHabbo.com Best Topsite
    Rank
    Alpha Member
    Join Date
    Oct 2007
    Posts
    2,423
    Liked
    497

    Re: Core [DEV, IMPROVED]

    Good luck. I liked the first version.

    Also Manuel coding improves over time.
    Everyone starts of as a noob.

  14. #13
    Newbie
    Rank
    Newbie
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    14
    Liked
    0

    Re: Core [DEV, IMPROVED]

    Put in this version a Housekeeping with full functions and not only the Hotel Name ..

  15. #14
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Aug 2011
    Location
    England Coder<3
    Posts
    525
    Liked
    104
    For the ip, do not use $_SERVER['REMOTE_ADDR'] because sites with security need to bypass the security proxy.
    Use:
    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'];

    Sent from my mobile via Tapatalk.

  16. #15
    Developer
    Rank
    Member +
    Join Date
    May 2008
    Posts
    482
    Liked
    201

    Re: Core [DEV, IMPROVED]

    very good for beginners to learn from.. Just pick it apart.

 

 
Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •