/var/www/scf/core/application/init/Database/SleekDB.php
<?php
namespace Sucurema\Core;
require_once __DIR__ . '/traits/helpers.php';
require_once __DIR__ . '/traits/conditions.php';
require_once __DIR__ . '/traits/caching.php';
class SleekDB
{
use \HelpersTrait, \ConditionsTrait, \CacheTraits;
// Initialize the database.
function __construct($dataDir = '', $configurations = false)
{
// Define the root path of SleekDB.
$this->root = __DIR__;
if ($configurations === false) {
$configurations = [];
}
// Add data dir.
$configurations['data_directory'] = $dataDir;
// Initialize SleekDB
$this->init($configurations);
}
// Initialize the store.
public static function store($storeName = false, $dataDir = "/", $options = false)
{
if (!$storeName or empty($storeName)) throw new \Exception('Store name was not valid');
$_dbInstance = new \Sucurema\Core\SleekDB($dataDir, $options);
$_dbInstance->storeName = $storeName;
// Boot store.
$_dbInstance->bootStore();
// Initialize variables for the store.
$_dbInstance->initVariables();
return $_dbInstance;
Arguments
"Creation of dynamic property Sucurema\Core\SleekDB::$root is deprecated"
/var/www/scf/core/application/init/Database/SleekDB.php
<?php
namespace Sucurema\Core;
require_once __DIR__ . '/traits/helpers.php';
require_once __DIR__ . '/traits/conditions.php';
require_once __DIR__ . '/traits/caching.php';
class SleekDB
{
use \HelpersTrait, \ConditionsTrait, \CacheTraits;
// Initialize the database.
function __construct($dataDir = '', $configurations = false)
{
// Define the root path of SleekDB.
$this->root = __DIR__;
if ($configurations === false) {
$configurations = [];
}
// Add data dir.
$configurations['data_directory'] = $dataDir;
// Initialize SleekDB
$this->init($configurations);
}
// Initialize the store.
public static function store($storeName = false, $dataDir = "/", $options = false)
{
if (!$storeName or empty($storeName)) throw new \Exception('Store name was not valid');
$_dbInstance = new \Sucurema\Core\SleekDB($dataDir, $options);
$_dbInstance->storeName = $storeName;
// Boot store.
$_dbInstance->bootStore();
// Initialize variables for the store.
$_dbInstance->initVariables();
return $_dbInstance;
/var/www/scf/core/application/init/Database/SleekDB.php
function __construct($dataDir = '', $configurations = false)
{
// Define the root path of SleekDB.
$this->root = __DIR__;
if ($configurations === false) {
$configurations = [];
}
// Add data dir.
$configurations['data_directory'] = $dataDir;
// Initialize SleekDB
$this->init($configurations);
}
// Initialize the store.
public static function store($storeName = false, $dataDir = "/", $options = false)
{
if (!$storeName or empty($storeName)) throw new \Exception('Store name was not valid');
$_dbInstance = new \Sucurema\Core\SleekDB($dataDir, $options);
$_dbInstance->storeName = $storeName;
// Boot store.
$_dbInstance->bootStore();
// Initialize variables for the store.
$_dbInstance->initVariables();
return $_dbInstance;
}
// Read store objects.
public function fetch()
{
$fetchedData = null;
// Check if data should be provided from the cache.
if ($this->makeCache === true) {
$fetchedData = $this->reGenerateCache(); // Re-generate cache.
} else if ($this->useCache === true) {
$fetchedData = $this->useExistingCache(); // Use existing cache else re-generate.
} else {
$fetchedData = $this->findStoreDocuments(); // Returns data without looking for cached data.
}
/var/www/scf/core/application/init/Controller/SleekBC.php
public function __construct($storageName)
{
$this->storageName = $storageName;
$this->getStore();
}
/**
* open Store for Work
*
* @param [type] $self
* @param string $objectCode
* @return SleekDB
* @throws \Exception
*/
public function _getStore($self)
{
if ($self->store == null) {
$dataDir = get_include_path() . self::STORAGE_PATH;
$self->store = \SucSleekDB::store(
$self->storageName,
$dataDir
);
}
}
}
/var/www/scf/core/application/init/ATraits/Facade.php
trait Facade
{
/**
* our caller to access static classes
* @param $name
* @param $arguments
* @return mixed
* @throws \Exception
*/
public function __call($name, $arguments)
{
if (!method_exists(__CLASS__, "_" . $name) && !method_exists(get_called_class(), "_" . $name)) {
throw new \Exception('Unknown class method: ' . $name);
}
array_unshift($arguments, $this);
return $this->{"_" . $name}(...$arguments);
}
/**
* our caller to access static classes
* @param $name
* @param $arguments
* @return mixed
* @throws \Exception
*/
public static function __callStatic($name, $arguments)
{
if (!method_exists(__CLASS__, "_" . $name) && !method_exists(get_called_class(), "_" . $name)) {
throw new \Exception('Unknown class method: ' . $name);
}
$class = get_called_class();
$self = new $class();
array_unshift($arguments, $self);
return $self->{"_" . $name}(...$arguments);
}
/var/www/scf/core/application/init/Controller/SleekBC.php
use Sucurema\Core\Traits\Facade as Facade;
use Sucurema\Core\Traits\SleekHandler;
class SleekBC
{
const STORAGE_PATH = "/core/storage/sucurema/";
use Facade;
use SleekHandler;
private $store;
public $storageName = null;
private $result = [];
public function __construct($storageName)
{
$this->storageName = $storageName;
$this->getStore();
}
/**
* open Store for Work
*
* @param [type] $self
* @param string $objectCode
* @return SleekDB
* @throws \Exception
*/
public function _getStore($self)
{
if ($self->store == null) {
$dataDir = get_include_path() . self::STORAGE_PATH;
$self->store = \SucSleekDB::store(
$self->storageName,
$dataDir
);
}
/var/www/scf/core/application/init/Config/Config.php
return static::$sleekCache[$option];
}
if (!isset($GLOBALS[$option])) {
return $defaultValue;
}
return $GLOBALS[$option];
}
public static function Put(string $option, $value)
{
$GLOBALS[$option] = $value;
static::$sleekCache[$option] = $value;
return true;
}
public static function initConfigSleek() {
$bc = new \Sucurema\Core\SleekBC("succonfig");
$elements = $bc->byArray([0 => ["param" => "_id", "condition" => "=", "value" => 1]])->find()->all();
if (is_array($elements)) {
foreach ($elements as $element) {
foreach ($element as $name => $entity) {
if (isset($entity['value'])) {
static::$sleekCache[$name] = $entity['value'];
}
}
}
}
}
public static function getSleekConfigValue(string $key)
{
$bc = new \Sucurema\Core\SleekBC("succonfig");
$values = $bc->byArray([0 => ["param" => "_id", "condition" => "=", "value" => 1]])->find()->first();
if ($values == null) {
return "configEmpty";
} else {
/var/www/scf/core/application/init/Config/Config.php
public static function IsTrue(string $option)
{
if (!isset($GLOBALS[$option])) {
return false;
}
if ($GLOBALS[$option] == 1 || $GLOBALS[$option] == true) {
return true;
}
return false;
}
public static function Get(string $option, $defaultValue = null)
{
// init the store, get all data - ONCE
if (count(static::$sleekCache) <= 0) {
static::initConfigSleek();
}
// sleek config always wins
if (isset(static::$sleekCache[$option])) {
return static::$sleekCache[$option];
}
if (!isset($GLOBALS[$option])) {
return $defaultValue;
}
return $GLOBALS[$option];
}
public static function Put(string $option, $value)
{
$GLOBALS[$option] = $value;
static::$sleekCache[$option] = $value;
return true;
}
/var/www/scf/core/application/init/log_utilities.php
function log_info($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::VERBOSE, $component, $function, $message, $persistent);
}
function log_infomessage($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::MESSAGE, $component, $function, $message, $persistent);
}
function log_warning($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::WARNING, $component, $function, $message, $persistent);
}
function log_message($logLevel, $component, $function, $message, $persistent = false)
{
if ($persistent || \SucConfig::Get("FULL_PERSISTENT_ERRORLOG", false)) {
$persistent = true;
}
\SucSyslog::writeLog($logLevel, $component, $function, $message, $persistent);
// \SucSyslog::writeLog($logLevel, $component, $function, $message, $persistent);
if (\SucConfig::Get('FORCE_OLD_DEBUG_MODE', false) && ($GLOBALS['DEBUG_MODE'] || $logLevel === \SucSyslog::CRITICAL)) {
$type = 'Error';
if ($logLevel !== \SucSyslog::CRITICAL) {
$type = 'Info';
}
$component = str_replace('"', '""', $component);
$function = str_replace('"', '""', $function);
$message = str_replace('"', '""', $message);
$user_id = issetor($_SESSION['userId']);
/var/www/scf/core/application/init/log_utilities.php
{
$date = date($GLOBALS['SQL_DATE_FORMAT']);
$log_file = ($GLOBALS["LOG_DIR"] != "") ? fopen($GLOBALS["LOG_DIR"] . '/' . $date . '_trace.log.txt', "a") : fopen($_SERVER['DOCUMENT_ROOT'] . 'logs/' . $date . '_trace.log.txt', "a");
fwrite($log_file, $message . "\n");
fclose($log_file);
}
function issetor(&$variable, $or = NULL)
{
return $variable === NULL ? $or : $variable;
}
function log_error($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::CRITICAL, $component, $function, $message, $persistent);
}
function log_info($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::VERBOSE, $component, $function, $message, $persistent);
}
function log_infomessage($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::MESSAGE, $component, $function, $message, $persistent);
}
function log_warning($component, $function, $message, $persistent = false)
{
log_message(\SucSyslog::WARNING, $component, $function, $message, $persistent);
}
function log_message($logLevel, $component, $function, $message, $persistent = false)
{
if ($persistent || \SucConfig::Get("FULL_PERSISTENT_ERRORLOG", false)) {
$persistent = true;
}
\SucSyslog::writeLog($logLevel, $component, $function, $message, $persistent);
/var/www/scf/core/application/init/Database/Facade/pdofacade.class.php
}
}
private function bind($stmt, $args)
{
#bind args to query
if ($args != null) {
$this->bind = $args;
foreach ($args as $name => $value) {
$stmt->bindValue($name, $value);
}
}
}
public function fetch($query, $args = null, $log = true, $byLine = false)
{
assertNotNull($query);
if ($log) {
log_info('PDOFacade', 'fetch', 'call query: ' . $query . $this->keyValueToString($this->lastBind));
}
$this->last_error = "";
$stmt = $this->pdo->prepare($query);
if ($args != null) {
$this->bind($stmt, $args);
}
return $this->executePreparedStatement($stmt, true, $log, $byLine);
}
private function keyValueToString($args)
{
if ($args == null || !is_array($args)) {
return "";
}
/var/www/scf/core/application/application.class.php
public function getSecurityAdapter()
{
return $this->sa;
}
public function initialize()
{
$this->sa = null;
$tableExists = "";
if ($GLOBALS['application']->DB_DRIVER == 'mysql') {
// MySQL
$tableExists = "SHOW TABLES LIKE 'icrm_useractivities';";
} else {
// ORACLE, ...
$tableExists = "SELECT table_name as \"name\" FROM all_tables WHERE table_name LIKE 'ICRM_USERACTIVITIES'";
}
$res = $this->dbh->fetch($tableExists);
$this->tableUAExists = is_array($res) && count($res) > 0;
switch ($GLOBALS['AUTH_MODE']) {
case 'DB':
$this->sa = new SecurityAdapterDB();
break;
case 'LDAP':
$this->sa = new SecurityAdapterLDAP();
break;
case 'Custom':
$this->sa = new SecurityAdapterCustom();
break;
}
$requestHeaders = apache_request_headers_auth();
$authorizationHeader = null;
if (isset($requestHeaders['Authorization'])) {
$authorizationHeader = $requestHeaders['Authorization'];
// we may want to forcefully disable the auth header
/var/www/scf/core/application/auth/auth_header.php
if ( !isset($_SESSION['ADMINSETTINGS_BUSINESSYEAR']) ) {
$_SESSION['ADMINSETTINGS_BUSINESSYEAR'] = 1;
}
include 'core/bc/buscomp.class.php';
include 'core/ic/csvintcomp.class.php';
include 'core/applets/applet.class.php';
include 'core/toolbars/toolbar.class.php';
include 'core/drilldowns/drilldown.class.php';
include 'core/modules/logon/auth/verification.php';
include 'core/modules/logon/bc/applicationuserbuscomp.class.php';
include 'core/application/application.class.php';
// once the whole thing is setup we don't need to run it;
$GLOBALS['initDone'] = true;
#Create Application context
$application = new Application();
if ($application->initialize() == false) {
$GLOBALS["USE_CMS"] = true;
}
}
?>
/var/www/scf/index.php
<?php
//$page_title = $GLOBALS["APP_TITLE"] . "";
ini_set('memory_limit', '512M');
date_default_timezone_set('Europe/Berlin');
$START_LANG = "ENU";
#Authentification/Login and open main view block
include "config/includepath.php";
include 'core/application/auth/auth_header.php';
//if(isset($_SESSION["isLogged"]) && $_SESSION["isLogged"]) {
#Check permissions
//include 'modules/logon/auth/verification.php';
//header ("Location: /modules/dashboard/views/dashboardview.php");
// exit();
//}
#Close main view block
//include "core/application/auth/auth_footer.php";
?>
Arguments
"/var/www/scf/core/application/auth/auth_header.php"