Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 6th July 2012, 23:02
rootKID rootKID is offline
VIP
 
Join Date: Jan 2012
P2P
Posts: 99
Question where to find $CURUSER where it being created?...
ok
im using latest (TBdev 09 source).

and im aware ''as far as i have seemed'' that when i login, there should be created a variable... i think

but my questions is, where to change ect?... im trying to convert some of it into my own web-tracker project, and would like to know where to look for it, and a explain on where its going to be created

thanks

that, orr could it be a function inside user-functions?

thanks in advance dudes... :).
Reply With Quote
  #2  
Old 6th July 2012, 23:43
Bigjoos's Avatar
Bigjoos Bigjoos is offline
U-232 Dev
 
Join Date: May 2008
United Kingdom
Posts: 244
Default
user_login function on bittorrent.php creates the $CURUSER array, your select query selects all fields from users table so at any point over the source code you can use $CURUSER[' whatever variable name from users here '] anywhere over your source code and pull your values. If they are not in the select query you cant use it in $CURUSER as it wont exist, if your selecting all then that explains itself.
Reply With Quote
  #3  
Old 7th July 2012, 10:53
rootKID rootKID is offline
VIP
 
Join Date: Jan 2012
P2P
Posts: 99
Smile
okay, thanks... i got it now i think :)

just that im trying to build up the same way as TBdev was builded... a global design from the file bittorrent.php inside the include folder... but each time im trying to login, then i just can't login... and i know this because of that when im logging in, then its supposed to send me to the index.php part... and it does not do that

and i also on index.php have a loggedinorreturn function, same as tbdev 09 had

ideas?

tell me if you need the files to look into it if you wish
elseway shoot away on what part i should be looking at
thanks :)
Reply With Quote
  #4  
Old 7th July 2012, 15:57
Joe Joe is offline
Senior Member
 
Join Date: Apr 2010
P2P
Posts: 167
Default
If you use it like this if ($CURUSER ) {
test here
}

It will hide everything

or

if ($CURUSER['class'] >= UC_POWER_USER) {
$htmlout .=" shit here ";
}

This will make so you need to be a power user or above to see anything..

I hope it helps yeah But maybe Bigjoos can tell it better
Reply With Quote
  #5  
Old 7th July 2012, 19:55
rootKID rootKID is offline
VIP
 
Join Date: Jan 2012
P2P
Posts: 99
Smile
okay, thanks... just one question,

what do i need to edit if i wish to put more users into the tracker?...

i mean, i know i have to define them inside config, but i also know that i need to define them other places... where would that be to be exact?... thanks :)...

EDIT:

this is the login.php page:

PHP Code:
<?php
require_once("include/bittorrent.php");
echo 
stdhead("Login");
?>





<form method="post" action="takelogin.php">
<table class="login_table" align="center" border="1">

<tr>
<td>Username</td>
<td><input type="text" name="username" id="username" size="35" /></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="password" id="password" size="35" /></td>
</tr>

<tr>
<td align="center" colspan="2"><input type="submit" name="login_submit" value="Login Now!" /></td>
</tr>

</table>
</form>





<?php
echo stdfooter();
?>

and this is the takelogin.php page:

PHP Code:
<?php
require_once 'include/bittorrent.php';
require_once 
"include/password_functions.php";
echo 
stdhead("Login");

if (!
mkglobal('username:password'))
die();
$lang array_merge(load_language('takelogin'));


$res mysql_query("SELECT id, passhash, secret, enabled FROM users WHERE username = " sqlesc($username) . " AND status = 'confirmed'");
$row mysql_fetch_assoc($res);

if (!
$row)
stderr($lang['tlogin_failed'], 'Username or password incorrect');

if (
$row['passhash'] != make_passhash($row['secret'], md5($password)))
stderr($lang['tlogin_failed'], 'Username or password incorrect');

if (
$row['enabled'] == 'no')
stderr($lang['tlogin_failed'], $lang['tlogin_disabled']);

logincookie($row['id'], $row['passhash']);

header("Location: {$SS['baseurl']}/index.php");

echo 
stdfooter();
?>
and inside bittorrent.php userlogin:

PHP Code:
function userlogin() {
global 
$SS;
unset(
$GLOBALS["CURUSER"]);

$ip getip();
$nip ip2long($ip);

require_once 
"cache/bans_cache.php";
if(
count($bans) > 0)
{
    foreach(
$bans as $k) {
        if(
$nip >= $k['first'] && $nip <= $k['last']) {
        
header("HTTP/1.0 403 Forbidden");
        print 
"<html><body><h1>403 Forbidden</h1>Unauthorized IP address. Please, piss off... you had your chance.</body></html>\n";
        exit();
        }
    }
    unset(
$bans);
}
if (!
$SS['site_online'] || !get_mycookie('uid') || !get_mycookie('pass'))
    return;
$id get_mycookie('uid');
if (!
$id || strlenget_mycookie('pass') ) != 32)
    return;
$res mysql_query("SELECT * FROM users WHERE id = $id AND enabled='yes' AND status = 'confirmed'");// or die(mysql_error());
$row mysql_fetch_assoc($res);
if (!
$row)
    return;

if (
get_mycookie('pass') !== $row["passhash"])
    return;
mysql_query("UPDATE users SET last_access='" TIME_NOW "', ip=".sqlesc($ip)." WHERE id=" $row["id"]);// or die(mysql_error());
$row['ip'] = $ip;
$GLOBALS["CURUSER"] = $row;

ideas?...
PS: is userlogin the only thing i need to get the login page to work? 'O_o...

Last edited by rootKID; 7th July 2012 at 20:17.
Reply With Quote
  #6  
Old 7th July 2012, 20:57
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Quote:
Originally Posted by Joe View Post
If you use it like this if ($CURUSER ) {
test here
}

It will hide everything

or

if ($CUR USER['class'] >= UC_POWER_USER) {
$htmlout .=" shit here ";
}

This will make so you need to be a power user or above to see anything..

I hope it helps yeah But maybe Bigjoos can tell it better
You can also do this

PHP Code:
if ($CUR USER['class'] >= UC_POWER_USER) {
    $htmlout .="     shit here ";
    }
else{
?>
<h1>Everyone will see...</h1>
<?
}
?>
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
  #7  
Old 8th July 2012, 09:48
rootKID rootKID is offline
VIP
 
Join Date: Jan 2012
P2P
Posts: 99
Smile
i know that part... just that i really need the login to work...

ideas?...
Reply With Quote
  #8  
Old 8th July 2012, 16:20
LeeHowarth LeeHowarth is offline
TT
 
Join Date: Nov 2008
Posts: 100
Default
You said your working on a new sourcecode... if you don't understand the principles of TBDev then your going to have your work cut out.

I strongly advise not to copy TBDev if your going to be using CakePHP, well i strongly advise not to use CakePHP either.

Why?

TBDev is light compared to CakePHP so you should follow the same approach, how it works in most tracker software is a user logins in via the login page a cookie is set with something that can identify a sole user then a redirection...

The redirection forces the userlogin to be called again but this time you have a cookie so it will attempt to get the data associated with what was set.
Reply With Quote
  #9  
Old 8th July 2012, 23:16
rootKID rootKID is offline
VIP
 
Join Date: Jan 2012
P2P
Posts: 99
Smile
EDIT:

here is my bittorrent.php login functions:

PHP Code:
/*LOGIN FUNCTIONS*/
function logincookie($id$passhash$updatedb 1$expires 0x7fffffff)
{
    
set_mycookie"uid"$id$expires );
    
set_mycookie"pass"$passhash$expires );

    if (
$updatedb)
        @
mysql_query("UPDATE users SET last_login = ".TIME_NOW." WHERE id = $id");
}

function 
set_mycookie$name$value=""$expires_in=0$sticky=)
    {
        global 
$SS;

        if ( 
$sticky == )
    {
        
$expires time() + 60*60*24*365;
    }
        else if ( 
$expires_in )
        {
            
$expires time() + ( $expires_in 86400 );
        }
        else
        {
            
$expires FALSE;
        }

        
$SS['cookie_domain'] = $SS['cookie_domain'] == "" ""  $SS['cookie_domain'];
        
$SS['cookie_path']   = $SS['cookie_path']   == "" "/" $SS['cookie_path'];

        if ( 
PHP_VERSION 5.2 )
        {
        if ( 
$SS['cookie_domain'] )
        {
        @
setcookie$SS['cookie_prefix'].$name$value$expires$SS['cookie_path'], $SS['cookie_domain'] . '; HttpOnly' );
        }
        else
        {
        @
setcookie$SS['cookie_prefix'].$name$value$expires$SS['cookie_path'] );
        }
    }
    else
    {
        @
setcookie$SS['cookie_prefix'].$name$value$expires$SS['cookie_path'], $SS['cookie_domain'], NULLTRUE );
    }
}

function 
logoutcookie() {
    
set_mycookie('uid''-1');
    
set_mycookie('pass''-1');
}

function 
loggedinorreturn() {
    global 
$CURUSER$SS;
    if (!
$CURUSER
    {
        
header("Location: {$SS['baseurl']}/login.php?returnto=" urlencode($_SERVER["REQUEST_URI"]));
        exit();
    }
}

function 
get_mycookie($name)
{
    global 
$SS;

        if (isset(
$_COOKIE[$SS['cookie_prefix'].$name]) AND !empty($_COOKIE[$SS['cookie_prefix'].$name]))
        {
            return 
urldecode($_COOKIE[$SS['cookie_prefix'].$name]);
        }
        else
        {
            return 
FALSE;
        }
}

function 
userlogin() {
global 
$SS;
unset(
$GLOBALS["CURUSER"]);

$ip getip();
$nip ip2long($ip);

require_once 
"cache/bans_cache.php";
if(
count($bans) > 0)
{
    foreach(
$bans as $k) {
        if(
$nip >= $k['first'] && $nip <= $k['last']) {
        
header("HTTP/1.0 403 Forbidden");
        print 
"<html><body><h1>403 Forbidden</h1>Unauthorized IP address. Please, piss off... you had your chance.</body></html>\n";
        exit();
        }
    }
    unset(
$bans);
}
if (!
$SS['site_online'] || !get_mycookie('uid') || !get_mycookie('pass'))
    return;
$id get_mycookie('uid');
if (!
$id || strlenget_mycookie('pass') ) != 32)
    return;
$res mysql_query("SELECT * FROM users WHERE id = $id AND enabled='yes' AND status = 'confirmed'");// or die(mysql_error());
$row mysql_fetch_assoc($res);
if (!
$row)
    return;

if (
get_mycookie('pass') !== $row["passhash"])
    return;
mysql_query("UPDATE users SET last_access='" TIME_NOW "', ip=".sqlesc($ip)." WHERE id=" $row["id"]);// or die(mysql_error());
$row['ip'] = $ip;
$GLOBALS["CURUSER"] = $row;
}

function 
mkglobal($vars) {
if (!
is_array($vars))
    
$vars explode(":"$vars);
foreach (
$vars as $v) {
    if (isset(
$_GET[$v]))
        
$GLOBALS[$v] = unesc($_GET[$v]);
    elseif (isset(
$_POST[$v]))
        
$GLOBALS[$v] = unesc($_POST[$v]);
    else
        return 
0;
}
return 
1;
}

function 
sqlesc($x) {
    return 
"'".mysql_real_escape_string($x)."'";
}
/*LOGIN FUNCTIONS*/ 

and here is my login.php file:

PHP Code:
<?php
require_once("include/bittorrent.php");
echo 
stdhead("Login");
?>





<form method="post" action="takelogin.php">
<table class="login_table" align="center" border="1">

<tr>
<td>Username</td>
<td><input type="text" name="username" id="username" size="35" /></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="password" id="password" size="35" /></td>
</tr>

<tr>
<td align="center" colspan="2"><input type="submit" name="login_submit" value="Login Now!" /></td>
</tr>

</table>
</form>





<?php
echo stdfooter();
?>


and this is my takelogin.php file:

PHP Code:
<?php
require_once 'include/bittorrent.php';
require_once 
"include/password_functions.php";
echo 
stdhead("Login");

if (!
mkglobal('username:password'))
die();

$lang array_merge(load_language('takelogin'));

$res mysql_query("SELECT id, passhash, secret, enabled FROM users WHERE username = " sqlesc($username) . " AND status = 'confirmed'");
$row mysql_fetch_assoc($res);

if (!
$row)
stderr($lang['tlogin_failed'], 'Username or password incorrect');

if (
$row['passhash'] != make_passhash($row['secret'], md5($password)))
stderr($lang['tlogin_failed'], 'Username or password incorrect');

if (
$row['enabled'] == 'no')
stderr($lang['tlogin_failed'], $lang['tlogin_disabled']);

logincookie($row['id'], $row['passhash']);

header("Location: {$SS['baseurl']}/index.php");

echo 
stdfooter();
?>
and at last, then this is my password_functions.php file:

PHP Code:
<?php
function mksecret($len=5)
    {
        
$salt '';
        
        for ( 
$i 0$i $len$i++ )
        {
            
$num   rand(33126);
            
            if ( 
$num == '92' )
            {
                
$num 93;
            }
            
            
$salt .= chr$num );
        }
        
        return 
$salt;
    }
    


function 
make_passhash_login_key($len=60)
    {
        
$pass mksecret$len );
        
        return 
md5($pass);
    }
    


function 
make_passhash($salt$md5_once_password)
    {
        return 
md5md5$salt ) . $md5_once_password );
    }
    


function 
make_password()
    {
        
$pass "";
        
        
$unique_id     uniqidmt_rand(), TRUE );
        
$prefix        mksecret();
        
$unique_id .= md5$prefix );
        
        
usleepmt_rand(15000,1000000) );
        
        
mt_srand( (double)microtime()*1000000 );
        
$new_uniqueid uniqidmt_rand(), TRUE );
        
        
$final_rand md5$unique_id.$new_uniqueid );
        
        
mt_srand();
        
        for (
$i 0$i 15$i++)
        {
            
$pass .= $final_randmt_rand(031) };
        }
    
        return 
$pass;
  }
    



?>
can you help me understand this a little bit... i mean, i do understand what you are doing and meaning with what you said to me... but i still can't think this one out on how to fix :/...

thanks in advance...

Bump: seriously... no one?...
i have can you at least tell me if i need somfthing...

just that i think i have it all, and still wont work -.-'...

Bump: hello again, a test can be viewed here: http://www.speed-scene.com/personal_sites/ssv1/speedscene/login.php

:)...

Last edited by rootKID; 9th July 2012 at 09:00.
Reply With Quote
Reply

Tags
$curuser , created , find

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 18:19. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.