|
@@ -0,0 +1,171 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
|
|
+
|
|
|
|
|
+class Route_Install extends RouteBase {
|
|
|
|
|
+
|
|
|
|
|
+ public function handleAuth() {
|
|
|
|
|
+ if (!User::logged()) {
|
|
|
|
|
+ throw new HttpException('Unauthorized', 401);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!User::isAdmin()) {
|
|
|
|
|
+ throw new HttpException('Unauthorized - only for administrators', 401);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function defaultAction() {
|
|
|
|
|
+ SE_Layout::gora();
|
|
|
|
|
+ SE_Layout::menu();
|
|
|
|
|
+ $this->menu();
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+ private function menu() {
|
|
|
|
|
+ $serversList = $this->fetchActiveLicences();
|
|
|
|
|
+ ?>
|
|
|
|
|
+<div class="jumbotron">
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <form class="form-inline" method="POST">
|
|
|
|
|
+ <input type="hidden" name="_task" value="createApp" />
|
|
|
|
|
+ <label>Przygotuj kod źródłowy do aktualizacji na serwerze klienta:</label>
|
|
|
|
|
+ <select class="form-control" name="licence_id">
|
|
|
|
|
+ <?php foreach ($serversList as $srv) : ?>
|
|
|
|
|
+ <option value="<?php echo $srv->ID; ?>">[<?php echo $srv->ID; ?>] <?php echo $srv->domain; ?></option>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <button type="submit" id="fldSbmtBtn" class="btn btn-primary" autocomplete="off">
|
|
|
|
|
+ Generuj
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </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
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function createAppAction() {
|
|
|
|
|
+ $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
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($args['licence_id'])) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <div class="alert alert-warning">
|
|
|
|
|
+ Nie wybrano serwera/licencji.
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->generateApp($args['licence_id']);
|
|
|
|
|
+
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function generateApp() {
|
|
|
|
|
+ $args = array();
|
|
|
|
|
+ $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;
|
|
|
|
|
+ }
|
|
|
|
|
+ $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();
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ echo'<pre>';print_r($domains);echo'</pre>';
|
|
|
|
|
+ $installPath = '/Library/Server/Web/Data/Sites/Default/PLIKI/SES_PROCESY5_A';
|
|
|
|
|
+ $installPath .= "/{$args['licence_id']}_upgrade_SE_source_encrypted";
|
|
|
|
|
+ $cmds = array();
|
|
|
|
|
+ $cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
|
|
|
|
|
+ $cmds[] = "mkdir {$installPath}";
|
|
|
|
|
+ $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} && /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>';
|
|
|
|
|
+ foreach ($cmds as $cmd) {
|
|
|
|
|
+ $out = ''; $ret = '';
|
|
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
|
|
+ echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
|
|
+ }
|
|
|
|
|
+// 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).'
|
|
|
|
|
+// -r *.php
|
|
|
|
|
+// -x superedit-DB_PROCEDURES_CREATE.php
|
|
|
|
|
+// -x INI.php
|
|
|
|
|
+// -x .config_base_structure.php
|
|
|
|
|
+// ';
|
|
|
|
|
+//
|
|
|
|
|
+// INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT):
|
|
|
|
|
+// $res2=DB::query("select SERVER_ADDRESS_SHORT from SES_PROCESY5_A where SERVER_ADDRESS_IP='".$h->SERVER_ADDRESS_IP."'");
|
|
|
|
|
+// while($h2=DB::fetch($res2)) {
|
|
|
|
|
+// $domain[]=' --domain '.$h2->SERVER_ADDRESS_SHORT;
|
|
|
|
|
+// ssh server@biuro.galeriaprzymorze.eu: PHP 5.5.20
|
|
|
|
|
+// ssh server@biuro.biall-net.pl
|
|
|
|
|
+// cd /Users/plabudda/procesy5-install-galeriaprzymorze.eu/
|
|
|
|
|
+// sudo chown -R server:admin SE/
|
|
|
|
|
+// /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
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function fetchActiveLicences() {
|
|
|
|
|
+ $activeLic = array();
|
|
|
|
|
+ $db = DB::getDB();
|
|
|
|
|
+ $sql = "select l.`ID`
|
|
|
|
|
+ , l.`SERVER_ADDRESS`
|
|
|
|
|
+ , l.`SERVER_ADDRESS_SHORT` as domain -- domain for sgencoder
|
|
|
|
|
+ , l.`SERVER_ADDRESS_IP`
|
|
|
|
|
+ from `SES_PROCESY5_A` l
|
|
|
|
|
+ where 1=1
|
|
|
|
|
+ -- TODO: and l.`A_STATUS` in('NORMAL','WAITING')
|
|
|
|
|
+ order by l.`ID` DESC
|
|
|
|
|
+ ";
|
|
|
|
|
+ $res = $db->query($sql);
|
|
|
|
|
+ while ($r = $db->fetch($res)) {
|
|
|
|
|
+ $activeLic[$r->ID] = $r;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $activeLic;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function fetchDomainsByLicenceId($licenceId) {
|
|
|
|
|
+ $domains = array();
|
|
|
|
|
+ $db = DB::getDB();
|
|
|
|
|
+ $sql = "select g.`SERVER_ADDRESS_SHORT`
|
|
|
|
|
+ from `SES_PROCESY5_A` g
|
|
|
|
|
+ where g.`SERVER_ADDRESS_IP`=(select l.`SERVER_ADDRESS_IP`
|
|
|
|
|
+ from `SES_PROCESY5_A` l
|
|
|
|
|
+ where l.`ID`='{$licenceId}'
|
|
|
|
|
+ -- TODO: and l.`A_STATUS` in('NORMAL','WAITING')
|
|
|
|
|
+ )
|
|
|
|
|
+ -- TODO: and g.`A_STATUS` in('NORMAL','WAITING')
|
|
|
|
|
+ ";
|
|
|
|
|
+ $res = $db->query($sql);
|
|
|
|
|
+ while ($r = $db->fetch($res)) {
|
|
|
|
|
+ $domains[] = $r->SERVER_ADDRESS_SHORT;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $domains;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|