public function afterAction($handlerAdapter)
 {
     parent::afterAction($handlerAdapter);
     $debug = Wekit::C('site', 'debug') || !Wekit::C('site', 'css.compress');
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
     /* @var $resource WindLangResource */
     $resource = Wind::getComponent('i18n');
     $_error = $this->getForward()->getVars('message');
     if ($resource !== null) {
         foreach ($_error as $key => $value) {
             if (is_array($value)) {
                 list($value, $var) = $value;
             } else {
                 $var = array();
             }
             $message = $resource->getMessage($value, $var);
             $message && ($_error[$key] = $message);
         }
     }
     $this->getForward()->setVars(array('message' => $_error, '__error' => ''));
     $type = $this->getRequest()->getAcceptTypes();
     // 如果是含有上传的递交,不能采用ajax的方式递交,需要以html的方式递交,并且返回的结果需要是json格式,将以json=1传递过来标志
     $json = $this->getInput('_json');
     $requestJson = $this->getRequest()->getIsAjaxRequest() && strpos(strtolower($type), "application/json") !== false;
     if ($requestJson || $json == 1) {
         $this->getResponse()->setHeader('Content-type', 'application/json; charset=' . Wekit::V('charset'));
         echo Pw::jsonEncode($this->getForward()->getVars());
         exit;
     }
 }
Beispiel #2
0
 public function run()
 {
     $id = (int) $this->getInput('id', 'get');
     $portal = $this->_getPortalDs()->getPortal($id);
     if (!$portal) {
         $this->showError("page.status.404");
     }
     if (!$portal['isopen']) {
         $permissions = $this->_getPermissionsService()->getPermissionsForUserGroup($this->loginUser->uid);
         if ($permissions < 1) {
             $this->showError("page.status.404");
         }
     }
     $this->setOutput($portal, 'portal');
     if ($portal['navigate']) {
         $this->setOutput($this->headguide($portal['title']), 'headguide');
     }
     if ($portal['template']) {
         $url = WindUrlHelper::checkUrl(PUBLIC_THEMES . '/portal/local/' . $portal['template'], PUBLIC_URL);
         $design['url']['css'] = $url . '/css';
         $design['url']['images'] = $url . '/images';
         $design['url']['js'] = $url . '/js';
         Wekit::setGlobal($design, 'design');
         $this->setTemplate("THEMES:portal.local." . $portal['template'] . ".template.index");
     } else {
         $this->setTemplate("TPL:special.index_run");
     }
     //$this->getForward()->getWindView()->compileDir = 'DATA:design.default.' . $id;
     $this->setTheme($portal['template'], 'THEMES:portal.local');
     Wind::import('SRV:seo.bo.PwSeoBo');
     PwSeoBo::init('area', 'custom', $id);
     PwSeoBo::set('{pagename}', $portal['title']);
 }
 public function beforeAction($handlerAdapter)
 {
     $this->setOutput(NEXT_VERSION, 'wind_version');
     $_consts = (include Wind::getRealPath('CONF:publish.php', true));
     foreach ($_consts as $const => $value) {
         if (defined($const)) {
             continue;
         }
         if ($const === 'PUBLIC_URL' && !$value) {
             $value = Wind::getApp()->getRequest()->getBaseUrl(true);
         }
         define($const, $value);
     }
     $url = array();
     $url['base'] = PUBLIC_URL;
     $url['res'] = WindUrlHelper::checkUrl(PUBLIC_RES, PUBLIC_URL);
     $url['css'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/css/', PUBLIC_URL);
     $url['images'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/images/', PUBLIC_URL);
     $url['js'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/js/dev/', PUBLIC_URL);
     $url['attach'] = WindUrlHelper::checkUrl(PUBLIC_ATTACH, PUBLIC_URL);
     Wekit::setGlobal($url, 'url');
     $this->setOutput('phpwind 8.7 to 9.0', 'wind_version');
     //ajax递交编码转换
     $token = $this->getInput('token', 'get');
     $lockFile = Wind::getRealPath('DATA:setup.setup.lock', true);
     if (file_exists($lockFile) && !$token) {
         $this->showError('升级程序已被锁定, 如需重新运行,请先删除setup.lock');
     }
     $encryptToken = trim(file_get_contents($lockFile));
     if (md5($token) != $encryptToken) {
         $this->showError('升级程序访问异常! 重新安装请先删除setup.lock');
     }
 }
Beispiel #4
0
 public function postHandle()
 {
     //门户管理模式 编译目录切换
     if ($this->getRequest()->getPost('design')) {
         $loginUser = Wekit::getLoginUser();
         $designPermission = $loginUser->getPermission('design_allow_manage.push');
         if ($designPermission > 0) {
             $dir = Wind::getRealDir('DATA:design.template');
             if (is_dir($dir)) {
                 WindFolder::rm($dir, true);
             }
             $this->forward->getWindView()->compileDir = 'DATA:design.template';
         }
     }
     // SEO settings
     Wind::import('SRV:seo.bo.PwSeoBo');
     $sitename = Wekit::C('site', 'info.name');
     PwSeoBo::set('{sitename}', $sitename);
     Wekit::setGlobal(NEXT_VERSION . ' ' . NEXT_RELEASE, 'version');
     Wekit::setGlobal(PwSeoBo::getData(), 'seo');
     $this->setOutput($this->getRequest()->getIsAjaxRequest() ? '1' : '0', '_ajax_');
     /*[设置给PwGlobalFilters需要的变量]*/
     $_var = array('current' => $this->forward->getWindView()->templateName, 'a' => $this->router->getAction(), 'c' => $this->router->getController(), 'm' => $this->router->getModule());
     $this->getResponse()->setData($_var, '_aCloud_');
     Wekit::load('APPS:appcenter.service.srv.PwDebugApplication')->compile();
 }
 public function afterAction($handlerAdapter)
 {
     parent::afterAction($handlerAdapter);
     $bread = array($this->bread['left']);
     unset($this->bread['left']);
     $this->bread && ($bread = array_merge($bread, $this->bread));
     Wekit::setGlobal($bread, 'profileBread');
 }
Beispiel #6
0
 public function beforeAction($handlerAdapter)
 {
     $url['baseUrl'] = PUBLIC_URL;
     $url['res'] = WindUrlHelper::checkUrl(PUBLIC_RES, PUBLIC_URL);
     $url['css'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/css', PUBLIC_URL);
     $url['images'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/images', PUBLIC_URL);
     $url['js'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/js/dev', PUBLIC_URL);
     Wekit::setGlobal($url, 'url');
     $config = Wind::getComponent('configParser')->parse(Wind::getRealPath('APPS:demo.WindManifest.xml', true, true));
     Wekit::setGlobal($config['application'], 'c');
 }
 public function preHandle()
 {
     $url = array();
     $var = Wekit::url();
     $url['base'] = $var->base;
     $url['res'] = $var->res;
     $url['css'] = $var->css;
     $url['images'] = $var->images;
     $url['js'] = $var->js;
     $url['attach'] = $var->attach;
     $url['themes'] = $var->themes;
     $url['extres'] = $var->extres;
     Wekit::setGlobal($url, 'url');
     $request = array('m' => $this->router->getModule(), 'c' => $this->router->getController(), 'a' => $this->router->getAction());
     $request['mc'] = $request['m'] . '/' . $request['c'];
     $request['mca'] = $request['mc'] . '/' . $request['a'];
     Wekit::setGlobal($request, 'request');
     if (in_array($request['mca'], array('default/index/login', 'default/index/showVerify', 'appcenter/app/upload'))) {
         return;
     }
     /* @var $userService AdminUserService */
     $userService = Wekit::load('ADMIN:service.srv.AdminUserService');
     /* @var $safeService AdminSafeService */
     $safeService = Wekit::load('ADMIN:service.srv.AdminSafeService');
     /* @var $founderService AdminFounderService */
     $founderService = Wekit::load('ADMIN:service.srv.AdminFounderService');
     /* @var $loginUser AdminUserBo */
     $loginUser = Wekit::getLoginUser();
     if (!$loginUser->isExists() || !$founderService->isFounder($loginUser->username) && !$safeService->ipLegal(Wind::getComponent('request')->getClientIp())) {
         if (!$this->getRequest()->getIsAjaxRequest()) {
             $this->forward->forwardAction('default/index/login');
         } else {
             $this->errorMessage->addError('logout', 'state');
             $this->errorMessage->sendError('ADMIN:login.fail.not.login');
         }
     }
     $_unVerifyTable = array('home', 'index', 'find');
     if (!in_array(strtolower($request['c']), $_unVerifyTable)) {
         if ($request['c'] != 'adminlog') {
             $logService = Wekit::load('ADMIN:service.srv.AdminLogService');
             $logService->log($this->getRequest(), $loginUser->username, $request['m'], $request['c'], $request['a']);
         }
         $_result = $userService->verifyUserMenuAuth($loginUser, $request['m'], $request['c'], $request['a']);
         if ($_result instanceof PwError) {
             $this->errorMessage->sendError($_result->getError());
         }
     }
 }
 public function afterAction($handlerAdapter)
 {
     parent::afterAction($handlerAdapter);
     $debug = Wekit::C('site', 'debug') || !Wekit::C('site', 'css.compress');
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
     /* @var $resource WindLangResource */
     $resource = Wind::getComponent('i18n');
     $_error = $this->getForward()->getVars('message');
     if ($resource !== null) {
         foreach ($_error as $key => $value) {
             if (is_array($value)) {
                 list($value, $var) = $value;
             } else {
                 $var = array();
             }
             $message = $resource->getMessage($value, $var);
             $message && ($_error[$key] = $message);
         }
     }
     $this->getForward()->setVars(array('message' => $_error, '__error' => ''));
     $type = $this->getRequest()->getAcceptTypes();
     // 如果是含有上传的递交,不能采用ajax的方式递交,需要以html的方式递交,并且返回的结果需要是json格式,将以json=1传递过来标志
     $json = $this->getInput('_json');
     $requestJson = $this->getRequest()->getIsAjaxRequest() && strpos(strtolower($type), "application/json") !== false;
     if ($requestJson || $json == 1) {
         $this->getResponse()->setHeader('Content-type', 'application/json; charset=' . Wekit::V('charset'));
         $vars = $this->getForward()->getVars();
         isset($vars['referer']) && ($vars['referer'] = rawurlencode($vars['referer']));
         foreach ($vars as $key => $value) {
             if ($key == 'html') {
                 continue;
             }
             //$vars[$key] = WindSecurity::escapeArrayHTML($value);
         }
         //jsonp
         $callback = $this->getInput('callback', 'get');
         if ($callback && preg_match('/[\\w_]/i', $callback)) {
             echo $callback . "(" . Pw::jsonEncode($vars) . ")";
             exit;
         }
         //            print_r($vars);
         echo Pw::jsonEncode($vars);
         exit;
     }
 }
Beispiel #9
0
 public function beforeAction($handlerAdapter)
 {
     if ('finish' != $handlerAdapter->getAction()) {
         Wekit::createapp('install');
     }
     //ajax递交编码转换
     if ($this->getRequest()->getIsAjaxRequest()) {
         $toCharset = $this->getResponse()->getCharset();
         if (strtoupper(substr($toCharset, 0, 2)) != 'UT') {
             $_tmp = array();
             foreach ($_POST as $key => $value) {
                 $key = WindConvert::convert($key, $toCharset, 'UTF-8');
                 $_tmp[$key] = WindConvert::convert($value, $toCharset, 'UTF-8');
             }
             $_POST = $_tmp;
         }
     }
     $_consts = (include Wind::getRealPath('CONF:publish.php', true));
     foreach ($_consts as $const => $value) {
         if (defined($const)) {
             continue;
         }
         if ($const === 'PUBLIC_URL' && !$value) {
             $value = Wind::getApp()->getRequest()->getBaseUrl(true);
         }
         define($const, $value);
     }
     $url = array();
     $url['base'] = PUBLIC_URL;
     $url['res'] = WindUrlHelper::checkUrl(PUBLIC_RES, PUBLIC_URL);
     $url['css'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/css/', PUBLIC_URL);
     $url['images'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/images/', PUBLIC_URL);
     $url['js'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/js/dev/', PUBLIC_URL);
     $url['attach'] = WindUrlHelper::checkUrl(PUBLIC_ATTACH, PUBLIC_URL);
     Wekit::setGlobal($url, 'url');
     $this->setOutput(NEXT_VERSION, 'wind_version');
     WindFile::isFile($this->_getInstallLockFile()) && $this->showError('INSTALL:have_install_lock');
 }
Beispiel #10
0
 public function beforeAction($handlerAdapter)
 {
     $this->_m = $handlerAdapter->getModule();
     $this->_c = $handlerAdapter->getController();
     $this->_a = $handlerAdapter->getAction();
     $this->_mc = $this->_m . '/' . $this->_c;
     $this->_mca = $this->_mc . '/' . $this->_a;
     $this->_setPreCache($this->_m, $this->_mc, $this->_mca);
     $this->loginUser = Wekit::getLoginUser();
     $this->_setPreHook($this->_m, $this->_mc, $this->_mca);
     $config = Wekit::C('site');
     if ($config['visit.state'] > 0) {
         $service = Wekit::load('site.srv.PwSiteStatusService');
         $resource = $service->siteStatus($this->loginUser, $config);
         if ($resource instanceof PwError) {
             if (!($config['visit.state'] == 1 && $this->_mc == 'u/login')) {
                 $this->showError($resource->getError());
             }
         }
     }
     if (!in_array($this->_mc, array('u/login', 'u/register', 'u/findPwd')) && !$this->loginUser->getPermission('allow_visit')) {
         if ($this->loginUser->isExists()) {
             if ($this->_mca != 'u/login/logout') {
                 $this->showError(array('permission.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
             }
         } else {
             $this->forwardAction('u/login/run');
         }
     }
     if ($config['refreshtime'] > 0 && Wind::getApp()->getRequest()->isGet() && !Wind::getApp()->getRequest()->getIsAjaxRequest()) {
         if (Wekit::app()->lastRequestUri == Wekit::app()->requestUri && Wekit::app()->lastvisit + $config['refreshtime'] > Pw::getTime()) {
             $this->showError('SITE:refresh.fast');
         }
     }
     $debug = $config['debug'] || !$config['css.compress'];
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
 }
 /**
  * 设置当前的标签
  *
  * @param unknown_type $handlerAdapter
  */
 protected function setCurrent($handlerAdapter)
 {
     Wekit::setGlobal($handlerAdapter->getController(), 'manageLeft');
 }
Beispiel #12
0
 public function postHandle()
 {
     $this->runDesign();
     $this->updateOnline();
     $this->setOutput($this->runCron(), 'runCron');
     //门户管理模式 编译目录切换
     if ($this->getRequest()->getPost('design')) {
         $loginUser = Wekit::getLoginUser();
         $designPermission = $loginUser->getPermission('design_allow_manage.push');
         if ($designPermission > 0) {
             $dir = Wind::getRealDir('DATA:design.template');
             if (is_dir($dir)) {
                 WindFolder::rm($dir, true);
             }
             $this->forward->getWindView()->compileDir = 'DATA:design.template';
         }
     }
     // SEO settings
     Wekit::setGlobal(NEXT_VERSION . ' ' . NEXT_RELEASE, 'version');
     $seo = Wekit::V('seo');
     Wekit::setGlobal($seo ? $seo->getData() : array('title' => Wekit::C('site', 'info.name')), 'seo');
     $this->setOutput($this->getRequest()->getIsAjaxRequest() ? '1' : '0', '_ajax_');
     /*[设置给PwGlobalFilters需要的变量]*/
     $_var = array('current' => $this->forward->getWindView()->templateName, 'a' => $this->router->getAction(), 'c' => $this->router->getController(), 'm' => $this->router->getModule());
     $this->getResponse()->setData($_var, '_aCloud_');
 }