heyrick1973 -at- yahoo -dot- co -dot uk

You are not reading my b.log using HTTPS. You can switch to HTTPS by clicking here.

If you aren't interested in political commentary, click here for something pleasingly geeky.

Saving the world

Well, my Frenchie friend got back in touch, and it is what I suspected. It is a form of communism. But, wait! When you strip away the political ex-Soviet rubbish, the basic form of communism is not actually that bad an idea. I have been quite happy to support a form of tit-for-tat working, for neighbours and such. I do <x> and in return they do <y>. What is pure communism rather than a much more encompassing version of that? And whether or not your mind is clouded with images of Chinese people, remember that cute quaint village life worked on a principle not unlike this. People lived in communes (now a word associated with hippies), people cared about their community, this was a mild form of communism. One might even suggest that the American Amish communities are following these principles, even if it is called something different.

The problem with the concept, and the problem with my friend's idea, is it is not human nature to share equally. I go to the next town and I fix Bob's computer. In return he comes and puts up some planks to fix up a bit of the barn. But wait, the computer work took half an hour and the barn took four hours. Do we measure in time alone, in which case I would owe him, or do we measure in competence in which case... I would probably still owe him as I'm sure woodworking ability is of more use to a world than the ability to poke keys.
The system works as it is a favour we're doing for each other. We agree on the terms, we both get what we want. But if it was a way of life, suddenly we'd start seeing it in terms of who is better than what. This is where communism in the Soviet era failed. Nobody was equal, it was the State spying in a poor populace where some people were definitely more equal than others (sounds like modern Britain). If you can't be assed to look in a stuffy boring tome of history, take a read of Orwell's "Animal Farm" for it describes the Soviet era and not what is wrong with communism, but rather what is wrong with humanity.

 

He carries on to make a very valid point that our current capitalist society is based upon one thing - profits. He says it doesn't make sense, and if you think about it, who do profits really help? Sure, some companies (such as the one I work for) get bigger, but how much of the profit is genuinely invested in the company? Profits, generally, please company directors and shareholders. But in the majority of cases (excepting notable cases such as The John Lewis Partnership), profits don't really help the employees (if my company does well, do we get a special bonus?) and the desire for profits will drive up prices which will ultimately make things more expensive for consumers. And if there's a price crash initiated by a competitor, the same product will be offered at a discount, but rather than risk losing profits the product will be made with corners cut or fewer staff or... it is, ultimately, an illogical and frankly bizarre way to run a society where a select few people will get rich and, frankly, screw the rest of us. You can see this to a degree in the DVD market where DVDs are priced at what they think the market will pay (and, months later, on the bottom shelves for €3-5 apiece)... but you will find no example greater than the tactics of the oil industry. Sheer blatant bare-faced profiteering with tongues stuck out, for they know we need oil and there are few other options (thanks in large part to oil companies buying the rights to alternative technologies and generally suppressing those that have a hope in hell of actually working). We need the oil, and while we might protest from time to time, it's a cartel and they can ask what they damn well want. And, by and large, they do.

My personal thoughts? It is a nice dream. I have no qualms about a society based upon sharing where money is an incidental rather than a necessity. But if we all picked ourselves up and moved to an idyllic island paradise, how long would it be before our paradise destroyed itself? How long before somebody elected themselves leader, gave preferences to specific people, others keeping the good stuff for themselves, deciding upon now much equality is really necessary and...

 

This brings us to the French problem, and indeed to a problem facing all countries. The post-war generation enjoyed many luxuries. Mom recounts how it was a brave new world in America in the '50s when she was a little girl. There seemed so many possibilities and so much potential.
It has all but burned out now. What is left are corrupt self-serving politicians trying to feather their nests while attempting to keep a difficult system afloat. The public health service, the pensions, the unemployment benefits, social aid...

What petit petit Nico doesn't entirely comprehend is that annoying the populace with a raise in retirement age is ultimately a flawed idea. For, well, there are only so many jobs. Old people shuffle off, and young'uns take their place. But if the older generation stays in work to avoid claiming pension, there will be younger people on the Secu because there's no work for them.

Should the French protest tomorrow?

Hell yes!

One of the things we Anglo-Saxons admire about the French (even if we'd rarely admit it) is that they are willing to stand up for what they believe in. It may be futile, or it may be the difference that gets the message across. It is, however you look at it, a whole lot better than typical English apathy.

 

One final thought on the topic of saving the world. How much do you think it will cost to lift the poor from poverty. To bring irrigation and technology to places like Africa and Mexico, to make them self-sufficient. Billions? Tens of billions?
Read the first paragraph of my 3rd October 2008 entry and think long and hard about it. Capitalist snouts will move mountains to save their own asses, and screw the rest of us. I have déjà vu... have I already said this? Hmmm...

 

Mailcheck - why?

I have to put regular credit on my mobile phone, as the credit present has an expiry. The problem is, I rarely have anybody to call and if I do I would use the VoIP phone (erm, when it is working!) as it is free.

So something I've become used to is, while on break at work, I start up Opera Mini on my Nokia 6230i and look to see what mails I have. Yahoo!'s mail works, but looks unattractive on a mobile. My other mailbox is hosted on a broken service (using horde). They say they do not support mobile webmail use, but the scripts they have detects I am on a mobile and tries to redirect me to the non-existant mobile version.
This is all I see:

Mobile mail, not exactly working.
When I click the link, it's a 404.

The way around this, if you're a programmer, is to scratch your head and then devise some PHP. Some PHP to log into the mail server(s), extract information on the messages (if any) and then throw back a minimal report. God it's good to be a geek!

The "minimal" is important. It costs me €0.15 per 10Kb unit, so a basic styling is given so it looks nicer on desktop browsers, however there are no pictures, no stylesheets, nothing fancy.

This will not be linked on my software page. It's a little thank you for reading all the drivel I write! ☺

 

Some pictures

How it looks under OperaMini 4.2 (what's on my phone):
Mailcheck on a mobile phone.
Note - do not select "Mobile view" in the settings. This is a 'flattened' version of reality where all table elements are collapsed to a single width. It looks bad. Generally, everywhere...

How it would look under newer (OperaMini 5) mobile devices:

Mailcheck on a mobile device.
I notice that the text sizes are more restricted. This is "small", yet looks about the same size as the typical text used in a desktop environment.

And for comparison, how it looks on a desktop browser. This is Opera 10.51, but to be honest I'd say it looks best in Firefox because Opera has strange concept of how to size table elements.

Mailcheck on a desktop.

 

The script

This script is copyright © 2010 Rick Murray. It is hereby released under the EUPL.

I would appreciate:

  • If you use this script, please let me know.
  • If you modify/extend this script, please share the changes with me!
Thanks.

<?php

// MAILCHECK SCRIPT
// by Rick Murray
//
// Enumerate messages on POP3 mail servers and return a simple
// and SMALL report for use in mobile applications.
//
// Version 0.02 2010/09/21
//
// Copyright © 2010 Rick Murray
//
//
// IMPORTANT:
//   This script does NOT contain any sort of security access
//   procedure. It is intended to be a specific script for a
//   specific purpose. Either add your own challenge, or hide
//   this on your server (under a different name!) and tell
//   NOBODY.
//   This script does not, however, include facilities to
//   retrieve messages.
//
//
// Licensed under the EUPL, Version 1.1 only (the "Licence");
// You may not use this work except in compliance with the Licence.
// You may obtain a copy of the Licence at:
//   http://ec.europa.eu/idabc/eupl5
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Licence is distributed on an "AS IS" basis,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the Licence for the specific language governing permissions and
// limitations under the Licence.



// set up the server login specifics here
// modify this to suit your own requirements
$server = array (
  array (
    "title"    => "Yahoo! mail",
    "server"   => "pop.mail.yahoo.com",
    "username" => "<your username here>",
    "password" => "<your password here>"
  ),
  array (
    "title"    => "Private mail",
    "server"   => "<your mailhost here>",
    "username" => "<your username here>",
    "password" => "<your password here>"
  ),
  array (
    "title"    => "BBC mailing list",
    "server"   => "<your mailhost here>",
    "username" => "<your username here>",
    "password" => "<your password here>"
  )

  // Copy the array block (don't forget comma
  // after all-but-last) for as many mail
  // servers as are required to be checked.
);


// some constants
define("POP3_PORT", 110);  // we don't support "fruity" servers
define("BUFFERSIZE", 128);
define("TIMEOUT", 6);


function talk_to_server($fp, $msg)
{
  // Send a message to the server, await a reply.
  $reply = "";
  fwrite($fp, $msg);
  while ( substr($reply, (strlen($reply) -1), 1) != "\n" )
  {
    $this_line = fgets($fp, BUFFERSIZE);
    $reply .= $this_line;
  }

  return $reply;
}


function check_okay($reply)
{
  // Return TRUE if "+OK" reply, else FALSE.

  $r = array();
  $r = explode(" ", $reply);
  return ($r[0] == "+OK") ? TRUE : FALSE;
}


function format_size($sizeinbytes)
{
  // Returns a neatly formatted size; uses the RISC OS 4096/4 convention.

  if ($sizeinbytes < 4096)
     return $sizeinbytes . " bytes";

  $sizeinbytes = $sizeinbytes / 1024;

  if ($sizeinbytes < 4096)
     return sprintf("%.1f Kbytes", $sizeinbytes);

  $sizeinbytes = $sizeinbytes / 1024;

  // unlikely to be over 4Gb!
  return sprintf("%.1f Mbytes", $sizeinbytes);
}



// ==================
// Script starts here
// ==================

// set up page header - very basic
echo "<html>\n<head><title>Mail check</title></head>\n<body>\n\n";


// loop through the servers
foreach ( $server as $mailserver )
{
  echo "<h2>" . $mailserver["title"] . "</h2>\n";

  $this_host = $mailserver["server"];
  $this_user = $mailserver["username"];
  $this_pass = $mailserver["password"];

  $connection = fsockopen($this_host, POP3_PORT, $errno, $errstr, TIMEOUT);
  if ( !$connection )
  {
    // uh-oh!
    echo "Connection to mailserver failed: " . $errstr . "\n<p>\n\n";
  }
  else
  {
    // good to go, we ought to have a POP3 banner message so read and discard
    $this_line = fgets($connection, BUFFERSIZE);

    // now log in
    talk_to_server($connection, "USER " . $this_user . "\n");
    talk_to_server($connection, "PASS " . $this_pass . "\n");

    // enumerate messages
    talk_to_server($connection, "LIST\n");

    $msgsize = array();
    $messages = 0;
    $this_line = "";
    while($this_line != ".\r\n")
    {
      $this_line = fgets($connection, BUFFERSIZE);

      // do some stuff if there is a valid message returned
      if ($this_line[0] != ".")
      {
        $msginfo = array();
        $msginfo = explode(" ", $this_line);
        $msgsize[] = $msginfo[1];
        $messages++;
      }
    }

    // generate a display
    if ($messages == 0)
    {
      echo "You do not have any messages in this mailbox.\n<p>&nbsp;<p>\n\n\n";
    }
    else
    {
      echo "You have " . $messages;
      if ($messages == 1)
        echo " message:\n\n<table border=0 width=\"100%\">\n";
      else
        echo " messages:\n\n<table border=0 width=\"100%\">\n";

      for ($recurse = 1; $recurse <= $messages; $recurse++)
      {
        // For each message, pull the headers to extract the 
        // sender, subject, and date.

        $msg_from = "";
        $msg_subj = "";
        $msg_date = "";

        talk_to_server($connection, "TOP " . $recurse . " 0\n");
        $this_line = "";
        while($this_line != ".\r\n")
        {
          $this_line = fgets($connection, BUFFERSIZE);

          if ( substr($this_line, 0, 5) == "From:" )
            $msg_from = htmlentities(substr($this_line, 6), ENT_COMPAT);

          if ( substr($this_line, 0, 5) == "Date:" )
            $msg_date = substr($this_line, 6, 25);

          if ( substr($this_line, 0, 8) == "Subject:" )
            $msg_subj = htmlentities(substr($this_line, 9), ENT_COMPAT);
        }

        // clip off trailing line ends
        $msg_from = substr($msg_from, 0, (strlen($msg_from) - 2)); // -2 for CRLF
        $msg_subj = substr($msg_subj, 0, (strlen($msg_subj) - 2));


        // patch for Satsuki
        if ( substr($msg_from, 0, 9) == "- satsuki" )
          $msg_from = "S" . substr($msg_from, 3);
        // This tidies up a quirk in Satsuki's email address, but it
        // also shows how you can play around with the data if you want
        // certain things to appear in a specific way. There are many
        // options, like your girlfriend's messages appearing bigger or
        // a different colour... Play with it.


        // now output a status for this message
        echo "<tr><td rowspan=5>&nbsp;</td><td colspan=2 bgcolor=\"#e0e0ff\">\n";
        echo "    <font face=\"Arial, sans-serif\"><b>" . $msg_subj;
        echo     "</b></font></td></tr>\n";
        echo "<tr><td align=\"right\" valign=\"top\">From:</td>\n";
        echo "    <td><font face=\"Arial, sans-serif\"><i>" . $msg_from;
        echo     "</i></font></td></tr>\n";
        echo "<tr><td align=\"right\">Date:</td><td><font face=\"Arial, sans-serif\">";
        echo $msg_date . "</font></td></tr>\n";
        echo "<tr><td align=\"right\">Size:</td><td><font face=\"Arial, sans-serif\">";
        echo format_size($msgsize[($recurse - 1)]) . "</font></td></tr>\n";
        echo "<tr><td colspan=2>&nbsp;</td></tr>\n"; // add some space
      } // end of message-report block

      // end of list
      echo "</table>\n";

    } // end of messages > 0 block
  } // end of POP3 login block 

  // we're done, close this connection
  talk_to_server($connection, "QUIT\n");
  fclose($connection);

  echo("<p>\n\n");
} // end of foreach mailserver block

// end of document
echo "<hr>\nMailcheck script v0.02 &copy; 2010 Rick Murray\n</body></html>\n";

// done.
exit();
?>

Versions:

0.02 2010/09/21
  • Email address and subject are escaped so <stuff> shows correctly.
  • Tweaks to table for better results on different browsers.
  • Removal of CRLF at ends of subject and email address.
  • Size formatting as "12.3 Mb" is better than something like "123456789 bytes".
0.01 2010/09/19
  • Initial version.

Plans:

  • Bugfixes, if any. ☺
  • Consider an option to retrieve specific messages. Will need some thought about how to handle messages with attachments, especially short messages with large (and useless on a mobile) attachments.

 

Your comments:

Please note that while I check this page every so often, I am not able to control what users write; therefore I disclaim all liability for unpleasant and/or infringing and/or defamatory material. Undesired content will be removed as soon as it is noticed. By leaving a comment, you agree not to post material that is illegal or in bad taste, and you should be aware that the time and your IP address are both recorded, should it be necessary to find out who you are. Oh, and don't bother trying to inline HTML. I'm not that stupid! ☺
 
You can now follow comment additions with the comment RSS feed. This is distinct from the b.log RSS feed, so you can subscribe to one or both as you wish.

Austin, 26th September 2010, 19:36
Not forgetting that the smallest form of French prefecture is called "commune"! I have a French home in addition to our house here in the UK, and when we're over there in Summer we get (willingly) roped into all manner of mutually beneficial projects - pineau making, roofing barns, moving firewood, providing lifts etc. etc. 
 
It's a fully functional (and ancient) form of communism thriving at the heart of one of the most successful capitalist democracies in Western Europe! 
 
I hadn't kept up with your b.log in over a year, and just spent this afternoon catching up. The trouble is, I've run out of entries now and want to read more! You have a very honest, self-effacing writing style that is enjoyable to read. Keep it up! 
 
As an aside, the Nouilles Japonaise that you buy from Satsuki are freely available in the "cuisines du monde" section of our local Super U in Sauzé Vaussais - maybe you could lobby your local to start stocking them?
Rick, 26th September 2010, 20:33
Thanks for the compliments. Indeed France does run along fairly communist principles, though one gets the feeling that Sarko wants to modernise this to something more akin to Britain or America - which to my mind would be a disaster. Can we say those countries are doing so well REALLY? 
 
We can currently get the noodles-in-a-part from our local Intermarché, but they seem to come and go. As far as Satsuki goes, there's only a few centimes difference in price and Satsuki has a much greater range, see http://www.satsuki.fr/nouilles-inst-en-bol.htm. Not to mention <miam!> Oyakata </miam!> noodles.
Austin, 26th September 2010, 20:56
I concur - I'd resist anything that tinkered with what makes France *French* (and I'm British for crying out loud - no wonder the French themselves are up-in-arms) 
 
I love the place as it is, it's why I bought property there and spend as much time there with my family as I'm able to. I'd imagine it's France's unique take on life that attracted you and your mum, too! 
 
And far from other nations surpassing France as a result of their respective governments' industrial relations, I think that the majority could learn a thing or two from the French. France is an industrial powerhouse! World leaders in the design and construction of nuclear power stations, three vast national carmakers, huge volume premium produce exporters etc. etc. 
 
Vive la France!
Rob O'Donnell, 29th September 2010, 08:01
+1 to Austin's compliments on your writing! :-) 
 
With regard to the first bit, communes and working together, look up Local Currency on Wikipedia .. it can work, and does work, for those situations where you want your barn fixing, but Bob doesn't need his computer fixing, but maybe Fred does..
Anon, 30th September 2010, 23:39
Regarding your GPRS prices, have you tried contacting your network to see if you can pay a small fee per month for some MBs of data? 
 
In the UK, it seems that this is easy - you can get 15*GB* through "3" for £15/month. Even Orange UK hands out some data in exchange for topping up your phone.

Add a comment (v0.08) [help?] . . . try the comment feed!
Your name
Your email (optional)
Validation Are you real? Please type 97042 backwards.
Your comment
Calendar
«   September 2010   »
MonTueWedThuFriSatSun
  1345
6891011
131417
20232425
2728   

Japan - can you help?
Japanese Red Cross
日本 赤十字社

Earthquake relief donations have closed.

Read about the JRC
Make a general donation

Last 5 entries

List all b.log entries

Return to the site index

Search

Search Rick's b.log!

Etc...

Thank you:
  • Fred
  • Bernard
  • Michael
  • David


QR code


Valid HTML 4.01 Transitional
Valid CSS
Valid RSS 2.0

 

© 2010 Rick Murray
This web page is licenced for your personal, private, non-commercial use only. No automated processing by advertising systems is permitted.
RIPA notice: No consent is given for interception of page transmission.

 

Have you noticed the watermarks on pictures?
Next entry - 2010/09/26
Return to top of page