Gazelle Article 2: Invites, Minor Edits and Small Add-ons

September 26, 2009 by MFSL

In this second article on how to install Gazelle, we’ll explain how to implement Invite Codes, configure the Donations, and BT client Whitelists. These last few days I’ve done a few minor edits in and around the code and did one small change to the invite system. Also, our twitter feed for the yet-to-be-announced tracker is running at http://twitter.com/SVTracker/. Invites codes and more fun stuff will be posted!

What You’ll Need:

  • SSH Client (PuTTy)
  • SFTP/FTP Client (WinSCP)

After following through with Article One, you should have something resembling this right now:

What you should have

Invite Codes

This is optional but its just what I decided I wanted for my site. If you like the current system then you might as well skip the part.

I would like to give credit to Mike89 for help with the guide on how to do this. I am only rewording a bit of stuff slightly.

I used WinSCP to edit these files as its a lot easier than using nano in PuTTy. If you are using PuTTy then apt-get install nano and use “nano -w /site/****/*****.*** to open and edit files.

First you need to edit /site/sections/users/invite.php. find <form action="user.php" method="post"> and replace the form with the following.


      <form action="user.php" method="post">
            <table cellpadding="6" cellspacing="1" border="0"
class="border" width="100%">
                <tr>
                    <td class="label">Generate invite code</td>
                    <td>
                        <input type="hidden" name="action"
value="invite" />
                        <input type="hidden" name="from"
                        value="<?=display_str($_GET['action'])?>" />
                        &nbsp;
                        <input type="submit" value="Generate!" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="center">
                        <p>Please note that the selling, trading or
 public giving away of our invitations is strictly forbidden,
 and will result in you and your entire invite tree being banned.
 This includes offering to give away our invitations on public forums. </p>
                        <p>To use invite codes, go to our 'Register' page
 and enter the invite code. </p>
                    </td>
                </tr>
            </table>
      </form>

Next, replace the entirety of /site/sections/users/takeinvite.php with

<?
if($LoggedUser['DisableInvites'] == '1' || ($LoggedUser['Invites']==0 &&
!check_perms('site_send_unlimited_invites')) ||
($NumUsers >= USER_LIMIT &&
!check_perms('site_can_invite_always'))){
    error(403);
}

    $InviteKey = db_string(make_secret());
    $InviteExpires = time_plus(60*60*24*3); // 3 days

    $DB->query("INSERT INTO invites
        (InviterID, InviteKey, Email, Expires) VALUES
        ('$LoggedUser[ID]', '$InviteKey', 'invite_code', '$InviteExpires')");

    update_user_data();
    if($_POST['from'] == 'invitetree'){
        header('Location: user.php?action=invitetree');
    } else {
        header('Location: user.php?action=invite');
    }
    die();

?>

Then, replace the entirety of /site/sections/register/closed.php with

<?
show_header('Registration Closed');
?>
<div style="width:500px;">
    <strong>Sorry, the site is currently invite only.</strong>
    <p>If you have an invite code, please enter it below. </p>
        <form action="register.php" method="get">
            <input type="text" name="invite" size="32" />
            <input type="submit" value="Register" />
        </form>
</div>
<?
show_footer();
?>

The following removes email confirmation as well so you dont have to keep going from here if you dont want to.
in
/sections/register/step1.php
after after “<? } else { ?>”

 <strong>Congratulations! Your account has been created.</strong><br />
    You can now log into your account using the
<a href="login.php">login</a> page.

and in /sections/register/index.php
Beginning at line 60 (near “if(!$Err) { “) replace the original query with this one

$DB->query(”INSERT INTO users_main
(ID, Username,Email,PassHash,Secret,torrent_pass,IP,PermissionID,Enabled,Invites) VALUES

(’$UserID’,'”.db_string($_REQUEST['username']).”‘,’”.db_string($_REQUEST['email']).”‘,

‘”.db_string(make_hash($_REQUEST['password'],$Secret)).”‘,’”.db_string($Secret).”‘,

‘”.db_string($torrent_pass).”‘,’”.db_string($_SERVER['REMOTE_ADDR']).”‘,’”.USER.”‘,’1′,

‘”.STARTING_INVITES.”‘)”);

Replace

    <h3>Current invites</h3>
    <div class="box pad">
        <table width="100%">
            <tr class="colhead">
                <td>Email</td>
                <td>Expires in</td>
                <td>Delete invite</td>
            </tr>
<?
    $DB->query("SELECT InviteKey, Email, Expires FROM invites WHERE
InviterID='$UserID' ORDER BY Expires");
    $Row = 'a';
    while(list($InviteKey, $Email, $Expires) = $DB->next_record()){
        $Row = ($Row == 'a') ? 'b' : 'a';
?>
            <tr class="row<?= $Row?>">
                <td><?= display_str($Email)?></td>
                <td><?= time_diff(gmmktime(), strtotime($Expires))?></td>
                <td><a href="user.php?action=deleteinvite
&amp; invite=<?= $InviteKey?>&amp;auth=<?=
$LoggedUser['AuthKey']?>">Delete invite</a></td>
            </tr>
<?    } ?>
        </table>
    </div>

With


    <h3>Current invites</h3>
    <div class="box pad">
        <table width="100%">
            <tr class="colhead">
                <td>Invite Key</td>
                <td>Expires in</td>
                <td>Delete invite</td>
            </tr>
<?
    $DB->query("SELECT InviteKey, Email, Expires FROM invites WHERE
InviterID='$UserID' ORDER BY Expires");
    $Row = 'a';
    while(list($InviteKey, $Email, $Expires) = $DB->next_record()){
        $Row = ($Row == 'a') ? 'b' : 'a';
?>
            <tr class="row<?= $Row?>">
                <td><?= display_str($InviteKey)?></td>
                <td><?= time_diff(gmmktime(), strtotime($Expires))?></td>
                <td><a href="user.php?action=deleteinvite
&amp;invite=<?= $InviteKey?> $amp;auth=<?=
$LoggedUser['AuthKey']?>">Delete invite</a></td>
            </tr>
<?    } ?>
        </table>
    </div>

And thats all there is to it.

invites.php now looks like:

Invitation codes through Gazelle

Donation Config

Open /site/sections/donate/config.php and edit the email, min. donation, and currency fields to whatever you want for your paypal account. You don’t want to go live and have all your donations going to what.cd right? :p

Client Whitelist

Load your site up in your browser and then click Staff tools and then Whitelist. This page defines which clients can connect to the tracker. Below is my whitelist. It contains only clients that I am 100% sure that they contain no Mal-ware and accurately report stats.

Here is my whitelist:

Whitelist.php

Joining the Beta…

Go to http://87.118.92.205/register.php and try to join the beta. 3 codes are available now, look for more codes coming soon on the twitter feed.

xnn238mjuurzt4sguhpecz8yezygzuhy
g6xvc84aq18ia47t6z164dhy0cb526pk
cu17d3njuzpakafzglnn6qjc9bqnyvzb