コード例 #1
0
function validate_identities_url($value)
{
    if ($value == 'http://') {
        return true;
    }
    if (environment('authentication') == 'password') {
        return true;
    }
    if (!(environment('openid_version') > 1)) {
        return true;
    }
    global $db;
    wp_plugin_include(array('wp-openid'));
    $logic = new WordPressOpenID_Logic(null);
    $logic->activate_plugin();
    if (!WordPressOpenID_Logic::late_bind()) {
        trigger_error('Sorry, there was an error in the OpenID plugin.', E_USER_ERROR);
    }
    $consumer = WordPressOpenID_Logic::getConsumer();
    $auth_request = $consumer->begin($value);
    if (null === $auth_request) {
        trigger_error('Sorry, an OpenID server could not be located from: ' . htmlentities($value), E_USER_ERROR);
    }
    return true;
}
コード例 #2
0
ファイル: identica.php プロジェクト: Br3nda/openmicroblogger
function identica_init()
{
    include 'wp-content/language/lang_chooser.php';
    //Loads the language-file
    // load Alex King's Twitter Tools WordPress plugin
    wp_plugin_include('twitter-tools');
    // set a flag on aktt
    global $aktt;
    $aktt->tweet_from_sidebar = false;
    // set the resource, action, button label, app name, grouplevel-unimplemented
    app_register_init('dents', 'edit.html', $txt['identica_identica'], 'identica', 2);
}
コード例 #3
0
ファイル: twitter.php プロジェクト: Br3nda/openmicroblogger
function send_to_twitter(&$model, &$rec)
{
    if (!get_profile_id()) {
        return;
    }
    // if the Record does not have a title or uri, bail out
    if (!isset($rec->title) || !isset($rec->uri)) {
        return;
    }
    if (get_option('twitter_status') != 'enabled') {
        return;
    }
    global $db, $prefix;
    $sql = "SELECT oauth_key,oauth_secret FROM " . $prefix . "twitter_users WHERE profile_id = " . get_profile_id();
    $result = $db->get_result($sql);
    if ($db->num_rows($result) == 1) {
        // http://abrah.am
        lib_include('twitteroauth');
        $key = $db->result_value($result, 0, 'oauth_key');
        $secret = $db->result_value($result, 0, 'oauth_secret');
        $consumer_key = environment('twitterKey');
        $consumer_secret = environment('twitterSecret');
        $to = new TwitterOAuth($consumer_key, $consumer_secret, $key, $secret);
        $notice_content = substr($rec->title, 0, 140);
        $content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $notice_content), 'POST');
    } else {
        wp_plugin_include('twitter-tools');
        // set a flag on aktt
        global $aktt;
        $aktt->tweet_from_sidebar = false;
        // truncate the tweet at 140 chars
        $notice_content = substr($rec->title, 0, 140);
        // activate Twitter Tools
        $_GET['activate'] = true;
        // trip the init() function
        aktt_init();
        // make a new tweet object
        $tweet = new aktt_tweet();
        // set the tweetbody
        $tweet->tw_text = stripslashes($notice_content);
        // send the tweet to Twitter
        $aktt->do_tweet($tweet);
    }
}
コード例 #4
0
function broadcast_omb_notice(&$model, &$rec)
{
    if (!isset($rec->title) || !isset($rec->uri)) {
        return;
    }
    global $request, $db;
    if (empty($rec->uri)) {
        $rec->set_value('uri', $request->url_for(array('resource' => '__' . $rec->id)));
        $rec->save_changes();
    }
    wp_plugin_include(array('wp-oauth'));
    $i = owner_of($rec);
    $listenee_uri = $i->profile;
    $notice_uri = $rec->uri;
    $notice_content = substr($rec->title, 0, 140);
    $notice_url = $notice_uri;
    $license = $i->license;
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
    $where = array('subscriptions.subscribed' => $i->id);
    $Subscription->set_param('find_by', $where);
    $Subscription->find();
    while ($sub = $Subscription->MoveNext()) {
        $sub_token = trim($sub->token);
        $sub_secret = trim($sub->secret);
        $sid = $sub->FirstChild('identities');
        $url = $sid->post_notice;
        if (!in_array($url, $sent_to) && !empty($url) && !strstr($url, $request->base)) {
            $sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
            $wp_plugins = "wp-plugins" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "enabled";
            $path = plugin_path() . $wp_plugins . DIRECTORY_SEPARATOR . 'wp-openid' . DIRECTORY_SEPARATOR;
            add_include_path($path);
            require_once "Auth/Yadis/Yadis.php";
            $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
            //for ($i=0;$i<5;$i++) {
            $consumer = new OAuthConsumer($request->base, '');
            $token = new OAuthToken($sub_token, $sub_secret);
            $parsed = parse_url($url);
            $params = array();
            parse_str($parsed['query'], $params);
            $req = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url, $params);
            $req->set_parameter('omb_version', OMB_VERSION);
            $req->set_parameter('omb_listenee', $listenee_uri);
            $req->set_parameter('omb_notice', $notice_uri);
            $req->set_parameter('omb_notice_content', $notice_content);
            $req->set_parameter('omb_notice_url', $notice_url);
            $req->set_parameter('omb_notice_license', $license);
            $req->sign_request($sha1_method, $consumer, $token);
            $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata());
            if ($result->status == 403) {
                $db->delete_record($sub);
            } else {
                parse_str($result->body, $return);
                if (is_array($return) && $return['omb_version'] == OMB_VERSION) {
                    $sent_to[] = $url;
                } else {
                    admin_alert('failed to post' . "\n\n" . $url . "\n\n" . $result->body . "\n\n" . $notice_content);
                }
            }
            //}
            // this is the old CURL version of omb_notice
            //$curl = curl_init($url);
            //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
            //curl_setopt($curl, CURLOPT_HEADER, false);
            //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            //curl_setopt($curl, CURLOPT_POST, true);
            //curl_setopt($curl, CURLOPT_POSTFIELDS, $req->to_postdata());
            //curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            //$result = curl_exec($curl);
            //curl_close($curl);
        }
    }
}
コード例 #5
0
ファイル: security.php プロジェクト: Br3nda/openmicroblogger
function openid_continue(&$vars)
{
    extract($vars);
    $valid = false;
    if (class_exists('MySQL') && environment('openid_version') > 1 && !isset($_SESSION['openid_degrade'])) {
        global $openid;
        wp_plugin_include(array('wp-openid'));
        $logic = new WordPressOpenID_Logic(null);
        $logic->activate_plugin();
        $consumer = WordPressOpenID_Logic::getConsumer();
        $openid->response = $consumer->complete($_SESSION['oid_return_to']);
        switch ($openid->response->status) {
            case Auth_OpenID_CANCEL:
                trigger_error('The OpenID assertion was cancelled.', E_USER_ERROR);
                break;
            case Auth_OpenID_FAILURE:
                // if we fail OpenID v2 here, we retry once with OpenID v1
                $_SESSION['openid_degrade'] = true;
                $request->set_param('return_url', $request->url_for('openid_continue') . '/');
                $request->set_param('protected_url', $request->base);
                $request->set_param('openid_url', $_SESSION['openid_url']);
                authenticate_with_openid();
                break;
            case Auth_OpenID_SUCCESS:
                $_SESSION['openid_complete'] = true;
                $valid = true;
                break;
        }
    }
    if (!$valid) {
        include $GLOBALS['PATH']['library'] . 'openid.php';
        $openid = new SimpleOpenID();
        $openid->SetIdentity($_SESSION['openid_url']);
        $openid->SetApprovedURL($request->url_for('openid_continue') . '/');
        $openid->SetTrustRoot($request->base);
        $server_url = $_SESSION['openid_server_url'];
        $openid->SetOpenIDServer($server_url);
        $valid = $openid->ValidateWithServer();
    }
    if ($valid) {
        $_SESSION['openid_complete'] = true;
    } else {
        trigger_error("Sorry, the openid server {$server_url} did not validate your identity.", E_USER_ERROR);
    }
    complete_openid_authentication($request);
    if (!empty($_SESSION['requested_url'])) {
        redirect_to($_SESSION['requested_url']);
    } else {
        redirect_to($request->base);
    }
}
コード例 #6
0
ファイル: shortener.php プロジェクト: Br3nda/openmicroblogger
function shortener_init()
{
    include 'wp-content/language/lang_chooser.php';
    //Loads the language-file
    wp_plugin_include('yourls-wordpress-to-twitter');
    global $wp_ozh_yourls;
    $filedir = "wp-content" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . 'yourls-wordpress-to-twitter';
    require_once $filedir . '/inc/core.php';
    require_once $filedir . '/inc/options.php';
    if (!defined('WP_CONTENT_URL')) {
        define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
    }
    if (!defined('WP_PLUGIN_DIR')) {
        define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
    }
    if (!defined('WP_PLUGIN_URL')) {
        define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' . '/yourls-wordpress-to-twitter');
    }
    if (!defined('PLUGINDIR')) {
        define('PLUGINDIR', 'wp-content/plugins' . '/yourls-wordpress-to-twitter');
    }
    app_register_init('shorteners', 'index.html', 'URL Shortener', 'shortener', 2);
}
コード例 #7
0
ファイル: omb.php プロジェクト: Br3nda/openmicroblogger
function broadcast_omb_profile_update()
{
    global $request, $db;
    wp_plugin_include(array('wp-oauth'));
    $i = get_profile();
    $listenee_uri = $i->profile;
    $license = $i->license;
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
    $where = array('subscriptions.subscribed' => $i->id);
    $Subscription->set_param('find_by', $where);
    $Subscription->find();
    while ($sub = $Subscription->MoveNext()) {
        $sub_token = trim($sub->token);
        $sub_secret = trim($sub->secret);
        $sid = $sub->FirstChild('identities');
        $url = $sid->update_profile;
        if (!in_array($url, $sent_to) && !empty($url) && !strstr($url, $request->base)) {
            $sent_to[] = $url;
            $sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
            $wp_plugins = "wp-plugins" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "enabled";
            $path = plugin_path() . $wp_plugins . DIRECTORY_SEPARATOR . 'wp-openid' . DIRECTORY_SEPARATOR;
            add_include_path($path);
            require_once "Auth/Yadis/Yadis.php";
            $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
            $consumer = new OAuthConsumer($request->base, '');
            $token = new OAuthToken($sub_token, $sub_secret);
            $parsed = parse_url($url);
            $params = array();
            parse_str($parsed['query'], $params);
            $req = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url, $params);
            $req->set_parameter('omb_version', OMB_VERSION);
            $req->set_parameter('omb_listenee', $listenee_uri);
            $listenee_params = array('omb_listenee_profile' => $i->profile, 'omb_listenee_nickname' => $i->nickname, 'omb_listenee_license' => $i->license, 'omb_listenee_fullname' => $i->fullname, 'omb_listenee_homepage' => $i->homepage, 'omb_listenee_bio' => $i->bio, 'omb_listenee_location' => $i->locality, 'omb_listenee_avatar' => $i->avatar);
            foreach ($listenee_params as $k => $v) {
                $req->set_parameter($k, $v);
            }
            $req->sign_request($sha1_method, $consumer, $token);
            $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata());
            if ($result->status == 403) {
                // not so much
            } else {
                parse_str($result->body, $return);
                if (is_array($return) && $return['omb_version'] == OMB_VERSION) {
                    // nice
                } else {
                    // could be better
                }
            }
        }
    }
}