Beispiel #1
0
 public function handle($instance, $serverKey, $parameters, $httpRequestMethod)
 {
     // If the request comes from local, reload the configuration
     $this->reloadConfiguration($instance, $serverKey);
     $methodName = null;
     $method = null;
     $this->findMethod($parameters, $methodName, $method, $serverKey, $httpRequestMethod);
     if (strtolower($method->getHttp()) != strtolower($httpRequestMethod)) {
         throw new MashapeException(EXCEPTION_INVALID_HTTPMETHOD, EXCEPTION_INVALID_HTTPMETHOD_CODE);
     }
     unset($parameters[METHOD]);
     // Remove the method name from the params
     $token = isset($parameters[TOKEN]) ? $parameters[TOKEN] : null;
     unset($parameters[TOKEN]);
     // remove the token parameter
     $language = isset($parameters[LANGUAGE]) ? $parameters[LANGUAGE] : null;
     unset($parameters[LANGUAGE]);
     // remove the language parameter
     $version = isset($parameters[VERSION]) ? $parameters[VERSION] : null;
     unset($parameters[VERSION]);
     // remove the version parameter
     //Validate Request
     if (self::validateRequest($serverKey, $token, $methodName, $language, $version)) {
         return doCall($method, $parameters, $instance, $serverKey);
     } else {
         throw new MashapeException(EXCEPTION_AUTH_INVALID, EXCEPTION_AUTH_INVALID_CODE);
     }
 }
Beispiel #2
0
 public function method1()
 {
     $x = 1;
     echo "method1\n";
     if ($x) {
         doCall("hello");
         return hello();
     }
     return 0;
 }
Beispiel #3
0
 public function handle($instance, $serverKey, $parameters, $httpRequestMethod)
 {
     // If the request comes from local, reload the configuration
     $this->reloadConfiguration($instance, $serverKey);
     $methodName = null;
     $method = null;
     $this->findMethod($parameters, $methodName, $method, $serverKey, $httpRequestMethod);
     if (strtolower($method->getHttp()) != strtolower($httpRequestMethod)) {
         throw new MashapeException(EXCEPTION_INVALID_HTTPMETHOD, EXCEPTION_INVALID_HTTPMETHOD_CODE);
     }
     unset($parameters[METHOD]);
     // Remove the method name from the params
     return doCall($method, $parameters, $instance, $serverKey);
 }
Beispiel #4
0
<?php

if ($code == BAD) {
    $action = REWRITE;
} else {
    $action = KEEP;
}
for ($i = 0; $i < 10; $i++) {
    while ($j > 0) {
        $j++;
        doCall($i + $j);
        if ($k) {
            $k /= 10;
        }
    }
}
Beispiel #5
0
function updateAddons($addons)
{
    $installedHash = getInstalledHash();
    $currentGeneralSettings = Reg::get('settings');
    foreach ($addons as $key => $addon) {
        appUpdateMsg('Checking download for ' . $addon['slug'] . '...');
        $downloadCheckLink = getOption('serviceURL') . 'download.php?appInstallHash=' . APP_INSTALL_HASH . '&installedHash=' . $installedHash . '&appVersion=' . APP_VERSION . '&type=addon&downloadType=update&download=' . $addon['slug'] . '&downloadVersion=' . $addon['version'];
        if ($currentGeneralSettings['participateBeta'] == 1) {
            $downloadCheckLink .= '&participateBeta=1';
        }
        $temp = doCall($downloadCheckLink, '', $timeout = 30);
        list($result, , , $curlInfo) = $temp;
        //$result = base64_decode($result);
        //$result = @unserialize($result);
        $result = getServiceResponseToArray($result);
        $cURLErrors = new cURLErrors($curlInfo);
        if ($cURLErrors->isOk()) {
            if ($result['status'] == 'success') {
                $addons[$key]['downloadLink'] = $result['downloadLink'];
                //$downloadCheckLink.'&checked=true';
            } elseif ($result['status'] == 'error') {
                unset($addons[$addon['slug']]);
                appUpdateMsg('Error while downloading addon ' . $addon['slug'] . ': ' . $result['errorMsg']);
            }
        } else {
            unset($addons[$addon['slug']]);
            appUpdateMsg('Error while downloading addon ' . $addon['slug'] . ': Unable to communicate with server(' . $cURLErrors->getErrorMsg() . ').');
        }
    }
    downloadAndUnzipAddons($addons);
    foreach ($addons as $addon) {
        if ($addon['process']['unzipDone']) {
            //$addon['process']['updated'] = true;
            include APP_ROOT . '/addons/' . $addon['slug'] . '/addon.' . $addon['slug'] . '.php';
            $prevVer = DB::getField("?:addons", "updateCurrentVersion", "slug = '" . $addon['slug'] . "'");
            if (method_exists('addon' . ucfirst($addon['slug']), 'update')) {
                call_user_func(array('addon' . ucfirst($addon['slug']), 'update'));
            }
            $newAddonVersion = getAddonVersion($addon['slug']);
            $optionVer['action'] = 'updated';
            $optionVer['actionTime'] = time();
            $optionVer['prevVer'] = $prevVer;
            $optionVer['newVer'] = $newAddonVersion;
            $optionVer['slug'] = $addon['slug'];
            manipulateOption('versionLogs', $optionVer);
            DB::update("?:addons", array('updateCurrentVersion' => $newAddonVersion), "slug = '" . $addon['slug'] . "'");
            //updating in database that addon is updated
            //remove updateAvailable for this addon so that it will stop false update notification in next browser app load
            $updateAddonsAvailable = @unserialize(getOption('updateAddonsAvailable'));
            if (isset($updateAddonsAvailable[$addon['slug']]['updateAvailable']) && !empty($updateAddonsAvailable[$addon['slug']]['updateAvailable'])) {
                unset($updateAddonsAvailable[$addon['slug']]['updateAvailable']);
                updateOption('updateAddonsAvailable', serialize($updateAddonsAvailable));
            }
            appUpdateMsg('Addon ' . $addon['slug'] . ' successfully updated.');
        }
    }
    appUpdateMsg('<br>Please <a href="' . APP_URL . '" target="_top">click here</a> to reload the app.');
    updateOption('updateLastCheck', 0);
    //to trigger checkUpdate in next page load
    //$_SESSION['addonAlertCount'] = 0;
    //manageCookies::cookieSet('addonAlertCount',0,array('expire'=>0));
    updateOption('addonAlertCount', '0');
}
 function testError()
 {
     RESTConfigurationLoader::reloadConfiguration(SERVER_KEY, dirname(__FILE__) . "/test7.xml");
     $method = new RESTMethod();
     $method->setName("touchError");
     $method->setObject("ClassOne");
     $method->setArray(true);
     $this->assertEquals('[{"code":1,"message":"custom message"}]', doCall($method, null, new NewSampleAPI(), SERVER_KEY));
 }
Beispiel #7
0
 public static function IWPAuthUser($params)
 {
     $registerURL = IWP_SITE_URL . 'app-login/';
     $noCache = '?no-cache-iwp=' . md5(microtime(true) . uniqid('', true) . substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(20, 60)));
     $registerURL .= $noCache;
     $data = array('appInstallHash' => APP_INSTALL_HASH, 'installedHash' => getInstalledHash());
     $params['appDetails'] = base64_encode(serialize($data));
     list($rawResponseData, , , $curlInfo) = doCall($registerURL, $params, $timeout = 30, array('normalPost' => 1));
     $cURLErrors = new cURLErrors($curlInfo);
     if (!$cURLErrors->isOk() && $curlInfo['info']['http_code'] != 403) {
         $errorResponse = array();
         $errorResponse['netError'] = 1;
         $errorResponse['errorMsg'] = $cURLErrors->getErrorMsg();
         return $errorResponse;
     }
     return json_decode($rawResponseData);
 }