Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions phpFlickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class phpFlickr {
* of your table.
*/
var $max_cache_rows = 1000;

var $proxy;
var $proxyServer;
var $proxyPort;
var $proxyUsername;
var $proxyPassword;

function phpFlickr ($api_key, $secret = NULL, $die_on_error = false) {
//The API Key must be set before any calls can be made. You can
Expand All @@ -69,6 +75,7 @@ function phpFlickr ($api_key, $secret = NULL, $die_on_error = false) {
//Find the PHP version and store it for future reference
$this->php_version = explode("-", phpversion());
$this->php_version = explode(".", $this->php_version[0]);
$this->proxy = false;
}

function enableCache ($type, $connection, $cache_expire = 600, $table = 'flickr_cache') {
Expand Down Expand Up @@ -222,6 +229,11 @@ function post ($data, $type = null) {
if ( function_exists('curl_init') ) {
// Has curl. Use it!
$curl = curl_init($this->rest_endpoint);
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxyServer);
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxyPort);
if ($this->proxyUsername!="") curl_setopt ($curl, CURLOPT_PROXYUSERPWD, $this->proxyUsername.':'.$this->proxyPassword);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down Expand Up @@ -345,9 +357,13 @@ function setToken ($token) {
$this->token = $token;
}

function setProxy ($server, $port) {
function setProxy ($server="localhost", $port="3128", $username="", $password="") {
// Sets the proxy for all phpFlickr calls.
$this->req->setProxy($server, $port);
$this->proxy=true;
$this->proxyServer=$server;
$this->proxyPort=$port;
$this->proxyUsername=$username;
$this->proxyPassword=$password;
}

function getErrorCode () {
Expand Down Expand Up @@ -431,6 +447,11 @@ function sync_upload ($photo, $title = null, $description = null, $tags = null,


$curl = curl_init($this->upload_endpoint);
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxyServer);
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxyPort);
if ($this->proxyUsername!="") curl_setopt ($curl, CURLOPT_PROXYUSERPWD, $this->proxyUsername.':'.$this->proxyPassword);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down Expand Up @@ -493,6 +514,11 @@ function async_upload ($photo, $title = null, $description = null, $tags = null,


$curl = curl_init($this->upload_endpoint);
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxyServer);
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxyPort);
if ($this->proxyUsername!="") curl_setopt ($curl, CURLOPT_PROXYUSERPWD, $this->proxyUsername.':'.$this->proxyPassword);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down Expand Up @@ -554,6 +580,11 @@ function replace ($photo, $photo_id, $async = null) {


$curl = curl_init($this->replace_endpoint);
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxyServer);
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxyPort);
if ($this->proxyUsername!="") curl_setopt ($curl, CURLOPT_PROXYUSERPWD, $this->proxyUsername.':'.$this->proxyPassword);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down