This topic is locked

Printing a report without having to log in

1/5/2010 4:51:24 PM
PHPRunner General questions
D
Dale author

I have searched for this to no avail. If someone can point me to a previous post, or assist, I would be greatly appreciative.
My Problem.

I generate a batch email to send to selected clients.

in the email are links, when clicked will go to the the print list produced by phprunner.

So, I do not want them to have to log in. Just click the link and phprunner runs the printed list.
It is just a printed report, so there is no reason to see or touch anything else. Just get the report in his browser. Print or close.

If they try anything with the url in the browser of course I want them directed to the login page as per normal.
I am quite sure I have seen this issue come up before, but alas I have been looking for over an hour and cannot find anything related.

Sergey Kornilov admin 1/5/2010

Enable Guest login and use 'User Group permissions' to provide guest users access to this report.

D
Dale author 1/5/2010

Perfect, thanks Sergey.

The print works now with the quest mode.

No sign in required.
I just modified the Login page to hide the <div> showing the Quest Sign on link.

D
Dale author 1/7/2010

Sorry, I jumped the gun about having success here.
What I find, if I click on the email link, it opens the browser and directly takes me to the login page.

Now if I leave the browser with the login page open, go back to my email and click the link again. THen it opens a new browser and works perfectly. Running the _print.php no problem.
I cant seem to get it to by pass the login screen and go directly to the
_print.php.
The link I produce in the email is as below.

http://www.vintbrew.com/deficiency/deficiency_print.php?mastertable=proj_trades&masterkey1=7&masterkey2=1&masterkey3=Corbetts&email=true
Is there something I can add into the url that phprunner can use to skip the login screen.
As a side note, the printed list doesnt include the master detail info on the printout. From within the application, selecting print produces the master detail just fine.

The master detail I can live with and I have ideas on how to make that work for the users that access the *_print.php via email.
I have the phprunner setup to allow guest login as previously recommended.
Any help would be appreciated as always.

J
Jane 1/8/2010

Dale,
I see what you're saying.

This error happens because $_SESSION["UserID"] is not filled. You need to open generated ..._print.php file, find thie line:

if(!@$_SESSION["UserID"])



and add following code just before:

if(!@$_SESSION["UserID"])

$_SESSION["UserID"]="Guest";


Also you need to fill $_SESSION["detailTableName_mastertable"] $_SESSION["detailTableName_masterkey1"] variables in this file:

if (@$_REQUEST["mastertable"])

$_SESSION["detailTableName_mastertable"] = $_REQUEST["mastertable"];

if (@$_REQUEST["masterkey1"])

$_SESSION["detailTableName_masterkey1"] = $_REQUEST["masterkey1"];
D
Dale author 1/8/2010

No Luck Jane,
I modified the deficiency_print.php as suggested.

When I click on it, the email link the very first time it takes me to the login page.
Leave the browser open, and click again and it works fine.
Really strange. Am I still mising something. As this is a _print.php is there something with the browser session missing.

It seems as long as that login page is loaded into the browser, then after words it works fine until you close and restart the browser.
And, the mastertable data is still not showing.
So close. Im hoping there is just a little detail that I am missing.

D
Dale author 1/8/2010

One step further. I know have the master details showing properly.

Your snippet

if (@$_REQUEST["mastertable"])

$_SESSION["detailTableName_mastertable"] = $_REQUEST["mastertable"];

if (@$_REQUEST["masterkey1"])

$_SESSION["detailTableName_masterkey1"] = $_REQUEST["masterkey1"];
I changed this to below and the masterdetails display fine.

if (@$_REQUEST["mastertable"])

$_SESSION["$strTableName."_mastertable"] = $_REQUEST["mastertable"];

if (@$_REQUEST["masterkey1"])

$_SESSION["$strTableName."_masterkey1"] = $_REQUEST["masterkey1"];

if (@$_REQUEST["masterkey2"])

$_SESSION["$strTableName."_masterkey2"] = $_REQUEST["masterkey2"];

if (@$_REQUEST["masterkey3"])

$_SESSION["$strTableName."_masterkey3"] = $_REQUEST["masterkey3"];
Now if I can just skip the login page that would be perfect.



No Luck Jane,
I modified the deficiency_print.php as suggested.

When I click on it, the email link the very first time it takes me to the login page.
Leave the browser open, and click again and it works fine.
Really strange. Am I still mising something. As this is a _print.php is there something with the browser session missing.

It seems as long as that login page is loaded into the browser, then after words it works fine until you close and restart the browser.
And, the mastertable data is still not showing.
So close. Im hoping there is just a little detail that I am missing.

D
Dale author 1/11/2010

Well, I am sitting here with my head in my hands. I spent about 3 hours yesterday, and the same today and still no resolution to skipping that login page.

Its going to be something really really silly, Im feeling.
I am about ready to just document the behavior and call it a security feature.
So just to confirm, Sergey, by adding the Guest Login and giving access to the print/export of the table to the <Guest> usergroup.

With this setup, I should just have to fill in the session userid and it should bypass the login page? (What puzzles me is why does it work on the second click on the link.?)
Any suggestions would be appreciated.

D
Dale author 1/11/2010

Well, I finally have it working. No more Login screen on the first loading of the *_print.php.
I spent all day, tracking down where the functions took me to that login page.

I got down into the dbcommon.php.
This is something that maybe you want to look at Sergey.

I found in the dbcommon file a function for the Guest login.

There it filled the $_SESSION["UserID"] with "Guest"

and the $_SESSION["GroupID"] with "<Guest>".
I found after echoing the $_SESSION["GroupID"] back onto the page, and it was Always nothing. Blank. empty. Im thinking it has to do with the <> surrounding the word guest.
THen I found it would throw me into the aftersuccessfullogin and because I have some if ($_SESSION["GroupID"] == 'site') etc etc. Because the $_SESSION["GroupID"] was blank it would

redirect to the login page.
I added and if condition to the dbcommon file to avoid aftersuccessfullogin function under certain @requests and now it is all working fine.
Confused. I am.

Bottom line, ver 5.1 build 2503 the guest $_SESSION["GroupID"]="<Guest>" resolves to blank. Im thinking this is where the problem may be.

I really dont like modifying the dbcommon file but the workaround seems to work. I have tried to change the http address after running the report and the security all seems to be there. No pages show that should. Just the print out and that's it. Perfect.
Hope this may be helpfull. Please let me know if I am way off left base with this one.