summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/index.php3
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/class/catalog.class.php3
-rw-r--r--lib/general.lib.php44
-rw-r--r--lib/ui.lib.php71
-rw-r--r--lib/xmlrpc.php29
-rw-r--r--modules/lib.php94
-rw-r--r--play/index.php16
-rw-r--r--server.php2
-rw-r--r--templates/show_admin_index.inc27
-rw-r--r--templates/show_local_catalog_info.inc.php37
-rw-r--r--templates/show_user.inc.php4
-rw-r--r--templates/tool_box.inc4
13 files changed, 212 insertions, 124 deletions
diff --git a/admin/index.php b/admin/index.php
index e01e00eb..3467f2c5 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -84,9 +84,10 @@ elseif ( $action == 'show_orphaned_files' ) {
show_orphaned_files();
}
else {
+ show_clear();
require (conf('prefix') . "/templates/show_admin_index.inc");
} // if they didn't pick anything
-echo "<br /><br />";
+show_clear();
show_page_footer ('Admin', '',$user->prefs['display_menu']);
?>
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index a41dd0b3..142e84e1 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -24,6 +24,8 @@
- Improved XMLRPC client and server functions, no longer attempts
to pull all songs at once, pulls in 500 song chunks
- Added tables/fields for Dynamic Playlists and IP tracking
+ - Fixed some spelling errors
+ - Added remote session validation for XMLRPC streaming
--------------------------------------------------------------------------
v.3.3.1 06/21/2005:
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 6703ae98..72ed8cbe 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -980,7 +980,6 @@ class Catalog {
$query_array = array(new xmlrpcval($start, "int"),new xmlrpcval($end,"int"));
$f = new xmlrpcmsg('remote_song_query',$query_array);
-
/* Depending upon the size of the target catalog this can be a very slow/long process */
set_time_limit(0);
@@ -1042,7 +1041,7 @@ class Catalog {
$new_song->time = $data[9];
$new_song->track = $data[10];
$new_song->genre = $this->check_genre($data[11]);
- $new_song->file = $root_path . "/play/index.php?song=" . $data[12] . "uid=$md5_ip";
+ $new_song->file = $root_path . "/play/index.php?song=" . $data[12];
$new_song->catalog = $this->id;
if (!$song_id = $this->check_remote_song($new_song->file)) {
diff --git a/lib/general.lib.php b/lib/general.lib.php
index ee32d328..64efa4c2 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -294,21 +294,49 @@ function fix_preferences($results) {
} // fix_preferences
-/*!
- @function session_exists
- @discussion checks to make sure they've specified a
- valid session
-*/
-function session_exists($sid) {
+/**
+ * session_exists
+ * checks to make sure they've specified a valid session, can handle xmlrpc
+ * @package General
+ * @cataogry Verify
+ * @todo Have XMLRPC check extend remote session
+ * @todo actually check
+ */
+function session_exists($sid,$xml_rpc=0) {
+
+ $found = true;
$sql = "SELECT * FROM session WHERE id = '$sid'";
$db_results = mysql_query($sql, dbh());
if (!mysql_num_rows($db_results)) {
- return false;
+ $found = false;
}
- return true;
+ /* If we need to check the remote session */
+ if ($xml_rpc) {
+ $server = rawurldecode($_GET['xml_server']);
+ $path = "/" . rawurldecode($_GET['xml_path']) . "/server.php";
+ $port = $_GET['xml_port'];
+
+ $path = str_replace("//","/",$path);
+
+ $client = new xmlrpc_client($path,$server,$port);
+
+ $query = new xmlrpcmsg('remote_session_verify',array(new xmlrpcval($sid,"string")) );
+
+ $response = $client->send($query,30);
+
+ $value = $response->value();
+
+ if (!$response->faultCode()) {
+ $data = php_xmlrpc_decode($value);
+ $found = $data;
+ }
+
+ } // xml_rpc
+
+ return $found;
} // session_exists
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 126aa5d0..715f82ea 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -531,7 +531,76 @@ function show_all_popular() {
function show_all_recent() {
-
} // show_all_recent
+/**
+ * show_local_catalog_info
+ * Shows the catalog stats
+ * @package Web INterface
+ * @catagory Display
+ */
+function show_local_catalog_info() {
+
+ $dbh = dbh();
+
+ /* Before we display anything make sure that they have a catalog */
+ $query = "SELECT * FROM catalog";
+ $db_results = mysql_query($query, $dbh);
+ if (!mysql_num_rows($db_results)) {
+ $items[] = "<span align=\"center\" class=\"error\">" . _("No Catalogs Found!") . "</span><br />";
+ $items[] = "<a href=\"" . conf('web_path') . "/admin/catalog.php?action=show_add_catalog\">" ._("Add a Catalog") . "</a>";
+ show_info_box(_("Catalog Statistics"),'catalog',$items);
+ return false;
+ }
+
+ $query = "SELECT count(*) AS songs, SUM(size) AS size, SUM(time) as time FROM song";
+ $db_result = mysql_query($query, $dbh);
+ $songs = mysql_fetch_assoc($db_result);
+
+ $query = "SELECT count(*) FROM album";
+ $db_result = mysql_query($query, $dbh);
+ $albums = mysql_fetch_row($db_result);
+
+ $query = "SELECT count(*) FROM artist";
+ $db_result = mysql_query($query, $dbh);
+ $artists = mysql_fetch_row($db_result);
+
+ $sql = "SELECT count(*) FROM user";
+ $db_result = mysql_query($sql, $dbh);
+ $users = mysql_fetch_row($db_result);
+
+ $time = time();
+ $last_seen_time = $time - 1200;
+ $sql = "SELECT count(DISTINCT s.username) FROM session AS s " .
+ "INNER JOIN user AS u ON s.username = u.username " .
+ "WHERE s.expire > " . $time . " " .
+ "AND u.last_seen > " . $last_seen_time;
+ $db_result = mysql_query($sql, $dbh);
+ $connected_users = mysql_fetch_row($db_result);
+
+ $hours = floor($songs['time']/3600);
+ $size = $songs['size']/1048576;
+
+ $days = floor($hours/24);
+ $hours = $hours%24;
+
+ $time_text = "$days ";
+ $time_text .= ($days == 1) ? _("day") : _("days");
+ $time_text .= ", $hours ";
+ $time_text .= ($hours == 1) ? _("hour") : _("hours");
+
+ if ( $size > 1024 ) {
+ $total_size = sprintf("%.2f", ($size/1024));
+ $size_unit = "GB";
+ }
+ else {
+ $total_size = sprintf("%.2f", $size);
+ $size_unit = "MB";
+ }
+
+ require(conf('prefix') . "/templates/show_local_catalog_info.inc.php");
+
+} // show_local_catalog_info
+
+
?>
diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php
index 194a9808..df484b69 100644
--- a/lib/xmlrpc.php
+++ b/lib/xmlrpc.php
@@ -80,7 +80,7 @@ function remote_song_query($params) {
$results = array();
- $sql = "SELECT song.id FROM song WHERE song.status='enabled' AND (";
+ $sql = "SELECT song.id FROM song WHERE song.enabled='1' AND (";
// Get the catalogs and build the query!
while ($r = mysql_fetch_object($db_results)) {
@@ -117,12 +117,37 @@ function remote_song_query($params) {
set_time_limit(0);
$encoded_array = php_xmlrpc_encode($results);
- if (conf('debug')) { log_event($_SESSION['userdata']['username'],' xmlrpc-server ',"Encoded: $encoded_array"); }
+ if (conf('debug')) { log_event($_SESSION['userdata']['username'],' xmlrpc-server ',"Encoded Song Query Results" . count($results)); }
return new xmlrpcresp($encoded_array);
} // remote_song_query
/**
+ * remote_session_verify
+ * This checks the session on THIS server and returns a true false
+ * @package XMLRPC
+ * @catagory Server
+ * @todo Public/Private Key handshake?
+ */
+function remote_session_verify($params) {
+
+ /* We may need to do this correctly.. :S */
+ $sid = $params->params['0']->me['string'];
+
+ if (session_exists($sid)) {
+ $data = true;
+ }
+ else {
+ $data = false;
+ }
+
+ $encoded_data = php_xmlrpc_encode($data);
+ if (conf('debug')) { log_event($_SESSION['userdata']['username'],' xmlrpc-server ',"Encoded Session Verify as $data Recieved: $sid"); }
+ return new xmlrpcresp($encoded_data);
+
+} // remote_session_verify
+
+/**
* remote_server_denied
* Access Denied Sucka!
* @package XMLRPC
diff --git a/modules/lib.php b/modules/lib.php
index 90094be9..6192c4af 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -9,100 +9,6 @@
*/
-
-/*
- * show_local_catalog_info()
- *
- */
-function show_local_catalog_info() {
- global $settings, $username;
- $dbh = dbh();
-
- $query = "SELECT count(*) AS songs, SUM(size) AS size, SUM(time) as time FROM song";
- $db_result = mysql_query($query, $dbh);
- $songs = mysql_fetch_array($db_result);
-
- $query = "SELECT count(*) FROM album";
- $db_result = mysql_query($query, $dbh);
- $albums = mysql_fetch_row($db_result);
-
- $query = "SELECT count(*) FROM artist";
- $db_result = mysql_query($query, $dbh);
- $artists = mysql_fetch_row($db_result);
-
- $sql = "SELECT count(*) FROM user";
- $db_result = mysql_query($sql, $dbh);
- $users = mysql_fetch_row($db_result);
-
- $time = time();
- $last_seen_time = $time - 1200;
- $sql = "SELECT count(DISTINCT s.username) FROM session AS s " .
- "INNER JOIN user AS u ON s.username = u.username " .
- "WHERE s.expire > " . $time . " " .
- "AND u.last_seen > " . $last_seen_time;
- $db_result = mysql_query($sql, $dbh);
- $connected_users = mysql_fetch_row($db_result);
-
- $hours = floor($songs['time']/3600);
- $size = $songs['size']/1048576;
-
- $days = floor($hours/24);
- $hours = $hours%24;
-
- $time_text = "$days ";
- $time_text .= ($days == 1) ? _("day") : _("days");
- $time_text .= ", $hours ";
- $time_text .= ($hours == 1) ? _("hour") : _("hours");
-
- if ( $size > 1024 ) {
- $total_size = sprintf("%.2f", ($size/1024));
- $size_unit = "GB";
- }
- else {
- $total_size = sprintf("%.2f", $size);
- $size_unit = "MB";
- }
-
-
- print '
-<table class="border" cellspacing="1" cellpadding="3" width="100%" border="0">
- <tr class="table-header">
- <td colspan="2">' . _("Catalog Statistics") . '</td>
- </tr>
- <tr class="even">
- <td> ' . _("Total Users") . ' </td>
- <td> <b>' . $users[0] .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Connected Users") . ' </td>
- <td> <b>' . $connected_users[0] .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Albums") . ' </td>
- <td> <b>' . $albums[0] .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Artists") . ' </td>
- <td> <b>' . $artists[0] .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Songs") . ' </td>
- <td> <b>' . $songs[0] .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Catalog Size") . ' </td>
- <td> <b>' . $total_size .' ' . $size_unit .'</b> </td>
- </tr>
- <tr class="even">
- <td> ' . _("Catalog Time") . ' </td>
- <td> <b>' . $time_text .'</b> </td>
- </tr>
-</table>
-';
-
-} // show_local_catalog_info()
-
-
/*
* show_random_play()
*
diff --git a/play/index.php b/play/index.php
index a72231c3..4d843bc4 100644
--- a/play/index.php
+++ b/play/index.php
@@ -41,8 +41,12 @@ $sid = htmlspecialchars($_REQUEST['sid']);
$dbh = dbh();
$user = new User($uid);
-if (conf('require_session') && !conf('xml_rpc')) {
- if(!session_exists($sid)) {
+if (conf('xml_rpc')) {
+ $xml_rpc = $_GET['xml_rpc'];
+}
+
+if (conf('require_session')) {
+ if(!session_exists($sid,$xml_rpc)) {
die(_("Session Expired: please log in again at") . " " . conf('web_path') . "/login.php");
}
@@ -125,7 +129,13 @@ $catalog = new Catalog($song->catalog);
if ( $catalog->catalog_type == 'remote' ) {
// redirect to the remote host's play path
- header("Location: $song->file");
+ /* Break Up the Web Path */
+ preg_match("/http:\/\/([^\/]+)\/*(.*)/", conf('web_path'), $match);
+ $server = rawurlencode($match[1]);
+ $path = rawurlencode($match[2]);
+
+ $extra_info = "&xml_rpc=1&xml_path=$path&xml_server=$server&xml_port=80&sid=$sid";
+ header("Location: " . $song->file . $extra_info);
}
else {
if ($user->prefs['play_type'] == 'downsample') {
diff --git a/server.php b/server.php
index db8e4df6..5f293206 100644
--- a/server.php
+++ b/server.php
@@ -31,7 +31,7 @@ if ($access->check('75',$_SERVER['REMOTE_ADDR'])) {
/* Setup Possible Actions */
$methods['remote_catalog_query'] = array('function' => 'remote_catalog_query');
$methods['remote_song_query'] = array('function' => 'remote_song_query');
- $methods['remote_session_auth'] = array('function' => 'remote_session_auth');
+ $methods['remote_session_verify'] = array('function' => 'remote_session_verify');
$s = new xmlrpc_server($methods);
}
diff --git a/templates/show_admin_index.inc b/templates/show_admin_index.inc
index e5fa6a9c..210f438a 100644
--- a/templates/show_admin_index.inc
+++ b/templates/show_admin_index.inc
@@ -23,13 +23,24 @@
@header Show Admin Index
@discussion shows the admin index
*/
+
+$sections = array(_("User Management") => conf('web_path') . "/admin/users.php",
+ _("E-mail Management") => conf('web_path') . "/admin/mail.php",
+ _("Catalog Managment") => conf('web_path') . "/admin/catalog.php",
+ _("Admin Preferences") => conf('web_path') . "/admin/preferences.php",
+ _("Access Lists") => conf('web_path') . "/admin/access.php");
+
+$common = array(_("Add a catalog") => conf('web_path') . "/admin/catalog.php?action=show_add_catalog",
+ _("Add a new user") => conf('web_path') . "/admin/users.php?action=show_add_user",
+ _("Clear Now Playing") => conf('web_path') . "/admin/catalog.php?action=clear_now_playing",
+ _("Add Access List Entry") => conf('web_path') . "/admin/access.php?action=show_add_host");
?>
-<p><font size="+1"><?php print _("Admin Section"); ?>:</font></p>
-<ul>
- <li><a href="<?php echo conf('web_path'); ?>/admin/users.php"><?php print _("Users"); ?></a> - <?php print _("Create/Modify User Accounts for Ampache"); ?></li>
- <li><a href="<?php echo conf('web_path'); ?>/admin/mail.php"><?php print _("Mail"); ?></a> - <?php print _("Mail your users to notfiy them of changes"); ?></li>
- <li><a href="<?php echo conf('web_path'); ?>/admin/catalog.php"><?php print _("Catalog"); ?></a> - <?php print _("Create/Update/Clean your catalog here"); ?></li>
- <li><a href="<?php echo conf('web_path'); ?>/admin/preferences.php"><?php print _("Admin Preferences"); ?></a> - <?php print _("Modify Site-wide preferences"); ?></li>
- <li><a href="<?php echo conf('web_path'); ?>/admin/access.php"><?php print _("Access Lists"); ?></a> - <?php print _("Modify Access List Permissions"); ?> (<?php print _("Must have access_control=true in ampache.cfg") ?>)</li>
-</ul>
+<table cellpadding="5" border="0" cellspacing="0">
+<tr>
+ <td valign="top"><?php show_tool_box(_("Common Functions"),$common); ?><?php show_clear(); ?></td>
+</tr>
+<tr>
+ <td valign="top"><?php show_tool_box(_("Admin Sections"),$sections); ?></td>
+</tr>
+</table>
diff --git a/templates/show_local_catalog_info.inc.php b/templates/show_local_catalog_info.inc.php
new file mode 100644
index 00000000..de8334fc
--- /dev/null
+++ b/templates/show_local_catalog_info.inc.php
@@ -0,0 +1,37 @@
+<?php
+
+
+?>
+<table align="left" width="100%" class="border" cellpadding="0" cellspacing="0">
+<tr class="table-header">
+ <th colspan="2"><?php echo _("Catalog Statistics"); ?> </th>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Total Users"); ?></td>
+ <td> <b><?php echo $users[0]; ?></b> </td>
+ </tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td><?php echo _("Connected Users"); ?></td>
+ <td><b><?php echo $connected_users[0]; ?></b></td>
+</tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td><?php echo _("Albums"); ?></td>
+ <td><b><?php echo $albums[0]; ?></b></td>
+</tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td><?php echo _("Artists"); ?></td>
+ <td><b><?php echo $artists[0]; ?></b></td>
+</tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td><?php echo _("Songs"); ?></td>
+ <td><b><?php echo $songs['songs']; ?></b></td>
+</tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td><?php echo _("Catalog Size"); ?></td>
+ <td><b><?php echo $total_size; ?> <?php echo $size_unit; ?></b></td>
+</tr>
+<tr class=<?php echo flip_class(); ?>>
+ <td> <?php echo _("Catalog Time"); ?></td>
+ <td><b><?php echo $time_text; ?></b></td>
+</tr>
+</table>
diff --git a/templates/show_user.inc.php b/templates/show_user.inc.php
index 239543a4..f0b1a834 100644
--- a/templates/show_user.inc.php
+++ b/templates/show_user.inc.php
@@ -23,7 +23,7 @@
<br /><br />
<div class="text-box">
<form name="change_password" method="post" action="<?php echo conf('web_path'); ?>/user.php?action=update_user" enctype="multipart/form-data" >
-<p class="header2">Changing User Information for <?php echo $this_user->fullname; ?></p>
+<p class="header2"><?php echo _("Changing User Information for") . " " . $this_user->fullname; ?></p>
<table>
<tr>
@@ -86,7 +86,7 @@
<br />
<div class="text-box">
<form name="clear_statistics" method="post" action="<?php echo conf('web_path'); ?>/user.php?action=clear_stats" enctype="multipart/form-data">
-<span class="header2">Delete Your Personal Statistics</span><br />
+<span class="header2"><?php echo _("Delete Your Personal Statistics"); ?></span><br />
<input type="hidden" name="user_id" value="<?php echo $this_user->username; ?>" />
<input type="submit" value="<?php echo _("Clear Stats"); ?>">
</form>
diff --git a/templates/tool_box.inc b/templates/tool_box.inc
index fafdcfe8..f1ec0ecf 100644
--- a/templates/tool_box.inc
+++ b/templates/tool_box.inc
@@ -27,9 +27,9 @@
?>
-<table class="border" cellspacing="1" cellpadding="3">
+<table class="border" cellspacing="1" cellpadding="3" >
<tr class="table-header" align="center">
- <td><?php echo $title; ?></td>
+ <th><?php echo $title; ?></th>
</tr>
<tr>
<td class="even">