diff --git a/altpager/altpager.css b/altpager/altpager.css new file mode 100755 index 00000000..26fb5b6d --- /dev/null +++ b/altpager/altpager.css @@ -0,0 +1,14 @@ + + + +#altpager-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#altpager { + float: left; +} + + diff --git a/altpager/altpager.php b/altpager/altpager.php new file mode 100755 index 00000000..65f9c0d8 --- /dev/null +++ b/altpager/altpager.php @@ -0,0 +1,89 @@ + + * + * + */ + + +function altpager_install() { + + register_hook('plugin_settings', 'addon/altpager/altpager.php', 'altpager_settings'); + register_hook('plugin_settings_post', 'addon/altpager/altpager.php', 'altpager_settings_post'); + + logger("installed altpager"); +} + + +function altpager_uninstall() { + + unregister_hook('plugin_settings', 'addon/altpager/altpager.php', 'altpager_settings'); + unregister_hook('plugin_settings_post', 'addon/altpager/altpager.php', 'altpager_settings_post'); + + + logger("removed altpager"); +} + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function altpager_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'altpager-submit'))) + return; + + set_pconfig(local_user(),'system','alt_pager',intval($_POST['altpager'])); + info( t('Altpager settings updated.') . EOL); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function altpager_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $altpager = get_pconfig(local_user(),'system','alt_pager'); + if($altpager === false) + $altpager = 0; + + $checked = (($altpager) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Alternate Pagination Setting') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} diff --git a/blogger.tgz b/blogger.tgz index f30042f9..d4de24f7 100644 Binary files a/blogger.tgz and b/blogger.tgz differ diff --git a/blogger/blogger.php b/blogger/blogger.php index 5c9b4399..aa1b9add 100755 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -4,121 +4,121 @@ * Name: Blogger Post Connector * Description: Post to Blogger (or anything else which uses blogger XMLRPC API) * Version: 1.0 - * Author: Mike Macgirvin + * */ -function blpost_install() { - register_hook('post_local', 'addon/blpost/blpost.php', 'blpost_post_local'); - register_hook('notifier_normal', 'addon/blpost/blpost.php', 'blpost_send'); - register_hook('jot_networks', 'addon/blpost/blpost.php', 'blpost_jot_nets'); - register_hook('connector_settings', 'addon/blpost/blpost.php', 'blpost_settings'); - register_hook('connector_settings_post', 'addon/blpost/blpost.php', 'blpost_settings_post'); +function blogger_install() { + register_hook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local'); + register_hook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send'); + register_hook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets'); + register_hook('connector_settings', 'addon/blogger/blogger.php', 'blogger_settings'); + register_hook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post'); } -function blpost_uninstall() { - unregister_hook('post_local', 'addon/blpost/blpost.php', 'blpost_post_local'); - unregister_hook('notifier_normal', 'addon/blpost/blpost.php', 'blpost_send'); - unregister_hook('jot_networks', 'addon/blpost/blpost.php', 'blpost_jot_nets'); - unregister_hook('connector_settings', 'addon/blpost/blpost.php', 'blpost_settings'); - unregister_hook('connector_settings_post', 'addon/blpost/blpost.php', 'blpost_settings_post'); +function blogger_uninstall() { + unregister_hook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local'); + unregister_hook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send'); + unregister_hook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets'); + unregister_hook('connector_settings', 'addon/blogger/blogger.php', 'blogger_settings'); + unregister_hook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post'); // obsolete - remove - unregister_hook('post_local_end', 'addon/blpost/blpost.php', 'blpost_send'); - unregister_hook('plugin_settings', 'addon/blpost/blpost.php', 'blpost_settings'); - unregister_hook('plugin_settings_post', 'addon/blpost/blpost.php', 'blpost_settings_post'); + unregister_hook('post_local_end', 'addon/blogger/blogger.php', 'blogger_send'); + unregister_hook('plugin_settings', 'addon/blogger/blogger.php', 'blogger_settings'); + unregister_hook('plugin_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post'); } -function blpost_jot_nets(&$a,&$b) { +function blogger_jot_nets(&$a,&$b) { if(! local_user()) return; - $bl_post = get_pconfig(local_user(),'blpost','post'); + $bl_post = get_pconfig(local_user(),'blogger','post'); if(intval($bl_post) == 1) { - $bl_defpost = get_pconfig(local_user(),'blpost','post_by_default'); + $bl_defpost = get_pconfig(local_user(),'blogger','post_by_default'); $selected = ((intval($bl_defpost) == 1) ? ' checked="checked" ' : ''); - $b .= '
' + $b .= '
' . t('Post to blogger') . '
'; } } -function blpost_settings(&$a,&$s) { +function blogger_settings(&$a,&$s) { if(! local_user()) return; /* Add our stylesheet to the page so we can make our settings look nice */ - $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variables */ - $enabled = get_pconfig(local_user(),'blpost','post'); + $enabled = get_pconfig(local_user(),'blogger','post'); $checked = (($enabled) ? ' checked="checked" ' : ''); - $def_enabled = get_pconfig(local_user(),'blpost','post_by_default'); + $def_enabled = get_pconfig(local_user(),'blogger','post_by_default'); $def_checked = (($def_enabled) ? ' checked="checked" ' : ''); - $bl_username = get_pconfig(local_user(), 'blpost', 'bl_username'); - $bl_password = get_pconfig(local_user(), 'blpost', 'bl_password'); - $bl_blog = get_pconfig(local_user(), 'blpost', 'bl_blog'); + $bl_username = get_pconfig(local_user(), 'blogger', 'bl_username'); + $bl_password = get_pconfig(local_user(), 'blogger', 'bl_password'); + $bl_blog = get_pconfig(local_user(), 'blogger', 'bl_blog'); /* Add some HTML to the existing form */ $s .= '
'; $s .= '

' . t('Blogger Post Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; $s .= '
'; - $s .= '
'; - $s .= ''; - $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; $s .= '
'; - $s .= '
'; - $s .= ''; - $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; $s .= '
'; - $s .= '
'; - $s .= ''; - $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; $s .= '
'; - $s .= '
'; - $s .= ''; - $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; $s .= '
'; /* provide a submit button */ - $s .= '
'; + $s .= '
'; } -function blpost_settings_post(&$a,&$b) { +function blogger_settings_post(&$a,&$b) { - if(x($_POST,'blpost-submit')) { + if(x($_POST,'blogger-submit')) { - set_pconfig(local_user(),'blpost','post',intval($_POST['blpost'])); - set_pconfig(local_user(),'blpost','post_by_default',intval($_POST['bl_bydefault'])); - set_pconfig(local_user(),'blpost','bl_username',trim($_POST['bl_username'])); - set_pconfig(local_user(),'blpost','bl_password',trim($_POST['bl_password'])); - set_pconfig(local_user(),'blpost','bl_blog',trim($_POST['bl_blog'])); + set_pconfig(local_user(),'blogger','post',intval($_POST['blogger'])); + set_pconfig(local_user(),'blogger','post_by_default',intval($_POST['bl_bydefault'])); + set_pconfig(local_user(),'blogger','bl_username',trim($_POST['bl_username'])); + set_pconfig(local_user(),'blogger','bl_password',trim($_POST['bl_password'])); + set_pconfig(local_user(),'blogger','bl_blog',trim($_POST['bl_blog'])); } } -function blpost_post_local(&$a,&$b) { +function blogger_post_local(&$a,&$b) { // This can probably be changed to allow editing by pointing to a different API endpoint @@ -131,11 +131,11 @@ function blpost_post_local(&$a,&$b) { if($b['private'] || $b['parent']) return; - $bl_post = intval(get_pconfig(local_user(),'blpost','post')); + $bl_post = intval(get_pconfig(local_user(),'blogger','post')); - $bl_enable = (($bl_post && x($_REQUEST,'blpost_enable')) ? intval($_REQUEST['blpost_enable']) : 0); + $bl_enable = (($bl_post && x($_REQUEST,'blogger_enable')) ? intval($_REQUEST['blogger_enable']) : 0); - if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'blpost','post_by_default'))) + if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'blogger','post_by_default'))) $bl_enable = 1; if(! $bl_enable) @@ -143,27 +143,27 @@ function blpost_post_local(&$a,&$b) { if(strlen($b['postopts'])) $b['postopts'] .= ','; - $b['postopts'] .= 'blpost'; + $b['postopts'] .= 'blogger'; } -function blpost_send(&$a,&$b) { +function blogger_send(&$a,&$b) { if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) return; - if(! strstr($b['postopts'],'blpost')) + if(! strstr($b['postopts'],'blogger')) return; if($b['parent'] != $b['id']) return; - $bl_username = xmlify(get_pconfig($b['uid'],'blpost','bl_username')); - $bl_password = xmlify(get_pconfig($b['uid'],'blpost','bl_password')); - $bl_blog = get_pconfig($b['uid'],'blpost','bl_blog'); + $bl_username = xmlify(get_pconfig($b['uid'],'blogger','bl_username')); + $bl_password = xmlify(get_pconfig($b['uid'],'blogger','bl_password')); + $bl_blog = get_pconfig($b['uid'],'blogger','bl_blog'); if($bl_username && $bl_password && $bl_blog) { @@ -189,7 +189,7 @@ function blpost_send(&$a,&$b) { EOT; - logger('blpost: data: ' . $xml, LOGGER_DATA); + logger('blogger: data: ' . $xml, LOGGER_DATA); if($bl_blog !== 'test') $x = post_url($bl_blog,$xml); diff --git a/communityhome.tgz b/communityhome.tgz index dbb235bb..129081b6 100755 Binary files a/communityhome.tgz and b/communityhome.tgz differ diff --git a/communityhome/communityhome.php b/communityhome/communityhome.php index 14c40328..2b14fd33 100755 --- a/communityhome/communityhome.php +++ b/communityhome/communityhome.php @@ -55,7 +55,7 @@ function communityhome_home(&$a, &$o){ $entry = replace_macros($tpl,array( '$id' => $rr['id'], '$profile-link' => $profile_link, - '$photo' => $rr[$photo], + '$photo' => $a->get_cached_avatar_image($rr[$photo]), '$alt-text' => $rr['name'], )); $aside['$lastusers_items'][] = $entry; diff --git a/dav/virtual_cal_source_friendica.inc.php b/dav/virtual_cal_source_friendica.inc.php index 5123e4ed..7434fbbc 100644 --- a/dav/virtual_cal_source_friendica.inc.php +++ b/dav/virtual_cal_source_friendica.inc.php @@ -52,8 +52,11 @@ class FriendicaVirtualCalSourceBackend extends VirtualCalSourceBackend } */ - $subject = substr(preg_replace("/\[[^\]]*\]/", "", $row["desc"]), 0, 100); - $description = preg_replace("/\[[^\]]*\]/", "", $row["desc"]); + // 2012-06-29 - change to Friendica new event behaviour where summary is present and required, + // but use desc for older events where summary wasn't present or required (but desc was) + + $subject = (($row["summary"]) ? $row["summary"] : substr(preg_replace("/\[[^\]]*\]/", "", $row["desc"]), 0, 100)); + $description = (($row["desc"]) ? preg_replace("/\[[^\]]*\]/", "", $row["desc"]) : $row["summary"]); $vevent = dav_create_vevent(wdcal_mySql2icalTime($row["start"]), wdcal_mySql2icalTime($row["finish"]), false); $vevent->setLocation(icalendar_sanitize_string($row["location"])); diff --git a/facebook.tgz b/facebook.tgz index b8335178..6ec94f3a 100644 Binary files a/facebook.tgz and b/facebook.tgz differ diff --git a/facebook/facebook.php b/facebook/facebook.php index a59036dd..127456af 100644 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -3,7 +3,8 @@ * Name: Facebook Connector * Version: 1.3 * Author: Mike Macgirvin - * Tobias Hößl + * Author: Tobias Hößl + * */ /** @@ -79,38 +80,38 @@ function facebook_init(&$a) { if (x($_REQUEST, "realtime_cb") && x($_REQUEST, "realtime_cb")) { logger("facebook_init: Facebook Real-Time callback called", LOGGER_DEBUG); - + if (x($_REQUEST, "hub_verify_token")) { // this is the verification callback while registering for real time updates - + $verify_token = get_config('facebook', 'cb_verify_token'); if ($verify_token != $_REQUEST["hub_verify_token"]) { logger('facebook_init: Wrong Facebook Callback Verifier - expected ' . $verify_token . ', got ' . $_REQUEST["hub_verify_token"]); return; } - + if (x($_REQUEST, "hub_challenge")) { logger('facebook_init: Answering Challenge: ' . $_REQUEST["hub_challenge"], LOGGER_DATA); echo $_REQUEST["hub_challenge"]; die(); } } - + require_once('include/items.php'); - + // this is a status update $content = file_get_contents("php://input"); if (is_numeric($content)) $content = file_get_contents("php://input"); $js = json_decode($content); logger(print_r($js, true), LOGGER_DATA); - + if (!isset($js->object) || $js->object != "user" || !isset($js->entry)) { logger('facebook_init: Could not parse Real-Time Update data', LOGGER_DEBUG); return; } - + $affected_users = array("feed" => array(), "friends" => array()); - + foreach ($js->entry as $entry) { $fbuser = $entry->uid; foreach ($entry->changed_fields as $field) { @@ -119,20 +120,20 @@ function facebook_init(&$a) { continue; } if (in_array($fbuser, $affected_users[$field])) continue; - + $r = q("SELECT `uid` FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'self_id' AND `v` = '%s' LIMIT 1", dbesc($fbuser)); if(! count($r)) continue; $uid = $r[0]['uid']; - + $access_token = get_pconfig($uid,'facebook','access_token'); if(! $access_token) return; - + switch ($field) { case "feed": logger('facebook_init: FB-User ' . $fbuser . ' / feed', LOGGER_DEBUG); - + if(! get_pconfig($uid,'facebook','no_wall')) { $private_wall = intval(get_pconfig($uid,'facebook','private_wall')); $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token); @@ -146,11 +147,11 @@ function facebook_init(&$a) { } } } - + break; case "friends": logger('facebook_init: FB-User ' . $fbuser . ' / friends', LOGGER_DEBUG); - + fb_get_friends($uid, false); set_pconfig($uid,'facebook','friend_check',time()); break; @@ -162,10 +163,11 @@ function facebook_init(&$a) { } } - if($a->argc != 2) return; + $nick = $a->argv[1]; + if(strlen($nick)) $r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($nick) @@ -188,7 +190,7 @@ function facebook_init(&$a) { $x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id=' . $appid . '&client_secret=' . $appsecret . '&redirect_uri=' - . urlencode($a->get_baseurl() . '/facebook/' . $nick) + . urlencode($a->get_baseurl() . '/facebook/' . $nick) . '&code=' . $auth_code); logger('facebook_init: returned access token: ' . $x, LOGGER_DATA); @@ -316,7 +318,7 @@ function fb_get_friends_sync_parsecontact($uid, $contact) { dbesc($contact->id), dbesc('facebook ' . $contact->id), dbesc($contact->name), - dbesc(($contact->nickname) ? $contact->nickname : strtolower($contact->first_name)), + dbesc(($contact->nickname) ? $contact->nickname : mb_convert_case($contact->first_name, MB_CASE_LOWER, "UTF-8")), dbesc('https://graph.facebook.com/' . $contact->id . '/picture'), dbesc(NETWORK_FACEBOOK), intval(CONTACT_IS_FRIEND), @@ -408,6 +410,7 @@ function fb_get_friends($uid, $fullsync = true) { $access_token = get_pconfig($uid,'facebook','access_token'); $no_linking = get_pconfig($uid,'facebook','no_linking'); + if($no_linking) return; @@ -432,7 +435,7 @@ function fb_get_friends($uid, $fullsync = true) { } // This is the POST method to the facebook settings page -// Content is posted to Facebook in the function facebook_post_hook() +// Content is posted to Facebook in the function facebook_post_hook() /** * @param App $a @@ -443,7 +446,7 @@ function facebook_post(&$a) { if($uid){ - $fb_limited = get_config('facebook','restrict'); + $fb_limited = get_config('facebook','crestrict'); $value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0); @@ -456,7 +459,7 @@ function facebook_post(&$a) { $private_wall = ((x($_POST,'facebook_private_wall')) ? intval($_POST['facebook_private_wall']) : 0); set_pconfig($uid,'facebook','private_wall',$private_wall); - + set_pconfig($uid,'facebook','blocked_apps',escape_tags(trim($_POST['blocked_apps']))); @@ -466,7 +469,7 @@ function facebook_post(&$a) { if($linkvalue == 0) set_pconfig($uid,'facebook','no_linking', 1); } - else + else set_pconfig($uid,'facebook','no_linking', (($linkvalue) ? 0 : 1)); // FB linkage was allowed but has just been turned off - remove all FB contacts and posts @@ -508,6 +511,13 @@ function facebook_content(&$a) { 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 disabled') . EOL); @@ -750,7 +760,7 @@ function facebook_plugin_admin(&$a, &$o){ elseif (is_array($subs)) { $o .= t('The given API Key seems to work correctly.') . '
'; $working_connection = true; - } else $o .= t('The correctness of the API Key could not be detected. Somthing strange\'s going on.') . '
'; + } else $o .= t('The correctness of the API Key could not be detected. Something strange\'s going on.') . '
'; } $o .= '
'; @@ -940,7 +950,7 @@ function facebook_post_hook(&$a,&$b) { if($fb_token && ($toplevel || $b['private'] || $reply)) { logger('facebook: able to post'); require_once('library/facebook.php'); - require_once('include/bbcode.php'); + require_once('include/bbcode.php'); $msg = $b['body']; @@ -1015,7 +1025,7 @@ function facebook_post_hook(&$a,&$b) { } // At first convert the text to html - $html = bbcode($body); + $html = bbcode($body, false, false); // Then convert it to plain text $msg = trim($b['title']." \n\n".html2plain($html, 0, true)); @@ -1132,8 +1142,8 @@ function facebook_post_hook(&$a,&$b) { } else { // if its only a message and a subject and the message is larger than 500 characters then post it as note $postvars = array( - 'access_token' => $fb_token, - 'message' => bbcode($b['body']), + 'access_token' => $fb_token, + 'message' => bbcode($b['body'], false, false), 'subject' => $b['title'], ); $url = 'https://graph.facebook.com/me/notes'; diff --git a/fromgplus/README b/fromgplus/README new file mode 100644 index 00000000..cecbb2b9 --- /dev/null +++ b/fromgplus/README @@ -0,0 +1 @@ +This extension is a preparation of the upcoming import of items via Google+ diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php new file mode 100644 index 00000000..88d2622f --- /dev/null +++ b/fromgplus/fromgplus.php @@ -0,0 +1,183 @@ + + * + */ + +function fromgplus_install() { + register_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); + register_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post'); +} + +function fromgplus_uninstall() { + unregister_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); + unregister_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post'); +} + +function fromgplus_addon_settings(&$a,&$s) { + + if(! local_user()) + return; + + $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : ''); + $account = get_pconfig(local_user(),'fromgplus','account'); + + $s .= '
'; + $s .= '

' . t('Google+ Import Settings').'

'; + $s .= '
'; + + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= '
'; + + return; +} + +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); + info( t('Google+ Import Settings saved.') . EOL); + } +} +/* +function html2bbcode($html) { + + $bbcode = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); + + $bbcode = str_replace(array("\n"), array(""), $bbcode); + $bbcode = str_replace(array("", ""), array("[b]", "[/b]"), $bbcode); + $bbcode = str_replace(array("", ""), array("[i]", "[/i]"), $bbcode); + $bbcode = str_replace(array("", ""), array("[s]", "[/s]"), $bbcode); + $bbcode = str_replace(array("
"), array("\n"), $bbcode); + + $bbcode = trim(strip_tags($bbcode)); + return($bbcode); +} + +function friendicapost($post) { + global $friendica; + + $api = new Statusnet($friendica["user"], $friendica["pw"], "GooglePlus", $friendica["server"]); + $ret = $api->updateStatus($post); + $api->endSession(); +} + +function handleattachments($item) { + $post = ""; + + foreach ($item->object->attachments as $attachment) { + switch($attachment->objectType) { + case "video": + //$post .= "\n\n[url=".$attachment->url."]". + // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n"; + $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n"; + + //if (strpos($attachment->embed->url, "youtube.com")) + // $post .= "[youtube]".$attachment->url."[/youtube]\n"; + //else + /// $post .= "[url=".$attachment->url."][img]".$attachment->image->url."[/img][/url]\n"; + + ///$post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]"; + break; + + case "article": + //$post .= "\n\n[url=".$attachment->url."]". + // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n"; + $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n"; + $post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]"; + break; + + case "photo": + //$post .= "\n\n[url=".$attachment->fullImage->url."]". + // "[img]".$attachment->fullImage->url."[/img][/url]\n"; + $post .= "\n\n[img]".$attachment->fullImage->url."[/img]\n"; + if ($attachment->displayName != "") + $post .= html2bbcode($attachment->displayName)."\n"; + break; + + case "photo-album": + $post .= "\n\n[url=".$attachment->url."]". + "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n"; + break; + + default: + print_r($attachment); + die(); + break; + } + } + return($post); +} + +$result = +file_get_contents("https://www.googleapis.com/plus/v1/people/".$google["id"]."/activities/public?alt=json&pp=1&key=".$google["key"]."&maxResults=".$google["maxfetch"]); +$activities = json_decode($result); + +$state = array("lastid"=>''); +if (file_exists($statefile)) + $state = unserialize(file_get_contents($statefile)); + +$lastid = ""; + +foreach($activities->items as $item) { + if ($item->id == $state["lastid"]) + break; + + if ($lastid == "") + $lastid = $item->id; + + switch($item->object->objectType) { + case "note": + $post = html2bbcode($item->object->content); + + if (is_array($item->object->attachments)) + $post .= handleattachments($item); + friendicapost($post); + break; + + case "activity": + $post = html2bbcode($item->annotation)."\n"; + //$post .= html2bbcode("♲ "); + $post .= html2bbcode("♻ "); + $post .= "[url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url]"; + $post .= " \n"; + //$post .= "[quote]"; + + $post .= html2bbcode($item->object->content); + + if (is_array($item->object->attachments)) + $post .= "\n".trim(handleattachments($item)); + + //$post .= "[/quote]"; + + friendicapost($post); + break; + + default: + print_r($item); + die(); + break; + } +} + +if ($lastid != "") { + $state['lastid'] = $lastid; + file_put_contents($statefile, serialize($state)); +} +*/ diff --git a/gravatar.tgz b/gravatar.tgz index 38e942f8..25106f26 100644 Binary files a/gravatar.tgz and b/gravatar.tgz differ diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index b9435a31..fc5358eb 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -2,7 +2,7 @@ /** * Name: Gravatar Support * Description: If there is no avatar image for a new user or contact this plugin will look for one at Gravatar. - * Version: 1.0 + * Version: 1.1 * Author: Klaus Weidenbach */ @@ -12,7 +12,7 @@ function gravatar_install() { register_hook('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - logger("installed gravatar"); + logger("registered gravatar in avatar_lookup hook"); } /** @@ -21,7 +21,7 @@ function gravatar_install() { function gravatar_uninstall() { unregister_hook('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - logger("uninstalled gravatar"); + logger("unregistered gravatar in avatar_lookup hook"); } /** @@ -81,7 +81,16 @@ function gravatar_plugin_admin (&$a, &$o) { 'x' => 'x' ); - $o = ''; + // Check if Libravatar is enabled and show warning + $r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1", + dbesc('libravatar') + ); + if (count($r)) { + $o = '
' .t('Information') .'

' .t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.
The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'



'; + } + + // output Gravatar settings + $o .= ''; $o .= replace_macros( $t, array( '$submit' => t('Submit'), '$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found at Gravatar. See README'), $default_avatars), diff --git a/infiniteimprobabilitydrive.tgz b/infiniteimprobabilitydrive.tgz index 6d10fb69..8d9a2203 100644 Binary files a/infiniteimprobabilitydrive.tgz and b/infiniteimprobabilitydrive.tgz differ diff --git a/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css b/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css index f4be6051..7fb4019c 100644 --- a/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css +++ b/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css @@ -1,4 +1,3 @@ -section { - padding-left: 0px; - -} \ No newline at end of file +section {padding-left: 0px;} + +iframe {border: none;} \ No newline at end of file diff --git a/jappixmini.tgz b/jappixmini.tgz index c7fc99a4..212bb25e 100644 Binary files a/jappixmini.tgz and b/jappixmini.tgz differ diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index d4b1993f..5d6f8446 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -435,7 +435,7 @@ function jappixmini_script(&$a,&$s) { $key = $row['k']; $pos = strpos($key, ":"); $dfrn_id = substr($key, $pos+1); - $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND `dfrn-id`='%s' OR `issued-id`='%s'", + $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')", dbesc($dfrn_id), dbesc($dfrn_id) ); @@ -488,6 +488,9 @@ function jappixmini_cron(&$a, $d) { $users = q("SELECT `uid` FROM `pconfig` WHERE `cat`='jappixmini' AND (`k`='autosubscribe' OR `k`='autoapprove') AND `v`='1'"); logger("jappixmini: Update list of contacts' jabber accounts for ".count($users)." users."); + if(! count($users)) + return; + foreach ($users as $row) { $uid = $row["uid"]; diff --git a/libertree.tgz b/libertree.tgz index a817c140..f467bc00 100644 Binary files a/libertree.tgz and b/libertree.tgz differ diff --git a/libertree/libertree.php b/libertree/libertree.php index 4f0c814d..0e7e1a81 100755 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -118,7 +118,7 @@ function libertree_post_local(&$a,&$b) { if($b['private'] || $b['parent']) return; - $ltree_post = intval(get_pconfig(local_user(),'libertree','post')); + $ltree_post = intval(get_pconfig(local_user(),'libertree','post')); $ltree_enable = (($ltree_post && x($_REQUEST,'libertree_enable')) ? intval($_REQUEST['libertree_enable']) : 0); @@ -153,8 +153,8 @@ function libertree_send(&$a,&$b) { $ltree_api_token = get_pconfig($b['uid'],'libertree','libertree_api_token'); $ltree_url = get_pconfig($b['uid'],'libertree','libertree_url'); $ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token"; - - if($ltree_url && $ltree_api_token && $ltree_blog) { + $ltree_source = "Friendica"; + if($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) { require_once('include/bb2diaspora.php'); $tag_arr = array(); @@ -167,16 +167,42 @@ function libertree_send(&$a,&$b) { } } if(count($tag_arr)) - $tags = implode(',',$tag_arr); + $tags = implode(',',$tag_arr); + $title = $b['title']; + $body = $b['body']; + // Insert a newline before and after a quote + $body = str_ireplace("[quote", "\n\n[quote", $body); + $body = str_ireplace("[/quote]", "[/quote]\n\n", $body); + + // Removal of tags and mentions + // #-tags + $body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body); + // @-mentions + $body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body); + + // remove multiple newlines + do { + $oldbody = $body; + $body = str_replace("\n\n\n", "\n\n", $body); + } while ($oldbody != $body); + + // convert to markdown + $body = bb2diaspora($body); + + // Adding the title + if(strlen($title)) + $body = "## ".html_entity_decode($title)."\n\n".$body; + $params = array( - 'text' => bb2diaspora($b['body']) + 'text' => $body, + 'source' => $ltree_source // 'token' => $ltree_api_token ); $result = post_url($ltree_blog,$params); - logger('libertree: ' . $result); + logger('libertree: ' . $result); } } diff --git a/libravatar.tgz b/libravatar.tgz new file mode 100644 index 00000000..0405af9b Binary files /dev/null and b/libravatar.tgz differ diff --git a/libravatar/README.md b/libravatar/README.md new file mode 100644 index 00000000..16fbd85a --- /dev/null +++ b/libravatar/README.md @@ -0,0 +1,36 @@ +# Libravatar Plugin +by [Klaus Weidenbach](http://friendica.dszdw.net/profile/klaus) + +This addon allows you to look up an avatar image for new users and contacts at [Libravatar](http://www.libravatar.com). It will be used if there have not been found any other avatar images yet for example through OpenID. + +Libravatar is a free and open replacement for Gravatar. It is a service where people can store an avatar image for their email-addresses. These avatar images can get looked up for example in comment functions, profile pages, etc. on other sites. There exists a central installation at [www.libravatar.com](http://www.libravatar.com), but you can also host it on your own server. If no avatar was found Libravatar will look up at Gravatar as a fallback. +There is no rating available, as it is on Gravatar, so all avatar lookups are g-rated. (Suitable for all audiences.) + +PHP >= 5.3 is required for this plugin! + +You can not use the Libravatar and Gravatar addon at the same time. You need to choose one. If you need other ratings than g you better stay with Gravatar, otherwise it is safe to use Libravatar, because it will fall back to Gravatar if nothing was found at Libravatar. + +* * * + +# Configuration +## Default Avatar Image +If no avatar was found for an email Libravatar can create some pseudo-random generated avatars based on an email hash. You can choose between these presets: + +* __MM__: (mystery-man) a static image +* __Identicon__: a generated geometric pattern based on email hash +* __Monsterid__: a generated 'monster' with different colors, faces, etc. based on email hash +* __Wavatar__: faces with different features and backgrounds based on email hash +* __Retro__: 8-bit arcade-styled pixelated faces based on email hash + +See examples at [Libravatar][1]. + +## Alternative Configuration +Open the .htconfig.php file and add "libravatar" to the list of activated addons: + + $a->config['system']['addon'] = "..., libravatar"; + +You can add one configuration variable for the addon: + + $a->config['libravatar']['default_avatar'] = "identicon"; + +[1]: http://wiki.libravatar.org/api/ "See API documentation at Libravatar for more information" diff --git a/libravatar/Services/Libravatar.php b/libravatar/Services/Libravatar.php new file mode 100644 index 00000000..1b6d022e --- /dev/null +++ b/libravatar/Services/Libravatar.php @@ -0,0 +1,669 @@ + + * @copyright 2011 Services_Libravatar committers. + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://pear.php.net/package/Services_Libravatar + * @since File available since Release 0.1.0 + */ + +/** + * PHP support for the Libravatar.org service. + * + * Using this class is easy. After including or requiring + * Services/Libravatar.php simply do: + * + * $libravatar = new Services_Libravatar(); + * $url = $libravatar->getUrl('melissa@meldraweb.com'); + * + * + * This would populate $url with the string: + * + * http://cdn.libravatar.org/avatar/4db84629c121f2d443d33bdb9fd149bc + * + * + * A complicated lookup using all the options is: + * + * $libravatar = new Services_Libravatar(); + * $libravatar->setSize(40); + * $libravatar->setAlgorithm('sha256'); + * $libravatar->setHttps(true); + * $libravatar->setDefault( + * 'http://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png' + * ); + * $url = $libravatar->getUrl('melissa@meldraweb.com'); + * + * + * @category Services + * @package Services_Libravatar + * @author Melissa Draper + * @copyright 2011 Services_Libravatar committers. + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version Release: 0.2.1 + * @link http://pear.php.net/package/Services_Libravatar + * @since Class available since Release 0.1.0 + */ +class Services_Libravatar +{ + /** + * Hashing algorithm to use + * + * @var string + * @see processAlgorithm() + * @see setAlgorithm() + */ + protected $algorithm = 'md5'; + + /** + * Default image URL to use + * + * @var string + * @see processDefault() + * @see setDefault() + */ + protected $default; + + /** + * If HTTPS URLs should be used + * + * @var boolean + * @see detectHttps() + * @see setHttps() + */ + protected $https; + + /** + * Image size in pixels + * + * @var integer + * @see processSize() + * @see setSize() + */ + protected $size; + + + /** + * Composes a URL for the identifier and options passed in + * + * Compose a full URL as specified by the Libravatar API, based on the + * email address or openid URL passed in, and the options specified. + * + * @param string $identifier a string of either an email address + * or an openid url + * @param array $options an array of (bool) https, (string) algorithm + * (string) size, (string) default. + * See the set* methods. + * + * @return string A string of a full URL for an avatar image + * + * @since Method available since Release 0.2.0 + * @deprecated Use getUrl() instead + */ + public function url($identifier, $options = array()) + { + return $this->getUrl($identifier, $options); + } + + /** + * Composes a URL for the identifier and options passed in + * + * Compose a full URL as specified by the Libravatar API, based on the + * email address or openid URL passed in, and the options specified. + * + * @param string $identifier a string of either an email address + * or an openid url + * @param array $options an array of (bool) https, (string) algorithm + * (string) size, (string) default. + * See the set* methods. + * + * @return string A string of a full URL for an avatar image + * + * @since Method available since Release 0.2.0 + * @throws InvalidArgumentException When an invalid option is passed + */ + public function getUrl($identifier, $options = array()) + { + // If no identifier has been passed, set it to a null. + // This way, there'll always be something returned. + if (!$identifier) { + $identifier = null; + } else { + $identifier = $this->normalizeIdentifier($identifier); + } + + // Load all options + $options = $this->checkOptionsArray($options); + $https = $this->https; + if (isset($options['https'])) { + $https = (bool)$options['https']; + } + + $algorithm = $this->algorithm; + if (isset($options['algorithm'])) { + $algorithm = $this->processAlgorithm($options['algorithm']); + } + + $default = $this->default; + if (isset($options['default'])) { + $default = $this->processDefault($options['default']); + } + $size = $this->size; + if (isset($options['size'])) { + $size = $this->processSize($options['size']); + } + + + $identifierHash = $this->identifierHash($identifier, $algorithm); + + // Get the domain so we can determine the SRV stuff for federation + $domain = $this->domainGet($identifier); + + // If https has been specified in $options, make sure we make the + // correct SRV lookup + $service = $this->srvGet($domain, $https); + $protocol = $https ? 'https' : 'http'; + + $params = array(); + if ($size !== null) { + $params['size'] = $size; + } + if ($default !== null) { + $params['default'] = $default; + } + $paramString = ''; + if (count($params) > 0) { + $paramString = '?' . http_build_query($params); + } + + // Compose the URL from the pieces we generated + $url = $protocol . '://' . $service . '/avatar/' . $identifierHash + . $paramString; + + // Return the URL string + return $url; + } + + /** + * Checks the options array and verify that only allowed options are in it. + * + * @param array $options Array of options for getUrl() + * + * @return void + * @throws Exception When an invalid option is used + */ + protected function checkOptionsArray($options) + { + //this short options are deprecated! + if (isset($options['s'])) { + $options['size'] = $options['s']; + unset($options['s']); + } + if (isset($options['d'])) { + $options['default'] = $options['d']; + unset($options['d']); + } + + $allowedOptions = array( + 'algorithm' => true, + 'default' => true, + 'https' => true, + 'size' => true, + ); + foreach ($options as $key => $value) { + if (!isset($allowedOptions[$key])) { + throw new InvalidArgumentException( + 'Invalid option in array: ' . $key + ); + } + } + + return $options; + } + + /** + * Normalizes the identifier (E-mail address or OpenID) + * + * @param string $identifier E-Mail address or OpenID + * + * @return string Normalized identifier + */ + protected function normalizeIdentifier($identifier) + { + if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) { + return strtolower($identifier); + } else { + return self::normalizeOpenId($identifier); + } + } + + /** + * Create a hash of the identifier. + * + * Create a hash of the email address or openid passed in. Algorithm + * used for email address ONLY can be varied. Either md5 or sha256 + * are supported by the Libravatar API. Will be ignored for openid. + * + * @param string $identifier A string of the email address or openid URL + * @param string $hash A string of the hash algorithm type to make + * Uses the php implementation of hash() + * MD5 preferred for Gravatar fallback + * + * @return string A string hash of the identifier. + * + * @since Method available since Release 0.1.0 + */ + protected function identifierHash($identifier, $hash = 'md5') + { + if (filter_var($identifier, FILTER_VALIDATE_EMAIL) || $identifier === null) { + // If email, we can select our algorithm. Default to md5 for + // gravatar fallback. + return hash($hash, $identifier); + } + + //no email, so the identifier has to be an OpenID + return hash('sha256', $identifier); + } + + /** + * Normalizes an identifier (URI or XRI) + * + * @param mixed $identifier URI or XRI to be normalized + * + * @return string Normalized Identifier. + * Empty string when the OpenID is invalid. + * + * @internal Adapted from OpenID::normalizeIdentifier() + */ + public static function normalizeOpenId($identifier) + { + // XRI + if (preg_match('@^xri://@i', $identifier)) { + return preg_replace('@^xri://@i', '', $identifier); + } + + if (in_array($identifier[0], array('=', '@', '+', '$', '!'))) { + return $identifier; + } + + // URL + if (!preg_match('@^http[s]?://@i', $identifier)) { + $identifier = 'http://' . $identifier; + } + if (strpos($identifier, '/', 8) === false) { + $identifier .= '/'; + } + if (!filter_var($identifier, FILTER_VALIDATE_URL)) { + return ''; + } + + $parts = parse_url($identifier); + $parts['scheme'] = strtolower($parts['scheme']); + $parts['host'] = strtolower($parts['host']); + + //http://openid.net/specs/openid-authentication-2_0.html#normalization + return $parts['scheme'] . '://' + . (isset($parts['user']) ? $parts['user'] : '') + . (isset($parts['pass']) ? ':' . $parts['pass'] : '') + . (isset($parts['user']) || isset($parts['pass']) ? '@' : '') + . $parts['host'] + . ( + (isset($parts['port']) + && $parts['scheme'] === 'http' && $parts['port'] != 80) + || (isset($parts['port']) + && $parts['scheme'] === 'https' && $parts['port'] != 443) + ? ':' . $parts['port'] : '' + ) + . $parts['path'] + . (isset($parts['query']) ? '?' . $parts['query'] : ''); + //leave out fragment as requested by the spec + } + + /** + * Grab the domain from the identifier. + * + * Extract the domain from the Email or OpenID. + * + * @param string $identifier A string of the email address or openid URL + * + * @return string A string of the domain to use + * + * @since Method available since Release 0.1.0 + */ + protected function domainGet($identifier) + { + if ($identifier === null) { + return null; + } + + // What are we, email or openid? Split ourself up and get the + // important bit out. + if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) { + $email = explode('@', $identifier); + return $email[1]; + } + + //OpenID + $url = parse_url($identifier); + $domain = $url['host']; + if (isset($url['port']) && $url['scheme'] === 'http' + && $url['port'] != 80 + || isset($url['port']) && $url['scheme'] === 'https' + && $url['port'] != 443 + ) { + $domain .= ':' . $url['port']; + } + + return $domain; + } + + /** + * Get the target to use. + * + * Get the SRV record, filtered by priority and weight. If our domain + * has no SRV records, fall back to Libravatar.org + * + * @param string $domain A string of the domain we extracted from the + * provided identifier with domainGet() + * @param boolean $https Whether or not to look for https records + * + * @return string The target URL. + * + * @since Method available since Release 0.1.0 + */ + protected function srvGet($domain, $https = false) + { + + // Are we going secure? Set up a fallback too. + if (isset($https) && $https === true) { + $subdomain = '_avatars-sec._tcp.'; + $fallback = 'seccdn.'; + } else { + $subdomain = '_avatars._tcp.'; + $fallback = 'cdn.'; + } + + // Lets try get us some records based on the choice of subdomain + // and the domain we had passed in. + $srv = dns_get_record($subdomain . $domain, DNS_SRV); + + // Did we get anything? No? + if (count($srv) == 0) { + // Then let's try Libravatar.org. + return $fallback . 'libravatar.org'; + } + + // Sort by the priority. We must get the lowest. + usort($srv, array($this, 'comparePriority')); + + $top = $srv[0]; + $sum = 0; + + // Try to adhere to RFC2782's weighting algorithm, page 3 + // "arrange all SRV RRs (that have not been ordered yet) in any order, + // except that all those with weight 0 are placed at the beginning of + // the list." + shuffle($srv); + $srvs = array(); + foreach ($srv as $s) { + if ($s['weight'] == 0) { + array_unshift($srvs, $s); + } else { + array_push($srvs, $s); + } + } + + foreach ($srvs as $s) { + if ($s['pri'] == $top['pri']) { + // "Compute the sum of the weights of those RRs" + $sum += (int) $s['weight']; + // "and with each RR associate the running sum in the selected + // order." + $pri[$sum] = $s; + } + } + + // "Then choose a uniform random number between 0 and the sum computed + // (inclusive)" + $random = rand(0, $sum); + + // "and select the RR whose running sum value is the first in the selected + // order which is greater than or equal to the random number selected" + foreach ($pri as $k => $v) { + if ($k >= $random) { + return $v['target']; + } + } + } + + /** + * Sorting function for record priorities. + * + * @param mixed $a A mixed value passed by usort() + * @param mixed $b A mixed value passed by usort() + * + * @return mixed The result of the comparison + * + * @since Method available since Release 0.1.0 + */ + protected function comparePriority($a, $b) + { + return $a['pri'] - $b['pri']; + } + + /** + * Automatically set the https option depending on the current connection + * value. + * + * If the current connection is HTTPS, the https options is activated. + * If it is not HTTPS, the https option is deactivated. + * + * @return self + */ + public function detectHttps() + { + $this->setHttps( + isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] + ); + + return $this; + } + + /** + * Verify and cast the email address hashing algorithm to use. + * + * @param string $algorithm Algorithm to use, "sha256" or "md5". + * + * @return string Algorithm + * + * @throws InvalidArgumentException When an unsupported algorithm is given + */ + protected function processAlgorithm($algorithm) + { + $algorithm = (string)$algorithm; + if ($algorithm !== 'md5' && $algorithm !== 'sha256') { + throw new InvalidArgumentException( + 'Only md5 and sha256 hashing supported' + ); + } + + return $algorithm; + } + + /** + * Verify and cast the default URL to use when no avatar image can be found. + * If none is set, the libravatar logo is returned. + * + * @param string $url Full URL to use OR one of the following: + * - "404" - give a "404 File not found" instead of an image + * - "mm" + * - "identicon" + * - "monsterid" + * - "wavatar" + * - "retro" + * + * @return string Default URL + * + * @throws InvalidArgumentException When an invalid URL is given + */ + protected function processDefault($url) + { + if ($url === null) { + return $url; + } + + $url = (string)$url; + + switch ($url) { + case '404': + case 'mm': + case 'identicon': + case 'monsterid': + case 'wavatar': + case 'retro': + break; + default: + $valid = filter_var($url, FILTER_VALIDATE_URL); + if (!$valid) { + throw new InvalidArgumentException('Invalid default avatar URL'); + } + break; + } + + return $url; + } + + /** + * Verify and cast the required size of the images. + * + * @param integer $size Size (width and height in pixels) of the image. + * NULL for the default width. + * + * @return integer Size + * + * @throws InvalidArgumentException When a size <= 0 is given + */ + protected function processSize($size) + { + if ($size === null) { + return $size; + } + + $size = (int)$size; + if ($size <= 0) { + throw new InvalidArgumentException('Size has to be larger than 0'); + } + + return (int)$size; + } + + + /** + * Set the email address hashing algorithm to use. + * To keep gravatar compatibility, use "md5". + * + * @param string $algorithm Algorithm to use, "sha256" or "md5". + * + * @return self + * @throws InvalidArgumentException When an unsupported algorithm is given + */ + public function setAlgorithm($algorithm) + { + $this->algorithm = $this->processAlgorithm($algorithm); + + return $this; + } + + /** + * Set the default URL to use when no avatar image can be found. + * If none is set, the gravatar logo is returned. + * + * @param string $url Full URL to use OR one of the following: + * - "404" - give a "404 File not found" instead of an image + * - "mm" + * - "identicon" + * - "monsterid" + * - "wavatar" + * - "retro" + * + * @return self + * @throws InvalidArgumentException When an invalid URL is given + */ + public function setDefault($url) + { + $this->default = $this->processDefault($url); + + return $this; + } + + /** + * Set if HTTPS URLs shall be returned. + * + * @param boolean $useHttps If HTTPS url shall be returned + * + * @return self + * + * @see detectHttps() + */ + public function setHttps($useHttps) + { + $this->https = (bool)$useHttps; + + return $this; + } + + /** + * Set the required size of the images. + * Every avatar image is square sized, which means you need to set only number. + * + * @param integer $size Size (width and height) of the image + * + * @return self + * @throws InvalidArgumentException When a size <= 0 is given + */ + public function setSize($size) + { + $this->size = $this->processSize($size); + + return $this; + } + +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + +?> diff --git a/libravatar/admin.tpl b/libravatar/admin.tpl new file mode 100644 index 00000000..814f4a44 --- /dev/null +++ b/libravatar/admin.tpl @@ -0,0 +1,2 @@ +{{ inc field_select.tpl with $field=$default_avatar}}{{ endinc }} +
diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php new file mode 100644 index 00000000..08ed6d00 --- /dev/null +++ b/libravatar/libravatar.php @@ -0,0 +1,114 @@ += 5.3) + * Version: 1.1 + * Author: Klaus Weidenbach + */ + +/** + * Installs the plugin hook + */ +function libravatar_install() { + if (! version_compare(PHP_VERSION, '5.3.0', '>=')) { + info(t('Could NOT install Libravatar successfully.
It requires PHP >= 5.3') .EOL); + // avoid registering the hook + return false; + } + register_hook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup'); + + logger("registered libravatar in avatar_lookup hook"); +} + +/** + * Removes the plugin hook + */ +function libravatar_uninstall() { + unregister_hook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup'); + + logger("unregistered libravatar in avatar_lookup hook"); +} + +/** + * Looks up the avatar at Libravatar and returns the URL. + * + * @param $a array + * @param &$b array + */ +function libravatar_lookup($a, &$b) { + $default_avatar = get_config('libravatar', 'default_img'); + + if (! $default_avatar) { + // if not set, look up if there was one from the gravatar addon + $default_avatar = get_config('gravatar', 'default_img'); + // setting default avatar if nothing configured + if (! $default_avatar) + $default_avatar = 'identicon'; // default image will be a random pattern + } + + require_once 'Services/Libravatar.php'; + $libravatar = new Services_Libravatar(); + $libravatar->setSize($b['size']); + $libravatar->setDefault($default_avatar); + $avatar_url = $libravatar->getUrl($b['email']); + + $b['url'] = $avatar_url; + $b['success'] = true; +} + +/** + * Display admin settings for this addon + */ +function libravatar_plugin_admin (&$a, &$o) { + $t = file_get_contents( dirname(__file__)."/admin.tpl"); + + $default_avatar = get_config('libravatar', 'default_img'); + + // set default values for first configuration + if(! $default_avatar) + $default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash + + // Available options for the select boxes + $default_avatars = array( + 'mm' => t('generic profile image'), + 'identicon' => t('random geometric pattern'), + 'monsterid' => t('monster face'), + 'wavatar' => t('computer generated face'), + 'retro' => t('retro arcade style face'), + ); + + // Show warning if PHP version is too old + if (! version_compare(PHP_VERSION, '5.3.0', '>=')) { + $o = '
' .t('Warning') .'

'; + $o .= sprintf(t('Your PHP version %s is lower than the required PHP >= 5.3.'), PHP_VERSION); + $o .= '
' .t('This addon is not functional on your server.') .'


'; + return; + } + + // Libravatar falls back to gravatar, so show warning about gravatar addon if enabled + $r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1", + dbesc('gravatar') + ); + if (count($r)) { + $o = '

' .t('Information') .'

' .t('Gravatar addon is installed. Please disable the Gravatar addon.
The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'



'; + } + + // output Libravatar settings + $o .= ''; + $o .= replace_macros( $t, array( + '$submit' => t('Submit'), + '$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found. See README'), $default_avatars), + )); +} + +/** + * Save admin settings + */ +function libravatar_plugin_admin_post (&$a) { + check_form_security_token('libravatarrsave'); + + $default_avatar = ((x($_POST, 'avatar')) ? notags(trim($_POST['avatar'])) : 'identicon'); + set_config('libravatar', 'default_img', $default_avatar); + info(t('Libravatar settings updated.') .EOL); +} +?> diff --git a/page.tgz b/page.tgz index c94f01b2..7e95737f 100644 Binary files a/page.tgz and b/page.tgz differ diff --git a/page/page.css b/page/page.css new file mode 100644 index 00000000..0c0fe3cd --- /dev/null +++ b/page/page.css @@ -0,0 +1,13 @@ + + + +#page-settings-label, #page-random-label, #page-profile-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#page-max-pages, #page-random, #page-profile { + float: left; +} + diff --git a/page/page.php b/page/page.php index 129af412..3f0f0419 100755 --- a/page/page.php +++ b/page/page.php @@ -1,7 +1,7 @@ * based on pages plugin by @@ -10,22 +10,35 @@ */ function page_install() { - register_hook('page_end', 'addon/page/page.php', 'page_page_end'); + register_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init'); + register_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings'); + register_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post'); + register_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced'); + } function page_uninstall() { + unregister_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init'); + unregister_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings'); + unregister_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post'); + unregister_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced'); + + // remove only - obsolete unregister_hook('page_end', 'addon/page/page.php', 'page_page_end'); } -function page_getpage($uid) { +function page_getpage($uid,$showhidden = true,$randomise = false) { $pagelist = array(); - $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact` + $order = (($showhidden) ? '' : " and hidden = 0 "); + $order .= (($randomise) ? ' order by rand() ' : ' order by name asc '); + + $contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact` WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d - order by name asc ", + $order ", intval($uid) ); @@ -55,7 +68,7 @@ function page_page_end($a,&$b) { $more = false; foreach($contacts as $contact) { - $page .= '
  • ' . $contact['url'] . ' '. + $page .= '
  • ' . $contact['url'] . ' '. $contact["name"]."
  • "; $total_shown ++; if($total_shown == 6) { @@ -71,5 +84,131 @@ function page_page_end($a,&$b) { $a->page['aside'] = $page . $a->page['aside']; } +function page_network_mod_init($a,$b) { + + $page = '
    +
    +

    '.t("Forums").'

    +
    "; + if (sizeof($contacts) > 0) + $a->page['aside'] = $page . $a->page['aside']; +} + + +function page_profile_advanced($a,&$b) { + + $profile = intval(get_pconfig($a->profile['profile_uid'],'page','show_on_profile')); + if(! $profile) + return; + + $page = '
    +
    '.t("Forums:").'
    +
    '; + + // place holder in case somebody wants configurability + $show_total = 9999; + + $randomise = true; + + $contacts = page_getpage($a->user['uid'],false,$randomise); + + $total_shown = 0; + $more = false; + + foreach($contacts as $contact) { + $page .= micropro($contact,false,'page-profile-advanced'); + $total_shown ++; + if($total_shown == $show_total) + break; + } + $page .= '
    '; + + if(count($contacts) > 0) + $b .= $page; + +} + + + +function page_plugin_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'page-settings-submit'))) + return; + + set_pconfig(local_user(),'page','max_pages',intval($_POST['page_max_pages'])); + set_pconfig(local_user(),'page','randomise',intval($_POST['page_random'])); + set_pconfig(local_user(),'page','show_on_profile',intval($_POST['page_profile'])); + + info( t('Page settings updated.') . EOL); +} + + +function page_plugin_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $max_pages = get_pconfig(local_user(),'page','max_pages'); + if($max_pages === false) + $max_pages = 6; + + $randomise = intval(get_pconfig(local_user(),'page','randomise')); + $randomise_checked = (($randomise) ? ' checked="checked" ' : ''); + + $profile = intval(get_pconfig(local_user(),'page','show_on_profile')); + $profile_checked = (($profile) ? ' checked="checked" ' : ''); + + + /* Add some HTML to the existing form */ + + $s .= '
    '; + $s .= '

    ' . t('Page Settings') . '

    '; + $s .= '
    '; + $s .= ''; + $s .= ''; + $s .= '
    '; + $s .= ''; + $s .= ''; + $s .= '
    '; + $s .= ''; + $s .= ''; + $s .= '
    '; + + $s .= '
    '; + + /* provide a submit button */ + + $s .= '
    '; + +} diff --git a/poormancron.tgz b/poormancron.tgz index cdf40ee1..8eda6264 100755 Binary files a/poormancron.tgz and b/poormancron.tgz differ diff --git a/poormancron/poormancron.php b/poormancron/poormancron.php index bbe023cd..7c48e0fa 100755 --- a/poormancron/poormancron.php +++ b/poormancron/poormancron.php @@ -1,7 +1,7 @@ */ diff --git a/privacy_image_cache.tgz b/privacy_image_cache.tgz index bf386938..27943df5 100644 Binary files a/privacy_image_cache.tgz and b/privacy_image_cache.tgz differ diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php index d3202c4d..b7236d09 100644 --- a/privacy_image_cache/privacy_image_cache.php +++ b/privacy_image_cache/privacy_image_cache.php @@ -36,16 +36,18 @@ function privacy_image_cache_init() { } $urlhash = 'pic:' . sha1($_REQUEST['url']); - $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash ); - if (count($r)) { - $img_str = $r[0]['data']; + // Double encoded url - happens with Diaspora + $urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url'])); + + $r = q("SELECT * FROM `photo` WHERE `resource-id` in ('%s', '%s') LIMIT 1", $urlhash, $urlhash2); + if (count($r)) { + $img_str = $r[0]['data']; $mime = $r[0]["desc"]; if ($mime == "") $mime = "image/jpeg"; - } - else { - require_once("Photo.php"); + } else { + require_once("Photo.php"); - $img_str = fetch_url($_REQUEST['url'],true); + $img_str = fetch_url($_REQUEST['url'],true); if (substr($img_str, 0, 6) == "GIF89a") { $mime = "image/gif"; $image = @imagecreatefromstring($img_str); @@ -77,16 +79,16 @@ function privacy_image_cache_init() { } $mime = "image/jpeg"; } - } + } - header("Content-type: $mime"); - header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT"); - header("Cache-Control: max-age=" . (3600*24)); + header("Content-type: $mime"); + header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT"); + header("Cache-Control: max-age=" . (3600*24)); - echo $img_str; + echo $img_str; - killme(); + killme(); } /** @@ -210,4 +212,4 @@ function privacy_image_cache_plugin_admin_post(&$a = null, &$o = null){ if (isset($_REQUEST['delete_all'])) { q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%"'); } -} \ No newline at end of file +} diff --git a/smiley_pack.tgz b/smiley_pack.tgz index a1358539..8c184414 100644 Binary files a/smiley_pack.tgz and b/smiley_pack.tgz differ diff --git a/smiley_pack/smiley_pack.php b/smiley_pack/smiley_pack.php index 258ade76..4623ded5 100644 --- a/smiley_pack/smiley_pack.php +++ b/smiley_pack/smiley_pack.php @@ -33,463 +33,463 @@ function smiley_pack_smilies(&$a,&$b) { #Animal smileys. $b['texts'][] = ':bunnyflowers'; - $b['icons'][] = '' . ':bunnyflowers' . ''; + $b['icons'][] = '' . ':bunnyflowers' . ''; $b['texts'][] = ':chick'; - $b['icons'][] = '' . ':chick' . ''; + $b['icons'][] = '' . ':chick' . ''; $b['texts'][] = ':bumblebee'; - $b['icons'][] = '' . ':bee' . ''; + $b['icons'][] = '' . ':bee' . ''; $b['texts'][] = ':ladybird'; - $b['icons'][] = '' . ':ladybird' . ''; + $b['icons'][] = '' . ':ladybird' . ''; $b['texts'][] = ':bigspider'; - $b['icons'][] = '' . ':bigspider' . ''; + $b['icons'][] = '' . ':bigspider' . ''; $b['texts'][] = ':cat'; - $b['icons'][] = '' . ':cat' . ''; + $b['icons'][] = '' . ':cat' . ''; $b['texts'][] = ':bunny'; - $b['icons'][] = '' . ':bunny' . ''; + $b['icons'][] = '' . ':bunny' . ''; $b['texts'][] = ':cow'; - $b['icons'][] = '' . ':cow' . ''; + $b['icons'][] = '' . ':cow' . ''; $b['texts'][] = ':crab'; - $b['icons'][] = '' . ':crab' . ''; + $b['icons'][] = '' . ':crab' . ''; $b['texts'][] = ':dolphin'; - $b['icons'][] = '' . ':dolphin' . ''; + $b['icons'][] = '' . ':dolphin' . ''; $b['texts'][] = ':dragonfly'; - $b['icons'][] = '' . ':dragonfly' . ''; + $b['icons'][] = '' . ':dragonfly' . ''; $b['texts'][] = ':frog'; - $b['icons'][] = '' . ':frog' . ''; + $b['icons'][] = '' . ':frog' . ''; $b['texts'][] = ':hamster'; - $b['icons'][] = '' . ':hamster' . ''; + $b['icons'][] = '' . ':hamster' . ''; $b['texts'][] = ':monkey'; - $b['icons'][] = '' . ':monkey' . ''; + $b['icons'][] = '' . ':monkey' . ''; $b['texts'][] = ':horse'; - $b['icons'][] = '' . ':horse' . ''; + $b['icons'][] = '' . ':horse' . ''; $b['texts'][] = ':parrot'; - $b['icons'][] = '' . ':parrot' . ''; + $b['icons'][] = '' . ':parrot' . ''; $b['texts'][] = ':tux'; - $b['icons'][] = '' . ':tux' . ''; + $b['icons'][] = '' . ':tux' . ''; $b['texts'][] = ':snail'; - $b['icons'][] = '' . ':snail' . ''; + $b['icons'][] = '' . ':snail' . ''; $b['texts'][] = ':sheep'; - $b['icons'][] = '' . ':sheep' . ''; + $b['icons'][] = '' . ':sheep' . ''; $b['texts'][] = ':dog'; - $b['icons'][] = '' . ':dog' . ''; + $b['icons'][] = '' . ':dog' . ''; $b['texts'][] = ':elephant'; - $b['icons'][] = '' . ':elephant' . ''; + $b['icons'][] = '' . ':elephant' . ''; $b['texts'][] = ':fish'; - $b['icons'][] = '' . ':fish' . ''; + $b['icons'][] = '' . ':fish' . ''; $b['texts'][] = ':giraffe'; - $b['icons'][] = '' . ':giraffe' . ''; + $b['icons'][] = '' . ':giraffe' . ''; $b['texts'][] = ':pig'; - $b['icons'][] = '' . ':pig' . ''; + $b['icons'][] = '' . ':pig' . ''; #Baby Smileys $b['texts'][] = ':baby'; - $b['icons'][] = '' . ':baby' . ''; + $b['icons'][] = '' . ':baby' . ''; $b['texts'][] = ':babycot'; - $b['icons'][] = '' . ':babycot' . ''; + $b['icons'][] = '' . ':babycot' . ''; $b['texts'][] = ':pregnant'; - $b['icons'][] = '' . ':pregnant' . ''; + $b['icons'][] = '' . ':pregnant' . ''; $b['texts'][] = ':stork'; - $b['icons'][] = '' . ':stork' . ''; + $b['icons'][] = '' . ':stork' . ''; #Confused Smileys $b['texts'][] = ':confused'; - $b['icons'][] = '' . ':confused' . ''; + $b['icons'][] = '' . ':confused' . ''; $b['texts'][] = ':shrug'; - $b['icons'][] = '' . ':shrug' . ''; + $b['icons'][] = '' . ':shrug' . ''; $b['texts'][] = ':stupid'; - $b['icons'][] = '' . ':stupid' . ''; + $b['icons'][] = '' . ':stupid' . ''; $b['texts'][] = ':dazed'; - $b['icons'][] = '' . ':dazed' . ''; + $b['icons'][] = '' . ':dazed' . ''; #Cool Smileys $b['texts'][] = ':affro'; - $b['icons'][] = '' . ':affro' . ''; + $b['icons'][] = '' . ':affro' . ''; #Devil/Angel Smileys $b['texts'][] = ':angel'; - $b['icons'][] = '' . ':angel' . ''; + $b['icons'][] = '' . ':angel' . ''; $b['texts'][] = ':cherub'; - $b['icons'][] = '' . ':cherub' . ''; + $b['icons'][] = '' . ':cherub' . ''; $b['texts'][] = ':devilangel'; - $b['icons'][] = '' . ':devilangel' . ''; + $b['icons'][] = '' . ':devilangel' . ''; $b['texts'][] = ':catdevil'; - $b['icons'][] = '' . ':catdevil' . ''; + $b['icons'][] = '' . ':catdevil' . ''; $b['texts'][] = ':devillish'; - $b['icons'][] = '' . ':devillish' . ''; + $b['icons'][] = '' . ':devillish' . ''; $b['texts'][] = ':daseesaw'; - $b['icons'][] = '' . ':daseesaw' . ''; + $b['icons'][] = '' . ':daseesaw' . ''; $b['texts'][] = ':turnevil'; - $b['icons'][] = '' . ':turnevil' . ''; + $b['icons'][] = '' . ':turnevil' . ''; $b['texts'][] = ':saint'; - $b['icons'][] = '' . ':saint' . ''; + $b['icons'][] = '' . ':saint' . ''; $b['texts'][] = ':graveside'; - $b['icons'][] = '' . ':graveside' . ''; + $b['icons'][] = '' . ':graveside' . ''; #Unpleasent smileys. $b['texts'][] = ':toilet'; - $b['icons'][] = '' . ':toilet' . ''; + $b['icons'][] = '' . ':toilet' . ''; $b['texts'][] = ':fartinbed'; - $b['icons'][] = '' . ':fartinbed' . ''; + $b['icons'][] = '' . ':fartinbed' . ''; $b['texts'][] = ':fartblush'; - $b['icons'][] = '' . ':fartblush' . ''; + $b['icons'][] = '' . ':fartblush' . ''; #Drinks $b['texts'][] = ':tea'; - $b['icons'][] = '' . ':tea' . ''; + $b['icons'][] = '' . ':tea' . ''; $b['texts'][] = ':drool'; - $b['icons'][] = '' . ':drool' . ''; + $b['icons'][] = '' . ':drool' . ''; #Sad smileys $b['texts'][] = ':crying'; - $b['icons'][] = '' . ':crying' . ''; + $b['icons'][] = '' . ':crying' . ''; $b['texts'][] = ':prisoner'; - $b['icons'][] = '' . ':prisoner' . ''; + $b['icons'][] = '' . ':prisoner' . ''; $b['texts'][] = ':sigh'; - $b['icons'][] = '' . ':sigh' . ''; + $b['icons'][] = '' . ':sigh' . ''; #Smoking - only one smiley in here, maybe it needs moving elsewhere? $b['texts'][] = ':smoking'; - $b['icons'][] = '' . ':smoking' . ''; + $b['icons'][] = '' . ':smoking' . ''; #Sport smileys $b['texts'][] = ':basketball'; - $b['icons'][] = '' . ':basketball' . ''; + $b['icons'][] = '' . ':basketball' . ''; $b['texts'][] = '~bowling'; - $b['icons'][] = '' . '~bowling' . ''; + $b['icons'][] = '' . '~bowling' . ''; $b['texts'][] = ':cycling'; - $b['icons'][] = '' . ':cycling' . ''; + $b['icons'][] = '' . ':cycling' . ''; $b['texts'][] = ':darts'; - $b['icons'][] = '' . ':darts' . ''; + $b['icons'][] = '' . ':darts' . ''; $b['texts'][] = ':fencing'; - $b['icons'][] = '' . ':fencing' . ''; + $b['icons'][] = '' . ':fencing' . ''; $b['texts'][] = ':juggling'; - $b['icons'][] = '' . ':juggling' . ''; + $b['icons'][] = '' . ':juggling' . ''; $b['texts'][] = ':skipping'; - $b['icons'][] = '' . ':skipping' . ''; + $b['icons'][] = '' . ':skipping' . ''; $b['texts'][] = ':archery'; - $b['icons'][] = '' . ':archery' . ''; + $b['icons'][] = '' . ':archery' . ''; $b['texts'][] = ':surfing'; - $b['icons'][] = '' . ':surfing' . ''; + $b['icons'][] = '' . ':surfing' . ''; $b['texts'][] = ':snooker'; - $b['icons'][] = '' . ':snooker' . ''; + $b['icons'][] = '' . ':snooker' . ''; $b['texts'][] = ':horseriding'; - $b['icons'][] = '' . ':horseriding' . ''; + $b['icons'][] = '' . ':horseriding' . ''; #Love smileys $b['texts'][] = ':iloveyou'; - $b['icons'][] = '' . ':iloveyou' . ''; + $b['icons'][] = '' . ':iloveyou' . ''; $b['texts'][] = ':inlove'; - $b['icons'][] = '' . ':inlove' . ''; + $b['icons'][] = '' . ':inlove' . ''; $b['texts'][] = '~love'; - $b['icons'][] = '' . ':love' . ''; + $b['icons'][] = '' . ':love' . ''; $b['texts'][] = ':lovebear'; - $b['icons'][] = '' . ':lovebear' . ''; + $b['icons'][] = '' . ':lovebear' . ''; $b['texts'][] = ':lovebed'; - $b['icons'][] = '' . ':lovebed' . ''; + $b['icons'][] = '' . ':lovebed' . ''; $b['texts'][] = ':loveheart'; - $b['icons'][] = '' . ':loveheart' . ''; + $b['icons'][] = '' . ':loveheart' . ''; #Tired/Sleep smileys $b['texts'][] = ':countsheep'; - $b['icons'][] = '' . ':countsheep' . ''; + $b['icons'][] = '' . ':countsheep' . ''; $b['texts'][] = ':hammock'; - $b['icons'][] = '' . ':hammock' . ''; + $b['icons'][] = '' . ':hammock' . ''; $b['texts'][] = ':pillow'; - $b['icons'][] = '' . ':pillow' . ''; + $b['icons'][] = '' . ':pillow' . ''; $b['texts'][] = ':yawn'; - $b['icons'][] = '' . ':yawn' . ''; + $b['icons'][] = '' . ':yawn' . ''; #Fight/Flame/Violent smileys $b['texts'][] = ':2guns'; - $b['icons'][] = '' . ':2guns' . ''; + $b['icons'][] = '' . ':2guns' . ''; $b['texts'][] = ':alienfight'; - $b['icons'][] = '' . ':alienfight' . ''; + $b['icons'][] = '' . ':alienfight' . ''; $b['texts'][] = ':army'; - $b['icons'][] = '' . ':army' . ''; + $b['icons'][] = '' . ':army' . ''; $b['texts'][] = ':arrowhead'; - $b['icons'][] = '' . ':arrowhead' . ''; + $b['icons'][] = '' . ':arrowhead' . ''; $b['texts'][] = ':bfg'; - $b['icons'][] = '' . ':bfg' . ''; + $b['icons'][] = '' . ':bfg' . ''; $b['texts'][] = ':bowman'; - $b['icons'][] = '' . ':bowman' . ''; + $b['icons'][] = '' . ':bowman' . ''; $b['texts'][] = ':chainsaw'; - $b['icons'][] = '' . ':chainsaw' . ''; + $b['icons'][] = '' . ':chainsaw' . ''; $b['texts'][] = ':crossbow'; - $b['icons'][] = '' . ':crossbow' . ''; + $b['icons'][] = '' . ':crossbow' . ''; $b['texts'][] = ':crusader'; - $b['icons'][] = '' . ':crusader' . ''; + $b['icons'][] = '' . ':crusader' . ''; $b['texts'][] = ':dead'; - $b['icons'][] = '' . ':dead' . ''; + $b['icons'][] = '' . ':dead' . ''; $b['texts'][] = ':hammersplat'; - $b['icons'][] = '' . ':hammersplat' . ''; + $b['icons'][] = '' . ':hammersplat' . ''; $b['texts'][] = ':lasergun'; - $b['icons'][] = '' . ':lasergun' . ''; + $b['icons'][] = '' . ':lasergun' . ''; $b['texts'][] = ':machinegun'; - $b['icons'][] = '' . ':machinegun' . ''; + $b['icons'][] = '' . ':machinegun' . ''; $b['texts'][] = ':acid'; - $b['icons'][] = '' . ':acid' . ''; + $b['icons'][] = '' . ':acid' . ''; #Fantasy smileys - monsters and dragons fantasy. The other type of fantasy belongs in adult smileys $b['texts'][] = ':alienmonster'; - $b['icons'][] = '' . ':alienmonster' . ''; + $b['icons'][] = '' . ':alienmonster' . ''; $b['texts'][] = ':barbarian'; - $b['icons'][] = '' . ':barbarian' . ''; + $b['icons'][] = '' . ':barbarian' . ''; $b['texts'][] = ':dinosaur'; - $b['icons'][] = '' . ':dinosaur' . ''; + $b['icons'][] = '' . ':dinosaur' . ''; $b['texts'][] = ':dragon'; - $b['icons'][] = '' . ':dragon' . ''; + $b['icons'][] = '' . ':dragon' . ''; $b['texts'][] = ':draco'; - $b['icons'][] = '' . ':draco' . ''; + $b['icons'][] = '' . ':draco' . ''; $b['texts'][] = ':ghost'; - $b['icons'][] = '' . ':ghost' . ''; + $b['icons'][] = '' . ':ghost' . ''; $b['texts'][] = ':mummy'; - $b['icons'][] = '' . ':mummy' . ''; + $b['icons'][] = '' . ':mummy' . ''; #Food smileys $b['texts'][] = ':apple'; - $b['icons'][] = '' . ':apple' . ''; + $b['icons'][] = '' . ':apple' . ''; $b['texts'][] = ':broccoli'; - $b['icons'][] = '' . ':brocolli' . ''; + $b['icons'][] = '' . ':brocolli' . ''; $b['texts'][] = ':cake'; - $b['icons'][] = '' . ':cake' . ''; + $b['icons'][] = '' . ':cake' . ''; $b['texts'][] = ':carrot'; - $b['icons'][] = '' . ':carrot' . ''; + $b['icons'][] = '' . ':carrot' . ''; $b['texts'][] = ':popcorn'; - $b['icons'][] = '' . ':popcorn' . ''; + $b['icons'][] = '' . ':popcorn' . ''; $b['texts'][] = ':tomato'; - $b['icons'][] = '' . ':tomato' . ''; + $b['icons'][] = '' . ':tomato' . ''; $b['texts'][] = ':banana'; - $b['icons'][] = '' . ':banana' . ''; + $b['icons'][] = '' . ':banana' . ''; $b['texts'][] = ':cooking'; - $b['icons'][] = '' . ':cooking' . ''; + $b['icons'][] = '' . ':cooking' . ''; $b['texts'][] = ':fryegg'; - $b['icons'][] = '' . ':fryegg' . ''; + $b['icons'][] = '' . ':fryegg' . ''; #Happy smileys $b['texts'][] = ':cloud9'; - $b['icons'][] = '' . ':cloud9' . ''; + $b['icons'][] = '' . ':cloud9' . ''; $b['texts'][] = ':tearsofjoy'; - $b['icons'][] = '' . ':tearsofjoy' . ''; + $b['icons'][] = '' . ':tearsofjoy' . ''; #Repsect smileys $b['texts'][] = ':bow'; - $b['icons'][] = '' . ':bow' . ''; + $b['icons'][] = '' . ':bow' . ''; $b['texts'][] = ':bravo'; - $b['icons'][] = '' . ':bravo' . ''; + $b['icons'][] = '' . ':bravo' . ''; $b['texts'][] = ':hailking'; - $b['icons'][] = '' . ':hailking' . ''; + $b['icons'][] = '' . ':hailking' . ''; $b['texts'][] = ':number1'; - $b['icons'][] = '' . ':number1' . ''; + $b['icons'][] = '' . ':number1' . ''; #Laugh smileys $b['texts'][] = ':hahaha'; - $b['icons'][] = '' . ':hahaha' . ''; + $b['icons'][] = '' . ':hahaha' . ''; $b['texts'][] = ':loltv'; - $b['icons'][] = '' . ':loltv' . ''; + $b['icons'][] = '' . ':loltv' . ''; $b['texts'][] = ':rofl'; - $b['icons'][] = '' . ':rofl' . ''; + $b['icons'][] = '' . ':rofl' . ''; #Music smileys $b['texts'][] = ':drums'; - $b['icons'][] = '' . ':drums' . ''; + $b['icons'][] = '' . ':drums' . ''; $b['texts'][] = ':guitar'; - $b['icons'][] = '' . ':guitar' . ''; + $b['icons'][] = '' . ':guitar' . ''; $b['texts'][] = ':trumpet'; - $b['icons'][] = '' . ':trumpet' . ''; + $b['icons'][] = '' . ':trumpet' . ''; #Smileys that used to be in core $b['texts'][] = ':headbang'; - $b['icons'][] = '' . ':headbang' . ''; + $b['icons'][] = '' . ':headbang' . ''; $b['texts'][] = ':beard'; - $b['icons'][] = '' . ':beard' . ''; + $b['icons'][] = '' . ':beard' . ''; $b['texts'][] = ':whitebeard'; - $b['icons'][] = '' . ':whitebeard' . ''; + $b['icons'][] = '' . ':whitebeard' . ''; $b['texts'][] = ':shaka'; - $b['icons'][] = '' . ':shaka' . ''; + $b['icons'][] = '' . ':shaka' . ''; $b['texts'][] = ':\\.../'; - $b['icons'][] = '' . ':\\.../' . ''; + $b['icons'][] = '' . ':\\.../' . ''; $b['texts'][] = ':\\ooo/'; - $b['icons'][] = '' . ':\\ooo/' . ''; + $b['icons'][] = '' . ':\\ooo/' . ''; $b['texts'][] = ':headdesk'; - $b['icons'][] = '' . ':headdesk' . ''; + $b['icons'][] = '' . ':headdesk' . ''; #These two are still in core, so oldcore isn't strictly right, but we don't want too many directories $b['texts'][] = ':-d'; - $b['icons'][] = '' . ':-d' . ''; + $b['icons'][] = '' . ':-d' . ''; $b['texts'][] = ':-o'; - $b['icons'][] = '' . ':-o' . ''; + $b['icons'][] = '' . ':-o' . ''; # Regex killers - stick these at the bottom so they appear at the end of the English and # at the start of $OtherLanguage. $b['texts'][] = ':cool'; - $b['icons'][] = '' . ':cool' . ''; + $b['icons'][] = '' . ':cool' . ''; $b['texts'][] = ':vomit'; - $b['icons'][] = '' . ':vomit' . ''; + $b['icons'][] = '' . ':vomit' . ''; $b['texts'][] = ':golf'; - $b['icons'][] = '' . ':golf' . ''; + $b['icons'][] = '' . ':golf' . ''; $b['texts'][] = ':football'; - $b['icons'][] = '' . ':football' . ''; + $b['icons'][] = '' . ':football' . ''; $b['texts'][] = ':tennis'; - $b['icons'][] = '' . ':tennis' . ''; + $b['icons'][] = '' . ':tennis' . ''; $b['texts'][] = ':alpha'; - $b['icons'][] = '' . ':alpha' . ''; + $b['icons'][] = '' . ':alpha' . ''; $b['texts'][] = ':marine'; - $b['icons'][] = '' . ':marine' . ''; + $b['icons'][] = '' . ':marine' . ''; $b['texts'][] = ':sabre'; - $b['icons'][] = '' . ':sabre' . ''; + $b['icons'][] = '' . ':sabre' . ''; $b['texts'][] = ':tank'; - $b['icons'][] = '' . ':tank' . ''; + $b['icons'][] = '' . ':tank' . ''; $b['texts'][] = ':viking'; - $b['icons'][] = '' . ':viking' . ''; + $b['icons'][] = '' . ':viking' . ''; $b['texts'][] = ':gangs'; - $b['icons'][] = '' . ':gangs' . ''; + $b['icons'][] = '' . ':gangs' . ''; $b['texts'][] = ':dj'; - $b['icons'][] = '' . ':dj' . ''; + $b['icons'][] = '' . ':dj' . ''; $b['texts'][] = ':elvis'; - $b['icons'][] = '' . ':elivs' . ''; + $b['icons'][] = '' . ':elivs' . ''; $b['texts'][] = ':violin'; - $b['icons'][] = '' . ':violin' . ''; + $b['icons'][] = '' . ':violin' . ''; } diff --git a/smilies_adult.tgz b/smilies_adult.tgz index 971547d7..95f12161 100644 Binary files a/smilies_adult.tgz and b/smilies_adult.tgz differ diff --git a/smilies_adult/smilies_adult.php b/smilies_adult/smilies_adult.php index 19c13b40..82b30a98 100644 --- a/smilies_adult/smilies_adult.php +++ b/smilies_adult/smilies_adult.php @@ -22,21 +22,21 @@ function smilies_adult_uninstall() { function smilies_adult_smilies(&$a,&$b) { $b['texts'][] = '(o)(o)'; - $b['icons'][] = '' . '(o)(o)' . ''; + $b['icons'][] = '' . '(o)(o)' . ''; $b['texts'][] = '(.)(.)'; - $b['icons'][] = '' . '(.)(.)' . ''; + $b['icons'][] = '' . '(.)(.)' . ''; $b['texts'][] = ':bong'; - $b['icons'][] = '' . ':bong' . ''; + $b['icons'][] = '' . ':bong' . ''; $b['texts'][] = ':sperm'; - $b['icons'][] = '' . ':sperm' . ''; + $b['icons'][] = '' . ':sperm' . ''; $b['texts'][] = ':drunk'; - $b['icons'][] = '' . ':drunk' . ''; + $b['icons'][] = '' . ':drunk' . ''; $b['texts'][] = ':finger'; - $b['icons'][] = '' . ':finger' . ''; + $b['icons'][] = '' . ':finger' . ''; } \ No newline at end of file diff --git a/statusnet.tgz b/statusnet.tgz index 33fbc68a..51390d30 100755 Binary files a/statusnet.tgz and b/statusnet.tgz differ diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index dd876168..99e84475 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -426,15 +426,15 @@ function statusnet_post_hook(&$a,&$b) { if($ckey && $csecret && $otoken && $osecret) { - require_once('include/bbcode.php'); + require_once('include/bbcode.php'); $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); $max_char = $dent->get_maxlength(); // max. length for a dent // we will only work with up to two times the length of the dent - // we can later send to StatusNet. This way we can "gain" some - // information during shortening of potential links but do not + // we can later send to StatusNet. This way we can "gain" some + // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. if (! $b['title']=='') { - $tmp = $b['title'] . ' : '. $b['body']; + $tmp = $b['title'].": \n".$b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); @@ -453,10 +453,16 @@ function statusnet_post_hook(&$a,&$b) { // that is, don't send if the option is not set in the // connector settings if ($linksenabled=='0') { - // #-tags - $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); - // @-mentions - $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp); + // #-tags + $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); + // @-mentions + $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp); + // recycle 1 + $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); + $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp); + // recycle 2 + //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8'); + //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp); } // preserve links to webpages $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp); @@ -476,7 +482,7 @@ function statusnet_post_hook(&$a,&$b) { } // ok, all the links we want to send out are save, now strip // away the remaining bbcode - $msg = strip_tags(bbcode($tmp)); + $msg = strip_tags(bbcode($tmp, false, false)); // quotes not working - let's try this $msg = html_entity_decode($msg); if (( strlen($msg) > $max_char) && $max_char > 0) { diff --git a/tumblr.tgz b/tumblr.tgz index d5a34c21..2a137b54 100755 Binary files a/tumblr.tgz and b/tumblr.tgz differ diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 723bdef0..03a67949 100755 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -166,19 +166,58 @@ function tumblr_send(&$a,&$b) { } } if(count($tag_arr)) - $tags = implode(',',$tag_arr); + $tags = implode(',',$tag_arr); + $link = ""; + $video = false; + $title = trim($b['title']); + + // Checking for a bookmark + if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) { + $link = $matches[1]; + if ($title == '') + $title = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8'); + + $body = $b['body']; + // splitting the text in two parts: + // before and after the bookmark + $pos = strpos($body, "[bookmark"); + $body1 = substr($body, 0, $pos); + $body2 = substr($body, $pos); + + // Removing the bookmark + $body2 = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'',$body2); + $body = $body1.$body2; + + $video = ((stristr($link,'youtube')) || (stristr($link,'youtu.be')) || (stristr($mtch[1],'vimeo'))); + } $params = array( 'email' => $tmbl_username, 'password' => $tmbl_password, - 'title' => $b['title'], - 'type' => 'regular', 'format' => 'html', 'generator' => 'Friendica', - 'tags' => $tags, - 'body' => bbcode($b['body']) - ); + 'tags' => $tags); + + if (($link != '') and $video) { + $params['type'] = "video"; + $params['embed'] = $link; + if ($title != '') + $params['caption'] = '

    '.$title. + "

    ".bbcode($body)."

    "; + else + $params['caption'] = bbcode($body); + } else if (($link != '') and !$video) { + $params['type'] = "link"; + $params['name'] = $title; + $params['url'] = $link; + //$params['description'] = bbcode($body); + $params['description'] = bbcode($b["body"]); + } else { + $params['type'] = "regular"; + $params['title'] = $title; + $params['body'] = bbcode($b['body']); + } $x = post_url($tmbl_blog,$params); $ret_code = $a->get_curl_code(); @@ -187,7 +226,7 @@ function tumblr_send(&$a,&$b) { elseif($ret_code == 403) logger('tumblr_send: authentication failure'); else - logger('tumblr_send: general error: ' . print_r($x,true)); + logger('tumblr_send: general error: ' . print_r($x,true)); } } diff --git a/twitter.tgz b/twitter.tgz index e011308e..192d6f85 100755 Binary files a/twitter.tgz and b/twitter.tgz differ diff --git a/twitter/twitter.php b/twitter/twitter.php index 0ac9396d..9984f369 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -290,7 +290,7 @@ function twitter_post_hook(&$a,&$b) { logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); require_once('library/twitteroauth.php'); - require_once('include/bbcode.php'); + require_once('include/bbcode.php'); $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); // in theory max char is 140 but T. uses t.co to make links // longer so we give them 10 characters extra @@ -316,18 +316,24 @@ function twitter_post_hook(&$a,&$b) { $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks'); // if a #tag is linked, don't send the [url] over to SN - // that is, don't send if the option is not set in the + // that is, don't send if the option is not set in the // connector settings if ($linksenabled=='0') { - // #-tags - $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); - // @-mentions - $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp); + // #-tags + $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); + // @-mentions + $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp); + // recycle 1 + $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); + $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp); + // recycle 2 + //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8'); + //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp); } $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp); $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp); - // find all http or https links in the body of the entry and - // apply the shortener if the link is longer then 20 characters + // find all http or https links in the body of the entry and + // apply the shortener if the link is longer then 20 characters if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) { preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls ); foreach ($allurls as $url) { @@ -341,7 +347,7 @@ function twitter_post_hook(&$a,&$b) { } // ok, all the links we want to send out are save, now strip // away the remaining bbcode - $msg = strip_tags(bbcode($tmp)); + $msg = strip_tags(bbcode($tmp, false, false)); // quotes not working - let's try this $msg = html_entity_decode($msg); if (( strlen($msg) > $max_char) && $max_char > 0) { diff --git a/wppost.tgz b/wppost.tgz index 21546b37..dc4338ac 100755 Binary files a/wppost.tgz and b/wppost.tgz differ diff --git a/wppost/wppost.php b/wppost/wppost.php index ee9acb0d..e8b6fc6d 100755 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -179,24 +179,26 @@ function wppost_send(&$a,&$b) { require_once('include/bbcode.php'); require_once('include/html2plain.php'); + $wptitle = trim($b['title']); + // If the title is empty then try to guess - if ($b['title'] == '') { + if ($wptitle == '') { // Take the description from the bookmark if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) - $b['title'] = $matches[2]; + $wptitle = $matches[2]; // If no bookmark is found then take the first line - if ($b['title'] == '') { + if ($wptitle == '') { $title = html2plain(bbcode($b['body']), 0, true); $pos = strpos($title, "\n"); if (($pos == 0) or ($pos > 60)) $pos = 60; - $b['title'] = substr($title, 0, $pos); + $wptitle = substr($title, 0, $pos); } } - $title = '' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . ''; + $title = '' . (($wptitle) ? $wptitle : t('Post from Friendica')) . ''; $post = $title . bbcode($b['body']); $wp_backlink = intval(get_pconfig($b['uid'],'wppost','backlink'));