Example #1
0
/**
 * Hook to core_themes_get()
 *
 * @return string Themes name or empty
 */
function site_hook_core_themes_get()
{
    $ret = '';
    $site_config = site_config_get();
    if (strtolower(trim($_SERVER['HTTP_HOST'])) == strtolower(trim($site_config['domain']))) {
        if ($site_config['themes_module']) {
            $ret = $site_config['themes_module'];
        }
    }
    return $ret;
}
Example #2
0
function recvsms_inbox_add($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver = "", $reference_id = '')
{
    global $core_config;
    // sms to inbox will be handled by plugins first
    $ret_intercept = recvsms_inbox_add_intercept($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver, $reference_id);
    if ($ret_intercept['param_modified']) {
        $sms_datetime = $ret_intercept['param']['sms_datetime'] ? $ret_intercept['param']['sms_datetime'] : $sms_datetime;
        $sms_sender = $ret_intercept['param']['sms_sender'] ? $ret_intercept['param']['sms_sender'] : $sms_sender;
        $target_user = $ret_intercept['param']['target_user'] ? $ret_intercept['param']['target_user'] : $target_user;
        $message = $ret_intercept['param']['message'] ? $ret_intercept['param']['message'] : $message;
        $sms_receiver = $ret_intercept['param']['sms_receiver'] ? $ret_intercept['param']['sms_receiver'] : $sms_receiver;
        $reference_id = $ret_intercept['param']['reference_id'] ? $ret_intercept['param']['reference_id'] : $reference_id;
    }
    $ok = FALSE;
    if ($sms_sender && $target_user && $message) {
        $user = user_getdatabyusername($target_user);
        if ($uid = $user['uid']) {
            // discard if banned
            if (user_banned_get($uid)) {
                logger_print("user banned, message ignored uid:" . $uid, 2, "recvsms_inbox_add");
                return FALSE;
            }
            // get name from target_user's phonebook
            $c_name = '';
            if (substr($sms_sender, 0, 1) == '@') {
                $c_username = str_replace('@', '', $sms_sender);
                $c_name = user_getfieldbyusername($c_username, 'name');
            } else {
                $c_name = phonebook_number2name($uid, $sms_sender);
            }
            $sender = $c_name ? $c_name . ' (' . $sms_sender . ')' : $sms_sender;
            // forward to Inbox
            if ($fwd_to_inbox = $user['fwd_to_inbox']) {
                $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_tblSMSInbox\n\t\t\t\t\t(in_sender,in_receiver,in_uid,in_msg,in_datetime,reference_id)\n\t\t\t\t\tVALUES ('{$sms_sender}','{$sms_receiver}','{$uid}','{$message}','" . core_adjust_datetime($sms_datetime) . "','{$reference_id}')\n\t\t\t\t";
                logger_print("saving sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user . " reference_id:" . $reference_id, 2, "recvsms_inbox_add");
                if ($inbox_id = @dba_insert_id($db_query)) {
                    logger_print("saved id:" . $inbox_id . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user, 2, "recvsms_inbox_add");
                    $ok = TRUE;
                }
            }
            // forward to email, consider site config too
            if ($parent_uid = user_getparentbyuid($uid)) {
                $site_config = site_config_get($parent_uid);
            }
            $web_title = $site_config['web_title'] ? $site_config['web_title'] : $core_config['main']['web_title'];
            $email_service = $site_config['email_service'] ? $site_config['email_service'] : $core_config['main']['email_service'];
            $email_footer = $site_config['email_footer'] ? $site_config['email_footer'] : $core_config['main']['email_footer'];
            $sms_receiver = $sms_receiver ? $sms_receiver : '-';
            if ($fwd_to_email = $user['fwd_to_email']) {
                if ($email = $user['email']) {
                    $subject = _('Message from') . " " . $sender;
                    $body = $web_title . "\n\n";
                    $body .= _('Message received at') . " " . $sms_receiver . " " . _('on') . " " . $sms_datetime . "\n\n";
                    $body .= _('From') . " " . $sender . "\n\n";
                    $body .= $message . "\n\n--\n";
                    $body .= $email_footer . "\n\n";
                    $body = stripslashes($body);
                    logger_print("send email from:" . $email_service . " to:" . $email . " message:[" . $message . "]", 3, "recvsms_inbox_add");
                    $data = array('mail_from_name' => $web_title, 'mail_from' => $email_service, 'mail_to' => $email, 'mail_subject' => $subject, 'mail_body' => $body);
                    sendmail($data);
                    logger_print("sent email from:" . $email_service . " to:" . $email, 3, "recvsms_inbox_add");
                }
            }
            // forward to mobile
            if ($fwd_to_mobile = $user['fwd_to_mobile']) {
                if ($mobile = $user['mobile']) {
                    // fixme anton
                    $c_message = $message . ' ' . $sender;
                    if ($sender_uid = user_mobile2uid($sms_sender)) {
                        if ($sender_username = user_uid2username($sender_uid)) {
                            $c_message = $message . ' ' . '@' . $sender_username;
                        }
                    }
                    $message = $c_message;
                    $unicode = core_detect_unicode($message);
                    $nofooter = TRUE;
                    logger_print("send to mobile:" . $mobile . " from:" . $sms_sender . " user:"******" message:" . $message, 3, "recvsms_inbox_add");
                    list($ok, $to, $smslog_id, $queue) = sendsms($target_user, $mobile, $message, 'text', $unicode, '', $nofooter);
                    if ($ok[0] == 1) {
                        logger_print("sent to mobile:" . $mobile . " from:" . $sms_sender . " user:"******"recvsms_inbox_add");
                    }
                }
            }
        }
    }
    return $ok;
}
Example #3
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with playSMS. If not, see <http://www.gnu.org/licenses/>.
 */
defined('_SECURE_') or die('Forbidden');
if (!auth_isvalid()) {
    auth_block();
}
// admin and normal users allowed to use this plugin
if (!($user_config['status'] == 2 || $user_config['status'] == 3)) {
    auth_block();
}
switch (_OP_) {
    case "site_config":
        $site_config = site_config_get();
        // enable register yes-no option
        $selected = $site_config['enable_register'] ? _('yes') : _('no');
        $options['enable_register'] = _options(array(_('yes') => 1, _('no') => 0), $site_config['enable_register']);
        // enable forgot yes-no option
        $selected = $site_config['enable_forgot'] ? _('yes') : _('no');
        $options['enable_forgot'] = _options(array(_('yes') => 1, _('no') => 0), $site_config['enable_forgot']);
        // enable logo yes-no option
        $options['enable_logo'] = _options(array(_('yes') => 1, _('no') => 0), $site_config['enable_logo']);
        // enable logo to replace main website title yes-no option
        $options['logo_replace_title'] = _options(array(_('yes') => 1, _('no') => 0), $site_config['logo_replace_title']);
        // get themes options
        $options['themes_module'] = _options($core_config['plugins']['list']['themes'], $site_config['themes_module']);
        // get language options
        $lang_list = '';
        for ($i = 0; $i < count($core_config['plugins']['list']['language']); $i++) {
Example #4
0
    }
    // special setting to credit unicode SMS the same as normal SMS length
    // for example: 2 unicode SMS (140 chars length) will be deducted as 1 credit just like a normal SMS (160 chars length)
    $result = registry_search($user_config['uid'], 'core', 'user_config', 'enable_credit_unicode');
    $user_config['opt']['enable_credit_unicode'] = (int) $result['core']['user_config']['enable_credit_unicode'];
    if (!$user_config['opt']['enable_credit_unicode']) {
        // global config overriden by user config
        $user_config['opt']['enable_credit_unicode'] = (int) $core_config['main']['enable_credit_unicode'];
    }
}
// override main config with site config for branding purposes distinguished by domain name
$site_config = array();
if (!$core_config['daemon_process'] && $_SERVER['HTTP_HOST']) {
    $s = site_config_getbydomain($_SERVER['HTTP_HOST']);
    if ((int) $s[0]['uid']) {
        $c_site_config = site_config_get((int) $s[0]['uid']);
        if (strtolower($c_site_config['domain']) == strtoloweR($_SERVER['HTTP_HOST'])) {
            $site_config = array_merge($c_site_config, $s[0]);
        }
    }
}
if (!$core_config['daemon_process'] && trim($_SERVER['HTTP_HOST']) && trim($site_config['domain']) && strtolower(trim($_SERVER['HTTP_HOST'])) == strtolower(trim($site_config['domain']))) {
    $core_config['main'] = array_merge($core_config['main'], $site_config);
}
// verify selected themes_module exists
$fn1 = _APPS_PATH_PLUG_ . '/themes/' . core_themes_get() . '/config.php';
$fn2 = _APPS_PATH_PLUG_ . '/themes/' . core_themes_get() . '/fn.php';
if (!(file_exists($fn1) && file_exists($fn2))) {
    logger_print('Fail to load themes ' . core_themes_get(), 1, 'init');
    ob_end_clean();
    die(_('FATAL ERROR') . ' : ' . _('Fail to load themes') . ' ' . core_themes_get());