Beispiel #1
0
mfcs::singleton();
// Quick and dirty Checks check
// @TODO this needs to be more formalized in a class to easily include other checks as well
if (!isCLI()) {
    $sql_check = sprintf("SELECT `value` FROM `checks` WHERE `name`='uniqueIDCheck'");
    $sqlResult_check = mfcs::$engine->openDB->query($sql_check);
    if (!$sqlResult_check['result']) {
        errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
        print "<p>Error checking MFCS sanity. Aborting.</p>";
        exit;
    }
    $row_check = mysql_fetch_array($sqlResult_check['result'], MYSQL_ASSOC);
    if ($row_check['value'] == "0") {
        // notify systems via email
        print "<h1>ERROR!</h1>";
        print "<p>MFCS Failed idno sanity check. Please contact systems Immediately.</p>";
        print "<p>Please jot down the steps you took getting to this point. Be as specific as possible.</p>";
        print "<p>Aborting.</p>";
        exit;
    }
}
// End Checks
$mfcsSearch = new mfcsSearch();
// Load the user's current projects
sessionSet('currentProject', users::loadProjects());
recurseInsert("includes/functions.php", "php");
recurseInsert("includes/validator.php", "php");
$engine->eTemplate("load", "distribution");
localVars::add("siteRoot", mfcs::config("siteRoot"));
localVars::add('pageTitle', mfcs::config("pageTitle"));
localVars::add('pageHeader', mfcs::config("pageHeader"));
Beispiel #2
0
    session_register('acc');
    session_register('status');
    //session_register('fruits');
    session_register('login_time');
    // 寫入 Session 變數值
    $_SESSION['acc'] = $acc;
    $_SESSION['status'] = true;
    $_SESSION['login_time'] = date('Y-m-d h:i:s');
    echo true;
}
function sessionCheck()
{
    if (isset($_SESSION["status"]) && $_SESSION["status"] === true) {
        echo true;
    } else {
        echo false;
    }
}
function sessionDelete()
{
    session_register('status');
    $_SESSION['status'] = false;
    echo true;
}
if ($_POST['act'] === "check") {
    sessionCheck();
} elseif ($_POST['act'] === "set") {
    sessionSet($_POST['account']);
} elseif ($_POST['act'] === "del") {
    sessionDelete();
}
Beispiel #3
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 #4
0
 public static function search($post)
 {
     if (isempty($post['formList'])) {
         return FALSE;
     }
     // Save the post for later use (like pagination pages)
     sessionSet('searchPOST', $post);
     if (!isempty($post['startDate']) && !isempty($post['endDate'])) {
         $date = TRUE;
         // @tODO build where clause for date here
     } else {
         $date = FALSE;
     }
     // build query for idno searches
     if ($post['fieldList'] == "idno" && preg_match('/^\\\\"(.+?)\\\\"/', trim($post['query']), $matches)) {
         $queryString = sprintf("LOWER(`idno`)='%s'", strtolower($matches[1]));
     } else {
         if ($post['fieldList'] == "idno" && preg_match('/^(.+?)\\*$/', trim($post['query']), $matches)) {
             $queryString = sprintf("LOWER(`idno`) LIKE '%s%%'", strtolower($matches[1]));
         } else {
             if ($post['fieldList'] == "idno" && preg_match('/^\\*(.+?)$/', trim($post['query']), $matches)) {
                 $queryString = sprintf("LOWER(`idno`) LIKE '%%%s'", strtolower($matches[1]));
             } else {
                 $queryString = sprintf("LOWER(`idno`) LIKE '%%%s%%'", strtolower($post['query']));
             }
         }
     }
     // if idno search, build mysql here and search
     if ($post['fieldList'] == "idno" && $date === TRUE) {
         $sql = sprintf("SELECT * FROM `objects` WHERE `idno` LIKE '%%%s%%' AND `formID`='%s' AND `createTime` >= '%s' AND `createTime` <= '%s' ORDER BY LENGTH(idno), `idno`", $post['query'], $post['formList'], strtotime($post['startDate']), strtotime($post['endDate']));
         $objects = objects::getObjectsForSQL($sql);
     } else {
         if ($post['fieldList'] == "idno") {
             $sql = sprintf("SELECT * FROM `objects` WHERE %s AND `formID`='%s' ORDER BY LENGTH(idno), `idno`", $queryString, $post['formList']);
             $objects = objects::getObjectsForSQL($sql);
         } else {
             if ($date === TRUE) {
                 $sql = sprintf("SELECT * FROM `objects` WHERE AND `formID`='%s' AND `createTime` >= '%s' AND `createTime` <= '%s' ORDER BY LENGTH(idno), `idno`", $post['formList'], strtotime($post['startDate']), strtotime($post['endDate']));
                 $objects = objects::getObjectsForSQL($sql);
             } else {
                 $objects = objects::getAllObjectsForForm($post['formList'], "idno", TRUE);
             }
         }
     }
     $results = array();
     foreach ($objects as $object) {
         // check that the item is in the date range, if a date range is specified.
         // if ($date === TRUE && ($object['createTime'] < strtotime($post['startDate']) || $object['createTime'] > strtotime($post['endDate']))) {
         // 	continue;
         // }
         $found = FALSE;
         if (!isempty($post['query'])) {
             if ($post['fieldList'] == "idno") {
                 $found = TRUE;
             } else {
                 if (isset($object['data'][$post['fieldList']]) && stripos($object['data'][$post['fieldList']], $post['query']) !== FALSE) {
                     $found = TRUE;
                 }
             }
         } else {
             if (is_empty($post['query'])) {
                 $found = TRUE;
             }
         }
         if ($found === TRUE) {
             $results[$object['ID']] = $object;
         }
     }
     return $results;
 }
Beispiel #5
0
        errorHandle::errorMsg($e->getMessage());
    }
} else {
    if (!is_empty(sessionGet('searchResults'))) {
        log::insert("Data View: Search: get results");
        $results = sessionGet('searchResults');
    } else {
        if (!is_empty(sessionGet('searchQuery'))) {
            log::insert("Data View: Search: get saved search");
            $searchQuery = sessionGET('searchQuery');
            try {
                $results = mfcsSearch::search($searchQuery);
                if ($results === FALSE) {
                    throw new Exception("Error retrieving results");
                }
                sessionSet("searchResults", $results);
            } catch (Exception $e) {
                log::insert("Data View: Search: Error", 0, 0, $e->getMessage());
                errorHandle::errorMsg($e->getMessage());
            }
        } else {
            if (isset($engine->cleanGet['MYSQL']['page'])) {
                log::insert("Data View: Search: page");
                $searchPOST = sessionGet('searchPOST');
                if ($searchPOST) {
                    $results = mfcsSearch::search($searchPOST);
                    if ($results === FALSE) {
                        throw new Exception("Error retrieving results");
                    }
                }
            } else {
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);
}