variable_get('tribune_colissimo_name', "Colissimo"),
);
if (variable_get('tribune_colissimo_authentified', FALSE)) {
$answer['login'] = $answer['info'];
}
if (preg_match(':^/'. t('colissimo') .'(.*)$:', $post['message'], $matches)) {
$args = $matches[1];
$response = _tribune_colissimo_status($args);
if ($response['error']) {
$answer['message'] = $response['error'];
} else {
$answer['message'] = $response['text'];
}
$answer['message'] = tribune_filters_print_clock($post) ." ". $answer['message'];
return array($answer);
}
}
function _tribune_colissimo_status($id) {
$url = "http://www.coliposte.net/ec/suivi_ec.jsp?colispart=". urlencode($id);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = str_replace("\n", " ", curl_exec($ch));
$result = iconv("ISO-8859-1", "UTF-8", $result);
$result = html_entity_decode($result, ENT_QUOTES, "UTF-8");
preg_match_all(':
.*'.
'(.*).*'.
'(.*).*'.
'(.*).*'.
'(.*).*'.
'
:Um', $result, $matches, PREG_SET_ORDER);
$status = "";
foreach ($matches as $match) {
$date = trim($match[1]);
$cp = trim($match[2]);
$desc = trim($match[3]);
$centre = trim($match[4]);
if (preg_match(':(.*)\W*\((.*)\).*:Um', $centre, $array)) {
$centre = trim($array[1])." (".preg_replace("/[^0-9]/", "", $array[2]).")";
}
$status .= t("!date - !centre !desc ", array('!date' => $date, '!desc' => $desc, '!centre' => $centre));
}
return array('error' => FALSE, 'text' => $status);
}
function tribune_colissimo_settings() {
$form = array();
$form['tribune_colissimo_name'] = array(
'#type' => "textfield",
'#title' => t("Display name"),
'#default_value' => variable_get('tribune_colissimo_name', "Colissimo"),
);
$form['tribune_colissimo_authentified'] = array(
'#type' => "checkbox",
'#title' => t("Appear to be authentified"),
'#default_value' => variable_get('tribune_colissimo_authentified', FALSE),
'#description' => t("Whether this filter will appear to be 'anonymous' or 'authentified'. Since the filter does not correspond to a real user, posting as authentified may result in 'nickname collisions'."),
);
return system_settings_form($form);
}