diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 00000000..bf4570c7 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,25 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..51e734a7 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..0fb0a2c1 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 00000000..15a2ff3a --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($vendorDir . '/ilovepdf/iloveimg-php/src'), + 'Ilove_Img_Compress\\' => array($baseDir . '/admin'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 00000000..ece45d67 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,38 @@ +register(true); + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 00000000..37834664 --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,41 @@ + + array ( + 'Iloveimg\\' => 9, + 'Ilove_Img_Compress\\' => 19, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Iloveimg\\' => + array ( + 0 => __DIR__ . '/..' . '/ilovepdf/iloveimg-php/src', + ), + 'Ilove_Img_Compress\\' => + array ( + 0 => __DIR__ . '/../..' . '/admin', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit96ba3e56cd403440af21e22afd622759::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit96ba3e56cd403440af21e22afd622759::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit96ba3e56cd403440af21e22afd622759::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 00000000..b4addf84 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,369 @@ +{ + "packages": [ + { + "name": "ilovepdf/iloveimg-php", + "version": "v1.1.15", + "version_normalized": "1.1.15.0", + "source": { + "type": "git", + "url": "https://github.com/ilovepdf/iloveimg-php.git", + "reference": "e825be5c31c81971b52caebd372e54846528c7f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ilovepdf/iloveimg-php/zipball/e825be5c31c81971b52caebd372e54846528c7f4", + "reference": "e825be5c31c81971b52caebd372e54846528c7f4", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "time": "2019-05-30T12:35:52+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Iloveimg\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "iloveimg", + "email": "info@iloveimg.com" + } + ], + "description": "iLoveIMG Php Api", + "homepage": "https://iloveimg.com/", + "support": { + "issues": "https://github.com/ilovepdf/iloveimg-php/issues", + "source": "https://github.com/ilovepdf/iloveimg-php/tree/v1.1.15" + }, + "install-path": "../ilovepdf/iloveimg-php" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.4.1", + "version_normalized": "6.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ~8.0.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.10.12", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "time": "2023-11-10T00:33:47+00:00", + "type": "library", + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.1" + }, + "install-path": "../php-stubs/wordpress-stubs" + }, + { + "name": "phpstan/extension-installer", + "version": "1.3.1", + "version_normalized": "1.3.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "time": "2023-05-24T08:59:17+00:00", + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.3.1" + }, + "install-path": "../phpstan/extension-installer" + }, + { + "name": "phpstan/phpstan", + "version": "1.10.41", + "version_normalized": "1.10.41.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "time": "2023-11-05T12:57:57+00:00", + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "install-path": "../phpstan/phpstan" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.28.0", + "version_normalized": "1.28.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2023-01-26T09:26:14+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php73" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.3.2", + "version_normalized": "1.3.2.0", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", + "phpstan/phpstan": "^1.10.30", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "^8.0 || ^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "time": "2023-10-16T17:23:56+00:00", + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.2" + }, + "install-path": "../szepeviktor/phpstan-wordpress" + } + ], + "dev": true, + "dev-package-names": [ + "php-stubs/wordpress-stubs", + "phpstan/extension-installer", + "phpstan/phpstan", + "symfony/polyfill-php73", + "szepeviktor/phpstan-wordpress" + ] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 00000000..05baccc7 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,77 @@ + array( + 'name' => 'ilovepdf/iloveimg-wp-compress', + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'reference' => '17537eb86b385e73f8853e3b2a9ab782b4e90462', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'ilovepdf/iloveimg-php' => array( + 'pretty_version' => 'v1.1.15', + 'version' => '1.1.15.0', + 'reference' => 'e825be5c31c81971b52caebd372e54846528c7f4', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ilovepdf/iloveimg-php', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'ilovepdf/iloveimg-wp-compress' => array( + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'reference' => '17537eb86b385e73f8853e3b2a9ab782b4e90462', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'php-stubs/wordpress-stubs' => array( + 'pretty_version' => 'v6.4.1', + 'version' => '6.4.1.0', + 'reference' => '6d6063cf9464a306ca2a0529705d41312b08500b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-stubs/wordpress-stubs', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpstan/extension-installer' => array( + 'pretty_version' => '1.3.1', + 'version' => '1.3.1.0', + 'reference' => 'f45734bfb9984c6c56c4486b71230355f066a58a', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../phpstan/extension-installer', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpstan/phpstan' => array( + 'pretty_version' => '1.10.41', + 'version' => '1.10.41.0', + 'reference' => 'c6174523c2a69231df55bdc65b61655e72876d76', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpstan/phpstan', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'symfony/polyfill-php73' => array( + 'pretty_version' => 'v1.28.0', + 'version' => '1.28.0.0', + 'reference' => 'fe2f306d1d9d346a7fee353d0d5012e401e984b5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php73', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'szepeviktor/phpstan-wordpress' => array( + 'pretty_version' => 'v1.3.2', + 'version' => '1.3.2.0', + 'reference' => 'b8516ed6bab7ec50aae981698ce3f67f1be2e45a', + 'type' => 'phpstan-extension', + 'install_path' => __DIR__ . '/../szepeviktor/phpstan-wordpress', + 'aliases' => array(), + 'dev_requirement' => true, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 00000000..6d3407db --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/ilovepdf/iloveimg-php/.gitignore b/vendor/ilovepdf/iloveimg-php/.gitignore new file mode 100644 index 00000000..4e55b582 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/.gitignore @@ -0,0 +1,7 @@ +/.idea/ +/vendor/ +*.DS_Store +.DS_Store +/tests/data/ +composer.lock +clover.xml \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/.travis.yml b/vendor/ilovepdf/iloveimg-php/.travis.yml new file mode 100644 index 00000000..159cd69e --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/.travis.yml @@ -0,0 +1,7 @@ +language: php + +php: + - '7.1' + - '7.2' + +before_script: composer install \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/changelog.md b/vendor/ilovepdf/iloveimg-php/changelog.md new file mode 100644 index 00000000..44556449 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/changelog.md @@ -0,0 +1,3 @@ +Changelog +--------- + diff --git a/vendor/ilovepdf/iloveimg-php/circle.yml b/vendor/ilovepdf/iloveimg-php/circle.yml new file mode 100644 index 00000000..23b55d14 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/circle.yml @@ -0,0 +1,3 @@ +machine: + php: + version: 7.1.3 \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/composer.json b/vendor/ilovepdf/iloveimg-php/composer.json new file mode 100644 index 00000000..b86eacb4 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/composer.json @@ -0,0 +1,30 @@ +{ + "name": "ilovepdf/iloveimg-php", + "description": "iLoveIMG Php Api", + "type": "library", + "homepage": "https://iloveimg.com/", + "license": "MIT", + "authors": [ + { + "name": "iloveimg", + "email": "info@iloveimg.com" + } + ], + "autoload": { + "psr-4": { + "Iloveimg\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "require": { + "php": ">=7.1", + "ext-curl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + } +} diff --git a/vendor/ilovepdf/iloveimg-php/init.php b/vendor/ilovepdf/iloveimg-php/init.php new file mode 100755 index 00000000..a6a057a5 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/init.php @@ -0,0 +1,32 @@ + + + + tests + + + + + lib + + + + + + \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/phpunit.xml b/vendor/ilovepdf/iloveimg-php/phpunit.xml new file mode 100644 index 00000000..4e4ddaaf --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/phpunit.xml @@ -0,0 +1,13 @@ + + + + tests + + + + + src + ./tests/TestCase.php + + + diff --git a/vendor/ilovepdf/iloveimg-php/readme.md b/vendor/ilovepdf/iloveimg-php/readme.md new file mode 100644 index 00000000..d15d0cda --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/readme.md @@ -0,0 +1,62 @@ +iLoveIMG Api - Php Library +-------------------------- + +[![Build Status](https://travis-ci.org/ilovepdf/iloveimg-php.svg?branch=master)](https://travis-ci.org/ilovepdf/iloveimg-php) +[![Latest Stable Version](https://poser.pugx.org/ilovepdf/iloveimg-php/version)](https://packagist.org/packages/ilovepdf/iloveimg-php) +[![Total Downloads](https://poser.pugx.org/ilovepdf/iloveimg-php/downloads.svg)](https://packagist.org/packages/ilovepdf/iloveimg-php) +[![License](https://poser.pugx.org/ilovepdf/iloveimg-php/license)](https://packagist.org/packages/ilovepdf/iloveimg-php) + +A library in php for [iLoveIMG Api](https://developer.iloveimg.com) + +You can sign up for a iLoveIMG account at https://developer.iloveimg.com + +Develop and automate PDF processing tasks like Compress PDF, Merge PDF, Split PDF, convert Office to PDF, PDF to JPG, Images to PDF, add Page Numbers, Rotate PDF, Unlock PDF, stamp a Watermark and Repair PDF. Each one with several settings to get your desired results. + +## Requirements + +PHP 7.1 and later. + +## Install + +### Using composer + +You can install the library via [Composer](http://getcomposer.org/). Run the following command: + +```bash +composer require iloveimg/iloveimg-php +``` + +To use the library, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading): + +```php +require_once('vendor/autoload.php'); +``` + + +### Manual Installation + +If you do not wish to use Composer, you can download the [latest release](https://github.com/ilovepdf/iloveimg-php/releases). Then, to use the library, include the `init.php` file. + +```php +require_once('/path/to/iloveimg-php/init.php'); +``` + +## Getting Started + +Simple usage looks like: + +```php +$iloveimg = new Iloveimg('project_public_id','project_secret_key'); +$myTask = $iloveimg->newTask('compress'); +$file1 = $myTask->addFile('file1.jpg'); +$myTask->execute(); +$myTask->download(); +``` + +## Samples + +See samples folder. + +## Documentation + +Please see https://developer.iloveimg.com/docs for up-to-date documentation. \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/chained_task.php b/vendor/ilovepdf/iloveimg-php/samples/chained_task.php new file mode 100644 index 00000000..0501287c --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/chained_task.php @@ -0,0 +1,34 @@ +newTask('rotate'); + +// file var keeps info about server file id, name... +// it can be used latter to cancel file +$file = $rotateTask->addFile('/path/to/file/document.jpg'); +$file->setRotation(90); + +// run the task +$rotateTask->execute(); + +//and create a new task from last action +$compressTask = $rotateTask->next('compress'); +$compressTask->setCompressionLevel('extreme'); + +// process files +$compressTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$compressTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/compress_advanced.php b/vendor/ilovepdf/iloveimg-php/samples/compress_advanced.php new file mode 100644 index 00000000..a029f7bd --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/compress_advanced.php @@ -0,0 +1,33 @@ +addFile('/path/to/file/document.jpg'); + +// we can set rotate to file +$file->setRotation(90); + +// set compression level +$myTask->setCompressionLevel('extreme'); + +// and set name for output file. +// the task will set the correct file extension for you. +$myTask->setOutputFilename('lowlow_compression'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download('path/to/download'); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/compress_basic.php b/vendor/ilovepdf/iloveimg-php/samples/compress_basic.php new file mode 100644 index 00000000..142ee85e --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/compress_basic.php @@ -0,0 +1,22 @@ +addFile('/path/to/file/document.jpg'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/get_remaining_files.php b/vendor/ilovepdf/iloveimg-php/samples/get_remaining_files.php new file mode 100644 index 00000000..f29270a2 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/get_remaining_files.php @@ -0,0 +1,26 @@ +getRemainingFiles(); + + +//print your remaining files +echo $remainingFiles; + +//only start new process if you have enough files +if($remainingFiles>0) { + //start the task + $myTask = $iloveimg->newTask('merge'); +} \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/repair_advanced.php b/vendor/ilovepdf/iloveimg-php/samples/repair_advanced.php new file mode 100644 index 00000000..e283a305 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/repair_advanced.php @@ -0,0 +1,27 @@ +addFile('/path/to/file/document.jpg'); + + +// and set name for output file. +// the task will set the correct file extension for you. +$myTask->setOutputFilename('repaired_file'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download('path/to/download'); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/repair_basic.php b/vendor/ilovepdf/iloveimg-php/samples/repair_basic.php new file mode 100644 index 00000000..028f7852 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/repair_basic.php @@ -0,0 +1,22 @@ +addFile('/path/to/file/document.jpg'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/resize_advanced.php b/vendor/ilovepdf/iloveimg-php/samples/resize_advanced.php new file mode 100644 index 00000000..1336bed9 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/resize_advanced.php @@ -0,0 +1,41 @@ +addFile('/path/to/file/document.jpg'); + + +//set resize mode to pixels +$myTask->setResizeMode('pixels'); + +//resize to fit into a 1024px square +$myTask->setPixelsWidth('1024'); +$myTask->setPixelsHeight('1024'); + +//do not make it bigger +$myTask->setNoEnlargeIfSmaller(true); + +//queep relation +$myTask->setMaintainRatio(true); + + +// and set name for output file. +// the task will set the correct file extension for you. +$myTask->setOutputFilename('repaired_file'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download('path/to/download'); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/resize_basic.php b/vendor/ilovepdf/iloveimg-php/samples/resize_basic.php new file mode 100644 index 00000000..76b6713c --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/resize_basic.php @@ -0,0 +1,26 @@ +addFile('/path/to/file/document.jpg'); + +//set resize mode to percentage and resize 50% +$myTask->setResizeMode('percentage'); +$myTask->setPercentage('50'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/rotate_advanced.php b/vendor/ilovepdf/iloveimg-php/samples/rotate_advanced.php new file mode 100644 index 00000000..b145eb01 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/rotate_advanced.php @@ -0,0 +1,29 @@ +addFile('/path/to/file/document.jpg'); + +// set the rotation, in degrees +$file->setRotation(90); + +// and set name for output file. +// the task will set the correct file extension for you. +$myTask->setOutputFilename('rotated_file'); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download('path/to/download'); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/rotate_basic.php b/vendor/ilovepdf/iloveimg-php/samples/rotate_basic.php new file mode 100644 index 00000000..a61dfe70 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/rotate_basic.php @@ -0,0 +1,25 @@ +addFile('/path/to/file/document.jpg'); + +// set the rotation, in degrees +$file->setRotation(90); + +// process files +$myTask->execute(); + +// and finally download file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/try_catch_errors.php b/vendor/ilovepdf/iloveimg-php/samples/try_catch_errors.php new file mode 100644 index 00000000..8aecdcdf --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/try_catch_errors.php @@ -0,0 +1,54 @@ +newTask('compress'); + + // or you can call task class directly, this set the same tool as before + $myTask = new \Iloveimg\CompressimageImageTask('project_public_id','project_secret_key'); + + + // file var keeps info about server file id, name... + // it can be used latter to cancel file + $file = $myTask->addFile('/path/to/file/document.jpg'); + $file2 = $myTask->addFile('/path/to/file/document2.jpg'); + + // and set name for output file. + // in this case it will output a zip file, so we set the package name. + $myTask->setPackagedFilename('compress_documents'); + + // and name for splitted document (inside the zip file) + $myTask->setOutputFilename('compressed'); + + // process files + $myTask->execute(); + + // and finally download file. If no path is set, it will be downloaded on current folder + $myTask->download('path/to/download'); + +} catch (\Iloveimg\Exceptions\StartException $e) { + echo "An error occured on start: " . $e->getMessage() . " "; +} catch (\Iloveimg\Exceptions\AuthException $e) { + echo "An error occured on auth: " . $e->getMessage() . " "; + echo implode(', ', $e->getErrors()); +} catch (\Iloveimg\Exceptions\UploadException $e) { + echo "An error occured on upload: " . $e->getMessage() . " "; + echo implode(', ', $e->getErrors()); +} catch (\Iloveimg\Exceptions\ProcessException $e) { + echo "An error occured on process: " . $e->getMessage() . " "; + echo implode(', ', $e->getErrors()); +} catch (\Exception $e) { + echo "An error occured: " . $e->getMessage(); +} \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/watermark_advanced.php b/vendor/ilovepdf/iloveimg-php/samples/watermark_advanced.php new file mode 100644 index 00000000..9134ce2b --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/watermark_advanced.php @@ -0,0 +1,58 @@ +addFile('/path/to/file/document.jpg'); + +$watermarkElement = $myTask->addElement(); + +// set the text +$watermarkElement->setText("watermark text"); + + +// set vertical position +$watermarkElement->setGravity("NorthWest"); + +// adjust vertical position +$watermarkElement->setWidthPercent(20); + +// adjust horizontal position +$watermarkElement->setHorizontalPositionAdjustment("100"); + +// set mode to text +$watermarkElement->setFontFamily("Arial"); + +// set mode to text +$watermarkElement->setFontStyle("Italic"); + +// set the font size +$watermarkElement->setFontSize("12"); + +// set color to red +$watermarkElement->setFontColor("#ff0000"); + +// set transparency +$watermarkElement->setTransparency("50"); + + +// and set name for output file. +// the task will set the correct file extension for you. +$myTask->setOutputFilename('watermarked'); + +// process files +$myTask->execute(); + +// and finally download the unlocked file. If no path is set, it will be downloaded on current folder +$myTask->download('path/to/download'); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/watermark_basic.php b/vendor/ilovepdf/iloveimg-php/samples/watermark_basic.php new file mode 100644 index 00000000..51664248 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/watermark_basic.php @@ -0,0 +1,24 @@ +addFile('/path/to/file/document.jpg'); + +$element = $myTask->addElement(); +$element->setText('watermark text'); + +// process files +$myTask->execute(); + +// and finally download the unlocked file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/webhook_listen.php b/vendor/ilovepdf/iloveimg-php/samples/webhook_listen.php new file mode 100644 index 00000000..45bcc9f4 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/webhook_listen.php @@ -0,0 +1,19 @@ +setWorkerServer($_POST['server']); +$myTask->setTask($_POST['task']); + +//and download the file +$myTask->download(); \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/samples/webhook_send.php b/vendor/ilovepdf/iloveimg-php/samples/webhook_send.php new file mode 100644 index 00000000..d1d968ba --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/samples/webhook_send.php @@ -0,0 +1,23 @@ +addFile('/path/to/file/document.jpg'); + +//set the webhook that will recibe the notification once file is ready to download +$myTask->setWebhook('http://your_url.com'); + + +// We don't download here because with the webhook we ordered the files must be processed in background. +// Notification will be sent once it's ready diff --git a/vendor/ilovepdf/iloveimg-php/src/CompressImageTask.php b/vendor/ilovepdf/iloveimg-php/src/CompressImageTask.php new file mode 100644 index 00000000..7591a567 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/CompressImageTask.php @@ -0,0 +1,45 @@ +tool = 'compressimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } + + /** + * @param $level string + * + * values: ["extreme"|"recommended"|"low"] + * default: "recommended" + */ + public function setCompressionLevel($level) + { + $this->checkValues($level, $this->compressionLevelValues); + + $this->compression_level = $level; + + return $this; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/ConvertImageTask.php b/vendor/ilovepdf/iloveimg-php/src/ConvertImageTask.php new file mode 100644 index 00000000..f8fe005d --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/ConvertImageTask.php @@ -0,0 +1,74 @@ +tool = 'convertimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } + + /** + * @param $level string + * + * values: ["jpg"|"png"|"gif"] + * default: "jpg" + */ + public function setTo(string $to) + { + $this->checkValues($to, $this->toValues); + $this->to = $to; + return $this; + } + + /** + * @param int $gif_time + * @return $this + */ + public function setGifTime(int $gif_time) + { + $this->gif_time = $gif_time; + return $this; + } + + /** + * @param bool $gif_loop + * @return $this + */ + public function setGifLoop(bool $gif_loop) + { + $this->gif_loop = $gif_loop; + return $this; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/CropImageTask.php b/vendor/ilovepdf/iloveimg-php/src/CropImageTask.php new file mode 100644 index 00000000..df9834eb --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/CropImageTask.php @@ -0,0 +1,84 @@ +tool = 'cropimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } + + /** + * @param int $x + * @return CropImageTask + */ + public function setX($x) + { + $this->x = $x; + return $this; + } + + /** + * @param int $y + * @return CropImageTask + */ + public function setY($y) + { + $this->y = $y; + return $this; + } + + /** + * @param int $width + * @return CropImageTask + */ + public function setWidth($width) + { + $this->width = $width; + return $this; + } + + /** + * @param int $height + * @return CropImageTask + */ + public function setHeight($height) + { + $this->height = $height; + return $this; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Element.php b/vendor/ilovepdf/iloveimg-php/src/Element.php new file mode 100644 index 00000000..afc49d09 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Element.php @@ -0,0 +1,339 @@ + $value) { + if (property_exists(self::class, $name)) { + $this->$name = $value; + } + } + } + } + + /** + * @param string $mode + * @return Element + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * @param string $text + * @return Element + */ + public function setText($text) + { + $this->text = $text; + return $this; + } + + /** + * @param string $image + * @return Element + */ + public function setImage($image) + { + if (get_class($image) === 'Iloveimg\File') { + $this->image = $image->getServerFilename(); + } + else{ + $this->image = $image; + } + $this->setType('image'); + return $this; + } + + /** + * @param int $rotation + */ + public function setRotation($rotation) + { + $this->rotation = $rotation; + return $this; + } + + /** + * @param string $font_family + */ + public function setFontFamily($font_family) + { + $this->checkValues($font_family, $this->fontFamilyValues); + + $this->font_family = $font_family; + return $this; + } + + /** + * @param string $font_style + */ + public function setFontStyle($font_style) + { + $this->font_style = $font_style; + return $this; + } + + /** + * @param int $font_size + */ + public function setFontSize($font_size) + { + $this->font_size = $font_size; + return $this; + } + + /** + * @param string $font_color + */ + public function setFontColor($font_color) + { + $this->font_color = $font_color; + return $this; + } + + /** + * @param string $font_color + */ + public function setColorShadow($color_shadow) + { + $this->color_shadow = $color_shadow; + return $this; + } + + /** + * @param int $transparency + */ + public function setTransparency($transparency) + { + $this->transparency = $transparency; + return $this; + } + + + /** + * @param string $vertical_position + */ + public function setVerticalPosition($vertical_position) + { + $this->checkValues($vertical_position, $this->verticalPositionValues); + + $this->vertical_position = $vertical_position; + return $this; + } + + /** + * @param string $horizontal_position + */ + public function setHorizontalPosition($horizontal_position) + { + $this->checkValues($horizontal_position, $this->horizontalPositionValues); + + $this->horizontal_position = $horizontal_position; + return $this; + } + + /** + * @param int $vertical_position_adjustment + */ + public function setVerticalPositionAdjustment($vertical_position_adjustment) + { + $this->vertical_position_adjustment = $vertical_position_adjustment; + return $this; + } + + /** + * @param int $horizontal_position_adjustment + */ + public function setHorizontalAdjustmentPercent($horizontal_adjustment_percent) + { + $this->horizontal_adjustment_percent = $horizontal_adjustment_percent; + return $this; + } + + /** + * @param $gravity + * @return $this + */ + public function setGravity($gravity) + { + $this->checkValues($gravity, $this->gravityValues); + + $this->gravity = $gravity; + return $this; + } + + /** + * @param int $width_percent + * @return $this + */ + public function setWidthPercent(int $width_percent) + { + $this->width_percent = $width_percent; + return $this; + } + + /** + * @param mixed $value + * @param array $allowed + * + * @return ImageTask + */ + public function checkValues($value, $allowedValues) + { + if (!in_array($value, $allowedValues)) { + throw new \InvalidArgumentException('Invalid ' . $this->tool . ' value "' . $value . '". Must be one of: ' . implode(',', $allowedValues)); + } + } + +} \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/src/Exceptions/AuthException.php b/vendor/ilovepdf/iloveimg-php/src/Exceptions/AuthException.php new file mode 100644 index 00000000..d7c32fbc --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Exceptions/AuthException.php @@ -0,0 +1,8 @@ +body->error) && $response->body->error->type) { + $this->type = $response->body->error->type; + } + if (isset($response->body->error->param)) { + $this->params = $response->body->error->param; + } + if ($this->params) { + if (is_array($this->params)) { + if(is_object($this->params[0])){ + $firstError = $this->params[0]->error; //test unlock fail + } + else{ + $firstError = $this->params[0]; + } + } else { + $params = json_decode(json_encode($this->params), true); + + if(is_string($params)){ + $firstError = $params; //download exception + } + else{ + $error = array_values($params); + if (is_array($error[0])) { + $error[0] = array_values($error[0]); + $firstError = $error[0][0]; //task deleted before execute + } else { + $firstError = $error[0]; + } + } + } + parent::__construct($message . ' (' . $firstError . ')', $code, $previous); + } else { + parent::__construct($message, $code, $previous); + } + } + + /** + * @return mixed + */ + public function getErrors() + { + return $this->params; + } + + /** + * @return mixed + */ + public function getType() + { + return $this->type; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Exceptions/PathException.php b/vendor/ilovepdf/iloveimg-php/src/Exceptions/PathException.php new file mode 100644 index 00000000..4bc182f6 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Exceptions/PathException.php @@ -0,0 +1,7 @@ +server_filename = $server_filename; + $this->filename = $filename; + } + + /** + * @return array + */ + function getFileOptions() + { + return array( + 'server_filename' => $this->server_filename, + 'filename' => $this->filename, + 'rotate' => $this->rotate + ); + } + + + /** + * @param integer $degrees [0|90|180|270] + * @return bool + */ + function setRotation($degrees) + { + if($degrees!=0 && $degrees!=90 && $degrees!=180 && $degrees!=270){ + throw new \InvalidArgumentException; + } + $this->rotate = $degrees; + return true; + } + + /** + * @return string + */ + function getServerFilename() + { + return $this->server_filename; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Iloveimg.php b/vendor/ilovepdf/iloveimg-php/src/Iloveimg.php new file mode 100644 index 00000000..b5f06ba0 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Iloveimg.php @@ -0,0 +1,346 @@ +setApiKeys($publicKey, $secretKey); + } + + /** + * @return string The API secret key used for requests. + */ + public function getSecretKey() + { + return $this->secretKey; + } + + /** + * @return string The API secret key used for requests. + */ + public function getPublicKey() + { + return $this->publicKey; + } + + /** + * Sets the API key to be used for requests. + * + * @param string $apiKey + */ + public function setApiKeys($publicKey, $secretKey) + { + $this->publicKey = $publicKey; + $this->secretKey = $secretKey; + } + + /** + * @return string The API version used for requests. null if we're using the + * latest version. + */ + public static function getApiVersion() + { + return self::$apiVersion; + } + + /** + * @param string $apiVersion The API version to use for requests. + */ + public static function setApiVersion($apiVersion) + { + self::$apiVersion = $apiVersion; + } + + /** + * @return string The JWT to be used on api requests + */ + public function getJWT() + { +// if (!is_null($this->token) && !$this->getFileEncryption()) { +// return $this->token; +// } + + // Collect all the data + $secret = $this->getSecretKey(); + + $currentTime = time(); + $request = ''; + $hostInfo = ''; + + // Merge token with presets not to miss any params in custom + // configuration + $token = array_merge([ + 'iss' => $hostInfo, + 'aud' => $hostInfo, + 'iat' => $currentTime - $this->timeDelay, + 'nbf' => $currentTime - $this->timeDelay, + 'exp' => $currentTime + 3600 + $this->timeDelay + ], []); + + // Set up id + $token['jti'] = $this->getPublicKey(); + + // Set encryptKey + if ($this->getFileEncryption()) { + $token['file_encryption_key'] = $this->getEncrytKey(); + } + + $this->token = JWT::encode($token, $secret, static::getTokenAlgorithm()); + + return $this->token; + } + + + /** + * @return string + */ + public static function getTokenAlgorithm() + { + return 'HS256'; + } + + + /** + * @param string $method + * @param string $endpoint + * @param string $body + * + * @return mixed response from server + * + * @throws AuthException + * @throws ProcessException + * @throws UploadException + */ + public function sendRequest($method, $endpoint, $body = null, $start = false) + { + $to_server = self::$startServer; + if (!$start && !is_null($this->getWorkerServer())) { + $to_server = $this->workerServer; + } + + if ($endpoint == 'process' || $endpoint == 'upload' || strpos($endpoint, 'download/') === 0) { + Request::timeout($this->timeoutLarge); + } else { + Request::timeout($this->timeout); + } + + $response = Request::$method($to_server . '/v1/' . $endpoint, array( + 'Accept' => 'application/json', + 'Authorization' => 'Bearer ' . $this->getJWT() + ), $body); + + if ($response->code != '200' && $response->code != '201') { + if ($response->code == 401) { + throw new AuthException($response->body->name, $response->code, null, $response); + } + if ($endpoint == 'upload') { + throw new UploadException($response->body->error->message, $response->code, null, $response); + } elseif ($endpoint == 'process') { + throw new ProcessException($response->body->error->message, $response->code, null, $response); + } elseif (strpos($endpoint, 'download') === 0) { + throw new DownloadException($response->body->error->message, $response->code, null, $response); + } else { + if ($response->code == 400) { + if (strpos($endpoint, 'task') != -1) { + throw new TaskException('Invalid task id'); + } + throw new \Exception('Bad Request'); + } + throw new \Exception($response->body->error->message); + } + } + return $response; + } + + /** + * @param string $tool api tool to use + * + * @return mixed Return implemented Task class for specified tool + * + * @throws \Exception + */ + public function newTask($tool = '', $makeStart = true) + { + $classname = '\\Iloveimg\\' . ucwords(strtolower($tool)) . 'ImageTask'; + if (!class_exists($classname)) { + throw new \InvalidArgumentException(); + } + return new $classname($this->getPublicKey(), $this->getSecretKey(), $makeStart); + } + + public static function setStartServer($server) + { + self::$startServer = $server; + } + + + public static function getStartServer() + { + return self::$startServer; + } + + /** + * @return string Return url + */ + public function getWorkerServer() + { + return $this->workerServer; + } + + /** + * @param null $workerServer + */ + public function setWorkerServer($workerServer) + { + $this->workerServer = $workerServer; + } + + + /** + * @param boolean $value + */ + public function setFileEncryption($value, $encryptKey = null) + { + $this->encrypted = $value; + if ($this->encrypted) { + $this->setEncryptKey($encryptKey); + } else { + $this->encryptKey = null; + } + } + + + /** + * @return bool + */ + public function getFileEncryption() + { + return $this->encrypted; + } + + /** + * @return mixed + */ + public function getEncrytKey() + { + return $this->encryptKey; + } + + /** + * @param mixed $encrytKey + */ + public function setEncryptKey($encryptKey = null) + { + if ($encryptKey == null) { + $encryptKey = IloveimgTool::rand_sha1(32); + } + $len = strlen($encryptKey); + if ($len != 16 && $len != 24 && $len != 32) { + throw new \InvalidArgumentException('Encrypt key shold have 16, 14 or 32 chars length'); + } + $this->encryptKey = $encryptKey; + } + + /** + * @return ImageTask + */ + public function getStatus($server, $taskId) + { + $workerServer = $this->getWorkerServer(); + $this->setWorkerServer($server); + $response = $this->sendRequest('get', 'task/' . $taskId); + $this->setWorkerServer($workerServer); + + return $response->body; + } + + /** + * @param $verify + */ + public function verifySsl($verify) + { + Request::verifyPeer($verify); + Request::verifyHost($verify); + } + + private function getUpdatedInfo() + { + $data = array('v' => self::VERSION); + $body = Body::Form($data); + $response = self::sendRequest('get', 'info', $body); + $this->info = $response->body; + return $this->info; + } + + + /** + * @return object + */ + public function getInfo() + { + $info = $this->getUpdatedInfo(); + return $info; + } + + /** + * @return integer + */ + public function getRemainingFiles() + { + $info = $this->getUpdatedInfo(); + return $info->remaining_files; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/IloveimgTool.php b/vendor/ilovepdf/iloveimg-php/src/IloveimgTool.php new file mode 100644 index 00000000..b3b55d82 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/IloveimgTool.php @@ -0,0 +1,31 @@ +start(); + } + } + + public function start() + { + $data = array('v' => self::VERSION); + $body = Body::Form($data); + $response = parent::sendRequest('get', 'start/' . $this->tool, $body); + if (empty($response->body->server)) { + throw new StartException('no server assigned on start'); + }; + $this->setWorkerServer('https://' . $response->body->server); + $this->setTask($response->body->task); + } + + public function next($nextTool): ImageTask + { + $data = [ + 'v' => self::VERSION, + 'task' => $this->getTaskId(), + 'tool' => $nextTool + ]; + $body = Body::Form($data); + + try { + $response = parent::sendRequest('post', 'task/next', $body); + + if (empty($response->body->task)) { + throw new StartException('No task assigned on chained start'); + }; + } catch (\Exception $e) { + throw new StartException('Error on start chained task'); + } + + $next = $this->newTask($nextTool); + $next->setWorkerServer($this->getWorkerServer()); + $next->setTask($response->body->task); + + //add files chained + foreach ($response->body->files as $serverFilename => $fileName) { + $next->files[] = new File($serverFilename, $fileName); + } + + return $next; + } + + public function setTask($task) + { + $this->task = $task; + } + + public function getTaskId() + { + return $this->task; + } + + public function getFiles() + { + return $this->files; + } + + public function getFilesArray() + { + $filesArray = []; + foreach ($this->files as $file) { + $filesArray[] = $file->getFileOptions(); + } + return $filesArray; + } + + public function getStatus($server = null, $taskId = null) + { + $server = $server ? $server : $this->getWorkerServer(); + $taskId = $taskId ? $taskId : $this->getTaskId(); + + if ($server == null || $taskId == null) { + throw new \Exception('Cannot get status if no file is uploaded'); + } + return parent::getStatus($this->getWorkerServer(), $this->getTaskId()); + } + + /** + * @param string $filePath + * @return File + */ + public function addFile($filePath) + { + $file = $this->uploadFile($this->task, $filePath); + array_push($this->files, $file); + return end($this->files); + } + + /** + * @param string $url + * @return File + */ + public function addFileFromUrl($url) + { + $file = $this->uploadUrl($this->task, $url); + array_push($this->files, $file); + return end($this->files); + } + + /** + * @param string $task + * @param string $filepath + * + * @return File + * + * @throws Exceptions\AuthException + * @throws Exceptions\ProcessException + * @throws UploadException + */ + public function uploadFile($task, $filepath) + { + $data = array('task' => $task, 'v' => self::VERSION); + $files = array('file' => $filepath); + $body = Request\Body::multipart($data, $files); + + $response = $this->sendRequest('post', 'upload', $body); + return new File($response->body->server_filename, basename($filepath)); + } + + /** + * @return ImageTask + */ + public function delete() + { + $response = $this->sendRequest('delete', 'task/' . $this->getTaskId()); + return $this; + } + + /** + * @param string $task + * @param string $url + * + * @return File + * + * @throws Exceptions\AuthException + * @throws Exceptions\ProcessException + * @throws UploadException + */ + public function uploadUrl($task, $url) + { + $data = array('task' => $task, 'cloud_file' => $url, 'v' => self::VERSION); + $body = Request\Body::Form($data); + $response = parent::sendRequest('post', 'upload', $body); + return new File($response->body->server_filename, basename($url)); + } + + /** + * @param null|string $path + * @param null|string $file + */ + public function download($path = null) + { + if ($path != null && !is_dir($path)) { + if (pathinfo($path, PATHINFO_EXTENSION) == '') { + throw new PathException('Invalid download path. Use method setOutputFilename() to set the output file name.'); + } + throw new PathException('Invalid download path. Set a valid folder path to download the file.'); + } + + $this->downloadFile($this->task); + + if (is_null($path)) $path = '.'; + $destination = $path . '/' . $this->outputFileName; + $file = fopen($destination, "w+"); + fputs($file, $this->outputFile); + fclose($file); + return; + } + + /** + * @param null|string $path + * @param null|string $file + */ + public function blob() + { + $this->downloadFile($this->task); + return $this->outputFile; + } + + /** + * @param null|string $path + * @param null|string $file + */ + public function toBrowser() + { + $this->downloadFile($this->task); + + if ($this->outputFileType == 'pdf') { + header("Content-type:application/pdf"); + header("Content-Disposition:attachment;filename=\"" . $this->outputFileName . "\""); + } else { + if (function_exists('mb_strlen')) { + $size = mb_strlen($this->outputFile, '8bit'); + } else { + $size = strlen($this->outputFile); + } + header('Content-Type: application/zip'); + header("Content-Disposition: attachment; filename=\"" . $this->outputFileName . "\""); + header("Content-Length: " . $size); + } + echo $this->outputFile; + return; + } + + /** + * @param string $task + * @param string $path + * + * @throws Exceptions\AuthException + * @throws Exceptions\ProcessException + * @throws Exceptions\UploadException + */ + private function downloadFile($task) + { + $data = array('v' => self::VERSION); + $body = Request\Body::Form($data); + $response = parent::sendRequest('get', 'download/' . $task, $body); + + if (preg_match("/filename\*\=utf-8\'\'([\W\w]+)/", $response->headers['Content-Disposition'], $matchesUtf)) { + $filename = urldecode(str_replace('"', '', $matchesUtf[1])); + } else { + preg_match('/ .*filename=\"([\W\w]+)\"/', $response->headers['Content-Disposition'], $matches); + $filename = str_replace('"', '', $matches[1]); + } + + $this->outputFile = $response->raw_body; + $this->outputFileName = $filename; + $this->outputFileType = pathinfo($this->outputFileName, PATHINFO_EXTENSION); + } + + /** + * @param $value + */ + public function sendEncryptedFiles($value) + { + self::$encrypted = $value; + } + + /** + * @param $value + * @return bool + */ + public function getEncrypted($value) + { + return self::$encrypted; + } + + /** + * @return ImageTask + * @throws Exceptions\AuthException + * @throws Exceptions\ProcessException + * @throws Exceptions\UploadException + */ + public function execute() + { + if ($this->task === null) { + throw new \Exception('Current task not exists'); + } + + $data = array_merge( + $this->getPublicVars($this), + array('task' => $this->task, 'files' => $this->files, 'v' => self::VERSION)); + + //clean unwanted vars to be sent + unset($data['timeoutLarge']); + unset($data['timeout']); + unset($data['timeDelay']); + + $body = Request\Body::multipart($data); + + $response = parent::sendRequest('post', 'process', urldecode(http_build_query($body))); + + $this->result = $response->body; + + return $this; + } + + public function getPublicVars() + { + return call_user_func('get_object_vars', $this); + } + + + /** + * @param string $filename Set filename for downloaded zip file + * @return ImageTask + */ + public function setPackagedFilename($filename) + { + $this->packaged_filename = $filename; + return $this; + } + + /** + * @param string $filename Set filename for individual file/s + * @return ImageTask + */ + public function setOutputFilename($filename) + { + $this->output_filename = $filename; + return $this; + } + + /** + * @param $file File + * @return ImageTask + * @throws Exceptions\AuthException + * @throws Exceptions\DownloadException + * @throws Exceptions\ProcessException + * @throws Exceptions\UploadException + * @throws \Exception + */ + public function deleteFile($file) + { + if (($key = array_search($file, $this->files)) !== false) { + $body = Request\Body::multipart(['task' => $this->getTaskId(), 'server_filename' => $file->server_filename, 'v' => self::VERSION]); + $this->sendRequest('post', 'upload/delete', $body); + unset($this->files[$key]); + } + return $this; + } + + /** + * @param mixed $value + * @param array $allowed + * + * @return ImageTask + */ + public function checkValues($value, $allowedValues) + { + if (!in_array($value, $allowedValues)) { + throw new \InvalidArgumentException('Invalid ' . $this->tool . ' value "' . $value . '". Must be one of: ' . implode(',', $allowedValues)); + } + } + + /** + * @param boolean $try_repair + * @return ImageTask + */ + public function setTryRepair($try_repair) + { + $this->try_repair = $try_repair; + + return $this; + } + + /** + * @param boolean $ignore_errors + */ + public function setIgnoreErrors($ignore_errors) + { + $this->ignore_errors = $ignore_errors; + + return $this; + } + + + /** + * alias for setIgnoreError + * + * Will be deprecated on v2.0 + * + * @param boolean $value If true, and multiple archives are processed it will ignore files with errors and continue process for all others + * @return ImageTask + */ + public function ignoreErrors($value) + { + $this->ignore_errors = $value; + + return $this; + } + + /** + * @param boolean $value + * @return ImageTask + */ + public function setFileEncryption($value, $encryptKey = null) + { + if (count($this->files) > 0) { + throw new \Exception('Encrypth mode cannot be set after file upload'); + } + + parent::setFileEncryption($value, $encryptKey); + + return $this; + } + + /** + * @param null $custom_int + * @return $this + */ + public function setCustomInt($customInt) + { + $this->custom_int = $customInt; + return $this; + } + + /** + * @param null $custom_string + * @return $this + */ + public function setCustomString($customString) + { + $this->custom_string = $customString; + return $this; + } + + /** + * @param null $tool + * @param null $status + * @param null $customInt + * @param null $page + * + * @throws \Exception + */ + public function listTasks($tool = null, $status = null, $customInt = null, $page = null) + { + + $this->checkValues($status, $this->statusValues); + + $data = [ + 'tool' => $tool, + 'status' => $status, + 'custom_int' => $customInt, + 'page' => $page, + 'v' => self::VERSION, + 'secret_key' => $this->getSecretKey() + ]; + + $body = Request\Body::multipart($data); + + $response = parent::sendRequest('post', 'task', $body, true); + + $this->result = $response->body; + + return $this->result; + } + + /** + * @param string $webhook + * @return $this + */ + public function setWebhook($webhook) + { + $this->webhook = $webhook; + return $this; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Lib/JWT.php b/vendor/ilovepdf/iloveimg-php/src/Lib/JWT.php new file mode 100644 index 00000000..79f50b25 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Lib/JWT.php @@ -0,0 +1,366 @@ + + * @author Anant Narayanan + * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD + * @link https://github.com/firebase/php-jwt + */ +class JWT +{ + + /** + * When checking nbf, iat or expiration times, + * we want to provide some extra leeway time to + * account for clock skew. + */ + public static $leeway = 0; + + /** + * Allow the current timestamp to be specified. + * Useful for fixing a value within unit testing. + * + * Will default to PHP time() value if null. + */ + public static $timestamp = null; + + public static $supported_algs = array( + 'HS256' => array('hash_hmac', 'SHA256'), + 'HS512' => array('hash_hmac', 'SHA512'), + 'HS384' => array('hash_hmac', 'SHA384'), + 'RS256' => array('openssl', 'SHA256'), + ); + + /** + * Decodes a JWT string into a PHP object. + * + * @param string $jwt The JWT + * @param string|array $key The key, or map of keys. + * If the algorithm used is asymmetric, this is the public key + * @param array $allowed_algs List of supported verification algorithms + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * + * @return object The JWT's payload as a PHP object + * + * @throws UnexpectedValueException Provided JWT was invalid + * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed + * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf' + * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat' + * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim + * + * @uses jsonDecode + * @uses urlsafeB64Decode + */ + public static function decode($jwt, $key, $allowed_algs = array()) + { + $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp; + + if (empty($key)) { + throw new InvalidArgumentException('Key may not be empty'); + } + if (!is_array($allowed_algs)) { + throw new InvalidArgumentException('Algorithm not allowed'); + } + $tks = explode('.', $jwt); + if (count($tks) != 3) { + throw new UnexpectedValueException('Wrong number of segments'); + } + list($headb64, $bodyb64, $cryptob64) = $tks; + if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) { + throw new UnexpectedValueException('Invalid header encoding'); + } + if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) { + throw new UnexpectedValueException('Invalid claims encoding'); + } + $sig = static::urlsafeB64Decode($cryptob64); + + if (empty($header->alg)) { + throw new UnexpectedValueException('Empty algorithm'); + } + if (empty(static::$supported_algs[$header->alg])) { + throw new UnexpectedValueException('Algorithm not supported'); + } + if (!in_array($header->alg, $allowed_algs)) { + throw new UnexpectedValueException('Algorithm not allowed'); + } + if (is_array($key) || $key instanceof \ArrayAccess) { + if (isset($header->kid)) { + $key = $key[$header->kid]; + } else { + throw new UnexpectedValueException('"kid" empty, unable to lookup correct key'); + } + } + + // Check the signature + if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) { + throw new SignatureInvalidException('Signature verification failed'); + } + + // Check if the nbf if it is defined. This is the time that the + // token can actually be used. If it's not yet that time, abort. + if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { + throw new BeforeValidException( + 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf) + ); + } + + // Check that this token has been created before 'now'. This prevents + // using tokens that have been created for later use (and haven't + // correctly used the nbf claim). + if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) { + throw new BeforeValidException( + 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat) + ); + } + + // Check if this token has expired. + if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) { + throw new ExpiredException('Expired token'); + } + + return $payload; + } + + /** + * Converts and signs a PHP object or array into a JWT string. + * + * @param object|array $payload PHP object or array + * @param string $key The secret key. + * If the algorithm used is asymmetric, this is the private key + * @param string $alg The signing algorithm. + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * @param mixed $keyId + * @param array $head An array with header elements to attach + * + * @return string A signed JWT + * + * @uses jsonEncode + * @uses urlsafeB64Encode + */ + public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) + { + $header = array('typ' => 'JWT', 'alg' => $alg); + if ($keyId !== null) { + $header['kid'] = $keyId; + } + if ( isset($head) && is_array($head) ) { + $header = array_merge($head, $header); + } + $segments = array(); + $segments[] = static::urlsafeB64Encode(static::jsonEncode($header)); + $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload)); + $signing_input = implode('.', $segments); + + $signature = static::sign($signing_input, $key, $alg); + $segments[] = static::urlsafeB64Encode($signature); + + return implode('.', $segments); + } + + /** + * Sign a string with a given key and algorithm. + * + * @param string $msg The message to sign + * @param string|resource $key The secret key + * @param string $alg The signing algorithm. + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * + * @return string An encrypted message + * + * @throws DomainException Unsupported algorithm was specified + */ + public static function sign($msg, $key, $alg = 'HS256') + { + if (empty(static::$supported_algs[$alg])) { + throw new DomainException('Algorithm not supported'); + } + list($function, $algorithm) = static::$supported_algs[$alg]; + switch($function) { + case 'hash_hmac': + return hash_hmac($algorithm, $msg, $key, true); + case 'openssl': + $signature = ''; + $success = openssl_sign($msg, $signature, $key, $algorithm); + if (!$success) { + throw new DomainException("OpenSSL unable to sign data"); + } else { + return $signature; + } + } + } + + /** + * Verify a signature with the message, key and method. Not all methods + * are symmetric, so we must have a separate verify and sign method. + * + * @param string $msg The original message (header and body) + * @param string $signature The original signature + * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key + * @param string $alg The algorithm + * + * @return bool + * + * @throws DomainException Invalid Algorithm or OpenSSL failure + */ + private static function verify($msg, $signature, $key, $alg) + { + if (empty(static::$supported_algs[$alg])) { + throw new DomainException('Algorithm not supported'); + } + + list($function, $algorithm) = static::$supported_algs[$alg]; + switch($function) { + case 'openssl': + $success = openssl_verify($msg, $signature, $key, $algorithm); + if (!$success) { + throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string()); + } else { + return $signature; + } + case 'hash_hmac': + default: + $hash = hash_hmac($algorithm, $msg, $key, true); + if (function_exists('hash_equals')) { + return hash_equals($signature, $hash); + } + $len = min(static::safeStrlen($signature), static::safeStrlen($hash)); + + $status = 0; + for ($i = 0; $i < $len; $i++) { + $status |= (ord($signature[$i]) ^ ord($hash[$i])); + } + $status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash)); + + return ($status === 0); + } + } + + /** + * Decode a JSON string into a PHP object. + * + * @param string $input JSON string + * + * @return object Object representation of JSON string + * + * @throws DomainException Provided string was invalid JSON + */ + public static function jsonDecode($input) + { + if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { + /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you + * to specify that large ints (like Steam Transaction IDs) should be treated as + * strings, rather than the PHP default behaviour of converting them to floats. + */ + $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING); + } else { + /** Not all servers will support that, however, so for older versions we must + * manually detect large ints in the JSON string and quote them (thus converting + *them to strings) before decoding, hence the preg_replace() call. + */ + $max_int_length = strlen((string) PHP_INT_MAX) - 1; + $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input); + $obj = json_decode($json_without_bigints); + } + + if (function_exists('json_last_error') && $errno = json_last_error()) { + static::handleJsonError($errno); + } elseif ($obj === null && $input !== 'null') { + throw new DomainException('Null result with non-null input'); + } + return $obj; + } + + /** + * Encode a PHP object into a JSON string. + * + * @param object|array $input A PHP object or array + * + * @return string JSON representation of the PHP object or array + * + * @throws DomainException Provided object could not be encoded to valid JSON + */ + public static function jsonEncode($input) + { + $json = json_encode($input); + if (function_exists('json_last_error') && $errno = json_last_error()) { + static::handleJsonError($errno); + } elseif ($json === 'null' && $input !== null) { + throw new DomainException('Null result with non-null input'); + } + return $json; + } + + /** + * Decode a string with URL-safe Base64. + * + * @param string $input A Base64 encoded string + * + * @return string A decoded string + */ + public static function urlsafeB64Decode($input) + { + $remainder = strlen($input) % 4; + if ($remainder) { + $padlen = 4 - $remainder; + $input .= str_repeat('=', $padlen); + } + return base64_decode(strtr($input, '-_', '+/')); + } + + /** + * Encode a string with URL-safe Base64. + * + * @param string $input The string you want encoded + * + * @return string The base64 encode of what you passed in + */ + public static function urlsafeB64Encode($input) + { + return str_replace('=', '', strtr(base64_encode($input), '+/', '-_')); + } + + /** + * Helper method to create a JSON error. + * + * @param int $errno An error number from json_last_error() + * + * @return void + */ + private static function handleJsonError($errno) + { + $messages = array( + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', + JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', + JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON' + ); + throw new DomainException( + isset($messages[$errno]) + ? $messages[$errno] + : 'Unknown JSON error: ' . $errno + ); + } + + /** + * Get the number of bytes in cryptographic strings. + * + * @param string + * + * @return int + */ + private static function safeStrlen($str) + { + if (function_exists('mb_strlen')) { + return mb_strlen($str, '8bit'); + } + return strlen($str); + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/RepairImageTask.php b/vendor/ilovepdf/iloveimg-php/src/RepairImageTask.php new file mode 100644 index 00000000..82f1f06f --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/RepairImageTask.php @@ -0,0 +1,24 @@ +tool = 'repairimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Request/Body.php b/vendor/ilovepdf/iloveimg-php/src/Request/Body.php new file mode 100644 index 00000000..85110f9b --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Request/Body.php @@ -0,0 +1,66 @@ + $file) { + $data[$name] = call_user_func(array(__CLASS__, 'File'), $file); + } + } + + return $data; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Request/Method.php b/vendor/ilovepdf/iloveimg-php/src/Request/Method.php new file mode 100644 index 00000000..8d0a06cd --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Request/Method.php @@ -0,0 +1,75 @@ + '', + 'pass' => '', + 'method' => CURLAUTH_BASIC + ); + + private static $proxy = array( + 'port' => false, + 'tunnel' => false, + 'address' => false, + 'type' => CURLPROXY_HTTP, + 'auth' => array ( + 'user' => '', + 'pass' => '', + 'method' => CURLAUTH_BASIC + ) + ); + + /** + * Set JSON decode mode + * + * @param bool $assoc When TRUE, returned objects will be converted into associative arrays. + * @param integer $depth User specified recursion depth. + * @param integer $options Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats) + * @return array + */ + public static function jsonOpts($assoc = false, $depth = 512, $options = 0) + { + return self::$jsonOpts = array($assoc, $depth, $options); + } + + /** + * Verify SSL peer + * + * @param bool $enabled enable SSL verification, by default is true + * @return bool + */ + public static function verifyPeer($enabled) + { + return self::$verifyPeer = $enabled; + } + + /** + * Verify SSL host + * + * @param bool $enabled enable SSL host verification, by default is true + * @return bool + */ + public static function verifyHost($enabled) + { + return self::$verifyHost = $enabled; + } + + /** + * Set a timeout + * + * @param integer $seconds timeout value in seconds + * @return integer + */ + public static function timeout($seconds) + { + return self::$socketTimeout = $seconds; + } + + /** + * Set default headers to send on every request + * + * @param array $headers headers array + * @return array + */ + public static function defaultHeaders($headers) + { + return self::$defaultHeaders = array_merge(self::$defaultHeaders, $headers); + } + + /** + * Set a new default header to send on every request + * + * @param string $name header name + * @param string $value header value + * @return string + */ + public static function defaultHeader($name, $value) + { + return self::$defaultHeaders[$name] = $value; + } + + /** + * Clear all the default headers + */ + public static function clearDefaultHeaders() + { + return self::$defaultHeaders = array(); + } + + /** + * Set curl options to send on every request + * + * @param array $options options array + * @return array + */ + public static function curlOpts($options) + { + return self::mergeCurlOptions(self::$curlOpts, $options); + } + + /** + * Set a new default header to send on every request + * + * @param string $name header name + * @param string $value header value + * @return string + */ + public static function curlOpt($name, $value) + { + return self::$curlOpts[$name] = $value; + } + + /** + * Clear all the default headers + */ + public static function clearCurlOpts() + { + return self::$curlOpts = array(); + } + + + /** + * Send a GET request to a URL + * + * @param string $url URL to send the GET request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Authentication username (deprecated) + * @param string $password Authentication password (deprecated) + * @return Response + */ + public static function get($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::GET, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a HEAD request to a URL + * @param string $url URL to send the HEAD request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function head($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::HEAD, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a OPTIONS request to a URL + * @param string $url URL to send the OPTIONS request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return Response + */ + public static function options($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::OPTIONS, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a CONNECT request to a URL + * @param string $url URL to send the CONNECT request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function connect($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::CONNECT, $url, $parameters, $headers, $username, $password); + } + + /** + * Send POST request to a URL + * @param string $url URL to send the POST request to + * @param array $headers additional headers to send + * @param mixed $body POST body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response response + */ + public static function post($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::POST, $url, $body, $headers, $username, $password); + } + + /** + * Send DELETE request to a URL + * @param string $url URL to send the DELETE request to + * @param array $headers additional headers to send + * @param mixed $body DELETE body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function delete($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::DELETE, $url, $body, $headers, $username, $password); + } + + /** + * Send PUT request to a URL + * @param string $url URL to send the PUT request to + * @param array $headers additional headers to send + * @param mixed $body PUT body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function put($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::PUT, $url, $body, $headers, $username, $password); + } + + /** + * Send PATCH request to a URL + * @param string $url URL to send the PATCH request to + * @param array $headers additional headers to send + * @param mixed $body PATCH body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function patch($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::PATCH, $url, $body, $headers, $username, $password); + } + + /** + * Send TRACE request to a URL + * @param string $url URL to send the TRACE request to + * @param array $headers additional headers to send + * @param mixed $body TRACE body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function trace($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::TRACE, $url, $body, $headers, $username, $password); + } + + /** + * This function is useful for serializing multidimensional arrays, and avoid getting + * the 'Array to string conversion' notice + * @param array|object $data array to flatten. + * @param bool|string $parent parent key or false if no parent + * @return array + */ + public static function buildHTTPCurlQuery($data, $parent = false) + { + $result = array(); + + if (is_object($data)) { + $data = get_object_vars($data); + } + + foreach ($data as $key => $value) { + if ($parent) { + $new_key = sprintf('%s[%s]', $parent, $key); + } else { + $new_key = $key; + } + + if (!$value instanceof \CURLFile and (is_array($value) or is_object($value))) { + $result = array_merge($result, self::buildHTTPCurlQuery($value, $new_key)); + } else { + $result[$new_key] = $value; + } + } + + return $result; + } + + /** + * Send a cURL request + * @param \Iloveimg\Method|string $method HTTP method to use + * @param string $url URL to send the request to + * @param mixed $body request body + * @param array $headers additional headers to send + * @param string $username Authentication username (deprecated) + * @param string $password Authentication password (deprecated) + * @throws \Iloveimg\Exception if a cURL error occurs + * @return Response + */ + public static function send($method, $url, $body = null, $headers = array(), $username = null, $password = null) + { + self::$handle = curl_init(); + + if ($method !== Method::GET) { + if ($method === Method::POST) { + curl_setopt(self::$handle, CURLOPT_POST, true); + } else { + curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method); + } + + curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body); + } elseif (is_array($body)) { + if (strpos($url, '?') !== false) { + $url .= '&'; + } else { + $url .= '?'; + } + + $url .= urldecode(http_build_query(self::buildHTTPCurlQuery($body))); + } + + $curl_base_options = [ + CURLOPT_URL => self::encodeUrl($url), + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_MAXREDIRS => 10, + CURLOPT_HTTPHEADER => self::getFormattedHeaders($headers), + CURLOPT_HEADER => true, + CURLOPT_SSL_VERIFYPEER => self::$verifyPeer, + //CURLOPT_SSL_VERIFYHOST accepts only 0 (false) or 2 (true). Future versions of libcurl will treat values 1 and 2 as equals + CURLOPT_SSL_VERIFYHOST => self::$verifyHost === false ? 0 : 2, + // If an empty string, '', is set, a header containing all supported encoding types is sent + CURLOPT_ENCODING => '' + ]; + + curl_setopt_array(self::$handle, self::mergeCurlOptions($curl_base_options, self::$curlOpts)); + + if (self::$socketTimeout !== null) { + curl_setopt(self::$handle, CURLOPT_TIMEOUT, self::$socketTimeout); + } + + if (self::$cookie) { + curl_setopt(self::$handle, CURLOPT_COOKIE, self::$cookie); + } + + if (self::$cookieFile) { + curl_setopt(self::$handle, CURLOPT_COOKIEFILE, self::$cookieFile); + curl_setopt(self::$handle, CURLOPT_COOKIEJAR, self::$cookieFile); + } + + // supporting deprecated http auth method + if (!empty($username)) { + curl_setopt_array(self::$handle, array( + CURLOPT_HTTPAUTH => CURLAUTH_BASIC, + CURLOPT_USERPWD => $username . ':' . $password + )); + } + + if (!empty(self::$auth['user'])) { + curl_setopt_array(self::$handle, array( + CURLOPT_HTTPAUTH => self::$auth['method'], + CURLOPT_USERPWD => self::$auth['user'] . ':' . self::$auth['pass'] + )); + } + + if (self::$proxy['address'] !== false) { + curl_setopt_array(self::$handle, array( + CURLOPT_PROXYTYPE => self::$proxy['type'], + CURLOPT_PROXY => self::$proxy['address'], + CURLOPT_PROXYPORT => self::$proxy['port'], + CURLOPT_HTTPPROXYTUNNEL => self::$proxy['tunnel'], + CURLOPT_PROXYAUTH => self::$proxy['auth']['method'], + CURLOPT_PROXYUSERPWD => self::$proxy['auth']['user'] . ':' . self::$proxy['auth']['pass'] + )); + } + + $response = curl_exec(self::$handle); + $error = curl_error(self::$handle); + $info = self::getInfo(); + + if ($error) { + if(strpos($error,'SSL certificate problem')){ + throw new \Exception($error.' Try using method verifySsl to false: "$iloveimg->verifySsl(false)"'); + } + throw new \Exception($error); + } + + // Split the full response in its headers and body + $header_size = $info['header_size']; + $header = substr($response, 0, $header_size); + $body = substr($response, $header_size); + $httpCode = $info['http_code']; + + return new Response($httpCode, $body, $header, self::$jsonOpts); + } + + public static function getInfo($opt = false) + { + if ($opt) { + $info = curl_getinfo(self::$handle, $opt); + } else { + $info = curl_getinfo(self::$handle); + } + + return $info; + } + + public static function getCurlHandle() + { + return self::$handle; + } + + public static function getFormattedHeaders($headers) + { + $formattedHeaders = array(); + + $combinedHeaders = array_change_key_case(array_merge(self::$defaultHeaders, (array) $headers)); + + foreach ($combinedHeaders as $key => $val) { + $formattedHeaders[] = self::getHeaderString($key, $val); + } + + if (!array_key_exists('user-agent', $combinedHeaders)) { + $formattedHeaders[] = 'user-agent: unirest-php/2.0'; + } + + if (!array_key_exists('expect', $combinedHeaders)) { + $formattedHeaders[] = 'expect:'; + } + + return $formattedHeaders; + } + + private static function getArrayFromQuerystring($query) + { + $query = preg_replace_callback('/(?:^|(?<=&))[^=[]+/', function ($match) { + return bin2hex(urldecode($match[0])); + }, $query); + + parse_str($query, $values); + + return array_combine(array_map('hex2bin', array_keys($values)), $values); + } + + /** + * Ensure that a URL is encoded and safe to use with cURL + * @param string $url URL to encode + * @return string + */ + private static function encodeUrl($url) + { + $url_parsed = parse_url($url); + + $scheme = $url_parsed['scheme'] . '://'; + $host = $url_parsed['host']; + $port = (isset($url_parsed['port']) ? $url_parsed['port'] : null); + $path = (isset($url_parsed['path']) ? $url_parsed['path'] : null); + $query = (isset($url_parsed['query']) ? $url_parsed['query'] : null); + + if ($query !== null) { + $query = '?' . http_build_query(self::getArrayFromQuerystring($query)); + } + + if ($port && $port[0] !== ':') { + $port = ':' . $port; + } + + $result = $scheme . $host . $port . $path . $query; + return $result; + } + + private static function getHeaderString($key, $val) + { + $key = trim(strtolower($key)); + return $key . ': ' . $val; + } + + /** + * @param array $existing_options + * @param array $new_options + * @return array + */ + private static function mergeCurlOptions(&$existing_options, $new_options) + { + $existing_options = $new_options + $existing_options; + return $existing_options; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/Request/Response.php b/vendor/ilovepdf/iloveimg-php/src/Request/Response.php new file mode 100644 index 00000000..9fcb9ff2 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/Request/Response.php @@ -0,0 +1,78 @@ +code = $code; + $this->headers = $this->parseHeaders($headers); + $this->raw_body = $raw_body; + $this->body = $raw_body; + + // make sure raw_body is the first argument + array_unshift($json_args, $raw_body); + + if (function_exists('json_decode')) { + $json = call_user_func_array('json_decode', $json_args); + + if (json_last_error() === JSON_ERROR_NONE) { + $this->body = $json; + } + } + } + + /** + * if PECL_HTTP is not available use a fall back function + * + * thanks to ricardovermeltfoort@gmail.com + * http://php.net/manual/en/function.http-parse-headers.php#112986 + * @param string $raw_headers raw headers + * @return array + */ + private function parseHeaders($raw_headers) + { + if (function_exists('http_parse_headers')) { + return http_parse_headers($raw_headers); + } else { + $key = ''; + $headers = array(); + + foreach (explode("\n", $raw_headers) as $i => $h) { + $h = explode(':', $h, 2); + + if (isset($h[1])) { + if (!isset($headers[$h[0]])) { + $headers[$h[0]] = trim($h[1]); + } elseif (is_array($headers[$h[0]])) { + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); + } else { + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); + } + + $key = $h[0]; + } else { + if (substr($h[0], 0, 1) == "\t") { + $headers[$key] .= "\r\n\t".trim($h[0]); + } elseif (!$key) { + $headers[0] = trim($h[0]); + } + } + } + + return $headers; + } + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/ResizeImageTask.php b/vendor/ilovepdf/iloveimg-php/src/ResizeImageTask.php new file mode 100644 index 00000000..91de95e4 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/ResizeImageTask.php @@ -0,0 +1,124 @@ +tool = 'resizeimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } + + /** + * @param $level string + * + * values: ["percentage"|"pixels"] + * default: "percentage" + * @return $this + */ + public function setResizeMode($mode) + { + $this->checkValues($mode, $this->resizeModeValues); + + $this->resize_mode = $mode; + + return $this; + } + + /** + * @param boolean $maintain_ratio + * @return $this + */ + public function setMaintainRatio($maintain_ratio) + { + $this->maintain_ratio = $maintain_ratio; + return $this; + } + + /** + * @param boolean $no_enlarge_if_smaller + * @return ResizeImageTask + */ + public function setNoEnlargeIfSmaller($no_enlarge_if_smaller) + { + $this->no_enlarge_if_smaller = $no_enlarge_if_smaller; + return $this; + } + + /** + * @param int $pixels_width + * @return ResizeImageTask + */ + public function setPixelsWidth($pixels_width) + { + $this->pixels_width = $pixels_width; + return $this; + } + + /** + * @param int $pixels_height + * @return ResizeImageTask + */ + public function setPixelsHeight($pixels_height) + { + $this->pixels_height = $pixels_height; + return $this; + } + + /** + * @param int $percentage + * @return ResizeImageTask + */ + public function setPercentage($percentage) + { + $this->percentage = $percentage; + return $this; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/RotateImageTask.php b/vendor/ilovepdf/iloveimg-php/src/RotateImageTask.php new file mode 100644 index 00000000..a1a377ad --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/RotateImageTask.php @@ -0,0 +1,26 @@ +tool = 'rotateimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } +} diff --git a/vendor/ilovepdf/iloveimg-php/src/WatermarkImageTask.php b/vendor/ilovepdf/iloveimg-php/src/WatermarkImageTask.php new file mode 100644 index 00000000..b3c9f212 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/src/WatermarkImageTask.php @@ -0,0 +1,73 @@ +tool = 'watermarkimage'; + parent::__construct($publicKey, $secretKey, $makeStart); + } + + /** + * @param boolean $mosaic + * @return $this + */ + public function setMosaic($mosaic) + { + $this->mosaic = $mosaic; + return $this; + } + + + /** + * adds a watermark element + * + * @param null $element + * @return \Iloveimg\Element|null + */ + public function addElement($element = null) + { + if (is_array($element) || $element == null) { + $element = new Element($element); + } + + if (get_class($element) !== 'Iloveimg\Element') { + throw new \InvalidArgumentException(); + } + + if($element->type == 'image'){ + foreach($this->files as $key=>$file){ + if($file->server_filename == $element->server_filename){ + $this->watermakFiles[] = $this->files[$key]; + unset($this->files[$key]); + } + } + } + + $this->elements[] = $element; + return $element; + } +} diff --git a/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/FileTest.php b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/FileTest.php new file mode 100644 index 00000000..0a230dde --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/FileTest.php @@ -0,0 +1,61 @@ +getFileOptions(); + $this->assertEquals($options['server_filename'], $serverFilename); + $this->assertEquals($options['filename'], $filename); + } + + + /** + * @test + */ + public function testCanSetRotation(){ + $rotation = 90; + $file = new File('file_server', 'file_name'); + $file->setRotation($rotation); + $options = $file->getFileOptions(); + $this->assertEquals($options['rotate'], $rotation); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function testSetRotationWithNotAllowedParamTrowsError(){ + $rotation = '900'; + $file = new File('file_server', 'file_name'); + $file->setRotation($rotation); + } + + /* + * @test + * @expectedException \InvalidArgumentException + */ + public function testEmptyServerFilenameTrowException(){ + $file = new File('', 'some_filename'); + $this->assertEquals($file->filename, 'some_filename'); + } + + /* + * @test + * @expectedException \InvalidArgumentException + */ + public function testEmptyFilenameTrowException(){ + $file = new File('server_filename', ''); + $this->assertEquals($file->server_filename, 'server_filename'); + } +} \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveTest.php b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveTest.php new file mode 100755 index 00000000..6532c04f --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveTest.php @@ -0,0 +1,50 @@ +publicKey, $this->secretKey); + $iloveimgTest = new Iloveimg($this->publicKeyTest, $this->secretKeyTest); + + $this->assertEquals($iloveimg->getPublicKey(), $this->publicKey); + $this->assertEquals($iloveimgTest->getPublicKey(), $this->publicKeyTest); + } + + /** + * @test + */ + public function testIloveimgEmptyParams() + { + $iloveimg = new Iloveimg(); + $iloveimgTest = new Iloveimg(); + + $iloveimg->setApiKeys($this->publicKey, $this->secretKey); + $iloveimgTest->setApiKeys($this->publicKeyTest, $this->secretKeyTest); + + + $this->assertEquals($iloveimg->getPublicKey(), $this->publicKey); + $this->assertEquals($iloveimgTest->getPublicKey(), $this->publicKeyTest); + } +} diff --git a/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveimgTest.php b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveimgTest.php new file mode 100644 index 00000000..e06464ef --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/tests/Iloveimg/IloveimgTest.php @@ -0,0 +1,131 @@ +iloveimg = new Iloveimg(); + $this->iloveimg->setApiKeys($this->publicKey, $this->secretKey); + } + + /** + * @test + */ + public function testShouldHaveSecretKey() + { + $secretKey = $this->iloveimg->getSecretKey(); + $this->assertEquals($this->secretKey, $secretKey); + } + + /** + * @test + */ + public function testShouldHavePublictKey() + { + $publicKey = $this->iloveimg->getPublicKey(); + $this->assertEquals($this->publicKey, $publicKey); + } + + /** + * @test + */ + public function testCanSetApiKeys() + { + $public = "public"; + $secret = "private"; + $this->iloveimg->setApiKeys($public, $secret); + $this->assertEquals($public, $this->iloveimg->getPublicKey()); + $this->assertEquals($secret, $this->iloveimg->getSecretKey()); + } + + /** + * @test + */ + public function testCanGetJwt() + { + $jwt = $this->iloveimg->getJWT(); + $this->assertNotNull($jwt, "jwt should not be null"); + } + + /** + * @test + * @expectedException \Exception + */ + public function testEmptyTaskShouldThrowException() + { + $task = $this->iloveimg->newTask(""); + $this->assertNotNull($task); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function testNotExistingTaskShouldThrowException() + { + $this->iloveimg->newTask("tralara"); + } + + /** + * @test + */ + public function testEncryptSetDefaultKey() + { + $this->iloveimg->setFileEncryption(true); + $this->assertNotNull($this->iloveimg->getEncrytKey()); + $this->assertEquals(strlen($this->iloveimg->getEncrytKey()), 32); + } + + + /** + * @test + */ + public function testCanSetEncrypt() + { + $key = '1234123412341234'; + $this->iloveimg->setFileEncryption(true, $key ); + $this->assertEquals($this->iloveimg->getEncrytKey(), $key); + } + + /** + * @test + */ + public function testUnsetEncryptRemovesKey() + { + $key = '1234123412341234'; + $this->iloveimg->setFileEncryption(true, $key ); + $this->iloveimg->setFileEncryption(false); + $this->assertNull($this->iloveimg->getEncrytKey()); + } + + + /** + * @test + * @dataProvider invalidKeys + * @expectedException \InvalidArgumentException + */ + public function testWrongEncryptKeyThrowsException($key) + { + $this->iloveimg->setFileEncryption(true, $key ); + } + + + public function invalidKeys() + { + return [ + ['1234'], + ['asdfqwe'], + ]; + } +} \ No newline at end of file diff --git a/vendor/ilovepdf/iloveimg-php/tests/bootstrap.no_autoload.php b/vendor/ilovepdf/iloveimg-php/tests/bootstrap.no_autoload.php new file mode 100755 index 00000000..4e9dcfc6 --- /dev/null +++ b/vendor/ilovepdf/iloveimg-php/tests/bootstrap.no_autoload.php @@ -0,0 +1,3 @@ +