From b2f0d2d085c355010f1475269c4beb4fba7b07dc Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 20 May 2016 17:44:26 -0700 Subject: cleanup proc_run after messing it up with debugging yesterday --- include/text.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 3f2e85fc8..554518e32 100644 --- a/include/text.php +++ b/include/text.php @@ -2860,3 +2860,32 @@ function pdl_selector($uid, $current="") { return $o; } +/* + * array flatten_array_recursive(array); + * returns a one-dimensional array from a multi-dimensional array + * empty values are discarded + * example: print_r(flatten_array_recursive(array('foo','bar',array('baz','blip',array('zob','glob')),'','grip'))); + * + * Array ( [0] => foo [1] => bar [2] => baz [3] => blip [4] => zob [5] => glob [6] => grip ) + * + */ + +function flatten_array_recursive($arr) { + $ret = array(); + + if(! $arr) + return $ret; + + foreach($arr as $a) { + if(is_array($a)) { + $tmp = flatten_array_recursive($a); + if($tmp) { + $ret = array_merge($ret,$tmp); + } + } + elseif($a) { + $ret[] = $a; + } + } + return($ret); +} -- cgit v1.2.3 From f4da365abdc1ce1da2dde1bb9798f58fc6dc1a9f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 20 May 2016 19:11:14 -0700 Subject: move template stuff to zotlabs/render --- include/text.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 554518e32..df6dac056 100644 --- a/include/text.php +++ b/include/text.php @@ -3,8 +3,6 @@ * @file include/text.php */ -require_once("include/template_processor.php"); -require_once("include/smarty.php"); require_once("include/bbcode.php"); // random string, there are 86 characters max in text mode, 128 for hex @@ -16,8 +14,8 @@ define('RANDOM_STRING_TEXT', 0x01 ); /** * @brief This is our template processor. * - * @param string|FriendicaSmarty $s the string requiring macro substitution, - * or an instance of FriendicaSmarty + * @param string|SmartyEngine $s the string requiring macro substitution, + * or an instance of SmartyEngine * @param array $r key value pairs (search => replace) * @return string substituted string */ -- cgit v1.2.3 From de006771c7fe92a889d759c2c75c1473c420ad47 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 22 May 2016 16:54:30 -0700 Subject: renamed include files identity.php (channel.php) and Contact.php (connections.php) --- include/text.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index df6dac056..91aeae989 100644 --- a/include/text.php +++ b/include/text.php @@ -1319,7 +1319,7 @@ function theme_attachments(&$item) { $title = t('Size') . ' ' . (($r['length']) ? userReadableSize($r['length']) : t('unknown')); - require_once('include/identity.php'); + require_once('include/channel.php'); if(is_foreigner($item['author_xchan'])) $url = $r['href']; else @@ -1486,7 +1486,7 @@ function format_event($jobject) { } function prepare_body(&$item,$attach = false) { - require_once('include/identity.php'); + require_once('include/channel.php'); call_hooks('prepare_body_init', $item); @@ -2261,7 +2261,7 @@ function design_tools() { $sys = false; if(App::$is_sys && is_site_admin()) { - require_once('include/identity.php'); + require_once('include/channel.php'); $channel = get_sys_channel(); $sys = true; } -- cgit v1.2.3 From 84ba6393ad32406a9875044aef2d031c7d0d7a46 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 May 2016 16:36:55 -0700 Subject: relocate index and db --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 91aeae989..21692e74f 100644 --- a/include/text.php +++ b/include/text.php @@ -571,7 +571,7 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { global $a; global $db; - if((App::$module == 'install') || (! ($db && $db->connected))) + if((App::$module == 'install') || (! (DBA::$dba && DBA::$dba->connected))) return; $debugging = get_config('system', 'debugging'); @@ -652,7 +652,7 @@ function dlogger($msg, $level = 0) { global $a; global $db; - if((App::$module == 'install') || (! ($db && $db->connected))) + if((App::$module == 'install') || (! (DBA::$dba && DBA::$dba->connected))) return; $debugging = get_config('system','debugging'); -- cgit v1.2.3 From 516c43ba154dc43ec0ef6135fb0a9732d0185a6f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 May 2016 17:54:45 -0700 Subject: more work associated with DBA and index.php shuffle --- include/text.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 21692e74f..caaef664f 100644 --- a/include/text.php +++ b/include/text.php @@ -567,21 +567,25 @@ function attribute_contains($attr, $s) { */ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { - // turn off logger in install mode - global $a; - global $db; - - if((App::$module == 'install') || (! (DBA::$dba && DBA::$dba->connected))) - return; - $debugging = get_config('system', 'debugging'); - $loglevel = intval(get_config('system', 'loglevel')); - $logfile = get_config('system', 'logfile'); + if(App::$module == 'setup' && is_writable('install.log')) { + $debugging = true; + $logfile = 'install.log'; + $loglevel = LOGGER_ALL; + } + else { + $debugging = get_config('system', 'debugging'); + $loglevel = intval(get_config('system', 'loglevel')); + $logfile = get_config('system', 'logfile'); + } if((! $debugging) || (! $logfile) || ($level > $loglevel)) return; $where = ''; + + // We require > 5.4 but leave the version check so that install issues (including version) can be logged + if(version_compare(PHP_VERSION, '5.4.0') >= 0) { $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; @@ -590,7 +594,8 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { $s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL; $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'priority' => $priority, 'logged' => false); - call_hooks('logger',$pluginfo); + if(! (App::$module == 'setup')) + call_hooks('logger',$pluginfo); if(! $pluginfo['logged']) @file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND); -- cgit v1.2.3 From 80f2ba640ec528bd43db243122a69e765703b7c0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 May 2016 20:49:23 -0700 Subject: code cleanup --- include/text.php | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index caaef664f..a7cc4c9bd 100644 --- a/include/text.php +++ b/include/text.php @@ -20,7 +20,6 @@ define('RANDOM_STRING_TEXT', 0x01 ); * @return string substituted string */ function replace_macros($s, $r) { - $a = get_app(); $arr = array('template' => $s, 'params' => $r); call_hooks('replace_macros', $arr); @@ -96,7 +95,6 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { if($type == 'application/x-pdl') return escape_tags($s); - $a = get_app(); if(App::$is_sys) { return $s; } @@ -653,11 +651,10 @@ function log_priority_str($priority) { * @param int $level A log level. */ function dlogger($msg, $level = 0) { + // turn off logger in install mode - global $a; - global $db; - if((App::$module == 'install') || (! (DBA::$dba && DBA::$dba->connected))) + if(App::$module == 'setup') return; $debugging = get_config('system','debugging'); @@ -815,7 +812,6 @@ function get_mentions($item,$tags) { function contact_block() { $o = ''; - $a = get_app(); if(! App::$profile['uid']) return; @@ -928,7 +924,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { function search($s,$id='search-box',$url='/search',$save = false) { - $a = get_app(); + return replace_macros(get_markup_template('searchbox.tpl'),array( '$s' => $s, '$id' => $id, @@ -1073,7 +1069,7 @@ function get_mood_verbs() { // Function to list all smilies, both internal and from addons // Returns array with keys 'texts' and 'icons' function list_smilies() { - $a = get_app(); + $texts = array( '<3', '</3', @@ -1106,10 +1102,8 @@ function list_smilies() { ':coffee', ':facepalm', ':like', - ':dislike', - 'red#matrix', - 'red#', - 'r#' + ':dislike' + ); $icons = array( @@ -1145,9 +1139,6 @@ function list_smilies() { ':facepalm', ':like', ':dislike', - 'redmatrix', - 'redmatrix', - 'redmatrix' ); @@ -1218,7 +1209,7 @@ function smile_unshield($m) { * @param array $x */ function preg_heart($x) { - $a = get_app(); + if (strlen($x[1]) == 1) return $x[0]; @@ -1491,7 +1482,6 @@ function format_event($jobject) { } function prepare_body(&$item,$attach = false) { - require_once('include/channel.php'); call_hooks('prepare_body_init', $item); @@ -1721,7 +1711,6 @@ function feed_hublinks() { /* return atom link elements for salmon endpoints */ function feed_salmonlinks($nick) { - $a = get_app(); $salmon = '' . "\n" ; @@ -1789,7 +1778,7 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { 'application/x-pdl' ); - $a = get_app(); + if(App::$is_sys) { $x[] = 'application/x-php'; } @@ -1822,7 +1811,6 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { function lang_selector() { - global $a; $langs = glob('view/*/hstrings.php'); -- cgit v1.2.3 From 61304d80d23bf624d9ca13319d2c6c09fdd0d70e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 26 May 2016 18:45:47 -0700 Subject: track down some issues from the application logs --- include/text.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index a7cc4c9bd..375a89d3f 100644 --- a/include/text.php +++ b/include/text.php @@ -322,6 +322,15 @@ function autoname($len) { function xmlify($str) { $buffer = ''; + if(is_array($str)) { + + // allow to fall through so we ge a PHP error, as the log statement will + // probably get lost in the noise unless we're specifically looking for it. + + btlogger('xmlify called with array: ' . print_r($str,true), LOGGER_NORMAL, LOG_WARNING); + } + + $len = mb_strlen($str); for($x = 0; $x < $len; $x ++) { $char = mb_substr($str,$x,1); -- cgit v1.2.3 From b1259876bf398880e7b0c1b44d90f94983243e72 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 31 May 2016 21:45:33 -0700 Subject: more db column renames --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 375a89d3f..c57f5fce4 100644 --- a/include/text.php +++ b/include/text.php @@ -810,7 +810,7 @@ function get_mentions($item,$tags) { return $o; foreach($tags as $x) { - if($x['type'] == TERM_MENTION) { + if($x['ttype'] == TERM_MENTION) { $o .= "\t\t" . '' . "\r\n"; $o .= "\t\t" . '' . "\r\n"; } -- cgit v1.2.3 From a9d7acda279ebb7f2b3cd61a91a5e1d8b590dcf2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 1 Jun 2016 21:48:54 -0700 Subject: the rest of the schema updates - WARNING: some third party plugins may fail; e.g. embedphotos and chess. $item['object'] is now $item['obj'] and $photo['type'] is $photo['mimetype'], $photo['scale'] is $photo['imgscale'] and $photo['data'] is now $photo['content']. There are a number of other changes, but these are the ones noted to cause issues with third-party plugins. The project plugins have been updated. Please note any new issues as this effort touched a lot of code in a lot of files. --- include/text.php | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index c57f5fce4..551cb72bc 100644 --- a/include/text.php +++ b/include/text.php @@ -1458,37 +1458,6 @@ function generate_named_map($location) { return (($arr['html']) ? $arr['html'] : $location); } -function format_event($jobject) { - $event = array(); - - $object = json_decode($jobject,true); - - //ensure compatibility with older items - this check can be removed at a later point - if(array_key_exists('description', $object)) { - - $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM - - $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( - '$title' => bbcode($object['title']), - '$dtstart_label' => t('Starts:'), - '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['start'] , $bd_format))), - '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('Finishes:'), - '$dtend_title' => datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['finish'] , $bd_format ))) - )); - - $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( - '$description' => bbcode($object['description']), - '$location_label' => t('Location:'), - '$location' => bbcode($object['location']) - )); - - } - - return $event; -} function prepare_body(&$item,$attach = false) { @@ -1516,7 +1485,7 @@ function prepare_body(&$item,$attach = false) { $s .= prepare_text($item['body'],$item['mimetype'], false); - $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event($item['object']) : false); + $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); $prep_arr = array( 'item' => $item, -- cgit v1.2.3 From f9075e2a2feca0f37fdf568be6e6e53460aa9034 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 2 Jun 2016 18:42:51 -0700 Subject: some initial emoji reaction work --- include/text.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 551cb72bc..834eec920 100644 --- a/include/text.php +++ b/include/text.php @@ -734,6 +734,10 @@ function get_tags($s) { // '=' needs to be avoided because when the replacement is made (in handle_tag()) it has to be ignored there // Feel free to allow '=' if the issue with '=' is solved in handle_tag() // added / ? and [ to avoid issues with hashchars in url paths + + // added ; to single word tags to allow emojis and other unicode character constructs in bbcode + // (this would actually be &#xnnnnn; but the ampersand will have been escaped to & by the time we see it.) + if(preg_match_all('/(? Date: Fri, 3 Jun 2016 15:09:58 -0700 Subject: missed an object -> obj conversion in prepare_body --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 834eec920..72db9c5ea 100644 --- a/include/text.php +++ b/include/text.php @@ -1473,7 +1473,7 @@ function prepare_body(&$item,$attach = false) { if($is_photo) { - $object = json_decode($item['object'],true); + $object = json_decode($item['obj'],true); // if original photo width is <= 640px prepend it to item body if($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) { -- cgit v1.2.3 From a6012af00d13bdab1806b7ae172d271d4ad9ebe5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 4 Jun 2016 17:06:12 -0700 Subject: For emojis in posts, extend smilies and save a lot of duplication of effort --- include/text.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 72db9c5ea..5d0010bd5 100644 --- a/include/text.php +++ b/include/text.php @@ -1155,6 +1155,18 @@ function list_smilies() { ); + $x = get_config('feature','emoji'); + if($x === false) + $x = 1; + if($x) { + if(! App::$emojitab) + App::$emojitab = json_decode(file_get_contents('library/emoji.json'),true); + foreach(App::$emojitab as $e) { + $texts[] = $e['shortname']; + $icons[] = '' . $e['name'] . ''; + } + } + $params = array('texts' => $texts, 'icons' => $icons); call_hooks('smilie', $params); -- cgit v1.2.3 From 81f6511d340ce986e9a8ff06bbc27070818f690a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 4 Jun 2016 17:09:37 -0700 Subject: return of the project smilie --- include/text.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 5d0010bd5..7495f01bd 100644 --- a/include/text.php +++ b/include/text.php @@ -1115,8 +1115,8 @@ function list_smilies() { ':coffee', ':facepalm', ':like', - ':dislike' - + ':dislike', + ':hubzilla' ); $icons = array( @@ -1152,6 +1152,7 @@ function list_smilies() { ':facepalm', ':like', ':dislike', + ':hubzilla', ); -- cgit v1.2.3 From bf438f67e15853488a0b2209194ce3365b918ca8 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 4 Jun 2016 17:13:55 -0700 Subject: the :tone variants are messed up, remove them --- include/text.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 7495f01bd..7d1e22170 100644 --- a/include/text.php +++ b/include/text.php @@ -1163,6 +1163,8 @@ function list_smilies() { if(! App::$emojitab) App::$emojitab = json_decode(file_get_contents('library/emoji.json'),true); foreach(App::$emojitab as $e) { + if(strpos($e['shortname'],':tone') === 0) + continue; $texts[] = $e['shortname']; $icons[] = '' . $e['name'] . ''; } -- cgit v1.2.3 From dd6718c2cdf2cadaf7478b848eb892dcda1dc7e9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 4 Jun 2016 18:10:42 -0700 Subject: provide a hover class for smiley emojis which renders them slightly larger on compatible devices when you single them out for inspection --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 7d1e22170..1bc19da34 100644 --- a/include/text.php +++ b/include/text.php @@ -1166,7 +1166,7 @@ function list_smilies() { if(strpos($e['shortname'],':tone') === 0) continue; $texts[] = $e['shortname']; - $icons[] = '' . $e['name'] . ''; + $icons[] = '' . $e['name'] . ''; } } -- cgit v1.2.3