| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Implementation of hook_menu().
|
| 5 |
*/
|
| 6 |
function gnokii_menu() {
|
| 7 |
$items['gnokii/outgoing'] = array(
|
| 8 |
'page callback' => 'gnokii_outgoing',
|
| 9 |
'type' => MENU_CALLBACK,
|
| 10 |
'access callback' => TRUE,
|
| 11 |
);
|
| 12 |
$items['gnokii/incoming'] = array(
|
| 13 |
'page callback' => 'gnokii_incoming',
|
| 14 |
'type' => MENU_CALLBACK,
|
| 15 |
'access callback' => TRUE,
|
| 16 |
);
|
| 17 |
return $items;
|
| 18 |
}
|
| 19 |
|
| 20 |
function gnokii_outgoing() {
|
| 21 |
$data = db_fetch_array(db_query("SELECT mid, number, message FROM {gnokii} WHERE status = 0 LIMIT 1"));
|
| 22 |
print 'number=' . $data['number'] . '&message=' . $data['message'];
|
| 23 |
db_query("UPDATE {gnokii} SET status = 1 WHERE mid = %d", $data['mid']);
|
| 24 |
exit();
|
| 25 |
}
|
| 26 |
|
| 27 |
function gnokii_incoming() {
|
| 28 |
sms_incoming($_POST['number'], $_POST['message']);
|
| 29 |
}
|
| 30 |
|
| 31 |
function gnokii_gateway_info() {
|
| 32 |
return array(
|
| 33 |
'gnokii' => array(
|
| 34 |
'name' => 'gnokii',
|
| 35 |
'send' => 'gnokii_gateway_send',
|
| 36 |
'receive' => TRUE,
|
| 37 |
),
|
| 38 |
);
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Callback for sending messages.
|
| 43 |
*/
|
| 44 |
function gnokii_gateway_send($number, $message) {
|
| 45 |
// Queue the message in the database for the daemon
|
| 46 |
db_query("INSERT INTO {gnokii} (number, message, status) VALUES('%s', '%s', %d)", array($number, $message, 0));
|
| 47 |
}
|