Website links

Topics

☀ Allotment
☀ Boating
☀ Catslide
☀ Computing
☀ Cooking on Cribbit
☀ Family and friends
☀ Mouldy Oldies
☀ Natural Philosophy
☀ New
☀ Recipe list
☀ Walking

Interactive

☀ Adham Fisher
☀ Alex's Mutterings
☀ Alex's website
☀ Alex on facebook
☀ Peter's website
☀ Jim on Ruskin
☀ cribBlog
☀ Gnomes
☀ Jason Lee-Dear
☀ Little Old Man Weekly
☀ theBloG

System

☀ About this website
☀ Contact me
☀ Site history
☀ Site statistics
☀ Visitors
☀ Updated this year
☀ Toggle handheld

Links-i-like


News & views

 BBC  Mother Jones  Boing Boing  SF Weekly  Londonist  Gothamist

Science

 Vixra LHC  LHC news  Grinding  Last word on nothing  Bad Astronomy  New Scientist

Personal sites

 10 Century  Strange History  Oxford bloggers  Wise words  Mind Hacks  Warren Ellis  Roger Marchant  Ant and Kate bike trip  Gaping Silence  On the wander  Living in London

Fun

 Sam Pepys  English Russia  Questionable content  Softer world  Money not art  Acephalus  Canals  Bats  Laughing Squid  Wobegone  Bizarre history.

Computing

 Unicode Map  w3schools  Notepad++  FamFamFam  chrispederick  A list apart  Filezilla

Valid XHTML 1.0 Transitional

-*- Website Homepage




Computing links

Computing home Banner Moving to PHP Find the favicon ASP resources html resources Password

Other links

Development history Apprentice training Under test portrait pics landscape pics

Computing

This is the computing home page.. Links to all and earlier [err heritage] posts can be accessed from the lefthand bar.

    Display random images with links
       20 October 2015       

psj20115985

coc0016.JPG

p6f0865

000pf2x7

port124074

gpa

>





As you can see from my post of 2 June, below, I was rather missing my banner of random images with links that adorn the front page of the website, and the top of this post. For a while I made do with a random image displayer but really wanted to be able to link to the underlying content as well as display the image.

Looked on the web for an instant solution and couldn't find anything that did what i wanted that didn't involve acres or java script so decided I should sort out something for myself...it seemed such an easy thing to do,

That's exactly how it turned out, two lines of php code, and the C programmer in me knows quite well that they could be reduced to just one , But [so far] I have resisted.

Wrote a quick and dirty routine to display all the portrait oriented pics and then a quick clone to display all the landscape oriented ones. Then added a bit of rampant featuritis by counting how many pics I had and then displaying a final one chosen at random. I have linked to the files here as I think it might be useful to be able to see them all with one click.

What I wanted though was a routine to display an image with its link so a bit more fiddling was needed. I already had files of html lines that displayed linked images so all that was needed was to write a routine to randomly select one of these lines from the requisite file and then stand back and grin.

Now if I can just remember how to display html code without it running I will show how the banner is produced.

The banner is made up from a number of portrait and landscape oriented pics. The mix of orientations being chosen so that the banner covers most of the page width.

Displaying the images is done by a line of html code, selected at random, from a pair of files called 'textlandscape.txt' and 'textportrait.txt'.

A line from the textlandscape file looks like this:
<a target= "_top" href= "party09.asp" ><img src="imageshomelandscape/noddy2.jpg" width="16%" alt="noddy2"/></a>

It displays the image noddty2.jpg and links it to the party09.asp page. That line is run below and displays the linked image as shown.

noddy2

All the images have been reduced in size from the originals contained in the main text for speed of loading.
The php code to select a random line from a file and cause it to be displayed is:

<?php
$piclink=file('textlandscape.txt');
echo($piclink[array_rand($piclink,1)]);
?>

The first line:
$piclink=file('textlandscape.txt');
Declares a file pointer to an array $piclink and reads the file 'textlandscape.txt' into the array.

The second line:
echo($piclink[array_rand($piclink,1)]);
Uses the array_rand() function to choose a single element of the array pointed to by $piclink and then passes it to the echo command for execution of the html string it has chosen.7

By the way, the single line version looks like this:
<?php
echo($piclink[array_rand(file('textlandscape.txt'),1)]);
?>
and does this!

blog2223







And that is quite enough rampant featuritus for now.


    Migrating to PHP
       2 June 2015       

Three years ago I set up my own webserver using Microsoft's ASP. I suppose I chose this because I had a new PC running Windows 7 and it came with it. Now I have migrated to a Unix operating system [Xubuntu] and the prospect of setting up ASP in this environment is far too daunting. So all new pages will be in PHP and older ones dealt with as they get updated, like probably never in some cases.

I have tried several options for updating, including 'instant' re-direction from the old file to the new one. Trouble with this is that it loses navigation to labels in the file and despite what it says on the tin, takes a while to actually do the re-direction. My version of PHP at any rate loads the whole file before re-directing from it.

Granted we are still running on a damp string internet connection here but the favicon post slows everthing down as it tries to find the live websites. I have often thought that the greatest thing I could do for mankind [ohh ok webkind] would be to lend [no give] my old computers to developers so that they can test their latest offerings on a real end-user platform and not the state of the art kit they are using.

The plan for the computing pages then is that new ones will be in PHP format and will contain links to the old ones via the lefthand side bar. I'll think of something different should this get to be too full, still a few years left at the present rate of updating.

So far, things have gone quite well in bringing up PHP. The main reason I chose ASP was for the content rotate utility and then Microsoft promptly depreciated it, thanks Microsoft. I've replaced it with a cloned/hacked PHP version which is OK but doesn't link when an image is clicked. I can see how to do this, I think, but I am happy enough with it as it as for now.

Of course, the real reason for wanting server side scripting was to make website maintenance easier by loading in side bars and menus etc without having to update them in every file.