-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinvite.php
92 lines (85 loc) · 3.11 KB
/
invite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* All functions for Registering users by invitation are going through here.
*
* @copyright http://www.impresscms.org/ The ImpressCMS Project
* @license LICENSE.txt
* @package Member
* @subpackage Users
* @author marcan <marcan@impresscms.org>
* @author Sina Asghari (aka stranger) <pesian_stranger@users.sourceforge.net>
* @version $Id: invite.php 21047 2011-03-14 15:52:14Z m0nty_ $
*/
$xoopsOption['pagetype'] = 'user';
include 'mainfile.php';
// If not a user and invite needs one, redirect
if ($icmsConfigUser['activation_type'] == 3 && $icmsConfigUser['allow_register'] == 0 && !is_object(icms::$user)) {
redirect_header('index.php', 6, _US_INVITEBYMEMBER);
exit();
}
$op = !isset($_POST['op']) ? 'invite' : $_POST['op'];
$email = isset($_POST['email']) ? trim(icms_core_DataFilter::stripSlashesGPC($_POST['email'])) : '';
switch ($op) {
case 'finish':
include 'header.php';
$stop = '';
if (!icms::$security->check()) {
$stop .= implode('<br />', icms::$security->getErrors()) . "<br />";
}
$icmsCaptcha = icms_form_elements_captcha_Object::instance();
if (! $icmsCaptcha->verify()) {
$stop .= $icmsCaptcha->getMessage() . '<br />';
}
if (!checkEmail($email)) {
$stop .= _US_INVALIDMAIL . '<br />';
}
if (empty($stop)) {
$invite_code = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
$sql = sprintf('INSERT INTO ' . icms::$xoopsDB->prefix('invites') . '
(invite_code, from_id, invite_to, invite_date, extra_info) VALUES
(%s, %d, %s, %d, %s)',
icms::$xoopsDB->quoteString(addslashes($invite_code)),
is_object(icms::$user) ? icms::$user->getVar('uid') : 0,
icms::$xoopsDB->quoteString(addslashes($email)),
time(),
icms::$xoopsDB->quoteString(addslashes(serialize(array())))
);
icms::$xoopsDB->query($sql);
// if query executed successful
if (icms::$xoopsDB->getAffectedRows() == 1) {
$xoopsMailer = new icms_messaging_Handler();
$xoopsMailer->useMail();
$xoopsMailer->setTemplate('invite.tpl');
$xoopsMailer->assign('SITENAME', $icmsConfig['sitename']);
$xoopsMailer->assign('ADMINMAIL', $icmsConfig['adminmail']);
$xoopsMailer->assign('SITEURL', ICMS_URL . "/");
$xoopsMailer->assign('USEREMAIL', $email);
$xoopsMailer->assign('REGISTERLINK', ICMS_URL . '/register.php?code=' . $invite_code);
$xoopsMailer->setToEmails($email);
$xoopsMailer->setFromEmail($icmsConfig['adminmail']);
$xoopsMailer->setFromName($icmsConfig['sitename']);
$xoopsMailer->setSubject(sprintf(_US_INVITEREGLINK, ICMS_URL));
if (!$xoopsMailer->send()) {
$stop .= _US_INVITEMAILERR;
} else {
echo _US_INVITESENT;
}
} else {
$stop .= _US_INVITEDBERR;
}
}
if (! empty($stop)) {
echo "<span style='color:#ff0000; font-weight:bold;'>$stop</span>";
include 'include/inviteform.php';
$invite_form->display();
}
include 'footer.php';
break;
case 'invite':
default:
include 'header.php';
include 'include/inviteform.php';
$invite_form->display();
include 'footer.php';
break;
}