Post by Mithras on Feb 13, 2007 15:03:25 GMT -8
Basically this code requires all members to view a certain page before they can view others. It's not fool-proof, but it does the trick.
This has two sections, first this section goes in the Global Header:
The red is the that the member must view in order to proceed. It can be the entire URL, or just part of it, it doesn't matter.
The blue are the URLs of the pages that will be blocked until they view the page in red. Again, you can use full URLs or parts of URLs. Make sure that each line follows the format of ['URL'],. Each line needs to have a comma after it, except the last line, which must have no comma.
Global Footer section:
This section requires no editing.
Tips/Tricks:
Minor edits to this code are allowed. DO NOT PM me for code support, that's what the Code Support board is for.
This has two sections, first this section goes in the Global Header:
<script type="text/javascript">
// Visit One Page to View Others by Mithras
// Do not repost without permission
// Global Header Section - Edit this first section
var goTo = '/index.cgi?board=yetanotherboard';
var restricted = [
['board=general'],
['board=another']
];
var forumName = 'Test Site';
// Do not edit below
function setCookie(_name,_value){
document.cookie = _name+"="+escape(_value)+";expires="+(new Date()).toGMTString().replace(/\d{4}/,"2050");
}
function getCookie(_name){
if(document.cookie.match(new RegExp(_name+"=(.+?)($|","gi")))
return unescape(RegExp.$1);
return null;
}
var show = false;
var cn = 'visited1';
for(i=0; i<restricted.length; i++) {
if(location.href.match(restricted)) {
if(getCookie(cn) == null) {
document.write('<div style="display:none;">');
show = true;
}
}
}
</script>
The red is the that the member must view in order to proceed. It can be the entire URL, or just part of it, it doesn't matter.
The blue are the URLs of the pages that will be blocked until they view the page in red. Again, you can use full URLs or parts of URLs. Make sure that each line follows the format of ['URL'],. Each line needs to have a comma after it, except the last line, which must have no comma.
Global Footer section:
<script type="text/javascript">
// Visit One Page to View Others by Mithras
// Do not repost without permission
// Global Footer Section - Do not edit
if(location.href.match(goTo)) {
setCookie(cn,'yes');
} else {
for(i=0; i<restricted.length; i++) {
if(location.href.match(restricted)) {
if(show)
document.write('</div><table width="92%" cellspacing="0" cellpadding="0" align="center"><tr><td valign="top" width="100%"><br /><a href="/index.cgi" class="nav">' + forumName + '</a> :: An Error Has Occurred<br/><table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="000000" class="bordercolor"><tr><td><table cellpadding="4" cellspacing="1" border="0" width="100%"><tr><td width="100%" class="titlebg" bgcolor="4080B0"><font size="2"><b>An Error Has Occurred</b></font></td></tr><tr><td width="100%" class="windowbg" bgcolor="EFEFEF"><font size="2">You must visit <a href="' + goTo + '">this page</a> before you are permitted to view the content of this board.</font></td></tr></table></td></tr></table><br /><br />');
}
}
}
</script>
This section requires no editing.
Tips/Tricks:
- If you want someone to have to view a page on a regular website, then you can put the entire code in the <body> section of the page that must be viewed. If you are just requiring that it be viewed, then they should both be placed next to each other. If you are going to hide part of that page, then the content to be hidden should be placed between the two sections of code.
- If you want to require your members to visit more than one page, then you can place the first section in your global header more than once, but you have to make a few modifications:
- Find this line: var cn = 'visited'; You must changed "visited" to something else. It can be absolutely anything, except visited.
- You must remove this section of coding from all but the first instance:
function setCookie(_name,_value){
document.cookie = _name+"="+escape(_value)+";expires="+(new Date()).toGMTString().replace(/\d{4}/,"2050");
}
function getCookie(_name){
if(document.cookie.match(new RegExp(_name+"=(.+?)($|","gi")))
return unescape(RegExp.$1);
return null;
}
- Find this line: var cn = 'visited'; You must changed "visited" to something else. It can be absolutely anything, except visited.
Minor edits to this code are allowed. DO NOT PM me for code support, that's what the Code Support board is for.