Esempio n. 1
0
 /**
  * @param string $method
  */
 private function _apiServerCall($model, $method, $arguments = array(), $admin = false)
 {
     $account_username = $model->username;
     $account_password = $this->di['crypt']->decrypt($model->pass, $this->_salt);
     $server = $this->getServer($model->server_id);
     $centovacast_url = $server['url'];
     if ($admin) {
         $account_password = '******' . $server['secret'];
     }
     require_once dirname(__FILE__) . '/ccapiclient/ccapiclient.php';
     $server = new CCServerAPIClient($centovacast_url);
     $server->cc_initialize($centovacast_url);
     $server->call($method, $account_username, $account_password, $arguments);
     if (!$server->success) {
         throw new \Exception($server->error);
     }
     return $server->bb_data;
 }
Esempio n. 2
0
/**
 * Changes the state of a Cast streaming server account.
 *
 * @internal
 *
 * @param array   $params   The $params array passed by WHMCS
 * @param string  $newstate One of:
 *       "start" - start the stream
 *       "stop" - stop the stream
 *       "restart" - restart the stream
 *
 * @return string The literal string "success" on success, or an error message on failure.
 */
function centovacast_SetState($params, $newstate)
{
    if (!in_array($newstate, array("start", "stop", "restart"))) {
        return "Invalid state";
    }
    list($serverusername, $serverpassword) = centovacast_GetServerCredentials($params, true);
    $username = $params['username'];
    if (false === ($ccurl = centovacast_GetCCURL($params, &$urlerror))) {
        return $urlerror;
    }
    $server = new CCServerAPIClient($ccurl);
    $arguments = array();
    $server->call($newstate, $username, $serverpassword, $arguments);
    logModuleCall("centovacast", "setstate", $server->raw_request, $server->raw_response, NULL, NULL);
    return $server->success ? "success" : $server->error;
}