diff options
author | momo-i <momo-i@ampache> | 2009-03-17 03:48:32 +0000 |
---|---|---|
committer | momo-i <momo-i@ampache> | 2009-03-17 03:48:32 +0000 |
commit | a571f040d68d15861035c981ec440d2a79af65c9 (patch) | |
tree | 19ba2a5296e1431d06c5a3cd857252e7a4497474 /lib/class | |
parent | ad47aa3d04d02888f90a439c207af25ccc739929 (diff) | |
download | ampache-a571f040d68d15861035c981ec440d2a79af65c9.tar.gz ampache-a571f040d68d15861035c981ec440d2a79af65c9.tar.bz2 ampache-a571f040d68d15861035c981ec440d2a79af65c9.zip |
Fixed: remote catalog doesn't clean
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/catalog.class.php | 74 | ||||
-rw-r--r-- | lib/class/xmlrpcserver.class.php | 19 |
2 files changed, 92 insertions, 1 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index bc6d44db..26c3492f 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1434,7 +1434,10 @@ class Catalog extends database_object { $label = "catalog.class.php::update_remote_album_images"; $total_updated = 0; - + + /* If album images don't exist, return value will be 0. */ + if(empty($data)) { return $total_updated; } + /* * We need to check the incomming albums to see which needs to receive an image */ @@ -1555,6 +1558,21 @@ class Catalog extends database_object { } // if localtype else { //do remote url check + $file_info = $this->exists_remote_song($results['file']); + + /* If it errors somethings splated, or the files empty */ + if ($file_info == false) { + /* Add Error */ + Error::add('general',"Error Remote File Not Found or 0 Bytes: " . $results['file']); + + $table = ($results['type'] == 'video') ? 'video' : 'song'; + /* Remove the file! */ + $sql = "DELETE FROM `$table` WHERE `id`='" . $results['id'] . "'"; + $delete_results = Dba::write($sql); + + // Count em! + $dead_files++; + } //if error } // remote catalog } //while gettings songs @@ -2259,6 +2277,60 @@ class Catalog extends database_object { } // check_remote_song /** + * exists_remote_song + * checks to see if a remote song exists in the remote file or not + * if it can't find a song it return the false + */ + public function exists_remote_song($url) { + + $url = parse_url(Dba::escape($url)); + + list($arg,$value) = split('=', $url['query']); + $token = xmlRpcClient::ampache_handshake($this->path,$this->key); + if (!$token) { + debug_event('XMLCLIENT','Error No Token returned', 2); + Error::display('general'); + return; + } else { + debug_event('xmlrpc',"token returned",'4'); + } + + preg_match("/http:\/\/([^\/\:]+):?(\d*)\/*(.*)/", $this->path, $match); + $server = $match['1']; + $port = $match['2'] ? intval($match['2']) : '80'; + $path = $match['3']; + + $full_url = "/" . ltrim($path . "/server/xmlrpc.server.php",'/'); + if(Config::get('proxy_host') AND Config::get('proxy_port')) { + $proxy_host = Config::get('proxy_host'); + $proxy_port = Config::get('proxy_port'); + $proxy_user = Config::get('proxy_user'); + $proxy_pass = Config::get('proxy_pass'); + } + + $client = new XML_RPC_Client($full_url,$server,$port,$proxy_host,$proxy_port,$proxy_user,$proxy_pass); + + $song_id = new XML_RPC_Value($value,'int'); + $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.check_song', array($song_id)); + $response = $client->send($xmlrpc_message,30); + + if ($response->faultCode() ) { + $error_msg = _("Error connecting to") . " " . $server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString(); + debug_event('XMLCLIENT(exists_remote_song)',$error_msg,'1'); + echo "<p class=\"error\">$error_msg</p>"; + return; + } + + $data = XML_RPC_Decode($response->value()); + + if($data == '0') { + return false; + } else { + return true; + } + } + + /** * check_local_mp3 * Checks the song to see if it's there already returns true if found, false if not */ diff --git a/lib/class/xmlrpcserver.class.php b/lib/class/xmlrpcserver.class.php index ae1d1653..3cdd7907 100644 --- a/lib/class/xmlrpcserver.class.php +++ b/lib/class/xmlrpcserver.class.php @@ -192,6 +192,25 @@ class xmlRpcServer { } // create_stream_session /** + * check_song + * This checks remote catalog + */ + public static function check_song($xmlrpc_object) { + + $var = $xmlrpc_object->params['0']->me['int']; + $sql = "SELECT `song`.`id` FROM `song` WHERE `id`='" . $var ."'"; + $db_results = Dba::read($sql); + if(Dba::num_rows($db_results) == '0') { + $return = 0; + } else { + $return = 1; + } + + return new XML_RPC_Response(XML_RPC_encode($return)); + + } + + /** * handshake * This should be run before any other XMLRPC actions, it checks the KEY encoded with a timestamp then returns a valid TOKEN to be * used in all further communication |