| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | <?phpDoo::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 : '');    }    public function testSoap(){        ini_set("soap.wsdl_cache_enabled", "0");        $client=new soapclient(Doo::conf()->APP_URL . '/service/user');        var_dump($client);        exit;        $client->soap_defencoding = 'UTF-8';        $paras=array('username' => "测试soap",'realname' => "测试soap");        $result=$client->call("addUser",$paras);        if (!$err=$client->getError()) {            echo "返回结果:",$result;        } else {            echo "调用出错:",$err;        }//        $server->handle();    }    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    }}
 |