浏览代码

Merge branch 'master' of ssh://biuro.biall-net.pl:2222/plabudda/se

a.binder 8 年之前
父节点
当前提交
19a4eac9eb

+ 33 - 0
SE/se-lib/Config.php

@@ -22,6 +22,8 @@
  *
  * TODO: dziedziczenie plikow na podstawie hosta - kropki? dla hosta www2.biall.com.pl i www.biall.com.pl dziedziczy po: biall.com.pl
  *
+ * If conf file not found '.cnf*.ini.php' then try to find file '.cnf*.inc.php'
+ *
  * Struktura pliku .cnf*.ini.php
 ;<?php
 ;die(); // For further security
@@ -39,6 +41,17 @@ Array
             [foo1] => bar1
         )
 )
+ *
+ * Struktura pliku .cnf*.inc.php
+<?php
+return function ($secret = '') {
+	if ('secret-p5-password' !== $secret) return null;
+	$conf = [
+		'host' => "",
+		// ...
+	];
+	return $conf;
+};
  */
 
 class Config {
@@ -120,6 +133,26 @@ class Config {
 			}
 		}
 
+		try {
+			if (empty($_cnf[$conf_file])) {
+				$file_suffix = '.inc.php';
+				$search_for_files[] = APP_PATH_CONFIG . DS . $file_prefix . '-' . $host . $file_suffix;
+				$search_for_files[] = APP_PATH_CONFIG . DS . $file_prefix . '-' . $host_parent . $file_suffix;
+				$search_for_files[] = APP_PATH_CONFIG . DS . $file_prefix . $file_suffix;
+				foreach ($search_for_files as $f) {
+					if (1 == V::get('DBG_CNF', '', $_GET)) { echo "f(" . end(explode('/',$f)) . ")=(" . file_exists($f) . ")"; }
+					if (file_exists($f)) {
+						$fun = include $f;
+						if (!is_callable($fun)) throw new Exception("Config func is not callable");
+						$_cnf[$conf_file] = $fun('secret-p5-password');
+						break;
+					}
+				}
+			}
+		} catch (Exception $e) {
+			DBG::log($e);
+		}
+
 		return $_cnf[$conf_file];
 	}
 

+ 12 - 12
SE/se-lib/Route/Install.php

@@ -347,7 +347,7 @@ jQuery(document).ready(function () {
 		if ('1' == V::get('DBG_ENCODER_HELP', '', $_REQUEST)) {// encoder help
 			$cmd = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --help ";
 			$out = ''; $ret = '';
-			exec($cmd, $out, $ret);
+			V::exec($cmd, $out, $ret);
 			DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
 			exit;
 		}
@@ -368,7 +368,7 @@ jQuery(document).ready(function () {
 
 		$cmd = "find . -name '*.php' ";
 		$out = ''; $ret = '';
-		exec("cd {$installPath}/SE && {$cmd}", $out, $ret);
+		V::exec("cd {$installPath}/SE && {$cmd}", $out, $ret);
 		if ($dbg) DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
 		else DBG::log($out, 'array', "cmd: `{$cmd}` (return:{$ret})");
 		if (0 !== $ret) throw new Exception("Error at find php files");
@@ -397,7 +397,7 @@ jQuery(document).ready(function () {
 		$returnValues = [];
 		foreach ($cmds as $cmd) {
 			$out = ''; $ret = '';
-			exec($cmd, $out, $ret);
+			V::exec($cmd, $out, $ret);
 			$encoderSummaryLine = end($out);
 			$returnValues[] = $encoderSummaryLine;
 			if ($dbg) {
@@ -636,11 +636,11 @@ jQuery(document).ready(function () {
 		$sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
 		$sshArgs = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
 		$scpArgs = (22 != $appLicenceInfo->sshPort)? "-P {$appLicenceInfo->sshPort}" : '';
-		 
+
 		$rsyncSshPort = (22 != $appLicenceInfo->sshPort)? "-e 'ssh -p {$appLicenceInfo->sshPort}'" : '';
-		
-		
-		
+
+
+
 		if (V::get('DBG_REMOTE', '', $_GET)) {// DBG
 			$cmd = "echo ~";
 			V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
@@ -807,10 +807,10 @@ chmod 600 ~/.ssh/authorized_keys;
 		//$cmd = "ssh -i ~/.ssh/id_rsa server@{$appLicenceInfo->mainServer} 'ls -1'";
 		$sshPort = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
 		$cmd = "ssh {$sshPort} {$this->sshArgsSkipHostKey}  {$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer} 'ls -1'";
-		V::exec("$cmd 2>&1", $out, $ret); // http://php.net/manual/pl/function.exec.php says I saw the exec, system, shell_exec and passthru functions, 
-				//and deduced that the solution was to 
-				//redirect the standard error (stderr) to the standard output (stdout). It's not very clean, since it mixes stderr with stdout, and I only wanted to log the stderr. 
-				//But it seems to be the only solution (suggestions are welcome). 
+		V::exec("$cmd 2>&1", $out, $ret); // http://php.net/manual/pl/function.exec.php says I saw the exec, system, shell_exec and passthru functions,
+				//and deduced that the solution was to
+				//redirect the standard error (stderr) to the standard output (stdout). It's not very clean, since it mixes stderr with stdout, and I only wanted to log the stderr.
+				//But it seems to be the only solution (suggestions are welcome).
 
 		DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
 		if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}; Out: ".implode($out)."; Cmd: {$cmd};");
@@ -838,7 +838,7 @@ chmod 600 ~/.ssh/authorized_keys;
 
 		foreach ($cmds as $cmd) {
 			$out = ''; $ret = '';
-			exec($cmd, $out, $ret);
+			V::exec($cmd, $out, $ret);
 			DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
 		}
 		// $this->_encodeSource($appLicenceInfo->installPath, $appLicenceInfo->domains);

+ 7 - 3
SE/se-lib/V.php

@@ -404,8 +404,12 @@ class V {
 	public static function exec($cmd, &$out, &$ret) {
 		$out = null;
 		$ret = null;
-		$path = "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/lib/mysql55/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/pl/programy/bin";
-		$cmd = "{$path}\n{$cmd}";
+		// NOTE: SourceGuardian requires file: "${HOME}/.config/SourceGuardian/"
+		$cmd = implode("\n", [
+			"PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/lib/mysql55/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/pl/programy/bin",
+			"export HOME='/Library/WebServer'",
+			$cmd
+		]);
 		exec($cmd, $out, $ret);
 		return $ret;
 	}
@@ -612,7 +616,7 @@ EOF';
 	public static function isNip($nip) {
 		if (!(is_numeric($nip) && preg_match('/^[[:digit:]]{10}$/', $nip))) return false;
 		$waga = [6, 5, 7, 2, 3, 4, 5, 6, 7];
-		$c = 0; 
+		$c = 0;
 		for ($i = 0; $i < 9; $i++) $c += $nip[$i] * $waga[$i];
 		$c = ($c % 11) % 10;
 		return ($nip[9] == $c);

二进制
SE/stuff/SourceGuardian/Loaders/Linux 32-bit/ixed.5.5.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 32-bit/ixed.5.6.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 32-bit/ixed.7.0.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 32-bit/ixed.7.1.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 64-bit/ixed.5.5.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 64-bit/ixed.5.6.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 64-bit/ixed.7.0.lin


二进制
SE/stuff/SourceGuardian/Loaders/Linux 64-bit/ixed.7.1.lin


二进制
SE/stuff/SourceGuardian/Loaders/Mac OS X/ixed.5.5.dar


二进制
SE/stuff/SourceGuardian/Loaders/Mac OS X/ixed.5.6.dar


二进制
SE/stuff/SourceGuardian/Loaders/Mac OS X/ixed.7.0.dar


二进制
SE/stuff/SourceGuardian/Loaders/Mac OS X/ixed.7.1.dar


+ 4 - 4
SE/superedit-INSTALL_SES_PROCESY_A.php

@@ -707,18 +707,18 @@ if($SERVER_VERSION=='10.12-Sierra') {
 
 
 // Modul ixed do SourceGuardian
-if($SERVER_VERSION=='10.9Maverick') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/Loaders/Mac\ OS\ X/ixed.5.4.dar','/usr/lib/php/extensions/no-debug-non-zts-20100525/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
+if($SERVER_VERSION=='10.9Maverick') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/MacOS/Loaders/Mac\ OS\ X/ixed.5.4.dar','/usr/lib/php/extensions/no-debug-non-zts-20100525/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
 if($SERVER_VERSION=='10.9Maverick') $cmd[]['rsh']='cat /etc/php.ini |grep "extension=ixed.5.4.dar" || echo "\nextension=ixed.5.4.dar\n" >> /etc/php.ini';
 
-if($SERVER_VERSION=='10.10Yosemite') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/Loaders/Mac\ OS\ X/ixed.5.5.dar','/usr/lib/php/extensions/no-debug-non-zts-20121212/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
+if($SERVER_VERSION=='10.10Yosemite') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/MacOS/Loaders/Mac\ OS\ X/ixed.5.5.dar','/usr/lib/php/extensions/no-debug-non-zts-20121212/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
 if($SERVER_VERSION=='10.10Yosemite') $cmd[]['rsh']='cat /etc/php.ini |grep "extension=ixed.5.5.dar" || echo "\nextension=ixed.5.5.dar\n" >> /etc/php.ini';
 
 
-if($SERVER_VERSION=='10.11-ElCapitan') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/Loaders/Mac\ OS\ X/ixed.5.5.dar','/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
+if($SERVER_VERSION=='10.11-ElCapitan') $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/MacOS/Loaders/Mac\ OS\ X/ixed.5.5.dar','/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/');//  $cmd[]['rsh']='installer -package /tmp/MacPorts-2.2.0-10.8-MountainLion.pkg -target "'.$SERVER_MOUNT_POINT_ROOT.'" -verbose';
 if($SERVER_VERSION=='10.11-ElCapitan') $cmd[]['rsh']='cat /etc/php.ini |grep "extension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/ixed.5.5.dar" || echo "\nextension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/ixed.5.5.dar\n" >> /etc/php.ini';
 
 if($SERVER_VERSION=='10.12-Sierra') {
-    $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/Loaders/Mac\ OS\ X/ixed.5.6.dar','/opt/local/lib/php56/extensions/no-debug-non-zts-20131226/');
+    $cmd[]['scp']=array('/Applications/SourceGuardian.app/Contents/MacOS/Loaders/Mac\ OS\ X/ixed.5.6.dar','/opt/local/lib/php56/extensions/no-debug-non-zts-20131226/');
     $cmd[]['rsh']='cat /etc/php.ini |grep "extension=/opt/local/lib/php56/extensions/no-debug-non-zts-20131226/ixed.5.6.dar" || echo "\nextension=/opt/local/lib/php56/extensions/no-debug-non-zts-20131226/ixed.5.6.dar\n" >> /etc/php.ini';
 }