summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
commitfe077220bf08ac7ad466e6fdfe88197c6d4ed56e (patch)
tree1e8d8eab876246fc57a1e6c414fe763570690bf6 /server
parentadd90bc902ce762626fe72d408f42d705d3f9de7 (diff)
downloadampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.gz
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.bz2
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.zip
broke a ton of stuff, but added some hotness... yes that is an excuse
Diffstat (limited to 'server')
-rw-r--r--server/ajax.server.php17
-rw-r--r--server/stats.ajax.php79
2 files changed, 93 insertions, 3 deletions
diff --git a/server/ajax.server.php b/server/ajax.server.php
index 7133fb26..f47c8856 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -25,8 +25,6 @@
require_once '../lib/init.php';
-$action = scrub_in($_REQUEST['action']);
-
/* Set the correct headers */
header("Content-type: text/xml; charset=" . Config::get('site_charset'));
header("Content-Disposition: attachment; filename=ajax.xml");
@@ -35,7 +33,20 @@ 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");
-switch ($action) {
+// Set that this is an ajax include
+define('AJAX_INCLUDE','1');
+
+switch ($_REQUEST['page']) {
+ case 'stats':
+ require_once Config::get('prefix') . '/server/stats.ajax.php';
+ exit;
+ break;
+ default:
+ // A taste of compatibility
+ break;
+} // end switch on page
+
+switch ($_REQUEST['action']) {
/* Controls the editing of objects */
case 'show_edit_object':
diff --git a/server/stats.ajax.php b/server/stats.ajax.php
new file mode 100644
index 00000000..cdb5a7cd
--- /dev/null
+++ b/server/stats.ajax.php
@@ -0,0 +1,79 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+/**
+ * Sub-Ajax page, requires AJAX_INCLUDE as one
+ */
+if (AJAX_INCLUDE != '1') { exit; }
+
+switch ($_REQUEST['action']) {
+ case 'show_recommend':
+ switch ($_REQUEST['type']) {
+ case 'artist':
+ case 'album':
+ case 'track':
+ // We're good
+ break;
+ default:
+ $results['rfc3514'] = '0x1';
+ break 2;
+ } // verifying the type
+
+ ob_start();
+ show_box_top(_('Recommendations'));
+ echo "Loading...";
+ $ajax_action = Ajax::action('?page=stats&action=recommend&type=' . $_REQUEST['type'] . '&id=' . $_REQUEST['id'],'show_recommend_refresh');
+ Ajax::run($ajax_action);
+ show_box_bottom();
+ $results['additional_information'] = ob_get_contents();
+ ob_end_clean();
+ break;
+ case 'recommend':
+ switch ($_REQUEST['type']) {
+ case 'artist':
+ $headers = array('name'=>_('Name'),'links'=>' ');
+ break;
+ case 'album':
+ case 'track':
+ // We're good
+ default:
+ $results['rtc3514'] = '0x1';
+ break 2;
+ }
+
+ // Get the recommendations
+ $objects = metadata::recommend_similar($_REQUEST['type'],$_REQUEST['id'],'7');
+
+ ob_start();
+ show_box_top(_('Recommendations'));
+ require_once Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
+ $results['additional_information'] = ob_get_contents();
+ ob_end_clean();
+ break;
+ default:
+ $results['rfc3514'] = '0x1';
+ break;
+} // switch on action;
+
+// We always do this
+echo xml_from_array($results);
+?>