Explorar o código

Kodowanie wszystkich plików php, w tym tylko newralgicznych dla domeny

Mariusz Muszyński %!s(int64=8) %!d(string=hai) anos
pai
achega
2e2ecaa337
Modificáronse 1 ficheiros con 52 adicións e 0 borrados
  1. 52 0
      SE/se-lib/Route/Install.php

+ 52 - 0
SE/se-lib/Route/Install.php

@@ -272,6 +272,7 @@ jQuery(document).ready(function () {
 		}
 
 		{
+/*
 			$phpFiles = array();
 			$skipPhpFiles = array();
 			$skipPhpFiles[] = 'bash_sync_perms.php';
@@ -325,9 +326,41 @@ jQuery(document).ready(function () {
 
 			DBG::_(true, true, 'phpFiles', $phpFiles, __CLASS__, __FUNCTION__, __LINE__);
 			if (empty($phpFiles)) throw new Exception("No php files to encode");
+*/
+
+			$domainEncodePhpFiles = [
+				'ant.php',
+				'api.php',
+				'budynki.php',
+				'index-ajax.php',
+				'index.php',
+				'procesy5.php',
+				'session-expire.php',
+				'test-sync.php',
+				'wfs-data.php',
+				'wfs-qgis.php',
+				'wfs.php',
+                        ];
+			$freeEncodePhpFiles = [];
+
+			$cmd = "cd {$installPath}/SE && find . -name '*.php' ";
+			$out = ''; $ret = '';
+			exec($cmd, $out, $ret);
+			echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
+			if (0 !== $ret) throw new Exception("Error at find php files");
+			if (empty($out)) throw new Exception("No php files found");
+			foreach ($out as $phpFilePath) {
+				$phpFilePath = ('./' == substr($phpFilePath, 0, 2))? substr($phpFilePath, 2) : $phpFilePath;
+				if (in_array($phpFilePath, $domainEncodePhpFiles)) continue;
+				$freeEncodePhpFiles[] = $phpFilePath;
+			}
+
+			DBG::_(true, true, 'freeEncodePhpFiles', $freeEncodePhpFiles, __CLASS__, __FUNCTION__, __LINE__);
+			if (empty($freeEncodePhpFiles)) throw new Exception("No php files to encode");
 		}
 
 		{
+/*
 			$cmd = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder {$phpVersionsForSgencoder} -b- ";
 			foreach ($appLicenceInfo->domains as $domain) {
 				$cmd .= " --domain {$domain} ";
@@ -339,6 +372,25 @@ jQuery(document).ready(function () {
 			echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
 			if (0 !== $ret) throw new Exception("Error at encode files");
 			if (empty($out)) throw new Exception("No output for encode files command");
+*/
+
+			$cmdTempl = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder {$phpVersionsForSgencoder} -b- ";
+			$cmdDomainEncodeDomainsTempl = " --domain " . implode(" --domain ", array_merge($appLicenceInfo->domains, ['localhost']));
+			$cmdDomainEncodeFilesTempl = " " . implode(" ", $domainEncodePhpFiles);
+			$cmdFreeEncodeFilesTempl = " " . implode(" ", $freeEncodePhpFiles);
+
+			$cmds = [
+				$cmdTempl . $cmdDomainEncodeDomainsTempl . $cmdDomainEncodeFilesTempl,
+				$cmdTempl . $cmdFreeEncodeFilesTempl,
+			];
+
+			foreach ($cmds as $cmd) {
+				$out = ''; $ret = '';
+				exec($cmd, $out, $ret);
+				echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
+				if (0 !== $ret) throw new Exception("Error at encode files");
+				if (empty($out)) throw new Exception("No output for encode files command");
+			}
 		}
 	}