add debug mode only fast user switcher

master
Andrew Dolgov 18 years ago
parent 803cfab11a
commit 461766f33e

@ -1533,7 +1533,7 @@
} }
print " print "
<td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> <td width='35%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
<td width='35%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> <td width='35%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
<td width='15%'><a href=\"javascript:updateFeedList('last_article')\">Last&nbsp;Article</a></td> <td width='15%'><a href=\"javascript:updateFeedList('last_article')\">Last&nbsp;Article</a></td>
<td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>"; <td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>";

@ -1011,14 +1011,23 @@
return true; return true;
} }
function authenticate_user($link, $login, $password) { function authenticate_user($link, $login, $password, $force_auth = false) {
if (!SINGLE_USER_MODE) { if (!SINGLE_USER_MODE) {
$pwd_hash = 'SHA1:' . sha1($password); $pwd_hash = 'SHA1:' . sha1($password);
$result = db_query($link, "SELECT id,login,access_level FROM ttrss_users WHERE if ($force_auth && defined('_DEBUG_USER_SWITCH')) {
login = '$login' AND pwd_hash = '$pwd_hash'"); $query = "SELECT id,login,access_level
FROM ttrss_users WHERE
login = '$login'";
} else {
$query = "SELECT id,login,access_level
FROM ttrss_users WHERE
login = '$login' AND pwd_hash = '$pwd_hash'";
}
$result = db_query($link, $query);
if (db_num_rows($result) == 1) { if (db_num_rows($result) == 1) {
$_SESSION["uid"] = db_fetch_result($result, 0, "id"); $_SESSION["uid"] = db_fetch_result($result, 0, "id");
@ -1145,6 +1154,14 @@
function login_sequence($link) { function login_sequence($link) {
if (!SINGLE_USER_MODE) { if (!SINGLE_USER_MODE) {
if (defined('_DEBUG_USER_SWITCH') && $_SESSION["uid"]) {
$swu = db_escape_string($_REQUEST["swu"]);
if ($swu) {
$_SESSION["prefs_cache"] = false;
return authenticate_user($link, $swu, null, true);
}
}
if (!validate_session($link)) { if (!validate_session($link)) {
logout_user(); logout_user();
$redirect_uri = get_login_redirect(); $redirect_uri = get_login_redirect();

@ -51,6 +51,7 @@ ul.feedList {
margin : 5px; margin : 5px;
padding : 0px 0px 0px 5px; padding : 0px 0px 0px 5px;
font-size : small; font-size : small;
white-space : nowrap;
} }
ul.feedList li.feedCat { ul.feedList li.feedCat {
@ -1244,3 +1245,9 @@ div.return a:hover {
border-style : solid; border-style : solid;
} }
#userSwitch {
position : absolute;
bottom : 2px;
right : 2px;
}

@ -564,3 +564,8 @@ function catchupCurrentFeed() {
} }
} }
function userSwitch() {
var chooser = document.getElementById("userSwitch");
var user = chooser[chooser.selectedIndex].value;
window.location = "tt-rss.php?swu=" + user;
}

@ -210,6 +210,16 @@ window.onload = init;
<?php } ?> <?php } ?>
<div id="footer"> <div id="footer">
<?php if (defined('_DEBUG_USER_SWITCH')) { ?>
<select id="userSwitch" onchange="userSwitch()">
<?php
foreach (array('admin', 'fox', 'test') as $u) {
$op_sel = ($u == $_SESSION["name"]) ? "selected" : "";
print "<option $op_sel>$u</option>";
}
?>
</select>
<? } ?>
<a href="http://tt-rss.spb.ru/">Tiny Tiny RSS</a> v<?php echo VERSION ?> &copy; 2005-2006 Andrew Dolgov <a href="http://tt-rss.spb.ru/">Tiny Tiny RSS</a> v<?php echo VERSION ?> &copy; 2005-2006 Andrew Dolgov
</div> </div>

Loading…
Cancel
Save