Exemple #1
0
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);
            }
        }
    }
}
Exemple #2
0
function registry_update($uid, $registry_group, $registry_family, $items)
{
    $ret = false;
    $db_table = _DB_PREF_ . '_tblRegistry';
    if (is_array($items)) {
        foreach ($items as $key => $val) {
            $conditions = array('uid' => $uid, 'registry_group' => $registry_group, 'registry_family' => $registry_family, 'registry_key' => $key);
            $values = array('c_timestamp' => strtotime(core_get_datetime()), 'registry_value' => $val);
            if (dba_count($db_table, $conditions)) {
                $ret[$key] = dba_update($db_table, $values, $conditions);
            } else {
                $ret[$key] = dba_add($db_table, array_merge($conditions, $values));
            }
            unset($conditions);
            unset($values);
        }
    }
    return $ret;
}
Exemple #3
0
/**
 * Update notification
 * @param integer $uid User ID
 * @param string $id Notification ID
 * @param array $data Updated data
 * @return boolean
 */
function notif_update($uid, $id, $data)
{
    $ret = FALSE;
    $replaced = '';
    $db_table = _DB_PREF_ . '_tblNotif';
    $result = dba_search($db_table, '*', array('uid' => $uid, 'id' => $id));
    foreach ($result[0] as $key => $val) {
        $items[$key] = $data[$key] ? $data[$key] : $val;
        if ($data[$key]) {
            $replaced = $key . ':' . $val . ' ';
        }
    }
    if ($items && trim($replaced)) {
        if (dba_update($db_table, $items, array('id' => $id))) {
            logger_print('uid:' . $uid . ' id:' . $id . ' ' . trim($replaced), 2, 'notif_update');
            $ret = TRUE;
        }
    }
    return $ret;
}
Exemple #4
0
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);
            }
        }
    }
}
Exemple #5
0
     $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');
             // only if users
             if ($user_config['status'] == 3) {
                 $up['parent_uid'] = $user_config['uid'];
                 $up['status'] = 4;
             }
             dba_update($db_table, $up, array('id' => $itemid));
         }
     }
     $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
     $_SESSION['dialog']['info'][] = _('Selected transactions has been deleted');
     header("Location: " . _u($ref));
     exit;
     break;
 case "add":
     $continue = FALSE;
     $uids = $_POST['uids'];
     if (is_array($uids)) {
         foreach ($uids as $uid) {
             if ($user_config['status'] == 3) {
                 $parent_uid = user_getparentbyuid($uid);
                 if ($parent_uid == $user_config['uid']) {
Exemple #6
0
        $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');
                        dba_update(_DB_PREF_ . '_tblUser_inbox', $up, array('in_uid' => $user_config['uid'], 'in_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['error_string'] = _('Selected incoming message has been deleted');
                header("Location: " . _u($ref));
        }
        break;
}
Exemple #7
0
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;
}
Exemple #8
0
        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');
                        dba_update(_DB_PREF_ . '_tblSMSIncoming', $up, array('in_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['dialog']['info'][] = _('Selected incoming message has been deleted');
                header("Location: " . _u($ref));
                exit;
        }
        break;
}
Exemple #9
0
        }
        break;
    case "import_yes":
        @set_time_limit(0);
        $num = $_POST['number_of_row'];
        $session_import = $_POST['session_import'];
        $data = $_SESSION['tmp'][$session_import];
        foreach ($data as $d) {
            $name = trim($d[0]);
            $destination = trim($d[1]);
            $schedule = trim($d[2]);
            if ($name && $destination && $schedule) {
                $schedule = core_adjust_datetime($schedule);
                // add destiantions, replace existing entry with the same name
                if (dba_isexists(_DB_PREF_ . '_featureSchedule_dst', array('schedule_id' => $schedule_id, 'name' => $name), 'AND')) {
                    // update
                    $items = array('c_timestamp' => mktime(), 'schedule' => $schedule, 'scheduled' => '0000-00-00 00:00:00');
                    $conditions = array('schedule_id' => $schedule_id, 'name' => $name, 'destination' => $destination);
                    dba_update(_DB_PREF_ . '_featureSchedule_dst', $items, $conditions);
                } else {
                    // insert
                    $items = array('schedule_id' => $schedule_id, 'schedule' => $schedule, 'scheduled' => '0000-00-00 00:00:00', 'name' => $name, 'destination' => $destination);
                    dba_add(_DB_PREF_ . '_featureSchedule_dst', $items);
                }
            }
        }
        $_SESSION['dialog']['info'][] = _('Entries in CSV file have been imported');
        header("Location: " . _u('index.php?app=main&inc=feature_schedule&route=import&op=list&schedule_id=' . $schedule_id));
        exit;
        break;
}
Exemple #10
0
/**
 * Update country
 * @param string $id Country ID
 * @param array $data Updated data
 * @return boolean
 */
function country_update($id, $data = array())
{
    $ret = FALSE;
    $replaced = '';
    if (!($id && is_array($data))) {
        return FALSE;
    }
    $db_table = _DB_PREF_ . '_tblCountry';
    $result = dba_search($db_table, '*', array('id' => $id));
    foreach ($result[0] as $key => $val) {
        $items[$key] = $data[$key] ? $data[$key] : $val;
        if ($data[$key]) {
            $replaced = $key . ':' . $val . ' ';
        }
    }
    if ($items && trim($replaced)) {
        if (dba_update($db_table, $items, array('id' => $id))) {
            logger_print('id:' . $id . ' ' . trim($replaced), 3, 'country_update');
            $ret = TRUE;
        }
    }
    return $ret;
}
Exemple #11
0
/**
 * Set user data by uid
 *
 * @param integer $uid
 *        User ID
 * @param array $data
 *        User data
 * @return boolean TRUE when user data updated
 */
function user_setdatabyuid($uid, $data)
{
    if ((int) $uid && is_array($data)) {
        $conditions = array('flag_deleted' => 0, 'uid' => $uid);
        if (dba_update(_DB_PREF_ . '_tblUser', $data, $conditions)) {
            return TRUE;
        }
    }
    return FALSE;
}
Exemple #12
0
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;
}
Exemple #13
0
     }
     $content .= "\n\t\t\t<h2>" . _('Manage autoreply') . "</h2>\n\t\t\t<h3>" . _('Edit SMS autoreply') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_edit_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<input type=hidden name=autoreply_id value=\"{$autoreply_id}\"> \n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _('SMS autoreply keyword') . "</td>\n\t\t\t\t\t<td><input type=text value=\"{$edit_autoreply_keyword}\" readonly></td>\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t" . $select_reply_smsc . "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value='" . _('Save') . "'></p>\n\t\t\t</form>\n\t\t\t<p>" . _back('index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_list');
     if ($err = TRUE) {
         _p(_dialog());
     }
     _p($content);
     break;
 case "sms_autoreply_edit_yes":
     if (auth_isadmin()) {
         $smsc = $_REQUEST['smsc'];
     }
     if ((int) $autoreply_id && $smsc) {
         $db_table = _DB_PREF_ . "_featureAutoreply";
         $items = array('smsc' => $smsc);
         $conditions = array('autoreply_id' => (int) $autoreply_id);
         dba_update($db_table, $items, $conditions);
         $_SESSION['dialog']['info'][] = _('SMS autoreply has been updated');
     } else {
         $_SESSION['dialog']['info'][] = _('Fail to update SMS autoreply');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_edit&autoreply_id=' . $autoreply_id));
     exit;
     break;
     // scenario
 // scenario
 case "sms_autoreply_scenario_del":
     $_SESSION['dialog']['info'][] = _('Fail to delete SMS autoreply scenario');
     if ($autoreply_id && ($autoreply_scenario_id = $_REQUEST['autoreply_scenario_id'])) {
         $db_query = "DELETE FROM " . _DB_PREF_ . "_featureAutoreply_scenario WHERE autoreply_id='{$autoreply_id}' AND autoreply_scenario_id='{$autoreply_scenario_id}'";
         if (@dba_affected_rows($db_query)) {
             $_SESSION['dialog']['info'][] = _('SMS autoreply scenario has been deleted');
Exemple #14
0
function sms_poll_handle($list, $sms_datetime, $sms_sender, $poll_keyword, $poll_param = '', $sms_receiver = '', $smsc = '', $raw_message = '')
{
    $ok = false;
    $smsc = gateway_decide_smsc($smsc, $list['smsc']);
    $poll_keyword = strtoupper(trim($poll_keyword));
    $poll_param = strtoupper(trim($poll_param));
    $choice_keyword = $poll_param;
    if ($sms_sender && $poll_keyword && $choice_keyword) {
        $poll_id = $list['poll_id'];
        // if poll disabled then immediately return, just ignore the vote
        if (!$list['poll_enable']) {
            logger_print('vote s:' . $sms_sender . ' k:' . $poll_keyword . ' c:' . $choice_keyword . ' poll disabled', 2, 'sms_poll');
            return TRUE;
        }
        $db_query = "SELECT choice_id FROM " . _DB_PREF_ . "_featurePoll_choice WHERE choice_keyword='{$choice_keyword}' AND poll_id='{$poll_id}'";
        $db_result = dba_query($db_query);
        $db_row = dba_fetch_array($db_result);
        $choice_id = (int) $db_row['choice_id'];
        $db_table = _DB_PREF_ . "_featurePoll_log";
        $items = array('poll_id' => $poll_id, 'choice_id' => $choice_id, 'poll_sender' => $sms_sender, 'in_datetime' => core_get_datetime(), 'status' => 0);
        // status 0 = failed/unknown
        // status 1 = valid
        // status 2 = out of vote option
        // status 3 = invalid
        $log_id = dba_add($db_table, $items);
        if ($poll_id && $choice_id) {
            $continue = sms_poll_check_option_vote($list, $sms_sender, $poll_keyword, $choice_keyword);
            if ($continue) {
                // send message valid
                if (dba_update($db_table, array('status' => 1), array('log_id' => $log_id))) {
                    logger_print('vote s:' . $sms_sender . ' k:' . $poll_keyword . ' c:' . $choice_keyword . ' log_id:' . $log_id . ' valid vote', 2, 'sms_poll');
                    if (($poll_message_valid = trim($list['poll_message_valid'])) && ($c_username = user_uid2username($list['uid']))) {
                        $unicode = core_detect_unicode($poll_message_valid);
                        $poll_message_valid = addslashes($poll_message_valid);
                        list($ok, $to, $smslog_id, $queue_code) = sendsms_helper($c_username, $sms_sender, $poll_message_valid, 'text', $unicode, $smsc);
                    }
                }
            } else {
                // send message out of vote option
                if (dba_update($db_table, array('status' => 2), array('log_id' => $log_id))) {
                    logger_print('vote s:' . $sms_sender . ' k:' . $poll_keyword . ' c:' . $choice_keyword . ' log_id:' . $log_id . ' out of vote option', 2, 'sms_poll');
                    if (($poll_message_option = trim($list['poll_message_option'])) && ($c_username = user_uid2username($list['uid']))) {
                        $unicode = core_detect_unicode($poll_message_option);
                        $poll_message_option = addslashes($poll_message_option);
                        list($ok, $to, $smslog_id, $queue_code) = sendsms_helper($c_username, $sms_sender, $poll_message_option, 'text', $unicode, $smsc);
                    }
                }
            }
            $ok = true;
        } else {
            // send message invalid
            if (dba_update($db_table, array('status' => 3), array('log_id' => $log_id))) {
                logger_print('vote s:' . $sms_sender . ' k:' . $poll_keyword . ' c:' . $choice_keyword . ' log_id:' . $log_id . ' invalid vote', 2, 'sms_poll');
                if (($poll_message_invalid = trim($list['poll_message_invalid'])) && ($c_username = user_uid2username($list['uid']))) {
                    $unicode = core_detect_unicode($poll_message_invalid);
                    $poll_message_invalid = addslashes($poll_message_invalid);
                    list($ok, $to, $smslog_id, $queue_code) = sendsms_helper($c_username, $sms_sender, $poll_message_invalid, 'text', $unicode, $smsc);
                }
            }
        }
    }
    return $ok;
}
Exemple #15
0
function sender_id_default_set($uid, $sender_id)
{
    $db_table = _DB_PREF_ . '_tblUser';
    $items = array('sender' => $sender_id);
    $conditions = array('flag_deleted' => 0, 'uid' => $uid);
    $ret = dba_update($db_table, $items, $conditions);
    return $ret;
}
Exemple #16
0
/**
 * Update notification
 *
 * @param integer $uid
 *        User ID
 * @param string $id
 *        Notification ID
 * @param array $fields
 *        Updated fields
 * @return boolean
 */
function notif_update($uid, $id, $fields)
{
    $ret = FALSE;
    if (!is_array($fields)) {
        return FALSE;
    }
    $db_table = _DB_PREF_ . '_tblNotif';
    $result = dba_search($db_table, '*', array('uid' => $uid, 'id' => $id));
    foreach ($result[0] as $key => $val) {
        $items[$key] = $fields[$key] ? $fields[$key] : $val;
        if ($fields[$key]) {
            $fields_replaced .= $key . ':' . $val . ' ';
        }
    }
    if ($items && trim($replaced)) {
        if (dba_update($db_table, $items, array('id' => $id))) {
            _log('uid:' . $uid . ' id:' . $id . ' ' . trim($fields_replaced), 2, 'notif_update');
            $ret = TRUE;
        }
    }
    return $ret;
}
Exemple #17
0
 case 'edit':
     $uid = $user_config['uid'];
     $c_pid = $_POST['pid'];
     $gpids = $_POST['gpids'];
     $maps = '';
     $save_to_group = FALSE;
     $mobile = str_replace("\\'", "", $_POST['mobile']);
     $mobile = str_replace("\"", "", $mobile);
     $name = str_replace("\\'", "", $_POST['name']);
     $name = str_replace("\"", "", $name);
     $email = str_replace("\\'", "", $_POST['email']);
     $email = str_replace("\"", "", $email);
     if ($c_pid && $mobile && $name) {
         $items = array('name' => $name, 'mobile' => $mobile, 'email' => $email);
         $conditions = array('id' => $c_pid, 'uid' => $uid);
         dba_update(_DB_PREF_ . '_featurePhonebook', $items, $conditions, 'AND');
         logger_print('contact edited pid:' . $c_pid . ' m:' . $mobile . ' n:' . $name . ' e:' . $email, 3, 'phonebook_edit');
     } else {
         $_SESSION['error_string'] = _('You must fill mandatory fields');
         header("Location: " . _u('index.php?app=main&inc=feature_phonebook&op=phonebook_list'));
         exit;
         break;
     }
     foreach ($gpids as $gpid) {
         $maps[][$c_pid] = $gpid;
     }
     dba_remove(_DB_PREF_ . '_featurePhonebook_group_contacts', array('pid' => $c_pid));
     foreach ($maps as $map) {
         foreach ($map as $key => $val) {
             $gpid = $val;
             $c_pid = $key;
Exemple #18
0
        $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');
                        dba_update(_DB_PREF_ . '_tblSMSIncoming', $up, array('in_uid' => $user_config['uid'], 'in_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['dialog']['info'][] = _('Selected incoming message has been deleted');
                header("Location: " . _u($ref));
                exit;
        }
        break;
}
Exemple #19
0
                    $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++) {
                    $checkid = $_POST['checkid' . $i];
                    $itemid = $_POST['itemid' . $i];
                    if ($checkid == "on" && $itemid) {
                        $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
                        $conditions = array('smslog_id' => $itemid);
                        if ($queue_code = trim($_REQUEST['queue_code'])) {
                            $conditions['queue_code'] = $queue_code;
                        }
                        dba_update(_DB_PREF_ . '_tblSMSOutgoing', $up, $conditions);
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['dialog']['info'][] = _('Selected outgoing message has been deleted');
                header("Location: " . _u($ref));
                exit;
        }
        break;
}
Exemple #20
0
        $go = $_REQUEST['go'];
        switch ($go) {
            case 'export':
                $conditions = array('flag_deleted' => 0);
                $table = _DB_PREF_ . '_tblSMSOutgoing';
                $join = 'INNER JOIN ' . _DB_PREF_ . '_tblUser AS B ON A.uid=B.uid';
                $list = dba_search($table . ' AS A', '*', $conditions, $search['dba_keywords'], '', $join);
                $data[0] = array(_('User'), _('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'], 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);
                $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++) {
                    $checkid = $_POST['checkid' . $i];
                    $itemid = $_POST['itemid' . $i];
                    if ($checkid == "on" && $itemid) {
                        $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
                        dba_update(_DB_PREF_ . '_tblSMSOutgoing', $up, array('smslog_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['error_string'] = _('Selected outgoing message has been deleted');
                header("Location: " . _u($ref));
        }
        break;
}
Exemple #21
0
function sendsms_queue_update($queue_code, $updates)
{
    $ret = false;
    if (is_array($updates)) {
        $ret = dba_update(_DB_PREF_ . '_tblSMSOutgoing_queue', $updates, array('queue_code' => $queue_code));
    }
    return $ret;
}
Exemple #22
0
        $counter = $db_row['counter'];
        $db_query = "SELECT member_number FROM " . _DB_PREF_ . "_featureSubscribe_member WHERE subscribe_id='{$subscribe_id}'";
        $db_result = dba_query($db_query);
        $sms_to = '';
        if ($message && $subscribe_id) {
            while ($db_row = dba_fetch_array($db_result)) {
                if ($member_number = $db_row['member_number']) {
                    $sms_to[] = $member_number;
                }
            }
            if ($sms_to[0]) {
                $unicode = core_detect_unicode($message);
                $message = addslashes($message);
                list($ok, $to, $smslog_id, $queue) = sendsms_helper($username, $sms_to, $message, 'text', $unicode, $smsc);
                if ($ok[0]) {
                    $counter++;
                    dba_update(_DB_PREF_ . '_featureSubscribe_msg', array('counter' => $counter), array('subscribe_id' => $subscribe_id, 'msg_id' => $msg_id));
                    $_SESSION['error_string'] .= _('Your SMS has been delivered to queue') . "<br>";
                } else {
                    $_SESSION['error_string'] .= _('Fail to send SMS') . "<br>";
                }
            } else {
                $_SESSION['error_string'] = _('You have no member');
            }
        } else {
            $_SESSION['error_string'] = _('You must fill all fields');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_view&msg_id=' . $msg_id . '&subscribe_id=' . $subscribe_id));
        exit;
        break;
}
Exemple #23
0
        $search = themes_search_session();
        $go = $_REQUEST['go'];
        switch ($go) {
            case 'export':
                $conditions = array('flag_deleted' => 0);
                $join = 'INNER JOIN ' . _DB_PREF_ . '_tblUser AS B ON in_uid=B.uid';
                $list = dba_search(_DB_PREF_ . '_tblUser_inbox', '*', $conditions, $search['dba_keywords'], '', $join);
                $data[0] = array(_('User'), _('Time'), _('From'), _('Message'));
                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_msg']);
                }
                $content = core_csv_format($data);
                $fn = 'all_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');
                        dba_update(_DB_PREF_ . '_tblUser_inbox', $up, array('in_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['error_string'] = _('Selected incoming message has been deleted');
                header("Location: " . _u($ref));
        }
        break;
}
Exemple #24
0
                    $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++) {
                    $checkid = $_POST['checkid' . $i];
                    $itemid = $_POST['itemid' . $i];
                    if ($checkid == "on" && $itemid) {
                        $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
                        $conditions = array('in_uid' => $user_config['uid'], 'in_id' => $itemid);
                        if ($in_sender = trim($_REQUEST['in_sender'])) {
                            $conditions['in_sender'] = $in_sender;
                        }
                        dba_update(_DB_PREF_ . '_tblSMSInbox', $up, $conditions);
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['dialog']['info'][] = _('Selected incoming message has been deleted');
                header("Location: " . _u($ref));
                exit;
        }
        break;
}
Exemple #25
0
function acl_setbyuid($acl_id, $uid)
{
    $ret = FALSE;
    if ((int) $uid && ($acl_name = acl_getname($acl_id))) {
        if (dba_update(_DB_PREF_ . '_tblUser', array('acl_id' => $acl_id), array('flag_deleted' => 0, 'uid' => $uid))) {
            return TRUE;
        }
    }
    return $ret;
}
Exemple #26
0
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');
}
Exemple #27
0
             }
         }
     } else {
         $json['status'] = 'ERR';
         $json['error'] = '100';
     }
     $log_this = TRUE;
     break;
 case "SET_TOKEN":
     if ($u = webservices_validate($h, $u)) {
         $user = user_getdatabyusername($u);
         if ($c_uid = $user['uid']) {
             $token = md5($c_uid . _PID_);
             $items = array('token' => $token);
             $conditions = array('flag_deleted' => 0, 'uid' => $c_uid);
             if (dba_update(_DB_PREF_ . '_tblUser', $items, $conditions)) {
                 $json['status'] = 'OK';
                 $json['error'] = '0';
                 $json['token'] = $token;
             } else {
                 $json['status'] = 'ERR';
                 $json['error'] = '100';
             }
         } else {
             $json['status'] = 'ERR';
             $json['error'] = '100';
         }
     } else {
         $json['status'] = 'ERR';
         $json['error'] = '100';
     }
Exemple #28
0
     // do not edit dev and blocked
     $continue = FALSE;
     if (!($smsc['gateway'] == 'dev' || $smsc['gateway'] == 'blocked')) {
         $continue = TRUE;
     }
     $c_gateway = gateway_valid_name($_REQUEST['gateway']);
     if ($continue && $c_id && $c_gateway && $c_gateway == $smsc['gateway']) {
         $dv = $plugin_config[$c_gateway]['_smsc_config_'] ? $plugin_config[$c_gateway]['_smsc_config_'] : array();
         $dynamic_variables = array();
         foreach ($dv as $key => $val) {
             $dynamic_variables[$key] = $_REQUEST[$key];
         }
         $items = array('last_update' => core_get_datetime(), 'data' => json_encode($dynamic_variables));
         $condition = array('id' => $c_id);
         $db_table = _DB_PREF_ . '_tblGateway';
         if ($new_id = dba_update($db_table, $items, $condition)) {
             $_SESSION['error_string'] = _('SMSC has been edited');
         } else {
             $_SESSION['error_string'] = _('Fail to edit SMSC');
         }
     } else {
         $_SESSION['error_string'] = _('Unknown error');
         header('Location: ' . _u('index.php?app=main&inc=core_gateway&op=gateway_list'));
         exit;
     }
     header('Location: ' . _u('index.php?app=main&inc=core_gateway&op=edit_smsc&id=' . $c_id));
     exit;
     break;
 case 'del_smsc':
     if ($c_id = $_REQUEST['id']) {
         $db_table = _DB_PREF_ . '_tblGateway';
Exemple #29
0
        $nav = themes_nav_session();
        $search = themes_search_session();
        $go = $_REQUEST['go'];
        switch ($go) {
            case 'export':
                $conditions = array('uid' => $user_config['uid'], 'flag_deleted' => 0);
                $list = dba_search(_DB_PREF_ . '_tblSMSOutgoing', '*', $conditions, $search['dba_keywords']);
                $data[0] = array(_('User'), _('Time'), _('To'), _('Message'), _('Status'));
                for ($i = 0; $i < count($list); $i++) {
                    $j = $i + 1;
                    $data[$j] = array(user_uid2username($list[$i]['uid']), core_display_datetime($list[$i]['p_datetime']), $list[$i]['p_dst'], $list[$i]['p_msg'], $list[$i]['p_status']);
                }
                $content = core_csv_format($data);
                $fn = 'user_outgoing-' . $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');
                        dba_update(_DB_PREF_ . '_tblSMSOutgoing', $up, array('uid' => $user_config['uid'], 'smslog_id' => $itemid));
                    }
                }
                $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
                $_SESSION['error_string'] = _('Selected outgoing message has been deleted');
                header("Location: " . _u($ref));
        }
        break;
}