Page 1 of 1

Anybody good at PHP? attn: bitwise

Posted: Mon May 16, 2005 3:43 am
by FragaGeddon
I don't know shit and need some help.

Posted: Mon May 16, 2005 3:44 am
by andyman
What are you trying to do?

http://andyman82.com/forum/index.php

Edit: while its out there, how in the hell can I cahnge the big "LOGO" on the top left?

Posted: Mon May 16, 2005 3:47 am
by mjrpes
Post a question and mebbe you'll get an answer.

Posted: Mon May 16, 2005 3:49 am
by Canidae
andyman wrote:What are you trying to do?

http://andyman82.com/forum/index.php

Edit: while its out there, how in the hell can I cahnge the big "LOGO" on the top left?
Uhhh...with a flash editor?

Posted: Mon May 16, 2005 3:51 am
by FragaGeddon
I'm want to use this program: Now Playing
I just need help with the PHP file to set it up the way I want.

Code: Select all

<?php

error_reporting(E_ALL ^ E_NOTICE);

$file = "now_playing.xml";
$xml_parser = xml_parser_create();

if ( is_file( $file ) )
{
	$fp = fopen( $file, "r" );
	$data = fread( $fp, filesize( $file ) );
	fclose( $fp );
	xml_parse_into_struct( $xml_parser, $data, $vals, $index );
	xml_parser_free( $xml_parser );

	if ( isset( $_GET["debug"] ) )
	{
		echo "<pre>";
		echo "Index array\n";
		print_r($index);
		echo "\nVals array\n";
		print_r($vals);
		echo "</pre>\n\n";
	}

	$fHeader = false;

	if ( $vals[ $index["NOW_PLAYING"][0] ]["attributes"]["PLAYING"] == 1 )
	{
		foreach ( $index["TITLE"] as $i => $j )
		{
			$url = '';
			$title = $vals[ $index["TITLE"][$i] ]["value"];

			if ( strlen( $title ) > 0 )
			{
				$artist = $vals[ $index["ARTIST"][$i] ]["value"];
				$album = $vals[ $index["ALBUM"][$i] ]["value"];
				$genre = $vals[ $index["GENRE"][$i] ]["value"];
				$kind = $vals[ $index["KIND"][$i] ]["value"];
				$track = $vals[ $index["TRACK"][$i] ]["value"];
				$numtracks = $vals[ $index["NUMTRACKS"][$i] ]["value"];
				$year = $vals[$index["YEAR"][$i] ]["value"];
				$comments = $vals[ $index["COMMENTS"][$i] ]["value"];
				$time = $vals[ $index["TIME"][$i] ]["value"];
				$bitrate = $vals[ $index["BITRATE"][$i] ]["value"];
				$rating = $vals[ $index["RATING"][$i] ]["value"];
				$disc = $vals[ $index["DISC"][$i] ]["value"];
				$numdiscs = $vals[ $index["NUMDISCS"][$i] ]["value"];
				$playcount = $vals[ $index["PLAYCOUNT"][$i] ]["value"];
				$compilation = $vals[ $index["COMPILATION"][$i] ]["value"];
				$urlamazon = $vals[ $index["URLAMAZON"][$i] ]["value"];
				$urlapple = $vals[ $index["URLAPPLE"][$i] ]["value"];
				$imageurl = $vals[ $index["IMAGE"][$i] ]["value"];
				$composer = $vals[ $index["COMPOSER"][$i] ]["value"];
				$urlsource = $vals[ $index["URLSOURCE"][$i] ]["value"];
				$grouping = $vals[ $index["GROUPING"][$i] ]["value"];

				if ( strlen( $grouping ) > 0 && strcmp( $grouping, "Podcast" ) == 0 )
				{
					$imageurl = '/images/podcast.gif';
				}
				else if ( strlen( $imageurl ) == 0 )
				{
					$imageurl = '/images/music-no-image.gif';
				}
				else
				{
					list($width, $height, $type, $attr) = getimagesize( $imageurl );

					if ( $width == 1 || $height == 1 )
					{
						$imageurl = '/images/music-no-image.gif';
					}
				}

				#
				# If we couldn't find them at Amazon, let's just do an artist search at B&N
				#

				if ( strlen( $urlamazon ) > 0 )
				{
					$url = $urlamazon;
				}
				else if ( strncmp( $comments, "http://", 7 ) == 0 )
				{
					$url = $comments;
				}
				else if ( strlen( $urlsource ) > 0 )
				{
					$url = $urlsource;
				}
				else
				{
					$url = 'http://music.barnesandnoble.com/search/results.asp?NME=' . urlencode( $artist ) . '&SNG=&INS=&LBL=&TYP=P&CAT=&Search=Search';
				}
				
				#
				# Output
				#

				if ( isset( $_GET["debug"] ) )
				{
					echo "<script type=\"text/javascript\">\n";
				}

				if ( !$fHeader )
				{
					$fHeader = true;
					echo 'document.write("<div class=\"sidetitle\">Now Playing (<a href=\"http://brandon.fuller.name/archives/hacks/nowplaying/\">?</a>)</div>");' . "\n";
				}

				echo 'document.write("<div class=\"side\" style=\"text-align: center;\"><a href=\"' . $url . '\" target=\"new\"><img src=\"' . $imageurl . '\" alt=\"' . htmlentities( $artist, ENT_QUOTES );
				if ( strlen( $album ) > 0 )
				{
					echo ' - ' . htmlentities( $album, ENT_QUOTES );
				}
				echo '\" /></a><br /><a href=\"' . $url . '\" target=\"new\">' . htmlentities( $artist, ENT_QUOTES ) . '</a><br><i>' . htmlentities( $title, ENT_QUOTES ) . "</i>\");\n";

				if ( strlen( $rating ) > 0 && !isset( $_GET["hide_rating"] ) )
				{
					echo 'document.write("<br /><br /><img src=\"/images/stars-' . $rating . '.gif\" alt=\"Rating\" />");' . "\n";
				}

				if ( strlen( $urlapple ) > 0 )
				{
					echo 'document.write("<br /><br /><a href=\"' . $urlapple . '\"><img src=\"/images/iTunes.gif\" alt=\"View at iTunes Music Store!\" /></a>");' . "\n";
				}

				echo "document.write(\"</div>\");\n";

				if ( isset( $_GET["debug"] ) )
				{
					echo "</script>\n";
				}
			}
		}
	}
}

?>
I want to find the images from my own directory on my site.
Want to remove the Now Playing link and move the artists name above the album cover.
I was hoping of someway of making it into a gif.

Or does someone know of a better program that works with iTunes?

Posted: Mon May 16, 2005 3:52 am
by andyman
Canidae wrote:
andyman wrote:What are you trying to do?

http://andyman82.com/forum/index.php

Edit: while its out there, how in the hell can I cahnge the big "LOGO" on the top left?
Uhhh...with a flash editor?
yea i know that but it is embedded in the php code somewhere and i don't know how to make it read a different image. I have found the original flash of LOGO HERE but no programs are able to break it down into editable parts.

Posted: Mon May 16, 2005 3:58 am
by mjrpes
If you look at the source code on your forum it has a line that says "comment out this line in order to use a gif image instead of flash." You have to find that in the code somewhere . I'd imagine it might be in the pages that deal with the template.

Posted: Mon May 16, 2005 4:01 am
by andyman
ok I'll give a looksy tomorrow...thanks!

Posted: Mon May 16, 2005 4:13 am
by FragaGeddon
k

Posted: Mon May 16, 2005 5:08 am
by bitWISE
I'm on it. Give me a few minutes to see if I can make sense of what I'm looking at.

Posted: Mon May 16, 2005 5:12 am
by FragaGeddon
If you check the site you might understand it a bit better?!?
All mages are here: http://www.fragageddon.com/images/MP3

Posted: Mon May 16, 2005 5:19 am
by bitWISE
Ok, this should tweak it the way you want. If you want to run images on your machine I could setup a system for you but we would have to agree on what you wanted to do and you would need to manually upload those images in the format. For example do want to have it setup like: 'images/albums/artist-album.gif' ?

Code: Select all

<?php
error_reporting(E_ALL ^ E_NOTICE);

$file = "now_playing.xml";
$xml_parser = xml_parser_create();

if ( is_file( $file ) )
{
   $fp = fopen( $file, "r" );
   $data = fread( $fp, filesize( $file ) );
   fclose( $fp );
   xml_parse_into_struct( $xml_parser, $data, $vals, $index );
   xml_parser_free( $xml_parser );

   if ( isset( $_GET["debug"] ) )
   {
      echo "<pre>";
      echo "Index array\n";
      print_r($index);
      echo "\nVals array\n";
      print_r($vals);
      echo "</pre>\n\n";
   }

   $fHeader = false;

   if ( $vals[ $index["NOW_PLAYING"][0] ]["attributes"]["PLAYING"] == 1 )
   {
      foreach ( $index["TITLE"] as $i => $j )
      {
         $url = '';
         $title = $vals[ $index["TITLE"][$i] ]["value"];

         if ( strlen( $title ) > 0 )
         {
            $artist = $vals[ $index["ARTIST"][$i] ]["value"];
            $album = $vals[ $index["ALBUM"][$i] ]["value"];
            $genre = $vals[ $index["GENRE"][$i] ]["value"];
            $kind = $vals[ $index["KIND"][$i] ]["value"];
            $track = $vals[ $index["TRACK"][$i] ]["value"];
            $numtracks = $vals[ $index["NUMTRACKS"][$i] ]["value"];
            $year = $vals[$index["YEAR"][$i] ]["value"];
            $comments = $vals[ $index["COMMENTS"][$i] ]["value"];
            $time = $vals[ $index["TIME"][$i] ]["value"];
            $bitrate = $vals[ $index["BITRATE"][$i] ]["value"];
            $rating = $vals[ $index["RATING"][$i] ]["value"];
            $disc = $vals[ $index["DISC"][$i] ]["value"];
            $numdiscs = $vals[ $index["NUMDISCS"][$i] ]["value"];
            $playcount = $vals[ $index["PLAYCOUNT"][$i] ]["value"];
            $compilation = $vals[ $index["COMPILATION"][$i] ]["value"];
            $urlamazon = $vals[ $index["URLAMAZON"][$i] ]["value"];
            $urlapple = $vals[ $index["URLAPPLE"][$i] ]["value"];
            $imageurl = $vals[ $index["IMAGE"][$i] ]["value"];
            $composer = $vals[ $index["COMPOSER"][$i] ]["value"];
            $urlsource = $vals[ $index["URLSOURCE"][$i] ]["value"];
            $grouping = $vals[ $index["GROUPING"][$i] ]["value"];

            if ( strlen( $grouping ) > 0 && strcmp( $grouping, "Podcast" ) == 0 )
            {
               $imageurl = '/images/podcast.gif';
            }
            else if ( strlen( $imageurl ) == 0 )
            {
               $imageurl = '/images/music-no-image.gif';
            }
            else
            {
               list($width, $height, $type, $attr) = getimagesize( $imageurl );

               if ( $width == 1 || $height == 1 )
               {
                  $imageurl = '/images/music-no-image.gif';
               }
            }

            #
            # If we couldn't find them at Amazon, let's just do an artist search at B&N
            #

            if ( strlen( $urlamazon ) > 0 )
            {
               $url = $urlamazon;
            }
            else if ( strncmp( $comments, "http://", 7 ) == 0 )
            {
               $url = $comments;
            }
            else if ( strlen( $urlsource ) > 0 )
            {
               $url = $urlsource;
            }
            else
            {
               $url = 'http://music.barnesandnoble.com/search/results.asp?NME=' . urlencode( $artist ) . '&SNG=&INS=&LBL=&TYP=P&CAT=&Search=Search';
            }
            
            #
            # Output
            #

            if ( isset( $_GET["debug"] ) )
            {
               echo "<script type=\"text/javascript\">\n";
            }

            if ( $fHeader )
            {
               $fHeader = true;
               echo 'document.write("<div class=\"sidetitle\">Now Playing (<a href=\"http://brandon.fuller.name/archives/hacks/nowplaying/\">?</a>)</div>");' . "\n";
            }

            echo 'document.write("<div class=\"side\" style=\"text-align: center;\"><a href=\"' . $url . '\" target=\"new\">' . htmlentities( $artist, ENT_QUOTES ) . '</a><br><a href=\"' . $url . '\" target=\"new\"><img src=\"' . $imageurl . '\" alt=\"' . htmlentities( $artist, ENT_QUOTES );

            if ( strlen( $album ) > 0 )
            {
               echo ' - ' . htmlentities( $album, ENT_QUOTES );
            }
            
			echo '\" /></a><br /><i>' . htmlentities( $title, ENT_QUOTES ) . "</i>\");\n";

            if ( strlen( $rating ) > 0 && !isset( $_GET["hide_rating"] ) )
            {
               echo 'document.write("<br /><br /><img src=\"/images/stars-' . $rating . '.gif\" alt=\"Rating\" />");' . "\n";
            }

            if ( strlen( $urlapple ) > 0 )
            {
               echo 'document.write("<br /><br /><a href=\"' . $urlapple . '\"><img src=\"/images/iTunes.gif\" alt=\"View at iTunes Music Store!\" /></a>");' . "\n";
            }

            echo "document.write(\"</div>\");\n";

            if ( isset( $_GET["debug"] ) )
            {
               echo "</script>\n";
            }
         }
      }
   }
}

?>

Posted: Mon May 16, 2005 5:25 am
by FragaGeddon
bitWISE wrote:Ok, this should tweak it the way you want. If you want to run images on your machine I could setup a system for you but we would have to agree on what you wanted to do and you would need to manually upload those images in the format. For example do want to have it setup like: 'images/albums/artist-album.gif' ?
Yeah I'm planning on uploading the images.
The file name would be: Artist - Album title

Posted: Mon May 16, 2005 5:27 am
by FragaGeddon

Posted: Mon May 16, 2005 5:33 am
by FragaGeddon
I believe I can change this to reflect my site:

Code: Select all

http://music.barnesandnoble.com/search/results.asp?NME=
Just not sure about this:

Code: Select all

. urlencode( $artist ) . '&SNG=&INS=&LBL=&TYP=P&CAT=&Search=Search';

Posted: Mon May 16, 2005 5:37 am
by bitWISE
Thats just linking the viewer over to a place where they can find more information about the album and/or buy it.

The image URL is being pulled straight from the XML file.

Posted: Mon May 16, 2005 5:40 am
by FragaGeddon
I aksed the author and he said I could just edit the PHP file. Oh well.
Thanks for the help.