diff --git a/app/config/config.yml b/app/config/config.yml
index 88f77a0..23f4a38 100755
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -81,6 +81,7 @@ env:
- translate
- facebook
- pages
+ - flickr
installed:
- password
@@ -90,6 +91,7 @@ env:
- translate
- facebook
- pages
+ - flickr
boot: omb
@@ -129,6 +131,9 @@ env:
twitterKey:
twitterSecret:
+ flickrKey:
+ flickrSecret:
+
facebookKey:
facebookSecret:
facebookAppId:
diff --git a/app/facebook/facebook.php b/app/facebook/facebook.php
index a5b4a35..45aab7f 100644
--- a/app/facebook/facebook.php
+++ b/app/facebook/facebook.php
@@ -9,3 +9,13 @@
// Services_Facebook::$secret = '';
+
+function facebook_init() {
+ include 'wp-content/language/lang_chooser.php'; //Loads the language-file
+ // set the resource, action, button label, app name, grouplevel-unimplemented
+ app_register_init( 'facebook_users', 'edit.html', $txt['facebook_facebook'], 'facebook', 2 );
+
+ //before_filter('download_tweets','get');
+}
+
+
diff --git a/app/omb/controllers/admin.php b/app/omb/controllers/admin.php
index 9c9011e..ea26148 100755
--- a/app/omb/controllers/admin.php
+++ b/app/omb/controllers/admin.php
@@ -365,4 +365,17 @@ function _sources( &$vars ) {
}
+function _cloud( &$vars ) {
+
+ extract( $vars );
+
+ admin_display_cloud_options();
+
+ return vars(
+ array(
+ ),
+ get_defined_vars()
+ );
+
+}
diff --git a/app/omb/controllers/settings.php b/app/omb/controllers/settings.php
index 26fedac..ee6498d 100755
--- a/app/omb/controllers/settings.php
+++ b/app/omb/controllers/settings.php
@@ -13,6 +13,12 @@ function put( &$vars ) {
$request->set_param(array('setting','value'),
md5_encrypt($request->params['setting']['value'], $db->dbname)
);
+ $event = $s->name."_enabled";
+ if (('enabled' == $request->params['setting']['value'])&&function_exists($event))
+ $event();
+ $event = $s->name."_disabled";
+ if (('disabled' == $request->params['setting']['value'])&&function_exists($event))
+ $event();
$resource->update_from_post( $request );
header_status( '201 Created' );
redirect_to( $request->resource );
@@ -73,6 +79,12 @@ function post( &$vars ) {
trigger_error( 'Sorry, you are not authorized to install '.$app, E_USER_ERROR );
}
+ $event = $settingname."_enabled";
+ if (('enabled' == $request->params['setting']['value'])&&function_exists($event))
+ $event();
+ $event = $settingname."_disabled";
+ if (('disabled' == $request->params['setting']['value'])&&function_exists($event))
+ $event();
$resource->insert_from_post( $request );
header_status( '201 Created' );
redirect_to( $request->resource );
diff --git a/app/omb/models/Method.php b/app/omb/models/Method.php
index 74fa5ef..bd188ea 100644
--- a/app/omb/models/Method.php
+++ b/app/omb/models/Method.php
@@ -121,8 +121,61 @@ function init() {
$m->save_changes();
$m->set_etag(1);
+
+ $m = $this->base();
+ $m->set_value( 'code', '
+
+global $db,$request;
+
+$Identity =& $db->get_table( \'identities\' );
+$Person =& $db->get_table( \'people\' );
+$i = $Identity->find_by(array(
+ \'nickname\'=>$db->escape_string($_POST[\'username\']),
+ \'password\'=>md5($db->escape_string($_POST[\'password\']))
+),1);
+$p = $Person->find( $i->person_id );
+if (!(isset( $p->id ) && $p->id > 0))
+ exit;
+
+header(\'Content-Type: text/xml\');
+echo \'
+\';
+if (isset($_FILES[\'media\'])) {
+ handle_posted_file(\'jpg\',$_FILES[\'media\'][\'tmp_name\'],$i);
+ $mediaid = \'_\'.$request->id;
+ $mediaurl = $request->url_for(array(
+\'resource\'=>\'__\'.$request->id.".jpg"));
+ echo \'
- '.$txt['sidebar_rss1'].' '.$request->params['nickname'].$txt['sidebar_rss2'].' + '.$txt['sidebar_rss1'].' '.$request->params['nickname'].$txt['sidebar_rss2'].'
'; } diff --git a/db/boot.php b/db/boot.php index 3ff28f4..bc08969 100755 --- a/db/boot.php +++ b/db/boot.php @@ -417,7 +417,7 @@ $request->base = substr($uri,0,strpos($uri,$tags[0][0][0])+(strlen($repl)+1)).$trail; } $stream = $tags[0][2][0]; -} elseif (isset($params['username']) && isset($params['password'])) { +} elseif (isset($params['username']) && isset($params['password']) && !isset($_FILES['media'])) { $sql = "SELECT nickname,profile_id FROM shorteners WHERE nickname LIKE '".$db->escape_string($params['username'])."'"; $sql .= " AND password LIKE '".$db->escape_string($params['password'])."'"; $result = $db->get_result( $sql ); @@ -525,11 +525,22 @@ while ($m = $Method->MoveNext()) { $api_method_perms[$m->function] = array('table'=>$m->resource,'perm'=>$m->permission); $api_methods[$m->function] = $m->code; + $patterns = explode( '/', $m->route ); + $requirements = array(); + foreach ( $patterns as $pos => $str ) { + if ( substr( $str, 0, 1 ) == ':' ) { + $requirements[] = '[A-Za-z0-9_.]+'; + } + } + $routesetup = array( + 'action'=>$m->function, + 'resource'=>$m->resource + ); + if (count($requirements) > 0) + $routesetup['requirements'] = $requirements; $request->connect( $m->route, - array( - 'action'=>$m->function - ) + $routesetup ); if ($m->omb) before_filter( 'authenticate_with_omb', $m->function ); @@ -549,9 +560,9 @@ load_plugin( $plugin ); - /** - * connect more Routes to the Mapper - */ +/** + * connect more Routes to the Mapper + */ $request->connect( ':resource/:id/email/:ident', diff --git a/db/library/dbscript/_functions.php b/db/library/dbscript/_functions.php index 8eb6d99..54d5fc3 100755 --- a/db/library/dbscript/_functions.php +++ b/db/library/dbscript/_functions.php @@ -1056,11 +1056,8 @@ function render_partial( $template ) { $response->render_partial( $request, $template ); } + function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { - global $wp_filter, $merged_filters; - $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); - $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); - unset( $merged_filters[ $tag ] ); return true; } @@ -2606,16 +2603,26 @@ function get_app_id() { global $db; global $request; - - if (!($request->resource == 'identities')) + + $id = false; + + if (!($request->resource == 'identities')) { + if ($request->params['byid'] > 0) - return $request->params['byid']; + $id = $request->params['byid']; elseif ($request->params['forid'] > 0) - return $request->params['forid']; + $id = $request->params['forid']; elseif (get_profile_id()) - return get_profile_id(); - else - return false; + $id = get_profile_id(); + + if ($id && !(strpos($id,".") === false )) { + $parts = split('\.',$id); + $id = $parts[0]; + } + + return $id; + + } // looking some profile page // load its apps @@ -3068,3 +3075,84 @@ function mb_unserialize($serial_str) { $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str ); return unserialize($out); } + + + +function handle_posted_file($filename="",$att,$profile) { + + global $db,$request,$response; + + $response->set_var('profile',$profile); + + load_apps(); + + $_FILES = array( + 'post' => array( + 'name' => array( 'attachment' => $filename ), + 'tmp_name' => array( 'attachment' => $att ) + )); + + $Post =& $db->model( 'Post' ); + $table = 'posts'; + $field = 'attachment'; + $modelvar = 'Post'; + + $request->set_param('resource',$table); + + $request->set_param( array( strtolower(classify($table)), $field ), + $att ); + + trigger_before( 'insert_from_post', $$modelvar, $request ); + + $content_type = 'text/html'; + $rec = $$modelvar->base(); + $content_type = type_of( $filename ); + $rec->set_value('profile_id',get_profile_id()); + $rec->set_value( 'parent_id', 0 ); + $rec->set_value( 'title', '' ); + $upload_types = environment('upload_types'); + if (!$upload_types) + $upload_types = array('jpg','jpeg','png','gif'); + $ext = extension_for( type_of($filename)); + if (!(in_array($ext,$upload_types))) + trigger_error('Sorry, this site only allows the following file types: '.implode(',',$upload_types), E_USER_ERROR); + $rec->set_value( $field, $att ); + $rec->save_changes(); + $tmp = $att; + if (is_jpg($tmp)) { + $thumbsize = environment('max_pixels'); + $Thumbnail =& $db->model('Thumbnail'); + $t = $Thumbnail->base(); + $newthumb = tempnam( "/tmp", "new".$rec->id.".jpg" ); + resize_jpeg($tmp,$newthumb,$thumbsize); + $t->set_value('target_id',$atomentry->id); + $t->save_changes(); + update_uploadsfile( 'thumbnails', $t->id, $newthumb ); + $t->set_etag(); + } + + $atomentry = $$modelvar->set_metadata($rec,$content_type,$table,'id'); + + $$modelvar->set_categories($rec,$request,$atomentry); + + $url = $request->url_for(array( + 'resource'=>$table, + 'id'=>$rec->id + )); + + $title = substr($rec->title,0,140); + + $over = ((strlen($title) + strlen($url) + 1) - 140); + + if ($over > 0) + $rec->set_value('title',substr($title,0,-$over)." ".$url); + else + $rec->set_value('title',$title." ".$url); + + $rec->save_changes(); + + trigger_after( 'insert_from_post', $$modelvar, $rec ); + + return true; + +} diff --git a/db/library/facebook_stream/FacebookStream.php b/db/library/facebook_stream/FacebookStream.php index cc659e2..5606efa 100755 --- a/db/library/facebook_stream/FacebookStream.php +++ b/db/library/facebook_stream/FacebookStream.php @@ -162,10 +162,37 @@ function VerifyUpdate($userid) { } } + + function VerifyPerm($userid,$perm) { + + $params = array( + 'ext_perm' => $perm, + 'uid' => $userid + ); + + // optional URL-encoded GET parameters + // next + // next_cancel + + $response = $this->api->users->callMethod('users.hasAppPermission', $params); + + if (!strpos($response->asXML(),"1getApiKey(); + $url .= '&v=1.0'; + $url .= '&ext_perm='; + $url .= $perm; + header('Location:'.$url); + exit; + } + + } function setStatus($status,$userid) { $this->VerifyUpdate($userid); + $this->VerifyPerm($userid,'photo_upload'); $params = array( 'uid' => $userid, @@ -186,6 +213,35 @@ function setStatus($status,$userid) { return (intval((string)$res) == 1); } + + function PhotoUpload( $file, $aid=0, $caption='',$userid ) { + + $this->VerifyUpdate($userid); + + $this->VerifyPerm($userid,'photo_upload'); + + $params = array( + 'method' => 'photos.upload', + 'v' => '1.0', + 'api_key' => $this->getApiKey(), + 'call_id' => microtime(true), + 'format' => 'XML', + 'uid' => $userid + ); + + if ($aid > 0) + $params['aid'] = $aid; + + if (strlen($caption)) + $params['caption'] = $caption; + + $params = $this->signRequest($params); + $params[basename($file)] = '@' . realpath($file); + $url = $this->api->photos->getAPI() . '?method=photos.upload'; + + return $this->http($url,$params); + + } /** * Make an HTTP request @@ -196,8 +252,9 @@ function http($url, $post_data = null) {/*{{{*/ $ch = curl_init(); if (defined("CURL_CA_BUNDLE_PATH")) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ////////////////////////////////////////////////// ///// Set to 1 to verify SSL Cert ////// @@ -215,4 +272,16 @@ function http($url, $post_data = null) {/*{{{*/ return $response; } + function signRequest($params) { + if (isset($params['sig'])) + unset($params['sig']); + ksort($params); + $sig = ''; + foreach ($params as $k => $v) + $sig .= $k .'=' . $v; + $sig .= $this->getApiSecret(); + $params['sig'] = md5($sig); + return $params; + } + } \ No newline at end of file diff --git a/wp-content/language/eng.php b/wp-content/language/eng.php index a94c5b3..55d622d 100644 --- a/wp-content/language/eng.php +++ b/wp-content/language/eng.php @@ -195,6 +195,11 @@ ////////////////////// $txt['twitter_twitter'] = "Connect to Twitter"; +////////////////////// +# /app/facebook/facebook.php +////////////////////// +$txt['facebook_facebook'] = "Connect to Facebook"; + ///////////////////////////////////// # /app/omb/controllers/identities.php @@ -484,6 +489,32 @@ $txt['twitter_settings_status'] = "Status"; +///////////////////////////////////// +# /app/flickr/views/flickr_users/_edit.html +///////////////////////////////////// +$txt['flickr_settings_ok'] = "OK"; +$txt['flickr_settings_cancel'] = "Cancel"; +$txt['flickr_settings_click_edit'] = "Click to edit..."; +$txt['flickr_settings_it_works'] = "Yes, it works!"; +$txt['flickr_settings_fail'] = "Fail! Can not connect to flickr"; +$txt['flickr_settings_post_to_flickr'] = "Post my photos to flickr"; +$txt['flickr_settings_test_settings'] = "Test your Settings"; +$txt['flickr_settings_status'] = "Status"; + + +///////////////////////////////////// +# /app/facebook/views/facebook_users/_edit.html +///////////////////////////////////// +$txt['facebook_settings_ok'] = "OK"; +$txt['facebook_settings_cancel'] = "Cancel"; +$txt['facebook_settings_click_edit'] = "Click to edit..."; +$txt['facebook_settings_it_works'] = "Yes, it works!"; +$txt['facebook_settings_fail'] = "Fail! Can not connect to Facebook"; +$txt['facebook_settings_post_to_facebook'] = "Post my notices to Facebook"; +$txt['facebook_settings_test_settings'] = "Test your Settings"; +$txt['facebook_settings_status'] = "Status"; + + ///////////////////////////////////// # /app/identica/views/dents/_edit.html ///////////////////////////////////// diff --git a/wp-content/language/ger.php b/wp-content/language/ger.php index c7b577d..f51d853 100644 --- a/wp-content/language/ger.php +++ b/wp-content/language/ger.php @@ -193,8 +193,13 @@ ////////////////////// # /app/twitter/twitter.php ////////////////////// + $txt['twitter_twitter'] = "Verbindung zu Twitter"; +////////////////////// +# /app/facebook/facebook.php +////////////////////// +$txt['facebook_facebook'] = "Verbindung zu Facebook"; ///////////////////////////////////// # /app/omb/controllers/identities.php @@ -482,6 +487,32 @@ $txt['twitter_settings_status'] = "Status"; +///////////////////////////////////// +# /app/flickr/views/flickr_users/_edit.html +///////////////////////////////////// +$txt['flickr_settings_ok'] = "OK"; +$txt['flickr_settings_cancel'] = "Cancel"; +$txt['flickr_settings_click_edit'] = "Click to edit..."; +$txt['flickr_settings_it_works'] = "Yes, it works!"; +$txt['flickr_settings_fail'] = "Fail! Can not connect to flickr"; +$txt['flickr_settings_post_to_flickr'] = "Post my photos to flickr"; +$txt['flickr_settings_test_settings'] = "Test your Settings"; +$txt['flickr_settings_status'] = "Status"; + + +///////////////////////////////////// +# /app/facebook/views/facebook_users/_edit.html +///////////////////////////////////// +$txt['facebook_settings_ok'] = "OK"; +$txt['facebook_settings_cancel'] = "Cancel"; +$txt['facebook_settings_click_edit'] = "Click to edit..."; +$txt['facebook_settings_it_works'] = "Yes, it works!"; +$txt['facebook_settings_fail'] = "Fail! Can not connect to facebook"; +$txt['facebook_settings_post_to_facebook'] = "Post my notices to facebook"; +$txt['facebook_settings_test_settings'] = "Test your Settings"; +$txt['facebook_settings_status'] = "Status"; + + ///////////////////////////////////// # /app/identica/views/dents/_edit.html /////////////////////////////////////