I have a page called snow.php. I want to disable people from being able to see my webpage if they type in www.mysite.com/snow.php unless they are linked from another page. So if I have another page called about.php and link to snow.php they'll be able to see it.
What you want is how to prevent hotlinking. Here is a small tutorial: http://www.hongkiat.com/blog/smarter-way-to-prevent-image-hotlinking-with-htaccess/
This method isn't 100% reliable, but you can use $HTTP_SERVER_VARS['HTTP_REFERER'] to get the current page that the user came from to access snow.php.
Related
I'm trying to make a page with some links and when somebody clicks on a link, the score count will go up.
How can I find out the visitor who has really seen the page related to link? But not just click the link and close the page for score...
really seen means: page loads completed.
and my links opens in new window.
any solution?
You cant really see pages that aren't in the same domain. Chrome even puts them in a separate thread.
Back in the day you could have used a CSS exploit talked about here: https://developer.mozilla.org/en-US/docs/Web/CSS/Privacy_and_the_:visited_selector
If you really want to make a page with this kind of functionality you will have to make a browser plugin/extension.
You can include a nonce token in the link, and post that token to the server, render the page embedding that same token in some javascript and have the javascript post back the token when the page is done rendering. Seems kinda overkill though.
The only thing I could thing of is maybe make the link to like a redirect page on your site and then you could control to see if the page was loaded and then like after the page was loaded redirect to the actual webpage to link is intended. This way you know for sure that the user waited to view the webpage.
Other than that I don't think there is any other way for you to go about this.
Let's say you have a link on your site and when you click that link it brings you to a different site. A site that you do not own and I would like it to have a "onclick" already activated maybe from a script that redirects to that link. Is this possible?
Simple answer NO. If possible it would be called 'mousejacking' :)
Setting window.location.href to a target link URL in javascript will, for most browsers, redirect the browser to the specified URL.
If you're specifically trying to make a link on your site redirect the user to a Google Search, read here.
There is almost no good reason to wrap an external site that you do not own in a frame. That kind of stuff is usually considered shady/malicious.
We have an application writted in PHP. Its main view is for example: /pages/index.
Now when the user clicks on certain links, it pulls in other Views via ajax. ie. a call may look like /pages/publish, so the PHP outputs the relevant html for the publish section back to the index view.
The problem we have is we'd like to be able to give the user the option of refreshing and seeing the same view as before. So, my initial thought is this, when we use .load() in jQuery, to take the URL its going to load and store it somewhere to be read by the PHP if the user refreshes. Is the best way to do or can someone think of a better way to do this whole thing?
Check out jQuery.address which should solve your problems! It allows AJAX loading of new pages, and will update the address bar accordingly. If a user saves this URL and reloads it, the script on the page can then load the correct page.
Alternatively, if you're HTML5-only, then you can try history.pushState() which will modify the URL without using the hash symbol, but support isn't 100% yet. (I don't think... it certainly behaves oddly on iPad from my experience.)
I know this is a strange thing to want to do, but...
How can I place a photo at the top of someone else's webpage ("Page B") -only- when a visitor links there from my page ("Page A")? I have permission to do this, but with certain limitations: my code needs to be in one location on Page B, and I can't make major changes to Page B. I cannot use Page B's server to run PHP, but I can run PHP on Page A's server.
The photo needs to open automatically with the rest of the Page B, and not require any user input to show up.
This is a unique vendor/retailer situation, so unfortunately I can't provide the urls.
Thanks for any help.
In PHP, you'd do something like:
<?php
if($_SERVER['HTTP_REFERER'] == 'http://www.yoursite.com/referringpage.html')
{
printf('<img src="yourbutton.png">');
}
?>
Which is very limited because:
It will only work for a referring single page (referringpage.html) and not otherreferringpage.html
It will only work for a single landing page. If the user navigates off of the page, then back (not through browser's back), the button will not show up.
To solve the first you could do a substring of the referrer, e.g.
<?php
if(substring($_SERVER['HTTP_REFERER'],0,24) == 'http://www.yoursite.com/')
{
printf('<img src="yourbutton.png">');
}
?>
To solve the second you could set session variables (except then you'd need access to the very top of the "outermost" page -- which doesn't sound like an option.)
Depends on the design of the page.
Lets say,
If the page is divided into frames, then you can use iframe.
if It's a single page, try have a separation with div tag. Insert the html into Div Tag.
If the above two points won't help you,give an idea of how the page is designed
I think a simple answer would be to write a html page (lets call it linkPage) that has the image/text/div or whatever you want to display on the top and then include an iframe that would cover the rest of the page using css. You could pass the page you are linking to as a GET or POST parameter to the linkPage and then set the src of the iframe to that url.
There are probably other ways of doing this that are more complicated / seamless but this would be the easiest, quickest way to get it done.
I just wanted to know, is there any possible way to change the URL that appears in the address bar of a webpage dynamically? Like, maybe there are two buttons on the webpage, and when the user clicks one it will (or won't it does not matter) refresh the page and the url will be mysite.com/page1, or if the user clickes the second button, the url that appears in the address bar will be mysite.com/page2?
I do not need it to chaneg the domain, just the part after.
Just wanted to say, that I DO NOT want to go to another page. This must be done on one page. It does not matter if it is done with JS, PHP, or via the .htaccess file, but it must do this with only one page.
Outside of changing the .location you only really have control over the window.location.hash.
window.location.hash = "boo"; http://mysite.com -> http://mysite.com/#boo
This is the only way to not go to a new page while changing the URL. All other methods will refresh the page or redirect the page:
window.location redirects user when changed
window.location.pathname redirects user when changed
window.location.search redirects user when changed
window.location.hash does not redirect user when changed
You can also just change the non domain path by using a relative url:
window.location = "page1"; // include forward-slash if necessary
// goes to http://somesite.com/page1
You can definitely (and easily) serve the same page off both /page1 and /page2 and have the buttons navigate respectively to one and the other -- "refreshing the page", as you say (i.e. loading it up again from the server, or browser cache), and of course change accordingly what appears in the address bar, too. However, I don't see what's the point of doing that.
I don't quite understand what you want.
Is it that in both cases, you want the same page to be shown but with different urls ?
In that case, you could write a .htaccess file to redirect to the same page for both /link1 and /link2 and point the button to either of the links.
Just to update this question in case others come along.
This can now be handled via javascript using pushState(). There's a couple of libraries (such as History.js) that aim to ease implementation across different browsers currently without proper support. However, if you'd like see a simple usage example without the use of such libraries, feel free to check out the following article on Hawkee
Dynamically change URLs using Push and Popstate