Skip to content

Commit

Permalink
Backport last code from @work
Browse files Browse the repository at this point in the history
  • Loading branch information
Poil committed Dec 6, 2014
1 parent 86f094e commit 247b0e4
Show file tree
Hide file tree
Showing 89 changed files with 2,171 additions and 175 deletions.
3 changes: 3 additions & 0 deletions component/auth/group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_group.php');
?>
3 changes: 3 additions & 0 deletions component/auth/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_user.php');
?>
3 changes: 3 additions & 0 deletions component/config/dynamic_dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_dynamic_dashboard.php');
?>
3 changes: 3 additions & 0 deletions component/config/environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_environment.php');
?>
3 changes: 3 additions & 0 deletions component/config/plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_plugin_filter.php');
?>
3 changes: 3 additions & 0 deletions component/config/project.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_project.php');
?>
3 changes: 3 additions & 0 deletions component/config/role.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_role.php');
?>
3 changes: 3 additions & 0 deletions component/config/server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_server.php');
?>
4 changes: 4 additions & 0 deletions component/dashboard/dynamic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/dashboard/dynamic/r_dynamic.php');
?>
4 changes: 4 additions & 0 deletions component/dashboard/light.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/dashboard/dashboard_light/d_dashboard_light.php');
?>
8 changes: 8 additions & 0 deletions component/dashboard/view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
if (isset($_GET['f_id_config_server'])) {
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/config/server/r_server_wh_id.php');
include(DIR_FSROOT.'/html/dashboard/server_plugins/d_server_plugins.php');
}

?>
3 changes: 3 additions & 0 deletions component/perm/module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_module.php');
?>
8 changes: 8 additions & 0 deletions component/small_admin/myaccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
echo '<h1>'.MY_ACCOUNT.'</h1>';
echo '<fieldset>';
echo '<legend>'.EDIT.'</legend>';
include(DIR_FSROOT.'/html/small_admin/myaccount/w_myaccount.php');
include(DIR_FSROOT.'/html/small_admin/myaccount/r_myaccount_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/myaccount/f_myaccount.php');
?>
3 changes: 3 additions & 0 deletions component/small_admin/mydashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include(DIR_FSROOT.'/view/backend/v_small_admin_mydashboard.php');
?>
56 changes: 56 additions & 0 deletions component/small_admin/mygroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
echo '<h1>'.MANAGE_MYGROUP.'</h1>';
include(DIR_FSROOT.'/html/small_admin/mygroup/w_group.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/r_group_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/r_group.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/d_group.php');
echo '<div class="clearfix"></div>';

if (isset($_GET['f_id_auth_group'])) {
echo '<a href="'.removeqsvar($cur_url,'f_id_auth_group').'"><button type="button" class="btn btn-primary">'.ADD.' '.GROUP.'</button></a>';
}
echo '<div class="clearfix"></div>';
$perm_grp = new PERMS();
$f_id_auth_group=intval(GET('f_id_auth_group'));
if (($f_id_auth_group && $perm_grp->auth_user_group($f_id_auth_group,true)) || !$f_id_auth_group) {
echo '<fieldset>';
if (isset($cur_group)) {
echo '<legend>'.$cur_group->group.'</legend>';
}
echo '<fieldset>';
if (isset($_GET['f_id_auth_group'])) {
echo '<legend>'.EDIT.'</legend>';
}
else {
echo '<legend>'.ADD.'</legend>';
}

include(DIR_FSROOT.'/html/small_admin/mygroup/f_group.php');
echo '</fieldset>';

if (isset($_GET['f_id_auth_group'])) {
echo '<fieldset>';
echo '<legend>'.USERS.'</legend>';
include(DIR_FSROOT.'/html/small_admin/mygroup_user/w_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/e_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/r_group_user_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/r_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/d_group_user.php');
echo '<div class="clearfix"></div>';

if (isset($_GET['f_id_auth_user'])) {
echo '<a href="'.removeqsvar($cur_url,'f_id_auth_user').'"><button type="button" class="btn btn-primary">'.ADD.' '.USER.'</button></a>';
}
echo '<div class="clearfix"></div>';
if (isset($_GET['f_id_auth_user'])) {
echo '<strong>'.DEL.'</strong>';
} else {
echo '<strong>'.ADD.'</strong>';
}
include(DIR_FSROOT.'/html/small_admin/mygroup_user/f_group_user.php');
echo '</fieldset>';
}
echo '</fieldset>';
}
echo '<div class="clearfix"></div>';
?>
8 changes: 8 additions & 0 deletions component/small_admin/newuser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
echo '<h1>'.ADD_USER.'</h1>';
echo '<fieldset>';
echo '<legend>'.EDIT.'</legend>';
include(DIR_FSROOT.'/html/small_admin/newuser/w_user.php');
include(DIR_FSROOT.'/html/small_admin/newuser/f_user.php');
echo '</fieldset>';
?>
3 changes: 3 additions & 0 deletions config/config.php.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ define('SL_CSS','col-xs-offset-3 col-sm-offset-3 col-md-offset-3 col-lg-offset-3
define('SEM_CSS','col-xs-9 col-sm-9 col-md-9 col-lg-9');
define('C_CSS','col-xs-offset-3 col-sm-offset-3 col-md-offset-3 col-lg-offset-3 col-xs-9 col-sm-9 col-md-9 col-lg-9');

# Display graph title as text (text/rrd)
define('GRAPH_TITLE','rrd');

/************************* CGP *************************/
# extra typesdb config to merge to default
#$CONFIG['typesdb'][] = '/usr/share/collectd/my_extra_types.db';
Expand Down
141 changes: 16 additions & 125 deletions config/module.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/*
function removeqsvar($url, $varname) {
return str_replace('&','&amp;',preg_replace('/[?&]'.$varname.'=[^&]+(&|$)/' ,'' , $url));
}
*/
function removeqsvar($url, $varname) {
if (is_array($varname)) {
foreach ($varname as $cur_var) {
Expand All @@ -22,126 +17,22 @@ function removeqsvar($url, $varname) {
$workflow=GET('workflow');

$perm_mod = new PERMS();
if ($perm_mod->perm_module($module, $component)) { // DEBUT PERM MODULE

if ($module=='config') {
if ($component=='project') {
include(DIR_FSROOT.'/view/backend/v_project.php');
} elseif ($component=='server') {
include(DIR_FSROOT.'/view/backend/v_server.php');
} else if ($component=='role') {
include(DIR_FSROOT.'/view/backend/v_role.php');
} else if ($component=='environment') {
include(DIR_FSROOT.'/view/backend/v_environment.php');
} else if ($component=='plugin') {
include(DIR_FSROOT.'/view/backend/v_plugin_filter.php');
} else if ($component=='dynamic_dashboard') {
include(DIR_FSROOT.'/view/backend/v_dynamic_dashboard.php');
}
} else if ($module=='auth') {
if ($component=='user') {
include(DIR_FSROOT.'/view/backend/v_user.php');
} else if ($component=='group') {
include(DIR_FSROOT.'/view/backend/v_group.php');
}
} else if ($module=='perm') {
if ($component=='module') {
include(DIR_FSROOT.'/view/backend/v_module.php');
}
} else if ($module=='dashboard') {
if ($component=='view') {
if (isset($_GET['f_id_config_server'])) {
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/config/server/r_server_wh_id.php');
include(DIR_FSROOT.'/html/dashboard/server_plugins/d_server_plugins.php');
}
} else if ($component == 'dynamic') {
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/dashboard/dynamic/r_dynamic.php');
} else if ($component == 'light') {
include(DIR_FSROOT.'/modules/preg_find.php');
include(DIR_FSROOT.'/html/dashboard/dashboard_light/d_dashboard_light.php');
}
} else if ($module=='small_admin') {
if ($component=='mygroup') {
echo '<h1>'.MANAGE_MYGROUP.'</h1>';
include(DIR_FSROOT.'/html/small_admin/mygroup/w_group.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/r_group_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/r_group.php');
include(DIR_FSROOT.'/html/small_admin/mygroup/d_group.php');
echo '<div class="clearfix"></div>';

if (isset($_GET['f_id_auth_group'])) {
echo '<a href="'.removeqsvar($cur_url,'f_id_auth_group').'"><button type="button" class="btn btn-primary">'.ADD.' '.GROUP.'</button></a>';
}
echo '<div class="clearfix"></div>';
$perm_grp = new PERMS();
$f_id_auth_group=intval(GET('f_id_auth_group'));
if (($f_id_auth_group && $perm_grp->auth_user_group($f_id_auth_group,true)) || !$f_id_auth_group) {
echo '<fieldset>';
if (isset($cur_group)) {
echo '<legend>'.$cur_group->group.'</legend>';
}
echo '<fieldset>';
if (isset($_GET['f_id_auth_group'])) {
echo '<legend>'.EDIT.'</legend>';
}
else {
echo '<legend>'.ADD.'</legend>';
}

include(DIR_FSROOT.'/html/small_admin/mygroup/f_group.php');
echo '</fieldset>';

if (isset($_GET['f_id_auth_group'])) {
echo '<fieldset>';
echo '<legend>'.USERS.'</legend>';
include(DIR_FSROOT.'/html/small_admin/mygroup_user/w_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/e_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/r_group_user_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/r_group_user.php');
include(DIR_FSROOT.'/html/small_admin/mygroup_user/d_group_user.php');
echo '<div class="clearfix"></div>';

if (isset($_GET['f_id_auth_user'])) {
echo '<a href="'.removeqsvar($cur_url,'f_id_auth_user').'"><button type="button" class="btn btn-primary">'.ADD.' '.USER.'</button></a>';
}
echo '<div class="clearfix"></div>';
if (isset($_GET['f_id_auth_user'])) {
echo '<strong>'.DEL.'</strong>';
} else {
echo '<strong>'.ADD.'</strong>';
}
include(DIR_FSROOT.'/html/small_admin/mygroup_user/f_group_user.php');
echo '</fieldset>';
}
echo '</fieldset>';
}
echo '<div class="clearfix"></div>';
} else if ($component=='myaccount') {
echo '<h1>'.MY_ACCOUNT.'</h1>';
echo '<fieldset>';
echo '<legend>'.EDIT.'</legend>';
include(DIR_FSROOT.'/html/small_admin/myaccount/w_myaccount.php');
include(DIR_FSROOT.'/html/small_admin/myaccount/r_myaccount_wh_id.php');
include(DIR_FSROOT.'/html/small_admin/myaccount/f_myaccount.php');
echo '</fieldset>';
} else if ($component=='newuser') {
echo '<h1>'.ADD_USER.'</h1>';
echo '<fieldset>';
echo '<legend>'.EDIT.'</legend>';
include(DIR_FSROOT.'/html/small_admin/newuser/w_user.php');
include(DIR_FSROOT.'/html/small_admin/newuser/f_user.php');
echo '</fieldset>';
} else if ($component=='mydashboard') {
include(DIR_FSROOT.'/view/backend/v_small_admin_mydashboard.php');
}
} else {
echo $CONFIG['welcome_text'];
}
} else {
if ($component && $module) {
echo '<br />'.NO_ACCESS.'<br />';
}

if(preg_match("/^[0-9a-z_]*$/", $module) && preg_match("/^[0-9a-z_]*$/", $component)){
if ($perm_mod->perm_module($module, $component)) { // DEBUT PERM MODULE
if(file_exists(DIR_FSROOT.'/component/'.$module.'/'.$component.'.php')){
include(DIR_FSROOT.'/component/'.$module.'/'.$component.'.php');
}else{
echo $CONFIG['welcome_text'];
}
} else {
if ($component && $module) {
echo '<br />'.NO_ACCESS.'<br />';
}
}
}else{
echo '<br />'.NO_ACCESS.'<br />';
die();
}
?>
34 changes: 24 additions & 10 deletions graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
$json = file_get_contents('plugin/'.$plugin.'-'.$plugininstance.'.json');
$plugin_json = json_decode($json, true);

if (is_null($plugin_json))
$log->write('CGP Error: invalid json in plugin/'.$plugin.'.json');
} else if (function_exists('json_decode') && file_exists('plugin/'.$plugin.'-'.$plugincategory.'.json')) {
$json = file_get_contents('plugin/'.$plugin.'-'.$plugincategory.'.json');
$plugin_json = json_decode($json, true);

if (is_null($plugin_json))
$log->write('CGP Error: invalid json in plugin/'.$plugin.'.json');
} else if (function_exists('json_decode') && file_exists('plugin/'.$plugin.'-'.$plugincategory.'-'.$plugininstance.'.json')) {
Expand Down Expand Up @@ -114,6 +120,10 @@
require_once 'type/GenericAggregation.class.php';
$obj = new Type_GenericAggregation($CONFIG, $_GET);
break;
case 'varnish':
require_once 'type/VarnishStacked.class.php';
$obj = new Type_VarnishStacked($CONFIG, $_GET);
break;
default:
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG, $_GET);
Expand All @@ -137,16 +147,20 @@
}
}

if (isset($plugin_json[$type]['title'])) {
$obj->rrd_title = $plugin_json[$type]['title'];
$replacements = array(
'{{PI}}' => GET('pi'),
'{{PC}}' => GET('pc'),
'{{TI}}' => GET('ti'),
'{{TC}}' => GET('tc'),
'{{HOST}}' => GET('h')
);
$obj->rrd_title = str_replace(array_keys($replacements), array_values($replacements), $obj->rrd_title);
if (GRAPH_TITLE=='rrd') {
if (isset($plugin_json[$type]['title'])) {
$obj->rrd_title = $plugin_json[$type]['title'];
$replacements = array(
'{{PI}}' => GET('pi'),
'{{PC}}' => GET('pc'),
'{{TI}}' => GET('ti'),
'{{TC}}' => GET('tc'),
'{{HOST}}' => GET('h')
);
$obj->rrd_title = str_replace(array_keys($replacements), array_values($replacements), $obj->rrd_title);
}
} else {
$obj->rrd_title='';
}

if (isset($plugin_json[$type]['vertical'])) {
Expand Down
Loading

0 comments on commit 247b0e4

Please sign in to comment.