PATH:
home
/
letacommog
/
letaweb
/
install
/
models
<?php class InstallConfigForm extends CFormModel { public $server_type; public $server_url; public $server_port; public $server_username; public $server_password; public $server_add_record; public function rules() { return array( array('server_url, server_port,server_username,server_password', 'required','on' => 'shared_hosting'), array('id, server_add_record,server_type,server_url,server_port,server_username,server_password', 'safe'), ); } public function save($item = null) { if ($this->server_type == 'cpanel') { $this->scenario = 'shared_hosting'; } if ($this->validate()) { include Yii::getPathofAlias('webroot').DIRECTORY_SEPARATOR.'config.php'; $db = new CDbConnection(); $db->connectionString = 'mysql:host='.$db_host.';dbname='.$db_name; $db->password = $db_password; $db->username = $db_username; $db->setActive(true); Yii::import('site_app.classes.hosting.*'); Yii::import('site_app.classes.components.hostingComponent'); $hostingComponent = new hostingComponent(); $hostingComponent->init(); $hostingComponent->type = $this->server_type; $hostingComponent->url = $this->server_url; $hostingComponent->port = $this->server_port; $hostingComponent->username = $this->server_username; $hostingComponent->password = $this->server_password; $result = $hostingComponent->getHostingClass()->addSubdomain('*', $_SERVER['HTTP_HOST']); if ($result != 1) { $this->addError('', $result); return false; } $db->createCommand()->update('tbl_configuration', array('value' => $this->server_type), 'name=:name', array(':name' => 'hosting_type')); $db->createCommand()->update('tbl_configuration', array('value' => $this->server_url), 'name=:name', array(':name' => 'hosting_url')); $db->createCommand()->update('tbl_configuration', array('value' => $this->server_port), 'name=:name', array(':name' => 'hosting_port')); $db->createCommand()->update('tbl_configuration', array('value' => $this->server_port), 'name=:name', array(':name' => 'hosting_port')); $s = '<?php return array("class"=>"hostingComponent",'; $s .= '"type"=>"'.$this->server_type.'",'; $s .= '"username"=>"'.$this->server_username.'",'; $s .= '"password"=>"'.$this->server_password.'",'; $s .= '"url"=>"'.$this->server_url.'",'; $s .= '"port"=>"'.$this->server_port.'",'; $s .= '"predefined_subdomain"=>"",'; $s .= '"predefined_domain"=>"",'; $s .= ');'; $hande = fopen(Yii::getPathofAlias('webroot').DIRECTORY_SEPARATOR.'hosting_config.php', 'w'); fwrite($hande, $s); fclose($hande); $db->createCommand()->update('tbl_configuration', array('value' => $_SERVER['HTTP_HOST']), 'name=:name', array(':name' => 'mainsite_url')); $s = "<?php return array('start_plan'=>1,'thumbnail_url'=>'','default_plan'=>1,'default_expired_date'=>15,'mainsite_url'=>'".$_SERVER['HTTP_HOST']."','best_plan'=>2,'language'=>'en','admin_email'=>'','admin_email_from_name'=>'SiteBuilder','forgotpassword_mail_template'=>0,'welcome_mail_template'=>0,'activation_mail_template'=>0,'mail_activation'=>0,);"; $hande = fopen(Yii::getPathofAlias('webroot').DIRECTORY_SEPARATOR.'mainsite_config.php', 'w'); fwrite($hande, $s); fclose($hande); return true; } else { return false; } } }
[+]
..
[-] InstallConfigForm.php
[edit]
[-] InstallForm.php
[edit]