summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-22 17:44:10 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-22 17:44:10 +0000
commit67cbb218cd89ac6be9d1d55ca3799080daac1f5a (patch)
tree9aabddaed61a0bda1e477cf44c69400d1590779f /lib
parentd5ae71f551f0aebef1dbae518a116a1c86430ffb (diff)
downloadampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.tar.gz
ampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.tar.bz2
ampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.zip
renamed xml-rpc acl to rpc, added default mime type of image/jpg and added config options for batch download to the fs, no garbage collection for non-completed downloads yet.
Diffstat (limited to 'lib')
-rw-r--r--lib/batch.lib.php18
-rw-r--r--lib/class/access.class.php13
-rw-r--r--lib/class/album.class.php3
-rw-r--r--lib/class/api.class.php10
-rw-r--r--lib/class/xmldata.class.php53
5 files changed, 85 insertions, 12 deletions
diff --git a/lib/batch.lib.php b/lib/batch.lib.php
index c49e04a4..ae919767 100644
--- a/lib/batch.lib.php
+++ b/lib/batch.lib.php
@@ -50,11 +50,27 @@ function get_song_files($song_ids) {
*/
function send_zip( $name, $song_files ) {
+ // Check if they want to save it to a file, if so then make sure they've got
+ // a defined path as well and that it's writeable
+ if (Config::get('file_zip_download') && Config::get('file_zip_path')) {
+ // Check writeable
+ if (!is_writable(Config::get('file_zip_path'))) {
+ $in_memory = '1';
+ debug_event('Error','File Zip Path:' . Config::get('file_zip_path') . ' is not writeable','1');
+ }
+ else {
+ $in_memory = '0';
+ $basedir = Config::get('file_zip_path');
+ }
+
+ } // if file downloads
+
/* Require needed library */
require_once Config::get('prefix') . '/modules/archive/archive.lib.php';
$arc = new zip_file( $name . ".zip" );
$options = array(
- 'inmemory' => 1, // create archive in memory
+ 'inmemory' => $in_memory, // create archive in memory
+ 'basedir' => $basedir,
'storepaths' => 0, // only store file name, not full path
'level' => 0 // no compression
);
diff --git a/lib/class/access.class.php b/lib/class/access.class.php
index c9e41512..59289c7c 100644
--- a/lib/class/access.class.php
+++ b/lib/class/access.class.php
@@ -183,10 +183,11 @@ class Access {
$sql = "SELECT `id` FROM `access_list`" .
" WHERE `start` <= '$ip' AND `end` >= '$ip' AND `type`='xml-rpc' AND `level` >= '$level'";
break;
+ case 'rpc':
case 'xml-rpc':
$sql = "SELECT `id` FROM `access_list`" .
" WHERE `start` <= '$ip' AND `end` >= '$ip'" .
- " AND `key` = '$key' AND `level` >= '$level' AND `type`='xml-rpc'";
+ " AND `key` = '$key' AND `level` >= '$level' AND (`type`='xml-rpc' OR `type`='rpc')";
break;
case 'network':
case 'interface':
@@ -221,11 +222,14 @@ class Access {
public static function validate_type($type) {
switch($type) {
- case 'xml-rpc':
+ case 'rpc':
case 'interface':
case 'network':
return $type;
break;
+ case 'xml-rpc':
+ return 'rpc';
+ break;
default:
return 'stream';
break;
@@ -297,8 +301,9 @@ class Access {
public function get_type_name() {
switch ($this->type) {
- case 'xml-rpc':
- return 'XML-RPC';
+ case 'xml-rpc':
+ case 'rpc':
+ return 'RPC';
break;
case 'network':
return 'Local Network Definition';
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 601b1f9b..bbacf852 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -751,6 +751,9 @@ class Album {
}
} // if we have PHP:GD
+ // Default to image/jpg as a guess if there is no passed mime type
+ $mime = $mime ? $mime : 'image/jpg';
+
// Push the image into the database
$sql = "REPLACE INTO `album_data` SET `art` = '" . Dba::escape($image) . "'," .
" `art_mime` = '" . Dba::escape($mime) . "'" .
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index 1ebc86e8..592ae953 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -26,6 +26,8 @@
*/
class Api {
+ public static $version = '340001';
+
/**
* constructor
* This really isn't anything to do here, so it's private
@@ -45,6 +47,11 @@ class Api {
*/
public static function handshake($timestamp,$passphrase,$ip,$username='') {
+ // If the timestamp is over 2hr old sucks to be them
+// if ($timestamp < (time() - 7200)) {
+// return 'Timestamp too old, try again';
+// }
+
// First we'll filter by username and IP
if (!$username) {
$user_id = '-1';
@@ -76,7 +83,8 @@ class Api {
// Create the Session, in this class for now needs to be moved
$token = self::create_session($row['level'],$ip,$user_id);
debug_event('API','Login Success, passphrase matched','1');
- return $token;
+
+ return array('auth'=>$token,'api'=>self::$version);
} // match
} // end while
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index c9d49a3f..ac776635 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -27,10 +27,9 @@
*/
class xmlData {
- public static $version = '340001';
-
// This is added so that we don't pop any webservers
public static $limit = '5000';
+ private static $offset = '0';
/**
* constructor
@@ -43,6 +42,17 @@ class xmlData {
} // constructor
/**
+ * set_offset
+ * This takes an int and changes the offset
+ */
+ public static function set_offset($offset) {
+
+ $offset = intval($offset);
+ self::$offset = $offset;
+
+ } // set_offset
+
+ /**
* error
* This generates a standard XML Error message
* nothing fancy here...
@@ -67,6 +77,35 @@ class xmlData {
} // single_string
/**
+ * keyed_array
+ * This will build an xml document from a key'd array,
+ */
+ public static function keyed_array($array,$callback='') {
+
+ $string = '';
+
+ // Foreach it
+ foreach ($array as $key=>$value) {
+ // If it's an array, run again
+ if (is_array($value)) {
+ $value = self::keyed_array($value,1);
+ $string .= "\t<$key>$value</$key>\n";
+ }
+ else {
+ $string .= "\t<$key><![CDATA[$value]]></$key>\n";
+ }
+
+ } // end foreach
+
+ if (!$callback) {
+ $string = self::_header() . $string . self::_footer();
+ }
+
+ return $string;
+
+ } // keyed_array
+
+ /**
* artists
* This takes an array of artists and then returns a pretty xml document with the information
* we want
@@ -74,9 +113,11 @@ class xmlData {
public static function artists($artists) {
if (count($artists) > self::$limit) {
- $artists = array_splice($artists,0,self::$limit);
+ $artists = array_splice($artists,self::$offset,self::$limit);
}
+ $string = '';
+
foreach ($artists as $artist_id) {
$artist = new Artist($artist_id);
$artist->format();
@@ -98,7 +139,7 @@ class xmlData {
public static function albums($albums) {
if (count($albums) > self::$limit) {
- $albums = array_splice($albums,0,self::$limit);
+ $albums = array_splice($albums,self::$offset,self::$limit);
}
foreach ($albums as $album_id) {
@@ -139,7 +180,7 @@ class xmlData {
public static function genres($genres) {
if (count($genres) > self::$limit) {
- $genres = array_slice($genres,0,self::$limit);
+ $genres = array_slice($genres,self::$offset,self::$limit);
}
// Foreach the ids
@@ -172,7 +213,7 @@ class xmlData {
public static function songs($songs) {
if (count($songs) > self::$limit) {
- $songs = array_slice($songs,0,self::$limit);
+ $songs = array_slice($songs,self::$offset,self::$limit);
}
// Foreach the ids!