function Login_Process() { $arg2 = $this->directlogin == true ? 'direct' : ''; // only process if user hit "post" if (gp('gp_posted', '', false) == '') { return; } vgfSet('LoginAttemptOK', false); // Error title vgfSet('ERROR_TITLE', '*'); // If the user supplied a loginUID, this is a post and we // must process the request. $ale = vgaGet('login_errors', array()); $app = $GLOBALS['AG']['application']; $em000 = isset($ale['000']) ? $ale['000'] : "That username/password combination did not work. Please try again."; $em001 = isset($ale['001']) ? $ale['001'] : "That username/password combination did not work. Please try again."; $em002 = isset($ale['002']) ? $ale['002'] : "That username/password combination did not work. Please try again."; $em099 = isset($ale['099']) ? $ale['099'] : "That username/password combination did not work. Please try again."; $terror = ""; $uid = gp('loginUID'); $uid = MakeUserID($uid); //$uid = str_replace('@','_',$uid); //$uid = str_replace('.','_',$uid); $pwd = gp("loginPWD", "", false); // First check, never allow the database server's superuser // account // if ($uid == "postgres") { ErrorAdd($em000); if (vgfGet('loglogins', false)) { sysLog(LOG_WARNING, "Andromeda:{$app}:Bad login attempt as postgres"); fwLogEntry('1011', 'Attempt login as postgres', '', $arg2); } return; } $app = $GLOBALS['AG']['application']; if (substr($uid, 0, strlen($app)) == $app) { ErrorAdd($em001); if (vgfGet('loglogins', false)) { sysLog(LOG_WARNING, "Andromeda:{$app}:Bad login attempt as group role"); fwLogEntry('1012', 'Attempt login as group role', $uid, $arg2); } return; } // Begin with a connection attempt. // on fail, otherwise continue $tcs = @SQL_CONN($uid, $pwd); if ($tcs === false) { ErrorAdd($em099); if (vgfGet('loglogins', false)) { sysLog(LOG_NOTICE, "Andromeda:{$app}:Bad login attempt server rejected"); fwLogEntry('1013', 'Server rejected username/password', $uid, $arg2); } return; } else { SQL_CONNCLOSE($tcs); } // The rest of this routine uses an admin connection. If we // have an error, we must close the connection before returning! // ...yes, yes, that's bad form, all complaints to /dev/null // if (vgfGet('loglogins', false)) { fwLogEntry('1010', 'Login OK', $uid, $arg2); } scDBConn_Push(); // See if they are a root user. If not, do they have an // active account? $root = false; $admin = false; $group_id_eff = ''; $results = SQL("\n Select oid\n FROM pg_roles \n WHERE rolname = CAST('{$uid}' as name)\n AND rolsuper= true"); $cr = SQL_NUMROWS($results); if ($cr != 0) { $root = true; } else { $results = SQL("Select * from users WHERE LOWER(user_id)='{$uid}'" . "AND (user_disabled<>'Y' or user_disabled IS NULL)"); $cr = SQL_NUMROWS($results); if ($cr == 0) { scDBConn_Pop(); ErrorAdd($em002); sysLog(LOG_WARNING, "Andromeda:{$app}:Bad login attempt code 002"); return; } else { $userinfo = SQL_Fetch_Array($results); $group_id_eff = $userinfo['group_id_eff']; SessionSet('user_name', $userinfo['user_name']); } } // Flag if the user is an administrator if ($root == true) { $admin = true; } else { $results = SQL("select count(*) as admin from usersxgroups " . "where user_id='{$uid}' and group_id ='{$app}" . "_admin'"); $row = SQL_FETCH_ARRAY($results); $admin = intval($row["admin"]) > 0 ? true : false; } // Get the users' groups $groups = ""; if ($root) { $results = SQL("\n select group_id \n from zdd.groups \n where COALESCE(grouplist,'')=''"); } else { $results = SQL("select group_id from usersxgroups WHERE LOWER(user_id)='{$uid}'"); } while ($row = SQL_FETCH_ARRAY($results)) { $agroups[] = "'" . trim($row['group_id']) . "'"; #$groups.=ListDelim($groups)."'".trim($row["group_id"])."'"; } $groups = array(); if (!empty($agroups)) { $groups = implode(",", $agroups); } //scDBConn_Pop(); // We have a successful login. If somebody else was already // logged in, we need to wipe out that person's session. But // don't do this if there was an anonymous login. if (LoggedIn()) { $uid_previous = SessionGet('UID'); if ($uid != $uid_previous) { //Session_Destroy(); SessionReset(); //Index_Hidden_Session_Start(false); } } // We know who they are and that they can connect, // see if there is any app-specific confirmation required // if (function_exists('app_login_process')) { //echo "Calling the process now"; if (!app_login_process($uid, $pwd, $admin, $groups)) { return; } } // Protect the session from hijacking, generate a new ID Session_regenerate_id(); // We now have a successful connection, set some // flags and lets go // vgfSet('LoginAttemptOK', true); SessionSet("UID", $uid); SessionSet("PWD", $pwd); SessionSet("ADMIN", $admin); SessionSet("ROOT", $root); SessionSet("GROUP_ID_EFF", $group_id_eff); SessionSet("groups", $groups); if (gp('gpz_page') == '') { # KFD 9/12/08, extra command to not change page if (gp('st2keep') != 1) { gpSet('gp_page', ''); } } $GLOBALS['session_st'] = 'N'; // for "N"ormal // ------------------------------------------------------------------- // We are about to make the menu. Before doing so, see if there // are any variables set for the menu layout. Set defaults and then // load from database. // $this->pmenu = array('MENU_TYPE' => vgaGet('MENU_TYPE', 'div'), 'MENU_CLASS_MODL' => vgaGet('MENU_CLASS_MODL', 'modulename'), 'MENU_CLASS_ITEM' => vgaGet('MENU_CLASS_ITEM', 'menuentry'), 'MENU_TICK' => vgaGET('MENU_TICK', ' - ')); //$sql = "SELECT * from variables WHERE variable like 'MENU%'"; //$dbres = SQL($sql); //while ($row = SQL_FETCH_ARRAY($dbres)) { // $this->pmenu[trim($row['variable'])]=trim($row['variable_value']); //} // ------------------------------------------------------------------- // KFD 10/28/06, Modified to examine "nomenu" instead of permsel // pulls all tables user has nomenu='N'. The basic idea is // to remove from $AGMENU the stuff they don't see // // GET AGMENU $AGMENU = array(); // avoid compiler warning, populated next line include "ddmodules.php"; // Pull distinct modules person has any menu options in. $sq = "SELECT DISTINCT module\n FROM zdd.perm_tabs \n WHERE nomenu='N'\n AND group_id iN ({$groups})"; $modules = SQL_AllRows($sq, 'module'); $AGkeys = array_keys($AGMENU); foreach ($AGkeys as $AGkey) { if (!isset($modules[$AGkey])) { unset($AGMENU[$AGkey]); } } // Now recurse the remaining modules and do the same trick // for each one, removing the tables that don't exist foreach ($AGMENU as $module => $moduleinfo) { $sq = "SELECT DISTINCT table_id\n FROM zdd.perm_tabs \n WHERE nomenu='N'\n AND module = '{$module}'\n AND group_id iN ({$groups})"; $tables = SQL_AllRows($sq, 'table_id'); $tkeys = array_keys($moduleinfo['items']); foreach ($tkeys as $tkey) { if (!isset($tables[$tkey])) { unset($AGMENU[$module]['items'][$tkey]); } } } // KFD 12/18/06. Put all table permissions into session $table_perms = SQL_AllRows("Select distinct table_id FROM zdd.perm_tabs\n WHERE group_id IN ({$groups})\n AND nomenu='N'", 'table_id'); SessionSet('TABLEPERMSMENU', array_keys($table_perms)); $table_perms = SQL_AllRows("Select distinct table_id FROM zdd.perm_tabs\n WHERE group_id IN ({$groups})\n AND permsel='Y'", 'table_id'); SessionSet('TABLEPERMSSEL', array_keys($table_perms)); $table_perms = SQL_AllRows("Select distinct table_id FROM zdd.perm_tabs\n WHERE group_id IN ({$groups})\n AND permins='Y'", 'table_id'); SessionSet('TABLEPERMSINS', array_keys($table_perms)); $table_perms = SQL_AllRows("Select distinct table_id FROM zdd.perm_tabs\n WHERE group_id IN ({$groups})\n AND permupd='Y'", 'table_id'); SessionSet('TABLEPERMSUPD', array_keys($table_perms)); $table_perms = SQL_AllRows("Select distinct table_id FROM zdd.perm_tabs\n WHERE group_id IN ({$groups})\n AND permdel='Y'", 'table_id'); SessionSet('TABLEPERMSDEL', array_keys($table_perms)); //echo "<div style='background-color:white'>"; //echo "$uid $groups $group_id_eff"; //hprint_r(SessionGet('TABLEPERMSMENU')); //hprint_r(SessionGet('TABLEPERMSSEL')); //echo "</div>"; // KFD 7/9/07, we always use joomla templates now, don't need // options to turn them off //if(defined('_ANDROMEDA_JOOMLA')) { // In a hybrid situation, put the menu into the session SessionSet('AGMENU', $AGMENU); //} $HTML_Menu = ""; $WML_Menu = ""; /* foreach ($AGMENU as $key=>$module) { //if($key=="datadict") continue; //if($key=="sysref") continue; $HTML_Module=""; $WML_Module=""; foreach($module["items"] as $itemname=>$item) { if (!isset($item["mode"])) { $item["mode"]="normal"; } switch ($item["mode"]) { case "normal": $ins=false; $extra=array(); if($item['menu_parms']<>'') { $aextras=explode('&',$item['menu_parms']); foreach($aextras as $aextra) { list($var,$value)=explode("=",$aextra); $extra[$var]=$value; } } $HTML_Module.=$this->_MenuItem( $item['description'],$itemname,$ins,$extra ); $WML_Module.="<div>"; $WML_Module.=hLink( '',$item['description'],'?gp_page='.$itemname ); $WML_Module.="</div>"; break; case "ins": //if ($admin || isset($tables_ins[$item["name"]])) { $HTML_Module.=$this->_MenuItem( $item['description'],$itemname,true ); //} break; #$HTML_Module.= # "\n<font class=\"tablename\">- <a href=\"index.php?gp_page=".$itemname."\">". # $item["description"]."</a></font><br />"; } } // the module is defined AFTER its contents so it can be // left off if it has no entries if ($HTML_Module!="") { $HTML_Menu.=$this->_MenuModule($module['description']); $HTML_Menu.=$HTML_Module; } if ($WML_Module!="") { $WML_Menu.="<div><b>".$module['description']."</b></div>"; $WML_Menu.=$WML_Module; } } */ DynamicSave("menu_" . $uid . ".php", $HTML_Menu); DynamicSave("menu_wml_" . $uid . ".php", $WML_Menu); // ------------------------------------------------------------------- // Fetch and cache user preferences if (vgaGet('member_profiles')) { cacheMember_Profiles(); } // ------------------------------------------------------------------- // Now find the user's table permissions more precisely table by table $sql = "select p.table_id,\n\t\t\t\tmax(case when p.permins='Y' then 1 else 0 end) as permins,\n\t\t\t\tmax(case when p.permupd='Y' then 1 else 0 end) as permupd,\n\t\t\t\tmax(case when p.permdel='Y' then 1 else 0 end) as permdel,\n\t\t\t\tmax(case when p.permsel='Y' then 1 else 0 end) as permsel\n\t\t\t\tfrom zdd.perm_tabs P\n\t\t\t\tWHERE group_id in ({$groups})\n\t\t\t\tGROUP BY p.table_id"; //echo $sql; $results = SQL($sql); $HTML_Perms = "<?php\n\$table_perms = array();\n"; while ($row = SQL_FETCH_ARRAY($results)) { $tn = $row["table_id"]; $ti = $row["permins"]; $tu = $row["permupd"]; $td = $row["permdel"]; $ts = $row["permsel"]; $HTML_Perms .= "\$table_perms[\"{$tn}\"]=array(\"ins\"=>{$ti},\"upd\"=>{$tu},\"del\"=>{$td},\"sel\"=>{$ts});\n"; } $HTML_Perms .= "?>\n"; DynamicSave("perms_" . $uid . ".php", $HTML_Perms); /* October 28, 2006, KFD. Rem'd this all out, column and row security made this irrelevant // ------------------------------------------------------------------- // Find out if this user has any UID Columns, columns that create // filters on the user's UID $sql = "Select column_id FROM groupuids WHERE group_id IN ($groups)"; //echo $sql; $results = SQL($sql); $groupuids = array(); while ($row = SQL_FETCH_ARRAY($results)) { //echo "Found this one".$row["column_id"]; $groupuids[$row["column_id"]] = $row["column_id"]; } SessionSet("groupuids",$groupuids); */ scDBConn_Pop(); return; }
function main() { // Get top page $this->PageSubtitle = "Documentation"; //$sq="SELECT pagename FROM docpageshier WHERE pagehier=1"; //$pageroot=SQL_OneValue('pagename',$sq); $pageroot = 'Data Dictionary'; $pn = gp('gppn'); $pn = $pn == '' ? $pageroot : $pn; $sq = "SELECT * from docpages \n WHERE pagename = " . sql_format('char', $pn); $row = SQL_oneRow($sq); if ($row === false) { echo "Page does not exist: " . $pn; return; } // Get one parent. We used to get all of them, but now // we only want one $hmenu = ''; $attop = false; $parents = array(); $peers = array(); $kids = array(); $pparent = $pprev = $pnext = ''; $plast = $pn; while ($plast != $pageroot) { $sq = "SELECT pagename_par FROM docpages \n WHERE pagename = '{$plast}'"; $rownew = SQL_AllRows($sq); $plast = $rownew[0]['pagename_par']; $parents[] = $plast; //if ($rownew[0]['pagename_par'] == $pageroot) { // break; //} } if (count($parents) > 0) { $parents = array_reverse($parents); //$hmenu=adocs_makemenu($parents,'Parent Topics'); // Grab this page's peers $pparent = $parents[count($parents) - 1]; $sq = "SELECT pagename FROM docpages \n WHERE pagename_par = '{$pparent}'\n ORDER BY sequence"; $rs = SQL($sq); while ($rowx = SQL_Fetch_Array($rs)) { $peers[] = $rowx['pagename']; } $peersr = array_flip($peers); $pprev = $peersr[$pn] == 0 ? '' : $peers[$peersr[$pn] - 1]; $pnext = $peersr[$pn] == count($peers) - 1 ? '' : $peers[$peersr[$pn] + 1]; } // Now pull out the kids $sq = "SELECT pagename FROM docpages \n WHERE pagename_par = '{$pn}'\n ORDER BY sequence"; $rs = SQL($sq); while ($rowx = SQL_Fetch_Array($rs)) { $kids[] = $rowx['pagename']; } // Make and save a menu out of what we've discovered adocs_makemenu($pageroot, $pn, $parents, $peers); // Now format the page and save it. No caching for now. $html = $row['pagetext']; $html = $this->WikiProcess($html); /* // Remove carriage returns, makes things much easier $html=str_replace("\r",'',$html); // Convert newlines to double br's, but first don't do doubles // after headings $html=str_replace("=\n\n","=\n",$html); $html=preg_replace("/\n\s*\n/","\n<br><br>\n",$html); // Convert bold & italitcs $html=preg_replace( "/'{4,}(.*)'{4,}/xmsU" ,'<b><i>$1</i></b>' ,$html); $html=preg_replace( "/'{3}(.*)'{3}/xmsU" ,'<i>$1</i>' ,$html); $html=preg_replace( "/\'{2}(.*)\'{2}/xmsU" ,'<b>$1</b>' ,$html); // Convert 6 levels of title $html=preg_replace( "/={6}(.*)={6}/xsU" ,'<head6>$1</head6>' ,$html); $html=preg_replace( "/={5}(.*)={5}/xsU" ,'<head5>$1</head5>' ,$html); $html=preg_replace( "/={4}(.*)={4}/xsU" ,'<head4>$1</head4>' ,$html); $html=preg_replace( "/={3}(.*)={3}/xsU" ,'<head3>$1</head3>' ,$html); $html=preg_replace( "/={2}(.*)={2}/xsU" ,'<head2>$1</head2>' ,$html); $html=preg_replace( '/^=(.*)=$/U' ,'<head1>$1</head1>' ,$html); // convert hyperlinks and images $matches=array(); while(preg_match('/\[{2,}(.*)\]{2,}/xmsU',$html,$matches)>0) { $search=$matches[1]; $asearch=explode(':',$search); if(count($asearch)==2) { $type=$asearch[0]; $match=$asearch[1]; } else { $type='ilink'; $match=$search; } switch(strtolower($type)) { case 'ilink': $this->Linkilink($html,$match); break; case 'image': $this->LinkImage($html,$match,$type); break; } $matches=array(); } */ // Prepare a list of parents if (count($parents) == 0) { $apars = array($pn); } else { $apars = $parents; $apars[] = $pn; } $hpars = ''; foreach ($apars as $apar) { $hpars .= ($hpars == '' ? '' : ' > ') . '<a href="?gp_page=x_docview&gppn=' . urlencode($apar) . '">' . $apar . '</a>'; } // Prepare the prev, next stuff $hpn = ''; if ($pprev . $pnext != '') { $hp = $pprev == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pprev) . '">PREV: ' . $pprev . '</a>'; $hn = $pnext == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pnext) . '">NEXT: ' . $pnext . '</a>'; $hpn = "\n\t\t\t<div class=\"row\">\n\t\t\t<div class=\"span9\">\n\t\t\t\t<div class=\"pull-left\">{$hp}</div>\n\t\t\t\t<div class=\"pull-right\">{$hn}</div>\n\t\t\t</div>\n\t\t\t</div>"; } // Pull out and assemble the see-also groups $hsa = ''; /* $hsa=''; $sq='SELECT DISTINCT seealso FROM seealsoxpages ' ." WHERE pagename='$pn'"; $sas=SQL_AllRows($sq); foreach($sas as $sa) { $hsa.="<hr>"; $seealso=$sa['seealso']; $hsa.="<hr><h2>See Also ($seealso):</h2><p>"; $sq="SELECT pagename FROM seealsoxpages " ." WHERE seealso = '$seealso' " ." AND pagename <> '$pn'" ." ORDER By pagename "; $sarows=SQL_AllRows($sq); foreach($sarows as $index=>$sarow) { $hsa.=($index==0 ? '' : ', ') .'<a href="?gppn='.urlencode($sarow['pagename']).'">' .$sarow['pagename'].'</a>'; } $sarows.='</p>'; } */ // Now the actual output and formatting // $this->PageSubtitle = $pn; echo "<div class=\"hero-unit\">Database Specification</div>"; echo $hpars . "<br><br>"; echo $hpn; echo "\n<hr>"; echo "\n<h2>" . $pn . "</h2>\n"; echo $html; if (count($kids) > 0 && $pn == 'Data Dictionary') { echo "\n<hr>"; echo "\n<head2>Child Topics</head2>"; foreach ($kids as $kid) { echo "\n<div><a href=\"?gp_page=x_docview&gppn=" . urlencode($kid) . "\">{$kid}</a></div>"; } } echo $hsa; echo "<hr>"; echo $hpn; ?> <hr> Page last modified <?php echo date('r', dEnsureTS($row['ts_upd'])); ?> by <?php echo $row['uid_upd']; ?> <br><br> <?php }
/** * Main Entry point for execution. * * @param string $yamlP2 * @param string $fontname default "Times" * @since 12/16/07 */ function main($dbres, $yamlP2, $secinfo) { // Branch out to do setup... $this->mainSetup($yamlP2); // declare this to avoid jedit compiler warning $row = array(); // Call the routine that sets up an array of // values to put into the bottom; $bottom = $this->setupBottom($yamlP2); $break = $this->setupBreak($yamlP2); // Begin by adding the first page $this->addPage($this->orientation); $row1 = false; while ($row = SQL_Fetch_Array($dbres)) { if ($row1) { if (!$this->compareBreak($yamlP2, $break, $row)) { $this->linesForColumns(); $this->outFromArray($break); $this->nextLine(); $break = $this->SetupBreak($yamlP2); } } $row1 = true; $this->outFromArray($row); if (count($break) > 0) { $break = $this->processForBreak($yamlP2, $break, $row); } if (count($bottom) > 0) { $bottom = $this->processForBottom($yamlP2, $bottom, $row); } } if (count($bottom) > 0) { $this->linesForColumns(); $this->outFromArray($bottom); } $this->overAndOut(); }
function ehProcessDisplay($SQ, $rows_col, $row_rep) { $gp_process = gp('gp_process'); $this->dispmode = $gp_process == 1 ? 'screen' : 'print'; // Set the template $html_main = gp('gp_process') == 1 ? 'html_skin_tc_prscreen' : 'html_print'; vgaSet('html_main', $html_main); // Execute the query, but do not retrieve $result = SQL($SQ); // Two counters: PageNum, and RowNum, the row number // inside of a page. $this->PageNum = 1; $this->RowNum = 1; $this->RowsPerPage = 66; // In all cases, begin with a header $this->ehPDInit(); if ($this->PageNum == 1) { $this->ehPDHeader($row_rep, $rows_col); } // This is the basic output loop while ($row = SQL_Fetch_Array($result)) { arrayStripNumericIndexes($row); $this->ehPDRow($row); // Always increase row count. For PDF, look for reset $RowNum++; if ($dispmode == 'print') { if ($RowNum > $RowsPerPage) { $this->ehPDFooter(); $this->RowNum = 1; $this->PageNum++; $this->ehPDHeader($PageNum); } } } // In all Cases, end with a footer $this->ehPDFooter(); $this->ehPDClose(); }
function SQLX_ToDyn($table, $pkcol, $lcols, $filters = array()) { // Turn filters into two strings $filt_name = $filt_where = ''; foreach ($filters as $colname => $colvalue) { $filt_name .= '_' . $colname . '_' . $colvalue; $filt_where .= $filt_where == '' ? '' : ' AND '; $filt_where .= " {$colname} = '{$colvalue}' "; } $filt_where = $filt_where == '' ? '' : ' WHERE ' . $filt_where; // first get the name $fname = 'table_' . $table . '_' . str_replace(',', '_', $lcols) . $filt_name . '.rpk'; // Pull from memory if processed, else cache if (!isset($GLOBALS['cache'][$fname])) { // not in memory, is it on disk? If not, must // execute the query $rows = aFromDyn($fname); if ($rows === false) { $rows = array(); $sq = "SELECT {$pkcol},{$lcols} FROM {$table} {$filt_where}"; $db = SQL($sq); while ($row = SQL_Fetch_Array($db)) { $rows[$row[$pkcol]] = $row; } DynFromA($fname, $rows); } $GLOBALS['cache'][$fname] = $rows; } $retval =& $GLOBALS['cache'][$fname]; return $retval; }
function RepStandard() { // First Generate the query $sq = $this->RepStandardQuery(); if ($this->display == 'SQL') { echo "<h1>The Generated SQL</h1>"; hprint_r($sq); return; } // Now execute the query and run the report if ($this->display == 'CSV') { echo "<pre>"; echo implode(',', $this->Cols) . "\n"; $res = SQL($sq); while ($row = pg_fetch_row($res)) { echo implode(',', $row) . "\n"; } echo "</pre>"; return; } // Pull the info on breaking, sums, etc. $srep = SQLFC($this->report_id); $s2 = "SELECT rcl.column_id,rcl.reportlevel,rcl.summact\n FROM reportcollevels rcl\n JOIN reportcolumns rc ON rcl.column_id = rc.column_id\n WHERE rc.report = {$srep}\n ORDER BY rcl.reportlevel,rc.uicolseq"; $breaks = SQL_AllRows($s2); $abreaks = array(); foreach ($breaks as $break) { if ($break['summact'] == 'BREAK') { $abreaks[$break['reportlevel']]['breaks'][$break['column_id']] = ''; } else { $abreaks[$break['reportlevel']]['data'][$break['column_id']] = array('summact' => $break['summact'], 'val' => 0, 'cnt' => 0); } } // There is always some setup, for either PDF or HTML, so do that // here. $this->RepHeader(); // Now execute the query and run the report $res = SQL($sq); $firstrow = true; while ($row = SQL_Fetch_Array($res)) { if ($firstrow) { $firstrow = false; $this->RepStandardBreakLevelsInit($abreaks, $row); } else { $this->RepStandardBreakLevels($abreaks, $row); } $xpos = 0; foreach ($this->rows_col as $column_id => $colinfo) { $disp = substr($row[$column_id], 0, $colinfo['dispsize']); $disp = STR_PAD($disp, $colinfo['dispsize'], ' '); $this->PlaceCell($xpos, $disp); $xpos += 2 + $colinfo['dispsize']; } $this->ehFlushLine(); $this->RepStandardRowsToLevels($abreaks, $row); } $this->RepStandardBreakLevels($abreaks, $row, true); // There is always some cleanup, either PDF or HTML $this->RepFooter(); }
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; }
/** * Main Entry point for execution. * * @param string $yamlP2 * @param string $fontname default "Times" * @since 12/16/07 */ function main($dbres, $yamlP2, $secinfo) { // Set most important flag first! # KFD 9/20/08, this can now be 'csvexport' also! $this->format = gp('gp_post'); // pdf or onscreen // Branch out to do setup... $this->mainSetup($yamlP2); // declare this to avoid jedit compiler warning $row = array(); // Call the routine that sets up an array of // values to put into the bottom and break $bottom = $this->setupBottom($yamlP2); $break = $this->setupBreak($yamlP2); // Begin by adding the first page if ($this->format == 'onscreen') { $this->headerOnScreen(); } elseif ($this->format == 'csvexport') { $this->csvline = array(); $this->csvexport = ''; } else { $this->addPage($this->orientation); } $row1 = false; while ($row = SQL_Fetch_Array($dbres)) { if ($row1) { if (!$this->compareBreak($yamlP2, $break, $row)) { $this->linesForColumns(); $this->outFromArray($break); $this->nextLine(); $this->nextLine(); $break = $this->SetupBreak($yamlP2); } } $row1 = true; $this->outFromArray($row); if (count($break) > 0) { $break = $this->processForBreak($yamlP2, $break, $row); } if (count($bottom) > 0) { $bottom = $this->processForBottom($yamlP2, $bottom, $row); } } if (count($break) > 0) { $this->linesForColumns(); $this->outFromArray($break); $this->nextLine(); } if (count($bottom) > 0) { $this->linesForColumns(); $this->outFromArray($bottom); } $this->overAndOut(); }
function ehTablesAvl($ajax = true) { $skey = SQL_Format('numb', gp('gp_skey')); // Get the list of tables that are in the report, // get them into list version, like 'tablea','table2','tabled'... $tables = SQL_AllRows("SELECT table_id \n FROM reporttables rt\n JOIN reports r ON r.report = rt.report\n WHERE r.skey = {$skey}"); $atables = array(); foreach ($tables as $table) { $atables[] = "'" . trim($table['table_id']) . "'"; } $stables = implode(',', $atables); if ($stables != '') { // They requested a particular table $sq = "select distinct t.table_id,t.description\n FROM tables t\n JOIN (\n SELECT table_id,table_id_par \n FROM tabfky\n UNION ALL\n SELECT table_id_par as table_id,table_id as table_id_par\n FROM tabfky\n ) fky\n ON t.table_id = fky.table_id\n WHERE fky.table_id_par in ({$stables})\n AND t.table_id NOT IN ({$stables}) \n ORDER BY t.description"; } else { $sq = "select table_id,description\n FROM tables \n order by description"; } $dbres = SQL($sq); $retval = ''; while ($row = SQL_Fetch_Array($dbres)) { $retval .= "\n<option value=\"" . $row['table_id'] . "\">" . $row['description'] . "</option>"; } // Echo the output //echo "echo|$sq"; //return; if ($ajax) { echo "ajx_tablesavl|"; } echo "<select multiple size=7 style=\"width: 300px\"\n name=\"sel_tablesavl\" id=\"sel_tablesavl\"\n >" . $retval . "</select>"; }