Skip to content

Commit

Permalink
File name fixed for few libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
nasirbest committed Dec 12, 2016
1 parent 1b0a751 commit d310cde
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 42 deletions.
2 changes: 1 addition & 1 deletion bin/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// default include is /usr/ictcore/core
chdir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core');

include_once "core.php";
include_once "Core.php";

function cron_process()
{
Expand Down
2 changes: 1 addition & 1 deletion bin/sendmail/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// remove sendmail and bin parent by .. / ..
chdir(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'core');
include_once "core.php";
include_once "Core.php";

$host = Conf::get('sample_provider:user', 'localhost');
$port = Conf::get('sample_provider:port', '933');
Expand Down
4 changes: 1 addition & 3 deletions bin/tiff2jpg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Mail : [email protected] *
* *************************************************************** */

use ICT\Core\Corelog;

$filename = $_GET["name"];
$path = "file/document/";
$pathThumbs = $path . "thumbs/";
Expand All @@ -29,5 +27,5 @@
$images->clear();
$images->destroy();
} catch (Exception $e) {
Corelog::log($e->getMessage(), Corelog::ERROR);
echo $e->getMessage();
}
File renamed without changes.
7 changes: 6 additions & 1 deletion core/lib/conf.php → core/lib/Conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function set($name, $value)
}
}

protected static function load($configuration = array())
public static function load ($config_id)
{
Corelog::log("Demo, loading configuration for $config_id");
}

protected static function merge($configuration = array())
{
foreach ($configuration as $class => $config) {
foreach ($config as $name => $data) {
Expand Down
26 changes: 14 additions & 12 deletions core/lib/Conf/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@
* Mail : [email protected] *
* *************************************************************** */

use Exception;
use ICT\Core\Conf;
use ICT\Core\CoreException;
use ICT\Core\Corelog;

class Conffile extends Conf
/*
* NOTE: no log in following file, cos this file will be executed before log setup
*/

class File extends Conf
{

public static function load($file_path)
public static $config_file = '/etc/ictcore.conf';

public static function load($file_path = NULL)
{
global $path_etc;
$configSource = is_file($file_path) ? $file_path : self::$config_file;

//reading configuration file.
//in success result is $ict_conf array.
$configSource = is_file($file_path) ? $file_path : $path_etc . '/ictcore.conf';

if (is_file($configSource)) {
$configuration = parse_ini_file($configSource, TRUE);
Corelog::log("configuration file loaded", Corelog::DEBUG, $configuration);
if (!is_array($configuration)) {
throw new CoreException('500', "Bad configuration file: $configSource");
throw new Exception("Bad configuration file: $configSource", '500');
}
} else {
throw new CoreException('500', "No configuration file found: $configSource");
throw new Exception("No configuration file found: $configSource", '500');
}

parent::load($configuration);
self::$config_file = $configSource;
parent::merge($configuration);
}

}
11 changes: 7 additions & 4 deletions core/lib/Conf/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
class System extends Conf
{

public static function load($node_id = null, $type = null)
public static $node_id = NULL;

public static function load($node_id = null)
{
$filter = array();
if (empty($node_id)) {
$node_id = self::get('node:node_id', null);
}
Corelog::log("configuration requested for node: $node_id, type: $type", Corelog::DEBUG);
Corelog::log("configuration requested for node: $node_id", Corelog::DEBUG);

$filter[] = '(c.permission_flag & ' . Conf::PERMISSION_GLOBAL_READ . ')=' . Conf::PERMISSION_GLOBAL_READ;
$filter[] = 'cd.class=' . Conf::SYSTEM;
Expand All @@ -31,8 +33,9 @@ public static function load($node_id = null, $type = null)
$filter[] = "cd.node_id=" . Conf::NODE_ALL;
}

$configuration = self::database_conf_get($filter, $type);
parent::load($configuration);
$configuration = self::database_conf_get($filter);
self::$node_id = $node_id;
parent::merge($configuration);
}

}
11 changes: 7 additions & 4 deletions core/lib/Conf/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
class User extends Conf
{

public static function load($user_id = null, $type = null)
public static $user_id = NULL;

public static function load($user_id = NULL)
{
$filter = array();
if (empty($user_id)) {
$user_id = Session::get('user:user_id', null);
}
Corelog::log("configuration requested for user: $user_id, type: $type", Corelog::DEBUG);
Corelog::log("configuration requested for user: $user_id", Corelog::DEBUG);

$filter[] = '(c.permission_flag & ' . Conf::PERMISSION_USER_WRITE . ')=' . Conf::PERMISSION_USER_WRITE;
$filter[] = 'cd.class=' . Conf::USER;
Expand All @@ -32,8 +34,9 @@ public static function load($user_id = null, $type = null)
return false; // can do nothing
}

$configuration = self::database_conf_get($filter, $type);
parent::load($configuration);
$configuration = self::database_conf_get($filter);
self::$user_id = $user_id;
parent::merge($configuration);
}

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions core/lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Mail : [email protected] *
* *************************************************************** */

use ICT\Core\Conf\File as ConfFile;
use ICT\Core\Conf\System as SystemConfiguration;

global $path_lib, $path_core, $path_root, $path_www, $path_etc, $path_log, $path_data, $website_log;

// following lines will allow to include files from both core and lib directories
Expand All @@ -26,18 +29,15 @@
// For Classes
$loader = require dirname($path_core) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

/* Include all required libraries
These library will responsible to provide commonly requrired functions
/* Include required libraries
These library will be responsible to provide commonly requrired functions
*/
include_once "common.php"; // common functions
include_once "Corelog.php"; // library for logging (order is important)
include_once "conf.php"; // library for gui / framework configuration
include_once "config.php"; // library for gateway / backend configuration
include_once "db.php"; // library for database management
include_once "session.php"; // library for session management
include_once "CoreException.php"; // library for error
// include_once "CoreThread.php"; // Multi Threading support for selected functions

// Read database and other basic configuration from configuration file
ConfFile::load('/etc/ictcore.conf');

// Corelog will be our default error handler
set_error_handler(array('ICT\\Core\\Corelog', 'error_handler'), E_ALL);

$website_host = Conf::get('website:host', '127.0.0.1');
Expand All @@ -50,7 +50,7 @@
date_default_timezone_set('UTC'); // required to bypass server timezone settings

/* Connecting, selecting database */
$ict_db_link = DB::connect();
DB::connect();

/* load default system configuration from database */
conf_system_load();
SystemConfiguration::load();
2 changes: 1 addition & 1 deletion docs/developer-guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ common
Common code / functions ( not related to telecommunication ) which are required to perform basic system and OS related activities.

* Token : to change communication parameters dynamically with variable support
* core.php : main include file, with common ict related functions
* Core.php : main include file, with common ict related functions
* lib : Common programming functions like database, configuration etc ..


Expand Down
3 changes: 1 addition & 2 deletions wwwroot/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
// default include is /usr/ictcore/core
chdir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core');

include_once "core.php";
include_once "lib/http.php";
include_once "Core.php";

try {
if (http_authenticate() != true) {
Expand Down
3 changes: 1 addition & 2 deletions wwwroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
chdir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core');

// Include the framework
include_once "core.php";
include_once "Api.php";
include_once "Core.php";

// **************************************************** PREPARE SYSTEM
$oApi = new Api();
Expand Down

0 comments on commit d310cde

Please sign in to comment.