This file is indexed.

/usr/share/gallery/login.php is in gallery 1.5.10.dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2008 Bharat Mediratta
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * $Id: login.php 17837 2008-08-11 23:27:40Z JensT $
 */

require_once(dirname(__FILE__) . '/init.php');
require_once(dirname(__FILE__) . '/classes/Logins.php');

list($username, $gallerypassword, $login, $reset_username, $forgot) =
	getRequestVar(array('username', 'gallerypassword', 'login', 'reset_username', 'forgot'));

list($g1_return, $cmd) = getRequestVar(array('g1_return', 'cmd'));

$username = gHtmlSafe($username);

$g1_return = unhtmlentities(urldecode($g1_return));

if(!isValidGalleryUrl($g1_return) || empty($g1_return)) {
	$g1_return = makeGalleryHeaderUrl();
}

$loginFailure = array();
$resetInfo = array();

if(!empty($cmd) && $cmd === 'logout') {
	gallery_syslog("Logout by ". $gallery->session->username ." from ". $_SERVER['REMOTE_ADDR']);
	$gallery->session->username = '';
	$gallery->session->language = '';
	destroyGallerySession();

	// Prevent the 'you have to be logged in' error message
	// when the user logs out of a protected album
	createGallerySession();
	$gallery->session->gRedirDone = true;

	header("Location: $g1_return");
}

if (!empty($username) && !empty($gallerypassword) && !empty($login)) {
	$userLogins = new Logins();
	$userLogins->load();

	$tmpUser = $gallery->userDB->getUserByUsername($username);
	if ($userLogins->userIslocked($username)) {
		$loginFailure[] = array(
			'type' => 'error',
			'text' => gTranslate('core', "This account is locked due too much wrong login attempts. Wait for automatic unlock, or contact an administrator.")
		);
	}
	elseif ($tmpUser && $tmpUser->isCorrectPassword($gallerypassword)) {

		// User is successfully logged in, regenerate a new
		// session ID to prevent session fixation attacks
		createGallerySession(true);

		// Perform the login
		$tmpUser->log("login");
		$tmpUser->save();
		$gallery->session->username = $username;
		gallery_syslog("Successful login for $username from " . $_SERVER['REMOTE_ADDR']);

		if ($tmpUser->getDefaultLanguage() != "") {
			$gallery->session->language = $tmpUser->getDefaultLanguage();
		}

		$userLogins->reset($username);
		$userLogins->save();

		if (!$gallery->session->offline) {
			header("Location: $g1_return");
		}
		else {
			echo '<span class="error">'. gTranslate('core', "SUCCEEDED") . '</span><p>';
			return;
		}
	}
	elseif($tmpUser) {
		$loginFailure[] = array(
			'type' => 'error',
			'text' => gTranslate('core', "Invalid username or password.")
		);

		$userLogins->addLoginTry($username);
		$userLogins->save();

		$gallerypassword = null;
		gallery_syslog("Failed login for $username from " . $_SERVER['REMOTE_ADDR']);
	}
	else {
		$loginFailure[] = array(
			'type' => 'error',
			'text' => gTranslate('core', "Invalid username or password.")
		);
		$gallerypassword = null;
		gallery_syslog("Failed login attempt with an invalid username from " . $_SERVER['REMOTE_ADDR']);

		$userLogins->addLoginTry($username);
		$userLogins->save();
}
}
elseif (!empty($login) && empty($forgot)) {
	$loginFailure[] = array(
		'type' => 'information',
		'text' => gTranslate('core', "Please enter username and password!")
	);
}
elseif (!empty($forgot) && empty($reset_username)) {
	$resetInfo[] = array(
		'type' => 'information',
		'text' => gTranslate('core', "Please enter <i>your</i> username.")
	);
}
elseif (!empty($forgot) && !empty($reset_username)) {
	$tmpUser = $gallery->userDB->getUserByUsername($reset_username);

	if ($tmpUser) {
		if (check_email($tmpUser->getEmail())) {
			if (gallery_mail(
				$tmpUser->email,
				gTranslate('core', "New password request"),
				sprintf(gTranslate('core', "Someone requested a new password for user %s from Gallery '%s' on %s. You can create a password by visiting the link below. If you didn't request a password, please ignore this mail. "), $reset_username, $gallery->app->galleryTitle, $gallery->app->photoAlbumURL) . "\n\n" .
				sprintf(gTranslate('core', "Click to reset your password: %s"),
				$tmpUser->genRecoverPasswordHash()) . "\n",
				sprintf(gTranslate('core', "New password request %s"), $reset_username)))
			{
				$tmpUser->log("new_password_request");
				$tmpUser->save();
			}
			else {
				$resetInfo[] = array(
					'type' => 'error',
					'text' => gTranslate('core', "Email could not be sent.") .
						"<br>"  .
						sprintf(gTranslate('core', "Please contact %s administrators for a new password."), $gallery->app->galleryTitle)
				);
			}
		}
	}

	if(empty($resetInfo) && empty($loginFailure)) {
		$resetInfo[] = array(
			'type' => 'information',
			'text' => sprintf(gTranslate('core', "If there is a valid email-address for this user, then an email has been sent to the address stored for %s.  Follow the instructions to change your password.  If you do not receive this email, please contact the Gallery administrators."), $reset_username)
		);
	}
}

$title = sprintf(gTranslate('core', "Login to %s"), $gallery->app->galleryTitle);

if (!$GALLERY_EMBEDDED_INSIDE) {
doctype();
?>
<html>
<head>
  <title><?php echo sprintf(gTranslate('core', "Login to %s"), $gallery->app->galleryTitle) ?></title>
  <?php
	common_header();
?>
</head>
<body>
<?php
}

includeHtmlWrap("gallery.header");

$breadcrumb['text'][]	= languageSelector();
?>

<div class="popuphead"><?php echo sprintf(gTranslate('core', "Login to %s"), $gallery->app->galleryTitle) ?></div>
<div class="popup" align="center">
	<?php echo gTranslate('core', "Logging in gives you greater permission to view, create, modify and delete albums.") ?>
</div>

<?php

includeLayout('breadcrumb.inc');

echo "\n<br>";

echo infoBox($loginFailure);
echo "\n<br>";

?>

<div class="g-loginpage popup" align="center">
<fieldset>
<legend class="g-emphasis"><?php echo gTranslate('common', "Login") ?></legend>
<?php
echo makeFormIntro('login.php', array('name' => 'loginForm'));
?>
 	<table>
<?php
	echo gInput('text', 'username', gTranslate('core', "Username"), true, $username,array('class' => 'g-form-text g-usernameInput'));

	echo gInput('password', 'gallerypassword', gTranslate('core', "Password"), true, null, array('class' => 'g-form-text g-passwordInput'));
?>
	</table>

	<p align="center">
	<?php echo gSubmit('login', gTranslate('core', "Login")); ?>
	<?php echo gButton('cancel', gTranslate('core', "Cancel"), "location.href='$g1_return'"); ?>
	</p>

	<?php echo gInput('hidden', 'g1_return', '', false, urlencode($g1_return)); ?>
	</form>
</fieldset>

	<?php
	if (isset($gallery->app->emailOn) && $gallery->app->emailOn == 'yes') {
	?>

<fieldset>
    <legend class="g-sectioncaption g-emphasis"><?php echo gTranslate('core', "Forgotten your password?") ?></legend>
					<?php
  echo makeFormIntro('login.php', array('name' => 'resetForm'));
	echo infoBox($resetInfo);

	echo gInput('text', 'reset_username', gTranslate('core', "Username"), false, $username, array('class' => 'g-form-text g-usernameInput'));
	echo "\n<p align=\"center\">";
	echo gSubmit('forgot', gTranslate('core', "Send me my password"));
	echo "\n</p>";
?>

	</form>
</fieldset>

	<?php } /* End if-email-on */

	if ($gallery->app->selfReg == 'yes') {
	?>
<fieldset>
    <legend class="g-sectioncaption g-emphasis"><?php echo gTranslate('core', "No account at all?"); ?></legend>
    <div class="center">
	<?php echo gButton('register', gTranslate('core', "Register a new account."), popup('register.php')); ?>
	</div>
</fieldset>
	<?php
	}
	?>

	<script language="javascript1.2" type="text/JavaScript">
	<!--
	// position cursor in top form field
	document.loginForm.username.focus();
	//-->
	</script>


</div>
<?php
	includeHtmlWrap("gallery.footer");
?>

</body>
</html>