|
|
|
@ -171,7 +171,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @see \Mage\Task\AbstractTask::getName() |
|
|
|
|
*/ |
|
|
|
|
public function getName() { |
|
|
|
|
public function getName() |
|
|
|
|
{ |
|
|
|
|
return $this->name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -180,7 +181,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @see \Mage\Task\AbstractTask::init() |
|
|
|
|
*/ |
|
|
|
|
public function init() { |
|
|
|
|
public function init() |
|
|
|
|
{ |
|
|
|
|
// Set the default extensions to ignore |
|
|
|
|
$this->checkIgnoreExtens = array( |
|
|
|
|
'jpg', |
|
|
|
@ -324,7 +326,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* @return bool |
|
|
|
|
* @throws \Mage\Task\ErrorWithMessageException |
|
|
|
|
*/ |
|
|
|
|
public function run() { |
|
|
|
|
public function run() |
|
|
|
|
{ |
|
|
|
|
$this->switchSrcToTmp(); |
|
|
|
|
$this->writeProjectFile(); |
|
|
|
|
$result = $this->runIonCube(); |
|
|
|
@ -351,7 +354,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
private function checkEncoding() { |
|
|
|
|
private function checkEncoding() |
|
|
|
|
{ |
|
|
|
|
$src = $this->source; |
|
|
|
|
// $ask holds flag to indicate we need to prompt the end user |
|
|
|
|
$ask = false; |
|
|
|
@ -407,7 +411,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return bool True if 'y' pressed |
|
|
|
|
*/ |
|
|
|
|
private function promptYn() { |
|
|
|
|
private function promptYn() |
|
|
|
|
{ |
|
|
|
|
$handle = fopen("php://stdin", "r"); |
|
|
|
|
$line = strtolower(fgets($handle)); |
|
|
|
|
if (trim($line) != 'y') { |
|
|
|
@ -428,7 +433,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return boolean True if file was encoded/encrypted |
|
|
|
|
*/ |
|
|
|
|
private function checkFileCoding($filename) { |
|
|
|
|
private function checkFileCoding($filename) |
|
|
|
|
{ |
|
|
|
|
// check to see if this is an encrypted file |
|
|
|
|
$ioncube = ioncube_read_file($filename, $ioncubeType); |
|
|
|
|
if (is_int($ioncube)) { |
|
|
|
@ -461,7 +467,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
private function deleteTmpFiles() { |
|
|
|
|
private function deleteTmpFiles() |
|
|
|
|
{ |
|
|
|
|
if (isset ($this->mageConfig ['keeptemp'])) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -480,7 +487,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
private function runIonCube() { |
|
|
|
|
private function runIonCube() |
|
|
|
|
{ |
|
|
|
|
$cli = $this->encoder . ' --project-file ' . $this->projectFile . ' ' . $this->ionSource . DIRECTORY_SEPARATOR . '*'; |
|
|
|
|
$ret = Console::executeCommand($cli, $out); |
|
|
|
|
return $ret; |
|
|
|
@ -495,7 +503,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
private function writeProjectFile() { |
|
|
|
|
private function writeProjectFile() |
|
|
|
|
{ |
|
|
|
|
// array used to build config file into |
|
|
|
|
$out = array(); |
|
|
|
|
// set the project destination |
|
|
|
@ -535,7 +544,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return array Final config array |
|
|
|
|
*/ |
|
|
|
|
private function mergeConfigFiles() { |
|
|
|
|
private function mergeConfigFiles() |
|
|
|
|
{ |
|
|
|
|
/* |
|
|
|
|
* Options are the order the arrays are in |
|
|
|
|
* F - Project File |
|
|
|
@ -591,7 +601,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
private function switchSrcToTmp() { |
|
|
|
|
private function switchSrcToTmp() |
|
|
|
|
{ |
|
|
|
|
$ret = Console::executeCommand('mv ' . $this->source . ' ' . $this->ionSource, $out); |
|
|
|
|
if (!$ret) { |
|
|
|
|
throw new ErrorWithMessageException ('Cant create tmp dir :' . $out, $ret); |
|
|
|
@ -611,7 +622,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* return array |
|
|
|
|
*/ |
|
|
|
|
private function getOptionsFromYaml($options) { |
|
|
|
|
private function getOptionsFromYaml($options) |
|
|
|
|
{ |
|
|
|
|
$s = array(); |
|
|
|
|
$p = array(); |
|
|
|
|
foreach ($options as $key => $value) { |
|
|
|
@ -635,7 +647,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* @param $fileName |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
private function getOptionsFromFile($fileName) { |
|
|
|
|
private function getOptionsFromFile($fileName) |
|
|
|
|
{ |
|
|
|
|
$s = array(); |
|
|
|
|
$p = array(); |
|
|
|
|
$fileContents = file_get_contents($fileName); |
|
|
|
@ -693,7 +706,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
|
private function splitParam($string) { |
|
|
|
|
private function splitParam($string) |
|
|
|
|
{ |
|
|
|
|
$split = explode(PHP_EOL, $string); |
|
|
|
|
if ($split === false) { |
|
|
|
|
// nothing found, so return a blank string |
|
|
|
@ -715,7 +729,8 @@ class EncryptTask extends AbstractTask
|
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
private function getOptionsDefault() { |
|
|
|
|
private function getOptionsDefault() |
|
|
|
|
{ |
|
|
|
|
$s = array(); |
|
|
|
|
$p = array(); |
|
|
|
|
// Set the switches |
|
|
|
|