summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSebastian Schmelzer2012-01-11 14:36:35 +0100
committerSebastian Schmelzer2012-01-11 14:36:35 +0100
commitfca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e (patch)
tree6e6aaf749f34db8c7c7153c23ef85c57187430bb /scripts
parentAPI: mit addBootos kann man nun auch editieren (diff)
downloadpbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.gz
pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.xz
pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.zip
format source files
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dbContent.php351
-rw-r--r--scripts/mysqlGraph.php74
2 files changed, 212 insertions, 213 deletions
diff --git a/scripts/dbContent.php b/scripts/dbContent.php
index a704ec2..7ee8502 100644
--- a/scripts/dbContent.php
+++ b/scripts/dbContent.php
@@ -1,4 +1,4 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
* This program is free software distributed under the GPL version 2.
@@ -10,207 +10,206 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
// generate mysql graph
-$name = substr(str_replace("/","",$_SERVER['SCRIPT_NAME']),0,-4);
+$name = substr(str_replace("/", "", $_SERVER['SCRIPT_NAME']), 0, -4);
$dotname = $name . '.dot';
$pngname = $name . '.png';
echo "Opening Database Connection...\n";
$link = mysql_connect('localhost', 'root', '123456');
if (!$link) {
- die('keine Verbindung möglich: ' . mysql_error());
+ die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db('pbs');
error_reporting(1);
-
-
-$format['groupnode'] = '"%s" [shape=trapezium, fontcolor="#ffffffff", style=filled, fillcolor="#004A99FF"];'."\n";
-$format['personnode'] = '"%s" [shape=ellipse, fontcolor="#ffffffff", style=filled, fillcolor="#FF0000FF"];'."\n";
-$format['poolnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#00FF00FF"];'."\n";
+
+
+$format['groupnode'] = '"%s" [shape=trapezium, fontcolor="#ffffffff", style=filled, fillcolor="#004A99FF"];'."\n";
+$format['personnode'] = '"%s" [shape=ellipse, fontcolor="#ffffffff", style=filled, fillcolor="#FF0000FF"];'."\n";
+$format['poolnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#00FF00FF"];'."\n";
$format['membershipnode'] = '"%s" [shape=ellipse, fontcolor="#ffffffff", style=filled, fillcolor="#990000FF"];'."\n";
-$format['clientnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FFFF00FF"];'."\n";
-$format['rolenode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#FF0099FF"];'."\n";
+$format['clientnode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FFFF00FF"];'."\n";
+$format['rolenode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#FF0099FF"];'."\n";
$format['bootmenunode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#009999FF"];'."\n";
-$format['bootisonode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FF9900FF"];'."\n";
-$format['bootosnode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#99FF99FF"];'."\n";
-
-$format['groupgroup'] = '"%s" -> "%s";'."\n";
-$format['personmember'] = '"%s" -> "%s";'."\n";
-$format['rolemember'] = '"%s" -> "%s";'."\n";
-$format['membergroup'] = '"%s" -> "%s";'."\n";
-$format['personrequest'] = '"%s" -> "%s" [style=dotted];'."\n";
-$format['poolgroup'] = '"%s" -> "%s";'."\n";
-$format['clientgroup'] = '"%s" -> "%s";'."\n";
-$format['clientpool'] = '"%s" -> "%s";'."\n";
-$format['bootisogroup'] = '"%s" -> "%s";'."\n";
-$format['bootmenugroup'] = '"%s" -> "%s";'."\n";
-$format['bootosbootmenu'] = '"%s" -> "%s";'."\n";
-$format['bootosgroup'] = '"%s" -> "%s";'."\n";
-
-
-
-
-function getGroups(){
- global $format;
- $q = "SELECT groupID,title FROM pbs_group";
- $groups = "subgraph cluster_0 {";
- $groups .= "label=Groups;";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $groups .= sprintf($format['groupnode'] ,"Group".$data['groupID']);
- }
- $groups .= "}";
- return $groups;
+$format['bootisonode'] = '"%s" [shape=ellipse, fontcolor="#000000ff", style=filled, fillcolor="#FF9900FF"];'."\n";
+$format['bootosnode'] = '"%s" [fontcolor="#000000ff", style=filled, fillcolor="#99FF99FF"];'."\n";
+
+$format['groupgroup'] = '"%s" -> "%s";'."\n";
+$format['personmember'] = '"%s" -> "%s";'."\n";
+$format['rolemember'] = '"%s" -> "%s";'."\n";
+$format['membergroup'] = '"%s" -> "%s";'."\n";
+$format['personrequest'] = '"%s" -> "%s" [style=dotted];'."\n";
+$format['poolgroup'] = '"%s" -> "%s";'."\n";
+$format['clientgroup'] = '"%s" -> "%s";'."\n";
+$format['clientpool'] = '"%s" -> "%s";'."\n";
+$format['bootisogroup'] = '"%s" -> "%s";'."\n";
+$format['bootmenugroup'] = '"%s" -> "%s";'."\n";
+$format['bootosbootmenu'] = '"%s" -> "%s";'."\n";
+$format['bootosgroup'] = '"%s" -> "%s";'."\n";
+
+
+
+
+function getGroups() {
+ global $format;
+ $q = "SELECT groupID,title FROM pbs_group";
+ $groups = "subgraph cluster_0 {";
+ $groups . = "label=Groups;";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $groups . = sprintf($format['groupnode'] , "Group".$data['groupID']);
+ }
+ $groups . = "}";
+ return $groups;
}
-function recGroups($groupID,$level=0,$data=''){
- global $format;
- $q = "SELECT groupID FROM pbs_groupgroups WHERE parentID = $groupID";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $groups .= sprintf($format['groupgroup'],"Group".$groupID, "Group".$data['groupID']);
- $groups .= recGroups($data['groupID']);
- }
- return $groups;
+function recGroups($groupID, $level = 0, $data = '') {
+ global $format;
+ $q = "SELECT groupID FROM pbs_groupgroups WHERE parentID = $groupID";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $groups . = sprintf($format['groupgroup'], "Group".$groupID, "Group".$data['groupID']);
+ $groups . = recGroups($data['groupID']);
+ }
+ return $groups;
}
-function getPersons(){
- global $format;
- $q = "SELECT personID,title FROM pbs_person";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $persons .= sprintf($format['personnode'] ,"Person". $data['personID']);
-
- }
- return $persons;
+function getPersons() {
+ global $format;
+ $q = "SELECT personID,title FROM pbs_person";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $persons . = sprintf($format['personnode'] , "Person". $data['personID']);
+
+ }
+ return $persons;
}
-function getMemberships(){
- global $format;
- $q = "SELECT personID,groupID,membershipID,roleID FROM pbs_membership";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $memberships .= sprintf($format['membershipnode'],"Member".$data['membershipID']);
- $memberships .= sprintf($format['personmember'],"Person".$data['personID'],"Member".$data['membershipID']);
- $memberships .= sprintf($format['rolemember'],"Role".$data['roleID'], "Member".$data['membershipID']);
- $memberships .= sprintf($format['membergroup'],"Member".$data['membershipID'], "Group".$data['groupID']);
- }
- return $memberships;
+function getMemberships() {
+ global $format;
+ $q = "SELECT personID,groupID,membershipID,roleID FROM pbs_membership";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $memberships . = sprintf($format['membershipnode'], "Member".$data['membershipID']);
+ $memberships . = sprintf($format['personmember'], "Person".$data['personID'], "Member".$data['membershipID']);
+ $memberships . = sprintf($format['rolemember'], "Role".$data['roleID'], "Member".$data['membershipID']);
+ $memberships . = sprintf($format['membergroup'], "Member".$data['membershipID'], "Group".$data['groupID']);
+ }
+ return $memberships;
}
-function getRequests(){
- global $format;
- $q = "SELECT personID,groupID FROM pbs_grouprequest";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $memberships .= sprintf($format['peronrequests'],"Group".$data['groupID'], "Person".$data['personID']);
- }
- return $memberships;
+function getRequests() {
+ global $format;
+ $q = "SELECT personID,groupID FROM pbs_grouprequest";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $memberships . = sprintf($format['peronrequests'], "Group".$data['groupID'], "Person".$data['personID']);
+ }
+ return $memberships;
}
-function getPools(){
- global $format;
- $q = "SELECT poolID,groupID FROM pbs_pool";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $pools .= sprintf($format['poolnode'] ,"Pool".$data['poolID']);
- $pools .= sprintf($format['poolgroup'],"Pool".$data['poolID'], "Group".$data['groupID']);
-
- }
- return $pools;
+function getPools() {
+ global $format;
+ $q = "SELECT poolID,groupID FROM pbs_pool";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $pools . = sprintf($format['poolnode'] , "Pool".$data['poolID']);
+ $pools . = sprintf($format['poolgroup'], "Pool".$data['poolID'], "Group".$data['groupID']);
+
+ }
+ return $pools;
}
-function getClients(){
- global $format;
- $q = "SELECT clientID,groupID FROM pbs_client";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $clients .= sprintf($format['clientnode'] ,"Client".$data['clientID']);
- $query2 = "SELECT clientID, poolID FROM pbs_poolentries WHERE clientID = '".$data['clientID']."'";
- $result2 = mysql_query($query2);
- if(mysql_num_rows($result2) == 0)
- $clients .= sprintf($format['clientgroup'],"Client".$data['clientID'], "Group".$data['groupID']);
- }
-
- return $clients;
+function getClients() {
+ global $format;
+ $q = "SELECT clientID,groupID FROM pbs_client";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $clients . = sprintf($format['clientnode'] , "Client".$data['clientID']);
+ $query2 = "SELECT clientID, poolID FROM pbs_poolentries WHERE clientID = '".$data['clientID']."'";
+ $result2 = mysql_query($query2);
+ if(mysql_num_rows($result2) == 0)
+ { $clients . = sprintf($format['clientgroup'], "Client".$data['clientID'], "Group".$data['groupID']); }
+ }
+
+ return $clients;
}
-function clientPools(){
- global $format;
- $q = "SELECT clientID,poolID FROM pbs_poolentries";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $clientpools .= sprintf($format['clientpool'],"Client".$data['clientID'], "Pool".$data['poolID']);
- }
- return $clientpools;
+function clientPools() {
+ global $format;
+ $q = "SELECT clientID,poolID FROM pbs_poolentries";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $clientpools . = sprintf($format['clientpool'], "Client".$data['clientID'], "Pool".$data['poolID']);
+ }
+ return $clientpools;
}
-function getRoles(){
- global $format;
- $q = "SELECT roleID,groupID FROM pbs_role";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $roles .= sprintf($format['rolenode'] ,"Role".$data['roleID']);
- # $roles .= "Role".$data['roleID'] ." -> " . "Group".$data['groupID'].";\n";
- }
- return $roles;
+function getRoles() {
+ global $format;
+ $q = "SELECT roleID,groupID FROM pbs_role";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $roles . = sprintf($format['rolenode'] , "Role".$data['roleID']);
+# $roles .= "Role".$data['roleID'] ." -> " . "Group".$data['groupID'].";\n";
+ }
+ return $roles;
}
-function getBootiso(){
- global $format;
- $q = "SELECT bootisoID,groupID FROM pbs_bootiso";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $bootiso .= sprintf($format['bootisonode'] ,"BootIso".$data['bootisoID']);
- $bootiso .= sprintf($format['bootisogroup'],"BootIso".$data['bootisoID'], "Group".$data['groupID']);
-
- }
- return $bootiso;
+function getBootiso() {
+ global $format;
+ $q = "SELECT bootisoID,groupID FROM pbs_bootiso";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $bootiso . = sprintf($format['bootisonode'] , "BootIso".$data['bootisoID']);
+ $bootiso . = sprintf($format['bootisogroup'], "BootIso".$data['bootisoID'], "Group".$data['groupID']);
+
+ }
+ return $bootiso;
}
-function getBootMenus(){
- global $format;
- $q = "SELECT bootmenuID,groupID FROM pbs_bootmenu";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $bootmenu .= sprintf($format['bootmenunode'] ,"BootMenu".$data['bootmenuID']);
- $bootmenu .= sprintf($format['bootmenugroup'],"BootMenu".$data['bootmenuID'], "Group".$data['groupID']);
- }
- return $bootmenu;
+function getBootMenus() {
+ global $format;
+ $q = "SELECT bootmenuID,groupID FROM pbs_bootmenu";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $bootmenu . = sprintf($format['bootmenunode'] , "BootMenu".$data['bootmenuID']);
+ $bootmenu . = sprintf($format['bootmenugroup'], "BootMenu".$data['bootmenuID'], "Group".$data['groupID']);
+ }
+ return $bootmenu;
}
-function getBootos(){
- global $format;
- $q = "SELECT bootosID,groupID FROM pbs_bootos";
- $result = mysql_query($q);
- while($data = mysql_fetch_array($result)){
- $bootos .= sprintf($format['bootosnode'] ,"BootOs".$data['bootosID']);
-
- $q2 = "SELECT * FROM pbs_bootmenuentries WHERE bootosID = ".$data['bootosID']."";
- $result2 = mysql_query($q2);
- if(mysql_num_rows($result2)){
- while($data2 = mysql_fetch_array($result2))
- $bootos .= sprintf($format['bootosbootmenu'],"BootOs".$data['bootosID'], "BootMenu".$data2['bootmenuID']);
- }
- else
- $bootos .= sprintf($format['bootosgroup'],"BootOs".$data['bootosID'], "Group".$data['groupID']);
- }
- return $bootos;
+function getBootos() {
+ global $format;
+ $q = "SELECT bootosID,groupID FROM pbs_bootos";
+ $result = mysql_query($q);
+ while($data = mysql_fetch_array($result)) {
+ $bootos . = sprintf($format['bootosnode'] , "BootOs".$data['bootosID']);
+
+ $q2 = "SELECT * FROM pbs_bootmenuentries WHERE bootosID = ".$data['bootosID']."";
+ $result2 = mysql_query($q2);
+ if(mysql_num_rows($result2)) {
+ while($data2 = mysql_fetch_array($result2))
+ { $bootos . = sprintf($format['bootosbootmenu'], "BootOs".$data['bootosID'], "BootMenu".$data2['bootmenuID']); }
+ } else
+ { $bootos . = sprintf($format['bootosgroup'], "BootOs".$data['bootosID'], "Group".$data['groupID']); }
+ }
+ return $bootos;
}
-
+
## Concatenation
$defs = '';
-$defs .= getGroups();
-$defs .= recGroups(1);
-$defs .= getPersons();
-$defs .= getMemberships();
-$defs .= getRoles();
-$defs .= getRequests();
-$defs .= getPools();
-$defs .= getClients();
-$defs .= clientPools();
-$defs .= getBootiso();
-$defs .= getBootMenus();
-$defs .= getBootos();
-
-
-
+$defs . = getGroups();
+$defs . = recGroups(1);
+$defs . = getPersons();
+$defs . = getMemberships();
+$defs . = getRoles();
+$defs . = getRequests();
+$defs . = getPools();
+$defs . = getClients();
+$defs . = clientPools();
+$defs . = getBootiso();
+$defs . = getBootMenus();
+$defs . = getBootos();
+
+
+
$str = 'digraph x {
- node [];
- ranksep=3;
- size="20,20";
- overlap="0:true"'."\n";
-$str .= str_replace("\n","\n\t",$defs);
-$str .= "}";
-
+ node [];
+ ranksep=3;
+ size="20,20";
+ overlap="0:true"'."\n";
+$str . = str_replace("\n", "\n\t", $defs);
+$str . = "}";
+
echo "Write to file ...\n";
// Create the dot file
$fp = fopen($dotname, "w");
diff --git a/scripts/mysqlGraph.php b/scripts/mysqlGraph.php
index b9012b2..0c0e9cb 100644
--- a/scripts/mysqlGraph.php
+++ b/scripts/mysqlGraph.php
@@ -1,4 +1,4 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
* This program is free software distributed under the GPL version 2.
@@ -13,7 +13,7 @@
echo "Opening Database Connection...\n";
$link = mysql_connect('localhost', 'root', '123456');
if (!$link) {
- die('keine Verbindung möglich: ' . mysql_error());
+ die('keine Verbindung möglich: ' . mysql_error());
}
#mysql_close($link);
mysql_select_db('pbs');
@@ -22,57 +22,57 @@ mysql_select_db('pbs');
$result = mysql_list_tables('pbs');
echo "Get Tables ...\n";
while ($row = mysql_fetch_row($result)) {
- $tables[$row[0]] = array();
+ $tables[$row[0]] = array();
}
mysql_free_result($result);
// Save all table-names
-foreach($tables as $tablename => $data){
- $result = mysql_query("SHOW COLUMNS FROM $tablename");
- while ($row = mysql_fetch_assoc($result)) {
- $tables[$tablename][] = $row;
- }
+foreach($tables as $tablename => $data) {
+ $result = mysql_query("SHOW COLUMNS FROM $tablename");
+ while ($row = mysql_fetch_assoc($result)) {
+ $tables[$tablename][] = $row;
+ }
}
mysql_free_result($result);
echo "Get Fieldlist from tables ...\n";
// Prepare dot-string
$b = "\n";
$str = 'digraph x {
- node [shape=record];
- ranksep=3;
- size="20,20";'.$b;
-
+ node [shape=record];
+ ranksep=3;
+ size="20,20";'.$b;
+
// get all table-fields
-foreach($tables as $tablename => $data){
- $str .= $tablename .' [label= "{';
- $array = array();
- $array[] = strtoupper($tablename);
- foreach($data as $d){
- $array[] = "<".$d['Field'].">".$d['Field'];
- }
- $str .= implode("|",$array);
- $str .= '}",width=3];'.$b;
+foreach($tables as $tablename => $data) {
+ $str . = $tablename .' [label= "{';
+ $array = array();
+ $array[] = strtoupper($tablename);
+ foreach($data as $d) {
+ $array[] = "<".$d['Field'].">".$d['Field'];
+ }
+ $str . = implode("|", $array);
+ $str . = '}",width=3];'.$b;
}
echo "Generate the Links ...\n";
// link the database-items (foreign-keys)
-foreach($tables as $tablename1 => $table1){
- foreach($table1 as $field1){
- $f1 = $field1['Field'];
- foreach($tables as $tablename2 => $table2){
- foreach($table2 as $field2){
- $f2 = $field2['Field'];
- if( $tablename1 != $tablename2 && $f1 == $f2 && strstr($f1,'ID') && "pbs_".str_replace("ID",'',$f1) == $tablename1){
- // Draw lines to tables
- $str .= $tablename1 ." -> ".$tablename2.";".$b;
- // draw lines to table-items
- #$str .= $tablename1.":".$f1 ." -> ".$tablename2.":".$f2 .";".$b;
- }
- }
- }
- }
+foreach($tables as $tablename1 => $table1) {
+ foreach($table1 as $field1) {
+ $f1 = $field1['Field'];
+ foreach($tables as $tablename2 => $table2) {
+ foreach($table2 as $field2) {
+ $f2 = $field2['Field'];
+ if( $tablename1 != $tablename2 && $f1 == $f2 && strstr($f1, 'ID') && "pbs_".str_replace("ID", '', $f1) == $tablename1) {
+ // Draw lines to tables
+ $str . = $tablename1 ." -> ".$tablename2.";".$b;
+ // draw lines to table-items
+#$str .= $tablename1.":".$f1 ." -> ".$tablename2.":".$f2 .";".$b;
+ }
+ }
+ }
+ }
}
-$str .= "}";
+$str . = "}";
echo "Write to file ...\n";
// Create the dot file
$fp = fopen("mysqlGraph.dot", "w");