Example #1
0
 case "remember_edit_email_advanced_settings":
     $_SESSION["ft"]["edit_email_advanced_settings"] = $request["edit_email_advanced_settings"];
     break;
 case "smart_fill":
     $scrape_method = $request["scrape_method"];
     $url = $request["url"];
     switch ($scrape_method) {
         case "file_get_contents":
             $url = ft_construct_url($url, "ft_sessions_url_override=1");
             $html = file_get_contents($url);
             header("Cache-Control: no-cache, must-revalidate");
             header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
             echo $html;
             break;
         case "curl":
             $url = ft_construct_url($url, "ft_sessions_url_override=1");
             $c = curl_init();
             curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($c, CURLOPT_URL, $url);
             $html = curl_exec($c);
             curl_close($c);
             header("Cache-Control: no-cache, must-revalidate");
             header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
             echo $html;
             break;
         case "redirect":
             header("location: {$url}");
             exit;
     }
     break;
 case "process_smart_fill_contents":
Example #2
0
/**
 * Logs a user out programmatically. This was added in 2.0.0 to replace the logout.php page. It has
 * a couple of benefits: (1) it's smart enough to know what page to go when logging out. Formerly, it
 * would always redirect to the account's logout URL, but there are situations where that's not always
 * desirable - e.g. sessions timeout. (2) it has the option of passing a message flag via the query
 * string.
 *
 * Internally, a user can logout by passing a "?logout" query string to any page in Form Tools.
 *
 * @param string $message_flag if this value is set, it ALWAYS redirects to the login page, so that the
 *   message is displayed. If it isn't set, it redirects to the user's custom logout URL (if set).
 */
function ft_logout_user($message_flag = "")
{
    global $g_root_url, $g_session_type;
    extract(ft_process_hook_calls("main", array(), array()));
    // this ensures sessions are started
    if ($g_session_type == "database") {
        $sess = new SessionManager();
    }
    @session_start();
    // first, if $_SESSION["ft"]["admin"] is set, it is an administrator logging out, so just redirect them
    // back to the admin pages
    if (isset($_SESSION["ft"]) && array_key_exists("admin", $_SESSION["ft"])) {
        ft_logout_as_client();
    } else {
        if (!empty($message_flag)) {
            // empty sessions, but be nice about it. Only delete the Form Tools namespaced sessions - any other
            // PHP scripts the user's running right now should be unaffected
            @session_start();
            @session_destroy();
            $_SESSION["ft"] = array();
            // redirect to the login page, passing along the appropriate message flag so the page knows what to display
            $logout_url = ft_construct_url("{$g_root_url}/", "message={$message_flag}");
            session_write_close();
            header("location: {$logout_url}");
            exit;
        } else {
            $logout_url = isset($_SESSION["ft"]["account"]["logout_url"]) ? $_SESSION["ft"]["account"]["logout_url"] : "";
            // empty sessions, but be nice about it. Only delete the Form Tools namespaced sessions - any other
            // PHP scripts the user happens to be running right now should be unaffected
            @session_start();
            @session_destroy();
            $_SESSION["ft"] = array();
            if (empty($logout_url)) {
                $logout_url = $g_root_url;
            }
            // redirect to login page
            session_write_close();
            header("location: {$logout_url}");
            exit;
        }
    }
}