/** * Upgrade version method */ public function actionUpgradeversion() { // check is newest $aryVersionData = $this->actionHasnew(true); $isok = 0; $data = array(); $msg = ""; try { if ($aryVersionData['ISOK'] !== 1 || empty($aryVersionData['DATA']['v'])) { throw new CModelException(CUtil::i18n('exception,version_upgrad_withoutUpgrad')); } // get up to version $strVersion = $aryVersionData['DATA']['v']; if (empty($strVersion)) { throw new CModelException(CUtil::i18n('exception,version_upgrad_upgradFaild')); } if ($strVersion <= CUR_VERSION_NUM) { throw new CModelException(CUtil::i18n('exception,version_upgrad_withoutUpgrad')); } // execute upgrade $command = SUDO_COMMAND . "cd " . WEB_ROOT . ";" . SUDO_COMMAND . "wget " . MAIN_DOMAIN . "/down/v{$strVersion}.zip;" . SUDO_COMMAND . "unzip -o v{$strVersion}.zip;" . SUDO_COMMAND . "rm -rf v{$strVersion}.zip;"; exec($command); $isok = 1; } catch (CModelException $e) { $msg = $e->getMessage(); } catch (CException $e) { $msg = NBT_DEBUG ? $e->getMessage() : CUtil::i18n('exception,sys_error'); } header('Content-Type: text/html; charset=utf-8'); echo $this->encodeAjaxData($isok, $data, $msg); exit; }
/** * Index method */ public function actionIndex() { //检查是否登入 Nbt::app()->login->checkIsLogin(); $this->replaceSeoTitle(CUtil::i18n('controllers,monitor_index_seoTitle')); $aryData = array(); $this->render('index', $aryData); }
/** * 用户信息 * @param string $strVerifyType 登入形式,例如输入密码登入 或者cookie登入 * @param array $aryUserInfo 传进来的用户数据 * * @author zhangyi * @date 2014-5-29 */ public function checkLogin($aryData = array()) { if (empty($aryData)) { throw new CModelException(CUtil::i18n('exception,sys_error')); } $aryUserInfo = $this->getUserInfo(); //验证用户名和密码 return $aryUserInfo['uname'] === $aryData['uname'] && $aryUserInfo['pwd'] === $aryData['pwd']; }
/** * 运行 * */ public function run() { if (empty($this->id)) { throw new CException("CWidget->id " . CUtil::i18n('framework,cwidgetDialog_run_undefined')); } if (empty($this->triggerId)) { throw new CException("CWidget->triggerId " . CUtil::i18n('framework,cwidgetDialog_run_undefined')); } if (empty($this->url)) { throw new CException("CWidget->url " . CUtil::i18n('framework,cwidgetDialog_run_undefined')); } $aryData = array(); $this->render('dialog', $aryData); }
/** * 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))); } } }
/** * Index method */ public function actionLogin() { $objLoginModel = LoginModel::model(); try { //检查是否是post请求 $boolCheckLogin = false; if (Nbt::app()->request->isPostRequest) { // 绑定数据 $aryUserInfo['uname'] = isset($_POST['uname']) ? htmlspecialchars(trim($_POST['uname'])) : ''; $aryUserInfo['pwd'] = isset($_POST['pwd']) ? CString::encodeMachinePassword(trim($_POST['pwd'])) : ''; $strIsRemember = isset($_POST['remember']) ? htmlspecialchars(trim($_POST['remember'])) : 'no'; // 检查登录 $boolCheckLogin = LoginModel::model()->checkLogin($aryUserInfo); if ($boolCheckLogin === false) { throw new CModelException(CUtil::i18n('controllers,login_index_pwdWrong')); } //根据是否登入成功,再判断是否将用户名和密码写入cookie if ($boolCheckLogin === true && $strIsRemember === 'yes') { $aryUserInfo['pwd'] = CString::encode($aryUserInfo['pwd'], UKEY); //设置cookie,时间为一年 setcookie($this->_cookeName, base64_encode(json_encode($aryUserInfo)), time() + 365 * 24 * 3600); } } else { if (!empty($_COOKIE[$this->_cookeName]) && $boolCheckLogin === false) { $aryUserInfo = json_decode(base64_decode($_COOKIE[$this->_cookeName]), 1); $aryUserInfo['pwd'] = CString::decode($aryUserInfo['pwd'], UKEY); if (($boolCheckLogin = $objLoginModel->checkLogin($aryUserInfo)) === false) { throw new CModelException(CUtil::i18n('controllers,login_index_pwdWrong')); } } } //contains/判断是否登入成功 if ($boolCheckLogin === true) { Nbt::app()->session->set('userInfo', $aryUserInfo); UtilMsg::saveTipToSession(CUtil::i18n('controllers,login_index_success')); $this->redirect(array('index/index')); } } catch (CModelException $e) { UtilMsg::saveErrorTipToSession($e->getMessage()); } $this->layout = 'login'; $this->seoTitle = CUtil::i18n('controllers,login_index_seoTitle'); //根据key判断文件是否存在,如果不存在则)创建一个默认账户 $objLoginModel->createDefaultUserInfo(); $this->render('login', array('aryData' => $aryUserInfo)); }
/** * 获取矿机数据 * * @author zhangyi * @date 2014-6-5 */ public function actionSpeedData() { $isOk = 0; $msg = ''; $aryData = array(); try { $objSpeedModel = SpeedModel::model(); /* if( Nbt::app() -> request -> isAjaxRequest ) { */ $aryData = $objSpeedModel->getSpeedDataByFile(); $strMode = ''; // If Sfards 3301 chip if (strpos(SYS_INFO, 'SF3301') === 0) { $strMode = 'sf'; } //如果数据不存在,则刷新一次数据 if (empty($aryData) && $objSpeedModel->refreshSpeedData($strMode) === true) { $aryData = $objSpeedModel->getSpeedDataByFile(); } //如果数据依然不存在,则抛出系统异常错误 if (!empty($aryData)) { $aryTemp['L'] = array_values($aryData['L']); $aryTemp['B'] = array_values($aryData['B']); $aryData = $aryTemp; unset($aryTemp); $isOk = 1; } else { throw new CModelException(CUtil::i18n('exception,sys_error')); } /* } else { throw new CModelException( CUtil::i18n('exception,sys_error') ); } */ } catch (CModelException $e) { $msg = $e->getMessage(); } echo $this->encodeAjaxData($isOk, $aryData, $msg); exit; }
/** * display view. * * @param string $_viewFile_ * @param array|string $_data_ * @param bool $_return_ * @return string */ public function render($_viewFile_, $_data_ = null) { // we use special variable names here to avoid conflict when extracting data if (is_array($_data_)) { extract($_data_, EXTR_PREFIX_SAME, 'data'); } else { $data = $_data_; } $_viewFile_1 = NBT_PATH . "/widget/views/{$_viewFile_}.php"; $_viewFile_2 = NBT_APPLICATION_PATH . "/libs/widgets/views/{$_viewFile_}.php"; if (file_exists($_viewFile_1) || file_exists($_viewFile_2)) { if (file_exists($_viewFile_1)) { require $_viewFile_1; } if (file_exists($_viewFile_2)) { require $_viewFile_2; } } else { throw new CException(CUtil::i18n('exception,view_notFound') . $_viewFile_); } }
/** * 初始化 * */ public function init() { parent::init(); $this->filetypesDescription = CUtil::i18n('framework,cwidgetSwfupload_filetypes'); }
/** * 输出更换验证码的链接 * */ 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>'; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title><?php echo CUtil::i18n('vlayout,btc&Ltc_setting'); ?> </title> <link href="<?php echo $this->baseUrl; ?> css/index.css" rel="StyleSheet" type="text/css"> <script src="<?php echo $this->baseUrl; ?> js/jquery.min.js" type="text/javascript"></script> </head> <body> <?php echo $content; ?> </body> </html>
/** * 上传 * */ public function upload() { //属性校验 if (empty($this->_fileUploadName)) { throw new CException(CUtil::i18n('exception,exec_set_notSet')); } if (empty($this->_intMaxSize)) { throw new CException(CUtil::i18n('exception,exec_file_noSetloadSize')); } if (empty($this->_aryAllowedExtension)) { throw new CException(CUtil::i18n('exception,exec_file_noSetUploadType')); } if (empty($this->_fileAbsPath)) { throw new CException(CUtil::i18n('exception,exec_file_noSetUploadFixedAds')); } if (empty($this->_fileSavePath)) { throw new CException(CUtil::i18n('exception,exec_file_noSetUploadAds')); } //PHP上传环境大小校验 $POST_MAX_SIZE = ini_get('post_max_size'); $unit = strtoupper(substr($POST_MAX_SIZE, -1)); $multiplier = $unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)); $intSysMaxsize = $multiplier * (int) $POST_MAX_SIZE; if ((int) $_SERVER['CONTENT_LENGTH'] > $intSysMaxsize && $POST_MAX_SIZE) { throw new CException(CUtil::i18n('exception,exec_file_sizeCannotExceed') . $intSysMaxsize . $unit); } if (!isset($_FILES[$this->_fileUploadName])) { throw new CException(CUtil::i18n('exception,exec_upload_FileNotFound') . $_FILES['.$this->_fileUploadName.']); } //上传错误 $FILE = $_FILES[$this->_fileUploadName]; if (isset($FILE["error"]) && $FILE["error"] != 0) { throw new CException($this->_aryUploadError[$FILE['error']]); } //临时文件不是一个合法的上传文件 if (!isset($FILE["tmp_name"]) || !@is_uploaded_file($FILE["tmp_name"])) { throw new CException(CUtil::i18n('exception,exec_file_fileIllegal')); } if (!isset($FILE['name'])) { throw new CException('$_FILE' . CUtil::i18n('exception,exec_sys_none') . 'name'); } //校验上传文件大小 $intFileSize = @filesize($FILE["tmp_name"]); if (!$intFileSize || $intFileSize > $this->_intMaxSize) { throw new CModelException(CUtil::i18n('exception,exec_file_sizeExceedMaxSize')); } if ($intFileSize <= 0) { throw new CModelException(CUtil::i18n('exception,exec_file_tooSmallFile')); } //文件名校验 /*$strFileName = preg_replace('/[^'.$this->_strAllowedFileName.']|\.+$/i', "", basename($FILE['name'])); if (strlen( $strFileName ) == 0 || strlen( $strFileName ) > $this->_intMaxFileName ) throw new CModelException( "文件名长度太长了,不要超过{$this->_intMaxFileName}位" );*/ //文件类型校验 $aryPathInfo = pathinfo($FILE['name']); $aryPathInfo['extension'] = strtolower(trim($aryPathInfo['extension'])); if (!in_array($aryPathInfo['extension'], $this->_aryAllowedExtension)) { throw new CModelException(CUtil::i18n('exception,exec_file_allowedTypes') . implode(',', $this->_aryAllowedExtension)); } //得到完整的文件保存路径【拼接文件扩展名】 $this->_fileSavePath .= ".{$aryPathInfo['extension']}"; $savefilepath = "{$this->_fileAbsPath}{$this->_fileSavePath}"; //创建目录 $arySavePathInfo = pathinfo($savefilepath); if (!file_exists($arySavePathInfo['dirname']) && !@mkdir($arySavePathInfo['dirname'], 0755, true)) { throw new CException(CUtil::i18n('exception,exec_file_unTomkdir') . $arySavePathInfo['dirname']); } //保存文件到指定位置 if (!@move_uploaded_file($FILE["tmp_name"], $savefilepath)) { throw new CModelException(CUtil::i18n('exception,exec_upload_Failed')); } $aryReturn = array(); $aryReturn['pathr'] = $this->_fileSavePath; $aryReturn['patha'] = $savefilepath; $aryReturn['extension'] = $aryPathInfo['extension']; return $aryReturn; }
/** * Cancel bind */ public function actionCancelbind() { // Get key $os = DIRECTORY_SEPARATOR == '\\' ? "windows" : "linux"; $mac_addr = new CMac($os); $strRKEY = ''; if (file_exists(WEB_ROOT . '/js/RKEY.TXT')) { $strRKEY = file_get_contents(WEB_ROOT . '/js/RKEY.TXT'); } $boolResult = $this->generateRKEY(); if ($boolResult === true) { $boolResult = $this->actionGeneratekey(true); } // send cancel bind request UtilApi::callCancelbind(md5($mac_addr->mac_addr . '-' . $strRKEY)); if ($boolResult === true) { UtilMsg::saveTipToSession(CUtil::i18n('exception,bound_cancel_success')); } else { UtilMsg::saveErrorTipToSession(CUtil::i18n('exception,bound_cancel_faild')); } $this->redirect(array('index/index')); }
<li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown"> <span id="langNow"><?php echo CUtil::i18n('vlayout,languge'); ?> </span><b class="caret"></b> </a> <ul id="languageMenu" class="dropdown-menu"> <li> <a data-lang="zh">简体中文</a> </li> <li> <a data-lang="en">English</a> </li> </ul> </li> <li> <a href="<?php echo $this->createUrl('login/logout'); ?> "><?php echo CUtil::i18n('vlayout,logout'); ?> </a> </li> </ul> </div> </div> </div>
public function deleteFile($_strFileName = '') { if (empty($_strFileName)) { throw new CModelException(CUtil::i18n('exception,exec_file_nameNotNull')); } if (file_exists($this->_store_url . $_strFileName)) { return unlink($this->_store_url . $_strFileName); } else { return false; } }
/** * @param string $value the current session save path * @throws CException if the path is not a valid directory */ public function setSavePath($value) { if (is_dir($value)) { session_save_path($value); } else { throw new CException(CUtil::i18n('exception,exec_session_adsAddFaild') . $value . CUtil::i18n('exception,exec_session_errorAds')); } }
/** * 计算时间距离现在多久 * * @param int $_timestamp 时间戳 * @return string */ public function tranTime($_timestamp) { $rtime = date("Y" . CUtil::i18n('framework,cutil_time_year') . "m" . CUtil::i18n('framework,cutil_time_month') . "d" . CUtil::i18n('framework,cutil_time_day') . " H:i:s", $_timestamp); $rtime = str_replace(date('Y' . CUtil::i18n('framework,cutil_time_year')), '', $rtime); $htime = date("H:i:s", $_timestamp); $now = time(); // 时间戳距离现在的时间 $time = $now - $_timestamp; // 昨天凌晨时间 $timey = strtotime(date('Y-m-d')) - 24 * 3600; // 前天凌晨时间 $timeby = $timey - 24 * 3600; if ($time < 60) { $str = CUtil::i18n('framework,cutil_time_just'); } elseif ($time < 60 * 60) { $min = floor($time / 60); $str = $min . CUtil::i18n('framework,cutil_time_minuteAgo'); } elseif ($time < 60 * 60 * 24) { $h = floor($time / (60 * 60)); $str = $h . CUtil::i18n('framework,cutil_time_hourAgo'); } elseif ($timey < $_timestamp) { $str = CUtil::i18n('framework,cutil_time_yesterday') . $htime; } elseif ($timeby < $_timestamp) { $str = CUtil::i18n('framework,cutil_time_beforeYesterday') . $htime; } else { $str = $rtime; } return $str; }
echo CUtil::i18n("framework,swfupload_choseFile"); ?> </span>', button_text_style: ".theFont { font-size: 16; }", button_text_left_padding: 12, button_text_top_padding: 3, // The event handler functions are defined in handlers.js file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, queue_complete_handler : queueComplete // Queue plugin event }; swfu = new SWFUpload(settings); }; </script> <div id="fsUploadProgress"></div> <!--<div id="divStatus">0 Files Uploaded</div>--> <div id="jqSelectFiles"> <span id="spanButtonPlaceHolder"></span> <input id="btnCancel" type="button" value="<?php echo CUtil::i18n('framework,swfupload_cancelUpload'); ?> " onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" /> </div>
/** * 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); }
<?php echo "\n"; ?> *****************************EXCEPTION************************************************* <?php if (NBT_DEBUG) { ?> <?php echo "\n" . $exception->getMessage() . ' (' . $exception->getFile() . ':' . $exception->getLine() . ')' . "\n"; ?> <?php echo "\n" . $exception->getTraceAsString() . "\n"; } else { ?> <?php echo "\n" . ($exception instanceof CModelException ? $exception->getMessage() : CUtil::i18n('exception,havaWrong')) . "\n"; } ?> ****************************************************************************************
</div> <span> (<?php echo CUtil::i18n('vindex,frequencyTip'); echo $speedDefLTC; ?> M)</span> </div> <?php } ?> <?php } ?> <div class="alert alert-warning text-center"> <strong><?php echo CUtil::i18n('vindex,importantOption'); ?> </strong> <?php echo CUtil::i18n('vindex,setting_save_tip'); ?> </div> <button class="btn btn-lg btn-primary btn-block" type="submit"><?php echo CUtil::i18n('vindex,setting_save'); ?> </button> </form> </div> </div>
?> </h1> </div> <div class="hashrate" data-url="<?php echo $this->createUrl('speed/speedData'); ?> "></div> <div class="page-header"> <h1><?php echo CUtil::i18n('vmonitor,status_title'); ?> <div class="pull-right"> <h4> <?php echo CUtil::i18n('vmonitor,this_version') . CUR_VERSION_NUM; ?> </h4> </div> </h1> </div> <div class="table-responsive"> <table id="statusTable" class="table table-hover table-bordered table-striped"> <tbody> <tr> <td colspan="3">loading...</td> </tr> </tbody> </table> </div>
public function cCaptcha($_val = null, $_aryParams = array(), &$_message = "") { $objWidgetCaptchaRenderImage = new CWidgetCaptchaRenderImage(); if (!$objWidgetCaptchaRenderImage->validate($_val)) { $_message = CUtil::i18n('framework,cvalidator_captcha_error'); return false; } return true; }