Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Explanation of the concept behind private pages?
#3
This gets it working so you can use the link to the page in the back end to view the page in the front end when logged in.

In gsconfig.php turn on site wide cookies:
Code:
# Make login cookie available sitewide.
define('GSCOOKIEISSITEWIDE', TRUE);

Then make the change suggested here http://get-simple.info/forum/post/11533/#p11533 in login_functions.php:
Change:
Code:
setcookie('GS_ADMIN_USERNAME', $USR);
to
Code:
if (defined('GSCOOKIEISSITEWIDE') && (GSCOOKIEISSITEWIDE == TRUE)) {

              setcookie('GS_ADMIN_USERNAME', $USR, 0, '/');
      } else {
              setcookie('GS_ADMIN_USERNAME', $USR);
      }

Then modify admin/inc/common.php changing:
Code:
/** grab user data */
if(!isset($base)) {
    if (isset($_COOKIE['GS_ADMIN_USERNAME'])) {
        $cookie_user_id = _id($_COOKIE['GS_ADMIN_USERNAME']);
        if (file_exists(GSUSERSPATH . $cookie_user_id.'.xml')) {
            $datau = getXML(GSUSERSPATH  . $cookie_user_id.'.xml');
            $USR = stripslashes($datau->USR);
            $HTMLEDITOR = $datau->HTMLEDITOR;
            $TIMEZONE = $datau->TIMEZONE;
            $LANG = $datau->LANG;
        } else {
            $USR = null;
            $TIMEZONE = 'America/New_York';    
        }
    } else {
        $USR = null;
        $TIMEZONE = 'America/New_York';
    }
} else {
    $USR = null;
    $TIMEZONE = 'America/New_York';
}
to not check for $base:
Code:
/** grab user data */
if (isset($_COOKIE['GS_ADMIN_USERNAME'])) {
    $cookie_user_id = _id($_COOKIE['GS_ADMIN_USERNAME']);
    if (file_exists(GSUSERSPATH . $cookie_user_id.'.xml')) {
        $datau = getXML(GSUSERSPATH  . $cookie_user_id.'.xml');
        $USR = stripslashes($datau->USR);
        $HTMLEDITOR = $datau->HTMLEDITOR;
        $TIMEZONE = $datau->TIMEZONE;
        $LANG = $datau->LANG;
    } else {
        $USR = null;
        $TIMEZONE = 'America/New_York';    
    }
} else {
    $USR = null;
    $TIMEZONE = 'America/New_York';
}

and lastly edit index.php to change:
Code:
# if page is private, check user
if ($private == 'Y') {
    redirect('404');
}
to be:
Code:
# if page is private, check user
if ($private == 'Y') {
    include($admin_relative.'cookie_functions.php');
    if (!cookie_check()) {
        redirect('404');
    }
}

This works in my environment, YMMV.

-Rob A>
Reply


Messages In This Thread
Explanation of the concept behind private pages? - by RobA - 2011-04-09, 02:16:25



Users browsing this thread: 2 Guest(s)