コード例 #1
0
        header($str);
    }
    echo substr($response, 0, 100);
    exit;
}
function mobile_settings(&$vars)
{
    render('action', 'mobile');
}
function _mobile(&$vars)
{
    extract($vars);
    $foo = "";
    return vars(array(&$foo), get_defined_vars());
}
after_filter('broadcast_sms_notice', 'insert_from_post');
function broadcast_sms_notice(&$model, &$rec)
{
    $smskey = environment('zeepAccessKey');
    if (empty($smskey)) {
        return;
    }
    if (!isset($rec->title)) {
        return;
    }
    global $request, $db;
    $i = owner_of($rec);
    $notice_content = substr($rec->title, 0, 100);
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
コード例 #2
0
ファイル: twitter.php プロジェクト: Br3nda/openmicroblogger
<?php

// attach a "hook" to the insert_from_post Model method
after_filter('send_to_twitter', 'insert_from_post');
// the "hook" function itself
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 {
コード例 #3
0
<?php

// send an e-mail when content changes
after_filter('send_email_notice', 'insert_from_post');
after_filter('send_email_notice', 'update_from_post');
after_filter('send_email_notice', 'delete_from_post');
function send_email_notice(&$model, &$rec)
{
    global $db;
    global $request;
    if (!(get_profile_id() && $request->resource == 'groups')) {
        return;
    }
    // get data modesl for 3 tables
    $Entry =& $db->get_table('entries');
    $Group =& $db->get_table('groups');
    $Person =& $db->get_table('people');
    // load the first 20 records from the groups table
    $Group->find();
    // keep a list of people we have notified
    $sent_to = array();
    // get the name of the table from the data model reference we received
    $notify_table = $model->table;
    // get the primary key value of the record reference we received
    $notify_id = $rec->id;
    // if the table that was modified is a metadata table (comments, reviews)
    // notify about the "target" table being modified
    if (array_key_exists('target_id', $model->field_array)) {
        $e = $Entry->find($rec->attributes['target_id']);
        if ($e) {
            $notify_table = $e->resource;
コード例 #4
0
<?php

before_filter(array('only_user' => 20), 'only', 'create, destroy, delete, flag, revert_tags, activate, update_batch');
before_filter(array('post_only_user' => 20), 'only', 'update, upload, flag');
before_filter(array('only_user' => 33), 'only', 'moderate, undelete');
before_filter(array('only_user' => 50), 'only', 'import, export');
verify_method('post', array('only', 'update, destroy, create, revert_tags, vote, flag'));
after_filter('save_tags_to_cookie', 'only', 'update, create');
helper('avatar', 'tag', 'comment', 'pool', 'favorite');
set_actions('activate', 'browse', 'create', 'delete', 'destroy', 'error', 'flag', 'index', 'import', 'moderate', 'random', 'show', 'undelete', 'update', 'update_batch', 'upload', 'vote');
コード例 #5
0
ファイル: boot.php プロジェクト: Br3nda/openmicroblogger
before_filter('load_model', 'update_from_request');
before_filter('load_model', 'fields_from_request');
before_filter('load_model', 'MoveFirst');
before_filter('load_model', 'MoveNext');
before_filter('load_model', 'base');
before_filter('load_model', 'find');
// add a filter to persist submitted data on error
before_filter('session_error', 'handle_error');
// activate Taint Mode to validate each input
before_filter('regex_validate', 'save_record');
// read the Access List and verify action permissions
before_filter('model_security', $request->action);
// if public resource, ping the search index server
after_filter('send_ping', 'insert_from_post');
after_filter('send_ping', 'update_from_post');
// echo value after single-field Ajax PUT call
after_filter('ajax_put_field', 'update_from_post');
after_filter('ajax_put_field', 'insert_from_post');
// authenticate yourself without OpenID
//test_log_in();
function test_log_in()
{
    $person_id = 1;
    set_cookie($person_id);
    $_SESSION['openid_complete'] = true;
}
/**
 * negotiate the best content-type for the client
 */
$response = new View();
render('action', $request->action);
コード例 #6
0
ファイル: identica.php プロジェクト: Br3nda/openmicroblogger
<?php

// attach a "hook" to the insert_from_post Model method
after_filter('send_to_identica', 'insert_from_post');
// the "hook" function itself
function send_to_identica(&$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('identica_status') != 'enabled') {
        return;
    }
    // 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();
    // get the Twitter Tools object
    global $aktt;
    // make a new tweet object
    $tweet = new aktt_tweet();
    // set the tweetbody
    $tweet->tw_text = stripslashes($notice_content);
    // send the dent to Identica
    global $db;
コード例 #7
0
ファイル: shortener.php プロジェクト: Br3nda/openmicroblogger
        add_option('ozh_yourls', array('service' => 'other', 'location' => '', 'yourls_path' => '', 'yourls_url' => '', 'yourls_login' => '', 'yourls_password' => '', 'rply_login' => '', 'rply_password' => '', 'other' => 'rply'));
        global $wp_ozh_yourls;
        if (!$wp_ozh_yourls) {
            wp_ozh_yourls_admin_init();
        }
        $service = wp_ozh_yourls_service();
    }
    $shorturl = wp_ozh_yourls_api_call(wp_ozh_yourls_service(), $_POST['ajax_shorten']);
    if ($shorturl) {
        echo $shorturl;
    } else {
        echo 'error';
    }
    exit;
}
after_filter('set_up_new_shortener', 'insert_from_post');
function set_up_new_shortener(&$model, &$rec)
{
    global $request;
    if (!($request->resource == 'blogs')) {
        return;
    }
    // XXX subdomain upgrade
    $url = $request->url_for(array('resource' => 'twitter/' . $rec->nickname));
    require_once ABSPATH . WPINC . '/class-snoopy.php';
    $snoop = new Snoopy();
    $snoop->agent = 'OpenMicroBlogger http://openmicroblogger.org';
    $snoop->submit($url);
    if (strpos($snoop->response_code, '200')) {
        $passer = get_code(5);
        if (signed_in()) {
コード例 #8
0
ファイル: cron.php プロジェクト: Br3nda/openmicroblogger
            $env[$set[2]] = $s->value;
        } elseif ($set[1] == 'perms') {
            $tab =& $db->models[$set[2]];
            if ($tab) {
                $tab->permission_mask($set[3], $s->value, $set[4]);
            }
        }
    }
}
if (isset($env)) {
    while (list($key, $plugin) = each($env['plugins'])) {
        load_plugin($plugin);
    }
}
// end dbscript booter
after_filter('send_ping', 'insert_tweets_via_cron');
$follow = array();
foreach ($env as $key => $val) {
    if (substr($key, 0, 13) == 'importtwitter' && $val == 1) {
        $optname = 'conf_for_' . $key;
        $options = get_option($optname);
        if (!$options) {
            $options = array();
            $options['busy'] = 0;
            $options['last_id'] = 0;
            $options['latest_id'] = 0;
            add_option($optname, $options);
        }
        if (!$options['busy']) {
            $options['busy'] = 1;
            //update_option($optname,$options);
コード例 #9
0
ファイル: notifix.php プロジェクト: Br3nda/openmicroblogger
<?php

after_filter('broadcast_notifixious_notice', 'insert_from_post');
function broadcast_notifixious_notice(&$model, &$rec)
{
    $notifixkey = '';
    $login = '******';
    $pass = '';
    $notifixurl = 'notifixio.us';
    if (!isset($rec->title)) {
        return;
    }
    if (!get_profile_id()) {
        return;
    }
    $installed = environment('installed');
    if (!in_array('notifixious', $installed)) {
        return;
    }
    if (!class_exists('Services_JSON')) {
        lib_include('json');
    }
    $url = "http://" . $notifixurl . "/sources/find.json";
    $params = "url=" . urlencode(get_bloginfo('rss2_url'));
    $results = notifixious_http_request($url . "?" . $params, "GET");
    $jsonobj = json_decode($results[1]);
    $source_id = $jsonobj->sources->source->permalink;
    if ($source_id != "") {
        update_option('notifixiousSourceId', '' . $source_id . '', '', 'no');
        update_option('notifixiousRegistered', '1', '', 'no');
        update_option('notifixiousClaimed', '0', '', 'yes');
コード例 #10
0
ファイル: omb.php プロジェクト: Br3nda/openmicroblogger
    if (!is_writable('cache')) {
        exit;
    }
    $result = $db->get_result("DELETE FROM " . $db->prefix . "uploads WHERE name = '" . $db->escape_string(urldecode($_FILES['Filedata']['name'])) . "'");
    $tmp = 'cache' . DIRECTORY_SEPARATOR . make_token();
    $tmp .= "." . extension_for(type_of($_FILES['Filedata']['name']));
    $Upload =& $db->model('Upload');
    $u = $Upload->base();
    $u->set_value('name', urldecode($_FILES['Filedata']['name']));
    $u->set_value('tmp_name', $tmp);
    $u->save_changes();
    move_uploaded_file($_FILES['Filedata']['tmp_name'], $tmp);
    echo "200 OK";
    exit;
}
after_filter('set_identity_from_nick', 'routematch');
function set_identity_from_nick(&$request, &$route)
{
    global $db;
    if (!isset($request->params['nickname'])) {
        return;
    }
    $nick = $db->escape_string(urldecode($request->params['nickname']));
    $nick = split('\\.', $nick);
    if (is_array($nick)) {
        if (isset($nick[1])) {
            $request->set('client_wants', $nick[1]);
        }
        $nick = trim($nick[0]);
    } else {
        $nick = trim($nick);