viewgit/viewgit/inc/functions.php:49 Function create_function() is deprecated [8192]
Index
» This day in Tech : Commitdiff HEAD
Seperated PHP and Joomla folders. Added readme.txt.
diff --git a/README.txt b/README.txt new file mode 100755 index 0000000..b9bc5b6 --- /dev/null +++ b/README.txt @@ -0,0 +1,148 @@ +This Day in Tech +This is a set of scripts and console applications that +dump text entries from Tom Merritt's Chronology of Tech +History book for the current day. + +https://merrittbooks.squarespace.com/2012/10/17/chronolog +y-of-tech-history + +It's a nice bit of geeky fun. The idea of this scripts +was to be able to use it in Message of the Day type +setups. + +Download + +The binaries are available from +http://kinggeek.co.uk/download in the tdit folder. +The source from http://kinggeek.co.uk/source + +Installation +There are console versions that can be/are compiled for +Linux, OSX, and Windows. + +It uses an sqlite3 database for it's storage so you need +probably need this installed on your system if it isn't +already. A Windows DLL is included with the windows +binary which should take care of this. On OSX it should +work out of the box. On linux you might need to install +sqlite3. On Redhat type distros something like + +yum install sqlite + +should do the job. On Debian style distros something like + +apt-get install sqlite3 + +Should do the trick. + +Command line usages options for the console program:- +You can copy the database to /etc for linux distros, or +you can specify where to find the db with the -d command +line option. The help from the console app:- + +This Day in Tech +Based on Tom Merritt's Chronology of Tech History +Usage: tdit [-d databasefile] [-r] [--help] + +-d databasefile : specify the database file to use. + Will try /etc/tdit.db or ./tdit.db if + not specified or found. +-r : print a single random entry for the day + (otherwise print all entries) +--help : print this help + + +Plain ol' PHP + +There is a plain PHP version which can be used by +including the edit_functions.php file and calling the +tdit() function:- + +function tdit($action) + + returns a string with This Day in Tech Quote(s). + +Specify the strings 'all' or 'random' as the $action +parameter to print all entries for today, or just a +single random one respectively. + +function tdit_dm($action,$day,$month) + +Does as above but lets you specify a day and month. There +is also test script which dumps the whole book. + +Joomla Plugins + +There is a Joomla 2.5 and a Joomla 1.5> version. + +Tested with only Joomla 3.0 and Joomla 1.5 because that +is what I had access to. + +Install the plugin in the normal way. You need sqlite3 +php support on your server (usually built in to PHP5+). +To use the plugin, in your content insert + +{tdit}single{/tdit} + +or + +{tdit}all{/tdit} + +and the text above will be replaced in an article with +the either a single event for the day or all the events +for the day as a unordered list with the css class +tdit_list. + +NB: If you get no output for an entry check the +tdit/tdit_functions.php file in the joomla plugin +install. The htmlentities function was causing output to +disappear on one server I tried it on. YMMV. + + +Building the console programs from source + +Download the source code from here. Extract the archive +somewhere. I've built successfully so far for 32 bit +linux, 64 bit linux, 32 bit OSX and for 32 bit Windows +(on 64 bit windows). + +For windows you need a MinGW/msys setup. Though it should +build easily enough with any C complier. + +It just seemed to work on OSX. On linux you need the +usual gcc GNU make etc. + +To build:- + +cd into the extracted directory. + + +Just type:- + +make -f nameofthemakefilefortheplatformyouron + +e.g. + +make -f Makefile.linux + +And it should all build. + +NB: The Makefile.linux32 makefile is to build a 32bit +binary on a 64bit linux system. + +Follow the installation instructions to install. + + +Licence + +This work is licensed under a Creative Commons +Attribution-ShareAlike 3.0 Unported License as is Tom's +original work. + +http://creativecommons.org/licenses/by-sa/3.0/deed.en + +Thanks to Tom Merritt for a great project. + + + + diff --git a/joomla/build.sh b/joomla/build.sh new file mode 100755 index 0000000..0d286cc --- /dev/null +++ b/joomla/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh +rm -f *.zip +echo Zipping joomla 1.5 package +cd joomla_content_plugin_1.5 +zip -r ../joomla_plugin_content_tdit_1.5.zip * +echo Zipping joomla 2.5 package +cd .. +cd joomla_content_plugin_2.5 +zip -r ../joomla_plugin_content_tdit_2.5.zip * diff --git a/joomla/joomla_content_plugin_1.5/tdit.php b/joomla/joomla_content_plugin_1.5/tdit.php new file mode 100755 index 0000000..ccf788b --- /dev/null +++ b/joomla/joomla_content_plugin_1.5/tdit.php @@ -0,0 +1,43 @@ +<?PHP +/** @file + * + */ + +// no direct access +defined( '_JEXEC' ) or die( 'Restricted access' ); +jimport('joomla.plugin.plugin'); + + + +class plgContentTDIT extends JPlugin +{ + +//joomla <2.5 +public function onPrepareContent(&$rw, &$parms, $pg=0 ) { + + if ( !preg_match("#{tdit}(.*?){/tdit}#s", $rw->text) ) { + return(true); + } + + + + $xpr="#{tdit}(.*?){/tdit}#s"; + if (preg_match_all($xpr, $rw->text, $matches, PREG_PATTERN_ORDER) > 0) { + $cnt=0; + foreach ($matches[0] as $match) { + $html=""; + $action = preg_replace("/{.+?}/", "", $match); + + + require_once('tdit/tdit_functions.php'); + $html=tdit($action); + + $rw->text=preg_replace($xpr,$html,$rw->text,1); + } + return true; + } + + } +} + +?> diff --git a/joomla/joomla_content_plugin_1.5/tdit.xml b/joomla/joomla_content_plugin_1.5/tdit.xml new file mode 100644 index 0000000..83492f0 --- /dev/null +++ b/joomla/joomla_content_plugin_1.5/tdit.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<install version="1.5" type="plugin" group="content"> + <name>Content - This day in tech - Joomla plugin</name> + <author>Matthew Smith - Uses data Tom Merritt’s Chronology of Tech History </author> + <creationDate>October 2012</creationDate> + <copyright>Copyleft 2012 Matthew Smith.</copyright> + <license>http://www.gnu.org/licenses/agpl-3.0.html</license> + <authorEmail>matt@librarysmith.co.uk</authorEmail> + <authorUrl>www.kinggeekco.uk</authorUrl> + <version>0.1</version> + <description>Usage {tdit}all|single{/tdit} - Displays entry(ies) from Tom Merritt's Chronology of Tech History</description> + <files> + <filename plugin="tdit">tdit.php</filename> + <folder>tdit</folder> + </files> + <params> + </params> +</install> \ No newline at end of file diff --git a/joomla/joomla_content_plugin_1.5/tdit/tdit.db b/joomla/joomla_content_plugin_1.5/tdit/tdit.db new file mode 100755 index 0000000..bff3991 Binary files /dev/null and b/joomla/joomla_content_plugin_1.5/tdit/tdit.db differ diff --git a/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php b/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php new file mode 100755 index 0000000..689aa5b --- /dev/null +++ b/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php @@ -0,0 +1,44 @@ +<?php + +// function tdit($action) +// returns a string with This Day in Tech Quote(s). +// Specify 'all' or 'random' as the $action parameter to print all entries for +// today, or just a single random one repectively. + +function tdit($action) { +date_default_timezone_set('Europe/London'); + +$year=date("Y"); +$month=date("m"); +$day=date("d"); + + +$results='<ul class="tdit_list">'; +if ($db = new SQLite3(JPATH_PLUGINS.'/content/tdit/tdit.db')) { + $res=$db->query("SELECT * FROM 'tdit' WHERE day = \"$day\" AND month = \"$month\""); +$i=0; + + +if (is_object($res)) { +$r=array(); + + while ($row = $res->fetchArray()) { + array_push($r,"<li>On this day in ".$row['year']." - ".htmlentities($row['event']."\n", ENT_IGNORE,'UTF-8').'</li>'); + } + + if ($action!="single") { + + foreach($r as $ln) $results.=$ln; + } else { + $rnd=rand(0,count($r)-1); + $results=$r[$rnd]; + } + + return($results."</ul>"); + + $db->close(); + + } else return("Error querying database"); + } +} +?> \ No newline at end of file diff --git a/joomla/joomla_content_plugin_2.5/tdit.php b/joomla/joomla_content_plugin_2.5/tdit.php new file mode 100755 index 0000000..dfc079f --- /dev/null +++ b/joomla/joomla_content_plugin_2.5/tdit.php @@ -0,0 +1,42 @@ +<?PHP +/** @file + * + */ + +// no direct access +defined( '_JEXEC' ) or die( 'Restricted access' ); +jimport('joomla.plugin.plugin'); + + + +class plgContentTDIT extends JPlugin +{ + +public function onContentPrepare($ctx,&$rw, &$parms, $pg=0 ) { + + if ( !preg_match("#{tdit}(.*?){/tdit}#s", $rw->text) ) { + return(true); + } + + + + $xpr="#{tdit}(.*?){/tdit}#s"; + if (preg_match_all($xpr, $rw->text, $matches, PREG_PATTERN_ORDER) > 0) { + $cnt=0; + foreach ($matches[0] as $match) { + $html=""; + $action = preg_replace("/{.+?}/", "", $match); + + + require_once('tdit/tdit_functions.php'); + $html=tdit($action); + + $rw->text=preg_replace($xpr,$html,$rw->text,1); + } + return true; + } + + } +} + +?> diff --git a/joomla/joomla_content_plugin_2.5/tdit.xml b/joomla/joomla_content_plugin_2.5/tdit.xml new file mode 100755 index 0000000..8491364 --- /dev/null +++ b/joomla/joomla_content_plugin_2.5/tdit.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<extension version="2.5" type="plugin" group="content"> + <name>Content - This day in tech - Joomla plugin</name> + <author>Matthew Smith - Uses data Tom Merritt’s Chronology of Tech History </author> + <creationDate>October 2012</creationDate> + <copyright>Copyleft 2012 Matthew Smith.</copyright> + <license>http://www.gnu.org/licenses/agpl-3.0.html</license> + <authorEmail>matt@librarysmith.co.uk</authorEmail> + <authorUrl>www.kinggeekco.uk</authorUrl> + <version>0.1</version> + <description>Usage {tdit}all|single{/tdit} - Displays entry(ies) from Tom Merritt's Chronology of Tech History</description> + <files> + <filename plugin="tdit">tdit.php</filename> + <folder>tdit</folder> + </files> + <params> + </params> +</extension> + + diff --git a/joomla/joomla_content_plugin_2.5/tdit/tdit.db b/joomla/joomla_content_plugin_2.5/tdit/tdit.db new file mode 100755 index 0000000..bff3991 Binary files /dev/null and b/joomla/joomla_content_plugin_2.5/tdit/tdit.db differ diff --git a/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php b/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php new file mode 100755 index 0000000..f192818 --- /dev/null +++ b/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php @@ -0,0 +1,44 @@ +<?php + +// function tdit($action) +// returns a string with This Day in Tech Quote(s). +// Specify 'all' or 'random' as the $action parameter to print all entries for +// today, or just a single random one repectively. + +function tdit($action) { +date_default_timezone_set('Europe/London'); + +$year=date("Y"); +$month=date("m"); +$day=date("d"); + + +$results='<ul class="tdit_list">'; +if ($db = new SQLite3(JPATH_PLUGINS.'/content/tdit/tdit/tdit.db')) { + $res=$db->query("SELECT * FROM 'tdit' WHERE day = \"$day\" AND month = \"$month\""); +$i=0; + + +if (is_object($res)) { +$r=array(); + + while ($row = $res->fetchArray()) { + array_push($r,"<li>On this day in ".$row['year']." - ".htmlentities($row['event']."\n", ENT_IGNORE,'UTF-8').'</li>'); + } + + if ($action!="single") { + + foreach($r as $ln) $results.=$ln; + } else { + $rnd=rand(0,count($r)-1); + $results=$r[$rnd]; + } + + return($results."</ul>"); + + $db->close(); + + } else return("Error querying database"); + } +} +?> \ No newline at end of file diff --git a/joomla/joomla_plugin_content_tdit_1.5.zip b/joomla/joomla_plugin_content_tdit_1.5.zip new file mode 100644 index 0000000..84fdec7 Binary files /dev/null and b/joomla/joomla_plugin_content_tdit_1.5.zip differ diff --git a/joomla/joomla_plugin_content_tdit_2.5.zip b/joomla/joomla_plugin_content_tdit_2.5.zip new file mode 100644 index 0000000..2eaac09 Binary files /dev/null and b/joomla/joomla_plugin_content_tdit_2.5.zip differ diff --git a/php/joomla/build.sh b/php/joomla/build.sh deleted file mode 100755 index e39495c..0000000 --- a/php/joomla/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -rm -f *.zip -zip -r joomla_plugin_content_tdit_1.5.zip joomla_content_plugin_1.5/* -zip -r joomla_plugin_content_tdit_2.5.zip joomla_content_plugin_2.5/* \ No newline at end of file diff --git a/php/joomla/joomla_content_plugin_1.5/tdit.php b/php/joomla/joomla_content_plugin_1.5/tdit.php deleted file mode 100755 index ccf788b..0000000 --- a/php/joomla/joomla_content_plugin_1.5/tdit.php +++ /dev/null @@ -1,43 +0,0 @@ -<?PHP -/** @file - * - */ - -// no direct access -defined( '_JEXEC' ) or die( 'Restricted access' ); -jimport('joomla.plugin.plugin'); - - - -class plgContentTDIT extends JPlugin -{ - -//joomla <2.5 -public function onPrepareContent(&$rw, &$parms, $pg=0 ) { - - if ( !preg_match("#{tdit}(.*?){/tdit}#s", $rw->text) ) { - return(true); - } - - - - $xpr="#{tdit}(.*?){/tdit}#s"; - if (preg_match_all($xpr, $rw->text, $matches, PREG_PATTERN_ORDER) > 0) { - $cnt=0; - foreach ($matches[0] as $match) { - $html=""; - $action = preg_replace("/{.+?}/", "", $match); - - - require_once('tdit/tdit_functions.php'); - $html=tdit($action); - - $rw->text=preg_replace($xpr,$html,$rw->text,1); - } - return true; - } - - } -} - -?> diff --git a/php/joomla/joomla_content_plugin_1.5/tdit.xml b/php/joomla/joomla_content_plugin_1.5/tdit.xml deleted file mode 100644 index 83492f0..0000000 --- a/php/joomla/joomla_content_plugin_1.5/tdit.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<install version="1.5" type="plugin" group="content"> - <name>Content - This day in tech - Joomla plugin</name> - <author>Matthew Smith - Uses data Tom Merritt’s Chronology of Tech History </author> - <creationDate>October 2012</creationDate> - <copyright>Copyleft 2012 Matthew Smith.</copyright> - <license>http://www.gnu.org/licenses/agpl-3.0.html</license> - <authorEmail>matt@librarysmith.co.uk</authorEmail> - <authorUrl>www.kinggeekco.uk</authorUrl> - <version>0.1</version> - <description>Usage {tdit}all|single{/tdit} - Displays entry(ies) from Tom Merritt's Chronology of Tech History</description> - <files> - <filename plugin="tdit">tdit.php</filename> - <folder>tdit</folder> - </files> - <params> - </params> -</install> \ No newline at end of file diff --git a/php/joomla/joomla_content_plugin_1.5/tdit/tdit.db b/php/joomla/joomla_content_plugin_1.5/tdit/tdit.db deleted file mode 100755 index bff3991..0000000 Binary files a/php/joomla/joomla_content_plugin_1.5/tdit/tdit.db and /dev/null differ diff --git a/php/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php b/php/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php deleted file mode 100755 index 689aa5b..0000000 --- a/php/joomla/joomla_content_plugin_1.5/tdit/tdit_functions.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -// function tdit($action) -// returns a string with This Day in Tech Quote(s). -// Specify 'all' or 'random' as the $action parameter to print all entries for -// today, or just a single random one repectively. - -function tdit($action) { -date_default_timezone_set('Europe/London'); - -$year=date("Y"); -$month=date("m"); -$day=date("d"); - - -$results='<ul class="tdit_list">'; -if ($db = new SQLite3(JPATH_PLUGINS.'/content/tdit/tdit.db')) { - $res=$db->query("SELECT * FROM 'tdit' WHERE day = \"$day\" AND month = \"$month\""); -$i=0; - - -if (is_object($res)) { -$r=array(); - - while ($row = $res->fetchArray()) { - array_push($r,"<li>On this day in ".$row['year']." - ".htmlentities($row['event']."\n", ENT_IGNORE,'UTF-8').'</li>'); - } - - if ($action!="single") { - - foreach($r as $ln) $results.=$ln; - } else { - $rnd=rand(0,count($r)-1); - $results=$r[$rnd]; - } - - return($results."</ul>"); - - $db->close(); - - } else return("Error querying database"); - } -} -?> \ No newline at end of file diff --git a/php/joomla/joomla_content_plugin_2.5/tdit.php b/php/joomla/joomla_content_plugin_2.5/tdit.php deleted file mode 100755 index dfc079f..0000000 --- a/php/joomla/joomla_content_plugin_2.5/tdit.php +++ /dev/null @@ -1,42 +0,0 @@ -<?PHP -/** @file - * - */ - -// no direct access -defined( '_JEXEC' ) or die( 'Restricted access' ); -jimport('joomla.plugin.plugin'); - - - -class plgContentTDIT extends JPlugin -{ - -public function onContentPrepare($ctx,&$rw, &$parms, $pg=0 ) { - - if ( !preg_match("#{tdit}(.*?){/tdit}#s", $rw->text) ) { - return(true); - } - - - - $xpr="#{tdit}(.*?){/tdit}#s"; - if (preg_match_all($xpr, $rw->text, $matches, PREG_PATTERN_ORDER) > 0) { - $cnt=0; - foreach ($matches[0] as $match) { - $html=""; - $action = preg_replace("/{.+?}/", "", $match); - - - require_once('tdit/tdit_functions.php'); - $html=tdit($action); - - $rw->text=preg_replace($xpr,$html,$rw->text,1); - } - return true; - } - - } -} - -?> diff --git a/php/joomla/joomla_content_plugin_2.5/tdit.xml b/php/joomla/joomla_content_plugin_2.5/tdit.xml deleted file mode 100755 index 8491364..0000000 --- a/php/joomla/joomla_content_plugin_2.5/tdit.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<extension version="2.5" type="plugin" group="content"> - <name>Content - This day in tech - Joomla plugin</name> - <author>Matthew Smith - Uses data Tom Merritt’s Chronology of Tech History </author> - <creationDate>October 2012</creationDate> - <copyright>Copyleft 2012 Matthew Smith.</copyright> - <license>http://www.gnu.org/licenses/agpl-3.0.html</license> - <authorEmail>matt@librarysmith.co.uk</authorEmail> - <authorUrl>www.kinggeekco.uk</authorUrl> - <version>0.1</version> - <description>Usage {tdit}all|single{/tdit} - Displays entry(ies) from Tom Merritt's Chronology of Tech History</description> - <files> - <filename plugin="tdit">tdit.php</filename> - <folder>tdit</folder> - </files> - <params> - </params> -</extension> - - diff --git a/php/joomla/joomla_content_plugin_2.5/tdit/tdit.db b/php/joomla/joomla_content_plugin_2.5/tdit/tdit.db deleted file mode 100755 index bff3991..0000000 Binary files a/php/joomla/joomla_content_plugin_2.5/tdit/tdit.db and /dev/null differ diff --git a/php/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php b/php/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php deleted file mode 100755 index f192818..0000000 --- a/php/joomla/joomla_content_plugin_2.5/tdit/tdit_functions.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -// function tdit($action) -// returns a string with This Day in Tech Quote(s). -// Specify 'all' or 'random' as the $action parameter to print all entries for -// today, or just a single random one repectively. - -function tdit($action) { -date_default_timezone_set('Europe/London'); - -$year=date("Y"); -$month=date("m"); -$day=date("d"); - - -$results='<ul class="tdit_list">'; -if ($db = new SQLite3(JPATH_PLUGINS.'/content/tdit/tdit/tdit.db')) { - $res=$db->query("SELECT * FROM 'tdit' WHERE day = \"$day\" AND month = \"$month\""); -$i=0; - - -if (is_object($res)) { -$r=array(); - - while ($row = $res->fetchArray()) { - array_push($r,"<li>On this day in ".$row['year']." - ".htmlentities($row['event']."\n", ENT_IGNORE,'UTF-8').'</li>'); - } - - if ($action!="single") { - - foreach($r as $ln) $results.=$ln; - } else { - $rnd=rand(0,count($r)-1); - $results=$r[$rnd]; - } - - return($results."</ul>"); - - $db->close(); - - } else return("Error querying database"); - } -} -?> \ No newline at end of file diff --git a/php/joomla/joomla_plugin_content_tdit_1.5.zip b/php/joomla/joomla_plugin_content_tdit_1.5.zip deleted file mode 100644 index 7b2a41c..0000000 Binary files a/php/joomla/joomla_plugin_content_tdit_1.5.zip and /dev/null differ diff --git a/php/joomla/joomla_plugin_content_tdit_2.5.zip b/php/joomla/joomla_plugin_content_tdit_2.5.zip deleted file mode 100644 index 5b3adef..0000000 Binary files a/php/joomla/joomla_plugin_content_tdit_2.5.zip and /dev/null differ