Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/cloudfil...
File: cloudfiles.php
/**
[1500] Fix | Delete
* Copy a remote storage Object to a target Container
[1501] Fix | Delete
*
[1502] Fix | Delete
* Given an Object instance or name and a target Container instance or name, copy copies the remote Object
[1503] Fix | Delete
* and all associated metadata.
[1504] Fix | Delete
*
[1505] Fix | Delete
* Example:
[1506] Fix | Delete
* <code>
[1507] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[1508] Fix | Delete
* #
[1509] Fix | Delete
* $conn = new CF_Connection($auth);
[1510] Fix | Delete
*
[1511] Fix | Delete
* $images = $conn->get_container("my photos");
[1512] Fix | Delete
*
[1513] Fix | Delete
* # Copy specific object
[1514] Fix | Delete
* #
[1515] Fix | Delete
* $images->copy_object_to("disco_dancing.jpg","container_target");
[1516] Fix | Delete
* </code>
[1517] Fix | Delete
*
[1518] Fix | Delete
* @param obj $obj name or instance of Object to copy
[1519] Fix | Delete
* @param obj $container_target name or instance of target Container
[1520] Fix | Delete
* @param string $dest_obj_name name of target object (optional - uses source name if omitted)
[1521] Fix | Delete
* @param array $metadata metadata array for new object (optional)
[1522] Fix | Delete
* @param array $headers header fields array for the new object (optional)
[1523] Fix | Delete
* @return boolean <kbd>true</kbd> if successfully copied
[1524] Fix | Delete
* @throws SyntaxException invalid Object/Container name
[1525] Fix | Delete
* @throws NoSuchObjectException remote Object does not exist
[1526] Fix | Delete
* @throws InvalidResponseException unexpected response
[1527] Fix | Delete
*/
[1528] Fix | Delete
function copy_object_to($obj,$container_target,$dest_obj_name=NULL,$metadata=NULL,$headers=NULL)
[1529] Fix | Delete
{
[1530] Fix | Delete
$obj_name = NULL;
[1531] Fix | Delete
if (is_object($obj)) {
[1532] Fix | Delete
if (get_class($obj) == "UpdraftPlus_CF_Object") {
[1533] Fix | Delete
$obj_name = $obj->name;
[1534] Fix | Delete
}
[1535] Fix | Delete
}
[1536] Fix | Delete
if (is_string($obj)) {
[1537] Fix | Delete
$obj_name = $obj;
[1538] Fix | Delete
}
[1539] Fix | Delete
if (!$obj_name) {
[1540] Fix | Delete
throw new SyntaxException("Object name not set.");
[1541] Fix | Delete
}
[1542] Fix | Delete
[1543] Fix | Delete
if ($dest_obj_name === NULL) {
[1544] Fix | Delete
$dest_obj_name = $obj_name;
[1545] Fix | Delete
}
[1546] Fix | Delete
[1547] Fix | Delete
$container_name_target = NULL;
[1548] Fix | Delete
if (is_object($container_target)) {
[1549] Fix | Delete
if (get_class($container_target) == "UpdraftPlus_CF_Container") {
[1550] Fix | Delete
$container_name_target = $container_target->name;
[1551] Fix | Delete
}
[1552] Fix | Delete
}
[1553] Fix | Delete
if (is_string($container_target)) {
[1554] Fix | Delete
$container_name_target = $container_target;
[1555] Fix | Delete
}
[1556] Fix | Delete
if (!$container_name_target) {
[1557] Fix | Delete
throw new SyntaxException("Container name target not set.");
[1558] Fix | Delete
}
[1559] Fix | Delete
[1560] Fix | Delete
$status = $this->cfs_http->copy_object($obj_name,$dest_obj_name,$this->name,$container_name_target,$metadata,$headers);
[1561] Fix | Delete
if ($status == 404) {
[1562] Fix | Delete
$m = "Specified object '".$this->name."/".$obj_name;
[1563] Fix | Delete
$m.= "' did not exist as source to copy from or '".$container_name_target."' did not exist as target to copy to.";
[1564] Fix | Delete
throw new NoSuchObjectException($m);
[1565] Fix | Delete
}
[1566] Fix | Delete
if ($status < 200 || $status > 299) {
[1567] Fix | Delete
throw new InvalidResponseException(
[1568] Fix | Delete
"Invalid response (".$status."): ".$this->cfs_http->get_error());
[1569] Fix | Delete
}
[1570] Fix | Delete
return true;
[1571] Fix | Delete
}
[1572] Fix | Delete
[1573] Fix | Delete
/**
[1574] Fix | Delete
* Copy a remote storage Object from a source Container
[1575] Fix | Delete
*
[1576] Fix | Delete
* Given an Object instance or name and a source Container instance or name, copy copies the remote Object
[1577] Fix | Delete
* and all associated metadata.
[1578] Fix | Delete
*
[1579] Fix | Delete
* Example:
[1580] Fix | Delete
* <code>
[1581] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[1582] Fix | Delete
* #
[1583] Fix | Delete
* $conn = new CF_Connection($auth);
[1584] Fix | Delete
*
[1585] Fix | Delete
* $images = $conn->get_container("my photos");
[1586] Fix | Delete
*
[1587] Fix | Delete
* # Copy specific object
[1588] Fix | Delete
* #
[1589] Fix | Delete
* $images->copy_object_from("disco_dancing.jpg","container_source");
[1590] Fix | Delete
* </code>
[1591] Fix | Delete
*
[1592] Fix | Delete
* @param obj $obj name or instance of Object to copy
[1593] Fix | Delete
* @param obj $container_source name or instance of source Container
[1594] Fix | Delete
* @param string $dest_obj_name name of target object (optional - uses source name if omitted)
[1595] Fix | Delete
* @param array $metadata metadata array for new object (optional)
[1596] Fix | Delete
* @param array $headers header fields array for the new object (optional)
[1597] Fix | Delete
* @return boolean <kbd>true</kbd> if successfully copied
[1598] Fix | Delete
* @throws SyntaxException invalid Object/Container name
[1599] Fix | Delete
* @throws NoSuchObjectException remote Object does not exist
[1600] Fix | Delete
* @throws InvalidResponseException unexpected response
[1601] Fix | Delete
*/
[1602] Fix | Delete
function copy_object_from($obj,$container_source,$dest_obj_name=NULL,$metadata=NULL,$headers=NULL)
[1603] Fix | Delete
{
[1604] Fix | Delete
$obj_name = NULL;
[1605] Fix | Delete
if (is_object($obj)) {
[1606] Fix | Delete
if (get_class($obj) == "UpdraftPlus_CF_Object") {
[1607] Fix | Delete
$obj_name = $obj->name;
[1608] Fix | Delete
}
[1609] Fix | Delete
}
[1610] Fix | Delete
if (is_string($obj)) {
[1611] Fix | Delete
$obj_name = $obj;
[1612] Fix | Delete
}
[1613] Fix | Delete
if (!$obj_name) {
[1614] Fix | Delete
throw new SyntaxException("Object name not set.");
[1615] Fix | Delete
}
[1616] Fix | Delete
[1617] Fix | Delete
if ($dest_obj_name === NULL) {
[1618] Fix | Delete
$dest_obj_name = $obj_name;
[1619] Fix | Delete
}
[1620] Fix | Delete
[1621] Fix | Delete
$container_name_source = NULL;
[1622] Fix | Delete
if (is_object($container_source)) {
[1623] Fix | Delete
if (get_class($container_source) == "UpdraftPlus_CF_Container") {
[1624] Fix | Delete
$container_name_source = $container_source->name;
[1625] Fix | Delete
}
[1626] Fix | Delete
}
[1627] Fix | Delete
if (is_string($container_source)) {
[1628] Fix | Delete
$container_name_source = $container_source;
[1629] Fix | Delete
}
[1630] Fix | Delete
if (!$container_name_source) {
[1631] Fix | Delete
throw new SyntaxException("Container name source not set.");
[1632] Fix | Delete
}
[1633] Fix | Delete
[1634] Fix | Delete
$status = $this->cfs_http->copy_object($obj_name,$dest_obj_name,$container_name_source,$this->name,$metadata,$headers);
[1635] Fix | Delete
if ($status == 404) {
[1636] Fix | Delete
$m = "Specified object '".$container_name_source."/".$obj_name;
[1637] Fix | Delete
$m.= "' did not exist as source to copy from or '".$this->name."/".$obj_name."' did not exist as target to copy to.";
[1638] Fix | Delete
throw new NoSuchObjectException($m);
[1639] Fix | Delete
}
[1640] Fix | Delete
if ($status < 200 || $status > 299) {
[1641] Fix | Delete
throw new InvalidResponseException(
[1642] Fix | Delete
"Invalid response (".$status."): ".$this->cfs_http->get_error());
[1643] Fix | Delete
}
[1644] Fix | Delete
[1645] Fix | Delete
return true;
[1646] Fix | Delete
}
[1647] Fix | Delete
[1648] Fix | Delete
/**
[1649] Fix | Delete
* Move a remote storage Object to a target Container
[1650] Fix | Delete
*
[1651] Fix | Delete
* Given an Object instance or name and a target Container instance or name, move copies the remote Object
[1652] Fix | Delete
* and all associated metadata and deletes the source Object afterwards
[1653] Fix | Delete
*
[1654] Fix | Delete
* Example:
[1655] Fix | Delete
* <code>
[1656] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[1657] Fix | Delete
* #
[1658] Fix | Delete
* $conn = new CF_Connection($auth);
[1659] Fix | Delete
*
[1660] Fix | Delete
* $images = $conn->get_container("my photos");
[1661] Fix | Delete
*
[1662] Fix | Delete
* # Move specific object
[1663] Fix | Delete
* #
[1664] Fix | Delete
* $images->move_object_to("disco_dancing.jpg","container_target");
[1665] Fix | Delete
* </code>
[1666] Fix | Delete
*
[1667] Fix | Delete
* @param obj $obj name or instance of Object to move
[1668] Fix | Delete
* @param obj $container_target name or instance of target Container
[1669] Fix | Delete
* @param string $dest_obj_name name of target object (optional - uses source name if omitted)
[1670] Fix | Delete
* @param array $metadata metadata array for new object (optional)
[1671] Fix | Delete
* @param array $headers header fields array for the new object (optional)
[1672] Fix | Delete
* @return boolean <kbd>true</kbd> if successfully moved
[1673] Fix | Delete
* @throws SyntaxException invalid Object/Container name
[1674] Fix | Delete
* @throws NoSuchObjectException remote Object does not exist
[1675] Fix | Delete
* @throws InvalidResponseException unexpected response
[1676] Fix | Delete
*/
[1677] Fix | Delete
function move_object_to($obj,$container_target,$dest_obj_name=NULL,$metadata=NULL,$headers=NULL)
[1678] Fix | Delete
{
[1679] Fix | Delete
$retVal = false;
[1680] Fix | Delete
[1681] Fix | Delete
if(self::copy_object_to($obj,$container_target,$dest_obj_name,$metadata,$headers)) {
[1682] Fix | Delete
$retVal = self::delete_object($obj,$this->name);
[1683] Fix | Delete
}
[1684] Fix | Delete
[1685] Fix | Delete
return $retVal;
[1686] Fix | Delete
}
[1687] Fix | Delete
[1688] Fix | Delete
/**
[1689] Fix | Delete
* Move a remote storage Object from a source Container
[1690] Fix | Delete
*
[1691] Fix | Delete
* Given an Object instance or name and a source Container instance or name, move copies the remote Object
[1692] Fix | Delete
* and all associated metadata and deletes the source Object afterwards
[1693] Fix | Delete
*
[1694] Fix | Delete
* Example:
[1695] Fix | Delete
* <code>
[1696] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[1697] Fix | Delete
* #
[1698] Fix | Delete
* $conn = new CF_Connection($auth);
[1699] Fix | Delete
*
[1700] Fix | Delete
* $images = $conn->get_container("my photos");
[1701] Fix | Delete
*
[1702] Fix | Delete
* # Move specific object
[1703] Fix | Delete
* #
[1704] Fix | Delete
* $images->move_object_from("disco_dancing.jpg","container_target");
[1705] Fix | Delete
* </code>
[1706] Fix | Delete
*
[1707] Fix | Delete
* @param obj $obj name or instance of Object to move
[1708] Fix | Delete
* @param obj $container_source name or instance of target Container
[1709] Fix | Delete
* @param string $dest_obj_name name of target object (optional - uses source name if omitted)
[1710] Fix | Delete
* @param array $metadata metadata array for new object (optional)
[1711] Fix | Delete
* @param array $headers header fields array for the new object (optional)
[1712] Fix | Delete
* @return boolean <kbd>true</kbd> if successfully moved
[1713] Fix | Delete
* @throws SyntaxException invalid Object/Container name
[1714] Fix | Delete
* @throws NoSuchObjectException remote Object does not exist
[1715] Fix | Delete
* @throws InvalidResponseException unexpected response
[1716] Fix | Delete
*/
[1717] Fix | Delete
function move_object_from($obj,$container_source,$dest_obj_name=NULL,$metadata=NULL,$headers=NULL)
[1718] Fix | Delete
{
[1719] Fix | Delete
$retVal = false;
[1720] Fix | Delete
[1721] Fix | Delete
if(self::copy_object_from($obj,$container_source,$dest_obj_name,$metadata,$headers)) {
[1722] Fix | Delete
$retVal = self::delete_object($obj,$container_source);
[1723] Fix | Delete
}
[1724] Fix | Delete
[1725] Fix | Delete
return $retVal;
[1726] Fix | Delete
}
[1727] Fix | Delete
[1728] Fix | Delete
/**
[1729] Fix | Delete
* Delete a remote storage Object
[1730] Fix | Delete
*
[1731] Fix | Delete
* Given an Object instance or name, permanently remove the remote Object
[1732] Fix | Delete
* and all associated metadata.
[1733] Fix | Delete
*
[1734] Fix | Delete
* Example:
[1735] Fix | Delete
* <code>
[1736] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[1737] Fix | Delete
* #
[1738] Fix | Delete
* $conn = new CF_Connection($auth);
[1739] Fix | Delete
*
[1740] Fix | Delete
* $images = $conn->get_container("my photos");
[1741] Fix | Delete
*
[1742] Fix | Delete
* # Delete specific object
[1743] Fix | Delete
* #
[1744] Fix | Delete
* $images->delete_object("disco_dancing.jpg");
[1745] Fix | Delete
* </code>
[1746] Fix | Delete
*
[1747] Fix | Delete
* @param obj $obj name or instance of Object to delete
[1748] Fix | Delete
* @param obj $container name or instance of Container in which the object resides (optional)
[1749] Fix | Delete
* @return boolean <kbd>True</kbd> if successfully removed
[1750] Fix | Delete
* @throws SyntaxException invalid Object name
[1751] Fix | Delete
* @throws NoSuchObjectException remote Object does not exist
[1752] Fix | Delete
* @throws InvalidResponseException unexpected response
[1753] Fix | Delete
*/
[1754] Fix | Delete
function delete_object($obj,$container=NULL)
[1755] Fix | Delete
{
[1756] Fix | Delete
$obj_name = NULL;
[1757] Fix | Delete
if (is_object($obj)) {
[1758] Fix | Delete
if (get_class($obj) == "UpdraftPlus_CF_Object") {
[1759] Fix | Delete
$obj_name = $obj->name;
[1760] Fix | Delete
}
[1761] Fix | Delete
}
[1762] Fix | Delete
if (is_string($obj)) {
[1763] Fix | Delete
$obj_name = $obj;
[1764] Fix | Delete
}
[1765] Fix | Delete
if (!$obj_name) {
[1766] Fix | Delete
throw new SyntaxException("Object name not set.");
[1767] Fix | Delete
}
[1768] Fix | Delete
[1769] Fix | Delete
$container_name = NULL;
[1770] Fix | Delete
[1771] Fix | Delete
if($container === NULL) {
[1772] Fix | Delete
$container_name = $this->name;
[1773] Fix | Delete
}
[1774] Fix | Delete
else {
[1775] Fix | Delete
if (is_object($container)) {
[1776] Fix | Delete
if (get_class($container) == "UpdraftPlus_CF_Container") {
[1777] Fix | Delete
$container_name = $container->name;
[1778] Fix | Delete
}
[1779] Fix | Delete
}
[1780] Fix | Delete
if (is_string($container)) {
[1781] Fix | Delete
$container_name = $container;
[1782] Fix | Delete
}
[1783] Fix | Delete
if (!$container_name) {
[1784] Fix | Delete
throw new SyntaxException("Container name source not set.");
[1785] Fix | Delete
}
[1786] Fix | Delete
}
[1787] Fix | Delete
[1788] Fix | Delete
$status = $this->cfs_http->delete_object($container_name, $obj_name);
[1789] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[1790] Fix | Delete
# return $this->delete_object($obj);
[1791] Fix | Delete
#}
[1792] Fix | Delete
if ($status == 404) {
[1793] Fix | Delete
$m = "Specified object '".$container_name."/".$obj_name;
[1794] Fix | Delete
$m.= "' did not exist to delete.";
[1795] Fix | Delete
throw new NoSuchObjectException($m);
[1796] Fix | Delete
}
[1797] Fix | Delete
if ($status != 204) {
[1798] Fix | Delete
throw new InvalidResponseException(
[1799] Fix | Delete
"Invalid response (".$status."): ".$this->cfs_http->get_error());
[1800] Fix | Delete
}
[1801] Fix | Delete
return True;
[1802] Fix | Delete
}
[1803] Fix | Delete
[1804] Fix | Delete
/**
[1805] Fix | Delete
* Helper function to create "path" elements for a given Object name
[1806] Fix | Delete
*
[1807] Fix | Delete
* Given an Object whos name contains '/' path separators, this function
[1808] Fix | Delete
* will create the "directory marker" Objects of one byte with the
[1809] Fix | Delete
* Content-Type of "application/directory".
[1810] Fix | Delete
*
[1811] Fix | Delete
* It assumes the last element of the full path is the "real" Object
[1812] Fix | Delete
* and does NOT create a remote storage Object for that last element.
[1813] Fix | Delete
*/
[1814] Fix | Delete
function create_paths($path_name)
[1815] Fix | Delete
{
[1816] Fix | Delete
if ($path_name[0] == '/') {
[1817] Fix | Delete
$path_name = mb_substr($path_name, 0, 1);
[1818] Fix | Delete
}
[1819] Fix | Delete
$elements = explode('/', $path_name, -1);
[1820] Fix | Delete
$build_path = "";
[1821] Fix | Delete
foreach ($elements as $idx => $val) {
[1822] Fix | Delete
if (!$build_path) {
[1823] Fix | Delete
$build_path = $val;
[1824] Fix | Delete
} else {
[1825] Fix | Delete
$build_path .= "/" . $val;
[1826] Fix | Delete
}
[1827] Fix | Delete
$obj = new UpdraftPlus_CF_Object($this, $build_path);
[1828] Fix | Delete
$obj->content_type = "application/directory";
[1829] Fix | Delete
$obj->write(".", 1);
[1830] Fix | Delete
}
[1831] Fix | Delete
}
[1832] Fix | Delete
[1833] Fix | Delete
/**
[1834] Fix | Delete
* Internal method to grab CDN/Container info if appropriate to do so
[1835] Fix | Delete
*
[1836] Fix | Delete
* @throws InvalidResponseException unexpected response
[1837] Fix | Delete
*/
[1838] Fix | Delete
private function _cdn_initialize()
[1839] Fix | Delete
{
[1840] Fix | Delete
list($status, $reason, $cdn_enabled, $cdn_ssl_uri, $cdn_streaming_uri, $cdn_uri, $cdn_ttl,
[1841] Fix | Delete
$cdn_log_retention, $cdn_acl_user_agent, $cdn_acl_referrer) =
[1842] Fix | Delete
$this->cfs_http->head_cdn_container($this->name);
[1843] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[1844] Fix | Delete
# return $this->_cdn_initialize();
[1845] Fix | Delete
#}
[1846] Fix | Delete
if (!in_array($status, array(204,404))) {
[1847] Fix | Delete
throw new InvalidResponseException(
[1848] Fix | Delete
"Invalid response (".$status."): ".$this->cfs_http->get_error());
[1849] Fix | Delete
}
[1850] Fix | Delete
$this->cdn_enabled = $cdn_enabled;
[1851] Fix | Delete
$this->cdn_streaming_uri = $cdn_streaming_uri;
[1852] Fix | Delete
$this->cdn_ssl_uri = $cdn_ssl_uri;
[1853] Fix | Delete
$this->cdn_uri = $cdn_uri;
[1854] Fix | Delete
$this->cdn_ttl = $cdn_ttl;
[1855] Fix | Delete
$this->cdn_log_retention = $cdn_log_retention;
[1856] Fix | Delete
$this->cdn_acl_user_agent = $cdn_acl_user_agent;
[1857] Fix | Delete
$this->cdn_acl_referrer = $cdn_acl_referrer;
[1858] Fix | Delete
}
[1859] Fix | Delete
[1860] Fix | Delete
#private function _re_auth()
[1861] Fix | Delete
#{
[1862] Fix | Delete
# $new_auth = new CF_Authentication(
[1863] Fix | Delete
# $this->cfs_auth->username,
[1864] Fix | Delete
# $this->cfs_auth->api_key,
[1865] Fix | Delete
# $this->cfs_auth->auth_host,
[1866] Fix | Delete
# $this->cfs_auth->account);
[1867] Fix | Delete
# $new_auth->authenticate();
[1868] Fix | Delete
# $this->cfs_auth = $new_auth;
[1869] Fix | Delete
# $this->cfs_http->setCFAuth($this->cfs_auth);
[1870] Fix | Delete
# return True;
[1871] Fix | Delete
#}
[1872] Fix | Delete
}
[1873] Fix | Delete
[1874] Fix | Delete
[1875] Fix | Delete
/**
[1876] Fix | Delete
* Object operations
[1877] Fix | Delete
*
[1878] Fix | Delete
* An Object is analogous to a file on a conventional filesystem. You can
[1879] Fix | Delete
* read data from, or write data to your Objects. You can also associate
[1880] Fix | Delete
* arbitrary metadata with them.
[1881] Fix | Delete
*
[1882] Fix | Delete
* @package php-cloudfiles
[1883] Fix | Delete
*/
[1884] Fix | Delete
class UpdraftPlus_CF_Object
[1885] Fix | Delete
{
[1886] Fix | Delete
public $container;
[1887] Fix | Delete
public $name;
[1888] Fix | Delete
public $last_modified;
[1889] Fix | Delete
public $content_type;
[1890] Fix | Delete
public $content_length;
[1891] Fix | Delete
public $metadata;
[1892] Fix | Delete
public $headers;
[1893] Fix | Delete
public $manifest;
[1894] Fix | Delete
private $etag;
[1895] Fix | Delete
[1896] Fix | Delete
/**
[1897] Fix | Delete
* Class constructor
[1898] Fix | Delete
*
[1899] Fix | Delete
* @param obj $container CF_Container instance
[1900] Fix | Delete
* @param string $name name of Object
[1901] Fix | Delete
* @param boolean $force_exists if set, throw an error if Object doesn't exist
[1902] Fix | Delete
*/
[1903] Fix | Delete
function __construct(&$container, $name, $force_exists=False, $dohead=True)
[1904] Fix | Delete
{
[1905] Fix | Delete
if ($name[0] == "/") {
[1906] Fix | Delete
$r = "Object name '".$name;
[1907] Fix | Delete
$r .= "' cannot contain begin with a '/' character.";
[1908] Fix | Delete
throw new SyntaxException($r);
[1909] Fix | Delete
}
[1910] Fix | Delete
if (strlen($name) > MAX_OBJECT_NAME_LEN) {
[1911] Fix | Delete
throw new SyntaxException("Object name exceeds "
[1912] Fix | Delete
. "maximum allowed length.");
[1913] Fix | Delete
}
[1914] Fix | Delete
$this->container = $container;
[1915] Fix | Delete
$this->name = $name;
[1916] Fix | Delete
$this->etag = NULL;
[1917] Fix | Delete
$this->_etag_override = False;
[1918] Fix | Delete
$this->last_modified = NULL;
[1919] Fix | Delete
$this->content_type = NULL;
[1920] Fix | Delete
$this->content_length = 0;
[1921] Fix | Delete
$this->metadata = array();
[1922] Fix | Delete
$this->headers = array();
[1923] Fix | Delete
$this->manifest = NULL;
[1924] Fix | Delete
if ($dohead) {
[1925] Fix | Delete
if (!$this->_initialize() && $force_exists) {
[1926] Fix | Delete
throw new NoSuchObjectException("No such object '".$name."'");
[1927] Fix | Delete
}
[1928] Fix | Delete
}
[1929] Fix | Delete
}
[1930] Fix | Delete
[1931] Fix | Delete
/**
[1932] Fix | Delete
* String representation of Object
[1933] Fix | Delete
*
[1934] Fix | Delete
* Pretty print the Object's location and name
[1935] Fix | Delete
*
[1936] Fix | Delete
* @return string Object information
[1937] Fix | Delete
*/
[1938] Fix | Delete
function __toString()
[1939] Fix | Delete
{
[1940] Fix | Delete
return $this->container->name . "/" . $this->name;
[1941] Fix | Delete
}
[1942] Fix | Delete
[1943] Fix | Delete
/**
[1944] Fix | Delete
* Internal check to get the proper mimetype.
[1945] Fix | Delete
*
[1946] Fix | Delete
* This function would go over the available PHP methods to get
[1947] Fix | Delete
* the MIME type.
[1948] Fix | Delete
*
[1949] Fix | Delete
* By default it will try to use the PHP fileinfo library which is
[1950] Fix | Delete
* available from PHP 5.3 or as an PECL extension
[1951] Fix | Delete
* (http://pecl.php.net/package/Fileinfo).
[1952] Fix | Delete
*
[1953] Fix | Delete
* It will get the magic file by default from the system wide file
[1954] Fix | Delete
* which is usually available in /usr/share/magic on Unix or try
[1955] Fix | Delete
* to use the file specified in the source directory of the API
[1956] Fix | Delete
* (share directory).
[1957] Fix | Delete
*
[1958] Fix | Delete
* if fileinfo is not available it will try to use the internal
[1959] Fix | Delete
* mime_content_type function.
[1960] Fix | Delete
*
[1961] Fix | Delete
* @param string $handle name of file or buffer to guess the type from
[1962] Fix | Delete
* @return boolean <kbd>True</kbd> if successful
[1963] Fix | Delete
* @throws BadContentTypeException
[1964] Fix | Delete
*/
[1965] Fix | Delete
function _guess_content_type($handle) {
[1966] Fix | Delete
if ($this->content_type)
[1967] Fix | Delete
return;
[1968] Fix | Delete
[1969] Fix | Delete
if (function_exists("finfo_open")) {
[1970] Fix | Delete
$local_magic = dirname(__FILE__) . "/share/magic";
[1971] Fix | Delete
$finfo = @finfo_open(FILEINFO_MIME, $local_magic);
[1972] Fix | Delete
[1973] Fix | Delete
if (!$finfo)
[1974] Fix | Delete
$finfo = @finfo_open(FILEINFO_MIME);
[1975] Fix | Delete
[1976] Fix | Delete
if ($finfo) {
[1977] Fix | Delete
[1978] Fix | Delete
if (is_file((string)$handle))
[1979] Fix | Delete
$ct = @finfo_file($finfo, $handle);
[1980] Fix | Delete
else
[1981] Fix | Delete
$ct = @finfo_buffer($finfo, $handle);
[1982] Fix | Delete
[1983] Fix | Delete
/* PHP 5.3 fileinfo display extra information like
[1984] Fix | Delete
charset so we remove everything after the ; since
[1985] Fix | Delete
we are not into that stuff */
[1986] Fix | Delete
if ($ct) {
[1987] Fix | Delete
$extra_content_type_info = strpos($ct, "; ");
[1988] Fix | Delete
if ($extra_content_type_info)
[1989] Fix | Delete
$ct = substr($ct, 0, $extra_content_type_info);
[1990] Fix | Delete
}
[1991] Fix | Delete
[1992] Fix | Delete
if ($ct && $ct != 'application/octet-stream')
[1993] Fix | Delete
$this->content_type = $ct;
[1994] Fix | Delete
[1995] Fix | Delete
@finfo_close($finfo);
[1996] Fix | Delete
}
[1997] Fix | Delete
}
[1998] Fix | Delete
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function