Hello, newsguy:
Here is the updated script to work on PHP 4.0.6, be aware of word
wrapping when copying and pasting, if you want, you can download it
from here:
http://www.qadram.com/script.zip
<?php
/***************************
Redirection script
Created by ArrayStudio for ClearHill
Date: 2003-10-12
Version: 0.1
Author: basti@arraystudio.com
http://www.arraystudio.com
***************************/
/***************************
INSTALATION
There is no special installation. You just need to copy this file somewhere
on your server and direct visitors to it.
SETUP
You have the form at the end of the file with options were user should be
redirected. Value for each option is an URL where user will be redirected
if he chooses that option. It can be either a full URL
(http://client.arraystudio.com)
or it can be just a page name if redirecting in same dir (for example page1.html).
In addition there are two configuration options below this text.
CHOICE_COOKIE - is name of the cookie that will be used to save users choice
CHOICE_COOKIE_LIFETIME - cookie duration in seconds
***************************/
//some configuration
define("CHOICE_COOKIE", "CollegeBlastSelect"); //name of the cookie
define("CHOICE_COOKIE_LIFETIME", 3600*24*30); //cookie life time in seconds
//check if we need to clear cookie
if($HTTP_GET_VARS["clear"] != "")
{
SetCookie(CHOICE_COOKIE, "", time()-3600);
Header("Location: http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["PHP_SELF"]);
exit;
}
//check if we have posted a choice
if($HTTP_POST_VARS["choice"] != "")
{
if($HTTP_POST_VARS["save"])
SetCookie(CHOICE_COOKIE, $HTTP_POST_VARS["choice"],
time()+CHOICE_COOKIE_LIFETIME);
//get choice from POST
$choice = $HTTP_POST_VARS["choice"];
}
else
{
//get choice from cookie
$choice = $HTTP_COOKIE_VARS[CHOICE_COOKIE];
}
//check if we have any choice
if($choice != "")
{
Header("Location: ".$choice);
exit;
}
//display actual page
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>CollegeBlast</title></head>
<body LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"
RIGHTMARGIN="0" background="images/mainpagebg.gif">
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
id="AutoNumber1" height="100%">
<tr>
<td width="100%">
<p align="center"><html>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="479"
id="AutoNumber2" height="267" background="images/capsule.gif">
<tr>
<td valign="top">
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
id="AutoNumber3">
<tr>
<td width="18%">
<img border="0" src="images/blank.gif" width="20" height="220"></td>
<td width="82%"> </td>
</tr>
<tr>
<td width="18%"> </td>
<td width="82%"><form method="POST" action="index.php" name="myform">
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
id="AutoNumber4">
<tr>
<td width="59%">
<p align="left">
<img border="0" src="images/blank.gif" width="20"
height="7"><select name="choice" onchange="this.form.submit()"
style="color: #000000; border: 0; font-style: normal; font-family:
verdana; font-weight: normal; font-size:10pt; background-color:
#FFFFCC">
<option value="">Chose one</option>
<option value="http://cm.collegeblast.com/">College Misericordia</option>
<option value="http://esu.collegeblast.com/">East Stroudsburg</option>
<option value="http://johnson.collegeblast.com/">Johnson College</option>
<option value="http://keystone.collegeblast.com/">Keystone College</option>
<option value="http://kings.collegeblast.com/">Kings College</option>
<option value="http://lackawanna.collegeblast.com/">Lackawanna College</option>
<option value="http://lccc.collegeblast.com/">Luzerne County Community</option>
<option value="http://marywood.collegeblast.com/">Marywood University</option>
<option value="http://nhcc.collegeblast.com/">Northampton Community</option>
<option value="http://hazleton.collegeblast.com/">PSU Hazleton</option>
<option value="http://wb.collegeblast.com/">PSU Wilkes-Barre</option>
<option value="http://worthington.collegeblast.com/">PSU Worthington</option>
<option value="http://uofs.collegeblast.com/">University of Scranton</option>
<option value="http://wilkes.collegeblast.com/">Wilkes University</option>
</select></td>
<td width="41%">
<input type="checkbox" name="save" value="1" checked></td>
</tr>
</table>
<p align="center">
<br>
</p>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
</body>
</html></td>
</tr>
</table>
</body>
</html>
If you find any problem with the script, please, don't hesitate to
request for any clarification. I will work on this answer until you
get what you need.
Regards. |
Request for Answer Clarification by
newsguy-ga
on
06 Jan 2004 08:16 PST
There is a feature where if you link to
http://www.collegeblast.com/index.php?clear=1 it should clear the
cookie and take the user to the index.php page to select a new option.
This doesn't appear to be working.
|
Clarification of Answer by
joseleon-ga
on
06 Jan 2004 08:42 PST
Hello, newsguy:
Change this line:
SetCookie(CHOICE_COOKIE, "", time()-3600);
to:
SetCookie(CHOICE_COOKIE, "");
And try to see if works by clearing the cookie, I think it's more a
cookie problem than a PHP 4.0.6 one because your way to delete the
cookie doesn't work on my PHP 4.2.3.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
06 Jan 2004 10:39 PST
That didn't work. Do you know how to work with cookies and would this
be something you could fix for me?
|
Clarification of Answer by
joseleon-ga
on
06 Jan 2004 14:17 PST
Hello, newsguy:
Yes, I know about cookies, it would be great if you post the script
you are using right now, because, for example, the links
"collegeblast.com" doesn't work and your site has different ones, that
way I can test your script on my server.
In any case, and only if I need it, I will request FTP access to your
server to test the solution.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
11 Jan 2004 12:40 PST
Hi, sorry about the lapse in time. Got busy.
Any way, the cookie still doesn't print the correct school name.
Here is the script that prints it (note that I changed the name of the
cookie but it does match the PHP script and that the table bgcolor
part isn't used:
//configuration
var cookie_name = 'CollegeBlastSch'; //this should be same as in PHP part of script
function chooseText()
{
var choice;
var text;
//get cookie
choice = getCookie(cookie_name);
//choose text
if(choice == 'http://www.collegeblast.com/cm/')
{
text = 'College Misericordia';
}
else if(choice == 'http://www.collegeblast.com/esu/')
{
text = 'East Stroudsburg University';
}
else if(choice == 'http://www.collegeblast.com/johnson/')
{
text = 'Johnson College';
}
else if(choice == 'http://www.collegeblast.com/keystone/')
{
text = 'Keystone College';
}
else if(choice == 'http://www.collegeblast.com/kings/')
{
text = 'Kings College';
}
else if(choice == 'http://www.collegeblast.com/lackawanna/')
{
text = 'Lackawanna College';
}
else if(choice == 'http://www.collegeblast.com/lccc/')
{
text = 'Luzerne County Community College';
}
else if(choice == 'http://www.collegeblast.com/marywood/')
{
text = 'Marywood University';
}
else if(choice == 'http://www.collegeblast.com/nhcc/')
{
text = 'Northampton Community College';
}
else if(choice == 'http://www.collegeblast.com/hazleton/')
{
text = 'Penn State Hazleton';
}
else if(choice == 'http://www.collegeblast.com/wb/')
{
text = 'Penn State Wilkes-Barre';
}
else if(choice == 'http://www.collegeblast.com/worthington/')
{
text = 'Penn State Worthington';
}
else if(choice == 'http://www.collegeblast.com/uofs/')
{
text = 'University of Scranton';
}
else if(choice == 'http://www.collegeblast.com/wilkes/')
{
text = 'Wilkes University';
}
else
{
text = 'No school selected';
}
return text;
}//chooseText
function chooseBg()
{
var choice;
var bg;
//get cookie
choice = getCookie(cookie_name);
//choose bgcolor
if(choice == 'http://www.collegeblast.com/cm/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_pink.jpg';
}
else if(choice == 'http://www.collegeblast.com/esu/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_pink.jpg';
}
else if(choice == 'http://www.collegeblast.com/johnson/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/keystone/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/kings/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_pink.jpg';
}
else if(choice == 'http://www.collegeblast.com/lackawanna/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_yellow.jpg';
}
else if(choice == 'http://www.collegeblast.com/lccc/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/marywood/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_green.jpg';
}
else if(choice == 'http://www.collegeblast.com/nhcc/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/hazleton/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/wb/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/worthington/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else if(choice == 'http://www.collegeblast.com/uofs/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_purple.jpg';
}
else if(choice == 'http://www.collegeblast.com/wilkes/')
{
bg = 'http://www.collegeblast.com/images/bg_sm_blue.jpg';
}
else
{
bg = 'http://www.collegeblast.com/images/bg_sm_yellow.jpg';
}
return bg;
}//chooseBg
/****************************************************************
YOU SHOULD NOT EDIT ANYTHING BELOW THIS POINT
****************************************************************/
function displayText()
{
var choice;
var text;
choice = getCookie(cookie_name);
text = chooseText();
document.write(text);
}//displayText
function setBackground(table)
{
var domDetect;
var bg;
//check if we have DOM browser (except Opera that doesn't return
valid values with getAttribute
if (typeof(window.opera) == 'undefined' && typeof(table.getAttribute)
!= 'undefined')
{
domDetect = true;
}
else
{
domDetect = false;
}
//choose bg
bg = chooseBg();
//set color
if(domDetect)
{
table.setAttribute('background', bg, 0);
}
else
{
//table.style.backgroundColor = color;
table.style.backgroundImage='url('+bg+')';
}
return true;
}//setBackground
// name - name of the desired cookie
// * return string containing value of specified cookie or null if
cookie does not exist
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}//getCookie
|
Clarification of Answer by
joseleon-ga
on
12 Jan 2004 07:50 PST
Hello, newsguy:
I thought the problem was in deletting the cookie, not in reading
it, in any case, this is a simple problem, but I would FTP access to
your server to modify the files and test it. In any case, just tell me
exactly what you want the scripts to do, I think you want:
-To have a frontpage when a first time user pick up a college to go
-Store that option in a cookie, so the next time, the user will be
redirected to the right college
-Allow delete that cookie to return to the previous state
Am I right?
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
12 Jan 2004 14:18 PST
You're almost right. The other thing I need it to do is print out the
name of the school stored in the cookie on every page as the script I
posted last is supposed to do. The problem is that it does it
sometimes but not others
|
Clarification of Answer by
joseleon-ga
on
13 Jan 2004 08:26 PST
Hello, newsguy:
Ok, in that case I will need you to send me the FTP access info to
your server, so I can edit your files and upload them to test if all
works correctly.
Google Answers prohibits to contact directly with customers, so to
send me that private info, you can create a text document with just
that info (server address, username and password) and upload the file
here:
http://www.xpde.com/upload.php
Once uploaded, I will be the only one with access to it, remember to
don't include any contact info, because that is prohibited.
If you have any question or do you want to use another method, just
tell me, cookies and PHP are very tricky and depend a lot on the
server, php version and the browser, so this is the fastest way to
solve it.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
13 Jan 2004 11:59 PST
OK the file should be there.
It now seems to get "stuck" on a school and only display that one, not changing it.
|
Clarification of Answer by
joseleon-ga
on
14 Jan 2004 01:42 PST
Hello, newsguy:
I have been checking all the features you need to get working and
here are the results:
-To have a frontpage when a first time user pick up a college to go
This feature works, if there is no cookie stored on the users
computer, the frontpage shows asking the user to pick up a college to
go and to save the selection
-Store that option in a cookie, so the next time, the user will be
redirected to the right college
If the user returns back is redirected to the college is stored on
the cookie, I have tested several colleges and it works
-Allow delete that cookie to return to the previous state
On the change school link it's present on each college:
http://www.collegeblast.com/help/change_school.htm
The link to clear the cookie works ok:
http://www.collegeblast.com/index.php?clear=1
It clears the cookie and redirects to index.php, so the user can pick
up a new college.
-Print out the name of the school stored in the cookie on every page
I have been checking the single college pages and there is no link to
the javascript code you posted, do you want me to integrate that code
inside the college pages?
If some of the features doesn't work for you, please, tell me which
browser are you using, so I can test it.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
14 Jan 2004 12:24 PST
Sorry, I forgot to clarify something. The school names of the main
school pages is not done using the script. You need to click on an
inside page, such as
http://collegeblast.com/content/business_directory/ and you'll see how
the cookie gets "stuck"
|
Clarification of Answer by
joseleon-ga
on
14 Jan 2004 15:27 PST
Hello, newsguy:
Finally I have found it, really hard to find, listen:
On the left menu options, you link to "Business directory" using this URL:
http://www.collegeblast.com/content/business_directory
And note that there is no '/' at the end? Well, your webserver,
converts that URL to this one:
http://collegeblast.com/content/business_directory/
Without the "www.", and because the cookie was set on the
www.collegeblast.com domain name, that is the reason that page cannot
read it.
To test it, just do it this:
-Select a college
-On the left, click on "Business Directory"
-You will see at the top "No school selected" and in the URL address
of the browser http://collegeblast.com
-Now click on the "[Change]" link and you will see how the school has
been read correctly and the URL address now point to
http://www.collegeblast.com
How to solve it? The easiest way is to add a trailing / to the links
that doesn't link directly to a page (like index.html, etc). That way,
the webserver will keep the user in the www.collegeblast.com domain.
I haven't been able to fix it by my self because the FTP account you
gave me it doesn't have write permissions on the business_directory,
but you can do it easily.
If not, just give me write permissions and I will do it by my self.
I hope this solves this question! ;-)
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
20 Jan 2004 07:38 PST
I fixed that but now the cookie clearing feature isn't working...
|
Clarification of Answer by
joseleon-ga
on
20 Jan 2004 07:43 PST
Hello,
Please, give write access to the account you sent me so I can fully
change your files, it will fixed in no time.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
21 Jan 2004 09:42 PST
I checked with my hosting company and you should have access.
|
Clarification of Answer by
joseleon-ga
on
22 Jan 2004 14:23 PST
Hello, newsguy:
I have been checking your site about clearing the cookie and it works for me:
-I enter http://www.collegeblast.com/index.php
-Then I select a college, for example, PSU Wilkes-Barre, with the Save
my selection box checked
-I'm redirected here:
http://www.collegeblast.com/wb/
-If I close the browser and I enter again, I get redirected to that site
-If I choose to change the college and then the link to the
index.php?clear=1 I go to the index page and I'm able to choose a
page.
Could you please tell me, what step in this process is failing, that
way I will be able to fix it.
Also, please, tell me which browser are you using, so both use the
same to reproduce the problem.
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
22 Jan 2004 19:38 PST
Well it's working now. Thanks!
|
Clarification of Answer by
joseleon-ga
on
23 Jan 2004 00:10 PST
Hello, newsguy:
Thanks for the tip!
Regards.
|
Request for Answer Clarification by
newsguy-ga
on
09 Feb 2004 09:51 PST
The clear cookie feature of the script doesn't seem to be working. I
believe it was working for awhile, but then stopped. Any ideas?
|
Clarification of Answer by
joseleon-ga
on
09 Feb 2004 13:25 PST
Hello, newsguy:
Have you modified the code of the site? I have just tested it and ir
works ok, it clears the cookie and prompts to choose a new college.
Are you behind a proxy?
Regards.
|