coding

Web design and programming

-- professional quality, reliable website design and programming since 1996 --

Specializing in providing solutions using the excellent open source Drupal CMS framework, PHP and MySQL. Expertise in setting up and hosting websites, migration of data and websites from older systems, network visualizations, writing new Drupal modules and PHP coding, etc.

Wikipedia Reflection

Ever wished providing the beauty that is Wikipedia on your own website? Now you can: just include this PHP script wherever you want Wikipedia to appear!

Note: It is highly recommended to temporarily cache pages fetched from Wikipedia. That will assure quicker execution, smaller bandwidth requirements, and also less load on the Wikipedia servers.
Statement published after some e-mails on behalf of Wikimedia Foundation asking me to remove this script:
  1. I don't agree with the Foundation blocking remote loading. We all contribute to the Wikipedia under GFDL and therefore have the right to display the Wikipedia's content. There is no difference between requesting a Wikipedia page via a graphical browser (such as Firefox or Google Chrome) and a command-line browser such as cURL.
  2. The Foundation keeps itself busy blocking remote loading. My own page running this script was blocked. I do not think blocking access is an appropriate way of spending money people donate to the Foundation in hope of increasing free content and openness. While blocking remote loading is not a friendly act taken by the Foundation, in the long term it will prove to be a rather ineffective. A script like this is boringly simple and anyone can write a new one.
  3. Even though my own test application of this script was blocked by Wikimedia Foundation, I prefer to keep the old simple script up on this page as a reminder of my first assertion, and as an inspiration for others to stand up for the freedom on the Internet.
Cheers,

Development of scripts like this can take a lot of time and effort. There are services, e.g. WikiFetcher, that charge incredible fees for a very similar thing!

I do not agree with compulsory pricing. This Wikipedia Reflection script can be used free of charge. However, if you enjoy it, you are encouraged to consider donating a few coins using

Thanks to:
  • Wikipedia voluntary contributors (distinct from Wikimedia Foundation)
  • David Polanco and Jim Worthen from aeonity.com
  • and many others
Future:
  • It would be really cool to be able to edit Wikipedia from another site (perhaps using Ajax?)
  • All ideas, snippets of code and comments are very welcome!

<?
# Wiki Reflection Version: 2.3 ( see http://www.vacilando.org/index.php?x=7065 )
# Open source license: GPL

# Make sure to force Unicode for Wikipedia content -- otherwise all foreign scripts will display utter nonsense. This should of course be in your header, though my experimenting shows it may as well stay right here.
  
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';

# Make sure images do not display with a border.
  
echo '<style TYPE="text/css">
        <!--
        img{border: 0 none;}
        -->
        </STYLE>'
;

$default_title 'Vacilando'# If you do not specify a title, this will be your default page.

$sourceurl 'http://en.wikipedia.org/wiki/'# This URL needs adjusting sometimes.
$pathfromroot substr$_SERVER['REQUEST_URI'], 0strpos$_SERVER['REQUEST_URI'], "?" ) );
$title_wiki $_GET['title'];
 if (
$title_wiki == "") { $title_wiki $default_title; }
$nicetitle str_replace"_"" "stripslashes$title_wiki ) );

function 
callback$buffer ) {

         global 
$nicetitle;
         global 
$title_wiki;
         global 
$sourceurl;

         
# Separate the article content
           
$buffer substr$bufferstrpos$buffer'<!-- start content -->' ) );
           
$buffer substr$buffer0strpos$buffer'<div class="printfooter">' ) );
         
# Replace relative links (use another wiki server)
           
$buffer str_replace'"/w/skin''"http://en.wikipedia.org/w/skin'$buffer );
           
$buffer str_replace'"/skins''"http://en.wikipedia.org/skins'$buffer );
         
# Replace relative links (use this server)
           
$buffer str_replace'"/wiki/''"' $pathfromroot '?title='$buffer );
         
# Remove edit links
           
$buffer str_replace">edit<""><"$buffer );
           
$buffer str_replace"[<""<"$buffer );
           
$buffer str_replace">]"">"$buffer );
         
$buffer str_replace'href="/w/index.php?''target="_blank" href="http://en.wikipedia.org/w/index.php?'$buffer ); # These are typically links to non-existent pages, so the Wikipedia edit page has to open.

         
if ( $buffer <> '' ) {
              
$buffer '<table width=100% cellspacing=0 cellpadding=1 bgcolor="#EEEEEE" border=0><tr><td>
                         <p><font size="+2"><b>' 
$nicetitle '</b>&nbsp;<sup><a href="http://en.wikipedia.org/w/index.php?title=' $title_wiki '&action=edit" title="Edit this article at Wikipedia" target="_blank"><font color="red" size="-1">edit</font></a></sup></font>
                         <br><i><small>extracted from </small><a href="http://www.wikipedia.org" target="_blank"><small>Wikipedia, the Free Encyclopedia</small></a><small>
                         (using <a href="http://www.vacilando.org/index.php?x=7065"><small>Wikipedia Reflection Script</small></a>)</small></i></td>
                         <td><form method="get"><br><input type="text" name="title" size="30">&nbsp;<input type="submit" value="search"></form></td>
                         <td><div align="right"><a href="http://www.gnu.org/copyleft/fdl.html" target="_blank"><img src="_misc/gnu-fdl.png" border="0"></a></div></td></tr></table><p>' 
$buffer;
            } else {
              
$buffer '<p>Unfortunately, no content could be extracted!
                         <p><a href="javascript:history.go(-1)">Return to the previous page</a> or consult the <a target="_blank" href="' 
$sourceurl $title_wiki '">Wikipedia article on "' $nicetitle '"</a>.';
            }

         return 
$buffer;
       }


# Your page header comes here...'

ob_start("callback");
#include $sourceurl . $title_wiki;
$cuu = new CURL;
echo 
$cuu -> get$sourceurl $title_wiki );
ob_end_flush();

# Your page footer comes here...'



# Define the cURL class:
  
class CURL {
     var 
$callback false;

     function 
setCallback($func_name) {
        
$this->callback $func_name;
     }

     function 
doRequest($method$url$vars) {
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
#curl_setopt($ch, CURLOPT_HEADER, 1);
        
curl_setopt($chCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
        
#curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_COOKIEJAR'cookie.txt');
        
curl_setopt($chCURLOPT_COOKIEFILE'cookie.txt');
        if (
$method == 'POST') {
            
curl_setopt($chCURLOPT_POST1);
            
curl_setopt($chCURLOPT_POSTFIELDS$vars);
        }
        
$data curl_exec($ch);
        
curl_close($ch);
        if (
$data) {
            if (
$this->callback)
            {
                
$callback $this->callback;
                
$this->callback false;
                return 
call_user_func($callback$data);
            } else {
                return 
$data;
            }
        } else {
            return 
curl_error($ch);
        }
     }

     function 
get($url) {
        return 
$this->doRequest('GET'$url'NULL');
     }

     function 
post($url$vars) {
        return 
$this->doRequest('POST'$url$vars);
     }
  }

?>

GoogLang

This script facilitates translation of web pages on your website using Google's Language Tools. In order to test how it functions, click on any of the flags in the top right corner of this page (or any other one on this website).


TrailScout (old)

A cookie-based PHP script that displays a path of hyperlinks to previously visited pages on a website. For example "Vacilando.Org > Writing > PHP Scripts > TrailScout". It is also known as "cookie crumb trail". None of the similar programs I found around the Web was good enough, so I decided to write my own.

This system does not need to use a database. The path is stored in a cookie for the duration of one session (= until you close all your browser windows). For each new visited page, the title (fetched automatically from between your tags) and the URL (complete with parameters) is stored in that session variable. If user visits a page that s/he has seen before, the trail of links is reduced and that page again becomes the last one in a row. There is a variable that can be used to limit the maximum number of links to be stored (this is useful for large sites where trails tend to be too long).


Galaxis: a calendar and encrypting program written in GFA Basic on Commodore Amiga

A look at Galaxis running in my Amiga

And this is the source code of Galaxis in GFA Basic


WikiTree

See another very successful Vacilando open source project, WikiTree.org!

TrailScout

TrailScout - the intuitive breadcrumb system for Drupal - simply showing the last few recently visited pages!

Get it here.

A breeze to install and run; try it out (just don't forget to enable user access permissions).

I'll add more info and description of properties, advantages and disadvantages, future plans, etc. very soon.


Hypergraph

Integration of Java hyperbolic tree geometry visualization developed at http://hypergraph.sourceforge.net/ in a Drupal module. >> Download the Hypergraph Drupal module. << Don't get scared by the words and play with the demo below. (Hold the left mouse button to pan the graph!)

Brilliant Gallery

[get_slashbgfromdrupal]

 



Step-by-step installation:

Syndicate content