Conflicts:
	application/core/FHC_Controller.php
This commit is contained in:
root
2016-06-21 16:31:06 +02:00
25 changed files with 798 additions and 265 deletions
+3 -3
View File
@@ -2,11 +2,11 @@
class DB_Model extends FHC_Model
{
protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ...
protected $pk; // Name of the PrimaryKey for DB-Update, Load, ...
protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ...
protected $pk; // Name of the PrimaryKey for DB-Update, Load, ...
protected $hasSequence; // False if this table has a composite primary key that is not using a sequence
// True if this table has a primary key that uses a sequence
protected $acl; // Name of the PrimaryKey for DB-Update, Load, ...
protected $acl; // Name of the PrimaryKey for DB-Update, Load, ...
function __construct($dbTable = null, $pk = null, $hasSequence = true)
{
+13 -11
View File
@@ -3,21 +3,23 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class FHC_Controller extends CI_Controller
{
public $uid;
function __construct()
protected $_uid; // needs to be changed to protected $_uid
public function __construct()
{
parent::__construct();
$this->load->library('session');
//$this->load->helper('language');
// look if User is logged in and set uid
if (isset($_SERVER['PHP_AUTH_USER']))
$this->uid = $_SERVER['PHP_AUTH_USER'];
if (isset($_SESSION['uid']))
$this->uid = $_SESSION['uid'];
$this->session->set_userdata('uid', 'pam');
$this->load->helper('fhcauth');
$this->_uid = getAuthUID();
}
public function getUID()
{
if (empty($this->_uid))
return false;
else
return $this->_uid;
}
}
+11 -1
View File
@@ -40,6 +40,16 @@ class FHC_Model extends CI_Model
{
return $this->fhc_db_acl->setUID($uid);
}
/** ---------------------------------------------------------------
* get UID
*
* @return string or (bool)false
*/
public function getUID()
{
return $this->fhc_db_acl->getUID();
}
/** ---------------------------------------------------------------
* Success
@@ -61,4 +71,4 @@ class FHC_Model extends CI_Model
{
return error($retval, $message);
}
}
}
+170
View File
@@ -0,0 +1,170 @@
<?php
class FS_Model extends FHC_Model
{
protected $filepath; // Path of the file
protected $acl; // Name of the permissions array index for FS writing, reading...
function __construct($filepath = null)
{
parent::__construct();
$this->load->library('FilesystemLib');
$this->acl = $this->config->item('fhc_acl');
$this->filepath = $filepath;
}
/** ---------------------------------------------------------------
* Read data from file system
*
* @return array
*/
public function read($filename)
{
// Check Class-Attributes
if (is_null($this->filepath))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check method parameters
if (is_null($filename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR);
if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename)))
{
return $this->_success(base64_encode($data));
}
else
{
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
}
}
/** ---------------------------------------------------------------
* Writing data to file system
*
* @param string $fileContent File content
* @return object
*/
public function write($filename, $content)
{
// Check Class-Attributes
if (is_null($this->filepath))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check method parameters
if (is_null($filename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
if (is_null($content))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'i'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR);
if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true)
{
return $this->_success(FHC_SUCCESS);
}
else
{
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
}
}
/** ---------------------------------------------------------------
* Append data to a file
*
* @param array $data File content
* @return array
*/
public function append($filename, $content)
{
// Check Class-Attributes
if (is_null($this->filepath))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check method parameters
if (is_null($filename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
if (is_null($content))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'i'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR);
if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true)
{
return $this->_success(FHC_SUCCESS);
}
else
{
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
}
}
/** ---------------------------------------------------------------
* Delete data from file system
*
* @param string $id Primary Key for DELETE
* @return array
*/
public function remove($filename)
{
// Check Class-Attributes
if (is_null($this->filepath))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check method parameters
if (is_null($filename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'd'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR);
if ($this->filesystemlib->remove($this->filepath, $filename) === true)
{
return $this->_success(FHC_SUCCESS);
}
else
{
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
}
}
/** ---------------------------------------------------------------
* Rename a file
*
* @param string $id Primary Key for DELETE
* @return array
*/
public function rename($filename, $newFilename)
{
// Check Class-Attributes
if (is_null($this->filepath))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check method parameters
if (is_null($filename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
if (is_null($newFilename))
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'u'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR);
if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true)
{
return $this->_success(FHC_SUCCESS);
}
else
{
return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR);
}
}
}