Location: PHPKode > projects > Brunhilde Media Server > brunhilde/themes.php
<?php

### theme.php ###
// allows a client to browse through and choose a theme for personal use

include("global.php");

// reads the theme directory and builds an array of every theme found
$theme_array = array();
$d = opendir("$THEME_PATH");
while($contents = readdir($d)) { //loops through all of the direcotories contents
  if($contents == "." || $contents == "..") { continue; }
  // if a folder is found
  else if(is_dir("$THEME_PATH$contents")) { array_push($theme_array, $contents); }
  // if a file is found
  else { continue; }
  }
  
closedir($d);
sort($theme_array);

// ensures that the "back to songlist" link is displayed
$cdir = "blarg";

// html
echo "<HTML>";
echo "<title>Brunhilde Theme Browser</title>\n";
echo "</head>";

// displays the standard header
include("header.php");

// page body
echo "
<p align=center>
<TABLE border=0 cellpadding=0 cellspacing=2 width=100% $BORDER>
 <TBODY>
 <TR>
  <TD>
   <TABLE border=0 cellpadding=1 cellspacing=1 width=100% $BODY>
    <TBODY>
    <TR $TITLE>
     <TD width=100% align=center><B>Theme Browser:</B></TD></TR>
    <TR>
     <TD>
      <TABLE border=0 width=100% cellpadding=0 cellspacing=0>
      <TBODY>
      <TR>
       <TD><BR></TD>
      </TR>
      <!-- Begin Theme Postings -->
";

// loops through each theme found in the themes directory
for($i = 0; $i < sizeof($theme_array); $i++) {
  $theme = $theme_array[$i];
  $theme_url = rawurlencode($theme_array[$i]);

  // gets information about the theme
  include("$THEME_DIR$theme/info.php");

  // uses "unknown name" if no name was given
  if(!isset($THEME_NAME)) { $THEME_NAME = "unknown name"; }

  // uses "unknown" if the author name is not given
  if(!isset($THEME_AUTHOR)) { $THEME_AUTHOR = "unknown"; }

  // uses "unknown" if the last updated date was not given
  if(!isset($THEME_DATE)) { $THEME_DATE = "unknown"; }

  // uses "none given" if no description was given
  if(!isset($THEME_DESC)) { $THEME_DESC = "none given."; }

  // uses "none given" if no comment was given
  if(!isset($THEME_COMMENT)) { $THEME_COMMENT = "none given."; }
  
  echo "
      
      
      <TR>
       <TD><BR></TD>
      </TR>
      <TR>
       <TD align=center><font size=3><B>'$THEME_NAME'</B></font></td>
      </TR>
      <TR>
       <TD valign=top>
        <TABLE width=100% cellspacing=2 cellpadding=4 border=0>
         <TBODY>
	 <TR>
	  <TD width=192 align=center valign=bottom>
	   <a href=sample.php?theme=$theme_url>
	   ";
  // looks for a supplied 'screenshot.jpg' file for display
  if(is_file("$THEME_DIR$theme/screenshot.jpg")) {
    echo "<img src=$THEME_DIR$theme/screenshot.jpg border=0 height=120 width=170></a>\n";
    }
  else {
    echo "<img src=pics/screenshot.jpg border=1 height=120 width=170></a>\n";
    }

echo "
         </TD>
	  <TD width=100% valign=top align=right>
	   Created by ";

  // leaves of the "mailto" link of the author's email address is unknown
  if(isset($THEME_MAIL)) { echo "<a href=mailto:$THEME_MAIL><B>$THEME_AUTHOR</B></a>"; }
  else { echo "<B>$THEME_AUTHOR</B>"; }

  echo "	   
	   <BR>
	   <font size=3>Updated $THEME_DATE</font>
	   <BR>
           <BR>
	   <p>
	    <font size=3><B>Description:&nbsp;&nbsp;</B></font><BR>
            <font size=3>$THEME_DESC&nbsp;&nbsp;</font>
	   </p>
           <p>
	    <font size=3><B>Author's&nbsp;Comment:&nbsp;&nbsp;</B></font><br>
	    <font size=3>$THEME_COMMENT&nbsp;&nbsp;</font>
	   </p>
	  </TD>
	 </TR>
         <TR>
	  <TD valign=top align=center>
	   <a href=sample.php?theme=$theme_url><small>
	   <B>screenshot</B></small>
	   </a>
          </TD>
         </TR>
	 </TBODY>
	</TABLE>
       </TD>
      </TR>
      </TBODY>
     </TABLE>
     <TABLE width=100% border=0 cellspacing=0 cellpadding=0>
      <TBODY>
      <TR>
       <TD colspan=3 nowrap>
        <TABLE width=\"100%\" border=0 cellspacing=0 cellpadding=0>
	 <TBODY>
          <TR>
           <TD align=right>
	    <a href=set_theme.php?theme=$theme_url>
	    <font size=3><B>&nbsp;&nbsp;Select&nbsp;This&nbsp;Theme&nbsp;&nbsp;</B></font><BR>
	    </a>
	   </TD>
          </TR>
          <TR>
           <TD>
            <hr>
           </TD>
          </TR>
          </TBODY>
         </table>

";

  // unsets theme variables for the next theme
  unset ($THEME_AUTHOR);
  unset ($THEME_MAIL);
  unset ($THEME_NAME);
  unset ($THEME_DESC);
  unset ($THEME_COMMENT);
  unset ($THEME_DATE);

  }

echo "
          </TD>
         </TR>
	 <TR>
	  <TD align=center valign=top>
           Point your server administrator to <a href=http://www.coreyo.net/projects/brunhilde/themes.php><B>www.coreyo.net/projects/brunhilde/themes.php</B></a> for more themes.
         </TD>
	</TR>
        </TBODY>
       </TABLE>
      </TD>
     </TR>
    </TBODY>
   </TABLE>
  </TD>
 </TR>
 </TBODY>
</TABLE>
</p>

";

  
// footer
include("footer.php");

echo "</body></html>";

exit;

?>
Return current item: Brunhilde Media Server