JMonitoring, a permanent eye on your Joomla! sites
For developers
<!--?php
// no direct access
defined('_JEXEC') or die('Restricted access');
//Load JMonitoringPlugin class
require_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_jmonitoringslave'.DS.'jmonitoringpluginmonitoring'.DS.'jmonitoringpluginmonitoring.php');
class plgJmonitoringplg_jmon_users extends JMonitoringPluginMonitoring
{
function onMonitoringCall($oldValuesSerialized = null)
{
$this--->setName("checkUsers");
$this->setDescription("Checks if a new user is registered");
$db =& JFactory::getDBO();
$db->setQuery("SELECT id from #__users ORDER BY id ASC");
$usersIds = $db->loadResultArray();
$usersList = implode($usersIds);
$oldValue = $this->readExJMonitoringValue($oldValuesSerialized);
if($oldValue == null)
{
$this->createJMonitoringValue('checkUsers', $usersList);
}
elseif($oldValue != $usersList)
{
$this->createJMonitoringAlert(2,"Users have changed");
$this->updateJMonitoringValue('checkUsers', $usersList);
}
return $this;
}
}
?>
<!--?php
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
//Authentification class for twitter
require 'tmhOAuth.php';
/*
* This class manages plgJmonitoringalertTwitter.
*
*/
class plgJmonitoringalertTwitter extends JPlugin {
function onAlertCall($sites) {
foreach ($sites as $site) {
//send errors
foreach ($site['errors'] as $error) {
$message = $this--->params->get('beforetext')." ";
$message .= $site['site']['name']." ".$error." ";
$message .= $this->params->get('hashtag');
$this->sendTweet($message);
}
//send informations
foreach ($site['informations'] as $information) {
$message = $this->params->get('beforetext')." ";
$message .= $site['site']['name']." ".$information." ";
$message .= $this->params->get('hashtag');
$this->sendTweet($message);
}
}
}
function sendTweet($message) {
//twitter authentification
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $this->params->get('consumer_key'), //entrer vos clés
'consumer_secret' => $this->params->get('consumer_secret'),
'user_token' => $this->params->get('user_token'),
'user_secret' => $this->params->get('user_secret'),
'debug' => '1'
));
$tmhOAuth->request('POST', $tmhOAuth->url('statuses/update'), array(
'status' => utf8_encode($message)
));
}
}
?>
JMonitoring ? Why ?
The more websites you have, the more JMonitoring you will need. Checking a list of websites is a complicated task and that is why JMonitoring has been developped.