09 Email Invite Mod

Started by Mindless, August 06, 2012, 12:07:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BamBam0077

Hey mindless,

not sure if this is correct sql for your invite system but since this said invite mod thought I would share a more upto date sql for your projects and your community.  ;)


CREATE TABLE `invites` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sender` int(10) unsigned NOT NULL DEFAULT '0',
`reciever` int(10) unsigned NOT NULL DEFAULT '0',
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`hash` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`invite_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`status` enum('pending','confirmed') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'pending',
PRIMARY KEY (`id`),
UNIQUE KEY (`hash`),
KEY `username` (`username`),
KEY `email` (`email`),
KEY `sender` (`sender`),
KEY `datestamps` (`invite_added`),
KEY `recieverid` (`reciever`,`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
"When Darkness Shadows Your Doubts, Deep Within Us Is Our Key, Not Success But Everything" ~ Anonymous


Laur[1]

#7
Function mksecret() is missing

No need for it, i found it

function mksecret($len = 20) {
$ret = "";
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(100, 120));
return $ret;
}

Mindless

Lang file found. Edited rickandmarys post.

rickandmary

#5
lang_invites.php

<?php

$lang 
= array(
#email invite mod 
'invites_usererror' => "User Error",
'invites_deny' => "Denied",
'invites_invalidid' => "Invalid Id",
'invites_confirm_invalid' => "Invalid action - contact staff on irc",
'invites_confirm_invalid1' => "Invalid action - contact staff on irc",
'invites_notyours' => "Not your invite to cancel",
'invites_sorry' => "Sorry",
'invites_removed' => "Your invite privileges have been removed.",
'invites_maxreached' => "We have reached our current invite limit, please check back again later.<br />You have ",
'invites_userinvites' => " invites to send once invites are open again.",
'invites_noinvites' => "You don't have any invites available, please check back soon.",
'invites_send' => "Send an invite",
'invites_you' => "You have ",
'invites_remaining' => " invites remaining.",
'invites_email' => "E-mail :",
'invites_message' => "Message :",
'invites_message1' => "Hello, I am inviting you to join ",
'invites_message2' => " This is a private community please read over the rules once you confirmed your invite. Regards, ",
'invites_send1' => "Send invite!",
'invites_pending' => "Pending Invites",
'invites_email1' => "Email",
'invites_sent' => "Sent",
'invites_cancel' => "Cancel",
'invites_nopending' => "No Pending Invites.",
'invites_confirmed' => "Confirmed Invitees",
'invites_invitee' => "Invitee",
'invites_download' => "Download",
'invites_upload' => "Upload",
'invites_ratio' => "Ratio",
'invites_joined' => "Joined",
'invites_noconfirmed' => "You have no Invitees.",

#takeconfirminvite stuff - saves a new lang file
'invites_confirm_note' => "Note: You need cookies enabled to sign up or log in.",
'invites_confirm_dusername' => "Desired username:",
'invites_confirm_password' => "Pick a password:",
'invites_confirm_passagain' => "Enter password again:",
'invites_confirm_verifyrules' => "I will read the site ",
'invites_confirm_rules' => " Rules",
'invites_confirm_page' => " page.",
'invites_confirm_verifyfaq' => " I agree to read the",
'invites_confirm_faq' => " FAQ ",
'invites_confirm_questions' => "before asking questions.",
'invites_confirm_verifyage' => " I am at least 18 years old.",
'invites_confirm_signup' => "Sign up! (Press Only Once)",
'invites_confirm_usererror' => "User Error",
'invites_confirm_invalidid' => "Invalid Id",
'invites_confirm_sorry' => "Sorry",
'invites_confirm_currlimit' => "The current user account limit  has been reached. Inactive accounts are pruned all the time, please check back again later...",
'invites_confirm_error' => "Error",
'invites_confirm_invalid' => "Invalid action - contact staff");

?>

Mindless

#4
Hmm actually the lang files are switchable - minor edits im sure you can handle, if they aint there i dont think i have them.

ErikZown

where is file lang_invites.php?

Thanks

MJF

Thank you very much..

Always great to see the 09 Mods, though TBDev went down...

:)

Mindless

#1
Quote
Bigjoos
First of all - All credit to thebrass - snuggs and all the original code creators of the email invite system - I only updated it and used snippets from a few
Just as the title says i spent a fair while slowy updated the original version posted by thebrass - current user invite amount checks and tracker amount checks -  and class checks of course all of which you can adjust to your own requirements - Thanks to Elephant2 for the addtions of being able to delete pending

Reworked for 09
Xhtml valid

First the sql :

ALTER TABLE `users` ADD  `invites` int(10) unsigned NOT NULL default '1';
ALTER TABLE `users` ADD  `invitedby` int(10) unsigned NOT NULL default '0';
ALTER TABLE `users` ADD  `invitedate` int(11) NOT NULL default '0';
ALTER TABLE `users` ADD  `invitees` varchar(100) character set utf8 collate utf8_bin NOT NULL default '';
ALTER TABLE `users` ADD  `invite_on` enum('yes','no') character set utf8 collate utf8_bin NOT NULL default 'yes';



@ file userdetails.php for displaying invitees  - the querys are shocking lol and need optimized and redone :

if ($CURUSER['class'] >= UC_MODERATOR && $user['invites'] > 0 || $user["id"] == $CURUSER["id"] && $user['invites'] > 0)
    $HTMLOUT .="<tr><td class='rowhead'>{$lang['userdetails_invites']}</td><td align='left'><a href='{$TBDEV['baseurl']}/invite.php'>$user[invites]</a></td></tr>\n";
    if ($CURUSER['class'] >= UC_MODERATOR && $user['invitedby'] > 0 || $user["id"] == $CURUSER["id"] && $user['invitedby'] > 0)
    {
    $invitedby = sql_query("SELECT username FROM users WHERE id=$user[invitedby]");
    $invitedby2 = mysql_fetch_assoc($invitedby);
    $HTMLOUT .="<tr><td class='rowhead'>Invited by</td><td align='left'><a href='{$TBDEV['baseurl']}/userdetails.php?id=$user[invitedby]'>$invitedby2[username]</a></td></tr>\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 = sql_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 .="<tr><td class='rowhead' width='1%'>{$lang['userdetails_invitees']}</td><td>";
    $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 = sql_query("SELECT id, username FROM users WHERE id='$user_id' and status='confirmed' ORDER BY username");
    $compl_users = mysql_fetch_assoc($compl_user);
    $HTMLOUT .="<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . $compl_users["id"] . "'>".htmlspeciachars($compl_users["username"])."</a>&nbsp;";
    if ($i == "9")
    break;
    $i++;
    }
    $HTMLOUT .="</td></tr>";
    $f = 1;
    }
    if ($f == "1")
    break;
    }
    }[/codebox]

for admin in your tools section :

[code]$HTMLOUT .= "<tr><td class='rowhead'>{$lang['userdetails_invright']}</td><td colspan='2' align='left'><input type='radio' name='invite_on' value='yes'" .($user["invite_on"]=="yes" ? " checked='checked'" : "") . " />{$lang['userdetails_yes']}<input type='radio' name='invite_on' value='no'" .($user["invite_on"]=="no" ? " checked='checked'" : "") . " />{$lang['userdetails_no']}</td></tr>\n";
$HTMLOUT .= "<tr><td class='rowhead'><b>{$lang['userdetails_invites']}</b></td><td colspan='2' align='left'><input type='text' size='3' name='invites' value='" . htmlspecialchars($user['invites']) . "' /></td></tr>\n";


@ file lang/en/lang_userdetails.php add :

'userdetails_invright' => "Invite rights",
'userdetails_invites' => "Invites",
'userdetails_invitees' => "Invitees",


@ file modtask.php :

//=== allow invites
     if ((isset($_POST['invite_on'])) && (($invite_on = $_POST['invite_on']) != $user['invite_on'])){ 
     $modcomment = get_date( time(), 'DATE', 1 ) . " - Invites allowed changed from $user[invite_on] to $invite_on by " . $CURUSER['username'] . ".\n" . $modcomment;
     $updateset[] = "invite_on = " . sqlesc($invite_on);
     }
     // change invites
     if ((isset($_POST['invites'])) && (($invites = $_POST['invites']) != ($curinvites = $user['invites'])))
     {
     $modcomment = get_date( time(), 'DATE', 1 ) . " - Invite amount changed to '".$invites."' from '".$curinvites."' by " . $CURUSER['username'] . ".\n" . $modcomment;
     $updateset[] = "invites = " . sqlesc($invites);
     }



@ upload lang/en/lang_invites.php

<?php

$lang 
= array(

#email invite mod 
'invites_error' => "Error",
'invites_limit' => "Sorry, user limit reached. Please try again later.",
'invites_sorry' => "Sorry",
'invites_removed' => "Your invite previlages has been removed.",
'invites_usererror' => "User Error",
'invites_deny' => "Denied",
'invites_invalidid' => "Invalid Id",
'invites_notyours' => "Not your invite to cancel",
'invites_sorry' => "Sorry",
'invites_removed' => "Your invite privileges have been removed.",
'invites_maxreached' => "We have reached our current invite limit, please check back again later.<br />You have ",
'invites_userinvites' => " invites to send once invites are open again.",
'invites_noinvites' => "You don't have any invites available, please check back soon.",
'invites_send' => "Send an invite",
'invites_you' => "You have ",
'invites_remaining' => " invites remaining.",
'invites_email' => "E-mail :",
'invites_message' => "Message :",
'invites_message1' => "Hello, I am inviting you to join ",
'invites_message2' => " This is a private community please read over the rules once you confirmed your invite.\n\nRegards, ",
'invites_send1' => "Send invite!",
'invites_pending' => "Pending Invites",
'invites_email1' => "Email",
'invites_sent' => "Sent",
'invites_cancel' => "Cancel",
'invites_nopending' => "No Pending Invites.",
'invites_confirmed' => "Confirmed Invitees",
'invites_invitee' => "Invitee",
'invites_download' => "Download",
'invites_upload' => "Upload",
'invites_ratio' => "Ratio",
'invites_joined' => "Joined",
'invites_noconfirmed' => "You have no Invitees.",

);

?>


@ file lang/en/lang_modtask.php add - you can leave this out till i finish the modtask lang code of :

'modtask_invites_enabled' => " - Invite rights enabled by ",
'modtask_invites_rights' => "Your invite rights have been given back by ",
'modtask_invites_youcan' => "  You can invite users again.",
'modtask_invites_removed' => "Your invite rights have been removed by",
'modtask_invites_reason' => "probably because you invited a bad user.",
'modtask_invites_amount' => "- Invite amount changed to",
'modtask_invites_from' => "from",
'modtask_invites_by' => "by",


@ file ok.php Under dbconn(); add :

$HTMLOUT ='';

Find :

if ( $type == "signup" && isset($_GET['email']) )
    {
    stderr( "{$lang['ok_success']}", sprintf($lang['ok_email'], htmlentities($_GET['email'], ENT_QUOTES)) );
    }

   
Under it add this :

elseif ( $type == "invite" && isset($_GET['email']) )
    {
    stderr( "{$lang['ok_invsuccess']}", sprintf($lang['ok_email2'], htmlentities($_GET['email'], ENT_QUOTES)) );
    }

   
@ file lang/en/lang_ok.php add :

'ok_invsuccess' => "Invite Signup successful!",
'ok_email2' => "A confirmation email has been sent to the address you specified (%s). Your invitee needs to read and respond to this email before he/she can use their account. If they don't do this, the new account will be deleted automatically after a few days.",


@ file config.php beside your other config variables

$TBDEV['invites'] = 1500;

Now upload the four attached files to root - As for any mod you install please ensure you check the scripts over for security as theres losts i see now, and if anyone can further improve this then please post them and i'll update the main post, like all mods its straight from archive missing fixes proabably - Any improvements - suggestions welcome

[attachment deleted by admin]