--- a/web/lib/Zend/Service/WindowsAzure/CommandLine/Package.php Thu May 07 15:10:09 2015 +0200
+++ b/web/lib/Zend/Service/WindowsAzure/CommandLine/Package.php Thu May 07 15:16:02 2015 +0200
@@ -16,24 +16,31 @@
* @package Zend_Service_Console
* @subpackage Exception
* @version $Id$
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
+/** @see Zend_Xml_Security */
+require_once 'Zend/Xml/Security.php';
+
+/**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
/**
* Package commands
- *
+ *
* @category Zend
* @package Zend_Service_WindowsAzure_CommandLine
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- *
+ *
* @command-handler package
* @command-handler-description Windows Azure Package commands
* @command-handler-header Windows Azure SDK for PHP
* @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer
+ * @command-handler-footer
* @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
* @command-handler-footer The parameter file is a simple INI file carrying one parameter
* @command-handler-footer value per line. It accepts the same parameters as one can
@@ -41,15 +48,15 @@
*/
class Zend_Service_WindowsAzure_CommandLine_Package
extends Zend_Service_Console_Command
-{
+{
/**
* Scaffolds a Windows Azure project structure which can be customized before packaging.
- *
+ *
* @command-name Scaffold
* @command-description Scaffolds a Windows Azure project structure which can be customized before packaging.
- *
+ *
* @command-parameter-for $path Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to create the Windows Azure project structure.
- * @command-parameter-for $scaffolder Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Scaffolder|-s Optional. The path to the scaffolder to use. Defaults to Scaffolders/DefaultScaffolder.phar
+ * @command-parameter-for $scaffolder Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Scaffolder|-s Optional. The path to the scaffolder to use. Defaults to Scaffolders/DefaultScaffolder.phar
*/
public function scaffoldCommand($path, $scaffolder, $argv)
{
@@ -58,13 +65,13 @@
$scaffolder = dirname(__FILE__) . '/Scaffolders/DefaultScaffolder.phar';
}
$scaffolder = realpath($scaffolder);
-
+
// Verify scaffolder
if (!is_file($scaffolder)) {
require_once 'Zend/Service/Console/Exception.php';
throw new Zend_Service_Console_Exception('Could not locate the given scaffolder: ' . $scaffolder);
}
-
+
// Include scaffolder
$archive = new Phar($scaffolder);
include $scaffolder;
@@ -72,7 +79,7 @@
require_once 'Zend/Service/Console/Exception.php';
throw new Zend_Service_Console_Exception('Could not locate a class named Scaffolder in the given scaffolder: ' . $scaffolder . '. Make sure the scaffolder package contains a file named index.php and contains a class named Scaffolder.');
}
-
+
// Cleanup $argv
$options = array();
foreach ($argv as $arg) {
@@ -82,22 +89,22 @@
}
$options[$key] = $value;
}
-
+
// Run scaffolder
$scaffolderInstance = new Scaffolder();
$scaffolderInstance->invoke($archive, $path, $options);
}
-
+
/**
* Packages a Windows Azure project structure.
- *
+ *
* @command-name Create
* @command-description Packages a Windows Azure project structure.
- *
+ *
* @command-parameter-for $path Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to package.
* @command-parameter-for $runDevFabric Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RunDevFabric|-dev Required. Switch. Run and deploy to the Windows Azure development fabric.
- * @command-parameter-for $outputPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutputPath|-out Optional. The output path for the resulting package.
+ * @command-parameter-for $outputPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutputPath|-out Optional. The output path for the resulting package.
*/
public function createPackageCommand($path, $runDevFabric, $outputPath)
{
@@ -118,14 +125,14 @@
}
$cspack = '"' . $windowsAzureSdkFolderCandidates[0] . '\cspack.exe' . '"';
$csrun = '"' . $windowsAzureSdkFolderCandidates[0] . '\csrun.exe' . '"';
-
+
// Open the ServiceDefinition.csdef file and check for role paths
$serviceDefinitionFile = $path . '/ServiceDefinition.csdef';
if (!file_exists($serviceDefinitionFile)) {
require_once 'Zend/Service/Console/Exception.php';
throw new Zend_Service_Console_Exception('Could not locate ServiceDefinition.csdef at ' . $serviceDefinitionFile . '.');
}
- $serviceDefinition = simplexml_load_file($serviceDefinitionFile);
+ $serviceDefinition = Zend_Xml_Security::scanFile($serviceDefinitionFile);
$xmlRoles = array();
if ($serviceDefinition->WebRole) {
if (count($serviceDefinition->WebRole) > 1) {
@@ -141,7 +148,7 @@
$xmlRoles = array_merge($xmlRoles, array($serviceDefinition->WorkerRole));
}
}
-
+
// Build '/role:' command parameter
$roleArgs = array();
foreach ($xmlRoles as $xmlRole) {
@@ -149,7 +156,7 @@
$roleArgs[] = '/role:' . $xmlRole["name"] . ';' . realpath($path . '/' . $xmlRole["name"]);
}
}
-
+
// Build command
$command = $cspack;
$args = array(
@@ -161,14 +168,14 @@
$args[] = '/copyOnly';
}
passthru($command . ' ' . implode(' ', $args));
-
+
// Can we copy a configuration file?
$serviceConfigurationFile = $path . '/ServiceConfiguration.cscfg';
$serviceConfigurationFileOut = $outputPath . '/ServiceConfiguration.cscfg';
if (file_exists($serviceConfigurationFile) && !file_exists($serviceConfigurationFileOut)) {
copy($serviceConfigurationFile, $serviceConfigurationFileOut);
}
-
+
// Do we have to start the development fabric?
if ($runDevFabric) {
passthru($csrun . ' /devstore:start /devfabric:start');
@@ -176,13 +183,13 @@
passthru($csrun . ' /run:"' . $packageOut . ';' . $serviceConfigurationFileOut . '" /launchBrowser');
}
}
-
+
/**
* Creates a scaffolder from a given path.
- *
+ *
* @command-name CreateScaffolder
* @command-description Creates a scaffolder from a given path.
- *
+ *
* @command-parameter-for $rootPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to package into a scaffolder.
* @command-parameter-for $scaffolderFile Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutFile|-out Required. The filename of the scaffolder.
*/
@@ -195,4 +202,4 @@
realpath($rootPath));
}
}
-Zend_Service_Console_Command::bootstrap($_SERVER['argv']);
\ No newline at end of file
+Zend_Service_Console_Command::bootstrap($_SERVER['argv']);