Пример #1
0
 function __construct($filename, $default_filename = '', $upgrade = true)
 {
     if (!file_exists($filename)) {
         if (file_exists($default_filename)) {
             copy($default_filename, $filename);
         } else {
             trigger_error("The INI settings file is missing: {$filename}");
             die;
         }
     }
     $this->_ini_file = $filename;
     $this->load();
     // check for updated ini settings if necessary
     // IF cong/upgrade exists!
     if ($upgrade && file_exists(APP_PATH . 'conf/upgrade')) {
         $new_ini = new Ini($default_filename, '', false);
         $new_ini->load();
         foreach ($new_ini as $key => $value) {
             if ($this->item($key) === null) {
                 $this->item($key, $value);
             }
         }
         $this->save();
         unset($new_ini);
         unlink(APP_PATH . 'conf/upgrade');
     }
 }
Пример #2
0
 public static function getInstance($type = 'ini')
 {
     if (!empty(ConfFactory::$conf)) {
         return ConfFactory::$conf;
     }
     $oObj = new Ini();
     ConfFactory::$conf = $oObj->loadInc(CONFIG_FILE);
     return ConfFactory::$conf;
 }
Пример #3
0
Файл: Ini.php Проект: djdaca/ini
 /**
 		Get static instance of configuration
 		
 		@return \Configuration $_instance
 	**/
 public static function getInstance($config = array())
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self($config);
     }
     return self::$_instance;
 }
Пример #4
0
 public function __construct($language, $segment = '')
 {
     if (Inflector::length($segment)) {
         $fileTranslation = LANGUAGE_PATH . DS . ucwords(Inflector::lower(repl('.', DS, $segment))) . DS . Inflector::lower($language) . '.ini';
     } else {
         $fileTranslation = LANGUAGE_PATH . DS . Inflector::lower($language) . '.ini';
     }
     if (File::exists($fileTranslation)) {
         $ini = new Ini($fileTranslation);
         $translations = $ini->parseIni();
         $this->setSentences($translations);
         Utils::set('ThinTranslate', $this);
     } else {
         throw new Exception('The translation file ' . $fileTranslation . ' does not exist.');
     }
 }
Пример #5
0
 function test_write()
 {
     // write simple structure, with 24 char padding
     $data = array('one' => 'two', 'three' => true);
     $ini = "; <?php /*\n\none                     = two\nthree                   = On\n\n; */ ?>";
     $this->assertEquals($ini, Ini::write($data));
     // write with sections
     $data = array('Section' => array('one' => 'http://www.foo.com/', 'two' => false));
     $ini = "; <?php /*\n\n[Section]\n\none                     = \"http://www.foo.com/\"\ntwo                     = Off\n\n; */ ?>";
     $this->assertEquals($ini, Ini::write($data));
 }
Пример #6
0
  protected function _doGet($key, $filename, $locale_id)
  {
    $path = $this->_getPath($filename, $locale_id);

    if(isset($this->_cache[$path][$key]))
      return $this->_cache[$path][$key];

    if(isset($this->_ini_objects[$path]))
      $ini = $this->_ini_objects[$path];
    else
    {
      $ini = new Ini($path);
      $this->_ini_objects[$path] = $ini;
    }

    if($value = $ini->getOption($key, 'constants'))
      $this->_cache[$path][$key] = $value;

    return $value;
  }
Пример #7
0
 public static function init($locale, $environment, $version)
 {
     $envFilename = Registry::get('applicationPath') . '/.env';
     if (file_exists($envFilename)) {
         $env = Ini::parse($envFilename, true, $locale . '-' . $environment . '-' . $version, 'common', false);
         $env = self::mergeEnvVariables($env);
     } else {
         $env = new \StdClass();
     }
     self::$data = Ini::bindArrayToObject($env);
 }
  function testOverrideUseRealFile()
  {
    $ini = new Ini(LIMB_DIR . '/tests/cases/util/ini_test2.ini', false);

    $this->assertTrue($ini->has_group('test1'));
    $this->assertTrue($ini->has_group('test2'));

    $this->assertEqual($ini->get_option('v1', 'test1'), 1);
    $this->assertEqual($ini->get_option('v2', 'test1'), 2);
    $this->assertEqual($ini->get_option('v3', 'test1'), 3);
    $this->assertEqual($ini->get_option('v1', 'test2'), 1);
  }
Пример #9
0
 public function login($post)
 {
     $param = array();
     $param['username'] = Ini::gSt('LOCAL_UID');
     $param['rememberMe'] = true;
     $model = new formLogin();
     if (Ini::userLevel($param['username'])) {
         $model->attributes = $param;
         if ($model->validate() && $model->login()) {
             $this->renderJSON(array('x' => 'http://admin.' . HOST . '/admin/default/'), true);
         }
     }
     $this->renderJSON(array('errs' => array('Sorry, you don\'t have permission to access admin')), false);
 }
Пример #10
0
 private static function load_static_settings()
 {
     self::$version = self::get_setting(self::SETTING_VERSION);
     self::$internal_path = str_replace("model", "", __DIR__);
     self::$external_path = self::get_setting(self::SETTING_EXTERNAL_PATH);
     self::$rscript_path = self::get_setting(self::SETTING_RSCRIPT_PATH);
     self::$temp_path = self::$internal_path . "temp/";
     self::$main_methods_r_path = self::$internal_path . "R/library/mainmethods.R";
     self::$is_rstudio_on = self::get_setting(self::SETTING_IS_RSTUDIO_ON) == 1;
     self::$rstudio_url = "http://" . $_SERVER['HTTP_HOST'] . ":8787";
     self::$dictionary_path = self::$internal_path . "model/dictionary.xml";
     self::$internal_media_path = self::$internal_path . "media/";
     self::$external_media_path = self::$external_path . "media/";
 }
Пример #11
0
function get_switch($filename, $username)
{
    $switches = array();
    $ini = new Ini();
    $ini->load($filename);
    foreach ($ini->sections() as $host) {
        if ($ini->get($host, "context") == $username) {
            $switch["host"] = $ini->get($host, "host");
            $switch["call-limit"] = $ini->get($host, "call-limit");
            $switches[] = $switch;
        }
    }
    return $switches;
}
Пример #12
0
<?php

/**
 * Global site settings manager.
 */
// keep unauthorized users out
$this->require_acl('admin', 'settings');
// set the layout and page title
$page->layout = 'admin';
$page->title = __('Site Settings');
// create the form
$form = new Form('post', $this);
// set the form data from the global conf() settings, since they've already
// been rewritten with the Appconf::storyteller() ones in bootstrap.php
$form->data = array('site_name' => conf('General', 'site_name'), 'site_domain' => conf('General', 'site_domain') ? conf('General', 'site_domain') : $_SERVER['HTTP_HOST'], 'email_from' => conf('General', 'email_from'), 'timezone' => conf('General', 'timezone'), 'google_analytics_id' => conf('General', 'google_analytics_id'));
echo $form->handle(function ($form) {
    // merge the new values into the settings
    $merged = Appconf::merge('admin', array('Site Settings' => array('site_name' => $_POST['site_name'], 'site_domain' => $_POST['site_domain'], 'email_from' => $_POST['email_from'], 'timezone' => $_POST['timezone'], 'google_analytics_id' => $_POST['google_analytics_id'])));
    // save the settings to disk
    if (!Ini::write($merged, 'conf/app.admin.' . ELEFANT_ENV . '.php')) {
        printf('<p>%s</p>', __('Unable to save changes. Check your permissions and try again.'));
        return;
    }
    // redirect to the main admin page with a notification
    $form->controller->add_notification(__('Settings saved.'));
    $form->controller->redirect('/');
});
Пример #13
0
    } else {
        $resources = User::acl()->resources();
        foreach ($resources as $resource => $label) {
            if (isset($_POST['resources'][$resource])) {
                unset($resources[$resource]);
            } else {
                $resources[$resource] = false;
            }
        }
        $resources['default'] = true;
        $_POST['resources'] = $resources;
    }
    // save the file
    $acl = User::acl();
    unset($acl->rules[$_GET['role']]);
    unset($acl->rules[$_POST['name']]);
    $acl->add_role($_POST['name'], $_POST['resources']['default']);
    foreach ($_POST['resources'] as $resource => $allow) {
        if ($allow) {
            $acl->allow($_POST['name'], $resource);
        } else {
            $acl->deny($_POST['name'], $resource);
        }
    }
    if (!Ini::write($acl->rules, conf('Paths', 'access_control_list'))) {
        $form->controller->add_notification(__('Unable to save the file.'));
        return false;
    }
    $form->controller->add_notification(__('Role saved.'));
    $form->controller->redirect('/user/roles');
});
Пример #14
0
<?php

/**
 * Add a new language to the list, including its name,
 * code, locale, character set, and fallback.
 */
$this->require_acl('admin', 'translator');
$page->layout = 'admin';
$page->title = __('Add language');
$form = new Form('post', $this);
require_once 'apps/translator/lib/Functions.php';
echo $form->handle(function ($form) {
    // Add to lang/languages.php
    $_POST['code'] = strtolower($_POST['code']);
    $_POST['locale'] = strtolower($_POST['locale']);
    if (!empty($_POST['locale'])) {
        $lang = $_POST['code'] . '_' . $_POST['locale'];
    } else {
        $lang = $_POST['code'];
    }
    $i18n = $form->controller->i18n();
    $i18n->languages[$lang] = array('name' => $_POST['name'], 'code' => $_POST['code'], 'locale' => $_POST['locale'], 'charset' => $_POST['charset'], 'fallback' => $_POST['fallback'], 'default' => 'Off', 'date_format' => $_POST['date_format'], 'short_format' => $_POST['short_format'], 'time_format' => $_POST['time_format']);
    uasort($i18n->languages, 'translator_sort_languages');
    if (!Ini::write($i18n->languages, 'lang/languages.php')) {
        return false;
    }
    $form->controller->add_notification(__('Language added.'));
    $form->controller->redirect('/translator/index');
});
Пример #15
0
<?php

require_once 'packages/sys/Ini.class.php';
$ini = new Ini('editplus.ini');
$ini->parse();
echo "<pre>";
print_r($ini->get());
echo "</pre>";
echo Language::string(124);
?>
</b></td>
            </tr>
        </table>
    </legend>
    <select id="formTableSelectMySQLTable" class="fullWidth ui-widget-content ui-corner-all">
        <option value="0">&lt;<?php 
echo Language::string(73);
?>
&gt;</option>
        <?php 
$sql = "SHOW TABLES";
$z = mysql_query($sql);
while ($r = mysql_fetch_array($z)) {
    if (in_array($r[0], Ini::get_user_system_tables()) || $r[0] == $table->name) {
        continue;
    }
    ?>
            <option value="<?php 
    echo $r[0];
    ?>
"><?php 
    echo $r[0];
    ?>
</option>
        <?php 
}
?>
    </select>
</fieldset>
Пример #17
0
 function testParseRealFile()
 {
   $ini = new Ini(LIMB_DIR . '/tests/cases/util/ini_test.ini', false);
   $this->assertEqual($ini->getAll(), array('test' => array('test' => 1)));
 }
Пример #18
0
/project/jobdetails/pj_id/<?php 
    echo $v->project_id;
    ?>
/n/<?php 
    echo Ini::slugstring($v->description);
    ?>
" id="myAccount23"><span class="viewNew"></span><span class="name">View Project</span></a>
											</li>
											<li><a href="<?php 
    echo Yii::app()->request->baseUrl;
    ?>
/project/jobdetails/pj_id/<?php 
    echo $v->project_id;
    ?>
/n/<?php 
    echo Ini::slugstring($v->description);
    ?>
" id="myAccount24"><span class="addPhotoNew"></span><span class="name">Add Photos</span></a>
											</li>
											<li><a href="<?php 
    echo Yii::app()->request->baseUrl;
    ?>
/project/edit?pj_id=<?php 
    echo $v->project_id;
    ?>
" id="myAccount25"><span class="editNew"></span><span class="name">Edit Project</span></a>
											</li>
											<li><a href="javascript:;" class="deleteproject" id="deleteproject_<?php 
    echo $v->project_id;
    ?>
" ><span class="endNew"></span><span class="name">Delete Project</span></a>
Пример #19
0
 /**
  * Fills the $tables property with a list of the directories
  * in inc/conf/quicklinks.xml.
  * 
  * @access	public
  * 
  */
 function getDirs()
 {
     global $loader;
     $loader->import('saf.Misc.Ini');
     $links = Ini::parse('inc/conf/quicklinks.php');
     foreach ($links as $name => $link) {
         if ($name != 'all') {
             $this->tables[$name] = $link->display;
         }
     }
 }
Пример #20
0
 public function create_db_user()
 {
     $user = Ini::$db_users_name_prefix . $this->id;
     $password = User::generate_password();
     $db_name = Ini::$db_users_db_name_prefix . $this->id;
     $sql = sprintf("CREATE USER '%s'@'localhost' IDENTIFIED BY '%s';", $user, $password);
     mysql_query($sql);
     $this->db_login = $user;
     $this->db_password = $password;
     $this->db_name = $db_name;
     parent::mysql_save();
     $sql = sprintf("CREATE DATABASE `%s` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", $db_name);
     mysql_query($sql);
     $sql = sprintf("GRANT ALL PRIVILEGES ON `%s`.* TO '%s'@'localhost'", $db_name, $user);
     mysql_query($sql);
     Ini::create_db_structure();
 }
Пример #21
0
/**
 * Export the configurations by MAC address and file type
 */
$access_role = "reader";
require_once "access.php";
require_once "lib/validate.php";
Header("Content-Type: text/plain; charset=UTF-8");
if ($_GET["type"] == "sig") {
    echo "voipconf\n";
    exit(0);
}
if (($mac = valid_mac($_GET["mac"])) === false) {
    exit(1);
}
require_once "lib/ini.php";
$chan = new Ini();
$chan->load($g_chan_sync);
foreach ($chan->sections() as $user) {
    if ($chan->get($user, "mac") == $mac) {
        $username = $user;
        break;
    }
}
if (!isset($username)) {
    exit(1);
}
switch ($_GET["type"]) {
    case "sbo":
        ?>
[<?php 
        echo $username;
Пример #22
0
?>
					    	<li class="view-more"><a href="" class="btn btn-info" data-toggle="modal" data-target="#myModal">View More<span class="glyphicon glyphicon-chevron-right"></span></a></li>
						</ul>
								<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						  <div class="modal-dialog">
							<div class="modal-content">
							  <div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title" id="myModalLabel">Top Cities</h4>
							  </div>
							  <div class="modal-body">
									<div id="MajorCities">
										<div class="column">
											<ul>
											<?php 
$all_cities = Ini::getCities();
?>
											<?php 
$total = ceil(count($all_cities) / 3);
?>
											<?php 
$ai = 1;
?>
											  <?php 
foreach ($all_cities as $k => $v) {
    ?>
											      <li><a href="<?php 
    echo Yii::app()->request->baseUrl;
    ?>
/contractor/find/city/<?php 
    echo $v->RewriteUrl;
Пример #23
0
 /**
  * Turns an INI structure into an INI formatted string, ready for writing
  * to a file.
  *
  * @param array hash
  * @param string instructions to include as comments in the data
  * @return string
  */
 function write($struct, $instructions = false)
 {
     $out = "; <?php /* DO NOT ALTER THIS LINE, IT IS HERE FOR SECURITY REASONS\n;\n";
     if ($instructions) {
         foreach (preg_split('/\\n/s', $instructions) as $line) {
             $out .= '; ' . $line . "\n";
         }
         $out .= ";\n\n";
     } else {
         $out .= "; WARNING: This file was automatically generated, and it may\n";
         $out .= "; not be wise to edit it by hand.  If there is an interface\n";
         $out .= "; to modify files of this type, please use that interface\n";
         $out .= "; instead of manually editing this file.  If you are not sure\n";
         $out .= "; or are not aware of such an interface, please talk to your\n";
         $out .= "; Sitellite administrator first.\n";
         $out .= ";\n\n";
     }
     if (is_array($struct[array_shift(array_keys($struct))])) {
         $sections = true;
     } else {
         $sections = false;
     }
     // reverse-filter
     $struct = $this->filter($struct, $sections, true);
     foreach ($struct as $key => $value) {
         if (is_array($value)) {
             $out .= "[{$key}]\n\n";
             foreach ($value as $k => $v) {
                 $out .= str_pad($k, 24) . '= ' . Ini::writeValue($v) . "\n\n";
             }
         } else {
             $out .= str_pad($key, 24) . '= ' . Ini::writeValue($value) . "\n\n";
         }
     }
     $out .= ";\n; THE END\n;\n; DO NOT ALTER THIS LINE, IT IS HERE FOR SECURITY REASONS */ " . CLOSE_TAG;
     return $out;
 }
Пример #24
0
 private function load_settings()
 {
     include __DIR__ . "/SETTINGS.php";
     self::$path_external = $path_external;
     self::$path_external_media = self::$path_external . "media/";
     self::$path_internal = str_replace("\\", "/", __DIR__) . "/";
     self::$path_internal_media = self::$path_internal . "media/";
     self::$path_r_script = $path_r_script;
     self::$path_r_exe = $path_r_exe;
     self::$path_php_exe = $path_php_exe;
     if ($path_temp != "") {
         self::$path_temp = $path_temp;
     } else {
         self::$path_temp = self::$path_internal . "temp/";
     }
     self::$path_mysql_home = $path_mysql_home;
     if ($path_sock != "") {
         self::$path_unix_sock_dir = $path_sock;
     } else {
         self::$path_unix_sock_dir = self::$path_internal . "socks/";
     }
     self::$path_unix_sock = self::$path_unix_sock_dir . "RConcerto.sock";
     self::$server_socks_type = $server_socks_type == "UNIX" ? 0 : 1;
     self::$server_host = $server_host;
     self::$server_port = $server_port;
     self::$r_instances_timeout = $r_instances_persistant_instance_timeout;
     self::$r_server_timeout = $r_instances_persistant_server_timeout;
     self::$r_max_execution_time = $r_max_execution_time;
     self::$path_online_library_ws = "http://concerto.e-psychometrics.com/demo/online_library/ws.php";
     self::$remote_client_password = $remote_client_password;
     self::$public_registration = $public_registration;
     self::$public_registration_default_UserType_id = $public_registration_default_UserType_id;
     self::$cms_session_keep_alive = $cms_session_keep_alive;
     self::$cms_session_keep_alive_interval = $cms_session_keep_alive_interval;
     self::$unix_locale = $unix_locale;
     self::$contact_emails = $contact_emails;
     self::$forum_url = $forum_url;
     self::$project_homepage_url = $project_homepage_url;
     self::$timer_tamper_prevention = $timer_tamper_prevention;
     self::$timer_tamper_prevention_tolerance = $timer_tamper_prevention_tolerance;
     self::$timezone = $timezone;
     if ($mysql_timezone == "") {
         self::$mysql_timezone = $timezone;
     } else {
         self::$mysql_timezone = $mysql_timezone;
     }
     self::$log_client_side_errors = $log_client_side_errors;
     self::$log_document_unload = $log_document_unload;
 }
Пример #25
0
 /**
  * apply curry.ini settings
  * 
  * @return boolean
  */
 public function applyConfig()
 {
     Loader::load('Ini', 'core');
     Loader::load('Db', 'db');
     $ini = false;
     if ($this->_appEnv == null) {
         // Default section is "product"
         $ini = Ini::load('database.ini', 'product');
     } else {
         $ini = Ini::load('database.ini', $this->_appEnv);
     }
     if ($ini === false) {
         // For the compatibility of a old version.
         $ini = Ini::load('database.ini', 'connection');
     }
     if ($ini !== false) {
         Db::setConfig($ini);
     }
     $ini = Ini::load('curry.ini');
     if ($ini === false) {
         return false;
     }
     if (array_key_exists('dispatch', $ini)) {
         $values = $ini['dispatch'];
         $key = 'plugin_enabled';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] == 1) {
                 $this->dispatcher->enablePlugin(true);
             }
         }
         $key = 'is_send_404';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] != 1) {
                 $this->dispatcher->isSend404(false);
             }
         }
         $key = 'sub_controller_enabled';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] == 1) {
                 $this->router->enableSubController(true);
             }
         }
         $key = 'is_rewrite';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] != 1) {
                 $this->router->isRewrite(false);
             }
         }
         $key = 'default_controller';
         if (array_key_exists($key, $values)) {
             $this->router->setDefaultController($values[$key]);
         }
         $key = 'default_action';
         if (array_key_exists($key, $values)) {
             $this->router->setDefaultAction($values[$key]);
         }
         $key = 'controller_query_key';
         if (array_key_exists($key, $values)) {
             $this->router->setControllerQueryKey($values[$key]);
         }
         $key = 'action_query_key';
         if (array_key_exists($key, $values)) {
             $this->router->setActionQueryKey($values[$key]);
         }
         $key = 'controller_suffix';
         if (array_key_exists($key, $values)) {
             NameManager::setControllerSuffix($values[$key]);
         }
         $key = 'action_suffix';
         if (array_key_exists($key, $values)) {
             NameManager::setActionSuffix($values[$key]);
         }
     }
     if (array_key_exists('view', $ini)) {
         $values = $ini['view'];
         $key = 'class_name';
         if (array_key_exists($key, $values)) {
             $this->dispatcher->setViewClass($values[$key]);
         }
         $key = 'layout_enabled';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] != 1) {
                 ViewAbstract::setDefaultLayoutEnabled(false);
             }
         }
         $key = 'template_extension';
         if (array_key_exists($key, $values)) {
             NameManager::setTemplateExtension($values[$key]);
         }
     }
     if (array_key_exists('request', $ini)) {
         $values = $ini['request'];
         $key = 'auto_trim';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] == 1) {
                 Request::setAutoTrim(true);
             }
         }
     }
     if (array_key_exists('database', $ini)) {
         $values = $ini['database'];
         $key = 'is_singleton';
         if (array_key_exists($key, $values)) {
             if (is_numeric($values[$key]) && $values[$key] == 0) {
                 Db::setIsSingleton(false);
             }
         }
     }
     if (array_key_exists('logger', $ini)) {
         Loader::load('Logger', 'utility');
         $values = $ini['logger'];
         $key = 'system_log';
         if (array_key_exists($key, $values)) {
             Logger::setLogName($values[$key]);
         }
         $key = 'query_log';
         if (array_key_exists($key, $values)) {
             Logger::setLogName($values[$key], 'query');
             Db::enableLogging('query');
         }
         $key = 'output_level';
         if (array_key_exists($key, $values)) {
             $val = strtolower(trim($values[$key]));
             if (is_numeric($val) == false) {
                 $levels = array('debug' => LogLevel::DEBUG, 'info' => LogLevel::INFO, 'warn' => LogLevel::WARN, 'error' => LogLevel::ERROR, 'except' => LogLevel::EXCEPT);
                 if (array_key_exists($val, $levels)) {
                     $val = $levels[$val];
                 } else {
                     $val = LogLevel::NO_OUTPUT;
                 }
             }
             Logger::setOutputLevel($val, 'query');
         }
         $key = 'max_line';
         if (array_key_exists($key, $values)) {
             Logger::setMaxLine($values[$key]);
         }
         $key = 'max_generation';
         if (array_key_exists($key, $values)) {
             Logger::setGeneration($values[$key]);
         }
     }
     if (array_key_exists('loader', $ini)) {
         $values = $ini['loader'];
         $key = 'autoload_dirs';
         if (array_key_exists($key, $values)) {
             $dirs = explode(',', $values[$key]);
             Loader::addAutoloadDirectory($dirs);
         }
     }
     return true;
 }
Пример #26
0
 /**
  * Initialize validator
  *
  * @return void
  */
 public function initValidator()
 {
     $ini = Ini::load('validate.ini', 'error_message');
     if ($ini !== false) {
         Validator::setDefaultErrorMessage($ini);
     }
     if (array_key_exists($this->action, $this->validateRules)) {
         $this->validator->setRules($this->validateRules[$this->action]);
     }
 }
Пример #27
0
 public static function init($locale, $environment, $version)
 {
     self::$data = new \StdClass();
     $config = Ini::parse(Registry::get('applicationPath') . '/configs/config.ini', true, $locale . '-' . $environment . '-' . $version, 'common', true);
     self::$data = $config;
 }
Пример #28
0
    if (!preg_match($valid_setting_name, $setting)) {
        Cli::out('Invalid setting name: ' . $setting, 'error');
        return;
    }
    if ($inner !== null && !preg_match($valid_inner_name, $inner)) {
        Cli::out('Invalid setting key name: ' . $inner, 'error');
        return;
    }
    // build an updated config to save
    $settings = conf();
    if ($inner !== null) {
        $merged = array_replace_recursive($settings, array($section => array($setting => array($inner => $value))));
    } else {
        $merged = array_replace_recursive($settings, array($section => array($setting => $value)));
    }
    if (!Ini::write($merged, 'conf/' . ELEFANT_ENV . '.php')) {
        Cli::out('Unable to save changes to: conf/' . ELEFANT_ENV . '.php', 'error');
    }
    // show setting info
} else {
    // list sections
    if (!isset($_SERVER['argv'][2])) {
        $settings = conf();
        $sections = array_keys($settings);
        sort($sections);
        echo join(', ', $sections) . "\n";
        return;
    }
    $parts = explode('.', $_SERVER['argv'][2]);
    // list settings in section
    if (count($parts) === 1) {
  function testCacheHit()
  {
    registerTestingIni(
      'testing2.ini',
      'test = 1'
    );

    registerTestingIni(
      'testing2.ini.override',
      'test = 2'
    );

    $ini = new Ini(VAR_DIR . 'testing2.ini', true); //ini should be cached here...

    $ini_mock = new IniMockVersionOverride($this);

    touch($ini->getCacheFile(), time()+100);

    $ini_mock->expectNever('_parse');
    $ini_mock->expectNever('_saveCache');

    $ini_mock->__construct(VAR_DIR . 'testing2.ini', true);

    $ini_mock->tally();

    $ini->resetCache();
  }
Пример #30
0
 /**
  * Perform the installation associated with the step.
  * Variables required by the installation are stored within the session.
  *
  * @author KnowledgeTree Team
  * @access public
  */
 public function installStep()
 {
     // get data from the server
     $conf = $this->getDataFromSession("configuration");
     $server = $conf['server'];
     $paths = $conf['paths'];
     // initialise writing to config.ini
     $configPath = realpath('../../config/config.ini');
     $ini = false;
     if (file_exists($configPath)) {
         $ini = new Ini($configPath);
     }
     // initialise the db connection
     // retrieve database information from session
     $dbconf = $this->getDataFromSession("database");
     // make db connection
     $this->_dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']);
     // add db config to server variables
     $server = $this->registerDBConfig($server, $dbconf);
     $table = 'config_settings';
     // write server settings to config_settings table and config.ini
     foreach ($server as $item) {
         switch ($item['where']) {
             case 'file':
                 $value = $item['value'];
                 if ($value == 'yes') {
                     $value = 'true';
                 }
                 if ($value == 'no') {
                     $value = 'false';
                 }
                 if (!$ini === false) {
                     $ini->updateItem($item['section'], $item['setting'], $value);
                 }
                 break;
             case 'db':
                 $value = mysql_real_escape_string($item['value']);
                 $setting = mysql_real_escape_string($item['setting']);
                 $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'";
                 $this->_dbhandler->query($sql);
                 break;
         }
     }
     // write the paths to the config_settings table
     if (is_array($paths)) {
         foreach ($paths as $item) {
             if (empty($item['setting'])) {
                 continue;
             }
             $value = mysql_real_escape_string($item['path']);
             $setting = mysql_real_escape_string($item['setting']);
             $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'";
             $this->_dbhandler->query($sql);
         }
     }
     // write out the config.ini file
     if (!$ini === false) {
         $ini->write();
     }
     // close the database connection
     $this->_dbhandler->close();
 }