Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial setup

  • Loading branch information...
commit 160b657360544a8f046e38ddd5d92428059382b8 0 parents
@FabriZZio FabriZZio authored
Showing with 15,222 additions and 0 deletions.
  1. +6 −0 .buildpath
  2. +22 −0 .project
  3. +5 −0 .settings/org.eclipse.php.core.prefs
  4. +9 −0 autoload.php
  5. +108 −0 lib/Ogone/OgoneConfirmationRequest.php
  6. +23 −0 lib/Ogone/ShaComposer/.svn/all-wcprops
  7. +130 −0 lib/Ogone/ShaComposer/.svn/entries
  8. +27 −0 lib/Ogone/ShaComposer/.svn/text-base/AbstractShaComposer.php.svn-base
  9. +28 −0 lib/Ogone/ShaComposer/.svn/text-base/AllParametersShaComposer.php.svn-base
  10. +28 −0 lib/Ogone/ShaComposer/.svn/text-base/MainParametersShaComposer.php.svn-base
  11. +27 −0 lib/Ogone/ShaComposer/AbstractShaComposer.php
  12. +28 −0 lib/Ogone/ShaComposer/AllParametersShaComposer.php
  13. +28 −0 lib/Ogone/ShaComposer/MainParametersShaComposer.php
  14. +38 −0 phpunit.xml.dist
  15. +27 −0 phpunit_.xml
  16. +82 −0 tests/Ogone/Tests/OgoneConfirmationRequestTest.php
  17. +17 −0 tests/Ogone/Tests/ShaComposer/.svn/all-wcprops
  18. +96 −0 tests/Ogone/Tests/ShaComposer/.svn/entries
  19. +37 −0 tests/Ogone/Tests/ShaComposer/.svn/text-base/AllParametersShaComposerTest.php.svn-base
  20. +41 −0 tests/Ogone/Tests/ShaComposer/.svn/text-base/MainParametersShaComposerTest.php.svn-base
  21. +37 −0 tests/Ogone/Tests/ShaComposer/AllParametersShaComposerTest.php
  22. +41 −0 tests/Ogone/Tests/ShaComposer/MainParametersShaComposerTest.php
  23. +7 −0 tests/TestCase.php
  24. +5 −0 tests/bootstrap.php
  25. +5 −0 vendors/Symfony/.svn/all-wcprops
  26. +31 −0 vendors/Symfony/.svn/entries
  27. +5 −0 vendors/Symfony/Component/.svn/all-wcprops
  28. +37 −0 vendors/Symfony/Component/.svn/entries
  29. +35 −0 vendors/Symfony/Component/ClassLoader/.svn/all-wcprops
  30. +198 −0 vendors/Symfony/Component/ClassLoader/.svn/entries
  31. +47 −0 vendors/Symfony/Component/ClassLoader/.svn/text-base/ApcUniversalClassLoader.php.svn-base
  32. +220 −0 vendors/Symfony/Component/ClassLoader/.svn/text-base/ClassCollectionLoader.php.svn-base
  33. +19 −0 vendors/Symfony/Component/ClassLoader/.svn/text-base/LICENSE.svn-base
  34. +82 −0 vendors/Symfony/Component/ClassLoader/.svn/text-base/MapFileClassLoader.php.svn-base
  35. +261 −0 vendors/Symfony/Component/ClassLoader/.svn/text-base/UniversalClassLoader.php.svn-base
  36. +47 −0 vendors/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
  37. +220 −0 vendors/Symfony/Component/ClassLoader/ClassCollectionLoader.php
  38. +19 −0 vendors/Symfony/Component/ClassLoader/LICENSE
  39. +82 −0 vendors/Symfony/Component/ClassLoader/MapFileClassLoader.php
  40. +261 −0 vendors/Symfony/Component/ClassLoader/UniversalClassLoader.php
  41. +23 −0 vendors/Symfony/Component/Console/.svn/all-wcprops
  42. +148 −0 vendors/Symfony/Component/Console/.svn/entries
  43. +809 −0 vendors/Symfony/Component/Console/.svn/text-base/Application.php.svn-base
  44. +19 −0 vendors/Symfony/Component/Console/.svn/text-base/LICENSE.svn-base
  45. +136 −0 vendors/Symfony/Component/Console/.svn/text-base/Shell.php.svn-base
  46. +809 −0 vendors/Symfony/Component/Console/Application.php
  47. +23 −0 vendors/Symfony/Component/Console/Command/.svn/all-wcprops
  48. +130 −0 vendors/Symfony/Component/Console/Command/.svn/entries
  49. +576 −0 vendors/Symfony/Component/Console/Command/.svn/text-base/Command.php.svn-base
  50. +82 −0 vendors/Symfony/Component/Console/Command/.svn/text-base/HelpCommand.php.svn-base
  51. +67 −0 vendors/Symfony/Component/Console/Command/.svn/text-base/ListCommand.php.svn-base
  52. +576 −0 vendors/Symfony/Component/Console/Command/Command.php
  53. +82 −0 vendors/Symfony/Component/Console/Command/HelpCommand.php
  54. +67 −0 vendors/Symfony/Component/Console/Command/ListCommand.php
  55. +29 −0 vendors/Symfony/Component/Console/Formatter/.svn/all-wcprops
  56. +164 −0 vendors/Symfony/Component/Console/Formatter/.svn/entries
  57. +243 −0 vendors/Symfony/Component/Console/Formatter/.svn/text-base/OutputFormatter.php.svn-base
  58. +83 −0 vendors/Symfony/Component/Console/Formatter/.svn/text-base/OutputFormatterInterface.php.svn-base
  59. +217 −0 vendors/Symfony/Component/Console/Formatter/.svn/text-base/OutputFormatterStyle.php.svn-base
  60. +77 −0 vendors/Symfony/Component/Console/Formatter/.svn/text-base/OutputFormatterStyleInterface.php.svn-base
  61. +243 −0 vendors/Symfony/Component/Console/Formatter/OutputFormatter.php
  62. +83 −0 vendors/Symfony/Component/Console/Formatter/OutputFormatterInterface.php
  63. +217 −0 vendors/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
  64. +77 −0 vendors/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
  65. +35 −0 vendors/Symfony/Component/Console/Helper/.svn/all-wcprops
  66. +198 −0 vendors/Symfony/Component/Console/Helper/.svn/entries
  67. +110 −0 vendors/Symfony/Component/Console/Helper/.svn/text-base/DialogHelper.php.svn-base
  68. +91 −0 vendors/Symfony/Component/Console/Helper/.svn/text-base/FormatterHelper.php.svn-base
  69. +42 −0 vendors/Symfony/Component/Console/Helper/.svn/text-base/Helper.php.svn-base
  70. +49 −0 vendors/Symfony/Component/Console/Helper/.svn/text-base/HelperInterface.php.svn-base
  71. +102 −0 vendors/Symfony/Component/Console/Helper/.svn/text-base/HelperSet.php.svn-base
  72. +110 −0 vendors/Symfony/Component/Console/Helper/DialogHelper.php
  73. +91 −0 vendors/Symfony/Component/Console/Helper/FormatterHelper.php
  74. +42 −0 vendors/Symfony/Component/Console/Helper/Helper.php
  75. +49 −0 vendors/Symfony/Component/Console/Helper/HelperInterface.php
  76. +102 −0 vendors/Symfony/Component/Console/Helper/HelperSet.php
  77. +53 −0 vendors/Symfony/Component/Console/Input/.svn/all-wcprops
  78. +300 −0 vendors/Symfony/Component/Console/Input/.svn/entries
  79. +307 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/ArgvInput.php.svn-base
  80. +194 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/ArrayInput.php.svn-base
  81. +211 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/Input.php.svn-base
  82. +132 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/InputArgument.php.svn-base
  83. +508 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/InputDefinition.php.svn-base
  84. +103 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/InputInterface.php.svn-base
  85. +182 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/InputOption.php.svn-base
  86. +78 −0 vendors/Symfony/Component/Console/Input/.svn/text-base/StringInput.php.svn-base
  87. +307 −0 vendors/Symfony/Component/Console/Input/ArgvInput.php
  88. +194 −0 vendors/Symfony/Component/Console/Input/ArrayInput.php
  89. +211 −0 vendors/Symfony/Component/Console/Input/Input.php
  90. +132 −0 vendors/Symfony/Component/Console/Input/InputArgument.php
  91. +508 −0 vendors/Symfony/Component/Console/Input/InputDefinition.php
  92. +103 −0 vendors/Symfony/Component/Console/Input/InputInterface.php
  93. +182 −0 vendors/Symfony/Component/Console/Input/InputOption.php
  94. +78 −0 vendors/Symfony/Component/Console/Input/StringInput.php
  95. +19 −0 vendors/Symfony/Component/Console/LICENSE
  96. +35 −0 vendors/Symfony/Component/Console/Output/.svn/all-wcprops
  97. +198 −0 vendors/Symfony/Component/Console/Output/.svn/entries
  98. +46 −0 vendors/Symfony/Component/Console/Output/.svn/text-base/ConsoleOutput.php.svn-base
  99. +34 −0 vendors/Symfony/Component/Console/Output/.svn/text-base/NullOutput.php.svn-base
  100. +186 −0 vendors/Symfony/Component/Console/Output/.svn/text-base/Output.php.svn-base
  101. +107 −0 vendors/Symfony/Component/Console/Output/.svn/text-base/OutputInterface.php.svn-base
  102. +112 −0 vendors/Symfony/Component/Console/Output/.svn/text-base/StreamOutput.php.svn-base
  103. +46 −0 vendors/Symfony/Component/Console/Output/ConsoleOutput.php
  104. +34 −0 vendors/Symfony/Component/Console/Output/NullOutput.php
  105. +186 −0 vendors/Symfony/Component/Console/Output/Output.php
  106. +107 −0 vendors/Symfony/Component/Console/Output/OutputInterface.php
  107. +112 −0 vendors/Symfony/Component/Console/Output/StreamOutput.php
  108. +136 −0 vendors/Symfony/Component/Console/Shell.php
  109. +17 −0 vendors/Symfony/Component/Console/Tester/.svn/all-wcprops
  110. +96 −0 vendors/Symfony/Component/Console/Tester/.svn/entries
  111. +100 −0 vendors/Symfony/Component/Console/Tester/.svn/text-base/ApplicationTester.php.svn-base
  112. +100 −0 vendors/Symfony/Component/Console/Tester/.svn/text-base/CommandTester.php.svn-base
  113. +100 −0 vendors/Symfony/Component/Console/Tester/ApplicationTester.php
  114. +100 −0 vendors/Symfony/Component/Console/Tester/CommandTester.php
  115. +35 −0 vendors/Symfony/Component/EventDispatcher/.svn/all-wcprops
  116. +198 −0 vendors/Symfony/Component/EventDispatcher/.svn/entries
  117. +70 −0 vendors/Symfony/Component/EventDispatcher/.svn/text-base/Event.php.svn-base
  118. +200 −0 vendors/Symfony/Component/EventDispatcher/.svn/text-base/EventDispatcher.php.svn-base
  119. +100 −0 vendors/Symfony/Component/EventDispatcher/.svn/text-base/EventDispatcherInterface.php.svn-base
  120. +45 −0 vendors/Symfony/Component/EventDispatcher/.svn/text-base/EventSubscriberInterface.php.svn-base
  121. +19 −0 vendors/Symfony/Component/EventDispatcher/.svn/text-base/LICENSE.svn-base
  122. +70 −0 vendors/Symfony/Component/EventDispatcher/Event.php
  123. +200 −0 vendors/Symfony/Component/EventDispatcher/EventDispatcher.php
  124. +100 −0 vendors/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
  125. +45 −0 vendors/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
  126. +19 −0 vendors/Symfony/Component/EventDispatcher/LICENSE
6 .buildpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<buildpath>
+ <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
+ <buildpathentry external="true" kind="lib" path="C:/php/apache/php-5.3.3-Win32-VC6-x86/PEAR"/>
+ <buildpathentry kind="src" path=""/>
+</buildpath>
22 .project
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>marlon-ogone</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.dltk.core.scriptbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.php.core.PHPNature</nature>
+ </natures>
+</projectDescription>
5 .settings/org.eclipse.php.core.prefs
@@ -0,0 +1,5 @@
+#Wed Jul 06 11:44:40 CEST 2011
+eclipse.preferences.version=1
+include_path=0;/marlon-ogone\u00051;C\:/php/apache/php-5.3.3-Win32-VC6-x86/PEAR
+phpVersion=php5.3
+use_asp_tags_as_php=false
9 autoload.php
@@ -0,0 +1,9 @@
+<?php
+use Symfony\Component\ClassLoader\UniversalClassLoader;
+require_once __DIR__ . '/vendors/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+
+$loader = new UniversalClassLoader;
+$loader->registerNamespaces(array(
+ 'Ogone' => __DIR__ . '/lib/'
+));
+$loader->register();
108 lib/Ogone/OgoneConfirmationRequest.php
@@ -0,0 +1,108 @@
+<?php
+namespace Ogone;
+
+use Ogone\ShaComposer\AbstractShaComposer;
+
+class OgoneConfirmationRequest
+{
+ /** @var string */
+ const SHASIGN_FIELD = 'shasign';
+
+ /**
+ * Available Ogone parameters
+ * @var array
+ */
+ private $ogoneParameters = array('aavaddress', 'aavcheck', 'aavzip', 'acceptance', 'alias', 'amount', 'bin', 'brand', 'cardno', 'cccty', 'cn',
+ 'complus', 'creation_status', 'currency', 'cvccheck', 'dcc_commpercentage', 'dcc_convamount', 'dcc_convccy', 'dcc_exchrate', 'dcc_exchratesource',
+ 'dcc_exchratets', 'dcc_indicator', 'dcc_marginpercentage', 'dcc_validhours', 'digestcardno', 'eci', 'ed', 'enccardno', 'ip', 'ipcty',
+ 'nbremailusage','nbripusage', 'nbripusage_alltx', 'nbrusage', 'ncerror', 'orderid', 'payid', 'pm', 'sco_category', 'scoring', 'status',
+ 'subscription_id', 'trxdate','vc');
+
+ /**
+ * @var array
+ */
+ private $requestParameters;
+
+ /**
+ * @var string
+ */
+ private $shaSign;
+
+ /**
+ * @var ShaComposer
+ */
+ private $shaComposer;
+
+ /**
+ * @param array $request Typically $_REQUEST
+ * @param AbstractShaComposer $shaComposer
+ * @throws \InvalidArgumentException
+ */
+ public function __construct($request, AbstractShaComposer $shaComposer)
+ {
+ if(!is_array($request)) {
+ throw new \InvalidArgumentException('Request parameter array expected.');
+ }
+
+ // set SHA composer
+ $this->shaComposer = $shaComposer;
+
+ // use lowercase internally
+ $request = array_change_key_case($request, CASE_LOWER);
+
+ // set sha sign
+ $this->shaSign = $this->setShaSign($request);
+
+ // filter request for Ogone parameters
+ $this->requestParameters = $this->filterRequestParameters($request);
+ }
+
+ /**
+ * Filter Ogone request parameters
+ * @param array $requestParameters
+ */
+ protected function filterRequestParameters($requestParameters)
+ {
+ // filter request for Ogone parameters
+ return array_intersect_key($requestParameters, array_flip($this->ogoneParameters));
+ }
+
+ /**
+ * Set Ogone SHA sign
+ * @param array $request
+ * @throws \InvalidArgumentException
+ */
+ protected function setShaSign($request)
+ {
+ if(!array_key_exists(self::SHASIGN_FIELD, $request) || $request[self::SHASIGN_FIELD] == '') {
+ throw new \InvalidArgumentException('SHASIGN parameter not present in request.');
+ }
+ return $request[self::SHASIGN_FIELD];
+ }
+
+ /**
+ * Checks if the request is valid
+ * @return bool
+ */
+ public function isValid()
+ {
+ return $this->shaComposer->compose($this->requestParameters) == $this->shaSign;
+ }
+
+ /**
+ * Retrieves a request parameter
+ * @param string $param
+ * @throws \InvalidArgumentException
+ */
+ public function getParam($param)
+ {
+ // always use lowercase internally
+ $param = strtolower($param);
+
+ if(!array_key_exists($param, $this->requestParameters)) {
+ throw new \InvalidArgumentException('Parameter ' . $param . ' does not exist.');
+ }
+
+ return $this->requestParameters[$param];
+ }
+}
23 lib/Ogone/ShaComposer/.svn/all-wcprops
@@ -0,0 +1,23 @@
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/m4domain/!svn/ver/292/trunk/lib/M4/Ogone/ShaComposer
+END
+MainParametersShaComposer.php
+K 25
+svn:wc:ra_dav:version-url
+V 87
+/svn/m4domain/!svn/ver/297/trunk/lib/M4/Ogone/ShaComposer/MainParametersShaComposer.php
+END
+AllParametersShaComposer.php
+K 25
+svn:wc:ra_dav:version-url
+V 86
+/svn/m4domain/!svn/ver/297/trunk/lib/M4/Ogone/ShaComposer/AllParametersShaComposer.php
+END
+AbstractShaComposer.php
+K 25
+svn:wc:ra_dav:version-url
+V 81
+/svn/m4domain/!svn/ver/296/trunk/lib/M4/Ogone/ShaComposer/AbstractShaComposer.php
+END
130 lib/Ogone/ShaComposer/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+292
+http://svn.marlon.be:8080/svn/m4domain/trunk/lib/M4/Ogone/ShaComposer
+http://svn.marlon.be:8080/svn/m4domain
+
+
+
+2011-07-06T07:49:00.724750Z
+292
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+c560fe6f-7ae4-fb44-9145-54ed49f5522c
+
+MainParametersShaComposer.php
+file
+297
+
+
+
+2011-07-06T09:33:56.083538Z
+1397bd275edec1899ba931266f91c4a4
+2011-07-06T09:32:37.521625Z
+297
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+751
+
+AllParametersShaComposer.php
+file
+297
+
+
+
+2011-07-06T09:34:26.556880Z
+525dce08bc2b3adc77da9096cab3bee5
+2011-07-06T09:32:37.521625Z
+297
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+649
+
+AbstractShaComposer.php
+file
+296
+
+
+
+2011-07-06T08:59:19.429290Z
+4f1ed0c9797095f948f4f5ff069da261
+2011-07-06T09:24:07.240375Z
+296
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+460
+
27 lib/Ogone/ShaComposer/.svn/text-base/AbstractShaComposer.php.svn-base
@@ -0,0 +1,27 @@
+<?php
+namespace M4\Ogone\ShaComposer;
+
+/**
+ * Base class for SHA Composers
+ */
+abstract class AbstractShaComposer
+{
+ /**
+ * @var string
+ */
+ protected $passphrase;
+
+ /**
+ * @param string $passphrase
+ */
+ public function __construct($passphrase)
+ {
+ $this->passphrase = (string) $passphrase;
+ }
+
+ /**
+ * Compose SHA string based on Ogone request parameters
+ * @param array $requestParameters
+ */
+ public abstract function compose($requestParameters);
+}
28 lib/Ogone/ShaComposer/.svn/text-base/AllParametersShaComposer.php.svn-base
@@ -0,0 +1,28 @@
+<?php
+namespace M4\Ogone\ShaComposer;
+
+/**
+ * SHA string composition the "new way", using all parameters in the request
+ */
+class AllParametersShaComposer extends AbstractShaComposer
+{
+ public function compose($requestParameters)
+ {
+ // use lowercase internally
+ $requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
+
+ // sort parameters
+ ksort($requestParameters);
+
+ // compose SHA string
+ $shaString = '';
+ foreach($requestParameters as $key => $value)
+ {
+ if($value !== null) {
+ $shaString .= strtoupper($key) . '=' . trim($value) . $this->passphrase;
+ }
+ }
+
+ return strtoupper(sha1($shaString));
+ }
+}
28 lib/Ogone/ShaComposer/.svn/text-base/MainParametersShaComposer.php.svn-base
@@ -0,0 +1,28 @@
+<?php
+namespace M4\Ogone\ShaComposer;
+
+/**
+ * SHA string composition the "old way", using only the "main" parameters
+ */
+class MainParametersShaComposer extends AbstractShaComposer
+{
+ public function compose($requestParameters)
+ {
+ // use lowercase internally
+ $requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
+
+ return strtoupper(sha1(implode('', array(
+ $requestParameters['orderid'],
+ $requestParameters['currency'],
+ $requestParameters['amount'],
+ $requestParameters['pm'],
+ $requestParameters['acceptance'],
+ $requestParameters['status'],
+ $requestParameters['cardno'],
+ $requestParameters['payid'],
+ $requestParameters['ncerror'],
+ $requestParameters['brand'],
+ $this->passphrase
+ ))));
+ }
+}
27 lib/Ogone/ShaComposer/AbstractShaComposer.php
@@ -0,0 +1,27 @@
+<?php
+namespace Ogone\ShaComposer;
+
+/**
+ * Base class for SHA Composers
+ */
+abstract class AbstractShaComposer

should be an interface ShaComposer

@FabriZZio Owner

Every ShaComposer needs a Passphrase, that's the reason I used an abstract class. When using an interface, the passphrase releated code (attribute declaration and constructor code) will be duplicated.

You could still leave the AbstractShaComposer, but use the interface everywhere you need typehinting. ("Program to an interface, not an implementation"). Theoretically, we might have ShaComposers that do no extend AbstractShaComposer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+{
+ /**
+ * @var string
+ */
+ protected $passphrase;
+
+ /**
+ * @param string $passphrase
+ */
+ public function __construct($passphrase)
+ {
+ $this->passphrase = (string) $passphrase;

make this a PassPhrase VO with built in validation

@FabriZZio Owner

Since the passphrase can be anything, I don't think this is necessary. Do you see any other reasons why it should be a VO?

It has to be a string, and we can't do typehinting on strings. It would also make the api more intentional and communicative. We don't want 'anything', we want a PassPhrase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+
+ /**
+ * Compose SHA string based on Ogone request parameters
+ * @param array $requestParameters
+ */
+ public abstract function compose($requestParameters);
+}
28 lib/Ogone/ShaComposer/AllParametersShaComposer.php
@@ -0,0 +1,28 @@
+<?php
+namespace Ogone\ShaComposer;
+
+/**
+ * SHA string composition the "new way", using all parameters in the request
+ */
+class AllParametersShaComposer extends AbstractShaComposer
+{
+ public function compose($requestParameters)
+ {
+ // use lowercase internally
+ $requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
+
+ // sort parameters
+ ksort($requestParameters);
+
+ // compose SHA string
+ $shaString = '';
+ foreach($requestParameters as $key => $value)
+ {
+ if($value !== null) {
+ $shaString .= strtoupper($key) . '=' . trim($value) . $this->passphrase;
+ }
+ }
+
+ return strtoupper(sha1($shaString));
+ }
+}
28 lib/Ogone/ShaComposer/MainParametersShaComposer.php
@@ -0,0 +1,28 @@
+<?php
+namespace Ogone\ShaComposer;
+
+/**
+ * SHA string composition the "old way", using only the "main" parameters
+ */
+class MainParametersShaComposer extends AbstractShaComposer
+{
+ public function compose($requestParameters)
+ {
+ // use lowercase internally
+ $requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
+
+ return strtoupper(sha1(implode('', array(
+ $requestParameters['orderid'],
+ $requestParameters['currency'],
+ $requestParameters['amount'],
+ $requestParameters['pm'],
+ $requestParameters['acceptance'],
+ $requestParameters['status'],
+ $requestParameters['cardno'],
+ $requestParameters['payid'],
+ $requestParameters['ncerror'],
+ $requestParameters['brand'],
+ $this->passphrase
+ ))));
+ }
+}
38 phpunit.xml.dist
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ failOnError="false"
+ syntaxCheck="false"
+ bootstrap="./tests/bootstrap.php"
+>
+
+ <logging>
+ <log type="coverage-html" target="build/coverage" title="Ogone"
+ charset="UTF-8" yui="true" highlight="true" lowUpperBound="35"
+ highLowerBound="70" />
+ <log type="coverage-clover" target="build/logs/clover.xml" />
+ <log type="junit" target="build/logs/junit.xml"
+ logIncompleteSkipped="false" />
+ <log type="testdox-html" target="build/logs/testdox/index.html"/>
+ </logging>
+
+ <testsuites>
+ <testsuite name="Ogone">
+ <directory>tests/Ogone/Tests/</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <whitelist addUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">lib</directory>
+ </whitelist>
+ </filter>
+</phpunit>
27 phpunit_.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="./tests/bootstrap.php"
+>
+
+ <testsuites>
+ <testsuite name="Ogone">
+ <directory>tests/Ogone/Tests/</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <whitelist addUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">lib</directory>
+ </whitelist>
+ </filter>
+</phpunit>
82 tests/Ogone/Tests/OgoneConfirmationRequestTest.php
@@ -0,0 +1,82 @@
+<?php
+namespace Ogone\Tests;
+
+use Ogone\ShaComposer\AbstractShaComposer;
+
+use Ogone\ShaComposer\MainParametersShaComposer;
+use Ogone\ShaComposer\AllParametersShaComposer;
+use Ogone\OgoneConfirmationRequest;
+
+class OgoneConfirmationRequestTest extends \TestCase
+{
+ const SHASTRING = 'foo';
+
+ /** @test */
+ public function CanBeVerified()
+ {
+ $confirmationRequest = new OgoneConfirmationRequest($this->setupRequest(), new FakeShaComposer());
+ $this->assertTrue($confirmationRequest->isValid());
+ }
+
+ /**
+ * @test
+ * @expectedException InvalidArgumentException
+ */
+ public function CannotExistWithoutShaSign()
+ {
+ $confirmationRequest = new OgoneConfirmationRequest(array(), new FakeShaComposer());
+ }
+
+ /** @test */
+ public function ParametersCanBeRetrieved()
+ {
+ $request = $this->setupRequest();
+
+ $confirmationRequest = new OgoneConfirmationRequest($request, new FakeShaComposer());
+ $this->assertEquals($request['orderID'], $confirmationRequest->getParam('orderid'));
+ }
+
+ /**
+ * @test
+ * @expectedException InvalidArgumentException
+ */
+ public function RequestIsFilteredFromNonOgoneParameters()
+ {
+ $confirmationRequest = new OgoneConfirmationRequest($this->setupRequest(), new FakeShaComposer());
+ $confirmationRequest->getParam('unknown_param');
+ }
+
+ /**
+ * @test
+ * @expectedException InvalidArgumentException
+ */
+ public function OnlyAcceptsARequestArray()
+ {
+ $confirmationRequest = new OgoneConfirmationRequest(new \stdClass(), new FakeShaComposer());
+ }
+
+ /**
+ * Helper method to setup a request array
+ */
+ private function setupRequest()
+ {
+ return array(
+ 'orderID' => '123',
+ 'SHASIGN' => self::SHASTRING,
+ 'UNKNOWN_PARAM' => false /* unkown parameter, should be filtered out */
+ );
+ }
+}
+
+/**
+ * Fake SHA Composer to decouple test from actual SHA composers
+ */
+class FakeShaComposer extends AbstractShaComposer
+{
+ public function __construct(){}
+
+ public function compose($requestParameters)
+ {
+ return OgoneConfirmationRequestTest::SHASTRING;
+ }
+}
17 tests/Ogone/Tests/ShaComposer/.svn/all-wcprops
@@ -0,0 +1,17 @@
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/m4domain/!svn/ver/296/trunk/tests/M4/Tests/Ogone/ShaComposer
+END
+MainParametersShaComposerTest.php
+K 25
+svn:wc:ra_dav:version-url
+V 99
+/svn/m4domain/!svn/ver/296/trunk/tests/M4/Tests/Ogone/ShaComposer/MainParametersShaComposerTest.php
+END
+AllParametersShaComposerTest.php
+K 25
+svn:wc:ra_dav:version-url
+V 98
+/svn/m4domain/!svn/ver/296/trunk/tests/M4/Tests/Ogone/ShaComposer/AllParametersShaComposerTest.php
+END
96 tests/Ogone/Tests/ShaComposer/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+296
+http://svn.marlon.be:8080/svn/m4domain/trunk/tests/M4/Tests/Ogone/ShaComposer
+http://svn.marlon.be:8080/svn/m4domain
+
+
+
+2011-07-06T09:24:07.240375Z
+296
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+c560fe6f-7ae4-fb44-9145-54ed49f5522c
+
+MainParametersShaComposerTest.php
+file
+
+
+
+
+2011-07-06T09:03:41.348164Z
+42abf9712e0d292717e2241ed06f110b
+2011-07-06T09:24:07.240375Z
+296
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+925
+
+AllParametersShaComposerTest.php
+file
+
+
+
+
+2011-07-06T08:58:47.657437Z
+ec927d2c93f85f54e1378e3aa786cfde
+2011-07-06T09:24:07.240375Z
+296
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+815
+
37 tests/Ogone/Tests/ShaComposer/.svn/text-base/AllParametersShaComposerTest.php.svn-base
@@ -0,0 +1,37 @@
+<?php
+namespace M4\Tests\Ogone\ShaComposer;
+
+use M4\Ogone\ShaComposer\AllParametersShaComposer;
+
+class AllParametersShaComposerTest extends \TestCase
+{
+ const PASSPHRASE = 'Mysecretsig1875!?';
+ const SHASTRING = 'B209960D5703DD1047F95A0F97655FFE5AC8BD52';
+
+ /** @test */
+ public function ShaStringCanBeComposed()
+ {
+ $request = $this->setupRequest();
+
+ $composer = new AllParametersShaComposer(self::PASSPHRASE);
+ $shaString = $composer->compose($request);
+
+ $this->assertEquals(self::SHASTRING, $shaString);
+ }
+
+ private function setupRequest()
+ {
+ return array(
+ 'currency' => 'EUR',
+ 'ACCEPTANCE' => 1234,
+ 'amount' => 15,
+ 'BRAND' => 'VISA',
+ 'CARDNO' => 'xxxxxxxxxxxx1111',
+ 'NCERROR' => 0,
+ 'PAYID' => 32100123,
+ 'PM' => 'CreditCard',
+ 'STATUS' => 9,
+ 'orderID' => 12
+ );
+ }
+}
41 tests/Ogone/Tests/ShaComposer/.svn/text-base/MainParametersShaComposerTest.php.svn-base
@@ -0,0 +1,41 @@
+<?php
+namespace M4\Tests\Ogone\ShaComposer;
+
+use M4\Ogone\ShaComposer\MainParametersShaComposer;
+
+class MainParametersShaComposerTest extends \TestCase
+{
+ const PASSPHRASE = 'm0b1l4sha!';
+ const SHASTRING = 'C17C595E20FD2BAC4AFFA68E677DA34F43023249';
+
+ /** @test */
+ public function ShaStringCanBeComposed()
+ {
+ $request = $this->setupRequest();
+
+ $composer = new MainParametersShaComposer(self::PASSPHRASE);
+ $shaString = $composer->compose($request);
+
+ $this->assertEquals(self::SHASTRING, $shaString);
+ }
+
+ private function setupRequest()
+ {
+ return array(
+ 'ACCEPTANCE' => 'test123',
+ 'AMOUNT' => '19.08',
+ 'BRAND' => 'VISA',
+ 'CARDNO' => 'XXXXXXXXXXXX1111',
+ 'CN' => 'Marlon',
+ 'CURRENCY' => 'EUR',
+ 'ED' => '0113',
+ 'IP' => '81.82.214.142',
+ 'NCERROR' => 0,
+ 'ORDERID' => 2101947639,
+ 'PAYID' => 10673859,
+ 'PM' => 'CreditCard',
+ 'STATUS' => 5,
+ 'TRXDATE' => '07/05/11'
+ );
+ }
+}
37 tests/Ogone/Tests/ShaComposer/AllParametersShaComposerTest.php
@@ -0,0 +1,37 @@
+<?php
+namespace Ogone\Tests\ShaComposer;
+
+use Ogone\ShaComposer\AllParametersShaComposer;
+
+class AllParametersShaComposerTest extends \TestCase
+{
+ const PASSPHRASE = 'Mysecretsig1875!?';
+ const SHASTRING = 'B209960D5703DD1047F95A0F97655FFE5AC8BD52';
+
+ /** @test */
+ public function ShaStringCanBeComposed()
+ {
+ $request = $this->setupRequest();
+
+ $composer = new AllParametersShaComposer(self::PASSPHRASE);
+ $shaString = $composer->compose($request);
+
+ $this->assertEquals(self::SHASTRING, $shaString);
+ }
+
+ private function setupRequest()
+ {
+ return array(
+ 'currency' => 'EUR',
+ 'ACCEPTANCE' => 1234,
+ 'amount' => 15,
+ 'BRAND' => 'VISA',
+ 'CARDNO' => 'xxxxxxxxxxxx1111',
+ 'NCERROR' => 0,
+ 'PAYID' => 32100123,
+ 'PM' => 'CreditCard',
+ 'STATUS' => 9,
+ 'orderID' => 12
+ );
+ }
+}
41 tests/Ogone/Tests/ShaComposer/MainParametersShaComposerTest.php
@@ -0,0 +1,41 @@
+<?php
+namespace Ogone\Tests\ShaComposer;
+
+use Ogone\ShaComposer\MainParametersShaComposer;
+
+class MainParametersShaComposerTest extends \TestCase
+{
+ const PASSPHRASE = 'm0b1l4sha!';
+ const SHASTRING = 'C17C595E20FD2BAC4AFFA68E677DA34F43023249';
+
+ /** @test */
+ public function ShaStringCanBeComposed()
+ {
+ $request = $this->setupRequest();
+
+ $composer = new MainParametersShaComposer(self::PASSPHRASE);
+ $shaString = $composer->compose($request);
+
+ $this->assertEquals(self::SHASTRING, $shaString);
+ }
+
+ private function setupRequest()
+ {
+ return array(
+ 'ACCEPTANCE' => 'test123',
+ 'AMOUNT' => '19.08',
+ 'BRAND' => 'VISA',
+ 'CARDNO' => 'XXXXXXXXXXXX1111',
+ 'CN' => 'Marlon',
+ 'CURRENCY' => 'EUR',
+ 'ED' => '0113',
+ 'IP' => '81.82.214.142',
+ 'NCERROR' => 0,
+ 'ORDERID' => 2101947639,
+ 'PAYID' => 10673859,
+ 'PM' => 'CreditCard',
+ 'STATUS' => 5,
+ 'TRXDATE' => '07/05/11'
+ );
+ }
+}
7 tests/TestCase.php
@@ -0,0 +1,7 @@
+<?php
+require_once 'PHPUnit/Framework/TestCase.php';
+
+abstract class TestCase extends PHPUnit_Framework_TestCase
+{
+
+}
5 tests/bootstrap.php
@@ -0,0 +1,5 @@
+<?php
+error_reporting(-1);
+
+require_once __DIR__.'/../autoload.php';
+require_once __DIR__.'/TestCase.php';
5 vendors/Symfony/.svn/all-wcprops
@@ -0,0 +1,5 @@
+K 25
+svn:wc:ra_dav:version-url
+V 47
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony
+END
31 vendors/Symfony/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+287
+http://svn.marlon.be:8080/svn/m4domain/trunk/vendors/Symfony
+http://svn.marlon.be:8080/svn/m4domain
+
+
+
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+c560fe6f-7ae4-fb44-9145-54ed49f5522c
+
+Component
+dir
+
5 vendors/Symfony/Component/.svn/all-wcprops
@@ -0,0 +1,5 @@
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component
+END
37 vendors/Symfony/Component/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+287
+http://svn.marlon.be:8080/svn/m4domain/trunk/vendors/Symfony/Component
+http://svn.marlon.be:8080/svn/m4domain
+
+
+
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+c560fe6f-7ae4-fb44-9145-54ed49f5522c
+
+Console
+dir
+
+EventDispatcher
+dir
+
+ClassLoader
+dir
+
35 vendors/Symfony/Component/ClassLoader/.svn/all-wcprops
@@ -0,0 +1,35 @@
+K 25
+svn:wc:ra_dav:version-url
+V 69
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader
+END
+ApcUniversalClassLoader.php
+K 25
+svn:wc:ra_dav:version-url
+V 97
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
+END
+MapFileClassLoader.php
+K 25
+svn:wc:ra_dav:version-url
+V 92
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader/MapFileClassLoader.php
+END
+LICENSE
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader/LICENSE
+END
+UniversalClassLoader.php
+K 25
+svn:wc:ra_dav:version-url
+V 94
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader/UniversalClassLoader.php
+END
+ClassCollectionLoader.php
+K 25
+svn:wc:ra_dav:version-url
+V 95
+/svn/m4domain/!svn/ver/76/trunk/vendors/Symfony/Component/ClassLoader/ClassCollectionLoader.php
+END
198 vendors/Symfony/Component/ClassLoader/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+287
+http://svn.marlon.be:8080/svn/m4domain/trunk/vendors/Symfony/Component/ClassLoader
+http://svn.marlon.be:8080/svn/m4domain
+
+
+
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+c560fe6f-7ae4-fb44-9145-54ed49f5522c
+
+ApcUniversalClassLoader.php
+file
+
+
+
+
+2011-06-08T15:10:55.491738Z
+d555c45a84ccc645e8634bc3dfda4305
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+994
+
+MapFileClassLoader.php
+file
+
+
+
+
+2011-06-08T15:10:55.494738Z
+53367273e1831a5a8da183fc2fedcb63
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1726
+
+LICENSE
+file
+
+
+
+
+2011-06-08T15:10:55.520743Z
+df54d83d7f7efc17ce284f8270ad641d
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1065
+
+UniversalClassLoader.php
+file
+
+
+
+
+2011-06-08T15:10:55.555750Z
+7f62c1205dce780b220ea55f36bf8456
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7577
+
+ClassCollectionLoader.php
+file
+
+
+
+
+2011-06-08T15:10:55.560751Z
+ae0640225618565a29df3b1788d44e50
+2011-05-31T19:07:27.248875Z
+76
+dieter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6773
+
47 vendors/Symfony/Component/ClassLoader/.svn/text-base/ApcUniversalClassLoader.php.svn-base
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+require_once __DIR__.'/UniversalClassLoader.php';
+
+/**
+ * Class loader utilizing APC to remember where files are.
+ *
+ * @author Kris Wallsmith <kris.wallsmith@symfony.com>
+ *
+ * @api
+ */
+class ApcUniversalClassLoader extends UniversalClassLoader
+{
+ private $prefix;
+
+ /**
+ * Constructor.
+ *
+ * @param string $prefix A prefix to create a namespace in APC
+ *
+ * @api
+ */
+ public function __construct($prefix)
+ {
+ $this->prefix = $prefix;
+ }
+
+ public function findFile($class)
+ {
+ if (false === $file = apc_fetch($this->prefix.$class)) {
+ apc_store($this->prefix.$class, $file = parent::findFile($class));
+ }
+
+ return $file;
+ }
+}
220 vendors/Symfony/Component/ClassLoader/.svn/text-base/ClassCollectionLoader.php.svn-base
@@ -0,0 +1,220 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+/**
+ * ClassCollectionLoader.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class ClassCollectionLoader
+{
+ static private $loaded;
+
+ /**
+ * Loads a list of classes and caches them in one big file.
+ *
+ * @param array $classes An array of classes to load
+ * @param string $cacheDir A cache directory
+ * @param string $name The cache name prefix
+ * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
+ * @param Boolean $adaptive Whether to remove already declared classes or not
+ * @param string $extension File extension of the resulting file
+ *
+ * @throws \InvalidArgumentException When class can't be loaded
+ */
+ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
+ {
+ // each $name can only be loaded once per PHP process
+ if (isset(self::$loaded[$name])) {
+ return;
+ }
+
+ self::$loaded[$name] = true;
+
+ $classes = array_unique($classes);
+
+ if ($adaptive) {
+ // don't include already declared classes
+ $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
+
+ // the cache is different depending on which classes are already declared
+ $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
+ }
+
+ $cache = $cacheDir.'/'.$name.$extension;
+
+ // auto-reload
+ $reload = false;
+ if ($autoReload) {
+ $metadata = $cacheDir.'/'.$name.$extension.'.meta';
+ if (!file_exists($metadata) || !file_exists($cache)) {
+ $reload = true;
+ } else {
+ $time = filemtime($cache);
+ $meta = unserialize(file_get_contents($metadata));
+
+ if ($meta[1] != $classes) {
+ $reload = true;
+ } else {
+ foreach ($meta[0] as $resource) {
+ if (!file_exists($resource) || filemtime($resource) > $time) {
+ $reload = true;
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!$reload && file_exists($cache)) {
+ require_once $cache;
+
+ return;
+ }
+
+ $files = array();
+ $content = '';
+ foreach ($classes as $class) {
+ if (!class_exists($class) && !interface_exists($class)) {
+ throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
+ }
+
+ $r = new \ReflectionClass($class);
+ $files[] = $r->getFileName();
+
+ $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName()));
+
+ // add namespace declaration for global code
+ if (!$r->inNamespace()) {
+ $c = "\nnamespace\n{\n$c\n}\n";
+ } else {
+ $c = self::fixNamespaceDeclarations('<?php '.$c);
+ $c = preg_replace('/^\s*<\?php/', '', $c);
+ }
+
+ $content .= $c;
+ }
+
+ // cache the core classes
+ if (!is_dir(dirname($cache))) {
+ mkdir(dirname($cache), 0777, true);
+ }
+ self::writeCacheFile($cache, self::stripComments('<?php '.$content));
+
+ if ($autoReload) {
+ // save the resources
+ self::writeCacheFile($metadata, serialize(array($files, $classes)));
+ }
+ }
+
+ /**
+ * Adds brackets around each namespace if it's not already the case.
+ *
+ * @param string $source Namespace string
+ *
+ * @return string Namespaces with brackets
+ */
+ static public function fixNamespaceDeclarations($source)
+ {
+ if (!function_exists('token_get_all')) {
+ return $source;
+ }
+
+ $output = '';
+ $inNamespace = false;
+ $tokens = token_get_all($source);
+
+ while ($token = array_shift($tokens)) {
+ if (is_string($token)) {
+ $output .= $token;
+ } elseif (T_NAMESPACE === $token[0]) {
+ if ($inNamespace) {
+ $output .= "}\n";
+ }
+ $output .= $token[1];
+
+ // namespace name and whitespaces
+ while (($t = array_shift($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
+ $output .= $t[1];
+ }
+ if (is_string($t) && '{' === $t) {
+ $inNamespace = false;
+ array_unshift($tokens, $t);
+ } else {
+ $output .= "\n{";
+ $inNamespace = true;
+ }
+ } else {
+ $output .= $token[1];
+ }
+ }
+
+ if ($inNamespace) {
+ $output .= "}\n";
+ }
+
+ return $output;
+ }
+
+ /**
+ * Writes a cache file.
+ *
+ * @param string $file Filename
+ * @param string $content Temporary file content
+ *
+ * @throws \RuntimeException when a cache file cannot be written
+ */
+ static private function writeCacheFile($file, $content)
+ {
+ $tmpFile = tempnam(dirname($file), basename($file));
+ if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
+ chmod($file, 0644);
+
+ return;
+ }
+
+ throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
+ }
+
+ /**
+ * Removes comments from a PHP source string.
+ *
+ * We don't use the PHP php_strip_whitespace() function
+ * as we want the content to be readable and well-formatted.
+ *
+ * @param string $source A PHP string
+ *
+ * @return string The PHP string with the comments removed
+ */
+ static private function stripComments($source)
+ {
+ if (!function_exists('token_get_all')) {
+ return $source;
+ }
+
+ $output = '';
+ foreach (token_get_all($source) as $token) {
+ if (is_string($token)) {
+ $output .= $token;
+ } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
+ $output .= $token[1];
+ }
+ }
+
+ // replace multiple new lines with a single newline
+ $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output);
+
+ return $output;
+ }
+}
19 vendors/Symfony/Component/ClassLoader/.svn/text-base/LICENSE.svn-base
@@ -0,0 +1,19 @@
+Copyright (c) 2004-2011 Fabien Potencier
+
+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.
82 vendors/Symfony/Component/ClassLoader/.svn/text-base/MapFileClassLoader.php.svn-base
@@ -0,0 +1,82 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+/**
+ * A class loader that uses a mapping file to look up paths.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+class MapFileClassLoader
+{
+ private $map = array();
+
+ /**
+ * Constructor.
+ *
+ * @param string $file Path to class mapping file
+ *
+ * @api
+ */
+ public function __construct($file)
+ {
+ $this->map = require $file;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param Boolean $prepend Whether to prepend the autoloader or not
+ *
+ * @api
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ */
+ public function loadClass($class)
+ {
+ if ('\\' === $class[0]) {
+ $class = substr($class, 1);
+ }
+
+ if (isset($this->map[$class])) {
+ require $this->map[$class];
+ }
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|null The path, if found
+ */
+ public function findFile($class)
+ {
+ if ('\\' === $class[0]) {
+ $class = substr($class, 1);
+ }
+
+ if (isset($this->map[$class])) {
+ return $this->map[$class];
+ }
+ }
+}
261 vendors/Symfony/Component/ClassLoader/.svn/text-base/UniversalClassLoader.php.svn-base
@@ -0,0 +1,261 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+/**
+ * UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
+ *
+ * It is able to load classes that use either:
+ *
+ * * The technical interoperability standards for PHP 5.3 namespaces and
+ * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
+ *
+ * * The PEAR naming convention for classes (http://pear.php.net/).
+ *
+ * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
+ * looked for in a list of locations to ease the vendoring of a sub-set of
+ * classes for large projects.
+ *
+ * Example usage:
+ *
+ * $loader = new UniversalClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->registerNamespaces(array(
+ * 'Symfony\Component' => __DIR__.'/component',
+ * 'Symfony' => __DIR__.'/framework',
+ * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
+ * ));
+ *
+ * // register a library using the PEAR naming convention
+ * $loader->registerPrefixes(array(
+ * 'Swift_' => __DIR__.'/Swift',
+ * ));
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * 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.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+class UniversalClassLoader
+{
+ private $namespaces = array();
+ private $prefixes = array();
+ private $namespaceFallback = array();
+ private $prefixFallback = array();
+
+ /**
+ * Gets the configured namespaces.
+ *
+ * @return array A hash with namespaces as keys and directories as values
+ */
+ public function getNamespaces()
+ {
+ return $this->namespaces;
+ }
+
+ /**
+ * Gets the configured class prefixes.
+ *
+ * @return array A hash with class prefixes as keys and directories as values
+ */
+ public function getPrefixes()
+ {
+ return $this->prefixes;
+ }
+
+ /**
+ * Gets the directory(ies) to use as a fallback for namespaces.
+ *
+ * @return array An array of directories
+ */
+ public function getNamespaceFallback()
+ {
+ return $this->namespaceFallback;
+ }
+
+ /**
+ * Gets the directory(ies) to use as a fallback for class prefixes.
+ *
+ * @return array An array of directories
+ */
+ public function getPrefixFallback()
+ {
+ return $this->prefixFallback;
+ }
+
+ /**
+ * Registers the directory to use as a fallback for namespaces.
+ *
+ * @param string|array $dirs A directory path or an array of directories
+ *
+ * @api
+ */
+ public function registerNamespaceFallback($dirs)
+ {
+ $this->namespaceFallback = (array) $dirs;
+ }
+
+ /**
+ * Registers the directory to use as a fallback for class prefixes.
+ *
+ * @param string|array $dirs A directory path or an array of directories
+ *
+ * @api
+ */
+ public function registerPrefixFallback($dirs)
+ {
+ $this->prefixFallback = (array) $dirs;
+ }
+
+ /**
+ * Registers an array of namespaces
+ *
+ * @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
+ *
+ * @api
+ */
+ public function registerNamespaces(array $namespaces)
+ {
+ foreach ($namespaces as $namespace => $locations) {
+ $this->namespaces[$namespace] = (array) $locations;
+ }
+ }
+
+ /**
+ * Registers a namespace.
+ *
+ * @param string $namespace The namespace
+ * @param array|string $paths The location(s) of the namespace
+ *
+ * @api
+ */
+ public function registerNamespace($namespace, $paths)
+ {
+ $this->namespaces[$namespace] = (array) $paths;
+ }
+
+ /**
+ * Registers an array of classes using the PEAR naming convention.
+ *
+ * @param array $classes An array of classes (prefixes as keys and locations as values)
+ *
+ * @api
+ */
+ public function registerPrefixes(array $classes)
+ {
+ foreach ($classes as $prefix => $locations) {
+ $this->prefixes[$prefix] = (array) $locations;
+ }
+ }
+
+ /**
+ * Registers a set of classes using the PEAR naming convention.
+ *
+ * @param string $prefix The classes prefix
+ * @param array|string $paths The location(s) of the classes
+ *
+ * @api
+ */
+ public function registerPrefix($prefix, $paths)
+ {
+ $this->prefixes[$prefix] = (array) $paths;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param Boolean $prepend Whether to prepend the autoloader or not
+ *
+ * @api
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ require $file;
+ }
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|null The path, if found
+ */
+ public function findFile($class)
+ {
+ if ('\\' == $class[0]) {
+ $class = substr($class, 1);
+ }
+
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $namespace = substr($class, 0, $pos);
+ foreach ($this->namespaces as $ns => $dirs) {
+ foreach ($dirs as $dir) {
+ if (0 === strpos($namespace, $ns)) {
+ $className = substr($class, $pos + 1);
+ $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+ }
+ }
+ }
+
+ foreach ($this->namespaceFallback as $dir) {
+ $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+ }
+ } else {
+ // PEAR-like class name
+ foreach ($this->prefixes as $prefix => $dirs) {
+ foreach ($dirs as $dir) {
+ if (0 === strpos($class, $prefix)) {
+ $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+ }
+ }
+ }
+
+ foreach ($this->prefixFallback as $dir) {
+ $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+ }
+ }
+ }
+}
47 vendors/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+require_once __DIR__.'/UniversalClassLoader.php';
+
+/**
+ * Class loader utilizing APC to remember where files are.
+ *
+ * @author Kris Wallsmith <kris.wallsmith@symfony.com>
+ *
+ * @api
+ */
+class ApcUniversalClassLoader extends UniversalClassLoader
+{
+ private $prefix;
+
+ /**
+ * Constructor.
+ *
+ * @param string $prefix A prefix to create a namespace in APC
+ *
+ * @api
+ */
+ public function __construct($prefix)
+ {
+ $this->prefix = $prefix;
+ }
+
+ public function findFile($class)
+ {
+ if (false === $file = apc_fetch($this->prefix.$class)) {
+ apc_store($this->prefix.$class, $file = parent::findFile($class));
+ }
+
+ return $file;
+ }
+}
220 vendors/Symfony/Component/ClassLoader/ClassCollectionLoader.php
@@ -0,0 +1,220 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+/**
+ * ClassCollectionLoader.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class ClassCollectionLoader
+{
+ static private $loaded;
+
+ /**
+ * Loads a list of classes and caches them in one big file.
+ *
+ * @param array $classes An array of classes to load
+ * @param string $cacheDir A cache directory
+ * @param string $name The cache name prefix
+ * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
+ * @param Boolean $adaptive Whether to remove already declared classes or not
+ * @param string $extension File extension of the resulting file
+ *
+ * @throws \InvalidArgumentException When class can't be loaded
+ */
+ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
+ {
+ // each $name can only be loaded once per PHP process
+ if (isset(self::$loaded[$name])) {
+ return;
+ }
+
+ self::$loaded[$name] = true;
+
+ $classes = array_unique($classes);
+
+ if ($adaptive) {
+ // don't include already declared classes
+ $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
+
+ // the cache is different depending on which classes are already declared
+ $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
+ }
+
+ $cache = $cacheDir.'/'.$name.$extension;
+
+ // auto-reload
+ $reload = false;
+ if ($autoReload) {
+ $metadata = $cacheDir.'/'.$name.$extension.'.meta';
+ if (!file_exists($metadata) || !file_exists($cache)) {
+ $reload = true;
+ } else {
+ $time = filemtime($cache);
+ $meta = unserialize(file_get_contents($metadata));
+
+ if ($meta[1] != $classes) {
+ $reload = true;
+ } else {
+ foreach ($meta[0] as $resource) {
+ if (!file_exists($resource) || filemtime($resource) > $time) {
+ $reload = true;
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!$reload && file_exists($cache)) {
+ require_once $cache;
+
+ return;
+ }
+
+ $files = array();
+ $content = '';
+ foreach ($classes as $class) {
+ if (!class_exists($class) && !interface_exists($class)) {
+ throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
+ }
+
+ $r = new \ReflectionClass($class);
+ $files[] = $r->getFileName();
+
+ $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName()));
+
+ // add namespace declaration for global code
+ if (!$r->inNamespace()) {
+ $c = "\nnamespace\n{\n$c\n}\n";
+ } else {
+ $c = self::fixNamespaceDeclarations('<?php '.$c);
+ $c = preg_replace('/^\s*<\?php/', '', $c);
+ }
+
+ $content .= $c;
+ }
+
+ // cache the core classes
+ if (!is_dir(dirname($cache))) {
+ mkdir(dirname($cache), 0777, true);
+ }
+ self::writeCacheFile($cache, self::stripComments('<?php '.$content));
+
+ if ($autoReload) {
+ // save the resources
+ self::writeCacheFile($metadata, serialize(array($files, $classes)));
+ }
+ }
+
+ /**
+ * Adds brackets around each namespace if it's not already the case.
+ *
+ * @param string $source Namespace string
+ *
+ * @return string Namespaces with brackets
+ */
+ static public function fixNamespaceDeclarations($source)
+ {
+ if (!function_exists('token_get_all')) {
+ return $source;
+ }
+
+ $output = '';
+ $inNamespace = false;
+ $tokens = token_get_all($source);
+
+ while ($token = array_shift($tokens)) {
+ if (is_string($token)) {
+ $output .= $token;
+ } elseif (T_NAMESPACE === $token[0]) {
+ if ($inNamespace) {
+ $output .= "}\n";
+ }
+ $output .= $token[1];
+
+ // namespace name and whitespaces
+ while (($t = array_shift($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
+ $output .= $t[1];
+ }
+ if (is_string($t) && '{' === $t) {
+ $inNamespace = false;
+ array_unshift($tokens, $t);
+ } else {
+ $output .= "\n{";
+ $inNamespace = true;
+ }
+ } else {
+ $output .= $token[1];
+ }
+ }
+
+ if ($inNamespace) {
+ $output .= "}\n";
+ }
+
+ return $output;
+ }
+
+ /**
+ * Writes a cache file.
+ *
+ * @param string $file Filename
+ * @param string $content Temporary file content
+ *
+ * @throws \RuntimeException when a cache file cannot be written
+ */
+ static private function writeCacheFile($file, $content)
+ {
+ $tmpFile = tempnam(dirname($file), basename($file));
+ if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
+ chmod($file, 0644);
+
+ return;
+ }
+
+ throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
+ }
+
+ /**
+ * Removes comments from a PHP source string.
+ *
+ * We don't use the PHP php_strip_whitespace() function
+ * as we want the content to be readable and well-formatted.
+ *
+ * @param string $source A PHP string
+ *
+ * @return string The PHP string with the comments removed
+ */
+ static private function stripComments($source)
+ {
+ if (!function_exists('token_get_all')) {
+ return $source;
+ }
+
+ $output = '';
+ foreach (token_get_all($source) as $token) {
+ if (is_string($token)) {
+ $output .= $token;
+ } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
+ $output .= $token[1];
+ }
+ }
+
+ // replace multiple new lines with a single newline
+ $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output);
+
+ return $output;
+ }
+}
19 vendors/Symfony/Component/ClassLoader/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2004-2011 Fabien Potencier
+
+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.
82 vendors/Symfony/Component/ClassLoader/MapFileClassLoader.php
@@ -0,0 +1,82 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\ClassLoader;
+
+/**
+ * A class loader that uses a mapping file to look up paths.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+class MapFileClassLoader
+{
+ private $map = array();
+
+ /**
+ * Constructor.
+ *
+ * @param string $file Path to class mapping file
+ *
+ * @api
+ */
+ public function __construct($file)
+ {
+ $this->map = require $file;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param Boolean $prepend Whether to prepend the autoloader or not
+ *
+ * @api
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ */
+ public function loadClass($class)
+ {
+ if ('\\' === $class[0]) {
+ $class = substr($class, 1);
+ }
+
+ if (isset($this->map[$class])) {
+ require $this->map[$class];
+ }
+ }