Example #1
0
 function ehMain()
 {
     // This is the only validation.
     $allowed = array('HTML', 'PDF', 'SQL', 'CSV');
     if (!in_array($this->display, $allowed)) {
         echo "Error: Report format may be any of " . implode(',', $allowed);
         return;
     }
     $rep = $this->report_id;
     // Get resolved table names based on security
     $tReports = DDTable_IDResolve('reports');
     // Get Report Information
     $report = SQL_OneRow("Select * from reports where report=" . SQLFC($rep));
     if (!$report) {
         echo "Error: Report " . hFormat($rep) . " not on file";
     }
     $this->row_rep = $report;
     $this->hTitle = $report['description'];
     // Either do custom or run standard report
     //if($report['custom']<>'')
     if (false) {
         include $rep . '_rep.php';
     } else {
         $this->RepStandard();
     }
 }
Example #2
0
 function hWikiFromTable($table_id, $pagename, $flag_title = true)
 {
     $tid = SQL_ESCAPE_STRING($table_id);
     $pn = SQLFC($pagename);
     $row = SQL_OneRow("SELECT pagewiki FROM {$tid} where pagename={$pn}");
     $title = $flag_title ? $pagename : '';
     return $this->hWiki($table_id, $pagename, $row['pagewiki'], $title);
 }
Example #3
0
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     $top = $container;
     # Pull the values
     $row = SQL_OneRow("Select * from " . $this->table_id);
     # Basic information at top
     html('div', $top, 'Instance Configuration', 'hero-unit');
     html('p', $top, 'Any changes made here will take immediate 
         effect for all users of this program, except where a user
         has configured their own preferred setting.');
     # Set up titles
     $table = html('table', $top);
     $table->addClass('table table-bordered table-condensed table-hover table-striped');
     $table->hp['id'] = 'x2data1';
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Default Value', 'dark');
     $tr->h('th', '&nbsp;', 'dark');
     $tr->h('th', 'Instance Value', 'dark');
     # Now put out inputs for each one
     $tbody = html('tbody', $table);
     $askip = array('recnum', '_agg', 'skey_quiet', 'skey');
     foreach ($this->flat as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         $tr->hp['id'] = 'tr_' . $column_id;
         $tr->SetAsParent();
         $td = html('td', $tr, $colinfo['description']);
         # The default value
         $td = html('td', $tr, ConfigGet($column_id, '*null*', array('user', 'inst')));
         $td->hp['id'] = 'def_' . $column_id;
         # The reset
         $td = html('td', $tr);
         $button = html('a-void', $td, 'Use Default');
         $button->hp['onclick'] = "makeDefault('{$column_id}')";
         # the input
         $input = input($colinfo);
         $input->hp['id'] = 'inp_' . $column_id;
         if ($colinfo['type_id'] == 'text') {
             $input->setHTML($row[$column_id]);
         } else {
             $input->hp['value'] = $row[$column_id];
             x4Script('$a.byId("' . $input->hp['id'] . '").value="' . $row[$column_id] . '"');
         }
         $input->hp['onchange'] = 'instaSave(this)';
         $input->ap['skey'] = $row['skey'];
         $td = html('td', $tr);
         $td->addChild($input);
     }
 }
Example #4
0
 function main()
 {
     // First pull the report
     $row_rep = SQL_OneRow("SELECT * from reports where skey=" . gp('gp_skey'));
     $sreport = SQL_Format('char', $row_rep['report']);
     // Now the tables
     $rows_tab = SQL_AllRows("SELECT * From reporttables WHERE report={$sreport}");
     $rows_tab = KeyRowsFromRows($rows_tab, 'table_id');
     // Now all columns
     $rows_col = SQL_AllRows("SELECT * From reportcolumns WHERE report={$sreport}\n           ORDER BY uicolseq ");
     // Go get the joins
     $SQL_FROMJOINS = $this->ehProcessFromJoins(array_keys($rows_tab));
     // Build a list of columns, and order-by columns, and filters
     $SQL_COLSA = array();
     $SQL_COLSOBA = array();
     $SQL_COLSWHA = array();
     foreach ($rows_col as $row_col) {
         $SQL_COLSA[] = $row_col['table_id'] . '.' . $row_col['column_id'];
         if ($row_col['uisort'] != 0) {
             $SQL_COLSOBA[$row_col['uisort']] = $row_col['table_id'] . '.' . $row_col['column_id'];
         }
         if ($row_col['compoper'] != '' && $row_col['compval'] != '') {
             $table_dd = DD_TableRef($row_col['table_id']);
             $ddcol =& $table_dd['flat'][$row_col['column_id']];
             $colval = SQL_Format($ddcol['type_id'], $row_col['compval']);
             $SQL_COLSWHA[] = $row_col['table_id'] . '.' . $row_col['column_id'] . $row_col['compoper'] . $colval;
         }
     }
     // Collapse the lists into strings
     $SQL_COLS = implode("\n       ,", $SQL_COLSA);
     $SQL_COLSOB = '';
     if (count($SQL_COLSOBA) > 0) {
         ksort($SQL_COLSOBA);
         $SQL_COLSOB = "\n ORDER BY " . implode(',', $SQL_COLSOBA);
     }
     $SQL_WHERE = '';
     if (count($SQL_COLSWHA) > 0) {
         $SQL_WHERE = "\n WHERE " . implode("\n       ", $SQL_COLSWHA);
     }
     // Now build the final SQL
     $SQ = " SELECT " . $SQL_COLS . $SQL_FROMJOINS . $SQL_WHERE . $SQL_COLSOB;
     //echo $SQ;
     // Display
     $this->ehProcessDisplay($SQ, $rows_col, $row_rep);
 }
Example #5
0
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     $top = $container;
     # Pull the values
     # For a user, if there is no row, enter one and try again
     $dd = ddTable("configuser");
     $view = ddView('configuser');
     $row = SQL_AllRows("Select * from {$view}");
     if (count($row) == 1) {
         $row = $row[0];
     } else {
         SQL("Insert into {$view} (skey_quiet) values ('N')");
         $row = SQL_OneRow("Select * from {$view}");
     }
     # Basic information at top
     html('h1', $top, 'User Configuration');
     html('p', $top, 'Any changes made here will take immediate 
         effect.');
     # Set up titles
     $table = html('table', $top);
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Your Value', 'dark');
     $tr->h('th', 'Default Value', 'dark');
     $tr->h('th', '&nbsp', 'dark');
     # Now put out inputs for each one
     $tbody = html('tbody', $table);
     $askip = array('recnum', '_agg', 'skey_quiet', 'skey', 'uid_ins');
     foreach ($this->flat as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         $tr->hp['id'] = 'tr_' . $column_id;
         $tr->SetAsParent();
         $td = html('td', $tr, $colinfo['description']);
         # the input
         $input = input($colinfo);
         $input->hp['id'] = 'inp_' . $column_id;
         if ($colinfo['type_id'] == 'text') {
             $input->setHTML($row[$column_id]);
         } else {
             $input->hp['value'] = $row[$column_id];
             x4Script('$a.byId("' . $input->hp['id'] . '").value="' . $row[$column_id] . '"');
         }
         $input->hp['onchange'] = 'instaSave(this)';
         $input->ap['skey'] = $row['skey'];
         $td = html('td', $tr);
         $td->addChild($input);
         # The default value
         $td = html('td', $tr, ConfigGet($column_id, '*null*', array('user')));
         $td->hp['id'] = 'def_' . $column_id;
         # The reset
         $td = html('td', $tr);
         $button = html('a-void', $td, 'Use Default');
         $button->hp['onclick'] = "makeDefault('{$column_id}')";
     }
 }
 function checkDBFilesForChanges()
 {
     global $parm;
     $this->LogStage("Checking spec files for changes");
     $changed = false;
     $checksums = array();
     $specboot = $parm["SPEC_BOOT"] . ".add";
     $checksums[] = array('file' => $specboot, 'md5' => md5_file($parm['DIR_PUB'] . "lib/" . $specboot), 'fullpath' => $parm['DIR_PUB'] . "lib/" . $specboot);
     if (isset($parm['INST'])) {
         $app = str_replace('_' . $parm['INST'], '', $parm['APP']);
     } else {
         $app = $parm['APP'];
     }
     if ($parm["SPEC_LIST"] != "") {
         $speclist = explode(",", $parm["SPEC_LIST"]);
         foreach ($speclist as $spec) {
             if (substr($spec, -5) != '.yaml') {
                 $file = $spec . ".add";
             } else {
                 $file = $spec;
             }
             $checksums[] = array('file' => $file, 'md5' => md5_file($parm["DIR_PUB"] . "application/" . $file), 'fullpath' => $parm["DIR_PUB"] . "application/" . $file);
         }
     }
     $checkqry = "SELECT relname FROM pg_class WHERE relname='instance_spec_checksums'";
     $checkrslts = SQL_AllRows($checkqry);
     if (count($checkrslts) == 0) {
         $this->LogEntry("Instance tracking table doesnt exist yet...ignoring until next build");
         return true;
     }
     foreach ($checksums as $checksum) {
         $query = "SELECT checksum,skey FROM " . ddTable_idResolve('instance_spec_checksums') . " WHERE \n            application=" . SQLFC($app) . " AND spec_name=" . SQLFC($checksum['file']) . (isset($parm['INST']) ? " AND instance=" . SQLFC($parm['INST']) : '');
         $row = SQL_OneRow($query);
         if ($row) {
             $this->LogEntry('Entry for ' . $checksum['file'] . ' file found');
             if ($row['checksum'] != $checksum['md5']) {
                 $this->LogEntry("Spec File Changed: " . $checksum['file']);
                 $changed = true;
                 $checksum_update = array('skey' => $row['skey'], 'checksum' => md5_file($checksum['fullpath']));
                 SQLX_Update('instance_spec_checksums', $checksum_update);
                 $this->LogEntry("Updating Entry");
             }
         } else {
             $this->LogEntry('Entry for ' . $checksum['file'] . ' not found');
             $checksum_entry = array('application' => $app, 'instance' => isset($parm['INST']) ? $parm['INST'] : '', 'spec_name' => $checksum['file'], 'checksum' => md5_file($checksum['fullpath']));
             SQLX_Insert('instance_spec_checksums', $checksum_entry);
             $this->LogEntry("Spec File Changed: " . $checksum['file']);
             $changed = true;
         }
     }
     if ($changed) {
         $this->LogEntry('One or more spec files have changed: Proceeding with full build');
     } else {
         $this->LogEntry('Spec files have not changed: Proceeding with mini build');
     }
     return $changed;
 }
Example #7
0
 /**
  * Go get FETCH values from other tables
  *
  */
 function fetch()
 {
     // Get the list of columns from the dd
     $column_id = gp('column');
     $table_id = $this->dd['table_id'];
     $table_id_fko = $this->dd['flat'][$column_id]['table_id_fko'];
     $match = $table_id . '_' . $table_id_fko . '_';
     $collist = $this->dd['FETCHDIST'][$match];
     // Build the SQL to fetch the row
     $colsc = array();
     $colsp = array();
     foreach ($collist as $idx => $info) {
         $colsp[] = $info['column_id_par'] . ' as ' . $info['column_id'];
     }
     $type_id = $this->dd['flat'][$column_id]['type_id'];
     $value = SQL_Format($type_id, gp('value'));
     $sql = "SELECT " . implode(',', $colsp) . "  FROM " . ddTable_idResolve($table_id_fko) . " WHERE " . $this->dd['fk_parents'][$table_id_fko]['cols_par'] . "= {$value}";
     $answer = SQL_OneRow($sql);
     x4Data('fetch', $answer);
 }
Example #8
0
 /**
  * The user has requested that we download the latest 
  * version of each application from its respective
  * 
  *
  */
 function mainPull()
 {
     x_echoFlush('<pre>');
     x_EchoFlush('<h2>Looking For Andromeda Version</h2>');
     x_EchoFlush("");
     // First take care of where we are pulling version
     // information from
     $def = "http://andro.svn.sourceforge.net/svnroot/andro/releases/";
     $row = SQL_OneRow("Select * from applications where application='andro'");
     if (!isset($row['svn_url'])) {
         x_EchoFlush("-- This looks like the first time this node has");
         x_EchoFlush("   been upgraded from Subversion.  Using default");
         x_echoFlush("   URL to look for releases:");
         x_EchoFlush("   " . $def);
         $url = $def;
     } else {
         if (is_null($row['svn_url']) || trim($row['svn_url']) == '') {
             x_EchoFlush("-- Setting the Subversion URL to default:");
             x_EchoFlush("   " . $def);
             $url = $def;
             $row['svn_url'] = $def;
             SQLX_Update('applications', $row);
         } else {
             $url = trim($row['svn_url']);
             x_EchoFlush("-- Using the following URL for Subversion:");
             x_EchoFlush("   " . $url);
         }
     }
     // Find out what the latest version is
     x_EchoFlush("");
     x_EchoFlush("-- Querying for latest version...");
     $command = 'svn list ' . $url;
     x_EchoFlush("   Command is: " . $command);
     $rawtext = `{$command}`;
     if ($rawtext == '') {
         x_EchoFlush("-- NO VERSIONS RETRIEVED!");
         x_EchoFlush("   It may be that the Sourceforge site is down?");
         x_EchoFlush("");
         x_echoFlush(" ---- Stopped Unexpectedly --- ");
         return;
     }
     $rawtext = str_replace("\r", "", $rawtext);
     $lines = explode("\n", $rawtext);
     // Pop off empty entry at end, then get latest version
     array_pop($lines);
     $latest = array_pop($lines);
     if (substr($latest, -1) == '/') {
         $latest = substr($latest, 0, strlen($latest) - 1);
     }
     x_EchoFlush("   Latest published version: " . $latest);
     // now find out what version we have
     x_EchoFlush(" ");
     x_EchoFlush("-- Finding out what version the node manager is at");
     $file = $GLOBALS['AG']['dirs']['application'] . '_andro_version_.txt';
     x_EchoFlush("   Looking at file: {$file}");
     if (!file_exists($file)) {
         x_EchoFlush("   File not found, it appears this is the first time");
         x_EchoFlush("   this node has been upgraded this way. Will proceed");
         x_EchoFlush("   to get latest version.");
     } else {
         $version = file_get_contents($file);
         x_EchoFlush("   Current version is " . $version);
         if ($version == $latest) {
             x_echoFlush("   This node is current!  Nothing to do!");
             x_EchoFlush("");
             x_echoFlush(" ---- Processing completed normally ---- ");
             return;
         } else {
             x_echoFlush("   Newer version available, will get latest.");
         }
     }
     // now get the latest code
     $dir = $GLOBALS['AG']['dirs']['root'];
     $command = 'svn export --force ' . $url . $latest . ' ' . $dir;
     x_EchoFlush("");
     x_EchoFlush("-- Overwriting Node Manager now");
     x_echoFlush("   Command is " . $command);
     `{$command}`;
     x_echoFlush("");
     file_put_contents($file, $latest);
     x_EchoFlush(" ---- Processing completed normally ---- ");
 }
Example #9
0
function CacheRowPut(&$table, &$row)
{
    $pkcol = $table['pks'];
    $pkval = $row[$pkcol];
    $pktyp = $table['flat'][$pkcol]['type_id'];
    $sq = "SELECT * FROM " . $table['table_id'] . " WHERE {$pkcol} = " . SQL_Format($pktyp, $pkval);
    $row = SQL_OneRow($sq);
    DynFromA($table['table_id'] . "_" . $pkval, $row);
}
Example #10
0
 /**
 function:hAjax_Colmove
 returns:string AJAX_Element
 
 Moves a column up or down by altering its uicolseq
 */
 function ehAjax_ColMove()
 {
     $gp_skey = gp('gp_skey');
     $cs_org = gp('gp_csorg');
     //$cs_org  = str_pad($cs_org,4,STR_PAD_LEFT,'0');
     $sk_org = gp('gp_skorg');
     if (gp('gp_ajax') == 'coldn') {
         $sq = "select rc.skey,rc.uicolseq \n               from reportcolumns rc \n               JOIN reports r  ON r.report = rc.report\n              WHERE r.skey = {$gp_skey}\n                AND rc.uicolseq > '{$cs_org}'\n              ORDER BY rc.uicolseq ASC LIMIT 1";
     } else {
         $sq = "select rc.skey,rc.uicolseq \n               from reportcolumns rc \n               JOIN reports r  ON r.report = rc.report\n              WHERE r.skey = {$gp_skey}\n                AND rc.uicolseq < '{$cs_org}'\n              ORDER BY rc.uicolseq DESC LIMIT 1";
     }
     $row = SQL_OneRow($sq);
     $swap_sk = $row['skey'];
     $swap_cs = $row['uicolseq'];
     $sq = "update reportcolumns set uicolseq='{$cs_org}'  where skey=" . $swap_sk;
     SQL($sq);
     $sq = "update reportcolumns set uicolseq='{$swap_cs}' where skey=" . $sk_org;
     SQL($sq);
     $this->ehColumns();
 }
Example #11
0
    function main()
    {
        $app = gp('gp_app');
        $sApp = SQLFC(gp('gp_app'));
        $sInst = SQLFC(gp('gp_inst'));
        $hApp = hSanitize(gp('gp_app'));
        $hInst = hSanitize(gp('gp_inst'));
        $rows = SQL_AllRows("SELECT * from instances \n           where application={$sApp} AND instance={$sInst}");
        if (count($rows) != 1) {
            ?>
         <div class="errorbox">Incorrect call to instance processing.</div>
         <?php 
            return;
        }
        $row = $rows[0];
        $hVer = hSanitize(trim($row['version']));
        // Maybe we are on processing branch
        if (gp('gp_posted') == 1) {
            $this->Process($rows[0]);
            return;
        }
        // KFD 2/4/08, Modify this to look for versions on disk
        //     for an svn-enabled server node
        $hWarn = '';
        $av = '';
        if (OptionGet('DEV_STATION', '') == 'N') {
            $sq = "Select * from applications where application={$sApp}";
            $rapp = SQL_OneRow($sq);
            if (trim($rapp['svn_url']) == '') {
                $hWarn = '<br/><br/><b>Subversion url needed.</b> ' . 'You can begin by providing a URL to the subversions ' . 'repository for this application on ' . '<a href="?gp_page=applications&gp_skey=' . $rapp['skey'] . '">the editing screen</a>.';
            }
            $versions = svnVersions();
            $verx = trim($versions[$app]['local']);
            $av = "<p>Latest Andromeda Version: " . trim($versions['andro']['local']);
        } else {
            // Get the current version, and get the latest version available
            $verx = SQL_OneValue("mv", "Select max(version) as mv from appversions\n               WHERE application={$sApp}");
            if (is_null($verx)) {
                $verx = '';
            }
        }
        ?>
        <h1>Instance Upgrade</h1>
        <p>Application: <?php 
        echo $hApp;
        ?>
   </p>
        <p>Instance: <?php 
        echo $hInst;
        ?>
     </p>
        <p>Current Version: <?php 
        echo $hVer == '' ? '-none-' : $hVer;
        ?>
 </p>
        <p>Latest Version Available: <?php 
        echo $verx == '' ? '-none-' : $verx;
        ?>
 </p>
        <?php 
        echo $av;
        ?>
 
        <p>&nbsp;</p>
        <p>
        <?php 
        if ($verx == '') {
            ?>
            <b>No official versions are available.</b>  An instance can only
            be upgraded when an official version is available.  You may
            download release code for this application, or you may
            generate files out of your development code.
            </p>
            <?php 
            echo $hWarn;
            ?>
            <?php 
            return;
        } else {
            $caption = $hVer == '' ? 'Build as ' : 'Upgrade To';
            echo hLinkPopup('', $caption . ' version ' . $verx, array('gp_app' => gp('gp_app'), 'gp_inst' => gp('gp_inst'), 'gp_posted' => 1, 'gp_page' => 'instances_p2', 'gp_out' => 'none', 'gp_ver' => $verx));
        }
    }
Example #12
0
 function fetchParent()
 {
     $ddpar = ddTable(gp('tableIdPar'));
     $pks = $ddpar['pks'];
     $stab = ddView(gp('tableIdPar'));
     $skey = SQLFN(gp('skeyPar'));
     $vals2 = SQL_OneRow("SELECT {$pks} FROM {$stab} WHERE skey = {$skey}");
     if (!$vals2) {
         $vals2 = array();
     }
     return $vals2;
 }
Example #13
0
function index_hidden_x6FETCH()
{
    $returns = array();
    # This is everything that *might* go back, make a place
    # for all of it
    $GLOBALS['AG']['x4'] = array('error' => array(), 'debug' => array(), 'notice' => array(), 'html' => array(), 'script' => array());
    // First fetch the values
    $table_id = gp('x6fetch');
    $dd = ddTable($table_id);
    $column = gp('x6col');
    $colvalue = gp('x6val');
    # Look for fetch columns that pull from this column's
    # table_id_fko
    $tfko = $dd['flat'][$column]['table_id_fko'];
    $cfko = $dd['flat'][$column]['column_id_fko'];
    $cols = array();
    foreach ($dd['flat'] as $fcol => $cdetails) {
        $arr = array('FETCH', 'FETCHDEF', 'DISTRIBUTE');
        if (in_array($cdetails['automation_id'], $arr)) {
            if ($cdetails['auto_table_id'] == $tfko) {
                $cols[$fcol] = $cdetails['auto_column_id'];
            }
        }
    }
    # We now have a list of source and destination
    # columns, build the query
    $sql = "Select " . implode(',', $cols) . " FROM {$tfko} WHERE {$cfko} = " . SQLFC($colvalue);
    $row = SQL_OneRow($sql);
    foreach ($cols as $fcol => $srccol) {
        $type = $dd['flat'][$fcol]['formshort'];
        if ($type == 'date') {
            x6html("x6inp_{$table_id}_{$fcol}", date("Y-m-d", dEnsureTs($row[$srccol])));
        } else {
            x6html("x6inp_{$table_id}_{$fcol}", $row[$srccol]);
        }
    }
    echo json_encode_safe($GLOBALS['AG']['x4']);
    exit;
}
Example #14
0
    function main()
    {
        $x_app = trim(gp('txt_application'));
        session_write_close();
        ob_start();
        echo "<h1>Build in progress</h1>";
        echo "<hr>";
        echo "<p>The system is now building the application: <b>" . $x_app . "</b>.</p>";
        echo "<p>If you are testing and expect to build several times in a row, do not ";
        echo "close this window, just hit REFRESH and the build will start again.</p>";
        echo "<p>All information below this line is from the build log.</p>";
        echo "<hr>";
        // Get everything we need from the database, use it to build
        // a "do" program.
        //
        $GLOBALS["x_password"] = trim(gp("supassword"));
        $tsql = 'SELECT * from applications ' . ' WHERE application = ' . SQL_Format('char', $x_app);
        $row_a = SQL_OneRow($tsql);
        $tsql = 'SELECT * from webpaths ' . ' WHERE webpath = ' . SQL_Format('char', $row_a['webpath']);
        $row_n = SQL_OneRow($tsql);
        $dirws = trim($row_n["dir_pub"]);
        if (substr($dirws, -1, 1) != "/") {
            $dirws .= "/";
        }
        $row["webserver_dir_pub"] = $dirws;
        $string = '
<?php
   // To run this program from the command line, you must
   // be logged in as a user that has superuser priveleges, such
   // as root or postgres.  When running from the web app,
   // the current user\'s priveleges are used.
	
   $GLOBALS["parm"] = array(
   "DBSERVER_URL"=>"localhost"
   ,"UID"=>"' . SessionGet('UID') . '"
   ,"DIR_PUBLIC"=>"' . trim($row_n["dir_pub"]) . '"
	,"DIR_PUBLIC_APP"=>"' . $x_app . '"
   ,"LOCALHOST_SUFFIX"=>"' . ArraySafe($row_n, 'dir_local', '') . '"
   ,"APP"=>"' . $x_app . '"
   ,"APPDSC"=>"' . trim($row_a["description"]) . '"
   ,"XDIRS"=>"' . trim($row_a['xdirs']) . '"
   ,"ROLE_LOGIN"=>"' . ArraySafe($row_a, 'flag_rolelogin', 'Y') . '"
   ,"FLAG_PWMD5"=>"' . ArraySafe($row_a, 'flag_pwmd5', 'N') . '"
   ,"TEMPLATE"=>"' . trim($row_a['template']) . '"
   ,"SPEC_BOOT"=>"' . trim($row_a["appspec_boot"]) . '"
   ,"SPEC_LIB"=>"' . trim($row_a["appspec_lib"]) . '"
   ,"SPEC_LIST"=>"' . trim($row_a["appspec"]) . '");

	include("androBuild.php");  
?>
';
        $t = pathinfo(__FILE__);
        $dircur = AddSlash($t["dirname"]) . "../tmp/";
        $file = $dircur . "do" . $x_app . ".php";
        $FILE = fopen($file, "w");
        fwrite($FILE, $string);
        fclose($FILE);
        x_EchoFlush("");
        include $file;
        echo ob_get_clean();
    }
Example #15
0
 function hBoxes($mode)
 {
     // Obtain a row depending on the mode we are in.  If there
     // wdas an error then reload the first row for this table
     if (is_array(vgfGet('ErrorRow_' . $this->table_id, ''))) {
         $row = vgfGet('ErrorRow_' . $this->table_id);
         $row['skey'] = gp('gpx_skey');
     } else {
         switch ($mode) {
             case 'search':
                 // if a previous search, use that, else fall through
                 // to using current row
                 $row = ConGet('table', $this->table_id, 'search', array());
                 if (count($row) != 0) {
                     break;
                 }
             case 'ins':
                 $row = DrillDownMatches();
                 if (count($row) == 0) {
                     $row = aFromGP('pre_');
                 }
                 // KFD 8/13/07, part of COPY ability
                 if (gp('gp_action') == 'copy') {
                     $row2 = SQL_OneRow("SELECT * FROM " . $this->table_id . " where skey=" . SQLFN(gp('gp_skey')));
                     foreach ($row2 as $column_id => $colvalue) {
                         if (is_numeric($column_id)) {
                             continue;
                         }
                         if (!isset($this->table['flat'][$column_id])) {
                             continue;
                         }
                         $aid = $this->table['flat'][$column_id]['automation_id'];
                         if ($aid == 'SEQUENCE' || $column_id == gp('gp_exclude')) {
                             unset($row2[$column_id]);
                         }
                     }
                     $row = array_merge($row, $row2);
                 }
                 break;
             case 'upd':
                 $skey = gp('gp_skey');
                 hidden('gp_skey', '');
                 if (trim($skey) == '') {
                     $row = array();
                 } else {
                     $skey = " WHERE skey=" . $skey;
                     $sq = "Select * FROM " . $this->view_id . $skey;
                     $row = SQL_OneRow($sq);
                 }
         }
     }
     // Save the row for other routines
     $this->row = $row;
     // Find out what skey we are on, give a next/prev
     // kind of button for stuff like that.
     // Set the next/prev stuff based on rows
     $HTML_PagePrev = $HTML_PageNext = $HTML_ViewingPage = "";
     if ($mode == "upd") {
         $lprev = $lnext = false;
         $skey = $this->row['skey'];
         $sess_skeys = ConGet("table", $this->table_id, "skeys", array());
         if (count($sess_skeys) > 1) {
             $sess_srows = array_flip($sess_skeys);
             $sess_srow = $sess_srows[$row['skey']];
             $lprev = $sess_srow == 0 ? false : true;
             $skeyf = $sess_srow == 0 ? 0 : $sess_skeys[0];
             $skeyp = $sess_srow == 0 ? 0 : $sess_skeys[$sess_srow - 1];
             $skeyn = $sess_srow >= count($sess_srows) - 1 ? 0 : $sess_skeys[$sess_srow + 1];
             $skeyl = $sess_srow >= count($sess_srows) - 1 ? 0 : $sess_skeys[count($sess_srows) - 1];
             $hprev = hLinkImage('first', 'First', 'gp_skey', $skeyf, $lprev) . hLinkImage('previous', 'Previous', 'gp_skey', $skeyp, $lprev);
             $lnext = $sess_srow < count($sess_srows) - 1 ? true : false;
             $hnext = hLinkImage('next', 'Next', 'gp_skey', $skeyn, $lnext) . hLinkImage('last', 'Last', 'gp_skey', $skeyl, $lnext);
             $HTML_ViewingPage = "Page " . ($sess_srow + 1) . " of " . count($sess_srows);
         }
     }
     // Output and save the navbar
     ob_start();
     if ($HTML_ViewingPage != '') {
         $hprev = $this->hTextButton('\\First', 'gp_skey', $skeyf, $lprev) . $this->hTextButton('\\Previous', 'gp_skey', $skeyp, $lprev);
         $hnext = $this->hTextButton('Ne\\xt', 'gp_skey', $skeyn, $lnext) . $this->hTextButton('Las\\t', 'gp_skey', $skeyl, $lnext);
         if (vgfget('buttons_in_commands')) {
             $this->h['NavBar'] = '';
             vgfSet('html_navbar', $hprev . $hnext);
         } else {
             $this->h['NavBar'] = "\n<div class=\"x2menubar\">\n" . $hprev . $HTML_ViewingPage . "&nbsp;&nbsp;&nbsp;" . $hnext . "\n</div><br>";
         }
     }
     // Second output is main content
     // KFD 8/9/07, Project DUPECHECK
     //             If a "dupecheck" projection exists, and they are
     //             doing a new entry, we first ask them to enter
     //             those values
     $dc = ArraySafe($this->table['projections'], 'dupecheck');
     if ($dc != '' && $mode == 'ins' && !gpExists('gp_nodupecheck')) {
         hidden('gp_action', 'dupecheck');
         $this->h['Content'] = $this->hBoxesX3($mode, 'dupecheck');
         $this->h['Content'] .= '<br/><br/>' . '<button  class="btn btn-primary id="object_for_enter" onclick="formSubmit()">(ENTER) Check For Duplicates</button>';
     } else {
         $this->h['Content'] = $this->hBoxesDefault($mode);
     }
 }
Example #16
0
    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>
        */
    }
Example #17
0
    function main_pr_execute()
    {
        ob_start();
        $sApp = SQLFC(gp('gp_app'));
        $sInst = SQLFC(gp('gp_inst'));
        $hApp = hSanitize(gp('gp_app'));
        $hInst = hSanitize(gp('gp_inst'));
        $rows = SQL_AllRows("SELECT * from instances \n           where application={$sApp} AND instance={$sInst}");
        if (count($rows) != 1) {
            ?>
         <div class="errorbox">Incorrect call to instance processing.</div>
         <?php 
            return;
        }
        $row = $rows[0];
        $sVer = SQLFC(gp('gp_ver'));
        $hVer = hSanitize(gp('gp_ver'));
        // KFD 2/4/08, If this is a subversion-enabled server,
        //     get version information from there
        if (OptionGet('DEV_STATION', '') != '') {
            $aversions = svnVersions();
            $mv = '-VER-' . $aversions['andro']['local'];
        } else {
            // Get information on latest version of Node Manager and
            // link to that
            $mv = SQL_OneValue("mv", "SELECT max(version) as mv \n                 FROM appversions\n                WHERE application='andro'");
        }
        $DIR_LINK_LIB = $GLOBALS['AG']['dirs']['root'] . '/pkg-apps/andro' . $mv;
        // Source of symlinks for app directories
        $DIR_LINK_APP = $GLOBALS['AG']['dirs']['root'] . "/pkg-apps/{$hApp}-VER-{$hVer}";
        // Get application information for the DO program
        $tsql = 'SELECT * from applications ' . ' WHERE application = ' . $sApp;
        $row_a = SQL_OneRow($tsql);
        $tsql = 'SELECT * from webpaths ' . ' WHERE webpath = ' . SQLFC($row_a['webpath']);
        $row_n = SQL_OneRow($tsql);
        $dirws = AddSlash(trim($row_n["dir_pub"]));
        //if (substr($dirws,-1,1)<>"/") $dirws.="/";
        //$row["webserver_dir_pub"] = $dirws;
        $string = '<?php
// To run this program from the command line, you must
// be logged in as a user that has superuser priveleges, such
// as root or postgres.  When running from the web app,
// the current user\'s priveleges are used.

$GLOBALS["parm"] = array(
   "DBSERVER_URL"=>"localhost"
   ,"UID"=>"' . SessionGet('UID') . '"
   ,"DIR_PUBLIC"=>"' . $dirws . '"
   ,"DIR_PUBLIC_APP"=>"' . $hApp . '_' . $hInst . '"
   ,"DIR_LINK_LIB"=>"' . $DIR_LINK_LIB . '"
   ,"DIR_LINK_APP"=>"' . $DIR_LINK_APP . '"
   ,"APP"=>"' . $hApp . '_' . $hInst . '"
   ,"INST"=>"' . $hInst . '"
   ,"IVER"=>"' . $hVer . '"
   ,"XDIRS"=>"' . trim($row_a['xdirs']) . '"
   ,"FLAG_PWMD5"=>"' . ArraySafe($row_a, 'flag_pwmd5', 'N') . '"
   ,"ROLE_LOGIN"=>"' . ArraySafe($row_a, 'flag_rolelogin', 'Y') . '"
   ,"TEMPLATE"=>"' . $row['template'] . '"
   ,"APPDSC"=>"' . trim($row_a["description"]) . '"
   ,"SPEC_BOOT"=>"' . trim($row_a["appspec_boot"]) . '"
   ,"SPEC_LIB"=>"' . trim($row_a["appspec_lib"]) . '"
   ,"SPEC_LIST"=>"' . trim($row_a["appspec"]) . '"
);
   
include("androBuild.php");  
?>
   ';
        $t = pathinfo(__FILE__);
        $dircur = AddSlash($t["dirname"]) . "../tmp/";
        //$dircur = $t["dirname"];
        if (substr($dircur, -1) != "/") {
            $dircur .= "/";
        }
        $file = $dircur . "do-{$hApp}-{$hInst}.php";
        $FILE = fopen($file, "w");
        fwrite($FILE, $string);
        fclose($FILE);
        include $file;
        if (ArraySafe($GLOBALS, 'retval', 0) == 1) {
            SQL("update instances set version={$sVer}\n               WHERE application = {$sApp}\n                 AND instance    = {$sInst}");
        }
        echo ob_get_clean();
    }