Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MAJOR: update kannel gateway config to use registry, add option to ha…

…ndle SMS incoming time in local time or UTC
  • Loading branch information...
commit 6f8c55991dc316e26d159d08564fedac2fb48ff0 1 parent 119a795
@antonraharja authored
View
4 db/playsms-upgrade-0992-to-100.sql
@@ -28,7 +28,11 @@ DELETE FROM `playsms_tblRegistry` WHERE `registry_group` = 'core' AND `registry_
INSERT INTO `playsms_tblRegistry` (`uid`, `registry_group`, `registry_family`, `registry_key`, `registry_value`) VALUES ('1', 'core', 'config', 'playsms_version', '1.0.0') ;
+-- 1.0-beta3
+
+
-- 1.0.0
UPDATE `playsms_tblRegistry` SET `registry_value` = '1.0.0' WHERE `id` = 1 ;
ALTER TABLE `playsms_toolsPhonebook_group` ADD `flag_sender` INT NOT NULL DEFAULT '0' ;
+DROP TABLE IF EXISTS `playsms_gatewayKannel_config` ;
View
36 db/playsms.sql
@@ -746,42 +746,6 @@ INSERT INTO `playsms_gatewayGnokii_config` VALUES (0,'gnokii','/var/spool/playsm
UNLOCK TABLES;
--
--- Table structure for table `playsms_gatewayKannel_config`
---
-
-DROP TABLE IF EXISTS `playsms_gatewayKannel_config`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `playsms_gatewayKannel_config` (
- `c_timestamp` bigint(20) NOT NULL DEFAULT '0',
- `cfg_name` varchar(20) NOT NULL DEFAULT 'kannel',
- `cfg_incoming_path` varchar(250) DEFAULT NULL,
- `cfg_username` varchar(100) DEFAULT NULL,
- `cfg_password` varchar(100) DEFAULT NULL,
- `cfg_global_sender` varchar(20) DEFAULT NULL,
- `cfg_bearerbox_host` varchar(250) DEFAULT NULL,
- `cfg_sendsms_host` varchar(250) DEFAULT NULL,
- `cfg_sendsms_port` varchar(10) DEFAULT NULL,
- `cfg_playsms_web` varchar(250) DEFAULT NULL,
- `cfg_dlr` int(11) NOT NULL DEFAULT '31',
- `cfg_additional_param` varchar(250) DEFAULT NULL,
- `cfg_datetime_timezone` varchar(30) NOT NULL DEFAULT '',
- `cfg_admin_url` varchar(250) DEFAULT NULL,
- `cfg_admin_password` varchar(50) DEFAULT NULL,
- `cfg_admin_port` int(11) NOT NULL DEFAULT '0'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `playsms_gatewayKannel_config`
---
-
-LOCK TABLES `playsms_gatewayKannel_config` WRITE;
-INSERT INTO `playsms_gatewayKannel_config` VALUES (0,'kannel','/var/spool/playsms','playsms','playsms','','127.0.0.1','127.0.0.1','13131','http://localhost/playsms','31','','','','',0);
-/*!40000 ALTER TABLE `playsms_gatewayKannel_config` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
-- Table structure for table `playsms_gatewayMsgtoolbox`
--
View
46 web/plugin/gateway/kannel/config.php
@@ -1,44 +1,21 @@
<?php
defined('_SECURE_') or die('Forbidden');
-$db_query = "SELECT * FROM "._DB_PREF_."_gatewayKannel_config";
-$db_result = dba_query($db_query);
-if ($db_row = dba_fetch_array($db_result)) {
- $kannel_param['name'] = $db_row['cfg_name'];
- $kannel_param['path'] = $db_row['cfg_incoming_path'];
- $kannel_param['username'] = $db_row['cfg_username'];
- $kannel_param['password'] = $db_row['cfg_password'];
- $kannel_param['global_sender'] = $db_row['cfg_global_sender'];
- $kannel_param['bearerbox_host'] = $db_row['cfg_bearerbox_host'];
- $kannel_param['sendsms_host'] = ( $db_row['cfg_sendsms_host'] ? $db_row['cfg_sendsms_host'] : $kannel_param['bearerbox_host'] );
- $kannel_param['sendsms_port'] = ( $db_row['cfg_sendsms_port'] ? $db_row['cfg_sendsms_port'] : '13131' );
- $kannel_param['playsms_web'] = $db_row['cfg_playsms_web'];
- // Handle DLR options in Kannel - emmanuel
- $kannel_param['dlr'] = $db_row['cfg_dlr'];
- // end of Handle DLR options in Kannel - emmanuel
- $kannel_param['additional_param'] = $db_row['cfg_additional_param'];
- $kannel_param['datetime_timezone'] = $db_row['cfg_datetime_timezone'];
- //fixme edward Adding New Parameter HTTP Kannel Admin
- $kannel_param['admin_url'] = $db_row['cfg_admin_url'];
- $kannel_param['admin_password'] = $db_row['cfg_admin_password'];
- $kannel_param['admin_port'] = ( $db_row['cfg_admin_port'] ? $db_row['cfg_admin_port'] : '13000' );
- //end of fixme edward Adding New Parameter HTTP Kannel Admin
-}
-
-// default path for kannel.conf, please edit the path if different from default
-$kannel_param['kannelconf'] = '/etc/kannel/kannel.conf';
+// get kannel config from registry
+$data = registry_search(1, 'gateway', 'kannel');
+$kannel_param = $data['gateway']['kannel'];
+$kannel_param['name'] = 'kannel';
+$kannel_param['playsms_web'] = ( $kannel_param['playsms_web'] ? $kannel_param['playsms_web'] : _HTTP_PATH_BASE_ );
+$kannel_param['bearerbox_host'] = ( $kannel_param['bearerbox_host'] ? $kannel_param['bearerbox_host'] : 'localhost' );
+$kannel_param['sendsms_host'] = ( $kannel_param['sendsms_host'] ? $kannel_param['sendsms_host'] : $kannel_param['bearerbox_host'] );
+$kannel_param['sendsms_port'] = ( $kannel_param['sendsms_port'] ? $kannel_param['sendsms_port'] : '13131' );
+$kannel_param['admin_host'] = ( $kannel_param['admin_host'] ? $kannel_param['admin_host'] : $kannel_param['bearerbox_host'] );
+$kannel_param['admin_port'] = ( $kannel_param['admin_port'] ? $kannel_param['admin_port'] : '13000' );
+$kannel_param['local_time'] = ( $kannel_param['local_time'] ? 1 : 0 );
// save plugin's parameters or options in $core_config
$core_config['plugin']['kannel'] = $kannel_param;
-//$gateway_number = $kannel_param['global_sender'];
-
-// insert to left menu array
-//if (isadmin()) {
-// $menutab_gateway = $core_config['menutab']['gateway'];
-// $menu_config[$menutab_gateway][] = array("index.php?app=menu&inc=gateway_kannel&op=manage", _('Manage kannel'));
-//}
-
// Test for DLR checkbox
/* DLR Kannel value
1: Delivered to phone
@@ -273,4 +250,3 @@
$checked[4] = "checked";
}
-?>
View
2  web/plugin/gateway/kannel/dlr.php
@@ -41,5 +41,3 @@
}
dlr($smslog_id,$uid,$p_status);
}
-
-?>
View
2  web/plugin/gateway/kannel/fn.php
@@ -137,5 +137,3 @@ function kannel_hook_call($requests) {
logger_print("end load geturl", 2, "kannel call");
}
}
-
-?>
View
8 web/plugin/gateway/kannel/geturl.php
@@ -17,8 +17,12 @@
}
// if the arrival time is in UTC then we need to adjust it with this:
-//$t = core_display_datetime($_REQUEST['t']);
-$t = trim($_REQUEST['t']); // assumed the arrival time is in local time not UTC
+if ($kannel_param['local_time']) {
+ $t = trim($_REQUEST['t']);
+} else {
+ // in UTC
+ $t = core_display_datetime($_REQUEST['t']);
+}
$q = trim($_REQUEST['q']); // sms_sender
$a = trim($_REQUEST['a']); // message
View
147 web/plugin/gateway/kannel/kannel.php
@@ -25,26 +25,26 @@
8: Delivered to SMSC
16: Non-Delivered to SMSC
*/
- //$checked[] = check_dlr_value($kannel_param['dlr']);
$up_dlr_box = "<input type='checkbox' name='dlr_box[]' value='1' ".$checked[0]."> "._('Delivered to phone')."<br />";
$up_dlr_box .= "<input type='checkbox' name='dlr_box[]' value='2' ".$checked[1]."> "._('Non-Delivered to phone')."<br />";
$up_dlr_box .= "<input type='checkbox' name='dlr_box[]' value='4' ".$checked[2]."> "._('Queued on SMSC')."<br />";
$up_dlr_box .= "<input type='checkbox' name='dlr_box[]' value='8' ".$checked[3]."> "._('Delivered to SMSC')."<br />";
$up_dlr_box .= "<input type='checkbox' name='dlr_box[]' value='16' ".$checked[4]."> "._('Non-Delivered to SMSC')."<br />";
// end of Handle DLR options config (emmanuel)
-
- //Fixme Edward, Browse /etc/kannel.conf to Show on web Page
- $fn = $core_config['plugin']['kannel']['kannelconf'];
- $fd = fopen($fn, 'r');
- $up_kannelconf = fread($fd, filesize($fn));
- fclose($fd);
- //End Of Fixme Edward, Browse /etc/kannel.conf to Show on web Page
-
+ if ($kannel_param['local_time']) {
+ $selected1 = 'selected';
+ } else {
+ $selected2 = 'selected';
+ }
+ $option_local_time = "
+ <option value=1 $selected1>"._('Yes')."</option>
+ <option value=0 $selected2>"._('No')."</option>
+ ";
$admin_port = $core_config['plugin']['kannel']['admin_port'];
- $admin_url = $core_config['plugin']['kannel']['sendsms_host'];
- $admin_url = ( $admin_port ? $admin_url.':'.$admin_port : $admin_url );
+ $admin_host = $core_config['plugin']['kannel']['sendsms_host'];
+ $admin_host = ( $admin_port ? $admin_host.':'.$admin_port : $admin_host );
$admin_password = $core_config['plugin']['kannel']['admin_password'];
- $url = 'http://'.$admin_url.'/status?password='.urlencode($admin_password);
+ $url = 'http://'.$admin_host.'/status?password='.urlencode($admin_password);
$kannel_status = file_get_contents($url);
$content .= "
@@ -66,7 +66,10 @@
<td>"._('Module sender ID')."</td><td><input type=text size=30 maxlength=16 name=up_global_sender value=\"".$kannel_param['global_sender']."\"> "._hint(_('Max. 16 numeric or 11 alphanumeric char. empty to disable'))."</td>
</tr>
<tr>
- <td>" . _('Module timezone') . "</td><td><input type=text size=5 maxlength=5 name=up_global_timezone value=\"" . $kannel_param['datetime_timezone'] . "\"> "._hint(_('Eg: +0700 for Jakarta/Bangkok timezone'))."</td>
+ <td>" . _('Module timezone') . "</td><td><input type=text size=5 maxlength=5 name=up_module_timezone value=\"" . $kannel_param['module_timezone'] . "\"> "._hint(_('Eg: +0700 for Jakarta/Bangkok timezone'))."</td>
+ </tr>
+ <tr>
+ <td>" . _('Incoming SMS time is in local time') . "</td><td><select name=up_local_time>".$option_local_time."</select> "._hint(_('Select no if the incoming SMS time is in UTC'))."</td>
</tr>
<tr>
<td>" . _('Bearerbox hostname or IP') . "</td><td><input type=text size=30 maxlength=250 name=up_bearerbox_host value=\"" . $kannel_param['bearerbox_host'] . "\"> "._hint(_('Kannel specific'))."</td>
@@ -90,17 +93,13 @@
</tr>
<!-- Fixme Edward Added Kanel HTTP Admin Parameter-->
<tr>
- <td>" . _('Kannel admin password') . "</td><td><input type=password size=30 maxlength=250 name=up_admin_password value=\"\"> "._hint(_('HTTP Kannel admin password'))."</td>
+ <td>" . _('Kannel admin host') . "</td><td><input type=text size=30 maxlength=250 name=up_admin_host value=\"" . $kannel_param['admin_host'] . " \"> "._hint(_('HTTP Kannel admin host'))."</td>
</tr>
<tr>
<td>" . _('Kannel admin port') . "</td><td><input type=text size=30 maxlength=250 name=up_admin_port value=\"" . $kannel_param['admin_port'] . "\"> "._hint(_('HTTP Kannel admin port'))."</td>
</tr>
<tr>
- <td>" . _('Kannel configuration file') . "</td>
- <td><input type=text size=30 value='".$core_config['plugin']['kannel']['kannelconf']."' disabled> "._hint(_('Kannel configuration file must be writable'))."</td>
- <tr>
- <td>"._('Kannel configuration')."</td>
- <td><textarea name='up_kannelconf' style='height: 20em; width: 100%'>".$up_kannelconf."</textarea></td>
+ <td>" . _('Kannel admin password') . "</td><td><input type=password size=30 maxlength=250 name=up_admin_password value=\"\"> "._hint(_('HTTP Kannel admin password'))."</td>
</tr>
<tr>
<td>" . _('Kannel status') . "</td><td><textarea rows='20' style='height: 20em; width: 100%' disabled>".$kannel_status."</textarea></td>
@@ -118,24 +117,7 @@
_p($content);
break;
case "manage_save":
- $up_username = $_POST['up_username'];
- $up_password = $_POST['up_password'];
- $up_global_sender = $_POST['up_global_sender'];
- $up_global_timezone = $_POST['up_global_timezone'];
- $up_bearerbox_host = $_POST['up_bearerbox_host'];
- $up_sendsms_host = $_POST['up_sendsms_host'];
- $up_sendsms_port = $_POST['up_sendsms_port'];
- $up_playsms_web = ( $_POST['up_playsms_web'] ? $_POST['up_playsms_web'] : $http_path['base'] );
- $up_additional_param = $_POST['up_additional_param'];
-
- $up_kannelconf = $_POST['up_kannelconf'];
- $up_kannelconf = stripslashes($up_kannelconf);
-
- $uname = strtolower(php_uname('s'));
- if (strpos($uname, "windows")===false) {
- $up_kannelconf = str_replace("\r", "", $up_kannelconf);
- }
-
+ $_SESSION['error_string'] = _('Changes has been made');
// Handle DLR config (emmanuel)
if (isset($_POST['dlr_box'])) {
for ($i = 0, $c = count($_POST['dlr_box']); $i < $c; $i++) {
@@ -143,78 +125,37 @@
}
}
// end of Handle DLR config (emmanuel)
-
- $up_admin_url = $_POST['up_admin_url'];
- $up_admin_password = $_POST['up_admin_password'];
- $up_admin_port = $_POST['up_admin_port'];
- $_SESSION['error_string'] = _('No changes has been made');
- if ($up_username && $up_bearerbox_host && $up_sendsms_port) {
- if ($up_password) {
- $password_change = "cfg_password='$up_password',";
- }
- if ($up_admin_password) {
- $admin_password_change = "cfg_admin_password='$up_admin_password',";
- }
-
- //Fixme Edward, Added Kannel HTTP Admin Parameter
- /* * $db_query = "
- UPDATE " . _DB_PREF_ . "_gatewayKannel_config
- SET c_timestamp='" . mktime() . "',
- cfg_username='$up_username',
- " . $password_change . "
- cfg_global_sender='$up_global_sender',
- cfg_datetime_timezone='$up_global_timezone',
- cfg_bearerbox_host='$up_bearerbox_host',
- cfg_sendsms_port='$up_sendsms_port',
- cfg_playsms_web='$up_playsms_web',
- cfg_additional_param='$up_additional_param'
- ";* */
- $db_query = "
- UPDATE " . _DB_PREF_ . "_gatewayKannel_config
- SET c_timestamp='" . mktime() . "',
- cfg_username='$up_username',
- " . $password_change . "
- cfg_global_sender='$up_global_sender',
- cfg_datetime_timezone='$up_global_timezone',
- cfg_bearerbox_host='$up_bearerbox_host',
- cfg_sendsms_host='$up_sendsms_host',
- cfg_sendsms_port='$up_sendsms_port',
- cfg_playsms_web='$up_playsms_web',
- cfg_additional_param='$up_additional_param',
- cfg_dlr='$up_playsms_dlr',
- cfg_admin_url='$up_admin_url',
- " . $admin_password_change . "
- cfg_admin_port='$up_admin_port'";
- //End Of Fixme Edward, Added Kannel HTTP Admin Parameter
- if (@dba_affected_rows($db_query)) {
- $_SESSION['error_string'] = _('Gateway module configurations has been saved');
- }
-
- //Fixme Edward, Handle Editing Kannel.conf Via Web
- $fn = $core_config['plugin']['kannel']['kannelconf'];
- $fd = fopen($fn, 'w');
- fwrite($fd, $up_kannelconf);
- fclose($fd);
- //End Of Edward, Handle Editing Kannel.conf Via Web
+ $items = array(
+ 'username' => $_POST['up_username'],
+ 'global_sender' => $_POST['up_global_sender'],
+ 'module_timezone' => $_POST['up_module_timezone'],
+ 'bearerbox_host' => $_POST['up_bearerbox_host'],
+ 'sendsms_host' => $_POST['up_sendsms_host'],
+ 'sendsms_port' => $_POST['up_sendsms_port'],
+ 'playsms_web' => $_POST['up_playsms_web'],
+ 'additional_param' => $_POST['up_additional_param'],
+ 'dlr' => $up_playsms_dlr,
+ 'admin_host' => $_POST['up_admin_host'],
+ 'admin_port' => $_POST['up_admin_port'],
+ 'local_time' => $_POST['up_local_time']
+ );
+ if ($_POST['up_password']) {
+ $items['password'] = $_POST['up_password'];
}
+ if ($_POST['up_admin_password']) {
+ $items['admin_password'] = $_POST['up_admin_password'];
+ }
+ registry_update(1, 'gateway', 'kannel', $items);
header("Location: index.php?app=menu&inc=gateway_kannel&op=manage");
exit();
break;
- case "manage_activate":
- $db_query = "UPDATE " . _DB_PREF_ . "_tblConfig_main SET c_timestamp='" . mktime() . "',cfg_gateway_module='kannel'";
- $db_result = dba_query($db_query);
- $_SESSION['error_string'] = _('Gateway has been activated');
- header("Location: index.php?app=menu&inc=gateway_kannel&op=manage");
- exit();
- break;
-
- //Fixme Edward, Adding New Case To Handle Button Restart Kannel Services
- case "manage_restart":
+
+ case "manage_restart":
$admin_port = $core_config['plugin']['kannel']['admin_port'];
- $admin_url = $core_config['plugin']['kannel']['bearerbox_host'];
- $admin_url = ( $admin_port ? $admin_url.':'.$admin_port : $admin_url );
+ $admin_host = $core_config['plugin']['kannel']['bearerbox_host'];
+ $admin_host = ( $admin_port ? $admin_host.':'.$admin_port : $admin_host );
$admin_password = $core_config['plugin']['kannel']['admin_password'];
- $url = 'http://'.$admin_url.'/restart?password='.$admin_password;
+ $url = 'http://'.$admin_host.'/restart?password='.$admin_password;
$restart = file_get_contents($url);
$_SESSION['error_string'] = _('Restart Kannel').' - '._('Status').': '.$restart;
header("Location: index.php?app=menu&inc=gateway_kannel&op=manage");
Please sign in to comment.
Something went wrong with that request. Please try again.