Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XML][PHP]Pomocy - musze przerobić skrypt, Muszę przerobić skrypt galerii
-tokar-
post
Post #1





Goście







Witam mam następujący skrypt, chcę go przerobić tak, aby skrypt wybierał obrazy z katalogu image pliki wyłączanie o nazwie 700x500*.* Jak mam to zrobić ? Z góry dziękuję za pomoc ;-)

  1. <?php
  2. // -----------------------
  3. // build_autoviewer_gallerydata v3
  4. // -----------------------
  5. // This script automatically generates the XML document for Autoviewer
  6. // www.airtightinteractive.com/projects/autoviewer/
  7. // Instructions to use are at:
  8. // www.airtightinteractive.com/projects/autoviewer/auto_server_instructions.html
  9. //
  10. // by: Geoff Smith + Felix Turner
  11.  
  12.  
  13. // SET GALLERY OPTIONS HERE
  14. // -----------------------
  15. $options .= '<gallery frameColor="0xFFFFFF" frameWidth="15" imagePadding="20" displayTime="6" enableRightClickOpen="true">';
  16. // Set sortImagesByDate to true to sort by date. Otherwise files are sorted by filename.
  17. $sortImagesByDate = true;
  18. // Set sortInReverseOrder to true to sort images in reverse order.
  19. $sortInReverseOrder = true;
  20. // END OF OPTIONS
  21. // -----------------------
  22.  
  23. print "Creating XML for Autoviewer.<br>";
  24. print "-------------------------------------------------<br><br>";
  25.  
  26. if ($sortImagesByDate){
  27. print "Sorting images by date.<br>";
  28. }else{
  29. print "Sorting images by filename.<br>";
  30. }
  31.  
  32. if ($sortInReverseOrder){
  33. print "Sorting images in reverse order.<br><br>";
  34. }else{
  35. print "Sorting images in forward order.<br><br>";
  36. }
  37.  
  38. //loop thru images
  39. $xml = '<?xml version="1.0" encoding="UTF-8" ?>'.$options;
  40. $folder = opendir("images");
  41. while($file = readdir($folder)) {
  42. if ($file[0] != "." && $file[0] != ".." && $file[0] != "Thumbs.db" ) {
  43. if ($sortImagesByDate){
  44. $files[$file] = filemtime("images/$file");
  45. }else{
  46. $files[$file] = $file;
  47. }
  48. }
  49. }
  50.  
  51. // now sort by date modified
  52. if ($sortInReverseOrder){
  53. arsort($files);
  54. }else{
  55. asort($files);
  56. }
  57.  
  58. foreach($files as $key => $value) {
  59.  
  60. // Get the image dimensions.
  61. $dimensions = getimagesize('images/'.$key);
  62. $width = $dimensions[0];
  63. $height = $dimensions[1];
  64.  
  65. $xml .= "\n<image>\n";
  66. $xml .= " <url>images/".$key."</url>\n";
  67. $xml .= " <caption></caption>\n";
  68. $xml .= " <width>".$width."</width>\n";
  69. $xml .= " <height>".$height."</height>\n";
  70. $xml .= "</image>\n";
  71.  
  72. print "- Created Image Entry for: $key whose width is ".$width." and whose height is ".$height.".<br />";
  73. }
  74.  
  75. closedir($folder);
  76.  
  77. $xml .= '</gallery>';
  78. //next line can cause erroneous warnings
  79. //chmod( 'gallery.xml', 0777 );
  80. $file = "gallery.xml";
  81. if (!$file_handle = fopen($file,"w")) {
  82. print "<br>Cannot open XML document: $file<br>";
  83. } elseif (!fwrite($file_handle, $xml)) {
  84. print "<br>Cannot write to XML document: $file<br>";
  85. }else{
  86. print "<br>Successfully created XML document: $file<br>";
  87. }
  88. fclose($file_handle);
  89.  
  90. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
tehaha
post
Post #2





Grupa: Zarejestrowani
Postów: 1 748
Pomógł: 388
Dołączył: 21.08.2009
Skąd: Gdynia

Ostrzeżenie: (0%)
-----


funkcją http://pl.php.net/readdir odczytujesz pliki z folderu i tam trzeba sprawdzić jaka jest nazwa, najprościej będzie to zrobić funkcją, pobierasz pierwsze 7 znaków nazwy funkcją http://php.net/manual/en/function.substr.php i sprawdzasz czy jest równa 700x500 jeżeli tak to dodajesz plik do tablicy, jeżeli nie to go nie dodajesz
Go to the top of the page
+Quote Post
-tokar-
post
Post #3





Goście







A czy mógłbyś mi pomóc napisać taką funkcje i wstawić do skryptu ?

Go to the top of the page
+Quote Post
nekomata
post
Post #4





Grupa: Zarejestrowani
Postów: 314
Pomógł: 44
Dołączył: 12.11.2010
Skąd: UK

Ostrzeżenie: (0%)
-----


Wystarczająco pomógł już ci kolega, na gotowca raczej nie licz , tutaj się pomaga a nie robi za kogoś , nie licz wiec na gotowca.
Go to the top of the page
+Quote Post
Daiquiri
post
Post #5





Grupa: Administratorzy
Postów: 1 552
Pomógł: 211
Dołączył: 7.07.2009
Skąd: NJ




@-tokar-
Najpierw pokaż to, co już sam zacząłeś robić i napisz w czym problem.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 12:34