From ac9063cf87814649a6ff1fcb8fb23db2ccc0b8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20S=CC=8Cedivy=CC=81?= Date: Sun, 26 Aug 2018 12:03:54 +0200 Subject: [PATCH] Delete install without composer --- install_without_composer.php | 283 ----------------------------------- 1 file changed, 283 deletions(-) delete mode 100644 install_without_composer.php diff --git a/install_without_composer.php b/install_without_composer.php deleted file mode 100644 index 0a6ad20..0000000 --- a/install_without_composer.php +++ /dev/null @@ -1,283 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @license MIT - * @author Filip Sedivy - * @deprecated - * Od verze 3.1.* přestane být instalace bez composeru podporovaná, protože není možné - * udržovat kód instalatoru soudružný spolu s balíčky Composeru - */ - - -class InstallWithoutComposer -{ - const DEBUG_ENABLE = true, - DEBUG_DISABLE = false; - - private $debug; - - public static $instance; - - public static function getInstance() - { - if(!self::$instance instanceof InstallWithoutComposer) - { - self::$instance = new self(); - } - return self::$instance; - } - - private function __construct($debug = self::DEBUG_ENABLE) - { - $this->setDebug($debug); - } - - public function setDebug($debug) - { - $this->debug = $debug; - } - - public function write($input) - { - if($this->debug == self::DEBUG_ENABLE) - { - if(php_sapi_name() == 'cli') - { - print($input . PHP_EOL); - } - else - { - echo print($input . '
'); - } - } - } -} - -$install = InstallWithoutComposer::getInstance(); - - -// Kontrola minimálních požadavků -if(!file_exists(__DIR__.'/composer.json')) -{ - $install->write('File composer.json is not exists'); - copy( 'https://raw.githubusercontent.com/filipsedivy/PHP-EET/master/composer.json', __DIR__.'/composer.json'); -} -$composerJson = json_decode(file_get_contents(__DIR__.'/composer.json'), true); -$minimalPhpVersion = $composerJson['require']['php']; - -preg_match('/([\W]+)([0-9.]+)/', $minimalPhpVersion, $phpMatch); -list($input, $operator, $version) = $phpMatch; - -if(!version_compare(PHP_VERSION, $version, $operator)) -{ - $install->write('The minimum version is: '.$version); - $install->write('Current version of PHP: '.PHP_VERSION); - trigger_error('Your version of PHP is not compatible with this library', E_CORE_ERROR); -} - -foreach($composerJson['require'] as $bundle => $version) -{ - if(substr($bundle, 0, 3) == 'ext') - { - $bundleExt = substr($bundle, 4); - if(!in_array($bundleExt, get_loaded_extensions())) - { - trigger_error($bundleExt.' is not available on your web server', E_CORE_ERROR); - } - } -} - -/** @var array Potřebné třídy */ -$necessaryClasses = array('ZipArchive'); - -/** @var array Závislosti */ -$dependency = array( - "PHP-EET" => "http://github.com/filipsedivy/PHP-EET/zipball/master/", - "WSE-PHP" => "http://github.com/robrichards/wse-php/zipball/master/", - "XMLSecLibs" => "https://github.com/robrichards/xmlseclibs/zipball/master" -); - - -// Kontrola existence tříd -foreach($necessaryClasses as $class) -{ - if(!class_exists($class)) - { - throw new Exception('This bundle needs the '.$class.' PHP extension.'); - } -} - -// Stažení závislostí -foreach($dependency as $name => $url) -{ - $dependencyPath = __DIR__.'/'.$name.'.zip'; - $install->write('Check dependence '.$name); - if(file_exists($dependencyPath)) - { - unlink($dependencyPath); - $install->write('Existing dependency '.$name.' was removed'); - } - - copy($url, $dependencyPath); - $install->write('Dependency '.$name.' has been downloaded'); - - - // V případě neexistence složky EETLib se vytvoří - if(!file_exists(__DIR__.'/EETLib') || !is_dir(__DIR__.'/EETLib')) - { - mkdir(__DIR__.'/EETLib', 0777); - $install->write('The EETLib folder was created'); - } - - - // Do této složky se rozzipují soubory - $ZipObject = new ZipArchive; - if($ZipObject->open($dependencyPath) === TRUE){ - $ZipObject->extractTo(__DIR__.'/EETLib'); - $ZipObject->close(); - $install->write('Dependency '.$name.' has been unpacked'); - }else{ - $install->write('Dependency '.$name.' can not be opened'); - } - - unlink($dependencyPath); - $install->write('The '.$name.' file has been removed'); -} - -// Vytvoření autoloaderu -ob_start(); ?> -function EETLib_Autoloader($class) -{ - // Mapování složek - $path = array( - "PHP-EET" => basename(glob(__DIR__."/filipsedivy-PHP-EET*")[0]), - "WSE-PHP" => basename(glob(__DIR__."/robrichards-wse-php*")[0]), - "XMLSecLibs" => basename(glob(__DIR__."/robrichards-xmlseclibs*")[0]) - ); - - // Mapování objektů - $map = array( - "FilipSedivy\\EET\\Certificate" => $path["PHP-EET"] . "/src/Certificate.php", - "FilipSedivy\\EET\\Dispatcher" => $path["PHP-EET"] . "/src/Dispatcher.php", - "FilipSedivy\\EET\\Receipt" => $path["PHP-EET"] . "/src/Receipt.php", - "FilipSedivy\\EET\\SoapClient" => $path["PHP-EET"] . "/src/SoapClient.php", - - "FilipSedivy\\EET\\Utils\\UUID" => $path["PHP-EET"] . "/src/Utils/UUID.php", - "FilipSedivy\\EET\\Utils\\Format" => $path["PHP-EET"] . "/src/Utils/Format.php", - - "FilipSedivy\\EET\\Exceptions\\CertificateException" => $path["PHP-EET"] . "/src/Exceptions/CertificateException.php", - "FilipSedivy\\EET\\Exceptions\\ClientException" => $path["PHP-EET"] . "/src/Exceptions/ClientException.php", - "FilipSedivy\\EET\\Exceptions\\EetException" => $path["PHP-EET"] . "/src/Exceptions/EetException.php", - "FilipSedivy\\EET\\Exceptions\\RequirementsException" => $path["PHP-EET"] . "/src/Exceptions/RequirementsException.php", - "FilipSedivy\\EET\\Exceptions\\ServerException" => $path["PHP-EET"] . "/src/Exceptions/ServerException.php", - - - "RobRichards\\XMLSecLibs\\XMLSecurityKey" => $path["XMLSecLibs"] . "/src/XMLSecurityKey.php", - "RobRichards\\XMLSecLibs\\XMLSecurityDSig" => $path["XMLSecLibs"] . "/src/XMLSecurityDSig.php", - "RobRichards\\XMLSecLibs\\XMLSecEnc" => $path["XMLSecLibs"] . "/src/XMLSecEnc.php", - - "RobRichards\\WsePhp\\WSSESoap" => $path["WSE-PHP"] . "/src/WSSESoap.php", - "RobRichards\\WsePhp\\WSASoap" => $path["WSE-PHP"] . "/src/WSASoap.php", - "RobRichards\\WsePhp\\WSSESoapServer" => $path["WSE-PHP"] . "/src/WSSESoapServer.php", - ); - - if(isset($map[$class]) && file_exists(__DIR__."/".$map[$class])) - { - require_once __DIR__."/".$map[$class]; - } -} - -spl_autoload_register("EETLib_Autoloader"); - -require_once __DIR__."/EETLib/Autoloader.php"; - -use FilipSedivy\EET\Dispatcher; -use FilipSedivy\EET\Receipt; -use FilipSedivy\EET\Utils\UUID; -use FilipSedivy\EET\Certificate; - -// Cesta k testovacímu certifikátu -$certExample = __DIR__."/EET_CA1_Playground-CZ00000019.p12"; -$certificate = new Certificate($certExample, 'eet'); - -$dispatcher = new Dispatcher($certificate); -$dispatcher->setPlaygroundService(); - -$uuid = UUID::v4(); - -$r = new Receipt; -$r->uuid_zpravy = $uuid; -$r->id_provoz = '11'; -$r->id_pokl = 'IP105'; -$r->dic_popl = 'CZ1212121218'; -$r->porad_cis = '1'; -$r->dat_trzby = new \DateTime(); -$r->celk_trzba = 500; - -echo '

---REQUEST---

'; -echo "
";
-
-try {
-
-    $dispatcher->send($r);
-
-    // Tržba byla úspěšně odeslána
-    echo sprintf("FIK: %s 
", $dispatcher->getFik()); - echo sprintf("BKP: %s
", $dispatcher->getBkp()); - -}catch(\FilipSedivy\EET\Exceptions\EetException $ex){ - // Tržba nebyla odeslána - - echo sprintf("BKP: %s
", $dispatcher->getBkp()); - echo sprintf("PKP: %s
", $dispatcher->getPkp()); - -}catch(Exception $ex){ - // Obecná chyba - var_dump($ex); - -} -write('Creating an autoloader'); -if(file_exists(__DIR__.'/EETLib/Autoloader.php')) -{ - unlink(__DIR__.'/EETLib/Autoloader.php'); -} -file_put_contents(__DIR__.'/EETLib/Autoloader.php', $startPhp . $autoloader); - -// Detekce existence ukázky -$install->write('Export samples'); -if(file_exists(__DIR__.'/EET_Example.php')) -{ - unlink(__DIR__.'/EET_Example.php'); -} -file_put_contents(__DIR__.'/EET_Example.php', $startPhp . $eetExample); - -// Zkopírování příkladu -$install->write('Export certificate'); -$phpEetFolder = glob(__DIR__.'/EETLib/filipsedivy-PHP-EET*'); -$eetFolderName = basename($phpEetFolder[0]); -$certExample = __DIR__.'/EETLib/'.$eetFolderName.'/examples/EET_CA1_Playground-CZ00000019.p12'; -if(file_exists($certExample)) -{ - if(file_exists(__DIR__.'/'.basename($certExample))) - { - unlink(__DIR__.'/'.basename($certExample)); - } - - copy($certExample, __DIR__.'/'.basename($certExample)); -}