Motorcycle Adventures and Free Software

Weblog: Archive

2004-06-01 - 2004-06-30

OpenPSA Campaigns Support Event Registrations

Posted on 2004-06-01 13:40:14 UTC to . 0 comments.

To support this, a type selector was added to the OpenPSA campaign editor:


Sponsored links

Microsoft Certification Exams โนเกีย Nokia มือถือ Online Project Management save money using, phone card
Reviews มือถือ Mobile All Apps

Success of WordPress: PHP vs. Java

Posted on 2004-06-02 12:36:30 UTC to . 0 comments.

One reason is that PHP provides a lightweight way of building efficient web applications. Russel Beattie writes:

Once again I ask - why is Java web programming not keeping up? Why are Java web projects so bloated (I've got 5+MB of .jar files in my current web project and I think more are coming). Why are the pages so difficult to set up, maintain. Why do Java programmers insist on putting more logic in standard Java classes that make me have to touch ant, wait for compile and many times reboot my web server in order to test?

I think it's because PHP programmers want to get stuff done and Java programmers are geeks who want do stuff the "right" way. I'm getting sick of being in the latter camp.

Another reason is that WordPress is quick to set up and provides lots of features out-of-the-box, as noted by Matt Croydon:

It's set up for mutli-author blogging out of the box. It does trackback, pings weblogs.com, and does all of the basic things that I can think of out of the box

Harry Fuecks found some interesting design decisions in WordPress as well:

What interests me about Wordpress is the decisions taken in it's design, such as using using PHP itself as a template language, backed with HTML rendering functions. Classes come into play when dealing with "architectural domain" issues such as XML-RPC and i18n.

Using plain PHP and the Midgard Style Engine for templating has been the approach I've advocated for the Aegir community after we ran into scalability issues with FastTemplates.

Positioning a Consultancy on the Web

Posted on 2004-06-08 07:52:53 UTC to . 0 comments.

While it’s tempting to project a grandiose image of being a large multi-faceted company which is internationally sought-after, the problem with doing so is that you miss out on a lot of smaller work since it’s assumed you’re too expensive. If you are in fact a large company, the smaller work might be of little concern. If you’re not and you enjoy working on projects that require less of your time, then you may wish to reconsider the message you’re putting forward. The market is large, and getting larger; there is a need for all levels of skill and experience.

These are good points as we're preparing to redesign the Nemein corporate site. Nemein is now purely an Open Source consultancy focused on Midgard CMS and OpenPSA development and deployments, and so the site should match that.

Updated 18:00: Stopdesign's recently redesigned corporate site has lots of good ideas that we will most likely utilize in the nemein.com redesign. These include a nice portfolio and a page explaining the company's philosophy.

More specifically, our site should feature:

  • Interconnected solution descriptions (content management, project tracking, ...) and case studies
  • Personnel bios connected to personal blogs and a "Planet Nemein" aggregator
  • Corporate principles area which explains our model of working; outsourcing, Open Source, standards, security, etc.
  • Partners area where we list all the companies we work with. Communities like OSCOM, Midgard Project and Linux Greenhouse should also be mentioned
As we're all quite busy, the site should be constructed so that it will only feature basic descriptions and some screenshots on different things, and point to actual project sites for more information. Solution and case descriptions should be short and atomic, explaining only one solution per document instead of a whole application. This way the information should stay manageable.

Some Caucasian Visa Research

Posted on 2004-06-08 13:23:09 UTC to . 0 comments.

The planned travel route is:

Of these countries, I will need a visa to Russia, Ukraine, Georgia and Armenia. Unfortunately only the visas to Russia and Ukraine are available from Lähialuematkat, and take 12 business days to get. Georgian and Armenian visas need to be applied to in embassies of those countries.

The closest Georgian embassy is in Moscow. The travel bulletin on Georgia issued by Foreign Ministry of Finland claims:

Finnish citizens require a visa for entry. Visas can be bought from the airport when entering the country. Visas can also be bought from land borders of Georgia.

However, I'm inclined to doubt this. Especially as Georgian embassies in UK and USA don't say anything about it.

I guess the best course of action is to apply for Russian and Ukrainian visas now. I should also get in touch with both the Georgian embassy in Moscow and my Georgian contacts from Summer Source, Nata and Taya.

I'm not currently sure of whether to skip Armenia completely. While they sell visas over the web, the travel bulletin on Armenia tells that the border between Armenia and Turkey is closed. The history of that country would be very interesting, though.

While researching this, I found a Finnish travel journal of a similar trip done in 2002 with a car. Interesting story which also brings hope for actually accomplishing all the required paperwork. However, they also encountered some red tape:

After the good roads, tourists and gorgeous mountains of Turkey we crossed the Georgian border at night. The crossing involved a collection of dubious payments and intense arguing with bribe collecting border officials. (typical border crossing fees in East Europe include disinfection fees, road taxes, registration fees, car fees, fees for printing out documents, fees for the official to stamp a paper, fee for the border guard to open the final gate...)

So far I've never had to bribe anybody when traveling in East Europe, but maybe I've been just lucky. Most border officials and cops also seem to consider my motorcycle so cool that they don't bother with bribes.

If everything goes well, the trip will start directly after GUADEC. Looks like a group of my friends will come to Saint Petersburg for couple of days of good time, and to say farewells. We had lots of fun on similar trip to escort Jose to his Asian tour.

Updated 18:00: None of the embassy phone numbers I've found online seem to work. Hopefully my email to Nata and Taya gives some leads, otherwise it will be up to trying to get working numbers from my telco's number service.

Updated 2004-06-23 16:15: Taya sent some information on this:

georgian visa is available at border, and it costs 2 times more then if you take it somewhere else, . it's about 80 USD at border and must less in georgian consulate.. so i think you should drop by georgian embassy in moscow..

Thanks!

Take the Web Standards Survey

Posted on 2004-06-08 22:51:17 UTC to . 0 comments.

From their blog entry:

Here is your chance to let our project team members know who you are and which challenges you encounter when working with or using web standards.

WaSP deals with the client side standards of web, while OSCOM deals with the server side standards. Both are important for building scalable, accessible and enduring web solutions.

Bonus points to WaSP for providing Midgard as the second example of a content management system in the survey.

Via Mezzoblue.

Sailing on Viking Ship in 2001

Posted on 2004-06-08 23:37:54 UTC to . 0 comments.

The voyage started from the ancient castle in Viborg. After Visotsk where all necessary papers were signed, Heimlosa Rus took course to Finland. Good favorable wind allowed to cover 40 sea-miles and next morning we came to Lapuri. In 1976 wrecks of a ship were found there and then they served as a model for the Heimlosa Rus. After 6 years of sailing around Europe the ship came back home.

The captain's notes on the 2001 trip can be found from the project site. In addition, I have bunch of photos online.

I was originally planning to participate in the 1998 trip across the mediterranean, but couldn't because of too much work. In 2001 I also had to leave the ship already in Loviisa because of the trip to the Pamplona bull run.

Sailing on Heimløsa Rus was very memorable, and reading about it got me to miss the sea again. Time to talk again with Mikael about a sailing trip...


Open Source Consulting for the Government

Posted on 2004-06-09 15:33:53 UTC to . 0 comments.

Here in Finland the government has been pushing Open Source for a while already.

The Ministry of Finance started an Open Source examination project back in 2001, and made openness of code and interfaces a recommendation for governmental information systems (also in Finnish).

In addition, the Ministry of Interior is funding the Finnish Center for Open Source Software (COSS), an Open Source advocacy group.

The number of areas where Open Source products and solutions are applicable, is increasing steadily. COSS aims at recognizing the key sectors where needs and possibilities for Open Source are most urgent, and directs its efforts towards them.

COSS contacted me last week, and we will have to see how Nemein could work together with them. Cooperation with Open Source business incubators like Linux Greenhouse could also be interesting.

Midgard has already made some inroads to government use, including running the New Zealand eGovernment portal (see case study).

The Other Side of Pitkäsilta

Posted on 2004-06-09 16:00:54 UTC to . 0 comments.

Kallio is the "worker area" of Helsinki, with a very colorful reputation. It is also a very lively place, with its share of bars, public saunas and ethnic restaurants. Kallio is also the center of socialist 1st of may celebrations.

The album has many snippets of information on Kallio in Finnish, and features old photos from beginning on 20th century, with comparisons to how Kallio looks today.

Paska-G's Sprint Rally

Posted on 2004-06-10 22:08:22 UTC to . 0 comments.

The rally will start tomorrow from Helsinki and hopefully end up to Hammerfest, Norway, near the North Cape. Of course, with such cars nothing will be certain.

Our car, dubbed Muerte Despacio is a black eighties Fiat Uno. We painted the car yesterday, with the Paska-G logo, red stripes, flowers and flames (courtesy of Kerttu).

If the car holds up, we should be back around sunday. But before that there should be a reasonable number of adventures, poetry in west Finland and swim in the Arctic ocean.

Each car's team will be maintaining a travel log via SMS:
The SMS gateway has shown a tendency of crashing, but Kaukola has promised to monitor it over the weekend. Thanks!

At the time of writing, weather is +6C in Hammerfest. You can monitor it with this:
Helsinki weather Hammerfest weather

Updated 2004-06-14 11:06: The Sprint ended yesterday. We won. When the SMS gateway worked it was very cool, but there were some stability issues.

Paska-G's Sprint is Over - We Won

Posted on 2004-06-13 14:31:57 UTC to . 0 comments.


Our main advantage in the rally were the tight, coordinated pit stops. The longest stop with refueling, refreshing the team and washing the windscreen took 2 minutes and 39 seconds. In total there were six gas breaks. Our black leather team clothes must also have helped in winning.

The race was at its best when we had some very tight chase scenes with the Fc Smurffit team. Especially the turning point in Hammerfest was exciting.

All cars finished the race successfully, with the last team arriving to finish almost 10 hours behind us.

Berners-Lee Gets the Millenium Technology Prize

Posted on 2004-06-14 21:02:56 UTC to . 0 comments.

The honor, which is accompanied by one million euros, is bestowed by the Finnish Technology Award Foundation as an international acknowledgement of outstanding technological innovation that directly promotes people's quality of life, is based on humane values, and encourages sustainable economic development.

While many people in Finland have commented that this kind of vanity awards are a waste of public money, I believe that in this case it went to the right person. In addition to being the inventor of WWW, Berners-Lee also directs the World Wide Web Consortium (W3C).

I heartily recommend his book Weaving the Web on the background story of how the Web was formed.

In the meanwhile, Finnish industry has just donated additional 10 million euros to the technology award foundation, and advocate the government to raise the total sum to 25 million.

Updated 2004-06-17: Digitoday reports that Berners-Lee's technology prize has gotten much media attention in USA and nine European countries. For example, International Herald Tribune writes:

If Tim Berners-Lee had decided to patent his idea in 1989, the Internet would be a different place.

...

That is why some people think it is fitting - or about time - that he finally becomes wealthy, with the award Tuesday of the world's largest technology prize, the Millennium Technology Prize from the Finnish Technology Award Foundation. The E1 million, or $1.2 million, prize for outstanding technological achievements that raised the quality of life is supported by the Finnish government and private contributors.

OSCOM 4 Is Coming

Posted on 2004-06-15 15:15:15 UTC to . 0 comments.

The theme of OSCOM.4 is "Cross-Pollination". This will be a conference with assistance from the Apache Software Foundation for the ApacheTracks content.

The Open Source content management community is rich and varied with many projects such as OpenCMS, Plone, Midgard, Cofax, Drupal, and many others. Almost all Open Source CMS rely on software from the Apache Software Foundation (ASF), and we look forward to lots of cross-pollination between the Apache and CMS communities. In addition, market awareness is rapidly growing, with several Open Source CMS and ASF projects being mentioned favorably in recent analyst reports.

While I will mostly be working as an organizer, I'm also planning to submit a proposal on a Practical CMS interop sprint.

Updated 18:42: Apache sessions will be called ApacheTracks instead of ApacheCon Europe.

Minor Blog Updates

Posted on 2004-06-15 19:06:34 UTC to . 0 comments.

Commenting was implemented with the net.nemein.discussion component using the methods described on Midgard site. Since I'm starting to get overwhelmed with spam, commenting my blog posts might be a good way to reach me.

So far all commenters will only be identified as "Anonymous Poster". I might provide some friends later with their own accounts to make moderation easier.

There have also been some background changes, including wider CSS layout box for the MidCOM authoring interface, upgrade to Aegir 1.0.3 nightly and nicer configuration for the HTMLAREA editor. Now the toolbar includes image insertion and <blockquote /> support:


Updated 2004-06-16: Here is the toolbar configuration snippet from /sitegroup-config /midcom.helper.datamanager.widget_html /config:
<?php

$nav = new midcom_helper_nav($GLOBALS["view_contentmgr"]->viewdata["context"]);
$leafid = $nav->get_current_leaf();
$leaf = $nav->get_leaf($leafid);
$leaftrueid = explode('/',$leaf[MIDCOM_NAV_URL]);
$leaftrueid = $leaftrueid[1];

$result = <<<EOF

// FIELD {$this->_fieldname} HTMLAREA init script START
var {$this->_fieldname} = null;

function {$this->_fieldname}_init() {

if (!document.getElementById("{$this->_fieldname}")) {
return;
}

config = new HTMLArea.Config();
config.imgURL = "{$prefix['images']}";
config.popupURL = "{$prefix['htmlarea']}popups/";
config.bodyStyle = "background-color: #fff;";
config.statusBar = false;
config.formatblock = {
"Heading 2": "h2",
"Heading 3": "h3",
"Normal": "p",
"Quote": "blockquote",
"Formatted": "pre"
};

config.registerButton("insertimage2", "Lisää kuva", "29eda1118f1e58028a3198e2a9c77271/ed_image.gif", false,
function(editor, id) {

chooser = window.open("/aegir/rcs/image/popup/?type=article&id=$leaftrueid&htmlarea=Y&hostid=", "chooser","height=450,width=400,modal=yes");
chooser.ifield = editor;

}
);

config.toolbar = [
[ "formatblock", "bold", "italic", "separator",
"justifyleft", "justifycenter", "justifyright", "separator",
"insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
"createlink", "insertimage2", "inserttable", "htmlmode","popupeditor"]
];

{$this->_customconfig}
{$this->_fieldname} = new HTMLArea("{$this->_fieldname}",config);
{$this->_fieldname}.generate();
};

// FIELD {$this->_fieldname} HTMLAREA init script END

EOF;
?>

Porkkalan Meripelastajat now in Midgard CMS

Posted on 2004-06-16 11:03:25 UTC to . 0 comments.

Midgard CMS and MidCOM enable the organization to easily maintain their information, announcements and photos on the website.

The site layout was designed by Henri Kaukola and implemented in XHTML and CSS using standards based web design methods.

Hosting for the website is provided by our partner Finnish Teleservice Center. User training is handled by TMV-Vision.

TMV-Vision has a news release in Finnish about the site launch.

OpenPSA User Documentation Online

Posted on 2004-06-16 16:35:36 UTC to. 0 comments.

The most complete sections are Personnel, Projects and Sales.

Whole OpenPSA documentation section is Open Content available under a Creative Commons license.

On Oracle's CMS Patent

Posted on 2004-06-17 16:10:35 UTC to . 0 comments.

The patent abstract explains how a Web CMS works:

A web site creation and maintenance system permits distributed control and centralized management of a web site. The physical implementation of the web site resides on a database maintained by a database administrator. The web site system permits a site administrator to construct the overall structure, design and style of the web site. This allows for a comprehensive design as well as a common look and feel for the web site. The web site system permits content for the web site to originate from multiple content contributors...

This is all clearly stuff that Midgard CMS and other CMSs have been doing for a long time before the patent was filed. There was even an Oracle port of Midgard available at almost the same time the Oracle guys applied for their patent.

Normally ludicrous American software patents like this wouldn't worry me, but now that they will also start to apply in European Union, it is a bit scarier.

Midgard CMS was released to public in May 8th 1999, and the Oracle patent was filed in March 31st 2000, so we have easily provable prior art.

There is some discussion on midgard-user on what to do about this. One way would be to approach The Public Patent Foundation. As the problem applies to all database-based content management systems and not only Midgard, it might even make sense for OSCOM act on it.

No ePatents!

Making Web Scripts Validate

Posted on 2004-06-20 23:05:35 UTC to . 0 comments.

When standards-conscious designers validate their XHTML and CSS templates, everything is nicely compliant up until the point where they start tying in the necessary automated systems like ad software, CMSes, or e-commerce apps. The tools then get in the way and code is needed to fix validation, but a lot of designers don’t code.

This is a serious issue if we want to enable standards-based web design or web browsing with wider range of devices like mobile phones and screen readers.

Most Open Source CMSs seem to either make it impossible or difficult to create valid websites with them. For example, when implementing my personal website, I had to make several patches to different MidCOM components to make it validate. And even now some pages have issues, not to mention that the content created with my current WYSIWYG editor doesn't go through any validation or clean-up loop.

This used to be an issue CMS developers didn't think much about. However, as XHTML is becoming more common the level of importance is rising. Dave Shea gives some ideas on how to improve the situation:

What we need is to start working together like this on a larger scale. You’ve gone to lengths to programmatically fix improperly nested tags? Great, write it up. You have a killer PHP function for parsing out raw ampersands that can be copied and pasted into a site-wide header? Perfect, share it. You can make a bad tool better? Do it! We don’t have to keep re-inventing the wheel for every new site, we can build common code bases that make validation painless and share them.

Valid XHTML output will be important step in the practical CMS interop plan. XHTML and CSS are not yet listed as standards endorsed by OSCOM. While most CMSs deal with more than just the web, these should be the base output standards used for that particular medium.

Tampere Experience

Posted on 2004-06-21 07:12:56 UTC to . 0 comments.

On friday we ate well in the Viking restaurant Harald, and enjoyed some beers in the Plevna microbrewery. Walking around in the Finlayson area of 19th century industrial architecture was also very nice.

Unfortunately the Center party had their national convention in the city during the weekend, and we had trouble finding accommodation. With luck we were finally able to get what was probably the last free double room in Tampere from Hostel Uimahallin Maja. 54€ per night was quite reasonable for a large room with capacity for up to four people and view to the park near Pirkankatu.

We started the saturday with coffee and strawberries on a pier and listening to a brass band. After that we visited the Lenin museum.

The main event for the day was visiting the Vapriikki museum complex, where there were three very interesting exhibitions: Samurai - Thousand Years of Cults and Culture, Life in the Past Lane - Motorcycles from the 50s and Palace of Knowledge - Treasures from Kunstkammer, St. Petersburg. All three can be visited with a single ticket and are highly recommended.



All in all, a very good Tampere experience.

Planets and Reading Lists

Posted on 2004-06-21 19:37:53 UTC to . 0 comments.

My full weblog is aggregated to Planet Midgard, Summer Source Blogs and Midgard developers on OSCOM.

In addition to aggregating all posts, the Midgard category is aggregated to Planet PHP, the Business category to Linux Greenhouse Blogs and the OSCOM category to Planet OSCOM. OpenPSA News are generated from my OpenPSA category.

These aggregators combined with people reading the weblog with news readers has ensured that RSS is by far the most popular way of accessing my website.

RSS is also my main method of accessing news and weblog postings. Currently my NetNewsWire Lite is following 83 different news feeds, mainly from the technical and web design communities.

I've now made my subscription list public in OPML format. This file can be imported into a news reader to get started with a good set of web and CMS related subscriptions.

Standard Labels in XHTML Layouts

Posted on 2004-06-21 19:56:50 UTC to . 0 comments.

Using standard CSS classes was one of the ideas I posted on practical CMS interop. If different Content Management Systems and web scripts could standardize on these keeping layouts synchronized between them would be very easy.

In his follow-up, Andy provides a more detailed list and structure of IDs to use. This could well be the starting point for standardization.

Updated 2004-06-23 16:20: Gregor J. Rothfuss followed up on the idea, and proposed an OSCOM skin repository of CSS styles for the common elements.

The story was also picked up by CMS Watch.

Updated 2004-08-11 14:24: Thorsten Scherler will hold a session on CSS naming conventions on Sep. 29th in the OSCOM 4 conference in Zürich, Switzerland.

Nemein's New Visual Guidelines

Posted on 2004-06-23 15:28:20 UTC to . 0 comments.

Over half of the new business Nemein gets comes through the Web site, so it makes sense to put some effort into improving it. The old site was very product-focused and didn't really communicate how the company works.

Design goals for the new site included:
  • Highlight solutions instead of the (Open Source) products behind them
  • Highlight Nemein's client list and some case studies
  • Explain why Open Source and Open Standards are important
  • Replace boring press releases with more current blog postings from Nemein consultants
  • Showcase how Nemein works on pro bono basis with some NGOs and Open Source projects
Some example layouts:
We would be very happy to get some feedback on the designs as weblog comments.

The site will be implemented with Midgard CMS using Web standards like XHTML and CSS.

Content Creation with SMS

Posted on 2004-06-30 20:06:17 UTC to . 0 comments.

The SMSs are sent to an old Ericsson R520 mobile phone which is connected to a Linux box running gsmsmsd from gsmlib. New SMSs are forwarded to Routa MC as emails, which are imported into Midgard using fetchmail and the OpenPSA mail import script supportmda.pl.

Then the SMSs are handled by a Midgard page which has the following code:

<?php
/*
Routa MC Travel Journals
SMS logbook upload handler

Henri Bergius <henri.bergius@iki.fi>

Based on snippet /TechSupport/UI/Handlers/Email-import
from OpenPSA (www.openpsa.org)

2004-06-30: Adapted from the Paska-G:n Sprintti upload handled (bergie)

Each topic to be handled by this system must have parameters
RoutaSMS/number/name set for matching the incoming SMSs to
articles and authors.

If notifications are required, they are handled by adding
parameters in format RoutaSMSsubscribe/name/email to the
root topic.

Note: the mail transfer agent expects to receive uppercase
OK when the mail has been successfully processed. If that is
missing or uppercase ERROR has been transmitted the email
will not be removed from server.
*/

// GUID to the topic where log topics reside
$routasms_topic_guid = "c4b2f1bead1f8a25f4c553ef4fe5a546";

// GUID of article where unrecognized messages are sent or NULL
$routasms_misc_article = null;

// User account for updating log articles
$routasms_username = "USERNAME";
$routasms_password = "PASSWORD";

// SMS receiver email address to remove from messages
$routasms_email_receive = "gateway@myorganization.org";

// Whether to enable email notifications
$routasms_notifications_enabled = true;
$routasms_notifications = array();

// Start buffering for the log
header("Content-type:text/plain");
ob_start();
echo "=================================================\n";
echo "DEBUG: Started email handling on ".date("Y-m-d H:i",time())."\n";
echo "DEBUG: User-Agent: ".$_SERVER['HTTP_USER_AGENT']."\n";

// Load the log topic
$routasms_topic = mgd_get_object_by_guid($routasms_topic_guid);
echo "DEBUG: Loaded topic ".$routasms_topic->name." (#".$routasms_topic->id.")\n";

// Function for logging the output
function routasms_log() {
$data = ob_get_contents();
//write the contents to a file
$fp = fopen("/tmp/routasms-upload.log","a");
fwrite($fp,$data);
fclose($fp);
// Output the status
ob_end_flush();
}

// Don't bother to even initialize anything if we don't have anything to process
if (!$_REQUEST["mailbody"]) {
echo "ERROR: No body received\n";
routasms_log();
exit();
} else {

// Check that we got the whole email
echo "DEBUG: got body, reported size=".$bodysize."b actual size=".strlen($mailbody)."b\n";
if ($_REQUEST["bodysize"] != strlen($_REQUEST["mailbody"])) {
echo "ERROR: Reported and actual bodysize different, transfer error ?\n";
routasms_log();
exit();
}

// Load Mail class from OpenPSA
mgd_include_snippet("/Nemeinnet_Core/Mail");

// Load NemeinRCS revision control script
mgd_include_snippet("/AegirCore/config/config");
global $rcsroot;
$rcsroot = $set["rcsroot"];
if (!$rcsroot) {
$rcsroot = "/var/lib/aegir/cvs";
}
echo "DEBUG: Set revision control root to ".$rcsroot." (got ".$set["rcsroot"]." from Aegir)\n";
mgd_include_snippet("/AegirCore/lib/rcs_functions");

// Load NemeinJournal classes
mgd_include_snippet("/NemeinJournal/Core/init");

// Authenticate the user if needed
if (!$midgard->user) {
mgd_auth_midgard($routasms_username, $routasms_password, 0);
$midgard = mgd_get_midgard();
if (!$midgard->user) {
echo "ERROR: No user authenticated (or authentication error)\n";
routasms_log();
exit();
}
}
$user = mgd_get_person($midgard->user);
echo "DEBUG: Authenticated user ".$user->name." (#".$midgard->user.")\n";

// Parse the email
$mail=new nemeinnet_mail();
$mail->body=$_REQUEST["mailbody"];
$mime=&$mail->mimeDecode();
echo "DEBUG: decoded body size ".strlen($mail->body)."b\n";

// Get the sending phone number
$name_preg="/[\"']?([^<@\"']*)[\"']?/";
preg_match($name_preg, $mail->from, $name_matches);
$routasms_number = preg_replace("/\.|_/", " ", $name_matches[1]);
echo "DEBUG: SMS sent by number ".$routasms_number."\n";

// Get the log message
$routasms_message = $mail->body;

// Remove receiver email address from message
$routasms_message = str_replace($routasms_email_receive." ","",$routasms_message);

// Get the log time
// TODO: read from the email
$routasms_time = time();

// Log article object
$routasms_log = false;

// Name of the sender
$routasms_sender = false;

// Load the log topics
$log_topics = mgd_list_topics($routasms_topic->id);
if ($log_topics) {
while ($log_topics->fetch()) {

// Load phone numbers
$number_params = $log_topics->listparameters("RoutaSMS");
if ($number_params) {
while ($number_params->fetch()) {

// Match with sending number
if ($number_params->name == $routasms_number) {
echo "DEBUG: SMS number matched with topic ".$log_topics->title." (#".$log_topics->id.")\n";
$routasms_sender = $log_topics->parameter("RoutaSMS",$number_params->name);

$routasms_log_topic = mgd_get_topic($log_topics->id);

// Load notification subscriber list
$notification_params = $routasms_log_topic->listparameters("RoutaSMSsubscribe");
if ($notification_params) {
while ($notification_params->fetch()) {
$routasms_notifications[$notification_params->name] = $routasms_log_topic->parameter("RoutaSMSsubscribe",$notification_params->name);
}
echo "DEBUG: Loaded ".count($routasms_notifications)." notification subscribers\n";
}

// Check if sender wants to create new entry
if (stristr(substr($routasms_message,0,6),"NEWLOG")) {

// Read the title of the new entry
$routasms_newlog_title = substr($routasms_message,7);
echo "DEBUG: Received NEWLOG command for entry \"".$routasms_newlog_title."\"\n";

// Create new NemeinJournal entry
$routasms_newlog = new journal_entry();
$routasms_newlog->topic = $routasms_log_topic->id;
$routasms_newlog->title = $routasms_newlog_title;
$routasms_newlog_id = $routasms_newlog->save();
if ($routasms_newlog_id) {
echo "DEBUG: Created new NemeinJournal entry #".$routasms_newlog_id."\n";

// Send notifications on the new journal entry
if ($routasms_notifications_enabled && count($routasms_notifications)) {
foreach ($routasms_notifications as $name => $email) {
// Send the notification in format supported by Nemein's SMS gateway
mail('"'.$name.'" <'.$email.'>','New journal entry '.$routasms_log->title.' ('.$routasms_log_topic->name.') was created by '.$routasms_sender,$routasms_log_topic->name.": New entry \"".substr($routasms_message,7)."\"",'From: "'.$routasms_topic->extra.'" <'.$routasms_email_receive.'>');
echo "DEBUG: mailed notification to \"".$name."\" <".$email.">\n";
}
}


// Entry has been created, exit
echo "OK\n";
routasms_log();
exit();
} else {
echo "ERROR: Failed to create NemeinJournal entry, reason ".mgd_errstr()."\n";
}

} else {
// Fetch the latest log entry article
$log_topics_articles = mgd_list_topic_articles($routasms_log_topic->id);
if ($log_topics_articles) {
if ($log_topics_articles->fetch()) {
echo "DEBUG: Loaded latest NemeinJournal entry #".$log_topics_articles->id."\n";
$routasms_log = new journal_entry($log_topics_articles->id);
}
} else {
echo "ERROR: No NemeinJournal entries found in topic\n";
// TODO: create empty log item??
}
}
}

}
}

}
} else {
echo "ERROR: No log topics under root topic\n";
routasms_log();
exit();
}

// Load the misc article if possible
if (!$routasms_log && $routasms_misc_article) {
echo "DEBUG: SMS number didn't match, loading misc article\n";
$routasms_log = mgd_get_object_by_guid($routasms_misc_article);
}

// Default to sending number as sender name
if (!$routasms_sender) {
$routasms_sender = $routasms_number;
}

// Store the message to the log
if ($routasms_log) {
// Start the message block
$routasms_log->content .= "<p>\n";
// Store message
$routasms_log->content .= $routasms_message;
// Store date
$routasms_log->content .= "\n <em>(".date("Y-m-d H:i",$routasms_time);
// Store sender
$routasms_log->content .= " - ".$routasms_sender.")</em>\n";
// End the message block
$routasms_log->content .= "</p>\n";
// Save the log
if (get_class($routasms_log) == "journal_entry") {
// NemeinJournal uses save() method instead of Midgard's standard update()
$status = $routasms_log->save();
} else {
$status = $routasms_log->update();
}
if ($status) {

// Send notifications on the journal entry update
if ($routasms_notifications_enabled && count($routasms_notifications)) {
foreach ($routasms_notifications as $name => $email) {
// Send the notification in format supported by Nemein's SMS gateway
mail('"'.$name.'" <'.$email.'>','Journal entry '.$routasms_log->title.' ('.$routasms_log_topic->name.') updated by '.$routasms_sender,$routasms_log_topic->name.": ".$routasms_message,'From: "'.$routasms_topic->extra.'" <'.$routasms_email_receive.'>');
echo "DEBUG: mailed notification to \"".$name."\" <".$email.">\n";
}
}

// Update revision control information
rcs_update($routasms_log);

// Message was saved successfully, say OK
echo "OK\n";

} else {
echo "ERROR: Failed to save log article, reason ".mgd_errstr()."\n";
}
} else {
echo "ERROR: No log article found\n";
routasms_log();
exit();
}
}
// Log status
routasms_log();
?>

The phone has had a tendency to crash, but Rambo is looking to fix that.

Back