Esempio n. 1
0
 /**
  * Escrever log
  * 
  * @return void
  */
 public function escrever($mensagem)
 {
     $data = date('d/m/Y H:i:s');
     $mensagem = "[ {$data} ] {$mensagem}" . PHP_EOL;
     $arquivo = Config::get('log.path');
     # Capitulo 2 - Laboratorio 2
 }
Esempio n. 2
0
 public function __CONSTRUCT($con_name = null)
 {
     if (empty($con_name)) {
         $con_name = self::$con_name;
     }
     $this->config = \Lib\Config::load('Redis')->{$con_name};
     $this->connect($this->config['host'], $this->config['port']);
 }
Esempio n. 3
0
 /**
  * Escrever log
  * 
  * @return void
  */
 public function escrever($mensagem)
 {
     $data = date('d/m/Y H:i:s');
     $mensagem = "[ {$data} ] {$mensagem}" . PHP_EOL;
     $arquivo = Config::get('log.path');
     # Capitulo 2 - Laboratorio 2
     file_put_contents($arquivo, $mensagem, FILE_APPEND);
 }
Esempio n. 4
0
 public function testIndexAuthenticated()
 {
     // We disable the Authentication
     Config::write('auth_required', false);
     $this->get('/');
     $this->assertEquals('302', $this->response->status());
     $this->assertEquals('/listing', $this->response['Location']);
 }
Esempio n. 5
0
 private function __construct()
 {
     // building data source name from config
     $dsn = 'mysql:host=' . Config::read('db.host') . ';dbname=' . Config::read('db.basename') . ';port=' . Config::read('db.port') . ';connect_timeout=15';
     // getting DB user from config
     $user = Config::read('db.user');
     // getting DB password from config
     $password = Config::read('db.password');
     $this->dbh = new PDO($dsn, $user, $password);
 }
Esempio n. 6
0
 private function __construct()
 {
     // building data source name from config
     $dsn = 'mysql:host=' . Config::read('db.host') . ';dbname=' . Config::read('db.basename') . ';charset=' . Config::read("db.charset");
     // getting DB user from config
     $user = Config::read('db.user');
     // getting DB password from config
     $password = Config::read('db.password');
     $this->dbh = new PDO($dsn, $user, $password);
     $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 }
Esempio n. 7
0
 /**
  * コンストラクタ
  * 設定ファイルはrootに配置されているconfig.php
  */
 private function __construct()
 {
     // building data source name from config
     $dsn = 'mysql:host=' . Config::read('db.host') . ';dbname=' . Config::read('db.basename') . ';port=' . Config::read('db.port') . ';connect_timeout=15';
     // getting DB user from config
     $user = Config::read('db.user');
     // getting DB password from config
     $password = Config::read('db.password');
     $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . Config::read('db.encode'));
     $this->dbh = new PDO($dsn, $user, $password, $options);
 }
Esempio n. 8
0
 /**
  * Constructor
  */
 private function __construct()
 {
     $dbConfig = Config::readFromAlias('db');
     if (!$dbConfig) {
         throw new \Exception('DB config not found!');
     }
     $dsnParams = array_intersect_key($dbConfig['mysql']['connect'], array_flip($this->getDSNAvailableParams()));
     $dsn = sprintf('mysql:%s', http_build_query($dsnParams, null, ';'));
     try {
         $this->dbh = new PDO($dsn, $dbConfig['mysql']['connect']['user'], $dbConfig['mysql']['connect']['password']);
     } catch (\Exception $e) {
         reconstructionPage();
     }
 }
Esempio n. 9
0
	public function viewCreate($params)
	{

		$strings = Config::load('guildTranslations', 'translations/guild');
		foreach ($strings as $key => $str) {
			Request::getInstance()->setParam('txt.' . $key, _($str));
		}
		Request::getInstance()->setParam('txt.enter_guild_name', _('alliance.enter_guild_name'));
		Request::getInstance()->setParam('txt.create', _('common.create'));

		$params['isLocked'] = getHero()->getLevel() < 15 ? true : false;

		return $params;
	}
Esempio n. 10
0
 public static function isInactive()
 {
     @session_start();
     $current_time = strtotime('now');
     if (!isset($_SESSION[self::$session_inactive])) {
         $_SESSION[self::$session_inactive] = $current_time;
     } else {
         if (strtotime('now') - $_SESSION[self::$session_inactive] > self::$inactive_length && self::isLogged()) {
             self::logout();
             header('Location:' . Config::getConfig(Config::$base));
         } else {
             $_SESSION[self::$session_inactive] = $current_time;
         }
     }
 }
 public function request($method, $path, $options = array())
 {
     // Capture STDOUT
     ob_start();
     // Prepare a mock environment
     \Slim\Environment::mock(array_merge(array('REQUEST_METHOD' => $method, 'SERVER_PORT' => Config::read('port_project'), 'PATH_INFO' => $path, 'SERVER_NAME' => 'http://localhost:9076'), $options));
     // Run the application
     require __DIR__ . '/../../www/bootstrap.php';
     $this->app = $app;
     $this->request = $app->request();
     $this->response = $app->response();
     // We fire the routes
     $this->app->run();
     // Return STDOUT
     return ob_get_clean();
 }
Esempio n. 12
0
 /**
  * Carregar View
  * 
  * @param string $tipo
  * @param string $arquivo
  * @param stdClass|array $dados
  * 
  * @return void
  * 
  * @throws \Exception
  */
 public static function carregar($tipo, $arquivo, $dados = array())
 {
     # Carregando items do menu
     $obj_Menus = new Menus();
     $items_menu = $obj_Menus->retornarItens($tipo);
     # Recuperando configuracao relacionada ao path
     $path = Config::get('path');
     # verificando se view existe
     if (file_exists(__DIR__ . "/../../templates/{$tipo}/{$arquivo}.tpl.php")) {
         # inclusao arquivo cabecalho.tpl.php
         require __DIR__ . "/../../templates/{$tipo}/_cabecalho.tpl.php";
         require __DIR__ . "/../../templates/{$tipo}/{$arquivo}.tpl.php";
         # inclusao arquivo cabecalho.tpl.php
         require __DIR__ . "/../../templates/{$tipo}/_rodape.tpl.php";
     } else {
         throw new \Exception("View nao encontrada!");
     }
 }
Esempio n. 13
0
 /**
  * Cria objeto da classe PDO (cria conexao com o banco)
  * 
  * @return void
  */
 private function conectar()
 {
     switch (Config::get('pdo.driver')) {
         case 'sqlite':
             $dsn = Config::get('pdo.driver') . ':' . Config::get('pdo.path');
             $user = null;
             $pass = null;
             break;
         default:
             $dsn = Config::get('pdo.driver') . ':host=' . Config::get('pdo.host') . ';dbname=' . Config::get('pdo.dbname');
             $user = Config::get('pdo.user');
             $pass = Config::get('pdo.pass');
     }
     // Cria objeto da classe PDO
     $this->obj_PDO = new \PDO($dsn, $user, $pass);
     // Determinando a forma padrao de tratamento de erros
     $this->obj_PDO->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     // Determinando a forma padrao de retorno de dados SELECT
     $this->obj_PDO->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
     $this->escrever('Conectado ao banco \'' . Config::get('pdo.driver') . '\'');
 }
Esempio n. 14
0
 /**
  * Make connection to the database.
  */
 public static function init()
 {
     $host = Config::getConfig(Config::$host);
     $port = Config::getConfig(Config::$port);
     $dbName = Config::getConfig(Config::$databaseName);
     $user = Config::getConfig(Config::$user);
     $password = Config::getConfig(Config::$password);
     $file = Config::getConfig(Config::$file);
     if ('' == $host) {
         throw new AriesException('Your host config is null.');
     } else {
         if ('' == $port) {
             throw new AriesException('Your port config is null.');
         } else {
             if ('' == $dbName) {
                 throw new AriesException('Your dbName config is null.');
             } else {
                 if ('' == $user) {
                     throw new AriesException('Your user config is null.');
                 }
             }
         }
     }
     if (Config::getConfig(Config::$driver) == Config::$mysql) {
         self::$db = new \PDO("mysql:host={$host};port={$port};dbname={$dbName}", $user, $password);
     } else {
         if (Config::getConfig(Config::$driver) == Config::$postgree) {
             self::$db = new \PDO("pgsql:host={$host};port={$port};dbname={$dbName}", $user, $password);
         } else {
             if (Config::getConfig(Config::$driver) == Config::$sqlite) {
                 if ('' == $file) {
                     throw new AriesException('Your file config is null.');
                 }
                 self::$db = new \PDO("sqlite:{$file}", $user, $password);
             }
         }
     }
 }
Esempio n. 15
0
<?php

use lib\Config;
// DB Config
Config::write('db.host', 'localhost');
Config::write('db.port', '');
Config::write('db.basename', 'events');
Config::write('db.user', 'root');
Config::write('db.password', '');
// Project Config
Config::write('path', 'http://localhost/slimMVC');
<?php

use lib\Config;
use Illuminate\Database\Capsule\Manager as DB;
// /render/:id controller
// Render a form
// When accessing /render/:id via GET,
// the form will be rendered
$app->get('/render/:id', function ($id) use($app) {
    $c = array();
    // We grab the form
    $form = models\Form::find($id);
    // We grab its fields
    $fields = $form->fields;
    // Base path
    $c['base_path'] = Config::read('base_path');
    $c['form'] = $form;
    $c['fields'] = $fields;
    $app->render('pages/render.html', $c);
})->name('render');
Esempio n. 17
0
<?php

use lib\Config;
// Configurações do Banco de Dados POSTGRESQL
Config::write('db.host', 'localhost');
Config::write('db.port', '5432');
Config::write('db.basename', 'mapa_alerta2');
Config::write('db.user', 'postgres');
Config::write('db.password', 'root');
// Endereço Publico do Projeto
Config::write('path', 'http://' . $_SERVER['HTTP_HOST'] . '/MapaAlerta/public');
Esempio n. 18
0
<?php

use lib\Config;
// Configurações do Banco de Dados POSTGRESQL
Config::write('db.host', 'localhost');
Config::write('db.port', '5432');
Config::write('db.basename', 'sca');
Config::write('db.user', 'postgres');
Config::write('db.password', 'root');
// Endereço Publico do Projeto
Config::write('path', 'http://localhost/SCA/public');
// Salt de Criptografia
Config::write('salt', 'Ep&JulgcTb)l(#Hta821m#teChPX6z(E');
Esempio n. 19
0
<?php

use Lib\Config;
// Inclusao do arquivo de bootstrap
require __DIR__ . '/bootstrap.php';
if ($_GET) {
    if (isset($_GET['modulo'])) {
        $modulo = "Model\\{$_GET['modulo']}";
        $objeto = new $modulo();
        $servidor_soap = new SoapServer(Config::get('path') . "wsdl/{$_GET['modulo']}.wsdl");
        $servidor_soap->setObject($objeto);
        $servidor_soap->handle();
    }
}
Esempio n. 20
0
if (Config::getPlugins('css') == 'lessCSS') {
    $lessFile = glob('public/less/*.less');
    if (sizeof($lessFile) > 0) {
        $less = new lessc();
        foreach ($lessFile as $value) {
            $filenames = explode('/', $value);
            $filename = $filenames[2];
            $less->checkedCompile($value, strstr($value, '/', true) . '/css/' . substr($filename, 0, strpos($filename, '.')) . '.css');
        }
    }
}
//Call caches header
if (Config::getConfig(Config::$cache) == 'true') {
    $router->headerCache();
}
AR_Config::initialize(function ($cfg) {
    $cfg->set_model_directory('app/models');
    $cfg->set_connections(Config::getDatabases());
    $cfg->set_default_connection(Config::getConfig(Config::$default_connection));
});
//Call controller
$router->route();
//Call caches footer
if (Config::getConfig(Config::$cache) == 'true') {
    $router->footerCache();
}
//Stop timer
$time_end = microtime(true);
$time = $time_end - $time_start;
//Comment below to hide timer
//echo 'Web executed in '.$time.' seconds';
Esempio n. 21
0
<?php

use lib\Config;
// DB Config
Config::write('db.host', 'localhost');
Config::write('db.port', '');
Config::write('db.basename', 'buildcorner');
Config::write('db.user', 'root');
Config::write('db.password', '');
// Project Config
Config::write('path', 'http://localhost/buildcorner-api');
Esempio n. 22
0
<?php

use lib\Config;
// DB Config
Config::write('db.host', '127.0.0.1');
Config::write('db.port', '');
Config::write('db.basename', 'api');
Config::write('db.user', 'root');
Config::write('db.password', '');
Config::write('db.encode', 'utf8');
Esempio n. 23
0
            continue;
        }
        // We edit the field
        $contact = models\Contact::find($id_contact);
        $contact->{$column_name} = $var;
        $contact->save();
    }
    $app->redirect($app->urlFor('getFormEdit', array('id' => $id)));
})->name('postFormContactEdit');
// /form/edit/:id/fields controller
// Edit Fields controller
// Name and placeholders for the current fields are updated
// type or number of fields cannot be updated for performance reasons
$app->post('/form/edit/:id/fields', function ($id) use($app) {
    $c = array();
    $allowed_field_names = Config::read('field_form_elements');
    $post_vars = $app->request()->post();
    // We iterate through id
    foreach ($post_vars as $key => $var) {
        // as keys are name_id
        $explode = explode('_', $key);
        $id_field = array_pop($explode);
        // column name can be placeholder or field_name
        $column_name = implode('_', $explode);
        // We try to avoid as possible possible Database mess
        if (!in_array($column_name, $allowed_field_names)) {
            continue;
        }
        // We edit the field
        $field = models\Field::find($id_field);
        $field->{$column_name} = $var;
Esempio n. 24
0
 /**
  * send rally point information by mail
  */
 protected function sendRallyPointMail()
 {
     $recipient = Config::getNotificationMail('RALLY_SET');
     if ($recipient && \Audit::instance()->email($recipient)) {
         $updatedCharacterId = (int) $this->get('updatedCharacterId', true);
         /**
          * @var $character CharacterModel
          */
         $character = $this->rel('updatedCharacterId');
         $character->getById($updatedCharacterId);
         if (!$character->dry()) {
             $body = [];
             $body[] = "Map:\t\t" . $this->mapId->name;
             $body[] = "System:\t\t" . $this->name;
             $body[] = "Region:\t\t" . $this->region;
             $body[] = "Security:\t" . $this->security;
             $body[] = "Character:\t" . $character->name;
             $body[] = "Time:\t\t" . date('g:i a; F j, Y', strtotime($this->rallyUpdated));
             $bodyMsg = implode("\r\n", $body);
             (new MailController())->sendRallyPoint($recipient, $bodyMsg);
         }
     }
 }
Esempio n. 25
0
 /**
  * get environment specific configuration data
  * @param string $key
  * @return string|null
  */
 static function getEnvironmentData($key)
 {
     return Config::getEnvironmentData($key);
 }
Esempio n. 26
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
define('LIB', './lib/');
define('APP', './app/');
if (!function_exists('pr')) {
    function pr($data)
    {
        echo '<pre>';
        print_r($data);
    }
}
ini_set('date.timezone', 'Asia/Shanghai');
require_once LIB . 'Autoloader.php';
\Lib\Autoloader::get();
//配置文件路径设置
\Lib\Config::setConfigNamespace('\\App\\Config');
require_once LIB . 'Dispacher.php';
\Lib\Dispacher::get()->dispach();
//register_shutdown_function(array(\Lib\Shut::instance(), 'shut'));
        // Now we know $key is valid, we can assign it
        // We use a helper to assist us in the different use cases we can
        // encounter where the type of input we want to create gives as the value in a format
        // different than we want to store (e.g. Checkbox gives 'on' and we want to store 1)
        $value_inserted = DbConversor::convert($form_field->getTypeString(), $var);
        $response->{$key} = $value_inserted;
        // We also add it to our parameters array for it to be send to the contact by
        // e-mail
        $parameters['fields'][$key] = $value_inserted;
        // And the field names
        $parameters['field_names'][$key] = $form_field->field_name;
    }
    $response->save();
    // Aaaand, we send emails to all the contacts of that form
    $twig = $app->view()->getEnvironment();
    // twig environment
    $transport = Swift_MailTransport::newInstance();
    // Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);
    $parameters['form'] = $form;
    foreach ($contacts as $contact) {
        // Contact to be accessible from the template
        $parameters['contact'] = $contact;
        $generator = new Email($twig);
        $message = $generator->getMessage(Config::read('email_template'), $parameters);
        $message->setTo($contact->contact_email);
        $message->setFrom(Config::read('email_from'));
        $mailer->send($message);
    }
    $app->redirect($form->redirect);
});
Esempio n. 28
0
 /**
  * Get all required static config data for program initialization
  * @param \Base $f3
  */
 public function init(\Base $f3)
 {
     // expire time in seconds
     $expireTimeHead = 60 * 60 * 12;
     $expireTimeSQL = 60 * 60 * 12;
     $f3->expire($expireTimeHead);
     $return = (object) [];
     $return->error = [];
     // static program data ----------------------------------------------------------------------------------------
     $return->timer = $f3->get('PATHFINDER.TIMER');
     // get all available map types --------------------------------------------------------------------------------
     $mapType = Model\BasicModel::getNew('MapTypeModel');
     $rows = $mapType->find('active = 1', null, $expireTimeSQL);
     $mapTypeData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'label' => $rowData->label, 'class' => $rowData->class, 'classTab' => $rowData->classTab];
         $mapTypeData[$rowData->name] = $data;
     }
     $return->mapTypes = $mapTypeData;
     // get all available map scopes -------------------------------------------------------------------------------
     $mapScope = Model\BasicModel::getNew('MapScopeModel');
     $rows = $mapScope->find('active = 1', null, $expireTimeSQL);
     $mapScopeData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'label' => $rowData->label];
         $mapScopeData[$rowData->name] = $data;
     }
     $return->mapScopes = $mapScopeData;
     // get all available system status ----------------------------------------------------------------------------
     $systemStatus = Model\BasicModel::getNew('SystemStatusModel');
     $rows = $systemStatus->find('active = 1', null, $expireTimeSQL);
     $systemScopeData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'label' => $rowData->label, 'class' => $rowData->class];
         $systemScopeData[$rowData->name] = $data;
     }
     $return->systemStatus = $systemScopeData;
     // get all available system types -----------------------------------------------------------------------------
     $systemType = Model\BasicModel::getNew('SystemTypeModel');
     $rows = $systemType->find('active = 1', null, $expireTimeSQL);
     $systemTypeData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'name' => $rowData->name];
         $systemTypeData[$rowData->name] = $data;
     }
     $return->systemType = $systemTypeData;
     // get available connection scopes ----------------------------------------------------------------------------
     $connectionScope = Model\BasicModel::getNew('ConnectionScopeModel');
     $rows = $connectionScope->find('active = 1', null, $expireTimeSQL);
     $connectionScopeData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'label' => $rowData->label, 'connectorDefinition' => $rowData->connectorDefinition];
         $connectionScopeData[$rowData->name] = $data;
     }
     $return->connectionScopes = $connectionScopeData;
     // get available character status -----------------------------------------------------------------------------
     $characterStatus = Model\BasicModel::getNew('CharacterStatusModel');
     $rows = $characterStatus->find('active = 1', null, $expireTimeSQL);
     $characterStatusData = [];
     foreach ((array) $rows as $rowData) {
         $data = ['id' => $rowData->id, 'name' => $rowData->name, 'class' => $rowData->class];
         $characterStatusData[$rowData->name] = $data;
     }
     $return->characterStatus = $characterStatusData;
     // get max number of shared entities per map ------------------------------------------------------------------
     $maxSharedCount = ['character' => $f3->get('PATHFINDER.MAP.PRIVATE.MAX_SHARED'), 'corporation' => $f3->get('PATHFINDER.MAP.CORPORATION.MAX_SHARED'), 'alliance' => $f3->get('PATHFINDER.MAP.ALLIANCE.MAX_SHARED')];
     $return->maxSharedCount = $maxSharedCount;
     // get program routes -----------------------------------------------------------------------------------------
     $return->routes = ['ssoLogin' => $this->getF3()->alias('sso', ['action' => 'requestAuthorization'])];
     // get notification status ------------------------------------------------------------------------------------
     $return->notificationStatus = ['rallySet' => (bool) Config::getNotificationMail('RALLY_SET')];
     // get SSO error messages that should be shown immediately ----------------------------------------------------
     // -> e.g. errors while character switch from previous HTTP requests
     if ($f3->exists(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR)) {
         $ssoError = (object) [];
         $ssoError->type = 'error';
         $ssoError->title = 'Login failed';
         $ssoError->message = $f3->get(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR);
         $return->error[] = $ssoError;
         $f3->clear(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR);
     }
     echo json_encode($return);
 }
Esempio n. 29
0
 /**
  * Generating js for the header.
  *
  * @return null|string
  */
 public function jsBuilder()
 {
     $js = glob($this->js_folder . '*.js');
     $result = null;
     foreach ($js as $value) {
         $result .= '<script src="' . Config::getConfig(Config::$base) . $value . '" type="text/javascript"></script>';
     }
     return $result;
 }
Esempio n. 30
0
<?php

use lib\Config;
use Illuminate\Database\Capsule\Manager as Capsule;
defined('APP_DEBUG') or define('APP_DEBUG', true);
//defined('APP_DB_DEBUG') or define('APP_DB_DEBUG', false);
//function reconstructionPage() {
//die(require APP_WEB_ROOT_PATH . DIRECTORY_SEPARATOR . 'index.php.temp');
//}
require 'db.php';
// Setup custom Twig view
$twigView = new \Slim\Views\Twig();
Config::$confArray = array('init' => array('debug' => APP_DEBUG, 'view' => $twigView, 'templates.path' => APP_ROOT_PATH . DIRECTORY_SEPARATOR . 'templates', 'mode' => 'production'), 'production' => array('parameters' => array('name' => 'Evgeniy Blinov', 'skype' => 'evgeniy_blinov', 'email' => '*****@*****.**'), 'auth' => array('cookies.secret_key' => '3c44d9aa3d78269adcc417ec67e03c26'), 'db' => array('mysql' => array('connect' => array('host' => 'localhost', 'port' => '3306', 'dbname' => APPLICATION_MYSQL_DB_NAME, 'user' => APPLICATION_MYSQL_USER, 'password' => APPLICATION_MYSQL_PASS, 'charset' => 'utf8')), 'eloquent' => array('default' => array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => APPLICATION_MYSQL_DB_NAME, 'username' => APPLICATION_MYSQL_USER, 'password' => APPLICATION_MYSQL_PASS, 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '')))));
Config::$env = 'production';
/**
 * Configure the database and boot Eloquent
 */
$capsule = new Capsule();
$capsule->addConnection(Config::$confArray[Config::$env]['db']['eloquent']['default']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
date_default_timezone_set('Europe/Moscow');