<?php 

use OpenCloud\Rackspace;

// ======================================================================================= //
// ======================================================================================= //

		// Editado por Santiago Botto (Sectorhosting,LLC)
		
		// Upload images to CloudSpace
		require '/home/virgen01/public_html/rackspace-tools/vendor/autoload.php';
		$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
		'username' => 'santiago.martin',
		'apiKey'   => 'f0a9eb5ac4f341e5be20b353db25faac'
		));
		$objectStoreService = $client->objectStoreService(null, 'IAD');

		date_default_timezone_set('America/Argentina/Buenos_Aires');
		$ye = date('Y');
		$mo = date('m');
		$folder = "$mo-$ye";
		$cpanel_user = get_current_user(); // Se almacena el nombre del user propietario de la web

		// Se comprueba si ya existe o no un contenedor con el nombre del user
		try {
				$container = $objectStoreService->getContainer($cpanel_user);
		} catch (Guzzle\Http\Exception\BadResponseException $e) {
				if ($e->getResponse()->getStatusCode() === 404) {
				}
		}

		// Si no existe el contenedor, se crea
		if (! $container)
		{
				$container = $objectStoreService->createContainer($cpanel_user);
		}

		$localFileName  = "http://lv12.com.ar/11-2016/resize_1480367937.jpg";
		$remoteFileName = "resize_1480367937.jpg";

		// Se sube la imagen en tamaño original
		$handle = fopen($localFileName, 'r');
		$object = $container->uploadObject($folder.'/'.$remoteFileName.$_SESSION['user_file_ext'], $handle);
		fclose($handle);
		
		$localFileName  = "http://lv12.com.ar/11-2016/thumbnail_1480367937.jpg";
		$remoteFileName = "thumbnail_1480367937.jpg";

		// Se sube la imagen de tamaño modificado
		$handle = fopen($localFileName, 'r');
		$object = $container->uploadObject($folder.'/'.$remoteFileName.$_SESSION['user_file_ext'], $handle);
		fclose($handle);			

		unset($object,$remoteFileName,$localFileName,$container,$e,$cpanel_user,$folder,$mo,$ye,$objectStoreService,$client);

		// Editado por Santiago Botto (Sectorhosting,LLC)
		
// ======================================================================================= //
// ======================================================================================= //

?>