Log in

View Full Version : need a script for a non profit org



FyshY25
01-11-2009, 08:14 PM
I am put in charge of building a web page for my schools Student Education Association (SEA). Well what I need is a javascript of some sort that will display Text and Links. I am using this for a news frame and i don't want to use an IFrame. I want to be able to update one file (new.js) or what ever and it display on all my pages. make since? I am open to ideas of easyer was of doing this also... Im not the best with codeing but my teacher sees me as the school geek and i was roped into doing it. Thank you for your help

Snookerman
01-11-2009, 08:42 PM
Can you use PHP? If yes, then you could use include() or require(), take a look at these articles:
http://www.w3schools.com/PHP/php_includes.asp (http://www.w3schools.com/PHP/php_includes.asp)
http://se2.php.net/include/ (http://se2.php.net/include/)

Good luck!

FyshY25
01-11-2009, 09:06 PM
I don't know what there server will allow or will not. That is why i want to keep it simple. I just want to know how to display Links and Text in a simple java array. I have my array defined
var news=new Array()

news[1]=' news one'

news[2]=' two '

news[3]=' what ever'

var whichquote=Math.floor(Math.random()*(quotes.length))
document.write(quotes[whichquote])

i have stolen this java from a random quote gen. and i want to make it display array 1 through what ever number i need. And can i add
<a href="whatever.html">link</a>
in this array or would it need to look something like this

<a href=\''whatever.html\''>link</a>

FyshY25
01-11-2009, 09:09 PM
I don't know what there server will allow or will not. That is why i want to keep it simple. I just want to know how to display Links and Text in a simple java array. I have my array defined
var news=new Array()

news[1]=' news one'

news[2]=' two '

news[3]=' what ever'

var whichquote=Math.floor(Math.random()*(quotes.length))
document.write(quotes[whichquote])

i have stolen this java from a random quote gen. and i want to make it display array 1 through what ever number i need and not a random. And can i add
<a href="whatever.html">link</a>
in this array or would it need to look something like this

<a href=\''whatever.html\''>link</a>
BTW im not getting payed for this or anything ... just a thanks so I don't want to learn any thing new just for this. But if someone could set it all up for me i would give them a big fat thanks too . =)

bluewalrus
01-11-2009, 09:12 PM
Try this to see if you have php. Open any editor and type this in (paste).

<?php
echo "You have php!";
?>

Then save it as php.php and put it on your server then open that page if you get the message You have php! then you have php.

FyshY25
01-11-2009, 09:26 PM
http://bob.ivytech.edu/~fysh/test.php
you tell me

Twey
01-11-2009, 09:29 PM
Yes, some form of server-side scripting is the way to go. You can do it with Javascript, but it is complex and/or non-standard, and will present a problem for users without Javascript enabled. It would be better to maintain it on each page yourself than to alienate a portion of your users. You could also generate the pages yourself on your development machine, using server-side scripting or a tool like GTML (http://www2.lifl.fr/~beaufils/gtml/) or the page template model found in tools like Dreamweaver.

The URL you showed above suggests that you do not have PHP, but your server does appear to have FrontPage extensions enabled. These will allow a very basic form of server-side scripting. You could also check for SSI with a test.shtml page:
<!--#echo var="REMOTE_ADDR" -->This should display your IP address. If it doesn't display anything, you don't have SSI.

Snookerman
01-11-2009, 09:29 PM
That means you don't have php.. =(

FyshY25
01-11-2009, 09:31 PM
so how can i do this ? currently i am using the IFRAME Scroller script but i keep getting a warning when i open it with IE and i don't want ppl to miss the content because it was not allowed. see for yourself http://bob.ivytech.edu/~fysh/

FyshY25
01-11-2009, 09:42 PM
okay the shtml did work .... now what ?? lol Thank you all for being so helpful

Twey
01-11-2009, 10:11 PM
If SSI works, then you can make a file foo.txt with some contents, then in a .shtml page (path assumes the file to be in the same directory, adjust it if not):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Foo</title>
</head>
<body>
<p>
<!--#include file="foo.txt" -->
</p>
</body>
</html>The most common problem that results from this is invalidity of the page, since people forget that the external file is pasted in verbatim. Make sure you check your pages continually with the validator (http://validator.w3.org/) during development.

FyshY25
01-14-2009, 04:33 AM
Okay the SSI is working great ! Thanks so much. But i have a question. I am going to have a news menu on the right with links to different things up and coming. Is there any way to build one news page and have a different <!--#include file="whatever.txt" --> based on if they clicked the whatever link.

I don't feel like im explaining my self right. To make life easier i would like to make a News.shtml page for all my news stories. Then if they click on the first link it takes time to News.shtml with the #include file=firstlink.txt
then if they click the second link it takes them to News.shtml with the #include file=secondlink.txt ?
i hope i am explaing my self right. and thanks for helping a n00b

Twey
01-14-2009, 06:30 AM
Maybe try this:
<!--#include virtual="${QUERY_STRING}.txt" -->If, for example, you go to News.shtml?firstlink, it will include firstlink.txt; if you go to News.shtml?secondlink, it will include secondlink.txt. Note the use of virtual rather than file here: this causes the request for the include to be interpreted as if it had come from the client, so only files accessible from the browser anyway are available. This is a vital security measure to stop someone from accessing, say, News.shtml?..%2f..%2fsecret_text_file and gaining access to potentially sensitive files outside the document root.

FyshY25
01-15-2009, 02:41 AM
Okay the SSI stuff is working great ! I have now only ran into one problem ... My IE will not show images but my FF will. I was wondering if anyone else could see it theirs dose it to. The URL is
http://bob.ivytech.edu/~fysh/


Also while fiddling around on the server I found this about PHP

PHP on Bob

Bob supports PHP, but our configuration is different from what you may be used to. The sole reason for our specific configuration is security (the explanation of this is outside the scope of this document). What we do to solve the problem is execute all PHP scripts just like they were CGI scripts, which forces them to execute with the privilege of the owner.

To get your PHP code working on Bob, follow these directions:

1. Write your PHP code just like you would ordinarily.
2. Move the PHP file(s) into your cgi-bin directory, ~/public_html/cgi-bin
3. Make the file(s) executable: chmod 700 file.php (700 is quite restrictive but more secure than other modes. If you require group or world readability for some reason, you can enable that too.)
4. Add a line to the top of each PHP script that needs to be executed: "#!/usr/local/bin/php" This is the part that actually makes this executed like a CGI script. That "shebang" line tells the shell what to use as an interpreter, in this case, the PHP interpreter. DO NOT add this file with a windows-based editor and then copy it over (read up on Windows vs. UNIX end-of-line characters) as it probably won't work -- use a UNIX editor.

Your code should now execute just like any other PHP script, only now it'll execute with your privileges.

what will this allow me to do and use?

Twey
01-15-2009, 12:14 PM
It will give you a lot more control over your pages. While SSI is just a quick interface to allow you to do some basic stuff, PHP is a fully-fledged programming language (if a fairly unpleasant one) and will allow you to write complex logic for your pages.

I don't have IE available to check out your images right now, but I do suggest you take a look at my Big List (http://dynamicdrive.com/forums/showpost.php?p=158839&postcount=1337). Your code runs afoul of a few of these.

Additionally, you have a redundant frameset. It's completely unnecessary — index.shtml should display as an index page just like index.html does, and if not you should direct visitors to it rather than using that nasty (and invalid in Strict) frameset — welcome page anybody? Frames have several inherent accessibility problems, mostly stemming from the fact that they break the 'page' model of the Web, and where they are used the webmaster must provide equivalent content in the <noframes> element, which you have failed to do.