示例#1
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new ConfigForm(Yii::getPathOfAlias('application.config.settings') . '.php');
     $InitConf = $model->getConfig();
     if (isset($_POST['config'])) {
         $model->updateConfig($_POST['config']);
         if ($model->validate()) {
             $model->saveToFile();
             $this->refresh();
         }
     }
     $this->render('/config', array('model' => $model));
 }
示例#2
0
 public function actionDefault()
 {
     $model = new ConfigForm();
     if (isset($_POST['ConfigForm'])) {
         $model->attributes = $_POST['ConfigForm'];
         $model->save();
         $this->redirect('/admin/config');
     }
     foreach ($model->attributes as $k => $v) {
         $model->{$k} = Config::model()->findByPk($k)->config_value;
     }
     $data = array('model' => $model);
     $this->render('default', $data);
 }
示例#3
0
 public function actionIndex()
 {
     $model = new ConfigForm();
     $form = new CForm('application.views.config.form', $model);
     $model->load();
     if ($form->submitted('submit')) {
         $model->attributes = $_POST['ConfigForm'];
         if ($model->save()) {
             Yii::app()->user->setFlash('config', Yii::t('app', 'Your new options have been saved.'));
         }
         $this->render('index', array('form' => $form, 'model' => $model, 'result' => $result));
     } else {
         $this->render('index', array('form' => $form));
     }
 }
示例#4
0
 public function saveDBInstallStatusConfig($status)
 {
     $conf_form = new ConfigForm($this->config_params_path . $this->install_db);
     $conf_form->updateParam('install_database_status', $status);
     $conf_form->saveToFile();
 }
示例#5
0
 public function createDefaultFiles()
 {
     if (!$this->configExists($this->config_params_path . $this->file_db_long_params)) {
         $db_params = new ConfigForm($this->config_params_path . $this->file_db_long_params);
         $db_params->updateParam('username', '');
         $db_params->updateParam('password', '');
         $db_params->updateParam('host', '');
         $db_params->updateParam('port', '');
         $db_params->updateParam('dbname', '');
         $db_params->saveToFile();
     }
     if (!$this->configExists($this->config_params_path . $this->install_db_long)) {
         $db_params = new ConfigForm($this->config_params_path . $this->install_db_long);
         $db_params->updateParam('checked_database_long_status', 0);
         $db_params->updateParam('install_database_long_status', 0);
         $db_params->saveToFile();
     }
     if (!$this->configExists($this->config_params_path . $this->file_database_long_sync_config)) {
         $conf_form = new ConfigForm($this->config_params_path . $this->file_database_long_sync_config);
         $conf_form->updateParam('sync_id', 'delaircoSyncDb');
         $conf_form->updateParam('periodicity', 'minutely');
         $conf_form->updateParam('interval', 1);
         $conf_form->updateParam('startTime', '');
         $conf_form->updateParam('delete_periodicity', 'DAY');
         $conf_form->updateParam('delete_period', 3);
         $conf_form->updateParam('max_row', 3000);
         $conf_form->saveToFile();
     }
     if (!$this->configExists($this->config_params_path . $this->file_mysql_long)) {
         $conf_form = new ConfigForm($this->config_params_path . $this->file_mysql_long);
         $conf_form->updateParam('class', 'CDbConnection');
         $conf_form->updateParam('connectionString', 'mysql:host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname);
         $conf_form->updateParam('username', $this->user);
         $conf_form->updateParam('password', $this->password);
         $conf_form->updateParam('charset', 'utf8');
         $conf_form->updateParam('emulatePrepare', true);
         $conf_form->updateParam('enableParamLogging', false);
         $conf_form->updateParam('enableProfiling', false);
         $conf_form->updateParam('persistent', true);
         $conf_form->updateParam('initSQLs', array("set time_zone='+00:00';"));
         $conf_form->saveToFile();
     }
 }
示例#6
0
<?php 
if (file_exists('config.php')) {
    include 'config.php';
} else {
    include 'config.php.base';
}
require_once "lib/configform.php";
$configform = new ConfigForm();
?>

<html lang="en">
<?php 
include 'includes/header.php';
?>

<body>
<?php 
include 'includes/topbar.php';
?>

		<div class="container-fluid">
		<div class="row-fluid">

<?php 
include 'includes/leftmenu.php';
?>

			<noscript>
				<div class="alert alert-block span10">
					<h4 class="alert-heading">Warning!</h4>
 /**
  * input and check if database connection is valid
  * create ./protected/config/environment.php file
  *
  * @return void
  */
 public function actionStep2()
 {
     Yii::app()->session->remove('env');
     $model = new ConfigForm();
     if (isset($_POST['ConfigForm']) === true) {
         $model->attributes = $_POST['ConfigForm'];
         $model->password = $_POST['ConfigForm']['password'];
         if ($model->validate() === true) {
             if ($model->checkConnection() !== true) {
                 //Attemting To Create The Database
                 @mysql_connect("{$model->host}", "{$model->username}", "{$model->password}");
                 if (mysql_query("CREATE DATABASE {$model->dbName}")) {
                     $flag_db_created = 1;
                 } else {
                     $flag_db_created = 0;
                 }
             }
             if ($model->checkConnection() === true) {
                 //create enviroment file
                 $configPath = Yii::getPathOfAlias('application.config');
                 $envSampleFile = $configPath . DIRECTORY_SEPARATOR . 'environment-sample.php';
                 if (file_exists($envSampleFile) === false) {
                     throw new CHttpException(500, 'File not found "' . $envSampleFile . '"');
                 }
                 $content = file_get_contents($envSampleFile);
                 $searches = array('@base_url@', '@host@', '@port@', '@dbname@', '@username@', '@password@');
                 $replaces = array($model->baseUrl, $model->host, $model->port, $model->dbName, $model->username, $model->password);
                 $content = str_replace($searches, $replaces, $content);
                 if (is_writable($configPath) === true || is_writable($configPath . '/environment.php') === true) {
                     file_put_contents($configPath . '/environment.php', $content);
                 } else {
                     Yii::app()->session['env'] = $content;
                 }
                 $this->redirect(array('default/step3'));
             } else {
                 $this->render('Step2ErrorDb');
             }
         }
     }
     //Check
     if (isset(Yii::app()->session['key']) and isset(Yii::app()->session['email'])) {
         $key_info['key'] = Yii::app()->session['key'];
         Yii::app()->session->remove('key');
         //Remove
         $key_info['email'] = Yii::app()->session['email'];
         Yii::app()->session->remove('email');
         //Remove
         Yii::app()->session['key'] = $key_info['key'];
         Yii::app()->session['email'] = $key_info['email'];
         $this->render('step2', array('model' => $model));
     } else {
         //session expired or direct link
         $this->redirect(array('index'));
     }
 }
 /**
  * input and check if database connection is valid
  * create ./protected/config/environment.php file
  *
  * @return void
  */
 public function actionStep2()
 {
     Yii::app()->session->remove('env');
     $model = new ConfigForm();
     if (isset($_POST['ConfigForm']) === true) {
         $model->attributes = $_POST['ConfigForm'];
         $model->password = $_POST['ConfigForm']['password'];
         if ($model->validate() === true) {
             if ($model->checkConnection() !== true) {
                 //Attemting To Create The Database
                 @mysql_connect("{$model->host}", "{$model->username}", "{$model->password}");
                 if (mysql_query("CREATE DATABASE {$model->dbName}")) {
                     $flag_db_created = 1;
                 } else {
                     $flag_db_created = 0;
                 }
             }
             if ($model->checkConnection() === true) {
                 //create enviroment file
                 $configPath = Yii::getPathOfAlias('application.config');
                 $envSampleFile = $configPath . DIRECTORY_SEPARATOR . 'environment-sample.php';
                 if (file_exists($envSampleFile) === false) {
                     throw new CHttpException(500, 'File not found "' . $envSampleFile . '"');
                 }
                 $content = file_get_contents($envSampleFile);
                 $searches = array('@base_url@', '@host@', '@port@', '@dbname@', '@username@', '@password@');
                 $replaces = array($model->baseUrl, $model->host, $model->port, $model->dbName, $model->username, $model->password);
                 $content = str_replace($searches, $replaces, $content);
                 if (is_writable($configPath) === true || is_writable($configPath . '/environment.php') === true) {
                     file_put_contents($configPath . '/environment.php', $content);
                 } else {
                     Yii::app()->session['env'] = $content;
                 }
                 $this->redirect(array('default/step3'));
             } else {
                 $this->render('Step2ErrorDb');
             }
         }
     }
     //Check
     if (isset(Yii::app()->session['key']) and isset(Yii::app()->session['email'])) {
         $key_info['key'] = Yii::app()->session['key'];
         Yii::app()->session->remove('key');
         //Remove
         $key_info['email'] = Yii::app()->session['email'];
         Yii::app()->session->remove('email');
         //Remove
         $serverurl = "http://licence-server.open-school.org/server.php";
         // $ch = curl_init ($serverurl);
         // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         // curl_setopt ($ch, CURLOPT_POST, true);
         // curl_setopt ($ch, CURLOPT_POSTFIELDS, $key_info);
         // $result = curl_exec ($ch);
         // $result = json_decode($result, true);
         // if($result['valid'] == 'true')
         if (1) {
             Yii::app()->session['key'] = $key_info['key'];
             Yii::app()->session['email'] = $key_info['email'];
             $this->render('step2', array('model' => $model));
         } else {
             //session contains invalid key
             //die("Invalid Key!");
             echo 'Invalid Key';
             $this->redirect(array('index'));
         }
     } else {
         //session expired or direct link
         $this->redirect(array('index'));
     }
 }
示例#9
0
    public function actionInstall() {
        global $CONFIG; // Путь к файлу конфигурации для его изменения
        $this->layout = "/install-layout";
        $db_error = false;
        $model = new InstallForm;

        if (Yii::app()->params['installed'] !== "yes") {

            if (!is_writable($CONFIG)) {
                $model->addError("site_name", "Файл " . $CONFIG . " должен быть доступен для записи");
            }

            if (!is_writable(Yii::getPathOfAlias('application.config.settings') . ".php")) {
                $model->addError("site_name", "Файл " 
                        .Yii::getPathOfAlias('application.config.settings') . ".php" 
                        . " должен быть доступен для записи");
            }

            if (!is_writable(Yii::getPathOfAlias('application.runtime'))) {
                $model->addError("site_name", "папка " 
                        .Yii::getPathOfAlias('application.runtime') 
                        . " должена быть доступена для записи");
            }

            if (!is_writable(Yii::app()->basePath . "/../assets")) {
                $model->addError("site_name", "папка /assets должена быть доступена для записи");
            }

            if (isset($_POST['InstallForm'])) {
                $model->attributes = $_POST['InstallForm'];

                // данные Mysql 
                $server = trim(stripslashes($_POST['InstallForm']['mysql_server']));
                $username = trim(stripslashes($_POST['InstallForm']['mysql_login']));
                $password = trim(stripslashes($_POST['InstallForm']['mysql_password']));
                $db_name = trim(stripslashes($_POST['InstallForm']['mysql_db_name']));

                // данные пользователя                     
                if (!$model->validate() or $model->userpass !== $model->userpass2) {
                    $model->addError('userpass2', "Пароли не совпадают");
                }

                if (!$model->errors) {
                    $db_con = mysqli_connect($server, $username, $password) or $db_error = mysqli_error();
                    mysqli_select_db($db_con, $db_name) or $db_error = mysqli_error($db_con);
                }

                if (!$db_error and ! $model->errors) {
                    $config_data = require $CONFIG;



                    $dump_file = file_get_contents(Yii::getPathOfAlias('application.data.install') . '.sql');

                    // Сохранение данных о пользователе 
                    $dump_file.=" INSERT INTO `users` 
                                    (`username`, `password`, `email`, `activkey`, `superuser`, `status`)     VALUES "
                            . "('" . $model->username . "', '" . UserModule::encrypting($model->userpass) . "', "
                            . "'" . $model->useremail . "', '" . UserModule::encrypting(microtime() . $model->userpass) . "',"
                            . " 1, 1);";

                    mysqli_multi_query($db_con, $dump_file) or $db_error = mysqli_error($db_con);

                    if (!$db_error) {
                        // Заполнение конфигурации
                        $config_data['components']['db'] = array(
                            'connectionString' => 'mysql:host=' . $server . ';dbname=' . $db_name,
                            'emulatePrepare' => true,
                            'username' => $username,
                            'password' => $password,
                            'charset' => 'utf8',
                            'tablePrefix' => '',
                        );
                        $config_data['name'] = trim(stripslashes($_POST['InstallForm']['site_name']));
                        $config_data['params'] = "require";

                        $config_array_str = var_export($config_data, true);
                        $config_array_str = str_replace("'params' => 'require',", "'params' => require 'settings.php',", $config_array_str);
                        //Сохранение конфигурации 
                        file_put_contents($CONFIG, "<? return " . $config_array_str . " ?>");

                        // Сохранение настроек
                        $settings = new ConfigForm(Yii::getPathOfAlias('application.config.settings') . ".php");
                        $settings->updateParam('adminEmail', $model->useremail);
                        $settings->updateParam('installed', 'yes');
                        $settings->saveToFile();

                        $this->redirect(array('site/index'));
                    }
                }
            }

            $this->render('install', array('model' => $model, 'db_error' => $db_error));
        } else {
            $this->redirect(array('site/index'));
        }
    }
示例#10
0
 public function saveInstallProcessStatus($status)
 {
     $conf_form = new ConfigForm($this->config_params_path . $this->file_install);
     $conf_form->updateParam('install_status', $status);
     $conf_form->saveToFile();
 }