Ejemplo n.º 1
0
 function Linkilink(&$html, $match)
 {
     $tid = SQL_ESCAPE_STRING($this->table_id);
     $sq = "SELECT pagename FROM {$tid}\n            WHERE pagename = '{$match}'";
     $rs = SQL_OneValue('pagename', $sq);
     if (!$rs) {
         $newval = '<span class="nolink">' . $match . '</span>';
     } else {
         $newval = '<a href="?gp_page=x_docview&gppn=' . urlencode($rs) . '">' . $rs . '</a>';
     }
     $html = str_replace('[[' . $match . ']]', $newval, $html);
 }
Ejemplo n.º 2
0
 function LinkImage(&$html, $match, $type)
 {
     $sq = "SELECT filename,description FROM media \n            WHERE filename = '{$match}'";
     $rs = SQL_OneValue('filename', $sq);
     if (!$rs) {
         $newval = '<span class="nolink">MISSING IMAGE: ' . $match . '</span>';
     } else {
         $newval = '<img src="' . $this->image_directory . '/' . $match . '">';
     }
     $html = preg_replace('/\\[\\[' . $type . ":" . $match . '\\]\\]/', $newval, $html);
 }
Ejemplo n.º 3
0
 function main()
 {
     // ------------------------------------------------
     // Branch out to ajax handling functions
     if (gpExists('fwajax')) {
         return $this->FWAjax();
     }
     //   ...early return
     // ------------------------------------------------
     // Public sites can turn off table maintenance pages
     if (vgfGet('suppress_maintenance', false)) {
         return;
     }
     vgfset('maintenance', true);
     # KFD 2/17/09 Sourceforge 2546056
     #             If we are in default main code branch, and
     #             there is no data dictionary, the user has
     #             called a bad page.
     if (!isset($this->table['projections'])) {
         ?>
       <h1>Bad Page Request</h1>
       <p>There is no page <?php 
         echo hx(gp('gp_page'));
         ?>
       <?php 
         return;
     }
     // If a "fk jump", retrieve skey and make it look
     // like an edit call.
     if (gp('gp_pk') != '') {
         $pkval = gp("gp_pk");
         $pkcol = $this->table["pks"];
         $pktyp = $this->table['flat'][$pkcol]["type_id"];
         $table_id = $this->table["table_id"];
         // KFD 10/26/06, used to be $table_id
         $sq = "SELECT skey FROM " . $this->view_id . " WHERE " . $pkcol . " = " . SQL_Format($pktyp, $pkval);
         gpSet('gp_skey', SQL_OneValue('skey', $sq));
         gpSet('gp_mode', 'upd');
     }
     // If we were invoked by a child table, don't do this
     if (is_null($this->table_obj_child)) {
         // KFD 10/26/06, keep as $table_id
         Hidden('gp_page', $this->table_id);
         // always return to same page
         Hidden('gp_mode', '');
         Hidden('gp_skey', '');
         Hidden('gp_action', '');
         Hidden('gp_save', '');
         hidden('gp_copy', '');
     }
     // Work out what to do if mode is blank.  Might mean
     // upd, might mean browse.
     $mode = gp('gp_mode');
     $skey = gp('gp_skey');
     if ($mode == '') {
         $mode = $this->MainCheckForMover();
         if ($mode == '') {
             $mode = $skey == '' ? 'browse' : 'upd';
             gpSet('gp_mode', $mode);
         }
     }
     $this->mode = $mode;
     // KFD 8/13/07, Experimental COPY ability
     if (gp('gp_action') == 'copy') {
         $mode = 'ins';
         gpSet('gp_mode', 'ins');
     }
     switch ($mode) {
         case 'search':
             $this->PageSubtitle .= " (Lookup Mode)";
             break;
         case 'ins':
             $this->PageSubtitle .= " (New Entry)";
             break;
     }
     // ----------------------------------------------
     // Generate the main HTML elements
     if ($mode == 'browse') {
         $this->hBrowse();
     } elseif ($mode == 'mover') {
         $this->hMover();
     } else {
         $this->hBoxes($mode);
     }
     if ($mode != "mover") {
         $this->hButtonBar($mode);
     }
     $this->hLinks($mode);
     $this->hExtra($mode);
     // Now if this is a child table in a 1:M, it will not actually
     // output its own stuff, it will invoke its parent, so let's
     // buffer the output
     if ($this->table_id_parent != '') {
         ob_start();
     }
     // Echo out the HTML
     $this->ehMain();
     // Put this out at end, after all HTML has been output
     if ($mode == "search") {
         //$controls=vgfGet('gpControls');
         $controls = ContextGet('OldRow');
         $hScript = '';
         foreach ($controls as $key => $info) {
             $hScript .= "\nob('x2t_{$key}').value='';";
         }
         jqDocReady("function clearBoxes() { \n" . $hScript . "}\n\n");
     }
     // Again, if this is a child table in a 1:M, capture the output and
     // make it the responsibility of the parent
     if ($this->table_id_parent != '') {
         $this->h['Complete'] = ob_get_clean();
         // Wipe out and replace all gp variables, fool the parent object
         $OldRow = ContextGet('OldRow', array());
         $gpsave = aFromGP('gp_');
         gpUnsetPrefix('gp_');
         $dd = ContextGet('drilldown', array());
         $dd1 = array_pop($dd);
         gpSet('gp_skey', $dd1['skey']);
         // Now invoke the parent object, tell it about us
         $object = objPage($this->table_id_parent);
         $object->table_obj_child = $this;
         $object->main();
         // Replace the wiped out gp variables
         gpUnsetPrefix('gp_');
         gpSetFromArray('gp_', $gpsave);
         ContextSet('OldRow', $OldRow);
         // Force the menu to come from the parent
         vgaSet('menu_selected', $this->table_id_parent);
     }
 }
Ejemplo n.º 4
0
function scDBUpdateOrInsert($table, $colvals)
{
    $table_id = $table["table_id"];
    $tabflat =& $table["flat"];
    // First query for the pk value.  If not found we will
    // just do an insert
    //
    $abort = false;
    $a_pk = explode(',', $table['pks']);
    $s_where = '';
    foreach ($a_pk as $colname) {
        if (!isset($colvals[$colname])) {
            $abort = true;
            break;
        }
        $a_where[] = $colname . ' = ' . SQL_Format($tabflat[$colname]['type_id'], $colvals[$colname]);
    }
    if ($abort) {
        $skey = false;
    } else {
        $s_where = implode(' AND ', $a_where);
        $sql = 'SELECT skey FROM ' . DDTable_IDResolve($table_id) . ' WHERE ' . $s_where;
        $skey = SQL_OneValue('skey', $sql);
    }
    // STD says on 12/15/2006 that this routine should not put errors on screen
    //if (Errors()) echo HTMLX_Errors();
    if (!$skey) {
        //echo "insert into ".$table_id."\n";
        $retval = SQLX_Insert($table, $colvals, false);
        if (Errors()) {
            // STD says on 12/15/2006 that this routine should not put errors on screen
            //echo HTMLX_Errors();
            //echo $sql;
            $retval = 0;
        }
    } else {
        //echo "update ".$table_id." on $skey\n";
        $colvals['skey'] = $skey;
        $retval = -$skey;
        SQLX_Update($table, $colvals);
        if (Errors()) {
            // STD says on 12/15/2006 that this routine should not put errors on screen
            //echo HTMLX_Errors();
            //echo $sql;
            $retval = 0;
        }
    }
    return $retval;
}
Ejemplo n.º 5
0
    function main()
    {
        $app = gp('gp_app');
        // Today's date will become version.  Confirm that it is ok
        $v = date("Y.m.d", time());
        $mv = SQL_AllRows("Select version from appversions \n           where version = '{$v}'\n             AND application=" . SQLFC($app));
        if (count($mv) > 0) {
            ?>
         <div class="errorbox">There is already a version of the application
           stamped for today.  Cannot have two versions in the same day.
         </div>
         <?php 
            return;
        }
        // Will need list of directories.
        if ($app == 'andro') {
            $dirs = SQL_AllRows("Select * from appdirs where flag_copy='Y'");
        } else {
            $dirs = SQL_AllRows("Select * from appdirs where flag_copy='Y'\n                AND flag_lib='N'");
        }
        // Determine the app and root directory
        // Get the app
        $this->app = $app;
        $root = SQL_OneValue('dir_pub', "select wp.dir_pub \n           from webpaths     wp\n           JOIN applications ap ON wp.webpath=ap.webpath\n          WHERE ap.application = " . SQLFC($app));
        $root = AddSlash($root) . AddSlash($app);
        $this->root = $root;
        //x_echoFlush("Root directory will be: ".$root);
        // Either run the process....
        if (gp('gp_process') == 1) {
            ob_start();
            $this->mainProcess($v, $dirs);
            echo ob_end_clean();
            return;
        }
        $link = '?gp_page=appversions_p&gp_process=1&gp_app=' . gp('gp_app');
        // ...or ask them to click the button
        ?>
      <h1>Freeze Current Version</h1>
      <p>This program will create a new version of all application files
         for application <?php 
        echo hSanitize(gp('gp_app'));
        ?>
.
         It will copy all disk files into the database.
         The version will be numbered as <?php 
        echo $v;
        ?>
.
      </p>
         
      <p>The top level directory to be scanned is: <?php 
        echo $root;
        ?>
.
      </p>
      
      <p>The subdirectories to be scanned are:
      </p>
      <ul>
      <?php 
        foreach ($dirs as $dir) {
            echo "<li>" . $dir['dirname'];
        }
        ?>
      </ul>
         
      <p><a href="javascript:Popup('<?php 
        echo $link;
        ?>
')">Process Now</a>
      </p>
      
      <?php 
    }
Ejemplo n.º 6
0
function AppDir($app)
{
    $app = trim($app);
    $wp = SQL_OneValue('dir_pub', "Select dir_pub\n         from applications a\n         JOIN webpaths     w ON a.webpath=w.webpath\n        WHERE a.application='{$app}'");
    return trim($wp) . "/{$app}/";
}
Ejemplo n.º 7
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));
        }
    }
Ejemplo n.º 8
0
 function PW_ForgotPage3()
 {
     $retval = false;
     $UID = gp('uid');
     $eml = gp('eml');
     $hash = gp('hash');
     $pw1 = gp('pw1');
     $pw2 = gp('pw2');
     if ($pw1 != $pw2) {
         ErrorAdd("Password values did not match");
     }
     if (strlen($pw1) < 5) {
         ErrorAdd("Password must be at least 5 characters");
     }
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     }
     // confirm that user/hash is ok
     //
     scDBConn_Push('usermaint');
     $sql = "\nSelect count(*) as cnt \n  FROM users \n where LOWER(email) =" . SQLFC($eml) . "\n   and user_pwkey   =" . SQLFC($hash) . "\n   and user_disabled<>'Y'";
     $cnt = SQL_OneValue('cnt', $sql);
     if ($cnt == 0) {
         ErrorAdd("Bad Link, cannot reset password.");
     }
     scDBConn_Pop();
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     }
     // All is clear, update the password
     scDBConn_Push('usermaint');
     $sql = "\nUPDATE users SET member_password="******"\n WHERE email = " . SQLFC($eml);
     SQL($sql);
     scDBConn_Pop();
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
     } else {
         echo "Password has been reset!";
     }
 }
Ejemplo n.º 9
0
 function viewClob()
 {
     $table_id = gp('x6page');
     $skey = SQLFC(gp('skey'));
     $column = gp('column');
     $sql = 'SELECT "' . $column . '" from "' . $table_id . '" where skey= ' . $skey;
     echo "<pre>";
     $text = SQL_OneValue($column, $sql);
     echo $text;
     file_put_contents(fsDirTop() . 'tmp/viewClob.txt', $text);
     echo "</pre>";
     exit;
 }
Ejemplo n.º 10
0
    function ehTab_Filters($ajax = true)
    {
        if ($ajax) {
            echo "x2_content|";
        }
        $skey = SQLFN(gp('gp_skey'));
        $report = SQL_OneValue('report', "Select report from reports where skey={$skey}");
        // Do any processing that may have come through
        if (gp('gp_ajax') == 'filtrep') {
            $repfilters = SQLFC(gp('gp_val'));
            //echo "we are setting $repfilters";
            SQL("UPDATE reports SET repfilters={$repfilters} WHERE skey={$skey}");
        }
        if (gp('gp_ajax') == 'filtlev') {
            $repfilters = SQLFC(gp('gp_val'));
            $skeylev = SQLFN(gp('gp_skeylev'));
            SQL("UPDATE reportlevels \n                 SET repfilters={$repfilters} WHERE skey={$skeylev}");
        }
        // Retrieve and display
        $repfilter = SQL_OneValue('repfilters', "Select skey,repfilters from reports where skey={$skey}");
        $levs = SQL_AllRows("Select rl.skey,rl.reportlevel,rl.repfilters \n           from reportlevels    rl\n          WHERE exists ( SELECT * from reportcollevels\n                          WHERE report = '{$report}'\n                            AND reportlevel = rl.reportlevel)\n            AND report='{$report}'");
        //echo hErrors();
        // Now for each level list some filters
        ?>
      <table>
        <tr>
          <td class="dhead" style="width: 10em">Level</td>
          <td class="dhead">SQL Filters</td>
          <td class="dhead">Save</td>
        </tr>
        <tr>
          <td valign=top>Base</td>
          <td><textarea id='lev0' name="lev0"
                   cols=60
                   rows=5 
                  style="border:1px solid gray"
                ><?php 
        echo $repfilter;
        ?>
</textarea></td>
           <td><a href="javascript:sndReq('&gp_ajax=filtrep&gp_val='+encodeURIComponent(ob('lev0').value))">Save</a>

        </tr>
      <?php 
        foreach ($levs as $lev) {
            $js = '&gp_ajax=filtlev&gp_skeylev=' . $lev['skey'];
            ?>
         <tr>
           <td valign=top><?php 
            echo $lev['reportlevel'];
            ?>
</td>
           <td><textarea 
                    cols=60 
                    rows=5 
                   style="border:1px solid gray"
               onchange="sndReq('<?php 
            echo $js;
            ?>
&gp_val='+this.value)"
                 ><?php 
            echo $lev['repfilters'];
            ?>
</textarea></td>
         </tr>
         <?php 
        }
        ?>
      </table>
      <br/>
      <h3>Columns in this report</h3>
      <table style="width:50%">
        <tr>
          <td class="dhead">Description</td>
          <td class="dhead">Table</td>
          <td class="dhead">Column</td>
        </tr>
        <?php 
        // Columns in this report
        $sql = "SELECT description,table_id,column_id from reportcolumns\n                WHERE report = '{$report}'\n                ORDER BY description";
        $cols = SQL_Allrows($sql);
        foreach ($cols as $col) {
            ?>
            <tr><td><?php 
            echo $col['description'];
            ?>
                <td><?php 
            echo $col['table_id'];
            ?>
                <td><?php 
            echo $col['column_id'];
            ?>
            <?php 
        }
        ?>
      </table>
      <?php 
    }
Ejemplo n.º 11
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();
    }