[pre-release] dev cms

Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 63
  1. #46
    Account Upgraded | Title Enabled! Predict is offline
    MemberRank
    Aug 2008 Join Date
    760Posts

    Re: [pre-release] dev cms

    Quote Originally Posted by Tha View Post
    Why are you using GLOBAL and not something like a static core class like this:

    PHP Code:
    <?php

    class Core {

        private static 
    $configuration;
        private static 
    $database;
        private static 
    $settings;

        public static function 
    includeClasses() {
            foreach(
    glob('includes/classes/class.*.php') as $file) {
                if (
    $file == 'includes/classes/class.core.php') {
                    continue;
                }
                
                include(
    $file);
            }
        }
        
        public static function 
    initialize() {
            
    self::$configuration = new Configuration();
            
            
    self::$database = new Database();
            
    self::$settings = new Settings();
        }
        
        public static function 
    getConfiguration() {
            return 
    self::$configuration;
        }
        
        public static function 
    getDatabase() {
            return 
    self::$database;
        }
        
        public static function 
    getSettings() {
            return 
    self::$settings;
        }
    }

    ?>
    default.php:

    PHP Code:
    <?php

    include('includes/classes/class.core.php');

    Core::includeClasses();
    Core::initialize();

    ?>
    (TO BE IMPROVED I KNOW, JUST GIVING EXAMPLE)
    They introduce global state into a program. Most programmers should be familiar with why global state is bad.
    They introduce tight coupling between the singleton and any class that uses it. This means you can't reuse the classes in question without reusing the singleton too.
    They make unit testing of classes that depend on the singleton problematic because you can't easily replace the singleton with a mock.
    They encourage a coding style where classes attempt to resolve their own dependencies. This is bad because it can reduce clarity regarding what dependencies the class has.
    PHP has a Share Nothing Architecture, meaning that PHP singletons aren't really singletons at all, there can be multiple instances alive at any one time (one per open request).
    What happens if you suddenly discover at some later date that you actually need more than one of the resource that's being provided by the singleton? It's a more common scenario than you might think

    A few reasons why Singleton is bad

  2. #47
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [pre-release] dev cms

    Quote Originally Posted by Predict View Post
    They introduce global state into a program. Most programmers should be familiar with why global state is bad.
    They introduce tight coupling between the singleton and any class that uses it. This means you can't reuse the classes in question without reusing the singleton too.
    They make unit testing of classes that depend on the singleton problematic because you can't easily replace the singleton with a mock.
    They encourage a coding style where classes attempt to resolve their own dependencies. This is bad because it can reduce clarity regarding what dependencies the class has.
    PHP has a Share Nothing Architecture, meaning that PHP singletons aren't really singletons at all, there can be multiple instances alive at any one time (one per open request).
    What happens if you suddenly discover at some later date that you actually need more than one of the resource that's being provided by the singleton? It's a more common scenario than you might think

    A few reasons why Singleton is bad
    Could be, but global aint 'awesome' too. Why not concider using it as a parameter of the function? Would be still better than either singleton or global.

  3. #48
    Account Upgraded | Title Enabled! Predict is offline
    MemberRank
    Aug 2008 Join Date
    760Posts

    Re: [pre-release] dev cms

    PHP Code:
        public static function users_search ($user)
        {
            GLOBAL 
    $config$db;
            
    $query = ('SELECT username, look FROM users WHERE username LIKE = ?');
            if (
    $statement $db->prepare($query))
            {
                
    $statement->bind_param('s''%'.$user.'%');
                
    $statement->execute();
                
    $statement->bind_result($username$look);
                while (
    $statement->fetch())
                {
                    
    $class = ($x == 0) ? 'odd' 'even';
                    
    $result .= ('<a href="'.$config['www']['url'].'?p=home&sub='.$username.'" target="_self" class="'.$class.'">
                            <div class="users-image"><img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure='
    .$look.'&direction=2&head_direction=2&size=s&gesture=sml.gif" alt="'.$username.'" /></div>
                            <div class="users-p"><b>'
    .$username.'</b></div>
                        </a>'
    );
                    
    $x++;
                }
                
    $statement->close();
            }
            
            return (
    $result);
        } 
    Uhm, can someone tell me what's wrong with this code? Mainly the part for the the query and bind_param (wildcard). Can't seem to get it working x.x

    Besides this, I think I'm going to move on with the project. I haven't been active within the pre-release/dev because I've had other stuff to do.

    Release on the current patch is in the attachments.
    Attached Files Attached Files

  4. #49
    Web & Interaction Design Gangnam is offline
    MemberRank
    Dec 2010 Join Date
    Lincoln, UKLocation
    1,983Posts

    Re: [pre-release] dev cms

    Quote Originally Posted by TR10G33K View Post
    PHP Code:
      if (isset($_GET['p'])) 
            { 
                if (
    $_GET['p'] == 'me'
                { 
                    
    $colour[0] = ' white'
                } 
                else if (
    $_GET['p'] == 'home'
                { 
                    
    $colour[1] = ' class="white"'
                } 
                else if (
    $_GET['p'] == 'account'
                { 
                    
    $colour[2] = ' class="white"'
                } 
                else if (
    $_GET['p'] == 'news'
                { 
                    
    $colour[3] = ' class="white"'
                } 
                else if (
    $_GET['p'] == 'staff'
                { 
                    
    $colour[4] = ' class="white"'
                } 
                else if (
    $_GET['p'] == 'shop'
                { 
                    
    $colour[5] = ' class="white"'
                } 
                else 
                { 
                    
    $colour NULL
                } 
            } 
    Start using switch statements man...
    There are no real benefits to using switch case, other than looking prettier.

  5. #50
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [pre-release] dev cms

    What a troll (in a good way).

    PHP Code:
    SELECT `username`, `lookFROM `usersWHERE `usernameLIKE LIMIT 30 

  6. #51
    Apprentice TruCluez is offline
    MemberRank
    Nov 2013 Join Date
    10Posts

    Re: [pre-release] dev cms

    ok, um isn't this wabbo/wubbo cms if not then nice edit I guess?

  7. #52
    .io developer JPride is offline
    MemberRank
    Sep 2013 Join Date
    The Next LegendLocation
    481Posts

    Re: [pre-release] dev cms

    TrueCluez, It's devCMS

    [Pre-release]


    Many thanks

    - ValorAngel

  8. #53
    Banned rafa95123 is offline
    BannedRank
    May 2009 Join Date
    /home/RaphaLocation
    564Posts

    Re: [pre-release] dev cms

    Well, i'm not expert in this area... But i did a little code to verify if email is already registered... Isn't a GREAT fix, but... :)

    1° Go to private/application/library and open the class.user.php, then search for this public function user_name($username), then add this after void founded:
    PHP Code:
    public function user_mail($username)
        {
            GLOBAL 
    $db;
            
    $query = ('SELECT mail FROM users WHERE mail = ? LIMIT 1');
            if (
    $statement $db->prepare($query))
            {
                
    $statement->bind_param('s'$username);
                
    $statement->execute();
                
    $statement->bind_result($username);
                
    $statement->fetch();
                
    $statement->close();
                return (
    $username);
            }
        } 
    2° Go to private/application/theme/public and open the login.php, then search for this:
    PHP Code:
    else if ($usr->user_name($_POST['reg_username']))
            {
                
    $errors[] = 'Please enter an username that does not already exist.';
            } 
    After of found, add this:
    PHP Code:
    else if ($usr->user_mail($_POST['reg_email']))
            {
                
    $errors[] = 'Please enter an email that does not already exist.';
            } 
    Now you will have a verification of email!
    If have something wrong with code, tell me, i'm new in PHP :p

  9. #54
    Account Upgraded | Title Enabled! Predict is offline
    MemberRank
    Aug 2008 Join Date
    760Posts

    Re: [pre-release] dev cms

    Quote Originally Posted by rafa95123 View Post
    Well, i'm not expert in this area... But i did a little code to verify if email is already registered... Isn't a GREAT fix, but... :)

    ...
    Great work (:

    Sorry I haven't been active with the project, recently.
    What I've done since the last update, I've changed, renamed, removed and updated the directories, I somewhat like the new folder structure and when you get chance, please give feedback.

    I've modified some of the code inside the library.html.php (previously class.html.php) that I saw a few flaws inside. The users_search function doesn't want to play ball, so I'm going to leave the function as it is and move onto something else. Moreover to Housekeeping, infact. I really need to recode the .CSS for the layout because it doesn't work properly in some browsers, I'm hoping to keep the code the same.

  10. #55
    Banned rafa95123 is offline
    BannedRank
    May 2009 Join Date
    /home/RaphaLocation
    564Posts

    Re: [pre-release] dev cms

    Well man, tell me one thing... to do the client, is hard? xD

  11. #56
    Im Back! PythoneX12 is offline
    MemberRank
    Sep 2010 Join Date
    634Posts

    Re: [pre-release] dev cms

    Not 100% sure of this as i just skimmed through ur code. I believe this line:

    $statement->bind_param('s', '%'.$user.'%');

    need to be

    $statement->bind_param($query, '%'.$user.'%');

    Due to the fact that its calling ur query to select users then selecting the user as follows.

  12. #57
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [pre-release] dev cms

    Quote Originally Posted by PythoneX12 View Post
    Not 100% sure of this as i just skimmed through ur code. I believe this line:

    $statement->bind_param('s', '%'.$user.'%');

    need to be

    $statement->bind_param($query, '%'.$user.'%');

    Due to the fact that its calling ur query to select users then selecting the user as follows.
    PHP: mysqli_stmt::bind_param - Manual



    Fuck, where's the dislike button when you need it.

  13. #58
    Im Back! PythoneX12 is offline
    MemberRank
    Sep 2010 Join Date
    634Posts

    Re: [pre-release] dev cms

    Oh hes using it differently. If u use it the way im using its the way i posted lol

  14. #59
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [pre-release] dev cms

    He uses the MySQLi library without a wrapper arround it. I assume you do. Look better before you post things like that. It looks like you're a idiot.

  15. #60
    Im Back! PythoneX12 is offline
    MemberRank
    Sep 2010 Join Date
    634Posts

    Re: [pre-release] dev cms

    Oh ya sorry didnt notice that now that i looked at his code lol



Page 4 of 5 FirstFirst 12345 LastLast

Advertisement