This commit is contained in:
Stefan Puraner
2015-05-07 10:25:47 +02:00
13 changed files with 1024 additions and 86 deletions
+2 -1
View File
@@ -49,11 +49,12 @@ abstract class db extends basis
abstract function db_fetch_array($result=null);
abstract function db_fetch_row($result=null, $i=null);
abstract function db_fetch_assoc($result=null, $i=null);
abstract function db_result($result = null, $i,$item);
abstract function db_result($result = null, $i, $item);
abstract function db_num_rows($result=null);
abstract function db_num_fields($result=null);
abstract function db_field_name($result=null, $i);
abstract function db_affected_rows($result=null);
abstract function db_result_seek($result=null, $offset);
abstract function db_last_error();
abstract function db_free_result($result=null);
abstract function db_version();
+8
View File
@@ -163,6 +163,14 @@ class basis_db extends db
return pg_affected_rows($result);
}
public function db_result_seek($result=null, $offset)
{
if(is_null($result))
return pg_result_seek($this->db_result, $offset);
else
return pg_result_seek($result, $offset);
}
public function db_fetch_array($result=null)
{
if(is_null($result))
+87
View File
@@ -0,0 +1,87 @@
<?php
/* Copyright (C) 2015 fhcomplete.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*
* An easy way to keep in track of external processes.
* Ever wanted to execute a process in php, but you still wanted to have somewhat controll of the process ? Well.. This is a way of doing it.
* @compability: Linux only. (Windows does not work).
* @author: Christian Paminger <christian.paminger@technikum-wien.at>
*/
class process
{
private $pid;
private $command;
public $lastout;
public $output;
public $exit;
public function __construct($cl=false)
{
if ($cl != false)
{
$this->command = $cl;
$this->runCom();
}
}
private function runCom()
{
$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!';
$this->lastout=exec($command, $this->output, $this->exit); //exec($command ,$op);
$this->pid = (int)$this->output[0];
}
public function setPid($pid)
{
$this->pid = $pid;
}
public function getPid()
{
return $this->pid;
}
public function status()
{
$command = 'ps -p '.$this->pid;
exec($command,$op);
if (!isset($op[1]))
return false;
else
return true;
}
public function start()
{
if ($this->command != '')
$this->runCom();
else
return true;
}
public function stop()
{
$command = 'kill '.$this->pid;
exec($command);
if ($this->status() == false)
return true;
else
return false;
}
}
?>
+29 -10
View File
@@ -25,7 +25,7 @@ class statistik extends basis_db
{
public $new;
public $statistik_obj=array();
public $result=array();
public $result;
public $statistik_kurzbz;
public $content_id;
@@ -52,7 +52,7 @@ class statistik extends basis_db
public $anzahl; //Hilfsvariable fuer Group BY Abfragen
// Daten der Statistik
public $data;
public $data; // DB ressource
public $html;
public $csv;
public $json;
@@ -60,9 +60,14 @@ class statistik extends basis_db
/**
* Konstruktor
*/
public function __construct($studiengang_kz=null)
public function __construct($statistik_kurzbz=null)
{
parent::__construct();
parent::__construct();
if(!is_null($statistik_kurzbz))
$this->load($statistik_kurzbz);
else
$this->new=true;
}
/**
@@ -122,9 +127,8 @@ class statistik extends basis_db
{
$qry = 'SELECT * FROM public.tbl_statistik';
if($order) {
if($order)
$qry .= ' ORDER BY ' . $order;
}
if($result = $this->db_query($qry))
{
@@ -242,7 +246,7 @@ class statistik extends basis_db
{
$this->errormsg = 'Fehler beim Laden der Daten';
return false;
}
}
}
/**
* Speichert einen Statistik Datensatz
@@ -539,7 +543,7 @@ class statistik extends basis_db
$anzahl_spalten = $this->db_num_fields($this->data);
for($spalte=0;$spalte<$anzahl_spalten;$spalte++)
{
$this->html.= '<th>'.$this->db_field_name($this->data,$spalte).'</th>';
$this->html.= '<th>'.$this->convert_html_chars($this->db_field_name($this->data,$spalte)).'</th>';
$this->csv.='"'.$this->db_field_name($this->data,$spalte).'",';
}
$this->html.= '</tr></thead><tbody>';
@@ -552,7 +556,7 @@ class statistik extends basis_db
for($spalte=0;$spalte<$anzahl_spalten;$spalte++)
{
$name = $this->db_field_name($this->data,$spalte);
$this->html.= '<td>'.$row->$name.'</td>';
$this->html.= '<td>'.$this->convert_html_chars($row->$name).'</td>';
$this->csv.= '"'.$row->$name.'",';
}
@@ -566,7 +570,7 @@ class statistik extends basis_db
}
else
{
$this->error_msg= 'Zu dieser Statistik gibt es keine SQL Abfrage';
$this->errormsg= 'Zu dieser Statistik gibt es keine SQL Abfrage';
return false;
}
}
@@ -582,6 +586,21 @@ class statistik extends basis_db
return $this->csv;
}
function writeCSV($filename, $delimiter=',', $enclosure='"')
{
$fh=fopen($filename,'w');
$fieldnames=array();
for ($i=0; $i < $this->db_num_fields($this->data); $i++)
$fieldnames[]=$this->db_field_name($this->data,$i);
fputcsv($fh, $fieldnames, $delimiter, $enclosure);
$this->db_result_seek($this->data,0);
while ($row = $this->db_fetch_row($this->data))
fputcsv($fh, $row, $delimiter, $enclosure);
fclose($fh);
return true;
}
function getJSON()
{
return json_encode($this->json);
+25
View File
@@ -230,6 +230,31 @@ class studiengang extends basis_db
return true;
}
/**
* Gibt alle Studiengaenge zurueck, fuer die man sich online bewerben kann
* @return boolean
*/
public function getAllForBewerbung()
{
$qry = 'SELECT DISTINCT studiengang_kz, typ, organisationseinheittyp_kurzbz, studiengangbezeichnung '
. 'FROM lehre.vw_studienplan '
. 'WHERE onlinebewerbung IS TRUE '
. 'ORDER BY studiengangbezeichnung ASC';
if(!$result = $this->db_query($qry))
{
$this->errormsg = 'Datensatz konnte nicht geladen werden';
return false;
}
while($row = $this->db_fetch_object($result))
{
$this->result[] = $row;
}
return true;
}
/**
* Laedt alle Studientypen in das Attribut studiengang_typ_array