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 require_once "sessions.php";
13 require_once "sanity_check.php";
14 require_once "functions.php";
15 require_once "config.php";
16 require_once "db.php";
18 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
20 init_connection($link);
22 /* Remove users which didn't login after receiving their registration information */
24 if (DB_TYPE
== "pgsql") {
25 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
26 AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
28 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
29 AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
32 if (file_exists("register_expire_do.php")) {
33 require_once "register_expire_do.php";
36 if ($action == "check") {
37 header("Content-Type: application/xml");
39 $login = trim(db_escape_string($_REQUEST['login']));
41 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
42 LOWER(login) = LOWER('$login')");
44 $is_registered = db_num_rows($result) > 0;
48 printf("%d", $is_registered);
58 <title
>Create
new account
</title
>
59 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
60 <link rel
="stylesheet" type
="text/css" href
="utility.css">
61 <script type
="text/javascript" src
="functions.js"></script
>
62 <script type
="text/javascript" src
="lib/prototype.js"></script
>
63 <script type
="text/javascript" src
="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
66 <script type
="text/javascript">
68 function checkUsername() {
71 var f
= document
.forms
['register_form'];
72 var login
= f
.login
.value
;
75 new Effect
.Highlight(f
.login
);
76 f
.sub_btn
.disabled
= true;
80 var query
= "register.php?action=check&login=" +
83 new Ajax
.Request(query
, {
84 onComplete
: function(transport
) {
88 var reply
= transport
.responseXML
;
90 var result
= reply
.getElementsByTagName('result')[0];
91 var result_code
= result
.firstChild
.nodeValue
;
93 if (result_code
== 0) {
94 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
95 f
.sub_btn
.disabled
= false;
97 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
98 f
.sub_btn
.disabled
= true;
101 exception_error("checkUsername_callback", e
);
107 exception_error("checkUsername", e
);
114 function validateRegForm() {
117 var f
= document
.forms
['register_form'];
119 if (f
.login
.value
.length
== 0) {
120 new Effect
.Highlight(f
.login
);
124 if (f
.email
.value
.length
== 0) {
125 new Effect
.Highlight(f
.email
);
129 if (f
.turing_test
.value
.length
== 0) {
130 new Effect
.Highlight(f
.turing_test
);
137 exception_error("validateRegForm", e
);
146 <div
class="floatingLogo"><img src
="images/ttrss_logo.png"></div
>
148 <h1
><?php
echo __("Create new account") ?
></h1
>
151 if (!ENABLE_REGISTRATION
) {
152 print_error(__("New user registrations are administratively disabled."));
154 print "<p><form method=\"GET\" action=\"logout.php\">
155 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
161 <?php
if (REG_MAX_USERS
> 0) {
162 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
163 $num_users = db_fetch_result($result, 0, "cu");
166 <?
if (!REG_MAX_USERS ||
$num_users < REG_MAX_USERS
) { ?
>
168 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
170 <?php if (file_exists("templates/register_notice.txt")) {
171 require_once "templates/register_notice.txt";
174 <? if (!$action) { ?>
176 <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>
178 <form action="register.php" method="POST" name="register_form">
179 <input type="hidden" name="action" value="do_register">
182 <td><?php echo __('Desired login
:') ?></td><td>
185 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
187 <td><?php echo __('Email
:') ?></td><td>
190 <td><?php echo __('How much is two plus two
:') ?></td><td>
191 <input name="turing_test"></td></tr>
192 <tr><td colspan="2" align="right">
193 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
') ?>"
194 disabled="true" onclick='return validateRegForm()'>
199 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
200 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
203 <? } else if ($action == "do_register") { ?>
206 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
207 $email = trim(db_escape_string($_REQUEST["email"]));
208 $test = trim(db_escape_string($_REQUEST["turing_test"]));
210 if (!$login || !$email || !$test) {
211 print_error(__("Your registration information is incomplete."));
212 print "<p><form method=\"GET\" action=\"tt-rss.php\">
213 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
218 if ($test == "four" || $test == "4") {
220 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
223 $is_registered = db_num_rows($result) > 0;
225 if ($is_registered) {
226 print_error(__('Sorry
, this username is already taken
.'));
227 print "<p><form method=\"GET\" action=\"tt-rss.php\">
228 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
232 $password = make_password();
234 $pwd_hash = encrypt_password($password, $login);
236 db_query($link, "INSERT INTO ttrss_users
237 (login,pwd_hash,access_level,last_login, email, created)
238 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
240 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
241 login = '$login' AND pwd_hash = '$pwd_hash'");
243 if (db_num_rows($result) != 1) {
244 print_error(__('Registration failed
.'));
245 print "<p><form method=\"GET\" action=\"tt-rss.php\">
246 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
250 $new_uid = db_fetch_result($result, 0, "id");
252 initialize_user($link, $new_uid);
256 "You are receiving this message, because you (or somebody else) have opened\n".
257 "an account at Tiny Tiny RSS.\n".
259 "Your login information is as follows:\n".
262 "Password: $password\n".
264 "Don't forget to login at least once to your
new account
, otherwise\n
".
265 "it will be deleted in
24 hours
.\n".
267 "If that wasn
't you, just ignore this message. Thanks.";
269 $mail = new PHPMailer();
271 $mail->PluginDir = "lib/phpmailer/";
272 $mail->SetLanguage("en", "lib/phpmailer/language/");
274 $mail->CharSet = "UTF-8";
276 $mail->From = DIGEST_FROM_ADDRESS;
277 $mail->FromName = DIGEST_FROM_NAME;
278 $mail->AddAddress($email);
280 if (DIGEST_SMTP_HOST) {
281 $mail->Host = DIGEST_SMTP_HOST;
282 $mail->Mailer = "smtp";
283 $mail->Username = DIGEST_SMTP_LOGIN;
284 $mail->Password = DIGEST_SMTP_PASSWORD;
287 // $mail->IsHTML(true);
288 $mail->Subject = "Registration information for Tiny Tiny RSS";
289 $mail->Body = $reg_text;
290 // $mail->AltBody = $digest_text;
294 if (!$rc) print_error($mail->ErrorInfo);
298 "New user had registered at your Tiny Tiny RSS installation.\n".
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(REG_NOTIFY_ADDRESS);
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 notice for Tiny Tiny RSS";
323 $mail->Body = $reg_text;
324 // $mail->AltBody = $digest_text;
328 print_notice(__("Account created successfully."));
330 print "<p><form method=\"GET\" action=\"tt-rss.php\">
331 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
339 print_error('Plese check the form again
, you have failed the robot test
.');
340 print "<p><form method=\"GET\" action=\"tt-rss.php\">
341 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
350 <?php print_notice(__('New user registrations are currently closed
.')) ?>
352 <?php print "<p><form method=\"GET\" action=\"tt-rss.php\">
353 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">