Beispiel #1
0
function tmpModuleLeft()
{
    // April 4, 2007, KFD.  Allow a breakout here
    if (function_exists('appModuleLeft')) {
        $continue = appModuleLeft();
        return $continue;
    }
    //echo "<br/>";
    if (!LoggedIn()) {
        return;
    }
    // Only display menu if
    if (OptionGet('MENULEFT', 'Y') == 'Y') {
        $module = SessionGet("AGMENU_MODULE");
        $AGMENU = SessionGet("AGMENU");
        $kount = 0;
        if (isset($AGMENU[$module])) {
            $desc = $AGMENU[$module]['description'];
            echo "<ul class=\"nav nav-list\">";
            echo "<li class=\"nav-header\">{$desc}</li>";
            foreach ($AGMENU[$module]['items'] as $key => $info) {
                $hExtra = ' tabindex="' . hpTabIndexNext(100) . '"';
                // We may make the first item the focused item if nothing else
                // has been picked yet.  This code runs when rendering is going on
                // and the class-specific biz code has all run already, so it will
                // not override any business-specific focus setting
                if (vgfGet('HTML_focus') == '') {
                    $hExtra .= ' ID="FIRSTSPLITMENU" NAME="FIRSTSPLITMENU" ';
                    vgfSet('HTML_focus', 'FIRSTSPLITMENU');
                }
                $kount++;
                $d = '?gp_page=' . $key;
                $h = hLink("mainlevel", $info['description'], $d, $hExtra);
                echo "\n<li>{$h}</li>";
                // Possibly two more links
                if (ArraySafe($info, 'linknew') == 'Y') {
                    $hx = ' tabindex="' . hpTabIndexNext(100) . '" style="margin-left:30px"';
                    $h = hLink("mainlevel", 'New', $d . '&gp_mode=ins', $hx);
                    echo "\n<li>{$h}</td></li>";
                }
                if (ArraySafe($info, 'linksearch') == 'Y') {
                    $hx = ' tabindex="' . hpTabIndexNext(100) . '" style="margin-left:30px"';
                    $h = hLink("mainlevel", 'Search', $d . '&gp_mode=search', $hx);
                    echo "\n<li>{$h}</li>";
                }
            }
            echo "</ul>";
        }
    }
    if (isset($continue)) {
        return $continue;
    }
    //while ($kount++ < 30) { echo "<br>"; }
}
 /**
  *  Main Entry point for execution.
  *
  *  @param string $rows       query results
  *  @param string $yamlP2     The processed YAML page description
  *  @param string $page       The name of the page we are working on
  */
 function main($yamlP2, $page)
 {
     // The application directory.
     $appdir = $GLOBALS['AG']['dirs']['root'] . "/application/";
     try {
         // Create new instance of smarty
         $smarty = new Smarty();
         $smarty->template_dir = $GLOBALS['AG']['dirs']['root'] . 'application/templates/';
         $smarty->compile_dir = $GLOBALS['AG']['dirs']['root'] . 'lib/smarty/compile/';
         $smarty->config_dir = $GLOBALS['AG']['dirs']['root'] . 'lib/smarty/config/';
         $smarty->cache_dir = $GLOBALS['AG']['dirs']['root'] . 'lib/smarty/cache/';
         $smarty->caching = false;
         if (ArraySafe($yamlP2['options'], 'noquery', 'N') == 'N') {
             foreach ($yamlP2['section'] as $section => $props) {
                 $smarty->assign($section . '-sql', $yamlP2['section'][$section]['sql']);
                 if (count($props) > 0) {
                     if (isset($yamlP2['section'][$section]['onerow'])) {
                         $onerow = $yamlP2['section'][$section]['onerow'];
                     } else {
                         $onerow = 'N';
                     }
                     if ($onerow == 'N') {
                         if (count($props['rows']) > 0) {
                             $smarty->assign($section, $props['rows']);
                         }
                     } elseif ($onerow == 'Y') {
                         if ($props['rows']) {
                             $smarty->assign($section, $props['rows']['0']);
                         }
                     }
                 }
             }
         }
         foreach ($yamlP2['options'] as $option => $val) {
             $smarty->assign($option, $val);
         }
         $smarty->display($yamlP2['template']);
     } catch (Exception $e) {
         echo 'Unable to create Smarty Object for the following reason: ' . $e->getMessage();
     }
 }
Beispiel #3
0
 function custom_construct()
 {
     if (ArraySafe($GLOBALS['AG'], 'flag_pwmd5', 'N') == 'Y') {
         unset($this->table['flat']['member_password']);
     }
 }
Beispiel #4
0
 /**
  *  Compares breaking variables to see if we broke
  *
  *  @param array $yamlP2  the processed YAML array
  *  @param array $break   the current values for break
  *  @param array $row     this particular row   
  *  @since 4/3/08
  */
 function compareBreak($yamlP2, $bottom, $row)
 {
     foreach ($yamlP2['table'] as $table => $tabinfo) {
         foreach ($tabinfo['column'] as $colname => $colinfo) {
             if (ArraySafe($colinfo, 'break') != 'Y') {
                 continue;
             }
             if ($bottom[$colname] != $row[$colname]) {
                 return false;
             }
         }
     }
     return true;
 }
function ElementOut($type, $dohtml = false)
{
    global $AG;
    // Hardcoded row we want in there
    if ($type == 'script') {
        //$calcRow=vgaGet('calcRow');
        //ElementAdd('script',"\nfunction calcRow() {\n$calcRow\n}");
        $ajaxTM = vgfGet('ajaxTM', 0) == 1 ? '1' : '0';
        ElementAdd('script', "\nvar ajaxTM={$ajaxTM}  /* Controls AJAX table maintenance */");
        //$clearBoxes=implode("\n",ArraySafe($AG,'clearBoxes',array()));
        //ElementAdd('script',"\nfunction clearBoxes() {\n$clearBoxes\n}");
    }
    $array = ArraySafe($AG, $type, array());
    $retval = "";
    $extra = "";
    if ($dohtml) {
        $extra = "<br/>";
    }
    foreach ($array as $msg) {
        $retval .= $msg . $extra . "\n";
    }
    $AG[$type] = array();
    if (!$dohtml) {
        return $retval;
    }
    if (!$retval) {
        return "";
    } else {
        return "<div class=\"{$type}\">{$retval}</div>";
    }
}
Beispiel #6
0
    function xajax()
    {
        if (gp('gp_xajax') != '1') {
            return $this->xAjaxColSave();
        }
        // No conditionals here, this is always ajax
        echo "xajax|";
        $tid = gp('gp_table_id');
        $parms['gp_table_id'] = $tid;
        $parms['gp_page'] = 'x_import';
        $parms['gp_xajax'] = '1';
        $parms['gp_map'] = gp('gp_map', '');
        //$a1=aFromgp('gp_');
        //hprint_r($a1);
        //$a2=aFromgp('txt_');
        //hprint_r($a2);
        // Look for a map delete command
        if (gpExists('gp_del')) {
            SQL("Delete from importmaps where importmap=" . SQLFC(gp('gp_del')));
            if (gp('gp_del') == gp('gp_map')) {
                gpSet('gp_map', '');
                $parms['gp_map'] = '';
            }
        }
        // Look for a map insert command. If found and works, automatically
        // select this as the map we want.
        $row = aFromGP('txt_');
        if (count($row) > 0 && gpExists('gp_new')) {
            $dd = DD_TableRef('importmaps');
            $row['table_id'] = gp('gp_table_id');
            SQLX_Insert($dd, $row);
            if (!Errors()) {
                gpSet('gp_map', $row['importmap']);
                $parms['gp_map'] = gp('gp_map');
            }
        }
        // Display a list of maps we may use
        $maps = SQL_AllRows("Select importmap,name_prefix from importmaps\n           where table_id=" . SQLFC($tid), 'importmap');
        //hprint_r($maps);
        ?>

      <h2>Map Selection</h2>
      
      <p>Please choose a map to use.  If no map exists, please create
         a new one.  After a map is chosen you can map individual columns.
      </p>
      
      <table id="x2data1">
        <thead>
          <tr><th>Map Name
              <th>Select
              <th>Delete
        </thead>
        <tbody>
      <?php 
        foreach ($maps as $map) {
            $px = $parms;
            $px['gp_map'] = $map['importmap'];
            $hp1 = http_build_query($px);
            $px['gp_del'] = $map['importmap'];
            $hp2 = http_build_query($px);
            echo $map['importmap'] == $parms['gp_map'] ? '<tr class="hilite">' : '<tr>';
            ?>
         <td><?php 
            echo $map['importmap'];
            ?>
         <td><a href="javascript:andrax('?<?php 
            echo $hp1;
            ?>
')">Select</a>
         <td><a href="javascript:andrax('?<?php 
            echo $hp2;
            ?>
')">Delete</a>
         <?php 
        }
        // Now the row for a new entry
        $px = $parms;
        $px['gp_new'] = 1;
        $hp = "'?" . http_build_query($px);
        $hp .= "&txt_importmap='+ob('txt_importmap').value";
        ?>
         <tr><td><input name="txt_importmap"   id="txt_importmap">
             <td>&nbsp;
             <td><a href="javascript:andrax(<?php 
        echo $hp;
        ?>
)">Create</a>
      </table>
      <?php 
        // If they have not picked a map, we are done.  If we continue
        // we will let them pick individual columns.
        if ($parms['gp_map'] == '') {
            return;
        }
        // Get column listing from dictionary
        $dd = DD_TableRef(gp('gp_table_id'));
        $cols = array_keys($dd['flat']);
        // Get cols available from import
        $fi = SessionGet('importfile');
        $FILE = fopen($fi['uname'], 'r');
        $sline = fsGets($FILE);
        $aline = explode('|', $sline);
        array_unshift($aline, '');
        $aline = array_combine($aline, $aline);
        // make keys and values the same
        fclose($FILE);
        // Get current map
        $mapcols = SQL_AllRows("Select column_id,column_id_src FROM importmapcolumns\n           WHERE importmap=" . SQLFC(gp('gp_map')) . "\n             AND table_id =" . SQLFC(gp('gp_table_id')), 'column_id');
        ?>
      <hr />
      <h2>Individual Column Mappings</h2>
      <table id="x2data1">
        <thead><tr><th>Destination Column</td>
                   <th>Caption</td>
                   <th>Source Column</td>
        </thead>
        <tbody>
      <?php 
        foreach ($cols as $col) {
            $value = ArraySafe($mapcols, $col, array());
            $value = ArraySafe($value, 'column_id_src', '');
            $px = $parms;
            $px['gp_xajax'] = $col;
            $andrax = "?" . http_build_query($px);
            $extra = "onchange=\"andrax('{$andrax}&gp_xval='+this.value)\"";
            $hSelect = hSelectFromAA($aline, 'anycol', $value, $extra);
            if ($dd['flat'][$col]['uino'] != 'Y') {
                ?>
            <tr><td><?php 
                echo $col;
                ?>
                <td><?php 
                echo $dd['flat'][$col]['description'];
                ?>
                <td><?php 
                echo $hSelect;
                ?>
            <?php 
            }
        }
        ?>
        </tbody>
      </table>
      <?php 
        $href = '?gp_page=x_import&gp_table_id=' . $tid . '&gp_fbproc=1' . '&gp_map=' . $parms['gp_map'];
        ?>
      <hr />
      <h2>File Process</h2>
      
      <p>The file <?php 
        echo $fi['name'];
        ?>
 was uploaded, size 
         <?php 
        echo number_format($fi['size']);
        ?>
 bytes.
      </p>
      
      <p><a href="javascript:SetAndPost('gp_nofile',1)">
         Upload A Different File
         </a>
      </p>  
         
      <p><a href="javascript:Popup('<?php 
        echo $href;
        ?>
')">Process Now</a>
      </p>
      
      <?php 
    }
Beispiel #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";
     }
 }
function mosShowListMenu($menutype)
{
    // -------------------------------------------------------
    // Andromeda Code: If we are in an Andromeda situation
    // then everything is vastly simplified, we already have
    // the menu and we don't do much conversion
    // -------------------------------------------------------
    if (defined('_ANDROMEDA_JOOMLA')) {
        if (!LoggedIn()) {
            return;
        }
        // KFD 7/6/07, cache the menu so we don't have to do
        // this on every call.
        // Cachegrind cost to build menu          : 259 / 199
        // Cachegrind cost logging in             : 140
        // Cachegrind cost login, cache to session: 2!!!!
        // Cachegrind cost to cache to disk       : 400!
        # KFD 4/17/08, rebuild menu if they switched modes
        # KFD 6/21/08, simplify this by just looking at x4Welcome
        #$menu_mode = gpExists('x4Page')
        #  ? (vgfGet('x4menu',false)==true ? 'x4' : 'classic')
        #  : 'classic';
        $menu_mode = configGet('x4welcome', 'N') == 'Y' ? 'x4' : 'classic';
        vgfSet('menu_mode', $menu_mode);
        # KFD 6/21/08 (END)
        if ($menu_mode != SessionGet('menu_mode')) {
            sessionSet('menu', '');
            sessionSet('menu_mode', $menu_mode);
        }
        $menu = SessionGet('menu', '');
        if ($menu != '') {
            echo $menu;
            return;
        }
        ob_start();
        $children = array();
        $open = array();
        $indents = array(array("<ul>", "<li>", "</li>", "</ul>"));
        $class_sfx = null;
        $hilightid = SessionGET('AGMENU_MODULE');
        $hilightid = '';
        $menus = SessionGET("AGMENU");
        foreach ($menus as $menuid => $menuinfo) {
            //if($menuid=='datadict') continue;
            //if($menuid=='sysref')   continue;
            $x = new joomla_fake();
            $x->type = 'url';
            $x->id = $menuid;
            if (sessionGet('menu_mode') == 'x4') {
                $x->link = 'javascript:void(0);';
            } else {
                $x->link = "?x_module=" . urlencode($menuid);
            }
            $x->browserNav = '';
            $x->name = $menuinfo['description'];
            $children[0][] = $x;
            foreach ($menuinfo['items'] as $page => $pageinfo) {
                $x = new joomla_fake();
                $x->type = 'url';
                $x->id = $page;
                # KFD 6/26/08, the vgfX(x4) was experimental, get rid of it
                #if(vgfGet('x4')===true) {
                #    $pd = $pageinfo['description'];
                #    $x->link="javascript:x4Page('$page','$pd')";
                #}
                #else {
                # KFD 6/26/08, work out the menu mode first
                $xmode = 'x2';
                if (sessionGet('menu_mode') == 'x4') {
                    $xmode = a($pageinfo, 'uix2', 'N') == 'Y' ? 'x2' : 'x4';
                }
                if ($xmode == 'x4') {
                    $x->link = '?x4Page=' . urlencode($page);
                    $x->link .= '&x4Return=' . vgaGet('nopage', 'menu');
                } else {
                    $x->link = "?x_module={$menuid}&x2=1&gp_page=" . urlencode($page);
                }
                if (ArraySafe($pageinfo, 'menu_parms') != '') {
                    $x->link .= '&' . urlencode($pageinfo['menu_parms']);
                }
                #}
                $x->browserNav = '';
                $x->name = $pageinfo['description'];
                $children[$menuid][] = $x;
            }
        }
        mosRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid);
        $menu = ob_get_clean();
        echo $menu;
        SessionSet('menu', $menu);
        //$fsMenuFileHTML=ob_get_clean();
        //file_put_contents($fsMenuFile,$fsMenuFileHTML);
        //echo $fsMenuFileHTML;
        return;
    }
    // -------------------------------------------------------
    // Andromeda Code: END
    // -------------------------------------------------------
    global $database, $my, $cur_template, $Itemid;
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_shownoauth;
    $class_sfx = null;
    $hilightid = null;
    /* If a user has signed in, get their user type */
    $intUserType = 0;
    if ($my->gid) {
        switch ($my->usertype) {
            case 'Super Administrator':
                $intUserType = 0;
                break;
            case 'Administrator':
                $intUserType = 1;
                break;
            case 'Editor':
                $intUserType = 2;
                break;
            case 'Registered':
                $intUserType = 3;
                break;
            case 'Author':
                $intUserType = 4;
                break;
            case 'Publisher':
                $intUserType = 5;
                break;
            case 'Manager':
                $intUserType = 6;
                break;
        }
    } else {
        /* user isn't logged in so make their usertype 0 */
        $intUserType = 0;
    }
    if ($mosConfig_shownoauth) {
        $database->setQuery("SELECT m.*, count(p.parent) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1'" . "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
    } else {
        $database->setQuery("SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1' AND m.access <= '{$my->gid}'" . "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
    }
    $rows = $database->loadObjectList('id');
    echo $database->getErrorMsg();
    //work out if this should be highlighted
    $sql = "SELECT m.* FROM #__menu AS m" . "\nWHERE menutype='" . $menutype . "' AND m.published='1'";
    $database->setQuery($sql);
    $subrows = $database->loadObjectList('id');
    $maxrecurse = 5;
    $parentid = $Itemid;
    //this makes sure toplevel stays hilighted when submenu active
    while ($maxrecurse-- > 0) {
        $parentid = getParentRow($subrows, $parentid);
        if (isset($parentid) && $parentid >= 0 && $subrows[$parentid]) {
            if (vgfGet('menu_mode') != 'x4') {
                $hilightid = $parentid;
            }
        } else {
            break;
        }
    }
    if (vgfGet('menu_mode') == 'x4') {
        $hilightid = '';
    }
    //echo "<!--[if lte IE 7]>\n";
    include_once "{$mosConfig_absolute_path}/templates/" . $cur_template . "/js/ie.js";
    //echo "<![endif]-->\n";
    $indents = array(array("<ul>", "<li>", "</li>", "</ul>"));
    // establish the hierarchy of the menu
    $children = array();
    // first pass - collect children
    foreach ($rows as $v) {
        $pt = $v->parent;
        $list = @$children[$pt] ? $children[$pt] : array();
        array_push($list, $v);
        $children[$pt] = $list;
    }
    // second pass - collect 'open' menus
    $open = array($Itemid);
    $count = 20;
    // maximum levels - to prevent runaway loop
    $id = $Itemid;
    while (--$count) {
        if (isset($rows[$id]) && $rows[$id]->parent > 0) {
            $id = $rows[$id]->parent;
            $open[] = $id;
        } else {
            break;
        }
    }
    $class_sfx = null;
    mosRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid);
}
Beispiel #9
0
$GLOBALS["AG"]["dirs"]["dyanmic"] = "/var/www/andro_root/andro/dynamic/";
$GLOBALS["AG"]["dirs"]["root"] = "/var/www/andro_root/andro/";
$GLOBALS["AG"]["application"] = "andro";
/*
* Connect to database
*/
connect();
/*
* Build andromeda
*/
include 'androInstallBuild.php';
/*
* Insert new webpaths record
*/
$dir_pub = realpath(dirname(__FILE__) . '/../..');
if (strpos(ArraySafe($_ENV, 'OS', ''), 'indows') !== false) {
    $dir_pub = str_replace("\\", "\\\\", $dir_pub);
}
$row = array('webpath' => 'DEFAULT', 'dir_pub' => $dir_pub, 'description' => 'Default Web Path');
SQLX_Insert('webpaths', $row);
/*
* Insert new applications record
*/
$row = array('application' => 'andro', 'description' => "Andromeda Node Manager", 'appspec' => 'andro.dd.yaml', 'node' => 'LOCAL', 'webpath' => 'DEFAULT', 'flag_svn' => 'Y', 'svn_url' => 'http://andro.svn.sourceforge.net/svnroot/andro/releases/');
SQLX_Insert('applications', $row);
/*
* End - Close connection
*/
disconnect();
//==================================================================
//	FUNCTIONS
Beispiel #10
0
function x4Errors()
{
    $ri = returnItems();
    $errs1 = ArraySafe($ri, 'message', array());
    $errs2 = ArraySafe($errs1, 'error', array());
    if (count($errs2) == 0) {
        return false;
    } else {
        return $errs2;
    }
}
Beispiel #11
0
    function MenuTable()
    {
        $AGMENU = SessionGet('AGMENU');
        $module = gp('x_module');
        $table_id = gp('x_menu');
        echo "<b>" . $AGMENU[$module]['items'][$table_id]['description'] . "</b>";
        ?>
      <br><br><br><br>
      1 - <a href="?gp_page=<?php 
        echo $table_id;
        ?>
&gp_mode=browse">View</a>
      <br><br><br><br>
      2 - <a href="?gp_page=<?php 
        echo $table_id;
        ?>
&gp_mode=search">Edit</a>
      <br><br><br><br>
      3 - <a href="?gp_page=<?php 
        echo $table_id;
        ?>
&gp_mode=search">Delete</a>
      <br><br><br><br>
      4 - <a href="?gp_page=<?php 
        echo $table_id;
        ?>
&gp_mode=ins">Add</a>
      <br><br><br><br>
      <?php 
        $x = 5;
        // SEAN: Here is where you put the extra stuff like "on hold"
        global $extramenu;
        $rapidchanges = $extramenu;
        $rapidchanges = ArraySafe($rapidchanges, $table_id);
        foreach ($rapidchanges as $change => $columns) {
            $desc = ArraySafe($columns, '_desc');
            unset($columns['_desc']);
            foreach ($columns as $name => $val) {
                $columns[$name] = 'gp_upd_' . $name . "=" . $val;
            }
            $parms = implode('&', $columns);
            ?>
            <?php 
            echo $x;
            ?>
 - <a href="?gp_page=x_pkc&gp_table_upd=<?php 
            echo $table_id . '&' . $parms;
            ?>
"><?php 
            echo $desc;
            ?>
</a>
            <br><br><br><br>
         <?php 
            $x++;
        }
        //hprint_r($rapidchanges);
        ?>
      Z - <a href="?x_module=<?php 
        echo $module;
        ?>
">Exit</a>
      <br><br><br><br>
      <?php 
    }
Beispiel #12
0
 function DoTests(&$steps)
 {
     $this->error = '';
     // If they manually forced a rollback to an earlier step,
     //  we will catch it below
     $rb = gp('stepreset', '-1');
     // look for flags that indicate manual approval of steps
     if (gp('pgconfig') == 1) {
         sessionSet('pgconfig', true);
     }
     if (gp('pgsuper') == 1) {
         sessionSet('pgsuper', true);
     }
     // If they provided credentials, try to post them
     if (gpExists('loginUID')) {
         if (substr(strtolower(gp('loginUID')), 0, 5) == 'andro') {
             ErrorAdd("Superuser account may not begin with 'andro'");
         } else {
             SessionSet('xUID', gp('loginUID'));
             SessionSet('xPWD', gp('loginPWD'));
         }
     }
     $finished = false;
     foreach ($steps as $current_step => $step) {
         switch ($current_step) {
             case 0:
                 if (!function_exists('pg_connect')) {
                     $finished = true;
                 }
                 break;
             case 1:
                 // If forcing rollback to here, clear user credentials
                 if ($rb == 1) {
                     SessionUnset('xUID');
                     SessionUnSet('xPWD');
                 }
                 // Test if they gave us uid/pwd and if it works
                 if (SessionGet('xUID') == '') {
                     $finished = true;
                 } else {
                     $cs = SQL_ConnString(SessionGet('xUID'), SessionGet('xPWD'), 'postgres');
                     $this->dbx = @pg_connect($cs);
                     if (!$this->dbx) {
                         $this->error = "Could Not Connect with that Username/Password";
                         $finished = true;
                     }
                 }
                 break;
             case 2:
                 // Since we got a connection, try to get versions
                 $res = SQL2("Select version()", $this->dbx);
                 $row = SQL_Fetch_Array($res);
                 $x = explode(' ', $row['version']);
                 $this->pgversion = $x[0] . ' ' . $x[1];
                 $vers = explode('.', $x[1]);
                 $vers = $vers[0] . '.' . $vers[1];
                 if ($vers < 8.1) {
                     $finished = true;
                 }
                 break;
             case 3:
                 if ($rb == 3) {
                     $this->andro = 1;
                     $finished = true;
                     break;
                 }
                 $cs = SQL_ConnString(SessionGet('xUID'), SessionGet('xPWD'), 'andro');
                 $this->dba = @pg_connect($cs);
                 if (!$this->dba) {
                     $finished = true;
                     $this->andro = 0;
                 } else {
                     pg_close($this->dba);
                     $file = $GLOBALS['AG']['dirs']['generated'] . 'ddmodules.php';
                     if (!file_exists($file)) {
                         $finished = true;
                         $this->andro = 1;
                     }
                 }
                 break;
             case 4:
                 // Initialize the node manager
                 SessionSet('UID', SessionGet('xUID'));
                 SessionSet('PWD', SessionGet('xPWD'));
                 scDBConn_Push();
                 $dir_pub = realpath(dirname(__FILE__) . '/../..');
                 if (strpos(ArraySafe($_ENV, 'OS', ''), 'indows') !== false) {
                     $dir_pub = str_replace("\\", "\\\\", $dir_pub);
                 }
                 $row = array('webpath' => 'DEFAULT', 'dir_pub' => $dir_pub, 'description' => 'Default Web Path');
                 $table_dd = dd_TableRef('webpaths');
                 SQLX_UpdateorInsert($table_dd, $row);
                 /*               
                 $table_dd=dd_TableRef('nodes');
                                $row=array(
                                   'node'=>'DHOST2'
                                   ,'description'=>"Andromeda Master Node"
                                   ,'node_url'=>'dhost2.secdat.com'
                                );
                                SQLX_UpdateorInsert($table_dd,$row); 
                                $row=array(
                                   'node'=>'LOCAL'
                                   ,'description'=>"Local Node"
                                   ,'node_url'=>'localhost'
                                );
                                SQLX_UpdateorInsert($table_dd,$row); 
                 */
                 $table_dd = dd_TableRef('applications');
                 $row = array('application' => 'andro', 'description' => "Andromeda Node Manager", 'appspec' => 'andro.dd.yaml', 'node' => 'LOCAL', 'webpath' => 'DEFAULT');
                 SQLX_UpdateorInsert($table_dd, $row);
                 scDBConn_Pop();
                 SessionSet('UID', 'andro');
                 SessionSet('PWD', 'andro');
                 break;
             case 5:
                 break;
             default:
                 $finished = true;
         }
         // if we are clear, stop now
         if ($finished) {
             break;
         }
     }
     for ($x = 0; $x < $current_step; $x++) {
         $steps[$x][0] = true;
     }
     return $current_step;
 }
Beispiel #13
0
function index_hidden_command()
{
    // Get command, strip out multiple spaces, split up and
    // grab the command separate from the arguments
    # KFD 9/10/08.  Unset pretty much everything we know about
    #               so we can create a new get/post setup out
    #               of the command.
    gpUnsetPrefix('gpx');
    gpUnsetPrefix('gp_');
    gpUnsetPrefix('x2t_');
    gpUnset('gpContext');
    $commands = gp('gp_command');
    $commands = preg_replace('/\\s{2,}/', ' ', $commands);
    gpSet('gp_command', $commands);
    $args = explode(' ', $commands);
    $table_frag = array_shift($args);
    $table_frag = strtolower($table_frag);
    // If a special command was added, pull it out
    $dotcmd = '';
    if (strpos($table_frag, '.') !== false) {
        list($table_frag, $dotcmd) = explode('.', $table_frag, 2);
    }
    // Now run through the list of pages looking for the first match, but
    // look at the aliases first if they exist
    $aliases = ArraySafe($GLOBALS, 'COMMAND_ALIASES', array());
    foreach ($aliases as $alias => $page) {
        if (substr(strtolower($alias), 0, strlen($table_frag)) == $table_frag) {
            $table_id = $page;
            break;
        }
    }
    $PAGES = array();
    include 'ddpages.php';
    $pages = array_keys($PAGES);
    foreach ($pages as $page) {
        if (substr(strtolower($page), 0, strlen($table_frag)) == $table_frag) {
            $table_id = $page;
            break;
        }
    }
    $x4 = configGet('x4welcome', 'N') == 'Y' ? true : false;
    // Can't figure it, have to leave
    if (!isset($table_id)) {
        vgfSet('command_error', 'Unknown: ' . $table_frag);
        return;
    }
    // Now decide what to do.
    if ($dotcmd == 'new') {
        if ($x4) {
            gpSet('x4Page', $table_id);
            gpSet('x4Mode', 'new');
        } else {
            gpSet('gp_mode', 'ins');
            gpSet('gp_page', $table_id);
        }
    } else {
        if ($dotcmd != '') {
            vgfSet('command_error', 'Unknown Command: ' . $table_frag . '.' . $dotcmd);
            return;
        } else {
            // for now we assume everything else is a lookup
            if (count($args) == 0) {
                // No arguments means go to lookup mode
                gpSet('gp_mode', 'search');
                gpSet('gp_page', $table_id);
                if ($x4) {
                    gpSet('x4Page', $table_id);
                }
            } else {
                // Clear prior search results
                processPost_TableSearchResultsClear($table_id);
                // Re-write the query into a search
                // by setting our values as the search values
                gpSet('gp_page', $table_id);
                gpSet('gpx_page', $table_id);
                gpSet('gp_mode', 'browse');
                gpSet('gpx_mode', 'search');
                # KFD 8/18/08 MAJOR CHANGE.  Loading this up w/old code caused
                #             things like viewname not to exist
                #$dd=dd_tableRef($table_id);
                $dd = ddTable($table_id);
                # KFD 8/18/08
                $cols = explode(',', $dd['projections']['_uisearch']);
                array_shift($cols);
                // pop off the first one, assume it is the pk/code
                gpUnsetPrefix('x2t_');
                // clear troublesome values
                foreach ($cols as $i => $colname) {
                    if (isset($args[$i])) {
                        gpSet('x2t_' . $colname, $args[$i]);
                    }
                }
                if ($x4) {
                    gpSet('x4Page', $table_id);
                    foreach ($cols as $i => $colname) {
                        if (isset($args[$i])) {
                            gpSet('pre_' . $colname, $args[$i]);
                        }
                    }
                }
            }
        }
    }
}
Beispiel #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();
    }
Beispiel #15
0
 /**
  *  Generate a comparison expression for a column
  *
  *  @param string $table_id the table
  *  @param string $colname  the column
  *  @param string $colinfo  other column information
  *  @access private
  */
 function SQLCompare($table, $colname, $colinfo)
 {
     // Early return and alternate branch
     if (a($colinfo, 'compare', '') == '') {
         return;
     }
     if (substr($colinfo['compare'], 0, 1) == '*') {
         return $this->SQLCompareStar($table, $colname, $colinfo);
     }
     $noempty = ArraySafe($colinfo, 'no_empty_compare', 'Y');
     $table_dd = ddTable($table);
     $uifilter = $this->yamlP2['uifilter'];
     $compare = "{$table}.{$colname} " . a($colinfo, 'compare', '');
     foreach ($uifilter as $filtername => $info) {
         if (strpos($compare, '@' . $filtername) !== false) {
             $type_id = $table_dd['flat'][$colname]['type_id'];
             if (a($info, 'value', '') != '') {
                 $val = SQL_FORMAT($type_id, $info['value']);
                 if ($noempty == 'Y' && trim($info['value']) == '') {
                     $compare = '';
                     break;
                 }
                 $compare = str_replace('@' . $filtername, $val, $compare);
             }
         }
     }
     return $compare;
 }
Beispiel #16
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);
     }
 }
Beispiel #17
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 
    }
Beispiel #18
0
/**
name:rowsForSelect
parm:string Table_id
parm:string First_Letters
return:array rows

Returns an array of rows that can be put into a drop-down select box.
The first column is always "_value" and the second is always "_display".

The second parameter, if provided, filters to the results so that
only values of _display that start with "First_Letters" are returned.

For a multiple-column primary key, this routine will filter for any pk
column that exists in the session array "ajaxvars".  This feature is
controlled by an (as-yet undocumented) feature in [[ahInputsComprehensive]]
that can make inputs use Ajax when their value changes to store their
value in the session on the server.

This was created 1/15/07 to work with Ajax-dynamic-list from
dhtmlgoodies.com.
*/
function RowsForSelect($table_id, $firstletters = '', $matches = array(), $distinct = '', $allcols = false)
{
    $table = DD_TableRef($table_id);
    // Determine which columns to pull and get them
    // KFD 10/8/07, a DISTINCT means we are pulling a single column of
    //              a multiple column key, pull only that column
    if ($distinct != '') {
        $proj = $distinct;
    } else {
        if (ArraySafe($table['projections'], 'dropdown') == '') {
            if (!vgfGet('x6')) {
                $proj = $table['pks'];
            } else {
                $proj = $table['projections']['_uisearch'];
            }
        } else {
            $proj = $table['projections']['dropdown'];
        }
    }
    $aproj = explode(',', $proj);
    $acollist = array();
    foreach ($aproj as $aproj1) {
        $acollist[] = "COALESCE({$aproj1},'')";
    }
    $collist = str_replace(',', " || ' - ' || ", $proj);
    //$collist = implode(" || ' - ' || ",$acollist);
    //syslog($collist);
    // Get the primary key, and resolve which view we have perms for
    // KFD 10/8/07, do only one column if passed
    if ($distinct != '') {
        $pk = $distinct;
    } else {
        $pk = $table['pks'];
    }
    $view_id = ddtable_idResolve($table_id);
    // Initialize the filters
    $aWhere = array();
    // Generate a filter for each pk that exists in session ajaxvars.
    // There is a BIG unchecked for issue here, which is that a multi-column
    //  PK must have *all but one* column supplied, and it then returns
    //  the unsupplied column.
    $pkeys = explode(',', $table['pks']);
    $ajaxvars = afromGP('adl_');
    foreach ($pkeys as $index => $pkey) {
        if (isset($ajaxvars[$pkey])) {
            $aWhere[] = "{$pkey}=" . SQLFC($ajaxvars[$pkey]);
            // This is important!  Unset the pk column, we'll pick the leftover
            unset($pkeys[$index]);
        }
    }
    // If we did the multi-pk route, provide the missing column
    //  as the key value
    if (count($ajaxvars) > 0) {
        $pk = implode(',', $pkeys);
    }
    // Determine if this is a filtered table
    if (isset($table['flat']['flag_noselect'])) {
        $aWhere[] = "COALESCE(flag_noselect,'N')<>'Y'";
    }
    // Add more matches on
    foreach ($matches as $matchcol => $matchval) {
        $aWhere[] = $matchcol . ' = ' . SQLFC($matchval);
    }
    // See if there is a hardcoded filter in the program class
    $obj = dispatchObject($table_id);
    if (method_exists($obj, 'aSelect_where')) {
        $aWhere[] = $obj->aSelect_where();
        if (ConfigGet('LOG_SQL', 'Y') == 'Y') {
            sysLog(LOG_NOTICE, $obj->aSelect_Where());
        }
    }
    // If "firstletters" have been passed, we will filter each
    // select column on it
    //
    // KFD 8/8/07, a comma in first letters now means look in
    //             1st column only + second column only
    $SLimit = '';
    $xWhere = array();
    if ($firstletters == '*') {
        // do nothing, no where clauses
    } elseif ($firstletters != '') {
        $SLimit = "Limit 40 ";
        if (strpos($firstletters, ',') === false) {
            // original code, search all columns
            $implode = ' OR ';
            foreach ($aproj as $aproj1) {
                $type_id = $table['flat'][$aproj1]['type_id'];
                $subs = '';
                if (!in_array($type_id, array('char', 'vchar', 'text'))) {
                    $subs = '::varchar';
                }
                $sl = strlen($firstletters);
                $xWhere[] = "SUBSTRING(LOWER({$aproj1}{$subs}) FROM 1 FOR {$sl})" . "=" . strtolower(SQLFC($firstletters));
            }
        } else {
            // New code 8/8/07, search first column, 2nd, third only,
            // based on existence of commas
            $implode = ' AND ';
            $afl = explode(',', $firstletters);
            foreach ($afl as $x => $fl) {
                $type_id = $table['flat'][$aproj1]['type_id'];
                $subs = '';
                if (!in_array($type_id, array('char', 'vchar', 'text'))) {
                    $subs = '::varchar';
                }
                $sl = strlen($fl);
                $xWhere[] = "SUBSTRING(LOWER({$aproj[$x + 1]}{$subs}) FROM 1 FOR {$sl})" . "=" . strtolower(SQLFC($fl));
            }
        }
    }
    if (count($xWhere) > 0) {
        $aWhere[] = "(" . implode($implode, $xWhere) . ")";
    }
    // Finish off the where clause
    if (count($aWhere) > 0) {
        $SWhere = "WHERE " . implode(' AND ', $aWhere);
    } else {
        $SWhere = '';
    }
    // Execute and return
    $sDistinct = $distinct != '' ? ' DISTINCT ' : '';
    $SOB = $aproj[0];
    if ($allcols) {
        # KFD 6/9/08, added in automatic ordering on queuopos column
        $OB = isset($table['flat']['queuepos']) ? 'queuepos' : '2';
        $sq = "SELECT skey,{$proj}\n              FROM {$view_id}\n           {$SWhere}\n            ORDER BY {$OB} {$SLimit}";
    } else {
        $sq = "SELECT {$sDistinct} {$pk} as _value,{$collist} as _display\n              FROM {$view_id}\n           {$SWhere}\n             ORDER BY {$SOB} {$SLimit} ";
    }
    /*
    openlog(false,LOG_NDELAY,LOG_USER);
    if ( ConfigGet( 'flag_syslog', 'Y' ) == 'Y' ) {
    	   syslog(LOG_INFO,$table['projections']['dropdown']);
    	   syslogbodyRows
    	   (LOG_INFO,$sq);
    }
    closelog();
    */
    if (ConfigGet('flag_syslog', 'Y') == 'Y') {
        syslog(LOG_INFO, $sq);
    }
    $rows = SQL_Allrows($sq);
    return $rows;
}
Beispiel #19
0
 function Type1Row($row)
 {
     $this->ClearLine();
     $posx = 0;
     // the position across
     foreach ($this->t1ColInfo as $colname => $colinfo) {
         $value = ArraySafe($row, $colname);
         $type_id = $colinfo['type_id'];
         $size = $this->Type1ColSize($colinfo);
         $colscale = ArraySafe($colinfo, 'colscale', 0);
         $this->OneCell($value, $type_id, $size, $colscale);
     }
     $this->OutputLine();
 }
Beispiel #20
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();
    }