Subversion Repositories HomeAutomation

Rev

Rev 2111 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. <?php
  2.  
  3. require_once("config.php");
  4. require_once("atomjs_interface.php");
  5.  
  6.  
  7. function GetSubfolders($directory, $pageConfiguration)
  8. {
  9.   $folders = array();
  10.  
  11.   if (file_exists($directory))
  12.   {
  13.     $directory_handle = opendir($directory);
  14.  
  15.     while (false !== ($filename = readdir($directory_handle)))
  16.     {
  17.       if (is_dir($directory . "/" . $filename) && $filename[0] != ".")
  18.       {
  19.       $found = 0;
  20.       foreach($pageConfiguration as $page) {
  21.           if (strcmp($page['page'],$filename)==0) {
  22.         $found = 1;
  23.           }
  24.       }
  25.         if ($found == 1)
  26.         $folders[] = $filename;
  27.       }
  28.     }
  29.  
  30.     closedir($directory_handle);
  31.  
  32.     if (count($folders) > 0)
  33.     {
  34.       natcasesort($folders);
  35.       $folders = array_values($folders);
  36.     }
  37.   }
  38.  
  39.   return $folders;
  40. }
  41.  
  42. if (isset($_GET["ajax"]))
  43. {
  44.   global $atomdHostname;
  45.   global $atomdPort;
  46.  
  47.   $buffer = "";
  48.  
  49.   try
  50.   {
  51.     $socket = atomjs_connect($atomdHostname, $atomdPort);
  52.  
  53.     atomjs_write($socket, $_GET["command"]);
  54.  
  55.     echo trim(atomjs_read($socket));
  56.   }
  57.   catch (Exception $e)
  58.   {
  59.     die($e);
  60.   }
  61.  
  62.   exit(0);
  63. }
  64. else
  65. {
  66.   $pages = GetSubfolders("pages/", $pageConfiguration);
  67. }
  68.  
  69. ?>