1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

fixed ajax requests with invalid session not causing logout

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-12-10 20:28:47 +00:00
parent c13392b861
commit c0f55e26b2
5 changed files with 21 additions and 64 deletions

View file

@ -4,6 +4,8 @@
-------------------------------------------------------------------------- --------------------------------------------------------------------------
v.3.4-Alpha4 v.3.4-Alpha4
- Fixed a bug where ajax actions wouldn't trigger a redirect to login
when session expired, instead they would just break
- Fixed a bug with Random Play if you had no artists/albums/playlists - Fixed a bug with Random Play if you had no artists/albums/playlists
- Fixed Admin's ability to modify other users preferences - Fixed Admin's ability to modify other users preferences
- Added User and Manager levels to Localplay, determines what the - Added User and Manager levels to Localplay, determines what the

View file

@ -247,7 +247,7 @@ class Update {
$version[] = array('version' => '340012','description'=>$update_string); $version[] = array('version' => '340012','description'=>$update_string);
$update_string = '- Removed Unused Preferneces.<br />' . $update_string = '- Removed Unused Preferences.<br />' .
'- Changed Localplay Config to Localplay Access.<br />' . '- Changed Localplay Config to Localplay Access.<br />' .
'- Changed all XML-RPC acls to RPC to reflect inclusion of new API.<br />'; '- Changed all XML-RPC acls to RPC to reflect inclusion of new API.<br />';

View file

@ -43,66 +43,6 @@ function int2ip($i) {
return "$d[0].$d[1].$d[2].$d[3]"; return "$d[0].$d[1].$d[2].$d[3]";
} // int2ip } // int2ip
/*
* Conf function by Robert Hopson
* call it with a $parm name to retrieve
* a var, pass it a array to set them
* to reset a var pass the array plus
* Clobber! replaces global $conf;
*/
/*function conf($param,$clobber=0)
{
static $params = array();
if(is_array($param))
//meaning we are setting values
{
foreach ($param as $key=>$val)
{
if(!$clobber && isset($params[$key]))
{
echo "Error: attempting to clobber $key = $val\n";
exit();
}
$params[$key] = $val;
}
return true;
}
else
//meaning we are trying to retrieve a parameter
{
if($params[$param]) return $params[$param];
else return;
}
} //conf
function error_results($param,$clobber=0)
{
static $params = array();
if(is_array($param))
//meaning we are setting values
{
foreach ($param as $key=>$val)
{
if(!$clobber && isset($params[$key]))
{
echo "Error: attempting to clobber $key = $val\n";
exit();
}
$params[$key] = $val;
}
return true;
}
else
//meaning we are trying to retrieve a parameter
{
if($params[$param]) return $params[$param];
else return;
}
} //error_results
*/
/** /**
* session_exists * session_exists
* checks to make sure they've specified a valid session, can handle xmlrpc * checks to make sure they've specified a valid session, can handle xmlrpc
@ -524,8 +464,19 @@ function logout() {
// Do a quick check to see if this is an AJAX'd logout request // Do a quick check to see if this is an AJAX'd logout request
// if so use the iframe to redirect // if so use the iframe to redirect
if (AJAX_INCLUDE == '1') { if (AJAX_INCLUDE == '1') {
$_SESSION['iframe']['target'] = Config::get('web_path') . '/login.php'; ob_end_clean();
$results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>'; ob_start();
/* Set the correct headers */
header("Content-type: text/xml; charset=" . Config::get('site_charset'));
header("Content-Disposition: attachment; filename=ajax.xml");
header("Expires: Tuesday, 27 Mar 1984 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$target = Config::get('web_path') . '/login.php';
$results['rfc3514'] = '<script type="text/javascript">reload_logout("'.$target.'")</script>';
echo xml_from_array($results); echo xml_from_array($results);
} }

View file

@ -92,6 +92,11 @@ function reload_util(target) {
document.getElementById('util_iframe').src = document.getElementById('util_iframe').src; document.getElementById('util_iframe').src = document.getElementById('util_iframe').src;
} }
// Log them out
function reload_logout(target) {
window.location = target;
}
function popup_art(url) { function popup_art(url) {
var newwindow; var newwindow;
newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no"); newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no");

View file

@ -18,7 +18,6 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
require_once 'lib/init.php'; require_once 'lib/init.php';
// This is a little bit of a special file, it takes the // This is a little bit of a special file, it takes the