diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ItemObject.php | 4 | ||||
-rw-r--r-- | include/apps.php | 115 | ||||
-rw-r--r-- | include/auth.php | 15 | ||||
-rw-r--r-- | include/bbcode.php | 38 | ||||
-rwxr-xr-x | include/items.php | 25 | ||||
-rw-r--r-- | include/js_strings.php | 1 | ||||
-rwxr-xr-x | include/plugin.php | 11 | ||||
-rw-r--r-- | include/session.php | 6 | ||||
-rw-r--r-- | include/widgets.php | 61 | ||||
-rw-r--r-- | include/zot.php | 3 |
10 files changed, 261 insertions, 18 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php index 36070335d..475642787 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -125,11 +125,11 @@ class Item extends BaseObject { $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : ''); $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : ''); - $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('like') : t('likes')); + $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('Like') : t('Likes')); if (feature_enabled($conv->get_profile_owner(),'dislike')) { $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : ''); $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : ''); - $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('dislike') : t('dislikes')); + $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('Dislike') : t('Dislikes')); } $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : ''); diff --git a/include/apps.php b/include/apps.php new file mode 100644 index 000000000..181079f2f --- /dev/null +++ b/include/apps.php @@ -0,0 +1,115 @@ +<?php /** @file */ + +/** + * apps + * + */ + +require_once('include/plugin.php'); + +function get_system_apps() { + + $ret = array(); + $files = glob('app/*.apd'); + if($files) { + foreach($files as $f) { + $x = parse_app_description($f); + if($x) { + $ret[] = $x; + } + } + } + $files = glob('addon/*/*.apd'); + if($files) { + foreach($files as $f) { + $n = basename($f,'.apd'); + if(plugin_is_installed($n)) { + $x = parse_app_description($f); + if($x) { + $ret[] = $x; + } + } + } + } + + return $ret; + +} + + +function parse_app_description($f) { + $ret = array(); + + $baseurl = z_root(); + $channel = get_app()->get_channel(); + $address = (($channel) ? $channel['channel_address'] : ''); + + //future expansion + + $observer = get_app()->get_observer(); + + + $lines = @file($f); + if($lines) { + foreach($lines as $x) { + if(preg_match('/^([a-zA-Z].*?):(.*?)$/ism',$x,$matches)) { + $ret[$matches[1]] = trim(str_replace(array('$baseurl','$nick'),array($baseurl,$address),$matches[2])); + } + } + } + + + + if(! $ret['photo']) + $ret['photo'] = $baseurl . '/' . get_default_profile_photo(80); + + + foreach($ret as $k => $v) { + if(strpos($v,'http') === 0) + $ret[$k] = zid($v); + } + + if(array_key_exists('hover',$ret)) + $ret['hover'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['hover']); + + if(array_key_exists('requires',$ret)) { + $require = trim(strtolower($ret['requires'])); + switch($require) { + case 'nologin': + if(local_user()) + unset($ret); + break; + case 'local_user': + if(! local_user()) + unset($ret); + break; + case 'observer': + if(! $observer) + unset($ret); + break; + default: + if(! local_user() && feature_enabled(local_user(),$require)) + unset($ret); + break; + + } + logger('require: ' . print_r($ret,true)); + } + if($ret) { + translate_system_apps($ret); + return $ret; + } + return false; +} + + +function translate_system_apps(&$arr) { + $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), + 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), 'Help' => t('Help') + + ); + + if(array_key_exists($arr['name'],$apps)) + $arr['name'] = $apps[$arr['name']]; + +}
\ No newline at end of file diff --git a/include/auth.php b/include/auth.php index c21705c99..e8f13d0fb 100644 --- a/include/auth.php +++ b/include/auth.php @@ -117,13 +117,14 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p // first check if we're enforcing that sessions can't change IP address - $check = get_config('system','paranoia'); - // extra paranoia - if the IP changed, log them out - if($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) { - logger('Session address changed. Paranoid setting in effect, blocking session. ' - . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); - nuke_session(); - goaway(z_root()); + if($_SESSION['addr'] != $_SERVER['REMOTE_ADDR']) { + logger('SECURITY: Session IP address changed: ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); + if(get_config('system','paranoia')) { + logger('Session address changed. Paranoid setting in effect, blocking session. ' + . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); + nuke_session(); + goaway(z_root()); + } } $r = q("select * from account where account_id = %d limit 1", diff --git a/include/bbcode.php b/include/bbcode.php index 326676b72..a4e7560d6 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -63,7 +63,7 @@ function bb_spacefy($st) { } // The previously spacefied [noparse][ i ]italic[ /i ][/noparse], -// now turns back and the [noparse] tags are trimed +// now turns back and the [noparse] tags are trimmed // returning [i]italic[/i] function bb_unspacefy_and_trim($st) { @@ -507,6 +507,30 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px;\">$2</span>",$Text); $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text); } + // Check for h1 + if (strpos($Text,'[h1]') !== false) { + $Text = preg_replace("(\[h1\](.*?)\[\/h1\])ism",'<h1>$1</h1>',$Text); + } + // Check for h2 + if (strpos($Text,'[h2]') !== false) { + $Text = preg_replace("(\[h2\](.*?)\[\/h2\])ism",'<h2>$1</h2>',$Text); + } + // Check for h3 + if (strpos($Text,'[h3]') !== false) { + $Text = preg_replace("(\[h3\](.*?)\[\/h3\])ism",'<h3>$1</h3>',$Text); + } + // Check for h4 + if (strpos($Text,'[h4]') !== false) { + $Text = preg_replace("(\[h4\](.*?)\[\/h4\])ism",'<h4>$1</h4>',$Text); + } + // Check for h5 + if (strpos($Text,'[h5]') !== false) { + $Text = preg_replace("(\[h5\](.*?)\[\/h5\])ism",'<h5>$1</h5>',$Text); + } + // Check for h6 + if (strpos($Text,'[h6]') !== false) { + $Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text); + } // Check for centered text if (strpos($Text,'[/center]') !== false) { $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text); @@ -606,24 +630,24 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Images // [img]pathtoimage[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text); } // [img float={left, right}]pathtoimage[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text); } if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text); } // [img=widthxheight]pathtoimage[/img] diff --git a/include/items.php b/include/items.php index 7a94336be..5aaeb55c0 100755 --- a/include/items.php +++ b/include/items.php @@ -239,6 +239,31 @@ function red_unescape_codeblock($m) { } +function red_zrlify_img_callback($matches) { + $m = @parse_url($matches[2]); + $zrl = false; + if($m['host']) { + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1", + dbesc($m['host']) + ); + if($r) + $zrl = true; + } + + $t = strip_zids($matches[2]); + if($t !== $matches[2]) { + $zrl = true; + $matches[2] = $t; + } + + if($zrl) + return '[zmg' . $matches[1] . ']' . $matches[2] . '[/zmg]'; + return $matches[0]; +} + + + + /** * @function post_activity_item($arr) * diff --git a/include/js_strings.php b/include/js_strings.php index fef84077e..1b62266d6 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -14,6 +14,7 @@ function js_strings() { '$passphrase' => t('Secret Passphrase'), '$passhint' => t('Passphrase hint'), '$permschange' => t('Notice: Permissions have changed but have not yet been submitted.'), + '$closeAll' => t('close all'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), diff --git a/include/plugin.php b/include/plugin.php index 9982a48a2..ace00d43a 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -94,6 +94,17 @@ function load_plugin($plugin) { } +function plugin_is_installed($name) { + $r = q("select name from addon where name = '%s' and installed = 1 limit 1", + dbesc($name) + ); + if($r) + return true; + return false; +} + + + // reload all updated plugins function reload_plugins() { diff --git a/include/session.php b/include/session.php index be1ec5ee7..b531688e2 100644 --- a/include/session.php +++ b/include/session.php @@ -11,7 +11,11 @@ $session_expire = 180000; function new_cookie($time) { $old_sid = session_id(); - session_set_cookie_params("$time"); + +// ??? This shouldn't have any effect if called after session_start() +// We probably need to set the session expiration and change the PHPSESSID cookie. + + session_set_cookie_params($time); session_regenerate_id(false); q("UPDATE session SET sid = '%s' WHERE sid = '%s'", dbesc(session_id()), dbesc($old_sid)); diff --git a/include/widgets.php b/include/widgets.php index 1b0e140c0..37a079bc7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -74,6 +74,18 @@ function widget_collections($args) { } +function widget_appselect($arr) { + return replace_macros(get_markup_template('app_select.tpl'),array( + '$title' => t('App Category'), + '$system' => t('System'), + '$personal' => t('Personal'), + '$featured' => t('Featured'), + '$new' => t('New') + )); +} + + + function widget_suggestions($arr) { if((! local_user()) || (! feature_enabled(local_user(),'suggest'))) @@ -719,4 +731,51 @@ $(document).ready(function() { EOT; return $o; -}
\ No newline at end of file +} + + +/** + * @function widget_photo($arr) + * widget to display a single photo. + * @param array $arr; + * 'src' => URL of photo + * 'zrl' => true or false, use zid in url + * 'style' => CSS string + * URL must be an http or https URL + */ + + +function widget_photo($arr) { + + $style = $zrl = false; + $params = ''; + if(array_key_exists('src',$arr) && isset($arr['src'])) + $url = $arr['src']; + + if(strpos($url,'http') !== 0) + return ''; + + if(array_key_exists('style',$arr) && isset($arr['style'])) + $style = $arr['style']; + + // ensure they can't sneak in an eval(js) function + + if(strpos($style,'(') !== false) + return ''; + + if(array_key_exists('zrl',$arr) && isset($arr['zrl'])) + $zrl = (($arr['zrl']) ? true : false); + + if($zrl) + $url = zid($url); + + $o = '<div class="widget">'; + + $o .= '<img ' . (($zrl) ? ' class="zrl" ' : '') + . (($style) ? ' style="' . $style . '"' : '') + . ' src="' . $url . '" />'; + + $o .= '</div>'; + + return $o; +} diff --git a/include/zot.php b/include/zot.php index 9e69aea96..869943a24 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1501,6 +1501,9 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) { $arr['uid'] = $channel['channel_id']; $item_result = item_store($arr); $item_id = $item_result['item_id']; + $parr = array('item_id' => $item_id,'item' => $arr,'sender' => $sender,'channel' => $channel); + call_hooks('activity_received',$parr); + add_source_route($item_id,$sender['hash']); $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); |