コード例 #1
0
 function __construct($cache = true)
 {
     parent::__construct("bigtree-internal-salesforce-api", "Salesforce API", "org.bigtreecms.api.salesforce", $cache);
     // Set OAuth Return URL
     $this->ReturnURL = ADMIN_ROOT . "developer/services/salesforce/return/";
     // Change things if we're in the test environment.
     if ($this->Settings["test_environment"]) {
         $this->AuthorizeURL = str_ireplace("login.", "test.", $this->AuthorizeURL);
         $this->TokenURL = str_replace("login.", "test.", $this->TokenURL);
     }
     // Get a new access token for this session.
     $this->Connected = false;
     if ($this->Settings["refresh_token"]) {
         $response = json_decode(BigTree::cURL($this->TokenURL, array("grant_type" => "refresh_token", "client_id" => $this->Settings["key"], "client_secret" => $this->Settings["secret"], "refresh_token" => $this->Settings["refresh_token"])), true);
         if ($response["access_token"]) {
             $this->InstanceURL = $response["instance_url"];
             $this->EndpointURL = $this->InstanceURL . "/services/data/v28.0/";
             $this->Settings["token"] = $response["access_token"];
             $this->Connected = true;
         }
     }
 }
コード例 #2
0
ファイル: flickr.php プロジェクト: kurt-planet/BigTree-CMS
 function oAuthRefreshToken()
 {
     $r = json_decode(BigTree::cURL($this->TokenURL, array("client_id" => $this->Settings["key"], "client_secret" => $this->Settings["secret"], "refresh_token" => $this->Settings["refresh_token"], "grant_type" => "refresh_token")));
     if ($r->access_token) {
         $this->Settings["token"] = $r->access_token;
         $this->Settings["expires"] = strtotime("+" . $r->expires_in . " seconds");
     }
 }
コード例 #3
0
ファイル: default.php プロジェクト: kurt-planet/BigTree-CMS
<?php

// Check whether our database is running the latest revision of BigTree or not.
$current_revision = $cms->getSetting("bigtree-internal-revision");
if ($current_revision < BIGTREE_REVISION && $admin->Level > 1) {
    BigTree::redirect(DEVELOPER_ROOT . "upgrade/database/");
}
// Check for newer versions of BigTree
$ignored_all = true;
if (!$_COOKIE["bigtree_admin"]["deferred_update"]) {
    $updates = array_filter((array) @json_decode(BigTree::cURL("http://www.bigtreecms.org/ajax/version-check/?current_version=" . BIGTREE_VERSION, false, array(CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 5)), true));
    // See if we've ignored these updates
    $ignorable = array();
    foreach ($updates as $update) {
        if (!$_COOKIE["bigtree_admin"]["ignored_update"][$update["version"]]) {
            $ignored_all = false;
        }
        $ignorable[] = $update["version"];
    }
}
// If we're ignoring updates through config, still ignore them
if (!empty($bigtree["config"]["ignore_admin_updates"])) {
    $ignored_all = true;
}
// Updates are available and we didn't ignore them
if (!$ignored_all && count($updates)) {
    ?>
<div class="container">
	<summary><h2>Update Available</h2></summary>
	<section>
		<p>You are currently running BigTree <?php 
コード例 #4
0
<?php

$storage = new BigTreeStorage();
$storage->Settings->Service = $_POST["service"];
$cloud = new BigTreeCloudStorage($_POST["service"]);
if ($_POST["container"]) {
    $storage->Settings->Container = $_POST["container"];
    // If we're using Rackspace, we need to explicitly CDN enable this container.
    if ($_POST["service"] == "rackspace") {
        BigTree::cURL($cloud->RackspaceCDNEndpoint . "/" . $_POST["container"], "", array(CURLOPT_PUT => true, CURLOPT_HTTPHEADER => array("X-Auth-Token: " . $cloud->Settings["rackspace"]["token"], "X-Cdn-Enabled: true")));
    }
} else {
    // We're only going to try to get a unique bucket 10 times to prevent an infinite loop
    $x = 0;
    $success = false;
    while (!$success && $x < 10) {
        $container = $cms->urlify(uniqid("bigtree-container-", true));
        $success = $cloud->createContainer($container, true);
        $x++;
    }
    if ($success) {
        $storage->Settings->Container = $container;
    } else {
        $admin->growl("Developer", "Failed to create container.", "error");
        BigTree::redirect(DEVELOPER_ROOT . "cloud-storage/");
    }
}
$container = $cloud->getContainer($storage->Settings->Container);
if ($container === false) {
    $admin->growl("Developer", "Failed to read container.", "error");
    BigTree::redirect(DEVELOPER_ROOT . "cloud-storage/");
コード例 #5
0
 protected function sendPayflow($params)
 {
     $count = 0;
     $this->Unresponsive = false;
     // We build a random hash to submit as the transaction ID so that Payflow knows we're trying a repeat transaction, and spoof Mozilla.
     $extras = array(CURLOPT_HTTPHEADER => array("X-VPS-Request-ID: " . uniqid("", true)), CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
     // Get the default parameters
     $params = array_merge($this->DefaultParameters, $params);
     // Authorize wants a GET instead of a POST, so we have to convert it away from an array.
     $fields = array();
     foreach ($params as $key => $val) {
         $fields[] = $key . "=" . str_replace("&", "%26", $val);
     }
     // Send it off to the server, try 3 times.
     while ($count < 3) {
         $response = BigTree::cURL($this->PostURL, implode("&", $fields), $extras);
         if ($response) {
             $response = strstr($response, 'RESULT');
             $response_array = array();
             $response_parts = explode("&", $response);
             foreach ($response_parts as $part) {
                 list($key, $val) = explode("=", $part);
                 $response_array[$key] = $val;
             }
             return $response_array;
         }
         $count++;
     }
     $this->Unresponsive = true;
     return false;
 }
コード例 #6
0
ファイル: init.php プロジェクト: matthisamoto/Graphfan
<?php

$updates = @json_decode(BigTree::cURL("http://www.bigtreecms.org/ajax/version-check/?current_version=" . BIGTREE_VERSION), true);
$update = $updates[$_GET["type"]];
if (!$update) {
    $admin->growl("Developer", "Couldn't Get Download Information", "error");
    BigTree::redirect(DEVELOPER_ROOT);
}
?>
<div class="container">
	<summary><h2>Upgrade BigTree</h2></summary>
	<section>
		<p>Please wait while we download the update...</p>
	</section>
</div>
<script>
	$.ajax("<?php 
echo ADMIN_ROOT;
?>
ajax/developer/upgrade/download/", { type: "POST", data: { file: "<?php 
echo $update["file"];
?>
" }, complete: function() {
		window.location.href = "<?php 
echo DEVELOPER_ROOT;
?>
upgrade/check-file/?type=<?php 
echo htmlspecialchars($_GET["type"]);
?>
";
	} });
コード例 #7
0
ファイル: _oauth.base.php プロジェクト: matthisamoto/Graphfan
 function oAuthSetToken($code)
 {
     $response = json_decode(BigTree::cURL($this->TokenURL, array("code" => $code, "client_id" => $this->Settings["key"], "client_secret" => $this->Settings["secret"], "redirect_uri" => $this->ReturnURL, "grant_type" => "authorization_code")));
     if ($response->error) {
         $this->OAuthError = $response->error;
         return false;
     }
     // Update Token information and save it back.
     $this->Settings["token"] = $response->access_token;
     $this->Settings["refresh_token"] = $response->refresh_token;
     $this->Settings["expires"] = $response->expires_in ? strtotime("+" . $response->expires_in . " seconds") : false;
     $this->Connected = true;
     return $response;
 }
コード例 #8
0
<?php

$response = json_decode(BigTree::cURL("https://www.google.com/recaptcha/api/siteverify?secret=" . $settings["recaptcha"]["secret_key"] . "&response=" . urlencode($_POST["g-recaptcha-response"]) . "&remoteip=" . $_SERVER["REMOTE_ADDR"]));
if (!$response->success) {
    $errors[] = $field_name;
}
コード例 #9
0
         $source_image = $source_image ? $source_image : $json[0]["thumbnail_small"];
         $field["output"] = array("service" => "vimeo", "id" => $video_id, "height" => $json[0]["height"], "width" => $json[0]["width"], "duration" => $json[0]["duration"], "embed" => '<iframe src="https://player.vimeo.com/video/' . $video_id . '?byline=0&portrait=0" width="' . $width . '" height="' . $height . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
         // No video :(
     } else {
         $bigtree["errors"][] = array("field" => $field["title"], "error" => "The Vimeo URL provided is invalid.");
         $field["ignore"] = true;
     }
     // Invalid URL
 } else {
     $bigtree["errors"][] = array("field" => $field["title"], "error" => "The URL you entered is not a valid YouTube or Vimeo URL.");
     $field["ignore"] = true;
 }
 // If we haven't failed, we're going to grab our image and set it up for crops and such
 if (!$field["ignore"]) {
     $local_image_copy = SITE_ROOT . "files/" . uniqid("temp-") . ".jpg";
     BigTree::cURL($source_image, false, array(), false, $local_image_copy);
     list($width, $height) = getimagesize($local_image_copy);
     // If this is a YouTube video we don't have video dimensions so we're going to guess them from the image size
     if ($field["output"]["service"] == "youtube") {
         $field["output"]["height"] = $height;
         $field["output"]["width"] = $width;
         $field["output"]["embed"] = '<iframe width="' . $width . '" height="' . $height . '" src="https://www.youtube.com/embed/' . $video_id . '" frameborder="0" allowfullscreen></iframe>';
     }
     // Normally we'd fail, but it's not like you can create a higher resolution video clip here.
     if ($width < $min_width || $height < $min_height) {
         BigTree::createUpscaledImage($local_image_copy, $local_image_copy, $min_width, $min_height);
     }
     // Pretend to be a normal image field and process it
     $field_copy = $field;
     $field_copy["file_input"] = array("name" => $field["output"]["service"] . "-video-" . $video_id . ".jpg", "tmp_name" => $local_image_copy, "error" => false);
     $field["output"]["image"] = BigTreeAdmin::processImageUpload($field_copy);
コード例 #10
0
 function callRackspace($endpoint = "", $data = false, $curl_options = array())
 {
     $curl_options = $curl_options + array(CURLOPT_HTTPHEADER => array("Accept: application/json", "X-Auth-Token: " . $this->Settings["rackspace"]["token"]));
     return json_decode(BigTree::cURL($this->RackspaceAPIEndpoint . ($endpoint ? "/{$endpoint}" : ""), $data, $curl_options));
 }
コード例 #11
0
ファイル: default.php プロジェクト: kurt-planet/BigTree-CMS
<?php

// If we can't do a local, FTP, or SFTP update then we give instructions on how to manually update
if (!$updater->Method) {
    BigTree::redirect($page_link . "failed/?id=" . $_GET["id"]);
}
// We're going to store the download URL in a cache to prevent the download script from abuse
$info = array_filter((array) @json_decode(BigTree::cURL("http://www.bigtreecms.org/ajax/extensions/version/?extensions[]=" . $_GET["id"], false, array(CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 5)), true));
$extension_info = $info[$_GET["id"]];
if (!$extension_info) {
    $admin->growl("Extensions", "Failed to get download information");
    BigTree::redirect(DEVELOPER_ROOT . "extensions/");
}
$download_key = $cms->cacheUnique("org.bigtreecms.downloads", $extension_info["github_url"]);
?>
<div class="container">
	<summary><h2>Upgrade Extension</h2></summary>
	<section>
		<p>Please wait while we download the update...</p>
	</section>
</div>
<script>
	$.ajax("<?php 
echo ADMIN_ROOT;
?>
ajax/developer/upgrade/download/", { type: "POST", data: { key: "<?php 
echo htmlspecialchars($download_key);
?>
" }, complete: function() {
		window.location.href = "<?php 
echo $page_link;
コード例 #12
0
 protected function sendSendGrid($subject, $body, $to, $from_email, $from_name, $reply_to = false, $text = false)
 {
     $url = 'https://api.sendgrid.com/api/mail.send.json';
     $user = $this->Settings["sendgrid_api_user"];
     $pass = $this->Settings["sendgrid_api_key"];
     // Build POST data
     $data = array("api_user" => $this->Settings["sendgrid_api_user"], "api_key" => $this->Settings["sendgrid_api_key"], "to" => is_array($to) ? implode(",", $to) : $to, "subject" => $subject, "html" => $body, "text" => $text, "from" => $from_email, "fromname" => $from_name, "replyto" => $reply_to);
     $response = json_decode(BigTree::cURL($url, $data, array()), true);
     if ($response["message"] === "success") {
         return true;
     } else {
         $this->Error = $response["errors"];
         return false;
     }
 }
コード例 #13
0
ファイル: geocoding.php プロジェクト: kurt-planet/BigTree-CMS
 private function geocodeYahoo($address)
 {
     $response = BigTree::cURL("http://query.yahooapis.com/v1/public/yql?format=json&q=" . urlencode('SELECT * FROM geo.placefinder WHERE text="' . sqlescape($address) . '"'));
     try {
         if (is_string($response)) {
             $response = json_decode($response, true);
         }
         $lat = $response["query"]["results"]["Result"]["latitude"];
         $lon = $response["query"]["results"]["Result"]["longitude"];
         if ($lat && $lon) {
             return array("latitude" => $lat, "longitude" => $lon);
         } else {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
 }
コード例 #14
0
ファイル: default.php プロジェクト: kurt-planet/BigTree-CMS
<?php

$extensions = $admin->getExtensions();
// Get version info on our installed extensions
$query = array();
foreach ($extensions as $extension) {
    $query[] = "extensions[]=" . urlencode($extension["id"]);
}
$version_info = array_filter((array) @json_decode(BigTree::cURL("http://www.bigtreecms.org/ajax/extensions/version/?" . implode("&", $query), false, array(CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 5)), true));
?>
<div class="table">
	<summary><h2>Extensions</h2></summary>
	<header>
		<span class="developer_templates_name">Extension Name</span>
		<span style="width: 80px;">Actions</span>
	</header>
	<ul>
		<?php 
foreach ($extensions as $extension) {
    $new = false;
    if (!isset($_COOKIE["bigtree_admin"]["ignored_extension_updates"][$extension["id"]])) {
        // Read manifest, see if a new version is available
        $manifest = json_decode(file_get_contents(SERVER_ROOT . "extensions/" . $extension["id"] . "/manifest.json"), true);
        if (intval($manifest["revision"]) < intval($version_info[$extension["id"]]["revision"])) {
            $new = true;
            $info = $version_info[$extension["id"]];
        }
    }
    ?>
		<li>
			<section class="developer_extensions_name">
コード例 #15
0
ファイル: cron.php プロジェクト: kalle0045/BigTree-CMS
<?php

$server_root = str_replace("core/cron.php", "", strtr(__FILE__, "\\", "/"));
include $server_root . "custom/environment.php";
include $server_root . "custom/settings.php";
include $server_root . "core/bootstrap.php";
$admin = new BigTreeAdmin();
// Send out Daily Digests and Content Alerts
$admin->emailDailyDigest();
// Cache Google Analytics Information
$analytics = new BigTreeGoogleAnalyticsAPI();
if ($analytics->API && $analytics->Profile) {
    $analytics->cacheInformation();
}
// Let the CMS know we're running cron properly
if (!$admin->settingExists("bigtree-internal-cron-last-run")) {
    $admin->createSetting(array("id" => "bigtree-internal-cron-last-run", "system" => "on"));
}
// Tell the admin we've ran cron recently.
$admin->updateSettingValue("bigtree-internal-cron-last-run", time());
// Ping bigtreecms.org with current version stats
if (!$bigtree["config"]["disable_ping"]) {
    BigTree::cURL("https://www.bigtreecms.org/ajax/ping/?www_root=" . urlencode(WWW_ROOT) . "&version=" . urlencode(BIGTREE_VERSION));
}