Esempio n. 1
0
 /**
  * Index method
  */
 public function actionIndex()
 {
     //检查是否登入
     Nbt::app()->login->checkIsLogin();
     $this->replaceSeoTitle(CUtil::i18n('controllers,monitor_index_seoTitle'));
     $aryData = array();
     $this->render('index', $aryData);
 }
Esempio n. 2
0
 /**
  * init
  * 
  */
 public function init()
 {
     parent::init();
     //check is login
     if ($this->isRequiredLogin && Nbt::app()->user->userId <= 0) {
         //ajax请求,输出ajax格式信息
         if (Nbt::app()->request->isAjaxRequest) {
             echo $this->encodeAjaxData(false, array(), CUtil::i18n('controllers,user_login_notLogin'));
             exit;
         } else {
             $url = Nbt::app()->request->getUrl();
             $this->redirect(array('login', 'gourl' => urlencode($url)));
         }
     }
 }
Esempio n. 3
0
 /**
  * run controller
  * 
  */
 public function runController($aryParams)
 {
     $controllerName = '';
     $actionName = '';
     $routeName = $this->getRequest()->routeName;
     $route = isset($aryParams[$routeName]) ? $aryParams[$routeName] : null;
     $aryRoute = is_null($route) ? array() : explode('/', $route);
     switch (count($aryRoute)) {
         case 1:
             $controllerName = $aryRoute[0];
             $actionName = $this->defaultAction;
             break;
         case 2:
             $controllerName = $aryRoute[0];
             $actionName = $aryRoute[1];
             break;
         case 0:
             $controllerName = $this->defaultController;
             $actionName = $this->defaultAction;
             break;
         default:
             throw new CException('Route name error.');
     }
     Nbt::app()->user->systemLogin();
     $controller = ucfirst($controllerName) . 'Controller';
     $action = 'action' . ucfirst($actionName);
     $c = new $controller();
     if (method_exists($c, $action)) {
         $c->setId($controllerName);
         $c->setActionId($actionName);
         $c->beforeAction();
         $c->{$action}();
         $c->afterAction();
         Nbt::app()->user->logout();
     } else {
         throw new CHttpException(404, "{$controller} have not defined function {$action}");
     }
 }
Esempio n. 4
0
 /**
  * Runs the action.
  */
 public function run()
 {
     $this->renderImage($this->getVerifyCode());
     Nbt::app()->end();
 }
Esempio n. 5
0
 /**
  * create absolute url contains www
  * 
  * @return string
  */
 public function createAbsoluteUrl($_route = "", $_aryParams = array(), $_schema = '', $_ampersand = '&')
 {
     return Nbt::app()->getRequest()->getHostInfo($_schema) . $this->createUrl($_route, $_aryParams, $_ampersand);
 }
Esempio n. 6
0
 /**
  * 输出更换验证码的链接
  *
  */
 public function renderChangeImageLink()
 {
     echo '<span id="jqChangeCaptcha">' . CUtil::i18n('framework,cwidgetCaptcha_imageLink_change') . '</span>';
     $url = Nbt::app()->createUrl('captcha/index');
     echo '<script>$(function(){ $("#jqChangeCaptcha").click(function(){ $("#jqCaptcha").attr("src","' . $url . (REWRITE_MODE === true ? '?' : '&') . 'random="+Math.random()); }); });</script>';
 }
 /**
  * Validates the input to see if it matches the generated code.
  * @param string $input user input
  * @return boolean whether the input is valid
  */
 public function validate($input)
 {
     $name = $this->getSessionKey();
     $session = Nbt::app()->session;
     $session->open();
     $code = $session->get($name);
     return $input === $code ? true : false;
 }
Esempio n. 8
0
 /**
  * 创建一个伪静态 URL 
  *
  * @param CUrlManager $manager URL 管理器对象
  * @param string $route 路由部分
  * @param array $params 其他参数
  * @param string $ampersand 参数之间的分割符
  * @return mixed
  */
 public function createUrl($manager, $route, $params, $ampersand)
 {
     if ($this->parsingOnly) {
         return false;
     }
     if ($manager->caseSensitive && $this->caseSensitive === null || $this->caseSensitive) {
         $case = '';
     } else {
         $case = 'i';
     }
     $tr = array();
     if ($route !== $this->route) {
         if ($this->routePattern !== null && preg_match($this->routePattern . $case, $route, $matches)) {
             foreach ($this->references as $key => $name) {
                 $tr[$name] = $matches[$key];
             }
         } else {
             return false;
         }
     }
     foreach ($this->defaultParams as $key => $value) {
         if (isset($params[$key])) {
             if ($params[$key] == $value) {
                 unset($params[$key]);
             } else {
                 return false;
             }
         }
     }
     foreach ($this->params as $key => $value) {
         if (!isset($params[$key])) {
             return false;
         }
     }
     if ($manager->matchValue && $this->matchValue === null || $this->matchValue) {
         foreach ($this->params as $key => $value) {
             if (!preg_match('/\\A' . $value . '\\z/u' . $case, $params[$key])) {
                 return false;
             }
         }
     }
     foreach ($this->params as $key => $value) {
         $tr["<{$key}>"] = urlencode($params[$key]);
         unset($params[$key]);
     }
     $suffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix;
     $url = strtr($this->template, $tr);
     if ($this->hasHostInfo) {
         $hostInfo = Nbt::app()->getRequest()->getHostInfo();
         if (stripos($url, $hostInfo) === 0) {
             $url = substr($url, strlen($hostInfo));
         }
     }
     if (empty($params)) {
         return $url !== '' ? $url . $suffix : $url;
     }
     if ($this->append) {
         $url .= '/' . $manager->createPathInfo($params, '/', '/') . $suffix;
     } else {
         if ($url !== '') {
             $url .= $suffix;
         }
         $url .= '?' . $manager->createPathInfo($params, '=', $ampersand);
     }
     return $url;
 }
Esempio n. 9
0
 /**
  * Normalizes the input parameter to be a valid URL.
  *
  * If the input parameter is an empty string, the currently requested URL will be returned.
  *
  * If the input parameter is a non-empty string, it is treated as a valid URL and will
  * be returned without any change.
  *
  * If the input parameter is an array, it is treated as a controller route and a list of
  * GET parameters, and the {@link CController::createUrl} method will be invoked to
  * create a URL. In this case, the first array element refers to the controller route,
  * and the rest key-value pairs refer to the additional GET parameters for the URL.
  * For example, <code>array('post/list', 'page'=>3)</code> may be used to generate the URL
  * <code>/index.php?r=post/list&page=3</code>.
  *
  * @param mixed the parameter to be used to generate a valid URL
  * @param string the normalized URL
  */
 public static function normalizeUrl($url)
 {
     if (is_array($url)) {
         //
     }
     return $url === '' ? Nbt::app()->getRequest()->getUrl() : $url;
 }
Esempio n. 10
0
 /**
  * get sort url
  * 
  * @param string $_fieldName	field name in database
  * @param string $_label		header of report
  * @param string $_htmlOptions	more link options.@see CHtml::link() htmloptions.
  */
 public function link($_fieldName, $_label = null, $_htmlOptions = array())
 {
     $director = $this->getDirector();
     $newLinkOrder = $this->ascTag;
     if (isset($director[$_fieldName])) {
         $attOrder = $director[$_fieldName];
         if ($attOrder == $this->ascTag) {
             $newLinkOrder = $this->descTag;
         }
         $aryConfigClass = array($this->descTag => $this->descClass, $this->ascTag => $this->ascClass);
         $class = $aryConfigClass[$attOrder];
         if (isset($_htmlOptions['class'])) {
             $_htmlOptions['class'] .= ' ' . $class;
         } else {
             $_htmlOptions['class'] = $class;
         }
     }
     $routeName = Nbt::app()->getRequest()->routeName;
     $aryParams = isset($_GET) ? $_GET : array();
     $aryParams[$this->sortVar] = "{$_fieldName}{$this->separators}{$newLinkOrder}";
     $route = isset($aryParams[$routeName]) ? $aryParams[$routeName] : null;
     unset($aryParams[$routeName]);
     $url = Nbt::app()->createUrl($route, $aryParams);
     return CHtml::link($_label, $url, $_htmlOptions);
 }
Esempio n. 11
0
 /**
  * 初始化
  *
  */
 public function init()
 {
     //自动开启session
     Nbt::app()->getSession()->open();
 }
Esempio n. 12
0
 /**
  * logout,and redirect login page.
  */
 public function actionLogout()
 {
     Nbt::app()->session->clear();
     setcookie($this->_cookeName, '', time() - 1);
     $this->redirect(array('login/login'));
 }
Esempio n. 13
0
 /**
  * 获取错误的提示信息
  *
  * @return string $_strMsg
  */
 public static function getErrorTipFromSession()
 {
     //删除并返当获取到的session值
     return Nbt::app()->session->remove('_atip_error');
 }
Esempio n. 14
0
 /**
  * 获取语言
  * 
  * @author zhangyi
  * @date 2014-5-15
  */
 public static function getLanguage()
 {
     return Nbt::app()->language->getLanguage();
 }
Esempio n. 15
0
 /**
  * Index method
  */
 public function actionIndex()
 {
     //检查是否登入
     Nbt::app()->login->checkIsLogin();
     try {
         $this->replaceSeoTitle(CUtil::i18n('controllers,index_index_seoTitle'));
         // open redis
         $redis = $this->getRedis();
         // 是否获取指定类型运算频率
         $intFreq = null;
         if (SYS_INFO === 'SF3301_D_V1') {
             $intFreq = array(0, 1);
         }
         // 可调速度集合
         $aryBTCSpeed = CUtilMachine::getSpeedList(SYS_INFO, is_null($intFreq) ? null : $intFreq[0]);
         $aryLTCSpeed = CUtilMachine::getSpeedList(SYS_INFO, is_null($intFreq) ? null : $intFreq[1]);
         // get default speed
         $intDefaultBTCSpeed = self::getDefaultSpeed(is_null($intFreq) ? null : $intFreq[0]);
         $intDefaultLTCSpeed = self::getDefaultSpeed(is_null($intFreq) ? null : $intFreq[1]);
         // Tip data
         $aryTipData = array();
         $aryBTCData = array();
         $aryLTCData = array();
         $btcVal = $redis->readByKey('btc.setting');
         $ltcVal = $redis->readByKey('ltc.setting');
         $aryBTCData = empty($btcVal) ? array() : json_decode($btcVal, true);
         if (empty($aryBTCData['speed'])) {
             $aryBTCData['speed'] = $intDefaultBTCSpeed;
         }
         $aryLTCData = empty($ltcVal) ? array() : json_decode($ltcVal, true);
         if (empty($aryLTCData['speed'])) {
             $aryLTCData['speed'] = $intDefaultLTCSpeed;
         }
         // get run model
         $strRunMode = $this->getRunMode();
         // if commit save
         if (Nbt::app()->request->isPostRequest) {
             $strBTCAddress = isset($_POST['address_btc']) ? htmlspecialchars($_POST['address_btc']) : '';
             $strBTCAccount = isset($_POST['account_btc']) ? htmlspecialchars($_POST['account_btc']) : '';
             $strBTCPassword = isset($_POST['password_btc']) ? htmlspecialchars($_POST['password_btc']) : '';
             $intBTCSpeed = isset($_POST['run_speed_btc']) ? intval($_POST['run_speed_btc']) : $intDefaultBTCSpeed;
             $strLTCAddress = isset($_POST['address_ltc']) ? htmlspecialchars($_POST['address_ltc']) : '';
             $strLTCAccount = isset($_POST['account_ltc']) ? htmlspecialchars($_POST['account_ltc']) : '';
             $strLTCPassword = isset($_POST['password_ltc']) ? htmlspecialchars($_POST['password_ltc']) : '';
             $intLTCSpeed = isset($_POST['run_speed_ltc']) ? intval($_POST['run_speed_ltc']) : $intDefaultLTCSpeed;
             $strGetRunMode = isset($_POST['runmodel']) ? htmlspecialchars($_POST['runmodel']) : '';
             if (!empty($strGetRunMode) && in_array($strGetRunMode, array('L', 'LB'))) {
                 RunModel::model()->storeRunMode($strGetRunMode);
                 $strRunMode = $strGetRunMode;
             }
             $aryBTCData['ad'] = $strBTCAddress;
             $aryBTCData['ac'] = $strBTCAccount;
             $aryBTCData['pw'] = $strBTCPassword;
             $aryBTCData['speed'] = $intBTCSpeed;
             //$aryBTCData['su'] = isset( $aryBTCData['su'] ) ? $aryBTCData['su'] : 1;
             $aryLTCData['ad'] = $strLTCAddress;
             $aryLTCData['ac'] = $strLTCAccount;
             $aryLTCData['pw'] = $strLTCPassword;
             $aryLTCData['speed'] = $intLTCSpeed;
             //$aryLTCData['su'] = isset( $aryLTCData['su'] ) ? $aryLTCData['su'] : 1;
             if (in_array($strRunMode, array('L'))) {
                 $boolCheck = CUtil::isParamsEmpty($aryLTCData);
                 if ($boolCheck === false) {
                     throw new CModelException(CUtil::i18n('exception,scrypt_setting_haveNullData'));
                 }
             } else {
                 if (in_array($strRunMode, array('B'))) {
                     $boolCheck = CUtil::isParamsEmpty($aryBTCData);
                     if ($boolCheck === false) {
                         throw new CModelException(CUtil::i18n('exception,sha_setting_haveNullData'));
                     }
                 }
             }
             // store data
             $redis->writeByKey('btc.setting', json_encode($aryBTCData));
             $redis->writeByKey('ltc.setting', json_encode($aryLTCData));
             $redis->saveData();
             $aryTipData['status'] = 'success';
             $aryTipData['text'] = CUtil::i18n('controllers,index_saveData_success');
         }
     } catch (Exception $e) {
         $aryTipData['status'] = 'error';
         $aryTipData['text'] = $e->getMessage();
     }
     $aryData = array();
     $aryData['tip'] = $aryTipData;
     $aryData['btc'] = $aryBTCData;
     $aryData['ltc'] = $aryLTCData;
     $aryData['runmodel'] = $strRunMode;
     $aryData['speedDefBTC'] = $intDefaultBTCSpeed;
     $aryData['speedDefLTC'] = $intDefaultLTCSpeed;
     $aryData['speedBTC'] = $aryBTCData['speed'];
     $aryData['speedLTC'] = $aryLTCData['speed'];
     $aryData['aryBTCSpeed'] = $aryBTCSpeed;
     $aryData['aryLTCSpeed'] = $aryLTCSpeed;
     $this->render('index', $aryData);
 }
Esempio n. 16
0
 public function getReturnUrl($_urlDefault = null)
 {
     $returnUrl = Nbt::app()->user->getReturnUrl();
     if ($returnUrl === null) {
         $returnUrl = $_urlDefault;
     }
     return $returnUrl;
 }