2021-10-26 07:06:37 +02:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
|
2023-12-25 16:29:48 +01:00
|
|
|
if (isset($_POST['command']) && $_POST['command'] == 'Logout') {
|
|
|
|
$past = time() - 3600;
|
|
|
|
foreach ( $_COOKIE as $key => $value )
|
|
|
|
{
|
|
|
|
setcookie( $key, $value, $past, '/' );
|
|
|
|
}
|
|
|
|
$_SESSION = array();
|
|
|
|
session_destroy();
|
|
|
|
$logmeout = true;
|
|
|
|
} else {
|
|
|
|
$logmeout = false;
|
|
|
|
}
|
|
|
|
|
2023-09-22 12:09:32 +02:00
|
|
|
include ("config.inc.php");
|
|
|
|
include ("newsportal.php");
|
2021-10-26 07:06:37 +02:00
|
|
|
|
2023-12-25 16:29:48 +01:00
|
|
|
if ($logmeout) {
|
|
|
|
include "head.inc";
|
|
|
|
echo "<center>";
|
|
|
|
echo "<hr><p>You have been logged out</p>";
|
|
|
|
echo '</center>';
|
|
|
|
echo '<br />';
|
|
|
|
include "tail.inc";
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
if (isset($_COOKIE['tzo'])) {
|
|
|
|
$offset = $_COOKIE['tzo'];
|
|
|
|
} else {
|
|
|
|
$offset = $CONFIG['timezone'];
|
|
|
|
}
|
|
|
|
if (! isset($_POST['command'])) {
|
|
|
|
$_POST['command'] = null;
|
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
$keyfile = $spooldir . '/keys.dat';
|
2021-10-26 07:06:37 +02:00
|
|
|
$keys = unserialize(file_get_contents($keyfile));
|
2023-12-25 16:29:48 +01:00
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
$title .= ' - User Configuration';
|
2021-10-26 07:06:37 +02:00
|
|
|
include "head.inc";
|
|
|
|
|
2023-09-04 15:06:43 +02:00
|
|
|
if (disable_page_by_user_agent($client_device, "bot", "User")) {
|
|
|
|
echo "<center>Page Disabled</center>";
|
|
|
|
include "tail.inc";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2021-10-26 07:06:37 +02:00
|
|
|
// How long should cookie allow user to stay logged in?
|
|
|
|
// 14400 = 4 hours
|
2023-08-20 00:33:05 +02:00
|
|
|
$auth_expire = 14400;
|
|
|
|
$logged_in = false;
|
|
|
|
if (! isset($_POST['username'])) {
|
2021-10-26 07:06:37 +02:00
|
|
|
$_POST['username'] = $_COOKIE['mail_name'];
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
$name = $_POST['username'];
|
|
|
|
if (! isset($_POST['password'])) {
|
|
|
|
$_POST['password'] = null;
|
|
|
|
}
|
|
|
|
if (! isset($_COOKIE['mail_auth'])) {
|
|
|
|
$_COOKIE['mail_auth'] = null;
|
|
|
|
}
|
2023-12-17 13:55:13 +01:00
|
|
|
if ((password_verify($_POST['username'] . $keys[0] . get_user_config($_POST['username'], 'encryptionkey'), $_COOKIE['mail_auth'])) || (password_verify($_POST['username'] . $keys[1] . get_user_config($_POST['username'], 'encryptionkey'), $_COOKIE['mail_auth']))) {
|
2023-12-25 16:29:48 +01:00
|
|
|
// if (((get_user_mail_auth_data($_COOKIE['mail_name'])) && password_verify($_POST['username'] . $keys[0] . get_user_config($_POST['username'], 'encryptionkey'), $_COOKIE['mail_auth'])) || (password_verify($_POST['username'] . $keys[1] . get_user_config($_POST['username'], 'encryptionkey'), $_COOKIE['mail_auth']))) {
|
2021-10-26 07:06:37 +02:00
|
|
|
$logged_in = true;
|
2023-08-20 00:33:05 +02:00
|
|
|
} else {
|
|
|
|
if (check_bbs_auth($_POST['username'], $_POST['password'])) {
|
|
|
|
$authkey = password_hash($_POST['username'] . $keys[0] . get_user_config($_POST['username'], 'encryptionkey'), PASSWORD_DEFAULT);
|
|
|
|
$pkey = hash('crc32', get_user_config($_POST['username'], 'encryptionkey'));
|
|
|
|
set_user_config(strtolower($_POST['username']), "pkey", $pkey);
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
2021-10-26 07:06:37 +02:00
|
|
|
if (navigator.cookieEnabled)
|
|
|
|
var authcookie = "<?php echo $authkey; ?>";
|
|
|
|
var savename = "<?php echo stripslashes($name); ?>";
|
|
|
|
var auth_expire = "<?php echo $auth_expire; ?>";
|
|
|
|
var name_expire = "7776000";
|
2022-01-13 00:44:35 +01:00
|
|
|
var pkey = "<?php echo $pkey; ?>";
|
2021-10-26 07:06:37 +02:00
|
|
|
document.cookie = "mail_auth="+authcookie+"; max-age="+auth_expire+"; path=/";
|
|
|
|
document.cookie = "mail_name="+savename+"; max-age="+name_expire+"; path=/";
|
2022-01-13 00:44:35 +01:00
|
|
|
document.cookie = "pkey="+pkey+"; max-age="+name_expire+"; path=/";
|
2021-10-26 07:06:37 +02:00
|
|
|
</script>
|
|
|
|
<?php
|
2023-08-20 00:33:05 +02:00
|
|
|
$logged_in = true;
|
|
|
|
} else {
|
|
|
|
echo 'Login failed.';
|
2021-10-26 07:06:37 +02:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
2023-09-04 15:06:43 +02:00
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
if (isset($_POST['command']) && $_POST['command'] == 'Configuration') {
|
2023-07-13 18:17:38 +02:00
|
|
|
echo '<h1 class="np_thread_headline">';
|
2023-08-20 00:33:05 +02:00
|
|
|
echo '<a href="user.php" target=' . $frame['menu'] . '>Configuration</a> / ';
|
|
|
|
echo htmlspecialchars($_POST['username']) . '</h1>';
|
|
|
|
} else {
|
2023-07-13 18:17:38 +02:00
|
|
|
echo '<h1 class="np_thread_headline">';
|
2023-08-20 00:33:05 +02:00
|
|
|
echo '<a href="user.php" target=' . $frame['menu'] . '>user login</a> / ';
|
|
|
|
echo htmlspecialchars($_POST['username']) . '</h1>';
|
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>';
|
|
|
|
// Mail button
|
2023-08-20 00:33:05 +02:00
|
|
|
if ($logged_in == true) {
|
|
|
|
echo '<td>';
|
|
|
|
echo '<form target="' . $frame['content'] . '" method="post" action="mail.php">';
|
|
|
|
echo '<input name="command" type="hidden" id="command" value="Mail" readonly="readonly">';
|
|
|
|
echo "<input type='hidden' name='username' value='" . $_POST['username'] . "' />";
|
|
|
|
echo '<button class="np_button_link" type="submit">Mail</button>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</td>';
|
|
|
|
// Files button
|
|
|
|
echo '<td>';
|
|
|
|
echo '<form target="' . $frame['content'] . '" method="post" action="files.php">';
|
|
|
|
echo '<input name="command" type="hidden" id="command" value="Files" readonly="readonly">';
|
|
|
|
echo "<input type='hidden' name='username' value='" . $_POST['username'] . "' />";
|
|
|
|
echo '<button class="np_button_link" type="submit">Files</button>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</td>';
|
|
|
|
// Configuration button
|
|
|
|
echo '<td>';
|
|
|
|
echo '<form target="' . $frame['content'] . '" method="post" action="user.php">';
|
|
|
|
echo '<input name="command" type="hidden" id="command" value="Configuration" readonly="readonly">';
|
|
|
|
echo "<input type='hidden' name='username' value='" . $_POST['username'] . "' />";
|
|
|
|
echo '<button class="np_button_link" type="submit">Configuration</button>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</td>';
|
|
|
|
// Logout button
|
|
|
|
echo '<td>';
|
|
|
|
echo '<form target="' . $frame['content'] . '" method="post" action="user.php">';
|
|
|
|
echo '<input name="command" type="hidden" id="command" value="Logout" readonly="readonly">';
|
|
|
|
echo "<input type='hidden' name='username' value='" . $_POST['username'] . "' />";
|
|
|
|
echo '<button class="np_button_link" type="submit">Logout</button>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
echo '<td width=100%></td></tr></table>';
|
2021-10-26 07:06:37 +02:00
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
if (isset($_POST['username'])) {
|
|
|
|
$name = $_POST['username'];
|
|
|
|
// Save name in cookie
|
|
|
|
if ($setcookies == true) {
|
2023-12-23 14:43:34 +01:00
|
|
|
setcookie("mail_name", stripslashes($name), time() + (3600 * 24 * 90), '/');
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
} else {
|
2023-08-20 00:33:05 +02:00
|
|
|
if ($setcookies) {
|
|
|
|
if ((isset($_COOKIE["mail_name"])) && (! isset($name))) {
|
|
|
|
$name = $_COOKIE["mail_name"];
|
|
|
|
} else {
|
|
|
|
$name = '';
|
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
if ($logged_in !== true) {
|
|
|
|
echo '<table border="0" align="center" cellpadding="0" cellspacing="1">';
|
|
|
|
echo '<form name="form1" method="post" action="user.php" enctype="multipart/form-data">';
|
|
|
|
echo '<tr><td><strong>Please Login<br /></strong></td></tr>';
|
|
|
|
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="' . $name . '"></td></tr>';
|
|
|
|
echo '<tr><td>Password:</td><td><input name="password" type="password" id="password"></td></tr>';
|
|
|
|
echo '<td><input name="command" type="hidden" id="command" value="Login" readonly="readonly"></td>';
|
|
|
|
echo '<input type="hidden" name="key" value="' . password_hash($CONFIG['thissitekey'] . $name, PASSWORD_DEFAULT) . '">';
|
|
|
|
echo '<td> </td>';
|
|
|
|
echo '<td><input type="submit" name="Submit" value="Login"></td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</table>';
|
|
|
|
exit(0);
|
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
|
2023-08-20 00:33:05 +02:00
|
|
|
$user = strtolower($_POST['username']);
|
|
|
|
$_SESSION['username'] = $user;
|
|
|
|
unset($user_config);
|
|
|
|
$userfile = $spooldir . '/' . $user . '-articleviews.dat';
|
|
|
|
if (is_file($userfile)) {
|
|
|
|
$userdata = unserialize(file_get_contents($userfile));
|
|
|
|
}
|
2023-07-13 18:17:38 +02:00
|
|
|
// Show Logged-In Message
|
2023-08-20 00:33:05 +02:00
|
|
|
if ($_POST['command'] != 'Configuration' && $_POST['command'] != 'SaveConfig') {
|
2023-09-22 12:09:32 +02:00
|
|
|
if (isset($_POST['source'])) {
|
|
|
|
$link = explode(':', $_POST['source']);
|
|
|
|
$golink = '<a href="' . $link[1] . '">Continue to ' . $link[0] . '</a>';
|
|
|
|
}
|
2023-07-13 18:17:38 +02:00
|
|
|
echo "<center>";
|
2023-08-20 00:33:05 +02:00
|
|
|
echo "<hr><p>You are logged in as " . $_POST['username'] . "</p>";
|
2023-09-22 12:09:32 +02:00
|
|
|
echo "<p>" . $golink . "</p>";
|
2023-07-13 18:17:38 +02:00
|
|
|
echo '</center>';
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
2021-10-26 07:06:37 +02:00
|
|
|
// Apply Config
|
2023-08-20 00:33:05 +02:00
|
|
|
if (isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
|
|
|
|
$user_config['signature'] = $_POST['signature'];
|
|
|
|
$user_config['xface'] = $_POST['xface'];
|
|
|
|
$user_config['timezone'] = $_POST['timezone'];
|
|
|
|
$user_config['theme'] = $_POST['listbox'];
|
|
|
|
file_put_contents($config_dir . '/userconfig/' . $user . '.config', serialize($user_config));
|
|
|
|
$_SESSION['theme'] = $user_config['theme'];
|
|
|
|
$mysubs = explode("\n", $_POST['subscribed']);
|
|
|
|
foreach ($mysubs as $sub) {
|
|
|
|
if (trim($sub) == '') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$sub = trim($sub);
|
|
|
|
if (! isset($userdata[$sub])) {
|
2022-01-12 00:19:54 +01:00
|
|
|
$userdata[$sub] = 0;
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
$newsubs[$sub] = $userdata[$sub];
|
2023-07-13 18:17:38 +02:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
file_put_contents($spooldir . '/' . $user . '-articleviews.dat', serialize($newsubs));
|
|
|
|
$userdata = unserialize(file_get_contents($userfile));
|
|
|
|
if ($userdata) {
|
|
|
|
ksort($userdata);
|
2021-10-26 07:06:37 +02:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
echo 'Configuration Saved for ' . $_POST['username'];
|
|
|
|
} else {
|
|
|
|
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . $user . '.config'));
|
|
|
|
}
|
2021-11-09 22:05:46 +01:00
|
|
|
// Get themes
|
2023-08-20 00:33:05 +02:00
|
|
|
$themedir = $rootdir . '/common/themes';
|
|
|
|
if (is_dir($themedir)) {
|
|
|
|
if ($theme_list = opendir($themedir)) {
|
|
|
|
while (($theme_dir = readdir($theme_list)) !== false) {
|
2023-12-25 16:29:48 +01:00
|
|
|
if ($theme_dir == '.' || $theme_dir == '..' || ! is_dir($themedir . '/' . $theme_dir)) {
|
2023-08-20 00:33:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$themes[] = $theme_dir;
|
2021-11-09 22:05:46 +01:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
closedir($theme_list);
|
2021-11-09 22:05:46 +01:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
sort($themes);
|
|
|
|
if (isset($_POST['command']) && $_POST['command'] == 'Configuration') {
|
|
|
|
// Show Config
|
2021-10-26 07:06:37 +02:00
|
|
|
echo '<hr><h1 class="np_thread_headline">Configuration:</h1>';
|
|
|
|
echo '<table cellspacing="0" width="100%" class="np_results_table">';
|
2023-08-20 00:33:05 +02:00
|
|
|
echo '<tr class="np_thread_head"><td class="np_thread_head">Settings for ' . $_POST['username'] . ' (leave blank for none):</td></tr>';
|
2021-10-26 07:06:37 +02:00
|
|
|
echo '<form method="post" action="user.php">';
|
|
|
|
echo '<tr class="np_result_line1">';
|
2023-08-20 00:33:05 +02:00
|
|
|
// Signature
|
|
|
|
echo '<td class="np_result_line1" style="word-wrap:break-word";>Signature:</td>';
|
|
|
|
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><textarea class="configuration" id="signature" name="signature" rows="6" cols="70">' . $user_config['signature'];
|
|
|
|
echo '</textarea></td>';
|
|
|
|
echo '</tr>';
|
|
|
|
// X-Face
|
|
|
|
echo '<td class="np_result_line1" style="word-wrap:break-word";>X-Face:</td>';
|
|
|
|
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><textarea class="configuration" id="xface" name="xface" rows="4" cols="80">' . $user_config['xface'];
|
|
|
|
echo '</textarea></td>';
|
|
|
|
echo '</tr>';
|
|
|
|
// Theme
|
|
|
|
echo '<td class="np_result_line1" style="word-wrap:break-word";>Theme: (' . $user_config['theme'] . ')</td>';
|
|
|
|
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word">';
|
|
|
|
echo '<select name="listbox" class="theme_listbox" size="10">';
|
|
|
|
foreach ($themes as $theme) {
|
|
|
|
if ($theme == $user_config['theme']) {
|
|
|
|
echo '<option value="' . $theme . '" selected="selected">' . $theme . '</option>';
|
|
|
|
} else {
|
|
|
|
echo '<option value="' . $theme . '">' . $theme . '</option>';
|
2022-01-12 00:19:54 +01:00
|
|
|
}
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
echo '</select>';
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
// Subscriptions
|
|
|
|
echo '<td class="np_result_line1" style="word-wrap:break-word";>Subscribed:</td>';
|
|
|
|
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><textarea class="configuration" id="subscribed" name="subscribed" rows="10" cols="40">';
|
|
|
|
foreach ($userdata as $key => $value) {
|
|
|
|
echo $key . "\n";
|
|
|
|
}
|
|
|
|
echo '</textarea></td>';
|
|
|
|
echo '</tr>';
|
|
|
|
/*
|
|
|
|
* // Timezone
|
|
|
|
* echo '<td class="np_result_line1" style="word-wrap:break-word";>Timezone offset (+/- hours from UTC):</td>';
|
|
|
|
* echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><input type="text" name="timezone" value="'.$user_config[timezone].'"></td>';
|
|
|
|
* echo '</tr>';
|
|
|
|
*/
|
|
|
|
echo '<td class="np_result_line2" style="word-wrap:break-word";>';
|
|
|
|
echo '<button class="np_button_link" type="submit">Save Configuration</button>';
|
|
|
|
echo '<a href="' . $_SERVER['PHP_SELF'] . '">Cancel</a>';
|
|
|
|
echo '</td></tr>';
|
|
|
|
echo '<input name="command" type="hidden" id="command" value="SaveConfig" readonly="readonly">';
|
2021-10-26 07:06:37 +02:00
|
|
|
echo '</form>';
|
|
|
|
echo '</tbody></table><br />';
|
2023-08-20 00:33:05 +02:00
|
|
|
} else {
|
2023-07-13 18:17:38 +02:00
|
|
|
echo '<br />';
|
2023-08-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
include "tail.inc";
|
2021-10-26 07:06:37 +02:00
|
|
|
?>
|