Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/cloudfil...
File: cloudfiles.php
[2500] Fix | Delete
/**
[2501] Fix | Delete
* Object's MD5 checksum
[2502] Fix | Delete
*
[2503] Fix | Delete
* Accessor method for reading Object's private ETag attribute.
[2504] Fix | Delete
*
[2505] Fix | Delete
* @return string MD5 checksum hexidecimal string
[2506] Fix | Delete
*/
[2507] Fix | Delete
function getETag()
[2508] Fix | Delete
{
[2509] Fix | Delete
return $this->etag;
[2510] Fix | Delete
}
[2511] Fix | Delete
[2512] Fix | Delete
/**
[2513] Fix | Delete
* Compute the MD5 checksum
[2514] Fix | Delete
*
[2515] Fix | Delete
* Calculate the MD5 checksum on either a PHP resource or data. The argument
[2516] Fix | Delete
* may either be a local filename, open resource for reading, or a string.
[2517] Fix | Delete
*
[2518] Fix | Delete
* <b>WARNING:</b> if you are uploading a big file over a stream
[2519] Fix | Delete
* it could get very slow to compute the md5 you probably want to
[2520] Fix | Delete
* set the $verify parameter to False in the write() method and
[2521] Fix | Delete
* compute yourself the md5 before if you have it.
[2522] Fix | Delete
*
[2523] Fix | Delete
* @param filename|obj|string $data filename, open resource, or string
[2524] Fix | Delete
* @return string MD5 checksum hexidecimal string
[2525] Fix | Delete
*/
[2526] Fix | Delete
function compute_md5sum(&$data)
[2527] Fix | Delete
{
[2528] Fix | Delete
[2529] Fix | Delete
if (function_exists("hash_init") && is_resource($data)) {
[2530] Fix | Delete
$ctx = hash_init('md5');
[2531] Fix | Delete
$fpos = ftell($data);
[2532] Fix | Delete
while (!feof($data)) {
[2533] Fix | Delete
$buffer = fgets($data, 65536);
[2534] Fix | Delete
hash_update($ctx, $buffer);
[2535] Fix | Delete
}
[2536] Fix | Delete
$md5 = hash_final($ctx, false);
[2537] Fix | Delete
fseek($data, $fpos);
[2538] Fix | Delete
} elseif ((string)is_file($data)) {
[2539] Fix | Delete
$md5 = md5_file($data);
[2540] Fix | Delete
} else {
[2541] Fix | Delete
$md5 = md5($data);
[2542] Fix | Delete
}
[2543] Fix | Delete
return $md5;
[2544] Fix | Delete
}
[2545] Fix | Delete
[2546] Fix | Delete
/**
[2547] Fix | Delete
* PRIVATE: fetch information about the remote Object if it exists
[2548] Fix | Delete
*/
[2549] Fix | Delete
private function _initialize()
[2550] Fix | Delete
{
[2551] Fix | Delete
list($status, $reason, $etag, $last_modified, $content_type,
[2552] Fix | Delete
$content_length, $metadata, $manifest, $headers) =
[2553] Fix | Delete
$this->container->cfs_http->head_object($this);
[2554] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[2555] Fix | Delete
# return $this->_initialize();
[2556] Fix | Delete
#}
[2557] Fix | Delete
if ($status == 404) {
[2558] Fix | Delete
return False;
[2559] Fix | Delete
}
[2560] Fix | Delete
if ($status < 200 || $status > 299) {
[2561] Fix | Delete
throw new InvalidResponseException("Invalid response (".$status."): "
[2562] Fix | Delete
. $this->container->cfs_http->get_error());
[2563] Fix | Delete
}
[2564] Fix | Delete
$this->etag = $etag;
[2565] Fix | Delete
$this->last_modified = $last_modified;
[2566] Fix | Delete
$this->content_type = $content_type;
[2567] Fix | Delete
$this->content_length = $content_length;
[2568] Fix | Delete
$this->metadata = $metadata;
[2569] Fix | Delete
$this->headers = $headers;
[2570] Fix | Delete
$this->manifest = $manifest;
[2571] Fix | Delete
return True;
[2572] Fix | Delete
}
[2573] Fix | Delete
/**
[2574] Fix | Delete
* Generate a Temp Url for a object
[2575] Fix | Delete
* Example:
[2576] Fix | Delete
* <code>
[2577] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[2578] Fix | Delete
* $conn = new CF_Connection($auth);
[2579] Fix | Delete
* $container = $conn->get_container("foo");
[2580] Fix | Delete
* $obj = $container->get_object("foo");
[2581] Fix | Delete
* $tempurl = $obj->get_temp_url("shared_secret", "expire_time_in_seconds", "{HTTP_METHOD}"); (note: replace {HTTP_METHOD} with the request method: GET, POST, PUT, DELETE, etc.
[2582] Fix | Delete
* </code>
[2583] Fix | Delete
* @returns The temp url
[2584] Fix | Delete
*/
[2585] Fix | Delete
public function get_temp_url($key, $expires, $method)
[2586] Fix | Delete
{
[2587] Fix | Delete
[2588] Fix | Delete
$expires += time();
[2589] Fix | Delete
$url = $this->container->cfs_http->getStorageUrl() . '/' . $this->container->name . '/' . $this->name;
[2590] Fix | Delete
return $url . '?temp_url_sig=' . hash_hmac('sha1', strtoupper($method) .
[2591] Fix | Delete
"\n" . $expires . "\n" . parse_url($url, PHP_URL_PATH), $key) .
[2592] Fix | Delete
'&temp_url_expires=' . $expires;
[2593] Fix | Delete
}
[2594] Fix | Delete
/**
[2595] Fix | Delete
* Generate hidden input for form post.
[2596] Fix | Delete
* @returns array Returns an associative array with form post input.
[2597] Fix | Delete
*/
[2598] Fix | Delete
public function get_form_post_input($key, $expires, $redirect, $max_file_size=5368709120, $max_file_count=1)
[2599] Fix | Delete
{
[2600] Fix | Delete
[2601] Fix | Delete
$expires += time();
[2602] Fix | Delete
$url = $this->container->cfs_http->getStorageUrl() . '/' . $this->container->name . '/' . $this->name;
[2603] Fix | Delete
$form_post = array('action' => $url, 'redirect' => $redirect, 'max_file_size' => $max_file_size, 'expires' => $expires, 'file' => $this->name);
[2604] Fix | Delete
$form_post['signature'] = hash_hmac('sha1', parse_url($url, PHP_URL_PATH) . "\n" . $redirect . "\n" . $max_file_size . "\n" . $max_file_count . "\n" . $expires, $key );
[2605] Fix | Delete
return $form_post;
[2606] Fix | Delete
}
[2607] Fix | Delete
#private function _re_auth()
[2608] Fix | Delete
#{
[2609] Fix | Delete
# $new_auth = new CF_Authentication(
[2610] Fix | Delete
# $this->cfs_auth->username,
[2611] Fix | Delete
# $this->cfs_auth->api_key,
[2612] Fix | Delete
# $this->cfs_auth->auth_host,
[2613] Fix | Delete
# $this->cfs_auth->account);
[2614] Fix | Delete
# $new_auth->authenticate();
[2615] Fix | Delete
# $this->container->cfs_auth = $new_auth;
[2616] Fix | Delete
# $this->container->cfs_http->setCFAuth($this->cfs_auth);
[2617] Fix | Delete
# return True;
[2618] Fix | Delete
#}
[2619] Fix | Delete
}
[2620] Fix | Delete
[2621] Fix | Delete
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
[2622] Fix | Delete
[2623] Fix | Delete
/*
[2624] Fix | Delete
* Local variables:
[2625] Fix | Delete
* tab-width: 4
[2626] Fix | Delete
* c-basic-offset: 4
[2627] Fix | Delete
* c-hanging-comment-ender-p: nil
[2628] Fix | Delete
* End:
[2629] Fix | Delete
*/
[2630] Fix | Delete
?>
[2631] Fix | Delete
[2632] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function