Categories
Wordpress

Updated WordTube code

Just discovered that updating a plug-in deletes any spare files in its directory.

As a result, my hack to the Wordtube plugin disappeared.

This messed up my solution to the Wordtube streaming playlist problem.

To avoid having to re-upload my re-edited version of the myextractXML.php file every time the plug-in is uploaded, here it is again:

<?php
/*
+----------------------------------------------------------------+
+   wordtube-XSPF XML output for playlist
+   by Alex Rabe reviewed by Alakhnor
+   required for wordTube
+----------------------------------------------------------------+
*/


// look up for the path
if ( !defined('ABSPATH') )
    require_once( dirname(__FILE__) . '/wordtube-config.php');

global $wpdb;

// get the path url from querystring
$playlist_id = $_GET['id'];

$title = 'WordTube Playlist';

$themediafiles = array();
$limit = '';

if (substr($playlist_id,0,4) == 'last') {
    $l= (int) substr($playlist_id,4);
    if ($l <= 0) $l = 10;
    $limit = ' LIMIT 0,'.$l;
    $playlist_id = '0';
}
// Otherwise gets most viewed
if ($playlist_id == 'most') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE counter >0 ORDER BY counter DESC LIMIT 10");
// Otherwise gets mp3
} elseif ($playlist_id == 'music') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE file LIKE '%.mp3%' ORDER BY vid DESC");
// Otherwise gets flv
} elseif ($playlist_id == 'video') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE file LIKE '%.flv%' ORDER BY vid DESC");
// Shows all files when 0
} elseif ($playlist_id == '0') {
    // Updated to work with version 3.6 of the database
    $themediafiles = $wpdb->get_results( "SELECT * FROM $wpdb->wordtube ORDER BY vid DESC ".$limit );
// Otherwise gets playlist
} else {
    // Remove all evil code
    $playlist_id = intval($_GET['id']);
    $playlist = $wpdb->get_row("SELECT * FROM $wpdb->wordtube_playlist WHERE pid = '$playlist_id'");
    if ($playlist) {
        $select  = " SELECT * FROM {$wpdb->wordtube} w";
        $select .= " INNER JOIN {$wpdb->wordtube_med2play} m";
    // Updated to work with version 3.6 of the database
        $select .= " WHERE (m.playlist_id = %d" ;
        $select .= " AND m.media_id = w.vid) GROUP BY w.vid ";
        $select .= " ORDER BY m.porder {$playlist->playlist_order} ,w.vid {$playlist->playlist_order}";
    // Updated to work with version 3.6 of the database
        $themediafiles = $wpdb->get_results( $wpdb->prepare( $select , $playlist_id ) );
    // End update
        $title = $playlist->playlist_name;
    }
}

// Create XML / XSPF output
header("content-type:text/xml;charset=utf-8");
   
echo "\n"."<playlist version='1' xmlns='http://xspf.org/ns/0/'>";
echo "\n\t".'<title>' . esc_attr($title) . '</title>';
echo "\n\t".'<tracklist>';
   
if (is_array ($themediafiles)){

    foreach ($themediafiles as $media) {
       
                $creator = esc_attr(stripslashes($media->creator));
                if ($creator == '')
                    $creator = 'Unknown';
                if ($media->image == '')
                    $image = get_option('siteurl') . '/wp-content/plugins/' . dirname( plugin_basename(__FILE__) ) . '/images/wordtube.jpg';
                else
                    $image = $media->image;
                $file = pathinfo($media->file);
// Added by MT starts
                $mediafile = $media->file;
                if (substr($mediafile, 0, 4) == 'rtmp') {
                    preg_match('/^(.+)\?id=(.+)/', $mediafile, $match);
                    if (!empty ($match)) {     
                        $streamer = $match[1];
                        $mediafile = $match[2];
                    }
                }
// ends
        echo "\n\t\t".'<track>';
        echo "\n\t\t\t".'<title>' . esc_attr( stripslashes($media->name) ) . '</title>';
        echo "\n\t\t\t".'<creator>' . esc_attr($creator) . '</creator>';
        echo "\n\t\t\t".'<location>' . esc_attr($mediafile) . '</location>'; //modified by MT
// Added by MT
        if(!empty($streamer)):
            echo "\n\t\t\t".'<meta rel="streamer"/>' . esc_attr($streamer) . '';
        endif;
// ends
        echo "\n\t\t\t".'<image>' . esc_attr($image) . '</image>';
        echo "\n\t\t\t".'<annotation>' . esc_attr( stripslashes($media->description) ) .  '</annotation>';
        echo "\n\t\t\t".'<id>' . $media->vid . '</id>';
        echo "\n\t\t\t".'<counter>' . $media->counter . '</counter>';
        echo "\n\t\t\t".'<info>' . esc_attr($media->link) . '</info>';
        echo "\n\t\t".'</track>';
    }
} else {
    print_r($themediafiles);
}
     
echo "\n\t".'</tracklist>';
echo "\n"."</playlist>\n"; 

?>

Updated again!

This code was further updated on October 16, 2013 to reflect this change to the WordPress API.

Categories
Campaign Elections QR codes Technology

QR-codes – making the UK’s top ten

Just over two years ago, I posted a couple of blog-posts about QR codes – the 2-d bar-codes that can be read by some mobile phones, and got some rather robust feedback on one where I expressed some scepticism about their future.

During the election, the idea of a Twitter poster came up, and, more for amusement than anything else (although I also wanted to say thank you to my supporters on Twitter), we produced some – and included a QR-code on them.

Could these be the geekiest posters in the UK? :-) #gomartintod #qr

Imagine my astonishment when I got an email today telling me about a blog-post on the QRazyStuff’s Blog that had put these posters into the Top 10 UK advertisers using QR Codes in 2010.

I’m flattered! And I shall wear my honorary membership of the QRazyClub with pride!

Just for the record, there are two  corrections that need to be made to the original QRazyClub article: I was only ever the Lib Dem candidate – and the tax-payer never paid a bean for our posters!

Categories
Tuition Fees

A bit of historical perspective on today’s student demonstration…

I was in Paris on business today so missed the student demonstration, but I didn’t miss the one in 1984. I even kept some press cuttings of it.  Here’s the report of the Cambridge Evening News on Friday November 30th, 1984:

Students join protest rally

NINE coaches of Cambridge students joined a rally in London in protest at Government proposals to cut student grants.

Students from both the university and the Cambridgeshire College of Arts and Technology joined the rally outside Queen Elizabeth Hall in London, which was organised by the National Union of Students.

They were protesting against the new proposals which would include the abolition of a minimum grant, a lower than inflation annual increase in grants generally, and the introduction of payment by families of students’ tuition fees.

Martin Tod, deputy president of the Cambridge Students Union, said he believed the protest might make the Government rethink the proposal to make families pay students’ tuition fees.

Condemnation

“This is as bad as asking parents to pay for their kids to go to school, and we hope to show the Government how badly it has been received,” he said.

The rally came after news that the university’s governing body, the Council of Senate, had added its voice to the condemnation of the cuts.

As well as agreeing to write to Sir Keith Joseph expressing protest, the Council of Senate agreed to refund £73 to the Cambridge Students Union spent on hiring halls for last week’s student protest.

And here’s the report from Stop Press – the Cambridge student newspaper at the time:

London rally attracts thousands

BY ANNE WARING AND CLAIRE HARCUP

Student protestors brought areas of the city of London to a standstill on Wednesday as they marched towards Downing Street and the Palace of Westminster. The march followed a rally organised by NUS to protest against projected grant cuts by the Government, and the introduction of means tested tuition fees.

According to NUS 30,000 students assembled on the South Bank for rallies taking place in the Queen Elizabeth Hall and nearby Jubilee Gardens. Police estimates put the number at 8000.

The meeting was addressed by Phil Woolas, NUS President; Frances Morrell, Leader of the Inner London Education Authority; Fred Jarvis, General Secretary of the National Union of Teachers; and by Clifford Giles, pensioner and parent.

In a torchlight procession the demonstrators attempted to cross Westminster Bridge where most of the day’s 180 arrests took place, after clashes with the police. After letting small groups on to the Bridge, the police stepped in to prevent further access. Other students found alternative routes across the The mes, although Waterloo and Lambeth Bridges were also sealed off, causing massive traffic congestion.

The day’s action culminated in a sit-down protest in Whitehall of about 600 students as they tried to deliver 28,000 protest letters to the Prime Minister. After half an hour, the crowd was moved on to Trafalgar Square by police.

The much publicised violence of the demonstration has been attributed both to inadequate organisation on the part of NUS and the heavy police presence. NUS clearly underestimated national support for the day’s action from all sections of higher education. The rally’s organisers had anticipated a turnout of 3,000, yet Leeds University alone filled 38 coaches with demonstrators. Frustration built up as many students felt that the march would not begin before dark, and many of those in Jubilee Gardens moved off before NUS President, Phil Woolas, began to speak.

Martin Tod, Deputy President of CSU, whilst agreeing that organisation was “sloppy”, added that “the trouble that occurred was due solely to police over-reaction”. Police had obstructed many routes with crash-barriers and vans, creating bottlenecks and fuelling rising anger. the police presence, including 30 horses and an estimated 1,000 policemen, had to contend with missiles as well as some pushing and shoving.

Reports suggested that five Cambridge students were arrested; but on Thursday morning CSU had heard from only two, who had both been released without charge. Of the total 23 held, most were charged with obstruction and assault of the police. Those students who marched towards the Palace of Westminster were acting illegally, by breaking the ban on demonstrations whilst Parliament was in session. By displaying its banner at the sit-down outside Downing Street, CSU was effective breaking the law.

Whilst the ITN News at Ten and Thursday’s Times and Telegraph emphasised that those marching were from wealthy families, speeches at the rallies concentrated on principles rather than on the social background of those affected, arguing that the right to free education was at stake through the introduction of the £500 contribution to fees. As Martin Tod maintained, “All students should receive a grant regardless of parental wealth … it’s the principle that matters.”

Wednesday’s action was the largest protest by students since 1969, and CSU intends to keep up the pressure with a National telephone blockade of the Conservative Party’s Central office on December 5th, and with the lobbying of MPs.

35 arrests today. 180 arrests in 1984.

Oh, and before students feel too down about the coverage of today’s demonstration, despite similar coverage in 1984, we won.

Featured on Liberal Democrat Voice

Categories
Fairness Social Justice Speech Video

Fairness in a time of austerity

Here’s the speech I made proposing the motion ‘Fairness in a time of austerity‘ at the recent Liverpoool Conference:

[media id=36 width=520 height=317]
There wasn’t too much disagreement (or indeed any disagreement) that I recall, and the motion was carried overwhelmingly.

Categories
Campaign

Latest update on the Lib Dems most active local online campaigns

An update on the party’s most active local online campaigns…

Five most active local constituencies with online petitions:

  1. Chippenham
  2. Solihull
  3. Bedford
  4. North East Bedfordshire
  5. Meriden

Five most active online campaigns

  1. Save Shirley’s Historic Signal Box - http://campaigns.libdems.org.uk/shirleysignalbox
  2. Save Melksham Library - http://jonhubbard.mycouncillor.org.uk/melksham-library/sign-the-petition-to-save-melksham-library/
  3. Save Bedfordshire Police - http://campaigns.libdems.org.uk/savebedspolice
  4. Stop The Incinerator - http://www.campaigns.libdems.org.uk/incinerator
  5. Save our ticket offices - http://www.ourcampaign.org.uk/saveourticketoffices