Ejemplo n.º 1
0
/**
 * Set option to site configuration
 *
 * @param array $config
 *        Partial or full site configuration
 * @return array Site configuration
 */
function site_config_set($config)
{
    global $user_config, $plugin_config;
    registry_remove($user_config['uid'], 'core', 'site_config');
    // save domain owner
    if ($user_config['status'] == 2 || $user_config['status'] == 3) {
        $items['uid'] = $user_config['uid'];
    } else {
        $items['uid'] = 0;
    }
    registry_update($user_config['uid'], 'core', 'site_config', $config);
    return site_config_get();
}
Ejemplo n.º 2
0
/**
 * Check if IP address deserved to get listed in blacklist, if deserved then blacklist_addip()
 *
 * @param string $label
 *        single label, can be $username or $uid, its up to the implementator
 * @param string $ip
 *        single IP address
 * @return boolean TRUE on checked (not necessarily added)
 */
function firewall_hook_blacklist_checkip($label, $ip)
{
    global $plugin_config;
    $ret = FALSE;
    $hash = md5($label . $ip);
    $data = registry_search(0, 'feature', 'firewall');
    $login_attempt = $data['feature']['firewall'][$hash];
    if ($login_attempt > $plugin_config['firewall']['login_attempt_limit']) {
        blacklist_addip($label, $ip);
    }
    $items[$hash] = $login_attempt ? $login_attempt + 1 : 1;
    if (registry_update(0, 'feature', 'firewall', $items)) {
        $ret = TRUE;
    }
    return $ret;
}
Ejemplo n.º 3
0
function credit_hook_rate_addusercredit($uid, $amount)
{
    global $plugin_config;
    $db_table = $plugin_config['credit']['db_table'];
    $parent_uid = user_getparentbyuid($uid);
    $username = user_uid2username($uid);
    $status = user_getfieldbyuid($uid, 'status');
    $amount = (double) $amount;
    if (abs($amount) <= 0) {
        _log('amount cannot be zero. amount:[' . $amount . ']', 2, 'credit_hook_rate_addusercredit');
        return FALSE;
    }
    // record it
    $id = dba_add($db_table, array('parent_uid' => $parent_uid, 'uid' => $uid, 'username' => $username, 'status' => $status, 'create_datetime' => core_get_datetime(), 'amount' => $amount, 'flag_deleted' => 0));
    // update user's credit
    if ($id) {
        _log('saved id:' . $id . ' parent_uid:' . $parent_uid . ' uid:' . $uid . ' username:'******' amount:' . $amount . ' balance:' . $balance, 3, 'credit_add');
        if (rate_setusercredit($uid, $balance)) {
            // set never been notified
            registry_update($uid, 'feature', 'credit', array('lowest_limit_notif' => FALSE));
            _log('updated uid:' . $uid . ' credit:' . $balance, 3, 'credit_add');
            return TRUE;
        } else {
            _log('fail to update uid:' . $uid . ' credit:' . $balance, 3, 'credit_add');
            dba_remove($db_table, array('id' => $id));
            return FALSE;
        }
    } else {
        _log('fail to save parent_uid:' . $parent_uid . ' uid:' . $uid . ' username:'******' amount:' . $amount . ' balance:' . $balance, 3, 'credit_add');
        return FALSE;
    }
}
Ejemplo n.º 4
0
 * playSMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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();
}
include $core_config['apps_path']['plug'] . "/gateway/gammu/config.php";
switch (_OP_) {
    case "manage":
        if ($err = TRUE) {
            $content = _dialog();
        }
        $content .= "\n\t\t\t<h2>" . _('Manage gammu') . "</h2>\n\t\t\t<form action=index.php?app=main&inc=gateway_gammu&op=manage_save method=post>\n\t\t\t" . _CSRF_FORM_ . "\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>" . _('Gateway name') . "</td><td>gammu</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Spool folder') . "</td><td><input type=text name=up_path value=\"" . $plugin_config['gammu']['path'] . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>";
        $content .= _back('index.php?app=main&inc=core_gateway&op=gateway_list');
        _p($content);
        break;
    case "manage_save":
        $up_path = core_sanitize_path($_POST['up_path']);
        $items = array('path' => $up_path);
        registry_update(0, 'gateway', 'gammu', $items);
        $_SESSION['dialog']['info'][] = _('Changes have been made');
        header("Location: " . _u('index.php?app=main&inc=gateway_gammu&op=manage'));
        exit;
        break;
}
Ejemplo n.º 5
0
    case "manage":
        if ($err = TRUE) {
            $error_content = _dialog();
        }
        $tpl = array('name' => 'jasmin', 'vars' => array('DIALOG_DISPLAY' => $error_content, 'Manage jasmin' => _('Manage jasmin'), 'Gateway name' => _('Gateway name'), 'Jasmin send SMS URL' => _mandatory(_('Jasmin send SMS URL')), 'Callback URL' => _('Callback URL'), 'API username' => _mandatory(_('API username')), 'API password' => _('API password'), 'Module sender ID' => _('Module sender ID'), 'Module timezone' => _('Module timezone'), 'Save' => _('Save'), 'Notes' => _('Notes'), 'HINT_CALLBACK_URL' => _hint(_('Empty callback URL to set default')), 'HINT_FILL_PASSWORD' => _hint(_('Fill to change the API password')), 'HINT_MODULE_SENDER' => _hint(_('Max. 16 numeric or 11 alphanumeric char. empty to disable')), 'HINT_TIMEZONE' => _hint(_('Eg: +0700 for Jakarta/Bangkok timezone')), 'CALLBACK_URL_IS' => _('Your current callback URL is'), 'CALLBACK_URL_ACCESSIBLE' => _('Your callback URL should be accessible from Jasmin'), 'JASMIN_PUSH_DLR' => _('Jasmin will push DLR and incoming SMS to your callback URL'), 'BUTTON_BACK' => _back('index.php?app=main&inc=core_gateway&op=gateway_list'), 'status_active' => $status_active, 'jasmin_param_url' => $plugin_config['jasmin']['url'], 'jasmin_param_callback_url' => $plugin_config['jasmin']['callback_url'], 'jasmin_param_api_username' => $plugin_config['jasmin']['api_username'], 'jasmin_param_module_sender' => $plugin_config['jasmin']['module_sender'], 'jasmin_param_datetime_timezone' => $plugin_config['jasmin']['datetime_timezone']));
        _p(tpl_apply($tpl));
        break;
    case "manage_save":
        $up_url = $_REQUEST['up_url'] ? $_REQUEST['up_url'] : $plugin_config['jasmin']['default_url'];
        $up_callback_url = $_REQUEST['up_callback_url'] ? $_REQUEST['up_callback_url'] : $plugin_config['jasmin']['default_callback_url'];
        $up_api_username = $_REQUEST['up_api_username'];
        $up_api_password = $_REQUEST['up_api_password'];
        $up_module_sender = $_REQUEST['up_module_sender'];
        $up_datetime_timezone = $_REQUEST['up_datetime_timezone'];
        if ($up_url && $up_api_username) {
            $items = array('url' => $up_url, 'callback_url' => $up_callback_url, 'api_username' => $up_api_username, 'module_sender' => $up_module_sender, 'datetime_timezone' => $up_datetime_timezone);
            if ($up_api_password) {
                $items['api_password'] = $up_api_password;
            }
            if (registry_update(0, 'gateway', 'jasmin', $items)) {
                $_SESSION['dialog']['info'][] = _('Gateway module configurations has been saved');
            } else {
                $_SESSION['dialog']['danger'][] = _('Fail to save gateway module configurations');
            }
        } else {
            $_SESSION['dialog']['danger'][] = _('All mandatory fields must be filled');
        }
        header("Location: " . _u('index.php?app=main&inc=gateway_jasmin&op=manage'));
        exit;
        break;
}
Ejemplo n.º 6
0
        // credit unicodes messages as single message
        $option_enable_credit_unicode = _options(array(_('yes') => 1, _('no') => 0), $data['core']['user_config']['enable_credit_unicode']);
        if (auth_isadmin()) {
            $option_enable_credit_unicode = "<select name='edit_enable_credit_unicode'>" . $option_enable_credit_unicode . "</select>";
        } else {
            $option_enable_credit_unicode = $user_config['opt']['enable_credit_unicode'] ? _('yes') : _('no');
        }
        // error string
        if ($err = TRUE) {
            $error_content = _dialog();
        }
        $tpl = array('name' => 'user_config', 'vars' => array('Application options' => _('Application options'), 'Username' => _('Username'), 'Access Control List' => _('Access Control List'), 'Effective SMS sender ID' => _('Effective SMS sender ID'), 'Default sender ID' => _('Default sender ID'), 'Default message footer' => _('Default message footer'), 'Webservices username' => _('Webservices username'), 'Webservices token' => _('Webservices token'), 'Renew webservices token' => _('Renew webservices token'), 'Enable webservices' => _('Enable webservices'), 'Webservices IP range' => _('Webservices IP range'), 'Active language' => _('Active language'), 'Timezone' => _('Timezone'), 'Credit' => _('Credit'), 'Enable credit unicode SMS as normal SMS' => _('Enable credit unicode SMS as normal SMS'), 'Forward message to inbox' => _('Forward message to inbox'), 'Forward message to email' => _('Forward message to email'), 'Forward message to mobile' => _('Forward message to mobile'), 'Local number length' => _('Local number length'), 'Prefix or country code' => _('Prefix or country code'), 'Always choose to send as unicode' => _('Always choose to send as unicode'), 'Save' => _('Save'), 'DIALOG_DISPLAY' => $error_content, 'FORM_TITLE' => $form_title, 'BUTTON_DELETE' => $button_delete, 'BUTTON_BACK' => $button_back, 'URL_UNAME' => $url_uname, 'VIEW' => $view, 'HINT_MAX_CHARS' => _hint(_('Max. 16 numeric or 11 alphanumeric characters')), 'HINT_MAX_ALPHANUMERIC' => _hint(_('Max. 30 alphanumeric characters')), 'HINT_COMMA_SEPARATED' => _hint(_('Comma separated')), 'HINT_TIMEZONE' => _hint(_('Eg: +0700 for Jakarta/Bangkok timezone')), 'HINT_LOCAL_LENGTH' => _hint(_('Min length to detect missing country code')), 'HINT_REPLACE_ZERO' => _hint(_('Replace prefix 0 or padding local numbers')), 'HINT_MANAGE_CREDIT' => _hint(_('Add or reduce credit from manage credit menu')), 'HINT_ACL' => _hint(_('ACL DEFAULT will not restrict access to menus')), 'option_new_token' => $option_new_token, 'option_enable_webservices' => $option_enable_webservices, 'option_language_module' => $option_language_module, 'option_fwd_to_inbox' => $option_fwd_to_inbox, 'option_fwd_to_email' => $option_fwd_to_email, 'option_fwd_to_mobile' => $option_fwd_to_mobile, 'option_acl' => $option_acl, 'option_sender_id' => $option_sender_id, 'c_username' => $c_username, 'effective_sender_id' => sendsms_get_sender($c_username), 'sender' => $sender, 'footer' => $footer, 'token' => $token, 'webservices_ip' => $webservices_ip, 'datetime_timezone' => $datetime_timezone, 'local_length' => $local_length, 'replace_zero' => $replace_zero, 'credit' => $credit, 'option_enable_credit_unicode' => $option_enable_credit_unicode));
        _p(tpl_apply($tpl));
        break;
    case "user_config_save":
        $fields = array('footer', 'datetime_timezone', 'language_module', 'fwd_to_inbox', 'fwd_to_email', 'fwd_to_mobile', 'local_length', 'replace_zero', 'new_token', 'enable_webservices', 'webservices_ip', 'sender', 'acl_id');
        $up = array();
        foreach ($fields as $field) {
            if (strlen($_POST['up_' . $field])) {
                $up[$field] = trim($_POST['up_' . $field]);
            }
        }
        $ret = user_edit_conf($c_uid, $up);
        $items['enable_credit_unicode'] = (int) $_POST['edit_enable_credit_unicode'];
        registry_update($c_uid, 'core', 'user_config', $items);
        $_SESSION['dialog']['info'][] = $ret['error_string'];
        _log('saving username:'******' error_string:[' . $ret['error_string'] . ']', 2, 'user_config');
        header("Location: " . _u('index.php?app=main&inc=core_user&route=user_config&op=user_config' . $url_uname . '&view=' . $view));
        exit;
        break;
}
Ejemplo n.º 7
0
        // option enable fetch
        $option_enable_fetch = _options(array(_('yes') => 1, _('no') => 0), $items_global['features']['mailsms']['enable_fetch']);
        // option check email sender
        $option_check_sender = _options(array(_('yes') => 1, _('no') => 0), $items_global['features']['mailsms']['check_sender']);
        // option protocol
        $option_protocol = _options(array('IMAP' => 'imap', 'POP3' => 'pop3'), $items_global['features']['mailsms']['protocol']);
        // option ssl
        $option_ssl = _options(array(_('yes') => 1, _('no') => 0), $items_global['features']['mailsms']['ssl']);
        // option cert
        $option_novalidate_cert = _options(array(_('yes') => 1, _('no') => 0), $items_global['features']['mailsms']['novalidate_cert']);
        $tpl = array('name' => 'mailsms', 'vars' => array('ERROR' => _err_display(), 'FORM_TITLE' => _('Manage email to SMS'), 'ACTION_URL' => _u('index.php?app=main&inc=feature_mailsms&op=mailsms_save'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_PASSWORD' => _hint(_('Fill the password field to change password')), 'Email to SMS address' => _('Email to SMS address'), 'Enable fetch new emails' => _('Enable fetch new emails'), 'Check email sender' => _('Check email sender'), 'Email protocol' => _('Email protocol'), 'Use SSL' => _('Use SSL'), 'No validate cert option' => _('No validate cert option'), 'Mail server address' => _('Mail server address'), 'Mail server port' => _('Mail server port'), 'Mailbox username' => _('Mailbox username'), 'Mailbox password' => _('Mailbox password'), 'PORT_DEFAULT' => '443', 'PORT_DEFAULT_SSL' => '993'), 'injects' => array('option_enable_fetch', 'option_check_sender', 'option_protocol', 'option_ssl', 'option_novalidate_cert', 'items_global'));
        _p(tpl_apply($tpl));
        break;
    case "mailsms_save":
        $items_global = array('email' => $_REQUEST['email'], 'enable_fetch' => $_REQUEST['enable_fetch'], 'check_sender' => $_REQUEST['check_sender'], 'protocol' => $_REQUEST['protocol'], 'ssl' => $_REQUEST['ssl'], 'novalidate_cert' => $_REQUEST['novalidate_cert'], 'port' => $_REQUEST['port'], 'server' => $_REQUEST['server'], 'username' => $_REQUEST['username'], 'hash' => md5($_REQUEST['username'] . $_REQUEST['server'] . $_REQUEST['port']));
        if ($_REQUEST['password']) {
            $items_global['password'] = $_REQUEST['password'];
        }
        registry_update(0, 'features', 'mailsms', $items_global);
        if ($_REQUEST['enable_fetch']) {
            $enabled = 'enabled';
            $_SESSION['error_string'] = _('Email to SMS configuration has been saved and service enabled');
        } else {
            $enabled = 'disabled';
            $_SESSION['error_string'] = _('Email to SMS configuration has been saved and service disabled');
        }
        _log($enabled . ' server:' . $_REQUEST['server'], 2, 'mailsms');
        header("Location: " . _u('index.php?app=main&inc=feature_mailsms&op=mailsms'));
        exit;
        break;
}
Ejemplo n.º 8
0
     break;
 case "sender_id_edit_yes":
     if (sender_id_update($uid, $c_sender_id, $c_sender_id_description, $_REQUEST['default'], $_REQUEST['approved'])) {
         $_SESSION['dialog']['info'][] = _('Sender ID description has been updated') . ' (' . _('Sender ID') . ': ' . $c_sender_id . ')';
     } else {
         $_SESSION['dialog']['info'][] = _('Fail to update due to invalid sender ID') . ' (' . _('Sender ID') . ': ' . $c_sender_id . ')';
     }
     header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $_REQUEST['id']));
     exit;
     break;
 case "toggle_status":
     $search = array('id' => $_REQUEST['id'], 'registry_family' => 'sender_id');
     foreach (registry_search_record($search) as $row) {
         $status = $row['registry_value'] == 0 ? 1 : 0;
         $items[$row['registry_key']] = $status;
         registry_update($row['uid'], 'features', 'sender_id', $items);
     }
     $_SESSION['dialog']['info'][] = ($status == 1 ? _('Sender ID is now approved') : _('Sender ID is now disabled')) . ' (' . _('Sender ID') . ': ' . $row['registry_key'] . ')';
     header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_list'));
     exit;
     break;
 case "sender_id_delete":
     $nav = themes_nav_session();
     $search = themes_search_session();
     $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
     $uid = auth_isadmin() && $data_sender_id[0]['uid'] ? $data_sender_id[0]['uid'] : $user_config['uid'];
     registry_remove($uid, 'features', 'sender_id', $data_sender_id[0]['registry_key']);
     registry_remove($uid, 'features', 'sender_id_description', $data_sender_id[0]['registry_key']);
     $default_sender_id = sender_id_default_get($uid);
     if (strtoupper($data_sender_id[0]['registry_key']) == strtoupper($default_sender_id)) {
         sender_id_default_set($data_sender_id[0]['uid'], '');
Ejemplo n.º 9
0
 *
 * 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();
}
include $core_config['apps_path']['plug'] . "/gateway/openvox/config.php";
$callback_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/plugin/gateway/openvox/callback.php";
$callback_url = str_replace("//", "/", $callback_url);
$callback_url = "http://" . $callback_url;
switch (_OP_) {
    case "manage":
        if ($err = TRUE) {
            $error_content = _dialog();
        }
        $tpl = array('name' => 'openvox', 'vars' => array('DIALOG_DISPLAY' => $error_content, 'Manage OpenVox' => _('Manage OpenVox'), 'Gateway name' => _('Gateway name'), 'Gateway host' => _('Gateway host'), 'Gateway port' => _('Gateway port'), 'Username' => _('Username'), 'Password' => _('Password'), 'Module sender ID' => _('Module sender ID'), 'Module timezone' => _('Module timezone'), 'Save' => _('Save'), 'Notes' => _('Notes'), 'HINT_FILL_SECRET' => _hint(_('Fill to change the password')), 'CALLBACK_URL_IS' => _('Your callback URL is'), 'CALLBACK_URL_ACCESSIBLE' => _('Your callback URL should be accessible from OpenVox'), 'BUTTON_BACK' => _back('index.php?app=main&inc=core_gateway&op=gateway_list'), 'openvox_param_gateway_host' => $plugin_config['openvox']['gateway_host'], 'openvox_param_gateway_port' => $plugin_config['openvox']['gateway_port'], 'openvox_param_username' => $plugin_config['openvox']['username'], 'callback_url' => $callback_url));
        _p(tpl_apply($tpl));
        break;
    case "manage_save":
        $_SESSION['dialog']['info'][] = _('Changes have been made');
        $items = array('gateway_host' => $_POST['up_gateway_host'], 'gateway_port' => $_POST['up_gateway_port'], 'username' => $_POST['up_username'], 'password' => $_POST['up_password']);
        if ($_POST['up_password']) {
            $items['password'] = $_POST['up_password'];
        }
        registry_update(1, 'gateway', 'openvox', $items);
        header("Location: " . _u('index.php?app=main&inc=gateway_openvox&op=manage'));
        exit;
        break;
}
Ejemplo n.º 10
0
/**
 * Add account to banned account list
 *
 * @param integer $uid
 *        User ID
 * @return boolean TRUE if user successfully added to banned user list
 */
function user_banned_add($uid)
{
    global $user_config;
    // account admin and currently logged in user/admin cannot be ban
    if ($uid && ($uid == 1 || $uid == $user_config['uid'])) {
        _log('unable to ban uid:' . $uid, 2, 'user_banned_add');
        return FALSE;
    }
    $bantime = core_get_datetime();
    if (user_session_get($uid)) {
        if (!user_session_remove($uid)) {
            return FALSE;
        }
    }
    $item = array($uid => $bantime);
    if (registry_update(1, 'auth', 'banned_users', $item)) {
        _log('banned uid:' . $uid . ' bantime:' . $bantime, 2, 'user_banned_add');
        return TRUE;
    } else {
        return FALSE;
    }
}
Ejemplo n.º 11
0
/**
 * Update sender ID
 *
 * @param integer $uid
 *        User ID
 * @param string $sender_id
 *        Sender ID
 * @param string $sender_id_description
 *        Sender ID description
 * @param integer $isdefault
 *        Flag 1 for default sender ID
 * @param integer $isapproved
 *        Flag 1 for approved sender ID
 * @return boolean TRUE when new sender ID has been updated
 */
function sender_id_update($uid, $sender_id, $sender_id_description = '', $isdefault = '_', $isapproved = '_')
{
    global $user_config;
    if (sender_id_check($uid, $sender_id)) {
        $default = '_';
        if ($isdefault !== '_') {
            $default = (int) $isdefault ? 1 : 0;
        }
        if ($isapproved !== '_') {
            if (auth_isadmin()) {
                $approved = (int) $isapproved ? 1 : 0;
                $data_sender_id = array($sender_id => $approved);
            }
        }
        $sender_id_description = trim($sender_id_description) ? trim($sender_id_description) : $sender_id;
        $data_description = array($sender_id => $sender_id_description);
        $uid = auth_isadmin() && $uid ? $uid : $user_config['uid'];
        if ($uid) {
            if ($data_sender_id) {
                registry_update($uid, 'features', 'sender_id', $data_sender_id);
            }
            registry_update($uid, 'features', 'sender_id_desc', $data_description);
        } else {
            // unknown error
            return FALSE;
        }
        // set default
        if ($default !== '_') {
            if (auth_isadmin() && $default && $approved) {
                // set default if isadmin, default and approved
                sender_id_default_set($uid, $sender_id);
            } else {
                // set to empty (remove default)
                sender_id_default_set($uid, '');
            }
        }
        return TRUE;
    } else {
        // not found
        return FALSE;
    }
}
Ejemplo n.º 12
0
            $default_logo_url = _HTTP_PATH_THEMES_ . '/common/images/logo.png';
            $logo_url = file_exists($themes_logo) ? $themes_logo_url : $default_logo_url;
            // force to disable logo when neither themes_logo or default_logo exists
            if (!file_exists($default_logo)) {
                $logo_url = '';
                $enable_logo = 0;
            }
        }
        // disable logo_replace_title when logo disabled
        if (!$enable_logo) {
            $logo_replace_title = 0;
        }
        // allow default account status 3 and 4 only
        $edit_default_user_status = (int) $_POST['edit_default_user_status'];
        if (!($edit_default_user_status == 3 || $edit_default_user_status == 4)) {
            $edit_default_user_status == 4;
        }
        // save
        foreach ($_POST as $key => $val) {
            if (substr($key, 0, 5) == 'edit_') {
                $post[$key] = str_replace('"', '\'', $val);
            }
        }
        $items = array('web_title' => $post['edit_web_title'], 'email_service' => $post['edit_email_service'], 'email_footer' => $post['edit_email_footer'], 'main_website_name' => $post['edit_main_website_name'], 'main_website_url' => $post['edit_main_website_url'], 'gateway_number' => core_sanitize_sender($post['edit_gateway_number']), 'gateway_timezone' => $post['edit_gateway_timezone'], 'username_length' => (int) $post['edit_username_length'] >= 3 && (int) $post['edit_username_length'] <= 100 ? (int) $post['edit_username_length'] : 30, 'default_rate' => (double) $post['edit_default_rate'], 'gateway_module' => $post['edit_gateway_module'] ? $post['edit_gateway_module'] : 'dev', 'themes_module' => $post['edit_themes_module'] ? $post['edit_themes_module'] : 'default', 'language_module' => $post['edit_language_module'] ? $post['edit_language_module'] : 'en_US', 'sms_max_count' => (int) ($post['edit_sms_max_count'] > 1 ? $post['edit_sms_max_count'] : 1), 'plus_sign_remove' => (int) $post['edit_plus_sign_remove'], 'plus_sign_add' => (int) $post['edit_plus_sign_add'], 'enable_credit_unicode' => (int) $post['edit_enable_credit_unicode'], 'brute_force_detection' => (int) $post['edit_brute_force_detection'], 'keyword_separator' => substr($post['edit_keyword_separator'], 0, 1), 'credit_lowest_limit' => (double) $post['edit_credit_lowest_limit'], 'sms_limit_per_hour' => (int) $post['edit_sms_limit_per_hour'], 'default_replace_zero' => $post['edit_default_replace_zero'], 'default_credit' => (double) $post['edit_default_credit'], 'default_user_status' => $edit_default_user_status, 'default_parent' => (int) $post['edit_default_parent'], 'default_acl' => (int) $post['edit_default_acl'], 'enable_register' => (int) $post['edit_enable_register'], 'enable_forgot' => (int) $post['edit_enable_forgot'], 'disable_login_as' => (int) $post['edit_disable_login_as'], 'enhance_privacy_subuser' => (int) $post['edit_enhance_privacy_subuser'], 'enable_logo' => (int) $enable_logo, 'logo_url' => $logo_url, 'logo_replace_title' => (int) $logo_replace_title, 'layout_footer' => $post['edit_layout_footer'] ? $post['edit_layout_footer'] : _('Application footer here. Go to main configuration or manage site to edit this footer.'), 'information_title' => $post['edit_information_title'] ? $post['edit_information_title'] : _('Information'), 'information_content' => $post['edit_information_content'] ? $post['edit_information_content'] : _('Go to main configuration or manage site to edit this page'));
        $result = registry_update(1, 'core', 'main_config', $items);
        _log('main configuration saved. uid:' . $user_config['uid'], 3, 'main_config');
        $_SESSION['dialog']['info'][] = _('Main configuration changes has been saved');
        header("Location: " . _u('index.php?app=main&inc=core_main_config&op=main_config'));
        exit;
        break;
}
Ejemplo n.º 13
0
 *
 * playSMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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();
}
include $core_config['apps_path']['plug'] . "/gateway/smstools/config.php";
switch (_OP_) {
    case "manage":
        $content .= _dialog() . "\n\t\t\t<h2>" . _('Manage smstools') . "</h2>\n\t\t\t<form action=index.php?app=main&inc=gateway_smstools&op=manage_save method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=label-sizer>" . _('Gateway name') . "</td><td>smstools</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . _('Default default_queue directory') . "</td><td><input type=text name=up_default_queue value=\"" . $plugin_config['smstools']['default_queue'] . "\"></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t<p>" . _back('index.php?app=main&inc=core_gateway&op=gateway_list');
        _p($content);
        break;
    case "manage_save":
        $up_default_queue = trim(core_sanitize_path($_POST['up_default_queue']));
        if (!$up_default_queue) {
            $up_default_queue = "/var/spool/sms";
        }
        $items = array('default_queue' => $up_default_queue);
        registry_update(0, 'gateway', 'smstools', $items);
        $_SESSION['dialog']['info'][] = _('Changes have been made');
        header("Location: " . _u('index.php?app=main&inc=gateway_smstools&op=manage'));
        exit;
        break;
}
Ejemplo n.º 14
0
function simplerate_hook_rate_deduct($smslog_id)
{
    global $core_config;
    logger_print("enter smslog_id:" . $smslog_id, 2, "simplerate deduct");
    $db_query = "SELECT p_dst,p_footer,p_msg,uid,unicode FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE smslog_id='{$smslog_id}'";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        $p_dst = $db_row['p_dst'];
        $p_msg = $db_row['p_msg'];
        $p_footer = $db_row['p_footer'];
        $uid = $db_row['uid'];
        $unicode = $db_row['unicode'];
        if ($p_dst && $p_msg && $uid) {
            // get charge
            $p_msg_len = strlen($p_msg) + strlen($p_footer);
            list($count, $rate, $charge) = rate_getcharges($uid, $p_msg_len, $unicode, $p_dst);
            // sender's
            $username = user_uid2username($uid);
            $credit = rate_getusercredit($username);
            $balance = $credit - $charge;
            // parent's when sender is a subuser
            $parent_uid = user_getparentbyuid($uid);
            if ($parent_uid) {
                $username_parent = user_uid2username($parent_uid);
                $credit_parent = rate_getusercredit($username_parent);
                $balance_parent = $credit_parent - $charge;
            }
            // if sender have parent then deduct parent first
            if ($parent_uid) {
                if (!rate_setusercredit($parent_uid, $balance_parent)) {
                    return FALSE;
                }
                logger_print("parent uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id . " msglen:" . $p_msg_len . " count:" . $count . " rate:" . $rate . " charge:" . $charge . " credit_parent:" . $credit_parent . " balance_parent:" . $balance_parent, 2, "simplerate deduct");
            }
            if (rate_setusercredit($uid, $balance)) {
                logger_print("user uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id . " msglen:" . $p_msg_len . " count:" . $count . " rate:" . $rate . " charge:" . $charge . " credit:" . $credit . " balance:" . $balance, 2, "simplerate deduct");
                if (billing_post($smslog_id, $rate, $credit, $count, $charge)) {
                    logger_print("deduct successful uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
                    // if balance under credit lowest limit and never been notified then notify admins, parent_uid and uid
                    $credit_lowest_limit = (double) $core_config['main']['credit_lowest_limit'];
                    _log('credit_lowest_limit:' . $credit_lowest_limit . ' balance:' . $balance . ' charge:' . $charge, 3, 'simplerate deduct');
                    $reg = registry_search($uid, 'feature', 'credit', 'lowest_limit_notif');
                    $notified = $reg['feature']['credit']['lowest_limit_notif'] ? TRUE : FALSE;
                    if ($charge && $balance && $credit_lowest_limit && $balance <= $credit_lowest_limit && !$notified) {
                        // set notified
                        registry_update($uid, 'feature', 'credit', array('lowest_limit_notif' => TRUE));
                        // notif admins
                        $admins = user_getallwithstatus(2);
                        foreach ($admins as $admin) {
                            $credit_message_to_admins = sprintf(_('Username %s with account ID %d has reached lowest credit limit of %s'), $username, $uid, $credit_lowest_limit);
                            recvsms_inbox_add(core_get_datetime(), _SYSTEM_SENDER_ID_, $admin['username'], $credit_message_to_admins);
                        }
                        // notif parent_uid if exists
                        if ($parent_uid && $username_parent) {
                            $credit_message_to_parent = sprintf(_('Your subuser with username %s and account ID %d has reached lowest credit limit of %s'), $username, $uid, $credit_lowest_limit);
                            recvsms_inbox_add(core_get_datetime(), _SYSTEM_SENDER_ID_, $username_parent, $credit_message_to_parent);
                        }
                        // notif uid
                        $sender_username = $username_parent ? $username_parent : _SYSTEM_SENDER_ID_;
                        $credit_message_to_self = sprintf(_('You have reached lowest credit limit of %s'), $credit_lowest_limit);
                        recvsms_inbox_add(core_get_datetime(), $sender_username, $username, $credit_message_to_self);
                        _log('sent notification credit_lowest_limit:' . $credit_lowest_limit, 3, 'simplerate deduct');
                    }
                    return TRUE;
                } else {
                    logger_print("deduct failed uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
                    return FALSE;
                }
            } else {
                logger_print("rate deduct failed due to unable to save to db uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
            }
        } else {
            logger_print("rate deduct failed due to empty data uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
        }
    } else {
        logger_print("rate deduct failed due to missing data uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
    }
    return FALSE;
}
Ejemplo n.º 15
0
        $post_rules['match_sender_id'] = (int) $_REQUEST['sandbox_match_sender_id'];
        $items['sandbox_match_sender_id'] = $post_rules['match_sender_id'];
        // sandbox prefix
        $post_rules['insert_prefix'] = trim(strtoupper(core_sanitize_alphanumeric($_REQUEST['sandbox_prefix'])));
        if ($post_rules['insert_prefix'] && keyword_isavail($post_rules['insert_prefix'])) {
            $_SESSION['dialog']['info'][] = _('Fail to insert keyword') . ' (' . _('keyword') . ': ' . $post_rules['insert_prefix'] . ')';
            $post_rules['insert_prefix'] = '';
        }
        $items['sandbox_prefix'] = $post_rules['insert_prefix'];
        // sandbox forward to users
        $post_rules['forward_to'] = serialize(array_unique($_REQUEST['uids']));
        $items['sandbox_forward_to'] = $post_rules['forward_to'];
        // sandbox forward to url
        $post_rules['forward_to_url'] = $_REQUEST['forward_to_url'];
        $items['sandbox_forward_to_url'] = $post_rules['forward_to_url'];
        // form settings
        // settings to leave copy on sandbox
        $items['settings_leave_copy_sandbox'] = (int) $_REQUEST['settings_leave_copy_sandbox'];
        // settings to match with all approved sender ID
        $items['settings_match_all_sender_id'] = (int) $_REQUEST['settings_match_all_sender_id'];
        // save to registry
        if (count($items)) {
            registry_update(1, 'feature', 'incoming', $items);
            $_SESSION['dialog']['info'][] = _('Incoming SMS route changes has been saved');
        } else {
            $_SESSION['dialog']['info'][] = _('No route has been saved');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_incoming&op=incoming'));
        exit;
        break;
}
Ejemplo n.º 16
0
        // option enable
        $option_enable = _options(array(_('yes') => 1, _('no') => 0), $items['features']['mailsms_user']['enable']);
        $tpl = array('name' => 'mailsms_user', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'FORM_TITLE' => _('My email to SMS'), 'ACTION_URL' => _u('index.php?app=main&inc=feature_mailsms&route=mailsms_user&op=mailsms_user_save'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_PASSWORD' => _hint(_('Fill the password field to change password')), 'Email to SMS address' => _('Email to SMS address'), 'PIN for email to SMS' => _mandatory(_('PIN for email to SMS'))), 'injects' => array('option_enable', 'items_global', 'items'));
        _p(tpl_apply($tpl));
        break;
    case "mailsms_user_save":
        $continue = FALSE;
        $pin = core_sanitize_alphanumeric(substr(trim($_REQUEST['pin']), 0, 40));
        if ($pin) {
            $continue = TRUE;
        } else {
            $_SESSION['dialog']['info'][] = _('PIN is empty');
            $_SESSION['dialog']['info'][] = _('Fail to save email to SMS PIN');
        }
        if ($continue) {
            $items = array('pin' => $pin);
            registry_update($user_config['uid'], 'features', 'mailsms_user', $items);
            $items_global = registry_search(0, 'features', 'mailsms');
            if ($items_global['features']['mailsms']['enable_fetch']) {
                $enabled = 'enabled';
                $_SESSION['dialog']['info'][] = _('Email to SMS PIN has been saved');
            } else {
                $enabled = 'disabled';
                $_SESSION['dialog']['info'][] = _('Email to SMS PIN has been saved but service is disabled');
            }
            _log($enabled . ' uid:' . $user_config['uid'] . ' u:' . $user_config['username'], 2, 'mailsms_user');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_mailsms&route=mailsms_user&op=mailsms_user'));
        exit;
        break;
}
Ejemplo n.º 17
0
        $tpl = array('name' => 'email2sms', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'FORM_TITLE' => _('Manage email to SMS'), 'ACTION_URL' => _u('index.php?app=main&inc=feature_email2sms&op=email2sms_save'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_PASSWORD' => _hint(_('Fill the password field to change password')), 'PIN for email to SMS' => _mandatory(_('PIN for email to SMS')), 'Enable email to SMS' => _('Enable email to SMS'), 'Check email sender' => _('Check email sender'), 'Email protocol' => _('Email protocol'), 'Use SSL' => _('Use SSL'), 'No validate cert option' => _('No validate cert option'), 'Mail server address' => _('Mail server address'), 'Mail server port' => _('Mail server port'), 'Mailbox username' => _('Mailbox username'), 'Mailbox password' => _('Mailbox password'), 'PORT_DEFAULT' => '443', 'PORT_DEFAULT_SSL' => '993'), 'injects' => array('select_users', 'option_enable', 'option_check_sender', 'option_protocol', 'option_ssl', 'option_novalidate_cert', 'items'));
        _p(tpl_apply($tpl));
        break;
    case "email2sms_save":
        $continue = FALSE;
        $pin = core_sanitize_alphanumeric(substr($_REQUEST['pin'], 0, 40));
        if ($pin) {
            $continue = TRUE;
        } else {
            $_SESSION['dialog']['info'][] = _('PIN is empty');
            $_SESSION['dialog']['info'][] = _('Fail to save email to SMS configuration');
        }
        if ($continue) {
            $items = array('pin' => $pin, 'enable' => $_REQUEST['enable'], 'check_sender' => $_REQUEST['check_sender'], 'protocol' => $_REQUEST['protocol'], 'ssl' => $_REQUEST['ssl'], 'novalidate_cert' => $_REQUEST['novalidate_cert'], 'port' => $_REQUEST['port'], 'server' => $_REQUEST['server'], 'username' => $_REQUEST['username'], 'hash' => md5($_REQUEST['username'] . $_REQUEST['server'] . $_REQUEST['port']));
            if ($_REQUEST['password']) {
                $items['password'] = $_REQUEST['password'];
            }
            registry_update($user_config['uid'], 'features', 'email2sms', $items);
            if ($_REQUEST['enable']) {
                $enabled = 'enabled';
                $_SESSION['dialog']['info'][] = _('Email to SMS configuration has been saved and enabled');
            } else {
                $enabled = 'disabled';
                $_SESSION['dialog']['info'][] = _('Email to SMS configuration has been saved but disabled');
            }
            _log($enabled . ' uid:' . $user_config['uid'] . ' u:' . $_REQUEST['username'] . ' server:' . $_REQUEST['server'], 2, 'email2sms');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_email2sms&op=email2sms'));
        exit;
        break;
}
Ejemplo n.º 18
0
use Gregwar\Captcha\CaptchaBuilder;
if (_OP_ == 'forgot') {
    $username = trim($_REQUEST['username']);
    $email = trim($_REQUEST['email']);
    $ok = FALSE;
    if (!auth_isvalid()) {
        if ($_REQUEST['captcha'] == $_SESSION['tmp']['captcha']) {
            if ($core_config['main']['enable_forgot']) {
                if ($username && $email) {
                    $db_query = "SELECT password FROM " . _DB_PREF_ . "_tblUser WHERE flag_deleted='0' AND username='******' AND email='{$email}'";
                    $db_result = dba_query($db_query);
                    if ($db_row = dba_fetch_array($db_result)) {
                        if ($password = $db_row['password']) {
                            $tmp_password = core_get_random_string();
                            $tmp_password_coded = md5($tmp_password);
                            if (registry_update(1, 'auth', 'tmp_password', array($username => $tmp_password_coded))) {
                                $subject = _('Password recovery');
                                $body = $core_config['main']['web_title'] . "\n\n";
                                $body .= _('You or someone else have requested a password recovery') . "\n\n";
                                $body .= _('This temporary password will be removed once you have logged in successfully') . "\n\n";
                                $body .= _('Username') . "\t: " . $username . "\n";
                                $body .= _('Password') . "\t: " . $tmp_password . "\n\n--\n";
                                $body .= $core_config['main']['email_footer'] . "\n\n";
                                $data = array('mail_from_name' => $core_config['main']['web_title'], 'mail_from' => $core_config['main']['email_service'], 'mail_to' => $email, 'mail_subject' => $subject, 'mail_body' => $body);
                                if (sendmail($data)) {
                                    $error_string = _('Password has been emailed') . " (" . _('Username') . ": " . $username . ")";
                                    $_SESSION['dialog']['info'][] = $error_string;
                                    $ok = TRUE;
                                } else {
                                    $error_string = _('Fail to send email');
                                    $_SESSION['dialog']['danger'][] = $error_string;
Ejemplo n.º 19
0
/**
 * Counter for throttle limit
 *
 * @param integer $uid
 *        User ID
 * @param integer $count
 *        (default is 1)
 *        Sent SMS
 * @return boolean TRUE of successful counter
 */
function sendsms_throttle_count($uid, $count = 1, $limit = 0, $period = 60)
{
    global $core_config;
    $limit = (int) $limit ? (int) $limit : $core_config['main']['sms_limit_per_hour'];
    $period = (int) $period ? (int) $period * 60 : 3600;
    if (!$limit) {
        // no limit no over limit
        return FALSE;
    }
    // get start time, UTC
    $reg = registry_search($uid, 'core', 'sendsms', 'throttle_start');
    $start = $reg['core']['sendsms']['throttle_start'];
    if ($start) {
        // get sum of sent SMS over the hour
        $reg = registry_search($uid, 'core', 'sendsms', 'throttle_sum');
        $sum = $reg['core']['sendsms']['throttle_sum'];
        _log('throttle bucket exists start:' . core_display_datetime($start) . ' sum:' . $sum . ' limit:' . $limit, 3, 'sendsms_throttle_count');
    } else {
        $start = core_get_datetime();
        $sum = 0;
        if (registry_update($uid, 'core', 'sendsms', array('throttle_start' => $start, 'throttle_sum' => $sum))) {
            _log('throttle bucket started start:' . core_display_datetime($start) . ' limit:' . $limit, 3, 'sendsms_throttle_count');
        } else {
            _log('fail to start throttle bucket', 3, 'sendsms_throttle_count');
            return FALSE;
        }
    }
    // check bucket expired
    if (strtotime($start) + $period < strtotime(core_get_datetime())) {
        // expired, create new
        $start = core_get_datetime();
        $sum = 0;
        _log('expired start:' . core_display_datetime($start), 3, 'sendsms_throttle_count');
    } else {
        //_log('not expired', 3, 'sendsms_throttle_count');
        // not expired
        if ((int) $sum <= $limit) {
            // add to bucket
            $sum += $count;
            //_log('add to bucket sum:' . $sum, 3, 'sendsms_throttle_count');
        } else {
            _log('overlimit sum:' . $sum . ' limit:' . $limit, 3, 'sendsms_throttle_count');
            return FALSE;
        }
    }
    // save in registry
    if (registry_update($uid, 'core', 'sendsms', array('throttle_start' => $start, 'throttle_sum' => $sum))) {
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 20
0
    case "manage":
        if ($err = TRUE) {
            $error_content = _dialog();
        }
        $tpl = array('name' => 'generic', 'vars' => array('DIALOG_DISPLAY' => $error_content, 'Manage generic' => _('Manage generic'), 'Gateway name' => _('Gateway name'), 'Generic send SMS URL' => _mandatory(_('Generic send SMS URL')), 'Callback URL' => _('Callback URL'), 'API username' => _mandatory(_('API username')), 'API password' => _('API password'), 'Module sender ID' => _('Module sender ID'), 'Module timezone' => _('Module timezone'), 'Save' => _('Save'), 'Notes' => _('Notes'), 'HINT_CALLBACK_URL' => _hint(_('Empty callback URL to set default')), 'HINT_FILL_PASSWORD' => _hint(_('Fill to change the API password')), 'HINT_MODULE_SENDER' => _hint(_('Max. 16 numeric or 11 alphanumeric char. empty to disable')), 'HINT_TIMEZONE' => _hint(_('Eg: +0700 for Jakarta/Bangkok timezone')), 'CALLBACK_URL_IS' => _('Your current callback URL is'), 'CALLBACK_URL_ACCESSIBLE' => _('Your callback URL should be accessible from Generic'), 'GENERIC_PUSH_DLR' => _('Generic will push DLR and incoming SMS to your callback URL'), 'BUTTON_BACK' => _back('index.php?app=main&inc=core_gateway&op=gateway_list'), 'status_active' => $status_active, 'generic_param_url' => $plugin_config['generic']['url'], 'generic_param_callback_url' => $plugin_config['generic']['callback_url'], 'generic_param_api_username' => $plugin_config['generic']['api_username'], 'generic_param_module_sender' => $plugin_config['generic']['module_sender'], 'generic_param_datetime_timezone' => $plugin_config['generic']['datetime_timezone']));
        _p(tpl_apply($tpl));
        break;
    case "manage_save":
        $up_url = $_REQUEST['up_url'] ? $_REQUEST['up_url'] : $plugin_config['generic']['default_url'];
        $up_callback_url = $_REQUEST['up_callback_url'] ? $_REQUEST['up_callback_url'] : $plugin_config['generic']['default_callback_url'];
        $up_api_username = $_REQUEST['up_api_username'];
        $up_api_password = $_REQUEST['up_api_password'];
        $up_module_sender = $_REQUEST['up_module_sender'];
        $up_datetime_timezone = $_REQUEST['up_datetime_timezone'];
        if ($up_url && $up_api_username) {
            $items = array('url' => $up_url, 'callback_url' => $up_callback_url, 'api_username' => $up_api_username, 'module_sender' => $up_module_sender, 'datetime_timezone' => $up_datetime_timezone);
            if ($up_api_password) {
                $items['api_password'] = $up_api_password;
            }
            if (registry_update(0, 'gateway', 'generic', $items)) {
                $_SESSION['dialog']['info'][] = _('Gateway module configurations has been saved');
            } else {
                $_SESSION['dialog']['danger'][] = _('Fail to save gateway module configurations');
            }
        } else {
            $_SESSION['dialog']['danger'][] = _('All mandatory fields must be filled');
        }
        header("Location: " . _u('index.php?app=main&inc=gateway_generic&op=manage'));
        exit;
        break;
}
Ejemplo n.º 21
0
function webservices_login_key_set($username)
{
    $uid = user_username2uid($username);
    $login_key = md5(core_get_random_string(32));
    if (registry_update($uid, 'core', 'webservices', array('login_key' => $login_key))) {
        $json['status'] = 'OK';
        $json['error'] = '0';
        $json['login_key'] = $login_key;
    } else {
        $json['status'] = 'ERR';
        $json['error'] = '626';
    }
    return $json;
}
Ejemplo n.º 22
0
/**
 * Set status of plugin
 *
 * @param integer $uid        
 * @param string $plugin_category        
 * @param string $plugin_name        
 * @param boolean $plugin_status        
 * @return boolean
 */
function core_plugin_set_status($uid, $plugin_category, $plugin_name, $plugin_status)
{
    $ret = FALSE;
    $status = core_plugin_get_status($uid, $plugin_category, $plugin_name);
    if ($status == 2 && $plugin_status || $status == 1 && !$plugin_status) {
        $ret = TRUE;
    } else {
        $plugin_status = $plugin_status ? 2 : 1;
        $items = array('enabled' => $plugin_status);
        if (registry_update($uid, $plugin_category, $plugin_name, $items)) {
            $ret = TRUE;
        }
    }
    return $ret;
}
Ejemplo n.º 23
0
        $_SESSION['error_string'] = _('Changes have been made');
        // Handle DLR config (emmanuel)
        if (isset($_POST['dlr_box'])) {
            for ($i = 0, $c = count($_POST['dlr_box']); $i < $c; $i++) {
                $up_playsms_dlr += intval($_POST['dlr_box'][$i]);
            }
        }
        // end of Handle DLR config (emmanuel)
        $items = array('username' => $_POST['up_username'], 'module_sender' => $_POST['up_module_sender'], 'module_timezone' => $_POST['up_module_timezone'], 'bearerbox_host' => $_POST['up_bearerbox_host'], 'sendsms_host' => $_POST['up_sendsms_host'], 'sendsms_port' => $_POST['up_sendsms_port'], 'playsms_web' => $_POST['up_playsms_web'], 'additional_param' => $_POST['up_additional_param'], 'dlr' => $up_playsms_dlr, 'admin_host' => $_POST['up_admin_host'], 'admin_port' => $_POST['up_admin_port'], 'local_time' => $_POST['up_local_time']);
        if ($_POST['up_password']) {
            $items['password'] = $_POST['up_password'];
        }
        if ($_POST['up_admin_password']) {
            $items['admin_password'] = $_POST['up_admin_password'];
        }
        registry_update(1, 'gateway', 'kannel', $items);
        header("Location: " . _u('index.php?app=main&inc=gateway_kannel&op=manage'));
        exit;
        break;
    case "manage_restart":
        $admin_port = $plugin_config['kannel']['admin_port'];
        $admin_host = $plugin_config['kannel']['bearerbox_host'];
        $admin_host = $admin_port ? $admin_host . ':' . $admin_port : $admin_host;
        $admin_password = $plugin_config['kannel']['admin_password'];
        $url = 'http://' . $admin_host . '/restart?password='******'error_string'] = _('Restart Kannel') . ' - ' . _('Status') . ': ' . $restart;
        header("Location: " . _u('index.php?app=main&inc=gateway_kannel&op=manage'));
        exit;
        break;
}
Ejemplo n.º 24
0
 * 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();
}
switch (_OP_) {
    case "sms_sync_list":
        $list = registry_search($user_config['uid'], 'feature', 'sms_sync');
        $sms_sync_secret = $list['feature']['sms_sync']['secret'];
        if ($list['feature']['sms_sync']['enable']) {
            $option_enable = 'checked';
        }
        $sync_url = $core_config['http_path']['base'] . '/plugin/feature/sms_sync/sync.php?uid=' . $user_config['uid'];
        unset($tpl);
        $tpl = array('name' => 'sms_sync', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'HINT_SECRET' => _hint(_('Secret key is used in SMSSync app')), 'HINT_ENABLE' => _hint(_('Check to enable receiving push messages from SMSSync app')), 'SECRET' => $sms_sync_secret, 'CHECKED' => $option_enable, 'SYNC_URL' => $sync_url, 'Manage sync' => _('Manage sync'), 'Secret key' => _('Secret key'), 'Enable SMS Sync' => _('Enable SMS Sync'), 'Sync URL' => _('Sync URL'), 'Notes' => _('Notes'), 'Download SMSSync app for Android from' => _('Download SMSSync app for Android from'), 'Save' => _('Save')));
        _p(tpl_apply($tpl));
        break;
    case "sms_sync_save":
        $items['secret'] = $_POST['sms_sync_secret'];
        $items['enable'] = trim($_POST['sms_sync_enable']) ? 1 : 0;
        if (registry_update($user_config['uid'], 'feature', 'sms_sync', $items)) {
            $_SESSION['dialog']['info'][] = _('SMS Sync configuration has been saved');
        } else {
            $_SESSION['dialog']['info'][] = _('Fail to save SMS Sync configuration');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_sms_sync&op=sms_sync_list'));
        exit;
        break;
}
Ejemplo n.º 25
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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();
}
include $core_config['apps_path']['plug'] . "/gateway/playnet/config.php";
switch (_OP_) {
    case "manage":
        $content = _dialog() . "\n\t\t\t<h2>" . _('Manage playnet') . "</h2>\n\t\t\t<form action=index.php?app=main&inc=gateway_playnet&op=manage_save method=post>\n\t\t\t" . _CSRF_FORM_ . "\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>" . _('Gateway name') . "</td><td>playnet</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Module sender ID') . "</td><td><input type=text maxlength=16 name=up_module_sender value=\"" . $plugin_config['playnet']['module_sender'] . "\"> " . _hint(_('Max. 16 numeric or 11 alphanumeric char. empty to disable')) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Module timezone') . "</td><td><input type=text size=5 maxlength=5 name=up_module_timezone value=\"" . $plugin_config['playnet']['module_timezone'] . "\"> " . _hint(_('Eg: +0700 for Jakarta/Bangkok timezone')) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>" . _back('index.php?app=main&inc=core_gateway&op=gateway_list');
        _p($content);
        break;
    case "manage_save":
        $items = array('module_sender' => $_POST['up_module_sender'], 'module_timezone' => $_POST['up_module_timezone']);
        if ($_POST['up_password']) {
            $items['password'] = $_POST['up_password'];
        }
        if ($_POST['up_admin_password']) {
            $items['admin_password'] = $_POST['up_admin_password'];
        }
        registry_update(0, 'gateway', 'playnet', $items);
        $_SESSION['dialog']['info'][] = _('Changes have been made');
        header("Location: " . _u('index.php?app=main&inc=gateway_playnet&op=manage'));
        exit;
        break;
}