/** * Constructor that loads chat parameters */ public function __construct() { Ini::setIniFileName(Ini::INI_CONF_FILE); $conf = Ini::getSectionParams('Room service'); $this->serviceName = $conf['serviceName']; $this->chatServiceName = Ini::getParam('Chat service', 'serviceName'); $this->logger = new Logger([Logger::CONSOLE]); }
/** * Constructor that loads chat parameters */ public function __construct() { Ini::setIniFileName(Ini::INI_CONF_FILE); $this->logger = new Logger([Logger::CONSOLE]); $this->esIndex = Ini::getParam('ElasticSearch', 'index'); $conf = Ini::getSectionParams('Chat service'); $this->serviceName = $conf['serviceName']; $this->historicStep = $conf['historicStep']; }
/** * Call the parent constructor, merge the commands list and launch the console */ public function __construct() { parent::__construct(); parent::$COMMANDS = array_merge(parent::$COMMANDS, static::$SELF_COMMANDS); $this->deploymentConfiguration = Ini::getSectionParams('Deployment'); $this->absoluteProjectRootPath = dirname(__FILE__, 5); $this->timeOffset = static::getTimezoneOffset('Greenwich'); static::$PROJECT_MAIN_STRUCTURE[$this->deploymentConfiguration['remoteProjectRootDirectoryName']] = static::$PROJECT_MAIN_STRUCTURE['.']; unset(static::$PROJECT_MAIN_STRUCTURE['.']); static::out(PHP_EOL . 'Absolute project root path is "' . $this->absoluteProjectRootPath . '"' . PHP_EOL); $this->launchConsole(); }
/** * Constructor that loads connection parameters * * @param string[] $parameters OPTIONAL connection parameters * @param bool $verbose OPTIONAL true if output should be print, false if not and null will load the * ini value */ public function __construct(array $parameters = null, bool $verbose = null) { $this->params = $parameters !== null ? $parameters : Ini::getSectionParams('Deployment'); $this->verbose = (int) Ini::getParam('Deployment', 'verbose'); $this->resource = null; }
/** * Utility method to reuse the same PDO instance at each call (work like a Singleton pattern) * * @static */ private static function initialize() { Ini::setIniFileName(Ini::INI_CONF_FILE); if (static::$printSQL === null) { // Load default printSQL value static::$printSQL = Ini::getParam('Console', 'printSql'); } try { if (static::$PDO === null) { if (static::$username !== '' && static::$password !== '') { if (count(static::$options) > 0) { static::$PDO = new \PDO(static::$dsn, static::$username, static::$password, static::$options); } else { static::$PDO = new \PDO(static::$dsn, static::$username, static::$password); } } elseif (static::$dsn !== '') { static::$PDO = new \PDO(static::$dsn); } else { // Load default database parameters $param = Ini::getSectionParams('Database'); static::$PDO = new \PDO($param['dsn'], $param['username'], $param['password'], $param['options']); } // Load default PDO parameters $params = Ini::getSectionParams('PDO'); foreach ($params as $paramName => $paramValue) { if (!is_numeric($paramValue)) { $paramValue = constant('\\PDO::' . $paramValue); } static::$PDO->setAttribute(constant('\\PDO::' . $paramName), $paramValue); } static::setPDOStatement(); } } catch (\Exception $e) { throw new Exception($e->getMessage(), Exception::$CRITICAL); } }
/** * Send an email to the user * * @param string $subject The email subject * @param string $content The email content in HTML * * @throws \Exception If the email failed to be sent */ public function sendEmail(string $subject, string $content) { $mailParams = Ini::getSectionParams('Email'); $mail = new \PHPMailer(); $mail->isSMTP(); $mail->SMTPDebug = $mailParams['debugMode']; $mail->Host = $mailParams['smtpHost']; $mail->SMTPAuth = (bool) $mailParams['smtpAuth']; $mail->Username = $mailParams['smtpUserName']; $mail->Password = $mailParams['smtpPassword']; $mail->SMTPSecure = $mailParams['smtpSecure']; $mail->Port = $mailParams['port']; $mail->Subject = $subject; $mail->setFrom($mailParams['fromEmail'], $mailParams['fromAlias']); $mail->addAddress($this->entity->email, $this->entity->firstName . ' ' . $this->entity->lastName); $mail->addReplyTo($mailParams['replyToEmail'], $mailParams['replyToAlias']); $mail->isHTML((bool) $mailParams['isHtml']); $mail->msgHTML($content); if (!$mail->send()) { throw new \Exception($mail->ErrorInfo, LogLevel::ERROR); } }
/** * Constructor that loads chat parameters */ public function __construct() { Ini::setIniFileName(Ini::INI_CONF_FILE); $conf = Ini::getSectionParams('Client service'); $this->serviceName = $conf['serviceName']; }
/** * Initialize Elasticsearch by creating index, mapping and aliases from the conf.ini file */ private function initElasticsearch() { $conf = Ini::getSectionParams('ElasticSearch'); // Create index $this->createElasticsearchIndex($conf['index'], (int) $conf['version'], (int) $conf['numberOfShards'], (int) $conf['numberOfReplicas']); // Create mapping $this->createElasticsearchMapping($conf['index'], (int) $conf['version'], 'message', static::$ES_CHAT_MAPPING); // Bind aliases $this->bindAliasesToIndex($conf['index'] . '_v' . $conf['version'], $conf['index']); // Generate data $this->generateEsData($conf['index']); }
<?php /** * Launch a websocket server instance * * @package Launcher * @author Romain Laneuville <*****@*****.**> */ use classes\IniManager as Ini; use classes\ThrowableManager; use classes\websocket\ServerRequestHandler; use Icicle\WebSocket\Server\Server; use Icicle\Loop; require_once 'autoloader.php'; try { $params = Ini::getSectionParams('Socket'); $server = new Server(new ServerRequestHandler()); $server->listen($params['port'], $params['address']); Loop\run(); } catch (\Throwable $t) { $throwableManager = new ThrowableManager(); $throwableManager->log($t); } finally { exit(0); }