Преглед на файлове

计量支付在线审批

版本号
数据库字典升级文件
NoNZero преди 9 години
родител
ревизия
55bd3aae54

+ 1 - 0
protected/config/acl.conf.php

@@ -3,6 +3,7 @@
 // anonymous user can only access Blog index page.
 $acl['anonymous']['allow'] = array(
     'LoginController' => array('login', 'Signin', 'Signout'),
+    'UpgradeController' => '*',
 );
 //$acl['anonymous']['deny'] = array(
 //    'UserController' => array('login', 'registerAccount'),

+ 7 - 0
protected/config/routes.conf.php

@@ -151,4 +151,11 @@ $route['*']['/manage/item/list/:pid/project'] = array('[admin]ItemController', '
 $route['*']['/manage/item/del/:pmid'] = array('[admin]ItemController', 'itemDel');
 $route['*']['/manage/restore/list'] = array('[admin]RestoreController', 'restoreList');
 $route['*']['/manage/sys/info'] = array('[admin]SysController', 'sysinfo');
+// upgrade
+$route['*']['/api/upgrade/v1/get/web/version'] = array('UpgradeController', 'getWebVersion');
+$route['*']['/api/upgrade/v1/get/software/version'] = array('UpgradeController', 'getSoftwareVersion');
+$route['*']['/api/upgrade/v1/get/switch/status'] = array('UpgradeController', 'getSwitchStatus');
+$route['*']['/api/upgrade/v1/set/switch/:onoff'] = array('UpgradeController', 'setSwitchStatus');
+$route['*']['/api/upgrade/v1/set/upgrade/info'] = array('UpgradeController', 'setUpgradeInfo');
+$route['*']['/api/upgrade/v1/get/version/status'] = array('UpgradeController', 'getVersionAndStatus');
 ?>

+ 55 - 14
protected/controller/ClientController.php

@@ -14,6 +14,7 @@ Doo::loadClass('numofperact');
 Doo::loadClass('measureauditact');
 Doo::loadClass('itemfile');
 Doo::loadModel('users');
+Doo::loadModelAt('aconfig', 'admin');
 
 /**
  * MainController
@@ -24,7 +25,7 @@ Doo::loadModel('users');
 class ClientController extends DooController
 {
 
-    private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile;
+    private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig;
     private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');
     private $fileTypeArray = array('台帐附件');
 
@@ -44,6 +45,7 @@ class ClientController extends DooController
         $this->measureauditact = new MeasureauditAct();
         $this->users = new Users();
         $this->itemfile = new ItemFile();
+        $this->modelconfig = new AConfig();
     }
 
     public function ClientSignin()
@@ -56,30 +58,64 @@ class ClientController extends DooController
             echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
             die;
         }
-        if (isset($_POST['v3name']) && isset($_POST['v3pass']))
+        if (isset($_POST['v3name']) && isset($_POST['v3name'])) {
+            echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
+            die;
+        }
+        if (isset($_POST['v4name']) && isset($_POST['v4pass']) && !empty($_POST['version'])) {
             try {
-                if ($this->auth->login($_POST['v3name'], $_POST['v3pass'])) {
-                    $uinfo = $this->auth->getUinfo();
-                    if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
-                        echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
-                        die;
+                if ($this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'] != 1) {
+                    $versionTotal = array_sum(explode('.', $_POST['version']));
+                    $StrJson = ($this->modelconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
+                    $jsonObj = json_decode($StrJson, true);
+                    if ($jsonObj) {
+                        $versionTotalUp = array_sum(explode('.', $jsonObj['version']));
+                        $strJson = json_encode(array('status' => 'upgrade', 'msg' => '您的客户端需要升级,请点击确定按钮,下载新版本,并且覆盖安装。', 'url' => $jsonObj['download']), JSON_UNESCAPED_UNICODE);
+                        if ($jsonObj['condition'] == 1) {
+                            if ($versionTotalUp != $versionTotal) {
+                                echo $strJson;
+                                die;
+                            }
+                        }
+                        if ($jsonObj['condition'] == 2) {
+                            if ($versionTotalUp > $versionTotal) {
+                                echo $strJson;
+                                die;
+                            }
+                        }
                     }
-                    if (isset($uinfo['uid'])) {
-                        $userArray = $this->profile->getProWithUid($uinfo['uid']);
-                        $avatarStr = $userArray['avatar'];
-                        if (isset($userArray['userid'])) {
-                            $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
-                            echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
+                    if ($this->auth->login($_POST['v4name'], $_POST['v4pass'])) {
+                        $uinfo = $this->auth->getUinfo();
+                        if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
+                            echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
                             die;
                         }
+                        if (isset($uinfo['uid'])) {
+                            $userArray = $this->profile->getProWithUid($uinfo['uid']);
+                            $avatarStr = $userArray['avatar'];
+                            if (isset($userArray['userid'])) {
+                                $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
+                                echo json_encode(array('status' => 'true', 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
+                                die;
+                            }
+                        }
+
+                    } else {
+                        echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
+                        die;
                     }
                 } else {
-                    echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
+                    echo json_encode(array('status' => 'false', 'msg' => '该计量支付已关闭,请联系相关管理人员。'), JSON_UNESCAPED_UNICODE);
                     die;
                 }
             } catch (Exception $exc) {
 
             }
+        } else {
+            echo json_encode(array('status' => 'false', 'msg' => '参数错误'), JSON_UNESCAPED_UNICODE);
+            die;
+        }
+
     }
 
     // 创建标段
@@ -1278,6 +1314,11 @@ class ClientController extends DooController
         }
     }
 
+//    function checkVersion($version)
+//    {
+//        preg_match();
+//    }
+
 }
 
 ?>

+ 37 - 51
protected/controller/LoginController.php

@@ -10,11 +10,13 @@ Doo::loadModelAt('aconfig', 'admin');
  *
  * @author NoNZero
  */
-class LoginController extends DooController {
+class LoginController extends DooController
+{
 
-    private $data, $auth, $profile,$aconfig;
+    private $data, $auth, $profile, $aconfig;
 
-    public function beforeRun($resource, $action) {
+    public function beforeRun($resource, $action)
+    {
         $uGroups = $this->profile->getUidByname($this->auth->getUid());
         if (!isset($uGroups['groups']))
             $uGroups['groups'] = 'anonymous';
@@ -23,60 +25,37 @@ class LoginController extends DooController {
             return Doo::acl()->defaultFailedRoute;
     }
 
-    public function __construct() {
+    public function __construct()
+    {
         $this->auth = new Auth();
         $this->profile = new Uprofile();
         $this->aconfig = new AConfig();
         $this->data['rootUrl'] = Doo::conf()->APP_URL;
     }
 
-//    public function Signup() {
-//	$this->render('login', $this->data);
-//    }
-//    public function beforeRun($resource, $action) {
-//	$uname = $this->auth->getUname();
-//	if ($uname) {
-//	    $uGroups = $this->users->getUidByname($this->auth->getUname());
-//	} else {
-//	    $uGroups['groups'] = 'anonymous';
-//	}
-//	$falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
-//	if (!$falg)
-//	    return Doo::conf()->APP_URL;
-//    }
-
-    public function welcome() {
+    public function welcome()
+    {
         $this->render('welcome', $this->data);
     }
 
-    public function Signin() {
+    public function Signin()
+    {
         $this->data['tips'] = '';
-        // 密码采用PHPASS
-        // 防止跨站采用user_agent随机串
-        // 重复提交CRSF_FORM
-        // 自动登录 可采用登录后生成一个可验证字符串,要求输入密码可通过网上登录查看(从客户端点击)加验证码
-//	if ($this->auth->isLoggedIn())
-//	    return Doo::conf()->APP_URL . 'project/welcome';
         if (isset($_POST['uemail']) && isset($_POST['upasswd'])) {
             if ($this->isValidFormHash($_POST['tokenform'])) {
-                $retval = $this->auth->checkLogin($_POST['uemail'], $_POST['upasswd']);
-                if (isset($retval['uid'])) {
-                    $this->auth->setUid($retval['uid']);
-                    $this->auth->setUemail($retval['uemail']);
-                    $_SESSION['token'] = sha1($this->create_randomstr() . $_SESSION['uid']);
-                    setcookie('token', $_SESSION['token'], 0, '/', Doo::conf()->APP_URL, FALSE, TRUE);
-//		    $profileArray = $this->profile->getProWithUid($this->auth->getUid());
-//		    if (isset($profileArray['userid'])) {
-                    return Doo::conf()->APP_URL . 'project/index';
-//		    } else {
-//			return Doo::conf()->APP_URL . 'project/welcome';
-//		    }
-//		    die();
+                if ($this->aconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff']!=1) {
+                    $retval = $this->auth->checkLogin($_POST['uemail'], $_POST['upasswd']);
+                    if (isset($retval['uid'])) {
+                        $this->auth->setUid($retval['uid']);
+                        $this->auth->setUemail($retval['uemail']);
+                        $_SESSION['token'] = sha1($this->create_randomstr() . $_SESSION['uid']);
+                        setcookie('token', $_SESSION['token'], 0, '/', Doo::conf()->APP_URL, FALSE, TRUE);
+                        return Doo::conf()->APP_URL . 'project/index';
+                    } else {
+                        $this->data['tips'] = '<div class="alert alert-error"><span data-icon="t" aria-hidden="true"></span> 帐号不存在或者密码错误</div>';
+                    }
                 } else {
-                    $this->data['tips'] = '<div class="alert alert-error">
-			    <span data-icon="t" aria-hidden="true"></span> 帐号不存在或者密码错误
-			</div>';
-//		    die();
+                    $this->data['tips'] = '<div class="alert alert-error"><span data-icon="t" aria-hidden="true"></span>已停用</div>';
                 }
             } else {
                 return Doo::conf()->APP_URL;
@@ -88,12 +67,14 @@ class LoginController extends DooController {
         $this->render('login', $this->data);
     }
 
-    function Signout() {
+    function Signout()
+    {
         $this->auth->logout();
         return Doo::conf()->APP_URL;
     }
 
-    function IsSessionHijacking() {
+    function IsSessionHijacking()
+    {
         $string = $_SERVER['HTTP_USER_AGENT'];
         if (!isset($_SESSION['randstr']))
             $_SESSION['randstr'] = $this->create_randomstr();
@@ -107,7 +88,8 @@ class LoginController extends DooController {
         }
     }
 
-    function isLoggedIn() {
+    function isLoggedIn()
+    {
         if (isset($_SESSION['token']) && isset($_COOKIE['token'])) {
             if ($_SESSION['token'] != $_COOKIE['token']) {
                 $this->Signout();
@@ -117,13 +99,15 @@ class LoginController extends DooController {
         }
     }
 
-    function generateFormHash($salt) {
+    function generateFormHash($salt)
+    {
         $hash = sha1(mt_rand(1, 1000000) . $salt);
         $_SESSION['csrf_hash'] = $hash;
         return $hash;
     }
 
-    function isValidFormHash($hash) {
+    function isValidFormHash($hash)
+    {
         return $_SESSION['csrf_hash'] === $hash;
     }
 
@@ -132,7 +116,8 @@ class LoginController extends DooController {
      * @param $password 密码
      * @param $random 随机数
      */
-    function random($length, $chars = '0123456789') {
+    function random($length, $chars = '0123456789')
+    {
         $hash = '';
         $max = strlen($chars) - 1;
         for ($i = 0; $i < $length; $i++) {
@@ -146,7 +131,8 @@ class LoginController extends DooController {
      * @param string $lenth 长度
      * @return string 字符串
      */
-    function create_randomstr($lenth = 6) {
+    function create_randomstr($lenth = 6)
+    {
         return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
     }
 

+ 79 - 0
protected/controller/UpgradeController.php

@@ -0,0 +1,79 @@
+<?php
+Doo::loadModelAt('aconfig', 'admin');
+
+/**
+ * MainController
+ * Feel free to delete the methods and replace them with your own code.
+ *
+ * @author NoNZero
+ */
+class UpgradeController extends DooController
+{
+
+    private $data, $modelconfig, $onoff = array('on', 'off');
+
+    public function __construct()
+    {
+        $this->data['rootUrl'] = Doo::conf()->APP_URL;
+        $this->modelconfig = new AConfig();
+    }
+
+    public function getWebVersion()
+    {
+        exit(json_encode(array('version' => DOO::conf()->ver), JSON_UNESCAPED_UNICODE));
+    }
+
+    public function getVersionAndStatus()
+    {
+        header("Access-Control-Allow-Origin: *");
+        $onoff = $this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'];
+        exit(json_encode(array('version' => DOO::conf()->ver, 'onoff' => $onoff), JSON_UNESCAPED_UNICODE));
+    }
+
+    public function getSoftwareVersion()
+    {
+        echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
+    }
+
+    public function setOnOff()
+    {
+        echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
+    }
+
+    public function getSwitchStatus()
+    {
+        $onoff = $this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'];
+        echo json_encode(array('onoff' => $onoff), JSON_UNESCAPED_UNICODE);
+        die();
+    }
+
+    public function setSwitchStatus()
+    {
+        header("Access-Control-Allow-Origin: *");
+        if (in_array($this->params['onoff'], $this->onoff)) {
+            if ($this->params['onoff'] == 'on') {
+                $this->modelconfig->onoff = 0;
+                $stronoff = $this->modelconfig->update(array('where' => 'conid=1'));
+            } else {
+                $this->modelconfig->onoff = 1;
+                $stronoff = $this->modelconfig->update(array('where' => 'conid=1',));
+            }
+        }
+        echo json_encode(array('onoff' => $stronoff), JSON_UNESCAPED_UNICODE);
+        die();
+    }
+
+    public function setUpgradeInfo()
+    {
+
+//                        error_log(var_dump($_POST, TRUE), 3, '/opt/html/dev/data/sss.txt');
+//        if (in_array($this->params['onoff'], $this->onoff)) {
+//            if ($this->params['onoff'] == 'on') {
+        $this->modelconfig->upgradeinfo = json_encode($_POST['json']);
+        $stronoff = $this->modelconfig->update(array('where' => 'conid=1'));
+//            }
+//        }
+        echo json_encode(array('onoff' => $stronoff), JSON_UNESCAPED_UNICODE);
+        die();
+    }
+}

+ 3 - 1
protected/module/admin/model/aconfig.php

@@ -9,9 +9,11 @@ class AConfig extends DooModel {
 
     public $conid;
     public $proname;
+    public $onoff;
+    public $upgradeinfo;
     public $_table = 'jl_config';
     public $_primarykey = 'conid';
-    public $_fields = array('conid', 'proname');
+    public $_fields = array('conid', 'proname', 'onoff', 'upgradeinfo');
 
     public function __construct() {
         parent::setupModel(__CLASS__);

+ 2 - 0
版本管理.sql

@@ -0,0 +1,2 @@
+ALTER TABLE 'jl_config' ADD 'onoff' TINYINT(2) NOT NULL DEFAULT '0';
+ALTER TABLE 'jl_config' ADD 'onoff' 'upgradeinfo' TEXT NOT NULL ;