Weeks 13 - 15

PHP, SVG and other

Extra credit (in lieu of second quiz).

Note: We decided to give you a bit more time on Assignment #6 -- now due Monday, December 5th. Two relevant notes:
1. The file I worked on in class on Wednesday has been fixed (problems with directories and SE Linux permissions) and can be seen at http://obsidian.sru.edu/users/ddailey/silly.php.
2. I've moved the relevant file (threefull) for the assignment to obsidian and given it proper permissions so you should be able to query it (without copying it) at

The magic command used to make the file useable by scripts is 

 chcon -t httpd_sys_content_t threefull

We have to figure out a way so that everyone can present their final project orally, either on the last two days of class (Friday, Dec. 9th and Monday, Dec. 12) or during the time reserved for the final (Friday December 16th,  1 - 3 pm).

Since there are two hours on Friday the 16th, up to 10 people can present on that day. Five each will present on Friday the 9th and Monday the 12th. Presentations must be less 10 minutes (and zero seconds) per person.
Email me prior to class on Dec. 7th requesting your top two choices of days to present. Those who email earliest will get their first choice of days. People who are not among the first to email me will be assigned times based on what times are left over.

Update: The ten people who emailed me by December 2nd will present on Friday the 16th (owing to their stated preferences). The remainder of the class will present on the last regularly scheduled class: Monday Dec. 12th.

Presentations will be (M-k)/n minutes where n is the number of people in the class, M is the number of minutes in the class, k is some constant to allow for transitions.

Describe your project, what you hoped to accomplish, what you did accomplish, demonstrate the working project (on the screen). Describe problems encountered, and or what you would have hope to add to it, and whether or not you wish to continue working on it after the class has ended.

Be sure to speak up so that everyone can hear you!

Turning in the final project: make sure that you email me all source code as well as a working link to the working project.

Projects are due at the moment the period for the final exam would begin!


A bit of SVG (SVG Basics)  

Something sort of self-contained

W3C/EU course :

intro lesson  

week 2 

week 3

week 4

Standard SVG template

scalable web pages

The book

Examples galore(e)

2nd Quiz -- Monday Dec. 5th (PHP and SVG)

USMap in SVG with AJAX, PHP and JavaScript (works everywhere now, including IE/ASV !)

notes on zoomable map

Take a look at this in Opera, Firefox or IE/7/8. See if you can get it working in Chrome and Safari as well.

What we have done so far with SVG in class.....

A simple data file with states can be seen at ~ddailey/public_html/data/simplestate -- (copyright issue)

a quick start toward two person interaction  (using AJAX) (Note: this is now working properly, I think. Also the file game3.php has been moved to obsidian at /home/SRUNET/david.dailey/game3.php where you should be able to examine it.)

Mediating two person interaction

PHP exercise. Make a PHP web page which "hypertextualizes" the "database" of US place names. Specifically, using the data available on granite at /homes/ddailey/public_html/data/places2k.txt , make a page which displays eight place names (names of eight incorporated places chosen at random) and the state of each as links in a table (2 columns x 8 rows). Whenever someone clicks on a state, 8 new places are randomly selected from that state and likewise displayed in 2 by 8 format. Whenever someone clicks on a place name, all place names sharing that name are likewise displayed, unless there are more than 8 of them, in which case, 8 are chosen at random. Congratulate people for finding places that belong to more than two states, and display a list of places that users have found that share the current record for most states with a given place name -- for example "Eureka" is found in 8 states: IL, KS, MO, MT, NC, SD, TX, and UT

Happy Valley Alaska
Happy Valley Texas

"Eureka" for example, is found in 8 states: IL, KS, MO, MT, NC, SD, TX, and UT, but there placenames that appear in more states..
You may prefer the simplified file at /homes/ddailey/public_html/data/stateplacenames2000.
The original file is from http://www.census.gov/geo/www/gazetteer/places2k.html where it is discussed.
There is also a file at ST_Place created from stateplacenames2000 from the command:
 sed 's/\ [^ ]*$//;s/^../& /' $s>ST_Place (where s=stateplacenames2000)
Notes: other examples of the hypertextualization of data may be seen with these examples:

Some town studies may be seen at townstudies.htm

And...take a look at this script: http://granite.sru.edu/~ddailey/data/randplace.php

Here is some code that might help:

if (isset($_GET["S"])){
determine whether or not the variable S has been  sent (in this case, as a part of the query string)
$B=preg_grep('/FL/', $P);
search the file $P for lines matching a regular expression. $B will be an array, but indexed by the lines numbers of $P.
$vals = array();
while ($i = each($B)){
array_push($vals, $k);
Make an array, $vals, which will be indexed from 0 to count($vals) -1 instead of by the lines numbers of $P
$parts=explode(" ",$P[$vals[$r]]);
$placename=join(" ",$parts);
Removing state name from record, and then recombining the rest into a string.


Or this one (to get you started)

Here's the PHP part:

if (!isset($c)) $c=10;
for ($j=0;$j<$c;$j++){
for ($i=0;$i<3;$i++){
$W=preg_split ("/\s+/",$l[$i]);
echo $W[2];
echo "<br>";
==> bootstarts <==
6 allen 5
6 bent 1
6 chest 18
6 clif 14
6 coal 0
==> bestmiddles <==
2 al 1420
2 ampton 18
2 an 2091
2 arborn 2
2 ark 355
==> bestendings <==
2 born 11
2 bury 41
2 by 64
2 castle 4
2 chester 18
 25 new 10
25 oak 4
31 lake 24
31 wood 211
37 west 18
22 er 2297
22 th 887
26 land 322
26 wood 211
28 s 5840
9 view 72
10 field 147
12 land 322
12 wood 211
14 ville 1007