Need help immediately, automatic referral system!!!!
I have a referral system which im trying to setup properly but have been working on it for 2 days straight now and cant find a solution, help will be greatly appreciated, all PHP files will be below. Thanks in advance!
When I click on a referral link, it redirects me to the register page, I then sign up and sometimes it will redirect to the me.php page and sometimes it will freeze with white screen on register_submit.php, but the problem is it dosnt update the database with the referral points so i can sign up using a referral link and it wont add the referral point to my account.
r.php (This processes the link before redirecting to the register page, example referral link, http://habbz.servequake.com/r.php?user=Test)
PHP Code:
<?php/* #################################################################### \|| |||| TwinkieCMS - Use of this software is strictly prohibited. *#|| # Copyright (C) 2014 lD@vidl. *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo. *#|| Tanto el script como los autores del mismo no tienen ningún tipo *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no *#|| se hacen responsables del uso que el usuario le dé. *#|| ||\ ################################################################### */ob_start(); require_once 'inc/core.php'; $user->logged('no');
function base58_decode($num) { $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; $len = strlen($num); $decoded = 0; $multi = 1; for ($i = $len - 1; $i >= 0; $i--) { $decoded += $multi * strpos($alphabet, $num[$i]); $multi = $multi * strlen($alphabet); } return $decoded; } $remote_ip = USER_IP; $sql = $db->query("SELECT * FROM users WHERE ip_last = '".$remote_ip."'");
if($sql->num_rows > 0) { header("Location: " . PATH . "/register.php"); exit; } else { if (isset($_GET['id'])){ $decoded = base58_decode($_GET['id']) or die(header("Location: ". PATH ."/")); $_SESSION['refer'] = $user->filtertext($decoded); $_SESSION['refer_type'] = "id"; } if (isset($_GET['user'])){ $_SESSION['refer'] = $user->filtertext($_GET['user']); $_SESSION['refer_type'] = "username"; } header("Location: ". PATH ."/register.php"); exit; }ob_end_flush(); ?>
register_submit.php (Redirects to me page after registering)
PHP Code:
<?php/* #################################################################### \|| |||| TwinkieCMS - Use of this software is strictly prohibited. *#|| # Copyright (C) 2014 lD@vidl. *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo. *#|| Tanto el script como los autores del mismo no tienen ningún tipo *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no *#|| se hacen responsables del uso que el usuario le dé. *#|| ||\ ################################################################### */ob_start(); require_once 'inc/core.php'; if($user->register_now()) { header("Location: ".PATH."/me.php"); exit; } else { header("Location: ".PATH."/register.php?username=".$_POST['reg_username']."&rememberme=false&focus=login-username&login-password"); exit; }ob_end_flush(); ?>
Part of functions.php (Rewards the referral with a refer point)
PHP Code:
}else{ $password3 = $this->HoloHash($password, $user); $this->AddUser($user, $mail, $password3, '', '', $avatarimage); $_SESSION['username'] = $user; $_SESSION['password'] = $password3; if(!empty($_SESSION['refer'])){ $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1"); } header("LOCATION: ". PATH ."/me.php"); return true; }
If you want to have a closer look at these files I will provide the download link for the CMS.
Cms: https://mega.co.nz/#!tYAFTaLK!BdhgYh...Bcf04-vC9-t5IU
Please help me find the solution to fix the problem, Thank You!!!! :grr:
Re: Need help immediately, automatic referral system!!!!
Replace this:
PHP Code:
$execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
To:
PHP Code:
$execute = $db->query("UPDATE users SET refer_count = refer_count + 1 WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
Didn't test it, I can provide you another solution if this one doesn't work :love:
Re: Need help immediately, automatic referral system!!!!
No that doesnt work as ive already tried that, I know the query is correct because I copied the query and changed .$this->filtertext($_SESSION['refer']). to my username and pasted it in phpmyadmin and it added 1 referral point to my username.
Thanks for the reply!
Re: Need help immediately, automatic referral system!!!!
Quote:
Originally Posted by
Habbz96
No that doesnt work as ive already tried that, I know the query is correct because I copied the query and changed .$this->filtertext($_SESSION['refer']). to my username and pasted it in phpmyadmin and it added 1 referral point to my username.
Thanks for the reply!
Simply display the $_SESSION and find out if it's catching the name correctly
PHP Code:
echo $_SESSION['refer'];
Re: Need help immediately, automatic referral system!!!!
I put the echo on the register_submit.php page and it displayed my username so thats working, what happens tho is if you click a referral link and then register it will freeze with white screen on register submit page until you refresh the page, then it will redirect to me page but doesnt add referral point.
It will only freeze on register submit if you have clicked a referral link until you refresh the page.
Re: Need help immediately, automatic referral system!!!!
Quote:
Originally Posted by
Habbz96
I put the echo on the register_submit.php page and it displayed my username so thats working, what happens tho is if you click a referral link and then register it will freeze with white screen on register submit page until you refresh the page, then it will redirect to me page but doesnt add referral point.
It will only freeze on register submit if you have clicked a referral link until you refresh the page.
Sorry, I've been out for GYM
Well, so the issue is with the $_POST thing in register_submit... can you paste it on pastebin? Is better to visualize the code xD
Re: Need help immediately, automatic referral system!!!!
register_submit.php
http://pastebin.com/dANsHhdu
I think its something to do with this code:
if(!empty($_SESSION['refer'])){
$execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
}
header("LOCATION: ". PATH ."/me.php");
return true;
or this code:
if(!empty($_SESSION['refer'])){
$execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
}
header("LOCATION: ". PATH ."/me.php");
return true;
Re: Need help immediately, automatic referral system!!!!
Quote:
Originally Posted by
Habbz96
Sorry, I forgot to ask you the other files, can you paste them as well in pastebin? :rolleyes:
Re: Need help immediately, automatic referral system!!!!
functions.php: http://pastebin.com/5eN1ZMC8
r.php: http://pastebin.com/9drApFDJ (What im aware of I dont think the problem is with r.php as it seems to do its job fine but I cant be certain)
Re: Need help immediately, automatic referral system!!!!
Quote:
Originally Posted by
Habbz96
Can you tell me the full path til he actual register? For instance:
User clicks some sort of link in link.php and then gets redirected to register.php, as soon as he fill the fields and click the form button, page gets blank
Re: Need help immediately, automatic referral system!!!!
Yeh for example, user clicks http://habbz.servequake.com/r.php?user=Alex then gets redirected to http://habbz.servequake.com/register.php then after filling out register and submitting the form they get redirected to http://habbz.servequake.com/register_submit.php then that redirects instantly or should do to http://habbz.servequake.com/me.php but in my case if a user signs up by clicking a referral point it freezes on a white screen at http://habbz.servequake.com/register_submit.php untill you refresh the page then it redirects to http://habbz.servequake.com/me.php but doesnt reward referral point other than that if they sign up without clicking referral link it seems to work fine.
Thanks for your help, greatly appreciated!!!! :kiss:
Re: Need help immediately, automatic referral system!!!!
Quote:
Originally Posted by
Habbz96
Again, I didn't test it, so this is all about testing, try to replace this (register_submit.php):
PHP Code:
if($user->register_now())
To:
PHP Code:
if($user->register_now() == true)
Re: Need help immediately, automatic referral system!!!!
That didnt work, does exactly the same thing and freezes with white screen on register_submit.php.
Re: Need help immediately, automatic referral system!!!!
PHP Code:
<?php/* #################################################################### \|| |||| TwinkieCMS - Use of this software is strictly prohibited. *#|| # Copyright (C) 2014 lD@vidl. *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo. *#|| Tanto el script como los autores del mismo no tienen ningún tipo *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no *#|| se hacen responsables del uso que el usuario le dé. *#|| ||\ ################################################################### */ob_start(); require_once 'inc/core.php'; if($user->register_now()) { echo "This would work"; } else { echo "This wouldn't work"; }ob_end_flush(); ?>
Replace your register_submit.php to this, what does it displays?
Re: Need help immediately, automatic referral system!!!!
It just displays:
register_now()) { echo "This would work"; } else { echo "This wouldn't work"; }ob_end_flush(); ?>
could u try pasting it in pastebin so its formatted correctly.