Thread: Referral Handler

Results 1 to 3 of 3
  1. #1 Referral Handler 
    Quantum Scape Founder Quantum's Avatar
    Join Date
    Oct 2020
    Posts
    64
    Thanks given
    9
    Thanks received
    17
    Rep Power
    47
    please delete
    Last edited by Quantum; 02-24-2021 at 04:36 AM.
    In a Quantum World, nothing is real. We are one, and one is all. Live in the Quantum World.

    Reply With Quote  
     

  2. #2  
    All you gotta do is speak on Ye

    Jay Gatsby's Avatar
    Join Date
    Jun 2010
    Posts
    2,272
    Thanks given
    1,052
    Thanks received
    1,634
    Rep Power
    5000
    Thanks for contributing - there's quite a few things I'd probably suggest cleaning up here as this feels very PHP 5.4 esque. Please don't be offended by any of the below, my intent is only to give you places to improve upon.

    Firstly, and I cannot stress this enough, and it really is the overarching point and the one point you should take from any of this reply - use a framework.

    I'm not suggesting you go install a Laravel application for a simple referral system, but there will definitely be a lightweight PHP framework you can use for this.


    There's a lack of consistency with your code styling, sometimes you're putting braces on a new line for conditionals and sometimes not.

    You should simplify the code a bit too - things like:
    Code:
    function getArray() {
    		$array = array(
    			"runelocus",
    			"top100arena",
    			'topg',
    			'gamingtoplist',
    			'runetoplist',
    			'rs-ps',
    			'rsps',
    			'coding',
    			'topofgames',
    		);
    		return $array;
    	}
    can easily just be

    Code:
     function getArray()
            {
                return [
                    "runelocus",
                    "top100arena",
                    'topg',
                    'gamingtoplist',
                    'runetoplist',
                    'rs-ps',
                    'rsps',
                    'coding',
                    'topofgames',
                ];
            }
    Respectfully, I'm struggling to understand a bit of this code due to things such as
    Code:
    for ($x = 0; $x < 9; $x++) {
    			if (strpos($_SESSION['url_referer'], getArray()[$x]) != false) {
    				return $x;
    			}
    		}
    Why are we looping between 0 and 9? Presumably because that's how many referral sites there are, but what if we add one or take one away?

    You could have done the following:

    Code:
      foreach(getArray() as $referralSite) {
                if(strpos($_SESSION['url_referer'], $referralSite) != false) {
                    return $referralSite;
                }
            }
    This way you would then have the name of your referral site returned to you, meaning you can then query that in your database.

    There's a few other glaring issues here, some that would be resolved using a framework and some that just come from keeping up practice - but I don't really have time right now to discuss them in depth I'm afraid. Feel free to ping me a message on Discord though if you want to go through them.

    Quote Originally Posted by combatx View Post
    Kris let me help your undeveloped mind set, I need new opcodes to support the 184 version?
    Quote Originally Posted by z3rk3ms View Post
    Do not try to treat us like idiots, you will be clowned and then smacked.
    Quote Originally Posted by Hitsplat317 View Post
    I've recently Purchased a Launcher, obviously it's came as a .psd





    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Quantum Scape Founder Quantum's Avatar
    Join Date
    Oct 2020
    Posts
    64
    Thanks given
    9
    Thanks received
    17
    Rep Power
    47
    Quote Originally Posted by Jay Gatsby View Post
    Thanks for contributing - there's quite a few things I'd probably suggest cleaning up here as this feels very PHP 5.4 esque. Please don't be offended by any of the below, my intent is only to give you places to improve upon.

    Firstly, and I cannot stress this enough, and it really is the overarching point and the one point you should take from any of this reply - use a framework.

    I'm not suggesting you go install a Laravel application for a simple referral system, but there will definitely be a lightweight PHP framework you can use for this.


    There's a lack of consistency with your code styling, sometimes you're putting braces on a new line for conditionals and sometimes not.

    You should simplify the code a bit too - things like:
    Code:
    function getArray() {
    		$array = array(
    			"runelocus",
    			"top100arena",
    			'topg',
    			'gamingtoplist',
    			'runetoplist',
    			'rs-ps',
    			'rsps',
    			'coding',
    			'topofgames',
    		);
    		return $array;
    	}
    can easily just be

    Code:
     function getArray()
            {
                return [
                    "runelocus",
                    "top100arena",
                    'topg',
                    'gamingtoplist',
                    'runetoplist',
                    'rs-ps',
                    'rsps',
                    'coding',
                    'topofgames',
                ];
            }
    Respectfully, I'm struggling to understand a bit of this code due to things such as
    Code:
    for ($x = 0; $x < 9; $x++) {
    			if (strpos($_SESSION['url_referer'], getArray()[$x]) != false) {
    				return $x;
    			}
    		}
    Why are we looping between 0 and 9? Presumably because that's how many referral sites there are, but what if we add one or take one away?

    You could have done the following:

    Code:
      foreach(getArray() as $referralSite) {
                if(strpos($_SESSION['url_referer'], $referralSite) != false) {
                    return $referralSite;
                }
            }
    This way you would then have the name of your referral site returned to you, meaning you can then query that in your database.

    There's a few other glaring issues here, some that would be resolved using a framework and some that just come from keeping up practice - but I don't really have time right now to discuss them in depth I'm afraid. Feel free to ping me a message on Discord though if you want to go through them.
    Definetely, it was something that I was working on and the dude stopped midway, we were testing out what was returning as a failure, as it got closer i would of finished and cleaned it up properly, but those are awesome notes ill put down. I just didnt want to spend anymore time on it and it was sitting on my desktop and figured i release what i had instead of just tossing it away.
    In a Quantum World, nothing is real. We are one, and one is all. Live in the Quantum World.

    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. New Object Handler
    By wildy in forum Tutorials
    Replies: 39
    Last Post: 08-14-2007, 09:57 PM
  2. Command Handler
    By Kbob in forum Tutorials
    Replies: 21
    Last Post: 07-25-2007, 01:56 AM
  3. Easyer way to make Staff Handler..
    By Santa Noobie in forum Tutorials
    Replies: 7
    Last Post: 06-13-2007, 08:35 PM
  4. Md5 Handler
    By Pandora in forum Tutorials
    Replies: 1
    Last Post: 05-19-2007, 06:51 PM
  5. Full ardougne stalls (thieving, without Handler)
    By Sam Server in forum Tutorials
    Replies: 5
    Last Post: 05-11-2007, 10:55 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •