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 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 (file_exists("register_expire_do.php")) {
35 require_once "register_expire_do.php";
38 if ($action == "check") {
39 header("Content-Type: application/xml");
41 $login = trim(db_escape_string($_REQUEST['login']));
43 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
44 LOWER(login) = LOWER('$login')");
46 $is_registered = db_num_rows($result) > 0;
50 printf("%d", $is_registered);
60 <title
>Create
new account
</title
>
61 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
62 <link rel
="stylesheet" type
="text/css" href
="utility.css">
63 <script type
="text/javascript" src
="functions.js"></script
>
64 <script type
="text/javascript" src
="prototype.js"></script
>
65 <script type
="text/javascript" src
="scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
68 <script type
="text/javascript">
70 function checkUsername() {
73 var f
= document
.forms
['register_form'];
74 var login
= f
.login
.value
;
77 new Effect
.Highlight(f
.login
);
78 f
.sub_btn
.disabled
= true;
82 var query
= "register.php?action=check&login=" +
85 new Ajax
.Request(query
, {
86 onComplete
: function(transport
) {
90 var reply
= transport
.responseXML
;
92 var result
= reply
.getElementsByTagName('result')[0];
93 var result_code
= result
.firstChild
.nodeValue
;
95 if (result_code
== 0) {
96 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
97 f
.sub_btn
.disabled
= false;
99 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
100 f
.sub_btn
.disabled
= true;
103 exception_error("checkUsername_callback", e
);
109 exception_error("checkUsername", e
);
116 function validateRegForm() {
119 var f
= document
.forms
['register_form'];
121 if (f
.login
.value
.length
== 0) {
122 new Effect
.Highlight(f
.login
);
126 if (f
.email
.value
.length
== 0) {
127 new Effect
.Highlight(f
.email
);
131 if (f
.turing_test
.value
.length
== 0) {
132 new Effect
.Highlight(f
.turing_test
);
139 exception_error("validateRegForm", e
);
148 <div
class="floatingLogo"><img src
="images/ttrss_logo.png"></div
>
150 <h1
><?php
echo __("Create new account") ?
></h1
>
153 if (!ENABLE_REGISTRATION
) {
154 print_error(__("New user registrations are administratively disabled."));
156 print "<p><form method=\"GET\" action=\"logout.php\">
157 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
163 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
165 <?php if (file_exists("templates/register_notice.txt")) {
166 require_once "templates/register_notice.txt";
169 <?php if (REG_MAX_USERS > 0) {
170 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
171 $num_users = db_fetch_result($result, 0, "cu");
174 <? if (!REG_MAX_USERS || $num_users < REG_MAX_USERS) { ?>
176 <? if (!$action) { ?>
178 <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>
180 <form action="register.php" method="POST" name="register_form">
181 <input type="hidden" name="action" value="do_register">
184 <td><?php echo __('Desired login
:') ?></td><td>
187 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
189 <td><?php echo __('Email
:') ?></td><td>
192 <td><?php echo __('How much is two plus two
:') ?></td><td>
193 <input name="turing_test"></td></tr>
194 <tr><td colspan="2" align="right">
195 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
"') ?>"
196 disabled
="true" onclick
='return validateRegForm()'>
201 <?php
print "<p><form method=\"GET\" action=\"tt-rss.php\">
202 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
205 <?
} else if ($action == "do_register") { ?
>
208 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
209 $email = trim(db_escape_string($_REQUEST["email"]));
210 $test = trim(db_escape_string($_REQUEST["turing_test"]));
212 if (!$login ||
!$email ||
!$test) {
213 print_error(__("Your registration information is incomplete."));
214 print "<p><form method=\"GET\" action=\"tt-rss.php\">
215 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
220 if ($test == "four" ||
$test == "4") {
222 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
225 $is_registered = db_num_rows($result) > 0;
227 if ($is_registered) {
228 print_error(__('Sorry, this username is already taken.'));
229 print "<p><form method=\"GET\" action=\"tt-rss.php\">
230 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
234 $password = make_password();
236 $pwd_hash = encrypt_password($password, $login);
238 db_query($link, "INSERT INTO ttrss_users
239 (login,pwd_hash,access_level,last_login, email, created)
240 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
242 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
243 login = '$login' AND pwd_hash = '$pwd_hash'");
245 if (db_num_rows($result) != 1) {
246 print_error(__('Registration failed.'));
247 print "<p><form method=\"GET\" action=\"tt-rss.php\">
248 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
252 $new_uid = db_fetch_result($result, 0, "id");
254 initialize_user($link, $new_uid);
258 "You are receiving this message, because you (or somebody else) have opened\n".
259 "an account at Tiny Tiny RSS.\n".
261 "Your login information is as follows:\n".
264 "Password: $password\n".
266 "Don't forget to login at least once to your new account, otherwise\n".
267 "it will be deleted in 24 hours.\n".
269 "If that wasn't you, just ignore this message. Thanks.";
271 $mail = new PHPMailer();
273 $mail->PluginDir
= "phpmailer/";
274 $mail->SetLanguage("en", "phpmailer/language/");
276 $mail->CharSet
= "UTF-8";
278 $mail->From
= DIGEST_FROM_ADDRESS
;
279 $mail->FromName
= DIGEST_FROM_NAME
;
280 $mail->AddAddress($email);
282 if (DIGEST_SMTP_HOST
) {
283 $mail->Host
= DIGEST_SMTP_HOST
;
284 $mail->Mailer
= "smtp";
285 $mail->Username
= DIGEST_SMTP_LOGIN
;
286 $mail->Password
= DIGEST_SMTP_PASSWORD
;
289 // $mail->IsHTML(true);
290 $mail->Subject
= "Registration information for Tiny Tiny RSS";
291 $mail->Body
= $reg_text;
292 // $mail->AltBody = $digest_text;
296 if (!$rc) print_error($mail->ErrorInfo
);
300 "New user had registered at your Tiny Tiny RSS installation.\n".
305 $mail = new PHPMailer();
307 $mail->PluginDir
= "phpmailer/";
308 $mail->SetLanguage("en", "phpmailer/language/");
310 $mail->CharSet
= "UTF-8";
312 $mail->From
= DIGEST_FROM_ADDRESS
;
313 $mail->FromName
= DIGEST_FROM_NAME
;
314 $mail->AddAddress(REG_NOTIFY_ADDRESS
);
316 if (DIGEST_SMTP_HOST
) {
317 $mail->Host
= DIGEST_SMTP_HOST
;
318 $mail->Mailer
= "smtp";
319 $mail->Username
= DIGEST_SMTP_LOGIN
;
320 $mail->Password
= DIGEST_SMTP_PASSWORD
;
323 // $mail->IsHTML(true);
324 $mail->Subject
= "Registration notice for Tiny Tiny RSS";
325 $mail->Body
= $reg_text;
326 // $mail->AltBody = $digest_text;
330 print_notice(__("Account created successfully."));
332 print "<p><form method=\"GET\" action=\"tt-rss.php\">
333 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
341 print_error('Plese check the form again, you have failed the robot test.');
342 print "<p><form method=\"GET\" action=\"tt-rss.php\">
343 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
352 <?php
print_notice(__('New user registrations are currently closed.')) ?
>
354 <?php
print "<p><form method=\"GET\" action=\"tt-rss.php\">
355 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">