PATH:
home
/
letacommog
/
letaweb
/
protected
/
controllers
<?php class PageController extends PController { public $layout = 'column3'; public function actionCheck_Domain() { $form = $_REQUEST['PageCreationForm']; $name = $form['name']; $name = trim($name); $name = strtolower($name); $valid_pages = Site::model()->find('name=:name', array(':name' => $name)); if (!isset($valid_pages)) { echo json_encode(true); } else { echo json_encode($this->term('LBL_ERROR_SUBDOMAIN_EXISTS')); } } protected function getStepInfo($step) { $steps = array( '0' => array('next' => 1, 'name' => 'Initialize','percent' => 0), '1' => array('next' => 2, 'name' => 'Copy Essential file','percent' => 10), '2' => array('next' => 3,'name' => 'Create database structe','percent' => 20), '3' => array('next' => 4,'name' => 'Copy database','percent' => 40), '4' => array('next' => 5, 'name' => 'Copy view file','percent' => 50), '5' => array('next' => 6, 'name' => 'Copy Css file','percent' => 60), '6' => array('next' => 7, 'name' => 'Copy Analytics file','percent' => 70), '7' => array('next' => 8, 'name' => 'Copy Assets file','percent' => 90), '8' => array('finish' => true, 'name' => 'Finishing'), ); return $steps[$step]; } public function actiondoCreatePage() { $rs = array('success' => false); if (isset($_POST['id']) && isset($_POST['step'])) { global $installation,$template, $webroot,$template_id, $sourcetDir, $targetDir; $installation_id = $_POST['id']; $installation = Page_Installation::model()->findByPk($installation_id); if (isset($installation)) { $step = (int) $_POST['step']; $page = $installation->page; $intalled_step = $installation->step; $template = $page->page_template; $webroot = Yii::getPathofAlias('webroot.websites').DIRECTORY_SEPARATOR; $sourcetDir = $targetDir = $webroot; if ($page->is_created_complete) { $rs = array('finish' => true, 'name' => 'Finishing'); $rs['html'] = $this->renderPartial('success', array('page' => $page), true); echo json_encode($rs); return; } if ($step < $intalled_step) { $step = $intalled_step + 1; } if (isset($template)) { $method_name = 'doCreatePageST'.$step; if (method_exists($this, $method_name)) { $this->$method_name(); return; } } } } echo json_encode($rs); } public function doCreatePageST1() { if (isset($_POST['id'])) { global $installation,$template, $template_id, $sourcetDir, $targetDir; $name = $installation->page->name; $display_name = ''; $name = str_replace(' ', '_', $name); $name = Functions::stripUnicode($name); $newname = $name; if (file_exists($targetDir.$newname)) { //throw new Exception(); } $installation->step = 1; $installation->save(); $stepInfo = $this->getStepInfo(1); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST2() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $name = $installation->page->name; Functions::full_copy($webroot.$template->name, $webroot.$name, 0); $installation->step = 2; $installation->save(); $stepInfo = $this->getStepInfo(2); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST3() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; @mkdir($targetDir.$page_name.'/storage'); @mkdir($targetDir.$page_name.'/storage/db'); @mkdir($targetDir.$page_name.'/storage/session'); $page = $installation->page; $installation->step = 3; $installation->save(); $stepInfo = $this->getStepInfo(3); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST4() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; $page = $installation->page; $page->copyDbData(); Functions::full_copy($sourcetDir.$template->name.'/module_data', $targetDir.$page_name.'/module_data'); Functions::full_copy($sourcetDir.$template->name.'/page_data', $targetDir.$page_name.'/page_data'); $installation->step = 4; $installation->save(); $stepInfo = $this->getStepInfo(4); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST5() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; Functions::full_copy($sourcetDir.$template->name.'/views', $targetDir.$page_name.'/views'); $installation->step = 5; $installation->save(); $stepInfo = $this->getStepInfo(5); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST6() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; Functions::full_copy($sourcetDir.$template->name.'/css', $targetDir.$page_name.'/css'); Functions::full_copy($sourcetDir.$template->name.'/fonts', $targetDir.$page_name.'/fonts'); $installation->step = 6; $installation->save(); $stepInfo = $this->getStepInfo(6); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST7() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; // Functions::full_copy( $sourcetDir.$template->name.'/bbclone', $targetDir.$page_name.'/bbclone' ); $installation->step = 7; $installation->save(); $stepInfo = $this->getStepInfo(7); $stepInfo['success'] = true; echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function doCreatePageST8() { if (isset($_POST['id'])) { global $installation,$template,$webroot, $template_id, $sourcetDir, $targetDir; $page_name = $installation->page->name; $display_name = ''; Functions::full_copy($sourcetDir.$template->name.'/assets', $targetDir.$page_name.'/assets'); $installation->step = 8; $installation->is_complete = 1; $installation->is_active = 0; $installation->save(); $page = $installation->page; $page->is_created_complete = 1; $page->plan_id = Yii::app()->params['start_plan']; if (Yii::app()->params['default_expired_date'] < 0) { $page->can_expire = 0; } else { $page->expired_date = date('Y-m-d', strtotime('+ '.Yii::app()->params['default_expired_date'].' day')); $page->can_expire = 1; } $page->asset_size = $template->asset_size; $page->save(); $stepInfo = $this->getStepInfo(8); $stepInfo['success'] = true; $stepInfo['html'] = $this->renderPartial('success', array('page' => $page), true); echo json_encode($stepInfo); return; } echo json_encode(array('success' => false)); } public function actiondoUndo() { if (isset($_POST['id'])) { $inst_id = $_REQUEST['id']; $installation = Page_Installation::model()->findByPk($inst_id, 'is_active=1'); $url = $this->createAbsoluteUrl('/site/create'); if (isset($installation)) { $page = $installation->page; if (isset($page)) { $page->delete(); } $installation->delete(); } echo json_encode($url); } } public function actionCreate() { if (isset($_REQUEST['inst_id'])) { $inst_id = $_REQUEST['inst_id']; $model = Page_Installation::model()->findByPk($inst_id, 'is_active=1'); if (!isset($model)) { $url = $this->createAbsoluteUrl('/site/create'); $this->redirect($url); } $this->layout = 'column_create_page'; $this->render('create', array('model' => $model)); } elseif (isset($_REQUEST['continue']) && isset($_REQUEST['id'])) { $id = $_REQUEST['id']; $page = Site::model()->findByPk($id); $model = Page_Installation::model()->find('page_id=:page_id and is_active=1', array(':page_id' => $id)); if (!isset($model)) { $url = $this->createAbsoluteUrl('/site/create'); $this->redirect($url); } if (isset($model)) { $this->layout = 'column_create_page'; $this->render('create_continue', array('model' => $model)); } } else { $url = $this->createAbsoluteUrl('/site/create'); $this->redirect($url, true); } } public function actionEdit() { if (Yii::app()->user->isGuest) { Yii::app()->user->loginRequired(); } $login_session = User_Session::model()->find("user_id=:user_id", array(":user_id"=>Yii::app()->user->id)); $id = $_REQUEST["id"]; $site = Site::model()->findByPk($id); if (isset($login_session)) { $token = $login_session->token; //the info per user with custom func. //login form action url $postinfo = "token=".urlencode($token); $url = $site->getEditSiteURL()."/user/postlogin?".$postinfo; $this->redirect($url); } else $this->redirect($site->getEditSiteURL()); } }
[+]
..
[-] PageController.php
[edit]
[-] IpnController.php
[edit]
[-] SiteController.php
[edit]