PHP coder man needed for something

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
stuntedheight
-


Joined: 08 Nov 2003
Posts: 42

PostPosted: Wed Feb 25, 2004 3:34 am    Post subject: PHP coder man needed for something Reply with quote

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 View user's profile Send private message AIM Address
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed Feb 25, 2004 4:05 am    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
stuntedheight
-


Joined: 08 Nov 2003
Posts: 42

PostPosted: Wed Feb 25, 2004 4:11 am    Post subject: Reply with quote

no, thats not what im talking about TRUSTpunk...

I want it like a standalone php file, with no outside files needed.
Back to top View user's profile Send private message AIM Address
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed Feb 25, 2004 4:17 am    Post subject: Reply with quote

Im not that advanced yet , sorry that I couldn't help you.
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Feb 25, 2004 5:12 pm    Post subject: Re: PHP coder man needed for something Reply with quote

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 View user's profile Send private message Send e-mail
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Fri Feb 27, 2004 12:15 am    Post subject: Reply with quote

The coder is available Free to download at
http://php.holtsmark.no/base64img/

:)
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group