public function show()
 {
     /**
      * Прописываем параметры в конфиг
      */
     $aSave = array('module.blog.encrypt' => md5(time() . mt_rand()), 'module.talk.encrypt' => md5(time() . mt_rand()), 'module.security.hash' => md5(time() . mt_rand()));
     InstallConfig::save($aSave);
 }
 public function actionStep4()
 {
     error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
     $conf_form = new InstallConfig();
     $conf_form_long = new AdminConfig();
     $conf_form->getAvailableStep();
     if ($conf_form->available_step < 4) {
         $this->redirect($this->createUrl('install/step3'));
     }
     if (Yii::app()->request->isPostRequest && isset($_POST['schedule'])) {
         $conf_form->setSchedule();
         $conf_form_long->deleteSync();
         $conf_form_long->createSync();
     }
     $conf_form->getAvailableStep();
     $this->render('step4', array('conf_form' => $conf_form, 'conf_form_long' => $conf_form_long));
 }
Example #3
0
 public function actionIndex($step = 0)
 {
     try {
         if (isset(Yii::$app->dbMain)) {
             if (!isset(Yii::$app->user->Install)) {
                 return;
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     //print_r(Yii::$app->dbMain);
     Yii::$app->user->setState('Install', 1);
     if (isset($_POST['InstallConfig'])) {
         $model = new InstallConfig();
         $model->attributes = $_POST['InstallConfig'];
         if ($model->make()) {
             unset(Yii::$app->user->Install);
             $this->redirect(Yii::$app->createAbsoluteUrl('install/user'));
         }
         //exit;
     }
     if ($step == 0) {
         //pre
         $model = new InstallPre();
         return $this->render('Pre', array('model' => $model));
     }
     if ($step == 1) {
         //recheck
         $model = new InstallPre();
         return $this->renderPartial('Pre', array('model' => $model));
     }
     if ($step == 2) {
         //config
         $model = new InstallConfig();
         return $this->renderPartial('config', array('model' => $model));
     }
     //*/
 }
Example #4
0
 /**
  * Обработка отправки формы
  *
  * @return bool
  */
 public function process()
 {
     /**
      * Проверяем корректность емайла
      */
     $sMail = InstallCore::getRequestStr('admin_mail');
     if (!preg_match("/^[\\da-z\\_\\-\\.\\+]+@[\\da-z_\\-\\.]+\\.[a-z]{2,5}\$/i", $sMail)) {
         return $this->addError(InstallCore::getLang('steps.installAdmin.errors.mail'));
     }
     /**
      * Проверяем корректность пароль
      */
     $sPasswd = InstallCore::getRequestStr('admin_passwd');
     if (mb_strlen($sPasswd, 'UTF-8') < 3) {
         return $this->addError(InstallCore::getLang('steps.installAdmin.errors.passwd'));
     }
     /**
      * Получаем данные коннекта к БД из конфига
      */
     InstallConfig::$sFileConfig = dirname(INSTALL_DIR) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.local.php';
     /**
      * Коннект к серверу БД
      */
     if (!($oDb = $this->getDBConnection(InstallConfig::get('db.params.host'), InstallConfig::get('db.params.port'), InstallConfig::get('db.params.user'), InstallConfig::get('db.params.pass')))) {
         return false;
     }
     /**
      * Выбираем БД
      */
     if (!@mysqli_select_db($oDb, InstallConfig::get('db.params.dbname'))) {
         return $this->addError(InstallCore::getLang('db.errors.db_query'));
     }
     /**
      * Обновляем пользователя
      */
     $sPrefix = InstallConfig::get('db.table.prefix');
     $sQuery = "\n\t\t\tUPDATE `{$sPrefix}user`\n\t\t\tSET\n\t\t\t\t`user_mail`\t = '{$sMail}',\n\t\t\t\t`user_admin`\t = '1',\n\t\t\t\t`user_password` = '" . md5($sPasswd) . "'\n\t\t\tWHERE `user_id` = 1";
     if (!mysqli_query($oDb, $sQuery)) {
         return $this->addError(InstallCore::getLang('db.errors.db_query'));
     }
     return true;
 }
<div class="complete">
    <p>
        Теперь обязательно удалите каталог <b>/application/install/</b> и можете <a href="<?php 
echo InstallConfig::get('path.root.web');
?>
">перейти на сайт</a>.
        <br/>
        Приятного использования новой версией LiveStreet!
    </p>
</div>
Example #6
0
 public function afterSave()
 {
     if ($this->scenario == 'mail') {
         if ($this->mail__use_fake_sendmail) {
             $sendmail_ini_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR . "sendmail.ini";
             $values = parse_ini_file($sendmail_ini_path, true);
             $values['sendmail']['smtp_server'] = $this->mail__smtp_server;
             $values['sendmail']['smtp_port'] = $this->mail__smtp_port;
             $values['sendmail']['smtp_ssl'] = $this->mail__smtps_support;
             $values['sendmail']['auth_username'] = $this->mail__sender_address;
             $values['sendmail']['auth_password'] = $this->mail__sender_password;
             InstallConfig::setConfigSection('sendmail', $values['sendmail'], $sendmail_ini_path);
         }
     }
     parent::afterSave();
 }
Example #7
0
 public static function checkFile($bCheckWritable = true)
 {
     if (is_null(self::$sFileConfig) or !file_exists(self::$sFileConfig)) {
         self::$sLastError = InstallCore::getLang('config.errors.file_not_found');
         return false;
     }
     if ($bCheckWritable) {
         if (!is_writable(self::$sFileConfig)) {
             self::$sLastError = InstallCore::getLang('config.errors.file_not_writable');
             return false;
         }
     }
     return true;
 }
Example #8
0
 public function testGetData()
 {
     $date = date('r');
     $object = new InstallConfig(['date' => $date]);
     $this->assertSame(['date' => $date], $object->getData());
 }
Example #9
0
 protected function processDbCheck()
 {
     /**
      * Коннект к серверу БД
      */
     if (!($oDb = $this->getDBConnection(InstallCore::getRequestStr('db.params.host'), InstallCore::getRequestStr('db.params.port'), InstallCore::getRequestStr('db.params.user'), InstallCore::getRequestStr('db.params.pass')))) {
         return false;
     }
     /**
      * Выбор БД
      */
     $sNameDb = InstallCore::getRequestStr('db.params.dbname');
     if (!InstallCore::getRequest('db_create')) {
         if (!@mysqli_select_db($oDb, $sNameDb)) {
             return $this->addError(InstallCore::getLang('steps.installDb.errors.db_not_found'));
         }
     } else {
         /**
          * Пытаемся создать БД
          */
         @mysqli_query($oDb, "CREATE DATABASE IF NOT EXISTS `{$sNameDb}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
         if (!@mysqli_select_db($oDb, $sNameDb)) {
             return $this->addError(InstallCore::getLang('steps.installDb.errors.db_not_create'));
         }
     }
     /**
      * Проверяем корректность префикса таблиц
      */
     if (!preg_match('#^[a-z0-9\\_]*$#i', InstallCore::getRequestStr('db.table.prefix'))) {
         return $this->addError(InstallCore::getLang('steps.installDb.errors.db_table_prefix'));
     }
     /**
      * Определяем поддержку InnoDB
      */
     $sEngineDB = 'MyISAM';
     if ($aRes = @mysqli_query($oDb, 'SHOW ENGINES')) {
         while ($aRow = mysqli_fetch_assoc($aRes)) {
             if (strtoupper($aRow['Engine']) == 'INNODB' and in_array(strtoupper($aRow['Support']), array('DEFAULT', 'YES'))) {
                 $sEngineDB = 'InnoDB';
                 break;
             }
         }
     }
     $sPathRootWeb = $this->getPathRootWeb();
     $aDirs = array();
     $sDirs = trim(str_replace('http://' . $_SERVER['HTTP_HOST'], '', $sPathRootWeb), '/');
     if ($sDirs != '') {
         $aDirs = explode('/', $sDirs);
     }
     /**
      * Прописываем параметры в конфиг
      */
     $aSave = array('db.params.host' => InstallCore::getRequestStr('db.params.host'), 'db.params.port' => InstallCore::getRequestStr('db.params.port'), 'db.params.dbname' => InstallCore::getRequestStr('db.params.dbname'), 'db.params.user' => InstallCore::getRequestStr('db.params.user'), 'db.params.pass' => InstallCore::getRequestStr('db.params.pass'), 'db.table.prefix' => InstallCore::getRequestStr('db.table.prefix'), 'db.tables.engine' => $sEngineDB, 'path.root.web' => $sPathRootWeb, 'path.offset_request_url' => count($aDirs));
     if (!InstallConfig::save($aSave)) {
         return $this->addError(InstallConfig::$sLastError);
     }
     return array($oDb, $sEngineDB);
 }
 public function m_0_4_1()
 {
     @apache_setenv('no-gzip', 1);
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     ini_set('memory_limit', '-1');
     //ob_start();
     $this->flushNotification('...Please wait... Updating is going on... DO NOT LEAVE THIS PAGE!');
     $this->flushNotification('<br/>...Going to add "is_last" fields to `listener_log` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . ListenerLog::model()->tableName() . "` LIKE 'is_last'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `" . ListenerLog::model()->tableName() . "` ADD `is_last` tinyint(1) NOT NULL DEFAULT '0' AFTER `is_processed`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $stations = Yii::app()->db->createCommand("SELECT * FROM `" . Station::model()->tableName() . "`")->queryAll();
         if ($stations) {
             foreach ($stations as $key => $value) {
                 ListenerLog::updateIsLastForStation($value['station_id']);
             }
         }
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... not need');
     }
     $this->flushNotification('<br/>...Going to add "is_processing" column to `listener_log` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . ListenerLog::model()->tableName() . "` LIKE 'is_processing'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `" . ListenerLog::model()->tableName() . "` ADD `is_processing` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_processed`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... not need');
     }
     // station
     $this->flushNotification('<br/><br/>Station table:');
     $this->flushNotification('<br/>...Going to update  "national_aws_number" field at `station` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . Station::model()->tableName() . "` LIKE 'national_aws_number'")->queryAll();
     if ($res[0]['Null'] == 'NO') {
         Yii::app()->db->createCommand("ALTER TABLE `station` CHANGE `national_aws_number` `national_aws_number`  int(11) DEFAULT '0'")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... not need');
     }
     $this->flushNotification('<br/>...Going to add new column "country_id" to `station` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . Station::model()->tableName() . "` LIKE 'country_id'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `station` ADD `country_id` int(11) NOT NULL DEFAULT '0' AFTER `magnetic_north_offset`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     $this->flushNotification('<br/>...Going to add new column "city_id" to `station` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . Station::model()->tableName() . "` LIKE 'city_id'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `station` ADD `city_id` int(11) NOT NULL DEFAULT '0' AFTER `country_id`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     $this->flushNotification('<br/>...Going to add new column "timezone_offset" to `station` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . Station::model()->tableName() . "` LIKE 'timezone_offset'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `station` ADD `timezone_offset` varchar(20) NOT NULL AFTER `timezone_id`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     $this->flushNotification('<br/>...Going to update "timezone_offset" data in `station` table...');
     $sql = "SELECT `station_id`, `timezone_id` FROM `" . Station::model()->tableName() . "` WHERE `timezone_offset` = ''";
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     if ($res) {
         foreach ($res as $key => $value) {
             $sql = "UPDATE `" . Station::model()->tableName() . "` SET `timezone_offset` = '" . TimezoneWork::getOffsetFromUTC($value['timezone_id'], 1) . "' WHERE `station_id` = '" . $value['station_id'] . "'";
             Yii::app()->db->createCommand($sql)->query();
         }
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... not need');
     }
     $this->flushNotification('<br/>...Going to add new column "awos_msg_source_folder" to `station` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `" . Station::model()->tableName() . "` LIKE 'awos_msg_source_folder'")->queryAll();
     if (!$res) {
         Yii::app()->db->createCommand("ALTER TABLE `station` ADD `awos_msg_source_folder` TEXT CHARACTER SET ucs2 COLLATE ucs2_general_ci NOT NULL AFTER `city_id`")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     // Sensor Data
     $this->flushNotification('<br/>...Going to update `sensor_data` table\'s data...');
     Yii::app()->db->createCommand("UPDATE `sensor_data` SET `period` = 1440 WHERE `period` = 86400")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     //Schedule report
     $this->flushNotification('<br/>...Going to create `schedule_report` table...');
     $tables = array();
     $res = Yii::app()->db->createCommand("SHOW TABLES")->queryAll();
     if ($res) {
         foreach ($res as $key => $value) {
             foreach ($value as $k1 => $v1) {
                 $tables[] = $v1;
             }
         }
     }
     if (!in_array('schedule_report', $tables)) {
         $sql = "CREATE TABLE `schedule_report` (\n                      `schedule_id` int(11) NOT NULL AUTO_INCREMENT,\n                      `report_type` varchar(50) NOT NULL DEFAULT 'synop' COMMENT 'synop, bufr',\n                      `station_id` int(11) NOT NULL,\n                      `period` int(11) NOT NULL DEFAULT '60' COMMENT 'in minutes',\n                      `method` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'email, ftp',\n                      `destination_email` varchar(255) NOT NULL,\n                      `destination_ip` varchar(15) NOT NULL,\n                      `destination_ip_port` int(5) NOT NULL DEFAULT '21',\n                      `destination_ip_folder` varchar(255) NOT NULL DEFAULT '/',\n                      `destination_ip_user` varchar(255) NOT NULL,\n                      `destination_ip_password` varchar(255) NOT NULL,\n                      `report_format` varchar(20) NOT NULL DEFAULT 'csv' COMMENT 'txt, csv',\n                      `last_scheduled_run_fact` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      `last_scheduled_run_planned` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      `updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      PRIMARY KEY (`schedule_id`)\n                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
         Yii::app()->db->createCommand($sql)->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     $this->flushNotification('<br/>...Going to create `schedule_report_processed` table...');
     if (!in_array('schedule_report_processed', $tables)) {
         $sql = "CREATE TABLE `schedule_report_processed` (\n                      `schedule_processed_id` int(11) NOT NULL AUTO_INCREMENT,\n                      `schedule_id` int(11) NOT NULL,\n                      `listener_log_id` int(11) NOT NULL,\n                      `is_processed` tinyint(1) NOT NULL DEFAULT '0',\n                      `report_string_initial` text NOT NULL,\n                      `report_string_changed` text NOT NULL,\n                      `serialized_report_problems` text NOT NULL,\n                      `serialized_report_errors` text NOT NULL,\n                      `serialized_report_explanations` text NOT NULL,\n                      `is_last` tinyint(1) NOT NULL DEFAULT '0',\n                      `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      `updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n                      PRIMARY KEY (`schedule_processed_id`),\n                      KEY `schedule_id` (`schedule_id`),\n                      KEY `listener_log_id` (`listener_log_id`),\n                      CONSTRAINT `schedule_report_processed_fk` FOREIGN KEY (`schedule_id`) REFERENCES `schedule_report` (`schedule_id`) ON DELETE CASCADE ON UPDATE NO ACTION,\n                      CONSTRAINT `schedule_report_processed_ibfk_1` FOREIGN KEY (`listener_log_id`) REFERENCES `listener_log` (`log_id`) ON DELETE CASCADE ON UPDATE NO ACTION\n                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
         Yii::app()->db->createCommand($sql)->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     // metrics
     $this->flushNotification('<br/><br/>New Metrics:');
     $this->flushNotification('<br/>...Going to add new metric "kJ/sq.m" ...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_metric` (`metric_id`, `html_code`, `short_name`, `full_name`, `code`) VALUES ('21', 'kJ/sq.m', 'kJ/sq.m', 'Kilo Joule per square meter', 'kjoule_per_sq_meter')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new metric "feet"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_metric` (`metric_id`, `html_code`, `short_name`, `full_name`, `code`) VALUES ('22', 'ft', 'ft', 'Feet', 'feet')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new metric "km"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_metric` (`metric_id`,`html_code`,`short_name`,`full_name`,`code`) VALUES (23 , 'km', 'km', 'Kilometer', 'kilometer')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "solar radiation" and "kj/sq.m"...');
     RefbookMeasurementTypeMetric::model()->deleteByPk(23);
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES ('23', '9', '21', '0')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new measuring type "Cloud Vertical Visibility"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type` (`measurement_type_id`, `display_name`, `code`, `ord`) VALUES (16 ,'Cloud Vertical Visibility', 'cloud_vertical_visibility', '14')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new measuring type "Cloud Height" ...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type` (`measurement_type_id`, `display_name`, `code`, `ord`) VALUES (17, 'Cloud Height', 'cloud_height', 15)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new measuring type "Sea Level" ...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type` (`measurement_type_id`, `display_name`, `code`, `ord`) VALUES (18 , 'Sea Level (Mean, Sigma, Wave Hight)', 'sea_level', '16')")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add relation between "Cloud Vertical Visibility" and "ft" ...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (24,16,22,1)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "Cloud Vertical Visibility" and "meter"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (25,16,11,0)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "Cloud Height" and "ft"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (26,17,22,1)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "Cloud Height" and "meter"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (27,17,11,0)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "Visibility" and "meter"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (28, 11, 11, 1)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to add new relation between "Sea Level" and "meter"...');
     Yii::app()->db->createCommand("INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id`, `measurement_type_id`, `metric_id`, `is_main`) VALUES (29, 18, 11, 1)")->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     // sensor handler
     $this->flushNotification('<br/>...Going to add new column "awos_station_uses" to `sensor_handler` table...');
     $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM `sensor_handler` LIKE 'awos_station_uses'")->queryAll();
     if (!$res) {
         $res = Yii::app()->db->createCommand("ALTER TABLE `sensor_handler` ADD `awos_station_uses` TINYINT( 1 ) NOT NULL DEFAULT '0'")->query();
         Yii::app()->db->createCommand("COMMIT")->query();
         $this->flushNotification(' ... done');
     } else {
         $this->flushNotification(' ... already exists');
     }
     $this->flushNotification('<br/>...Going to update `sensor_handler` table...');
     $sql = "UPDATE `sensor_handler` SET \n                `handler_id_code` = 'SeaLevelAWS',\n                `display_name` = 'Sea Level and Tide Data',\n                `description` = 'Handler \"Sea Level and Tide Data\" : Processes string like \"SL1XXXXYYYYZZZZ\", where <br/>SL1 - device Id; <br/>XXXX - Mean value;<br/>YYYY - Sigma value; <br/>ZZZZ - Wave Height <br/>Example: SL1179017900140 = SL1 sensor sent data: Mean value = 1.79, Sigma value = 1.79, Wave height = 140m.',\n                `default_prefix` = 'SL',\n                `aws_station_uses` = 1,\n                `rain_station_uses` = 0,\n                `awos_station_uses` = 0,\n                `aws_single_group` = 'sea_level'\n                WHERE `handler_id` = 13";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "UPDATE `sensor_handler` SET \n                `handler_id_code` = 'VisibilityAWS',\n                `display_name` = 'Visibility',\n                `description` = 'Handler \"Visibility\"',\n                `default_prefix` = 'VI',\n                `aws_station_uses` = 1,\n                `rain_station_uses` = 0,\n                `awos_station_uses` = 0,\n                `aws_single_group` = 'visibility'\n                WHERE `handler_id` = 14";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "UPDATE `sensor_handler` SET `handler_id_code` = 'CloudHeightAWS',\n                `display_name` = 'Cloud Height',\n                `description` = 'Handler \"Cloud Height\"',\n                `default_prefix` = 'CH',\n                `aws_station_uses` = 1,\n                `rain_station_uses` = 0,\n                `awos_station_uses` = 0,\n                `aws_single_group` = 'clouds'\n                WHERE `handler_id` = 15";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $this->flushNotification('<br/>...Going to update calculation_handler table...');
     $res = Yii::app()->db->createCommand("UPDATE `calculation_handler` SET `display_name` = 'Pressure Adjusted to MSL' WHERE `handler_id` = 2");
     Yii::app()->db->createCommand("COMMIT")->query();
     $this->flushNotification(' ... done');
     $bat_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'at' . DIRECTORY_SEPARATOR . 'schedule.bat';
     $schedule_bat_content = getConfigValue('php_exe_path') . " -f  " . dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "console.php schedule";
     file_put_contents($bat_path, $schedule_bat_content);
     exec('schtasks /create /sc minute /mo 1 /F /ru "SYSTEM" /tn delaircoScheduleScript /tr ' . $bat_path, $output);
     $values = getConfigValue('schedule');
     $values['each_minute_process_id'] = 'delaircoScheduleScript';
     InstallConfig::setConfigSection('schedule', $values);
     $values = getConfigValue('path');
     $values['site_url_for_console'] = It::baseUrl();
     InstallConfig::setConfigSection('path', $values);
     It::memStatus('update__success');
     $this->flushNotification('<script type="text/javascript"> setTimeout(function(){document.location.href="' . Yii::app()->controller->createUrl('update/index') . '"}, 10000)</script>');
 }
Example #11
0
 /**
  * Конвертор версии 1.0.3 в 2.0.0
  *
  * @param $oDb
  *
  * @return bool
  */
 public function convertFrom_1_0_3_to_2_0_0($oDb)
 {
     /**
      * Запускаем SQL патч
      */
     $sFile = 'sql' . DIRECTORY_SEPARATOR . 'patch_1.0.3_to_2.0.0.sql';
     list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath($sFile), array('engine' => InstallConfig::get('db.tables.engine'), 'prefix' => InstallConfig::get('db.table.prefix'), 'check_table' => 'cron_task')));
     if ($bResult) {
         /**
          * Проверяем необходимость конвертировать таблицу плагина Page
          */
         if ($this->dbCheckTable("prefix_page")) {
             $sFile = 'sql' . DIRECTORY_SEPARATOR . 'patch_page_1.3_to_2.0.sql';
             list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath($sFile), array('engine' => InstallConfig::get('db.tables.engine'), 'prefix' => InstallConfig::get('db.table.prefix'), 'check_table_field' => array('prefix_page', 'id'))));
             if (!$bResult) {
                 return $this->addError(join('<br/>', $aErrors));
             }
         }
         /**
          * Конвертируем опросы
          * Сначала проверяем необходимость конвертации опросов
          */
         if ($this->dbCheckTable("prefix_topic_question_vote")) {
             $iPage = 1;
             $iLimitCount = 50;
             $iLimitStart = 0;
             while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'question' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
                 $iPage++;
                 $iLimitStart = ($iPage - 1) * $iLimitCount;
                 /**
                  * Топики
                  */
                 foreach ($aTopics as $aTopic) {
                     $aPollData = @unserialize($aTopic['topic_extra']);
                     if (!isset($aPollData['answers'])) {
                         continue;
                     }
                     /**
                      * Создаем опрос
                      */
                     $aFields = array('user_id' => $aTopic['user_id'], 'target_type' => 'topic', 'target_id' => $aTopic['topic_id'], 'title' => htmlspecialchars($aTopic['topic_title']), 'count_answer_max' => 1, 'count_vote' => isset($aPollData['count_vote']) ? $aPollData['count_vote'] : 0, 'count_abstain' => isset($aPollData['count_vote_abstain']) ? $aPollData['count_vote_abstain'] : 0, 'date_create' => $aTopic['topic_date_add']);
                     if ($iPollId = $this->dbInsertQuery('prefix_poll', $aFields)) {
                         foreach ($aPollData['answers'] as $iAnswerIdOld => $aAnswer) {
                             /**
                              * Создаем вариант ответа
                              */
                             $aFields = array('poll_id' => $iPollId, 'title' => htmlspecialchars($aAnswer['text']), 'count_vote' => htmlspecialchars($aAnswer['count']), 'date_create' => $aTopic['topic_date_add']);
                             if ($iAnswerId = $this->dbInsertQuery('prefix_poll_answer', $aFields)) {
                                 /**
                                  * Получаем список кто голосовал за этот вариант
                                  */
                                 if ($aVotes = $this->dbSelect("SELECT * FROM prefix_topic_question_vote WHERE topic_id = '{$aTopic['topic_id']}' AND answer = '{$iAnswerIdOld}' ")) {
                                     foreach ($aVotes as $aVote) {
                                         /**
                                          * Добавляем новый факт голосования за вариант
                                          */
                                         $aFields = array('poll_id' => $iPollId, 'user_id' => $aVote['user_voter_id'], 'answers' => serialize(array($iAnswerId)), 'date_create' => $aTopic['topic_date_add']);
                                         $this->dbInsertQuery('prefix_poll_vote', $aFields);
                                     }
                                 }
                             }
                         }
                         /**
                          * Добавляем факты голосования воздержавшихся
                          */
                         /**
                          * Получаем список кто голосовал за этот вариант
                          */
                         if ($aVotes = $this->dbSelect("SELECT * FROM prefix_topic_question_vote WHERE topic_id = '{$aTopic['topic_id']}' AND answer = -1 ")) {
                             foreach ($aVotes as $aVote) {
                                 /**
                                  * Добавляем новый факт воздержания
                                  */
                                 $aFields = array('poll_id' => $iPollId, 'user_id' => $aVote['user_voter_id'], 'answers' => serialize(array()), 'date_create' => $aTopic['topic_date_add']);
                                 $this->dbInsertQuery('prefix_poll_vote', $aFields);
                             }
                         }
                     }
                     /**
                      * Меняем тип топика
                      */
                     $this->dbQuery("UPDATE prefix_topic SET topic_type = 'topic' WHERE topic_id ='{$aTopic['topic_id']}'");
                     /**
                      * Убираем лишние данные из topic_extra
                      */
                     unset($aPollData['answers']);
                     unset($aPollData['count_vote_abstain']);
                     unset($aPollData['count_vote']);
                     $sExtra = mysqli_escape_string($this->rDbLink, serialize($aPollData));
                     $this->dbQuery("UPDATE prefix_topic_content SET topic_extra = '{$sExtra}' WHERE topic_id ='{$aTopic['topic_id']}'");
                 }
             }
             /**
              * Удаляем старые таблицы
              */
             if (!$this->getErrors()) {
                 $this->dbQuery('DROP TABLE prefix_topic_question_vote');
             }
         }
         /**
          * Конвертируем топик-ссылки
          */
         $iPage = 1;
         $iLimitCount = 50;
         $iLimitStart = 0;
         while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra, c.topic_text, c.topic_text_short, c.topic_text_source FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'link' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
             $iPage++;
             $iLimitStart = ($iPage - 1) * $iLimitCount;
             /**
              * Топики
              */
             foreach ($aTopics as $aTopic) {
                 $aData = @unserialize($aTopic['topic_extra']);
                 if (!isset($aData['url'])) {
                     continue;
                 }
                 /**
                  * Переносим ссылку в текст топика
                  */
                 $sUrl = $aData['url'];
                 if (strpos($sUrl, '://') === false) {
                     $sUrl = 'http://' . $sUrl;
                 }
                 $sUrl = htmlspecialchars($sUrl);
                 $sTextAdd = "\n<br/><br/><a href=\"{$sUrl}\">{$sUrl}</a>";
                 $aTopic['topic_text'] .= $sTextAdd;
                 $aTopic['topic_text_short'] .= $sTextAdd;
                 $aTopic['topic_text_source'] .= $sTextAdd;
                 unset($aData['url']);
                 $sExtra = mysqli_escape_string($this->rDbLink, serialize($aData));
                 $sText = mysqli_escape_string($this->rDbLink, $aTopic['topic_text']);
                 $sTextShort = mysqli_escape_string($this->rDbLink, $aTopic['topic_text_short']);
                 $sTextSource = mysqli_escape_string($this->rDbLink, $aTopic['topic_text_source']);
                 $this->dbQuery("UPDATE prefix_topic_content SET topic_extra = '{$sExtra}', topic_text = '{$sText}', topic_text_short = '{$sTextShort}', topic_text_source = '{$sTextSource}'  WHERE topic_id ='{$aTopic['topic_id']}'");
                 /**
                  * Меняем тип топика
                  */
                 $this->dbQuery("UPDATE prefix_topic SET topic_type = 'topic' WHERE topic_id ='{$aTopic['topic_id']}'");
             }
         }
         /**
          * Конвертируем топик-фотосеты
          */
         if ($this->dbCheckTable("prefix_topic_photo")) {
             $iPage = 1;
             $iLimitCount = 50;
             $iLimitStart = 0;
             while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra, c.topic_text, c.topic_text_short, c.topic_text_source FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'photoset' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
                 $iPage++;
                 $iLimitStart = ($iPage - 1) * $iLimitCount;
                 /**
                  * Топики
                  */
                 foreach ($aTopics as $aTopic) {
                     $aData = @unserialize($aTopic['topic_extra']);
                     if (!isset($aData['main_photo_id'])) {
                         continue;
                     }
                     /**
                      * Получаем фото
                      */
                     if ($aPhotos = $this->dbSelect("SELECT * FROM prefix_topic_photo WHERE topic_id = '{$aTopic['topic_id']}' ")) {
                         $aMediaItems = array();
                         foreach ($aPhotos as $aPhoto) {
                             /**
                              * Необходимо перенести изображение в media и присоеденить к топику
                              */
                             $sFileSource = $this->convertPathWebToServer($aPhoto['path']);
                             /**
                              * Формируем список старых изображений для удаления
                              */
                             $sMask = pathinfo($sFileSource, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($sFileSource, PATHINFO_FILENAME) . '_*';
                             $aFilesForRemove = array();
                             if ($aPaths = glob($sMask)) {
                                 foreach ($aPaths as $sPath) {
                                     $aFilesForRemove[$sPath] = $sPath;
                                 }
                             }
                             if ($oImage = $this->createImageObject($sFileSource)) {
                                 $iWidth = $oImage->getSize()->getWidth();
                                 $iHeight = $oImage->getSize()->getHeight();
                                 if ($this->resizeImage($oImage, 1000)) {
                                     if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_1000x')) {
                                         unset($aFilesForRemove[$sFileSave]);
                                     }
                                 }
                                 if ($oImage = $this->createImageObject($sFileSource)) {
                                     if ($this->resizeImage($oImage, 500)) {
                                         if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_500x')) {
                                             unset($aFilesForRemove[$sFileSave]);
                                         }
                                     }
                                 }
                                 if ($oImage = $this->createImageObject($sFileSource)) {
                                     if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 100)) {
                                         if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_100x100crop')) {
                                             unset($aFilesForRemove[$sFileSave]);
                                         }
                                     }
                                 }
                                 if ($oImage = $this->createImageObject($sFileSource)) {
                                     if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 50)) {
                                         if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_50x50crop')) {
                                             unset($aFilesForRemove[$sFileSave]);
                                         }
                                     }
                                 }
                                 /**
                                  * Добавляем запись в медиа
                                  */
                                 $aDataMedia = array('image_sizes' => array(array('w' => 1000, 'h' => null, 'crop' => false), array('w' => 500, 'h' => null, 'crop' => false), array('w' => 100, 'h' => 100, 'crop' => true), array('w' => 50, 'h' => 50, 'crop' => true)));
                                 if ($aPhoto['description']) {
                                     $aDataMedia['title'] = htmlspecialchars($aPhoto['description']);
                                 }
                                 $aFields = array('user_id' => $aTopic['user_id'], 'type' => 1, 'target_type' => 'topic', 'file_path' => '[relative]' . str_replace(dirname(dirname(INSTALL_DIR)), '', $sFileSource), 'file_name' => pathinfo($sFileSource, PATHINFO_FILENAME), 'file_size' => filesize($sFileSource), 'width' => $iWidth, 'height' => $iHeight, 'date_add' => $aTopic['topic_date_add'], 'data' => serialize($aDataMedia));
                                 if ($iMediaId = $this->dbInsertQuery('prefix_media', $aFields)) {
                                     /**
                                      * Добавляем связь медиа с топиком
                                      */
                                     $aFields = array('media_id' => $iMediaId, 'target_id' => $aTopic['topic_id'], 'target_type' => 'topic', 'date_add' => $aTopic['topic_date_add'], 'data' => '');
                                     if ($iMediaTargetId = $this->dbInsertQuery('prefix_media_target', $aFields)) {
                                         $sFileWeb = InstallConfig::get('path.root.web') . str_replace(dirname(dirname(INSTALL_DIR)), '', $sFileSource);
                                         $aMediaItems[$iMediaId] = $sFileWeb;
                                     }
                                 }
                                 /**
                                  * Удаляем старые
                                  */
                                 foreach ($aFilesForRemove as $sFileRemove) {
                                     @unlink($sFileRemove);
                                 }
                             }
                         }
                         /**
                          * Добавляем в начало текста топика вывод фотосета
                          */
                         $sCodeRender = '';
                         $sCodeSource = '';
                         if ($aMediaItems) {
                             $sCodeSource = '<gallery items="' . join(',', array_keys($aMediaItems)) . '" nav="thumbs" caption="1" />' . "\n";
                             $sCodeRender = '<div class="fotorama"  data-nav="thumbs" >' . "\n";
                             foreach ($aMediaItems as $iId => $sFileWeb) {
                                 $sCodeRender .= '<img src="' . $sFileWeb . '"  />' . "\n";
                             }
                             $sCodeRender .= '</div>' . "\n";
                         }
                         unset($aData['main_photo_id']);
                         unset($aData['count_photo']);
                         $sExtra = mysqli_escape_string($this->rDbLink, serialize($aData));
                         $sText = mysqli_escape_string($this->rDbLink, $sCodeRender . $aTopic['topic_text']);
                         $sTextShort = mysqli_escape_string($this->rDbLink, $sCodeRender . $aTopic['topic_text_short']);
                         $sTextSource = mysqli_escape_string($this->rDbLink, $sCodeSource . $aTopic['topic_text_source']);
                         $this->dbQuery("UPDATE prefix_topic_content SET topic_extra = '{$sExtra}', topic_text = '{$sText}', topic_text_short = '{$sTextShort}', topic_text_source = '{$sTextSource}'  WHERE topic_id ='{$aTopic['topic_id']}'");
                         /**
                          * Меняем тип топика
                          */
                         $this->dbQuery("UPDATE prefix_topic SET topic_type = 'topic' WHERE topic_id ='{$aTopic['topic_id']}'");
                     }
                 }
             }
             /**
              * Удаляем старые таблицы
              */
             if (!$this->getErrors()) {
                 $this->dbQuery('DROP TABLE prefix_topic_photo');
             }
         }
         /**
          * Конвертируем урлы топиков к ЧПУ формату
          */
         $iPage = 1;
         $iLimitCount = 50;
         $iLimitStart = 0;
         while ($aTopics = $this->dbSelect("SELECT * FROM prefix_topic WHERE topic_slug = '' LIMIT {$iLimitStart},{$iLimitCount}")) {
             $iPage++;
             $iLimitStart = ($iPage - 1) * $iLimitCount;
             /**
              * Топики
              */
             foreach ($aTopics as $aTopic) {
                 $sSlug = InstallCore::transliteration($aTopic['topic_title']);
                 $sSlug = $this->GetUniqueTopicSlug($sSlug, $aTopic['topic_id']);
                 $sSlug = mysqli_escape_string($this->rDbLink, $sSlug);
                 /**
                  * Меняем тип топика
                  */
                 $this->dbQuery("UPDATE prefix_topic SET topic_slug = '{$sSlug}' WHERE topic_id ='{$aTopic['topic_id']}'");
             }
         }
         /**
          * Конвертируем аватарки блогов
          */
         $iPage = 1;
         $iLimitCount = 50;
         $iLimitStart = 0;
         while ($aBlogs = $this->dbSelect("SELECT * FROM prefix_blog  WHERE blog_avatar <> '' and blog_avatar <> '0' and blog_avatar  IS NOT NULL LIMIT {$iLimitStart},{$iLimitCount}")) {
             $iPage++;
             $iLimitStart = ($iPage - 1) * $iLimitCount;
             foreach ($aBlogs as $aBlog) {
                 $sAvatar = $aBlog['blog_avatar'];
                 if (strpos($sAvatar, 'http') === 0) {
                     $sAvatar = preg_replace('#_\\d{1,3}x\\d{1,3}(\\.\\w{3,5})$#i', '\\1', $sAvatar);
                     $sFileSource = $this->convertPathWebToServer($sAvatar);
                     /**
                      * Формируем список старых изображений для удаления
                      */
                     $sMask = pathinfo($sFileSource, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($sFileSource, PATHINFO_FILENAME) . '_*';
                     $aFilesForRemove = array();
                     if ($aPaths = glob($sMask)) {
                         foreach ($aPaths as $sPath) {
                             $aFilesForRemove[$sPath] = $sPath;
                         }
                     }
                     /**
                      * Ресайзим к новым размерам
                      */
                     if ($oImage = $this->createImageObject($sFileSource)) {
                         if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 500)) {
                             if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_500x500crop')) {
                                 unset($aFilesForRemove[$sFileSave]);
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 100)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_100x100crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 64)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_64x64crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 48)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_48x48crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 24)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_24x24crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         /**
                          * Удаляем старые
                          */
                         foreach ($aFilesForRemove as $sFileRemove) {
                             @unlink($sFileRemove);
                         }
                         /**
                          * Меняем путь до аватара
                          */
                         $sAvatar = '[relative]' . str_replace(dirname(dirname(INSTALL_DIR)), '', $sFileSource);
                         $sAvatar = mysqli_escape_string($this->rDbLink, $sAvatar);
                         $this->dbQuery("UPDATE prefix_blog SET blog_avatar = '{$sAvatar}' WHERE blog_id ='{$aBlog['blog_id']}'");
                     }
                 }
             }
         }
         /**
          * Конвертируем аватарки и фото пользователей
          * Дополнительно добавляем роль для прав
          */
         /**
          * Получаем текущий список админов
          */
         $aUserAdmin = array();
         if ($this->dbCheckTable("prefix_user_administrator")) {
             if ($aAdmins = $this->dbSelect("SELECT * FROM prefix_user_administrator ")) {
                 foreach ($aAdmins as $aRow) {
                     $aUserAdmin[] = $aRow['user_id'];
                 }
             }
         }
         $iPage = 1;
         $iLimitCount = 50;
         $iLimitStart = 0;
         while ($aUsers = $this->dbSelect("SELECT * FROM prefix_user LIMIT {$iLimitStart},{$iLimitCount}")) {
             $iPage++;
             $iLimitStart = ($iPage - 1) * $iLimitCount;
             foreach ($aUsers as $aUser) {
                 $sAvatar = $aUser['user_profile_avatar'];
                 $sPhoto = $aUser['user_profile_foto'];
                 /**
                  * Аватарки
                  */
                 if (strpos($sAvatar, 'http') === 0) {
                     $sAvatar = preg_replace('#_\\d{1,3}x\\d{1,3}(\\.\\w{3,5})$#i', '\\1', $sAvatar);
                     $sFileSource = $this->convertPathWebToServer($sAvatar);
                     /**
                      * Формируем список старых изображений для удаления
                      */
                     $sMask = pathinfo($sFileSource, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($sFileSource, PATHINFO_FILENAME) . '_*';
                     $aFilesForRemove = array();
                     if ($aPaths = glob($sMask)) {
                         foreach ($aPaths as $sPath) {
                             $aFilesForRemove[$sPath] = $sPath;
                         }
                     }
                     /**
                      * Ресайзим к новым размерам
                      */
                     if ($oImage = $this->createImageObject($sFileSource)) {
                         if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 100)) {
                             if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_100x100crop')) {
                                 unset($aFilesForRemove[$sFileSave]);
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 64)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_64x64crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 48)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_48x48crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         if ($oImage = $this->createImageObject($sFileSource)) {
                             if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 24)) {
                                 if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_24x24crop')) {
                                     unset($aFilesForRemove[$sFileSave]);
                                 }
                             }
                         }
                         /**
                          * Удаляем старые
                          */
                         foreach ($aFilesForRemove as $sFileRemove) {
                             @unlink($sFileRemove);
                         }
                         /**
                          * Меняем путь до аватара
                          */
                         $sAvatar = '[relative]' . str_replace(dirname(dirname(INSTALL_DIR)), '', $sFileSource);
                     }
                 }
                 /**
                  * Фото
                  */
                 if (strpos($sPhoto, 'http') === 0) {
                     $sFileSource = $this->convertPathWebToServer($sPhoto);
                     /**
                      * Меняем путь до аватара
                      */
                     $sPhoto = '[relative]' . str_replace(dirname(dirname(INSTALL_DIR)), '', $sFileSource);
                 }
                 /**
                  * Права
                  */
                 if (!$this->dbSelectOne("SELECT * FROM prefix_rbac_role_user WHERE user_id = '{$aUser['user_id']}' and role_id = 2 ")) {
                     /**
                      * Добавляем
                      */
                     $aFields = array('user_id' => $aUser['user_id'], 'role_id' => 2, 'date_create' => date("Y-m-d H:i:s"));
                     $this->dbInsertQuery('prefix_rbac_role_user', $aFields);
                 }
                 /**
                  * Timezone
                  */
                 $sTzName = null;
                 if ($aUser['user_settings_timezone']) {
                     $sTzName = $this->convertTzOffsetToName($aUser['user_settings_timezone']);
                 }
                 /**
                  * Реферальный код
                  */
                 $sReferralCode = $aUser['user_referral_code'];
                 if (!$sReferralCode) {
                     $sReferralCode = md5($aUser['user_id'] . '_' . mt_rand());
                 }
                 /**
                  * Админы
                  */
                 $isAdmin = 0;
                 if (in_array($aUser['user_id'], $aUserAdmin) or $aUser['user_admin']) {
                     $isAdmin = 1;
                 }
                 /**
                  * Сохраняем в БД
                  */
                 $sAvatar = mysqli_escape_string($this->rDbLink, $sAvatar);
                 $sPhoto = mysqli_escape_string($this->rDbLink, $sPhoto);
                 $this->dbQuery("UPDATE prefix_user SET user_admin = '{$isAdmin}' , user_referral_code = '{$sReferralCode}' , user_settings_timezone = " . ($sTzName ? "'{$sTzName}'" : 'null') . " , user_profile_avatar = '{$sAvatar}', user_profile_foto = '{$sPhoto}' WHERE user_id ='{$aUser['user_id']}'");
                 /**
                  * Удаляем таблицы
                  */
                 if ($this->dbCheckTable("prefix_user_administrator")) {
                     $this->dbQuery('DROP TABLE prefix_user_administrator');
                 }
             }
         }
         if ($this->getErrors()) {
             return $this->addError(join('<br/>', $aErrors));
         }
         return true;
     }
     return $this->addError(join('<br/>', $aErrors));
 }