2 // This file uses two additional include files:
4 // 1) templates/register_notice.txt - displayed above the registration form
5 // 2) register_expire_do.php - contains user expiration queries when necessary
7 $action = $_REQUEST["action"];
9 require_once "functions.php";
10 require_once "sessions.php";
11 require_once "sanity_check.php";
12 require_once "config.php";
13 require_once "db.php";
15 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
17 init_connection($link);
19 /* Remove users which didn't login after receiving their registration information */
21 if (DB_TYPE
== "pgsql") {
22 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
23 AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
25 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
26 AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
29 if (file_exists("register_expire_do.php")) {
30 require_once "register_expire_do.php";
33 if ($action == "check") {
34 header("Content-Type: application/xml");
36 $login = trim(db_escape_string($_REQUEST['login']));
38 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
39 LOWER(login) = LOWER('$login')");
41 $is_registered = db_num_rows($result) > 0;
45 printf("%d", $is_registered);
55 <title
>Create
new account
</title
>
56 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
57 <link rel
="stylesheet" type
="text/css" href
="utility.css">
58 <script type
="text/javascript" src
="functions.js"></script
>
59 <script type
="text/javascript" src
="lib/prototype.js"></script
>
60 <script type
="text/javascript" src
="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
63 <script type
="text/javascript">
65 function checkUsername() {
68 var f
= document
.forms
['register_form'];
69 var login
= f
.login
.value
;
72 new Effect
.Highlight(f
.login
);
73 f
.sub_btn
.disabled
= true;
77 var query
= "register.php?action=check&login=" +
80 new Ajax
.Request(query
, {
81 onComplete
: function(transport
) {
85 var reply
= transport
.responseXML
;
87 var result
= reply
.getElementsByTagName('result')[0];
88 var result_code
= result
.firstChild
.nodeValue
;
90 if (result_code
== 0) {
91 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
92 f
.sub_btn
.disabled
= false;
94 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
95 f
.sub_btn
.disabled
= true;
98 exception_error("checkUsername_callback", e
);
104 exception_error("checkUsername", e
);
111 function validateRegForm() {
114 var f
= document
.forms
['register_form'];
116 if (f
.login
.value
.length
== 0) {
117 new Effect
.Highlight(f
.login
);
121 if (f
.email
.value
.length
== 0) {
122 new Effect
.Highlight(f
.email
);
126 if (f
.turing_test
.value
.length
== 0) {
127 new Effect
.Highlight(f
.turing_test
);
134 exception_error("validateRegForm", e
);
143 <div
class="floatingLogo"><img src
="images/logo_wide.png"></div
>
145 <h1
><?php
echo __("Create new account") ?
></h1
>
148 if (!ENABLE_REGISTRATION
) {
149 print_error(__("New user registrations are administratively disabled."));
151 print "<p><form method=\"GET\" action=\"backend.php\">
152 <input type=\"hidden\" name=\"op\" value=\"logout\">
153 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
159 <?php
if (REG_MAX_USERS
> 0) {
160 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
161 $num_users = db_fetch_result($result, 0, "cu");
164 <?php
if (!REG_MAX_USERS ||
$num_users < REG_MAX_USERS
) { ?
>
166 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
168 <?php if (file_exists("templates/register_notice.txt")) {
169 require_once "templates/register_notice.txt";
172 <?php if (!$action) { ?>
174 <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>
176 <form action="register.php" method="POST" name="register_form">
177 <input type="hidden" name="action" value="do_register">
180 <td><?php echo __('Desired login
:') ?></td><td>
183 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
185 <td><?php echo __('Email
:') ?></td><td>
188 <td><?php echo __('How much is two plus two
:') ?></td><td>
189 <input name="turing_test"></td></tr>
190 <tr><td colspan="2" align="right">
191 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
') ?>"
192 disabled="true" onclick='return validateRegForm()'>
197 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
198 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
201 <?php } else if ($action == "do_register") { ?>
204 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
205 $email = trim(db_escape_string($_REQUEST["email"]));
206 $test = trim(db_escape_string($_REQUEST["turing_test"]));
208 if (!$login || !$email || !$test) {
209 print_error(__("Your registration information is incomplete."));
210 print "<p><form method=\"GET\" action=\"tt-rss.php\">
211 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
216 if ($test == "four" || $test == "4") {
218 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
221 $is_registered = db_num_rows($result) > 0;
223 if ($is_registered) {
224 print_error(__('Sorry
, this username is already taken
.'));
225 print "<p><form method=\"GET\" action=\"tt-rss.php\">
226 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
230 $password = make_password();
232 $pwd_hash = encrypt_password($password, $login);
234 db_query($link, "INSERT INTO ttrss_users
235 (login,pwd_hash,access_level,last_login, email, created)
236 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
238 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
239 login = '$login' AND pwd_hash = '$pwd_hash'");
241 if (db_num_rows($result) != 1) {
242 print_error(__('Registration failed
.'));
243 print "<p><form method=\"GET\" action=\"tt-rss.php\">
244 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
248 $new_uid = db_fetch_result($result, 0, "id");
250 initialize_user($link, $new_uid);
254 "You are receiving this message, because you (or somebody else) have opened\n".
255 "an account at Tiny Tiny RSS.\n".
257 "Your login information is as follows:\n".
260 "Password: $password\n".
262 "Don't forget to login at least once to your
new account
, otherwise\n
".
263 "it will be deleted in
24 hours
.\n".
265 "If that wasn
't you, just ignore this message. Thanks.";
267 $mail = new PHPMailer();
269 $mail->PluginDir = "lib/phpmailer/";
270 $mail->SetLanguage("en", "lib/phpmailer/language/");
272 $mail->CharSet = "UTF-8";
274 $mail->From = DIGEST_FROM_ADDRESS;
275 $mail->FromName = DIGEST_FROM_NAME;
276 $mail->AddAddress($email);
278 if (DIGEST_SMTP_HOST) {
279 $mail->Host = DIGEST_SMTP_HOST;
280 $mail->Mailer = "smtp";
281 $mail->Username = DIGEST_SMTP_LOGIN;
282 $mail->Password = DIGEST_SMTP_PASSWORD;
285 // $mail->IsHTML(true);
286 $mail->Subject = "Registration information for Tiny Tiny RSS";
287 $mail->Body = $reg_text;
288 // $mail->AltBody = $digest_text;
292 if (!$rc) print_error($mail->ErrorInfo);
296 "New user had registered at your Tiny Tiny RSS installation.\n".
301 $mail = new PHPMailer();
303 $mail->PluginDir = "lib/phpmailer/";
304 $mail->SetLanguage("en", "lib/phpmailer/language/");
306 $mail->CharSet = "UTF-8";
308 $mail->From = DIGEST_FROM_ADDRESS;
309 $mail->FromName = DIGEST_FROM_NAME;
310 $mail->AddAddress(REG_NOTIFY_ADDRESS);
312 if (DIGEST_SMTP_HOST) {
313 $mail->Host = DIGEST_SMTP_HOST;
314 $mail->Mailer = "smtp";
315 $mail->Username = DIGEST_SMTP_LOGIN;
316 $mail->Password = DIGEST_SMTP_PASSWORD;
319 // $mail->IsHTML(true);
320 $mail->Subject = "Registration notice for Tiny Tiny RSS";
321 $mail->Body = $reg_text;
322 // $mail->AltBody = $digest_text;
326 print_notice(__("Account created successfully."));
328 print "<p><form method=\"GET\" action=\"tt-rss.php\">
329 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
337 print_error('Plese check the form again
, you have failed the robot test
.');
338 print "<p><form method=\"GET\" action=\"tt-rss.php\">
339 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
348 <?php print_notice(__('New user registrations are currently closed
.')) ?>
350 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
351 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">