Example #1
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     if (!$this->c::isCli()) {
         throw $this->c::issue('Requires CLI mode.');
     }
 }
Example #2
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App           Instance of App.
  * @param array       $instance_base Instance base.
  * @param array       $instance      Instance args (highest precedence).
  */
 public function __construct(Classes\App $App, array $instance_base = [], array $instance = [])
 {
     parent::__construct($App);
     # Server CFGs (if applicable).
     $use_server_cfgs = (bool) ($instance['©use_server_cfgs'] ?? $instance_base['©use_server_cfgs'] ?? !empty($_SERVER['CFG_HOST']));
     $_ = $use_server_cfgs && !empty($_SERVER['CFG_HOST']) ? $_SERVER : [];
     # Default host names; needed below as fallbacks.
     $host = $_['CFG_HOST'] ?? $_SERVER['HTTP_HOST'] ?? mb_strtolower(php_uname('n'));
     $root_host = $_['CFG_ROOT_HOST'] ?? implode('.', array_slice(explode('.', $host), -2));
     # Default instance base (i.e., default config).
     $default_instance_base = ['©use_server_cfgs' => false, '©debug' => ['©enable' => (bool) ($_['CFG_DEBUG'] ?? false), '©edge' => (bool) ($_['CFG_DEBUG_EDGE'] ?? false), '©log' => (bool) ($_['CFG_DEBUG_LOG'] ?? $_['CFG_DEBUG'] ?? false), '©log_callback' => false, '©er_enable' => (bool) ($_['CFG_DEBUG_ER_ENABLE'] ?? $_['CFG_DEBUG'] ?? false), '©er_display' => (bool) ($_['CFG_DEBUG_ER_DISPLAY'] ?? $_['CFG_DEBUG_ER_ENABLE'] ?? $_['CFG_DEBUG'] ?? false), '©er_assertions' => (bool) ($_['CFG_DEBUG_ER_ASSERTIONS'] ?? $_['CFG_DEBUG_ER_ENABLE'] ?? $_['CFG_DEBUG'] ?? false)], '©handle_throwables' => (bool) ($_['CFG_HANDLE_THROWABLES'] ?? false), '©locales' => (array) ($_['CFG_LOCALES'] ?? ($_ ? ['en_US.UTF-8', 'C'] : [])), '©contacts' => ['©admin' => ['©gender' => (string) ($_['CFG_ADMIN_GENDER'] ?? 'male'), '©username' => (string) ($_['CFG_ADMIN_USERNAME'] ?? 'admin'), '©name' => (string) ($_['CFG_ADMIN_NAME'] ?? $_['CFG_ADMIN_USERNAME'] ?? 'Admin'), '©email' => (string) ($_['CFG_ADMIN_EMAIL'] ?? $_['CFG_ADMIN_PUBLIC_EMAIL'] ?? 'admin@' . $root_host), '©public_email' => (string) ($_['CFG_ADMIN_PUBLIC_EMAIL'] ?? 'admin@' . $root_host)]], '©di' => ['©default_rule' => ['new_instances' => [Classes\Core\Error::class, Classes\Core\Route::class, Classes\Core\CliOpts::class, Classes\Core\Template::class, Classes\Core\Tokenizer::class, Classes\Core\Paginator::class, Classes\Core\SearchTermHighlighter::class, Classes\Core\Base\Exception::class]]], '©sub_namespace_map' => [], '©mysql_db' => ['©hosts' => [(string) ($_['CFG_MYSQL_DB_HOST'] ?? '127.0.0.1') => ['©port' => (int) ($_['CFG_MYSQL_DB_PORT'] ?? 3306), '©charset' => (string) ($_['CFG_MYSQL_DB_CHARSET'] ?? 'utf8mb4'), '©collate' => (string) ($_['CFG_MYSQL_DB_COLLATE'] ?? 'utf8mb4_unicode_ci'), '©username' => (string) ($_['CFG_MYSQL_DB_USERNAME'] ?? 'client'), '©password' => (string) ($_['CFG_MYSQL_DB_PASSWORD'] ?? ''), '©ssl_enable' => (bool) ($_['CFG_MYSQL_SSL_ENABLE'] ?? false), '©ssl_key' => (string) ($_['CFG_MYSQL_SSL_KEY'] ?? ''), '©ssl_crt' => (string) ($_['CFG_MYSQL_SSL_CRT'] ?? ''), '©ssl_ca' => (string) ($_['CFG_MYSQL_SSL_CA'] ?? ''), '©ssl_cipher' => (string) ($_['CFG_MYSQL_SSL_CIPHER'] ?? '')]], '©shards' => [['©range' => ['©from' => 0, '©to' => 65535], '©properties' => ['©host' => (string) ($_['CFG_MYSQL_DB_HOST'] ?? '127.0.0.1'), '©name' => (string) ($_['CFG_MYSQL_DB_NAME'] ?? 'db0')]]]], '©brand' => ['©acronym' => (string) ($_['CFG_BRAND_ACRONYM'] ?? 'APP'), '©name' => (string) ($_['CFG_BRAND_NAME'] ?? $_['CFG_HOST'] ?? $host), '©author' => ['©gender' => (string) ($_['CFG_BRAND_AUTHOR_GENDER'] ?? $_['CFG_ADMIN_GENDER'] ?? 'male'), '©username' => (string) ($_['CFG_BRAND_AUTHOR_USERNAME'] ?? $_['CFG_ADMIN_USERNAME'] ?? 'admin'), '©name' => (string) ($_['CFG_BRAND_AUTHOR_NAME'] ?? $_['CFG_ADMIN_NAME'] ?? 'Admin'), '©email' => (string) ($_['CFG_BRAND_AUTHOR_EMAIL'] ?? $_['CFG_ADMIN_EMAIL'] ?? $_['CFG_ADMIN_PUBLIC_EMAIL'] ?? 'admin@' . $root_host), '©public_email' => (string) ($_['CFG_BRAND_AUTHOR_PUBLIC_EMAIL'] ?? $_['CFG_ADMIN_PUBLIC_EMAIL'] ?? 'admin@' . $root_host)], '©slug' => (string) ($_['CFG_BRAND_SLUG'] ?? $_['CFG_SLUG'] ?? 'app'), '©var' => (string) ($_['CFG_BRAND_VAR'] ?? $_['CFG_VAR'] ?? 'app'), '©short_slug' => (string) ($_['CFG_BRAND_SHORT_SLUG'] ?? $_['CFG_BRAND_SLUG'] ?? $_['CFG_SLUG'] ?? 'app'), '©short_var' => (string) ($_['CFG_BRAND_SHORT_VAR'] ?? $_['CFG_BRAND_VAR'] ?? $_['CFG_VAR'] ?? 'app'), '©text_domain' => (string) ($_['CFG_BRAND_TEXT_DOMAIN'] ?? $_['CFG_BRAND_SLUG'] ?? $_['CFG_SLUG'] ?? 'app'), '©keywords' => (array) ($_['CFG_BRAND_KEYWORDS'] ?? []), '©description' => (string) ($_['CFG_BRAND_DESCRIPTION'] ?? ''), '©tagline' => (string) ($_['CFG_BRAND_TAGLINE'] ?? ''), '©favicon' => (string) ($_['CFG_BRAND_FAVICON'] ?? '/favicon.ico'), '©logo' => (string) ($_['CFG_BRAND_LOGO'] ?? '/client-s/images/logo.png'), '©image' => (string) ($_['CFG_BRAND_IMAGE'] ?? '/client-s/images/image.png'), '©favicons' => ['©dir' => (string) ($_['CFG_BRAND_FAVICONS_DIR'] ?? '/client-s/images/favicons'), '©theme_color' => (string) ($_['CFG_BRAND_FAVICONS_THEME_COLOR'] ?? '#ffffff'), '©pinned_color' => (string) ($_['CFG_BRAND_FAVICONS_PINNED_ACTIVE_COLOR'] ?? '#2b5797')]], '©urls' => ['©hosts' => ['©app' => (string) ($_['CFG_HOST'] ?? $host), '©cdn' => (string) ($_['CFG_CDN_HOST'] ?? 'cdn.' . $root_host), '©roots' => ['©app' => (string) ($_['CFG_ROOT_HOST'] ?? $root_host), '©cdn' => (string) ($_['CFG_CDN_ROOT_HOST'] ?? $root_host)]], '©base_paths' => ['©app' => (string) ($_['CFG_HOST_BASE_PATH'] ?? ($_ ? '/' : '/src/')), '©cdn' => (string) ($_['CFG_CDN_HOST_BASE_PATH'] ?? '/')], '©cdn_filter_enable' => (bool) ($_['CFG_CDN_FILTER_ENABLE'] ?? false), '©default_scheme' => (string) ($_['CFG_DEFAULT_URL_SCHEME'] ?? 'https'), '©sig_key' => (string) ($_['CFG_URL_SIG_KEY'] ?? $_['CFG_ENCRYPTION_KEY'] ?? '')], '©fs_paths' => ['©logs_dir' => (string) ($_['CFG_LOGS_DIR'] ?? '/var/log/app/%%app_slug%%'), '©cache_dir' => (string) ($_['CFG_CACHE_DIR'] ?? '/tmp/app/%%app_slug%%/cache'), '©routes_dir' => (string) ($_['CFG_ROUTES_DIR'] ?? '%%app_base_dir%%/src/includes/routes'), '©templates_dir' => (string) ($_['CFG_TEMPLATES_DIR'] ?? '%%app_base_dir%%/src/includes/templates'), '©errors_dir' => (string) ($_['CFG_ERRORS_DIR'] ?? ($_ ? '/bootstrap/src/html/errors' : ''))], '©fs_permissions' => ['©transient_dirs' => (int) ($_['CFG_TRANSIENT_DIR_PERMISSIONS'] ?? 02775)], '©memcache' => ['©enabled' => (bool) ($_['CFG_MEMCACHE_ENABLED'] ?? $_ ? true : false), '©namespace' => (string) ($_['CFG_MEMCACHE_NAMESPACE'] ?? 'app'), '©servers' => [['©host' => (string) ($_['CFG_MEMCACHE_HOST'] ?? '127.0.0.1'), '©port' => (int) ($_['CFG_MEMCACHE_PORT'] ?? 11211), '©weight' => (int) ($_['CFG_MEMCACHE_WEIGHT'] ?? 0)]]], '©email' => ['©from_name' => (string) ($_['CFG_EMAIL_FROM_NAME'] ?? $_['CFG_BRAND_NAME'] ?? $_['CFG_HOST'] ?? 'App'), '©from_email' => (string) ($_['CFG_EMAIL_FROM_EMAIL'] ?? $_['CFG_ADMIN_PUBLIC_EMAIL'] ?? 'app@' . $root_host), '©reply_to_name' => (string) ($_['CFG_EMAIL_REPLY_TO_NAME'] ?? ''), '©reply_to_email' => (string) ($_['CFG_EMAIL_REPLY_TO_EMAIL'] ?? ''), '©smtp_host' => (string) ($_['CFG_EMAIL_SMTP_HOST'] ?? '127.0.0.1'), '©smtp_port' => (int) ($_['CFG_EMAIL_SMTP_PORT'] ?? 25), '©smtp_secure' => (string) ($_['CFG_EMAIL_SMTP_SECURE'] ?? ''), '©smtp_username' => (string) ($_['CFG_EMAIL_SMTP_USERNAME'] ?? ''), '©smtp_password' => (string) ($_['CFG_EMAIL_SMTP_PASSWORD'] ?? '')], '©encryption' => ['©key' => (string) ($_['CFG_ENCRYPTION_KEY'] ?? '')], '©cookies' => ['©encryption_key' => (string) ($_['CFG_COOKIES_ENCRYPTION_KEY'] ?? $_['CFG_ENCRYPTION_KEY'] ?? '')], '©hash_ids' => ['©hash_key' => (string) ($_['CFG_HASH_IDS_HASH_KEY'] ?? $_['CFG_ENCRYPTION_KEY'] ?? '')], '©passwords' => ['©hash_key' => (string) ($_['CFG_PASSWORDS_HASH_KEY'] ?? $_['CFG_ENCRYPTION_KEY'] ?? '')], '©aws' => ['©region' => (string) ($_['CFG_AWS_REGION'] ?? 'us-east-1'), '©access_key' => (string) ($_['CFG_AWS_ACCESS_KEY'] ?? ''), '©secret_key' => (string) ($_['CFG_AWS_SECRET_KEY'] ?? ''), '©s3_bucket' => (string) ($_['CFG_AWS_S3_BUCKET'] ?? ''), '©s3_version' => (string) ($_['CFG_AWS_S3_VERSION'] ?? '2006-03-01')], '©embedly' => ['©api_key' => (string) ($_['CFG_EMBEDLY_API_KEY'] ?? '')], '©webpurify' => ['©api_key' => (string) ($_['CFG_WEBPURIFY_API_KEY'] ?? '')], '©bitly' => ['©api_key' => (string) ($_['CFG_BITLY_API_KEY'] ?? '')], '©mailchimp' => ['©list_id' => (string) ($_['CFG_MAILCHIMP_LIST_ID'] ?? ''), '©api_key' => (string) ($_['CFG_MAILCHIMP_API_KEY'] ?? '')], '©slack' => ['©api_client_id' => (string) ($_['CFG_SLACK_API_CLIENT_ID'] ?? ''), '©api_client_secret' => (string) ($_['CFG_SLACK_API_CLIENT_SECRET'] ?? ''), '©api_access_token' => (string) ($_['CFG_SLACK_API_ACCESS_TOKEN'] ?? ''), '©api_webhook_url' => (string) ($_['CFG_SLACK_API_WEBHOOK_URL'] ?? '')]];
     # Merge `$instance_base` param into `$default_instance_base`.
     $instance_base = $this->App->mergeConfig($default_instance_base, $instance_base);
     # Merge everything together & convert to object properties now.
     $config = $this->App->mergeConfig($instance_base, $instance);
     $config = $this->App->fillConfigReplacementCodes($config);
     $config = (object) $config;
     // Config properties.
     # Adjust a few values associated w/ master switches.
     if (!$config->©debug['©enable']) {
         $config->©debug['©edge'] = false;
         $config->©debug['©log'] = $config->©debug['©log_callback'] = false;
         $config->©debug['©er_enable'] = $config->©debug['©er_display'] = $config->©debug['©er_assertions'] = false;
     } elseif (!$config->©debug['©er_enable']) {
         $config->©debug['©er_display'] = $config->©debug['©er_assertions'] = false;
     }
     # Overload configuration properties.
     $this->overload($config, true);
     // Overload public/writable properties.
 }
Example #3
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     if ($this->c::isCli()) {
         throw $this->c::issue('Not possible in CLI mode.');
     }
 }
Example #4
0
 /**
  * Constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     if (!class_exists('PDO')) {
         throw $this->c::issue('Missing PDO extension for PHP.');
     }
 }
Example #5
0
 /**
  * Class constructor.
  *
  * @since 151216 Memcached utilities.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->enabled = $this->App->Config->©memcache['©enabled'];
     $this->namespace = $this->App->Config->©memcache['©namespace'];
     $this->servers = $active_servers = [];
     // Initialize.
     foreach ($this->App->Config->©memcache['©servers'] as $_server) {
         $_host = $_server['©host'];
         $_port = $_server['©port'] ?? 11211;
         $_weight = $_server['©weight'] ?? 0;
         $this->servers[$_host . ':' . $_port] = [$_host, $_port, $_weight];
     }
     // unset($_server, $_host, $_port, $_weight);
     if (!class_exists('Memcached')) {
         return;
         // Not possible.
     } elseif (!$this->enabled || !$this->namespace || !$this->servers) {
         return;
         // Disabled or lacking config values.
     }
     $this->Pool = new \Memcached($this->App->namespace_sha1);
     $this->Pool->setOption(\Memcached::OPT_NO_BLOCK, true);
     $this->Pool->setOption(\Memcached::OPT_SEND_TIMEOUT, 5);
     $this->Pool->setOption(\Memcached::OPT_RECV_TIMEOUT, 5);
     $this->Pool->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
     if (\Memcached::HAVE_IGBINARY) {
         // Size and speed gains.
         $this->Pool->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
         $this->Pool->setOption(\Memcached::OPT_SERIALIZER, \Memcached::SERIALIZER_IGBINARY);
     }
     $this->maybeAddServerConnections();
 }
Example #6
0
 /**
  * Class constructor.
  *
  * @since 150424 Adding hash IDs.
  *
  * @param Classes\App $App       Instance of App.
  * @param string      $salt      Secret key.
  * @param int         $min_chars Minumum chars.
  * @param string      $alphabet  Chars to use in ID.
  */
 public function __construct(Classes\App $App, string $key = '', int $min_chars = 0, string $alphabet = '')
 {
     parent::__construct($App);
     if (!$key && !($key = $this->App->Config->©hash_ids['©hash_key'])) {
         throw $this->c::issue('Missing HashIds hash key.');
     }
     $this->Parser = new Parser($key, $min_chars, $alphabet);
 }
Example #7
0
 /**
  * Class constructor.
  *
  * @since 161009 Slack utils.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     if (!$this->App->Config->©fs_paths['©cache_dir']) {
         throw $this->c::issue('Missing cache directory.');
     }
     $this->cache_dir = $this->App->Config->©fs_paths['©cache_dir'] . '/slack';
 }
Example #8
0
 /**
  * Constructor.
  *
  * @since 160719 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->Sdk = new AwsLib\Sdk(['version' => 'latest', 'region' => $this->App->Config->©aws['©region'], 'credentials' => ['key' => $this->App->Config->©aws['©access_key'], 'secret' => $this->App->Config->©aws['©secret_key']]]);
     $this->S3Client = $this->Sdk->createS3(['version' => $this->App->Config->©aws['©s3_version']]);
     // A quick example of how this can be used in PHP.
     // $this->S3Client->registerStreamWrapper();
     // See: <http://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-stream-wrapper.html>
 }
Example #9
0
 /**
  * Class constructor.
  *
  * @since 160710 Error utils.
  *
  * @param Classes\App $App     Instance of App.
  * @param string      $slug    Error slug.
  * @param string      $message Error message.
  * @param mixed       $data    Error data.
  */
 public function __construct(Classes\App $App, string $slug = '', string $message = '', $data = null)
 {
     parent::__construct($App);
     $this->errors = [];
     $this->error_data = [];
     $this->default_slug = 'error';
     $this->default_message = __('Unknown error.');
     if ($slug || $message || isset($data)) {
         $this->add($slug, $message, $data);
     }
 }
Example #10
0
 /**
  * Class constructor.
  *
  * @since 161006 Paginator.
  *
  * @param Classes\App $App  Instance of App.
  * @param array       $args Pagination args.
  */
 public function __construct(Classes\App $App, array $args = [])
 {
     parent::__construct($App);
     $default_args = ['page' => 1, 'per_page' => 25, 'found_rows' => 0, 'show_pages' => 15, 'page_url' => '#%%page%%', 'pages_class' => 'ui basic buttons', 'page_class' => 'ui button', 'page_active_class' => 'ui basic primary button', 'page_disabled_class' => 'ui disabled button', 'page_icon_class' => 'ui icon button', 'page_icon_disabled_class' => 'ui disabled icon button', 'prev_page_icon' => '<i class="left arrow icon"></i>', 'next_page_icon' => '<i class="right arrow icon"></i>', 'ellipsis_icon' => '<i class="ellipsis horizontal icon"></i>'];
     $args = array_merge($default_args, $args);
     $args = array_intersect_key($args, $default_args);
     $args = array_map('strval', $args);
     $args['page'] = max(1, (int) $args['page']);
     $args['per_page'] = max(1, (int) $args['per_page']);
     $args['found_rows'] = max(0, (int) $args['found_rows']);
     $args['show_pages'] = max(2, (int) $args['show_pages']);
     $this->overload((object) $args, true);
 }
Example #11
0
 /**
  * Class constructor.
  *
  * @since 161007 Highligher.
  *
  * @param Classes\App $App  Instance of App.
  * @param string      $q    The search query.
  * @param array       $args Highligher args.
  */
 public function __construct(Classes\App $App, string $q, array $args = [])
 {
     parent::__construct($App);
     $default_args = ['class' => '-hst'];
     $args = array_merge($default_args, $args);
     $args = array_intersect_key($args, $default_args);
     $args = array_map('strval', $args);
     $this->q = $q;
     // Copy of param.
     $this->terms = $this->parseTerms($this->q);
     $this->regex = $this->termsToRegex($this->terms);
     $this->class = $this->c::escAttr((string) $args['class']);
 }
Example #12
0
 /**
  * Magic utility factory.
  *
  * @since 150424 Initial release.
  *
  * @param string $method Method to call upon.
  * @param array  $args   Arguments to pass to the method.
  *
  * @return mixed Overloaded method return value.
  *
  * @link http://php.net/manual/en/language.oop5.overloading.php
  */
 public function __call(string $method, array $args = [])
 {
     if (isset($this->x___overload[$method])) {
         return $this->x___overload[$method](...$args);
     }
     $map = $this->map($method);
     $class = Classes::class . $map['sub_namespace'] . '\\Utils\\' . $map['prop_meth'];
     $class = $this->App->getClass($class);
     if (class_exists($class)) {
         $Utility = $this->App->Di->get($class, [], true);
         $this->overload((object) [$method => $Utility], true);
         return $Utility(...$args);
     }
     return parent::__call($method);
 }
Example #13
0
 /**
  * Constructor.
  *
  * @since 150424 Initial release.
  *
  * @param array            $instance_base Instance base.
  * @param array            $instance      Instance args.
  * @param Classes\App|null $Parent        Parent app (optional).
  */
 public function __construct(array $instance_base = [], array $instance = [], Classes\App $Parent = null)
 {
     parent::__construct();
     # Establish debug mode early-on.
     if (isset($instance['©debug']['©enable'])) {
         $debug = (bool) $instance['©debug']['©enable'];
     } elseif (isset($instance_base['©debug']['©enable'])) {
         $debug = (bool) $instance_base['©debug']['©enable'];
     } else {
         // Based on server CFGs (if enabled).
         $use_server_cfgs = (bool) ($instance['©use_server_cfgs'] ?? $instance_base['©use_server_cfgs'] ?? !empty($_SERVER['CFG_HOST']));
         $debug = $use_server_cfgs && !empty($_SERVER['CFG_DEBUG']);
     }
     # Define a possible parent app.
     $this->Parent = $Parent;
     # Define reflection-based properties.
     // If not already obtained by an extender.
     $this->Reflection = $this->Reflection ?: new \ReflectionClass($this);
     $this->class = $this->class ?: $this->Reflection->getName();
     $this->namespace = $this->namespace ?: $this->Reflection->getNamespaceName();
     $this->namespace_sha1 = $this->namespace_sha1 ?: sha1($this->namespace);
     $this->file = $this->file ?: $this->Reflection->getFileName();
     $this->dir = $this->dir ?: dirname($this->file);
     $this->dir_basename = $this->dir_basename ?: basename($this->dir);
     $this->base_dir = $this->base_dir ?: dirname($this->dir, 3);
     $this->base_dir_basename = $this->base_dir_basename ?: basename($this->base_dir);
     $this->ws_core_dir = $this->ws_core_dir ?: dirname(__FILE__, 4);
     $this->is_ws_core = $this->class === self::class;
     $this->is_core = $this->is_ws_core || !$this->Parent;
     # Validate app instance (if applicable).
     if ($debug) {
         // Only in debug mode.
         if (isset($GLOBALS[$this->class])) {
             throw new Exception(sprintf('One instance of `%1$s` only please.', $this->class));
         } elseif (mb_substr($this->namespace, -8) !== '\\Classes') {
             throw new Exception(sprintf('Invalid namespace: `%1$s`. Expecting: `...\\Classes`.', $this->namespace));
         } elseif (mb_substr($this->dir, -21) !== '/src/includes/classes') {
             throw new Exception(sprintf('Invalid dir: `%1$s`. Expecting: `.../src/includes/classes`.', $this->dir));
         }
     }
     # Instantiate/configure child class instances; e.g., Config, Di, Utils.
     $this->Config = new Classes\Core\Base\Config($this, $instance_base, $instance);
     $this->Di = new Classes\Core\Base\Di($this, $this->Config->©di['©default_rule']);
     $this->Utils = new Classes\Core\Base\Utils($this);
     $this->Di->addInstances([$this, $this->Config, $this->Utils]);
     # Setup global references & facades.
     # http://docstore.mik.ua/orelly/webprog/pcook/ch07_13.htm
     $GLOBALS[$this->class] = $this;
     // Global access variable.
     $GLOBALS[$this->Facades->c = $this->namespace . '\\CoreFacades'] = $this;
     $_facades_base_class = $this->getClass(Classes\Core\Base\Facades::class);
     eval('namespace ' . $this->namespace . ' { class CoreFacades extends \\' . $_facades_base_class . ' {} }');
     foreach ($this->Config->©sub_namespace_map as $_sub_namespace => $_identifiers) {
         if (class_exists($_facades_base_class = $this->getClass($this->namespace . '\\' . $_sub_namespace . '\\Base\\Facades'))) {
             $GLOBALS[$this->Facades->{$_identifiers['©facades']} = $this->namespace . '\\' . $_sub_namespace . 'Facades'] = $this;
             eval('namespace ' . $this->namespace . ' { class ' . $_sub_namespace . 'Facades extends \\' . $_facades_base_class . ' {} }');
         }
     }
     // unset($_sub_namespace, $_identifiers, $_facades_base_class);
     $GLOBALS[$this->Facades->a = $this->namespace . '\\AppFacades'] = $this;
     $_facades_base_class = $this->namespace . '\\Base\\Facades';
     $_facades_base_class = class_exists($_facades_base_class) ? $_facades_base_class : 'StdClass';
     eval('namespace ' . $this->namespace . ' { class AppFacades extends \\' . $_facades_base_class . ' {} }');
     # Post-construct sub-routines.
     $this->maybeDebug();
     $this->maybeSetLocales();
     $this->maybeHandleThrowables();
 }
Example #14
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
     $this->key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
 }
Example #15
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App  Instance of App.
  * @param string      $dir  Template file directory.
  * @param string      $file Relative to directory.
  * @param array       $args Additional args.
  */
 public function __construct(Classes\App $App, string $dir, string $file, array $args = [])
 {
     parent::__construct($App);
     if (!($template = $this->c::locateTemplate($file, $dir))) {
         throw $this->c::issue(sprintf('Missing template: `%1$s`.', $dir . '/' . $file));
     }
     $default_args = ['parents' => [], 'parent_vars' => [], 'Route' => null];
     $args += $default_args;
     $this->dir = $template['dir'];
     $this->file = $template['file'];
     $this->ext = $template['ext'];
     $this->parents = (array) $args['parents'];
     $this->parent_vars = (array) $args['parent_vars'];
     $this->vars = [];
     // Initialize.
     $this->Route = $args['Route'];
     $this->parsed = 0;
     $this->setAdditionalProps();
 }
Example #16
0
 /**
  * Class constructor.
  *
  * @since 150424 SHA-1 modulus.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->total_mysql_db_shards = count($this->App->Config->©mysql_db['©shards']);
 }
Example #17
0
 /**
  * Tokenize specific elements.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App      Instance of App.
  * @param string      $string   Input string.
  * @param array       $tokenize Specific elements.
  * @param array       $args     Any behavioral args.
  *
  * @return string The tokenized string.
  */
 public function __construct(Classes\App $App, string $string, array $tokenize, array $args = [])
 {
     parent::__construct($App);
     $this->id = $this->c::uniqueId();
     $this->string = $string;
     // String to tokenize.
     $this->tokenize = $tokenize;
     // What to tokenize.
     $default_args = ['shortcode_tag_names' => [], 'exclude_escaped_shortcode' => false, 'shortcode_unautop_compat' => false, 'shortcode_unautop_compat_tag_name' => ''];
     // Establishes argument defaults.
     $this->args = $args + $default_args;
     $this->args['shortcode_tag_names'] = (array) $this->args['shortcode_tag_names'];
     $this->args['exclude_escaped_shortcode'] = (bool) $this->args['exclude_escaped_shortcode'];
     $this->args['shortcode_unautop_compat'] = (bool) $this->args['shortcode_unautop_compat'];
     $this->args['shortcode_unautop_compat_tag_name'] = (string) $this->args['shortcode_unautop_compat_tag_name'];
     $this->tokens = [];
     // Initialize tokens.
     if (!$this->string || !$this->tokenize) {
         return;
         // Nothing to do.
     }
     $this->maybeTokenizeShortcodes();
     $this->maybeTokenizePreTags();
     $this->maybeTokenizeCodeTags();
     $this->maybeTokenizeSampTags();
     $this->maybeTokenizeAnchorTags();
     $this->maybeTokenizeAllTags();
     $this->maybeTokenizeMdFences();
     $this->maybeTokenizeMdLinks();
 }
Example #18
0
 /**
  * Class constructor.
  *
  * @since 150424 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->static_exts = array_keys($this::MIME_TYPES);
     $this->static_exts = array_diff($this->static_exts, ['php']);
 }
Example #19
0
 /**
  * Class constructor.
  *
  * @since 161008 Route.
  *
  * @param Classes\App $App  Instance of App.
  * @param array       $args Route instance args.
  */
 public function __construct(Classes\App $App, array $args)
 {
     parent::__construct($App);
     $default_args = ['dir' => '', 'file' => '', 'ext' => '', 'path' => '', 'rewrite_query_vars' => []];
     $args = array_merge($default_args, $args);
     $args = array_intersect_key($args, $default_args);
     $this->dir = (string) $args['dir'];
     $this->file = (string) $args['file'];
     $this->ext = (string) $args['ext'];
     $this->path = (string) $args['path'];
     $this->rewrite_query_vars = (array) $args['rewrite_query_vars'];
     $this->query_vars = [];
     $this->vars = [];
     $this->parsed = 0;
     $this->setAdditionalProps();
 }
Example #20
0
 /**
  * Class constructor.
  *
  * @since 160606 Request types.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->is_wordpress = $this->c::isWordPress();
 }
Example #21
0
 /**
  * Constructor.
  *
  * @since 160719 Initial release.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
     $this->PDO_exists = class_exists('PDO');
 }
Example #22
0
 /**
  * Class constructor.
  *
  * @since 160620 Adding MailChimp.
  *
  * @param Classes\App $App Instance of App.
  */
 public function __construct(Classes\App $App)
 {
     parent::__construct($App);
 }