Macrotone Blogs

Macrotone blogs upon Joomla, our products and other matters.

Running scheduled (cron) tasks with Joomla

joomlaWe have recently developed a feature with one of our components to make use of a scheduled task to perform a repetitive action, which avoids the need for us to enter the site and manually click upon various icon(s) which in turn cause the required action(s) to occur. Such a requirement is reasonably common and includes things such as sending scheduled emails etc. We were expecting it to be difficult to implement but as it turned out was pleasantly easy to achieve.

Upon UNIX based systems ‘Cron’ is a daemon that provides a time-based job scheduler that runs in the  background on UNIX systems that executes commands at specified intervals. These commands are called "cron jobs."  Windows servers use a Scheduled Task to  execute commands. Typically a task requiring repetitive actions  to be carried out on a regular (pre-determined) basis would be ideal candidates for using ‘cron’.

There are basically a few methods that can be used to provide a  scheduled task within Joomla. The preferred method will depend upon the specific web hosting supplier and the facilities they supply. [For our implementation it was necessary to supply both mechanisms, since some of our users’ systems may not have one or the other.]

Continue reading

reCAPTCHA updated by Google

We have noticed recently that on some sites, that Google’s reCAPTCHA have included a number of numeric challenges instead of characters. We didn’t take much interest at the time but mentally noted it.

Google has today rolled out an updated version of its reCAPTCHA system.  We first saw the details herereCAPTCHA is a user-dialogue system originally developed by Luis von Ahn, Ben Maurer, Colin McMillen, David Abraham and Manuel Blum at Carnegie Mellon University's main Pittsburgh campus, and acquired by Google in September 2009. CAPTCHA stands for “Completely Automated Public Turing test to tell Computers and Humans Apart”, and as its name implies, it is a quick test used in computing to determine whether or not the user is human, and one has probably seen it many times on different sites, and we even use it upon our own, however we still seem to be displaying character strings.

http://techglam.com/wp-content/uploads/2013/10/reCAPTCHA.jpg

Generally reCAPTCHA  presents two words (and the term words is used loosely): one which it knows (used to test whether you are human), and one which it doesn’t (used to help digitize the text in books). Since humans find numeric CAPTCHAs (pictured above) significantly easier to solve than those containing arbitrary text, Google will be showing you more and more numbers, which explains our observations. So we can expect to see it more often.

Using an IDE for Joomla development

phpstormWe have never really taken to using an Integrated Development Environment tool (IDE) for product development.  This is nothing against IDE’s per se, just that over the years we have used a lot of tools, some good, some bad, and have found that just when one starts getting productive with them, they suddenly stop being supported.  We could name (but won’t) numerous tools that fall into that category.  A lot end up being taken over by a certain well known ‘computer software vendor’ who then milks them for the support fees, but never develops them, before finally dropping them. This then leave one ‘high and dry’ and forced to change to another tools.

Continue reading

Changing Joomla MySQL database connection details

mysqlWe recently had cause to have to modify the connection details that a Test Joomla setup was using to connect to the underlying database.  The reason was that we wanted to test out a component installation where some specific database privileges had not been granted.

In out case we were interested in the database privileges ‘CREATE VIEW’, ‘CREATE ROUTINE’ and ‘TRIGGER’. Since our component would make use of database triggers, procedures and views we needed to test out an installation on a system where such grants were not present.

Our systems had the required privileges granted and we knew that editing the ‘configuration.php’ file in the existing Joomla installation should enable us to achieve this easily, but despite our attempts this wouldn’t work and instead gave us an error: ‘Database connection error (3): Could not connect to database ‘.

We played with the username and password settings in the ‘configuration.php’ file without any success it just wouldn’t connect and we knew that we had another database set up with the same username and password.

Then we remembered that we had only granted permissions for this ‘restricted’ database account to a specific database.  All we had to do was ensure that the correct grants were made for our 'second database’.

   1:  CREATE USER 'test'@'localhost' IDENTIFIED BY 'password';           -- Not required if the user already exists.
   2:  GRANT SELECT, INSERT, UPDATE, DELETE ON DBX.* TO 'test'@'localhost';
   3:  CREATE USER 'test'@'%' IDENTIFIED BY 'password';                    -- Not required if the user already exists.
   4:  GRANT SELECT, INSERT, UPDATE, DELETE ON DBX.* TO 'test'@'%';
   5:   
   6:  GRANT LOCK TABLES, CREATE TEMPORARY TABLES, CREATE, DROP, INDEX, ALTER ON DBX.* TO 'test'@'localhost';
   7:  GRANT LOCK TABLES, CREATE TEMPORARY TABLES, CREATE, DROP, INDEX, ALTER ON DBX.* TO 'test'@'%';

 

Where test is the name of your connection user, password is whatever your desired password is, and DBX is the name of your MySQL database.  Obviously if your database is not on your localhost you need to modify it for the appropriate host name or IP address, which ever is most apt.

Once we had done this it all worked perfectly and our testing could commence.

A new Audit tool for Joomla

auditAbout a week ago we released a new component for Joomla named JAudit.

Running upon Joomla 2.5 and Joomla 3.x this is a comprehensive auditing component that makes use of the underlying database to log changes made to the Joomla tables. It does not require any changes to Joomla core code and should work without impacting any Joomla functionality. The component requires that the system has been granted the appropriate database privilege to create database triggers.

We have long believed that if you are using a fully featured database upon your Joomla site it seems ‘silly’ to not make use of the features that the database provides.  Databases these days are very feature rich and it is only necessary to look at the possibilities of these features to realise just how much one is missing out upon. One analogy that brings this home, might be ‘Would you pay for a Ferrari and only drive it around in first gear?’

Continue reading

Debugging PHP with Java console.

b2ap3 thumbnail joomlaIt may seem a strange title for a blog, but we have been looking at a small ‘opportunity’ in converting one of our components to Joomla 3.x.

First a brief explanation is required. The module in question is a PHP module which calls some Javascript code which in turn then calls a separate PHP routine.  The error we were trying to resolve involved this ‘second’ PHP routine.  The module was designed to display a Google map and the first PHP module sets up the display, the Javascript code builds up the required map and it is in turn, populated with data obtained from the database and formatted by the second PHP routine.

This ‘inner’ PHP routine was working perfectly on Joomla 2.5 but on Joomla 3.1 only the map itself was displayed, not the 'map points’.  It was apparent therefore that there must be ‘code’ that was not Joomla 3.x compatible but how to find it.  Code inspection did not reveal any apparent cause. The changes to remove JRequest and replace it with JInput were working fine, and attempts to use print, dump, enqueueMessage, etc. statements were accepted but would never display any information which one could see.  [This might possibly be due to our trying to display text ‘after’ the ‘error point’, but am not totally convinced yet.] Inspection of error logs also were not informative, mainly it is suspected due to the Javascript ignoring the errors and proceeding to execute even after receiving a error from the PHP routine.

Continue reading

Emailing €˜items€™ with relative image URLs from Joomla.

issues-48We have been looking at a small ‘opportunity’ which we discovered when we were emailing material such as an ‘article’ or Issue Tracker ‘issue’ from our Joomla system.

The problem is quite simple to explain since it can be caused by the content editor that is forced to use relative URLs.

This can be resolved by creating a new profile in the editor (such as JCE) which is configured to use absolute urls and then assign the profile to the particular component where absolute URLs are needed.

There is a small note on it for JCE which explains how to do this in more detail.

Continue reading

Trouble Shooting Flow Chart

In a similar vein to our last Humorous post I also recall the proverbial Trouble Shooting Flow chart, a couple of which I show suitably bowlerized below.

This diagram and others that are similar are said to have circulated on the internet before it was the known as the ‘internet’ but is nonetheless certainly a distant iteration of the original.

Continue reading
Tags:

Rush Job Calendar

Sometimes the ‘old’ jokes are the best and we were reminded of this the other day when we were asked if we could add some new features to one of our extensions.

There are a few variations of this around but they all basically ‘resolve’ the same problem.

Mirday Friday Friday Friday Thursday Wednesday Tuesday
8 7 6 5 4 3 2
16 14 13 12 11 10 9
23 22 21 20 19 18 17
32 29 28 27 26 25 24
39 38 37 36 35 34 33

 

  1. This is a special calendar for handling rush jobs. All rush jobs are wanted yesterday. With this calendar a job can be ordered on the 7th and delivered on the 3rd.
  2. Most jobs are required by Friday, so there are three Fridays in every week.
  3. There are eight new days added to each month to allow for end-of-the-month panic jobs.
  4. There is no 1st of the month – thus avoiding late delivery of the previous month’s last-minute panic jobs.
  5. Monday morning hangovers are abolished together with non-productive Saturdays and Sundays.
  6. With no 15th, 30th or 31st, no 'time-off" is necessary for cashing salary cheques or paying bills.
  7. A new day – Mirday’ (sometimes called Negotiation Day) – has been introduced keeping the other days free for uninterrupted panic and for making excuses.
Tags:

Joomla date/time displays and Database vales.

b2ap3 icon joomlaHave been looking at an interesting problem of the display of date/time values on Joomla screens.

First it is apparent from looking at the database stored values that Joomla stores all of the date/time values (calendar) in the database as UTC values, which means that all of the stored values are consistent.

However when these are displayed upon a form or in a tabular form, care has to be taken that the format of the values is consistent.  For example if the displayed value is shown as a ‘text’ field, the values stored in the database (UTC) is displayed, which is not necessarily the ‘local’ time.  We are in the London area and currently are using DST (Daylight saving time) which is an hour ahead of UTC (GMT – Greenwich Mean Time) .  One has to make consistent use of the ‘calendar’ type and if necessary make it read-only, thus ensuring the correct value, suitably converted is displayed.

Another complication that we have not yet worked out the cause of is that if using JForm with the calendar type and using the default of ‘NOW’ which should display the local time (according to the documentation),  it displays a time value 8 hours ahead of the local time.  Where is gets that from I am not sure.  i.e.  If local time is 11:30m, the ‘now’ value as determined by the JForm default shows as 19:30.  Go figure!  It was necessary therefore for us to specify the default value as empty and assign a default value in the view based upon the local time so that the form value is correct.

We have therefore decided that to avoid confusion all date/time values should be displayed using local time.

Go To Top

Joomla! Debug Console

Session

Profile Information

Memory Usage

Database Queries