X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=modules%2Fplanetlab.module;h=2845f7504133307898dbb99ba94a285f806903e3;hb=621f5f2521d88af260fe7b4ed416826662929669;hp=19646867fd3515b21947f4caef23c16c16c723fe;hpb=563c48d8dd76808124f252a45bca6c7b555933ab;p=plewww.git diff --git a/modules/planetlab.module b/modules/planetlab.module index 1964686..2845f75 100644 --- a/modules/planetlab.module +++ b/modules/planetlab.module @@ -7,6 +7,7 @@ // // $Id$ // +error_reporting(0); require_once 'plc_config.php'; require_once 'plc_session.php'; @@ -73,6 +74,17 @@ function plc_my_site_links() { return $html; } +// ditto +function plc_my_node_links () { + $html = ''; + if (count (plc_my_site_ids()) == 1) { + $html .= leaf( href (l_nodes_my_site() ,"My Site Nodes")); + } else { + $html .= leaf( href (l_nodes_all_my_site(),"All My Sites Nodes")); + } + return $html; +} + // fake theme to look like menu function menu_theme ($menu) { $result = ''; @@ -93,7 +105,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()); @@ -147,10 +162,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item .= l_person_t(plc_my_person_id(),"My Account"); $bullet_item .= ul_start(); if (plc_is_admin() || plc_is_pi()) - $bullet_item .= leaf( href( l_persons_site(plc_my_site_id()), "My Users")); + $bullet_item .= leaf( href( l_persons_site(plc_my_site_id()), "My Site Accounts")); if (plc_is_admin()) { - $bullet_item .= leaf(href(l_persons_peer('local'),'Local users (looong)')); - $bullet_item .= leaf(href(l_persons(),'All users (looong)')); + $bullet_item .= leaf(href(l_persons_peer('local'),'Local Accounts (slow)')); + $bullet_item .= leaf(href(l_persons(),'All Accounts (slow)')); } $bullet_item .= ul_end(); @@ -170,18 +185,23 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item = ''; $bullet_item .= href(l_nodes(),"Nodes"); $bullet_item .= ul_start(); - $bullet_item .= leaf( href (l_nodes_site (plc_my_site_id()),"My Site Nodes")); - $bullet_item .= leaf( href (l_register_node(),"Register Node")); + $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")); $bullet_item .= ul_end(); $items [] = expanded($bullet_item); //////////////////// Slices $bullet_item = ''; //if( !( plc_is_tech() && ! plc_is_user() && ! plc_is_pi() && ! plc_is_admin() ) ) - $bullet_item .= href(l_slices(),"Slices"); + if (plc_is_admin()) { + $bullet_item .= href(l_slices(),"Slices"); + } else { + $bullet_item .= href(l_slices(),"My Slices"); + } $bullet_item .= ul_start(); if (plc_is_admin()) - $bullet_item .= leaf ( href(l_slices_site(plc_my_site_id()), 'My Site Slices')); + $bullet_item .= leaf ( href(l_slices_my_site(), 'My Site Slices')); if( plc_is_admin() || plc_is_pi() ) { $bullet_item .= leaf(href(l_slice_add(),"Create Slice")); } @@ -195,7 +215,8 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item = ''; $bullet_item .= href(l_admin(),"Admin search"); $bullet_item .= ul_start(); - $bullet_item .= leaf( href (l_node_add(),"Add Node")); + if ( plc_is_admin() ) + $bullet_item .= leaf( href (l_node_add(),"Add Node")); $bullet_item .= leaf( href( l_tags(),"Tags")); $bullet_item .= leaf( href( l_nodegroups(),"Node groups")); $bullet_item .= leaf (href(l_peers(),'Peers')); @@ -326,6 +347,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']); @@ -347,7 +376,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; }