/** * get_xml * This returns the xmldocument for the current rss type, it calls a sub function that gathers the data * and then uses the xmlDATA class to build the document * @return string */ public function get_xml($params = null) { if ($this->type === "podcast") { if ($params != null && is_array($params)) { $object_type = $params['object_type']; $object_id = $params['object_id']; if (Core::is_library_item($object_type)) { $libitem = new $object_type($object_id); if ($libitem->id) { $libitem->format(); return XML_Data::podcast($libitem); } } } } else { // Function call name $data_function = 'load_' . $this->type; $pub_date_function = 'pubdate_' . $this->type; $data = call_user_func(array('Ampache_RSS', $data_function)); $pub_date = null; if (method_exists('Ampache_RSS', $data_function)) { $pub_date = call_user_func(array('Ampache_RSS', $pub_date_function)); } XML_Data::set_type('rss'); $xml_document = XML_Data::rss_feed($data, $this->get_title(), $this->get_description(), $pub_date); return $xml_document; } return null; }
/** * get_xml * This returns the xmldocument for the current rss type, it calls a sub function that gathers the data * and then uses the xmlDATA class to build the document */ public function get_xml() { // Function call name $data_function = 'load_' . $this->type; $pub_date_function = 'pubdate_' . $this->type; $data = call_user_func(array('Ampache_RSS', $data_function)); $pub_date = call_user_func(array('Ampache_RSS', $pub_date_function)); XML_Data::set_type('rss'); $xml_document = XML_Data::rss_feed($data, $this->get_title(), $this->get_description(), $pub_date); return $xml_document; }
debug_event('Access Denied', 'Unauthorized access attempt to API [' . $_SERVER['REMOTE_ADDR'] . ']', '3'); ob_end_clean(); echo XML_Data::error('403', T_('Unauthorized access attempt to API - ACL Error')); exit; } if ($_REQUEST['action'] != 'handshake' and $_REQUEST['action'] != 'ping') { Session::extend($_REQUEST['auth']); $GLOBALS['user'] = User::get_from_username($username); } // Get the list of possible methods for the Ampache API $methods = get_class_methods('api'); // Define list of internal functions that should be skipped $internal_functions = array('set_filter'); // Recurse through them and see if we're calling one of them foreach ($methods as $method) { if (in_array($method, $internal_functions)) { continue; } // If the method is the same as the action being called // Then let's call this function! if ($_GET['action'] == $method) { call_user_func(array('api', $method), $_GET); // We only allow a single function to be called, and we assume it's cleaned up! exit; } } // end foreach methods in API // If we manage to get here, we still need to hand out an XML document ob_end_clean(); echo XML_Data::error('405', T_('Invalid Request'));
public static function stats($input) { $type = $input['type']; $offset = $input['offset']; $limit = $input['limit']; if ($type == "newest") { $albums = Stats::get_newest("album", $limit, $offset); } else { if ($type == "highest") { $albums = Rating::get_highest("album", $limit, $offset); } else { if ($type == "frequent") { $albums = Stats::get_top("album", $limit, '', $offset); } else { if ($type == "recent") { $albums = Stats::get_recent("album", $limit, $offset); } else { if ($type == "flagged") { $albums = Userflag::get_latest('album'); } else { if (!$limit) { $limit = AmpConfig::get('popular_threshold'); } $albums = Album::get_random($limit); } } } } } ob_end_clean(); echo XML_Data::albums($albums); }
/** * last_shouts * This get the latest posted shouts * @param array $input */ public static function last_shouts($input) { $limit = intval($input['limit']); if ($limit < 1) { $limit = AmpConfig::get('popular_threshold'); } if (AmpConfig::get('sociable')) { $username = $input['username']; if (!empty($username)) { $shouts = Shoutbox::get_top($limit, $username); } else { $shouts = Shoutbox::get_top($limit); } ob_end_clean(); echo XML_Data::shouts($shouts); } else { debug_event('api', 'Sociable feature is not enabled.', 3); } }
/** * create_xspf */ public function create_xspf() { $result = ""; foreach ($this->urls as $url) { $xml = array(); $xml['track'] = array('title' => $url->title, 'creator' => $url->author, 'duration' => $url->time * 1000, 'location' => $url->url, 'identifier' => $url->url); if ($url->type == 'video') { $xml['track']['meta'] = array('attribute' => 'rel="provider"', 'value' => 'video'); } if ($url->info_url) { $xml['track']['info'] = $url->info_url; } if ($url->image_url) { $xml['track']['image'] = $url->image_url; } if ($url->album) { $xml['track']['album'] = $url->album; } $result .= XML_Data::keyed_array($xml, true); } // end foreach XML_Data::set_type('xspf'); echo XML_Data::header(); echo $result; echo XML_Data::footer(); }
/** * timeline * This get current user friends timeline * @param array $input */ public static function friends_timeline($input) { if (AmpConfig::get('sociable')) { $limit = intval($input['limit']); $since = intval($input['since']); if ($GLOBALS['user']->id > 0) { $activities = Useractivity::get_friends_activities($GLOBALS['user']->id, $limit, $since); ob_end_clean(); echo XML_Data::timeline($activities); } } else { debug_event('api', 'Sociable feature is not enabled.', 3); } }
/** * set_type * * This sets the type of XML_Data we are working on * * @param string $type XML_Data type * @return void */ public static function set_type($type) { if (!in_array($type, array('rss', 'xspf', 'itunes'))) { return false; } self::$type = $type; }