View previous topic :: View next topic |
Author |
Message |
stuntedheight -
Joined: 08 Nov 2003 Posts: 42
|
Posted: Wed Feb 25, 2004 3:34 am Post subject: PHP coder man needed for something |
|
|
Hi.
I suck at PHP so i was wandering if someone could code something for me.
I have this php file that refers to a folder for some images that the script uses. Well im going to be using this file in a bunch of diffrent directorys and i dont wanna have a million diffrent folders with the same stuff in it. And i dont want to have to change the path to the images folder everytime i copy this php file to another new directory.
I was wandering if there was a way to like embed the images into the .php file it self so it would eliminate the use of outside pictures. Heres the code...
<?php
########################################################
# Script Info
# ===========
# File: DirectoryListing.php
# Author: Ash Young (ash@evoluted.net
# Created: 20/12/03
# Modified: 20/12/03
# Website: http://evoluted.net/directorylisting.php
# Requirements: PHP
#
# Description
# ===========
# Displays all files contained within a directory in
# a well formed table, with category-image tags
#
# If you have any functions that you like to see
# implemented in this script then please just send
# an email to ash@evoluted.net
#
# Useage
# ======
#
# To change the colours display when using the script
# scroll down to set up section
#
# To use the script just upload to your server with
# the images and point your browser to the scripts
# filename
#
# SETUP
# =====
#
# Change the following variables to display what colours
# the script outputs
########################################################
DEFINE("IMAGEROOT", "images/"); #CHANGE /images/ TO THE PATH OF THE ASSOCIATED IMAGES
$textcolor = "#FFFFFF"; #TEXT COLOUR
$bgcolor = "#535353"; #PAGE BACKGROUND COLOUR
$normalcolor = "#0066FF"; #TABLE ROW BACKGROUND COLOUR
$highlightcolor = "#006699"; #TABLE ROW BACKGROUND COLOUR WHEN HIGHLIGHTED
$headercolor = "#003366"; #TABLE HEADER BACKGROUND COLOUR
$bordercolor = "#202750"; #TABLE BORDER COLOUR
?>
<html>
<head>
<title>Directory Listings of <? echo $_SERVER["REQUEST_URI"]; ?> </title>
<style type='text/css'>
<!--
body { color: <? echo $textcolor; ?>; font: tahoma, small verdana,arial,helvetica,sans-serif; background-color: <? echo $bgcolor; ?>; }
table { font-family: tahoma, Verdana, Geneva, sans-serif; font-size: 7pt; border: 1px; border-style: solid; border-color: <? echo $bordercolor; ?>; }
.row { background-color: <? echo $normalcolor; ?>; border: 0px;}
a:link { color: <? echo $textcolor; ?>; text-decoration: none; }
a:visited { color: <? echo $textcolor; ?>; text-decoration: none; }
a:hover, a:active { color: <? echo $textcolor; ?>; text-decoration: none; }
img {border: 0;}
#bottomborder {border: <? echo $bordercolor;?>;border-style: solid;border-top-width: 0px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px}
//-->
</style>
</head>
<body>
<?php
clearstatcache();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != substr($PHP_SELF, -(strlen($PHP_SELF) - strrpos($PHP_SELF, "/") - 1))) {
if (filetype($file) == "dir") {
#add directory array
$dirs[] = $file . "/";
}
else {
$files[] = $file;
}
}
}
closedir($handle);
}
@natcasesort($dirs); @natcasesort($files);
$dirs = @array_values($dirs); $files = @array_values($files);
echo "<table width=\"450\" border=\"0\" cellspacing=\"0\" align=\"center\"><tr bgcolor=\"$headercolor\"><td colspan=\"2\" id=\"bottomborder\">File</td><td id=\"bottomborder\" width=\"50\">Size</td><td id=\"bottomborder\" width=\"120\" nowrap>Date Modified</td></tr>";
$arsize = sizeof($dirs);
for($i=0;$i<$arsize;$i++) {
echo "\t<tr class=\"row\" onMouseOver=\"this.style.backgroundColor='$highlightcolor'; this.style.cursor='hand';\" onMouseOut=\"this.style.backgroundColor='$normalcolor';\" onClick=\"window.location.href='" . $dirs[$i] . "';\">";
echo "\t\t<td width=\"16\"><img src=\"" . IMAGEROOT . "folder.gif\" width=\"16\" height=\"16\" alt=\"Directory\"></td>";
echo "\t\t<td><a href=\"" . $dirs[$i] . "\">" . $dirs[$i] . "</a></td>";
echo "\t\t<td width=\"50\" align=\"left\">-</td>";
echo "\t\t<td width=\"120\" align=\"left\" nowrap>" . date ("M d Y h:i:s A", filemtime($dirs[$i])) . "</td>";
echo "\t</tr>";
}
$arsize = sizeof($files);
for($i=0;$i<$arsize;$i++) {
switch (substr($files[$i], -3)) {
case "jpg":
$img = "jpg.gif";
break;
case "gif":
$img = "gif.gif";
break;
case "zip":
$img = "zip.gif";
break;
case "png":
$img = "png.gif";
break;
case "avi":
$img = "move.gif";
break;
case "mpg":
$img = "move.gif";
break;
default:
$img = "what.gif";
break;
}
echo "\t<tr class=\"row\" onMouseOver=\"this.style.backgroundColor='$highlightcolor'; this.style.cursor='hand';\" onMouseOut=\"this.style.backgroundColor='$normalcolor';\" onClick=\"window.location.href='" . $files[$i] . "';\">\r\n";
echo "\t\t<td width=\"16\"><img src=\"" . IMAGEROOT . "$img\" width=\"16\" height=\"16\" alt=\"Directory\"></td>\r\n";
echo "\t\t<td><a href=\"" . $files[$i] . "\">" . $files[$i] . "</a></td>\r\n";
echo "\t\t<td width=\"50\" align=\"left\">" . round(filesize($files[$i])/1024) . "KB</td>\r\n";
echo "\t\t<td width=\"120\" align=\"left\" nowrap>" . date ("M d Y h:i:s A", filemtime($files[$i])) . "</td>\r\n";
echo "\t</tr>\r\n";
}
echo "</table>";
?>
</body>
</html>
I need to embed the following files...
gif.gif
folder.gif
jpg.gif
move.gif
png.gif
what.gif
zip.gif
all these files are in a folder called "/images/" |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed Feb 25, 2004 4:05 am Post subject: |
|
|
I program a bit in PHP and I think
what your trying to do is put image
tags in that php code , do this
Place the following image tag in the place
you want your images displayed , you can
add more than one image and <br> tags
are aloud in the code
Code: | print "<img src=\"image.gif\">"; |
The \"\" are their to make the php code execute
without it thinking its part of a PHP Varibal or something |
|
Back to top |
|
|
stuntedheight -
Joined: 08 Nov 2003 Posts: 42
|
Posted: Wed Feb 25, 2004 4:11 am Post subject: |
|
|
no, thats not what im talking about TRUSTpunk...
I want it like a standalone php file, with no outside files needed. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed Feb 25, 2004 4:17 am Post subject: |
|
|
Im not that advanced yet , sorry that I couldn't help you. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Wed Feb 25, 2004 5:12 pm Post subject: Re: PHP coder man needed for something |
|
|
stuntedheight,
Yes, you can embed the images inside your PHP file but this is a little bit tricky. You can find a real world example in the Andromeda script(http://www.turnstyle.com/andromeda/). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
eznetlinks -
Joined: 27 Sep 2003 Posts: 144
|
|
Back to top |
|
|
|