Author Archives: Jo Redwood

About Jo Redwood

Student at the University of Plymouth, studying digital art and technology.

404 Logging

I decided to setup my 404 page to log the wrong addresses people are attempting to use on my site to a mysql database. A simple version of the script below, add it to your 404 page and input the right login and table details.

< ?php
mysql_connect("localhost", "user", "") or die("Cannot connect to DB!");
mysql_select_db("site") or die("Cannot select DB!");

$ip = getRealIpAddr();
$address = mysql_real_escape_string($_SERVER['REQUEST_URI']);

$insert = "INSERT INTO `404_log` (`address`, `ip`) VALUES ('$address' , '$ip')";
mysql_query($insert); 

function getRealIpAddr(){
    if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
    $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
?>

getRealIpAddr function from here

Some SQL to setup the table.

CREATE TABLE IF NOT EXISTS `404_log` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `address` varchar(500) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
  `ip` varchar(20) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
  `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Catchup

I have been experimenting and working on my site continuously for the last few weeks but have not really blogged about it. The next few posts should cover:

  • 404 logging
  • Circular text
  • Modular pages
  • Comment system
  • Moving wordpress
  • Dynamic background

Remove greater than symbol from beginning of imported blogger titles and posts in wordpress

For some strange reason whenever I import blogger posts into wordpress a greater than symbol is added at the front of each post title and main text. I looked into the wordpress mySQL database and found that in the table wp_posts the columbs post_title and post_content had the error.

So I spent a while and eventually came up with two queries that removes all greater than arrows from the begining of each post and title:

UPDATE wp_posts SET post_title = TRIM(LEADING '>' FROM post_title)

UPDATE wp_posts SET post_content = TRIM(LEADING '>' FROM post_content)

And now that clears up my problem, although it would be nice to automate this.

I hope this is helpfull to someone.

IDAT106- XML Parsing

After several hours I’ve managed to cobble together some actionscript 3 to parse the XML information outputted by the program we are using.

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("data.xml"));

function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
Parse(xmlData);
}

This loads and reads the XML document and sends it to be Parsed.

This is the start of the code seeks out data by its tags and puts it into array. An if statement is used for each tag and i++; is used within the last if to cycle the array index.

var address = new Array(); ...

function Parse(Input:XML):void {
var Children:XMLList = Input.item.children();

for each (var Info:XML in Children) {

if (Info.name() == "address") {
address[i] = Info;
}
...

Inorder to load date information which comes in this form: 4/03/2010 11:53:33, into a form the times can be compared to find the greatest and lowest of all of them I used substring to extract them and then joined the data back together.

Fdetect[i] = temp.substring(11,13) + temp.substring(14,16) + temp.substring(17,19);

if (Fdetect[i] <>
style="font-size:78%;">Earliest = Fdetect[i];
}

If the current value is less then the stored lowest value then it replaces it. This allows me to automatically find the earliest and latest time for all of the data which is useful for visually representing it.

IDAT106

After weighing up the benefits of both ways of doing our project we have decided that the use of Arduino, though exciting, is over complex and that collecting the data using a laptop will allow us to focus on the visual element of our project.

After various inquiries using ardiuno for this project is possible however the original intention and motivation to have a number of small units left unattended is not achievable.

I will continue to post regarding Arduino as I would like to do a project using it at some point in the future.

IDAT101 – New Look

Over the last few days I have been working on the appearance and functionality of my website. I don’t consider this to be what I want it to look like but more as an intermediate step towards getting there.

  • Replaced H1 with digital signature using CSS, text is hidden yet keeps its SEO value.
  • Made clicking on logo link back to main page.
  • Replaced entire header with a single image.
  • Switched entire site to .php
  • Added automatic year updating functionality to copyright statement.
  • Cropped and merged a number of pages.
  • Cleaned up image locations on server.
  • Updated all links.
  • Moved navigation menu position.
  • New favicon.
  • Altered .htaccess to direct 404 errors to 404.php.
  • Removed all iframes.
  • Removed all facebook API integration.
  • Replaced invalid embedded flash code with valid code.

Known issues:

  • Navigation menu stretches vertically in IE6 & IE7.
  • Navigation menu could look better.
  • Blog page loads awkwardly in IE6-8, maybe waiting for feedburner javascript to fininsh.
  • Imported blog content needs styling.
  • Gallery and connectivity link buttons uses some inline CSS.
  • Somewhat hacky use of CSS.

To do:

  • Fix known issues.
  • Add content to portfolio and about page.
  • Reintergrate twitter API.
  • Make site more dynamic.