diff --git a/buildtgz b/buildtgz index 37c734f8..61dd5d71 100755 --- a/buildtgz +++ b/buildtgz @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Make doesn't handle subdirs very well # without providing a Makefile in each one. # So we will just manually find any source diff --git a/calc.tgz b/calc.tgz index a849ef0e..f5d6870d 100755 Binary files a/calc.tgz and b/calc.tgz differ diff --git a/facebook.tgz b/facebook.tgz index 582d4e5a..e049d2b8 100755 Binary files a/facebook.tgz and b/facebook.tgz differ diff --git a/facebook/facebook.php b/facebook/facebook.php index 755e7766..39013402 100755 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -24,8 +24,7 @@ * d. Navigate to Set Web->Site URL & Domain -> Website Settings. Set * Site URL to yoursubdomain.yourdomain.com. Set Site Domain to your * yourdomain.com. - * 2. (This step is now obsolete. Enable the plugin via the Admin panel.) - * Enable the facebook plugin by including it in .htconfig.php - e.g. + * 2. Enable the facebook plugin by including it in .htconfig.php - e.g. * $a->config['system']['addon'] = 'plugin1,plugin2,facebook'; * 3. Visit the Facebook Settings section of the "Settings->Plugin Settings" page. * and click 'Install Facebook Connector'. @@ -732,7 +731,7 @@ function facebook_post_hook(&$a,&$b) { logger('facebook: postvars: ' . print_r($postvars,true)); // "test_mode" prevents anything from actually being posted. - // Otherwise, let's do it. + // Otherwise, let's do it. if(! get_config('facebook','test_mode')) { $x = post_url($url, $postvars); @@ -953,11 +952,13 @@ function fb_consume_stream($uid,$j,$wall = false) { // don't store post if we don't have a contact if(! x($datarray,'contact-id')) { - logger('no contact: post ignored'); - continue; + // Test: Workaround for page entries + $datarray['contact-id'] = $self[0]['id']; + //logger('no contact: post ignored'); + //continue; } - $datarray['verb'] = ACTIVITY_POST; + $datarray['verb'] = ACTIVITY_POST; if($wall) { $datarray['owner-name'] = $self[0]['name']; $datarray['owner-link'] = $self[0]['url']; diff --git a/openstreetmap.tgz b/openstreetmap.tgz index e54b0c78..93dc874b 100644 Binary files a/openstreetmap.tgz and b/openstreetmap.tgz differ diff --git a/openstreetmap/README b/openstreetmap/README deleted file mode 100644 index 41fc842c..00000000 --- a/openstreetmap/README +++ /dev/null @@ -1,30 +0,0 @@ - ____ OpenStreetMap Plugin ____ -by Mike Macgirvin - Klaus Weidenbach - -This addon allows you to use OpenStreetMap for displaying locations. - -___ Requirements ___ - -To use this plugin you need a tile Server that provides the maps. -OpenStreetMap data is free for everyone to use. Their tile servers are not. -Please take a look at their "Tile Usage Policy": -http://wiki.openstreetmap.org/wiki/Tile_usage_policy -You can run your own tile server or choose one from their list of public -tile servers: http://wiki.openstreetmap.org/wiki/TMS -Support the OpenStreetMap community and share the load. - -___ Configuration ___ - -Open the .htconfig.php file and add "openstreetmap" to the list of activated -addons. - $a->config['system']['addon'] = "openstreetmap, ..." - -You have to add two configuration variables for the addon: - $a->config['openstreetmap']['tmsserver'] = 'http://www.openstreetmap.org/'; - $a->config['openstreetmap']['zoom'] = '18'; - -The *tmsserver* points to the tile server you want to use. Use the full URL, -with protocol (http/s) and trailing slash. You can configure the default zoom -level on the map with *zoom*. 1 will show the whole world and 18 is the highest -zoom level available. diff --git a/openstreetmap/admin.tpl b/openstreetmap/admin.tpl deleted file mode 100644 index 75db9cd7..00000000 --- a/openstreetmap/admin.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ inc field_input.tpl with $field=$tmsserver }}{{ endinc }} -{{ inc field_input.tpl with $field=$zoom }}{{ endinc }} -
diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 415e448d..ef5d6bef 100755 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -1,49 +1,45 @@ - * Author: Klaus Weidenbach + * * */ + function openstreetmap_install() { + register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); logger("installed openstreetmap"); } + function openstreetmap_uninstall() { + unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); logger("removed openstreetmap"); } + function openstreetmap_location($a, &$item) { + if(! (strlen($item['location']) || strlen($item['coord']))) return; - /* - * Get the configuration variables from the .htconfig file. - */ - $tmsserver = get_config('openstreetmap','tmsserver'); - if(! $tmsserver) - $tmsserver = 'http://openstreetmap.org'; - $zoom = get_config('openstreetmap','zoom'); - if(! $zoom) - $zoom = 17; - $location = ''; $coord = ''; - $location = (($item['location']) ? '' . $item['location'] . '' : ''); + $location = (($item['location']) ? '' . $item['location'] . '' : ''); if($item['coord']) { $coords = explode(' ', $item['coord']); if(count($coords) > 1) { - $coord = '' . $item['coord'] . '' ; + $coord = '' . $item['coord'] . '' ; } } if(strlen($coord)) { @@ -56,26 +52,3 @@ function openstreetmap_location($a, &$item) { return; } - -function openstreetmap_plugin_admin (&$a, &$o) { - $t = file_get_contents( dirname(__file__)."/admin.tpl"); - $tmsserver = get_config('openstreetmap','tmsserver'); - if(! $tmsserver) - $tmsserver = 'http://openstreetmap.org'; - $zoom = get_config('openstreetmap','zoom'); - if(! $zoom) - $zoom = 17; - - $o = replace_macros( $t, array( - '$submit' => t('Submit'), - '$tmsserver' => array('tmsserver', t('Tile Server URL'), $tmsserver, t('A list of public tile servers')), - '$zoom' => array('zoom', t('Default zoom'), $zoom, t('The default zoom level. (1:world, 18:highest)')), - )); -} -function openstreetmap_plugin_admin_post (&$a) { - $url = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : ''); - $zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '17'); - set_config('openstreetmap', 'tmsserver', $url); - set_config('openstreetmap', 'zoom', $zoom); - info( t('Settings updated.'). EOL); -} diff --git a/piwik.tgz b/piwik.tgz index 2e572dc1..54752c6e 100755 Binary files a/piwik.tgz and b/piwik.tgz differ diff --git a/qcomment.tgz b/qcomment.tgz index 76dffda1..b0ae94bc 100644 Binary files a/qcomment.tgz and b/qcomment.tgz differ diff --git a/showmore.tgz b/showmore.tgz new file mode 100644 index 00000000..ef095853 Binary files /dev/null and b/showmore.tgz differ diff --git a/showmore/README b/showmore/README new file mode 100755 index 00000000..8ee882e3 --- /dev/null +++ b/showmore/README @@ -0,0 +1,3 @@ +Show more + +Shortens messages and offers a link to show more. diff --git a/showmore/showmore.css b/showmore/showmore.css new file mode 100755 index 00000000..710c1f3f --- /dev/null +++ b/showmore/showmore.css @@ -0,0 +1,19 @@ + +#showmore-label, #showmore-enable-label { + float: left; + width: 300px; + margin-top: 10px; +} + +#showmore-words, #showmore-enable { + float: left; + margin-top: 10px; +} + +#showmore-submit { + margin-top: 15px; +} + +.showmore-desc { + margin-top: 10px; +} diff --git a/showmore/showmore.php b/showmore/showmore.php new file mode 100755 index 00000000..7842a58e --- /dev/null +++ b/showmore/showmore.php @@ -0,0 +1,121 @@ + + * based upon NSFW from Mike Macgirvin + * + */ + +function showmore_install() { + register_hook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); + register_hook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); + register_hook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); +} + +function showmore_uninstall() { + unregister_hook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); + unregister_hook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); + unregister_hook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); +} + +function showmore_addon_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"; + + $enable_checked = (intval(get_pconfig(local_user(),'showmore','disable')) ? '' : ' checked="checked"'); + $chars = get_pconfig(local_user(),'showmore','chars'); + if(!$chars) + $chars = '1100'; + + $s .= '
'; + $s .= '

' . t('"Show more" Settings').'

'; + $s .= '
'; + + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; +// $s .= '
' . t('Use /expression/ to provide regular expressions') . '
'; + + return; +} + +function showmore_addon_settings_post(&$a,&$b) { + + if(! local_user()) + return; + + if($_POST['showmore-submit']) { + set_pconfig(local_user(),'showmore','chars',trim($_POST['showmore-chars'])); + $enable = ((x($_POST,'showmore-enable')) ? intval($_POST['showmore-enable']) : 0); + $disable = 1-$enable; + set_pconfig(local_user(),'showmore','disable', $disable); + info( t('Show More Settings saved.') . EOL); + } +} + +function showmore_prepare_body(&$a,&$b) { + + $words = null; + if(get_pconfig(local_user(),'showmore','disable')) + return; + + $chars = (int)get_pconfig(local_user(),'showmore','chars'); + if(!$chars) + $chars = 1100; + + if (strlen(strip_tags(trim($b['html']))) > $chars) { + $found = true; + $shortened = trim(showmore_cutitem($b['html'], $chars))."..."; + } + + if($found) { + $rnd = random_string(8); + $b['html'] = ''.$shortened." ". + ''.sprintf(t('Show More')).''. + ''; + } +} + +function showmore_cutitem($text, $limit) { + $text = trim($text); + + $text = mb_convert_encoding($text, 'HTML-ENTITIES', "UTF-8"); + + $text = substr($text, 0, $limit); + + $pos1 = strrpos($text, "<"); + $pos2 = strrpos($text, ">"); + $pos3 = strrpos($text, "&"); + $pos4 = strrpos($text, ";"); + + if ($pos1 > $pos3) { + if ($pos1 > $pos2) + $text = substr($text, 0, $pos1); + } else { + if ($pos3 > $pos4) + $text = substr($text, 0, $pos3); + } + + $doc = new DOMDocument(); + $doc->preserveWhiteSpace = false; + + $doctype = ''; + @$doc->loadHTML($doctype."".$text.""); + + $text = $doc->saveHTML(); + $text = str_replace(array("", "", $doctype), array("", "", ""), $text); + + return($text); +} diff --git a/statusnet.tgz b/statusnet.tgz index e73c3b5d..3d7c9f58 100755 Binary files a/statusnet.tgz and b/statusnet.tgz differ diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 38202483..f558cbec 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1,8 +1,7 @@ */ @@ -23,6 +22,13 @@ * Documentation: http://diekershoff.homeunix.net/redmine/wiki/friendikaplugin/StatusNet_Plugin */ +/* __TODO__ + * + * - what about multimedia content? + * so far we just strip HTML tags from the message + */ + + /*** * We have to alter the TwitterOAuth class a little bit to work with any StatusNet * installation abroad. Basically it's only make the API path variable and be happy. @@ -147,6 +153,7 @@ function statusnet_settings_post ($a,$post) { if (isset($_POST['statusnet-disconnect'])) { /*** * if the statusnet-disconnect checkbox is set, clear the statusnet configuration + * TODO can we revoke the access tokens at Twitter and do we need to do so? */ del_pconfig( local_user(), 'statusnet', 'consumerkey' ); del_pconfig( local_user(), 'statusnet', 'consumersecret' ); @@ -368,30 +375,6 @@ function statusnet_post_local(&$a,&$b) { } } -function short($url) { - require_once('library/slinky.php'); - $slinky = new Slinky( $url ); - $yourls_url = get_config('yourls','url1'); - if ($yourls_url) { - $yourls_username = get_config('yourls','username1'); - $yourls_password = get_config('yourls', 'password1'); - $yourls_ssl = get_config('yourls', 'ssl1'); - $yourls = new Slinky_YourLS(); - $yourls->set( 'username', $yourls_username ); - $yourls->set( 'password', $yourls_password ); - $yourls->set( 'ssl', $yourls_ssl ); - $yourls->set( 'yourls-url', $yourls_url ); - $slinky->set_cascade( array( $yourls, new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); - } - else { - // setup a cascade of shortening services - // try to get a short link from these services - // in the order ur1.ca, trim, id.gd, tinyurl - $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); - } - return $slinky->short(); -} - function statusnet_post_hook(&$a,&$b) { /** @@ -416,50 +399,33 @@ function statusnet_post_hook(&$a,&$b) { 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 time 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 - // shorten all the links in a 200000 character long essay. - $tmp = substr($b['body'], 0, 2*$max_char); - // if [url=bla][img]blub.png[/img][/url] get blub.png - $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp); -// $tmp = preg_replace( '/\[url\=(\w+.*?)\]\[img\](\w+.*?)\[\/img\]\[\/url\]/i', '$2', $tmp); - // preserve links to images, videos and audios - $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp); - $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp); - $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp); - $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp); - $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp); - $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp); - // if a #tag is linked, don't send the [url] over to SN - // this is commented out by default as it means backlinks - // to friendica, if you don't like this feel free to - // uncomment the following line -// $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); - // preserve links to webpages - $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 - if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) { - preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls ); - foreach ($allurls as $url) { - foreach ($url as $u) { - if (strlen($u)>20) { - $sl = short($u); - $tmp = str_replace( $u, $sl, $tmp ); - } - } - } - } - // ok, all the links we want to send out are save, now strip - // away the remaining bbcode - $msg = strip_tags(bbcode($tmp)); + $max_char = $dent->get_maxlength(); // max. length for a dent + $msg = strip_tags(bbcode($b['body'])); // quotes not working - let's try this $msg = html_entity_decode($msg); if (( strlen($msg) > $max_char) && $max_char > 0) { - $shortlink = short( $b['plink'] ); + $shortlink = ""; + require_once('library/slinky.php'); + $slinky = new Slinky( $b['plink'] ); + $yourls_url = get_config('yourls','url1'); + if ($yourls_url) { + $yourls_username = get_config('yourls','username1'); + $yourls_password = get_config('yourls', 'password1'); + $yourls_ssl = get_config('yourls', 'ssl1'); + $yourls = new Slinky_YourLS(); + $yourls->set( 'username', $yourls_username ); + $yourls->set( 'password', $yourls_password ); + $yourls->set( 'ssl', $yourls_ssl ); + $yourls->set( 'yourls-url', $yourls_url ); + $slinky->set_cascade( array( $yourls, new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } + else { + // setup a cascade of shortening services + // try to get a short link from these services + // in the order ur1.ca, trim, id.gd, tinyurl + $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } + $shortlink = $slinky->short(); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); diff --git a/wppost.tgz b/wppost.tgz index 6dad5c11..34858866 100755 Binary files a/wppost.tgz and b/wppost.tgz differ diff --git a/wppost/wppost.php b/wppost/wppost.php index 5c1482e7..6db0d944 100755 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -38,7 +38,7 @@ function wppost_jot_nets(&$a,&$b) { if(intval($wp_post) == 1) { $wp_defpost = get_pconfig(local_user(),'wppost','post_by_default'); $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : ''); - $b .= '
' + $b .= '
' . t('Post to Wordpress') . '
'; } }