コード例 #1
0
ファイル: a_pullcode.php プロジェクト: KlabsTechnology/andro
    function main()
    {
        if (gp('gp_posted') == 1) {
            return $this->PullCode();
        }
        if (gp('gp_posted') == 2) {
            return $this->PullAndro();
        }
        sourceDeprecated();
        ?>
      <h1>Upgrade Node Manager Only</h1>

      <p>This program below will download the latest available code
         for the node manager only.
      </p>
      
      <p style="color:red">Warning!  This program will overwrite the live
      running code of the Node Manager.  Any programs directly linked to the
      node manager will be instantly updated (this does not apply to 
         instances).  Remember to always keep production databases running
      as instances so that they are unaffected by this action.
      </p>
      
      <a href="javascript:Popup('?gp_page=a_pullcode&gp_posted=2')">Step 1: Get Code</a>
      <br/>
      <br/>
      <?php 
        echo hLinkBuild('andro', 'Step 2: Rebuild Node Manager');
        ?>
     
      <h1>Download Latest Software Updates</h1>      

      <p>This program downloads the latest available version
         of each program listed in the table of applications.
         The code is pulled from the 'Authoritative Node' for 
         that application (applications without an authoritative
         node are not reviewed).
      </p>
      
      <p>This program does not actually run updates to any running
         instances, each instance is upgraded manually at the 
         discretion of the administrator.
      </p>
      
      <br>
      <p>
      <a href="javascript:Popup('?gp_page=a_pullcode&gp_posted=1')">Pull Now</a>

      <?php 
    }
コード例 #2
0
ファイル: a_scontrol.php プロジェクト: KlabsTechnology/andro
    function main()
    {
        switch (gp('gp_action')) {
            case 'pull':
                $this->mainPull();
                break;
            case 'over':
                $this->mainOver();
                break;
            case 'diff':
                $this->mainDiff();
                break;
        }
        if (gp('gp_action') != '') {
            return;
        }
        if (gpExists('gp_clearremote')) {
            SessionSet('remoteUID', '');
            SessionSet('remotePWD', '');
            SessionSet('remoteNODE', '');
        }
        // Need this basic stuff for everything
        $skey = gp('gp_skey');
        hidden('gp_skey', $skey);
        hidden('gp_page', 'a_scontrol');
        $row = SQL_OneRow("Select * from applications WHERE skey={$skey}");
        $App = trim($row['application']);
        $sApp = SQLFC($App);
        $node = SQL_OneRow("Select * from nodes WHERE node=" . SQLFC($row['node']));
        $this->row = $row;
        $this->node = $node;
        // Some file functions execute before showing the screen, because
        // they affect what is displayed on the screen
        switch (gp('gpfa')) {
            case 'patch':
                $this->Patch();
                break;
            case 'overlocal':
                $this->OverLocal();
                break;
            case 'servsend':
                $this->ServerSend();
                break;
            case 'servdel':
                $this->ServerDel();
                break;
        }
        $h1 = "?gp_page=a_scontrol" . "&gp_action=pull&gp_url=" . $node['node_url'] . "&gp_app=" . $App;
        $h2 = "?gp_page=a_scontrol&gp_action=over";
        $h3 = "?gp_page=a_scontrol&gp_skey={$skey}";
        ?>
      <h1>Source Code Operations</h1>
      <p>For application 
         <a href="?gp_page=applications&gp_skey=<?php 
        echo $skey;
        ?>
"><?php 
        echo $App;
        ?>
</a>.
      </p>
      <?php 
        echo sourceDeprecated();
        ?>
      <?php 
        if (!$this->CheckRemoteUID($node['node'])) {
            return;
        }
        ?>

      <p><a href="javascript:formPostString('x=y')">Refresh This Page</a></p>
      <p>The Authoritative Node for this application is 
         <?php 
        echo $node['node'];
        ?>
 at <?php 
        echo $node['node_url'];
        ?>
.
         You are using username <b><?php 
        echo SessionGet('remoteUID');
        ?>
</b> on
         the remote node.
         <a href="javascript:formPostString('gp_clearremote=1')">Connect as New User</a>.
      </p>
      <br>
      
      <style>table.sc td { padding: 3px; }</style>
      <table cellpadding=0 cellspacing=0 class="sc">
        <tr><td class="dhead" width=100>Function</td>
            <td class="dhead">Details</td>
        <tr><td>
            <a href="javascript:Popup('<?php 
        echo $h1;
        ?>
')">
               Update Reference</a>
            <td>Pulls the latest code from the Authoritative Node and puts
                it into the "ref" directory of the application.  Does not
                modify programs in 'application' or 'appclib' (or 'lib',
                'clib', 'root' and 'templates' for the node manager).
        <!--
        <tr><td>
            <a href="javascript:Popup('< ?=$h2? >')">
               Overwrite From Reference</a>
            <td><font color=red>Unconditionally destroys any code you have
                for this application</font> and replaces it with the
                reference code. Before being destroyed, the code is backed up into
                a directory named "ref-"+current timestamp, so that it can
                be recovered if necessary.  It is the programmer's
                responsibility to delete these backup directories as desired.
           -->
      </table>
      <?php 
        $hbase = "?gp_page=a_scontrol&gp_app={$App}&gp_skey={$skey}";
        $dir = AppDir($App);
        $dirs = AppDirs($App);
        $filesL = array();
        $filesR = array();
        clearstatcache();
        // need this before scanning dirs
        foreach ($dirs as $onedir) {
            $this->WalkDir($filesL, $dir, trim($onedir));
            $this->WalkDir($filesR, $dir . "ref/", trim($onedir));
        }
        // Files they have and we don't. Pretty easy
        ?>
      <br><br>
      <h2>Server Files Not on Local Machine</h2>
      <table>
        <tr><td class="dhead">Filename
            <td class="dhead">&nbsp;
            <td class="dhead">&nbsp;
      <?php 
        $count = 0;
        foreach ($filesR as $name => $fileR) {
            if (!isset($filesL[$name])) {
                $hlinkC = $hbase . '&gpfa=overlocal' . '&gpfile=' . urlencode($name);
                $hlinkD = $hbase . '&gpfa=servdel' . '&gpfile=' . urlencode($name);
                $count++;
                $row = array($name, "&nbsp&nbsp;<a href='{$hlinkC}'>Overwrite Local</a>&nbsp&nbsp;", "&nbsp&nbsp;<a href='{$hlinkD}'>Delete From Server</a>&nbsp&nbsp;");
                echo hTRFromArray('', $row);
            }
        }
        if ($count == 0) {
            echo hTrFromArray('', array('none', ''));
        }
        echo "</table>";
        // Files we have and they dont
        ?>
      <br><br>
      <h2>Local Files Not on Server</h2>
      <table>
        <tr><td class="dhead">Name
            <td class="dhead">&nbsp;
      <?php 
        $count = 0;
        foreach ($filesL as $name => $fileL) {
            if (!isset($filesR[$name])) {
                $count++;
                $hlink = $hbase . '&gpfa=servsend' . '&gpfile=' . urlencode($name);
                $row = array($name, "&nbsp&nbsp;<a href='{$hlink}'>Send To Server</a>&nbsp&nbsp;");
                echo hTRFromArray('', $row);
            }
        }
        if ($count == 0) {
            echo hTrFromArray('', array('none', ''));
        }
        echo "</table>";
        ?>
      <br><br>
      <h2>Files That Are Different</h2>
      <table>
        <tr><td class="dhead">Name
            <td class="dhead">Differences
            <td class="dhead">&nbsp;
            <td class="dhead">&nbsp;
            <td class="dhead">&nbsp;
      <?php 
        foreach ($filesR as $name => $fileR) {
            if (!isset($filesL[$name])) {
                continue;
            }
            $fileL = $filesL[$name];
            $diffs = array();
            if ($fileL['fsize'] != $fileR['fsize']) {
                $diffs[] = 'fsize';
            }
            if ($fileL['md5'] != $fileR['md5']) {
                $diffs[] = 'md5';
            }
            if (count($diffs) != 0) {
                $hlinkP = $hbase . '&gpfa=patch' . '&gpfile=' . urlencode($name);
                $hlinkC = $hbase . '&gpfa=overlocal' . '&gpfile=' . urlencode($name);
                $hlinkD = "javascript:Popup('{$hbase}" . '&gp_action=diff' . '&gpfile=' . urlencode($name) . "')";
                $row = array($name . "&nbsp;&nbsp;", "&nbsp;&nbsp;" . implode(' ', $diffs) . "&nbsp;&nbsp;", "&nbsp;&nbsp;<a href='{$hlinkP}'>Patch To Server</a>&nbsp;&nbsp;", "&nbsp;&nbsp;<a href='{$hlinkC}'>Overwrite Local</a>&nbsp;&nbsp;", "&nbsp;&nbsp;<a href=\"{$hlinkD}\">View Diff</a>&nbsp;&nbsp;");
                echo hTRFromArray('', $row);
            }
        }
        echo "</table>";
        //hprint_r($filesL);
        //hprint_r($filesR);
        /*
        <table cellpadding=0 cellspacing=0 class="sc">
          <tr><td class="dhead">File</td>
              <td class="dhead">Local</td>
              <td class="dhead">Reference</td>
              <td class="dhead">Patch to Server</td>
              <td class="dhead">New To Server</td>
              <td class="dhead">Ovewrite Local</td>
        */
    }