function establish(ConnectionConfiguration $connConfig)
 {
     $restConnection = new RestApiClient($this->buildEndpoint($connConfig), $connConfig->getSessionId());
     $restConnection->setCompressionEnabled(WorkbenchConfig::get()->value("enableGzip"));
     $restConnection->setUserAgent(getWorkbenchUserAgent());
     $restConnection->setExternalLogReference($_SESSION['restDebugLog']);
     //TODO: maybe replace w/ its own log?? //TODO: move into ctx
     $restConnection->setLoggingEnabled(WorkbenchConfig::get()->value("debug") == true);
     $restConnection->setProxySettings(getProxySettings());
     $restConnection->setIncludeSessionCookie(WorkbenchConfig::get()->value("includeSessionCookie"));
     return $restConnection;
 }
 public function __construct($sessionId, $clientId, $endpoint, $wsdlPath)
 {
     $_SERVER['HTTP_USER_AGENT'] = getWorkbenchUserAgent();
     $soapClientArray = array();
     if (WorkbenchConfig::get()->value("debug") == true) {
         $soapClientArray['trace'] = 1;
     }
     $soapClientArray['encoding'] = 'utf-8';
     $soapClientArray['exceptions'] = true;
     $soapClientArray['cache_wsdl'] = WSDL_CACHE_NONE;
     //set compression settings
     if (WorkbenchConfig::get()->value("enableGzip") && phpversion() > '5.1.2') {
         $soapClientArray['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 1;
     }
     //set proxy settings
     if (WorkbenchConfig::get()->value("proxyEnabled") == true) {
         $proxySettings = array();
         $proxySettings['proxy_host'] = WorkbenchConfig::get()->value("proxyHost");
         $proxySettings['proxy_port'] = (int) WorkbenchConfig::get()->value("proxyPort");
         // Use an integer, not a string
         $proxySettings['proxy_login'] = WorkbenchConfig::get()->value("proxyUsername");
         $proxySettings['proxy_password'] = WorkbenchConfig::get()->value("proxyPassword");
         $soapClientArray = array_merge($soapClientArray, $proxySettings);
     }
     $this->sforce = new SoapClient($wsdlPath, $soapClientArray);
     // set session cookie, if enabled
     if (WorkbenchConfig::get()->value("includeSessionCookie")) {
         $this->sforce->__setCookie("sid", $sessionId);
     }
     //start to set headers
     $headerArray = array();
     //set session header
     $sessionVar = array('sessionId' => new SoapVar($sessionId, XSD_STRING));
     $headerBody = new SoapVar($sessionVar, SOAP_ENC_OBJECT);
     $headerArray[] = new SoapHeader($this->getNamespace(), 'SessionHeader', $headerBody, false);
     //set call options header
     if ($clientId != null) {
         $clientBody = array('client' => new SoapVar(WorkbenchConfig::get()->value("callOptions_client"), XSD_STRING));
         $callOptionsHeader = new SoapHeader($this->getNamespace(), 'CallOptions', $clientBody, false);
         $headerArray[] = $callOptionsHeader;
     }
     //set allowFieldTruncationHeader header
     if (WorkbenchConfig::get()->value("allowFieldTruncationHeader_allowFieldTruncation")) {
         $allowFieldTruncationBody = array('allowFieldTruncation' => new SoapVar(WorkbenchConfig::get()->value("allowFieldTruncationHeader_allowFieldTruncation"), XSD_BOOLEAN));
         $allowFieldTruncationHeader = new SoapHeader($this->getNamespace(), 'AllowFieldTruncationHeader', $allowFieldTruncationBody, false);
         $headerArray[] = $allowFieldTruncationHeader;
     }
     $this->sforce->__setSoapHeaders($headerArray);
     $this->sforce->__setLocation($endpoint);
     return $this->sforce;
 }
예제 #3
0
if (WorkbenchConfig::get()->isConfigured("displayLiveMaintenanceMessage")) {
    print "<div style='background-color: orange; width: 100%; padding: 2px; font-size: 8pt; font-weight: bold;'>" . "Workbench is currently undergoing maintenance. The service may be intermittently unavailable during this time.</div><br/>";
}
//check for latest version
function strip_seps($haystack)
{
    foreach (array(' ', '_', '-') as $n) {
        $haystack = str_replace($n, "", $haystack);
    }
    return $haystack;
}
if (WorkbenchConfig::get()->value("checkForLatestVersion") && extension_loaded('curl') && (isset($_GET['autoLogin']) || 'login.php' == basename($_SERVER['PHP_SELF']))) {
    try {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/ryanbrainard/forceworkbench/tags');
        curl_setopt($ch, CURLOPT_USERAGENT, getWorkbenchUserAgent());
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $tagsResponse = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        if ($tagsResponse === false || $info['http_code'] != 200) {
            throw new Exception("Could not access GitHub tags");
        }
        $tags = json_decode($tagsResponse);
        $betaTagNames = array();
        $gaTagNames = array();
        foreach ($tags as $tag) {
            if (preg_match('/^[0-9]+.[0-9]+/', $tag->name) === 0) {
                continue;
            } else {
예제 #4
0
 }
 // don't even try to deal with complex types
 if (isset($configValue['dataType']) && $configValue['dataType'] == "complex") {
     continue;
 }
 //clear config cookies if restoreDefaults selected or the config is not overrideable
 if (isset($_POST['restoreDefaults']) || !isset($configValue['overrideable']) || !$configValue['overrideable']) {
     // ...and is actually in the user's cookies
     if (isset($_COOKIE[$configKey])) {
         setcookie($configKey, NULL, time() - 3600);
     }
     continue;
 }
 // should only get down here if we're actually setting configs
 //special case for default clientId so that it doesnt persist after upgrading if not customized
 if ($configKey == 'callOptions_client' && $_POST[$configKey] == getWorkbenchUserAgent()) {
     setcookie($configKey, NULL, time() - 3600);
     continue;
 }
 if ($configValue['dataType'] == "boolean" && !($configValue['default'] == true && isset($_POST[$configKey]) || $configValue['default'] == false && !isset($_POST[$configKey]))) {
     //for overriden booleans
     setcookie($configKey, isset($_POST[$configKey]) ? 1 : 0, time() + 60 * 60 * 24 * 365 * 10);
 } else {
     if (isset($_POST[$configKey]) && $configValue['default'] != $_POST[$configKey]) {
         //for non-null strings and numbers
         setcookie($configKey, $_POST[$configKey], time() + 60 * 60 * 24 * 365 * 10);
     } else {
         //for null or non-overriding strings and numbers (remove cookie)
         setcookie($configKey, NULL, time() - 3600);
     }
 }
 function __construct()
 {
     // initialize in case load issues
     $config = array();
     //load default config values
     require 'defaults.php';
     // load file-based config overrides
     if (is_file('config/overrides.php')) {
         /** @noinspection PhpIncludeInspection */
         require 'config/overrides.php';
     }
     // load legecy file-based config-overrides
     if (is_file('configOverrides.php')) {
         /** @noinspection PhpIncludeInspection */
         require 'configOverrides.php';
     }
     // unset from global namespace
     $this->config = $config;
     unset($config);
     // load environment variable based overrides
     $configNamespace = "forceworkbench";
     $configDelim = "__";
     foreach ($_ENV as $envKey => $envValue) {
         if (strpos($envKey, $configNamespace) !== 0) {
             continue;
         }
         $envKey = str_replace("___DOT___", ".", $envKey);
         $envKeyParts = explode($configDelim, $envKey);
         foreach ($envKeyParts as $keyPart) {
             if ($keyPart === $configNamespace) {
                 $point =& $this->config;
                 continue;
             }
             if (!isset($point[$keyPart])) {
                 $point[$keyPart] = "";
             }
             $point =& $point[$keyPart];
         }
         if (!isset($point) || is_array($point)) {
             workbenchLog(LOG_ERR, "Invalid location for {$envKey}");
             continue;
         }
         $point = $envValue === "false" ? false : $envValue;
     }
     foreach ($this->config as $configKey => $configValue) {
         // skip headers
         if (isset($configValue['isHeader'])) {
             continue;
         } else {
             if (isset($_COOKIE[$configKey])) {
                 // override the session value with that of the cookie
                 if ($configValue['overrideable']) {
                     $this->config[$configKey]['value'] = $_COOKIE[$configKey];
                 } else {
                     setcookie($configKey, NULL, time() - 3600);
                     $this->config[$configKey]['value'] = $configValue['default'];
                 }
             } else {
                 $this->config[$configKey]['value'] = $configValue['default'];
             }
         }
     }
     if ($this->config['callOptions_client']['default'] == 'WORKBENCH_DEFAULT' && !isset($_COOKIE['callOptions_client'])) {
         $this->config['callOptions_client']['value'] = getWorkbenchUserAgent();
     }
 }