コード例 #1
0
ファイル: ifttt.php プロジェクト: ZerGabriel/friendica-addons
function ifttt_settings_post(&$a, &$b)
{
    if (x($_POST, 'ifttt-submit')) {
        if (isset($_POST['ifttt-rekey'])) {
            del_pconfig(local_user(), 'ifttt', 'key');
        }
    }
}
コード例 #2
0
ファイル: widgets.php プロジェクト: robhell/friendica-addons
function widgets_settings_post()
{
    if (!local_user()) {
        return;
    }
    if (isset($_POST['widgets-submit'])) {
        del_pconfig(local_user(), 'widgets', 'key');
    }
}
コード例 #3
0
function ostatus_subscribe_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $o = "<h2>" . t("Subsribing to OStatus contacts") . "</h2>";
    $uid = local_user();
    $a = get_app();
    $counter = intval($_REQUEST['counter']);
    if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
        if ($_REQUEST["url"] == "") {
            return $o . t("No contact provided.");
        }
        $contact = probe_url($_REQUEST["url"]);
        if (!$contact) {
            return $o . t("Couldn't fetch information for contact.");
        }
        $api = $contact["baseurl"] . "/api/";
        // Fetching friends
        $data = z_fetch_url($api . "statuses/friends.json?screen_name=" . $contact["nick"]);
        if (!$data["success"]) {
            return $o . t("Couldn't fetch friends for contact.");
        }
        set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
    }
    $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
    $total = sizeof($friends);
    if ($counter >= $total) {
        $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/settings/connectors">';
        del_pconfig($uid, "ostatus", "legacy_friends");
        del_pconfig($uid, "ostatus", "legacy_contact");
        $o .= t("Done");
        return $o;
    }
    $friend = $friends[$counter++];
    $url = $friend->statusnet_profile_url;
    $o .= "<p>" . $counter . "/" . $total . ": " . $url;
    $data = probe_url($url);
    if ($data["network"] == NETWORK_OSTATUS) {
        $result = new_contact($uid, $url, true);
        if ($result["success"]) {
            $o .= " - " . t("success");
        } else {
            $o .= " - " . t("failed");
        }
    } else {
        $o .= " - " . t("ignored");
    }
    $o .= "</p>";
    $o .= "<p>" . t("Keep this window open until done.") . "</p>";
    $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/ostatus_subscribe?counter=' . $counter . '">';
    return $o;
}
コード例 #4
0
function fromgplus_addon_settings_post(&$a, &$b)
{
    if (!local_user()) {
        return;
    }
    if ($_POST['fromgplus-submit']) {
        set_pconfig(local_user(), 'fromgplus', 'account', trim($_POST['fromgplus-account']));
        $enable = x($_POST, 'fromgplus-enable') ? intval($_POST['fromgplus-enable']) : 0;
        set_pconfig(local_user(), 'fromgplus', 'enable', $enable);
        if (!$enable) {
            del_pconfig(local_user(), 'fromgplus', 'lastdate');
        }
        info(t('Google+ Import Settings saved.') . EOL);
    }
}
コード例 #5
0
ファイル: pdledit.php プロジェクト: Mauru/red
function pdledit_post(&$a)
{
    if (!local_user()) {
        return;
    }
    if (!$_REQUEST['module']) {
        return;
    }
    if (!trim($_REQUEST['content'])) {
        del_pconfig(local_user(), 'system', 'mod_' . $_REQUEST['module'] . '.pdl');
        goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
    }
    set_pconfig(local_user(), 'system', 'mod_' . $_REQUEST['module'] . '.pdl', escape_tags($_REQUEST['content']));
    info(t('Layout updated.') . EOL);
    goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
}
コード例 #6
0
ファイル: Pdledit.php プロジェクト: phellmes/hubzilla
 function post()
 {
     if (!local_channel()) {
         return;
     }
     if (!$_REQUEST['module']) {
         return;
     }
     if (!feature_enabled(local_channel(), 'advanced_theming')) {
         return;
     }
     if (!trim($_REQUEST['content'])) {
         del_pconfig(local_channel(), 'system', 'mod_' . $_REQUEST['module'] . '.pdl');
         goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
     }
     set_pconfig(local_channel(), 'system', 'mod_' . $_REQUEST['module'] . '.pdl', escape_tags($_REQUEST['content']));
     build_sync_packet();
     info(t('Layout updated.') . EOL);
     goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
 }
コード例 #7
0
/**
 * @param App $a
 * @return string
 */
function fbpost_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if (!service_class_allows(local_user(), 'facebook_connect')) {
        notice(t('Permission denied.') . EOL);
        return upgrade_bool_message();
    }
    if ($a->argc > 1 && $a->argv[1] === 'remove') {
        del_pconfig(local_user(), 'facebook', 'post');
        info(t('Facebook Post disabled') . EOL);
    }
    require_once "mod/settings.php";
    settings_init($a);
    $o = '';
    $accounts = array();
    $fb_installed = false;
    if (get_pconfig(local_user(), 'facebook', 'post')) {
        $access_token = get_pconfig(local_user(), 'facebook', 'access_token');
        if ($access_token) {
            // fetching the list of accounts to check, if facebook is working
            // The value is needed several lines below.
            $url = 'https://graph.facebook.com/me/accounts';
            $s = fetch_url($url . "?access_token=" . $access_token, false, $redirects, 10);
            if ($s) {
                $accounts = json_decode($s);
                if (isset($accounts->data)) {
                    $fb_installed = true;
                }
            }
            // I'm not totally sure, if this above will work in every situation,
            // So this old code will be called as well.
            if (!$fb_installed) {
                $url = "https://graph.facebook.com/me/feed";
                $s = fetch_url($url . "?access_token=" . $access_token . "&limit=1", false, $redirects, 10);
                if ($s) {
                    $j = json_decode($s);
                    if (isset($j->data)) {
                        $fb_installed = true;
                    }
                }
            }
        }
    }
    $appid = get_config('facebook', 'appid');
    if (!$appid) {
        notice(t('Facebook API key is missing.') . EOL);
        return '';
    }
    $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/fbpost/fbpost.css' . '" media="all" />' . "\r\n";
    $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
    $fbsync = count($result) > 0;
    if ($fbsync) {
        $title = t('Facebook Import/Export/Mirror');
    } else {
        $title = t('Facebook Export/Mirror');
    }
    $o .= '<img class="connector" src="images/facebook.png" /><h3 class="connector">' . $title . '</h3>';
    if (!$fb_installed) {
        $o .= '<div id="fbpost-enable-wrapper">';
        //read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access
        //export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update
        $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_actions,publish_pages,user_posts,user_photos,user_status,user_videos,manage_pages,user_managed_groups">' . t('Install Facebook Post connector for this account.') . '</a>';
        $o .= '</div>';
    }
    if ($fb_installed) {
        $o .= '<div id="fbpost-disable-wrapper">';
        $o .= '<a href="' . $a->get_baseurl() . '/fbpost/remove' . '">' . t('Remove Facebook Post connector') . '</a></div>';
        $o .= '<div id="fbpost-enable-wrapper">';
        //export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update
        $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_actions,publish_pages,user_posts,user_photos,user_status,user_videos,manage_pages,user_managed_groups">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
        $o .= '</div>';
        $o .= '<div id="fbpost-post-default-form">';
        $o .= '<form action="fbpost" method="post" >';
        $post_by_default = get_pconfig(local_user(), 'facebook', 'post_by_default');
        $checked = $post_by_default ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . EOL;
        $suppress_view_on_friendica = get_pconfig(local_user(), 'facebook', 'suppress_view_on_friendica');
        $checked = $suppress_view_on_friendica ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="suppress_view_on_friendica" value="1"' . $checked . '/>' . ' ' . t('Suppress "View on friendica"') . EOL;
        $mirror_posts = get_pconfig(local_user(), 'facebook', 'mirror_posts');
        $checked = $mirror_posts ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="mirror_posts" value="1"' . $checked . '/>' . ' ' . t('Mirror wall posts from facebook to friendica.') . EOL;
        // List all pages
        $post_to_page = get_pconfig(local_user(), 'facebook', 'post_to_page');
        $page_access_token = get_pconfig(local_user(), 'facebook', 'page_access_token');
        $fb_token = get_pconfig($a->user['uid'], 'facebook', 'access_token');
        //$url = 'https://graph.facebook.com/me/accounts';
        //$x = fetch_url($url."?access_token=".$fb_token, false, $redirects, 10);
        //$accounts = json_decode($x);
        $o .= t("Post to page/group:") . "<select name='post_to_page'>";
        if (intval($post_to_page) == 0) {
            $o .= "<option value='0-0' selected>" . t('None') . "</option>";
        } else {
            $o .= "<option value='0-0'>" . t('None') . "</option>";
        }
        foreach ($accounts->data as $account) {
            if (is_array($account->perms)) {
                if ($post_to_page == $account->id) {
                    $o .= "<option value='" . $account->id . "-" . $account->access_token . "' selected>" . $account->name . "</option>";
                } else {
                    $o .= "<option value='" . $account->id . "-" . $account->access_token . "'>" . $account->name . "</option>";
                }
            }
        }
        $url = 'https://graph.facebook.com/me/groups';
        $x = fetch_url($url . "?access_token=" . $fb_token, false, $redirects, 10);
        $groups = json_decode($x);
        foreach ($groups->data as $group) {
            if ($post_to_page == $group->id) {
                $o .= "<option value='" . $group->id . "-0' selected>" . $group->name . "</option>";
            } else {
                $o .= "<option value='" . $group->id . "-0'>" . $group->name . "</option>";
            }
        }
        $o .= "</select>";
        if ($fbsync) {
            $o .= '<div class="clear"></div>';
            $sync_enabled = get_pconfig(local_user(), 'fbsync', 'sync');
            $checked = $sync_enabled ? ' checked="checked" ' : '';
            $o .= '<input type="checkbox" name="fbsync" value="1"' . $checked . '/>' . ' ' . t('Import Facebook newsfeed.') . EOL;
            $create_user = get_pconfig(local_user(), 'fbsync', 'create_user');
            $checked = $create_user ? ' checked="checked" ' : '';
            $o .= '<input type="checkbox" name="create_user" value="1"' . $checked . '/>' . ' ' . t('Automatically create contacts.') . EOL;
        }
        $o .= '<p><input type="submit" name="submit" value="' . t('Save Settings') . '" /></form></div>';
    }
    return $o;
}
コード例 #8
0
function pumpio_settings_post(&$a, &$b)
{
    if (x($_POST, 'pumpio-submit')) {
        if (x($_POST, 'pumpio_delete')) {
            set_pconfig(local_user(), 'pumpio', 'consumer_key', '');
            set_pconfig(local_user(), 'pumpio', 'consumer_secret', '');
            set_pconfig(local_user(), 'pumpio', 'oauth_token', '');
            set_pconfig(local_user(), 'pumpio', 'oauth_token_secret', '');
            set_pconfig(local_user(), 'pumpio', 'post', false);
            set_pconfig(local_user(), 'pumpio', 'import', false);
            set_pconfig(local_user(), 'pumpio', 'host', '');
            set_pconfig(local_user(), 'pumpio', 'user', '');
            set_pconfig(local_user(), 'pumpio', 'public', false);
            set_pconfig(local_user(), 'pumpio', 'mirror', false);
            set_pconfig(local_user(), 'pumpio', 'post_by_default', false);
            set_pconfig(local_user(), 'pumpio', 'lastdate', 0);
            set_pconfig(local_user(), 'pumpio', 'last_id', '');
        } else {
            // filtering the username if it is filled wrong
            $user = $_POST['pumpio_user'];
            if (strstr($user, "@")) {
                $pos = strpos($user, "@");
                if ($pos > 0) {
                    $user = substr($user, 0, $pos);
                }
            }
            // Filtering the hostname if someone is entering it with "http"
            $host = $_POST['pumpio_host'];
            $host = trim($host);
            $host = str_replace(array("https://", "http://"), array("", ""), $host);
            set_pconfig(local_user(), 'pumpio', 'post', intval($_POST['pumpio']));
            set_pconfig(local_user(), 'pumpio', 'import', $_POST['pumpio_import']);
            set_pconfig(local_user(), 'pumpio', 'host', $host);
            set_pconfig(local_user(), 'pumpio', 'user', $user);
            set_pconfig(local_user(), 'pumpio', 'public', $_POST['pumpio_public']);
            set_pconfig(local_user(), 'pumpio', 'mirror', $_POST['pumpio_mirror']);
            set_pconfig(local_user(), 'pumpio', 'post_by_default', intval($_POST['pumpio_bydefault']));
            if (!$_POST['pumpio_mirror']) {
                del_pconfig(local_user(), 'pumpio', 'lastdate');
            }
            //header("Location: ".$a->get_baseurl()."/pumpio/connect");
        }
    }
}
コード例 #9
0
function twitter_settings_post($a, $post)
{
    if (!local_channel()) {
        return;
    }
    // don't check twitter settings if twitter submit button is not clicked
    if (!x($_POST, 'twitter-submit')) {
        return;
    }
    if (isset($_POST['twitter-disconnect'])) {
        /***
         * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair
         * from the user configuration
         */
        del_pconfig(local_channel(), 'twitter', 'consumerkey');
        del_pconfig(local_channel(), 'twitter', 'consumersecret');
        del_pconfig(local_channel(), 'twitter', 'oauthtoken');
        del_pconfig(local_channel(), 'twitter', 'oauthsecret');
        del_pconfig(local_channel(), 'twitter', 'post');
        del_pconfig(local_channel(), 'twitter', 'post_by_default');
        del_pconfig(local_channel(), 'twitter', 'post_taglinks');
        del_pconfig(local_channel(), 'twitter', 'lastid');
        del_pconfig(local_channel(), 'twitter', 'intelligent_shortening');
        del_pconfig(local_channel(), 'twitter', 'own_id');
    } else {
        if (isset($_POST['twitter-pin'])) {
            //  if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
            logger('got a Twitter PIN');
            require_once 'library/twitteroauth.php';
            $ckey = get_config('twitter', 'consumerkey');
            $csecret = get_config('twitter', 'consumersecret');
            //  the token and secret for which the PIN was generated were hidden in the settings
            //  form as token and token2, we need a new connection to Twitter using these token
            //  and secret to request a Access Token with the PIN
            $connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
            $token = $connection->getAccessToken($_POST['twitter-pin']);
            //  ok, now that we have the Access Token, save them in the user config
            set_pconfig(local_channel(), 'twitter', 'oauthtoken', $token['oauth_token']);
            set_pconfig(local_channel(), 'twitter', 'oauthsecret', $token['oauth_token_secret']);
            set_pconfig(local_channel(), 'twitter', 'post', 1);
            set_pconfig(local_channel(), 'twitter', 'post_taglinks', 1);
            //  reload the Addon Settings page, if we don't do it see Friendica Bug #42
            goaway($a->get_baseurl() . '/settings/featured');
        } else {
            //  if no PIN is supplied in the POST variables, the user has changed the setting
            //  to post a tweet for every new __public__ posting to the wall
            set_pconfig(local_channel(), 'twitter', 'post', intval($_POST['twitter-enable']));
            set_pconfig(local_channel(), 'twitter', 'post_by_default', intval($_POST['twitter-default']));
            set_pconfig(local_channel(), 'twitter', 'post_taglinks', intval($_POST['twitter-sendtaglinks']));
            set_pconfig(local_channel(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
            set_pconfig(local_channel(), 'twitter', 'intelligent_shortening', intval($_POST['twitter-shortening']));
            set_pconfig(local_channel(), 'twitter', 'import', intval($_POST['twitter-import']));
            set_pconfig(local_channel(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
            info(t('Twitter settings updated.') . EOL);
        }
    }
}
コード例 #10
0
ファイル: appnet.php プロジェクト: rabuzarus/friendica-addons
function appnet_settings_post(&$a, &$b)
{
    if (x($_POST, 'appnet-submit')) {
        if (isset($_POST['appnet-disconnect'])) {
            del_pconfig(local_user(), 'appnet', 'clientsecret');
            del_pconfig(local_user(), 'appnet', 'clientid');
            del_pconfig(local_user(), 'appnet', 'token');
            del_pconfig(local_user(), 'appnet', 'post');
            del_pconfig(local_user(), 'appnet', 'post_by_default');
            del_pconfig(local_user(), 'appnet', 'import');
        }
        if (isset($_POST["clientsecret"])) {
            set_pconfig(local_user(), 'appnet', 'clientsecret', $_POST['clientsecret']);
        }
        if (isset($_POST["clientid"])) {
            set_pconfig(local_user(), 'appnet', 'clientid', $_POST['clientid']);
        }
        if (isset($_POST["token"]) and $_POST["token"] != "") {
            set_pconfig(local_user(), 'appnet', 'token', $_POST['token']);
        }
        set_pconfig(local_user(), 'appnet', 'post', intval($_POST['appnet']));
        set_pconfig(local_user(), 'appnet', 'post_by_default', intval($_POST['appnet_bydefault']));
        set_pconfig(local_user(), 'appnet', 'import', intval($_POST['appnet_import']));
    }
}
コード例 #11
0
function twitter_fetch_own_contact($a, $uid)
{
    $ckey = get_config('twitter', 'consumerkey');
    $csecret = get_config('twitter', 'consumersecret');
    $otoken = get_pconfig($uid, 'twitter', 'oauthtoken');
    $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
    $own_id = get_pconfig($uid, 'twitter', 'own_id');
    $contact_id = 0;
    if ($own_id == "") {
        require_once 'library/twitteroauth.php';
        $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
        // Fetching user data
        $user = $connection->get('account/verify_credentials');
        set_pconfig($uid, 'twitter', 'own_id', $user->id_str);
        $contact_id = twitter_fetch_contact($uid, $user, true);
    } else {
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc("twitter::" . $own_id));
        if (count($r)) {
            $contact_id = $r[0]["id"];
        } else {
            del_pconfig($uid, 'twitter', 'own_id');
        }
    }
    return $contact_id;
}
コード例 #12
0
ファイル: update.php プロジェクト: vinzv/friendica
function update_1190()
{
    require_once 'include/plugin.php';
    set_config('system', 'maintenance', 1);
    if (plugin_enabled('forumlist')) {
        $plugin = 'forumlist';
        $plugins = get_config('system', 'addon');
        $plugins_arr = array();
        if ($plugins) {
            $plugins_arr = explode(",", str_replace(" ", "", $plugins));
            $idx = array_search($plugin, $plugins_arr);
            if ($idx !== false) {
                unset($plugins_arr[$idx]);
                //delete forumlist manually from addon and hook table
                // since uninstall_plugin() don't work here
                q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
                q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
                set_config('system', 'addon', implode(", ", $plugins_arr));
            }
        }
    }
    // select old formlist addon entries
    $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ", dbesc('forumlist'));
    // convert old forumlist addon entries in new config entries
    if (count($r)) {
        foreach ($r as $rr) {
            $uid = $rr['uid'];
            $family = $rr['cat'];
            $key = $rr['k'];
            $value = $rr['v'];
            if ($key === 'randomise') {
                del_pconfig($uid, $family, $key);
            }
            if ($key === 'show_on_profile') {
                if ($value) {
                    set_pconfig($uid, feature, forumlist_profile, $value);
                }
                del_pconfig($uid, $family, $key);
            }
            if ($key === 'show_on_network') {
                if ($value) {
                    set_pconfig($uid, feature, forumlist_widget, $value);
                }
                del_pconfig($uid, $family, $key);
            }
        }
    }
    set_config('system', 'maintenance', 0);
    return UPDATE_SUCCESS;
}
コード例 #13
0
ファイル: id.php プロジェクト: TamirAl/hubzilla
 function delAssoc($handle)
 {
     logger('delAssoc');
     $channel = channelx_by_nick(basename($handle));
     if ($channel) {
         return del_pconfig($channel['channel_id'], 'openid', 'associate');
     }
 }
コード例 #14
0
ファイル: settings.php プロジェクト: Gillesq/hubzilla
function settings_post(&$a)
{
    if (!local_channel()) {
        return;
    }
    if ($_SESSION['delegate']) {
        return;
    }
    $channel = $a->get_channel();
    logger('mod_settings: ' . print_r($_REQUEST, true));
    if (argc() > 1 && argv(1) === 'oauth' && x($_POST, 'remove')) {
        check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
        $key = $_POST['remove'];
        q("DELETE FROM tokens WHERE id='%s' AND uid=%d", dbesc($key), local_channel());
        goaway($a->get_baseurl(true) . "/settings/oauth/");
        return;
    }
    if (argc() > 2 && argv(1) === 'oauth' && (argv(2) === 'edit' || argv(2) === 'add') && x($_POST, 'submit')) {
        check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
        $name = x($_POST, 'name') ? $_POST['name'] : '';
        $key = x($_POST, 'key') ? $_POST['key'] : '';
        $secret = x($_POST, 'secret') ? $_POST['secret'] : '';
        $redirect = x($_POST, 'redirect') ? $_POST['redirect'] : '';
        $icon = x($_POST, 'icon') ? $_POST['icon'] : '';
        $ok = true;
        if ($name == '') {
            $ok = false;
            notice(t('Name is required') . EOL);
        }
        if ($key == '' || $secret == '') {
            $ok = false;
            notice(t('Key and Secret are required') . EOL);
        }
        if ($ok) {
            if ($_POST['submit'] == t("Update")) {
                $r = q("UPDATE clients SET\n\t\t\t\t\t\t\tclient_id='%s',\n\t\t\t\t\t\t\tpw='%s',\n\t\t\t\t\t\t\tname='%s',\n\t\t\t\t\t\t\tredirect_uri='%s',\n\t\t\t\t\t\t\ticon='%s',\n\t\t\t\t\t\t\tuid=%d\n\t\t\t\t\t\tWHERE client_id='%s'", dbesc($key), dbesc($secret), dbesc($name), dbesc($redirect), dbesc($icon), intval(local_channel()), dbesc($key));
            } else {
                $r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid)\n\t\t\t\t\tVALUES ('%s','%s','%s','%s','%s',%d)", dbesc($key), dbesc($secret), dbesc($name), dbesc($redirect), dbesc($icon), intval(local_channel()));
                $r = q("INSERT INTO xperm (xp_client, xp_channel, xp_perm) VALUES ('%s', %d, '%s') ", dbesc($key), intval(local_channel()), dbesc('all'));
            }
        }
        goaway($a->get_baseurl(true) . "/settings/oauth/");
        return;
    }
    if (argc() > 1 && argv(1) == 'featured') {
        check_form_security_token_redirectOnErr('/settings/featured', 'settings_featured');
        call_hooks('feature_settings_post', $_POST);
        build_sync_packet();
        return;
    }
    if (argc() > 1 && argv(1) === 'features') {
        check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
        // Build list of features and check which are set
        $features = get_features();
        $all_features = array();
        foreach ($features as $k => $v) {
            foreach ($v as $f) {
                $all_features[] = $f[0];
            }
        }
        foreach ($all_features as $k) {
            if (x($_POST, "feature_{$k}")) {
                set_pconfig(local_channel(), 'feature', $k, 1);
            } else {
                set_pconfig(local_channel(), 'feature', $k, 0);
            }
        }
        build_sync_packet();
        return;
    }
    if (argc() > 1 && argv(1) == 'display') {
        check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
        $theme = x($_POST, 'theme') ? notags(trim($_POST['theme'])) : $a->channel['channel_theme'];
        $mobile_theme = x($_POST, 'mobile_theme') ? notags(trim($_POST['mobile_theme'])) : '';
        $user_scalable = x($_POST, 'user_scalable') ? intval($_POST['user_scalable']) : 0;
        $nosmile = x($_POST, 'nosmile') ? intval($_POST['nosmile']) : 0;
        $title_tosource = x($_POST, 'title_tosource') ? intval($_POST['title_tosource']) : 0;
        $channel_list_mode = x($_POST, 'channel_list_mode') ? intval($_POST['channel_list_mode']) : 0;
        $network_list_mode = x($_POST, 'network_list_mode') ? intval($_POST['network_list_mode']) : 0;
        $channel_divmore_height = x($_POST, 'channel_divmore_height') ? intval($_POST['channel_divmore_height']) : 400;
        if ($channel_divmore_height < 50) {
            $channel_divmore_height = 50;
        }
        $network_divmore_height = x($_POST, 'network_divmore_height') ? intval($_POST['network_divmore_height']) : 400;
        if ($network_divmore_height < 50) {
            $network_divmore_height = 50;
        }
        $browser_update = x($_POST, 'browser_update') ? intval($_POST['browser_update']) : 0;
        $browser_update = $browser_update * 1000;
        if ($browser_update < 10000) {
            $browser_update = 10000;
        }
        $itemspage = x($_POST, 'itemspage') ? intval($_POST['itemspage']) : 20;
        if ($itemspage > 100) {
            $itemspage = 100;
        }
        if ($mobile_theme == "---") {
            del_pconfig(local_channel(), 'system', 'mobile_theme');
        } else {
            set_pconfig(local_channel(), 'system', 'mobile_theme', $mobile_theme);
        }
        set_pconfig(local_channel(), 'system', 'user_scalable', $user_scalable);
        set_pconfig(local_channel(), 'system', 'update_interval', $browser_update);
        set_pconfig(local_channel(), 'system', 'itemspage', $itemspage);
        set_pconfig(local_channel(), 'system', 'no_smilies', 1 - intval($nosmile));
        set_pconfig(local_channel(), 'system', 'title_tosource', $title_tosource);
        set_pconfig(local_channel(), 'system', 'channel_list_mode', $channel_list_mode);
        set_pconfig(local_channel(), 'system', 'network_list_mode', $network_list_mode);
        set_pconfig(local_channel(), 'system', 'channel_divmore_height', $channel_divmore_height);
        set_pconfig(local_channel(), 'system', 'network_divmore_height', $network_divmore_height);
        if ($theme == $a->channel['channel_theme']) {
            // call theme_post only if theme has not been changed
            if (($themeconfigfile = get_theme_config_file($theme)) != null) {
                require_once $themeconfigfile;
                theme_post($a);
            }
        }
        $r = q("UPDATE channel SET channel_theme = '%s' WHERE channel_id = %d", dbesc($theme), intval(local_channel()));
        call_hooks('display_settings_post', $_POST);
        build_sync_packet();
        goaway($a->get_baseurl(true) . '/settings/display');
        return;
        // NOTREACHED
    }
    if (argc() > 1 && argv(1) === 'account') {
        check_form_security_token_redirectOnErr('/settings/account', 'settings_account');
        call_hooks('account_settings_post', $_POST);
        //		call_hooks('settings_account', $_POST);
        $errs = array();
        if (x($_POST, 'npassword') || x($_POST, 'confirm')) {
            $newpass = $_POST['npassword'];
            $confirm = $_POST['confirm'];
            if ($newpass != $confirm) {
                $errs[] = t('Passwords do not match. Password unchanged.');
            }
            if (!x($newpass) || !x($confirm)) {
                $errs[] = t('Empty passwords are not allowed. Password unchanged.');
            }
            if (!$errs) {
                $salt = random_string(32);
                $password_encoded = hash('whirlpool', $salt . $newpass);
                $r = q("update account set account_salt = '%s', account_password = '******', account_password_changed = '%s' \n\t\t\t\t\twhere account_id = %d", dbesc($salt), dbesc($password_encoded), dbesc(datetime_convert()), intval(get_account_id()));
                if ($r) {
                    info(t('Password changed.') . EOL);
                } else {
                    $errs[] = t('Password update failed. Please try again.');
                }
            }
        }
        if ($errs) {
            foreach ($errs as $err) {
                notice($err . EOL);
            }
            $errs = array();
        }
        $email = x($_POST, 'email') ? trim(notags($_POST['email'])) : '';
        $account = $a->get_account();
        if ($email != $account['account_email']) {
            if (!valid_email($email)) {
                $errs[] = t('Not valid email.');
            }
            $adm = trim(get_config('system', 'admin_email'));
            if ($adm && strcasecmp($email, $adm) == 0) {
                $errs[] = t('Protected email address. Cannot change to that email.');
                $email = $a->user['email'];
            }
            if (!$errs) {
                $r = q("update account set account_email = '%s' where account_id = %d", dbesc($email), intval($account['account_id']));
                if (!$r) {
                    $errs[] = t('System failure storing new email. Please try again.');
                }
            }
        }
        if ($errs) {
            foreach ($errs as $err) {
                notice($err . EOL);
            }
        }
        goaway($a->get_baseurl(true) . '/settings/account');
    }
    check_form_security_token_redirectOnErr('/settings', 'settings');
    call_hooks('settings_post', $_POST);
    $set_perms = '';
    $role = x($_POST, 'permissions_role') ? notags(trim($_POST['permissions_role'])) : '';
    $oldrole = get_pconfig(local_channel(), 'system', 'permissions_role');
    if ($role != $oldrole || $role === 'custom') {
        if ($role === 'custom') {
            $hide_presence = x($_POST, 'hide_presence') && intval($_POST['hide_presence']) == 1 ? 1 : 0;
            $publish = x($_POST, 'profile_in_directory') && intval($_POST['profile_in_directory']) == 1 ? 1 : 0;
            $def_group = x($_POST, 'group-selection') ? notags(trim($_POST['group-selection'])) : '';
            $r = q("update channel set channel_default_group = '%s' where channel_id = %d", dbesc($def_group), intval(local_channel()));
            $global_perms = get_perms();
            foreach ($global_perms as $k => $v) {
                $set_perms .= ', ' . $v[0] . ' = ' . intval($_POST[$k]) . ' ';
            }
            $acl = new AccessList($channel);
            $acl->set_from_array($_POST);
            $x = $acl->get();
            $r = q("update channel set channel_allow_cid = '%s', channel_allow_gid = '%s', \n\t\t\t\tchannel_deny_cid = '%s', channel_deny_gid = '%s' where channel_id = %d", dbesc($x['allow_cid']), dbesc($x['allow_gid']), dbesc($x['deny_cid']), dbesc($x['deny_gid']), intval(local_channel()));
        } else {
            $role_permissions = get_role_perms($_POST['permissions_role']);
            if (!$role_permissions) {
                notice('Permissions category could not be found.');
                return;
            }
            $hide_presence = 1 - intval($role_permissions['online']);
            if ($role_permissions['default_collection']) {
                $r = q("select hash from groups where uid = %d and name = '%s' limit 1", intval(local_channel()), dbesc(t('Friends')));
                if (!$r) {
                    require_once 'include/group.php';
                    group_add(local_channel(), t('Friends'));
                    group_add_member(local_channel(), t('Friends'), $channel['channel_hash']);
                    $r = q("select hash from groups where uid = %d and name = '%s' limit 1", intval(local_channel()), dbesc(t('Friends')));
                }
                if ($r) {
                    q("update channel set channel_default_group = '%s', channel_allow_gid = '%s', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d", dbesc($r[0]['hash']), dbesc('<' . $r[0]['hash'] . '>'), intval(local_channel()));
                } else {
                    notice(sprintf('Default privacy group \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
                    return;
                }
            } else {
                q("update channel set channel_default_group = '', channel_allow_gid = '', channel_allow_cid = '', channel_deny_gid = '', \n\t\t\t\t\tchannel_deny_cid = '' where channel_id = %d", intval(local_channel()));
            }
            $r = q("update abook set abook_my_perms  = %d where abook_channel = %d and abook_self = 1", intval(array_key_exists('perms_accept', $role_permissions) ? $role_permissions['perms_accept'] : 0), intval(local_channel()));
            set_pconfig(local_channel(), 'system', 'autoperms', $role_permissions['perms_auto'] ? intval($role_permissions['perms_accept']) : 0);
            foreach ($role_permissions as $p => $v) {
                if (strpos($p, 'channel_') !== false) {
                    $set_perms .= ', ' . $p . ' = ' . intval($v) . ' ';
                }
                if ($p === 'directory_publish') {
                    $publish = intval($v);
                }
            }
        }
        set_pconfig(local_channel(), 'system', 'hide_online_status', $hide_presence);
        set_pconfig(local_channel(), 'system', 'permissions_role', $role);
    }
    $username = x($_POST, 'username') ? notags(trim($_POST['username'])) : '';
    $timezone = x($_POST, 'timezone_select') ? notags(trim($_POST['timezone_select'])) : '';
    $defloc = x($_POST, 'defloc') ? notags(trim($_POST['defloc'])) : '';
    $openid = x($_POST, 'openid_url') ? notags(trim($_POST['openid_url'])) : '';
    $maxreq = x($_POST, 'maxreq') ? intval($_POST['maxreq']) : 0;
    $expire = x($_POST, 'expire') ? intval($_POST['expire']) : 0;
    $evdays = x($_POST, 'evdays') ? intval($_POST['evdays']) : 3;
    $photo_path = x($_POST, 'photo_path') ? escape_tags(trim($_POST['photo_path'])) : '';
    $attach_path = x($_POST, 'attach_path') ? escape_tags(trim($_POST['attach_path'])) : '';
    $channel_menu = x($_POST['channel_menu']) ? htmlspecialchars_decode(trim($_POST['channel_menu']), ENT_QUOTES) : '';
    $expire_items = x($_POST, 'expire_items') ? intval($_POST['expire_items']) : 0;
    $expire_starred = x($_POST, 'expire_starred') ? intval($_POST['expire_starred']) : 0;
    $expire_photos = x($_POST, 'expire_photos') ? intval($_POST['expire_photos']) : 0;
    $expire_network_only = x($_POST, 'expire_network_only') ? intval($_POST['expire_network_only']) : 0;
    $allow_location = x($_POST, 'allow_location') && intval($_POST['allow_location']) == 1 ? 1 : 0;
    $blocktags = x($_POST, 'blocktags') && intval($_POST['blocktags']) == 1 ? 0 : 1;
    // this setting is inverted!
    $unkmail = x($_POST, 'unkmail') && intval($_POST['unkmail']) == 1 ? 1 : 0;
    $cntunkmail = x($_POST, 'cntunkmail') ? intval($_POST['cntunkmail']) : 0;
    $suggestme = x($_POST, 'suggestme') ? intval($_POST['suggestme']) : 0;
    $post_newfriend = $_POST['post_newfriend'] == 1 ? 1 : 0;
    $post_joingroup = $_POST['post_joingroup'] == 1 ? 1 : 0;
    $post_profilechange = $_POST['post_profilechange'] == 1 ? 1 : 0;
    $adult = $_POST['adult'] == 1 ? 1 : 0;
    $cal_first_day = x($_POST, 'first_day') && intval($_POST['first_day']) == 1 ? 1 : 0;
    $channel = $a->get_channel();
    $pageflags = $channel['channel_pageflags'];
    $existing_adult = $pageflags & PAGE_ADULT ? 1 : 0;
    if ($adult != $existing_adult) {
        $pageflags = $pageflags ^ PAGE_ADULT;
    }
    $notify = 0;
    if (x($_POST, 'notify1')) {
        $notify += intval($_POST['notify1']);
    }
    if (x($_POST, 'notify2')) {
        $notify += intval($_POST['notify2']);
    }
    if (x($_POST, 'notify3')) {
        $notify += intval($_POST['notify3']);
    }
    if (x($_POST, 'notify4')) {
        $notify += intval($_POST['notify4']);
    }
    if (x($_POST, 'notify5')) {
        $notify += intval($_POST['notify5']);
    }
    if (x($_POST, 'notify6')) {
        $notify += intval($_POST['notify6']);
    }
    if (x($_POST, 'notify7')) {
        $notify += intval($_POST['notify7']);
    }
    if (x($_POST, 'notify8')) {
        $notify += intval($_POST['notify8']);
    }
    $vnotify = 0;
    if (x($_POST, 'vnotify1')) {
        $vnotify += intval($_POST['vnotify1']);
    }
    if (x($_POST, 'vnotify2')) {
        $vnotify += intval($_POST['vnotify2']);
    }
    if (x($_POST, 'vnotify3')) {
        $vnotify += intval($_POST['vnotify3']);
    }
    if (x($_POST, 'vnotify4')) {
        $vnotify += intval($_POST['vnotify4']);
    }
    if (x($_POST, 'vnotify5')) {
        $vnotify += intval($_POST['vnotify5']);
    }
    if (x($_POST, 'vnotify6')) {
        $vnotify += intval($_POST['vnotify6']);
    }
    if (x($_POST, 'vnotify7')) {
        $vnotify += intval($_POST['vnotify7']);
    }
    if (x($_POST, 'vnotify8')) {
        $vnotify += intval($_POST['vnotify8']);
    }
    if (x($_POST, 'vnotify9')) {
        $vnotify += intval($_POST['vnotify9']);
    }
    if (x($_POST, 'vnotify10')) {
        $vnotify += intval($_POST['vnotify10']);
    }
    if (x($_POST, 'vnotify11')) {
        $vnotify += intval($_POST['vnotify11']);
    }
    $always_show_in_notices = x($_POST, 'always_show_in_notices') ? 1 : 0;
    $channel = $a->get_channel();
    $err = '';
    $name_change = false;
    if ($username != $channel['channel_name']) {
        $name_change = true;
        require_once 'include/identity.php';
        $err = validate_channelname($username);
        if ($err) {
            notice($err);
            return;
        }
    }
    if ($timezone != $channel['channel_timezone']) {
        if (strlen($timezone)) {
            date_default_timezone_set($timezone);
        }
    }
    set_pconfig(local_channel(), 'system', 'use_browser_location', $allow_location);
    set_pconfig(local_channel(), 'system', 'suggestme', $suggestme);
    set_pconfig(local_channel(), 'system', 'post_newfriend', $post_newfriend);
    set_pconfig(local_channel(), 'system', 'post_joingroup', $post_joingroup);
    set_pconfig(local_channel(), 'system', 'post_profilechange', $post_profilechange);
    set_pconfig(local_channel(), 'system', 'blocktags', $blocktags);
    set_pconfig(local_channel(), 'system', 'channel_menu', $channel_menu);
    set_pconfig(local_channel(), 'system', 'vnotify', $vnotify);
    set_pconfig(local_channel(), 'system', 'always_show_in_notices', $always_show_in_notices);
    set_pconfig(local_channel(), 'system', 'evdays', $evdays);
    set_pconfig(local_channel(), 'system', 'photo_path', $photo_path);
    set_pconfig(local_channel(), 'system', 'attach_path', $attach_path);
    set_pconfig(local_channel(), 'system', 'cal_first_day', $cal_first_day);
    $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d {$set_perms} where channel_id = %d", dbesc($username), intval($pageflags), dbesc($timezone), dbesc($defloc), intval($notify), intval($unkmail), intval($maxreq), intval($expire), intval(local_channel()));
    if ($r) {
        info(t('Settings updated.') . EOL);
    }
    if (!is_null($publish)) {
        $r = q("UPDATE profile SET publish = %d WHERE is_default = 1 AND uid = %d", intval($publish), intval(local_channel()));
    }
    if ($name_change) {
        $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s'", dbesc($username), dbesc(datetime_convert()), dbesc($channel['channel_hash']));
        $r = q("update profile set name = '%s' where uid = %d and is_default = 1", dbesc($username), intval($channel['channel_id']));
    }
    proc_run('php', 'include/directory.php', local_channel());
    build_sync_packet();
    //$_SESSION['theme'] = $theme;
    if ($email_changed && $a->config['system']['register_policy'] == REGISTER_VERIFY) {
        // FIXME - set to un-verified, blocked and redirect to logout
        // Why? Are we verifying people or email addresses?
    }
    goaway($a->get_baseurl(true) . '/settings');
    return;
    // NOTREACHED
}
コード例 #15
0
function retriever_plugin_settings_post($a, $post)
{
    if ($_POST['all_photos']) {
        set_pconfig(local_user(), 'retriever', 'all_photos', $_POST['all_photos']);
    } else {
        del_pconfig(local_user(), 'retriever', 'all_photos');
    }
}
コード例 #16
0
ファイル: Display.php プロジェクト: phellmes/hubzilla
 function post()
 {
     check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
     $themespec = explode(':', \App::$channel['channel_theme']);
     $existing_theme = $themespec[0];
     $existing_schema = $themespec[1];
     $theme = x($_POST, 'theme') ? notags(trim($_POST['theme'])) : $existing_theme;
     if (!$theme) {
         $theme = 'redbasic';
     }
     $mobile_theme = x($_POST, 'mobile_theme') ? notags(trim($_POST['mobile_theme'])) : '';
     $preload_images = x($_POST, 'preload_images') ? intval($_POST['preload_images']) : 0;
     $user_scalable = x($_POST, 'user_scalable') ? intval($_POST['user_scalable']) : 0;
     $nosmile = x($_POST, 'nosmile') ? intval($_POST['nosmile']) : 0;
     $title_tosource = x($_POST, 'title_tosource') ? intval($_POST['title_tosource']) : 0;
     $channel_list_mode = x($_POST, 'channel_list_mode') ? intval($_POST['channel_list_mode']) : 0;
     $network_list_mode = x($_POST, 'network_list_mode') ? intval($_POST['network_list_mode']) : 0;
     $channel_divmore_height = x($_POST, 'channel_divmore_height') ? intval($_POST['channel_divmore_height']) : 400;
     if ($channel_divmore_height < 50) {
         $channel_divmore_height = 50;
     }
     $network_divmore_height = x($_POST, 'network_divmore_height') ? intval($_POST['network_divmore_height']) : 400;
     if ($network_divmore_height < 50) {
         $network_divmore_height = 50;
     }
     $browser_update = x($_POST, 'browser_update') ? intval($_POST['browser_update']) : 0;
     $browser_update = $browser_update * 1000;
     if ($browser_update < 10000) {
         $browser_update = 10000;
     }
     $itemspage = x($_POST, 'itemspage') ? intval($_POST['itemspage']) : 20;
     if ($itemspage > 100) {
         $itemspage = 100;
     }
     if ($mobile_theme == "---") {
         del_pconfig(local_channel(), 'system', 'mobile_theme');
     } else {
         set_pconfig(local_channel(), 'system', 'mobile_theme', $mobile_theme);
     }
     set_pconfig(local_channel(), 'system', 'preload_images', $preload_images);
     set_pconfig(local_channel(), 'system', 'user_scalable', $user_scalable);
     set_pconfig(local_channel(), 'system', 'update_interval', $browser_update);
     set_pconfig(local_channel(), 'system', 'itemspage', $itemspage);
     set_pconfig(local_channel(), 'system', 'no_smilies', 1 - intval($nosmile));
     set_pconfig(local_channel(), 'system', 'title_tosource', $title_tosource);
     set_pconfig(local_channel(), 'system', 'channel_list_mode', $channel_list_mode);
     set_pconfig(local_channel(), 'system', 'network_list_mode', $network_list_mode);
     set_pconfig(local_channel(), 'system', 'channel_divmore_height', $channel_divmore_height);
     set_pconfig(local_channel(), 'system', 'network_divmore_height', $network_divmore_height);
     $newschema = '';
     if ($theme == $existing_theme) {
         // call theme_post only if theme has not been changed
         if (($themeconfigfile = $this->get_theme_config_file($theme)) != null) {
             require_once $themeconfigfile;
             if (class_exists('\\Zotlabs\\Theme\\' . ucfirst($theme) . 'Config')) {
                 $clsname = '\\Zotlabs\\Theme\\' . ucfirst($theme) . 'Config';
                 $theme_config = new $clsname();
                 $schemas = $theme_config->get_schemas();
                 if (array_key_exists($_POST['schema'], $schemas)) {
                     $newschema = $_POST['schema'];
                 }
                 if ($newschema === '---') {
                     $newschema = '';
                 }
                 $theme_config->post();
             }
         }
     }
     logger('theme: ' . $theme . ($newschema ? ':' . $newschema : ''));
     $_SESSION['theme'] = $theme . ($newschema ? ':' . $newschema : '');
     $r = q("UPDATE channel SET channel_theme = '%s' WHERE channel_id = %d", dbesc($theme . ($newschema ? ':' . $newschema : '')), intval(local_channel()));
     call_hooks('display_settings_post', $_POST);
     build_sync_packet();
     goaway(z_root() . '/settings/display');
     return;
     // NOTREACHED
 }
コード例 #17
0
function mailstream_plugin_settings_post($a, $post)
{
    if ($_POST['mailstream_address'] != "") {
        set_pconfig(local_user(), 'mailstream', 'address', $_POST['mailstream_address']);
    } else {
        del_pconfig(local_user(), 'mailstream', 'address');
    }
    if ($_POST['mailstream_nolikes']) {
        set_pconfig(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']);
    } else {
        del_pconfig(local_user(), 'mailstream', 'nolikes');
    }
    if ($_POST['mailstream_enabled']) {
        set_pconfig(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']);
    } else {
        del_pconfig(local_user(), 'mailstream', 'enabled');
    }
    if ($_POST['mailstream_attachimg']) {
        set_pconfig(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']);
    } else {
        del_pconfig(local_user(), 'mailstream', 'attachimg');
    }
}
コード例 #18
0
ファイル: facebook.php プロジェクト: robhell/friendica-addons
/**
 * @param App $a
 * @return string
 */
function facebook_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if ($a->argc > 1 && $a->argv[1] === 'remove') {
        del_pconfig(local_user(), 'facebook', 'post');
        info(t('Facebook disabled') . EOL);
    }
    if ($a->argc > 1 && $a->argv[1] === 'friends') {
        fb_get_friends(local_user(), true);
        info(t('Updating contacts') . EOL);
    }
    $fb_limited = get_config('facebook', 'restrict');
    $o = '';
    $fb_installed = false;
    if (get_pconfig(local_user(), 'facebook', 'post')) {
        $access_token = get_pconfig(local_user(), 'facebook', 'access_token');
        if ($access_token) {
            $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
            if ($s) {
                $j = json_decode($s);
                if (isset($j->data)) {
                    $fb_installed = true;
                }
            }
        }
    }
    $appid = get_config('facebook', 'appid');
    if (!$appid) {
        notice(t('Facebook API key is missing.') . EOL);
        return '';
    }
    $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/facebook/facebook.css' . '" media="all" />' . "\r\n";
    $o .= '<h3>' . t('Facebook Connect') . '</h3>';
    if (!$fb_installed) {
        $o .= '<div id="facebook-enable-wrapper">';
        $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook connector for this account.') . '</a>';
        $o .= '</div>';
    }
    if ($fb_installed) {
        $o .= '<div id="facebook-disable-wrapper">';
        $o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook connector') . '</a></div>';
        $o .= '<div id="facebook-enable-wrapper">';
        $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
        $o .= '</div>';
        $o .= '<div id="facebook-post-default-form">';
        $o .= '<form action="facebook" method="post" >';
        $post_by_default = get_pconfig(local_user(), 'facebook', 'post_by_default');
        $checked = $post_by_default ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . EOL;
        $no_linking = get_pconfig(local_user(), 'facebook', 'no_linking');
        $checked = $no_linking ? '' : ' checked="checked" ';
        if ($fb_limited) {
            if ($no_linking) {
                $o .= EOL . '<strong>' . t('Facebook friend linking has been disabled on this site. The following settings will have no effect.') . '</strong>' . EOL;
                $checked .= " disabled ";
            } else {
                $o .= EOL . '<strong>' . t('Facebook friend linking has been disabled on this site. If you disable it, you will be unable to re-enable it.') . '</strong>' . EOL;
            }
        }
        $o .= '<input type="checkbox" name="facebook_linking" value="1"' . $checked . '/>' . ' ' . t('Link all your Facebook friends and conversations on this website') . EOL;
        $o .= '<p>' . t('Facebook conversations consist of your <em>profile wall</em> and your friend <em>stream</em>.');
        $o .= ' ' . t('On this website, your Facebook friend stream is only visible to you.');
        $o .= ' ' . t('The following settings determine the privacy of your Facebook profile wall on this website.') . '</p>';
        $private_wall = get_pconfig(local_user(), 'facebook', 'private_wall');
        $checked = $private_wall ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="facebook_private_wall" value="1"' . $checked . '/>' . ' ' . t('On this website your Facebook profile wall conversations will only be visible to you') . EOL;
        $no_wall = get_pconfig(local_user(), 'facebook', 'no_wall');
        $checked = $no_wall ? ' checked="checked" ' : '';
        $o .= '<input type="checkbox" name="facebook_no_wall" value="1"' . $checked . '/>' . ' ' . t('Do not import your Facebook profile wall conversations') . EOL;
        $o .= '<p>' . t('If you choose to link conversations and leave both of these boxes unchecked, your Facebook profile wall will be merged with your profile wall on this website and your privacy settings on this website will be used to determine who may see the conversations.') . '</p>';
        $blocked_apps = get_pconfig(local_user(), 'facebook', 'blocked_apps');
        $o .= '<div><label id="blocked-apps-label" for="blocked-apps">' . t('Comma separated applications to ignore') . ' </label></div>';
        $o .= '<div><textarea id="blocked-apps" name="blocked_apps" >' . htmlspecialchars($blocked_apps) . '</textarea></div>';
        $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form></div>';
    }
    return $o;
}
コード例 #19
0
ファイル: gpluspost.php プロジェクト: sim6/friendica-addons
function gpluspost_settings_post(&$a, &$b)
{
    if (x($_POST, 'gpluspost-submit')) {
        set_pconfig(local_user(), 'gpluspost', 'post', intval($_POST['gpluspost']));
        set_pconfig(local_user(), 'gpluspost', 'post_by_default', intval($_POST['gpluspost_bydefault']));
        set_pconfig(local_user(), 'gpluspost', 'no_loop_prevention', intval($_POST['gpluspost_noloopprevention']));
        if (!gpluspost_nextscripts()) {
            set_pconfig(local_user(), 'gpluspost', 'skip_without_link', intval($_POST['gpluspost_skipwithoutlink']));
        } else {
            set_pconfig(local_user(), 'gpluspost', 'username', trim($_POST['username']));
            set_pconfig(local_user(), 'gpluspost', 'password', trim($_POST['password']));
            set_pconfig(local_user(), 'gpluspost', 'page', trim($_POST['page']));
        }
        $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fromgplus' AND `installed`");
        if (count($result) > 0) {
            set_pconfig(local_user(), 'fromgplus', 'account', trim($_POST['fromgplus-account']));
            $enable = x($_POST, 'fromgplus-enable') ? intval($_POST['fromgplus-enable']) : 0;
            set_pconfig(local_user(), 'fromgplus', 'enable', $enable);
            if (!$enable) {
                del_pconfig(local_user(), 'fromgplus', 'lastdate');
            }
        }
    }
}
コード例 #20
0
function statusnet_fetch_own_contact($a, $uid)
{
    $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
    $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
    $api = get_pconfig($uid, 'statusnet', 'baseapi');
    $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
    $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
    $own_url = get_pconfig($uid, 'statusnet', 'own_url');
    $contact_id = 0;
    if ($own_url == "") {
        require_once 'library/twitteroauth.php';
        $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
        // Fetching user data
        $user = $connection->get('account/verify_credentials');
        set_pconfig($uid, 'statusnet', 'own_url', normalise_link($user->statusnet_profile_url));
        $contact_id = statusnet_fetch_contact($uid, $user, true);
    } else {
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc($own_url));
        if (count($r)) {
            $contact_id = $r[0]["id"];
        } else {
            del_pconfig($uid, 'statusnet', 'own_url');
        }
    }
    return $contact_id;
}
コード例 #21
0
ファイル: Channel.php プロジェクト: phellmes/hubzilla
 function post()
 {
     $channel = \App::get_channel();
     check_form_security_token_redirectOnErr('/settings', 'settings');
     call_hooks('settings_post', $_POST);
     $set_perms = '';
     $role = x($_POST, 'permissions_role') ? notags(trim($_POST['permissions_role'])) : '';
     $oldrole = get_pconfig(local_channel(), 'system', 'permissions_role');
     if ($role != $oldrole || $role === 'custom') {
         if ($role === 'custom') {
             $hide_presence = x($_POST, 'hide_presence') && intval($_POST['hide_presence']) == 1 ? 1 : 0;
             $publish = x($_POST, 'profile_in_directory') && intval($_POST['profile_in_directory']) == 1 ? 1 : 0;
             $def_group = x($_POST, 'group-selection') ? notags(trim($_POST['group-selection'])) : '';
             $r = q("update channel set channel_default_group = '%s' where channel_id = %d", dbesc($def_group), intval(local_channel()));
             $global_perms = \Zotlabs\Access\Permissions::Perms();
             foreach ($global_perms as $k => $v) {
                 \Zotlabs\Access\PermissionLimits::Set(local_channel(), $k, intval($_POST[$k]));
             }
             $acl = new \Zotlabs\Access\AccessList($channel);
             $acl->set_from_array($_POST);
             $x = $acl->get();
             $r = q("update channel set channel_allow_cid = '%s', channel_allow_gid = '%s', \n\t\t\t\t\tchannel_deny_cid = '%s', channel_deny_gid = '%s' where channel_id = %d", dbesc($x['allow_cid']), dbesc($x['allow_gid']), dbesc($x['deny_cid']), dbesc($x['deny_gid']), intval(local_channel()));
         } else {
             $role_permissions = \Zotlabs\Access\PermissionRoles::role_perms($_POST['permissions_role']);
             if (!$role_permissions) {
                 notice('Permissions category could not be found.');
                 return;
             }
             $hide_presence = 1 - intval($role_permissions['online']);
             if ($role_permissions['default_collection']) {
                 $r = q("select hash from groups where uid = %d and gname = '%s' limit 1", intval(local_channel()), dbesc(t('Friends')));
                 if (!$r) {
                     require_once 'include/group.php';
                     group_add(local_channel(), t('Friends'));
                     group_add_member(local_channel(), t('Friends'), $channel['channel_hash']);
                     $r = q("select hash from groups where uid = %d and gname = '%s' limit 1", intval(local_channel()), dbesc(t('Friends')));
                 }
                 if ($r) {
                     q("update channel set channel_default_group = '%s', channel_allow_gid = '%s', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d", dbesc($r[0]['hash']), dbesc('<' . $r[0]['hash'] . '>'), intval(local_channel()));
                 } else {
                     notice(sprintf('Default privacy group \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
                     return;
                 }
             } else {
                 q("update channel set channel_default_group = '', channel_allow_gid = '', channel_allow_cid = '', channel_deny_gid = '', \n\t\t\t\t\t\tchannel_deny_cid = '' where channel_id = %d", intval(local_channel()));
             }
             $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['perms_connect']);
             foreach ($x as $k => $v) {
                 set_abconfig(local_channel(), $channel['channel_hash'], 'my_perms', $k, $v);
                 if ($role_permissions['perms_auto']) {
                     set_pconfig(local_channel(), 'autoperms', $k, $v);
                 } else {
                     del_pconfig(local_channel(), 'autoperms', $k);
                 }
             }
             if ($role_permissions['limits']) {
                 foreach ($role_permissions['limits'] as $k => $v) {
                     \Zotlabs\Access\PermissionLimits::Set(local_channel(), $k, $v);
                 }
             }
             if (array_key_exists('directory_publish', $role_permissions)) {
                 $publish = intval($role_permissions['directory_publish']);
             }
         }
         set_pconfig(local_channel(), 'system', 'hide_online_status', $hide_presence);
         set_pconfig(local_channel(), 'system', 'permissions_role', $role);
     }
     $username = x($_POST, 'username') ? notags(trim($_POST['username'])) : '';
     $timezone = x($_POST, 'timezone_select') ? notags(trim($_POST['timezone_select'])) : '';
     $defloc = x($_POST, 'defloc') ? notags(trim($_POST['defloc'])) : '';
     $openid = x($_POST, 'openid_url') ? notags(trim($_POST['openid_url'])) : '';
     $maxreq = x($_POST, 'maxreq') ? intval($_POST['maxreq']) : 0;
     $expire = x($_POST, 'expire') ? intval($_POST['expire']) : 0;
     $evdays = x($_POST, 'evdays') ? intval($_POST['evdays']) : 3;
     $photo_path = x($_POST, 'photo_path') ? escape_tags(trim($_POST['photo_path'])) : '';
     $attach_path = x($_POST, 'attach_path') ? escape_tags(trim($_POST['attach_path'])) : '';
     $channel_menu = x($_POST['channel_menu']) ? htmlspecialchars_decode(trim($_POST['channel_menu']), ENT_QUOTES) : '';
     $expire_items = x($_POST, 'expire_items') ? intval($_POST['expire_items']) : 0;
     $expire_starred = x($_POST, 'expire_starred') ? intval($_POST['expire_starred']) : 0;
     $expire_photos = x($_POST, 'expire_photos') ? intval($_POST['expire_photos']) : 0;
     $expire_network_only = x($_POST, 'expire_network_only') ? intval($_POST['expire_network_only']) : 0;
     $allow_location = x($_POST, 'allow_location') && intval($_POST['allow_location']) == 1 ? 1 : 0;
     $blocktags = x($_POST, 'blocktags') && intval($_POST['blocktags']) == 1 ? 0 : 1;
     // this setting is inverted!
     $unkmail = x($_POST, 'unkmail') && intval($_POST['unkmail']) == 1 ? 1 : 0;
     $cntunkmail = x($_POST, 'cntunkmail') ? intval($_POST['cntunkmail']) : 0;
     $suggestme = x($_POST, 'suggestme') ? intval($_POST['suggestme']) : 0;
     $post_newfriend = $_POST['post_newfriend'] == 1 ? 1 : 0;
     $post_joingroup = $_POST['post_joingroup'] == 1 ? 1 : 0;
     $post_profilechange = $_POST['post_profilechange'] == 1 ? 1 : 0;
     $adult = $_POST['adult'] == 1 ? 1 : 0;
     $cal_first_day = x($_POST, 'first_day') && intval($_POST['first_day']) == 1 ? 1 : 0;
     $pageflags = $channel['channel_pageflags'];
     $existing_adult = $pageflags & PAGE_ADULT ? 1 : 0;
     if ($adult != $existing_adult) {
         $pageflags = $pageflags ^ PAGE_ADULT;
     }
     $notify = 0;
     if (x($_POST, 'notify1')) {
         $notify += intval($_POST['notify1']);
     }
     if (x($_POST, 'notify2')) {
         $notify += intval($_POST['notify2']);
     }
     if (x($_POST, 'notify3')) {
         $notify += intval($_POST['notify3']);
     }
     if (x($_POST, 'notify4')) {
         $notify += intval($_POST['notify4']);
     }
     if (x($_POST, 'notify5')) {
         $notify += intval($_POST['notify5']);
     }
     if (x($_POST, 'notify6')) {
         $notify += intval($_POST['notify6']);
     }
     if (x($_POST, 'notify7')) {
         $notify += intval($_POST['notify7']);
     }
     if (x($_POST, 'notify8')) {
         $notify += intval($_POST['notify8']);
     }
     $vnotify = 0;
     if (x($_POST, 'vnotify1')) {
         $vnotify += intval($_POST['vnotify1']);
     }
     if (x($_POST, 'vnotify2')) {
         $vnotify += intval($_POST['vnotify2']);
     }
     if (x($_POST, 'vnotify3')) {
         $vnotify += intval($_POST['vnotify3']);
     }
     if (x($_POST, 'vnotify4')) {
         $vnotify += intval($_POST['vnotify4']);
     }
     if (x($_POST, 'vnotify5')) {
         $vnotify += intval($_POST['vnotify5']);
     }
     if (x($_POST, 'vnotify6')) {
         $vnotify += intval($_POST['vnotify6']);
     }
     if (x($_POST, 'vnotify7')) {
         $vnotify += intval($_POST['vnotify7']);
     }
     if (x($_POST, 'vnotify8')) {
         $vnotify += intval($_POST['vnotify8']);
     }
     if (x($_POST, 'vnotify9')) {
         $vnotify += intval($_POST['vnotify9']);
     }
     if (x($_POST, 'vnotify10')) {
         $vnotify += intval($_POST['vnotify10']);
     }
     if (x($_POST, 'vnotify11')) {
         $vnotify += intval($_POST['vnotify11']);
     }
     $always_show_in_notices = x($_POST, 'always_show_in_notices') ? 1 : 0;
     $err = '';
     $name_change = false;
     if ($username != $channel['channel_name']) {
         $name_change = true;
         require_once 'include/channel.php';
         $err = validate_channelname($username);
         if ($err) {
             notice($err);
             return;
         }
     }
     if ($timezone != $channel['channel_timezone']) {
         if (strlen($timezone)) {
             date_default_timezone_set($timezone);
         }
     }
     set_pconfig(local_channel(), 'system', 'use_browser_location', $allow_location);
     set_pconfig(local_channel(), 'system', 'suggestme', $suggestme);
     set_pconfig(local_channel(), 'system', 'post_newfriend', $post_newfriend);
     set_pconfig(local_channel(), 'system', 'post_joingroup', $post_joingroup);
     set_pconfig(local_channel(), 'system', 'post_profilechange', $post_profilechange);
     set_pconfig(local_channel(), 'system', 'blocktags', $blocktags);
     set_pconfig(local_channel(), 'system', 'channel_menu', $channel_menu);
     set_pconfig(local_channel(), 'system', 'vnotify', $vnotify);
     set_pconfig(local_channel(), 'system', 'always_show_in_notices', $always_show_in_notices);
     set_pconfig(local_channel(), 'system', 'evdays', $evdays);
     set_pconfig(local_channel(), 'system', 'photo_path', $photo_path);
     set_pconfig(local_channel(), 'system', 'attach_path', $attach_path);
     set_pconfig(local_channel(), 'system', 'cal_first_day', $cal_first_day);
     $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d {$set_perms} where channel_id = %d", dbesc($username), intval($pageflags), dbesc($timezone), dbesc($defloc), intval($notify), intval($unkmail), intval($maxreq), intval($expire), intval(local_channel()));
     if ($r) {
         info(t('Settings updated.') . EOL);
     }
     if (!is_null($publish)) {
         $r = q("UPDATE profile SET publish = %d WHERE is_default = 1 AND uid = %d", intval($publish), intval(local_channel()));
     }
     if ($name_change) {
         $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s'", dbesc($username), dbesc(datetime_convert()), dbesc($channel['channel_hash']));
         $r = q("update profile set fullname = '%s' where uid = %d and is_default = 1", dbesc($username), intval($channel['channel_id']));
     }
     \Zotlabs\Daemon\Master::Summon(array('Directory', local_channel()));
     build_sync_packet();
     if ($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) {
         // FIXME - set to un-verified, blocked and redirect to logout
         // Why? Are we verifying people or email addresses?
     }
     goaway(z_root() . '/settings');
     return;
     // NOTREACHED
 }
コード例 #22
0
function statusnet_settings_post($a, $post)
{
    if (!local_channel()) {
        return;
    }
    // don't check statusnet settings if statusnet submit button is not clicked
    if (!x($_POST, 'statusnet-submit')) {
        return;
    }
    if (isset($_POST['statusnet-disconnect'])) {
        /***
         * if the statusnet-disconnect checkbox is set, clear the statusnet configuration
         */
        del_pconfig(local_channel(), 'statusnet', 'consumerkey');
        del_pconfig(local_channel(), 'statusnet', 'consumersecret');
        del_pconfig(local_channel(), 'statusnet', 'post');
        del_pconfig(local_channel(), 'statusnet', 'post_by_default');
        del_pconfig(local_channel(), 'statusnet', 'oauthtoken');
        del_pconfig(local_channel(), 'statusnet', 'oauthsecret');
        del_pconfig(local_channel(), 'statusnet', 'baseapi');
        del_pconfig(local_channel(), 'statusnet', 'post_taglinks');
        del_pconfig(local_channel(), 'statusnet', 'lastid');
        del_pconfig(local_channel(), 'statusnet', 'mirror_posts');
        del_pconfig(local_channel(), 'statusnet', 'intelligent_shortening');
    } else {
        if (isset($_POST['statusnet-preconf-apiurl'])) {
            /***
             * If the user used one of the preconfigured GNU social server credentials
             * use them. All the data are available in the global config.
             * Check the API Url never the less and blame the admin if it's not working ^^
             */
            $globalsn = get_config('statusnet', 'sites');
            foreach ($globalsn as $asn) {
                if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
                    $apibase = $asn['apiurl'];
                    $x = z_fetch_url($apibase . 'statusnet/version.xml', false, 0, array('novalidate' => true));
                    $c = $x['body'];
                    if (strlen($c) > 0) {
                        set_pconfig(local_channel(), 'statusnet', 'consumerkey', $asn['consumerkey']);
                        set_pconfig(local_channel(), 'statusnet', 'consumersecret', $asn['consumersecret']);
                        set_pconfig(local_channel(), 'statusnet', 'baseapi', $asn['apiurl']);
                        set_pconfig(local_channel(), 'statusnet', 'application_name', $asn['applicationname']);
                    } else {
                        notice(t('Please contact your site administrator.<br />The provided API URL is not valid.') . EOL . $asn['apiurl'] . EOL);
                    }
                }
            }
            goaway(z_root() . '/settings/featured');
        } else {
            if (isset($_POST['statusnet-consumersecret'])) {
                //  check if we can reach the API of the GNU social server
                //  we'll check the API Version for that, if we don't get one we'll try to fix the path but will
                //  resign quickly after this one try to fix the path ;-)
                $apibase = $_POST['statusnet-baseapi'];
                $x = z_fetch_url($apibase . 'statusnet/version.xml', false, 0, array('novalidate' => true));
                $c = $x['body'];
                if (strlen($c) > 0) {
                    //  ok the API path is correct, let's save the settings
                    set_pconfig(local_channel(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
                    set_pconfig(local_channel(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
                    set_pconfig(local_channel(), 'statusnet', 'baseapi', $apibase);
                    set_pconfig(local_channel(), 'statusnet', 'application_name', $_POST['statusnet-applicationname']);
                } else {
                    //  the API path is not correct, maybe missing trailing / ?
                    $apibase = $apibase . '/';
                    $x = z_fetch_url($apibase . 'statusnet/version.xml', false, 0, array('novalidate' => true));
                    $c = $x['body'];
                    if (strlen($c) > 0) {
                        //  ok the API path is now correct, let's save the settings
                        set_pconfig(local_channel(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
                        set_pconfig(local_channel(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
                        set_pconfig(local_channel(), 'statusnet', 'baseapi', $apibase);
                    } else {
                        //  still not the correct API base, let's do noting
                        notice(t('We could not contact the GNU social API with the Path you entered.') . EOL);
                    }
                }
                goaway(z_root() . '/settings/featured');
            } else {
                if (isset($_POST['statusnet-pin'])) {
                    //  if the user supplied us with a PIN from GNU social, let the magic of OAuth happen
                    $api = get_pconfig(local_channel(), 'statusnet', 'baseapi');
                    $ckey = get_pconfig(local_channel(), 'statusnet', 'consumerkey');
                    $csecret = get_pconfig(local_channel(), 'statusnet', 'consumersecret');
                    //  the token and secret for which the PIN was generated were hidden in the settings
                    //  form as token and token2, we need a new connection to Twitter using these token
                    //  and secret to request a Access Token with the PIN
                    $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']);
                    $token = $connection->getAccessToken($_POST['statusnet-pin']);
                    //  ok, now that we have the Access Token, save them in the user config
                    set_pconfig(local_channel(), 'statusnet', 'oauthtoken', $token['oauth_token']);
                    set_pconfig(local_channel(), 'statusnet', 'oauthsecret', $token['oauth_token_secret']);
                    set_pconfig(local_channel(), 'statusnet', 'post', 1);
                    set_pconfig(local_channel(), 'statusnet', 'post_taglinks', 1);
                    //  reload the Addon Settings page, if we don't do it see Bug #42
                    goaway(z_root() . '/settings/featured');
                } else {
                    //  if no PIN is supplied in the POST variables, the user has changed the setting
                    //  to post a dent for every new __public__ posting to the wall
                    set_pconfig(local_channel(), 'statusnet', 'post', intval($_POST['statusnet-enable']));
                    set_pconfig(local_channel(), 'statusnet', 'post_by_default', intval($_POST['statusnet-default']));
                    set_pconfig(local_channel(), 'statusnet', 'post_taglinks', intval($_POST['statusnet-sendtaglinks']));
                    set_pconfig(local_channel(), 'statusnet', 'mirror_posts', intval($_POST['statusnet-mirror']));
                    set_pconfig(local_channel(), 'statusnet', 'intelligent_shortening', intval($_POST['statusnet-shortening']));
                    info(t('GNU social settings updated.') . EOL);
                }
            }
        }
    }
}