'', 'adminUser' => '', 'adminPass' => ''); $serverGroupIDObj = Capsule::table('tblproducts') ->select('servergroup') ->where('id', '=', $productID) ->get(); $serverGroupID = $serverGroupIDObj[0]->servergroup; $serverIDObj = Capsule::table('tblservergroupsrel') ->select('serverid') ->where('groupid', '=', $serverGroupID) ->get(); $serverID = $serverIDObj[0]->serverid; $server = Capsule::table('tblservers') ->select('hostname', 'username', 'password') ->where('id', '=', $serverID) ->where('active', '=', 1) ->get(); $accessData['nextcloudServer'] = $server[0]->hostname; $accessData['adminUser'] = $server[0]->username; $adminPassDecrypt = localAPI('DecryptPassword', array('password2' => $server[0]->password)); if ($adminPassDecrypt['result'] == 'success') { $accessData['adminPass'] = $adminPassDecrypt['password']; } //error_log("NextCloud User Avaialable: ACC " . $accountName); //error_log("--------------------------"); //error_log("NextCloud User Avaialable: PID " . $productID); //error_log("NextCloud User Avaialable: GID " . $serverGroupID); //error_log("NextCloud User Avaialable: SID " . $serverID); //error_log("NextCloud User Avaialable: SERVER " . $accessData['nextcloudServer']); //error_log("NextCloud User Avaialable: USER " . $accessData['adminUser']); //error_log("NextCloud User Avaialable: PASS " . $accessData['adminPass']); $nextcloudURL = 'https://' . $accessData['nextcloudServer'] . "/ocs/v1.php/cloud/users?search=" . $email; //error_log("NextCloud User Avaialable: URL " . $nextcloudURL); $response = nextcloud_send($nextcloudURL,$accessData['adminUser'],$accessData['adminPass'],"GET"); //error_log("NextCloud User Available NextCloud Response: " . $response->ocs->meta->statuscode); //error_log("NextCloud User Available NextCloud Response Content " . print_r($response,true)); if (is_null($response) == true) { echo "error"; exit; } if ($response->ocs->meta->statuscode != '100') { echo "no"; } else { if (count($response->ocs->data->users) > 0) { echo "no"; exit; } else { echo "yes"; exit; } } function nextcloud_send($href, $username, $password, $action, $post = array()) { $postdata = http_build_query($post); $ch = curl_init(); if (strtoupper($action) == 'GET') { curl_setopt($ch, CURLOPT_HTTPGET, true); } curl_setopt($ch, CURLOPT_URL, $href); curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json","OCS-APIRequest: true",'content-type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $result_json = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpcode >= 200 && $httpcode < 300) { //print_r($result_json);die(); $result_bom = nextcloud_remove_utf8bom($result_json); $result = json_decode($result_bom); return($result); } else { return null; } } function nextcloud_remove_utf8bom($text) { $bom = pack('H*', 'EFBBBF'); $text = preg_replace("/^$bom/", '', $text); return $text; }