Issues (1270)

register.php (22 issues)

1
<!DOCTYPE html>
2
<html>
3
<head>
4
<title>Create new account</title>
5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
<?php echo stylesheet_tag("css/default.css") ?>
0 ignored issues
show
Deprecated Code introduced by
The function stylesheet_tag() has been deprecated: Use Twig filter cssTag ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

6
<?php echo /** @scrutinizer ignore-deprecated */ stylesheet_tag("css/default.css") ?>

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Are you sure the usage of stylesheet_tag('css/default.css') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
7
<?php echo javascript_tag("js/common.js") ?>
0 ignored issues
show
Are you sure the usage of javascript_tag('js/common.js') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Deprecated Code introduced by
The function javascript_tag() has been deprecated: Use Twig filter jsTag ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

7
<?php echo /** @scrutinizer ignore-deprecated */ javascript_tag("js/common.js") ?>

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
8
<?php echo javascript_tag("lib/prototype.js") ?>
0 ignored issues
show
Are you sure the usage of javascript_tag('lib/prototype.js') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Deprecated Code introduced by
The function javascript_tag() has been deprecated: Use Twig filter jsTag ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

8
<?php echo /** @scrutinizer ignore-deprecated */ javascript_tag("lib/prototype.js") ?>

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
9
<?php echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls") ?>
0 ignored issues
show
Deprecated Code introduced by
The function javascript_tag() has been deprecated: Use Twig filter jsTag ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

9
<?php echo /** @scrutinizer ignore-deprecated */ javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls") ?>

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Are you sure the usage of javascript_tag('lib/scri...load=effects,controls') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
10
</head>
11
12
<script type="text/javascript">
13
14
	public function checkUsername() {
15
16
		try {
17
			var f = document.forms['register_form'];
18
			var login = f.login.value;
19
20
			if (login == "") {
21
				new Effect.Highlight(f.login);
22
				f.sub_btn.disabled = true;
23
				return false;
24
			}
25
26
			var query = "register.php?action=check&login=" +
27
					encodeURIComponent(login);
28
29
			new Ajax.Request(query, {
30
				onComplete: function(transport) {
31
32
					try {
33
34
						var reply = transport.responseXML;
35
36
						var result = reply.getElementsByTagName('result')[0];
37
						var result_code = result.firstChild.nodeValue;
38
39
						if (result_code == 0) {
40
							new Effect.Highlight(f.login, {startcolor : '#00ff00'});
41
							f.sub_btn.disabled = false;
42
						} else {
43
							new Effect.Highlight(f.login, {startcolor : '#ff0000'});
44
							f.sub_btn.disabled = true;
45
						}
46
					} catch (e) {
47
						App.Error.report(e);
48
					}
49
50
				} });
51
52
		} catch (e) {
53
			App.Error.report(e);
54
		}
55
56
		return false;
57
58
	}
59
60
	public function validateRegForm() {
61
		try {
62
63
			var f = document.forms['register_form'];
64
65
			if (f.login.value.length == 0) {
66
				new Effect.Highlight(f.login);
67
				return false;
68
			}
69
70
			if (f.email.value.length == 0) {
71
				new Effect.Highlight(f.email);
72
				return false;
73
			}
74
75
			if (f.turing_test.value.length == 0) {
76
				new Effect.Highlight(f.turing_test);
77
				return false;
78
			}
79
80
			return true;
81
82
		} catch (e) {
83
			alert(e.stack);
84
			return false;
85
		}
86
	}
87
88
</script>
89
90
<body class="claro ttrss_utility">
91
92
<h1><?php echo __("Create new account") ?></h1>
93
94
<div class="content">
95
96
<?php
97
        if (!ENABLE_REGISTRATION) {
0 ignored issues
show
The constant ENABLE_REGISTRATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
98
            print_error(__("New user registrations are administratively disabled."));
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

98
            /** @scrutinizer ignore-deprecated */ print_error(__("New user registrations are administratively disabled."));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
The call to print_error() has too many arguments starting with __('New user registratio...istratively disabled.'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
            /** @scrutinizer ignore-call */ 
99
            print_error(__("New user registrations are administratively disabled."));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
99
100
            print "<p><form method=\"GET\" action=\"backend.php\">
101
				<input type=\"hidden\" name=\"op\" value=\"logout\">
102
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
103
				</form>";
104
            return;
105
        }
106
?>
107
108
<?php if (REG_MAX_USERS > 0) {
0 ignored issues
show
The constant REG_MAX_USERS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
109
        $result = db_query("SELECT COUNT(*) AS cu FROM ttrss_users");
110
        $num_users = db_fetch_result($result, 0, "cu");
111
} ?>
112
113
<?php if (!REG_MAX_USERS || $num_users < REG_MAX_USERS) { ?>
114
115
	<!-- If you have any rules or ToS you'd like to display, enter them here -->
116
117
	<?php	if (file_exists("templates/register_notice.txt")) {
118
            require_once "templates/register_notice.txt";
119
    } ?>
120
121
	<?php if (!$action) { ?>
122
123
	<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>
124
125
	<form action="register.php" method="POST" name="register_form">
126
	<input type="hidden" name="action" value="do_register">
127
	<table>
128
	<tr>
129
	<td><?php echo __('Desired login:') ?></td><td>
130
		<input name="login" required>
131
	</td><td>
132
		<input type="submit" value="<?php echo __('Check availability') ?>" onclick='return checkUsername()'>
133
	</td></tr>
134
	<tr><td><?php echo __('Email:') ?></td><td>
135
		<input name="email" type="email" required>
136
	</td></tr>
137
	<tr><td><?php echo __('How much is two plus two:') ?></td><td>
138
		<input name="turing_test" required></td></tr>
139
	<tr><td colspan="2" align="right">
140
	<input type="submit" name="sub_btn" value="<?php echo __('Submit registration') ?>"
141
			disabled="disabled" onclick='return validateRegForm()'>
142
	</td></tr>
143
	</table>
144
	</form>
145
146
	<?php print "<p><form method=\"GET\" action=\"index.php\">
147
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
148
				</form>"; ?>
149
150
	<?php } else if ($action == "do_register") { ?>
151
152
	<?php
153
        $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"])));
154
        $email = trim(db_escape_string($_REQUEST["email"]));
155
        $test = trim(db_escape_string($_REQUEST["turing_test"]));
156
157
        if (!$login || !$email || !$test) {
158
            print_error(__("Your registration information is incomplete."));
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

158
            /** @scrutinizer ignore-deprecated */ print_error(__("Your registration information is incomplete."));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
159
            print "<p><form method=\"GET\" action=\"index.php\">
160
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
161
				</form>";
162
            return;
163
        }
164
165
        if ($test == "four" || $test == "4") {
166
167
            $result = db_query("SELECT id FROM ttrss_users WHERE
168
				login = '$login'");
169
170
            $is_registered = db_num_rows($result) > 0;
171
172
            if ($is_registered) {
173
                print_error(__('Sorry, this username is already taken.'));
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

173
                /** @scrutinizer ignore-deprecated */ print_error(__('Sorry, this username is already taken.'));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
174
                print "<p><form method=\"GET\" action=\"index.php\">
175
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
176
				</form>";
177
            } else {
178
179
                $password = make_password();
180
181
                $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
182
                $pwd_hash = encrypt_password($password, $salt, true);
183
184
                db_query("INSERT INTO ttrss_users
185
					(login,pwd_hash,access_level,last_login, email, created, salt)
186
					VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW(), '$salt')");
187
188
                $result = db_query("SELECT id FROM ttrss_users WHERE
189
					login = '$login' AND pwd_hash = '$pwd_hash'");
190
191
                if (db_num_rows($result) != 1) {
192
                    print_error(__('Registration failed.'));
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

192
                    /** @scrutinizer ignore-deprecated */ print_error(__('Registration failed.'));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
193
                    print "<p><form method=\"GET\" action=\"index.php\">
194
					<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
195
					</form>";
196
                } else {
197
198
                    $new_uid = db_fetch_result($result, 0, "id");
199
200
                    initialize_user($new_uid);
201
202
                    $reg_text = "Hi!\n".
203
                        "\n".
204
                        "You are receiving this message, because you (or somebody else) have opened\n".
205
                        "an account at Tiny Tiny RSS.\n".
206
                        "\n".
207
                        "Your login information is as follows:\n".
208
                        "\n".
209
                        "Login: $login\n".
210
                        "Password: $password\n".
211
                        "\n".
212
                        "Don't forget to login at least once to your new account, otherwise\n".
213
                        "it will be deleted in 24 hours.\n".
214
                        "\n".
215
                        "If that wasn't you, just ignore this message. Thanks.";
216
217
                    $mailer = new Mailer();
218
                    $rc = $mailer->mail(["to_address" => $email,
219
                        "subject" => "Registration information for Tiny Tiny RSS",
220
                        "message" => $reg_text]);
221
222
                    if (!$rc) {
223
                        print_error($mailer->error());
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

223
                        /** @scrutinizer ignore-deprecated */ print_error($mailer->error());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
224
                    }
225
226
                    $reg_text = "Hi!\n".
227
                        "\n".
228
                        "New user had registered at your Tiny Tiny RSS installation.\n".
229
                        "\n".
230
                        "Login: $login\n".
231
                        "Email: $email\n";
232
233
                    $mailer = new Mailer();
234
                    $rc = $mailer->mail(["to_address" => REG_NOTIFY_ADDRESS,
0 ignored issues
show
The constant REG_NOTIFY_ADDRESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
235
                        "subject" => "Registration notice for Tiny Tiny RSS",
236
                        "message" => $reg_text]);
237
238
                    if (!$rc) {
239
                        print_error($mailer->error());
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

239
                        /** @scrutinizer ignore-deprecated */ print_error($mailer->error());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
240
                    }
241
242
                    print_notice(__("Account created successfully."));
0 ignored issues
show
Deprecated Code introduced by
The function print_notice() has been deprecated: Use twig function noticeMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

242
                    /** @scrutinizer ignore-deprecated */ print_notice(__("Account created successfully."));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
The call to print_notice() has too many arguments starting with __('Account created successfully.'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

242
                    /** @scrutinizer ignore-call */ 
243
                    print_notice(__("Account created successfully."));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
243
244
                    print "<p><form method=\"GET\" action=\"index.php\">
245
					<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
246
					</form>";
247
248
                }
249
250
            }
251
252
            } else {
253
                print_error('Plese check the form again, you have failed the robot test.');
0 ignored issues
show
Deprecated Code introduced by
The function print_error() has been deprecated: Use twig function errorMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

253
                /** @scrutinizer ignore-deprecated */ print_error('Plese check the form again, you have failed the robot test.');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
254
                print "<p><form method=\"GET\" action=\"index.php\">
255
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
256
				</form>";
257
258
            }
259
        }
260
    ?>
261
262
<?php } else { ?>
263
264
	<?php print_notice(__('New user registrations are currently closed.')) ?>
0 ignored issues
show
Deprecated Code introduced by
The function print_notice() has been deprecated: Use twig function noticeMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

264
	<?php /** @scrutinizer ignore-deprecated */ print_notice(__('New user registrations are currently closed.')) ?>

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
265
266
	<?php print "<p><form method=\"GET\" action=\"index.php\">
267
				<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
268
				</form>"; ?>
269
270
<?php } ?>
271
272
	</div>
273
274
</body>
275
</html>
276