Anybody good at PHP? attn: bitwise

Open discussion about any topic, as long as you abide by the rules of course!
Post Reply
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Anybody good at PHP? attn: bitwise

Post by FragaGeddon »

I don't know shit and need some help.
Last edited by FragaGeddon on Mon May 16, 2005 4:13 am, edited 1 time in total.
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
andyman
Posts: 11198
Joined: Wed Feb 09, 2005 8:20 pm

Post 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?
mjrpes
Posts: 4980
Joined: Tue Nov 28, 2000 8:00 am

Post by mjrpes »

Post a question and mebbe you'll get an answer.
[size=85]yea i've too been kind of thinking about maybe a new sig but sort of haven't come to quite a decision yet[/size]
Canidae
Posts: 2351
Joined: Tue Feb 08, 2005 5:29 am

Post 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?
[img]http://www.subliminaldissonance.com/popehat.jpg[/img] [img]http://www.subliminaldissonance.com/images/smilies/nothing.jpg[/img]
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post 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?
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
andyman
Posts: 11198
Joined: Wed Feb 09, 2005 8:20 pm

Post 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.
mjrpes
Posts: 4980
Joined: Tue Nov 28, 2000 8:00 am

Post 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.
[size=85]yea i've too been kind of thinking about maybe a new sig but sort of haven't come to quite a decision yet[/size]
andyman
Posts: 11198
Joined: Wed Feb 09, 2005 8:20 pm

Post by andyman »

ok I'll give a looksy tomorrow...thanks!
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post by FragaGeddon »

k
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Post by bitWISE »

I'm on it. Give me a few minutes to see if I can make sense of what I'm looking at.
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post by FragaGeddon »

If you check the site you might understand it a bit better?!?
All mages are here: http://www.fragageddon.com/images/MP3
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Post 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";
            }
         }
      }
   }
}

?>
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post 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
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post by FragaGeddon »

[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post 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';
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Post 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.
User avatar
FragaGeddon
Posts: 3229
Joined: Sun Sep 17, 2000 7:00 am

Post by FragaGeddon »

I aksed the author and he said I could just edit the PHP file. Oh well.
Thanks for the help.
[img]http://www.fragageddon.com/images/albums/userpics/10001/FragaGeddon.png[/img]
Post Reply