Esempio n. 1
0
*/
include_once 'inc/gutuma.php';
include_once 'inc/subscription.php';
include_once 'inc/newsletter.php';
// Initialize Gutuma without validation or redirection
gu_init(FALSE, FALSE);
// Acceptable public action values, i.e ones that don't require a valid session
$public_actions = array('subscribe', 'unsubscribe');
// Get posted action var which determines which function gets called
if (!is_post_var('action')) {
    gu_ajax_error(t('No action specified in AJAX request'));
}
$action = get_post_var('action');
$is_public_action = in_array($action, $public_actions);
// Check for valid session if not a public action
if (!gu_session_is_valid() && !$is_public_action) {
    gu_ajax_error(t('This action requires a valid session. Try logging in again.'));
}
// Call the appropriate function
switch ($action) {
    case 'subscribe':
        $list = is_post_var('list') ? gu_list::get((int) get_post_var('list'), TRUE) : NULL;
        $address = is_post_var('address') ? get_post_var('address') : '';
        gu_ajax_subscribe($list, $address, TRUE);
        break;
    case 'unsubscribe':
        $list = is_post_var('list') ? gu_list::get((int) get_post_var('list'), TRUE) : NULL;
        $address = is_post_var('address') ? get_post_var('address') : '';
        gu_ajax_subscribe($list, $address, FALSE);
        break;
    case 'list_add':
Esempio n. 2
0
/**
 * Attempts to authenticate the current user when parameters come from Pluxml. First checks the current session, then any stored cookies, and finally redirects to the login page
 * @return bool TRUE if session is valid, else causes exit and redirect
 */
function plx_gu_session_authenticate($name = FALSE, $username = NULL, $password = NULL, $remember = TRUE, $user = FALSE)
{
    // Check aganist specified credentials
    if (isset($name) && isset($username) && isset($password)) {
        if (plx_gu_session_check_credentials($name, $username, $password, $user)) {
            if ($remember) {
                setcookie('username', $username, time() + 60 * 60 * 24 * 7);
                setcookie('password', $password, time() + 60 * 60 * 24 * 7);
            }
            gu_session_set_valid(TRUE);
            return TRUE;
        } else {
            gu_session_set_valid(FALSE);
            return FALSE;
        }
    }
    // Check the session variable next
    if (gu_session_is_valid()) {
        return TRUE;
    }
    // Then try authenticating with cookie values
    if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
        if (plx_gu_session_check_credentials($_COOKIE['username'], $_COOKIE['password'], true)) {
            gu_session_set_valid(TRUE);
            return TRUE;
        }
    }
    gu_session_set_valid(FALSE);
    return FALSE;
}
Esempio n. 3
0
 | <?php 
    echo t('Welcome ');
    echo isset($u['connect']) ? $u['connect'] : gu_config::get('admin_name');
    ?>
 | <a href="login.php?action=logout"><?php 
    echo t('Logout');
    ?>
</a></div>
			<?php 
}
?>
			
		</div>	
		<div id="mainmenu">
			<?php 
if (gu_session_is_valid()) {
    ?>
			
			<ul>
			<?php 
    if ($_SESSION['profil'] == PROFIL_ADMIN) {
        ?>
 
			
				<li><a href="index.php" <?php 
        echo str_ends($_SERVER['SCRIPT_NAME'], '/index.php') ? 'class="current"' : '';
        ?>
><?php 
        echo t('Home');
        ?>
</a></li>
Esempio n. 4
0
/**
 * Checks to see if Gutuma is running in debugging mode
 * @return bool TRUE if Gutuma is running in demo mode, else FALSE
 */
function gu_is_debugging()
{
    return is_get_var('DEBUG') && gu_session_is_valid();
}