automated copy of all pages with relative paths using php / mysql - php

I have access to a website that I pay to use that has a really lame user lookup query. The information I need pertaining to users requires me to click each individual name and a modal window pops up with the info in it. I don't manage or own this site so I have no intentions of trying to access their DB directly - I just want to access the info using the (legal) means they allow.
This wouldn't be an issue if I only needed like 10 but I have to do 3200!!!!
I want to download all the info on each user page into a hosted MySQL DB. The website accesses the user pages with a javascript function and the URL looks like this ...
xxxxxxx.com/ModalReport?sharedID=0000&modalType=user
by changing the sharedID and directly using the URL in my browser, I can access each user's page (yay no modal!!!) - HOWEVER it must be running sessions because if I'm not logged in to begin with, I cannot access the page
Is there code or even an app that will access each page using the URL, copy to a db and then increment he shareID + 1 and start over and then stop when it runs out of pages?
thanks!!

Related

Pass Parameters from one PHP to Another, on Localhost, not using HTTP requests, includes, or sessions

I want to track and save to my local DB any event where my website's users click on links.
the user ID is saved in session information.
Links are structured like this: example.com/go.php?d=1234 , with 1234 being example for concrete link user want to go to.
Right now, on go.php, I use _GET and then redirect to user to the actual link (by searching another DB table to find the matching link for the d value, such as 1234.
I want the tracking to happen simultaneously, on server side only, in order to avoid slowing or undermining the redirection process of the user.
Therefore, my idea is to have go.php call another php script on my localhost - track.php.
And inside track.php do an INSERT with the user's data into another DB table, so if anything fails with the insertation, user will not be affected.
How can I pass data like the user's ID and the link ID that was clicked (and other info I plan to collect, such as user agent, resolution, referrer page, etc), under those requirements?
I can't use session since session are stored on the user's machine and I don't want user to have any interaction with this script, and even if session is stored on server, there can be multiple users who will click the same time on links and overwrite the session info I guess.
I don't want to pass info via a URL and use _GET to extract it, since I don't want to use an HTTP request, it makes no sense to use one (speed and security perspective), if everything should happen on my local host.
I don't want to use an include since like I said, if anything in the track.php code will fail, if it is included within go.php, this can cause fatal error and undermine the redirection process.
EDIT:
Is it possible for example to trigger track.php, the same way as cron jobs are triggered?
For example, If one can set a cron job like:
php /home/user/backend/track.php user_id=1 link_id=1234 user_agent="mozilla 1.7/85"
and pass parameters this way, so maybe in script I can do something like:
some-php-function(php /home/user/backend/track.php user_id=1 link_id=1234 user_agent="mozilla 1.7/85")
So maybe something like:
shell_exec(php /home/user/backend/track.php user_id=$u_id link_id=$l_id user_agent="$agent");

Similar way to PHP Sessions in Zoho Creator

A short tutorial in W3schools about PHP Sessions writes the following:
When you work with an application, you open it, do some changes, and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are or what you do, because the HTTP address doesn't maintain state.
Session variables solve this problem by storing user information to be used across multiple pages (e.g. username, favorite color, etc). By default, session variables last until the user closes the browser.
So; Session variables hold information about one single user, and are available to all pages in one application.
I would like to ask you if there is something similar in Zoho Creator. The reason why I am asking is because I have an application with 3 pages (each page has an embedded form). Each page redirects to the other (1st Page -> 2nd Page -> 3rd Page) and passes data through them via openurl. The final result is an HTML Page with the data of these 3 Pages (they have a unique ID).
Let's say that I am in the second page and for some reason (electricity blackout, do another job and close the browser) I want to escape from the application and the next time to continue from the same point, is there any way to do that??
I can suggest you next way
On first page generate unique session Id for the user and pass this id as a parameter to next page in URL. You can crypt in this id pointer to record from first form for example..

php session to check if you already redirected the user

I do not have a database.
My website will use a php class (mobiledetect.php) to find the user agent and type of browser, whereby a certain .css file is parsed. If the user prefers to view the full css site, how can I create a php session so as not to redirect the user again. So, only to ask the first php class once?
I am new to php.
Basically, I see two options that you have -- one is to just store the information locally (in the PHP session), the other is to store the user preferences in a cookie.
If you could actually show us your mobiledetect.php code, it would probably be easier to help you with actual code.

make webpage counters work in redirects

I'm writing a php program that redirects user to a page.(something like link shortener)
I want count pages visits without using mysql or etc. so I chose to work with a page counter service like histats but to make these services to work webpage has to be opened by user and a jsp or embeded flash has to be runned in user browser. but my program redirects user to another page that doesn't belongs to me and page on my domain wont be opened!
is there any way to make these counters to work?
You cannot normally force the user to call the counter URL. Especially when you redirect the client via http. You may save the hits in a plain file or any other database.
You should also know that the user maybe blocks the counter with an adblocker when you use a please wait for redirection message. Instat of redirect directly.

How can I add a parameter to the manifest file HTML5 for offline mode?

I have a web application and I want to make it run offline as well. In this application I just have a form and I am using PHP for submitting it. I am using a manifest.php file like the one described in http://building-iphone-apps.labs.oreilly.com/ch06.html .
The problem is that I need somehow to add the parameters from the form in the manifest, for caching the right file, for example the file welcome.php?name=aaaa and not the welcome.php . So I need to use a GET for the name in the manifest.php. But if I understood well the manifest file is created in the beginning before the form is submitted so the value on "name" is empty.
Is there a way to add these parameters in my manifest file for running the application offline as well?
Thanks
The only way you can do that is to list the files with their parameters in the manifest, so you would have to know all the possible parameters in advance and then use your manifest.php to spit them out, ending up with a manifest file that looks something like this:
CACHE MANIFEST
welcome.php?name=aaaa
welcome.php?name=aaab
welcome.php?name=aaac
...thousands more lines...
welcome.php?name=zzzz
NETWORK:
welcome.php
However, I strongly recommend you don't do it this way if (as it looks like) you want to present a personalised welcome page to the user. With this approach every user will download every welcome page, even though they only need to see one of them.
There are two approaches I think will work better:
1: Deliver personalised pages
If only thing which changes is this page, force the user to logon before accessing the welcome.php page, then use a session variable instead of a query parameter to deliver the personalised page. You then just need to specify welcome.php in your manifest and every user will cache one personalised version.
2: Write a full offline app
If your web app is going to have user specific data at every step you need to break down what are the common application components and what is the user data, and serve them separately. If your app is going to do anything offline it's going to be doing it with JavaScript, you should therefore use JavaScript to update the page in the browser rather than generating entire pages on the server side with PHP.
Most of your PHP pages are basically going to be templates which you will load with user data through JavaScript (you can still populate them the 'old' way for users who don't have offline capability in the browser). You will have at least one PHP page which delivers data in response to AJAX requests. For this approach you're going to need to learn about Local Storage and the various JavaScript APIs for managing the cache and detecting offline state. Once the user decides to install the offline version of your web app you download all of that user's data and put it in Local Storage, then use that data to update each page as it loads when the user is offline. Any changes made then need to be synced back to the server when the user is back online.
Due to applciation cache is loaded after the page it references to. You have to reload the cache by applicatonCache.update() when the parameters are available.
The trick to inject the parameters into the the manifest is to set cookies before invoking update(). Your serverside script gets the cookies and can generate the appropriate manifest content.

Categories