mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-07-27 20:00:52 +03:00
php lint + code standard PSR-2
This commit is contained in:
parent
ebd12ebeb2
commit
73f290e896
15 changed files with 796 additions and 531 deletions
|
@ -1,79 +1,80 @@
|
|||
<?php
|
||||
|
||||
include_once('config.inc.php');
|
||||
include_once('misc.inc.php');
|
||||
include_once 'config.inc.php';
|
||||
include_once 'misc.inc.php';
|
||||
|
||||
/* This class is written by Wefact. See https://www.wefact.nl/wefact-hosting/apiv2/
|
||||
*/
|
||||
|
||||
class WeFactAPI {
|
||||
|
||||
class WeFactAPI
|
||||
{
|
||||
private $url;
|
||||
private $responseType;
|
||||
private $apiKey;
|
||||
|
||||
function __construct(){
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $wefactapiurl;
|
||||
global $wefactapikey;
|
||||
$this->url = $wefactapiurl;
|
||||
$this->api_key = $wefactapikey;
|
||||
}
|
||||
|
||||
public function sendRequest($controller, $action, $params){
|
||||
|
||||
if(is_array($params)){
|
||||
$params['api_key'] = $this->api_key;
|
||||
|
||||
public function sendRequest($controller, $action, $params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['controller'] = $controller;
|
||||
$params['action'] = $action;
|
||||
}
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch,CURLOPT_URL, $this->url);
|
||||
curl_setopt($ch, CURLOPT_URL, $this->url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT,'10');
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
|
||||
$curlResp = curl_exec($ch);
|
||||
$curlError = curl_error($ch);
|
||||
|
||||
if ($curlError != ''){
|
||||
$result = array(
|
||||
|
||||
if ($curlError != '') {
|
||||
$result = [
|
||||
'controller' => 'invalid',
|
||||
'action' => 'invalid',
|
||||
'status' => 'error',
|
||||
'date' => date('c'),
|
||||
'errors' => array($curlError)
|
||||
);
|
||||
}else{
|
||||
'errors' => [$curlError]
|
||||
];
|
||||
} else {
|
||||
$result = json_decode($curlResp, true);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function do_wefact_auth($u, $p) {
|
||||
function do_wefact_auth($u, $p)
|
||||
{
|
||||
$wefact = new WeFactApi();
|
||||
$r = $wefact->sendRequest('debtor', 'show', array(
|
||||
'DebtorCode' => $u));
|
||||
$r = $wefact->sendRequest('debtor', 'show', [
|
||||
'DebtorCode' => $u]);
|
||||
|
||||
if (isset($r['status']) && $r['status'] == 'success') {
|
||||
$r = $wefact->sendRequest('debtor', 'checklogin', array(
|
||||
$r = $wefact->sendRequest('debtor', 'checklogin', [
|
||||
'Username' => $u,
|
||||
'Password' => $p
|
||||
));
|
||||
]);
|
||||
|
||||
if (isset($r['status']) && $r['status'] == 'success') {
|
||||
if (get_user_info($u) == FALSE) {
|
||||
if (get_user_info($u) == false) {
|
||||
add_user($u);
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue