function email2sms_hook_playsmsd() { global $core_config; // fetch every 60 seconds if (!core_playsmsd_timer(60)) { return; } // _log('fetch now:'.$now, 2, 'email2sms_hook_playsmsd'); // get all users $users = dba_search(_DB_PREF_ . '_tblUser', 'uid'); foreach ($users as $user) { $uid = $user['uid']; // get email2sms registry data for $uid $items = registry_search($uid, 'features', 'email2sms'); $enable = $items['features']['email2sms']['enable']; $protocol = $items['features']['email2sms']['protocol']; $port = $items['features']['email2sms']['port']; $server = $items['features']['email2sms']['server']; $username = $items['features']['email2sms']['username']; $password = $items['features']['email2sms']['password']; if (!($enable && $protocol && $port && $server && $username && $password)) { continue; } // _log('fetch uid:' . $uid, 3, 'email2sms_hook_playsmsd'); $param = 'email2sms_uid_' . $uid; $is_fetching = playsmsd_pid_get($param) ? TRUE : FALSE; if (!$is_fetching) { $RUN_THIS = "nohup " . $core_config['daemon']['PLAYSMS_BIN'] . "/playsmsd playsmsd once " . $param . " >/dev/null 2>&1 &"; // _log('execute:' . $RUN_THIS, 3, 'email2sms_hook_playsmsd'); shell_exec($RUN_THIS); } } }
/** * Count number of SMS for report * * @param integer $uid * User ID or 0 for all users * @param integer $dlr_status * Delivery report status * @param integer $flag_deleted * Deleted SMS flagged with 1 * @return integer Number of SMS */ function report_count($uid = 0, $dlr_status = 0, $flag_deleted = 0) { $sms_count = 0; $db_table = _DB_PREF_ . '_tblSMSOutgoing'; $conditions = array('p_status' => (int) $dlr_status, 'flag_deleted' => (int) $flag_deleted); if ($uid) { $conditions['uid'] = $uid; } $list = dba_search($db_table, 'queue_code', $conditions, '', array('GROUP BY' => 'queue_code')); foreach ($list as $row) { $db_table = _DB_PREF_ . '_tblSMSOutgoing_queue'; $data = dba_search($db_table, 'sms_count', array('queue_code' => $row['queue_code'])); $sms_count += $data[0]['sms_count']; } return (int) $sms_count; }
function dlrd() { global $core_config; $core_config['dlrd_limit'] = (int) $core_config['dlrd_limit'] ? (int) $core_config['dlrd_limit'] : 200; $list = dba_search(_DB_PREF_ . '_tblDLR', '*', array('flag_processed' => 1), '', array('LIMIT' => $core_config['dlrd_limit'])); $j = 0; for ($j = 0; $j < count($list); $j++) { if ($id = $list[$j]['id']) { $smslog_id = $list[$j]['smslog_id']; $p_status = $list[$j]['p_status']; $uid = $list[$j]['uid']; if (dba_update(_DB_PREF_ . '_tblDLR', array('flag_processed' => 2), array('id' => $id))) { logger_print("id:" . $id . " smslog_id:" . $smslog_id . " p_status:" . $p_status . " uid:" . $uid, 3, "dlrd"); setsmsdeliverystatus($smslog_id, $uid, $p_status); } } } }
function recvsmsd() { global $core_config; $core_config['recvsmsd_limit'] = (int) $core_config['recvsmsd_limit'] ? (int) $core_config['recvsmsd_limit'] : 200; $list = dba_search(_DB_PREF_ . '_tblRecvSMS', '*', array('flag_processed' => 1), '', array('LIMIT' => $core_config['recvsmsd_limit'])); $j = 0; for ($j = 0; $j < count($list); $j++) { if ($id = $list[$j]['id']) { $sms_datetime = $list[$j]['sms_datetime']; $sms_sender = $list[$j]['sms_sender']; $message = $list[$j]['message']; $sms_receiver = $list[$j]['sms_receiver']; $smsc = $list[$j]['smsc']; if (dba_update(_DB_PREF_ . '_tblRecvSMS', array('flag_processed' => 2), array('id' => $id))) { logger_print("id:" . $id . " dt:" . core_display_datetime($sms_datetime) . " sender:" . $sms_sender . " m:" . $message . " receiver:" . $sms_receiver . " smsc:" . $smsc, 3, "recvsmsd"); recvsms_process(core_display_datetime($sms_datetime), $sms_sender, $message, $sms_receiver, $smsc); } } } }
/** * Display SMSCs on UI * * @global array $core_config * @return string */ function _gateway_display_smsc() { global $core_config, $icon_config; $db_table = _DB_PREF_ . '_tblGateway'; $extras = array('ORDER BY' => 'gateway'); $smsc_list = dba_search($db_table, '*', '', '', $extras); $content = "\n\t\t<div class=table-responsive>\n\t\t<table class=playsms-table-list id='gateway_view_smsc'>\n\t\t\t<thead><tr>\n\t\t\t\t<th width=40%>" . _('Name') . "</th>\n\t\t\t\t<th width=50%>" . _('Gateway') . "</th>\n\t\t\t\t<th width=10%>" . _('Action') . "</th>\n\t\t\t</tr></thead>\n\t\t\t<tbody>"; foreach ($smsc_list as $smsc) { $c_link_edit = ''; $c_link_del = ''; if (!($smsc['gateway'] == 'dev' || $smsc['gateway'] == 'blocked')) { $smsc['link_edit'] = "index.php?app=main&inc=core_gateway&op=edit_smsc&id=" . $smsc['id']; $c_link_edit = "<a href='" . _u($smsc['link_edit']) . "'>" . $icon_config['edit'] . "</a>"; $smsc['link_del'] = "index.php?app=main&inc=core_gateway&op=del_smsc&id=" . $smsc['id']; $c_link_del = "<a href=\"javascript: ConfirmURL('" . _('Are you sure ?') . "', '" . _u($smsc['link_del']) . "')\">" . $icon_config['delete'] . "</span></a>"; } $content .= "\n\t\t\t<tr>\n\t\t\t\t<td>" . $smsc['name'] . "</td>\n\t\t\t\t<td>" . $smsc['gateway'] . "</td>\n\t\t\t\t<td>\n\t\t\t\t\t" . $c_link_edit . "\n\t\t\t\t\t" . $c_link_del . "\n\t\t\t\t</td>\n\t\t\t</tr>"; } $content .= "</tbody></table></div>"; return $content; }
$tpl['vars']['DIALOG_DISPLAY'] = $error_content; $tpl['name'] = 'user_inbox'; $content = tpl_apply($tpl); _p($content); break; case "actions": $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0); if ($in_sender = trim($_REQUEST['in_sender'])) { $conditions['in_sender'] = $in_sender; } $list = dba_search(_DB_PREF_ . '_tblSMSInbox', 'in_datetime, in_sender, in_msg', $conditions, $search['dba_keywords']); $data[0] = array(_('Time'), _('From'), _('Message')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array(core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_msg']); } $content = core_csv_format($data); if ($in_sender) { $fn = 'user_inbox-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '-' . $in_sender . '.csv'; } else { $fn = 'user_inbox-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '.csv'; } core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) {
$url_uname = '&uname=' . $uname; } else { $user_edited = user_getdatabyusername($uname); $c_username = $uname; $url_uname = '&uname=' . $uname; if ($user_edited['parent_uid'] == $user_config['uid']) { $is_parent = TRUE; } else { auth_block(); } } } $c_uid = user_username2uid($c_username); switch (_OP_) { case "user_config": if ($c_user = dba_search(_DB_PREF_ . '_tblUser', '*', array('flag_deleted' => 0, 'uid' => $c_uid))) { $token = $c_user[0]['token']; $webservices_ip = $c_user[0]['webservices_ip']; $enable_webservices = $c_user[0]['enable_webservices']; $sender = core_sanitize_sender($c_user[0]['sender']); $footer = core_sanitize_footer($c_user[0]['footer']); $datetime_timezone = core_get_timezone($c_username); $fwd_to_inbox = $c_user[0]['fwd_to_inbox']; $fwd_to_email = $c_user[0]['fwd_to_email']; $fwd_to_mobile = $c_user[0]['fwd_to_mobile']; $local_length = $c_user[0]['local_length']; $replace_zero = $c_user[0]['replace_zero']; $acl_id = (int) $c_user[0]['acl_id']; $credit = rate_getusercredit($c_username); } else { $_SESSION['dialog']['info'][] = _('User does not exist') . ' (' . _('username') . ': ' . $uname . ')';
/** * Get timezone * * @param $username username * or empty for default timezone * @return timezone */ function core_get_timezone($username = '') { global $core_config; $ret = ''; if ($username) { $list = dba_search(_DB_PREF_ . '_tblUser', 'datetime_timezone', array('flag_deleted' => 0, 'username' => $username)); $ret = $list[0]['datetime_timezone']; } if (!$ret) { $ret = $core_config['main']['gateway_timezone']; } return $ret; }
} _p($content); break; case "actions": $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('A.flag_deleted' => 0); if ($queue_code = trim($_REQUEST['queue_code'])) { $conditions['A.queue_code'] = $queue_code; } $table = _DB_PREF_ . '_tblSMSOutgoing'; $join = "INNER JOIN " . _DB_PREF_ . "_tblUser AS B ON B.flag_deleted='0' AND A.uid=B.uid"; $list = dba_search($table . ' AS A', 'B.username, A.p_gateway, A.p_smsc, A.p_datetime, A.p_dst, A.p_msg, A.p_footer, A.p_status', $conditions, $search['dba_keywords'], '', $join); $data[0] = array(_('User'), _('Gateway'), _('SMSC'), _('Time'), _('To'), _('Message'), _('Status')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array($list[$i]['username'], $list[$i]['p_gateway'], $list[$i]['p_smsc'], core_display_datetime($list[$i]['p_datetime']), $list[$i]['p_dst'], $list[$i]['p_msg'] . $list[$i]['p_footer'], $list[$i]['p_status']); } $content = core_csv_format($data); if ($queue_code) { $fn = 'all_outgoing-' . $core_config['datetime']['now_stamp'] . '-' . $queue_code . '.csv'; } else { $fn = 'all_outgoing-' . $core_config['datetime']['now_stamp'] . '.csv'; } core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) {
function registry_search_record($search, $keywords = '', $extras = '') { $db_table = _DB_PREF_ . '_tblRegistry'; foreach ($search as $key => $val) { if ($val) { $conditions[$key] = $val; } } return dba_search($db_table, '*', $conditions, $keywords, $extras); }
* along with playSMS. If not, see <http://www.gnu.org/licenses/>. */ defined('_SECURE_') or die('Forbidden'); if (!auth_isadmin()) { auth_block(); } switch (_OP_) { case "stoplist_list": $search_category = array(_('Mobile') => 'mobile', _('Username') => 'uid'); $base_url = 'index.php?app=main&inc=feature_stoplist&op=stoplist_list'; $search = themes_search($search_category, $base_url, array('uid' => 'user_username2uid')); $keywords = $search['dba_keywords']; $count = dba_count(_DB_PREF_ . '_featureStoplist', '', $keywords); $nav = themes_nav($count, $search['url']); $extras = array('ORDER BY' => 'uid', 'LIMIT' => $nav['limit'], 'OFFSET' => $nav['offset']); $list = dba_search(_DB_PREF_ . '_featureStoplist', '*', '', $keywords, $extras); $content = _dialog() . "\n\t\t\t<h2>" . _('Manage stoplist') . "</h2>\n\t\t\t<p>" . $search['form'] . "</p>\n\t\t\t<form name=fm_stoplist_list id=fm_stoplist_list action='index.php?app=main&inc=feature_stoplist&op=actions' method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan=3>\n\t\t\t\t\t\t\t<div class=actions_box>\n\t\t\t\t\t\t\t\t<div class=pull-left>\n\t\t\t\t\t\t\t\t\t<a href='" . _u('index.php?app=main&inc=feature_stoplist&op=stoplist_add') . "'>" . $icon_config['add'] . "</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\t\$('#action_go').click(function(){\n\t\t\t\t\t\t\t\t\t\t\t\$('#fm_stoplist_list').submit();\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t</script>\n\t\t\t\t\t\t\t\t<div class=pull-right>\n\t\t\t\t\t\t\t\t\t<select name=go class=search_input_category>\n\t\t\t\t\t\t\t\t\t\t<option value=>" . _('Select') . "</option>\n\t\t\t\t\t\t\t\t\t\t<option value=delete>" . _('Delete') . "</option>\n\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t<a href='#' id=action_go>" . $icon_config['go'] . "</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th width=45%>" . _('User') . "</th>\n\t\t\t\t\t\t<th width=50%>" . _('Blocked mobile') . "</th>\n\t\t\t\t\t\t<th width=5%><input type=checkbox onclick=CheckUncheckAll(document.fm_stoplist_list)></th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t<tbody>"; $i = $nav['top']; $j = 0; for ($j = 0; $j < count($list); $j++) { $pid = $list[$j]['id']; $username = user_uid2username($list[$j]['uid']); $mobile = $list[$j]['mobile']; $i--; $c_i = "<a href=\"" . _u('index.php?app=main&inc=feature_stoplist&op=stoplist_edit&id=' . $pid) . "\">" . $i . ".</a>"; if ($list[$j]['uid'] == $user_config['uid']) { $name = "<a href='" . _u('index.php?app=main&inc=feature_stoplist&op=stoplist_edit&pid=' . $pid) . "'>" . $name . "</a>"; } $content .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$username}</td>\n\t\t\t\t\t<td>{$mobile}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<input type=hidden name=itemid[" . $j . "] value=\"{$pid}\">\n\t\t\t\t\t\t<input type=checkbox name=checkid[" . $j . "]>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>"; } $content .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=pull-right>" . $nav['form'] . "</div>\n\t\t\t</form>";
$content .= "\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=pull-right>" . $nav['form'] . "</div>\n\t\t\t</form>"; if ($err = TRUE) { _p(_dialog()); } _p($content); break; case "actions": $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('A.flag_deleted' => 0, 'A.in_status' => 1); $join = "INNER JOIN " . _DB_PREF_ . "_tblUser AS B ON B.flag_deleted='0' AND A.in_uid=B.uid"; $extras = array('AND A.in_keyword' => '!= ""'); $list = dba_search(_DB_PREF_ . '_tblSMSIncoming as A', 'B.username, A.in_id, A.in_uid, A.in_sender, A.in_keyword, A.in_datetime, A.in_feature, A.in_message', $conditions, $search['dba_keywords'], $extras, $join); $data[0] = array(_('User'), _('Time'), _('From'), _('Keyword'), _('Content'), _('Feature')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array($list[$i]['username'], core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_keyword'], $list[$i]['in_message'], $list[$i]['in_feature']); } $content = core_csv_format($data); $fn = 'all_incoming-' . $core_config['datetime']['now_stamp'] . '.csv'; core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) { $checkid = $_POST['checkid' . $i]; $itemid = $_POST['itemid' . $i]; if ($checkid == "on" && $itemid) { $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
function playnet_hook_webservices_output($operation, $requests, $returns) { global $plugin_config; $go = $requests['go']; $smsc = $requests['smsc']; $username = $requests['u']; $password = $requests['p']; if (!($operation == 'playnet' && $go && $smsc && $username && $password)) { return FALSE; } $c_plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); // auth remote if (!($c_plugin_config['playnet']['local_playnet_username'] && $c_plugin_config['playnet']['local_playnet_password'] && $c_plugin_config['playnet']['local_playnet_username'] == $username && $c_plugin_config['playnet']['local_playnet_password'] == $password)) { $content['status'] = 'ERROR'; $content['error_string'] = 'Authentication failed'; $returns['modified'] = TRUE; $returns['param']['content'] = json_encode($content); $returns['param']['content-type'] = 'text/json'; return $returns; } switch ($go) { case 'get_outgoing': $conditions = array('flag' => 1, 'smsc' => $smsc); $extras = array('ORDER BY' => 'id', 'LIMIT' => $c_plugin_config['playnet']['poll_limit']); $list = dba_search(_DB_PREF_ . '_gatewayPlaynet_outgoing', '*', $conditions, '', $extras); foreach ($list as $data) { $rows[] = array('smsc' => $data['smsc'], 'smslog_id' => $data['smslog_id'], 'uid' => $data['uid'], 'sender_id' => $data['sender_id'], 'sms_to' => $data['sms_to'], 'message' => $data['message'], 'sms_type' => $data['sms_type'], 'unicode' => $data['unicode']); // update flag $items = array('flag' => 2); $condition = array('flag' => 1, 'id' => $data['id']); dba_update(_DB_PREF_ . '_gatewayPlaynet_outgoing', $items, $condition, 'AND'); // update dlr $p_status = 1; dlr($data['smslog_id'], $data['uid'], $p_status); } if (count($rows)) { $content['status'] = 'OK'; $content['data'] = $rows; } else { $content['status'] = 'ERROR'; $content['error_string'] = 'No outgoing data'; } break; case 'set_incoming': $payload = json_decode(stripslashes($requests['payload']), 1); if ($payload['message']) { $sms_sender = $payload['sms_sender']; $message = $payload['message']; $sms_receiver = $payload['sms_receiver']; if ($id = recvsms(core_get_datetime(), $sms_sender, $message, $sms_receiver, $smsc)) { $content['status'] = 'OK'; $content['data'] = array('recvsms_id' => $id); } else { $content['status'] = 'ERROR'; $content['error_string'] = 'Unable to save incoming data'; } } else { $content['status'] = 'ERROR'; $content['error_string'] = 'No incoming data'; } } $returns['modified'] = TRUE; $returns['param']['content'] = json_encode($content); $returns['param']['content-type'] = 'text/json'; if ($content['status'] == 'OK') { _log('accessed param_go:[' . $go . '] param_smsc:[' . $smsc . '] param_u:[' . $username . '] param_p:[' . $password . ']', 3, 'playnet_hook_webservices_output'); } return $returns; }
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with playSMS. If not, see <http://www.gnu.org/licenses/>. */ defined('_SECURE_') or die('Forbidden'); if (!auth_isvalid()) { auth_block(); } if ($poll_id = (int) $_REQUEST['poll_id']) { $db_table = _DB_PREF_ . '_featurePoll'; $conditions = array('poll_id' => $poll_id); if (!auth_isadmin()) { $conditions['uid'] = $user_config['uid']; } $list = dba_search($db_table, 'poll_id', $conditions); if (!($list[0]['poll_id'] == $poll_id)) { auth_block(); } } switch (_OP_) { case "sms_poll_list": if ($err = $_SESSION['error_string']) { $content = "<div class=error_string>{$err}</div>"; } $content .= "\n\t\t\t<h2>" . _('Manage poll') . "</h2>\n\t\t\t" . _button('index.php?app=main&inc=feature_sms_poll&op=sms_poll_add', _('Add SMS poll')); $content .= "\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t<thead><tr>"; if (auth_isadmin()) { $content .= "\n\t\t\t\t<th width=15%>" . _('Keyword') . "</th>\n\t\t\t\t<th width=20%>" . _('Title') . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Once') . " " . _hint(_('Senders sent once')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Multi') . " " . _hint(_('Senders sent multi votes')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Valid') . " " . _hint(_('Total valid SMS')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Invalid') . " " . _hint(_('Total invalid SMS')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('All') . " " . _hint(_('Grand total SMS')) . "</th>\n\t\t\t\t<th width=15%>" . _('User') . "</th>\n\t\t\t\t<th width=10%>" . _('Status') . "</th>\n\t\t\t\t<th width=15%>" . _('Action') . "</th>"; } else { $content .= "\n\t\t\t\t<th width=15%>" . _('Keyword') . "</th>\n\t\t\t\t<th width=35%>" . _('Title') . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Once') . " " . _hint(_('Senders sent once')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Multi') . " " . _hint(_('Senders sent multi votes')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Valid') . " " . _hint(_('Total valid SMS')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('Invalid') . " " . _hint(_('Total invalid SMS')) . "</th>\n\t\t\t\t<th width=5% nowrap>" . _('All') . " " . _hint(_('Grand total SMS')) . "</th>\n\t\t\t\t<th width=10%>" . _('Status') . "</th>\n\t\t\t\t<th width=15%>" . _('Action') . "</th>";
function webservices_query($username) { $user = user_getdatabyusername($username); // get user's data $status = $user['status']; $uid = $user['uid']; $name = $user['name']; $email = $user['email']; $mobile = $user['mobile']; // get credit $credit = rate_getusercredit($username); $credit = $credit ? $credit : '0'; // get last id on user's inbox table $fields = 'in_id'; $conditions = array('in_uid' => $uid, 'flag_deleted' => 0); $extras = array('ORDER BY' => 'in_id DESC', 'LIMIT' => 1); $list = dba_search(_DB_PREF_ . '_tblSMSInbox', $fields, $conditions, '', $extras); $last_inbox_id = $list[0]['in_id']; // get last id on incoming table $fields = 'in_id'; $conditions = array('in_uid' => $uid, 'flag_deleted' => 0, 'in_status' => 1); $extras = array('ORDER BY' => 'in_id DESC', 'LIMIT' => 1); $list = dba_search(_DB_PREF_ . '_tblSMSIncoming', $fields, $conditions, '', $extras); $last_incoming_id = $list[0]['in_id']; // get last id on outgoing table $fields = 'smslog_id'; $conditions = array('uid' => $uid, 'flag_deleted' => 0); $extras = array('ORDER BY' => 'smslog_id DESC', 'LIMIT' => 1); $list = dba_search(_DB_PREF_ . '_tblSMSOutgoing', $fields, $conditions, '', $extras); $last_outgoing_id = $list[0]['smslog_id']; // compile data $data = array('user' => array('username' => $username, 'uid' => (int) $uid, 'status' => (int) $status, 'name' => $name, 'email' => $email, 'mobile' => $mobile, 'credit' => $credit), 'last_id' => array('user_inbox' => (int) $last_inbox_id, 'user_incoming' => (int) $last_incoming_id, 'user_outgoing' => (int) $last_outgoing_id)); $json['status'] = 'OK'; $json['error'] = '0'; $json['data'] = $data; return $json; }
function dba_valid($db_table, $field, $value) { global $user_config; $ret = false; if ($db_table && $field && $value) { $conditions[$field] = $value; if (!auth_isadmin()) { $conditions['uid'] = $user_config['uid']; } if ($list = dba_search($db_table, $field, $conditions)) { $ret = $list[0][$field]; } } return $ret; }
<?php defined('_SECURE_') or die('Forbidden'); if (!auth_isvalid()) { auth_block(); } if ($quiz_id = (int) $_REQUEST['quiz_id']) { $db_table = _DB_PREF_ . '_featureQuiz'; $conditions = array('quiz_id' => $quiz_id); if (!auth_isadmin()) { $conditions['uid'] = $user_config['uid']; } $list = dba_search($db_table, 'quiz_id', $conditions); if (!($list[0]['quiz_id'] == $quiz_id)) { auth_block(); } } switch (_OP_) { case "sms_quiz_list": if ($err = TRUE) { $content = _dialog(); } $content .= "\n\t\t\t\t<h2>" . _('Manage quiz') . "</h2>\n\t\t\t\t" . _button('index.php?app=main&inc=feature_sms_quiz&op=sms_quiz_add', _('Add SMS quiz')); $content .= "\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t<thead><tr>"; if (auth_isadmin()) { $content .= "\n\t\t\t\t<th width=20%>" . _('Keyword') . "</th>\n\t\t\t\t<th width=40%>" . _('Question') . "</th>\n\t\t\t\t<th width=20%>" . _('User') . "</th>\n\t\t\t\t<th width=10%>" . _('Status') . "</th>\n\t\t\t\t<th width=10%>" . _('Action') . "</th>"; } else { $content .= "\n\t\t\t\t<th width=20%>" . _('Keyword') . "</th>\n\t\t\t\t<th width=60%>" . _('Question') . "</th>\n\t\t\t\t<th width=10%>" . _('Status') . "</th>\n\t\t\t\t<th width=10%>" . _('Action') . "</th>"; } $content .= "\n\t\t\t</thead></tr>\n\t\t\t<tbody>"; $i = 0;
header("Location: " . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_add&subscribe_id=' . $subscribe_id)); exit; break; case "msg_del": $msg_id = $_REQUEST['msg_id']; if ($msg_id) { $db_query = "DELETE FROM " . _DB_PREF_ . "_featureSubscribe_msg WHERE subscribe_id='{$subscribe_id}' AND msg_id='{$msg_id}'"; if (@dba_affected_rows($db_query)) { $_SESSION['error_string'] = _('Message has been deleted'); } } header("Location: " . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_list&subscribe_id=' . $subscribe_id)); exit; break; case "msg_view": $list = dba_search(_DB_PREF_ . '_featureSubscribe', 'subscribe_keyword', array('subscribe_id' => $subscribe_id)); $subscribe_name = $list[0]['subscribe_keyword']; $msg_id = $_REQUEST['msg_id']; $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe_msg WHERE subscribe_id='{$subscribe_id}' AND msg_id='{$msg_id}'"; $db_result = dba_query($db_query); $db_row = dba_fetch_array($db_result); $message = $db_row['msg']; $counter = $db_row['counter']; if ($err = $_SESSION['error_string']) { $content = "<div class=error_string>{$err}</div>"; } $content .= "\n\t\t\t<h2>" . _('Manage subscribe') . "</h2>\n\t\t\t<h3>" . _('Message detail') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_subscribe&op=msg_send method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<input type=hidden value={$message} name=msg>\n\t\t\t<input type=hidden value={$subscribe_id} name=subscribe_id>\n\t\t\t<input type=hidden value={$msg_id} name=msg_id>\n\t\t\t<table class=playsms-table>\n\t\t\t<tr><td class=label-sizer>" . _('SMS subscribe keyword') . "</td><td>{$subscribe_name}</td></tr>\n\t\t\t<tr><td>" . _('Message ID') . "</td><td>" . $msg_id . "</td></tr>\n\t\t\t<tr><td>" . _('Message') . "</td><td>" . $message . "</td></tr>\n\t\t\t<tr><td>" . _('Sent') . "</td><td>" . $counter . "</td></tr>\n\t\t\t</table>\n\t\t\t<br />\n\t\t\t<p>" . _('Send this message to all members') . "</p>\n\t\t\t<p><input type=submit value=\"" . _('Send') . "\" class=\"button\" />\n\t\t\t</form>\n\t\t\t<p>" . _back('index.php?app=main&inc=feature_sms_subscribe&op=msg_list&subscribe_id=' . $subscribe_id); _p($content); break; case "msg_send": $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe WHERE subscribe_id='{$subscribe_id}'";
/** * Check if mobile number is exists in stoplist * * @param integer $uid * User ID * @param string $mobile * single mobile number * @return boolean TRUE when found and FALSE if not found */ function stoplist_hook_blacklist_mobile_isexists($uid = 0, $mobile) { $ret = FALSE; $conditions = array('mobile' => $mobile); if ($uid = (int) $uid) { $conditions['uid'] = $uid; } $row = dba_search(_DB_PREF_ . '_featureStoplist', 'mobile', $conditions); if (count($row) > 0) { $ret = TRUE; } return $ret; }
_p($content); break; case "actions": $db_table = $plugin_config['credit']['db_table']; $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('flag_deleted' => 0); // only if users if ($user_config['status'] == 3) { $conditions['parent_uid'] = $user_config['uid']; $conditions['status'] = 4; } $list = dba_search($db_table, '*', $conditions, $search['dba_keywords']); $data[0] = array(_('User'), _('Transaction datetime'), _('Amount')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array($list[$i]['username'], core_display_datetime($list[$i]['create_datetime']), $list[$i]['amount']); } $content = core_csv_format($data); $fn = 'credit-' . $core_config['datetime']['now_stamp'] . '.csv'; core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) { $checkid = $_POST['checkid' . $i]; $itemid = $_POST['itemid' . $i]; if ($checkid == "on" && $itemid) { $up = array('c_timestamp' => mktime(), 'delete_datetime' => core_get_datetime(), 'flag_deleted' => '1');
$c_sender_id_description = trim($_REQUEST['description']) ? trim($_REQUEST['description']) : $c_sender_id; switch (_OP_) { case 'sender_id_list': $search_category = array(_('Username') => 'uid', _('Sender ID') => 'registry_key'); $keyword_converter = array('uid' => 'user_username2uid'); $base_url = 'index.php?app=main&inc=core_sender_id&op=sender_id_list'; $search = themes_search($search_category, $base_url, $keyword_converter); $conditions = array('uid' => $user_config['uid'], 'registry_family' => 'sender_id'); if (auth_isadmin()) { unset($conditions['uid']); } $keywords = $search['dba_keywords']; $count = dba_count(_DB_PREF_ . '_tblRegistry', $conditions, $keywords); $nav = themes_nav($count, $search['url']); $extras = array('ORDER BY' => 'uid', 'LIMIT' => $nav['limit'], 'OFFSET' => $nav['offset']); $list = dba_search(_DB_PREF_ . '_tblRegistry', '*', $conditions, $keywords, $extras); $sender_id_list = array(); $i = $nav['top']; $j = 0; for ($j = 0; $j < count($list); $j++) { $username = auth_isadmin() ? user_uid2username($list[$j]['uid']) : ''; $status = $list[$j]['registry_value'] == 1 ? "<span class=status_enabled></span>" : "<span class=status_disabled></span>"; $toggle_status = auth_isadmin() ? "<a href='" . _u('index.php?app=main&inc=core_sender_id&op=toggle_status&id=' . $list[$j]['id']) . "'>" . $status . "</a>" : $status; $action = "\n\t\t\t\t<a href='" . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $list[$j]['id']) . "'>" . $icon_config['edit'] . "</a>\n\t\t\t\t<a href=\"javascript: ConfirmURL('" . addslashes(_('Are you sure you want to delete sender ID') . ' ? (' . _('Sender ID') . ': ' . $list[$j]['registry_key'] . ')') . "','" . _u('index.php?app=main&inc=core_sender_id&op=sender_id_delete&id=' . $list[$j]['id']) . "')\">" . $icon_config['delete'] . "</a>\n\t\t\t"; $sender_id_list[] = array('username' => $username, 'sender_id' => core_sanitize_sender($list[$j]['registry_key']), 'sender_id_description' => sender_id_description($list[$j]['uid'], $list[$j]['registry_key']), 'lastupdate' => core_display_datetime(core_convert_datetime($list[$j]['c_timestamp'])), 'status' => $toggle_status, 'action' => $action); } $tpl = array('name' => 'sender_id', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'SEARCH_FORM' => $search['form'], 'NAV_FORM' => $nav['form'], 'FORM_TITLE' => _('Manage sender ID'), 'ADD_URL' => _u('index.php?app=main&inc=core_sender_id&op=sender_id_add'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_STATUS' => _hint(_('Click the status button to enable or disable status')), 'Sender ID' => _('Sender ID'), 'Username' => _('Username'), 'Last update' => _('Last update')), 'ifs' => array('isadmin' => auth_isadmin()), 'loops' => array('sender_id_list' => $sender_id_list), 'injects' => array('icon_config')); _p(tpl_apply($tpl)); break; case "sender_id_add": $nav = themes_nav_session();
if ($err = $_SESSION['error_string']) { $error_content = "<div class=error_string>{$err}</div>"; } $tpl['vars']['ERROR'] = $error_content; $tpl['name'] = 'user_inbox'; $content = tpl_apply($tpl); _p($content); break; case "actions": $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0); $list = dba_search(_DB_PREF_ . '_tblUser_inbox', '*', $conditions, $search['dba_keywords']); $data[0] = array(_('User'), _('Time'), _('From'), _('Message')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array(user_uid2username($list[$i]['in_uid']), core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_msg']); } $content = core_csv_format($data); $fn = 'user_inbox-' . $core_config['datetime']['now_stamp'] . '.csv'; core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) { $checkid = $_POST['checkid' . $i]; $itemid = $_POST['itemid' . $i]; if ($checkid == "on" && $itemid) { $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
$name = $db_row['name']; $message = $db_row['message']; $schedule_rule = $db_row['schedule_rule']; if ($id && $name && $message) { $content = _dialog() . "\n\t\t\t\t<h2>" . _('Schedule messages') . "</h2>\n\t\t\t\t<h3>" . _('Manage schedule') . "</h3>\n\t\t\t\t" . _CSRF_FORM_ . "\n\t\t\t\t<input type=hidden name=id value='{$id}'>\n\t\t\t\t<table class=playsms-table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _('Schedule ID') . "</td><td>" . $id . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Schedule name') . "</td><td>" . $name . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Scheduled message') . "</td><td>" . $message . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Schedule rule') . "</td><td>" . $plugin_config['schedule']['rules_display'][$schedule_rule] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t</table>"; // list of destinations $search_category = array(_('Schedule') => 'schedule', _('Name') => 'name', _('Destination') => 'destination'); $base_url = 'index.php?app=main&inc=feature_schedule&route=manage&op=list&id=' . $id; $search = themes_search($search_category, $base_url); $fields = '*'; $conditions = array('schedule_id' => $id); $keywords = $search['dba_keywords']; $count = dba_count(_DB_PREF_ . '_featureSchedule_dst', $conditions, $keywords); $nav = themes_nav($count, $search['url']); $extras = array('ORDER BY' => 'schedule, name, destination', 'LIMIT' => $nav['limit'], 'OFFSET' => $nav['offset']); $list = dba_search(_DB_PREF_ . '_featureSchedule_dst', $fields, $conditions, $keywords, $extras); $content .= "\n\t\t\t\t<h3>" . _('List of destinations') . "</h3>\n\t\t\t\t<form name=fm_schedule_dst_list id=fm_schedule_dst_list action='" . $base_url . "' method=post>\n\t\t\t\t" . _CSRF_FORM_ . "\n\t\t\t\t<p>" . $search['form'] . "</p>\t\t\t\t\t\t\n\t\t\t\t<a href='" . _u('index.php?app=main&inc=feature_schedule&route=manage&op=dst_add&schedule_id=' . $id) . "'>" . $icon_config['add'] . "</a>\n\t\t\t\t<a href='" . _u('index.php?app=main&inc=feature_schedule&route=import&op=list&schedule_id=' . $id) . "'>" . $icon_config['import'] . "</a>\n\t\t\t\t<a href='" . _u('index.php?app=main&inc=feature_schedule&route=export&op=list&schedule_id=' . $id) . "'>" . $icon_config['export'] . "</a>\n\t\t\t\t<div class=table-responsive>\n\t\t\t\t<table class=playsms-table-list>\n\t\t\t\t<thead><tr>\n\t\t\t\t\t<th width=30%>" . _('Name') . "</th>\n\t\t\t\t\t<th width=30%>" . _('Destination') . "</th>\n\t\t\t\t\t<th width=30%>" . _('Schedule') . "</th>\n\t\t\t\t\t<th width=10%>" . _('Action') . "</th>\n\t\t\t\t</tr></thead>\n\t\t\t\t<tbody>"; foreach ($list as $db_row) { $action = "<a href=\"" . _u('index.php?app=main&inc=feature_schedule&route=manage&op=dst_edit&schedule_id=' . $id . '&id=' . $db_row['id']) . "\">" . $icon_config['edit'] . "</a> "; $action .= "<a href=\"javascript: ConfirmURL('" . _('Are you sure you want to remove this number from SMS schedule ?') . " (" . $db_row['name'] . " " . $db_row['destination'] . ")','" . _u('index.php?app=main&inc=feature_schedule&route=manage&op=dst_del&schedule_id=' . $id . '&id=' . $db_row['id']) . "')\">" . $icon_config['delete'] . "</a>"; $i++; $content .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . $db_row['name'] . "</td>\n\t\t\t\t\t\t<td>" . $db_row['destination'] . "</td>\n\t\t\t\t\t\t<td>" . core_display_datetime($db_row['schedule']) . "</td>\n\t\t\t\t\t\t<td>" . $action . "</td>\n\t\t\t\t\t</tr>"; } $content .= "\n\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t\t<div class=pull-right>" . $nav['form'] . "</div>\n\t\t\t\t</form>"; $content .= "<p>" . _back('index.php?app=main&inc=feature_schedule&op=list'); } else { auth_block(); } _p($content); break; case "dst_add":
$url_uname = '&uname=' . $uname; } else { $user_edited = user_getdatabyusername($uname); $c_username = $uname; $url_uname = '&uname=' . $uname; if ($user_edited['parent_uid'] == $user_config['uid']) { $is_parent = TRUE; } else { auth_block(); } } } $c_uid = user_username2uid($c_username); switch (_OP_) { case "user_config": if ($c_user = dba_search(_DB_PREF_ . '_tblUser', '*', array('uid' => $c_uid))) { $token = $c_user[0]['token']; $webservices_ip = $c_user[0]['webservices_ip']; $enable_webservices = $c_user[0]['enable_webservices']; $sender = core_sanitize_sender($c_user[0]['sender']); $footer = core_sanitize_footer($c_user[0]['footer']); $datetime_timezone = core_get_timezone($c_username); $fwd_to_inbox = $c_user[0]['fwd_to_inbox']; $fwd_to_email = $c_user[0]['fwd_to_email']; $fwd_to_mobile = $c_user[0]['fwd_to_mobile']; $local_length = $c_user[0]['local_length']; $replace_zero = $c_user[0]['replace_zero']; $credit = rate_getusercredit($c_username); } else { $_SESSION['error_string'] = _('User does not exist') . ' (' . _('username') . ': ' . $uname . ')'; header("Location: " . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_list&view=' . $view));
function schedule_hook_playsmsd() { global $core_config; // fetch every minutes if (!core_playsmsd_timer(60)) { return; } // mark a start //_log('start scheduler', 2, 'schedule_hook_playsmsd'); // get current server time $current_datetime = core_display_datetime(core_get_datetime()); $current_timestamp = strtotime($current_datetime); // collect active schedules $conditions = array('flag_active' => 1, 'flag_deleted' => 0); $schedules = dba_search(_DB_PREF_ . '_featureSchedule', '*', $conditions); foreach ($schedules as $sch) { $schedule_id = $sch['id']; $uid = $sch['uid']; $schedule_name = $sch['name']; $schedule_rule = (int) $sch['schedule_rule']; // collect destinations $conditions = array('schedule_id' => $schedule_id); $destinations = dba_search(_DB_PREF_ . '_featureSchedule_dst', '*', $conditions, '', $extras); foreach ($destinations as $dst) { $id = $dst['id']; $name = $dst['name']; $schedule_message = str_ireplace('#NAME#', $name, $sch['message']); $destination = $dst['destination']; $schedule = $dst['schedule'] ? core_display_datetime($dst['schedule']) : '0000-00-00 00:00:00'; $scheduled = $dst['scheduled'] ? core_display_datetime($dst['scheduled']) : '0000-00-00 00:00:00'; if (!$scheduled || $scheduled == '0000-00-00 00:00:00') { $scheduled = $schedule; } $scheduled_timestamp = strtotime($scheduled); //_log('uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' current:[' . $current_datetime . '] schedule:[' . $schedule . '] scheduled:[' . $scheduled . ']', 2, 'schedule_hook_playsmsd'); $continue = FALSE; if ($current_timestamp >= $scheduled_timestamp) { switch ($schedule_rule) { // once case '0': //$scheduled = '2038-01-19 10:14:07'; $scheduled = '2030-01-19 10:14:07'; $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($current_datetime); $scheduled_display = $current_datetime; $continue = TRUE; break; // Annually // Annually case '1': $current_schedule = date('Y', $current_timestamp) . '-' . date('m-d H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 year'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Monthly // Monthly case '2': $current_schedule = date('Y-m', $current_timestamp) . '-' . date('d H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 month'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Weekly // Weekly case '3': $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule)); $current_day = date('l', strtotime($current_schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = 'next ' . $current_day; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Daily // Daily case '4': $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 day'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; } } if ($continue) { // set scheduled to next time $items = array('c_timestamp' => mktime(), 'scheduled' => $scheduled); $conditions = array('schedule_id' => $schedule_id, 'id' => $id); if (dba_update(_DB_PREF_ . '_featureSchedule_dst', $items, $conditions, 'AND')) { // if the interval is under an hour then go ahead, otherwise expired $interval = $current_timestamp - $scheduled_timestamp; if ($interval <= 3600) { _log('sendsms uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd'); $username = user_uid2username($uid); sendsms_helper($username, $destination, $schedule_message, 'text', $unicode); } else { _log('expired uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . '] interval:' . $interval, 2, 'schedule_hook_playsmsd'); } } else { _log('fail update uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd'); } } } } // mark an end //_log('end scheduler', 2, 'schedule_hook_playsmsd'); }
} $content .= "\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=pull-right>" . $nav['form'] . "</div>\n\t\t\t</form>"; if ($err = TRUE) { _p(_dialog()); } _p($content); break; case "actions": $nav = themes_nav_session(); $search = themes_search_session(); $go = $_REQUEST['go']; switch ($go) { case 'export': $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0, 'in_status' => 1); $extras = array('AND in_keyword' => '!= ""'); $list = dba_search(_DB_PREF_ . '_tblSMSIncoming', 'in_sender, in_keyword, in_datetime, in_feature, in_message', $conditions, $search['dba_keywords'], $extras); $data[0] = array(_('Time'), _('From'), _('Keyword'), _('Content'), _('Feature')); for ($i = 0; $i < count($list); $i++) { $j = $i + 1; $data[$j] = array(core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_keyword'], $list[$i]['in_message'], $list[$i]['in_feature']); } $content = core_csv_format($data); $fn = 'user_incoming-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '.csv'; core_download($content, $fn, 'text/csv'); break; case 'delete': for ($i = 0; $i < $nav['limit']; $i++) { $checkid = $_POST['checkid' . $i]; $itemid = $_POST['itemid' . $i]; if ($checkid == "on" && $itemid) { $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with playSMS. If not, see <http://www.gnu.org/licenses/>. */ defined('_SECURE_') or die('Forbidden'); if (!auth_isadmin()) { auth_block(); } $tpl = array('name' => 'report_admin', 'vars' => array('Report' => _('Report'), 'All reports' => _('All reports'), 'User' => _('User'), 'Pending' => _('Pending'), 'Sent' => _('Sent'), 'Delivered' => _('Delivered'), 'Failed' => _('Failed'), 'Billing' => _('Billing'), 'Credit' => _('Credit'))); // p_status values mapped to tpl array elements $map_values = array('0' => 'num_rows_pending', '1' => 'num_rows_sent', '2' => 'num_rows_failed', '3' => 'num_rows_delivered'); $l = 0; // USER LIST RESTRIVAL $rows = dba_search(_DB_PREF_ . '_tblUser', 'username, uid, credit, status, 0 as num_rows_pending, 0 as num_rows_sent, 0 as num_rows_delivered, 0 as num_rows_failed', '', '', array('ORDER BY' => 'status')); // populate array with the values from the mysql query $db_query = "SELECT uid, flag_deleted, p_status, COUNT(*) AS count from " . _DB_PREF_ . "_tblSMSOutgoing GROUP BY uid, flag_deleted, p_status"; $db_result = dba_query($db_query); for ($iset = array(); $irow = dba_fetch_array($db_result); $iset[] = $irow) { } // update the rows array with values from the iset array for ($i = 0; $i < count($iset); $i++) { $c = 0; // find the array key to update based on uid for ($ii = 0; $ii < count($rows); ++$ii) { if ($rows[$ii]['uid'] === $iset[$i]['uid']) { $array_key = $ii; break; } }
/** * Check IP address is exists in blacklist * * @param string $label * single label, can be $username or $uid, its up to the implementator * @param string $ip * single IP address * @return boolean TRUE when found and FALSE if not found */ function firewall_hook_blacklist_ifipexists($label, $ip) { $ret = FALSE; $condition = array('uid' => user_username2uid($label), 'ip_address' => $ip); $row = dba_search(_DB_PREF_ . '_featureFirewall', 'ip_address', $condition); if (count($row) > 0) { $ret = TRUE; } return $ret; }
function playnet_hook_webservices_output($operation, $requests, $returns) { global $plugin_config; $go = $requests['go']; $smsc = $requests['s']; $username = $requests['u']; $password = $requests['p']; if (!($operation == 'playnet' && $go && $smsc && $username && $password)) { return FALSE; } $c_plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); // auth remote if (!($c_plugin_config['playnet']['local_playnet_username'] && $c_plugin_config['playnet']['local_playnet_password'] && $c_plugin_config['playnet']['local_playnet_username'] == $username && $c_plugin_config['playnet']['local_playnet_password'] == $password)) { $content['status'] = 'ERROR'; $content['error_string'] = 'Authentication failed'; $returns['modified'] = TRUE; $returns['param']['content'] = json_encode($content); $returns['param']['content-type'] = 'text/json'; return $returns; } switch ($go) { case 'get_outgoing': $conditions = array('flag' => 1, 'smsc' => $smsc); $extras = array('ORDER BY' => 'id', 'LIMIT' => $c_plugin_config['playnet']['poll_limit']); $list = dba_search(_DB_PREF_ . '_gatewayPlaynet_outgoing', '*', $conditions, '', $extras); foreach ($list as $data) { $rows[] = array('smsc' => $data['smsc'], 'smslog_id' => $data['smslog_id'], 'uid' => $data['uid'], 'sender_id' => $data['sender_id'], 'sms_to' => $data['sms_to'], 'message' => $data['message'], 'sms_type' => $data['sms_type'], 'unicode' => $data['unicode']); // update flag $items = array('flag' => 2); $condition = array('flag' => 1, 'id' => $data['id']); dba_update(_DB_PREF_ . '_gatewayPlaynet_outgoing', $items, $condition, 'AND'); // update dlr $p_status = 1; dlr($data['smslog_id'], $data['uid'], $p_status); } if (count($rows)) { $content['status'] = 'OK'; $content['data'] = $rows; } else { $content['status'] = 'ERROR'; $content['error_string'] = 'No data'; } break; } $returns['modified'] = TRUE; $returns['param']['content'] = json_encode($content); $returns['param']['content-type'] = 'text/json'; return $returns; }
function webservices_ix($c_username, $src = '', $dst = '', $datetime = '', $c = 100, $last = false) { $json['status'] = 'ERR'; $json['error'] = '501'; $conditions['flag_deleted'] = 0; if ($uid = user_username2uid($c_username)) { $conditions['in_uid'] = $uid; } if ($src) { if ($src[0] == '0') { $c_src = substr($src, 1); } else { $c_src = substr($src, 3); } $keywords['in_sender'] = '%' . $c_src; } if ($dst) { $conditions['in_receiver'] = $dst; } if ($datetime) { $keywords['in_datetime'] = '%' . $datetime . '%'; } if ($last) { $extras['AND in_id'] = '>' . $last; } $extras['ORDER BY'] = 'in_datetime DESC'; if ($c) { $extras['LIMIT'] = $c; } else { $extras['LIMIT'] = 100; } if ($uid) { $j = 0; $list = dba_search(_DB_PREF_ . '_tblUser_inbox', '*', $conditions, $keywords, $extras); foreach ($list as $db_row) { $id = $db_row['in_id']; $src = $db_row['in_sender']; $dst = $db_row['in_receiver']; $message = str_replace('"', "'", $db_row['in_msg']); $datetime = $db_row['in_datetime']; $json['data'][$j]['id'] = $id; $json['data'][$j]['src'] = $src; $json['data'][$j]['dst'] = $dst; $json['data'][$j]['msg'] = $message; $json['data'][$j]['dt'] = $datetime; $j++; } if ($j > 0) { unset($json['status']); unset($json['error']); } } return $json; }