|
@@ -57,60 +57,237 @@ jQuery(document).ready(function () {
|
|
|
SE_Layout::menu();
|
|
SE_Layout::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
|
|
|
|
|
- if (empty($args['licence_id'])) {
|
|
|
|
|
- ?>
|
|
|
|
|
- <div class="alert alert-warning">
|
|
|
|
|
- Nie wybrano serwera/licencji.
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $appLicenceInfo = $this->_fetchAppLicenceInfo($args['licence_id']);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $this->_endWithException($e);
|
|
|
|
|
+ }
|
|
|
|
|
+ //$this->generateApp($args['licence_id']);
|
|
|
|
|
+?>
|
|
|
|
|
+<div class="jumbotron">
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <h3>Generowanie aplikacji dla licencji <?php echo $appLicenceInfo->ID; ?></h3>
|
|
|
|
|
+ <p>Licencja dla domen: <?php echo implode(', ', $appLicenceInfo->domains); ?></p>
|
|
|
|
|
+ <p>Katalog z zakodowanymi plikami: <?php echo $appLicenceInfo->installFolderName; ?></p>
|
|
|
|
|
+ <form class="form-inline" method="POST">
|
|
|
|
|
+ <input type="hidden" name="_task" value="createApp" />
|
|
|
|
|
+ <input type="hidden" name="licence_id" value="<?php echo $appLicenceInfo->ID; ?>" />
|
|
|
|
|
+ <input type="hidden" name="_generateEncryptedSource" value="1" />
|
|
|
|
|
+ <button type="submit" id="fldSbmtBtn" class="btn btn-primary" autocomplete="off">
|
|
|
|
|
+ Generuj
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php if ($appLicenceInfo->installFolderGitExists) : ?>
|
|
|
|
|
+ <br>
|
|
|
|
|
+ <div class="alert alert-info">
|
|
|
|
|
+ Katalog istnieje i zawiera już repozytorium git:
|
|
|
|
|
+ <br> - <a href="index.php?_route=Install&_task=gitResetHard&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
|
|
+ target="_blank"
|
|
|
|
|
+ class="btn btn-xs btn-default">aktualizuj werjsę (git reset --hard, git pull, set SE/VERSION)</a>
|
|
|
|
|
+ <br> - <a href="index.php?_route=Install&_task=encodeSource&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
|
|
+ target="_blank"
|
|
|
|
|
+ class="btn btn-xs btn-default">encode files</a>
|
|
|
|
|
+ <br> send files:
|
|
|
|
|
+ <pre>
|
|
|
|
|
+ ssh server@biuro.galeriaprzymorze.eu 'rm -rf ~/se.encrypted.upgrade/SE'
|
|
|
|
|
+ # scp -r SE server@biuro.galeriaprzymorze.eu:~/se.encrypted.upgrade/
|
|
|
|
|
+ rsync --archive --verbose --update --times --compress --one-file-system --omit-dir-times --no-g --no-perms SE/ server@biuro.galeriaprzymorze.eu:~/se.encrypted.upgrade/SE/
|
|
|
|
|
+ ssh server@biuro.galeriaprzymorze.eu 'ln -s /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/config'
|
|
|
|
|
+ ssh server@biuro.galeriaprzymorze.eu 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
|
|
+ https://biuro.galeriaprzymorze.eu/se.encrypted.upgrade/
|
|
|
|
|
+ </pre>
|
|
|
|
|
+ </ul>
|
|
|
</div>
|
|
</div>
|
|
|
- <?php
|
|
|
|
|
- SE_Layout::dol();
|
|
|
|
|
- exit;
|
|
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</div>
|
|
|
|
|
+<script type="text/javascript">
|
|
|
|
|
+jQuery(document).ready(function () {
|
|
|
|
|
+ jQuery('#fldSbmtBtn').on('click', function () {
|
|
|
|
|
+ jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
|
|
+ jQuery(this).parent().submit();
|
|
|
|
|
+ })
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
|
|
+<?php
|
|
|
|
|
+ $generateEncryptedSource = (1 == V::get('_generateEncryptedSource', 0, $_REQUEST, 'int'));
|
|
|
|
|
+ if ($generateEncryptedSource) {
|
|
|
|
|
+ echo '<div class="container">';
|
|
|
|
|
+ echo '<h4>' . "Generowanie..." . '</h4>';
|
|
|
|
|
+ echo '<div style="border:1px solid silver; max-height:400px; overflow-y:scroll">';
|
|
|
|
|
+ try {
|
|
|
|
|
+ $this->generateApp($appLicenceInfo);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ echo '</div></div>';// .container/ scroll
|
|
|
|
|
+ $this->_endWithException($e);
|
|
|
|
|
+ }
|
|
|
|
|
+ echo '</div>';// .container
|
|
|
|
|
+?>
|
|
|
|
|
+<div class="alert alert-success">
|
|
|
|
|
+ <strong>Gotowe</strong> Aplikacja znajduje się w katalogu <?php echo $appLicenceInfo->installFolderName; ?>
|
|
|
|
|
+</div>
|
|
|
|
|
+<?php
|
|
|
}
|
|
}
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $this->generateApp($args['licence_id']);
|
|
|
|
|
|
|
+ public function gitResetHardAction() {
|
|
|
|
|
+ $args = array();
|
|
|
|
|
+ $args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
|
|
+ SE_Layout::gora();
|
|
|
|
|
+ SE_Layout::menu();
|
|
|
|
|
+ //$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ $appLicenceInfo = $this->_fetchAppLicenceInfo($args['licence_id']);
|
|
|
|
|
+ $this->_gitResetHard($appLicenceInfo);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $this->_endWithException($e);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
SE_Layout::dol();
|
|
SE_Layout::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function generateApp() {
|
|
|
|
|
|
|
+ public function _gitResetHard($appLicenceInfo) {
|
|
|
|
|
+ if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
|
|
+ $installPath = $appLicenceInfo->installPath;
|
|
|
|
|
+ if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
|
|
+
|
|
|
|
|
+ $cmds = array();
|
|
|
|
|
+ $cmds[] = "cd {$installPath} && git reset --hard";
|
|
|
|
|
+ $cmds[] = "cd {$installPath} && git pull";
|
|
|
|
|
+ $cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
|
|
+ foreach ($cmds as $cmd) {
|
|
|
|
|
+ $out = ''; $ret = '';
|
|
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
|
|
+ echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function encodeSourceAction() {
|
|
|
$args = array();
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
- if (empty($args['licence_id'])) {
|
|
|
|
|
- $this->menu();
|
|
|
|
|
- ?>
|
|
|
|
|
- <div class="alert alert-warning">
|
|
|
|
|
- Nie wybrano serwera/licencji.
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php
|
|
|
|
|
- SE_Layout::dol();
|
|
|
|
|
- exit;
|
|
|
|
|
|
|
+ SE_Layout::gora();
|
|
|
|
|
+ SE_Layout::menu();
|
|
|
|
|
+ //$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ $appLicenceInfo = $this->_fetchAppLicenceInfo($args['licence_id']);
|
|
|
|
|
+ $this->_encodeSource($appLicenceInfo);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $this->_endWithException($e);
|
|
|
}
|
|
}
|
|
|
- $domains = $this->fetchDomainsByLicenceId($args['licence_id']);
|
|
|
|
|
- if (empty($domains)) {
|
|
|
|
|
- $this->menu($args['licence_id']);
|
|
|
|
|
- ?>
|
|
|
|
|
- <div class="alert alert-warning">
|
|
|
|
|
- Domains not found.
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php
|
|
|
|
|
- SE_Layout::dol();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function _encodeSource($appLicenceInfo) {
|
|
|
|
|
+ if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
|
|
+ $installPath = $appLicenceInfo->installPath;
|
|
|
|
|
+ if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
|
|
+
|
|
|
|
|
+ $phpVersion = '5.5';
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
- echo'<pre>Domains with Licence: ';print_r($domains);echo'</pre>';
|
|
|
|
|
- $installPath = '/Library/Server/Web/Data/Sites/Default/PLIKI/SES_PROCESY5_A';
|
|
|
|
|
- $installPath .= "/{$args['licence_id']}_upgrade_SE_source_encrypted";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ $phpFiles = array();
|
|
|
|
|
+ $skipPhpFiles = array();
|
|
|
|
|
+ $skipPhpFiles[] = 'bash_sync_perms.php';
|
|
|
|
|
+ $skipPhpFiles[] = '.config.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/V.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Lib.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/DB.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/User.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/UserProfile.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Config.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Config/INI.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/FoldersConfig.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/FileUploader.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Route/Budget.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Route/FixCrmProcesInitIdx.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Route/FixProjectPath.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Route/FixZasobPath.php';
|
|
|
|
|
+ //$skipPhpFiles[] = 'se-lib/Route/Install.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'se-lib/Route/Msgs.php';
|
|
|
|
|
+ $skipPhpFiles[] = 'superedit-DB_PROCEDURES_CREATE.php';
|
|
|
|
|
+ //$skipPhpFiles[] = '';
|
|
|
|
|
+
|
|
|
|
|
+ $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, $skipPhpFiles)) continue;
|
|
|
|
|
+ if ('schema/' == substr($phpFilePath, 0, 7)) continue;
|
|
|
|
|
+ $phpFiles[] = $phpFilePath;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DBG::_(true, true, 'phpFiles', $phpFiles);
|
|
|
|
|
+ if (empty($phpFiles)) throw new Exception("No php files to encode");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ $cmd = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --phpversion {$phpVersion} -b- ";
|
|
|
|
|
+ foreach ($appLicenceInfo->domains as $domain) {
|
|
|
|
|
+ $cmd .= " --domain {$domain} ";
|
|
|
|
|
+ }
|
|
|
|
|
+ $cmd .= " " . implode(" ", $phpFiles);
|
|
|
|
|
+ $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");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function _fetchAppLicenceInfo($idLicence) {
|
|
|
|
|
+ $idLicence = intval($idLicence);
|
|
|
|
|
+ if (empty($idLicence)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
|
|
+
|
|
|
|
|
+ //DBG::_(true, true, 'idLicence', $idLicence, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
+ $appLicenceInfo = new stdClass();
|
|
|
|
|
+ $appLicenceInfo->ID = $idLicence;
|
|
|
|
|
+ $appLicenceInfo->domains = $this->fetchDomainsByLicenceId($idLicence);
|
|
|
|
|
+ $installRootPath = '/Library/Server/Web/Data/Sites/Default/PLIKI/SES_PROCESY5_A';
|
|
|
|
|
+ $appLicenceInfo->installFolderName = "{$idLicence}_upgrade_SE_source_encrypted";
|
|
|
|
|
+ $appLicenceInfo->installPath = "{$installRootPath}/{$appLicenceInfo->installFolderName}";
|
|
|
|
|
+ //DBG::_(true, true, 'appLicenceInfo', $appLicenceInfo, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found.");
|
|
|
|
|
+ $appLicenceInfo->installFolderExists = file_exists("{$appLicenceInfo->installPath}/SE");
|
|
|
|
|
+ $appLicenceInfo->installFolderGitExists = file_exists("{$appLicenceInfo->installPath}/.git");
|
|
|
|
|
+ return $appLicenceInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function generateApp($appLicenceInfo) {
|
|
|
|
|
+ if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
|
|
+ $installPath = $appLicenceInfo->installPath;
|
|
|
|
|
+ if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
|
|
+
|
|
|
$cmds = array();
|
|
$cmds = array();
|
|
|
$cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
|
|
$cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
|
|
|
$cmds[] = "mkdir {$installPath}";
|
|
$cmds[] = "mkdir {$installPath}";
|
|
|
$cmds[] = "cd {$installPath} && git clone git@biuro.biall-net.pl:plabudda/se.git .";
|
|
$cmds[] = "cd {$installPath} && git clone git@biuro.biall-net.pl:plabudda/se.git .";
|
|
|
$cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
$cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
- $cmds[] = "cd {$installPath} && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --phpversion 5.5 -b- --domain galeriaprzymorze.eu -r SE/*.php SE/se-lib/*.php SE/se-lib/*/*.php SE/se-lib/*/*/*.php SE/procesy/*.php SE/odt2xhtml/*.php -x superedit-DB_PROCEDURES_CREATE.php -x INI.php -x .config_base_structure.php";
|
|
|
|
|
//echo'<pre>cmds: ';print_r($cmds);echo'</pre>';
|
|
//echo'<pre>cmds: ';print_r($cmds);echo'</pre>';
|
|
|
foreach ($cmds as $cmd) {
|
|
foreach ($cmds as $cmd) {
|
|
|
$out = ''; $ret = '';
|
|
$out = ''; $ret = '';
|
|
|
exec($cmd, $out, $ret);
|
|
exec($cmd, $out, $ret);
|
|
|
echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
}
|
|
}
|
|
|
|
|
+ $this->_encodeSource($appLicenceInfo);
|
|
|
// 1763: $exec='cd '.$installer_dir.' && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder -b-
|
|
// 1763: $exec='cd '.$installer_dir.' && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder -b-
|
|
|
// '.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).'
|
|
// '.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).'
|
|
|
// -r *.php
|
|
// -r *.php
|
|
@@ -171,4 +348,17 @@ jQuery(document).ready(function () {
|
|
|
return $domains;
|
|
return $domains;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function _endWithException($e) {
|
|
|
|
|
+?>
|
|
|
|
|
+<div class="container">
|
|
|
|
|
+ <div class="alert alert-danger">
|
|
|
|
|
+ <?php echo $e->getMessage(); ?>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <p>Wróć do <a href="index.php?_route=Install">menu</a></p>
|
|
|
|
|
+</div>
|
|
|
|
|
+<?php
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|