ソースを参照

紫光接口合并

NoNZero 8 年 前
コミット
5808de7deb

+ 16 - 0
protected/class/auth.php

@@ -39,6 +39,22 @@ class Auth
         }
     }
 
+    public function loginWithUserName($uname)
+    {
+        $uinfo = $this->checkLoginWithUserName($uname);
+        if (isset($uinfo['uid'])) {
+            $this->uinfo = $uinfo;
+            return TRUE;
+        } else {
+            return FALSE;
+        }
+    }
+
+    public function checkLoginWithUserName($uemail)
+    {
+        return $this->user->loginWithUserName($uemail);
+    }
+
     public function getUinfo()
     {
         return $this->uinfo;

ファイルの差分が大きいため隠しています
+ 8148 - 0
protected/class/nusoap.php


+ 15 - 0
protected/class/profile.php

@@ -28,6 +28,21 @@ class Profile
         return $this->uprofile->insert();
     }
 
+    public function ZGinsertProfile($uid = 0, $realname)
+    {
+        if (!isset($uid))
+            return FALSE;
+        $this->uprofile->userid = $uid;
+        $this->uprofile->name = $realname;
+        $this->uprofile->company = '';
+        $this->uprofile->jobs = '';
+        $this->uprofile->phone = '';
+        $this->uprofile->mobile = '';
+        $this->uprofile->qq = '';
+        $this->uprofile->groups = 'vip';
+        return $this->uprofile->insert();
+    }
+
     public function getProWithUid($userid = 0)
     {
         if (!isset($userid))

+ 31 - 16
protected/class/user.php

@@ -8,31 +8,46 @@ Doo::loadClass('PasswordHash');
  *
  * @author zongheng
  */
-class User {
+class User
+{
 
     private $__user, $__ph;
 
-    function __construct() {
-	$this->__user = new Users();
-	$this->__ph = new PasswordHash(8, FALSE);
+    function __construct()
+    {
+        $this->__user = new Users();
+        $this->__ph = new PasswordHash(8, FALSE);
     }
 
-    public function login($uemail, $upasswd) {
-	$userArray = $this->__user->getOne(array('where' => 'uemail=?', 'param' => array($uemail), 'asArray' => TRUE));
-	if (isset($userArray) && $userArray && $this->__ph->CheckPassword($upasswd, $userArray['upass'])) {
-	    return $userArray;
-	} else {
-	    return FALSE;
-	}
+    public function login($uemail, $upasswd)
+    {
+        $userArray = $this->__user->getOne(array('where' => 'uemail=?', 'param' => array($uemail), 'asArray' => TRUE));
+        if (isset($userArray) && $userArray && $this->__ph->CheckPassword($upasswd, $userArray['upass'])) {
+            return $userArray;
+        } else {
+            return FALSE;
+        }
     }
 
-    public function getRowUser($userid) {
-	return $this->__user->getOne(array('where' => 'uid=?', 'param' => array($userid), 'asArray' => TRUE));
+    public function loginWithUserName($uemail)
+    {
+        $userArray = $this->__user->getOne(array('where' => 'uemail=?', 'param' => array($uemail), 'asArray' => TRUE));
+        if (isset($userArray)) {
+            return $userArray;
+        } else {
+            return FALSE;
+        }
     }
 
-    public function updatePassWd($userid, $passwd) {
-	$this->__user->upass = $this->__ph->HashPassword($passwd);
-	return $this->__user->update(array('where' => 'uid=?', 'param' => array($userid)));
+    public function getRowUser($userid)
+    {
+        return $this->__user->getOne(array('where' => 'uid=?', 'param' => array($userid), 'asArray' => TRUE));
+    }
+
+    public function updatePassWd($userid, $passwd)
+    {
+        $this->__user->upass = $this->__ph->HashPassword($passwd);
+        return $this->__user->update(array('where' => 'uid=?', 'param' => array($userid)));
     }
 
 }

+ 18 - 6
protected/controller/LoginController.php

@@ -41,9 +41,22 @@ class LoginController extends DooController
     public function Signin()
     {
         $this->data['tips'] = '';
-        if (isset($_POST['uemail']) && isset($_POST['upasswd'])) {
-            if ($this->isValidFormHash($_POST['tokenform'])) {
-                if ($this->aconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff']!=1) {
+        if ($_GET['username']) {
+            if (isset($_GET['username'])) {
+                $retval = $this->auth->checkLoginWithUserName($_GET['username']);
+                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 {
+            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']);
@@ -55,12 +68,11 @@ class LoginController extends DooController
                         $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>';
+                    return Doo::conf()->APP_URL;
                 }
-            } else {
-                return Doo::conf()->APP_URL;
             }
         }
+
         $this->data['_token_'] = $this->generateFormHash($this->create_randomstr());
         $this->data['proName'] = $this->aconfig->getOne(array('select' => 'proName', 'asArray' => TRUE))['proName'];
         $this->data['ver'] = DOO::conf()->ver;

+ 91 - 0
protected/module/admin/controller/ServiceController.php

@@ -0,0 +1,91 @@
+<?php
+Doo::loadModelAt('auser', 'admin');
+Doo::loadModelAt('ausers', 'admin');
+Doo::loadModel('users');
+Doo::loadClass('profile');
+Doo::loadClass('PasswordHash');
+Doo::loadClass('mailer');
+Doo::loadClass('nusoap');
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+// 列表停用 编辑 重置密码
+// 管理员权限管理
+// 管理员修改密码
+class ServiceController extends DooController
+{
+    private $data, $users, $user, $profile, $ph, $userz, $mailer;
+
+
+    public function __construct()
+    {
+        $this->users = new AUsers();
+        $this->user = new AUser();
+        $this->userz = new Users();
+        $this->profile = new Profile();
+        $this->mailer = new Mailer();
+        $this->ph = new PasswordHash(8, FALSE);
+        $this->data['rootUrl'] = Doo::conf()->APP_URL;
+    }
+
+    public function ZGServer()
+    {
+        ini_set("soap.wsdl_cache_enabled", "0");
+        $server = new SoapServer(Doo::conf()->APP_URL . 'service/getwsdl?wsdl', array('soap_version' => SOAP_1_2));
+        $server->setClass('ServiceController');
+        $server->addFunction('addUser');
+        $server->addFunction(SOAP_FUNCTIONS_ALL);
+        $server->handle();
+    }
+
+    public function getWSDL()
+    {
+        ini_set("soap.wsdl_cache_enabled", "0");
+        $soap = new soap_server;
+        $soap->configureWSDL('UserService', 'urn:UserService', Doo::conf()->APP_URL . 'service/user');
+        $soap->soap_defencoding = 'UTF-8';
+        $soap->register(
+            'addUser',
+            array('username' => 'xsd:string', 'realname' => 'xsd:string'),
+            array('retval' => 'xsd:boolean'),
+            'urn:UserService',
+            'urn:UserService#addUser'
+        );
+//        $soap->register(
+//            'updateUser',
+//            array('username' => 'xsd:string')
+//        );
+//        $soap->service(file_get_contents("php://input"));
+        $soap->service(isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '');
+    }
+
+    function addUser($username, $realname)
+    {
+        if (isset($username) && isset($realname)) {
+            $uid = $this->users->createUser($username, $username);
+            if ($uid) {
+                $this->profile->ZGinsertProfile($uid, urldecode($realname));
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    public function randomPassword()
+    {
+        $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
+        $pass = array(); //remember to declare $pass as an array
+        $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
+        for ($i = 0; $i < 8; $i++) {
+            $n = rand(0, $alphaLength);
+            $pass[] = $alphabet[$n];
+        }
+        return implode($pass); //turn the array into a string
+    }
+}