remove error_reporting(0) that has been causing all the pain with logs
[plewww.git] / modules / planetlab.module
index 95647a2..7e577c5 100644 (file)
@@ -8,6 +8,8 @@
   // $Id$
   //
 
+//error_reporting(0);
+
 require_once 'plc_config.php';
 require_once 'plc_session.php';
 require_once 'plc_functions.php';
@@ -104,7 +106,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
   } else if ($op == 'view') {
     $block = array();
 
-    if (!$plc->person) {
+    if ($plc->hide_planetlab_block) {
+      // do nothing
+      // this is a private hook from the Vicci module to hide the planetlab module
+    } else if (!$plc->person) {
       // Force login via HTTPS
       unset($_GET['time']);
       $form['#action'] = "https://" . $_SERVER['HTTP_HOST'] . url($_GET['q'], drupal_get_destination());
@@ -182,8 +187,9 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
       $bullet_item .= href(l_nodes(),"Nodes");
       $bullet_item .= ul_start();
       $bullet_item .= plc_my_node_links();
-      if (plc_is_admin() || plc_is_pi() || plc_is_tech()) 
-       $bullet_item .= leaf( href (l_register_node(),"Register Node"));
+      if (plc_is_admin() || plc_is_pi() || plc_is_tech()) {
+             $bullet_item .= leaf( href (l_register_node(), "Register Node (ko)"));
+      }
       $bullet_item .= ul_end();
       $items [] = expanded($bullet_item);
 
@@ -343,6 +349,14 @@ function planetlab_user($type, &$edit, &$user, $category = NULL) {
   }
 }
 
+function isValidFileName($file) {
+
+    /* don't allow .. and allow any "word" character \ / */
+
+    return preg_match('/^(((?:\.)(?!\.))|\w)+$/', $file);
+
+}
+
 function planetlab_page() {
   $path = $_SERVER['DOCUMENT_ROOT'] . preg_replace('/^db\//', '/planetlab/', $_GET['q']);
 
@@ -364,7 +378,12 @@ function planetlab_page() {
       $output = ob_get_contents();
       ob_end_clean();
     } else {
-      $output = file_get_contents($path);
+         if (isValidFileName($path)) {
+            $output = file_get_contents($path);
+         }
+         else {
+            $output = "";
+         }
     }
     return $output;
   }