Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated the samples to remove the scaffold. This is necessary as the …

…scaffold is updating almost weekly and quickly outdating these samples. Users now have the choice of how to put the samples into scaffolds, or they can use the paz tool to automate the scaffolding and packaging at http://github.com/blobaugh/WAZ-PHP-Utils
  • Loading branch information...
commit 57400435dc3acb94720f6c361ebdde50c34129c4 1 parent 57947d6
@blobaugh blobaugh authored
Showing with 0 additions and 28,141 deletions.
  1. BIN  GuestBookUsingBlobs/LocalGuestBookUsingBlobs.cspkg
  2. +0 −6 GuestBookUsingBlobs/ServiceConfiguration.cscfg
  3. +0 −18 GuestBookUsingBlobs/ServiceDefinition.csdef
  4. +0 −74 GuestBookUsingBlobs/WebRole/Microsoft/AutoLoader.php
  5. +0 −426 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command.php
  6. +0 −80 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Argv.php
  7. +0 −111 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/ConfigFile.php
  8. +0 −84 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Env.php
  9. +0 −57 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/ParameterSourceInterface.php
  10. +0 −75 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Prompt.php
  11. +0 −90 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/StdIn.php
  12. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/Console/Exception.php
  13. +0 −47 GuestBookUsingBlobs/WebRole/Microsoft/Exception.php
  14. +0 −1,427 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client.php
  15. +0 −489 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Curl.php
  16. +0 −38 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Exception.php
  17. +0 −78 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Interface.php
  18. +0 −259 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Proxy.php
  19. +0 −523 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Socket.php
  20. +0 −46 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Adapter/Stream.php
  21. +0 −36 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client/Exception.php
  22. +0 −408 GuestBookUsingBlobs/WebRole/Microsoft/Http/Cookie.php
  23. +0 −395 GuestBookUsingBlobs/WebRole/Microsoft/Http/CookieJar.php
  24. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/Http/Exception.php
  25. +0 −664 GuestBookUsingBlobs/WebRole/Microsoft/Http/Response.php
  26. +0 −240 GuestBookUsingBlobs/WebRole/Microsoft/Http/Response/Stream.php
  27. +0 −426 GuestBookUsingBlobs/WebRole/Microsoft/Log.php
  28. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/Log/Exception.php
  29. +0 −38 GuestBookUsingBlobs/WebRole/Microsoft/Log/FactoryInterface.php
  30. +0 −55 GuestBookUsingBlobs/WebRole/Microsoft/Log/Filter/Abstract.php
  31. +0 −40 GuestBookUsingBlobs/WebRole/Microsoft/Log/Filter/Interface.php
  32. +0 −87 GuestBookUsingBlobs/WebRole/Microsoft/Log/Filter/Message.php
  33. +0 −103 GuestBookUsingBlobs/WebRole/Microsoft/Log/Filter/Priority.php
  34. +0 −79 GuestBookUsingBlobs/WebRole/Microsoft/Log/Filter/Suppress.php
  35. +0 −41 GuestBookUsingBlobs/WebRole/Microsoft/Log/Formatter/Interface.php
  36. +0 −133 GuestBookUsingBlobs/WebRole/Microsoft/Log/Writer/Abstract.php
  37. +0 −298 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/CommandLine/SqlAzure.php
  38. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Exception.php
  39. +0 −583 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Management/Client.php
  40. +0 −51 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Management/Exception.php
  41. +0 −70 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Management/FirewallRuleInstance.php
  42. +0 −72 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Management/ServerInstance.php
  43. +0 −84 GuestBookUsingBlobs/WebRole/Microsoft/SqlAzure/Management/ServiceEntityAbstract.php
  44. +0 −193 GuestBookUsingBlobs/WebRole/Microsoft/Uri.php
  45. +0 −37 GuestBookUsingBlobs/WebRole/Microsoft/Uri/Exception.php
  46. +0 −761 GuestBookUsingBlobs/WebRole/Microsoft/Uri/Http.php
  47. +0 −187 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Certificate.php
  48. +0 −590 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Deployment.php
  49. +0 −106 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/GetAsynchronousOperation.php
  50. +0 −164 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Package.php
  51. +0 −324 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/PackageScaffolder/PackageScaffolderAbstract.php
  52. +0 −193 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolder.php
  53. +0 −1  GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/build.bat
  54. +0 −89 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/index.php
  55. +0 −20 ...ebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/Web.config
  56. +0 −12 ...ft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/bin/install-php-impl.cmd
  57. +0 −10 ...crosoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/bin/install-php.cmd
  58. +0 −32 ...crosoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/bin/install-php.ps1
  59. +0 −35 ...icrosoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/diagnostics.wadcfg
  60. +0 −2  ...icrosoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/php/ext/readme.txt
  61. +0 −21 ...bRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/php/php.ini
  62. BIN  .../Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/resources/WebPICmdLine/Microsoft.Web.Deployment.dll
  63. BIN  ...rs/DefaultScaffolder/resources/PhpOnAzure.Web/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.UI.dll
  64. BIN  ...lders/DefaultScaffolder/resources/PhpOnAzure.Web/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.dll
  65. BIN  .../CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/resources/WebPICmdLine/WebpiCmdLine.exe
  66. +0 −41 ...Azure/CommandLine/Scaffolders/DefaultScaffolder/resources/PhpOnAzure.Web/resources/WebPICmdLine/license.rtf
  67. +0 −9 ...bRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/ServiceConfiguration.cscfg
  68. +0 −23 .../WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/DefaultScaffolder/resources/ServiceDefinition.csdef
  69. +0 −1  ...tBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/ScaffoldTemplateScaffolder/build.bat
  70. +0 −87 ...tBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/ScaffoldTemplateScaffolder/index.php
  71. +0 −1  ...Blobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/ScaffoldTemplateScaffolder/resources/build.bat
  72. +0 −41 ...Blobs/WebRole/Microsoft/WindowsAzure/CommandLine/Scaffolders/ScaffoldTemplateScaffolder/resources/index.php
  73. +0 −1  ...le/Microsoft/WindowsAzure/CommandLine/Scaffolders/ScaffoldTemplateScaffolder/resources/resources/readme.txt
  74. +0 −209 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Service.php
  75. +0 −281 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/Storage.php
  76. +0 −54 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/CommandLine/sample.php
  77. +0 −252 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Credentials/CredentialsAbstract.php
  78. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Credentials/Exception.php
  79. +0 −310 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Credentials/SharedAccessSignature.php
  80. +0 −185 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Credentials/SharedKey.php
  81. +0 −164 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Credentials/SharedKeyLite.php
  82. +0 −74 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationDataSources.php
  83. +0 −70 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationDiagnosticInfrastructureLogs.php
  84. +0 −93 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationDirectories.php
  85. +0 −225 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationInstance.php
  86. +0 −70 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationLogs.php
  87. +0 −84 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationObjectBaseAbstract.php
  88. +0 −92 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationPerformanceCounters.php
  89. +0 −94 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/ConfigurationWindowsEventLog.php
  90. +0 −70 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/DirectoryConfigurationSubscription.php
  91. +0 −51 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/Exception.php
  92. +0 −52 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/LogLevel.php
  93. +0 −225 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/Manager.php
  94. +0 −67 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Diagnostics/PerformanceCounterSubscription.php
  95. +0 −48 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Exception.php
  96. +0 −81 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Log/Formatter/WindowsAzure.php
  97. +0 −187 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Log/Writer/WindowsAzure.php
  98. +0 −79 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/AffinityGroupInstance.php
  99. +0 −73 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/CertificateInstance.php
  100. +0 −2,372 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/Client.php
  101. +0 −109 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/DeploymentInstance.php
  102. +0 −51 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/Exception.php
  103. +0 −82 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/HostedServiceInstance.php
  104. +0 −64 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/LocationInstance.php
  105. +0 −70 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/OperatingSystemFamilyInstance.php
  106. +0 −79 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/OperatingSystemInstance.php
  107. +0 −73 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/OperationStatusInstance.php
  108. +0 −84 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/ServiceEntityAbstract.php
  109. +0 −79 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/StorageServiceInstance.php
  110. +0 −96 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Management/SubscriptionOperationInstance.php
  111. +0 −49 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/RetryPolicy/Exception.php
  112. +0 −71 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/RetryPolicy/NoRetry.php
  113. +0 −100 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/RetryPolicy/RetryN.php
  114. +0 −80 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php
  115. +0 −194 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/RoleEnvironment.php
  116. +0 −340 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/SessionHandler.php
  117. +0 −565 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage.php
  118. +0 −256 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/Batch.php
  119. +0 −185 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/BatchStorageAbstract.php
  120. +0 −1,974 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/Blob.php
  121. +0 −563 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/Blob/Stream.php
  122. +0 −107 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/BlobContainer.php
  123. +0 −106 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/BlobInstance.php
  124. +0 −234 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/DynamicTableEntity.php
  125. +0 −73 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/LeaseInstance.php
  126. +0 −67 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/PageRegionInstance.php
  127. +0 −559 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/Queue.php
  128. +0 −69 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/QueueInstance.php
  129. +0 −82 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/QueueMessage.php
  130. +0 −73 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/SignedIdentifier.php
  131. +0 −86 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/StorageEntityAbstract.php
  132. +0 −899 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/Table.php
  133. +0 −372 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/TableEntity.php
  134. +0 −364 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/TableEntityQuery.php
  135. +0 −73 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/Storage/TableInstance.php
  136. BIN  GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/bin/RoleEnvironmentProxy.exe
  137. +0 −6 GuestBookUsingBlobs/WebRole/Microsoft/WindowsAzure/bin/RoleEnvironmentProxy.exe.config
  138. +0 −12 GuestBookUsingBlobs/WebRole/bin/install-php-impl.cmd
  139. +0 −14 GuestBookUsingBlobs/WebRole/bin/install-php.cmd
  140. +0 −32 GuestBookUsingBlobs/WebRole/bin/install-php.ps1
  141. BIN  GuestBookUsingBlobs/WebRole/php/ext/php_azure.dll
  142. +0 −2  GuestBookUsingBlobs/WebRole/php/ext/readme.txt
  143. +0 −22 GuestBookUsingBlobs/WebRole/php/php.ini
  144. BIN  GuestBookUsingBlobs/WebRole/resources/WebPICmdLine/Microsoft.Web.Deployment.dll
  145. BIN  GuestBookUsingBlobs/WebRole/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.UI.dll
  146. BIN  GuestBookUsingBlobs/WebRole/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.dll
  147. BIN  GuestBookUsingBlobs/WebRole/resources/WebPICmdLine/WebpiCmdLine.exe
  148. +0 −41 GuestBookUsingBlobs/WebRole/resources/WebPICmdLine/license.rtf
  149. 0  GuestBookUsingBlobs/{WebRole → }/index.php
  150. 0  GuestBookUsingBlobs/{WebRole → }/info.php
  151. 0  {GuestBookUsingTables/WebRole → GuestBookUsingBlobs}/main.css
  152. 0  {GuestBookUsingTables/WebRole → GuestBookUsingBlobs}/sign.png
  153. BIN  GuestBookUsingQueues/LocalGuestBookUsingQueues.cspkg
  154. +0 −6 GuestBookUsingQueues/ServiceConfiguration.cscfg
  155. +0 −18 GuestBookUsingQueues/ServiceDefinition.csdef
  156. +0 −74 GuestBookUsingQueues/WebRole/Microsoft/AutoLoader.php
  157. +0 −426 GuestBookUsingQueues/WebRole/Microsoft/Console/Command.php
  158. +0 −80 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/Argv.php
  159. +0 −111 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/ConfigFile.php
  160. +0 −84 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/Env.php
  161. +0 −57 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/ParameterSourceInterface.php
  162. +0 −75 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/Prompt.php
  163. +0 −90 GuestBookUsingQueues/WebRole/Microsoft/Console/Command/ParameterSource/StdIn.php
  164. +0 −48 GuestBookUsingQueues/WebRole/Microsoft/Console/Exception.php
  165. +0 −47 GuestBookUsingQueues/WebRole/Microsoft/Exception.php
  166. +0 −1,427 GuestBookUsingQueues/WebRole/Microsoft/Http/Client.php
  167. +0 −489 GuestBookUsingQueues/WebRole/Microsoft/Http/Client/Adapter/Curl.php
  168. +0 −38 GuestBookUsingQueues/WebRole/Microsoft/Http/Client/Adapter/Exception.php
Sorry, we could not display the entire diff because too many files (474) changed.
View
BIN  GuestBookUsingBlobs/LocalGuestBookUsingBlobs.cspkg
Binary file not shown
View
6 GuestBookUsingBlobs/ServiceConfiguration.cscfg
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ServiceConfiguration serviceName="PhpOnAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
- <Role name="WebRole">
- <Instances count="1" />
- </Role>
-</ServiceConfiguration>
View
18 GuestBookUsingBlobs/ServiceDefinition.csdef
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ServiceDefinition name="PhpOnAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
- <WebRole name="WebRole" enableNativeCodeExecution="true" vmsize="Small">
- <Sites>
- <Site name="WebRole" physicalDirectory="./WebRole">
- <Bindings>
- <Binding name="Endpoint1" endpointName="HttpEndpoint" />
- </Bindings>
- </Site>
- </Sites>
- <Startup>
- <!-- <Task commandLine="install-php.cmd >> .\startup-tasks-log.txt 2>>.\startup-tasks-error-log.txt" executionContext="elevated" taskType="simple" /> -->
- </Startup>
- <Endpoints>
- <InputEndpoint name="HttpEndpoint" protocol="http" port="80" />
- </Endpoints>
- </WebRole>
-</ServiceDefinition>
View
74 GuestBookUsingBlobs/WebRole/Microsoft/AutoLoader.php
@@ -1,74 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/** Microsoft root directory */
-if (!defined('MICROSOFT_ROOT')) {
- define('MICROSOFT_ROOT', realpath(dirname(__FILE__) . '/../') . DIRECTORY_SEPARATOR);
-}
-Microsoft_AutoLoader::Register();
-
-/**
- * @category Microsoft
- * @package Microsoft
- * @subpackage AutoLoader
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_AutoLoader
-{
- /**
- * Registers the autoloader
- */
- public static function Register() {
- return spl_autoload_register(array('Microsoft_AutoLoader', 'Load'));
- }
-
- /**
- * Load a class
- *
- * @param string $className Class name to load
- */
- public static function Load($className){
- if ((class_exists($className)) || (strpos($className, 'Microsoft') === false)) {
- return false;
- }
-
- $classFilePath = MICROSOFT_ROOT . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
-
- if ((file_exists($classFilePath) === false) || (is_readable($classFilePath) === false)) {
- return false;
- }
-
- require($classFilePath);
- }
-}
View
426 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command.php
@@ -1,426 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command
-{
- /**
- * The handler.
- *
- * @var array
- */
- protected $_handler;
-
- /**
- * Gets the handler.
- *
- * @return array
- */
- public function getHandler()
- {
- return $this->_handler;
- }
-
- /**
- * Sets the handler.
- *
- * @param array $handler
- * @return Microsoft_Console_Command
- */
- public function setHandler($handler)
- {
- $this->_handler = $handler;
- return $this;
- }
-
- /**
- * Replaces PHP's error handler
- *
- * @param mixed $errno
- * @param mixed $errstr
- * @param mixed $errfile
- * @param mixed $errline
- */
- public static function phpstderr($errno, $errstr, $errfile, $errline)
- {
- self::stderr($errno . ': Error in ' . $errfile . ':' . $errline . ' - ' . $errstr);
- }
-
- /**
- * Replaces PHP's exception handler
- *
- * @param Exception $exception
- */
- public static function phpstdex($exception)
- {
- self::stderr('Error: ' . $exception->getMessage());
- }
-
- /**
- * Writes output to STDERR, followed by a newline (optional)
- *
- * @param string $errorMessage
- * @param string $newLine
- */
- public static function stderr($errorMessage, $newLine = true)
- {
- if (error_reporting() === 0) {
- return;
- }
- file_put_contents('php://stderr', $errorMessage . ($newLine ? "\r\n" : ''));
- }
-
- /**
- * Bootstrap the shell command.
- *
- * @param array $argv PHP argument values.
- */
- public static function bootstrap($argv)
- {
- // Abort bootstrapping depending on the MICROSOFT_CONSOLE_COMMAND_HOST constant.
- if (defined('MICROSOFT_CONSOLE_COMMAND_HOST') && strtolower(MICROSOFT_CONSOLE_COMMAND_HOST) != 'console') {
- return;
- }
-
- // Replace error handler
- set_error_handler(array('Microsoft_Console_Command', 'phpstderr'));
- set_exception_handler(array('Microsoft_Console_Command', 'phpstdex'));
-
- // Build the application model
- $model = self::_buildModel();
-
- // Find a class that corresponds to the $argv[0] script name
- $requiredHandlerName = str_replace('.bat', '', str_replace('.sh', '', str_replace('.php', '', strtolower(basename($argv[0])))));
- $handler = null;
- foreach ($model as $possibleHandler) {
- if ($possibleHandler->handler == strtolower($requiredHandlerName)) {
- $handler = $possibleHandler;
- break;
- }
- }
- if (is_null($handler)) {
- self::stderr("No class found that implements handler '" . $requiredHandlerName . "'. Create a class that is named '" . $requiredHandlerName . "' and extends Microsoft_Console_Command or is decorated with a docblock comment '@command-handler " . $requiredHandlerName . "'. Make sure it is loaded either through an autoloader or explicitly using require_once().");
- die();
- }
-
- // Find a method that matches the command name
- $command = null;
- foreach ($handler->commands as $possibleCommand) {
- if (in_array(strtolower(isset($argv[1]) ? $argv[1] : '<default>'), $possibleCommand->aliases)) {
- $command = $possibleCommand;
- break;
- }
- }
- if (is_null($command)) {
- $commandName = (isset($argv[1]) ? $argv[1] : '<default>');
- self::stderr("No method found that implements command " . $commandName . ". Create a method in class '" . $handler->class . "' that is named '" . strtolower($commandName) . "Command' or is decorated with a docblock comment '@command-name " . $commandName . "'.");
- die();
- }
-
- // Parse parameter values
- $parameterValues = array();
- $missingParameterValues = array();
- $parameterInputs = array_splice($argv, 2);
- foreach ($command->parameters as $parameter) {
- // Default value: null
- $value = null;
-
- // Consult value providers for value. First one wins.
- foreach ($parameter->valueproviders as $valueProviderName) {
- if (!class_exists($valueProviderName)) {
- $valueProviderName = 'Microsoft_Console_Command_ParameterSource_' . $valueProviderName;
- }
- $valueProvider = new $valueProviderName();
-
- $value = $valueProvider->getValueForParameter($parameter, $parameterInputs);
- if (!is_null($value)) {
- break;
- }
- }
- if (is_null($value) && $parameter->required) {
- $missingParameterValues[] = $parameter->aliases[0];
- } else if (is_null($value)) {
- $value = $parameter->defaultvalue;
- }
-
- // Set value
- $parameterValues[] = $value;
- $argvValues[$parameter->aliases[0]] = $value;
- }
-
- // Mising parameters?
- if (count($missingParameterValues) > 0) {
- self::stderr("Some parameters are missing:\r\n" . implode("\r\n", $missingParameterValues));
- die();
- }
-
- // Supply argv in a nice way
- $parameterValues['argv'] = $parameterInputs;
-
- // Run the command
- $className = $handler->class;
- $classInstance = new $className();
- $classInstance->setHandler($handler);
- call_user_func_array(array($classInstance, $command->method), $parameterValues);
-
- // Restore error handler
- restore_exception_handler();
- restore_error_handler();
- }
-
- /**
- * Builds the handler model.
- *
- * @return array
- */
- protected static function _buildModel()
- {
- $model = array();
-
- $classes = get_declared_classes();
- foreach ($classes as $class) {
- $type = new ReflectionClass($class);
-
- $handlers = self::_findValueForDocComment('@command-handler', $type->getDocComment());
- if (count($handlers) == 0 && $type->isSubclassOf('Microsoft_Console_Command')) {
- // Fallback: if the class extends Microsoft_Console_Command, register it as
- // a command handler.
- $handlers[] = $class;
- }
- $handlerDescriptions = self::_findValueForDocComment('@command-handler-description', $type->getDocComment());
- $handlerHeaders = self::_findValueForDocComment('@command-handler-header', $type->getDocComment());
- $handlerFooters = self::_findValueForDocComment('@command-handler-footer', $type->getDocComment());
-
- for ($hi = 0; $hi < count($handlers); $hi++) {
- $handler = $handlers[$hi];
- $handlerDescription = isset($handlerDescriptions[$hi]) ? $handlerDescriptions[$hi] : isset($handlerDescriptions[0]) ? $handlerDescriptions[0] : '';
- $handlerDescription = str_replace('\r\n', "\r\n", $handlerDescription);
- $handlerDescription = str_replace('\n', "\n", $handlerDescription);
-
- $handlerModel = (object)array(
- 'handler' => strtolower($handler),
- 'description' => $handlerDescription,
- 'headers' => $handlerHeaders,
- 'footers' => $handlerFooters,
- 'class' => $class,
- 'commands' => array()
- );
-
- $methods = $type->getMethods();
- foreach ($methods as $method) {
- $commands = self::_findValueForDocComment('@command-name', $method->getDocComment());
- if (substr($method->getName(), -7) == 'Command' && !in_array(substr($method->getName(), 0, -7), $commands)) {
- // Fallback: if the method is named <commandname>Command,
- // register it as a command.
- $commands[] = substr($method->getName(), 0, -7);
- }
- for ($x = 0; $x < count($commands); $x++) {
- $commands[$x] = strtolower($commands[$x]);
- }
- $commandDescriptions = self::_findValueForDocComment('@command-description', $method->getDocComment());
- $commandExamples = self::_findValueForDocComment('@command-example', $method->getDocComment());
-
- if (count($commands) > 0) {
- $command = $commands[0];
- $commandDescription = isset($commandDescriptions[0]) ? $commandDescriptions[0] : '';
-
- $commandModel = (object)array(
- 'command' => $command,
- 'aliases' => $commands,
- 'description' => $commandDescription,
- 'examples' => $commandExamples,
- 'class' => $class,
- 'method' => $method->getName(),
- 'parameters' => array()
- );
-
- $parameters = $method->getParameters();
- $parametersFor = self::_findValueForDocComment('@command-parameter-for', $method->getDocComment());
- for ($pi = 0; $pi < count($parameters); $pi++) {
- // Initialize
- $parameter = $parameters[$pi];
- $parameterFor = null;
- $parameterForDefaultValue = null;
-
- // Is it a "catch-all" parameter?
- if ($parameter->getName() == 'argv') {
- continue;
- }
-
- // Find the $parametersFor with the same name defined
- foreach ($parametersFor as $possibleParameterFor) {
- $possibleParameterFor = explode(' ', $possibleParameterFor, 4);
- if ($possibleParameterFor[0] == '$' . $parameter->getName()) {
- $parameterFor = $possibleParameterFor;
- break;
- }
- }
- if (is_null($parameterFor)) {
- die('@command-parameter-for missing for parameter $' . $parameter->getName());
- }
-
- if (is_null($parameterForDefaultValue) && $parameter->isOptional()) {
- $parameterForDefaultValue = $parameter->getDefaultValue();
- }
-
- $parameterModel = (object)array(
- 'name' => '$' . $parameter->getName(),
- 'defaultvalue' => $parameterForDefaultValue,
- 'valueproviders' => explode('|', $parameterFor[1]),
- 'aliases' => explode('|', $parameterFor[2]),
- 'description' => (isset($parameterFor[3]) ? $parameterFor[3] : ''),
- 'required' => (isset($parameterFor[3]) ? strpos(strtolower($parameterFor[3]), 'required') !== false && strpos(strtolower($parameterFor[3]), 'required if') === false : false),
- );
-
- // Add to model
- $commandModel->parameters[] = $parameterModel;
- }
-
- // Add to model
- $handlerModel->commands[] = $commandModel;
- }
- }
-
- // Add to model
- $model[] = $handlerModel;
- }
- }
-
- return $model;
- }
-
- /**
- * Finds the value for a specific docComment.
- *
- * @param string $docCommentName Comment name
- * @param unknown_type $docComment Comment object
- * @return array
- */
- protected static function _findValueForDocComment($docCommentName, $docComment)
- {
- $returnValue = array();
-
- $commentLines = explode("\n", $docComment);
- foreach ($commentLines as $commentLine) {
- if (strpos($commentLine, $docCommentName . ' ') !== false) {
- $returnValue[] = trim(substr($commentLine, strpos($commentLine, $docCommentName) + strlen($docCommentName) + 1));
- }
- }
-
- return $returnValue;
- }
-
- /**
- * Display information on an object
- *
- * @param object $object Object
- * @param array $propertiesToDump Property names to display
- */
- protected function _displayObjectInformation($object, $propertiesToDump = array())
- {
- foreach ($propertiesToDump as $property) {
- printf('%-16s: %s' . "\r\n", $property, $object->$property);
- }
- printf("\r\n");
- }
-
- /**
- * Displays the help information.
- *
- * @command-name <default>
- * @command-name -h
- * @command-name -help
- * @command-description Displays the current help information.
- */
- public function helpCommand() {
- $handler = $this->getHandler();
- $newline = "\r\n";
-
- if (count($handler->headers) > 0) {
- foreach ($handler->headers as $header) {
- printf('%s%s', $header, $newline);
- }
- printf($newline);
- }
- printf('%s%s', $handler->description, $newline);
- printf($newline);
- printf('Available commands:%s', $newline);
- foreach ($handler->commands as $command) {
- $description = str_split($command->description, 50);
- printf(' %-25s %s%s', implode(', ', $command->aliases), $description[0], $newline);
- for ($di = 1; $di < count($description); $di++) {
- printf(' %-25s %s%s', '', $description[$di], $newline);
- }
- printf($newline);
-
- if (count($command->parameters) > 0) {
- foreach ($command->parameters as $parameter) {
- $description = str_split($parameter->description, 50);
- printf(' %-23s %s%s', implode(', ', $parameter->aliases), $description[0], $newline);
- for ($di = 1; $di < count($description); $di++) {
- printf(' %-23s %s%s', '', $description[$di], $newline);
- }
- printf($newline);
- }
- }
- printf($newline);
-
- if (count($command->examples) > 0) {
- printf(' Example usage:%s', $newline);
- foreach ($command->examples as $example) {
- printf(' %s%s', $example, $newline);
- }
- printf($newline);
- }
- }
-
- if (count($handler->footers) > 0) {
- printf($newline);
- foreach ($handler->footers as $footer) {
- printf('%s%s', $footer, $newline);
- }
- printf($newline);
- }
- }
-}
View
80 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Argv.php
@@ -1,80 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command_ParameterSource_Argv
- implements Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array())
- {
- // Default value
- $parameterValue = null;
-
- // Loop parameter inputs
- foreach ($argv as $parameterInput) {
- $parameterInput = explode('=', $parameterInput, 2);
-
- if (in_array($parameterInput[0], $parameter->aliases)) {
- $parameterValue = isset($parameterInput[1]) ? $parameterInput[1] : true;
- break;
- }
- }
- if (strtolower($parameterValue) == 'true') {
- $parameterValue = true;
- } else if (strtolower($parameterValue) == 'false') {
- $parameterValue = false;
- }
-
- // Done!
- return $parameterValue;
- }
-}
View
111 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/ConfigFile.php
@@ -1,111 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command_ParameterSource_ConfigFile
- implements Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array())
- {
- // Configuration file path
- $configurationFilePath = null;
-
- // Check if a path to a configuration file is specified
- foreach ($argv as $parameterInput) {
- $parameterInput = explode('=', $parameterInput, 2);
-
- if (strtolower($parameterInput[0]) == '--configfile' || strtolower($parameterInput[0]) == '-f') {
- if (!isset($parameterInput[1])) {
- throw new Microsoft_Console_Exception("No path to a configuration file is given. Specify the path using the --ConfigFile or -F switch.");
- }
- $configurationFilePath = $parameterInput[1];
- break;
- }
- }
-
- // Value given?
- if (is_null($configurationFilePath)) {
- return null;
- }
- if (!file_exists($configurationFilePath)) {
- throw new Microsoft_Console_Exception("Invalid configuration file given. Specify the correct path using the --ConfigFile or -F switch.");
- }
-
- // Parse values
- $iniValues = parse_ini_file($configurationFilePath);
-
- // Default value
- $parameterValue = null;
-
- // Loop aliases
- foreach ($parameter->aliases as $alias) {
- if (array_key_exists($alias, $iniValues)) {
- $parameterValue = $iniValues[$alias]; break;
- } else if (array_key_exists(strtolower($alias), $iniValues)) {
- $parameterValue = $iniValues[strtolower($alias)]; break;
- } else if (array_key_exists(str_replace('-', '', $alias), $iniValues)) {
- $parameterValue = $iniValues[str_replace('-', '', $alias)]; break;
- } else if (array_key_exists(strtolower(str_replace('-', '', $alias)), $iniValues)) {
- $parameterValue = $iniValues[strtolower(str_replace('-', '', $alias))]; break;
- }
- }
-
- if (strtolower($parameterValue) == 'true') {
- $parameterValue = true;
- } else if (strtolower($parameterValue) == 'false') {
- $parameterValue = false;
- }
-
- // Done!
- return $parameterValue;
- }
-}
View
84 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Env.php
@@ -1,84 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command_ParameterSource_Env
- implements Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array())
- {
- // Default value
- $parameterValue = null;
-
- // Fetch value for parameter
- foreach ($parameter->aliases as $alias) {
- while (strpos($alias, '-') !== false) {
- $alias = substr($alias, 1);
- }
- $value = getenv($alias);
-
- if (!is_null($value) && $value !== false) {
- $parameterValue = $value;
- break;
- }
- }
-
- if (strtolower($parameterValue) == 'true') {
- $parameterValue = true;
- } else if (strtolower($parameterValue) == 'false') {
- $parameterValue = false;
- }
-
- // Done!
- return $parameterValue;
- }
-}
View
57 ...UsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/ParameterSourceInterface.php
@@ -1,57 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-interface Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array());
-}
View
75 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/Prompt.php
@@ -1,75 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command_ParameterSource_Prompt
- implements Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array())
- {
- // Default value
- $parameterValue = null;
-
- // Prompt the user
- fwrite(STDOUT, "Supply a value for " . $parameter->aliases[0] . ": ");
- /*if ($parameter->description != '' && !is_null($parameter->description)) {
- fwrite(STDOUT, $parameter->description . ".\r\n");
- }*/
-
- while (is_null($parameterValue) || $parameterValue == '') {
- $parameterValue = trim(fgets(STDIN));
- }
-
- // Done!
- return $parameterValue;
- }
-}
View
90 GuestBookUsingBlobs/WebRole/Microsoft/Console/Command/ParameterSource/StdIn.php
@@ -1,90 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../../../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Command_ParameterSource_StdIn
- implements Microsoft_Console_Command_ParameterSource_ParameterSourceInterface
-{
- /**
- * Get value for a named parameter.
- *
- * @param mixed $parameter Parameter to get a value for
- * @param array $argv Argument values passed to the script when run in console.
- * @return mixed
- */
- public function getValueForParameter($parameter, $argv = array())
- {
- // Default value
- $parameterValue = null;
-
- // Check STDIN for data
- if (ftell(STDIN) !== false) {
- // Read from STDIN
- $fs = fopen("php://stdin", "r");
- if ($fs !== false) {
- /*
- while (!feof($fs)) {
- $data = fread($fs, 1);
- var_dump($data);
- $parameterValue .= $data;
- } */
- $parameterValue = stream_get_contents($fs);
- fclose($fs);
- }
-
- // Remove ending \r\n
- $parameterValue = rtrim($parameterValue);
-
- if (strtolower($parameterValue) == 'true') {
- $parameterValue = true;
- } else if (strtolower($parameterValue) == 'false') {
- $parameterValue = false;
- }
- }
-
- // Done!
- return $parameterValue;
- }
-}
View
48 GuestBookUsingBlobs/WebRole/Microsoft/Console/Exception.php
@@ -1,48 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft_Console
- * @subpackage Exception
- * @version $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft_Console
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Console_Exception extends Microsoft_Exception
-{}
View
47 GuestBookUsingBlobs/WebRole/Microsoft/Exception.php
@@ -1,47 +0,0 @@
-<?php
-/**
- * Copyright (c) 2009 - 2011, RealDolmen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of RealDolmen nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Microsoft
- * @package Microsoft
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/AutoLoader.php';
-
-/**
- * @category Microsoft
- * @package Microsoft
- * @subpackage Exception
- * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @license http://phpazure.codeplex.com/license
- */
-class Microsoft_Exception extends Exception
-{}
View
1,427 GuestBookUsingBlobs/WebRole/Microsoft/Http/Client.php
@@ -1,1427 +0,0 @@
-<?php
-
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Microsoft
- * @package Microsoft_Http
- * @subpackage Client
- * @version $Id: Client.php 19661 2009-12-15 18:03:07Z matthew $
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-
-/**
- * @see Microsoft_AutoLoader
- */
-require_once dirname(__FILE__) . '/../AutoLoader.php';
-
-/**
- * Microsoft_Http_Client is an implemetation of an HTTP client in PHP. The client
- * supports basic features like sending different HTTP requests and handling
- * redirections, as well as more advanced features like proxy settings, HTTP
- * authentication and cookie persistance (using a Microsoft_Http_CookieJar object)
- *
- * @todo Implement proxy settings
- * @category Microsoft
- * @package Microsoft_Http
- * @subpackage Client
- * @throws Microsoft_Http_Client_Exception
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Microsoft_Http_Client
-{
- /**
- * HTTP request methods
- */
- const GET = 'GET';
- const POST = 'POST';
- const PUT = 'PUT';
- const HEAD = 'HEAD';
- const DELETE = 'DELETE';
- const TRACE = 'TRACE';
- const OPTIONS = 'OPTIONS';
- const CONNECT = 'CONNECT';
- const MERGE = 'MERGE';
-
- /**
- * Supported HTTP Authentication methods
- */
- const AUTH_BASIC = 'basic';
- //const AUTH_DIGEST = 'digest'; <-- not implemented yet
-
- /**
- * HTTP protocol versions
- */
- const HTTP_1 = '1.1';
- const HTTP_0 = '1.0';
-
- /**
- * Content attributes
- */
- const CONTENT_TYPE = 'Content-Type';
- const CONTENT_LENGTH = 'Content-Length';
-
- /**
- * POST data encoding methods
- */
- const ENC_URLENCODED = 'application/x-www-form-urlencoded';
- const ENC_FORMDATA = 'multipart/form-data';
-
- /**
- * Configuration array, set using the constructor or using ::setConfig()
- *
- * @var array
- */
- protected $config = array(
- 'maxredirects' => 5,
- 'strictredirects' => false,
- 'useragent' => 'Microsoft_Http_Client',
- 'timeout' => 10,
- 'adapter' => 'Microsoft_Http_Client_Adapter_Socket',
- 'httpversion' => self::HTTP_1,
- 'keepalive' => false,
- 'storeresponse' => true,
- 'strict' => true,
- 'output_stream' => false,
- );
-
- /**
- * The adapter used to preform the actual connection to the server
- *
- * @var Microsoft_Http_Client_Adapter_Interface
- */
- protected $adapter = null;
-
- /**
- * Request URI
- *
- * @var Microsoft_Uri_Http
- */
- protected $uri = null;
-
- /**
- * Associative array of request headers
- *
- * @var array
- */
- protected $headers = array();
-
- /**
- * HTTP request method
- *
- * @var string
- */
- protected $method = self::GET;
-
- /**
- * Associative array of GET parameters
- *
- * @var array
- */
- protected $paramsGet = array();
-
- /**
- * Assiciative array of POST parameters
- *
- * @var array
- */
- protected $paramsPost = array();
-
- /**
- * Request body content type (for POST requests)
- *
- * @var string
- */
- protected $enctype = null;
-
- /**
- * The raw post data to send. Could be set by setRawData($data, $enctype).
- *
- * @var string
- */
- protected $raw_post_data = null;
-
- /**
- * HTTP Authentication settings
- *
- * Expected to be an associative array with this structure:
- * $this->auth = array('user' => 'username', 'password' => 'password', 'type' => 'basic')
- * Where 'type' should be one of the supported authentication types (see the AUTH_*
- * constants), for example 'basic' or 'digest'.
- *
- * If null, no authentication will be used.
- *
- * @var array|null
- */
- protected $auth;
-
- /**
- * File upload arrays (used in POST requests)
- *
- * An associative array, where each element is of the format:
- * 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')
- *
- * @var array
- */
- protected $files = array();
-
- /**
- * The client's cookie jar
- *
- * @var Microsoft_Http_CookieJar
- */
- protected $cookiejar = null;
-
- /**
- * The last HTTP request sent by the client, as string
- *
- * @var string
- */
- protected $last_request = null;
-
- /**
- * The last HTTP response received by the client
- *
- * @var Microsoft_Http_Response
- */
- protected $last_response = null;
-
- /**
- * Redirection counter
- *
- * @var int
- */
- protected $redirectCounter = 0;
-
- /**
- * Fileinfo magic database resource
- *
- * This varaiable is populated the first time _detectFileMimeType is called
- * and is then reused on every call to this method
- *
- * @var resource
- */
- static protected $_fileInfoDb = null;
-
- /**
- * Contructor method. Will create a new HTTP client. Accepts the target
- * URL and optionally configuration array.
- *
- * @param Microsoft_Uri_Http|string $uri
- * @param array $config Configuration key-value pairs.
- */
- public function __construct($uri = null, $config = null)
- {
- if ($uri !== null) {
- $this->setUri($uri);
- }
- if ($config !== null) {
- $this->setConfig($config);
- }
- }
-
- /**
- * Set the URI for the next request
- *
- * @param Microsoft_Uri_Http|string $uri
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setUri($uri)
- {
- if (is_string($uri)) {
- $uri = Microsoft_Uri::factory($uri);
- }
-
- if (!$uri instanceof Microsoft_Uri_Http) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Passed parameter is not a valid HTTP URI.');
- }
-
- // Set auth if username and password has been specified in the uri
- if ($uri->getUsername() && $uri->getPassword()) {
- $this->setAuth($uri->getUsername(), $uri->getPassword());
- }
-
- // We have no ports, set the defaults
- if (! $uri->getPort()) {
- $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80));
- }
-
- $this->uri = $uri;
-
- return $this;
- }
-
- /**
- * Get the URI for the next request
- *
- * @param boolean $as_string If true, will return the URI as a string
- * @return Microsoft_Uri_Http|string
- */
- public function getUri($as_string = false)
- {
- if ($as_string && $this->uri instanceof Microsoft_Uri_Http) {
- return $this->uri->__toString();
- } else {
- return $this->uri;
- }
- }
-
- /**
- * Set configuration parameters for this HTTP client
- *
- * @param Microsoft_Config | array $config
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setConfig($config = array())
- {
- if ($config instanceof Microsoft_Config) {
- $config = $config->toArray();
-
- } elseif (! is_array($config)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Array expected, got ' . gettype($config));
- }
-
- foreach ($config as $k => $v) {
- $this->config[strtolower($k)] = $v;
- }
-
- // Pass configuration options to the adapter if it exists
- if ($this->adapter instanceof Microsoft_Http_Client_Adapter_Interface) {
- $this->adapter->setConfig($config);
- }
-
- return $this;
- }
-
- /**
- * Set the next request's method
- *
- * Validated the passed method and sets it. If we have files set for
- * POST requests, and the new method is not POST, the files are silently
- * dropped.
- *
- * @param string $method
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setMethod($method = self::GET)
- {
- if (! preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("'{$method}' is not a valid HTTP request method.");
- }
-
- if ($method == self::POST && $this->enctype === null) {
- $this->setEncType(self::ENC_URLENCODED);
- }
-
- $this->method = $method;
-
- return $this;
- }
-
- /**
- * Set one or more request headers
- *
- * This function can be used in several ways to set the client's request
- * headers:
- * 1. By providing two parameters: $name as the header to set (eg. 'Host')
- * and $value as it's value (eg. 'www.example.com').
- * 2. By providing a single header string as the only parameter
- * eg. 'Host: www.example.com'
- * 3. By providing an array of headers as the first parameter
- * eg. array('host' => 'www.example.com', 'x-foo: bar'). In This case
- * the function will call itself recursively for each array item.
- *
- * @param string|array $name Header name, full header string ('Header: value')
- * or an array of headers
- * @param mixed $value Header value or null
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setHeaders($name, $value = null)
- {
- // If we got an array, go recusive!
- if (is_array($name)) {
- foreach ($name as $k => $v) {
- if (is_string($k)) {
- $this->setHeaders($k, $v);
- } else {
- $this->setHeaders($v, null);
- }
- }
- } else {
- // Check if $name needs to be split
- if ($value === null && (strpos($name, ':') > 0)) {
- list($name, $value) = explode(':', $name, 2);
- }
-
- // Make sure the name is valid if we are in strict mode
- if ($this->config['strict'] && (! preg_match('/^[a-zA-Z0-9-]+$/', $name))) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("{$name} is not a valid HTTP header name");
- }
-
- $normalized_name = strtolower($name);
-
- // If $value is null or false, unset the header
- if ($value === null || $value === false) {
- unset($this->headers[$normalized_name]);
-
- // Else, set the header
- } else {
- // Header names are stored lowercase internally.
- if (is_string($value)) {
- $value = trim($value);
- }
- $this->headers[$normalized_name] = array($name, $value);
- }
- }
-
- return $this;
- }
-
- /**
- * Get the value of a specific header
- *
- * Note that if the header has more than one value, an array
- * will be returned.
- *
- * @param string $key
- * @return string|array|null The header value or null if it is not set
- */
- public function getHeader($key)
- {
- $key = strtolower($key);
- if (isset($this->headers[$key])) {
- return $this->headers[$key][1];
- } else {
- return null;
- }
- }
-
- /**
- * Set a GET parameter for the request. Wrapper around _setParameter
- *
- * @param string|array $name
- * @param string $value
- * @return Microsoft_Http_Client
- */
- public function setParameterGet($name, $value = null)
- {
- if (is_array($name)) {
- foreach ($name as $k => $v)
- $this->_setParameter('GET', $k, $v);
- } else {
- $this->_setParameter('GET', $name, $value);
- }
-
- return $this;
- }
-
- /**
- * Set a POST parameter for the request. Wrapper around _setParameter
- *
- * @param string|array $name
- * @param string $value
- * @return Microsoft_Http_Client
- */
- public function setParameterPost($name, $value = null)
- {
- if (is_array($name)) {
- foreach ($name as $k => $v)
- $this->_setParameter('POST', $k, $v);
- } else {
- $this->_setParameter('POST', $name, $value);
- }
-
- return $this;
- }
-
- /**
- * Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
- *
- * @param string $type GET or POST
- * @param string $name
- * @param string $value
- * @return null
- */
- protected function _setParameter($type, $name, $value)
- {
- $parray = array();
- $type = strtolower($type);
- switch ($type) {
- case 'get':
- $parray = &$this->paramsGet;
- break;
- case 'post':
- $parray = &$this->paramsPost;
- break;
- }
-
- if ($value === null) {
- if (isset($parray[$name])) unset($parray[$name]);
- } else {
- $parray[$name] = $value;
- }
- }
-
- /**
- * Get the number of redirections done on the last request
- *
- * @return int
- */
- public function getRedirectionsCount()
- {
- return $this->redirectCounter;
- }
-
- /**
- * Set HTTP authentication parameters
- *
- * $type should be one of the supported types - see the self::AUTH_*
- * constants.
- *
- * To enable authentication:
- * <code>
- * $this->setAuth('shahar', 'secret', Microsoft_Http_Client::AUTH_BASIC);
- * </code>
- *
- * To disable authentication:
- * <code>
- * $this->setAuth(false);
- * </code>
- *
- * @see http://www.faqs.org/rfcs/rfc2617.html
- * @param string|false $user User name or false disable authentication
- * @param string $password Password
- * @param string $type Authentication type
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setAuth($user, $password = '', $type = self::AUTH_BASIC)
- {
- // If we got false or null, disable authentication
- if ($user === false || $user === null) {
- $this->auth = null;
-
- // Clear the auth information in the uri instance as well
- if ($this->uri instanceof Microsoft_Uri_Http) {
- $this->getUri()->setUsername('');
- $this->getUri()->setPassword('');
- }
- // Else, set up authentication
- } else {
- // Check we got a proper authentication type
- if (! defined('self::AUTH_' . strtoupper($type))) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Invalid or not supported authentication type: '$type'");
- }
-
- $this->auth = array(
- 'user' => (string) $user,
- 'password' => (string) $password,
- 'type' => $type
- );
- }
-
- return $this;
- }
-
- /**
- * Set the HTTP client's cookie jar.
- *
- * A cookie jar is an object that holds and maintains cookies across HTTP requests
- * and responses.
- *
- * @param Microsoft_Http_CookieJar|boolean $cookiejar Existing cookiejar object, true to create a new one, false to disable
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setCookieJar($cookiejar = true)
- {
- if (! class_exists('Microsoft_Http_CookieJar')) {
- require_once 'Microsoft/Http/CookieJar.php';
- }
-
- if ($cookiejar instanceof Microsoft_Http_CookieJar) {
- $this->cookiejar = $cookiejar;
- } elseif ($cookiejar === true) {
- $this->cookiejar = new Microsoft_Http_CookieJar();
- } elseif (! $cookiejar) {
- $this->cookiejar = null;
- } else {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Invalid parameter type passed as CookieJar');
- }
-
- return $this;
- }
-
- /**
- * Return the current cookie jar or null if none.
- *
- * @return Microsoft_Http_CookieJar|null
- */
- public function getCookieJar()
- {
- return $this->cookiejar;
- }
-
- /**
- * Add a cookie to the request. If the client has no Cookie Jar, the cookies
- * will be added directly to the headers array as "Cookie" headers.
- *
- * @param Microsoft_Http_Cookie|string $cookie
- * @param string|null $value If "cookie" is a string, this is the cookie value.
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setCookie($cookie, $value = null)
- {
- if (! class_exists('Microsoft_Http_Cookie')) {
- require_once 'Microsoft/Http/Cookie.php';
- }
-
- if (is_array($cookie)) {
- foreach ($cookie as $c => $v) {
- if (is_string($c)) {
- $this->setCookie($c, $v);
- } else {
- $this->setCookie($v);
- }
- }
-
- return $this;
- }
-
- if ($value !== null) {
- $value = urlencode($value);
- }
-
- if (isset($this->cookiejar)) {
- if ($cookie instanceof Microsoft_Http_Cookie) {
- $this->cookiejar->addCookie($cookie);
- } elseif (is_string($cookie) && $value !== null) {
- $cookie = Microsoft_Http_Cookie::fromString("{$cookie}={$value}", $this->uri);
- $this->cookiejar->addCookie($cookie);
- }
- } else {
- if ($cookie instanceof Microsoft_Http_Cookie) {
- $name = $cookie->getName();
- $value = $cookie->getValue();
- $cookie = $name;
- }
-
- if (preg_match("/[=,; \t\r\n\013\014]/", $cookie)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})");
- }
-
- $value = addslashes($value);
-
- if (! isset($this->headers['cookie'])) {
- $this->headers['cookie'] = array('Cookie', '');
- }
- $this->headers['cookie'][1] .= $cookie . '=' . $value . '; ';
- }
-
- return $this;
- }
-
- /**
- * Set a file to upload (using a POST request)
- *
- * Can be used in two ways:
- *
- * 1. $data is null (default): $filename is treated as the name if a local file which
- * will be read and sent. Will try to guess the content type using mime_content_type().
- * 2. $data is set - $filename is sent as the file name, but $data is sent as the file
- * contents and no file is read from the file system. In this case, you need to
- * manually set the Content-Type ($ctype) or it will default to
- * application/octet-stream.
- *
- * @param string $filename Name of file to upload, or name to save as
- * @param string $formname Name of form element to send as
- * @param string $data Data to send (if null, $filename is read and sent)
- * @param string $ctype Content type to use (if $data is set and $ctype is
- * null, will be application/octet-stream)
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setFileUpload($filename, $formname, $data = null, $ctype = null)
- {
- if ($data === null) {
- if (($data = @file_get_contents($filename)) === false) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Unable to read file '{$filename}' for upload");
- }
-
- if (! $ctype) {
- $ctype = $this->_detectFileMimeType($filename);
- }
- }
-
- // Force enctype to multipart/form-data
- $this->setEncType(self::ENC_FORMDATA);
-
- $this->files[] = array(
- 'formname' => $formname,
- 'filename' => basename($filename),
- 'ctype' => $ctype,
- 'data' => $data
- );
-
- return $this;
- }
-
- /**
- * Set the encoding type for POST data
- *
- * @param string $enctype
- * @return Microsoft_Http_Client
- */
- public function setEncType($enctype = self::ENC_URLENCODED)
- {
- $this->enctype = $enctype;
-
- return $this;
- }
-
- /**
- * Set the raw (already encoded) POST data.
- *
- * This function is here for two reasons:
- * 1. For advanced user who would like to set their own data, already encoded
- * 2. For backwards compatibilty: If someone uses the old post($data) method.
- * this method will be used to set the encoded data.
- *
- * $data can also be stream (such as file) from which the data will be read.
- *
- * @param string|resource $data
- * @param string $enctype
- * @return Microsoft_Http_Client
- */
- public function setRawData($data, $enctype = null)
- {
- $this->raw_post_data = $data;
- $this->setEncType($enctype);
- if (is_resource($data)) {
- // We've got stream data
- $stat = @fstat($data);
- if($stat) {
- $this->setHeaders(self::CONTENT_LENGTH, $stat['size']);
- }
- }
- return $this;
- }
-
- /**
- * Clear all GET and POST parameters
- *
- * Should be used to reset the request parameters if the client is
- * used for several concurrent requests.
- *
- * clearAll parameter controls if we clean just parameters or also
- * headers and last_*
- *
- * @param bool $clearAll Should all data be cleared?
- * @return Microsoft_Http_Client
- */
- public function resetParameters($clearAll = false)
- {
- // Reset parameter data
- $this->paramsGet = array();
- $this->paramsPost = array();
- $this->files = array();
- $this->raw_post_data = null;
-
- if($clearAll) {
- $this->headers = array();
- $this->last_request = null;
- $this->last_response = null;
- } else {
- // Clear outdated headers
- if (isset($this->headers[strtolower(self::CONTENT_TYPE)])) {
- unset($this->headers[strtolower(self::CONTENT_TYPE)]);
- }
- if (isset($this->headers[strtolower(self::CONTENT_LENGTH)])) {
- unset($this->headers[strtolower(self::CONTENT_LENGTH)]);
- }
- }
-
- return $this;
- }
-
- /**