[289] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | Class VServices {
|
---|
| 4 |
|
---|
| 5 | private $_apiUrl;
|
---|
| 6 | private $_curlObj;
|
---|
| 7 | private $_userId;
|
---|
| 8 | private $_password;
|
---|
| 9 |
|
---|
[418] | 10 | private $_httpUser;
|
---|
| 11 | private $_httpPasswd;
|
---|
| 12 |
|
---|
[289] | 13 | public function __construct() {
|
---|
| 14 | }
|
---|
| 15 | public function setApiUrl($url) {
|
---|
| 16 | $this->_apiUrl = $url;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public function setConnection($curl) {
|
---|
| 20 | $this->_curlObj = $curl;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public function setUserId ($userId) {
|
---|
| 24 | $this->_userId = $userId;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public function setPassword ($password) {
|
---|
| 28 | $this->_password = $password;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | public function getPrivateTree () {
|
---|
| 32 | $this->_curlObj->create($this->_apiUrl. 'space/dir/isgetall/1');
|
---|
| 33 | $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
|
---|
| 34 | $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
|
---|
[365] | 35 | $post = $this->_userId ? array('userid' => $this->_userId) : array();
|
---|
[289] | 36 | $this->_curlObj->post($post);
|
---|
| 37 | return $this->_curlObj->execute();
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | * $aryParams
|
---|
| 42 | *
|
---|
| 43 | * @param unknown $action
|
---|
| 44 | * @param unknown $aryParams
|
---|
| 45 | */
|
---|
[418] | 46 |
|
---|
[417] | 47 | public function actionExecute ($action, $aryParams = array(), $module = 'space') {
|
---|
[418] | 48 | $this->_curlObj->create($this->_apiUrl. $module .'/'.$action);
|
---|
[289] | 49 | $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
|
---|
| 50 | $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
|
---|
| 51 |
|
---|
[418] | 52 | if ($this->_httpUser && $this->_httpPasswd) {
|
---|
| 53 | $this->_curlObj->http_login($this->_httpUser, $this->_httpPasswd);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[365] | 56 | if ($this->_userId) $aryParams['userid'] = $this->_userId;
|
---|
[418] | 57 | if (count($aryParams) > 0) $this->_curlObj->post($aryParams);
|
---|
[457] | 58 |
|
---|
| 59 | $result = $this->_curlObj->execute();
|
---|
| 60 |
|
---|
| 61 | write_file('log.txt', var_export($result, true)."\n".var_export($this->_apiUrl. $module .'/'.$action, true)."\n".var_export($aryParams, true));
|
---|
| 62 |
|
---|
| 63 | return $result;
|
---|
[418] | 64 | }
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 |
|
---|
[289] | 68 | public function __destruct() {
|
---|
| 69 |
|
---|
| 70 | }
|
---|
| 71 | } |
---|