Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 10:53 am EST

Geeklog Forums

User Login for Root

Page navigation


Jay

Anonymous
I followed the instructions written within the php file. All that I get when I save, and go to the static page is a blank box where the username input field should be. No text other than:

"Last Updated Wednesday, February 07 2007 @ 08:24 PM EST; 11 Hits View Printable Version
Edit"

I have php enabled as described in the staticpages documentation. Am I missing something?
 Quote

Jay

Anonymous
Bump. Smile
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Quote by: Jay

Am I missing something?



... possibly, but I don`t know what :wink: It is working 100% o.k. with me.

I changed the instructions to this:

Text Formatted Code
// INSTRUCTIONS:

// create a static page with the ID = userlogin4root
// enable PHP (NOT return)
// make sure only ROOT can open/edit this page!
// copy this code into it ( w/o the !)
// open the page and enter any EXISTING username into the field.
// refresh the page or click on "home"


The line I changed was: "copy this code into it ( w/o the !)" And I also turned off the censormode in config.php: $_CONF['censormode'] = 0;
 Quote

Jay

Anonymous
Ah well, I can't figure it out. I'm new to geeklog, so this is my first attempt at any static page.

This is exactly how I have it setup:

Title: Root Login
Label: Root Login
Page Format: Left and right blocks
ID: userlogin4root


Text Formatted Code
include_once("../lib-common.php");
global $_TABLES, $_CONF, $_USER,$LANG01;

if (!SEC_inGroup('Root')) {exit;}

$username = '';
$uid = '';
if (!isset($_POST['username'])) {
    $out .= "Please enter a username, press submit and reload the page."
        . "You will then be logged in as that user. To log back in as root, log out and log back in with "
        . "your root username & password.<br>"
        . "<form action="{$_CONF['site_url']}/staticpages/index.php?page=userlogin4root" method="post">"
        . "Username: <input type="text" name="username" value=""> "
        . "<input type="submit">";
    echo $out;
} else {
    $username = COM_applyFilter($_POST['username']);
    $result = DB_query( "SELECT status, uid FROM {$_TABLES['users']} WHERE username='$username' AND ((remoteservice is null) or (remoteservice = ''))" );
    $tmp = mysql_errno();
    $nrows = DB_numRows( $result );

    if(( $tmp == 0 ) && ( $nrows == 1 )) {
        $U = DB_fetchArray( $result );
        $uid = $U['uid'];

        $userdata = SESS_getUserDataFromId($uid);
        $_USER=$userdata;
        $sessid = SESS_newSession($_USER['uid'], $_SERVER['REMOTE_ADDR'], $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']);
        SESS_setSessionCookie($sessid, $_CONF['session_cookie_timeout'], $_CONF['cookie_session'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']);
        PLG_loginUser ($_USER['uid']);

        // Now that we handled session cookies, handle longterm cookie
        if (!isset($_COOKIE[$_CONF['cookie_name']]) || !isset($_COOKIE['password'])) {
            // Either their cookie expired or they are new
            $cooktime = COM_getUserCookieTimeout();
            if ($VERBOSE) {
                COM_errorLog("Trying to set permanent cookie with time of $cooktime",1);
            }
            if ($cooktime > 0) {
                // They want their cookie to persist for some amount of time so set it now
                if ($VERBOSE) {
                    COM_errorLog('Trying to set permanent cookie',1);
                }
                setcookie ($_CONF['cookie_name'], $_USER['uid'],
                           time() + $cooktime, $_CONF['cookie_path'],
                           $_CONF['cookiedomain'], $_CONF['cookiesecure']);
                setcookie ($_CONF['cookie_password'], md5 ($passwd),
                           time() + $cooktime, $_CONF['cookie_path'],
                           $_CONF['cookiedomain'], $_CONF['cookiesecure']);
            }
        } else {
            $userid = $_COOKIE[$_CONF['cookie_name']];
            if (empty ($userid) || ($userid == 'deleted')) {
                unset ($userid);
            } else {
                $userid = COM_applyFilter ($userid, true);
                if ($userid > 1) {
                    if ($VERBOSE) {
                        COM_errorLog ('NOW trying to set permanent cookie',1);
                        COM_errorLog ('Got '.$userid.' from perm cookie in users.php',1);
                    }
                    // Create new session
                    $userdata = SESS_getUserDataFromId ($userid);
                    $_USER = $userdata;
                    if ($VERBOSE) {
                        COM_errorLog ('Got '.$_USER['username'].' for the username in user.php',1);
                    }
                }
            }
        }

        // Now that we have users data see if their theme cookie is set.
        // If not set it
        setcookie ($_CONF['cookie_theme'], $_USER['theme'], time() + 31536000,
                   $_CONF['cookie_path'], $_CONF['cookiedomain'],
                   $_CONF['cookiesecure']);

        if (!empty ($_SERVER['HTTP_REFERER']) && (strstr ($_SERVER['HTTP_REFERER'], '/users.php') === false)) {
            $indexMsg = $_CONF['site_url'] . '/index.php?msg=';
            if (substr ($_SERVER['HTTP_REFERER'], 0, strlen ($indexMsg)) == $indexMsg) {
                $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
            } else {
                // If user is trying to login - force redirect to index.php
                if (strstr ($_SERVER['HTTP_REFERER'], 'mode=login') === false) {
                    $display .= COM_refresh ($_SERVER['HTTP_REFERER']);
                } else {
                    $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
                }
            }
        } else {
            $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
        }
    } else {
        $tmp = $LANG01[32] . ": '$username'";
        COM_errorLog( $tmp, 1 );
        echo $tmp;
    }
}


(In a block)

PHP: Execute PHP

Access rights: Jay (me)
Group: Root

Permissions R E R E R R

Save it, it appears on my statis pages list. Click it, and it just shows a blank block. I'm sure I'm just not doing something right, but damned if I know what it is.

I have the censor mode disabled.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Did you enable php for static pages? Although I just disabled it for group static page admin and it still worked, erm?

Well, I can just tell you the differences with my installation:

Title: userlogin4root
Label: none
Page Format: Left and right blocks
Format HTML (not advanced editor))
ID: userlogin4root

Owner: Admin
Group: root

Permissions R E - - - -
 Quote

Jay

Anonymous
Yep, php for static pages is enabled. I can't think of anything else that would interfere. If I set it to NOT execute PHP, it posts all the code, and 2 input boxes right in the middle for the username (and I assume a misinterpreted submit button) but still, if it executes the php, everything is blank.

I'll keep playing with it when I have more time and see if I can get it to do something.
 Quote

tokyoahead

Anonymous
Hi,

I am the author of that static page.
try the simple approach:

start a new static page, enable php on it (not return type) and put the following code into it:

Text Formatted Code
echo "hello world";


all other settings dont matter.

if that does not work, your problem is independent of my code, and your static pages PHP code is not working as it should.
 Quote

Jay

Anonymous
Yep, that worked no problem. Still no luck with the userlogin4root one though.
 Quote

tokyoahead

Anonymous
ok now try

Text Formatted Code
if (!SEC_inGroup('Root')) {echo "you are not root!";}
 Quote

Jay

Anonymous
Ah, that showed up blank.
 Quote

tokyoahead

Anonymous
thats good. so you have everything it needs to run the static page. I wonder why it does not work then.

I am not sure what can be wrong. With what application did you open the .php-file to copy the contents into the static page?

please do not use a software like dreamweaver since it destroys the code.
use notepad or a real php editor.

please also try this new version of the static page:

http://tokyoahead.com/main/filemgmt/index.php?id=39
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I just tried your new version and it also works fine for admin and another member of group root.

Jay, are you sure you are a member of root? Could you try that as admin id=2

Access rights: Jay (me)
Group: Root
 Quote

Jay

Anonymous
I use Notepad++, which is just a better version of notepad that doesn't distort everything like windows notepad is popular for.

Also, I think that zip file is corrupt in the link for 1.1. It won't open for me.
Quote by: 1000ideen

I just tried your new version and it also works fine for admin and another member of group root.

Jay, are you sure you are a member of root? Could you try that as admin id=2

Access rights: Jay (me)
Group: Root



Jay is my admin uid=2. I just renamed it after I installed geeklog.

I tried it with another admin on my site that has root access too and no luck with that one.
 Quote

Jay

Anonymous
nevermind, got the zip to open up. Still no luck though, same blank page.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
It might be interesting to find out what is wrong.

BTW: just be careful when running around with that open zip!
 Quote

tokyoahead

Anonymous
do you get the form first, submit that and then a blank page or a blank page from the start?
 Quote

Jay

Anonymous
Blank from the start. No form, no nothing.
 Quote

tokyoahead

Anonymous
could you do the following:

copy and paste the code from the static page as you put it in there into a text-file and put it somewhere for download?
I want to make sure that you have the code there properly.

thanks
 Quote

Jay

Anonymous
Sure thing. I'm sure I messed something up, but here's how I have it in the static page

http://www.darcsystems.com/static.txt
 Quote

tokyoahead

Anonymous
yeah you messed it up... your HTML is missing the backslashes in front of the quotes.

You are supposed to have
Text Formatted Code

        . "<form action=\"{$_CONF['site_url']}/staticpages/index.php?page=userlogin4root\" method=\"post\">"
        . "Username: <input type=\"text\" name=\"username\" value=\"\"> "
        . "<input type=\"submit\">";
 


but you have

Text Formatted Code

        . "<form action="{$_CONF['site_url']}/staticpages/index.php?page=userlogin4root" method="post">"
        . "Username: <input type="text" name="username" value=""> "
        . "<input type="submit">";
 


try to copy & paste this here directly again:

Text Formatted Code

include_once("../lib-common.php");
global $_TABLES, $_CONF, $_USER,$LANG01;

if (!SEC_inGroup('Root')) {
    echo "Sorry, only a Root-User can access this page!";
}

$username = '';
$uid = '';
if (!isset($_POST['username'])) {
    $out = "Please enter a username, press submit and reload the page."
        . "You will then be logged in as that user. To log back in as root, log out and log back in with "
        . "your root username & password.<br>"
        . "<form action=\"{$_CONF['site_url']}/staticpages/index.php?page=userlogin4root\" method=\"post\">"
        . "Username: <input type=\"text\" name=\"username\" value=\"\"> "
        . "<input type=\"submit\">";
    echo $out;
} else {
    $username = COM_applyFilter($_POST['username']);
    $result = DB_query( "SELECT status, uid FROM {$_TABLES['users']} WHERE username='$username' AND ((remoteservice is null) or (remoteservice = ''))" );
    $tmp = mysql_errno();
    $nrows = DB_numRows( $result );

    if(( $tmp == 0 ) && ( $nrows == 1 )) {
        $U = DB_fetchArray( $result );
        $uid = $U['uid'];

        $userdata = SESS_getUserDataFromId($uid);
        $_USER=$userdata;
        $sessid = SESS_newSession($_USER['uid'], $_SERVER['REMOTE_ADDR'], $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']);
        SESS_setSessionCookie($sessid, $_CONF['session_cookie_timeout'], $_CONF['cookie_session'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']);
        PLG_loginUser ($_USER['uid']);

        // Now that we handled session cookies, handle longterm cookie
        if (!isset($_COOKIE[$_CONF['cookie_name']]) || !isset($_COOKIE['password'])) {
            // Either their cookie expired or they are new
            $cooktime = COM_getUserCookieTimeout();
            if ($VERBOSE) {
                COM_errorLog("Trying to set permanent cookie with time of $cooktime",1);
            }
            if ($cooktime > 0) {
                // They want their cookie to persist for some amount of time so set it now
                if ($VERBOSE) {
                    COM_errorLog('Trying to set permanent cookie',1);
                }
                setcookie ($_CONF['cookie_name'], $_USER['uid'],
                           time() + $cooktime, $_CONF['cookie_path'],
                           $_CONF['cookiedomain'], $_CONF['cookiesecure']);
                setcookie ($_CONF['cookie_password'], md5 ($passwd),
                           time() + $cooktime, $_CONF['cookie_path'],
                           $_CONF['cookiedomain'], $_CONF['cookiesecure']);
            }
        } else {
            $userid = $_COOKIE[$_CONF['cookie_name']];
            if (empty ($userid) || ($userid == 'deleted')) {
                unset ($userid);
            } else {
                $userid = COM_applyFilter ($userid, true);
                if ($userid > 1) {
                    if ($VERBOSE) {
                        COM_errorLog ('NOW trying to set permanent cookie',1);
                        COM_errorLog ('Got '.$userid.' from perm cookie in users.php',1);
                    }
                    // Create new session
                    $userdata = SESS_getUserDataFromId ($userid);
                    $_USER = $userdata;
                    if ($VERBOSE) {
                        COM_errorLog ('Got '.$_USER['username'].' for the username in user.php',1);
                    }
                }
            }
        }

        // Now that we have users data see if their theme cookie is set.
        // If not set it
        setcookie ($_CONF['cookie_theme'], $_USER['theme'], time() + 31536000,
                   $_CONF['cookie_path'], $_CONF['cookiedomain'],
                   $_CONF['cookiesecure']);

        if (!empty ($_SERVER['HTTP_REFERER']) && (strstr ($_SERVER['HTTP_REFERER'], '/users.php') === false)) {
            $indexMsg = $_CONF['site_url'] . '/index.php?msg=';
            if (substr ($_SERVER['HTTP_REFERER'], 0, strlen ($indexMsg)) == $indexMsg) {
                $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
            } else {
                // If user is trying to login - force redirect to index.php
                if (strstr ($_SERVER['HTTP_REFERER'], 'mode=login') === false) {
                    $display .= COM_refresh ($_SERVER['HTTP_REFERER']);
                } else {
                    $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
                }
            }
        } else {
            $display .= COM_refresh ($_CONF['site_url'] . '/index.php');
        }
        echo $display;
    } else {
        $tmp = $LANG01[32] . ": '$username'";
        COM_errorLog( $tmp, 1 );
        echo $tmp;
    }
}
 
 Quote

Page navigation

All times are EST. The time is now 10:53 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content