Exemplo n.º 1
0
 protected function _checkSystemState()
 {
     $_error = false;
     $_state = SystemManager::getSystemState();
     if (!$this->_activated && $_state != PlatformStates::INIT_REQUIRED) {
         $_state = PlatformStates::ADMIN_REQUIRED;
     }
     if (!empty($this->_remoteError)) {
         $_error = 'error=' . urlencode($this->_remoteError);
     }
     if (PlatformStates::READY == $_state) {
         $_defaultApp = Pii::getParam('dsp.default_app', static::DEFAULT_STARTUP_APP);
         //	Try local launchpad
         if (is_file(\Kisma::get('app.app_path') . $_defaultApp)) {
             $_defaultApp = rtrim($_defaultApp . Curl::urlSeparator($_defaultApp) . $_error, '?');
             $this->redirect($_defaultApp);
         }
         //            Log::notice(
         //                'No default application defined/found. Running launchpad...' .
         //                PHP_EOL .
         //                '==============================' .
         //                PHP_EOL .
         //                'Config dump:' .
         //                PHP_EOL .
         //                print_r( \Kisma::get( null ), true ) .
         //                '==============================' .
         //                PHP_EOL .
         //                '==============================' .
         //                PHP_EOL .
         //                'Params dump:' .
         //                PHP_EOL .
         //                print_r( Pii::params(), true ) .
         //                '==============================' .
         //                PHP_EOL
         //            );
         //	If we have no app, run the launchpad
         $this->redirect(static::DEFAULT_STARTUP_APP);
     } else {
         if (!$this->_handleAction($_state)) {
             Log::error('Invalid state "' . $_state . '" or no handler configured.');
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * Var dumper
 */
$_cwd = getcwd();
$_home = dirname($_cwd);
$_vendor = $_home . '/vendor';
$_app = $_home . '/app';
$_models = $_app . '/models';
$_autoload = file_exists($_vendor . '/autoload.php') && is_readable($_vendor . '/autoload.php');
$_appRight = is_dir($_models);
$_html = null;
$_vars = \Kisma::get(null);
if (!empty($_vars)) {
    foreach ($_vars as $_key => $_value) {
        switch ($_value) {
            case false === $_value:
                $_value = '<strong>FALSE</strong>';
                break;
            case true === $_value:
                $_value = '<strong>TRUE</strong>';
                break;
            case null === $_value:
                $_value = '<strong>NULL</strong>';
                break;
            default:
            case is_string($_value):
                $_value = '' . $_value . '';
                break;
            case !is_scalar($_value):
Exemplo n.º 3
0
Arquivo: Curl.php Projeto: kisma/kisma
 /**
  * Returns the validated URL that has been called to get here
  *
  * @param bool $includeQuery If true, query string is included
  * @param bool $includePath  If true, the uri path is included
  *
  * @return string
  */
 public static function currentUrl($includeQuery = true, $includePath = true)
 {
     //	Are we SSL? Check for load balancer protocol as well...
     $_port = intval(Option::get($_SERVER, 'HTTP_X_FORWARDED_PORT', Option::get($_SERVER, 'SERVER_PORT', 80)));
     $_protocol = Option::get($_SERVER, 'HTTP_X_FORWARDED_PROTO', 'http' . (Option::getBool($_SERVER, 'HTTPS') ? 's' : null)) . '://';
     $_host = Option::get($_SERVER, 'HTTP_X_FORWARDED_HOST', Option::get($_SERVER, 'HTTP_HOST', gethostname()));
     $_parts = parse_url($_protocol . $_host . Option::get($_SERVER, 'REQUEST_URI'));
     if ((empty($_port) || !is_numeric($_port)) && null !== ($_parsePort = Option::get($_parts, 'port'))) {
         $_port = @intval($_parsePort);
     }
     if (null !== ($_query = Option::get($_parts, 'query'))) {
         $_query = static::urlSeparator($_query) . http_build_query(explode('&', $_query));
     }
     if (false !== strpos($_host, ':') || $_protocol == 'https://' && $_port == 443 || $_protocol == 'http://' && $_port == 80) {
         $_port = null;
     } else {
         $_port = ':' . $_port;
     }
     if (false !== strpos($_host, ':')) {
         $_port = null;
     }
     $_currentUrl = $_protocol . $_host . $_port . (true === $includePath ? Option::get($_parts, 'path') : null) . (true === $includeQuery ? $_query : null);
     if (\Kisma::get('debug.curl.current_url')) {
         Log::debug('Parsed current URL to be: ' . $_currentUrl, $_parts);
     }
     return $_currentUrl;
 }
Exemplo n.º 4
0
    unset($_salts);
}
/**
 * Application Paths
 */
\Kisma::set(array('app.app_name' => $_appName, 'app.project_root' => $_basePath, 'app.vendor_path' => $_vendorPath, 'app.log_path' => $_logFilePath, 'app.log_file_name' => $_logFileName, 'app.install_type' => array($_installType => $_installName), 'app.fabric_hosted' => $_fabricHosted, 'app.doc_root' => $_docRoot));
/**
 * Database Caching
 */
$_dbCache = $_dbCacheEnabled ? array('class' => 'CDbCache', 'connectionID' => 'db', 'cacheTableName' => 'df_sys_cache', 'autoCreateCacheTable' => true) : null;
$_storageKey = \Kisma::get('platform.storage_key');
/**
 * Set up and return the common settings...
 */
if ($_fabricHosted) {
    $_storagePath = $_storageBasePath = LocalStorageTypes::FABRIC_STORAGE_BASE_PATH . '/' . $_storageKey;
    $_privatePath = \Kisma::get('platform.private_path');
    $_storagePath = $_storageBasePath . (version_compare(DSP_VERSION, '2.0.0', '<') ? '/blob' : null);
    $_identity = array('dsp.storage_id' => $_storageKey, 'dsp.private_storage_id' => \Kisma::get('platform.private_storage_key'));
} else {
    $_storagePath = $_storageBasePath = $_basePath . LocalStorageTypes::LOCAL_STORAGE_BASE_PATH;
    $_privatePath = $_basePath . '/storage/.private';
    $_identity = array('dsp.storage_id' => null, 'dsp.private_storage_id' => null);
}
//	Merge the common junk with specifics
$_instanceSettings = array_merge($_identity, array(LocalStorageTypes::STORAGE_BASE_PATH => $_storageBasePath, LocalStorageTypes::STORAGE_PATH => $_storagePath, LocalStorageTypes::PRIVATE_PATH => $_privatePath, LocalStorageTypes::LOCAL_CONFIG_PATH => $_privatePath . '/config', LocalStorageTypes::SNAPSHOT_PATH => $_privatePath . '/snapshots', LocalStorageTypes::APPLICATIONS_PATH => $_storagePath . '/applications', LocalStorageTypes::LIBRARY_PATH => $_storagePath . '/plugins', LocalStorageTypes::PLUGINS_PATH => $_storagePath . '/plugins', LocalStorageTypes::SWAGGER_PATH => $_storagePath . '/swagger'));
//	Keep these out of the global space
unset($_storageBasePath, $_storagePath, $_privatePath, $_identity, $_storageKey);
/** @noinspection PhpIncludeInspection */
return array_merge($_instanceSettings, array('base_path' => $_basePath, 'dsp.version' => DSP_VERSION, 'dsp_name' => \Kisma::get('platform.dsp_name'), 'dsp.auth_endpoint' => DEFAULT_INSTANCE_AUTH_ENDPOINT, 'dsp.fabric_hosted' => $_fabricHosted, 'dsp.no_persistent_storage' => false, 'cloud.endpoint' => DEFAULT_CLOUD_API_ENDPOINT, 'oauth.salt' => 'rW64wRUk6Ocs+5c7JwQ{69U{]MBdIHqmx9Wj,=C%S#cA%+?!cJMbaQ+juMjHeEx[dlSe%h%kcI', 'keys' => $_keys, 'dsp.allow_remote_logins' => true, 'dsp.allow_admin_remote_logins' => true, 'adminEmail' => DEFAULT_SUPPORT_EMAIL, 'dsp.service_config' => require __DIR__ . SERVICES_CONFIG_PATH, 'dsp.service_location_map' => array(), 'dsp.default_services' => array(array('api_name' => 'user', 'name' => 'User Login'), array('api_name' => 'system', 'name' => 'System Configuration'), array('api_name' => 'api_docs', 'name' => 'API Documentation')), 'dsp.install_type' => $_installType, 'dsp.install_name' => $_installName, 'dsp.restricted_verbs' => InstallationTypes::getRestrictedVerbs($_installType), 'dsp.default_app' => '/launchpad/index.html', 'dsp.confirm_invite_url' => '/' . $_defaultController . '/confirmInvite', 'dsp.confirm_register_url' => '/' . $_defaultController . '/confirmRegister', 'dsp.confirm_reset_url' => '/' . $_defaultController . '/confirmPassword', 'dsp.db_max_records_returned' => 1000, 'dsp.enable_profiler' => false, 'dsp.debug_level' => LoggingLevels::WARNING, 'dsp.enable_event_observers' => true, 'dsp.enable_rest_events' => true, 'dsp.enable_platform_events' => true, 'dsp.enable_event_scripts' => true, 'dsp.enable_user_scripts' => true, 'dsp.log_events' => true, 'dsp.log_all_events' => false, 'dsp.log_script_memory_usage' => false, 'dsp.log_cache_stats' => false, 'dsp.cache_stats_event' => 'system.config.read', 'login.remember_me_copy' => 'Remember Me'), $_dspSalts);
Exemplo n.º 5
0
Arquivo: Log.php Projeto: kisma/kisma
 /**
  * Makes sure we have a log file name and path
  *
  * @deprecated in v0.2.20. To be removed in v0.3.0. Replaced by Monolog
  */
 protected static function _checkLogFile()
 {
     if (null !== static::$_logger) {
         return static::$_logFileValid = true;
     }
     if (empty(static::$_logFilePath)) {
         //	Try and figure out a good place to log...
         static::$_logFilePath = (\Kisma::get('app.log_path', \Kisma::get('app.base_path')) ?: dirname(getcwd())) . '/log';
     }
     if (!is_dir(static::$_logFilePath)) {
         if (false === @mkdir(static::$_logFilePath, 0777, true)) {
             error_log('Unable to create default log directory: ' . static::$_logFilePath);
             return static::$_logFileValid = false;
         }
     }
     if (empty(static::$_logFileName)) {
         static::$_logFileName = static::DEFAULT_LOG_FILE_NAME;
     }
     static::$_defaultLog = static::$_logFilePath . '/' . trim(static::$_logFileName, '/');
     static::$_logger = new Logger(static::DEFAULT_CHANNEL_NAME);
     static::$_logger->pushHandler(new StreamHandler(static::$_defaultLog));
     //	If we're in debug mode and these haven't been disabled, enable...
     if (\Kisma::get(CoreSettings::DEBUG)) {
         static::$_enableChromePhp = static::$_enableChromePhp ?: true;
         static::$_enableFirePhp = static::$_enableFirePhp ?: true;
     }
     //	Enable conditional handlers
     if (static::$_enableFirePhp) {
         static::$_logger->pushHandler(new FirePHPHandler());
     }
     if (static::$_enableChromePhp) {
         static::$_logger->pushHandler(new ChromePHPHandler());
     }
     return static::$_logFileValid = true;
 }
Exemplo n.º 6
0
//	Where the log files go and the name...
$_logFilePath = $_basePath . '/log';
$_logFileName = basename(\Kisma::get('app.log_file'));
//	Our app's name
$_appName = 'Portal Sandbox Test Suite';
/**
 * Aliases
 */
file_exists(__DIR__ . ALIASES_CONFIG_PATH) && (require __DIR__ . ALIASES_CONFIG_PATH);
/**
 * Application Paths
 */
\Kisma::set('app.app_name', $_appName);
\Kisma::set('app.doc_root', $_docRoot);
\Kisma::set('app.log_path', $_logFilePath);
\Kisma::set('app.vendor_path', $_vendorPath);
\Kisma::set('app.log_file_name', $_logFileName);
\Kisma::set('app.project_root', $_basePath);
/**
 * Database Caching
 */
$_dbCache = $_dbCacheEnabled ? array('class' => 'CDbCache', 'connectionID' => 'db', 'cacheTableName' => 'df_sys_cache', 'autoCreateCacheTable' => true) : null;
/**
 * Set up and return the common settings...
 */
if (Fabric::fabricHosted()) {
    $_instanceSettings = array('storage_base_path' => '/data/storage/' . \Kisma::get('platform.storage_key'), 'storage_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob', 'private_path' => \Kisma::get('platform.private_path'), 'snapshot_path' => \Kisma::get('platform.private_path') . '/snapshots', 'applications_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/applications', 'library_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/lib', 'plugins_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/plugins', 'dsp_name' => \Kisma::get('platform.dsp_name'), 'dsp.storage_id' => \Kisma::get('platform.storage_key'), 'dsp.private_storage_id' => \Kisma::get('platform.private_storage_key'));
} else {
    $_instanceSettings = array('storage_base_path' => $_basePath . '/storage', 'storage_path' => $_basePath . '/storage', 'private_path' => $_basePath . '/storage/.private', 'snapshot_path' => $_basePath . '/storage/.private/snapshots', 'applications_path' => $_basePath . '/storage/applications', 'library_path' => $_basePath . '/storage/lib', 'plugins_path' => $_basePath . '/storage/plugins', 'dsp_name' => gethostname(), 'dsp.storage_id' => null, 'dsp.private_storage_id' => null);
}
return array_merge($_instanceSettings, array('base_path' => $_basePath, 'dsp.version' => DSP_VERSION, 'dsp.name' => $_instanceSettings['dsp_name'], 'dsp.auth_endpoint' => DEFAULT_INSTANCE_AUTH_ENDPOINT, 'cloud.endpoint' => DEFAULT_CLOUD_API_ENDPOINT, 'oauth.salt' => 'rW64wRUk6Ocs+5c7JwQ{69U{]MBdIHqmx9Wj,=C%S#cA%+?!cJMbaQ+juMjHeEx[dlSe%h%kcI', 'dsp.allow_remote_logins' => true, 'dsp.allow_admin_remote_logins' => true, 'adminEmail' => DEFAULT_SUPPORT_EMAIL, 'dsp.service_config' => require __DIR__ . SERVICES_CONFIG_PATH, 'dsp.service_location_map' => array(), 'dsp.default_services' => array(array('api_name' => 'user', 'name' => 'User Login'), array('api_name' => 'system', 'name' => 'System Configuration'), array('api_name' => 'api_docs', 'name' => 'API Documentation')), 'dsp.default_app' => '/launchpad/index.html', 'dsp.confirm_invite_url' => '/confirm_invite.html', 'dsp.confirm_register_url' => '/confirm_reg.html', 'dsp.confirm_reset_url' => '/confirm_reset.html', 'dsp.db_max_records_returned' => 1000, 'admin.resource_schema' => require __DIR__ . DEFAULT_ADMIN_RESOURCE_SCHEMA, 'admin.default_theme' => 'united'));
Exemplo n.º 7
0
 /**
  * Returns an array of standard values passed to all views
  *
  * @param null  $viewFile
  * @param array $additional
  *
  * @return array
  */
 protected static function _getBaseRenderPayload($viewFile = null, $additional = array())
 {
     $additional = array_merge($additional, \Kisma::get('view.defaults', array()));
     if (null !== $viewFile) {
         $additional = array_merge($additional, \Kisma::get('view.config.' . $viewFile, array()));
     }
     $_payload = array('app_name' => \Kisma::get('app.name'), 'app_root' => \Kisma::get('app.root'), 'app_version' => \Kisma::get('app.version'), 'page_date' => date('Y-m-d H:i:s'), 'vendor_path' => \Kisma::get('app.base_path') . '/vendor', 'navbar' => \Kisma::get('app.navbar'));
     return array_merge($_payload, $additional);
 }
Exemplo n.º 8
0
 /**
  * @covers Kisma::get
  */
 public function testGet()
 {
     $this->assertTrue(\Kisma::get('testSetOption'));
 }
Exemplo n.º 9
0
    }
    unset($_salts);
}
/**
 * Application Paths
 */
\Kisma::set(array('app.app_name' => $_appName, 'app.project_root' => $_basePath, 'app.vendor_path' => $_vendorPath, 'app.log_path' => $_logFilePath, 'app.log_file_name' => $_logFileName, 'app.install_type' => array($_installType => $_installName), 'app.fabric_hosted' => $_fabricHosted, 'app.doc_root' => $_docRoot));
/**
 * Database Caching
 */
$_dbCache = $_dbCacheEnabled ? array('class' => 'CDbCache', 'connectionID' => 'db', 'cacheTableName' => 'df_sys_cache', 'autoCreateCacheTable' => true) : null;
$_storageKey = \Kisma::get('platform.storage_key');
/**
 * Set up and return the common settings...
 */
if ($_fabricHosted) {
    $_storagePath = $_storageBasePath = LocalStorageTypes::FABRIC_STORAGE_BASE_PATH . '/' . $_storageKey;
    $_privatePath = \Kisma::get('platform.private_path');
    $_storagePath = $_storageBasePath . (version_compare(DSP_VERSION, '2.0.0', '<') ? '/blob' : null);
    $_identity = array('dsp.storage_id' => $_storageKey, 'dsp.private_storage_id' => \Kisma::get('platform.private_storage_key'), 'dsp_name' => \Kisma::get('platform.dsp_name'));
} else {
    $_storagePath = $_storageBasePath = $_basePath . LocalStorageTypes::LOCAL_STORAGE_BASE_PATH;
    $_privatePath = $_basePath . '/storage/.private';
    $_identity = array('dsp.storage_id' => null, 'dsp.private_storage_id' => null, 'dsp_name' => \Kisma::get('platform.host_name'));
}
//	Merge the common junk with specifics
$_instanceSettings = array_merge($_identity, array(LocalStorageTypes::STORAGE_BASE_PATH => $_storageBasePath, LocalStorageTypes::STORAGE_PATH => $_storagePath, LocalStorageTypes::PRIVATE_PATH => $_privatePath, LocalStorageTypes::LOCAL_CONFIG_PATH => $_privatePath . '/config', LocalStorageTypes::PRIVATE_CONFIG_PATH => $_privatePath . '/config', LocalStorageTypes::SNAPSHOT_PATH => $_privatePath . '/snapshots', LocalStorageTypes::APPLICATIONS_PATH => $_storagePath . '/applications', LocalStorageTypes::LIBRARY_PATH => $_storagePath . '/plugins', LocalStorageTypes::PLUGINS_PATH => $_storagePath . '/plugins', LocalStorageTypes::SWAGGER_PATH => $_storagePath . '/swagger'));
//	Keep these out of the global space
unset($_storageBasePath, $_storagePath, $_privatePath, $_identity, $_storageKey);
/** @noinspection PhpIncludeInspection */
return array_merge($_instanceSettings, array('platform.timestamp_format' => 'Y-m-d H:i:s', 'app.base_path' => $_basePath, 'app.private_path' => $_basePath . $_instanceSettings[LocalStorageTypes::PRIVATE_PATH], 'app.plugins_path' => $_basePath . $_instanceSettings[LocalStorageTypes::PLUGINS_PATH], 'app.enable_profiler' => false, 'app.debug_level' => LoggingLevels::WARNING, 'base_path' => $_basePath, 'dsp.version' => DSP_VERSION, 'dsp.auth_endpoint' => DEFAULT_INSTANCE_AUTH_ENDPOINT, 'dsp.fabric_hosted' => $_fabricHosted, 'dsp.no_persistent_storage' => false, 'cloud.endpoint' => DEFAULT_CLOUD_API_ENDPOINT, 'dsp.metadata_endpoint' => DEFAULT_METADATA_ENDPOINT, 'oauth.salt' => 'rW64wRUk6Ocs+5c7JwQ{69U{]MBdIHqmx9Wj,=C%S#cA%+?!cJMbaQ+juMjHeEx[dlSe%h%kcI', 'keys' => $_keys, 'dsp.allow_remote_logins' => false, 'dsp.allow_admin_remote_logins' => false, 'dsp.hpp_hosts' => array(), 'adminEmail' => DEFAULT_SUPPORT_EMAIL, 'dsp.service_config' => require __DIR__ . SERVICES_CONFIG_PATH, 'dsp.service_location_map' => array(), 'dsp.default_services' => array(array('api_name' => 'user', 'name' => 'User Login'), array('api_name' => 'system', 'name' => 'System Configuration'), array('api_name' => 'api_docs', 'name' => 'API Documentation')), 'dsp.install_type' => $_installType, 'dsp.install_name' => $_installName, 'dsp.restricted_verbs' => InstallationTypes::getRestrictedVerbs($_installType), 'dsp.default_app' => DEFAULT_ADMIN_APP_PATH . '/index.html', 'dsp.confirm_invite_url' => DEFAULT_ADMIN_APP_PATH . '/#/user-invite', 'dsp.confirm_register_url' => DEFAULT_ADMIN_APP_PATH . '/#/register-confirm', 'dsp.confirm_reset_url' => DEFAULT_ADMIN_APP_PATH . '/#/reset-password', 'dsp.db_max_records_returned' => 1000, 'dsp.db_time_format' => null, 'dsp.db_date_format' => null, 'dsp.db_datetime_format' => null, 'dsp.db_timestamp_format' => null, 'dsp.log_cors_info' => false, 'dsp.enable_event_observers' => true, 'dsp.enable_rest_events' => true, 'dsp.enable_platform_events' => true, 'dsp.enable_event_scripts' => true, 'dsp.enable_user_scripts' => true, 'dsp.log_events' => true, 'dsp.log_all_events' => false, 'dsp.log_script_memory_usage' => false, 'dsp.scripting.user_libraries' => array(), 'dsp.log_cache_stats' => false, 'dsp.cache_stats_event' => 'system.config.read', 'login.remember_me_copy' => 'Remember Me', 'dsp.chat_launchpad' => false, 'dsp.chat_admin' => true), $_dspSalts);
Exemplo n.º 10
0
 /**
  * Cleans up a trace array
  *
  * @param array $trace
  * @param int   $skipLines
  * @param null  $basePath
  *
  * @return null|string
  */
 protected static function _cleanTrace(array &$trace, $skipLines = null, $basePath = null)
 {
     $_trace = array();
     $_basePath = $basePath ?: \Kisma::get('app.base_path');
     //	Skip some lines
     if (!empty($skipLines) && count($trace) > $skipLines) {
         $trace = array_slice($trace, $skipLines);
     }
     foreach ($trace as $_index => $_code) {
         $_traceItem = array();
         Scalar::sins($trace[$_index], 'file', 'Unspecified');
         Scalar::sins($trace[$_index], 'line', 0);
         Scalar::sins($trace[$_index], 'function', 'Unspecified');
         $_traceItem['file_name'] = trim(str_replace(array($_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://'), array(null, '    ', null, null, null, null), $trace[$_index]['file']));
         $_args = null;
         if (isset($_code['args']) && !empty($_code['args'])) {
             foreach ($_code['args'] as $_arg) {
                 if (is_object($_arg)) {
                     $_args .= get_class($_arg) . ', ';
                 } else {
                     if (is_array($_arg)) {
                         $_args .= '[array], ';
                     } else {
                         if (is_bool($_arg)) {
                             if ($_arg) {
                                 $_args .= 'true, ';
                             } else {
                                 $_args .= 'false, ';
                             }
                         } else {
                             if (is_numeric($_arg)) {
                                 $_args .= $_arg . ', ';
                             } else {
                                 if (is_scalar($_arg)) {
                                     $_args .= '"' . $_arg . '", ';
                                 } else {
                                     $_args .= '"' . gettype($_arg) . '", ';
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $_traceItem['line'] = $trace[$_index]['line'];
         if (isset($_code['type'])) {
             $_traceItem['function'] = (isset($_code['class']) ? $_code['class'] : null) . $_code['type'] . $_code['function'];
         } else {
             $_traceItem['function'] = $_code['function'];
         }
         $_traceItem['function'] .= '(' . ($_args ? ' ' . trim($_args, ', ') . ' ' : null) . ')';
         $_traceItem['index'] = $_index;
         $_trace[] = $_traceItem;
     }
     return $_trace;
 }