Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Disabling Sign Ups / Invite Only (http://www.bvlist.com/showthread.php?t=9859)

gh0st 5th April 2014 20:35

Disabling Sign Ups / Invite Only
 
Hey guys. I recently just installed TBdev (TBDev.2009(Final).rev.295) on my CentOS/Apache server and it seems to be running fine so far. The only problem I'm running into is the extreme lack of Admin control and functionality. I do see the "Admin" link, but the controls listed are very few.

One of the most important things I'd like to implement on my tracker is the ability to either (1) close sign ups and use an invite system or (2) disable registration altogether and only I would be able to add users manually. However I don't see anything where I can change that within the Admin control panel and I'm not sure if I'm supposed to add/edit code in one of the PHP files to accomplish this.

If anyone could assist, that would be most helpful! Thanks.

Krypto 5th April 2014 21:53

In include/config.php you just need to change the value of the below.

Code:

$TBDEV['maxusers'] = 5000; // LoL Who we kiddin' here?
So if you didn't want to install the Invite Mod all you'd have to do is change the above value to 1, then you could just use the Add User in the Staff Section.

gh0st 5th April 2014 21:58

Hi Krypto, thanks for the reply! That's good to know I can just decrease the "maxusers" to accomplish what I'm looking for - however I'm interested in the "Invite Mod" you referred to...

Before making this, I searched the forums and the closest thing I could come up with is this thread (what costy22it posted), but right under that Bigjoos mentions that it wouldn't work. Do you mind pointing me in the right direction for this mod? Apparently my searching skills just suck.

";}



Or the old original code :
Code: PHP
  1. if ($CURUSER["class"] >= UC_MODERATOR && $user["invites"] > 0 || $user["id"] == $CURUSER["id"] && $user["invites"] > 0)

  2.     $HTMLOUT .="
\n";
  •     if ($CURUSER["class"] >= UC_MODERATOR && $user["invitedby"] > 0 || $user["id"] == $CURUSER["id"] && $user["invitedby"] > 0)

  •     {

  •     $invitedby = mysql_query("SELECT username FROM users WHERE id=$user[invitedby]");

  •     $invited_by2 = mysql_fetch_assoc($invitedby);

  •     $HTMLOUT .="
  • \n";
  •     }

  •     if ($CURUSER["class"] >= UC_MODERATOR && $user["invitees"] > 0 || $user["id"] == $CURUSER["id"] && $user["invitees"] > 0)

  •     {

  •     $compl = $user["invitees"];

  •     $compl_list = explode(" ", $compl);

  •     $arr = array();

  •     foreach($compl_list as $array_list)

  •     $arr[] = $array_list;

  •     $compl_arr = array_reverse($arr, TRUE);

  •     $f=0;

  •     foreach($compl_arr as $user_id)

  •     {

  •     $compl_user = mysql_query("SELECT id, username FROM users WHERE id='$user_id' and status='confirmed'");

  •     $compl_users = mysql_fetch_assoc($compl_user);

  •     if ($compl_users["id"] > 0)

  •     {

  •     $HTMLOUT .="
  • ";
  •     $f = 1;

  •     }

  •     if ($f == "1")

  •     break;

  •     }

  •     }



  • @File lang/en/lang_userdetails.php :
    Code: PHP
    1. 'userdetails_invites' => "Invites",

    2. 'userdetails_invitees' => "Invitees",

    3. 'userdetails_invby' => 'Invited by',





    /**
    * @file userdetails.php
    */

    staff section, set invite on or off & invite amount
    Code: PHP
    1. $HTMLOUT .= "
    \n";
  •       $HTMLOUT .= "
  • \n";




    /**
    * @file lang/en/lang_userdetails.php
    */

    lang_userdetails.php add
    Code: PHP
    1. 'userdetails_invright' => "Invite rights",

    2. 'userdetails_invites' => "Invites",

    3. 'userdetails_invby' => "Invited by",





    /**
    * @file modtask.php
    */
    Code: PHP
    1. // invite rights

    2.       if ((isset($_POST['invite_rights'])) && (($invite_rights = $_POST['invite_rights']) != $user['invite_rights'])){

    3.       if ($invite_rights == 'yes')

    4.       {

    5.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite rights enabled by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    6.       $msg = sqlesc("Your invite rights have been given back by " . htmlspecialchars($CURUSER['username']) . ". You can invite users again.");

    7.       $added = time();

    8.       mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    9.       }

    10.       elseif ($invite_rights == 'no'){

    11.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite rights disabled by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    12.       $msg = sqlesc("Your invite rights have been removed by " . htmlspecialchars($CURUSER['username']) . ", probably because you invited a bad user.");

    13.       $added = time();

    14.       mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    15.       }

    16.       $updateset[] = "invite_rights = " . sqlesc($invite_rights);

    17.       }

    18.       // change invite amount

    19.       if ((isset($_POST['invites'])) && (($invites = $_POST['invites']) != ($curinvites = $user['invites'])))

    20.       {

    21.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite amount changed to ".$invites." from ".$curinvites." by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    22.       $updateset[] = "invites = " . sqlesc($invites);

    23.       }




    /**
    * @file bittorrent.php ~lines 906-907 to display invites
    */
    Code: PHP
    1. "$IsDonor$warn  [/logout.php'>{$lang['gl_logout']}] $member_reputation".

    2.       "  Invites: /invite.php'>{$CURUSER['invites']}




    @ file config under :
    Code: PHP
    1. $TBDEV['invites'] = 3500; // LoL Who we kiddin' here?




    Add :
    Code: PHP
    1. $TBDEV['openreg'] = true; //==true=open, false = closed




    @ file signup.php under :
    Code: PHP
    1. $lang = array_merge( load_language('global'), load_language('signup') );




    add :
    Code: PHP
    1. if(!$TBDEV['openreg'])

    2.     stderr('Sorry', 'Invite only - Signups are closed presently');




    @ file takesignup.php under :
    Code: PHP
    1. $lang = array_merge( load_language('global'), load_language('takesignup') );




    add :
    Code: PHP
    1. if(!$TBDEV['openreg'])

    2.     stderr('Sorry', 'Invite only - Signups are closed presently');



    Then save upload the 4 files to root and that should be all.

    invite.php :

    Code: PHP

    1. /*

    2. +------------------------------------------------

    3. |  $Date$

    4. |  $Revision$ 09 Final

    5. |  $Invite

    6. |  $Author$ Neptune,Bigjoos

    7. |  $URL$

    8. +------------------------------------------------

    9. */

    10. require_once('include/bittorrent.php');

    11. require_once('include/user_functions.php');

    12. require_once('include/password_functions.php');

    13. dbconn();

    14. loggedinorreturn();

    15. $HTMLOUT ='';

    16. $sure ='';

    17. $lang = array_merge( load_language('global'), load_language('invite_code') );

    18. $do = (isset($_GET["do"]) ? $_GET["do"] : (isset($_POST["do"]) ? $_POST["do"] : ''));

    19. $valid_actions = array('create_invite', 'delete_invite', 'confirm_account', 'view_page', 'send_email');

    20. $do = (($do && in_array($do,$valid_actions,true)) ? $do : '') or header("Location: ?do=view_page");

    21. /**

    22. * @action Main Page

    23. */

    24. if ($do == 'view_page') {

    25. $query = myysql_query('SELECT * FROM users WHERE invitedby = '.sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

    26. $rows = mysql_num_rows($query);

    27. $HTMLOUT ='';

    28. $HTMLOUT .= "

    Joe 10th April 2014 05:19

    Have a try at this a sit was posted for the 09 source and I know pytn bigjjoes and pdq all used this along the way..


    Code:

    mproved & Safer Number Key Invite System By Neptune.
    Reworked for Tbdev 09
    Xhtml Valid

    The files are now up to date for 2009 final revision.

    /**
    * @sql
    */
    Code: SQL
    1. CREATE TABLE `invite_codes` (

    2.   `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,

    3.   `sender` INT(10) UNSIGNED NOT NULL DEFAULT '0',

    4.   `receiver` VARCHAR(32) NOT NULL DEFAULT '0',

    5.   `code` VARCHAR(32) NOT NULL DEFAULT '',

    6.   `invite_added` INT(10) NOT NULL,

    7.   `status` enum('Pending','Confirmed') NOT NULL DEFAULT 'Pending',

    8.   PRIMARY KEY  (`id`),

    9.   KEY `sender` (`id`)

    10. ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

    11. ALTER TABLE `users` ADD `invites` INT(10) UNSIGNED NOT NULL DEFAULT '1';

    12. ALTER TABLE `users` ADD `invitedby` INT(10) UNSIGNED NOT NULL DEFAULT '0';

    13. ALTER TABLE `users` ADD `invite_rights` enum('yes','no') NOT NULL DEFAULT 'yes';

    14. ALTER TABLE `users` ADD `invitees` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';



    /**
    * @file config.php
    */

    add after maxusers
    Code: PHP
    1. $TBDEV['invites'] = 3500; // set this to what you want




    /**
    * @file userdetails.php
    */

    for displaying invitees
    Code: PHP
    1. if ($CURUSER['class'] >= UC_MODERATOR && $user['invitedby'] > 0 || $user['id'] == $CURUSER['id'] && $user['invitedby'] > 0) {

    2.       $invitedby = mysql_query('SELECT username FROM users WHERE id = ' . sqlesc($user['invitedby']));

    3.       $invitedby2 = mysql_fetch_array($invitedby);

    4.       $HTMLOUT .= "
    {$lang['userdetails_invby']}/userdetails.php?id=".$user['invitedby']."'>'".htmlspecialchars($invitedby2['username'])."'
    {$lang['userdetails_invites']}/invite.php'>".htmlspecialchars($user["invites"])."
    {$lang['userdetails_invby']}invited by/userdetails.php?id=$user[invitedby]'>$invited_by2[username]
    {$lang['userdetails_invitees']}";
  •     $compl = $user["invitees"];

  •     $compl_list = explode(" ", $compl);

  •     $arr = array();

  •     foreach($compl_list as $array_list)

  •     $arr[] = $array_list;

  •     $compl_arr = array_reverse($arr, TRUE);

  •     $i = 0;

  •     foreach($compl_arr as $user_id)

  •     {

  •     $compl_user = mysql_query("SELECT id, username FROM users WHERE id='$user_id' and status='confirmed' ORDER BY username");

  •     $compl_users = mysql_fetch_assoc($compl_user);

  •     $HTMLOUT .="/userdetails.php?id=" . $compl_users["id"] . "'>" . $compl_users["username"] . " ";

  •     if ($i == "9")

  •     break;

  •     $i++;

  •     }

  •     $HTMLOUT .="
  • {$lang['userdetails_invright']} .($user["invite_rights"]=="yes" ? " checked='checked'" : "") . " />{$lang['userdetails_yes']} .($user["invite_rights"]=="no" ? " checked='checked'" : "") . " />{$lang['userdetails_no']}
    {$lang['userdetails_invites']}]) . "' />


  • ";
  • if(!$rows){

  • $HTMLOUT .= "
  • ";
  • } else {

  • $HTMLOUT .= "







  • ";
  • for ($i = 0; $i < $rows; ++$i) {

  • $arr = mysql_fetch_assoc($query);

  • if ($arr['status'] == 'pending')

  • $user = "
  • ";
  • else

  • $user = "
  • ";
  • if ($arr['downloaded'] > 0) {

  • $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3);

  • $ratio = "".$ratio."";

  • } else {

  • if ($arr['uploaded'] > 0) {

  • $ratio = 'Inf.';

  • }

  • else {

  • $ratio = '---';

  • }

  • }

  • if ($arr["status"] == 'confirmed')

  • $status = "{$lang['invites_confirm1']}";

  • else

  • $status = "{$lang['invites_pend']}";

  • $HTMLOUT .= "
  • ".$user."";
  • if ($arr['status'] == 'pending') {

  • $HTMLOUT .= "
  • ";
  • }

  • else

  • $HTMLOUT .= "
  • ";
  • }

  • }

  • $HTMLOUT .= "
  • {$lang['invites_users']}
    {$lang['invites_nousers']}
    {$lang['invites_username']}{$lang['invites_uploaded']}{$lang['invites_downloaded']}{$lang['invites_ratio']}{$lang['invites_status']}{$lang['invites_confirm']}
    " . htmlspecialchars($arr['username']) . "/userdetails.php?id=$arr[id]'>" . htmlspecialchars($arr['username']) . "" .($arr["warned"] == "yes" ? warned.gif' border='0' alt='Warned' />" : "")." " .($arr["enabled"] == "no" ? disabled.gif' border='0' alt='Disabled' />" : "")." " .($arr["donor"] == "yes" ? "star.gif' border='0' alt='Donor' />" : "")."
    " . mksize($arr['uploaded']) . "" . mksize($arr['downloaded']) . "".$ratio."".$status."]."&sender=".$CURUSER['id']."'>confirm.png' alt='confirm' title='Confirm' border='0' />
    ---
    ";
  • $select = mysql_query("SELECT * FROM invite_codes WHERE sender = ".$CURUSER['id']." AND status = 'Pending'") or sqlerr();

  • $num_row = mysql_num_rows($select);

  • $HTMLOUT .= ""."";
  • if(!$num_row) {

  • $HTMLOUT.= "
  • ";
  • } else {

  • $HTMLOUT .= "
  • ";
  • for ($i = 0; $i < $num_row; ++$i)

  • {

  • $fetch_assoc = mysql_fetch_assoc($select);

  • $HTMLOUT .= "


  • ";
  • $HTMLOUT .= "

  • ";
  • }

  • }

  • $HTMLOUT .= "
  • ";
  • $HTMLOUT .= "
  • {$lang['invites_codes']}
    {$lang['invites_nocodes']}
    {$lang['invites_send_code']}{$lang['invites_date']}{$lang['invites_delete']}{$lang['invites_status']}
    ".$fetch_assoc['code']." ]."'>email.gif' border='0' alt='Email' title='Send Email' /> " . get_date($fetch_assoc['invite_added'], '', 0,1)." ]."&sender=".$CURUSER['id']."'>del.png' border='0' alt='Delete'/> ".$fetch_assoc['status']."
    ' style='height: 20px' />
    ";

  • print stdhead('Invites') . $HTMLOUT . stdfoot();

  • die;

  • }

  • /**

  • * @action Create Invites

  • */

  • elseif ($do =='create_invite') {

  • if ($CURUSER['invites'] <= 0)

  • stderr($lang['invites_error'], $lang['invites_noinvite']);

  • if ($CURUSER["invite_rights"] == 'no')

  • stderr($lang['invites_deny'], $lang['invites_disabled']);

  • $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);

  • $arr = mysql_fetch_row($res);

  • if ($arr[0] >= $TBDEV['invites'])

  • stderr($lang['invites_error'], $lang['invites_limit']);

  • $invite = md5(mksecret());

  • mysql_query('INSERT INTO invite_codes (sender, invite_added, code) VALUES ( ' . sqlesc((int)$CURUSER['id']) . ', ' . sqlesc(time()) . ', ' . sqlesc($invite) . ' )') or sqlerr(__FILE__, __LINE__);

  • mysql_query('UPDATE users SET invites = invites - 1 WHERE id = ' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

  • header("Location: ?do=view_page");

  • }

  • /**

  • * @action Send e-mail

  • */

  • elseif ($do =='send_email') {

  • if ($_SERVER["REQUEST_METHOD"] == "POST") {

  • $email = (isset($_POST['email'])? htmlentities($_POST['email']) : '');

  • $invite = (isset($_POST['code'])? $_POST['code'] : '');

  • if (!$email) stderr($lang['invites_error'], $lang['invites_noemail']);

  • $check = (mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM users WHERE email = ' . sqlesc($email)))) or sqlerr(__FILE__, __LINE__);

  • if ($check[0] != 0) stderr('Error', 'This email address is already in use!');

  • if (!validemail($email)) stderr($lang['invites_error'], $lang['invites_invalidemail']);

  • $inviter = htmlspecialchars($CURUSER['username']);

  • $body = <<

  • You have been invited to {$TBDEV['site_name']} by $inviter. They have

  • specified this address ($email) as your email. If you do not know this person, please ignore this email. Please do not reply.

  • This is a private site and you must agree to the rules before you can enter:

  • {$TBDEV['baseurl']}/useragreement.php

  • {$TBDEV['baseurl']}/rules.php

  • {$TBDEV['baseurl']}/faq.php

  • ------------------------------------------------------------

  • To confirm your invitation, you have to follow this link and type the invite code:

  • {$TBDEV['baseurl']}/invite_signup.php

  • Invite Code: $invite

  • ------------------------------------------------------------

  • After you do this, your inviter need's to confirm your account.

  • We urge you to read the RULES and FAQ before you start using {$TBDEV['site_name']}.

  • EOD;

  • $sendit = mail($email, "You have been invited to {$TBDEV['site_name']}", $body, "From: {$TBDEV['site_email']}", "-f{$TBDEV['site_email']}");

  • if (!$sendit) stderr($lang['invites_error'], $lang['invites_unable']);

  • else stderr('', $lang['invites_confirmation']); }

  • $id = (isset($_GET['id']) ? (int)$_GET['id'] : (isset($_POST['id']) ? (int)$_POST['id'] : ''));

  • if (!is_valid_id($id)) stderr($lang['invites_error'], $lang['invites_invalid']);

  • $query = mysql_query('SELECT * FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender = ' . sqlesc($CURUSER['id']).' AND status = "Pending"') or sqlerr(__FILE__, __LINE__);

  • $fetch = mysql_fetch_assoc($query) or stderr($lang['invites_error'], $lang['invites_noexsist']);

  • $HTMLOUT .= "

  • E-Mail]."'  />
    ";

  • print stdhead('Invites') . $HTMLOUT . stdfoot();

  • }

  • /**

  • * @action Delete Invites

  • */

  • elseif ($do =='delete_invite') {

  • $id = (isset($_GET["id"]) ? (int)$_GET["id"] : (isset($_POST["id"]) ? (int)$_POST["id"] : ''));

  • $query = mysql_query('SELECT * FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender = ' . sqlesc($CURUSER['id']).' AND status = "Pending"') or sqlerr(__FILE__, __LINE__);

  • $assoc = mysql_fetch_assoc($query);

  • if (!$assoc)

  • stderr($lang['invites_error'],$lang['invites_noexsist']);

  • isset($_GET['sure']) && $sure = htmlspecialchars($_GET['sure']);

  • if (!$sure)

  • stderr($lang['invites_delete1'], $lang['invites_sure'].' Click .$_SERVER['PHP_SELF'].'?do=delete_invite&id='.$id.'&sender='.$CURUSER['id'].'&sure=yes">here to delete it or here to go back.');

  • mysql_query('DELETE FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender =' . sqlesc($CURUSER['id'].' AND status = "Pending"')) or sqlerr(__FILE__, __LINE__);

  • mysql_query('UPDATE users SET invites = invites + 1 WHERE id = '.sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

  • header("Location: ?do=view_page");

  • }

  • /**

  • * @action Confirm Accounts

  • */

  • elseif ($do ='confirm_account') {

  • $userid = (isset($_GET["userid"]) ? (int)$_GET["userid"] : (isset($_POST["userid"]) ? (int)$_POST["userid"] : ''));

  • if (!is_valid_id($userid))

  • stderr($lang['invites_error'], $lang['invites_invalid']);

  • $select = mysql_query('SELECT id, username FROM users WHERE id = ' . sqlesc($userid) . ' AND invitedby = ' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

  • $assoc = mysql_fetch_assoc($select);

  • if (!$assoc)

  • stderr($lang['invites_error'], $lang['invites_errorid']);

  • isset($_GET['sure']) && $sure = htmlspecialchars($_GET['sure']);

  • if (!$sure)

  • stderr($lang['invites_confirm1'], $lang['invites_sure1'].' '.htmlspecialchars($assoc['username']).'\'s account? Click .$userid.'&sender='.$CURUSER['id'].'&sure=yes">here to confirm it or here to go back.');

  • mysql_query('UPDATE users SET status = "confirmed" WHERE id = '.sqlesc($userid).' AND invitedby = '.sqlesc($CURUSER['id']).' AND status="pending"') or sqlerr(__FILE__, __LINE__);

  • //==pm to new invitee/////

  • $msg = sqlesc("Hey there :wave:

  • Welcome to {$TBDEV['site_name']}!

  • We have made many changes to the site, and we hope you enjoy them!

  • We have been working hard to make {$TBDEV['site_name']} somethin' special!

  • {$TBDEV['site_name']} has a strong community (just check out forums), and is a feature rich site. We hope you'll join in on all the fun!

  • Be sure to read the {$TBDEV['baseurl']}/rules.php]Rules and {$TBDEV['baseurl']}[/COLOR]/faq.php]FAQ before you start using the site.[/COLOR]

  • We are a strong friendly community here {$TBDEV['site_name']} is so much more then just torrents.

  • Just for kicks, we've started you out with 200.0 Karma Bonus  Points, and a couple of bonus GB to get ya started!

  • so, enjoy 

  • cheers,

  • {$TBDEV['site_name']} Staff");

  • $id = $assoc["id"];

  • $subject = sqlesc("Welcome to {$TBDEV['site_name']} !");

  • $added = sqlesc(time());

  • mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $id, $msg, $added)") or sqlerr(__FILE__, __LINE__);

  • ///////////////////end////////////

  • header("Location: ?do=view_page");

  • }

  • ?>



  • invite_signup.php :

    Code: [Select]
    require_once('include/bittorrent.php');
    require_once(
    'include/user_functions.php');
    require_once(
    'cache/timezones.php');
    require_once(
    'include/page_verify.php');
    dbconn();
    get_template();

    $stdfoot = array(/** include js **/'js' => array('check','jquery.pstrength-min.1.2'));

    $lang = array_merge( load_language('global'), load_language('signup') );
    $newpage = new page_verify();
    $newpage->create('tkIs');

    $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_row($res);
    if (
    $arr[0] >= $TBDEV['maxusers'])
    stderr("Sorry", "The current user account limit (" . number_format($TBDEV['maxusers']) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...");

    if(!
    $TBDEV['openreg'])
       
    stderr('Sorry', 'Invite only - Signups are closed presently');

    // TIMEZONE STUFF
           
    $offset = (string)$TBDEV['time_offset'];
           
           
    $time_select = "";
       
    // TIMEZONE END

    $HTMLOUT='';

    $HTMLOUT .= "
        "
    ;
    // Normal Entry Point...
    $value = array('...','...','...','...','...','...');
    $value[rand(1,count($value)-1)] = 'X';
    $HTMLOUT .="
       
       

    Note: You need cookies enabled to sign up or log in.


    ]}/take_invite_signup.php'>







    ";
    //==Passhint
       
    $passhint="";
       
    $questions = array(
          array(
    "id"=> "1", "question"=> "{$lang['signup_q1']}"),
            array(
    "id"=> "2", "question"=> "{$lang['signup_q2']}"),
            array(
    "id"=> "3", "question"=> "{$lang['signup_q3']}"),
            array(
    "id"=> "4", "question"=> "{$lang['signup_q4']}"),
            array(
    "id"=> "5", "question"=> "{$lang['signup_q5']}"),
            array(
    "id"=> "6", "question"=> "{$lang['signup_q6']}"));
            foreach(
    $questions as $sph){ 
           
    $passhint .= "\n";
            }
           
    $HTMLOUT .= "

           




    Desired username:
    Pick a password:
    Enter password again:
    Enter invite-code:
    Email address:
    The email address must be valid. The email address won't be publicly shown anywhere unless you chose to from your settings.
    {$lang['signup_timez']}{$time_select}
    {$lang['signup_select']}
    {$lang['signup_enter']}{$lang['signup_this_answer']}{$lang['signup_this_answer1']}
    I will read the site rules page.
    I agree to read the FAQ before asking questions.
    I am at least 18 years old.
    Now click the button marked X to complete the sign up!
    ";
     for (
    $i=0; $i < count($value); $i++) {
     
    $HTMLOUT .= ".$value[$i]."\" class=\"btn\" />";
     }
     
    $HTMLOUT .= "
    ";

    print
    stdhead('Invites') . $HTMLOUT . stdfoot($stdfoot);
    ?>

    take_invite_signup.php :

    Code: PHP

    1. require_once('include/bittorrent.php');

    2. require_once('include/user_functions.php');

    3. require_once('include/password_functions.php');

    4. require_once('include/page_verify.php');

    5. dbconn();

    6. get_template();

    7. $lang = array_merge( load_language('global'), load_language('takesignup') );

    8. $newpage = new page_verify();

    9. $newpage->check('tkIs');

    10. $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);

    11. $arr = mysql_fetch_row($res);

    12. if ($arr[0] >= $TBDEV['maxusers'])

    13. stderr($lang['stderr_errorhead'], sprintf($lang['stderr_ulimit'], $TBDEV['maxusers']));

    14. if (!mkglobal("wantusername:wantpassword:passagain:email:invite:captchaSelection:submitme:passhint:hintanswer"))

    15. die();

    16. if ($submitme != 'X')

    17.   stderr('Ha Ha', 'You Missed, You plonker !');

    18. if(empty($captchaSelection) || $_SESSION['simpleCaptchaAnswer'] != $captchaSelection){

    19. header('Location: invite_signup.php');

    20. exit();

    21. }

    22. function validusername($username) {

    23. if ($username == "")

    24. return false;

    25. // The following characters are allowed in user names

    26. $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    27. for ($i = 0; $i < strlen($username); ++$i)

    28. if (strpos($allowedchars, $username[$i]) === false)

    29. return false;

    30. return true;

    31. }

    32. if (empty($wantusername) || empty($wantpassword) || empty($email) || empty($invite) || empty($passhint) || empty($hintanswer))

    33. stderr("Error","Don't leave any fields blank.");

    34. if(!blacklist($wantusername))

    35. stderr($lang['takesignup_user_error'],sprintf($lang['takesignup_badusername'],htmlspecialchars($wantusername)));

    36. if (strlen($wantusername) > 12)

    37. stderr("Error","Sorry, username is too long (max is 12 chars)");

    38. if ($wantpassword != $passagain)

    39. stderr("Error","The passwords didn't match! Must've typoed. Try again.");

    40. if (strlen($wantpassword) < 6)

    41. stderr("Error","Sorry, password is too short (min is 6 chars)");

    42. if (strlen($wantpassword) > 40)

    43. stderr("Error","Sorry, password is too long (max is 40 chars)");

    44. if ($wantpassword == $wantusername)

    45. stderr("Error","Sorry, password cannot be same as user name.");

    46. if (!validemail($email))

    47. stderr("Error","That doesn't look like a valid email address.");

    48. if (!validusername($wantusername))

    49. stderr("Error","Invalid username.");

    50. // make sure user agrees to everything...

    51. if ($_POST["rulesverify"] != "yes" || $_POST["faqverify"] != "yes" || $_POST["ageverify"] != "yes")

    52. stderr("Error","Sorry, you're not qualified to become a member of this site.");

    53. // check if email addy is already in use

    54. $a = (@mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM users WHERE email = ' . sqlesc($email)))) or die(mysql_error());

    55. if ($a[0] != 0)

    56. stderr('Error', 'The e-mail address ' . htmlspecialchars($email) . ' is already in use.');

    57. //=== check if ip addy is already in use

    58. $c = (@mysql_fetch_row(mysql_query("select count(*) from users where ip='" . $_SERVER['REMOTE_ADDR'] . "'"))) or die(mysql_error());

    59. if ($c[0] != 0)

    60. stderr("Error", "The ip " . $_SERVER['REMOTE_ADDR'] . " is already in use. We only allow one account per ip address.");

    61. // TIMEZONE STUFF

    62.     if(isset($_POST["user_timezone"]) && preg_match('#^\-?\d{1,2}(?:\.\d{1,2})?$#', $_POST['user_timezone']))

    63.     {

    64.     $time_offset = sqlesc($_POST['user_timezone']);

    65.     }

    66.     else

    67.     {

    68.     $time_offset = isset($TBDEV['time_offset']) ? sqlesc($TBDEV['time_offset']) : '0'; }

    69.     // have a stab at getting dst parameter?

    70.     $dst_in_use = localtime(time() + ($time_offset * 3600), true);

    71.     // TIMEZONE STUFF END

    72. $select_inv = mysql_query('SELECT sender, receiver, status FROM invite_codes WHERE code = ' . sqlesc($invite)) or die(mysql_error());

    73. $rows = mysql_num_rows($select_inv);

    74. $assoc = mysql_fetch_assoc($select_inv);

    75. if ($rows == 0)

    76. stderr("Error","Invite not found.\nPlease request a invite from one of our members.");

    77. if ($assoc["receiver"]!=0)

    78. stderr("Error","Invite already taken.\nPlease request a new one from your inviter.");

    79.     $secret = mksecret();

    80.     $wantpasshash = make_passhash( $secret, md5($wantpassword) );

    81.     $editsecret = ( !$arr[0] ? "" : make_passhash_login_key() );

    82.     $wanthintanswer = md5($hintanswer);

    83. $new_user = mysql_query("INSERT INTO users (username, passhash, secret, passhint, hintanswer, editsecret, invitedby, email, ". (!$arr[0]?"class, ":"") ."added, last_access, last_login, time_offset, dst_in_use) VALUES (" .

    84. implode(",", array_map("sqlesc", array($wantusername, $wantpasshash, $secret, $editsecret, $passhint, $wanthintanswer, (int)$assoc['sender'], $email))).

    85. ", ". (!$arr[0]?UC_SYSOP.", ":""). "'".  time() ."','".  time() ."','".  time() ."', $time_offset, {$dst_in_use['tm_isdst']})");

    86. $message = "Welcome New {$TBDEV['site_name']} Member : - " . htmlspecialchars($wantusername) . "";

    87. if (!$new_user) {

    88. if (mysql_errno() == 1062)

    89. stderr("Error","Username already exists!");

    90. stderr("Error","borked");

    91. }

    92. //===send PM to inviter

    93. $sender = $assoc["sender"];

    94. $added = sqlesc(time());

    95. $msg = sqlesc("Hey there [you] ! :wave:\nIt seems that someone you invited to {$TBDEV['site_name']} has arrived ! :clap2: \n\n Please go to your {$TBDEV['baseurl']}/invite.php]Invite page to confirm them so they can log in.\n\ncheers\n"[/COLOR]);

    96. $subject = sqlesc("Someone you invited has arrived!");

    97. mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $sender, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    98. //////////////end/////////////////////

    99. $id = mysql_insert_id();

    100. mysql_query('UPDATE invite_codes SET receiver = ' . sqlesc($id) . ', status = "Confirmed" WHERE sender = ' . sqlesc((int)$assoc['sender']). ' AND code = ' . sqlesc($invite)) or sqlerr(__FILE__, __LINE__);

    101. write_log('User account '.htmlspecialchars($wantusername).' was created!');

    102. autoshout($message);

    103. stderr('Success','Signup successfull, Your inviter needs to confirm your account now before you can use your account !');

    104. ?>



    lang_invite_code.php :

    Code: PHP

    1. $lang = array(

    2. #invite errors

    3. 'invites_error' => "Error",

    4. 'invites_deny' => "Denied",

    5. 'invites_limit' => "Sorry, user limit reached. Please try again later.",

    6. 'invites_disabled' => "Your invite sending privileges has been disabled by the Staff!",

    7. 'invites_noinvite' => "No invites !",

    8. 'invites_invalidemail' => "That doesn't look like a valid email address.",

    9. 'invites_noemail' => "You must enter an email address!",

    10. 'invites_unable' => "Unable to send mail. Please contact an administrator about this error.",

    11. 'invites_confirmation' => "A confirmation email has been sent to the address you specified.",

    12. 'invites_invalid' => "Invalid ID!",

    13. 'invites_noexsist' => "This invite code does not exist.",

    14. 'invites_sure' => "Are you sure you want to delete this invite code?",

    15. 'invites_errorid' => "No user with this ID.",

    16. 'invites_sure1' => "Are you sure you want to confirm",

    17. #invites

    18. 'invites_users' => "Invited Users",

    19. 'invites_nousers' => "No Invitees Yet",

    20. 'invites_username' => "Username",

    21. 'invites_uploaded' => "Uploaded",

    22. 'invites_downloaded' => "Downloaded",

    23. 'invites_ratio' => "Ratio",

    24. 'invites_status' => "Status",

    25. 'invites_confirm' => "Confirm",

    26. 'invites_confirm1' => "Confirmed",

    27. 'invites_pend' => "Pending",

    28. 'invites_codes' => "Created Invite Codes",

    29. 'invites_nocodes' => "You have not created any invite codes at the moment!",

    30. 'invites_date' => "Created Date",

    31. 'invites_delete' => "Delete",

    32. 'invites_create' => "Create Invite Code",

    33. 'invites_send_code' => "Send Invite Code",

    34. 'invites_delete1' => "Delete Invite",

    35. 'invites_confirm1' => "Confirmed Account",

    36. );

    37. ?>







    Bump: Have a try at this a sit was posted for the 09 source and I know pytn bigjjoes and pdq all used this along the way..


    Code:

    mproved & Safer Number Key Invite System By Neptune.
    Reworked for Tbdev 09
    Xhtml Valid

    The files are now up to date for 2009 final revision.

    /**
    * @sql
    */
    Code: SQL
    1. CREATE TABLE `invite_codes` (

    2.   `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,

    3.   `sender` INT(10) UNSIGNED NOT NULL DEFAULT '0',

    4.   `receiver` VARCHAR(32) NOT NULL DEFAULT '0',

    5.   `code` VARCHAR(32) NOT NULL DEFAULT '',

    6.   `invite_added` INT(10) NOT NULL,

    7.   `status` enum('Pending','Confirmed') NOT NULL DEFAULT 'Pending',

    8.   PRIMARY KEY  (`id`),

    9.   KEY `sender` (`id`)

    10. ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

    11. ALTER TABLE `users` ADD `invites` INT(10) UNSIGNED NOT NULL DEFAULT '1';

    12. ALTER TABLE `users` ADD `invitedby` INT(10) UNSIGNED NOT NULL DEFAULT '0';

    13. ALTER TABLE `users` ADD `invite_rights` enum('yes','no') NOT NULL DEFAULT 'yes';

    14. ALTER TABLE `users` ADD `invitees` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';



    /**
    * @file config.php
    */

    add after maxusers
    Code: PHP
    1. $TBDEV['invites'] = 3500; // set this to what you want




    /**
    * @file userdetails.php
    */

    for displaying invitees
    Code: PHP
    1. if ($CURUSER['class'] >= UC_MODERATOR && $user['invitedby'] > 0 || $user['id'] == $CURUSER['id'] && $user['invitedby'] > 0) {

    2.       $invitedby = mysql_query('SELECT username FROM users WHERE id = ' . sqlesc($user['invitedby']));

    3.       $invitedby2 = mysql_fetch_array($invitedby);

    4.       $HTMLOUT .= "{$lang['userdetails_invby']}/userdetails.php?id=".$user['invitedby']."'>'".htmlspecialchars($invitedby2['username'])."'"; }




    Or the old original code :
    Code: PHP
    1. if ($CURUSER["class"] >= UC_MODERATOR && $user["invites"] > 0 || $user["id"] == $CURUSER["id"] && $user["invites"] > 0)

    2.     $HTMLOUT .="{$lang['userdetails_invites']}/invite.php'>".htmlspecialchars($user["invites"])."\n";

    3.     if ($CURUSER["class"] >= UC_MODERATOR && $user["invitedby"] > 0 || $user["id"] == $CURUSER["id"] && $user["invitedby"] > 0)

    4.     {

    5.     $invitedby = mysql_query("SELECT username FROM users WHERE id=$user[invitedby]");

    6.     $invited_by2 = mysql_fetch_assoc($invitedby);

    7.     $HTMLOUT .="{$lang['userdetails_invby']}invited by/userdetails.php?id=$user[invitedby]'>$invited_by2[username]\n";

    8.     }

    9.     if ($CURUSER["class"] >= UC_MODERATOR && $user["invitees"] > 0 || $user["id"] == $CURUSER["id"] && $user["invitees"] > 0)

    10.     {

    11.     $compl = $user["invitees"];

    12.     $compl_list = explode(" ", $compl);

    13.     $arr = array();

    14.     foreach($compl_list as $array_list)

    15.     $arr[] = $array_list;

    16.     $compl_arr = array_reverse($arr, TRUE);

    17.     $f=0;

    18.     foreach($compl_arr as $user_id)

    19.     {

    20.     $compl_user = mysql_query("SELECT id, username FROM users WHERE id='$user_id' and status='confirmed'");

    21.     $compl_users = mysql_fetch_assoc($compl_user);

    22.     if ($compl_users["id"] > 0)

    23.     {

    24.     $HTMLOUT .="{$lang['userdetails_invitees']}";

    25.     $compl = $user["invitees"];

    26.     $compl_list = explode(" ", $compl);

    27.     $arr = array();

    28.     foreach($compl_list as $array_list)

    29.     $arr[] = $array_list;

    30.     $compl_arr = array_reverse($arr, TRUE);

    31.     $i = 0;

    32.     foreach($compl_arr as $user_id)

    33.     {

    34.     $compl_user = mysql_query("SELECT id, username FROM users WHERE id='$user_id' and status='confirmed' ORDER BY username");

    35.     $compl_users = mysql_fetch_assoc($compl_user);

    36.     $HTMLOUT .="/userdetails.php?id=" . $compl_users["id"] . "'>" . $compl_users["username"] . " ";

    37.     if ($i == "9")

    38.     break;

    39.     $i++;

    40.     }

    41.     $HTMLOUT .="";

    42.     $f = 1;

    43.     }

    44.     if ($f == "1")

    45.     break;

    46.     }

    47.     }



    @File lang/en/lang_userdetails.php :
    Code: PHP
    1. 'userdetails_invites' => "Invites",

    2. 'userdetails_invitees' => "Invitees",

    3. 'userdetails_invby' => 'Invited by',





    /**
    * @file userdetails.php
    */

    staff section, set invite on or off & invite amount
    Code: PHP
    1. $HTMLOUT .= "{$lang['userdetails_invright']} .($user["invite_rights"]=="yes" ? " checked='checked'" : "") . " />{$lang['userdetails_yes']} .($user["invite_rights"]=="no" ? " checked='checked'" : "") . " />{$lang['userdetails_no']}\n";

    2.       $HTMLOUT .= "{$lang['userdetails_invites']}]) . "' />\n";





    /**
    * @file lang/en/lang_userdetails.php
    */

    lang_userdetails.php add
    Code: PHP
    1. 'userdetails_invright' => "Invite rights",

    2. 'userdetails_invites' => "Invites",

    3. 'userdetails_invby' => "Invited by",





    /**
    * @file modtask.php
    */
    Code: PHP
    1. // invite rights

    2.       if ((isset($_POST['invite_rights'])) && (($invite_rights = $_POST['invite_rights']) != $user['invite_rights'])){

    3.       if ($invite_rights == 'yes')

    4.       {

    5.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite rights enabled by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    6.       $msg = sqlesc("Your invite rights have been given back by " . htmlspecialchars($CURUSER['username']) . ". You can invite users again.");

    7.       $added = time();

    8.       mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    9.       }

    10.       elseif ($invite_rights == 'no'){

    11.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite rights disabled by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    12.       $msg = sqlesc("Your invite rights have been removed by " . htmlspecialchars($CURUSER['username']) . ", probably because you invited a bad user.");

    13.       $added = time();

    14.       mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    15.       }

    16.       $updateset[] = "invite_rights = " . sqlesc($invite_rights);

    17.       }

    18.       // change invite amount

    19.       if ((isset($_POST['invites'])) && (($invites = $_POST['invites']) != ($curinvites = $user['invites'])))

    20.       {

    21.       $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite amount changed to ".$invites." from ".$curinvites." by " . htmlspecialchars($CURUSER['username']) . ".\n" . $modcomment;

    22.       $updateset[] = "invites = " . sqlesc($invites);

    23.       }




    /**
    * @file bittorrent.php ~lines 906-907 to display invites
    */
    Code: PHP
    1. "$IsDonor$warn  [/logout.php'>{$lang['gl_logout']}] $member_reputation".

    2.       "  Invites: /invite.php'>{$CURUSER['invites']}




    @ file config under :
    Code: PHP
    1. $TBDEV['invites'] = 3500; // LoL Who we kiddin' here?




    Add :
    Code: PHP
    1. $TBDEV['openreg'] = true; //==true=open, false = closed




    @ file signup.php under :
    Code: PHP
    1. $lang = array_merge( load_language('global'), load_language('signup') );




    add :
    Code: PHP
    1. if(!$TBDEV['openreg'])

    2.     stderr('Sorry', 'Invite only - Signups are closed presently');




    @ file takesignup.php under :
    Code: PHP
    1. $lang = array_merge( load_language('global'), load_language('takesignup') );




    add :
    Code: PHP
    1. if(!$TBDEV['openreg'])

    2.     stderr('Sorry', 'Invite only - Signups are closed presently');



    Then save upload the 4 files to root and that should be all.

    invite.php :

    Code: PHP

    1. /*

    2. +------------------------------------------------

    3. |  $Date$

    4. |  $Revision$ 09 Final

    5. |  $Invite

    6. |  $Author$ Neptune,Bigjoos

    7. |  $URL$

    8. +------------------------------------------------

    9. */

    10. require_once('include/bittorrent.php');

    11. require_once('include/user_functions.php');

    12. require_once('include/password_functions.php');

    13. dbconn();

    14. loggedinorreturn();

    15. $HTMLOUT ='';

    16. $sure ='';

    17. $lang = array_merge( load_language('global'), load_language('invite_code') );

    18. $do = (isset($_GET["do"]) ? $_GET["do"] : (isset($_POST["do"]) ? $_POST["do"] : ''));

    19. $valid_actions = array('create_invite', 'delete_invite', 'confirm_account', 'view_page', 'send_email');

    20. $do = (($do && in_array($do,$valid_actions,true)) ? $do : '') or header("Location: ?do=view_page");

    21. /**

    22. * @action Main Page

    23. */

    24. if ($do == 'view_page') {

    25. $query = myysql_query('SELECT * FROM users WHERE invitedby = '.sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

    26. $rows = mysql_num_rows($query);

    27. $HTMLOUT ='';

    28. $HTMLOUT .= "



    29. ";
    30. if(!$rows){

    31. $HTMLOUT .= "
    32. ";
    33. } else {

    34. $HTMLOUT .= "







    35. ";
    36. for ($i = 0; $i < $rows; ++$i) {

    37. $arr = mysql_fetch_assoc($query);

    38. if ($arr['status'] == 'pending')

    39. $user = "
    40. ";
    41. else

    42. $user = "
    43. ";
    44. if ($arr['downloaded'] > 0) {

    45. $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3);

    46. $ratio = "".$ratio."";

    47. } else {

    48. if ($arr['uploaded'] > 0) {

    49. $ratio = 'Inf.';

    50. }

    51. else {

    52. $ratio = '---';

    53. }

    54. }

    55. if ($arr["status"] == 'confirmed')

    56. $status = "{$lang['invites_confirm1']}";

    57. else

    58. $status = "{$lang['invites_pend']}";

    59. $HTMLOUT .= "
    60. ".$user."";
    61. if ($arr['status'] == 'pending') {

    62. $HTMLOUT .= "
    63. ";
    64. }

    65. else

    66. $HTMLOUT .= "
    67. ";
    68. }

    69. }

    70. $HTMLOUT .= "
    71. {$lang['invites_users']}
      {$lang['invites_nousers']}
      {$lang['invites_username']} {$lang['invites_uploaded']} {$lang['invites_downloaded']} {$lang['invites_ratio']} {$lang['invites_status']} {$lang['invites_confirm']}
      " . htmlspecialchars($arr['username']) . " /userdetails.php?id=$arr[id]'>" . htmlspecialchars($arr['username']) . "" .($arr["warned"] == "yes" ? warned.gif' border='0' alt='Warned' />" : "")." " .($arr["enabled"] == "no" ? disabled.gif' border='0' alt='Disabled' />" : "")." " .($arr["donor"] == "yes" ? "star.gif' border='0' alt='Donor' />" : "")."
      " . mksize($arr['uploaded']) . "" . mksize($arr['downloaded']) . "".$ratio."".$status." ]."&sender=".$CURUSER['id']."'>confirm.png' alt='confirm' title='Confirm' border='0' />
      ---
      ";

    72. $select = mysql_query("SELECT * FROM invite_codes WHERE sender = ".$CURUSER['id']." AND status = 'Pending'") or sqlerr();

    73. $num_row = mysql_num_rows($select);

    74. $HTMLOUT .= ""."";
    75. if(!$num_row) {

    76. $HTMLOUT.= "
    77. ";
    78. } else {

    79. $HTMLOUT .= "
    80. ";
    81. for ($i = 0; $i < $num_row; ++$i)

    82. {

    83. $fetch_assoc = mysql_fetch_assoc($select);

    84. $HTMLOUT .= "


    85. ";
    86. $HTMLOUT .= "

    87. ";
    88. }

    89. }

    90. $HTMLOUT .= "
    91. ";
    92. $HTMLOUT .= "
    93. {$lang['invites_codes']}
      {$lang['invites_nocodes']}
      {$lang['invites_send_code']}{$lang['invites_date']}{$lang['invites_delete']}{$lang['invites_status']}
      ".$fetch_assoc['code']." ]."'>email.gif' border='0' alt='Email' title='Send Email' /> " . get_date($fetch_assoc['invite_added'], '', 0,1)." ]."&sender=".$CURUSER['id']."'>del.png' border='0' alt='Delete'/> ".$fetch_assoc['status']."
      ' style='height: 20px' />
      ";

    94. print stdhead('Invites') . $HTMLOUT . stdfoot();

    95. die;

    96. }

    97. /**

    98. * @action Create Invites

    99. */

    100. elseif ($do =='create_invite') {

    101. if ($CURUSER['invites'] <= 0)

    102. stderr($lang['invites_error'], $lang['invites_noinvite']);

    103. if ($CURUSER["invite_rights"] == 'no')

    104. stderr($lang['invites_deny'], $lang['invites_disabled']);

    105. $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);

    106. $arr = mysql_fetch_row($res);

    107. if ($arr[0] >= $TBDEV['invites'])

    108. stderr($lang['invites_error'], $lang['invites_limit']);

    109. $invite = md5(mksecret());

    110. mysql_query('INSERT INTO invite_codes (sender, invite_added, code) VALUES ( ' . sqlesc((int)$CURUSER['id']) . ', ' . sqlesc(time()) . ', ' . sqlesc($invite) . ' )') or sqlerr(__FILE__, __LINE__);

    111. mysql_query('UPDATE users SET invites = invites - 1 WHERE id = ' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

    112. header("Location: ?do=view_page");

    113. }

    114. /**

    115. * @action Send e-mail

    116. */

    117. elseif ($do =='send_email') {

    118. if ($_SERVER["REQUEST_METHOD"] == "POST") {

    119. $email = (isset($_POST['email'])? htmlentities($_POST['email']) : '');

    120. $invite = (isset($_POST['code'])? $_POST['code'] : '');

    121. if (!$email) stderr($lang['invites_error'], $lang['invites_noemail']);

    122. $check = (mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM users WHERE email = ' . sqlesc($email)))) or sqlerr(__FILE__, __LINE__);

    123. if ($check[0] != 0) stderr('Error', 'This email address is already in use!');

    124. if (!validemail($email)) stderr($lang['invites_error'], $lang['invites_invalidemail']);

    125. $inviter = htmlspecialchars($CURUSER['username']);

    126. $body = <<

    127. You have been invited to {$TBDEV['site_name']} by $inviter. They have

    128. specified this address ($email) as your email. If you do not know this person, please ignore this email. Please do not reply.

    129. This is a private site and you must agree to the rules before you can enter:

    130. {$TBDEV['baseurl']}/useragreement.php

    131. {$TBDEV['baseurl']}/rules.php

    132. {$TBDEV['baseurl']}/faq.php

    133. ------------------------------------------------------------

    134. To confirm your invitation, you have to follow this link and type the invite code:

    135. {$TBDEV['baseurl']}/invite_signup.php

    136. Invite Code: $invite

    137. ------------------------------------------------------------

    138. After you do this, your inviter need's to confirm your account.

    139. We urge you to read the RULES and FAQ before you start using {$TBDEV['site_name']}.

    140. EOD;

    141. $sendit = mail($email, "You have been invited to {$TBDEV['site_name']}", $body, "From: {$TBDEV['site_email']}", "-f{$TBDEV['site_email']}");

    142. if (!$sendit) stderr($lang['invites_error'], $lang['invites_unable']);

    143. else stderr('', $lang['invites_confirmation']); }

    144. $id = (isset($_GET['id']) ? (int)$_GET['id'] : (isset($_POST['id']) ? (int)$_POST['id'] : ''));

    145. if (!is_valid_id($id)) stderr($lang['invites_error'], $lang['invites_invalid']);

    146. $query = mysql_query('SELECT * FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender = ' . sqlesc($CURUSER['id']).' AND status = "Pending"') or sqlerr(__FILE__, __LINE__);

    147. $fetch = mysql_fetch_assoc($query) or stderr($lang['invites_error'], $lang['invites_noexsist']);

    148. $HTMLOUT .= "

    149. E-Mail]."'  />
      ";

    150. print stdhead('Invites') . $HTMLOUT . stdfoot();

    151. }

    152. /**

    153. * @action Delete Invites

    154. */

    155. elseif ($do =='delete_invite') {

    156. $id = (isset($_GET["id"]) ? (int)$_GET["id"] : (isset($_POST["id"]) ? (int)$_POST["id"] : ''));

    157. $query = mysql_query('SELECT * FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender = ' . sqlesc($CURUSER['id']).' AND status = "Pending"') or sqlerr(__FILE__, __LINE__);

    158. $assoc = mysql_fetch_assoc($query);

    159. if (!$assoc)

    160. stderr($lang['invites_error'],$lang['invites_noexsist']);

    161. isset($_GET['sure']) && $sure = htmlspecialchars($_GET['sure']);

    162. if (!$sure)

    163. stderr($lang['invites_delete1'], $lang['invites_sure'].' Click .$_SERVER['PHP_SELF'].'?do=delete_invite&id='.$id.'&sender='.$CURUSER['id'].'&sure=yes">here to delete it or here to go back.');

    164. mysql_query('DELETE FROM invite_codes WHERE id = ' . sqlesc($id) . ' AND sender =' . sqlesc($CURUSER['id'].' AND status = "Pending"')) or sqlerr(__FILE__, __LINE__);

    165. mysql_query('UPDATE users SET invites = invites + 1 WHERE id = '.sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

    166. header("Location: ?do=view_page");

    167. }

    168. /**

    169. * @action Confirm Accounts

    170. */

    171. elseif ($do ='confirm_account') {

    172. $userid = (isset($_GET["userid"]) ? (int)$_GET["userid"] : (isset($_POST["userid"]) ? (int)$_POST["userid"] : ''));

    173. if (!is_valid_id($userid))

    174. stderr($lang['invites_error'], $lang['invites_invalid']);

    175. $select = mysql_query('SELECT id, username FROM users WHERE id = ' . sqlesc($userid) . ' AND invitedby = ' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);

    176. $assoc = mysql_fetch_assoc($select);

    177. if (!$assoc)

    178. stderr($lang['invites_error'], $lang['invites_errorid']);

    179. isset($_GET['sure']) && $sure = htmlspecialchars($_GET['sure']);

    180. if (!$sure)

    181. stderr($lang['invites_confirm1'], $lang['invites_sure1'].' '.htmlspecialchars($assoc['username']).'\'s account? Click .$userid.'&sender='.$CURUSER['id'].'&sure=yes">here to confirm it or here to go back.');

    182. mysql_query('UPDATE users SET status = "confirmed" WHERE id = '.sqlesc($userid).' AND invitedby = '.sqlesc($CURUSER['id']).' AND status="pending"') or sqlerr(__FILE__, __LINE__);

    183. //==pm to new invitee/////

    184. $msg = sqlesc("Hey there :wave:

    185. Welcome to {$TBDEV['site_name']}!

    186. We have made many changes to the site, and we hope you enjoy them!

    187. We have been working hard to make {$TBDEV['site_name']} somethin' special!

    188. {$TBDEV['site_name']} has a strong community (just check out forums), and is a feature rich site. We hope you'll join in on all the fun!

    189. Be sure to read the {$TBDEV['baseurl']}/rules.php]Rules and {$TBDEV['baseurl']}[/COLOR]/faq.php]FAQ before you start using the site.[/COLOR]

    190. We are a strong friendly community here {$TBDEV['site_name']} is so much more then just torrents.

    191. Just for kicks, we've started you out with 200.0 Karma Bonus  Points, and a couple of bonus GB to get ya started!

    192. so, enjoy 

    193. cheers,

    194. {$TBDEV['site_name']} Staff");

    195. $id = $assoc["id"];

    196. $subject = sqlesc("Welcome to {$TBDEV['site_name']} !");

    197. $added = sqlesc(time());

    198. mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $id, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    199. ///////////////////end////////////

    200. header("Location: ?do=view_page");

    201. }

    202. ?>



    invite_signup.php :

    Code: [Select]
    require_once('include/bittorrent.php');
    require_once(
    'include/user_functions.php');
    require_once(
    'cache/timezones.php');
    require_once(
    'include/page_verify.php');
    dbconn();
    get_template();

    $stdfoot = array(/** include js **/'js' => array('check','jquery.pstrength-min.1.2'));

    $lang = array_merge( load_language('global'), load_language('signup') );
    $newpage = new page_verify();
    $newpage->create('tkIs');

    $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_row($res);
    if (
    $arr[0] >= $TBDEV['maxusers'])
    stderr("Sorry", "The current user account limit (" . number_format($TBDEV['maxusers']) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...");

    if(!
    $TBDEV['openreg'])
       
    stderr('Sorry', 'Invite only - Signups are closed presently');

    // TIMEZONE STUFF
           
    $offset = (string)$TBDEV['time_offset'];
           
           
    $time_select = "";
       
    // TIMEZONE END

    $HTMLOUT='';

    $HTMLOUT .= "
        "
    ;
    // Normal Entry Point...
    $value = array('...','...','...','...','...','...');
    $value[rand(1,count($value)-1)] = 'X';
    $HTMLOUT .="
       
       

    Note: You need cookies enabled to sign up or log in.


    ]}/take_invite_signup.php'>







    ";
    //==Passhint
       
    $passhint="";
       
    $questions = array(
          array(
    "id"=> "1", "question"=> "{$lang['signup_q1']}"),
            array(
    "id"=> "2", "question"=> "{$lang['signup_q2']}"),
            array(
    "id"=> "3", "question"=> "{$lang['signup_q3']}"),
            array(
    "id"=> "4", "question"=> "{$lang['signup_q4']}"),
            array(
    "id"=> "5", "question"=> "{$lang['signup_q5']}"),
            array(
    "id"=> "6", "question"=> "{$lang['signup_q6']}"));
            foreach(
    $questions as $sph){ 
           
    $passhint .= "\n";
            }
           
    $HTMLOUT .= "

           




    Desired username:
    Pick a password:
    Enter password again:
    Enter invite-code:
    Email address:
    The email address must be valid. The email address won't be publicly shown anywhere unless you chose to from your settings.
    {$lang['signup_timez']}{$time_select}
    {$lang['signup_select']}
    {$lang['signup_enter']}{$lang['signup_this_answer']}{$lang['signup_this_answer1']}
    I will read the site rules page.
    I agree to read the FAQ before asking questions.
    I am at least 18 years old.
    Now click the button marked X to complete the sign up!
    ";
     for (
    $i=0; $i < count($value); $i++) {
     
    $HTMLOUT .= ".$value[$i]."\" class=\"btn\" />";
     }
     
    $HTMLOUT .= "
    ";

    print
    stdhead('Invites') . $HTMLOUT . stdfoot($stdfoot);
    ?>

    take_invite_signup.php :

    Code: PHP

    1. require_once('include/bittorrent.php');

    2. require_once('include/user_functions.php');

    3. require_once('include/password_functions.php');

    4. require_once('include/page_verify.php');

    5. dbconn();

    6. get_template();

    7. $lang = array_merge( load_language('global'), load_language('takesignup') );

    8. $newpage = new page_verify();

    9. $newpage->check('tkIs');

    10. $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);

    11. $arr = mysql_fetch_row($res);

    12. if ($arr[0] >= $TBDEV['maxusers'])

    13. stderr($lang['stderr_errorhead'], sprintf($lang['stderr_ulimit'], $TBDEV['maxusers']));

    14. if (!mkglobal("wantusername:wantpassword:passagain:email:invite:captchaSelection:submitme:passhint:hintanswer"))

    15. die();

    16. if ($submitme != 'X')

    17.   stderr('Ha Ha', 'You Missed, You plonker !');

    18. if(empty($captchaSelection) || $_SESSION['simpleCaptchaAnswer'] != $captchaSelection){

    19. header('Location: invite_signup.php');

    20. exit();

    21. }

    22. function validusername($username) {

    23. if ($username == "")

    24. return false;

    25. // The following characters are allowed in user names

    26. $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    27. for ($i = 0; $i < strlen($username); ++$i)

    28. if (strpos($allowedchars, $username[$i]) === false)

    29. return false;

    30. return true;

    31. }

    32. if (empty($wantusername) || empty($wantpassword) || empty($email) || empty($invite) || empty($passhint) || empty($hintanswer))

    33. stderr("Error","Don't leave any fields blank.");

    34. if(!blacklist($wantusername))

    35. stderr($lang['takesignup_user_error'],sprintf($lang['takesignup_badusername'],htmlspecialchars($wantusername)));

    36. if (strlen($wantusername) > 12)

    37. stderr("Error","Sorry, username is too long (max is 12 chars)");

    38. if ($wantpassword != $passagain)

    39. stderr("Error","The passwords didn't match! Must've typoed. Try again.");

    40. if (strlen($wantpassword) < 6)

    41. stderr("Error","Sorry, password is too short (min is 6 chars)");

    42. if (strlen($wantpassword) > 40)

    43. stderr("Error","Sorry, password is too long (max is 40 chars)");

    44. if ($wantpassword == $wantusername)

    45. stderr("Error","Sorry, password cannot be same as user name.");

    46. if (!validemail($email))

    47. stderr("Error","That doesn't look like a valid email address.");

    48. if (!validusername($wantusername))

    49. stderr("Error","Invalid username.");

    50. // make sure user agrees to everything...

    51. if ($_POST["rulesverify"] != "yes" || $_POST["faqverify"] != "yes" || $_POST["ageverify"] != "yes")

    52. stderr("Error","Sorry, you're not qualified to become a member of this site.");

    53. // check if email addy is already in use

    54. $a = (@mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM users WHERE email = ' . sqlesc($email)))) or die(mysql_error());

    55. if ($a[0] != 0)

    56. stderr('Error', 'The e-mail address ' . htmlspecialchars($email) . ' is already in use.');

    57. //=== check if ip addy is already in use

    58. $c = (@mysql_fetch_row(mysql_query("select count(*) from users where ip='" . $_SERVER['REMOTE_ADDR'] . "'"))) or die(mysql_error());

    59. if ($c[0] != 0)

    60. stderr("Error", "The ip " . $_SERVER['REMOTE_ADDR'] . " is already in use. We only allow one account per ip address.");

    61. // TIMEZONE STUFF

    62.     if(isset($_POST["user_timezone"]) && preg_match('#^\-?\d{1,2}(?:\.\d{1,2})?$#', $_POST['user_timezone']))

    63.     {

    64.     $time_offset = sqlesc($_POST['user_timezone']);

    65.     }

    66.     else

    67.     {

    68.     $time_offset = isset($TBDEV['time_offset']) ? sqlesc($TBDEV['time_offset']) : '0'; }

    69.     // have a stab at getting dst parameter?

    70.     $dst_in_use = localtime(time() + ($time_offset * 3600), true);

    71.     // TIMEZONE STUFF END

    72. $select_inv = mysql_query('SELECT sender, receiver, status FROM invite_codes WHERE code = ' . sqlesc($invite)) or die(mysql_error());

    73. $rows = mysql_num_rows($select_inv);

    74. $assoc = mysql_fetch_assoc($select_inv);

    75. if ($rows == 0)

    76. stderr("Error","Invite not found.\nPlease request a invite from one of our members.");

    77. if ($assoc["receiver"]!=0)

    78. stderr("Error","Invite already taken.\nPlease request a new one from your inviter.");

    79.     $secret = mksecret();

    80.     $wantpasshash = make_passhash( $secret, md5($wantpassword) );

    81.     $editsecret = ( !$arr[0] ? "" : make_passhash_login_key() );

    82.     $wanthintanswer = md5($hintanswer);

    83. $new_user = mysql_query("INSERT INTO users (username, passhash, secret, passhint, hintanswer, editsecret, invitedby, email, ". (!$arr[0]?"class, ":"") ."added, last_access, last_login, time_offset, dst_in_use) VALUES (" .

    84. implode(",", array_map("sqlesc", array($wantusername, $wantpasshash, $secret, $editsecret, $passhint, $wanthintanswer, (int)$assoc['sender'], $email))).

    85. ", ". (!$arr[0]?UC_SYSOP.", ":""). "'".  time() ."','".  time() ."','".  time() ."', $time_offset, {$dst_in_use['tm_isdst']})");

    86. $message = "Welcome New {$TBDEV['site_name']} Member : - " . htmlspecialchars($wantusername) . "";

    87. if (!$new_user) {

    88. if (mysql_errno() == 1062)

    89. stderr("Error","Username already exists!");

    90. stderr("Error","borked");

    91. }

    92. //===send PM to inviter

    93. $sender = $assoc["sender"];

    94. $added = sqlesc(time());

    95. $msg = sqlesc("Hey there [you] ! :wave:\nIt seems that someone you invited to {$TBDEV['site_name']} has arrived ! :clap2: \n\n Please go to your {$TBDEV['baseurl']}/invite.php]Invite page to confirm them so they can log in.\n\ncheers\n"[/COLOR]);

    96. $subject = sqlesc("Someone you invited has arrived!");

    97. mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $sender, $msg, $added)") or sqlerr(__FILE__, __LINE__);

    98. //////////////end/////////////////////

    99. $id = mysql_insert_id();

    100. mysql_query('UPDATE invite_codes SET receiver = ' . sqlesc($id) . ', status = "Confirmed" WHERE sender = ' . sqlesc((int)$assoc['sender']). ' AND code = ' . sqlesc($invite)) or sqlerr(__FILE__, __LINE__);

    101. write_log('User account '.htmlspecialchars($wantusername).' was created!');

    102. autoshout($message);

    103. stderr('Success','Signup successfull, Your inviter needs to confirm your account now before you can use your account !');

    104. ?>



    lang_invite_code.php :

    Code: PHP

    1. $lang = array(

    2. #invite errors

    3. 'invites_error' => "Error",

    4. 'invites_deny' => "Denied",

    5. 'invites_limit' => "Sorry, user limit reached. Please try again later.",

    6. 'invites_disabled' => "Your invite sending privileges has been disabled by the Staff!",

    7. 'invites_noinvite' => "No invites !",

    8. 'invites_invalidemail' => "That doesn't look like a valid email address.",

    9. 'invites_noemail' => "You must enter an email address!",

    10. 'invites_unable' => "Unable to send mail. Please contact an administrator about this error.",

    11. 'invites_confirmation' => "A confirmation email has been sent to the address you specified.",

    12. 'invites_invalid' => "Invalid ID!",

    13. 'invites_noexsist' => "This invite code does not exist.",

    14. 'invites_sure' => "Are you sure you want to delete this invite code?",

    15. 'invites_errorid' => "No user with this ID.",

    16. 'invites_sure1' => "Are you sure you want to confirm",

    17. #invites

    18. 'invites_users' => "Invited Users",

    19. 'invites_nousers' => "No Invitees Yet",

    20. 'invites_username' => "Username",

    21. 'invites_uploaded' => "Uploaded",

    22. 'invites_downloaded' => "Downloaded",

    23. 'invites_ratio' => "Ratio",

    24. 'invites_status' => "Status",

    25. 'invites_confirm' => "Confirm",

    26. 'invites_confirm1' => "Confirmed",

    27. 'invites_pend' => "Pending",

    28. 'invites_codes' => "Created Invite Codes",

    29. 'invites_nocodes' => "You have not created any invite codes at the moment!",

    30. 'invites_date' => "Created Date",

    31. 'invites_delete' => "Delete",

    32. 'invites_create' => "Create Invite Code",

    33. 'invites_send_code' => "Send Invite Code",

    34. 'invites_delete1' => "Delete Invite",

    35. 'invites_confirm1' => "Confirmed Account",

    36. );

    37. ?>







    All times are GMT +2. The time now is 03:58.

    Powered by vBulletin® Version 3.8.11 Beta 3
    Copyright ©2000 - 2024, vBulletin Solutions Inc.