コード例 #1
0
ファイル: a_codexfer.php プロジェクト: KlabsTechnology/andro
 function DevPull()
 {
     // Get the app and its local directory
     $app = gp('gp_app');
     $wp = AppDir($app);
     // Pull list of directories
     $dirs = AppDirs($app);
     $hdirs = implode(' ', $dirs);
     // Go to directory, rm devcode.tgz, build it again
     if (file_exists($wp . '/devcode.tgz')) {
         unlink($wp . '/devcode.tgz');
     }
     chdir($wp);
     $cmd = 'tar czvf devcode.tgz ' . $hdirs;
     `{$cmd}`;
     readfile($wp . '/devcode.tgz');
 }
コード例 #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>
        */
    }