Overview
  • Namespace
  • Class

Namespaces

  • rpf
    • api
      • module
    • extension
      • module
    • system
      • module

Classes

  • rpf\api\api
  • rpf\api\apiModule
  • rpf\api\bbRpc
  • rpf\api\module\bbCustomer_getFreeOrdNr
  • rpf\api\module\bbCustomer_readAddress
  • rpf\api\module\bbCustomer_readDiscount
  • rpf\api\module\bbCustomer_readEntry
  • rpf\api\module\bbCustomer_readPayment
  • rpf\api\module\bbCustomer_readTitle
  • rpf\api\module\bbCustomer_saveAdress
  • rpf\api\module\bbCustomer_validateAddress
  • rpf\api\module\bbCustomer_validateEntry
  • rpf\api\module\bbCustomer_validatePayinfo
  • rpf\api\module\bbDomain_readEntry
  • rpf\api\module\bbDomain_readFrontpage
  • rpf\api\module\bbDomain_readHandles
  • rpf\api\module\bbDomain_readPhpini
  • rpf\api\module\bbDomain_readSettings
  • rpf\api\module\bbDomain_readSubdomain
  • rpf\api\module\bbDomain_readWebalizerSettings
  • rpf\api\module\bbDomain_searchEntry
  • rpf\api\module\bbEmail_readAccount
  • rpf\api\module\bbMysql_inuseEntry
  • rpf\api\module\bbMysql_makeBackup
  • rpf\api\module\bbMysql_readEntry
  • rpf\api\module\bbOrder_readAccountAddress
  • rpf\api\module\bbOrder_readAccountEntry
  • rpf\api\module\bbOrder_readDisposition
  • rpf\api\module\bbOrder_readEntry
  • rpf\api\module\bbQuota_readEntry
  • rpf\api\module\customer
  • rpf\api\module\email
  • rpf\api\module\order
  • rpf\api\module\placeholder
  • rpf\api\module\user
  • rpf\extension\extension
  • rpf\extension\extensionModule
  • rpf\extension\invoiceTextExport
  • rpf\extension\mailExport
  • rpf\extension\module\domainExport
  • rpf\extension\module\index
  • rpf\extension\module\mgntRatioExport
  • rpf\system\module
  • rpf\system\module\log
  • rpf\system\module\moduleManager
  • rpf\system\rpf

Exceptions

  • rpf\system\module\exception
 1 <?php
 2 
 3 namespace rpf\api\module;
 4 use rpf\api\apiModule;
 5 use rpf\api\bbRpc;
 6 use rpf\system\module\exception;
 7 use rpf\system\module\log;
 8 
 9 class user extends apiModule {
10 
11     /**
12      * Authorizes the given user at the api
13      *
14      * @param $rp2InstanceUrl
15      * @param $rp2ApiUser
16      * @param $rp2ApiPwd
17      * @return bool
18      */
19     public function auth($rp2InstanceUrl, $rp2ApiUser, $rp2ApiPwd)
20     {
21         $duration = microtime(1);
22         log::debug('Setting RPC-URL', "bbRpc::setUrl($rp2InstanceUrl)");
23         bbRpc::setUrl($rp2InstanceUrl);
24         $userId = bbRpc::auth($rp2ApiUser, $rp2ApiPwd);
25         $duration = round(microtime(1)-$duration, 3);
26 
27         if (!$userId)
28         {
29             log::warning("Login failed from ".$_SERVER['REMOTE_ADDR']." within $duration sec.", "bbRpc::auth($rp2ApiUser, *****)", $_SERVER);
30             $this->fetchRpcLog();
31             return false;
32         }
33         else
34         {
35             // https://doku.premium-admin.eu/doku.php/api/methoden/bbrpc/setutf8native
36             log::info("Login successful from ".$_SERVER['REMOTE_ADDR']." within $duration sec.", "bbRpc::auth($rp2ApiUser, *****)");
37             $this->fetchRpcLog();
38 
39             log::debug('Set UTF-8', 'bbRpc::setUTF8Native(true)');
40             bbRpc::setUTF8Native(true);
41             $this->fetchRpcLog();
42             return true;
43         }
44     }
45 
46     /**
47      * Authenticates the user at the api by httpAuth
48      * Only works if you're hosting this script on the same machine
49      * as the rp2-instance, because the api-url is parsed out of the
50      * home-path
51      *
52      * @return $this
53      * @throws \Exception
54      */
55     public function httpAuth()
56     {
57         // Get the correct path on http AND ssh/bash
58         $path = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : $_SERVER['PWD'];
59         preg_match("/\\/.*\\/(\\d*)_\\d*\\/.*/", $path, $matches);
60         $dfOrderNr = $matches[1];
61         $rp2InstanceUrl = "http://$dfOrderNr.premium-admin.eu/";
62 
63         if ( !(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) &&
64             $this->auth($rp2InstanceUrl, $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) )
65         {
66             static::sendHttpAuth($dfOrderNr);
67         }
68 
69         return $this;
70     }
71 
72     protected static function sendHttpAuth($dfOrderNr)
73     {
74         header("WWW-Authenticate: Basic realm=\"Please enter your RP2-User and Password for A$dfOrderNr\"");
75         header('HTTP/1.0 401 Unauthorized');
76         \rpf\showError('Login', "Please authenticate with your RP²-Username and Password for A$dfOrderNr");
77         exit;
78     }
79 }
API documentation generated by ApiGen