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 if ($_REQUEST["format"] == "feed") {
20 header("Content-Type: text/xml");
22 print '<?xml version="1.0" encoding="utf-8"?>';
23 print "<feed xmlns=\"http://www.w3.org/2005/Atom\">
24 <id>".htmlspecialchars(SELF_URL_PATH
. "/register.php")."</id>
25 <title>Tiny Tiny RSS registration slots</title>
26 <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH
. "/register.php?format=feed")."\"/>
27 <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH
)."\"/>";
29 if (ENABLE_REGISTRATION
) {
30 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
31 $num_users = db_fetch_result($result, 0, "cu");
33 $num_users = REG_MAX_USERS
- $num_users;
34 if ($num_users < 0) $num_users = 0;
35 $reg_suffix = "enabled";
38 $reg_suffix = "disabled";
42 <id>".htmlspecialchars(SELF_URL_PATH
)."/register.php?$num_users"."</id>
43 <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH
. "/register.php")."\"/>";
45 print "<title>$num_users slots are currently available, registration $reg_suffix</title>";
46 print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>";
55 /* Remove users which didn't login after receiving their registration information */
57 if (DB_TYPE
== "pgsql") {
58 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
59 AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
61 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
62 AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
65 if (file_exists("register_expire_do.php")) {
66 require_once "register_expire_do.php";
69 if ($action == "check") {
70 header("Content-Type: application/xml");
72 $login = trim(db_escape_string($_REQUEST['login']));
74 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
75 LOWER(login) = LOWER('$login')");
77 $is_registered = db_num_rows($result) > 0;
81 printf("%d", $is_registered);
91 <title
>Create
new account
</title
>
92 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
93 <link rel
="stylesheet" type
="text/css" href
="utility.css">
94 <script type
="text/javascript" src
="functions.js"></script
>
95 <script type
="text/javascript" src
="lib/prototype.js"></script
>
96 <script type
="text/javascript" src
="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
99 <script type
="text/javascript">
101 function checkUsername() {
104 var f
= document
.forms
['register_form'];
105 var login
= f
.login
.value
;
108 new Effect
.Highlight(f
.login
);
109 f
.sub_btn
.disabled
= true;
113 var query
= "register.php?action=check&login=" +
116 new Ajax
.Request(query
, {
117 onComplete
: function(transport
) {
121 var reply
= transport
.responseXML
;
123 var result
= reply
.getElementsByTagName('result')[0];
124 var result_code
= result
.firstChild
.nodeValue
;
126 if (result_code
== 0) {
127 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
128 f
.sub_btn
.disabled
= false;
130 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
131 f
.sub_btn
.disabled
= true;
134 exception_error("checkUsername_callback", e
);
140 exception_error("checkUsername", e
);
147 function validateRegForm() {
150 var f
= document
.forms
['register_form'];
152 if (f
.login
.value
.length
== 0) {
153 new Effect
.Highlight(f
.login
);
157 if (f
.email
.value
.length
== 0) {
158 new Effect
.Highlight(f
.email
);
162 if (f
.turing_test
.value
.length
== 0) {
163 new Effect
.Highlight(f
.turing_test
);
170 exception_error("validateRegForm", e
);
179 <div
class="floatingLogo"><img src
="images/logo_wide.png"></div
>
181 <h1
><?php
echo __("Create new account") ?
></h1
>
184 if (!ENABLE_REGISTRATION
) {
185 print_error(__("New user registrations are administratively disabled."));
187 print "<p><form method=\"GET\" action=\"backend.php\">
188 <input type=\"hidden\" name=\"op\" value=\"logout\">
189 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
195 <?php
if (REG_MAX_USERS
> 0) {
196 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
197 $num_users = db_fetch_result($result, 0, "cu");
200 <?php
if (!REG_MAX_USERS ||
$num_users < REG_MAX_USERS
) { ?
>
202 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
204 <?php if (file_exists("templates/register_notice.txt")) {
205 require_once "templates/register_notice.txt";
208 <?php if (!$action) { ?>
210 <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>
212 <form action="register.php" method="POST" name="register_form">
213 <input type="hidden" name="action" value="do_register">
216 <td><?php echo __('Desired login
:') ?></td><td>
219 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
221 <tr><td><?php echo __('Email
:') ?></td><td>
224 <tr><td><?php echo __('How much is two plus two
:') ?></td><td>
225 <input name="turing_test"></td></tr>
226 <tr><td colspan="2" align="right">
227 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
') ?>"
228 disabled="disabled" onclick='return validateRegForm()'>
233 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
234 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
237 <?php } else if ($action == "do_register") { ?>
240 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
241 $email = trim(db_escape_string($_REQUEST["email"]));
242 $test = trim(db_escape_string($_REQUEST["turing_test"]));
244 if (!$login || !$email || !$test) {
245 print_error(__("Your registration information is incomplete."));
246 print "<p><form method=\"GET\" action=\"tt-rss.php\">
247 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
252 if ($test == "four" || $test == "4") {
254 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
257 $is_registered = db_num_rows($result) > 0;
259 if ($is_registered) {
260 print_error(__('Sorry
, this username is already taken
.'));
261 print "<p><form method=\"GET\" action=\"tt-rss.php\">
262 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
266 $password = make_password();
268 $pwd_hash = encrypt_password($password, $login);
270 db_query($link, "INSERT INTO ttrss_users
271 (login,pwd_hash,access_level,last_login, email, created)
272 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
274 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
275 login = '$login' AND pwd_hash = '$pwd_hash'");
277 if (db_num_rows($result) != 1) {
278 print_error(__('Registration failed
.'));
279 print "<p><form method=\"GET\" action=\"tt-rss.php\">
280 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
284 $new_uid = db_fetch_result($result, 0, "id");
286 initialize_user($link, $new_uid);
290 "You are receiving this message, because you (or somebody else) have opened\n".
291 "an account at Tiny Tiny RSS.\n".
293 "Your login information is as follows:\n".
296 "Password: $password\n".
298 "Don't forget to login at least once to your
new account
, otherwise\n
".
299 "it will be deleted in
24 hours
.\n".
301 "If that wasn
't you, just ignore this message. Thanks.";
303 $mail = new PHPMailer();
305 $mail->PluginDir = "lib/phpmailer/";
306 $mail->SetLanguage("en", "lib/phpmailer/language/");
308 $mail->CharSet = "UTF-8";
310 $mail->From = DIGEST_FROM_ADDRESS;
311 $mail->FromName = DIGEST_FROM_NAME;
312 $mail->AddAddress($email);
314 if (DIGEST_SMTP_HOST) {
315 $mail->Host = DIGEST_SMTP_HOST;
316 $mail->Mailer = "smtp";
317 $mail->Username = DIGEST_SMTP_LOGIN;
318 $mail->Password = DIGEST_SMTP_PASSWORD;
321 // $mail->IsHTML(true);
322 $mail->Subject = "Registration information for Tiny Tiny RSS";
323 $mail->Body = $reg_text;
324 // $mail->AltBody = $digest_text;
328 if (!$rc) print_error($mail->ErrorInfo);
332 "New user had registered at your Tiny Tiny RSS installation.\n".
337 $mail = new PHPMailer();
339 $mail->PluginDir = "lib/phpmailer/";
340 $mail->SetLanguage("en", "lib/phpmailer/language/");
342 $mail->CharSet = "UTF-8";
344 $mail->From = DIGEST_FROM_ADDRESS;
345 $mail->FromName = DIGEST_FROM_NAME;
346 $mail->AddAddress(REG_NOTIFY_ADDRESS);
348 if (DIGEST_SMTP_HOST) {
349 $mail->Host = DIGEST_SMTP_HOST;
350 $mail->Mailer = "smtp";
351 $mail->Username = DIGEST_SMTP_LOGIN;
352 $mail->Password = DIGEST_SMTP_PASSWORD;
355 // $mail->IsHTML(true);
356 $mail->Subject = "Registration notice for Tiny Tiny RSS";
357 $mail->Body = $reg_text;
358 // $mail->AltBody = $digest_text;
362 print_notice(__("Account created successfully."));
364 print "<p><form method=\"GET\" action=\"tt-rss.php\">
365 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
373 print_error('Plese check the form again
, you have failed the robot test
.');
374 print "<p><form method=\"GET\" action=\"tt-rss.php\">
375 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
384 <?php print_notice(__('New user registrations are currently closed
.')) ?>
386 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
387 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">