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 set_include_path(get_include_path() . PATH_SEPARATOR
. "include");
9 require_once 'lib/phpmailer/class.phpmailer.php';
11 $action = $_REQUEST["action"];
13 require_once "functions.php";
14 require_once "sessions.php";
15 require_once "sanity_check.php";
16 require_once "config.php";
17 require_once "db.php";
19 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
21 init_connection($link);
23 if ($_REQUEST["format"] == "feed") {
24 header("Content-Type: text/xml");
26 print '<?xml version="1.0" encoding="utf-8"?>';
27 print "<feed xmlns=\"http://www.w3.org/2005/Atom\">
28 <id>".htmlspecialchars(SELF_URL_PATH
. "/register.php")."</id>
29 <title>Tiny Tiny RSS registration slots</title>
30 <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH
. "/register.php?format=feed")."\"/>
31 <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH
)."\"/>";
33 if (ENABLE_REGISTRATION
) {
34 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
35 $num_users = db_fetch_result($result, 0, "cu");
37 $num_users = REG_MAX_USERS
- $num_users;
38 if ($num_users < 0) $num_users = 0;
39 $reg_suffix = "enabled";
42 $reg_suffix = "disabled";
46 <id>".htmlspecialchars(SELF_URL_PATH
)."/register.php?$num_users"."</id>
47 <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH
. "/register.php")."\"/>";
49 print "<title>$num_users slots are currently available, registration $reg_suffix</title>";
50 print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>";
59 /* Remove users which didn't login after receiving their registration information */
61 if (DB_TYPE
== "pgsql") {
62 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
63 AND created < NOW() - INTERVAL '1 day' AND access_level = 0");
65 db_query($link, "DELETE FROM ttrss_users WHERE last_login IS NULL
66 AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0");
69 if (file_exists("register_expire_do.php")) {
70 require_once "register_expire_do.php";
73 if ($action == "check") {
74 header("Content-Type: application/xml");
76 $login = trim(db_escape_string($_REQUEST['login']));
78 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
79 LOWER(login) = LOWER('$login')");
81 $is_registered = db_num_rows($result) > 0;
85 printf("%d", $is_registered);
95 <title
>Create
new account
</title
>
96 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
97 <link rel
="stylesheet" type
="text/css" href
="utility.css">
98 <script type
="text/javascript" src
="js/functions.js"></script
>
99 <script type
="text/javascript" src
="lib/prototype.js"></script
>
100 <script type
="text/javascript" src
="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script
>
103 <script type
="text/javascript">
105 function checkUsername() {
108 var f
= document
.forms
['register_form'];
109 var login
= f
.login
.value
;
112 new Effect
.Highlight(f
.login
);
113 f
.sub_btn
.disabled
= true;
117 var query
= "register.php?action=check&login=" +
120 new Ajax
.Request(query
, {
121 onComplete
: function(transport
) {
125 var reply
= transport
.responseXML
;
127 var result
= reply
.getElementsByTagName('result')[0];
128 var result_code
= result
.firstChild
.nodeValue
;
130 if (result_code
== 0) {
131 new Effect
.Highlight(f
.login
, {startcolor
: '#00ff00'});
132 f
.sub_btn
.disabled
= false;
134 new Effect
.Highlight(f
.login
, {startcolor
: '#ff0000'});
135 f
.sub_btn
.disabled
= true;
138 exception_error("checkUsername_callback", e
);
144 exception_error("checkUsername", e
);
151 function validateRegForm() {
154 var f
= document
.forms
['register_form'];
156 if (f
.login
.value
.length
== 0) {
157 new Effect
.Highlight(f
.login
);
161 if (f
.email
.value
.length
== 0) {
162 new Effect
.Highlight(f
.email
);
166 if (f
.turing_test
.value
.length
== 0) {
167 new Effect
.Highlight(f
.turing_test
);
174 exception_error("validateRegForm", e
);
183 <div
class="floatingLogo"><img src
="images/logo_wide.png"></div
>
185 <h1
><?php
echo __("Create new account") ?
></h1
>
188 if (!ENABLE_REGISTRATION
) {
189 print_error(__("New user registrations are administratively disabled."));
191 print "<p><form method=\"GET\" action=\"backend.php\">
192 <input type=\"hidden\" name=\"op\" value=\"logout\">
193 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
199 <?php
if (REG_MAX_USERS
> 0) {
200 $result = db_query($link, "SELECT COUNT(*) AS cu FROM ttrss_users");
201 $num_users = db_fetch_result($result, 0, "cu");
204 <?php
if (!REG_MAX_USERS ||
$num_users < REG_MAX_USERS
) { ?
>
206 <!-- If you have any rules
or ToS you
'd like to display, enter them here -->
208 <?php if (file_exists("templates/register_notice.txt")) {
209 require_once "templates/register_notice.txt";
212 <?php if (!$action) { ?>
214 <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>
216 <form action="register.php" method="POST" name="register_form">
217 <input type="hidden" name="action" value="do_register">
220 <td><?php echo __('Desired login
:') ?></td><td>
223 <input type="submit" value="<?php echo __('Check availability
') ?>" onclick='return checkUsername()'>
225 <tr><td><?php echo __('Email
:') ?></td><td>
228 <tr><td><?php echo __('How much is two plus two
:') ?></td><td>
229 <input name="turing_test"></td></tr>
230 <tr><td colspan="2" align="right">
231 <input type="submit" name="sub_btn" value="<?php echo __('Submit registration
') ?>"
232 disabled="disabled" onclick='return validateRegForm()'>
237 <?php print "<p><form method=\"GET\" action=\"index.php\">
238 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
241 <?php } else if ($action == "do_register") { ?>
244 $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
245 $email = trim(db_escape_string($_REQUEST["email"]));
246 $test = trim(db_escape_string($_REQUEST["turing_test"]));
248 if (!$login || !$email || !$test) {
249 print_error(__("Your registration information is incomplete."));
250 print "<p><form method=\"GET\" action=\"index.php\">
251 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
256 if ($test == "four" || $test == "4") {
258 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
261 $is_registered = db_num_rows($result) > 0;
263 if ($is_registered) {
264 print_error(__('Sorry
, this username is already taken
.'));
265 print "<p><form method=\"GET\" action=\"index.php\">
266 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
270 $password = make_password();
272 $pwd_hash = encrypt_password($password, $login);
274 db_query($link, "INSERT INTO ttrss_users
275 (login,pwd_hash,access_level,last_login, email, created)
276 VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW())");
278 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
279 login = '$login' AND pwd_hash = '$pwd_hash'");
281 if (db_num_rows($result) != 1) {
282 print_error(__('Registration failed
.'));
283 print "<p><form method=\"GET\" action=\"index.php\">
284 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
288 $new_uid = db_fetch_result($result, 0, "id");
290 initialize_user($link, $new_uid);
294 "You are receiving this message, because you (or somebody else) have opened\n".
295 "an account at Tiny Tiny RSS.\n".
297 "Your login information is as follows:\n".
300 "Password: $password\n".
302 "Don't forget to login at least once to your
new account
, otherwise\n
".
303 "it will be deleted in
24 hours
.\n".
305 "If that wasn
't you, just ignore this message. Thanks.";
307 $mail = new PHPMailer();
309 $mail->PluginDir = "lib/phpmailer/";
310 $mail->SetLanguage("en", "lib/phpmailer/language/");
312 $mail->CharSet = "UTF-8";
314 $mail->From = DIGEST_FROM_ADDRESS;
315 $mail->FromName = DIGEST_FROM_NAME;
316 $mail->AddAddress($email);
318 if (DIGEST_SMTP_HOST) {
319 $mail->Host = DIGEST_SMTP_HOST;
320 $mail->Mailer = "smtp";
321 $mail->Username = DIGEST_SMTP_LOGIN;
322 $mail->Password = DIGEST_SMTP_PASSWORD;
325 // $mail->IsHTML(true);
326 $mail->Subject = "Registration information for Tiny Tiny RSS";
327 $mail->Body = $reg_text;
328 // $mail->AltBody = $digest_text;
332 if (!$rc) print_error($mail->ErrorInfo);
336 "New user had registered at your Tiny Tiny RSS installation.\n".
341 $mail = new PHPMailer();
343 $mail->PluginDir = "lib/phpmailer/";
344 $mail->SetLanguage("en", "lib/phpmailer/language/");
346 $mail->CharSet = "UTF-8";
348 $mail->From = DIGEST_FROM_ADDRESS;
349 $mail->FromName = DIGEST_FROM_NAME;
350 $mail->AddAddress(REG_NOTIFY_ADDRESS);
352 if (DIGEST_SMTP_HOST) {
353 $mail->Host = DIGEST_SMTP_HOST;
354 $mail->Mailer = "smtp";
355 $mail->Username = DIGEST_SMTP_LOGIN;
356 $mail->Password = DIGEST_SMTP_PASSWORD;
359 // $mail->IsHTML(true);
360 $mail->Subject = "Registration notice for Tiny Tiny RSS";
361 $mail->Body = $reg_text;
362 // $mail->AltBody = $digest_text;
366 print_notice(__("Account created successfully."));
368 print "<p><form method=\"GET\" action=\"index.php\">
369 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
377 print_error('Plese check the form again
, you have failed the robot test
.');
378 print "<p><form method=\"GET\" action=\"index.php\">
379 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
388 <?php print_notice(__('New user registrations are currently closed
.')) ?>
390 <?php print "<p><form method=\"GET\" action=\"index.php\">
391 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">