mediengestalter.info
FAQ :: Mitgliederliste :: MGi Team

Willkommen auf dem Portal für Mediengestalter

Aktuelles Datum und Uhrzeit: Di 23.04.2024 11:57 Benutzername: Passwort: Auto-Login

Thema: [PHP] Script Slideshow mod.!? vom 10.09.2004


Neues Thema eröffnen   Neue Antwort erstellen MGi Foren-Übersicht -> Programmierung -> [PHP] Script Slideshow mod.!?
Seite: 1, 2  Weiter
Autor Nachricht
dede
Threadersteller

Dabei seit: 29.04.2002
Ort: Köln
Alter: 47
Geschlecht: Männlich
Verfasst Fr 10.09.2004 12:41
Titel

[PHP] Script Slideshow mod.!?

Antworten mit Zitat Zum Seitenanfang

Moin zusammen,

ich habe auf meiner website folgendes script das im moment so verfährt das bild 001.jpg zuerst dargestelt wird und 002.jpg danach. Ich würde es aber gaaanz toll finden wenn es davor dargestellt würde damit immer das neueste bild am anfang steht und das älteste am schluss!?

Zitat:
<?php

################################################################################
################################################################################
// PHPSlideShow v0.6.2 written by Greg Lawler
// from http://www.zinkwazi.com/pages.php?page_name=scripts

// v0.6.2 august 2002 - minor upgrade, added javascript notes
// v0.6.1 july 2002 - fixed special character bug.
// v0.6 july 2002 - added lots of formatting options and a security patch
// v0.5.1 march 2002 - minor bug fixes, reg exp fix...
// v0.5 march 2002 - osx path fix, page headings for multi dir, cleaner...
// v0.4 july 10 2001
// v0.3.5 july 5 2001
// v0.3.4 april 19 2001
// v0.3.3 january 9 2001
// v0.3.1 september 29 2000 - added support for image buttons
// v0.3 september 12 2000 - added support for comments
// v0.2 august 28 2000
//
// Feel free to use/modify this little script
//
// IMPORTANT NOTE....
// if you want to send me a token of appreciation,
// anything from http://www.starbucks.com will be gladly accepted *zwinker*
// my address is:
// attention: greg lawler
// 801 alston road, santa barbara, ca 93108 usa
// otherwise it's free.
//
// this script comes with no implied warranty.
//
// enjoy Lächel
// greg

############################# Quick Start Installation #########################
// put this file in a directory that contains your images
// the slideshow should now work...

############################# Customized Installation #########################
// Q: how do i add image comments/descriptions to the slideshow?
// A: make a file (e.g. pics.txt) that contains the image names and descriptions
// place each image name and description on a new line separated by a semi colon.
// an easy way to do this is type
// ls *.jpg > pics.txt in linux or
// dir *.jpg > pics.txt in dos - you will need edit this with notepad/vi to clean
// out any extra stuff that dir puts in there and to add the semi colon and
// description.
// the slideshow should now work including comments...
//
// Q: how do i give each directory of images it's own page heading?
// A: place a file called heading.txt in each directory. place the page heading
// on the first line of this file.
//
// Q: how do i use one slideshow for multiple different directories of images?
// A: all you need to do to enable this is to call the script and pass it the
// directory path.
//
// for example:
// pictures_directory -> phpslideshow.php
// -> dog_pics
// -> cat_pics
// so you have a directory called pictures_directory that contains your
// phpslideshow.php and two directories containing pictures of your pets...
// in order to access the shows:
// http://yourserver.com/pictures_directory/phpslideshow.php?directory=dog_pics
// http://yourserver.com/pictures_directory/phpslideshow.php?directory=cat_pics
//
// if there were images in the pictures_directory, you'd see them like this:
// http://yourserver.com/pictures_directory/phpslideshow.php?directory=cat_pics
//
// these three examples will run phpslideshow but each one will load a different
// set of images and descriptions located in the directories shown
//
// NOTE: for security, you can only access directories within the same dir as
// the phpslideshow.php script...
//
// Q: how do i use phpslideshow.php in my existing web page or html template?
// A: change the $standalone variable from true to false.
// what this does is removes the html page headers and footers and only prints
// out the phpslideshow table...
// to use this in an existing php page, use the following line:
// include("phpslideshow.php");
// don't forget that this is php code so it needs to be inside the <? php tags.
// also, the // at the beginning of the line needs to be removed.
//
// Q: how do i make my php slide show appear in it's own popup window?
// A: copy the following lines into the body of a web page
// (minus the leading two comment slashes on each line...)
// <!--begin PHPSlideshow popup code -->
//<script>
// function pop(){
// // change this to point to your PHPSlideshow URL
// var your_slideshow_url="phpslideshow.php?directory=."
// // change the width and height of your window here to fit your images.
// winpops=window.open(your_slideshow_url,'','width=640,height=400,')
// }
//</script>
//<a href="javascript:pop()">My cool PHPSlideshow</a>
// <!--end PHPSlideshow popup code-->
//
// EXAMPLE pics.txt file
//
// greg.jpg;Me
// dog.png;My dog John
// cat;
// tux.jpg;My friend Tux
//
// NO BLANK LINES either!
// as you can see, not all pics need a description
// point your browser at the script and voilla!

##### CREDITS #####
// the following nice folks have contributed code snippets, bug fixes, ideas Lächel
// patrick, nicolas, otto, wei-min lee, tom, jonathan, jason rust, hai phung
// greg rundlett, laszlo (jabba), mike collard, justin, jadex, bunnyguy
################################################################################
################################################################################

// some formatting options...
$top_row_color = "#DAEC8F";
$image_row_color = "#DAEC8F";
$bottom_row_color = "#DAEC8F";
$page_background_color = "#AFD21D";
$main_table_border_color = "#AAABA5";
$img_border_color = "#AAABA5";
$main_table_width = "450 px";
$home_link = "pixelpope.de";
$next_alt = "weiter";
$back_alt = "zur&uuml;ck";
$your_home_url = "http://www.pixelpope.de";

// set this to true to display the image filename
$show_image_name = "false";

// set to true to display navigation icons instead of text...
$show_navigation_buttons = "false";
$back_button = "back.gif";
$next_button = "next.gif";

// automated slideshow options
// set this to true to enable the auto slideshow feature
$auto_slideshow = "false";
// $sec is number of seconds between slides...
$sec = "2";

// set standalone to false if you are using this script in an existing php doc
// e.g. insert the following line in the page where
// you want phpslideshow to appear
// include("phpslideshow.php");
// dont forget to remove the comment slashes...
$standalone = "true";

// file containing optional image descriptions
$pic_info_file="pics.txt";

// name of file containing optional page headings
$heading_info_file = "heading.txt";

################################################################################
// grab the variables we want set for newer php version compatability
// the @ supress the error messages if your php.ini error level is too high
@$currentPic = $GLOBALS['HTTP_GET_VARS']['currentPic'];
@$directory = $GLOBALS['HTTP_GET_VARS']['directory'];

// check for platform dependent path info... (for windows and mac OSX)
$path = empty($HTTP_SERVER_VARS['PATH_INFO'])?
$HTTP_SERVER_VARS['PHP_SELF']:$HTTP_SERVER_VARS['PATH_INFO'];

// a little security - check that the user did not change the path...
// the path may not contain .. or : (as in cLächel or start with / (root dir)
if (preg_match('*Schnief*\.\.|^/|\Lächel:', $directory)) {
print "<b>ERROR:</b> Your request conttable
ains an invalid path.<br>";
print "For security purposes, you can only access directories ";
print "within this one.<br>";
print "Your dir path may not contain .. or : or start with a /<br>";
print "<br><a href=\"$path\">Try again</a>";
exit;
}

// set directory
if (empty($directory)) $directory = ".";

// if there is no $heading_info_file (see format above) set page heading here
if ( !file_exists("$directory/$heading_info_file")) {
$header = "daily mirror";
$browser_title = "$header";
}
else {
$heading_info = file("$directory/$heading_info_file");
$header = htmlentities($heading_info[0]);
}

// image / text buttons
if ($show_navigation_buttons == "true") {
$back_src = "<img src=\"$back_button\" alt=\"$back_alt\" border=\"0\">";
$next_src = "<img src=\"$next_button\" alt=\"$next_alt\" border=\"0\">";
}
else {
$back_src = "<b>$back_alt</b>";
$next_src = "<b>$next_alt</b>";
}

if ( !file_exists("$directory/$pic_info_file")) {
$dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
sort( $pic_info );
}
}
}

else $pic_info=file("$directory/$pic_info_file");

// begin messing with the array
$number_pics = count ($pic_info);
if (empty($currentPic)) $currentPic = 0;
if (($currentPic > $number_pics)||($currentPic == $number_pics))
$currentPic = '0';
$item = explode (";", $pic_info[$currentPic]);
$last = $number_pics - 1;
$next = $currentPic + 1;
if ($currentPic > 0 ) $back = $currentPic - 1;
else $currentPic = "0";

// print the description if it exists
$blank = empty($item[1])?'&nbsp;':htmlentities($item[1]);
// a hack so that you can include <br> tags in the comments...
$blank = ereg_replace ("&lt;br&gt;", "<br>", $blank);
$show_name = ($show_image_name=="false")?'&nbsp;':htmlentities($item[0]);

if ($currentPic > 0 ) $nav=$back;
else $nav=$last;

// meta refresh stuff for auto slideshow...
if ($auto_slideshow == "true") {
$meta_refresh = "<meta http-equiv=\"refresh\" content=\"";
$meta_refresh .= "$sec;url=$path?directory=$directory&currentPic=$next\">";
}
else $meta_refresh = "\n";

################################################################################

// top of html page stuff
// print the page header if in standalone mode
if ($standalone == "true") {
print <<< HERE

<!-- PHPSlideshow v0.6.2 by Greg Lawler -->
<!-- http://www.zinkwazi.com/pages.php?page_name=scripts -->
<html>
<head>
$meta_refresh
<title>$header</title>
<style type="text/css">
body { font-family: verdana; font-size: 10px; }
a { font-family: verdana;
font-size: 10px;
text-decoration: none }
</style>
<link href="copy.css" rel="stylesheet" type="text/css">

</head>
<body bgcolor="$page_background_color">

HERE;
}

// draw the main table in html
print <<< HERE

<center><br><br><br><br><br>
<table width="$main_table_width" align="center" valign="center"
border="0" cellspacing="0" cellpadding="1" bgcolor="$main_table_border_color">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="$top_row_color">
<td align="left" nowrap width="50%" class="copy">&nbsp;&nbsp;<b>$header</b></td>
<td width="50%" align="right" valign="center" class="copy">
<a href="$path?directory=$directory&currentPic=$nav">$back_src</a>
[ $next von $number_pics ]
<a href="$path?directory=$directory&currentPic=$next">$next_src</a>&nbsp;&nbsp;
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td bgcolor="$image_row_color" align="center" valign="center">
<a href="$path?directory=$directory&currentPic=$next">
<img src="$directory/$item[0]" alt="image" border="1"
style="border-color: $img_border_color">
</a>
</td>
<td bgcolor="$image_row_color" align="center" valign="center"
width="80%">$blank<br>$show_name</td>
</tr>
<tr bgcolor="$bottom_row_color">
<td>&nbsp;</td>
<td align="right">&nbsp;<b><a href="$your_home_url">$home_link</a></b></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
HERE;

// print the page footer if in standalone mode
if ($standalone == "true") {
print <<< HERE
</body>
</html>
HERE;
}

?>


Zuletzt bearbeitet von dede am Fr 10.09.2004 16:10, insgesamt 1-mal bearbeitet
  View user's profile Private Nachricht senden
rob

Dabei seit: 11.12.2003
Ort: ~/
Alter: 46
Geschlecht: Männlich
Verfasst Fr 10.09.2004 12:52
Titel

Antworten mit Zitat Zum Seitenanfang

Das Problem liegt hier:
Code:
  $dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
sort( $pic_info ); 

Es wird ein Handle auf das Verzeichnis geöffnet und dann wird jede Datei gecheckt. Wenn es sich um eine Datei mit der Endung jpg,jpeg,gif oder png handelt, dann wird der dateiname in ein array aufgenommen und dieses anschliessend sortiert. da stehen nur die datenamen drin, also wird danach sortiert.
du müßtest das script so modifizieren, daß du die zeit der letzten änderung mit in das array schreibst.
das kannst du mit filemtime() auslesen.
und dann würde ich ein mehrdimensionales array erstellen, wo du auch die zeit mit aufnimmst. danach mußt du dann nach zeit sortieren und kannst das zur weiteren verarbeitung dann wieder in ein eindimensionales array mit nur den dateinamen überführen.
  View user's profile Private Nachricht senden
Anzeige
Anzeige
kaputt

Dabei seit: 08.05.2003
Ort: -
Alter: -
Geschlecht: Männlich
Verfasst Fr 10.09.2004 13:14
Titel

Antworten mit Zitat Zum Seitenanfang

rob hat geschrieben:
Das Problem liegt hier:
Code:
  $dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
sort( $pic_info ); 

Es wird ein Handle auf das Verzeichnis geöffnet und dann wird jede Datei gecheckt. Wenn es sich um eine Datei mit der Endung jpg,jpeg,gif oder png handelt, dann wird der dateiname in ein array aufgenommen und dieses anschliessend sortiert. da stehen nur die datenamen drin, also wird danach sortiert.
du müßtest das script so modifizieren, daß du die zeit der letzten änderung mit in das array schreibst.
das kannst du mit filemtime() auslesen.
und dann würde ich ein mehrdimensionales array erstellen, wo du auch die zeit mit aufnimmst. danach mußt du dann nach zeit sortieren und kannst das zur weiteren verarbeitung dann wieder in ein eindimensionales array mit nur den dateinamen überführen.

blupp...

es reicht, wenn er in deine letzte code-zeile an den anfang ein "r" schreibt...

rsort

fertig!
  View user's profile Private Nachricht senden
rob

Dabei seit: 11.12.2003
Ort: ~/
Alter: 46
Geschlecht: Männlich
Verfasst Fr 10.09.2004 13:22
Titel

Antworten mit Zitat Zum Seitenanfang

dann erfolgt die sortierung aber noch immer nach dateinamen - allerdings in umgekehrter reihenfolge.
das funktioniert dann nur, wenn die bilder jedesmal mit einer höheren nummer als dateinamen abgespeichert werden und es müßte dann auch immer die gleiche anzahl an stellen (also nullen vorweg) da sein, damit 1 nicht größer als 010 ist.

kann also nur genutzt werden, wenn man die bilder alle immer wirklich sauber durchnummeriert.


Zuletzt bearbeitet von rob am Fr 10.09.2004 13:23, insgesamt 1-mal bearbeitet
  View user's profile Private Nachricht senden
kaputt

Dabei seit: 08.05.2003
Ort: -
Alter: -
Geschlecht: Männlich
Verfasst Fr 10.09.2004 13:30
Titel

Antworten mit Zitat Zum Seitenanfang

Da er ja von neueren usw... Dateien spricht, denke ich, dass es auf jeden Fall sinnvoll wäre, die Files einfach im Format:

2004-09-10_001.jpg
2004-09-10_002.jpg

usw zu nennen - und fertig. Bevor er da fett PHP schreiben muss *zwinker*
  View user's profile Private Nachricht senden
dede
Threadersteller

Dabei seit: 29.04.2002
Ort: Köln
Alter: 47
Geschlecht: Männlich
Verfasst Fr 10.09.2004 16:04
Titel

Antworten mit Zitat Zum Seitenanfang

ähem. ein resort und fertig? also die dateinamen sind immer sehr sauber... von 001 bis dato 021.jpg


Von daher würde das doch funktionieren oder? mit dem resort?

kannste mir vielleicht die Stelle des Codes zeigen wo ich das einfügen muss?

* Ich bin unwürdig *
  View user's profile Private Nachricht senden
karmacoder

Dabei seit: 15.04.2002
Ort: Fürth
Alter: 42
Geschlecht: Männlich
Verfasst Fr 10.09.2004 17:15
Titel

Antworten mit Zitat Zum Seitenanfang

peBBo hat geschrieben:
rob hat geschrieben:
Das Problem liegt hier:
Code:
  $dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
sort( $pic_info ); 

Es wird ein Handle auf das Verzeichnis geöffnet und dann wird jede Datei gecheckt. Wenn es sich um eine Datei mit der Endung jpg,jpeg,gif oder png handelt, dann wird der dateiname in ein array aufgenommen und dieses anschliessend sortiert. da stehen nur die datenamen drin, also wird danach sortiert.
du müßtest das script so modifizieren, daß du die zeit der letzten änderung mit in das array schreibst.
das kannst du mit filemtime() auslesen.
und dann würde ich ein mehrdimensionales array erstellen, wo du auch die zeit mit aufnimmst. danach mußt du dann nach zeit sortieren und kannst das zur weiteren verarbeitung dann wieder in ein eindimensionales array mit nur den dateinamen überführen.

blupp...

es reicht, wenn er in deine letzte code-zeile an den anfang ein "r" schreibt...

rsort

fertig!


hat er doch gesagt:

Code:
  $dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
[b]r[/b]sort( $pic_info ); 
  View user's profile Private Nachricht senden Website dieses Benutzers besuchen
Account gelöscht


Ort: -
Alter: -
Verfasst Fr 10.09.2004 17:24
Titel

Antworten mit Zitat Zum Seitenanfang

rob hat geschrieben:
Das Problem liegt hier:
Code:
  $dh = opendir( "$directory" );
while( $file = readdir( $dh ) ) {
// look for these file types....
if (eregi("(jpg|jpeg|gif|png)$",$file)) {
$pic_info[] = $file;
sort( $pic_info ); 

Es wird ein Handle auf das Verzeichnis geöffnet und dann wird jede Datei gecheckt. Wenn es sich um eine Datei mit der Endung jpg,jpeg,gif oder png handelt, dann wird der dateiname in ein array aufgenommen und dieses anschliessend sortiert. da stehen nur die datenamen drin, also wird danach sortiert.
du müßtest das script so modifizieren, daß du die zeit der letzten änderung mit in das array schreibst.
das kannst du mit filemtime() auslesen.
und dann würde ich ein mehrdimensionales array erstellen, wo du auch die zeit mit aufnimmst. danach mußt du dann nach zeit sortieren und kannst das zur weiteren verarbeitung dann wieder in ein eindimensionales array mit nur den dateinamen überführen.


alter schwede, ich versteh nur bahnhof! Menno!
 
 
Ähnliche Themen Slideshow mit Action Script
Suche bestimtes Script für Slideshow/Slider o.ä.
Dreamweaver Java Script Slideshow ausblenden?
[Suche] Slideshow Script mit Play/Pause Funktion
"bretteleben"-Slideshow- Script : Code + Frage dazu
[jQuery Cycle] Slideshow in Slideshow wechseln zusammen
Neues Thema eröffnen   Neue Antwort erstellen Seite: 1, 2  Weiter
MGi Foren-Übersicht -> Programmierung


Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst an Umfragen in diesem Forum nicht mitmachen.