function ProcessPosts()
 {
     global $USER;
     $pc = 0;
     if (!empty($USER->Browsers[0]->QueuedPosts)) {
         if (!$USER->Browsers[0]->Waiting) {
             while (!empty($_GET["mi" . $pc])) {
                 $pc++;
             }
             foreach ($USER->Browsers[0]->QueuedPosts as $id => $postar) {
                 $_GET["mp" . $pc] = $postar[0];
                 $_GET["mrid" . $pc] = $_GET["mi" . $pc] = Encoding::Base64UrlEncode($id);
                 $_GET["mc" . $pc++] = Encoding::Base64UrlEncode($postar[1]);
                 DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `id`='" . DBManager::RealEscape($id) . "' LIMIT 1;");
             }
             $pc = 0;
             $USER->Browsers[0]->QueuedPosts = array();
         }
     }
     $this->OverlayHTML = "";
     if (!empty($_GET["mi" . $pc]) || $USER->Browsers[0]->Waiting || !empty($USER->Browsers[0]->InitChatWith) || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
         if ($USER->Browsers[0]->Waiting && $this->Botmode && !empty($USER->Browsers[0]->QueuedPosts)) {
             $USER->Browsers[0]->QueuedPosts = array();
         } else {
             if (!Visitor::$OpenChatExternal) {
                 $this->Init();
             }
         }
         if (!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
             $USER->Browsers[0]->Forward->Save(true, true);
             Visitor::$IsActiveOverlayChat = !$USER->Browsers[0]->Declined;
         }
     }
     if (!empty($USER->Browsers[0]->ChatId)) {
         $USER->AddFunctionCall("lz_chat_id='" . $USER->Browsers[0]->ChatId . "';", false);
     }
     $USER->Browsers[0]->VisitId = $USER->VisitId;
     while (!empty($_GET["mi" . $pc])) {
         $id = Communication::ReadParameter("mrid" . $pc, md5($USER->Browsers[0]->SystemId . $USER->Browsers[0]->ChatId . $_GET["mi" . $pc]));
         $senderName = !empty($USER->Browsers[0]->UserData->Fullname) ? $USER->Browsers[0]->UserData->Fullname : LocalizationManager::$TranslationStrings["client_guest"] . " " . Visitor::GetNoName($USER->UserId . Communication::GetIP());
         $post = new Post($id, $USER->Browsers[0]->SystemId, "", Encoding::Base64UrlDecode($_GET["mp" . $pc]), Communication::ReadParameter("mc" . $pc, time()), $USER->Browsers[0]->ChatId, $senderName);
         $post->BrowserId = VisitorMonitoring::$Browser->BrowserId;
         if (!empty($_GET["mpti" . $pc])) {
             $post->Translation = Encoding::Base64UrlDecode($_GET["mpt" . $pc]);
             $post->TranslationISO = Encoding::Base64UrlDecode($_GET["mpti" . $pc]);
         }
         $saved = false;
         if (!$USER->Browsers[0]->Waiting) {
             foreach (Server::$Groups as $groupid => $group) {
                 if ($group->IsDynamic && $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE && isset($group->Members[$USER->Browsers[0]->SystemId])) {
                     foreach ($group->Members as $member => $persistent) {
                         if ($member != $USER->Browsers[0]->SystemId) {
                             if (!empty(Server::$Operators[$member])) {
                                 processPost($id, $post, $member, $pc, $groupid, $USER->Browsers[0]->ChatId);
                             } else {
                                 processPost($id, $post, $member, $pc, $groupid, CacheManager::GetValueBySystemId($member, "chat_id", ""));
                             }
                             $saved = true;
                         }
                     }
                     $pGroup = $group;
                 }
             }
             foreach ($USER->Browsers[0]->Members as $systemid => $member) {
                 if (!empty($member->Declined)) {
                     continue;
                 }
                 if (!empty(Server::$Operators[$systemid]) && !empty($pGroup) && isset($pGroup->Members[$systemid])) {
                     continue;
                 }
                 if (!(!empty($pGroup) && !empty(Server::$Operators[$systemid]))) {
                     $saved = processPost($id, $post, $systemid, $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, Server::$Operators[$systemid]->IsBot);
                 }
             }
             if (!empty($USER->Browsers[0]->OperatorId) && (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot || $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE)) {
                 $rpost = new Post($id = getId(32), Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $USER->Browsers[0]->SystemId, $answer = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies($post->Text . " " . $post->Translation, $USER->Browsers[0]), time(), $USER->Browsers[0]->ChatId, Server::$Operators[$USER->Browsers[0]->OperatorId]->Fullname);
                 if (!empty($answer)) {
                     if (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                         sleep(1);
                         $USER->AddFunctionCall("lz_chat_input_bot_state(true,false);", false);
                     }
                     $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                     $rpost->Save();
                     $saved = true;
                     foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                         if ($opsysid != Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId || !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                             $rpost = new Post($id, Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $opsysid, $answer, time(), $USER->Browsers[0]->ChatId, Server::$Operators[$opsysid]->Fullname);
                             $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                             $rpost->Save();
                         }
                     }
                 }
             }
             if ($saved) {
                 $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
             }
         } else {
             processPost($id, $post, "", $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, false);
             $USER->Browsers[0]->QueuedPosts[$id] = array(0 => $_GET["mp" . $pc], 1 => time(), 2 => VisitorMonitoring::$Browser->BrowserId);
             $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
         }
         $pc++;
     }
     if (!empty($USER->Browsers[0]->OperatorId) && empty($pc) && !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
         $autoReply = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies("", $USER->Browsers[0]);
         if (!empty($autoReply)) {
             ChatAutoReply::SendAutoReply($autoReply, $USER, $USER->Browsers[0]->OperatorId);
         }
     }
 }
Exemplo n.º 2
0
/**
* The subroutine that eats like a meal.  Does everything with
* the data-oriented posted variables, independent of what page
* we are on or going to.  Stores search criteria, does updates,
* deletes, inserts.
*
* INPUTS
*/
function databaseFromPost()
{
    return processPost();
}
Exemplo n.º 3
0
    //jQuery("table").tablesorter({widthFixed: true, widgets: ['zebra']}).tablesorterPager({container: $("#pager")}); 
}); 
</script>
<div class="wrap">

<?php 
$subtitle = __("Bidders", 'silentauction');
if ($showPage) {
    $subtitle .= ' <a href="' . get_admin_url(null, 'admin.php') . "?page=sa-bidders&view=add\" class=\"page-title-action\">" . __("Add Bidder", 'silentauction') . '</a>';
}
sa_heading($subtitle);
?>
	
<?php 
if ($showPage) {
    processPost($crud);
    $actions = array('action-summary');
    $viewKey = '';
    foreach ($actions as $a) {
        if (isset($_GET[$a])) {
            $viewKey = $a;
        }
    }
    if ($viewKey == '' && isset($_GET['view'])) {
        $viewKey = $_GET['view'];
    }
    switch ($viewKey) {
        case 'add':
            doAddView($crud);
            break;
        case 'edit':
Exemplo n.º 4
0
    function movethread()
    {
        global $tc_db, $tpl_page;
        $this->AdministratorsOnly();
        $tpl_page .= '<h2>' . _gettext('Move thread') . '</h2><br />';
        if (isset($_POST['id']) && isset($_POST['board_from']) && isset($_POST['board_to'])) {
            // Get the IDs for the from and to boards
            $board_from_id = $tc_db->GetOne("SELECT HIGH_PRIORITY `id` FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($_POST['board_from']) . "");
            $board_to_id = $tc_db->GetOne("SELECT HIGH_PRIORITY `id` FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($_POST['board_to']) . "");
            $board_from = $_POST['board_from'];
            $board_to = $_POST['board_to'];
            $id = $tc_db->qstr($_POST['id']);
            if (isset($_POST['mf'])) {
                $image = $tc_db->GetOne("SELECT `file` FROM " . KU_DBPREFIX . "posts WHERE `boardid` = " . $board_from_id . " AND `id` = " . $id);
                $filetype = $tc_db->GetOne("SELECT `file_type` FROM " . KU_DBPREFIX . "posts WHERE `boardid` = " . $board_from_id . " AND `id` = " . $id);
                $from_pic = KU_BOARDSDIR . $board_from . '/src/' . $image . '.' . $filetype;
                $from_thumb = KU_BOARDSDIR . $board_from . '/thumb/' . $image . 's' . '.' . $filetype;
                $from_cat = KU_BOARDSDIR . $board_from . '/thumb/' . $image . 'c' . '.' . $filetype;
                $to_pic = KU_BOARDSDIR . $board_to . '/src/' . $image . '.' . $filetype;
                $to_thumb = KU_BOARDSDIR . $board_to . '/thumb/' . $image . 's' . '.' . $filetype;
                $to_cat = KU_BOARDSDIR . $board_to . '/thumb/' . $image . 'c' . '.' . $filetype;
                @rename($from_pic, $to_pic);
                @rename($from_thumb, $to_thumb);
                @rename($from_cat, $to_cat);
                @unlink($from_pic);
                @unlink($from_thumb);
                @unlink($from_cat);
            }
            $from_html = KU_BOARDSDIR . $board_from . '/res/' . $_POST['id'] . '.html';
            $from_html_50 = KU_BOARDSDIR . $board_from . '/res/' . $_POST['id'] . '+50.html';
            $from_html_100 = KU_BOARDSDIR . $board_from . '/res/' . $_POST['id'] . '-100.html';
            @unlink($from_html);
            @unlink($from_html_50);
            @unlink($from_html_100);
            $tc_db->Execute("START TRANSACTION");
            $new_id = $tc_db->GetOne("SELECT COALESCE(MAX(id),0) + 1 FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_to_id);
            $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `id` = " . $new_id . ", `boardid` = " . $board_to_id . " WHERE `boardid` = " . $board_from_id . " AND `id` = " . $id);
            processPost($new_id, $new_id, $id, $board_from, $board_to, $board_to_id);
            $results = $tc_db->GetAll("SELECT `id` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_from_id . " AND `parentid` = " . $id . " ORDER BY `id` ASC");
            foreach ($results as $line) {
                if (isset($_POST['mf'])) {
                    $image = $tc_db->GetOne("SELECT `file` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_from_id . " AND `id` = " . $line['id']);
                    $filetype = $tc_db->GetOne("SELECT `file_type` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_from_id . " AND `id` = " . $line['id']);
                    $from_pic = KU_BOARDSDIR . $board_from . '/src/' . $image . '.' . $filetype;
                    $from_thumb = KU_BOARDSDIR . $board_from . '/thumb/' . $image . 's' . '.' . $filetype;
                    $from_cat = KU_BOARDSDIR . $board_from . '/thumb/' . $image . 'c' . '.' . $filetype;
                    $to_pic = KU_BOARDSDIR . $board_to . '/src/' . $image . '.' . $filetype;
                    $to_thumb = KU_BOARDSDIR . $board_to . '/thumb/' . $image . 's' . '.' . $filetype;
                    $to_cat = KU_BOARDSDIR . $board_to . '/thumb/' . $image . 'c' . '.' . $filetype;
                    @rename($from_pic, $to_pic);
                    @rename($from_thumb, $to_thumb);
                    @rename($from_cat, $to_cat);
                    @unlink($from_pic);
                    @unlink($from_thumb);
                    @unlink($from_cat);
                }
                $insert_id = $tc_db->GetOne("SELECT COALESCE(MAX(id),0) + 1 FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_to_id);
                $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `id` = " . $insert_id . ", `boardid` = " . $board_to_id . " WHERE `boardid` = " . $board_from_id . " AND `id` = " . $line['id']);
                processPost($insert_id, $new_id, $id, $board_from, $board_to, $board_to_id);
                $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `parentid` = " . $new_id . " WHERE `boardid` = " . $board_to_id . " AND `id` = " . $insert_id);
            }
            $tc_db->Execute("COMMIT");
            $board_class = new Board($board_from);
            $board_class->RegenerateThreads();
            $board_class->RegeneratePages();
            unset($board_class);
            $board_class = new Board($board_to);
            $board_class->RegenerateThreads();
            $board_class->RegeneratePages();
            unset($board_class);
            $tpl_page .= _gettext('Move complete.') . ' <br /><hr />';
        }
        $tpl_page .= '<form action="?action=movethread" method="post">

		<label for="id">' . _gettext('ID') . ':</label>
		<input type="text" name="id" />
		<br />

		<label for="board_from">' . _gettext('From') . ':</label>' . $this->MakeBoardListDropdown('board_from', $this->BoardList($_SESSION['manageusername'])) . '<br />

		<label for="board_to">' . _gettext('To') . ':</label>' . $this->MakeBoardListDropdown('board_to', $this->BoardList($_SESSION['manageusername'])) . '<br />
		<label for="mf">' . _gettext('Move Files') . ':</label>
		<input type="checkbox" id="mf" name="mf" /><br />
		<input type="submit" value="' . _gettext('Move thread') . '" />';
    }
function processPosts($counter = 0)
{
    global $USER, $STATS, $GROUPS, $INTERNAL, $LZLANG;
    while (isset($_POST["p_p" . $counter])) {
        if (STATS_ACTIVE) {
            $STATS->ProcessAction(ST_ACTION_EXTERNAL_POST);
        }
        $id = md5($USER->Browsers[0]->SystemId . base64UrlDecode($_POST[POST_EXTERN_CHAT_ID]) . base64UrlDecode($_POST["p_i" . $counter]));
        $senderName = !empty($USER->Browsers[0]->Fullname) ? $USER->Browsers[0]->Fullname : $LZLANG["client_guest"] . " " . getNoName($USER->UserId . getIP());
        $post = new Post($id, $USER->Browsers[0]->SystemId, "", base64UrlDecode($_POST["p_p" . $counter]), time(), $USER->Browsers[0]->ChatId, $senderName);
        foreach ($GROUPS as $groupid => $group) {
            if ($group->IsDynamic && !empty($group->Members[$USER->Browsers[0]->SystemId])) {
                foreach ($group->Members as $member => $persistent) {
                    if ($member != $USER->Browsers[0]->SystemId) {
                        if (!empty($INTERNAL[$member])) {
                            processPost($id, $post, $member, $counter, $groupid, $USER->Browsers[0]->ChatId);
                        } else {
                            processPost($id, $post, $member, $counter, $groupid, getValueBySystemId($member, "chat_id", ""));
                        }
                    }
                }
                $pGroup = $group;
            }
        }
        foreach ($USER->Browsers[0]->Members as $systemid => $member) {
            if (!empty($member->Declined)) {
                continue;
            }
            if (!empty($INTERNAL[$systemid]) && !empty($pGroup->Members[$systemid])) {
                continue;
            }
            if (!(!empty($pGroup) && !empty($INTERNAL[$systemid]))) {
                processPost($id, $post, $systemid, $counter, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId);
            }
        }
        $autoReply = $USER->Browsers[0]->InternalUser->GetAutoReplies($post->Text, $USER->Browsers[0]);
        if (!empty($autoReply)) {
            $arpost = new Post($id = getId(32), $USER->Browsers[0]->InternalUser->SystemId, $USER->Browsers[0]->SystemId, $autoReply, time(), $USER->Browsers[0]->ChatId, $USER->Browsers[0]->InternalUser->Fullname);
            $arpost->ReceiverOriginal = $arpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
            $arpost->Save();
            foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                $rpost = new Post($id, $USER->Browsers[0]->InternalUser->SystemId, $opsysid, $autoReply, time(), $USER->Browsers[0]->ChatId, $INTERNAL[$systemid]->Fullname);
                $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                $rpost->Save();
            }
        }
        $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_POST["p_i" . $counter]) . "');", false);
        $counter++;
    }
    $counter = 0;
    while (isset($_POST["pr_i" . $counter])) {
        $post = new Post(base64UrlDecode($_POST["pr_i" . $counter]), "", "", "", "", "", "");
        $post->MarkReceived($USER->Browsers[0]->SystemId);
        $USER->AddFunctionCall("lz_chat_message_set_received('" . base64UrlDecode($_POST["pr_i" . $counter]) . "');", false);
        $counter++;
    }
}
Exemplo n.º 6
0
                 $rpost->Save();
                 $saved = true;
                 foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                     if ($opsysid != $USER->Browsers[0]->InternalUser->SystemId || !$USER->Browsers[0]->InternalUser->IsBot) {
                         $rpost = new Post($id, $USER->Browsers[0]->InternalUser->SystemId, $opsysid, $answer, time(), $USER->Browsers[0]->ChatId, $INTERNAL[$systemid]->Fullname);
                         $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                         $rpost->Save();
                     }
                 }
             }
         }
         if ($saved) {
             $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_GET["mi" . $pc]) . "');", false);
         }
     } else {
         processPost($id, $post, "", $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, false);
         $USER->Browsers[0]->QueuedPosts[$id] = array(0 => $_GET["mp" . $pc], 1 => time(), 2 => $BROWSER->BrowserId);
         $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_GET["mi" . $pc]) . "');", false);
     }
     $pc++;
 }
 $startTime = 0;
 $isOp = false;
 if ($USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE) {
     $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHAT_OPERATORS . "` WHERE `chat_id`='" . DBManager::RealEscape($USER->Browsers[0]->ChatId) . "' ORDER BY `status` DESC, `dtime` DESC;");
     while ($row = DBManager::FetchArray($result)) {
         if (isset($INTERNAL[$row["user_id"]])) {
             $ChatMember = new ChatMember($row["user_id"], $row["status"], !empty($row["declined"]), $row["jtime"], $row["ltime"]);
             if ($ChatMember->Status == 1 && $ChatMember->Joined >= $USER->Browsers[0]->LastActive) {
                 $isOp = true;
                 addHTML(str_replace("<!--message-->", str_replace("<!--intern_name-->", $INTERNAL[$ChatMember->SystemId]->Fullname, $LZLANG["client_intern_arrives"]), getFile(TEMPLATE_HTML_MESSAGE_OVERLAY_CHAT_STATUS)), "sys", "LMMJ" . $ChatMember->SystemId);
Exemplo n.º 7
0
    			// Usamos el serializador de xml de PEAR
    			$options = array ('indent' => ' ','addDecl' => false,'rootName' => $fc->getAction(), XML_SERIALIZER_OPTION_RETURN_RESULT => true);
    			$serializer = new XML_Serializer($options);
    			RestUtils::sendResponse(200, $serializer->serialize($send_data),'application/xml');
    		}//*/
}
$data = RestUtils::processRequest();
switch ($data->getMethod()) {
    // this is a request for all users, not one in particular
    case 'get':
        $user_data = processGet($data);
        send($data, $user_data);
        break;
    case 'post':
        // creamos un usuario (o modificamos si ya existe su uuid)
        $user_data = processPost($data);
        send($data, $user_data);
        break;
    case 'put':
        $user_data = processPut($data);
        send($data, $user_data);
        break;
    case 'delete':
        $user_data = processDelete($data);
        send($data, $user_data);
        break;
}
function processGet($data)
{
    $uri = parse_url($_SERVER['REQUEST_URI']);
    $exploded = explode("/", $uri["path"]);
Exemplo n.º 8
0
function index_hidden_page()
{
    global $AG;
    $sessok = !LoggedIn() ? false : true;
    // KFD 3/6/08, moved here from the main stream of index_hidden
    //             because these are relevant only to page processing
    if (gpExists('x_module')) {
        SessionSet('AGMENU_MODULE', gp('x_module'));
    } elseif (vgaGet('nomodule') != '' && SessionGet('AGMENU_MODULE') == '') {
        SessionSet('AGMENU_MODULE', vgaGet('nomodule'));
    }
    // If the search flag is set, we need to know what class for this
    // application handles searchs
    if (gpExists('gp_search')) {
        gpSet('gp_page', vgaGet('SEARCH_CLASS'));
    }
    // Load up a list of pages that public users are allowed to see,
    // with home and password always there.
    global $MPPages;
    // allows it to be in applib
    $MP = array();
    //$MPPages= array();
    // This is the old method, load $MPPages from its own file
    if (file_exists_incpath('appPublicMenu.php')) {
        include_once 'appPublicMenu.php';
    }
    if (!is_array($MPPages)) {
        $MPPages = array();
    }
    $MPPages['x_home'] = 'Home Page';
    $MPPages['x_login'] = '******';
    $MPPages['x_noauth'] = 'Authorization Required';
    $MPPages['x_password'] = "******";
    $MPPages['x_mpassword'] = "******";
    $MPPages['x_paypalipn'] = 'Paypal IPN';
    // If the install page exists, it will be used, no getting
    // around it.
    $install = $GLOBALS['AG']['dirs']['application'] . 'install.php';
    $instal2 = $GLOBALS['AG']['dirs']['application'] . 'install.done.php';
    if (file_exists($install)) {
        if (gp('gp_install') == 'finish') {
            rename($install, $instal2);
        } else {
            $MPPages['install'] = 'install';
            gpSet('gp_page', 'install');
        }
    }
    // First pass is to look for the "flaglogin" flag.  This says save all
    // current page settings and go to login screen.  They will be restored
    // on a successful login.  Very useful for links that say "Login to
    // see nifty stuff..."
    if (gp('gp_flaglogin') == '1') {
        gpSet('gp_flaglogin', '');
        gpToSession();
        gpSet('gp_page', 'x_login');
    }
    // Second pass redirection, pick default page if there
    // is none, and verify public pages.
    //
    $gp_page = gp('gp_page');
    if ($gp_page == '') {
        if (vgfGet('LoginAttemptOK') === true && vgfGet('x4') === true) {
            $gp_page = 'x4init';
            gpSet('gp_page', 'x4init');
            SessionSet('TEMPLATE', 'x4');
        } else {
            if (function_exists('appNoPage')) {
                $gp_page = appNoPage();
            } else {
                if (!LoggedIn()) {
                    $gp_page = FILE_EXISTS_INCPATH('x_home.php') ? 'x_home' : 'x_login';
                } else {
                    // KFD 3/2/07, pull vga stuff to figure defaults
                    if (vgaGet('nopage') != '') {
                        $gp_page = vgaGet('nopage');
                    } else {
                        $gp_page = 'x_welcome';
                    }
                }
            }
        }
    }
    // If they are trying to access a restricted page and are not
    // logged in, cache their request and redirect to login page
    if (!$sessok && !isset($MPPages[$gp_page])) {
        if (vgfGet('loglogins', false)) {
            fwLogEntry('1014', 'Page access w/o login', $gp_page);
        }
        gpToSession();
        $gp_page = 'x_login';
    }
    // If pos is activated and the current requested page does not
    // match what they are cleared for, redirect to login
    if (vgaGet('POS_SECURITY', false) == true && SessionGet('ADMIN') == false) {
        if (SessionGet('POS_PAGE', '', 'FW') != $gp_page) {
            gpToSession();
            $gp_page = 'x_login';
        }
    }
    gpSet('gp_page', $gp_page);
    // Make any database saves.  Do this universally, even if save
    // was not selected.  If errors, reset to previous request.
    //if(gp('gp_save')=='1') processPost();
    processPost();
    if (Errors()) {
        gpSetFromArray('gp_', aFromGp('gpx_'));
    }
    // Put Userid where HTML forms can find it
    //vgfSet("UID",SessionGet("UID"));
    //if (vgfSet("UID")=="") { vgfSet("UID","Not Logged In"); }
    // THIS IS NEWER X_TABLE2 version of drilldown commands,
    // considerably simpler than the older ones. It makes use of
    // three gp_dd variables.
    //
    // Notice how we process drillbacks FIRST, allowing a link
    // to contain both drillback and drilldown, for the super-nifty
    // effect of a "drill-across"
    hidden('gp_dd_page');
    hidden('gp_dd_skey');
    hidden('gp_dd_back');
    if (intval(gp('gp_dd_back')) > 0 && $sessok) {
        // this is drillback
        $dd = ContextGet('drilldown', array());
        $back = intval(gp('gp_dd_back'));
        if (count($dd) >= $back) {
            $spot = count($dd) - $back;
            $aback = $dd[$spot];
            gpSet('gp_skey', $aback['skey']);
            gpSet('gp_page', $aback['page']);
            $gp_page = $aback['page'];
            gpSet('gpx_skey', $aback['skey']);
            gpSet('gpx_page', $aback['page']);
            gpSetFromArray('parent_', $aback['parent']);
            if (!gpExists('gp_mode')) {
                gpSet('gp_mode', 'upd');
            }
            $dd = $spot == 0 ? array() : array_slice($dd, 0, $spot);
            ContextSet('drilldown', $dd);
            ContextSet('drilldown_top', $aback['page']);
            //ContextSet('drilldown_level',count($dd));
        }
    }
    if (gp('gp_dd_page') != '' && $sessok) {
        // this is drilldown...
        $matches = DrillDownMatches();
        $matches = array_merge($matches, aFromGP('parent_'));
        $dd = ContextGet('drilldown', array());
        $newdd = array('matches' => $matches, 'parent' => aFromGP('parent_'), 'skey' => gp('gpx_skey'), 'page' => gp('gpx_page'));
        $dd[] = $newdd;
        ContextSet('drilldown', $dd);
        ContextSet('drilldown_top', gp('gp_dd_page'));
        //ContextSet('drilldown_level',count($dd));
        // having saved the stack, redirect to new page.
        $tnew = gp('gp_dd_page');
        $gp_page = $tnew;
        gpSet('gp_page', $tnew);
        if (gp('gp_dd_skey') != '') {
            gpSet('gp_skey', gp('gp_dd_skey'));
            gpSet('gp_mode', 'upd');
        }
        // Clear search of new page, set filters to blank
        processPost_TableSearchResultsClear($tnew);
        ConSet('table', $tnew, 'search', array());
    }
    // If no drilldown commands were received, and we are not on
    // the page that is the top, user must have picked a new page
    // altogether, wipe out the drilldown stack
    if (gp('gp_page') != ContextGet('drilldown_top', '')) {
        ContextSet('drilldown', array());
        ContextSet('drilldown_top', '');
    }
    // Must always have these on the user's form.  These can
    // be retired with x_Table, they are for old drilldown
    //
    hidden("dd_page", "");
    hidden("dd_ddc", "");
    hidden("dd_ddv", "");
    hidden("dd_ddback", "");
    hidden("dd_action", "searchexecute");
    hidden("dd_skey", "");
    // Load user preferences just before display
    UserPrefsLoad();
    $dir = $GLOBALS['AG']['dirs']['root'] . 'application/';
    if (file_exists($dir . $gp_page . ".page.yaml")) {
        include 'androPage.php';
        $obj_page = new androPage();
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main($gp_page);
        if ($obj_page->flag_buffer) {
            vgfSet("HTML", ob_get_clean());
            //ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    } else {
        $obj_page = DispatchObject($gp_page);
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main();
        if ($obj_page->flag_buffer && vgfGet('HTML') == '') {
            vgfSet("HTML", ob_get_contents());
            ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    }
    // Save context onto the page.  Note that it is not really
    // protected by these methods, just compressed and obscured.
    //
    $t2 = serialize($GLOBALS['AG']['clean']['gpContext']);
    $t2 = gzcompress($t2);
    $t2 = base64_encode($t2);
    Hidden('gpContext', $t2);
    // KFD 3/7/07, give the app the final opportunity to process
    //             things before the display, while logged in.
    if (function_exists('appdisplaypre')) {
        appDisplayPre();
    }
    // ...and write output and we are done.  Assume if there was
    // no buffering that the output is already done.
    if ($obj_page->flag_buffer != false) {
        // Work out what template we are using
        index_hidden_template('x2');
        // KFD 5/30/07, send back only main content if asked
        if (gp('ajxBUFFER') == 1) {
            echo "andromeda_main_content|";
            ehStandardContent();
            echo "|-|_focus|" . vgfGet('HTML_focus');
            $ajax = ElementReturn('ajax', array());
            echo '|-|' . implode('|-|', $ajax);
            echo '|-|_title|' . vgfGet('PageTitle');
        } elseif (defined('_VALID_MOS')) {
            // This is the default branch, using a Joomla template
            // DUPLICATE ALERT: This code copied into
            //          index_hidden_x4Dispatch() above
            global $J;
            $mainframe = $J['mainframe'];
            $my = $J['my'];
            $mosConfig_absolute_path = $J['mC_absolute_path'];
            $mosConfig_live_site = $J['mC_live_site'];
            $template_color = $J['template_color'];
            $template_color = 'red';
            $file = $GLOBALS['AG']['dirs']['root'] . '/templates/' . $mainframe->GetTemplate() . "/index.php";
            include $file;
        } elseif ($obj_page->html_template !== '') {
            // This is newer style, let the class specify the template.
            include $obj_page->html_template . '.php';
        } else {
            // This is old style, defaults to "html_main.php", can be
            // set also by vgaSet() or by gp(gp_out)
            $html_main = vgaGet('html_main') == '' ? 'html_main' : vgaGet('html_main');
            switch (CleanGet("gp_out", "", false)) {
                case "print":
                    include "html_print.php";
                    break;
                case "info":
                    include "html_info.php";
                    break;
                case "":
                    include $html_main . ".php";
                    break;
                default:
            }
        }
    }
}