public function actionEdit($id) { if (isset($_POST['SlideForm'])) { $error = ""; if (empty($_POST['SlideForm']['name'])) { $error = "name"; } if (empty($_POST['SlideForm']['content'])) { $error = "content"; } if (Env::getCurrentUser() == null) { $error = "auth"; } if (Env::getCurrentUser()->isBanned()) { $error = "banned"; } if (!empty($error)) { Env::setCookie("slider_content", $_POST['SlideForm']['content']); Env::setCookie("slider_name", $_POST['SlideForm']['name']); $this->redirect('/slider/edit/#error-' . $error); } else { Env::deleteCookie("slider_content"); Env::deleteCookie("slider_name"); $slide = Slide::model()->findByPk($id); $slide->name = Env::clear($_POST['SlideForm']['name']); $slide->content = $_POST['SlideForm']['content']; $slide->update(); $this->redirect('/slider'); } } else { $this->render('edit', array("slide" => Slide::model()->findByPk($id))); } }
public function actionCreate() { $this->checkAddAccess(Env::getCurrentUser()); if (isset($_POST['PostForm'])) { $error = ""; if (empty($_POST['PostForm']['title'])) { $error = "title"; } if (empty($_POST['PostForm']['content'])) { $error = "content"; } if (empty($_POST['PostForm']['type'])) { $error = "type"; } if (empty($_POST['PostForm']['logo'])) { $error = "logo"; } if ($this->checkTags($_POST['PostForm']['tags'])) { $error = "tags"; } if (Env::getCurrentUser() == null) { $error = "auth"; } if (Env::getCurrentUser()->isBanned()) { $error = "banned"; } if (!empty($error)) { Env::setCookie("post_logo", $_POST['PostForm']['logo']); Env::setCookie("post_content", $_POST['PostForm']['content']); Env::setCookie("post_type", $_POST['PostForm']['type']); Env::setCookie("post_tags", $_POST['PostForm']['tags']); Env::setCookie("post_title", $_POST['PostForm']['title']); $this->redirect('/video/create/#error-' . $error); } else { Env::deleteCookie("post_logo"); Env::deleteCookie("post_content"); Env::deleteCookie("post_type"); Env::deleteCookie("post_tags"); Env::deleteCookie("post_title"); $post = new Post(); $post->title = Env::clear($_POST['PostForm']['title']); $post->content = $_POST['PostForm']['content']; $post->type = Env::clear($_POST['PostForm']['type']); $post->logo = Env::clear($_POST['PostForm']['logo']); $post->uid = Env::getCurrentUser()->id; $post->time = time(); $post->save(); $post->addTags(Env::clear($_POST['PostForm']['tags'])); $this->redirect(Yii::app()->homeUrl); } } else { $this->render('create'); } }
function _showTermination() { global $objTpl, $_ARRLANG, $_CONFIG, $_DBCONFIG, $objCommon, $basePath, $sessionObj, $documentRoot; // load template file $objTpl->addBlockfile('CONTENT', 'CONTENT_BLOCK', "termination.html"); $result = $this->_createConfigFile(); if ($result !== true) { $objTpl->setVariable(array('ERROR_MSG' => $result)); $objTpl->parse('errorMsg'); $objTpl->hideBlock('termination'); } else { $objCommon->updateCheck(); $objTpl->hideBlock('errorMsg'); $port = intval($_SERVER['SERVER_PORT']); if ($port != 80) { $port = ':' . $port; } else { $port = ''; } if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { $protocol = "http://"; } else { $protocol = "https://"; } $webUrl = $protocol . $_SESSION['installer']['sysConfig']['domainURL'] . $port . $_SESSION['installer']['config']['offsetPath'] . '/'; $adminUrl = $protocol . $_SESSION['installer']['sysConfig']['domainURL'] . $port . $_SESSION['installer']['config']['offsetPath'] . '/cadmin/'; $congratulationsMsg = $_ARRLANG['TXT_CONGRATULATIONS_MESSAGE']; $congratulationsMsg = str_replace("[VERSION]", $_CONFIG['coreCmsVersion'], $congratulationsMsg); $congratulationsMsg = str_replace("[EDITION]", $_CONFIG['coreCmsEdition'], $congratulationsMsg); $internetSiteMsg = $_ARRLANG['TXT_INTERNET_SITE_MESSAGE']; $internetSiteMsg = str_replace("[WEB_URL]", "<a href=\"" . $webUrl . "\" target=\"_blank\" title=\"" . $_ARRLANG['TXT_INTERNET_SITE_FOR_VISITORS'] . "\">" . $webUrl . "</a>", $internetSiteMsg); $adminSiteMsg = $_ARRLANG['TXT_ADMIN_SITE_MESSAGE']; $adminSiteMsg = str_replace("[ADMIN_URL]", "<a href=\"" . $adminUrl . "\" target=\"_blank\" title=\"" . $_ARRLANG['TXT_ADMIN_SITE'] . "\">" . $adminUrl . "</a>", $adminSiteMsg); $objTpl->setVariable(array('TXT_LOGIN_CREDENTIAL' => $_ARRLANG['TXT_LOGIN_EMAIL'], 'CONGRATULATIONS_MESSAGE' => $congratulationsMsg, 'INTERNET_SITE_MESSAGE' => $internetSiteMsg, 'ADMIN_SITE_MESSAGE' => $adminSiteMsg, 'USERNAME' => $_SESSION['installer']['account']['username'], 'PASSWORD' => $_SESSION['installer']['account']['password'], 'HTML_IMAGE_CODE' => $_SESSION['installer']['updateCheckImage'])); $objTpl->parse('termination'); // overwrite current DBCONFIG with the new data, so the database can be loaded correct in this request $_DBCONFIG['host'] = $_SESSION['installer']['config']['dbHostname']; $_DBCONFIG['database'] = $_SESSION['installer']['config']['dbDatabaseName']; $_DBCONFIG['user'] = $_SESSION['installer']['config']['dbUsername']; $_DBCONFIG['password'] = $_SESSION['installer']['config']['dbPassword']; $_DBCONFIG['tablePrefix'] = $_SESSION['installer']['config']['dbTablePrefix']; @session_destroy(); // clear cx in env, because from now on we use the core Cx and not longer the InstallerCx \Env::clear('cx'); // we will now initialize a new session and will login the administrator (userID = 1). // this is required to allow the License system (versioncheck.php) to update // the license section template // We might have some overhead, since versioncheck.php does more or less the same again $documentRoot = realpath(dirname($basePath)); require_once $documentRoot . '/core/Core/init.php'; init('minimal', false); if (!isset($sessionObj) || !is_object($sessionObj)) { $sessionObj = cmsSession::getInstance(); } $userId = 1; $_SESSION->cmsSessionUserUpdate($userId); $_GET['force'] = 'true'; $_GET['silent'] = 'true'; require_once $documentRoot . '/core_modules/License/versioncheck.php'; } }
\$('#editor1').markItUp(mySettings); SCRIPTS; ?> <div class="post"> <?php if (Env::getCurrentUser() == null || Env::getCurrentUser()->group < 3) { ?> <div class="addpost-needauth"> Недостаточно прав для создания слайда. </div> <?php } else { ?> <div id="error-container"></div> <form method="POST" class="addpost addslide" action="/slider/generate"> <div class="meta"> <input type="text" class="title" name="SlideForm[name]" placeholder="Название слайда" value="<?php echo Env::clear($_POST['name']); ?> "> </div> <textarea id="editor1" name="SlideForm[content]" rows="10" cols="80">HTML-содержание слайдера</textarea> <br> <input type="submit" value="Сохранить"> <div class="manager_button">Загрузчик картинок</div> <div class="buttons_line"></div> </form> <?php } ?> </div>
public function actionEdit($id) { $post = Post::model()->findByPk($id); if (!$post->isAbleToEdit(Env::getCurrentUser())) { throw new AccessException(); } if (isset($_POST['PostForm'])) { $error = ""; if (empty($_POST['PostForm']['title'])) { $error = "title"; } if (empty($_POST['PostForm']['desc'])) { $error = "desc"; } if (empty($_POST['PostForm']['content'])) { $error = "content"; } if (empty($_POST['PostForm']['type'])) { $error = "type"; } if (empty($_POST['PostForm']['logo'])) { $error = "logo"; } if ($this->checkTags($_POST['PostForm']['tags'])) { $error = "tags"; } if (Env::getCurrentUser() == null) { $error = "auth"; } if (Env::getCurrentUser()->isBanned()) { $error = "banned"; } if (!empty($error)) { Env::setCookie("post_logo", $_POST['PostForm']['logo']); Env::setCookie("post_desc", $_POST['PostForm']['desc']); Env::setCookie("post_content", $_POST['PostForm']['content']); Env::setCookie("post_type", $_POST['PostForm']['type']); Env::setCookie("post_tags", $_POST['PostForm']['tags']); Env::setCookie("post_title", $_POST['PostForm']['title']); $this->redirect('/post/edit/#error-' . $error); } else { Env::deleteCookie("post_logo"); Env::deleteCookie("post_desc"); Env::deleteCookie("post_content"); Env::deleteCookie("post_type"); Env::deleteCookie("post_tags"); Env::deleteCookie("post_title"); $post->title = Env::clear($_POST['PostForm']['title']); $post->desc = Env::clear($_POST['PostForm']['desc']); $post->content = Env::xss_clean($_POST['PostForm']['content']); $post->type = Env::clear($_POST['PostForm']['type']); $post->logo = Env::clear($_POST['PostForm']['logo']); $post->time = time(); $post->update(); $post->clearTags(); $post->addTags(Env::clear($_POST['PostForm']['tags'])); $this->redirect('/post/' . $post->id); } } else { $this->render('edit', array("post" => Post::model()->findByPk($id))); } }