Skip to content

Commit

Permalink
rssCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hendrickson committed Oct 22, 2009
1 parent c1bce87 commit 1c6721c
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/omb/controllers/admin.php
Expand Up @@ -315,6 +315,7 @@ function _sources( &$vars ) {
$returnvars = array();

$TwitterUser =& $db->model('TwitterUser');
$TwitterUser->set_limit(1000);
$TwitterUser->find_by( array('eq'=>'not like','oauth_key'=>''),1 );
$i=1;
while ($tu = $TwitterUser->MoveNext()) {
Expand Down
7 changes: 5 additions & 2 deletions app/omb/plugins/security.php
Expand Up @@ -909,10 +909,13 @@ function _oauth( &$vars ) {
);
}

function make_identity( $user ) {
function make_identity( $user, $newperson=false ) {
global $db,$prefix,$request;
$Person =& $db->model('Person');
if (get_person_id()) {
if ($newperson) {
$p = $Person->base();
$p->save();
} elseif (get_person_id()) {
// make a new identity for the Person
$p = $Person->find(get_person_id());
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/rsscloud/plugins/rsscloud.php
@@ -1,5 +1,5 @@
<?php
return;

function set_up_cloud_ping(){
$pid = get_profile_id();
global $optiondata,$request,$blogdata;
Expand Down
23 changes: 20 additions & 3 deletions app/rsscloud/rsscloud.php
Expand Up @@ -18,7 +18,8 @@ function load_my_cloud_element() {

function rsscloud_init(){

lib_include( 'rsscloud/rsscloud' );
if ( '' == get_option( 'cloud_domain' ) )
set_default_omb_cloud_options();

add_action('rss2_head','load_my_cloud_element');

Expand All @@ -31,9 +32,25 @@ function rsscloud_init(){
update_cloud_options();

elseif ( '' == get_option( 'cloud_domain' ) )
set_default_cloud_options();
set_default_omb_cloud_options();

app_register_init( 'admin', 'cloud.html', 'rssCloud Options', 'rsscloud', 2 );
app_register_init( 'feeds', 'index.html', 'Feeds', 'rsscloud', 2 );

}

function set_default_omb_cloud_options(){
global $request;
$cloud_path = '/api/rsscloud/pleaseNotify';
$cloud_ping = '/api/rsscloud/ping';
if (strlen($request->path)>1) {
$cloud_path = '/'.$request->path.$cloud_path;
$cloud_ping = '/'.$request->path.$cloud_ping;
}
add_option('cloud_domain',$request->domain,'Cloud Domain');
add_option('cloud_port','80','Cloud Port');
add_option('cloud_path',$cloud_path,'Cloud Path');
add_option('cloud_function','','Cloud Function');
add_option('cloud_protocol','http-post','Cloud Protocol');
add_option('cloud_ping',$cloud_ping,'Cloud Ping Path');
}

54 changes: 54 additions & 0 deletions db/library/dbscript/_functions.php
Expand Up @@ -3156,3 +3156,57 @@ function handle_posted_file($filename="",$att,$profile) {
return true;

}

function ent2ncr($text) {
return $text;
}

function esc_html($text) {
return $text;
}

function wp_remote_post( $url, $paramarr ){

$method = $paramarr['method'];
$timeout = $paramarr['timeout'];
$agent = $paramarr['user-agent'];
$port = $paramarr['port'];

foreach($paramarr['body'] as $url) {
// test the callback
}

// 'method' => 'POST',
// 'timeout' => RSSCLOUD_HTTP_TIMEOUT,
// 'user-agent' => RSSCLOUD_USER_AGENT,
// 'port' => $port,
// 'body' => array(
// 'url' => $_POST['url1']

$result = array();
$result['response'] = array('code'=>200);
return $result;

}


function readUrl($url){
$timeout = 10;
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
$content = curl_exec( $ch );
$response = curl_getinfo( $ch );
curl_close ( $ch );
if($response['http_code'] == 200)
{
return $content;
}
return false;
}
14 changes: 7 additions & 7 deletions db/library/dbscript/collection.php
Expand Up @@ -118,6 +118,7 @@ function Collection( $resource, $find_by = NULL, $accept = "text/html" ) {

if ($table->rowcount() > 0) {
$first = true;
$this->updated = timestamp();
while ( $Member = $table->MoveNext() ) {
if ( isset( $db->models['entries'] )) {
$Entry = $Member->FirstChild( 'entries' );
Expand All @@ -127,14 +128,13 @@ function Collection( $resource, $find_by = NULL, $accept = "text/html" ) {
}
}
$this->members[$Member->$uri_key] = $Entry->last_modified;
$this->updated = timestamp();
if (isset($Member->modified) && !empty($Member->modified))
$this->updated = $Member->modified;
if ($first) {
if ( isset( $db->models['entries'] )) {
if (!empty($Entry->last_modified))
$this->updated = $Entry->last_modified;
}
if (isset($Member->created) && !empty($Member->created))
$this->updated = $Member->created;
elseif (isset($Member->modified) && !empty($Member->modified))
$this->updated = $Member->modified;
elseif (!empty($Entry->last_modified))
$this->updated = $Entry->last_modified;
}
$first = false;
}
Expand Down
50 changes: 50 additions & 0 deletions db/library/remy-tweed/cron.php
Expand Up @@ -195,6 +195,53 @@
}
}

$Feed =& $db->model('Feed');
$Feed->set_limit(1000);
$Feed->find();

if ( '' == get_option( 'cloud_domain' ) )
set_default_omb_cloud_options();

while ($f = $Feed->MoveNext()) {
$dow = date("w",time());
if ($dow != $f->day_of_sub && !empty($f->cloud_domain)){
$f->set_value('day_of_sub',$dow);
$f->save_changes();
$subscribe_url = "http://" . $f->cloud_domain . ":" . $f->cloud_port . "" . $f->cloud_path . "";
$params = array(
'notifyProcedure'=>get_option('cloud_function'),
'port'=>get_option('cloud_port'),
'path'=>get_option('cloud_path'),
'protocol'=>get_option('cloud_protocol'),
'url1'=>$f->xref,
'domain'=>get_option('cloud_domain')
);
$ch = curl_init();
if (defined("CURL_CA_BUNDLE_PATH")) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
curl_setopt($ch, CURLOPT_URL, $subscribe_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if (isset($params)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
if ($f->cloud_port == 80){
$response = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
admin_alert("rssCloud renew: " . $f->title);
}else{
admin_alert("rssCloud skip renew: " . $f->title.implode(" ",$params));
}
}
}

exit;


foreach ($follow as $tuid=>$options) {

// http://abrah.am
Expand Down Expand Up @@ -320,3 +367,6 @@ function add_tweet_user($data) {






4 changes: 2 additions & 2 deletions db/library/rsscloud_element.php
Expand Up @@ -56,7 +56,7 @@ function add_cloud_element(){
$cloud_function = get_option('cloud_function');
$cloud_protocol = get_option('cloud_protocol');

echo "<cloud domain=\"" . $cloud_domain . "\" port=\"" . $current_port . "\" path=\"" . $cloud_path . "\" registerProcedure=\"" . $cloud_function . "\" protocol=\"" . $cloud_protocol . "\" />";
echo "<cloud domain=\"" . $cloud_domain . "\" port=\"" . $cloud_port . "\" path=\"" . $cloud_path . "\" registerProcedure=\"" . $cloud_function . "\" protocol=\"" . $cloud_protocol . "\" />";
}

function set_default_cloud_options(){
Expand Down Expand Up @@ -190,7 +190,7 @@ function rss_cloud_ping(){
$ping_path = get_option('cloud_ping');
if (empty($ping_path)) $ping_path="/rsscloud/ping";

$ping_url="http://" . $current_domain . ":" . $current_port . "/" . $ping_path . "";
$ping_url="http://" . $current_domain . ":" . $current_port . "" . $ping_path . "";
/*
If in doubt about your settings, uncomment the next line:
*/
Expand Down

0 comments on commit 1c6721c

Please sign in to comment.