|
|
@@ -396,6 +396,7 @@ jQuery(document).ready(function () {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
$this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
$this->_encodeSource($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
+ $this->_encodeConfigs($appLicenceInfo->configPath);
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
@@ -508,6 +509,62 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function _encodeConfigs($configPath) {
|
|
|
+ $cmd = "find . -name '*.inc.php' ";
|
|
|
+ $out = ''; $ret = '';
|
|
|
+ V::exec("cd {$configPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
|
|
|
+ $freeEncodePhpFiles = $out;
|
|
|
+
|
|
|
+ $phpVersionsForSgencoder = '--phpversion 5.5 --phpversion 5.6';// encode for PHP 5.x (currently supported PHP 5.0-5.6)
|
|
|
+ $cmdTempl = "cd {$configPath} && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder {$phpVersionsForSgencoder} -b- ";
|
|
|
+ $cmdDomainEncodeDomainsTempl = " --domain " . implode(" --domain ", array_merge($domains, ['localhost']));
|
|
|
+ // $cmdDomainEncodeFilesTempl = " " . implode(" ", $domainEncodePhpFiles);
|
|
|
+ $cmdFreeEncodeFilesTempl = " " . implode(" ", $freeEncodePhpFiles);
|
|
|
+
|
|
|
+ $cmds = [
|
|
|
+ // $cmdTempl . $cmdDomainEncodeDomainsTempl . $cmdDomainEncodeFilesTempl,
|
|
|
+ $cmdTempl . $cmdFreeEncodeFilesTempl,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $dbg = true;
|
|
|
+ $returnValues = [];
|
|
|
+ foreach ($cmds as $cmd) {
|
|
|
+ $out = ''; $ret = '';
|
|
|
+ V::exec($cmd, $out, $ret);
|
|
|
+ $encoderSummaryLine = end($out);
|
|
|
+ $returnValues[] = $encoderSummaryLine;
|
|
|
+ if ($dbg) {
|
|
|
+ DBG::nicePrint([$cmd], "cmd");
|
|
|
+ DBG::nicePrint($out, "return: '{$ret}'");
|
|
|
+ // DBG::nicePrint([$encoderSummaryLine], "cmd last line");
|
|
|
+ }
|
|
|
+ else DBG::log([$cmd, $out], 'array', "cmd return:'{$ret}'");
|
|
|
+ // if (0 !== $ret) throw new Exception("Error at encode files");
|
|
|
+ if (empty($out)) throw new Exception("No output for encode files command");
|
|
|
+ }
|
|
|
+ $statusInfo = array_reduce($returnValues, function ($ret, $encoderSummaryLine) {
|
|
|
+ DBG::log([$ret, $encoderSummaryLine], 'array', "DBG reduce [\$ret, \$encoderSummaryLine]");
|
|
|
+ $matches = [];
|
|
|
+ preg_match_all('/(\d+) files, (\d+) processed, (\d+) errors/', $encoderSummaryLine, $matches, PREG_SET_ORDER, 0);
|
|
|
+ return [
|
|
|
+ 'files' => $ret['files'] + (int)$matches[0][1],
|
|
|
+ 'processed' => $ret['processed'] + (int)$matches[0][2],
|
|
|
+ 'errors' => $ret['errors'] + (int)$matches[0][3],
|
|
|
+ ];
|
|
|
+ }, [
|
|
|
+ 'files' => 0,
|
|
|
+ 'processed' => 0,
|
|
|
+ 'errors' => 0,
|
|
|
+ ]);
|
|
|
+ if ($statusInfo['errors'] === 0 && $statusInfo['files'] > 0) {
|
|
|
+ if ($dbg) UI::alert('success', "{$statusInfo['files']} files, {$statusInfo['processed']} processed, {$statusInfo['errors']} errors");
|
|
|
+ } else {
|
|
|
+ if ($dbg) UI::alert('danger', "{$statusInfo['files']} files, {$statusInfo['processed']} processed, {$statusInfo['errors']} errors");
|
|
|
+ else throw new Exception("{$statusInfo['files']} files, {$statusInfo['processed']} processed, {$statusInfo['errors']} errors");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function getAppLicenceInfo($idLicence) {
|
|
|
$idLicence = intval($idLicence);
|
|
|
if (empty($idLicence)) throw new Exception("Nie wybrano serwera/licencji.");
|