2 // Note: this script uses an undocumented constant in config.php named
3 // REG_NOTIFY_ADDRESS - email address to send registration notifications to.
5 // define('REG_NOTIFY_ADDRESS', 'my-address@domain.dom');
7 error_reporting(E_ERROR | E_WARNING | E_PARSE
);
9 $action = $_REQUEST["action"];
11 define('MAX_USERS', 55);
13 require_once "sessions.php";
15 require_once "sanity_check.php";
16 require_once "functions.php";
17 require_once "config.php";
18 require_once "db.php";
20 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
22 init_connection($link);
24 /* Remove users which didn't login after receiving their registration information */
26 if (DB_TYPE
== "pgsql") {
27 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
28 AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
30 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
31 AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
34 if ($action == "check") {
35 header("Content-Type: application/xml");
37 $login = trim(db_escape_string($_REQUEST['login']));
39 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
40 LOWER(login) = LOWER('$login')");
42 $is_registered = db_num_rows($result) > 0;
46 printf("%d", $is_registered);
56 <title
>Create
new account
</title
>
57 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
58 <link rel
="stylesheet" type
="text/css" href
="utility.css">
59 <link rel
="alternate" type
="application/rss+xml" title
="online.tt-rss.org - Registration Status" href
="http://online.tt-rss.org/register_rss.php">
60 <script type
="text/javascript" src
="functions.js"></script
>
61 <script type
="text/javascript" src
="prototype.js"></script
>
62 <script type
="text/javascript" src
="scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
65 <script type
="text/javascript">
67 function checkUsername() {
70 var f
= document
.forms
['register_form'];
71 var login
= f
.login
.value
;
74 new Effect
.Highlight(f
.login
);
75 f
.sub_btn
.disabled
= true;
79 var query
= "register.php?action=check&login=" +
82 new Ajax
.Request(query
, {
83 onComplete
: function(transport
) {
87 var reply
= transport
.responseXML
;
89 var result
= reply
.getElementsByTagName('result')[0];
90 var result_code
= result
.firstChild
.nodeValue
;
92 if (result_code
== 0) {
93 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
94 f
.sub_btn
.disabled
= false;
96 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
97 f
.sub_btn
.disabled
= true;
100 exception_error("checkUsername_callback", e
);
106 exception_error("checkUsername", e
);
113 function validateRegForm() {
116 var f
= document
.forms
['register_form'];
118 if (f
.login
.value
.length
== 0) {
119 new Effect
.Highlight(f
.login
);
123 if (f
.email
.value
.length
== 0) {
124 new Effect
.Highlight(f
.email
);
128 if (f
.turing_test
.value
.length
== 0) {
129 new Effect
.Highlight(f
.turing_test
);
136 exception_error("validateRegForm", e
);
145 <div
class="floatingLogo"><img src
="images/ttrss_logo.png"></div
>
147 <h1
><?php
echo __("Create new account") ?
></h1
>
150 if (!ENABLE_REGISTRATION
) {
151 print_error(__("New user registrations are administratively disabled."));
153 print "<p><form method=\"GET\" action=\"logout.php\">
154 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
160 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
163 <?php if (REG_MAX_USERS > 0) {
164 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
165 $num_users = db_fetch_result($result, 0, "cu");
168 <? if (!REG_MAX_USERS || $num_users < REG_MAX_USERS) { ?>
170 <? if (!$action) { ?>
172 <p><?php echo __('Your temporary password will be sent to the specified email
. Accounts
, which were not logged in once
, are erased automatically
24 hours after temporary password is sent
.') ?></p>
174 <form action="register.php" method="POST" name="register_form">
175 <input type="hidden" name="action" value="do_register">
178 <td><?php echo __('Desired login
:') ?></td><td>
181 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
183 <td><?php echo __('Email
:') ?></td><td>
186 <td><?php echo __('How much is two plus two
:') ?></td><td>
187 <input name="turing_test"></td></tr>
188 <tr><td colspan="2" align="right">
189 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
"') ?>"
190 disabled
="true" onclick
='return validateRegForm()'>
195 <?
} else if ($action == "do_register") { ?
>
197 <p
><?php
echo __('Processing registration...') ?
></p
>
200 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
201 $email = trim(db_escape_string($_REQUEST["email"]));
202 $test = trim(db_escape_string($_REQUEST["turing_test"]));
204 if (!$login ||
!$email ||
!$test) {
205 print "<div class='error'>Please fill in the form.</div>";
206 print "<p><a href='register.php'>Return to registration form</a></p>";
210 if ($test == "four" ||
$test == "4") {
212 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
215 $is_registered = db_num_rows($result) > 0;
217 if ($is_registered) {
218 print_error(__('Sorry, this username is already taken.'));
219 print "<p><form method=\"GET\" action=\"tt-rss.php\">
220 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
224 $password = make_password();
226 $pwd_hash = encrypt_password($password, $login);
228 db_query($link, "INSERT INTO ttrss_users
229 (login,pwd_hash,access_level,last_login, email, created)
230 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
232 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
233 login = '$login' AND pwd_hash = '$pwd_hash'");
235 if (db_num_rows($result) != 1) {
236 print_error(__('Registration failed.'));
237 print "<p><form method=\"GET\" action=\"tt-rss.php\">
238 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
242 $new_uid = db_fetch_result($result, 0, "id");
244 initialize_user($link, $new_uid);
248 "You are receiving this message, because you (or somebody else) have opened\n".
249 "an account at Tiny Tiny RSS.\n".
251 "Your login information is as follows:\n".
254 "Password: $password\n".
256 "Don't forget to login at least once to your new account, otherwise\n".
257 "it will be deleted in 24 hours.\n".
259 "If that wasn't you, just ignore this message. Thanks.";
261 $mail = new PHPMailer();
263 $mail->PluginDir
= "phpmailer/";
264 $mail->SetLanguage("en", "phpmailer/language/");
266 $mail->CharSet
= "UTF-8";
268 $mail->From
= DIGEST_FROM_ADDRESS
;
269 $mail->FromName
= DIGEST_FROM_NAME
;
270 $mail->AddAddress($email);
272 if (DIGEST_SMTP_HOST
) {
273 $mail->Host
= DIGEST_SMTP_HOST
;
274 $mail->Mailer
= "smtp";
275 $mail->Username
= DIGEST_SMTP_LOGIN
;
276 $mail->Password
= DIGEST_SMTP_PASSWORD
;
279 // $mail->IsHTML(true);
280 $mail->Subject
= "Registration information for Tiny Tiny RSS";
281 $mail->Body
= $reg_text;
282 // $mail->AltBody = $digest_text;
286 if (!$rc) print_error($mail->ErrorInfo
);
290 "New user had registered at your Tiny Tiny RSS installation.\n".
295 $mail = new PHPMailer();
297 $mail->PluginDir
= "phpmailer/";
298 $mail->SetLanguage("en", "phpmailer/language/");
300 $mail->CharSet
= "UTF-8";
302 $mail->From
= DIGEST_FROM_ADDRESS
;
303 $mail->FromName
= DIGEST_FROM_NAME
;
304 $mail->AddAddress(REG_NOTIFY_ADDRESS
);
306 if (DIGEST_SMTP_HOST
) {
307 $mail->Host
= DIGEST_SMTP_HOST
;
308 $mail->Mailer
= "smtp";
309 $mail->Username
= DIGEST_SMTP_LOGIN
;
310 $mail->Password
= DIGEST_SMTP_PASSWORD
;
313 // $mail->IsHTML(true);
314 $mail->Subject
= "Registration notice for Tiny Tiny RSS";
315 $mail->Body
= $reg_text;
316 // $mail->AltBody = $digest_text;
320 print_notice(__("Account created successfully."));
322 print "<p><form method=\"GET\" action=\"tt-rss.php\">
323 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
331 print_error('Plese check the form again, you have failed the robot test.');
332 print "<p><form method=\"GET\" action=\"tt-rss.php\">
333 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
342 <?php
print_notice(__('New user registrations are currently closed.')) ?
>
344 <?php
print "<p><form method=\"GET\" action=\"tt-rss.php\">
345 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">