Robert McLeod Description: Gets all the artists from your profile on ilike and displays them on a page of your choice. */ /* Copyright 2008 Robert McLeod (email : hamstar@telescum.co.nz) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ if (!class_exists("Artists_ilikePlugin")) { class Artists_ilikePlugin { var $adminOptionsName = 'ArtistsilikeAdminOptions'; function Artists_ilikePlugin() { //constructor } function generateArtistsilike() { # Include our classes include_once('php/simple_html_dom.php'); include_once('php/curl.php'); # Set some variables $user = get_option("aiUser"); $url = "http://ilike.com/user/$user/fan_of"; $artists = ''; $eof = 0; $count = 1; if($user) { # Create a new curl object $curl = new curl(); if(empty($curl)) { echo 'curl is empty'; } # Recurse through all the pages while($eof == 0) { # Get the url with curl $response = $curl->get("$url?page=$count"); # Make a html_dom object from our curl response $html = str_get_html($response->body); # Check that there are artists to get if(strstr($html,'hasn\'t told us which artists they like yet.')) { $eof = 1; } else { # Search the html for ul foreach($html->find('ul') as $elem) { # The artists are kept in the artist_list class if($elem->class == 'artist_list') { # Add them to the artists string $artists .= $elem->innertext; } } } # Increment the counter $count++; } # Turn all the artist links into absolute $artists = str_get_html($artists); foreach($artists->find('a') as $a) { $href=$a->href; $a->href = "http://ilike.com$href"; } # Remove the clear left div str_replace('
','',$artists); # Print the artists and the ul $artists = ''; _e("Settings Updated.","Artists_ilikePlugin"); echo '
'; #_e("No such user at ilike. Please check your username.","Artists_ilikePlugin"); #echo '
'; _e("Please set a username first.","Artists_ilikePlugin"); echo '
'; _e("Please wait... ","Artists_ilikePlugin"); $map = $this->generateArtistsilike(); update_option('aiArtistMap',$map); update_option('aiLastMapGenerated',time()); _e("Artist Map Regenerated","Artists_ilikePlugin"); echo '