Example #1
0
/**
 * Processes loading of this sample code through a web browser.  Uses AuthSub
 * authentication and outputs a list of a user's albums if succesfully
 * authenticated.
 *
 * @return void
 */
function processPageLoad()
{
    global $_SESSION, $_GET;
    if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) {
        requestUserLogin('Please login to your Google Account.');
    } else {
        $client = getAuthSubHttpClient();
        if (!empty($_REQUEST['command'])) {
            switch ($_REQUEST['command']) {
                case 'retrieveSelf':
                    outputUserFeed($client, "default");
                    break;
                case 'retrieveUser':
                    outputUserFeed($client, $_REQUEST['user']);
                    break;
                case 'retrieveAlbumFeed':
                    outputAlbumFeed($client, $_REQUEST['user'], $_REQUEST['album']);
                    break;
                case 'retrievePhotoFeed':
                    outputPhotoFeed($client, $_REQUEST['user'], $_REQUEST['album'], $_REQUEST['photo']);
                    break;
            }
        }
        // Now we handle the potentially destructive commands, which have to
        // be submitted by POST only.
        if (!empty($_POST['command'])) {
            switch ($_POST['command']) {
                case 'addPhoto':
                    addPhoto($client, $_POST['user'], $_POST['album'], $_FILES['photo']);
                    break;
                case 'deletePhoto':
                    deletePhoto($client, $_POST['user'], $_POST['album'], $_POST['photo']);
                    break;
                case 'addAlbum':
                    addAlbum($client, $_POST['user'], $_POST['name']);
                    break;
                case 'deleteAlbum':
                    deleteAlbum($client, $_POST['user'], $_POST['album']);
                    break;
                case 'addComment':
                    addComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']);
                    break;
                case 'addTag':
                    addTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']);
                    break;
                case 'deleteComment':
                    deleteComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']);
                    break;
                case 'deleteTag':
                    deleteTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']);
                    break;
                default:
                    break;
            }
        }
        // If a menu parameter is available, display a submenu.
        if (!empty($_REQUEST['menu'])) {
            switch ($_REQUEST['menu']) {
                case 'user':
                    displayUserMenu();
                    break;
                case 'photo':
                    displayPhotoMenu();
                    break;
                case 'album':
                    displayAlbumMenu();
                    break;
                case 'logout':
                    logout();
                    break;
                default:
                    header('HTTP/1.1 400 Bad Request');
                    echo "<h2>Invalid menu selection.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
            }
        }
        if (empty($_REQUEST['menu']) && empty($_REQUEST['command'])) {
            displayMenu();
        }
    }
}
Example #2
0
require_once 'bin/common.php';
checkUser();
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title><?php 
echo $config->getTitle();
?>
</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>

	<div id="main">
	<div class="caption"><?php 
echo $config->getTitle();
?>
</div>
	<?php 
//displayLogin();
displayUserMenu($config);
?>
	  
	<div id="source"><?php 
echo $config->getVersion();
?>
</div>
	</div>     
</body>
</html>
/**
 * Processes loading of this sample code through a web browser.
 *
 * @return void
 */
function runWWWVersion()
{
    session_start();
    // Note that all calls to endHTML() below end script execution!
    // Check to make sure that the user has set a password.
    $p = LOGIN_PASSWORD;
    if (empty($p)) {
        startHTML(false);
        displayPasswordNotSetNotice();
        endHTML();
    }
    // Grab any login credentials that might be waiting in the request
    if (!empty($_POST['password'])) {
        if ($_POST['password'] == LOGIN_PASSWORD) {
            $_SESSION['authenticated'] = 'true';
        } else {
            // Invalid password. Stop and display a login screen.
            startHTML(false);
            requestUserLogin("Incorrect password.");
            endHTML();
        }
    }
    // If the user isn't authenticated, display a login screen
    if (!isset($_SESSION['authenticated'])) {
        startHTML(false);
        requestUserLogin();
        endHTML();
    }
    // Try to login. If login fails, log the user out and display an
    // error message.
    try {
        $client = getClientLoginHttpClient(GAPPS_USERNAME . '@' . GAPPS_DOMAIN, GAPPS_PASSWORD);
        $gapps = new Zend_Gdata_Gapps($client, GAPPS_DOMAIN);
    } catch (Zend_Gdata_App_AuthException $e) {
        session_destroy();
        startHTML(false);
        displayAuthenticationFailedNotice();
        endHTML();
    }
    // Success! We're logged in.
    // First we check for commands that can be submitted either though
    // POST or GET (they don't make any changes).
    if (!empty($_REQUEST['command'])) {
        switch ($_REQUEST['command']) {
            case 'retrieveUser':
                startHTML();
                retrieveUser($gapps, true, $_REQUEST['user']);
                endHTML(true);
            case 'retrieveAllUsers':
                startHTML();
                retrieveAllUsers($gapps, true);
                endHTML(true);
            case 'retrieveNickname':
                startHTML();
                retrieveNickname($gapps, true, $_REQUEST['nickname']);
                endHTML(true);
            case 'retrieveNicknames':
                startHTML();
                retrieveNicknames($gapps, true, $_REQUEST['user']);
                endHTML(true);
            case 'retrieveAllNicknames':
                startHTML();
                retrieveAllNicknames($gapps, true);
                endHTML(true);
            case 'retrieveEmailLists':
                startHTML();
                retrieveEmailLists($gapps, true, $_REQUEST['recipient']);
                endHTML(true);
            case 'retrieveAllEmailLists':
                startHTML();
                retrieveAllEmailLists($gapps, true);
                endHTML(true);
            case 'retrieveAllRecipients':
                startHTML();
                retrieveAllRecipients($gapps, true, $_REQUEST['emailList']);
                endHTML(true);
        }
    }
    // Now we handle the potentially destructive commands, which have to
    // be submitted by POST only.
    if (!empty($_POST['command'])) {
        switch ($_POST['command']) {
            case 'createUser':
                startHTML();
                createUser($gapps, true, $_POST['user'], $_POST['givenName'], $_POST['familyName'], $_POST['pass']);
                endHTML(true);
            case 'updateUserName':
                startHTML();
                updateUserName($gapps, true, $_POST['user'], $_POST['givenName'], $_POST['familyName']);
                endHTML(true);
            case 'updateUserPassword':
                startHTML();
                updateUserPassword($gapps, true, $_POST['user'], $_POST['pass']);
                endHTML(true);
            case 'setUserSuspended':
                if ($_POST['mode'] == 'suspend') {
                    startHTML();
                    suspendUser($gapps, true, $_POST['user']);
                    endHTML(true);
                } elseif ($_POST['mode'] == 'restore') {
                    startHTML();
                    restoreUser($gapps, true, $_POST['user']);
                    endHTML(true);
                } else {
                    header('HTTP/1.1 400 Bad Request');
                    startHTML();
                    echo "<h2>Invalid mode.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
                    endHTML(true);
                }
            case 'setUserAdmin':
                if ($_POST['mode'] == 'issue') {
                    startHTML();
                    giveUserAdminRights($gapps, true, $_POST['user']);
                    endHTML(true);
                } elseif ($_POST['mode'] == 'revoke') {
                    startHTML();
                    revokeUserAdminRights($gapps, true, $_POST['user']);
                    endHTML(true);
                } else {
                    header('HTTP/1.1 400 Bad Request');
                    startHTML();
                    echo "<h2>Invalid mode.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
                    endHTML(true);
                }
            case 'setForceChangePassword':
                if ($_POST['mode'] == 'set') {
                    startHTML();
                    setUserMustChangePassword($gapps, true, $_POST['user']);
                    endHTML(true);
                } elseif ($_POST['mode'] == 'clear') {
                    startHTML();
                    clearUserMustChangePassword($gapps, true, $_POST['user']);
                    endHTML(true);
                } else {
                    header('HTTP/1.1 400 Bad Request');
                    startHTML();
                    echo "<h2>Invalid mode.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
                    endHTML(true);
                }
            case 'deleteUser':
                startHTML();
                deleteUser($gapps, true, $_POST['user']);
                endHTML(true);
            case 'createNickname':
                startHTML();
                createNickname($gapps, true, $_POST['user'], $_POST['nickname']);
                endHTML(true);
            case 'deleteNickname':
                startHTML();
                deleteNickname($gapps, true, $_POST['nickname']);
                endHTML(true);
            case 'createEmailList':
                startHTML();
                createEmailList($gapps, true, $_POST['emailList']);
                endHTML(true);
            case 'deleteEmailList':
                startHTML();
                deleteEmailList($gapps, true, $_POST['emailList']);
                endHTML(true);
            case 'modifySubscription':
                if ($_POST['mode'] == 'subscribe') {
                    startHTML();
                    addRecipientToEmailList($gapps, true, $_POST['recipient'], $_POST['emailList']);
                    endHTML(true);
                } elseif ($_POST['mode'] == 'unsubscribe') {
                    startHTML();
                    removeRecipientFromEmailList($gapps, true, $_POST['recipient'], $_POST['emailList']);
                    endHTML(true);
                } else {
                    header('HTTP/1.1 400 Bad Request');
                    startHTML();
                    echo "<h2>Invalid mode.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
                    endHTML(true);
                }
        }
    }
    // Check for an invalid command. If so, display an error and exit.
    if (!empty($_REQUEST['command'])) {
        header('HTTP/1.1 400 Bad Request');
        startHTML();
        echo "<h2>Invalid command.</h2>\n";
        echo "<p>Please check your request and try again.</p>";
        endHTML(true);
    }
    // If a menu parameter is available, display a submenu.
    if (!empty($_REQUEST['menu'])) {
        switch ($_REQUEST['menu']) {
            case 'user':
                startHTML();
                displayUserMenu();
                endHTML();
            case 'nickname':
                startHTML();
                displayNicknameMenu();
                endHTML();
            case 'emailList':
                startHTML();
                displayEmailListMenu();
                endHTML();
            case 'logout':
                startHTML(false);
                logout();
                endHTML();
            default:
                header('HTTP/1.1 400 Bad Request');
                startHTML();
                echo "<h2>Invalid menu selection.</h2>\n";
                echo "<p>Please check your request and try again.</p>";
                endHTML(true);
        }
    }
    // If we get this far, that means there's nothing to do. Display
    // the main menu.
    // If no command was issued and no menu was selected, display the
    // main menu.
    startHTML();
    displayMenu();
    endHTML();
}
Example #4
0
function displayContent($wts_content, $config)
{
    if ($wts_content->isHome) {
        ?>
        <div class="post"><?php 
        displayWelcome($config);
        ?>
<div class="clear"></div></div><div class="divider"></div>
        <?php 
        displayAnnounce($config);
    }
    if ($wts_content->isWelcome()) {
        ?>
        <div class="post"><?php 
        displayWelcome($config);
        ?>
<div class="clear"></div></div><div class="divider"></div>
        <?php 
    }
    if ($wts_content->isAbout) {
        ?>
        <div class="post"><?php 
        displayAbout($config);
        ?>
<div class="clear"></div></div><div class="divider"></div>
        <?php 
    }
    if (isValidUser($config)) {
        if ($wts_content->isAnounceAdmin) {
            ?>
            <div class="post"><?php 
            displayAdminAnnounce($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isLeaveForm) {
            ?>
            <div class="post"><?php 
            displayLeaveForm($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isTimeRequestForm) {
            ?>
            <div class="post"><?php 
            displayNewTimeRequestForm($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSubmittedRequests) {
            ?>
            <div class="post"><?php 
            displaySubmittedRequests($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSubmittedRequestsNEW) {
            ?>
            <div class="post"><?php 
            displaySubmittedRequestsNEW($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isLeaveApproval) {
            ?>
            <div class="post"><?php 
            displayLeaveApprovalNEW($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isUserMenu) {
            ?>
            <div class="post"><?php 
            displayUserMenu($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isLogout()) {
            logoutUser($config, "You have logged out");
        }
        if ($wts_content->isSearching) {
            ?>
            <div class="post"><?php 
            searchPage($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isUpdateProfile) {
            ?>
            <div class="post"><?php 
            displayUpdateProfile($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isLookup) {
            ?>
            <div class="post"><?php 
            displayRequestLookup($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isUseReport) {
            ?>
            <div class="post"><?php 
            displayTimeUseReport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isPhpMyEdit) {
            ?>
            <div class="post"><?php 
            displayPhpMyEditMenu();
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isMUNIS) {
            ?>
            <div class="post"><?php 
            MUNISreport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSecLog) {
            ?>
            <div class="post"><?php 
            displaySecondaryLog($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isUserLookup) {
            ?>
            <div class="post"><?php 
            displayUserLookup($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSecApprove) {
            ?>
            <div class="post"><?php 
            displaySecondaryLog($config, $approve = true);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isResManage) {
            ?>
            <div class="post"><?php 
            displayReserves($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isUserVerify) {
            ?>
            <div class="post"><?php 
            displayUserVerify($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isMySubmitReq) {
            ?>
            <div class="post"><?php 
            displayMySubmittedRequestsNEW($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isReports) {
            ?>
            <div class="post"><?php 
            displayReportMenu($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isApprovedUseReport) {
            ?>
            <div class="post"><?php 
            approvedTimeUseReport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->subReqCal) {
            ?>
            <div class="post"><?php 
            reportsCal($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->hrEmpRep) {
            ?>
            <div class="post"><?php 
            hrPayrolReportByEmployee($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSickRep) {
            ?>
            <div class="post"><?php 
            sickReport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isEventLogs) {
            ?>
            <div class="post"><?php 
            displayLogs($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isOTRep) {
            ?>
            <div class="post"><?php 
            overtimeReport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isRadioLog) {
            ?>
            <div class="post"><?php 
            displayRadioLog($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isMyInv) {
            ?>
            <div class="post"><?php 
            showMyInventory($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isSecLogRep) {
            ?>
            <div class="post"><?php 
            displaySecLogReport($config);
            ?>
<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        if ($wts_content->isPrintRequestNo) {
            ?>
            <div class="post"><?php 
            $requests = new request_class();
            $requests->config = $config;
            $requests->showPrintFriendlyRequest();
            ?>
                <div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
        $reqURI = dirname($_SERVER['REQUEST_URI']);
        if ($reqURI != "/") {
            $reqURI = $reqURI . "/";
        }
        //popupmessage(str_replace($reqURI, "", $_SERVER['PHP_SELF']).' URI '.$reqURI.' self '.$_SERVER['PHP_SELF'].' showPrintFriendly:'.$config->showPrinterFriendly);
        if (str_replace($reqURI, "", $_SERVER['PHP_SELF']) != "printFriendly.php" && $config->showPrinterFriendly) {
            echo '<a target="_blank" href="printFriendly.php?' . str_replace($_SERVER['PHP_SELF'] . "?", "", $_SERVER['REQUEST_URI']) . '"> Print Tables</a>';
        }
        myAlerts($config, $wts_content);
    } else {
        if ($wts_content->isSearching) {
            ?>
            <div class="post"><h3>Search Results</h3>Must Login First<div class="clear"></div></div><div class="divider"></div>
            <?php 
        }
    }
}