Пример #1
0
 function main()
 {
     hidden('gp_page', 'x_emailblast');
     hidden('gp_table', CleanGet('gp_table', '', false));
     hidden('gp_posted', 1);
     $table = CleanGet('gp_table', '', false);
     if ($table == '') {
         ErrorAdd('Incorrect call to x_emailblast, no table parameter.' . 'This is a programming error, please contact your ' . 'technical support department');
         return;
     }
     // Get an object for the page we need.  Then
     // pull the list of skeys in the current search
     // and pull the rows.
     //
     $obj = DispatchObject($table);
     $a_skeys = ContextGet("tables_" . $obj->table_id . "_skeys", array());
     $l_skeys = implode(',', $a_skeys);
     // get this little detail taken care of
     //
     $this->PageSubtitle = 'Email blast to ' . $obj->table['description'];
     // Get the list of columns of interest, and pull them
     // and slot them by skey, so the list of skeys can be
     // used to order them
     //
     $lDisplayColumns = $obj->table['projections']['email'];
     $aDisplayColumns = explode(',', $lDisplayColumns);
     $EmailColumn = $obj->table['projections']['emailaddr'];
     $sql = 'SELECT skey,' . $EmailColumn . ',' . $lDisplayColumns . ' FROM ' . $table . ' WHERE skey IN (' . $l_skeys . ')';
     $DBRes = SQL($sql);
     $rows = array();
     while ($row = SQL_FETCH_Array($DBRes)) {
         $rows[$row['skey']] = $row;
     }
     $okToSend = false;
     if (CleanGet('gp_posted', '', false) == 1) {
         if (CleanGet('txt_subject', '', false) == '') {
             ErrorAdd('Please fill in a subject first');
         }
         if (trim(CleanGet('txt_email', '', false)) == '') {
             ErrorAdd('Please fill in an email body');
         }
         if (!Errors()) {
             $okToSend = true;
         }
     }
     // Now that we have the results, decide whether we
     // are sending out the email or
     if ($okToSend) {
         $this->EmailBlast($rows, $a_skeys, $EmailColumn, $aDisplayColumns);
     } else {
         $this->EmailHTML($rows, $a_skeys, $aDisplayColumns);
     }
 }
Пример #2
0
    function main()
    {
        # KFD 2/17/09.  If installed with Debian package, will
        #               have username and password of "start".
        #               Must force a new id now.
        #
        if (SessionGet('UID') == 'start') {
            if (gp('user_id') != '') {
                if (gp('user_id') == '') {
                    ErrorAdd("User Id may not be empty");
                }
                if (substr(gp('user_id'), 0, 5) == 'andro') {
                    ErrorAdd("User Id may not begin with 'andro'");
                }
                if (gp('password1') != gp('password2')) {
                    ErrorAdd("Passwords do not match");
                }
                if (strlen(trim(gp('password1'))) == 0) {
                    ErrorAdd("Password may not be empty");
                }
                if (!Errors()) {
                    $row = array('user_id' => gp('user_id'), 'member_password' => gp('password1'));
                    SQLX_Insert('usersroot', $row);
                    if (!Errors()) {
                        scDBConn_Pop();
                        SessionSet('UID', gp('user_id'));
                        SessionSet('PWD', gp('password1'));
                        scDBConn_Push();
                        SQL("DELETE FROM USERSROOT WHERE user_id='start'");
                        # Get rid of the form that replaces login
                        $file = fsDirTop() . 'application/x_login_form.inc.html';
                        $fileto = $file . '.done';
                        @rename($file, $fileto);
                        ?>
                        <h1>New Root User Created</h1>
                        
                        <p>Your new user is created.</p>
                        
                        <p><a href="index.php?st2logout=1">
                           Return to Login Page</a></p>
                        <?php 
                        return;
                    }
                }
            }
            ?>
            <h1>New Install - Must Create User</h1>
            
            <p>You are logged into your Node Manager with the default
               username of "start" and password "start".  We have to change
               this right now so nobody can get into your new system.
            </p>
            
            <p>Please provide a new ROOT (superuser) user id and password
               below.  Andromeda will create the new user, log you in as
               that user, and remove the "start" user.
            </p>
            
            <table>
              <tr><td align="left">User Name
                  <td><input name = 'user_id' /> (may not begin with 'andro')
              <tr><td align="left">Password
                  <td><input type="password" name = 'password1'/>
              <tr><td align="left">Password (verify)
                  <td><input type="password" name = 'password2'/>
            </table>
            <input type="submit" value="Create User Now" />
            <?php 
            return;
        }
        /* FUTURE X6 VERSION OF NODE MANAGER
           ?>
           <h1>Node Manager Upgrade Required</h1>
           
           <p>The new version of the Node Manager uses the "x6" 
              interface to provide a richer experience.  Please click
              the link below to upgrade your Node Manager.  Once the
              upgrade is complete, log out and back in.
           </p>
           
           <p><a href="javascript:Popup('index.php?gp_page=a_builder&gp_out=none&x2=1&txt_application=andro','Build')"
               >Upgrade Node Manager Now</a>.</p>
               
           <p><a href="?st2logout=1">Logout After Upgrade</a>.</p>
           
           <?php
           return;
           */
        # <------- EARLY RETURN.
        # KFD 1/10/08, The old x_welcome screen is not used anymore,
        #              we have the new 'cpanel' now in x6.
        # ===============================================================
        ?>
        <h1>Welcome to the Andromeda Node Manager</h1>
        <?php 
        // Work out if there is a new release available
        //
        $apps = svnVersions();
        $andro = a($apps, 'andro', array('svn_url' => ''));
        if (trim($andro['svn_url']) == '') {
            $htmlVersions = '';
        } else {
            $htmlVersions = @file_get_contents($andro['svn_url']);
        }
        $matches = array();
        preg_match_all('/<li><a href=.*\\>(.*)<\\/a><\\/li>/', $htmlVersions, $matches);
        $versions = ArraySafe($matches, 1, array());
        if (count($versions) > 0) {
            $latest = array_pop($versions);
            $latest = str_replace('/', '', $latest);
            // Get current latest
            $current = $andro['local'];
            if ($latest > $current) {
                ?>
            <br/>
            <div style="border: 5px solid gray; color: blue
            font-weight: bolder; margin: 8px; padding: 0 8px 8px 8px">
            <h2>New Version of Andromeda Available</h2>
            
            <p>Version <?php 
                echo $latest;
                ?>
 is available.   <a href="?gp_page=a_pullsvn"
            >Click Here </a> to go to the Pull Code From Subversion.
            </div>
            <?php 
            }
        }
        $dirs = SQL_AllRows("select * from webpaths where webpath='DEFAULT'");
        ?>
<div style="font-size: 120%; line-height: 120%; padding: 10px">

<h2>For First Time Users</h2>
    This program is the Andromeda <b>Node Manager</b>.  You use this
    program to build your applications.
    <br/>
    <br/>
    Our main documentation is <a target="_blank" href=
    "http://www.andromeda-project.org/">here</a>.
    <br/>
    <br/>

    If you want to start programming a new application right away, 
    <a target="_blank"  href=
    "http://www.andromeda-project.org/creatinganapplication.html"
    >The instructions are here</a>, or you can just 
    <a href="?gp_page=applications&gp_mode=ins">define a new application here.</a>
    <br/>
    <br/>

After you defined an application, click on the "build this application"
link to create all of the directories and the empty database.</p>
<br/>
<br/>

<h2>Your Application Program Files</h2>

After building the application skeleton you can start working on the
   database specification.  If your application code is "test", then put
   the database specification into the file
   <br/>
   <br/>
   <b><?php 
        echo $dirs[0]['dir_pub'];
        ?>
/test/application/test.dd.yaml</b>
<br/>
<br/>

All Andromeda applications start with
a database specification.  These specifications are 
more powerful than anything else out there, 
and you will want learn the Andromeda's 
<a target="_blank" href=
"http://www.andromeda-project.org/databaseprogramming.html"
>Database Programming</a> language.

<br/>
<br/>
Once you are ready to try some custom pages, you are ready to look
at <a target="_blank" href=
"http://www.andromeda-project.org/webprogramming.html"
>Web Programming</a>.
   
    
</div>        
        <?php 
    }
Пример #3
0
<section class="all-subj-menu">
  <div>
   <?php 
echo Navigation($current_subject, $current_page, false);
?>
  </div>
  </section>

    <section  class="page">
              <div>
                  <?php 
echo message();
?>
                   <?php 
$errors = Errors();
?>
                     <?php 
echo FormErrors($errors);
?>
                    

              <h2>Create Subject</h2>
                   <form action="create_subject.php" method="post">
                     <p>Menu Name:
                     <input type="text" name="menu_name" value="" />
                     </p>
                     <p>Position
                     <select name="position">
                     <?php 
$subject_set = FindAllSubjects(false);
Пример #4
0
 /**
  *  Run the report based on options provided by user.
  *
  *  @param string $yamlP2  A processed YAML page description
  *  @access private
  */
 private function pageReport()
 {
     // Create the reporting object
     require_once 'androPageReport.php';
     $oReport = new androPageReport();
     // For each section, run the output
     foreach ($this->yamlP2['section'] as $secname => $secinfo) {
         $dbres = SQL($secinfo['sql']);
         if (gp("showsql") == 1) {
             hprint_r($secinfo['sql']);
         }
         if (Errors()) {
             hprint_r($secinfo['sql']);
             echo hErrors();
         }
         if (gp("showsql") == 1) {
             return;
         }
         // Now pass the SQL resource to the reporting engine
         $oReport->main($dbres, $this->yamlP2, $secinfo);
     }
 }
Пример #5
0
 /**
  * Execute an skey-based update
  *
  */
 function update()
 {
     $row = aFromGP('x4v_');
     $skey = 0;
     $table_id = $this->dd['table_id'];
     # KFD 6/12/08, allow functions to modify or prevent a write
     $tbefore = $table_id . "_writeBefore";
     $tafter = $table_id . "_writeAfter";
     if (function_exists($tbefore)) {
         $message = $tbefore($row);
         if ($message != '') {
             x4Error($message);
             return;
         }
     }
     # KFD 6/28/08, a non-empty date must be valid
     $errors = false;
     foreach ($row as $col => $value) {
         if (!isset($this->dd['flat'][$col])) {
             unset($row[$col]);
             continue;
         }
         $ermsg = "Invalid date format for " . $this->dd['flat'][$col]['description'];
         $ermsg2 = "Invalid date value for " . $this->dd['flat'][$col]['description'];
         if ($this->dd['flat'][$col]['type_id'] == 'date') {
             if (trim($value) == '') {
                 continue;
             }
             if (strpos($value, '/') === false && strpos($value, '-') === false) {
                 x4Error($ermsg);
                 $errors = true;
                 continue;
             }
             if (strpos($value, '/') !== false) {
                 $parsed = explode('/', $value);
                 if (count($parsed) != 3) {
                     $errors = true;
                     x4Error($ermsg);
                     continue;
                 }
                 if (!checkdate($parsed[0], $parsed[1], $parsed[2])) {
                     x4Error($ermsg2);
                     $errors = true;
                     continue;
                 }
             }
             if (strpos($value, '-') !== false) {
                 $parsed = explode('-', $value);
                 if (count($parsed) != 3) {
                     $errors = true;
                     x4Error($ermsg);
                     continue;
                 }
                 if (!checkdate($parsed[1], $parsed[2], $parsed[0])) {
                     x4Error($ermsg2);
                     $errors = true;
                     continue;
                 }
             }
         }
     }
     if ($errors) {
         return;
     }
     if ($row['skey'] == 0 || !isset($row['skey'])) {
         unset($row['skey']);
         $skey = SQLX_Insert($this->dd, $row);
         if (!errors()) {
             $row = SQL_OneRow("Select * FROM {$this->view_id} WHERE skey = {$skey}");
         }
         x4Data('row', $row);
     } else {
         SQLX_Update($this->dd, $row);
         if (!errors()) {
             $skey = $row['skey'];
             $row = SQL_OneRow("Select * FROM {$this->view_id} WHERE skey = {$skey}");
             x4Data('row', $row);
         }
     }
     # KFD 6/12/08, allow functions to modify or prevent a write
     if (Errors()) {
         return;
     }
     if (function_exists($tafter)) {
         $message = $tafter($row);
         if ($message != '') {
             x4Error($message);
             return;
         }
     }
 }
Пример #6
0
 function fbProcInner($fi, $t)
 {
     x_EchoFlush("BEGIN FILE PROCESSING");
     $FILE = fopen($fi['uname'], 'r');
     if (!$FILE) {
         x_EchoFlush("Trouble opening local uploaded file.");
         x_EchoFlush("ABORT WITH ERROR");
         return 0;
     }
     // Make sure first line is ok
     $line1 = fsGets($FILE);
     if (strlen($line1) == 0) {
         x_EchoFlush("Failed reading first line, file is empty?");
         x_EchoFlush("ABORT WITH ERROR");
         return 0;
     }
     if (strlen($line1) > 4998) {
         x_EchoFlush("First line is &gt; 4998 bytes, this cannot be right.");
         x_EchoFlush("ABORT WITH ERROR");
         return 0;
     }
     // Now convert the first line into the list of columns
     $acols = explode('|', $line1);
     x_echoFlush("COLUMNS IN FILE:");
     foreach ($acols as $acol) {
         x_EchoFlush($acol);
     }
     // Retrieve maps
     $mapcols = SQL_AllRows("SELECT column_id,COALESCE(column_id_src,'') as src\n            FROM importmapcolumns\n           WHERE table_id=" . SQLFC($t['table_id']) . "\n             AND importmap=" . SQLFC(gp('gp_map')), 'column_id');
     echo "<hr>";
     echo "<h2>Map is as follows: " . gp('gp_map') . "</h2>";
     hprint_r($mapcols);
     echo "<hr>";
     // Now convert each line as we go
     $linenum = 0;
     $linesok = 0;
     while (($oneline = fsGets($FILE)) !== false) {
         $linenum++;
         // Give the user something to believe in
         if ($linenum % 100 == 0) {
             x_EchoFlush("Line: {$linenum} processing");
         }
         // Pull the line
         $data = explode('|', $oneline);
         // Maybe a problem?
         if (count($data) != count($acols)) {
             x_EchoFlush("ERROR LINE {$linenum}");
             x_EchoFlush("Too many or too few values");
             hprint_r($data);
             continue;
         }
         // No problem yet, attempt the insert
         ErrorsClear();
         // Assign first-row column names to incoming data
         $row = array_combine($acols, $data);
         // Match the values from the map
         $rowi = array();
         foreach ($mapcols as $mapcol => $info) {
             if ($info['src'] != '') {
                 if (isset($row[$info['src']])) {
                     $rowi[$mapcol] = $row[$info['src']];
                 }
             }
         }
         $mixed = array($t['table_id'] => array($rowi));
         SQLX_Cleanup($mixed);
         SQLX_insert($t, $mixed[$t['table_id']][0]);
         // Complaints?  Problems? Report them!
         if (Errors() && strpos(hErrors(), 'Duplicate Value') === false) {
             x_EchoFlush('------------------------------------------------');
             x_EchoFlush("ERROR LINE {$linenum} when attempting to insert");
             x_EchoFlush(hErrors());
             x_EchoFlush('------------------------------------------------');
             continue;
         }
         $linesok++;
     }
     return array($linenum, $linesok);
 }
Пример #7
0
 function processSubmit()
 {
     // Get the submitted data
     $table = gp('gp_table_upd', '');
     // Get the flat table def
     $table_dd = dd_TableRef($table);
     $tabflat = ArraySafe($table_dd, 'flat');
     //hprint_r($table);
     $row = aFromGP('gp_upd_');
     //hprint_r($row);
     //hprint_r($row);
     // Build a WHERE clause
     $where = array();
     foreach ($row as $col => $val) {
         if (ArraySafe($tabflat[$col], 'primary_key', 'N') != 'Y') {
             continue;
         }
         $where[] = $col . " = '" . $val . "'";
     }
     //hprint_r($where);
     $where = implode(' AND ', $where);
     // Build a SELECT
     $sql = "SELECT skey\n                 FROM " . ddTable_IDResolve($table) . "\n                WHERE " . $where;
     //hprint_r($sql);
     $records = SQL_AllRows($sql);
     if (count($records) != 1) {
         echo "Invalid or non-unique key supplied\n<br>";
         return;
     }
     // Well, we haven't failed yet, let's add the skey before the update, just to be safe.
     $row['skey'] = $records[0]['skey'];
     $skey = $records[0]['skey'];
     //hprint_r($row);
     SQLX_Update($table_dd, $row);
     if (Errors()) {
         echo hErrors();
     } else {
         echo "Update Successful.  <a href=\"?gp_page={$table}&gp_skey={$skey}\">View Record</a> <br>\n";
     }
 }
Пример #8
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;
}
Пример #9
0
 function mainPRocess($v, $dirs)
 {
     // First create the version
     $table_dd = DD_TableRef('appversions');
     $row = array('version' => $v, 'date' => time(), 'application' => $this->app);
     SQLX_Insert($table_dd, $row);
     if (Errors()) {
         echo hErrors();
         return;
     }
     // We'll need this for every file we load
     $this->tlf = DD_TableRef('appfiles');
     // Create the application save directory
     $app = $this->app;
     $r2 = $GLOBALS['AG']['dirs']['root'];
     if (!file_exists($r2 . 'pkg-apps')) {
         mkdir($r2 . 'pkg-apps');
     }
     if (!file_exists($r2 . "pkg-apps/{$app}-{$v}")) {
         mkdir($r2 . "pkg-apps/{$app}-{$v}");
     }
     $r2 = $r2 . "pkg-apps/{$app}-{$v}";
     foreach ($dirs as $dir) {
         if (!file_exists($this->root . $dir['dirname'])) {
             mkdir($this->root . $dir['dirname']);
         }
         $this->mainPR_DirFiles($v, $r2, $this->root, $dir['dirname'], '');
     }
     $dpa = $GLOBALS['AG']['dirs']['root'] . 'pkg-apps/';
     chdir($GLOBALS['AG']['dirs']['root'] . 'pkg-apps/');
     $command = "tar czvf {$app}-{$v}.tgz {$app}-{$v}";
     x_EchoFlush("");
     x_EchoFlush("Tarballing with this command: {$command}");
     `{$command}`;
     x_EchoFlush("");
     // Now create the install version.
     if ($this->app == 'andro') {
         x_EchoFlush("Renaming install.done.php to install.php");
         rename("{$dpa}{$app}-{$v}/application/install.done.php", "{$dpa}{$app}-{$v}/application/install.php");
         x_EchoFlush("Renaming directory to andro, copying index.php");
         rename("{$dpa}{$app}-{$v}", $dpa . "andro");
         copy($dpa . "andro/root/index.php", $dpa . "andro/index.php");
         copy($dpa . "andro/root/htaccess", $dpa . "andro/.htaccess");
         // KFD 8/2/07, Sourceforge bug #1755244, for the node manager
         //             these are created by build but we need them for
         //             the build, so make them here.
         mkdir($dpa . "andro/tmp");
         mkdir($dpa . "andro/generated");
         // KFD 8/2/07, Sourceforge bug #1755244, END
         $command = "tar czvf {$app}-{$v}-install.tgz andro index.php .htaccess";
         x_EchoFlush("");
         x_EchoFlush("Tarballing install version with this command: {$command}");
         `{$command}`;
         x_EchoFlush("Renaming directory back to {$app}-{$v}");
         unlink($dpa . "andro/index.php");
         unlink($dpa . "andro/.htaccess");
         rename($dpa . "andro", "{$dpa}{$app}-{$v}");
         x_EchoFlush("Process is complete!");
     }
 }
Пример #10
0
 function MD5_ForgotPage3()
 {
     $UID = gp('uid');
     $md5 = gp('md5');
     $pw1 = gp('pw1');
     $pw2 = gp('pw2');
     fwLogEntry('1025', 'PW Change Attempt', $UID);
     if ($pw1 != $pw2) {
         ErrorAdd("Password values did not match");
     }
     if (strlen($pw1) < 6) {
         ErrorAdd("Password must be at least 5 characters");
     }
     if (!preg_match("/[0-9]/", $pw1)) {
         ErrorAdd("Password must contain at least one numeric digit");
     }
     if (!preg_match("/[a-z]/", $pw1)) {
         ErrorAdd("Password must contain at least one lower case character");
     }
     if (!preg_match("/[A-Z]/", $pw1)) {
         ErrorAdd("Password must contain at least one upper case character");
     }
     if (strpos(strtolower($pw1), strtolower($UID)) !== false) {
         ErrorAdd("You cannot use your user_id in your password!");
     }
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     }
     $row = array('user_id' => $UID, 'md5' => $md5, 'member_password' => $pw1);
     SQLX_Insert('users_pwverifies', $row);
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     } else {
         fwLogEntry('1026', 'PW Change Success', $UID);
         ?>
      <p>Your password has been set, you can now 
         <a href="?gp_page=x_login">Login</a>.
      
      <?php 
     }
 }
Пример #11
0
 /**
  * Execute an skey-based delete
  *
  */
 function delete()
 {
     $perm = $this->uiPerm(gp('x6page'), 'del');
     if (!$perm) {
         x6Error("Deletion not allowed from this screen");
         return;
     }
     # KFD 6/8/09 Google #29 Various changes to allow pre- and post-
     #                       delete methods
     $table_id = gp('x6page');
     $view = ddView(gp('x6page'));
     $skey = SQLFN(gp('skey'));
     $method = $table_id . "_before_delete";
     $continue = true;
     if (method_exists($this, $method)) {
         $continue = $this->{$method}($skey);
     }
     if ($continue) {
         $sq = "Delete from {$view} where skey = {$skey}";
         SQL($sq);
         if (Errors()) {
             x6Errors(hErrors());
         } else {
             $method = $table_id . "_after_delete";
             if (method_exists($this, $method)) {
                 $this->{$method}();
             }
         }
     }
 }
Пример #12
0
function index_hidden_page()
{
    global $AG;
    $sessok = !LoggedIn() ? false : true;
    // KFD 3/6/08, moved here from the main stream of index_hidden
    //             because these are relevant only to page processing
    if (gpExists('x_module')) {
        SessionSet('AGMENU_MODULE', gp('x_module'));
    } elseif (vgaGet('nomodule') != '' && SessionGet('AGMENU_MODULE') == '') {
        SessionSet('AGMENU_MODULE', vgaGet('nomodule'));
    }
    // If the search flag is set, we need to know what class for this
    // application handles searchs
    if (gpExists('gp_search')) {
        gpSet('gp_page', vgaGet('SEARCH_CLASS'));
    }
    // Load up a list of pages that public users are allowed to see,
    // with home and password always there.
    global $MPPages;
    // allows it to be in applib
    $MP = array();
    //$MPPages= array();
    // This is the old method, load $MPPages from its own file
    if (file_exists_incpath('appPublicMenu.php')) {
        include_once 'appPublicMenu.php';
    }
    if (!is_array($MPPages)) {
        $MPPages = array();
    }
    $MPPages['x_home'] = 'Home Page';
    $MPPages['x_login'] = '******';
    $MPPages['x_noauth'] = 'Authorization Required';
    $MPPages['x_password'] = "******";
    $MPPages['x_mpassword'] = "******";
    $MPPages['x_paypalipn'] = 'Paypal IPN';
    // If the install page exists, it will be used, no getting
    // around it.
    $install = $GLOBALS['AG']['dirs']['application'] . 'install.php';
    $instal2 = $GLOBALS['AG']['dirs']['application'] . 'install.done.php';
    if (file_exists($install)) {
        if (gp('gp_install') == 'finish') {
            rename($install, $instal2);
        } else {
            $MPPages['install'] = 'install';
            gpSet('gp_page', 'install');
        }
    }
    // First pass is to look for the "flaglogin" flag.  This says save all
    // current page settings and go to login screen.  They will be restored
    // on a successful login.  Very useful for links that say "Login to
    // see nifty stuff..."
    if (gp('gp_flaglogin') == '1') {
        gpSet('gp_flaglogin', '');
        gpToSession();
        gpSet('gp_page', 'x_login');
    }
    // Second pass redirection, pick default page if there
    // is none, and verify public pages.
    //
    $gp_page = gp('gp_page');
    if ($gp_page == '') {
        if (vgfGet('LoginAttemptOK') === true && vgfGet('x4') === true) {
            $gp_page = 'x4init';
            gpSet('gp_page', 'x4init');
            SessionSet('TEMPLATE', 'x4');
        } else {
            if (function_exists('appNoPage')) {
                $gp_page = appNoPage();
            } else {
                if (!LoggedIn()) {
                    $gp_page = FILE_EXISTS_INCPATH('x_home.php') ? 'x_home' : 'x_login';
                } else {
                    // KFD 3/2/07, pull vga stuff to figure defaults
                    if (vgaGet('nopage') != '') {
                        $gp_page = vgaGet('nopage');
                    } else {
                        $gp_page = 'x_welcome';
                    }
                }
            }
        }
    }
    // If they are trying to access a restricted page and are not
    // logged in, cache their request and redirect to login page
    if (!$sessok && !isset($MPPages[$gp_page])) {
        if (vgfGet('loglogins', false)) {
            fwLogEntry('1014', 'Page access w/o login', $gp_page);
        }
        gpToSession();
        $gp_page = 'x_login';
    }
    // If pos is activated and the current requested page does not
    // match what they are cleared for, redirect to login
    if (vgaGet('POS_SECURITY', false) == true && SessionGet('ADMIN') == false) {
        if (SessionGet('POS_PAGE', '', 'FW') != $gp_page) {
            gpToSession();
            $gp_page = 'x_login';
        }
    }
    gpSet('gp_page', $gp_page);
    // Make any database saves.  Do this universally, even if save
    // was not selected.  If errors, reset to previous request.
    //if(gp('gp_save')=='1') processPost();
    processPost();
    if (Errors()) {
        gpSetFromArray('gp_', aFromGp('gpx_'));
    }
    // Put Userid where HTML forms can find it
    //vgfSet("UID",SessionGet("UID"));
    //if (vgfSet("UID")=="") { vgfSet("UID","Not Logged In"); }
    // THIS IS NEWER X_TABLE2 version of drilldown commands,
    // considerably simpler than the older ones. It makes use of
    // three gp_dd variables.
    //
    // Notice how we process drillbacks FIRST, allowing a link
    // to contain both drillback and drilldown, for the super-nifty
    // effect of a "drill-across"
    hidden('gp_dd_page');
    hidden('gp_dd_skey');
    hidden('gp_dd_back');
    if (intval(gp('gp_dd_back')) > 0 && $sessok) {
        // this is drillback
        $dd = ContextGet('drilldown', array());
        $back = intval(gp('gp_dd_back'));
        if (count($dd) >= $back) {
            $spot = count($dd) - $back;
            $aback = $dd[$spot];
            gpSet('gp_skey', $aback['skey']);
            gpSet('gp_page', $aback['page']);
            $gp_page = $aback['page'];
            gpSet('gpx_skey', $aback['skey']);
            gpSet('gpx_page', $aback['page']);
            gpSetFromArray('parent_', $aback['parent']);
            if (!gpExists('gp_mode')) {
                gpSet('gp_mode', 'upd');
            }
            $dd = $spot == 0 ? array() : array_slice($dd, 0, $spot);
            ContextSet('drilldown', $dd);
            ContextSet('drilldown_top', $aback['page']);
            //ContextSet('drilldown_level',count($dd));
        }
    }
    if (gp('gp_dd_page') != '' && $sessok) {
        // this is drilldown...
        $matches = DrillDownMatches();
        $matches = array_merge($matches, aFromGP('parent_'));
        $dd = ContextGet('drilldown', array());
        $newdd = array('matches' => $matches, 'parent' => aFromGP('parent_'), 'skey' => gp('gpx_skey'), 'page' => gp('gpx_page'));
        $dd[] = $newdd;
        ContextSet('drilldown', $dd);
        ContextSet('drilldown_top', gp('gp_dd_page'));
        //ContextSet('drilldown_level',count($dd));
        // having saved the stack, redirect to new page.
        $tnew = gp('gp_dd_page');
        $gp_page = $tnew;
        gpSet('gp_page', $tnew);
        if (gp('gp_dd_skey') != '') {
            gpSet('gp_skey', gp('gp_dd_skey'));
            gpSet('gp_mode', 'upd');
        }
        // Clear search of new page, set filters to blank
        processPost_TableSearchResultsClear($tnew);
        ConSet('table', $tnew, 'search', array());
    }
    // If no drilldown commands were received, and we are not on
    // the page that is the top, user must have picked a new page
    // altogether, wipe out the drilldown stack
    if (gp('gp_page') != ContextGet('drilldown_top', '')) {
        ContextSet('drilldown', array());
        ContextSet('drilldown_top', '');
    }
    // Must always have these on the user's form.  These can
    // be retired with x_Table, they are for old drilldown
    //
    hidden("dd_page", "");
    hidden("dd_ddc", "");
    hidden("dd_ddv", "");
    hidden("dd_ddback", "");
    hidden("dd_action", "searchexecute");
    hidden("dd_skey", "");
    // Load user preferences just before display
    UserPrefsLoad();
    $dir = $GLOBALS['AG']['dirs']['root'] . 'application/';
    if (file_exists($dir . $gp_page . ".page.yaml")) {
        include 'androPage.php';
        $obj_page = new androPage();
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main($gp_page);
        if ($obj_page->flag_buffer) {
            vgfSet("HTML", ob_get_clean());
            //ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    } else {
        $obj_page = DispatchObject($gp_page);
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main();
        if ($obj_page->flag_buffer && vgfGet('HTML') == '') {
            vgfSet("HTML", ob_get_contents());
            ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    }
    // Save context onto the page.  Note that it is not really
    // protected by these methods, just compressed and obscured.
    //
    $t2 = serialize($GLOBALS['AG']['clean']['gpContext']);
    $t2 = gzcompress($t2);
    $t2 = base64_encode($t2);
    Hidden('gpContext', $t2);
    // KFD 3/7/07, give the app the final opportunity to process
    //             things before the display, while logged in.
    if (function_exists('appdisplaypre')) {
        appDisplayPre();
    }
    // ...and write output and we are done.  Assume if there was
    // no buffering that the output is already done.
    if ($obj_page->flag_buffer != false) {
        // Work out what template we are using
        index_hidden_template('x2');
        // KFD 5/30/07, send back only main content if asked
        if (gp('ajxBUFFER') == 1) {
            echo "andromeda_main_content|";
            ehStandardContent();
            echo "|-|_focus|" . vgfGet('HTML_focus');
            $ajax = ElementReturn('ajax', array());
            echo '|-|' . implode('|-|', $ajax);
            echo '|-|_title|' . vgfGet('PageTitle');
        } elseif (defined('_VALID_MOS')) {
            // This is the default branch, using a Joomla template
            // DUPLICATE ALERT: This code copied into
            //          index_hidden_x4Dispatch() above
            global $J;
            $mainframe = $J['mainframe'];
            $my = $J['my'];
            $mosConfig_absolute_path = $J['mC_absolute_path'];
            $mosConfig_live_site = $J['mC_live_site'];
            $template_color = $J['template_color'];
            $template_color = 'red';
            $file = $GLOBALS['AG']['dirs']['root'] . '/templates/' . $mainframe->GetTemplate() . "/index.php";
            include $file;
        } elseif ($obj_page->html_template !== '') {
            // This is newer style, let the class specify the template.
            include $obj_page->html_template . '.php';
        } else {
            // This is old style, defaults to "html_main.php", can be
            // set also by vgaSet() or by gp(gp_out)
            $html_main = vgaGet('html_main') == '' ? 'html_main' : vgaGet('html_main');
            switch (CleanGet("gp_out", "", false)) {
                case "print":
                    include "html_print.php";
                    break;
                case "info":
                    include "html_info.php";
                    break;
                case "":
                    include $html_main . ".php";
                    break;
                default:
            }
        }
    }
}