Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Icon Filename Extension

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map)
Author Message
Zdolny



Joined: 14 Oct 2008
Posts: 5

PostPosted: Thu Nov 05, 2009 3:06 pm    Post subject: Icon Filename Extension Reply with quote

Small extension which give access to images located in dirs in weathermap/images.

You can create dir weathermap/images/routers and there put image

Code:

*** editor.inc.php_old  2009-04-19 14:25:00.000000000 +0200
--- editor.inc.php      2009-11-05 19:33:27.000000000 +0100
***************
*** 297,319 ****

        if (is_dir($imagedir))
        {
-               $n=0;
                $dh=opendir($imagedir);
-
                if ($dh)
                {
                        while ($file=readdir($dh))
                        {
                                $realfile=$imagedir . DIRECTORY_SEPARATOR . $file;
                  $uri = $imagedir . "/" . $file;
!
!                               if(is_file($realfile) && ( preg_match('/\.(gif|jpg|png)$/i',$file) ))
                                {
                                        $imagelist[] = $uri;
-                                       $n++;
                                }
-                       }

                        closedir ($dh);
                }
        }
--- 297,329 ----

        if (is_dir($imagedir))
        {
                $dh=opendir($imagedir);
                if ($dh)
                {
                        while ($file=readdir($dh))
                        {
                                $realfile=$imagedir . DIRECTORY_SEPARATOR . $file;
                  $uri = $imagedir . "/" . $file;
!                               if(is_file($realfile) && ( preg_match('/\.(gif|jpg|png|bmp)$/i',$file) ))
                                {
                                        $imagelist[] = $uri;
                                }

+                               if (is_dir($realfile) && !( preg_match('/\./i',$realfile) ))
+                                       {
+                                       $dh1=opendir($realfile);
+                                       while ($file=readdir($dh1))
+                                                               {
+                                                                       $realfile2=$realfile . DIRECTORY_SEPARATOR . $file;
+                                                       $uri2 = $realfile . "/" . $file;
+                                                                       if(is_file($realfile2) && ( preg_match('/\.(gif|jpg|png)$/i',$file) ))
+                                                                       {
+                                                                               $imagelist[] = $uri2;
+                                                                       }
+                                                               }
+                                       closedir ($dh1);
+                                       }
+                       }
                        closedir ($dh);
                }
        }

Full function:

Code:

function get_imagelist($imagedir)
{
   $imagelist = array();

   if (is_dir($imagedir))
   {
      $dh=opendir($imagedir);
      if ($dh)
      {
         while ($file=readdir($dh))
         {
            $realfile=$imagedir . DIRECTORY_SEPARATOR . $file;
                $uri = $imagedir . "/" . $file;
            if(is_file($realfile) && ( preg_match('/\.(gif|jpg|png|bmp)$/i',$file) ))
            {
               $imagelist[] = $uri;
            }

            if (is_dir($realfile) && !( preg_match('/\./i',$realfile) ))
               {
               $dh1=opendir($realfile);
               while ($file=readdir($dh1))
                        {
                           $realfile2=$realfile . DIRECTORY_SEPARATOR . $file;
                               $uri2 = $realfile . "/" . $file;
                           if(is_file($realfile2) && ( preg_match('/\.(gif|jpg|png|bmp)$/i',$file) ))
                           {
                              $imagelist[] = $uri2;
                           }
                        }
               closedir ($dh1);
               }
         }
         closedir ($dh);
      }
   }
   return ($imagelist);
}



Untitled.jpg
 Description:
 Filesize:  82.32 KB
 Viewed:  652 Time(s)

Untitled.jpg


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group