Jump to content

Is it possible to jump into a live program and detect where the program is coming from.


Recommended Posts

For example with an IDE to run a program is there a way to put some code in the path and let it tell me where it came from like a referral?
For example lets say I am at pgm1.php and at the top of that program i put something like.

$ref = $_SERVER['HTTP_REFERER'];
echo("$ref<br>";

Result: https://www.mydomain.com/wp-admin/admin.php?page=lambo

As you can clearly see the page that we have entered the code in is referred by the URL here.

It tells me that it was last at a word press page /wp-admin/admin-php and I can go to that page and it will be the last page it was at..

So bottom line then if i add this code to the admin page and click the same button i had before.. it will tell me the file that called out the admin page.

Baslcaly I am looking for ideas on how to track the page i am now all the way back to the page with the button on it and all intermediate pages that it passes thru to get to the final destination.  It seems that to succesfully troubleshoot a fault is to follow the path of the entire job and see if any breaks...

Any thoughts or suggestions on how to best do this would greatly be appreciated.

 

I would say you are looking at it backwards. Don't try to chase it back. Instead use a session array variable and on each page that goes to a new one you want to track, add the referring page to the session array before forwarding to the next page. That array will then show the sequence of pages used to get to the current one. Alternatively you can have the new page add the referrer to the array to collect each page visited during that session.

I am sorry i am not much of a Session guy.. do i need to go spend hours on how to do sessions.. as there is maybe a 100k php files that it might wander thru so the problem is I don't know what all pages it might go thru to get there.. else I would not be trying to work backwards to get the sequence of pages that will be hit.
I need to use this process frequently so is there some content I could study that would help me setup some kind of tracking system if i wanted to find out the sequence of pages that it went thru to end at my target page.
This sounds like something that I would love to know more about.. and had not thought about sessions.. since I am not that knowledgable about Sessions.

Thanks for your help..

But I do have everyone blocked from the site... to make sure a lot of other folks are not loading those pages that i am trying to track.

 

 

 

Thank you soooo much gw1500se for the idea... I am right now as we speak in the middle of a youtube video on setting up SESSIONS..

Hopefully soon I will understand exactly what you are referring to... and will in the future be able to make frequent use of the session use.

I have played with sessions before but not great at it.. but now I an intensely studying examples so it should solve my problem.

 

OOPS! just finished lesson one.. and already realized this may not work for me...
My experience (what little it is) is that it will track all the pages the user visits... but that is not what I want its all the pages the puter visits while the user is logged in .Am I wrong but i thought when a user clicks and goes to a new page.. it will log each page he sees but the puter may have visited a dozen pages for his one.. What I mean is when user clicks on an html page it may query javascript, php, or anything to get the info he has requested.. but session will not show all those files. that he did not see.. Correct.. If so its worthless for what i need as to trouble shoot finding the pages the user say is not very valuable since to troubleshoot i have to know every page the puter say during this session... I am sure those questions will be answered as i go thru the tutorials.. but if you know the answer please tell me so I dont go thru a bunch of tutorials and find it will not work... Thanks

 

You cannot track the user back through every page they visited. You can track them as they browse your website and you can sometimes (not always!) see what page they were on immediately before the current one.

The answer is what gw1500se said: if you want to know what someone does after they click a button then track what they do after the click the button. Store each page in an array in the session, and when they get to the page you care about you can pull that array out.

This is commonly referred to as "conversion tracking" or something similar. It's common for virtually every website that has some ecommerce or monetary aspect to it in order to see what drives people to the "goal" (them spending money) and what does not. So if you want to know more about the concept, there's some keywords for you to research.

Thanks for that requinix, however I do not want to track anyone but myself as discussed above as a troubleshooting tool... But so far i have read a dozen articles and 2 youtubes and so far no one has answered my question and that is as I said above. "Can i track every page they need/use on the way to my Target page.. I know it will track any intermediate page that they land on.. howeve that would be useless in php as we know from point a to point b is only one page jump.. but they may have loaded several pages to get there....and my guess is it won't record any page that is called but not displayed... for example many html page's call a php page to tell it where to go next... but I suspect that Sessions won't log those intermediate page.. I do not mind spending hours learning all the ins and outs of Sessions but hate to do that if it will not work for what I need... and i suspect that some of the old hands at Session's can quickly say Yes or No it won't do that.
The only other things that i can think of would study the source code of any page that Sessions logs and see what all files they will be demanding in the header or any other place in the code.  Thanks..

1 hour ago, tommytx said:

so far no one has answered my question and that is as I said above. "Can i track every page they need/use on the way to my Target page..

You've been given the answer: "yes, but you have to write code to do it". Even if it's just tracking you, the process is still the same. PHP won't do all this for you.

However, if it's just you then maybe you don't need the session. Maybe just logging the information is enough and you can look through the logs?

If you want to track where someone has been on your site and what path the took, the simplest thing to do is just have some code that runs on every request which captures the current page and stores it into the current session.   For example

$_SESSION['history'][] = $_SERVER['REQUEST_URI'];

Make sure you've started the session, either here or elsewhere.

Then when you want to that information, such as in your error handler, just read the current $_SESSION['history'] value and it should contain a list of all the URLs they visited in order from oldest to newest.

You might want to enforce a limit on the history so it doesn't grow too large, say maybe only keep the last 50 URLs or so.

Personally I've never really needed this kind of information for troubleshooting.  Knowing which page the error occurred on and the $_GET/$_POST values is generally enough to resolve any issues.

  • Like 1
  • 2 weeks later...

Thanks for that information i will try to use it... however I looked at sessions, and they do tell me each page i visited but it did not seem to report those under the cover intermediate pages that were required to get to my destination.. For example many cases we have a form filled in which calls a php page or even a javascript page to interpret that and send me to my final destination.. but unless I was doing something wrong, Sessions did not show the intermediate pages.. so no way to tell if they worked or not.. unless I got to the final destination.. It shows page 1 and page 2 and page 3 etc but if an undercover page was needed it did not show that.  Thanks the ideas i will keep working with it.. I guess I need something like running the page in a php IDE but haven't had much luck running an IDE on a monstor program..... Thanks Again.

 

My problem is that no one actually visited those pages the program pulled from them to get information so that it knows what next page to send you to..

Are you saying that if if do the session correctly it will also show pages that no one visited.. since when those pages were used by the page that was visited noone actually visited that php or javascript or java page ... so if I am troubleshooting i have no idea those sub pages were used unless i study each page that was visited to see if those pages called any other pages....does that make sense.... Again lets say I do not end up at my target page... so I have no indication that its not a visited page but an unvisited page that may be the troublemaker... . maybe i am making this too hard..
Its possible that i might use Sessions and find out that i visited 10 pages but to get to the 10 page it may have required 20 total page accesses and the other 10 would not be listed so that i now where the problem is...
I may be able to pull them out of the logs that identify every page activity with IP since even the sub internal pages will be logged by ip in the master log..
And i can block out all other traffic via htaccess so that no one else gets in so i will be tracking just one IP making it simpler...
Maybe I will just write this one off as too complicated unless i can get all the questionable pages into an IDE so that every move can be tracked logged and stopped at any point i choose.

 

 

gw1500se not pulling the pages the pages i visit pulls them...many pages you land on call on php, javascript etc to decide where to take you next but the Session will not log those pages since i did not visit them the page i am on visited them.  So to troubleshoot better you would need to see not only a list of pages you visited and logged into Sessions you would need to be aware of any other pages used to get you to your target..as anyone could have causes you to fail to reach the target.

dodgeit  sorta.. notall incljuded but have to know of any classes in the include that was used but more importantly files that were called by the page i am on.. like when you fill out a form many times it calls a php page that i never see never log to enter data into the data base... so if i don't know that happened I do not know that page could be part of the problem..

The only way I know of to get a list of all those pages would be to open the source and look for files being called internally that will not long on a Session list.

 

The whole point of the OP's thread is really, "How to debug" (troubleshoot). All of the answers provided are responses to the OP's attempted solution to debugging. (XY Problem)

OP, make sure you have error reporting and logging turned on. Php is more than happy to tell you exactly what is wrong and what line and file the problem is. The Php and server error logs are your friend.

Edited by benanamen
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.