diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-05 07:13:25 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-05 07:13:25 +0000 |
commit | 83c7a25a76efaf74467c6654f20be3a8029040d9 (patch) | |
tree | aa90f459c74d7d1ec8ba38fa4077873ed4f65dd8 /lib/class | |
parent | edf482ff3d21c84d99f25b84884563a8781fa7ae (diff) | |
download | ampache-83c7a25a76efaf74467c6654f20be3a8029040d9.tar.gz ampache-83c7a25a76efaf74467c6654f20be3a8029040d9.tar.bz2 ampache-83c7a25a76efaf74467c6654f20be3a8029040d9.zip |
missed some requires, tweaked the lastfm class and removed an unused function from general
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/audioscrobbler.class.php | 38 | ||||
-rw-r--r-- | lib/class/dba.class.php | 18 |
2 files changed, 35 insertions, 21 deletions
diff --git a/lib/class/audioscrobbler.class.php b/lib/class/audioscrobbler.class.php index 68162c46..a90fc773 100644 --- a/lib/class/audioscrobbler.class.php +++ b/lib/class/audioscrobbler.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -21,20 +21,20 @@ class scrobbler { - var $error_msg; - var $username; - var $password; - var $challenge; - var $submit_host; - var $submit_port; - var $submit_url; - var $queued_tracks; + public $error_msg; + public $username; + public $password; + public $challenge; + public $submit_host; + public $submit_port; + public $submit_url; + public $queued_tracks; /** * Constructor * This is the constructer it takes a username and password */ - function scrobbler($username, $password) { + public function __construct($username, $password) { $this->error_msg = ''; $this->username = trim($username); @@ -47,7 +47,7 @@ class scrobbler { /** * get_error_msg */ - function get_error_msg() { + public function get_error_msg() { return $this->error_msg; @@ -55,7 +55,8 @@ class scrobbler { /** * get_queue_count - function get_queue_count() { + */ + public function get_queue_count() { return count($this->queued_tracks); @@ -66,9 +67,9 @@ class scrobbler { * This does a handshake with the audioscrobber server it doesn't pass the password, but * it does pass the username and has a 10 second timeout */ - function handshake() { + public function handshake() { - $as_socket = @fsockopen('post.audioscrobbler.com', 80, $errno, $errstr, 10); + $as_socket = @fsockopen('post.audioscrobbler.com', 80, $errno, $errstr, 15); if(!$as_socket) { $this->error_msg = $errstr; return false; @@ -84,7 +85,7 @@ class scrobbler { $buffer = ''; while(!feof($as_socket)) { - $buffer .= fread($as_socket, 8192); + $buffer .= fread($as_socket, 4096); } fclose($as_socket); $split_response = preg_split("/\r\n\r\n/", $buffer); @@ -126,7 +127,7 @@ class scrobbler { * submit the track or talk to LastFM in anyway, kind of useless for our uses but its * here, and that's how it is. */ - function queue_track($artist, $album, $track, $timestamp, $length) { + public function queue_track($artist, $album, $track, $timestamp, $length) { $date = gmdate('Y-m-d H:i:s', $timestamp); $mydate = date('Y-m-d H:i:s T', $timestamp); @@ -146,12 +147,13 @@ class scrobbler { return true; } // queue_track + /** * submit_tracks * This actually talks to LastFM submiting the tracks that are queued up. It * passed the md5'd password combinted with the challenge, which is then md5'd */ - function submit_tracks() { + public function submit_tracks() { // Check and make sure that we've got some queued tracks if(!count($this->queued_tracks)) { @@ -173,7 +175,7 @@ class scrobbler { $i++; } - $as_socket = @fsockopen($this->submit_host, $this->submit_port, $errno, $errstr, 10); + $as_socket = @fsockopen($this->submit_host, $this->submit_port, $errno, $errstr, 15); if(!$as_socket) { $this->error_msg = $errstr; diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index b37ca39d..70bd47f5 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -34,6 +34,7 @@ class Dba { private static $_default_db; + private static $_sql; private static $config; /** @@ -53,7 +54,11 @@ class Dba { */ public static function query($sql) { + // Run the query $resource = mysql_query($sql,self::dbh()); + + // Save the query, to make debug easier + self::$_sql = $sql; return $resource; @@ -81,7 +86,9 @@ class Dba { $result = mysql_fetch_assoc($resource); - if (!$result) { return array(); } + if (!$result) { + return array(); + } return $result; @@ -96,7 +103,9 @@ class Dba { $result = mysql_fetch_row($resource); - if (!$result) { return array(); } + if (!$result) { + return array(); + } return $result; @@ -112,7 +121,9 @@ class Dba { $result = mysql_num_rows($resource); - if (!$result) { return '0'; } + if (!$result) { + return '0'; + } return $result; } // num_rows @@ -137,6 +148,7 @@ class Dba { if (!$dbh) { debug_event('Database','Error unable to connect to database' . mysql_error(),'1'); } $select_db = mysql_select_db($database,$dbh); + if (!$select_db) { debug_event('Database','Error unable to select ' . $database . ' error ' . mysql_error(),'1'); } return $dbh; |