Ejemplo n.º 1
0
 public function myFunction()
 {
     log::debug('Starting export', __METHOD__);
     // Optional: Adding debug-notification to syslog
     return $this->getApi()->getPlaceholder()->setMethod('bbSomeClass::someMethod')->addParam('param1', true)->addParam('param2', 'string')->addParam('param3', ['a', 'r', 'r', 'y'])->get();
     // Send api-call and fetch the result
 }
Ejemplo n.º 2
0
 /**
  * Authorizes the given user at the api
  *
  * @param $rp2InstanceUrl
  * @param $rp2ApiUser
  * @param $rp2ApiPwd
  * @return bool
  */
 public function auth($rp2InstanceUrl, $rp2ApiUser, $rp2ApiPwd)
 {
     $duration = microtime(1);
     log::debug('Setting RPC-URL', "bbRpc::setUrl({$rp2InstanceUrl})");
     bbRpc::setUrl($rp2InstanceUrl);
     $userId = bbRpc::auth($rp2ApiUser, $rp2ApiPwd);
     $duration = round(microtime(1) - $duration, 3);
     if (!$userId) {
         log::warning("Login failed from " . $_SERVER['REMOTE_ADDR'] . " within {$duration} sec.", "bbRpc::auth({$rp2ApiUser}, *****)", $_SERVER);
         $this->fetchRpcLog();
         return false;
     } else {
         // https://doku.premium-admin.eu/doku.php/api/methoden/bbrpc/setutf8native
         log::info("Login successful from " . $_SERVER['REMOTE_ADDR'] . " within {$duration} sec.", "bbRpc::auth({$rp2ApiUser}, *****)");
         $this->fetchRpcLog();
         log::debug('Set UTF-8', 'bbRpc::setUTF8Native(true)');
         bbRpc::setUTF8Native(true);
         $this->fetchRpcLog();
         return true;
     }
 }
Ejemplo n.º 3
0
/**
 * Let us use a autoloader for our classes.
 * (cause nobody likes require_once)
 *
 * @param $class
 * @return bool
 * @throws \Exception
 */
function classLoader($class)
{
    $path = explode('\\', $class);
    unset($path[0]);
    //Namespace 'rpf'
    $file = __DIR__ . '/class';
    foreach ($path as $name) {
        $file .= "/{$name}";
    }
    $file .= '.php';
    if (file_exists($file)) {
        require_once $file;
        $logFileName = str_replace(__DIR__, '', $file);
        log::debug("Include {$logFileName}", __FUNCTION__ . "('{$class}')");
        return true;
    } else {
        log::error("Couldn't  load class from '{$file}'", __FUNCTION__ . "({$class})");
        echo "<pre>";
        throw new \Exception("File {$file} not found");
        return false;
    }
}
Ejemplo n.º 4
0
 /**
  * DEPRECATED - Don't use any more
  * @return order
  */
 public function getOrder()
 {
     log::debug("Usage of deprecated object 'order'", __METHOD__);
     return $this->getModule(order::class);
 }
Ejemplo n.º 5
0
 /**
  * @todo fix me, seems like I'm broken
  */
 protected function fetchRpcLog()
 {
     // I realy don't like the way of fetching RPC-Error-Messages...
     //$hLoglvl = array("error"=>0, "warn"=>1, "notice"=>2, "ok"=>3, "debug"=>4);
     global $_BBRPC_Msgs;
     if (is_array($_BBRPC_Msgs)) {
         foreach ($_BBRPC_Msgs as $key => &$hMsg) {
             switch ($hMsg["typ"]) {
                 case 0:
                     module\log::error("RPC-Msg.: {$hMsg}", __METHOD__);
                     break;
                 case 1:
                     module\log::warning("RPC-Msg.: {$hMsg}", __METHOD__);
                     break;
                 case 2:
                     module\log::info("RPC-Msg.: {$hMsg}", __METHOD__);
                     break;
                 case 3:
                     module\log::debug("RPC-Msg.: OK! {$hMsg}", __METHOD__);
                     break;
                 case 4:
                     module\log::debug("RPC-Msg.: {$hMsg}", __METHOD__);
                     break;
             }
             unset($_BBRPC_Msgs[$key]);
         }
     }
 }
Ejemplo n.º 6
0
 public function showIndex()
 {
     log::debug('Displaying Index-Page', __METHOD__);
     echo file_get_contents(__DIR__ . '/index/index.tpl');
 }
Ejemplo n.º 7
0
 public function __destruct()
 {
     log::debug("Shutdown moduleManager\n\n\n    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n", __METHOD__);
 }