Exemple #1
0
/**
 * Get or set system configuration.
 * 
 * @param string $key
 * @param string $value (optional)
 * @return mixed
 */
function config($key, $value = null)
{
    if ($value === null) {
        return Rhymix\Framework\Config::get($key);
    } else {
        Rhymix\Framework\Config::set($key, $value);
    }
}
 /**
  * Remove FTP configuration.
  */
 function procAdminRemoveFTPInfo()
 {
     Rhymix\Framework\Config::set('ftp.host', null);
     Rhymix\Framework\Config::set('ftp.port', null);
     Rhymix\Framework\Config::set('ftp.user', null);
     Rhymix\Framework\Config::set('ftp.pass', null);
     Rhymix\Framework\Config::set('ftp.path', null);
     Rhymix\Framework\Config::set('ftp.pasv', true);
     Rhymix\Framework\Config::set('ftp.sftp', false);
     Rhymix\Framework\Config::save();
     $this->setMessage('success_deleted');
 }
Exemple #3
0
            // XE compatible classes.
        // XE compatible classes.
        default:
            if (isset($GLOBALS['RX_AUTOLOAD_FILE_MAP'][$lc_class_name])) {
                $filename = RX_BASEDIR . $GLOBALS['RX_AUTOLOAD_FILE_MAP'][$lc_class_name];
            } elseif (preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches)) {
                $filename = RX_BASEDIR . 'modules/' . strtolower($matches[1] . '/' . $matches[1]);
                if (isset($matches[2]) && $matches[2]) {
                    $filename .= '.admin';
                }
                $filename .= isset($matches[3]) && $matches[3] ? '.' . strtolower($matches[3]) : '.class';
                $filename .= '.php';
            }
    }
    if ($filename && file_exists($filename)) {
        include $filename;
    }
});
/**
 * Also include the Composer autoloader.
 */
require_once RX_BASEDIR . 'vendor/autoload.php';
/**
 * Load system configuration.
 */
Rhymix\Framework\Config::init();
/**
 * Set the internal timezone.
 */
$internal_timezone = Rhymix\Framework\DateTime::getTimezoneNameByOffset(config('locale.internal_timezone'));
date_default_timezone_set($internal_timezone);
Exemple #4
0
/**
 * Convert YYYYMMDDHHIISS format to Unix timestamp.
 * This function assumes the internal timezone.
 *
 * @param string $str Time in YYYYMMDDHHIISS format
 * @return int
 */
function ztime($str)
{
    if (!$str) {
        return null;
    }
    $year = (int) substr($str, 0, 4);
    $month = (int) substr($str, 4, 2) ?: 1;
    $day = (int) substr($str, 6, 2) ?: 1;
    if (strlen($str) >= 8) {
        $hour = (int) substr($str, 8, 2);
        $min = (int) substr($str, 10, 2);
        $sec = (int) substr($str, 12, 2);
    } else {
        $hour = $min = $sec = 0;
    }
    $timestamp = gmmktime($hour, $min, $sec, $month, $day, $year);
    $offset = Rhymix\Framework\Config::get('locale.internal_timezone') ?: date('Z', $timestamp);
    return $timestamp - $offset;
}
Exemple #5
0
 /**
  * Display FTP Configuration(settings) page
  * @return void
  */
 function dispAdminConfigFtp()
 {
     Context::set('ftp_info', Rhymix\Framework\Config::get('ftp'));
     Context::set('sftp_support', function_exists('ssh2_sftp'));
     $this->setTemplateFile('config_ftp');
 }
Exemple #6
0
 /**
  * Find selected languages to serve in the site
  *
  * @return array Selected languages
  */
 public static function loadLangSelected()
 {
     static $lang_selected = array();
     if (!count($lang_selected)) {
         $supported = Rhymix\Framework\Lang::getSupportedList();
         $selected = Rhymix\Framework\Config::get('locale.enabled_lang');
         if ($selected) {
             foreach ($selected as $lang) {
                 $lang_selected[$lang] = $supported[$lang]['name'];
             }
         } else {
             $lang_selected = array_map(function ($val) {
                 return $val['name'];
             }, $supported);
         }
     }
     return $lang_selected;
 }
 /**
  * @brief Install with received information
  */
 function procInstall($install_config = null)
 {
     // Check if it is already installed
     if (Context::isInstalled()) {
         return new Object(-1, 'msg_already_installed');
     }
     // Get install parameters.
     $config = Rhymix\Framework\Config::getDefaults();
     if ($install_config) {
         $install_config = (array) $install_config;
         $config['db']['master']['type'] = str_replace('_innodb', '', $install_config['db_type']);
         $config['db']['master']['host'] = $install_config['db_hostname'];
         $config['db']['master']['port'] = $install_config['db_port'];
         $config['db']['master']['user'] = $install_config['db_userid'];
         $config['db']['master']['pass'] = $install_config['db_password'];
         $config['db']['master']['database'] = $install_config['db_database'];
         $config['db']['master']['prefix'] = $install_config['db_table_prefix'];
         $config['db']['master']['charset'] = $install_config['db_charset'];
         $config['db']['master']['engine'] = strpos($install_config['db_type'], 'innodb') !== false ? 'innodb' : (strpos($install_config['db_type'], 'mysql') !== false ? 'myisam' : null);
         $config['use_rewrite'] = $install_config['use_rewrite'] === 'Y' ? true : false;
         $config['url']['ssl'] = $install_config['use_ssl'] ?: 'none';
         $time_zone = $install_config['time_zone'];
         $user_info = new stdClass();
         $user_info->email_address = $install_config['email_address'];
         $user_info->password = $install_config['password'];
         $user_info->nick_name = $install_config['nick_name'];
         $user_info->user_id = $install_config['user_id'];
     } else {
         $config['db']['master']['type'] = str_replace('_innodb', '', $_SESSION['db_config']->db_type);
         $config['db']['master']['host'] = $_SESSION['db_config']->db_host;
         $config['db']['master']['port'] = $_SESSION['db_config']->db_port;
         $config['db']['master']['user'] = $_SESSION['db_config']->db_user;
         $config['db']['master']['pass'] = $_SESSION['db_config']->db_pass;
         $config['db']['master']['database'] = $_SESSION['db_config']->db_database;
         $config['db']['master']['prefix'] = $_SESSION['db_config']->db_prefix;
         $config['db']['master']['charset'] = $_SESSION['db_config']->db_charset;
         $config['db']['master']['engine'] = strpos($_SESSION['db_config']->db_type, 'innodb') !== false ? 'innodb' : (strpos($_SESSION['db_config']->db_type, 'mysql') !== false ? 'myisam' : null);
         $config['use_rewrite'] = $_SESSION['use_rewrite'] === 'Y' ? true : false;
         $config['url']['ssl'] = Context::get('use_ssl') ?: 'none';
         $time_zone = Context::get('time_zone');
         $user_info = Context::gets('email_address', 'password', 'nick_name', 'user_id');
     }
     // Fix the database table prefix.
     $config['db']['master']['prefix'] = rtrim($config['db']['master']['prefix'], '_');
     if ($config['db']['master']['prefix'] !== '') {
         $config['db']['master']['prefix'] .= '_';
     }
     // Set the default language.
     $config['locale']['default_lang'] = Context::getLangType();
     $config['locale']['enabled_lang'] = array($config['locale']['default_lang']);
     // Set the default time zone.
     if (strpos($time_zone, '/') !== false) {
         $config['locale']['default_timezone'] = $time_zone;
         $user_timezone = null;
     } else {
         $user_timezone = intval(Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat($time_zone ?: '+0900') / 3600);
         switch ($user_timezone) {
             case 9:
                 $config['locale']['default_timezone'] = 'Asia/Seoul';
                 break;
             case 0:
                 $config['locale']['default_timezone'] = 'Etc/UTC';
                 break;
             default:
                 $config['locale']['default_timezone'] = 'Etc/GMT' . ($user_timezone > 0 ? '-' : '+') . abs($user_timezone);
         }
     }
     // Set the internal time zone.
     if ($config['locale']['default_timezone'] === 'Asia/Seoul') {
         $config['locale']['internal_timezone'] = 32400;
     } elseif ($user_timezone !== null) {
         $config['locale']['internal_timezone'] = $user_timezone * 3600;
     } else {
         $config['locale']['internal_timezone'] = 0;
     }
     // Set the default URL.
     $config['url']['default'] = Context::getRequestUri();
     // Load the new configuration.
     Rhymix\Framework\Config::setAll($config);
     Context::loadDBInfo($config);
     // Check DB.
     $oDB = DB::getInstance();
     if (!$oDB->isConnected()) {
         return $oDB->getError();
     }
     // Assign a temporary administrator while installing.
     foreach ($user_info as $key => $val) {
         Context::set($key, $val, true);
     }
     $user_info->is_admin = 'Y';
     Context::set('logged_info', $user_info);
     // Install all the modules.
     try {
         $oDB->begin();
         $this->installDownloadedModule();
         $oDB->commit();
     } catch (Exception $e) {
         $oDB->rollback();
         return new Object(-1, $e->getMessage());
     }
     // Execute the install script.
     $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\\.php)$/');
     if (count($scripts)) {
         sort($scripts);
         foreach ($scripts as $script) {
             $script_path = FileHandler::getRealPath('./modules/install/script/');
             $output = (include $script_path . $script);
         }
     }
     // Apply site lock.
     if (Context::get('use_sitelock') === 'Y') {
         $user_ip_range = getView('install')->detectUserIPRange();
         Rhymix\Framework\Config::set('lock.locked', true);
         Rhymix\Framework\Config::set('lock.message', 'This site is locked.');
         Rhymix\Framework\Config::set('lock.allow', array('127.0.0.1', $user_ip_range));
     }
     // Save the new configuration.
     Rhymix\Framework\Config::save();
     // Unset temporary session variables.
     unset($_SESSION['use_rewrite']);
     unset($_SESSION['db_config']);
     // Redirect to the home page.
     $this->setMessage('msg_install_completed');
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : RX_BASEURL;
     $this->setRedirectUrl($returnUrl);
     return new Object();
 }
 /**
  * Migrate from previous configuration format.
  */
 public function migrateConfig($config)
 {
     $systemconfig = array();
     if (isset($config->sending_method)) {
         $systemconfig['mail.type'] = $config->sending_method;
     } elseif (isset($config->send_type)) {
         $systemconfig['mail.type'] = $config->send_type;
     }
     if ($systemconfig['mail.type'] === 'mail') {
         $systemconfig['mail.type'] = 'mailfunction';
     }
     if (isset($config->username)) {
         if (in_array('username', $this->sending_methods[$config->sending_method]['conf'])) {
             $config->{$config->sending_method . '_username'} = $config->username;
         }
         unset($config->username);
     }
     if (isset($config->password)) {
         if (in_array('password', $this->sending_methods[$config->sending_method]['conf'])) {
             $config->{$config->sending_method . '_password'} = $config->password;
         }
         unset($config->password);
     }
     if (isset($config->domain)) {
         if (in_array('domain', $this->sending_methods[$config->sending_method]['conf'])) {
             $config->{$config->sending_method . '_domain'} = $config->domain;
         }
         unset($config->domain);
     }
     if (isset($config->api_key)) {
         if (in_array('api_key', $this->sending_methods[$config->sending_method]['conf'])) {
             $config->{$config->sending_method . '_api_key'} = $config->api_key;
         }
         unset($config->api_key);
     }
     if (isset($config->account_type)) {
         if (in_array('account_type', $this->sending_methods[$config->sending_method]['conf'])) {
             $config->{$config->sending_method . '_account_type'} = $config->account_type;
         }
         unset($config->account_type);
     }
     if (isset($config->aws_region)) {
         $config->ses_region = $config->aws_region;
         unset($config->aws_region);
     }
     if (isset($config->aws_access_key)) {
         $config->ses_access_key = $config->aws_access_key;
         unset($config->aws_access_key);
     }
     if (isset($config->aws_secret_key)) {
         $config->ses_secret_key = $config->aws_secret_key;
         unset($config->aws_secret_key);
     }
     $mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers();
     foreach ($mail_drivers as $driver_name => $driver_definition) {
         foreach ($config as $key => $value) {
             if (strncmp($key, $driver_name . '_', strlen($driver_name) + 1) === 0) {
                 $subkey = substr($key, strlen($driver_name) + 1);
                 switch ($subkey) {
                     case 'host':
                     case 'port':
                     case 'security':
                         $systemconfig["mail.{$driver_name}.smtp_" . $subkey] = $value;
                         break;
                     case 'username':
                     case 'password':
                         $systemconfig["mail.{$driver_name}." . ($driver_name === 'smtp' ? 'smtp_' : 'api_') . substr($subkey, 0, 4)] = $value;
                         break;
                     case 'account_type':
                     case 'region':
                         $systemconfig["mail.{$driver_name}.api_type"] = $value;
                         break;
                     case 'access_key':
                         $systemconfig["mail.{$driver_name}.api_user"] = $value;
                         break;
                     case 'secret_key':
                         $systemconfig["mail.{$driver_name}.api_pass"] = $value;
                         break;
                     case 'domain':
                         $systemconfig["mail.{$driver_name}.api_domain"] = $value;
                         break;
                     case 'api_key':
                         $systemconfig["mail.{$driver_name}.api_token"] = $value;
                         break;
                     default:
                         break;
                 }
                 unset($config->{$key});
             }
         }
     }
     if (count($systemconfig)) {
         foreach ($systemconfig as $key => $value) {
             Rhymix\Framework\Config::set($key, $value);
         }
         Rhymix\Framework\Config::save();
     }
     unset($config->is_enabled);
     unset($config->sending_method);
     unset($config->send_type);
     $config->log_sent_mail = toBool($config->log_sent_mail);
     $config->log_errors = toBool($config->log_errors);
     $config->force_sender = toBool($config->force_sender);
     if (!isset($config->exceptions)) {
         $config->exceptions = array();
     }
     return $config;
 }
 /**
  * Save the exception configuration.
  */
 public function procAdvanced_MailerAdminInsertExceptions()
 {
     // Get the current configuration.
     $config = $this->getConfig();
     $sending_methods = Rhymix\Framework\Mail::getSupportedDrivers();
     // Get and validate the list of exceptions.
     $exceptions = array();
     for ($i = 1; $i <= 3; $i++) {
         $method = strval(Context::get('exception_' . $i . '_method'));
         $domains = trim(Context::get('exception_' . $i . '_domains'));
         if ($method !== '' && $domains !== '') {
             if ($method !== 'default' && !isset($sending_methods[$method])) {
                 return new Object(-1, 'msg_advanced_mailer_sending_method_is_invalid');
             }
             if ($method !== 'default') {
                 foreach ($this->sending_methods[$method]['required'] as $conf_name) {
                     if (!Rhymix\Framework\Config::get("mail.{$method}.{$conf_name}")) {
                         return new Object(-1, sprintf(Context::getLang('msg_advanced_mailer_sending_method_is_not_configured'), Context::getLang('cmd_advanced_mailer_sending_method_' . $method)));
                     }
                 }
             }
             $exceptions[$i]['method'] = $method;
             $exceptions[$i]['domains'] = array();
             $domains = array_map('trim', preg_split('/[,\\n]/', $domains, null, PREG_SPLIT_NO_EMPTY));
             foreach ($domains as $domain) {
                 if (strpos($domain, 'xn--') !== false) {
                     $domain = Rhymix\Framework\URL::decodeIdna($domain);
                 }
                 $exceptions[$i]['domains'][] = $domain;
             }
         }
     }
     // Save the new configuration.
     $config->exceptions = $exceptions;
     $output = getController('module')->insertModuleConfig('advanced_mailer', $config);
     if ($output->toBool()) {
         $this->setMessage('success_registed');
     } else {
         return $output;
     }
     if (Context::get('success_return_url')) {
         $this->setRedirectUrl(Context::get('success_return_url'));
     } else {
         $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminExceptions'));
     }
 }
Exemple #10
0
                }
                $filename .= isset($matches[3]) && $matches[3] ? '.' . strtolower($matches[3]) : '.class';
                $filename .= '.php';
            }
    }
    if ($filename && file_exists($filename)) {
        include $filename;
    }
});
/**
 * Also include the Composer autoloader.
 */
require_once RX_BASEDIR . 'vendor/autoload.php';
/**
 * Load system configuration.
 */
Rhymix\Framework\Config::init();
/**
 * Install the debugger.
 */
Rhymix\Framework\Debug::registerErrorHandlers(error_reporting());
/**
 * Set the internal timezone.
 */
$internal_timezone = Rhymix\Framework\DateTime::getTimezoneNameByOffset(config('locale.internal_timezone'));
date_default_timezone_set($internal_timezone);
/**
 * Initialize the cache handler.
 */
Rhymix\Framework\Cache::init(Rhymix\Framework\Config::get('cache'));