Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

buildlist.php

Asked Modified Viewed 1,498 times
P
pera
P
pera 10
  • Newbie, joined since
  • Contributed 9 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
asked
Newbie

At least in my installed version of php-fusion built imagelist.js incorrectly, since foldernames like news, smileys became also image entries there.

Therefore i wrote this kind of version of buildlist.php.
do you agree on this?
=====================================

<?php
/*---------------------------------------------------+
| buildlist.php - iLister enginge.
+----------------------------------------------------+
| Copyright © 2005 Johs Lind
| http://www.geltzer.dk/
| Inspired by: Php-fusion 6 coding
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
if (!defined("IN_FUSION")) { header("Location: ../index.php"); exit; }

// images ------------------------

// THIS SMALL FUNCTION HELPS US GET RID OF
// '*.PHP', '*.JS', '..' AND '.' INTRUDERS IN IMAGEARRAY
// REMEMBER: IT NEEDS RELATIVE PATH FROM CURRENT FOLDER TO WORK.
function wic($path)
{
  //Web Image Check
  $parts = pathinfo($path);
  $ext = strtolower($parts['extension']);
  return(in_array($ext, array('jpg','jpeg','gif','png')) && is_file($path));
}

$temp = opendir(IMAGES);
while ($file = readdir($temp)) {
       if (wic(IMAGES.$file)) {
      $image_files[][0] = "['Images: ".$file."',";
      $image_files[][1] = "'".$settings['siteurl']."images/".$file."'],\n";
   }
}
closedir($temp);

// articles ---------------
$temp = opendir(IMAGES_A);
while ($file = readdir($temp)) {
   if (wic(IMAGES_A.$file)) {
      $image_files[][0] = "['articles: ".$file."',";
      $image_files[][1] = "'".$settings['siteurl']."images/articles/".$file."'],\n";
   }
}
closedir($temp);
   
// news -------------------
$temp = opendir(IMAGES_N);
while ($file = readdir($temp)) {
   if (wic(IMAGES_N.$file)) {
      $image_files[][0] = "['news: ".$file."',";
      $image_files[][1] = "'".$settings['siteurl']."images/news/".$file."'],\n";
   }
}
closedir($temp);

// photoalbum -------------------
$album = array();
$sql = dbquery("
   SELECT ".$db_prefix."photo_albums.album_title, ".$db_prefix."photos.photo_id
   FROM ".$db_prefix."photo_albums, ".$db_prefix."photos
   WHERE ".$db_prefix."photo_albums.album_id = ".$db_prefix."photos.album_id
");

while ($data = dbarray($sql)) {
   $album[]=$data['album_title'];
   $album[]=$data['photo_id'];
}

$temp = opendir(PHOTOS);
while ($file = readdir($temp)) {
   if (wic(PHOTOS.$file)) {
      $slut = strpos($file,".");
      $smlg = substr($file,0,$slut);
      $navn = "";
      for ($i=1;$i < count($album);$i=$i+2){
         if ($smlg == $album[$i]) {
            $navn = $album[$i-1];
            break;
         }
      }
      $image_files[][0] = "['".$navn." album: ".$file."',";
      $image_files[][1] = "'".$settings['siteurl']."images/photoalbum/".$file."'],\n";
   }
}
closedir($temp);
      

// compile list -----------------
if (isset($image_files)) {
   $indhold = "var tinyMCEImageList = new Array(\n";
   for ($i=0;$i < count($image_files);$i++){
      $indhold = $indhold.$image_files[$i][0].$image_files[$i][1];
   }
   $lang = strlen($indhold)-2;
   $indhold = substr($indhold,0,$lang);
   $indhold = $indhold.");\n\n";
   $fp = fopen(IMAGES."imagelist.js","w");
   fwrite($fp, $indhold);
   fclose($fp);
}
?>
Edited by Falk on 06-01-2007 03:05,
0 replies
There are no post found.

Category Forum

Bugs and Errors - 6

Labels

None yet

Statistics

  • Views 0 views
  • Posts 0 posts
  • Votes 0 votes
  • Topic users 1 member

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet