summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/ErrorController.php103
-rw-r--r--application/controllers/IndexController.php69
-rw-r--r--application/controllers/ResourceController.php1092
-rw-r--r--application/controllers/StatsController.php92
4 files changed, 669 insertions, 687 deletions
diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php
index a9a448d..66f9193 100644
--- a/application/controllers/ErrorController.php
+++ b/application/controllers/ErrorController.php
@@ -1,63 +1,60 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
-class ErrorController extends Zend_Controller_Action
-{
+class ErrorController extends Zend_Controller_Action {
- public function errorAction()
- {
- $errors = $this->_getParam('error_handler');
-
- switch ($errors->type) {
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
-
- // 404 error -- controller or action not found
- $this->getResponse()->setHttpResponseCode(404);
- $this->view->message = 'Page not found';
- $this->_redirect('/user/');
- print_a($errors);
- break;
- default:
- // application error
- $this->getResponse()->setHttpResponseCode(500);
- $this->view->message = 'Application error - Please contact the admin';
- print_a($errors);
- break;
- }
-
- // Log exception, if logger available
- if ($log = $this->getLog()) {
- $log->crit($this->view->message, $errors->exception);
- }
-
- // conditionally display exceptions
- if ($this->getInvokeArg('displayExceptions') == true) {
- $this->view->exception = $errors->exception;
- }
-
- $this->view->request = $errors->request;
+ public function errorAction() {
+ $errors = $this->_getParam('error_handler');
+
+ switch ($errors->type) {
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+
+ // 404 error -- controller or action not found
+ $this->getResponse()->setHttpResponseCode(404);
+ $this->view->message = 'Page not found';
+ $this->_redirect('/user/');
+ print_a($errors);
+ break;
+ default:
+ // application error
+ $this->getResponse()->setHttpResponseCode(500);
+ $this->view->message = 'Application error - Please contact the admin';
+ print_a($errors);
+ break;
+ }
+
+ // Log exception, if logger available
+ if ($log = $this->getLog()) {
+ $log->crit($this->view->message, $errors->exception);
}
- public function getLog()
- {
- $bootstrap = $this->getInvokeArg('bootstrap');
- if (!$bootstrap->hasPluginResource('Log')) {
- return false;
- }
- $log = $bootstrap->getResource('Log');
- return $log;
+ // conditionally display exceptions
+ if ($this->getInvokeArg('displayExceptions') == true) {
+ $this->view->exception = $errors->exception;
+ }
+
+ $this->view->request = $errors->request;
+ }
+
+ public function getLog() {
+ $bootstrap = $this->getInvokeArg('bootstrap');
+ if (!$bootstrap->hasPluginResource('Log')) {
+ return false;
}
+ $log = $bootstrap->getResource('Log');
+ return $log;
+ }
}
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
index 8ad2fc4..bf49eae 100644
--- a/application/controllers/IndexController.php
+++ b/application/controllers/IndexController.php
@@ -1,41 +1,38 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class IndexController extends Zend_Controller_Action
-{
-
- public function init()
- {
- /* Initialize action controller here */
- }
-
- public function indexAction()
- {
- if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){
- $mySession =new Zend_Session_Namespace('pbs');
- if(!isset($mySession->postdata)){
- $mySession->postdata = $_POST;
- }
-
- // $d = new Pbs_Debug();
- // $d->debug(array('MainIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata)));
-
- $this->_redirect("/fbgui/index/index");
- }
- $this->_redirect("/user/auth/login");
- // action body
-
-
- }
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
+
+class IndexController extends Zend_Controller_Action {
+
+ public function init() {
+ /* Initialize action controller here */
+ }
+
+ public function indexAction() {
+ if(stristr($_SERVER['HTTP_USER_AGENT'], 'prebootGUI')) {
+ $mySession = new Zend_Session_Namespace('pbs');
+ if(!isset($mySession->postdata)) {
+ $mySession->postdata = $_POST;
+ }
+
+ // $d = new Pbs_Debug();
+ // $d->debug(array('MainIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata)));
+
+ $this->_redirect("/fbgui/index/index");
+ }
+ $this->_redirect("/user/auth/login");
+ // action body
+
+
+ }
}
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index 1707c38..54eeb84 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -1,556 +1,546 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class ResourceController extends Zend_Controller_Action
-{
-
- private $thisSession;
- private $page;
- private $membership;
- private $rightrolesMapper;
-
- public function init()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $session = new Application_Model_Session();
- $sm = new Application_Model_SessionMapper();
-
- //TODO Error Messages if something failed
- $alpha = $this->_request->getParam('alpha');
- $apikey = $this->_request->getParam('apikey');
-
- if($apikey != ""){
- $membershipMapper = new Application_Model_MembershipMapper();
- $this->membership = new Application_Model_Membership();
- $this->rightrolesMapper = new Application_Model_RightRolesMapper();
-
- list($this->membership) = $membershipMapper->findBy(array('apikey' => $apikey));
- if($this->membership == null){
- header('HTTP/1.0 401 Member not found');
- die();
- }
-
- }
- elseif($alpha == "0"){
- $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
-
- $this->page = $this->_request->getParam('page');
-
- if(!is_numeric($bootmenuentryID)){
- $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/error');
- }
-
- $bootmenuentry = new Application_Model_BootMenuEntries();
- $bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper();
- $bootmenuMapper = new Application_Model_BootMenuMapper();
- $bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry);
-
- $session->setBootosID($bootmenuentry->getBootosID())
- ->setBootmenuentryID($bootmenuentry->getID())
- ->setTime(time())
- ->setMembershipID('1')
- ->setIp($_SERVER['REMOTE_ADDR'])
- ->setAlphasessionID('0');
-
- $this->thisSession = $session;
-
- }
- elseif($alpha != ""){
- $alphasessionID = $alpha;
- $result = $sm->findBy(array('alphasessionID' => $alphasessionID),true);
- # print_a($result);
- $this->thisSession = $session->setOptions($result[0]);
- $this->thisSession->setID($result[0]['sessionID']);
- }
-
- }
-
- public function indexAction()
- {
-
-
- }
-//TODO Try/Catch + Metadata check
- public function addbootosAction()
- {
-
- list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $this->membership->getRoleID()));
- if($rightroles == null){
- header('HTTP/1.0 403 No Right to Create Bootos');
- die();
- }
-
- $apikey = $this->_request->getParam('apikey');
- if($apikey == ""){
- header('HTTP/1.0 400 No API-Key');
- die();
- }
-
- $params = $this->_request->getParams();
- $source = $_SERVER['REMOTE_ADDR'];
-
- if($params['title'] == '' || $params['distro'] == '' || $params['distroversion'] == '' || $params['share'] == '' || $source == ''){
- header('HTTP/1.0 400 Title, Distro, Distroversion and Share must be set');
- die();
- }
-
- if($_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' || $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != ''|| $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != ''){
- header('HTTP/1.0 400 File must be larger than 0 bytes');
- die();
- }
-
- $bootosMapper = new Application_Model_BootOsMapper();
- $groupID = $this->membership->getGroupID();
-
- list($bootos) = $bootosMapper->findBy(array('groupid' => $groupID, 'title' => $params['title'], 'distro' => $params['distro'], 'distroversion' => $params['distroversion'], 'source' => $source, 'share' => $params['share']));
- if($bootos != null){
-
- list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '58', 'roleID' => $this->membership->getRoleID()));
- if($rightroles == null){
- header('HTTP/1.0 403 No Right to Edit Bootos');
- die();
- }
-
- $bootosID = $bootos->getID();
- $bootossrc = $bootos->getSource();
-
- $bootos->setOptions($params);
- $bootos->setID($bootosID);
- $bootos->setGroupID($groupID);
- $bootos->setSource($bootossrc);
- $bootos->setCreated(time());
- $bootos->setPublic('-1');
-
- $initpath = "../resources/bootos/".$bootosID."/initramfs/";
- $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
- $configpath = "../resources/bootos/".$bootosID."/config/";
-
- mkdir($initpath ,0777, true);
- mkdir($kernelpath ,0777, true);
- mkdir($configpath ,0777, true);
-
- if($_FILES['config']['name'] != ''){
- $bootos->setSource($_SERVER['REMOTE_ADDR']);
- move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
- }
- if($_FILES['kernel']['name'] != ''){
- $bootos->setSource($_SERVER['REMOTE_ADDR']);
- move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
- }
- if($_FILES['init']['name'] != ''){
- $bootos->setSource($_SERVER['REMOTE_ADDR']);
- move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
- }
-
- $bootosMapper->save($bootos);
-
- header('HTTP/1.0 201 Bootos edited');
-
- }else{
-
- $bootos = new Application_Model_BootOs();
-
- $bootos->setOptions($params);
- $bootos->setGroupID($groupID);
- $bootos->setSource($source);
- $bootos->setCreated(time());
- $bootos->setPublic('-1');
- $bootosID = $bootosMapper->save($bootos);
- $bootos->setID($bootosID);
-
- $initpath = "../resources/bootos/".$bootosID."/initramfs/";
- $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
- $configpath = "../resources/bootos/".$bootosID."/config/";
-
- mkdir($initpath ,0777, true);
- mkdir($kernelpath ,0777, true);
- mkdir($configpath ,0777, true);
-
- if($_FILES['config']['name'] != ''){
- move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
-
- }
- if($_FILES['kernel']['name'] != ''){
- move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
- }
- if($_FILES['init']['name'] != ''){
- move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
- $newconfig = new Pbs_NewConfig();
- $newconfig->createDefaultConfig($bootos);
- }
-
- header('HTTP/1.0 201 Bootos created');
- }
-
- }
-
-
- public function addprebootAction()
- {
-
- list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '40', 'roleID' => $this->membership->getRoleID()));
- if($rightroles == null){
- header('HTTP/1.0 403 No Right to Create Preboots');
- die();
- }
-
- $apikey = $this->_request->getParam('apikey');
- if($apikey == ""){
- header('HTTP/1.0 400 No API-Key');
- die();
- }
-
- $params = $this->_request->getParams();
- $source = $_SERVER['REMOTE_ADDR'];
-
- if($params['title'] == '' || $_FILES['preboot']['name'] == ''){
- header('HTTP/1.0 400 Title and Preboot must be set');
- die();
- }
-
- if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){
- header('HTTP/1.0 400 File must be larger than 0 bytes');
- die();
- }
-
- $prebootMapper = new Application_Model_PreBootMapper();
- $groupID = $this->membership->getGroupID();
-
- list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
- if($preboot != null){
- header('HTTP/1.0 400 Preboot already exists');
- die();
- }
-
- $preboot = new Application_Model_PreBoot();
-
- $preboot->setOptions($params);
- $preboot->setGroupID($groupID);
- $preboot->setSource($source);
- $preboot->setCreated(time());
-
- $prebootID = $prebootMapper->save($preboot);
-
- $prebootpath = "../resources/bootmedium/".$prebootID."/";
- mkdir($prebootpath ,0777, true);
-
- if($_FILES['preboot']['name'] != '' ){
- move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
- }
-
- header('HTTP/1.0 201 Preboot created');
-
-
- }
-
- public function editprebootAction()
- {
-
- list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '41', 'roleID' => $this->membership->getRoleID()));
- if($rightroles == null){
- header('HTTP/1.0 403 No Right to Edit Preboot');
- die();
- }
-
- $apikey = $this->_request->getParam('apikey');
- if($apikey == ""){
- header('HTTP/1.0 400 No API-Key');
- die();
- }
-
- $params = $this->_request->getParams();
- $source = $_SERVER['REMOTE_ADDR'];
-
- if($params['title'] == ''){
- header('HTTP/1.0 400 Title must be set');
- die();
- }
-
- if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){
- header('HTTP/1.0 400 File must be larger than 0 bytes');
- die();
- }
-
- $prebootMapper = new Application_Model_PreBootMapper();
- $groupID = $this->membership->getGroupID();
- $preboot = new Application_Model_PreBoot();
-
- list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
-
- if($preboot == null){
- header('HTTP/1.0 400 Preboot not found');
- die();
- }
-
- $prebootsrc = $preboot->getSource();
- $prebootID = $preboot->getID();
-
- $preboot->setOptions($params);
- $preboot->setGroupID($groupID);
- $preboot->setSource($prebootsrc);
- $preboot->setCreated(time());
-
- $prebootpath = "../resources/bootmedium/".$prebootID."/";
- mkdir($prebootpath ,0777, true);
-
- if($_FILES['preboot']['name'] != ''){
- $preboot->setSource($source);
- move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
- }
-
- $prebootMapper->save($preboot);
-
- header('HTTP/1.0 201 Preboot edited');
-
- }
-
- public function getinitramfsAction()
- {
-
- $bootosID = $this->thisSession->getBootosID();
-
- if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- // create file.
- chdir("../resources/bootos/$bootosID/initramfs/");
- $initname = array_pop(scandir("./"));
-
- header("Content-Length: ".filesize(getcwd()."/".$initname));
-
- passthru( "cat ".$initname);
- }else{
- header('HTTP/1.0 404 Not Found');
- }
- }
-
- public function getconfigAction()
- {
- $bootmenuentryID = $this->thisSession->getBootmenuentryID();
- $bootmenuentry = new Application_Model_BootMenuEntries();
- $bmm = new Application_Model_BootMenuEntriesMapper();
- $bmm->find($bootmenuentryID,$bootmenuentry);
-
- $configID = $bootmenuentry->getConfigID();
- $bootosID = $this->thisSession->getBootosID();
-
- if(is_dir("../resources/bootos/$bootosID/config/")){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="default.tgz"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- if($configID == null){
- chdir("../resources/bootos/$bootosID/config/");
- passthru( "cat default.tgz");
- }else{
- $bootosuserMapper = new Application_Model_BootOsUserMapper();
- $bootosuser = $bootosuserMapper->findBy(array('configID' => $configID));
-
- $hash = md5(microtime(1));
- $tmp_conf = "../resources/config/$hash";
- mkdir($tmp_conf ,0777, true);
- exec("tar -C $tmp_conf -xf ../resources/bootos/$bootosID/config/default.tgz",$restul);
- exec("tar -C $tmp_conf/rootfs/ -xf ../resources/config/etc.tgz");
-
- $username = '';
- $userpassword = '';
-
- if($this->thisSession->getMembershipID() != null){
- $person = new Application_Model_Person();
- $personMapper = new Application_Model_PersonMapper();
- $membershipMapper = new Application_Model_MembershipMapper();
- $personID = $membershipMapper->find($this->thisSession->getMembershipID())->getPersonID();
- $person = $personMapper->find($personID);
- $username = strtolower($person->getName());
- $username = preg_replace("!\s!","",$username);
- $userpassword = $person->getLoginPassword();
- }
- $anzUsers = count($bootosuser);
- $test = array();
- if($anzUsers <= 2){
- foreach($bootosuser as $user)
- $test[] = $user->getLogin();
- }
-
- $configView = new Zend_View();
- $f = fopen("$tmp_conf/initramfs/postinit.local", "a");
-
- $userid = 1000;
-
- foreach($bootosuser as $user){
-
- if($user->getLogin() == '%username%'){
- $configView->loginname = $username;
- }else{
- $configView->loginname = $user->getLogin();
- }
-
- $configView->userid = $userid++;
-
- if($user->getPassword() == '%password%'){
- $configView->password = $userpassword;
- }else{
- $configView->password = $user->getPassword();
- }
-
- if($user->getHometypeID() == 2){
- $configView->homepath = $user->getHomepath();
- }elseif($user->getHometypeID() == 1){
- $configView->homepath = "/media/openslx-stick/home/".$configView->loginname;
- }else{
- $configView->homepath = "/home/".$configView->loginname;
- }
-
- if($configView->loginname != '' && $configView->password != ''){
-
- if($user->getHometypeID() == 1){
- $configView->usb = true;
- }
- else{
- $configView->usb = false;
- if($anzUsers <= 2 && $user->getLogin() == 'kiosk' && in_array('%username%',$test) && $this->thisSession->getMembershipID() == null)
- $configView->autologin = true;
- elseif($anzUsers <= 2 && $user->getLogin() == '%username%' && $this->thisSession->getMembershipID() != null)
- $configView->autologin = true;
- else
- $configView->autologin = false;
-
- }
-
- $configView->addScriptPath(APPLICATION_PATH.'/views/scripts/resource/');
- $config = $configView->render('getconfig.phtml');
-
- fputs($f, $config);
-
- }
- }
- fclose($f);
-
- // create the gzipped tarfile.
- chdir($tmp_conf);
- passthru( "tar cz *");
- exec("rm -rf ../$hash");
-
- }
- }else{
- header('HTTP/1.0 404 Not Found');
- }
- }
-
- public function getkernelAction()
- {
-
- $bootosID = $this->thisSession->getBootosID();
-
- if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- // create the gzipped tarfile.
- chdir("../resources/bootos/$bootosID/kernel/");
- $kernelname = array_pop(scandir("./"));
-
- header("Content-Length: ".filesize(getcwd()."/".$kernelname));
-
- passthru( "cat ". $kernelname);
- }else{
- header('HTTP/1.0 404 Not Found');
- }
-
- }
-
- public function getkclAction()
- {
-
-
- $bmeID = $this->thisSession->getBootmenuentryID();
-
- if(is_numeric($bmeID)){
-
- $bmemapper = new Application_Model_BootMenuEntriesMapper();
- $bme = new Application_Model_BootMenuEntries();
- $bootosmapper = new Application_Model_BootOsMapper();
- $bmemapper->find($bmeID,$bme);
-
- header('Content-Type: text/html');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- $kcl = $bootosmapper->find($bme->getBootosID())->getDefaultkcl();
-
- if($bme->getKcl() && $kcl != null){
- $result = $kcl . " alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/c/".$this->_request->getParam('alpha')."/default.tgz ".$bme->getKclappend();
- }else{
- $result = "alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/c/".$this->_request->getParam('alpha')."/default.tgz ".$bme->getKclappend();
- }
- $result = trim($result);
- header("Content-Length: ".(strlen($result)));
-
- echo $result;
-
-
- }
-
- }
-
- public function getbootmenuentryAction()
- {
- // obsolete function (now only for debugging)
- // after selecting the BootOS it will be saved in session
- // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction
- // can be called with session-identifier
-
- $return_val =
- array(
- 'info' => 'This function is for debugging purpose only',
- 'kernel' => $this->generateURL('getkernel', 'alpha', $this->thisSession->getAlphasessionID(), "kernel"),
- 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $this->thisSession->getAlphasessionID(), "initramfs"),
- 'kcl' => $this->generateURL('getkcl', 'alpha', $this->thisSession->getAlphasessionID(), "kcl.txt"),
- 'config' => $this->generateURL('getconfig', 'alpha', $this->thisSession->getAlphasessionID(), 'default.tgz')
- );
-
- $result = $return_val;
- $result2 = "<table class='json'>";
- $result2 .= "<tr><td><b>info</b>: </td><td>".$result['info']."</td></tr>";
- $result2 .= "<tr><td><b>kernel</b>: </td><td><a href=".$result['kernel'].">".$result['kernel']."<a></td></tr>";
- $result2 .= "<tr><td><b>initramfs</b>: </td><td><a href=".$result['initramfs'].">".$result['initramfs']."<a></td></tr>";
- $result2 .= "<tr><td><b>kcl</b>: </td><td><a href=".$result['kcl'].">".$result['kcl']."<a></td></tr>";
- $result2 .= "<tr><td><b>config</b>: </td><td><a href=".$result['config'].">".$result['config']."<a></td></tr>";
- $result2 .= "</table>";
- echo $result2;
- }
-
- private function generateURL($action, $varname, $varvalue, $filename){
- $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue .'/bootmenuentryID/'.$this->thisSession->getBootmenuentryID().'/file/' . $filename ;
- $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
- return $path;
- }
-
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
+
+class ResourceController extends Zend_Controller_Action {
+
+ private $thisSession;
+ private $page;
+ private $membership;
+ private $rightrolesMapper;
+
+ public function init() {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+
+ //TODO Error Messages if something failed
+ $alpha = $this->_request->getParam('alpha');
+ $apikey = $this->_request->getParam('apikey');
+
+ if($apikey != "") {
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $this->membership = new Application_Model_Membership();
+ $this->rightrolesMapper = new Application_Model_RightRolesMapper();
+
+ list($this->membership) = $membershipMapper->findBy(array('apikey' => $apikey));
+ if($this->membership == null) {
+ header('HTTP/1.0 401 Member not found');
+ die();
+ }
+
+ }
+ elseif($alpha == "0") {
+ $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
+
+ $this->page = $this->_request->getParam('page');
+
+ if(!is_numeric($bootmenuentryID)) {
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/error');
+ }
+
+ $bootmenuentry = new Application_Model_BootMenuEntries();
+ $bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper();
+ $bootmenuMapper = new Application_Model_BootMenuMapper();
+ $bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry);
+
+ $session->setBootosID($bootmenuentry->getBootosID())
+ ->setBootmenuentryID($bootmenuentry->getID())
+ ->setTime(time())
+ ->setMembershipID('1')
+ ->setIp($_SERVER['REMOTE_ADDR'])
+ ->setAlphasessionID('0');
+
+ $this->thisSession = $session;
+
+ }
+ elseif($alpha != "") {
+ $alphasessionID = $alpha;
+ $result = $sm->findBy(array('alphasessionID' => $alphasessionID), true);
+# print_a($result);
+ $this->thisSession = $session->setOptions($result[0]);
+ $this->thisSession->setID($result[0]['sessionID']);
+ }
+
+ }
+
+ public function indexAction() {
+
+
+ }
+ //TODO Try/Catch + Metadata check
+ public function addbootosAction() {
+
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null) {
+ header('HTTP/1.0 403 No Right to Create Bootos');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == "") {
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == '' || $params['distro'] == '' || $params['distroversion'] == '' || $params['share'] == '' || $source == '') {
+ header('HTTP/1.0 400 Title, Distro, Distroversion and Share must be set');
+ die();
+ }
+
+ if($_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' || $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' || $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '') {
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
+ $bootosMapper = new Application_Model_BootOsMapper();
+ $groupID = $this->membership->getGroupID();
+
+ list($bootos) = $bootosMapper->findBy(array('groupid' => $groupID, 'title' => $params['title'], 'distro' => $params['distro'], 'distroversion' => $params['distroversion'], 'source' => $source, 'share' => $params['share']));
+ if($bootos != null) {
+
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '58', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null) {
+ header('HTTP/1.0 403 No Right to Edit Bootos');
+ die();
+ }
+
+ $bootosID = $bootos->getID();
+ $bootossrc = $bootos->getSource();
+
+ $bootos->setOptions($params);
+ $bootos->setID($bootosID);
+ $bootos->setGroupID($groupID);
+ $bootos->setSource($bootossrc);
+ $bootos->setCreated(time());
+ $bootos->setPublic('-1');
+
+ $initpath = "../resources/bootos/".$bootosID."/initramfs/";
+ $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
+ $configpath = "../resources/bootos/".$bootosID."/config/";
+
+ mkdir($initpath , 0777, true);
+ mkdir($kernelpath , 0777, true);
+ mkdir($configpath , 0777, true);
+
+ if($_FILES['config']['name'] != '') {
+ $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
+ }
+ if($_FILES['kernel']['name'] != '') {
+ $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
+ }
+ if($_FILES['init']['name'] != '') {
+ $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
+ }
+
+ $bootosMapper->save($bootos);
+
+ header('HTTP/1.0 201 Bootos edited');
+
+ } else {
+
+ $bootos = new Application_Model_BootOs();
+
+ $bootos->setOptions($params);
+ $bootos->setGroupID($groupID);
+ $bootos->setSource($source);
+ $bootos->setCreated(time());
+ $bootos->setPublic('-1');
+ $bootosID = $bootosMapper->save($bootos);
+ $bootos->setID($bootosID);
+
+ $initpath = "../resources/bootos/".$bootosID."/initramfs/";
+ $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
+ $configpath = "../resources/bootos/".$bootosID."/config/";
+
+ mkdir($initpath , 0777, true);
+ mkdir($kernelpath , 0777, true);
+ mkdir($configpath , 0777, true);
+
+ if($_FILES['config']['name'] != '') {
+ move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
+
+ }
+ if($_FILES['kernel']['name'] != '') {
+ move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
+ }
+ if($_FILES['init']['name'] != '') {
+ move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
+ $newconfig = new Pbs_NewConfig();
+ $newconfig->createDefaultConfig($bootos);
+ }
+
+ header('HTTP/1.0 201 Bootos created');
+ }
+
+ }
+
+
+ public function addprebootAction() {
+
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '40', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null) {
+ header('HTTP/1.0 403 No Right to Create Preboots');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == "") {
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == '' || $_FILES['preboot']['name'] == '') {
+ header('HTTP/1.0 400 Title and Preboot must be set');
+ die();
+ }
+
+ if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != '') {
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
+ $prebootMapper = new Application_Model_PreBootMapper();
+ $groupID = $this->membership->getGroupID();
+
+ list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
+ if($preboot != null) {
+ header('HTTP/1.0 400 Preboot already exists');
+ die();
+ }
+
+ $preboot = new Application_Model_PreBoot();
+
+ $preboot->setOptions($params);
+ $preboot->setGroupID($groupID);
+ $preboot->setSource($source);
+ $preboot->setCreated(time());
+
+ $prebootID = $prebootMapper->save($preboot);
+
+ $prebootpath = "../resources/bootmedium/".$prebootID."/";
+ mkdir($prebootpath , 0777, true);
+
+ if($_FILES['preboot']['name'] != '' ) {
+ move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
+ }
+
+ header('HTTP/1.0 201 Preboot created');
+
+
+ }
+
+ public function editprebootAction() {
+
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '41', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null) {
+ header('HTTP/1.0 403 No Right to Edit Preboot');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == "") {
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == '') {
+ header('HTTP/1.0 400 Title must be set');
+ die();
+ }
+
+ if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != '') {
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
+ $prebootMapper = new Application_Model_PreBootMapper();
+ $groupID = $this->membership->getGroupID();
+ $preboot = new Application_Model_PreBoot();
+
+ list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
+
+ if($preboot == null) {
+ header('HTTP/1.0 400 Preboot not found');
+ die();
+ }
+
+ $prebootsrc = $preboot->getSource();
+ $prebootID = $preboot->getID();
+
+ $preboot->setOptions($params);
+ $preboot->setGroupID($groupID);
+ $preboot->setSource($prebootsrc);
+ $preboot->setCreated(time());
+
+ $prebootpath = "../resources/bootmedium/".$prebootID."/";
+ mkdir($prebootpath , 0777, true);
+
+ if($_FILES['preboot']['name'] != '') {
+ $preboot->setSource($source);
+ move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
+ }
+
+ $prebootMapper->save($preboot);
+
+ header('HTTP/1.0 201 Preboot edited');
+
+ }
+
+ public function getinitramfsAction() {
+
+ $bootosID = $this->thisSession->getBootosID();
+
+ if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)) {
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create file.
+ chdir("../resources/bootos/$bootosID/initramfs/");
+ $initname = array_pop(scandir("./"));
+
+ header("Content-Length: ".filesize(getcwd()."/".$initname));
+
+ passthru( "cat ".$initname);
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ }
+ }
+
+ public function getconfigAction() {
+ $bootmenuentryID = $this->thisSession->getBootmenuentryID();
+ $bootmenuentry = new Application_Model_BootMenuEntries();
+ $bmm = new Application_Model_BootMenuEntriesMapper();
+ $bmm->find($bootmenuentryID, $bootmenuentry);
+
+ $configID = $bootmenuentry->getConfigID();
+ $bootosID = $this->thisSession->getBootosID();
+
+ if(is_dir("../resources/bootos/$bootosID/config/")) {
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="default.tgz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ if($configID == null) {
+ chdir("../resources/bootos/$bootosID/config/");
+ passthru( "cat default.tgz");
+ } else {
+ $bootosuserMapper = new Application_Model_BootOsUserMapper();
+ $bootosuser = $bootosuserMapper->findBy(array('configID' => $configID));
+
+ $hash = md5(microtime(1));
+ $tmp_conf = "../resources/config/$hash";
+ mkdir($tmp_conf , 0777, true);
+ exec("tar -C $tmp_conf -xf ../resources/bootos/$bootosID/config/default.tgz", $restul);
+ exec("tar -C $tmp_conf/rootfs/ -xf ../resources/config/etc.tgz");
+
+ $username = '';
+ $userpassword = '';
+
+ if($this->thisSession->getMembershipID() != null) {
+ $person = new Application_Model_Person();
+ $personMapper = new Application_Model_PersonMapper();
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $personID = $membershipMapper->find($this->thisSession->getMembershipID())->getPersonID();
+ $person = $personMapper->find($personID);
+ $username = strtolower($person->getName());
+ $username = preg_replace("!\s!", "", $username);
+ $userpassword = $person->getLoginPassword();
+ }
+ $anzUsers = count($bootosuser);
+ $test = array();
+ if($anzUsers <= 2) {
+ foreach($bootosuser as $user)
+ $test[] = $user->getLogin();
+ }
+
+ $configView = new Zend_View();
+ $f = fopen("$tmp_conf/initramfs/postinit.local", "a");
+
+ $userid = 1000;
+
+ foreach($bootosuser as $user) {
+
+ if($user->getLogin() == '%username%') {
+ $configView->loginname = $username;
+ } else {
+ $configView->loginname = $user->getLogin();
+ }
+
+ $configView->userid = $userid++;
+
+ if($user->getPassword() == '%password%') {
+ $configView->password = $userpassword;
+ } else {
+ $configView->password = $user->getPassword();
+ }
+
+ if($user->getHometypeID() == 2) {
+ $configView->homepath = $user->getHomepath();
+ }
+ elseif($user->getHometypeID() == 1) {
+ $configView->homepath = "/media/openslx-stick/home/".$configView->loginname;
+ }
+ else {
+ $configView->homepath = "/home/".$configView->loginname;
+ }
+
+ if($configView->loginname != '' && $configView->password != '') {
+
+ if($user->getHometypeID() == 1) {
+ $configView->usb = true;
+ } else {
+ $configView->usb = false;
+ if($anzUsers <= 2 && $user->getLogin() == 'kiosk' && in_array('%username%', $test) && $this->thisSession->getMembershipID() == null)
+ { $configView->autologin = true; }
+ elseif($anzUsers <= 2 && $user->getLogin() == '%username%' && $this->thisSession->getMembershipID() != null)
+ $configView->autologin = true;
+ else
+ { $configView->autologin = false; }
+
+ }
+
+ $configView->addScriptPath(APPLICATION_PATH.'/views/scripts/resource/');
+ $config = $configView->render('getconfig.phtml');
+
+ fputs($f, $config);
+
+ }
+ }
+ fclose($f);
+
+ // create the gzipped tarfile.
+ chdir($tmp_conf);
+ passthru( "tar cz *");
+ exec("rm -rf ../$hash");
+
+ }
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ }
+ }
+
+ public function getkernelAction() {
+
+ $bootosID = $this->thisSession->getBootosID();
+
+ if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)) {
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/kernel/");
+ $kernelname = array_pop(scandir("./"));
+
+ header("Content-Length: ".filesize(getcwd()."/".$kernelname));
+
+ passthru( "cat ". $kernelname);
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ }
+
+ }
+
+ public function getkclAction() {
+
+
+ $bmeID = $this->thisSession->getBootmenuentryID();
+
+ if(is_numeric($bmeID)) {
+
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $bme = new Application_Model_BootMenuEntries();
+ $bootosmapper = new Application_Model_BootOsMapper();
+ $bmemapper->find($bmeID, $bme);
+
+ header('Content-Type: text/html');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ $kcl = $bootosmapper->find($bme->getBootosID())->getDefaultkcl();
+
+ if($bme->getKcl() && $kcl != null) {
+ $result = $kcl . " alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/c/".$this->_request->getParam('alpha')."/default.tgz ".$bme->getKclappend();
+ } else {
+ $result = "alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/c/".$this->_request->getParam('alpha')."/default.tgz ".$bme->getKclappend();
+ }
+ $result = trim($result);
+ header("Content-Length: ".(strlen($result)));
+
+ echo $result;
+
+
+ }
+
+ }
+
+ public function getbootmenuentryAction() {
+ // obsolete function (now only for debugging)
+ // after selecting the BootOS it will be saved in session
+ // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction
+ // can be called with session-identifier
+
+ $return_val =
+ array(
+ 'info' => 'This function is for debugging purpose only',
+ 'kernel' => $this->generateURL('getkernel', 'alpha', $this->thisSession->getAlphasessionID(), "kernel"),
+ 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $this->thisSession->getAlphasessionID(), "initramfs"),
+ 'kcl' => $this->generateURL('getkcl', 'alpha', $this->thisSession->getAlphasessionID(), "kcl.txt"),
+ 'config' => $this->generateURL('getconfig', 'alpha', $this->thisSession->getAlphasessionID(), 'default.tgz')
+ );
+
+ $result = $return_val;
+ $result2 = "<table class='json'>";
+ $result2 . = "<tr><td><b>info</b>: </td><td>".$result['info']."</td></tr>";
+ $result2 . = "<tr><td><b>kernel</b>: </td><td><a href=".$result['kernel'].">".$result['kernel']."<a></td></tr>";
+ $result2 . = "<tr><td><b>initramfs</b>: </td><td><a href=".$result['initramfs'].">".$result['initramfs']."<a></td></tr>";
+ $result2 . = "<tr><td><b>kcl</b>: </td><td><a href=".$result['kcl'].">".$result['kcl']."<a></td></tr>";
+ $result2 . = "<tr><td><b>config</b>: </td><td><a href=".$result['config'].">".$result['config']."<a></td></tr>";
+ $result2 . = "</table>";
+ echo $result2;
+ }
+
+ private function generateURL($action, $varname, $varvalue, $filename) {
+ $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue .'/bootmenuentryID/'.$this->thisSession->getBootmenuentryID().'/file/' . $filename ;
+ $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
+ return $path;
+ }
+
}
diff --git a/application/controllers/StatsController.php b/application/controllers/StatsController.php
index 05762a4..6ccd6bc 100644
--- a/application/controllers/StatsController.php
+++ b/application/controllers/StatsController.php
@@ -1,51 +1,49 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class StatsController extends Zend_Controller_Action
-{
-
- public function init()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
- }
-
- public function graphgroupAction(){
-
- $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
-
- if(isset($userIDsNamespace['groupID'])){
- header("Content-Type: image/png");
- header("Expires: 0");
- $n = new Pbs_Graph();
-
- $level = $this->_request->getParam('level');
- if(is_numeric($level) && $level != ''){
- $n->setHiglightLevel($level);
- }
- $groupID = $userIDsNamespace['groupID'];
-
- $group = $this->_request->getParam('group');
- if((Pbs_Acl::checkRight('gsdo') || Pbs_Acl::checkRight('gsdog')) && is_numeric($group)){
- $groupID = $group;
- }
-
- $child = $this->_request->getParam('child');
- if(Pbs_Acl::checkRight('glk') && $child != ''){
- $n->newChild($child);
- }
-
- echo $n->graph($groupID);
- }
- }
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
+
+class StatsController extends Zend_Controller_Action {
+
+ public function init() {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ }
+
+ public function graphgroupAction() {
+
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
+ if(isset($userIDsNamespace['groupID'])) {
+ header("Content-Type: image/png");
+ header("Expires: 0");
+ $n = new Pbs_Graph();
+
+ $level = $this->_request->getParam('level');
+ if(is_numeric($level) && $level != '') {
+ $n->setHiglightLevel($level);
+ }
+ $groupID = $userIDsNamespace['groupID'];
+
+ $group = $this->_request->getParam('group');
+ if((Pbs_Acl::checkRight('gsdo') || Pbs_Acl::checkRight('gsdog')) && is_numeric($group)) {
+ $groupID = $group;
+ }
+
+ $child = $this->_request->getParam('child');
+ if(Pbs_Acl::checkRight('glk') && $child != '') {
+ $n->newChild($child);
+ }
+
+ echo $n->graph($groupID);
+ }
+ }
}