Redirect the person, who has already seen the page - html

I am looking for help for the following scenario:
I have a website1.com. I would like website1.com to be like a presentation page. I want every person who has seen the page to be redirected automatically to website2.com.
Another way to look at it:
Lets say the page on website1.com contains information, which would be irrelevant for the person, who has already seen it, therefore I want them to be redirect from the page to website2.com cause then i don't loose the visitor, since I own both of those sites.
From the prespective of the visitor:
I land on a website, which I have not visited yet, website1.com. However, if I have already been to website1.com in the past ( cookie registers it ) , then i am redirected to website2.com
Hope how i broke it down is clear for everybody.
Thank you in advance for the help.

If you are using PHP, you could do it that way at the begining of your page:
<?php
if (!isset($_COOKIE['myCookie'])){
setcookie('myCookie', true, time() + (86400 * 30));
}
else{
header('Location: http://www.website2.com');
}
?>
If you are not using PHP, your serverside language surely have a way to set cookie and the logic will be the same. Hope it helped

Related

Can you restrict meta reload?

so I'm trying to use meta reload to update my website (using the code below) and I was wondering if it was possible to make it reload once after opening the page.
<meta http-equiv="refresh" content="3" >
Why, because looking at a website that refreshes every 3 seconds is really annoying to look at. If you can help, thank you.
#David's comment (original post)
To store values without files and within the webpage. I suggest you encrypt the data because it is visible in the developers console 'local storage'
function holdArray(array){
localStorage.setItem("holdArray", array);
return true;
}
function releaseArray(){
if(localStorage.hasOwnProperty('holdArray')){
return localStorage.getItem("holdArray");
}
}
Set data
holdArray(JSON.stringify(yourvariable));
Get data
let storage = releaseArray();
All I had to do to make it update once when the page was loaded was change index.html to index.php
Thank you with all the help you guys gave me, but this is all I ended up needing to do. I still very much appreciate the effort though.

HTML injection into someone else's website?

I've got a product that embeds into websites similarly to Paypal (customers add my button to their website, users click on this button and once the service is complete I redirect them back to the original website).
I'd like to demo my technology to customers without actually modifying their live website. To that end, is it possible to configure http://stackoverflow.myserver.com/ so it mirrors http://www.stackoverflow.com/ while seamlessly injecting my button?
Meaning, I want to demo the experience of using my button on the live website without actually re-hosting the customer's database on my server.
I know there are security concerns here, so feel free to mention them so long as we meet the requirements. I do not need to demo this for website that uses HTTPS.
More specifically, I would like to demonstrate the idea of financial bounties on Stackoverflow questions by injecting a Paypal button into the page. How would I demo this off http://stackoverflow.myserver.com/ without modifying https://stackoverflow.com/?
REQUEST TO REOPEN: I have reworded the question to be more specific per your request. If you still believe it is too broad, please help me understand your reasoning by posting a comment below.
UPDATE: I posted a follow-up challenge at How to rewrite URLs referenced by Javascript code?
UPDATE2: I discarded the idea of bookmarklets and Greasemonkey because they require customer-side installation/modification. We need to make the process as seamless as possible, otherwise many of get turned off by the process and won't let us pitch.
I would suggest to create a proxy using a HTTP handler.
In the ProcessRequest you can do a HttpWebRequest to get the content on the other side, alter it and return the adjusted html to the browser. You can rewrite the urls inside to allow the loading of images, etc from the original source.
public void ProcessRequest(HttpContext context)
{
// get the content using HttpWebRequest
string html = ...
// alter it
// write back the adjusted html
context.Response.Write(html);
}
If you're demoing on the client-side and looking to just hack it in quickly, you could pull it off with some jQuery. I slapped the button after the SO logo just for a demo. You could type this into your console:
$('head').append('<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>')
$('#hlogo').append('<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" class="standard"><label for="buy">Buy Now:</label><input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif"><input id="type" type="hidden" name="expType" value="light"><input id="paykey" type="hidden" name="paykey" value="insert_pay_key">')
var embeddedPPFlow = new PAYPAL.apps.DGFlow({trigger: 'submitBtn'});
Now, I'm not sure if I did something wrong or not because I got this error on the last part:
Expected 'none' or URL but found 'alpha('. Error in parsing value for 'filter'. Declaration dropped.
But at any rate if you are demoing you could just do this, maybe as a plan B. (You could also write a userscript for this so you don't have to open the console, I guess?)
After playing with this for a very long time I ended up doing the following:
Rewrite the HTML and JS files on the fly. All other resources are hosted by the original website.
For HTML files, inject a <base> tag, pointing to the website being redirected. This will cause the browser to automatically redirect relative links (in the HTML file, CSS files, and even Flash!) to the original website.
For the JS files, apply a regular expression to patch specific sections of code that point to the wrote URL. I load up the redirected page in a browser, look for broken links, and figure out which section of JS needs to be patched to correct the problem.
This sounds a lot harder than it actually is. On average, patching each page takes less than 5 minutes of work.
The big discovery was the <base> tag! It corrected the vast majority of links on my behalf.

Generating page information depending on variable selected

I am building a site with a select tag that has all 50 states. I want to be able to have a page generated for each state selected rather than having to write 50 separate pages. Any ideas on how I would accomplish this? Thank you.
You can either load all data on page load, or via ajax, and only show the data for the current state,
or if you have a server side database/data source to pull the data from you could also just have the page deliver data for a specific state, defined by a query/GET variable, the URL would look something like:
http://mysite.com/myPage.aspx?state=ca
or
http://mysite.com/myPage.php?state=az
When the page is requested you can then have your server page populate the correct data for the current state, which would then be sent over to the client.
Generally speaking I would lean toward the server side solution, especially if your visitors will likely only visit a handful of states then there's no reason to load ALL states data. On the flip side if the data for each state is very minimal it might not make much different either way.
EDIT
I'm not aware of any specific tutorials on the web, but since this encompasses putting a few things together I'll tell you the topics that might be useful in accomplishing this.
Depending on your level of knowledge of php, or c#, or other chosen language for your server side part, research the following topics:
Read a Get variable
Switch case statements
Add variable value into parts of html, or concatenation of html strings
Optionally various database topics, (if you don't want to hard code
data into your code)
For example, your server side php page could look something like this (untested code):
<?php
switch($_GET["state"]) {
case "ca":
$pageTitle = "California";
$pageContent = "stuff about CA";
break;
case "az":
$pageTitle = "Arizona";
$pageContent = "stuff about a really hot state";
break;
...
}
....
echo '<h1>' . $pageTitle . '</h1>' . '<p>' . $pageContent . '</p>';
?>
Along with that you'd want to handle when the visitor selects a different state, and upon selection of a state load the correct page. With jQuery you could do something with the change() method.
in your html body declare you drop down list (select input) with id="stateSelectDropDown", then in your javascript (untested code):
<script type="text/javascript">
$(function() {
$("#stateSelectDropDown").change(funciton() {
window.location = "nameOfThisPage.php?state=" + $(this).val();
});
}
</script>
I apologize for any typos or bad syntax, I hope this points you in the right direction.

how to post a value to a php page in a facebook app?

I am a noob facebook app developer and I would be very grateful for a little hand-holding getting started by professionals. I created a very simple app. It's only one file (index.php) and it has an html form that posts a value back to index.php to display. It worked before I added a "share to wall" request to the authentication. Now (I guess) there is a redirection before realoading the index.php, so it gets no $_POST value and it doesn't display the entered value. I would be very grateful if somebody would actually check out my app and its code and tell me how to fix it. (I think it's important to mention that it requests permission to post to the user's wall, but actually it doesn't post anything to the wall. I want to add that functionality later.) Here is the app:
https://apps.facebook.com/webszebb/
And here is the code (screenshot):
http://webszebb.hu/indexphp.png
Thanks.
For the sake of simplicity I'd suggest doing something like:
<html header stuff>
<?php
...snip...
if ($_REQUEST['do'] == 'whatever the action is, i.e: action="?foo" would be foo here') {
print('Your previous number was ' . $_POST['my_number']);
} else {
print('form');
}
?>
But to answer your question I'm assuming the $fb->api('/me') probably redirects you.

MediaWiki: page editing allowed by creator only or with approval

I'm trying to restraint editing on the Wiki (using MediaWiki) that I'm creating as an internal project for my company.
We would like to be able to let the page creators specify none or one of the two following options:
Nobody besides the creator of this page can edit the content of this page
Anybody can edit the content of this page, but there must be an approval by the page creator before the changes are visible (whether it'd be by mail, on the wiki directly or something else - does not matter).
If the creator does not specify any of the 2 options, anybody can edit the page, and the changes are immediatly visible (default behaviour).
I've been browsing the net but I did not find an out-of-the-box solution for this. We managed to make some great custom stuff thanks to the edition of the LocalSettings file but not this.
Is there a solution for that functionality?
I don't know of an extension that would make this easy.
What I think you could do would be to take an extension like Flagged Revs or Approved Revs and make it so that instead of using groups as the determiner of approval status, it uses username. This might not be too difficult. Does this make sense?
I had the same problem as you and now i fixed it, here is the solution:
I am using http://www.mediawiki.org/wiki/Extension%3aApproved_Revs for article protection but it didn't fulfil my need it allowed the user to change the currently approved revision of the article and so the change was immediately reflected on the main page so I hacked it a bit, basically you need only one change
go to ApprovedRevs/ApprovedRevs.hooks.php
and find the following code:
static public function setLatestAsApproved( &$article , &$user, $text,
$summary, $flags, $unused1, $unused2, &$flags, $revision,
&$status, $baseRevId ) {
this is a function declaration just after it add the following code:
return false;
and it will work the way you wanted it to be i.e (the change you did will not be reflected until you approve it)