From 5ed020ec148c97e810075454dd91646a7d03a588 Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 16 Feb 2022 21:00:35 -0800 Subject: [PATCH 01/40] remove old updates; allow the system_channel to have admin rights --- Code/Lib/Activity.php | 20 ++- Code/Lib/Apps.php | 1 + Code/Update/_1000.php | 15 -- Code/Update/_1001.php | 27 --- Code/Update/_1002.php | 20 --- Code/Update/_1003.php | 16 -- Code/Update/_1004.php | 24 --- Code/Update/_1005.php | 13 -- Code/Update/_1006.php | 45 ----- Code/Update/_1007.php | 16 -- Code/Update/_1008.php | 16 -- Code/Update/_1009.php | 15 -- Code/Update/_1010.php | 19 -- Code/Update/_1011.php | 17 -- Code/Update/_1012.php | 17 -- Code/Update/_1013.php | 22 --- Code/Update/_1014.php | 15 -- Code/Update/_1015.php | 19 -- Code/Update/_1016.php | 40 ----- Code/Update/_1017.php | 15 -- Code/Update/_1018.php | 16 -- Code/Update/_1019.php | 15 -- Code/Update/_1020.php | 15 -- Code/Update/_1021.php | 18 -- Code/Update/_1022.php | 15 -- Code/Update/_1023.php | 15 -- Code/Update/_1024.php | 16 -- Code/Update/_1025.php | 16 -- Code/Update/_1026.php | 16 -- Code/Update/_1027.php | 16 -- Code/Update/_1028.php | 16 -- Code/Update/_1029.php | 16 -- Code/Update/_1030.php | 30 ---- Code/Update/_1031.php | 16 -- Code/Update/_1032.php | 22 --- Code/Update/_1033.php | 30 ---- Code/Update/_1034.php | 21 --- Code/Update/_1035.php | 25 --- Code/Update/_1036.php | 15 -- Code/Update/_1037.php | 30 ---- Code/Update/_1038.php | 16 -- Code/Update/_1039.php | 16 -- Code/Update/_1040.php | 17 -- Code/Update/_1041.php | 16 -- Code/Update/_1042.php | 16 -- Code/Update/_1043.php | 16 -- Code/Update/_1044.php | 16 -- Code/Update/_1045.php | 16 -- Code/Update/_1046.php | 16 -- Code/Update/_1047.php | 16 -- Code/Update/_1048.php | 29 --- Code/Update/_1049.php | 16 -- Code/Update/_1050.php | 16 -- Code/Update/_1051.php | 16 -- Code/Update/_1052.php | 15 -- Code/Update/_1053.php | 15 -- Code/Update/_1054.php | 15 -- Code/Update/_1055.php | 15 -- Code/Update/_1056.php | 16 -- Code/Update/_1057.php | 15 -- Code/Update/_1058.php | 20 --- Code/Update/_1059.php | 15 -- Code/Update/_1060.php | 25 --- Code/Update/_1061.php | 16 -- Code/Update/_1062.php | 35 ---- Code/Update/_1063.php | 17 -- Code/Update/_1064.php | 16 -- Code/Update/_1065.php | 16 -- Code/Update/_1066.php | 16 -- Code/Update/_1067.php | 15 -- Code/Update/_1068.php | 15 -- Code/Update/_1069.php | 16 -- Code/Update/_1070.php | 16 -- Code/Update/_1071.php | 16 -- Code/Update/_1072.php | 17 -- Code/Update/_1073.php | 24 --- Code/Update/_1074.php | 19 -- Code/Update/_1075.php | 17 -- Code/Update/_1076.php | 15 -- Code/Update/_1077.php | 15 -- Code/Update/_1078.php | 16 -- Code/Update/_1079.php | 15 -- Code/Update/_1080.php | 16 -- Code/Update/_1081.php | 15 -- Code/Update/_1082.php | 15 -- Code/Update/_1083.php | 16 -- Code/Update/_1084.php | 24 --- Code/Update/_1085.php | 20 --- Code/Update/_1086.php | 16 -- Code/Update/_1087.php | 18 -- Code/Update/_1088.php | 18 -- Code/Update/_1089.php | 16 -- Code/Update/_1090.php | 16 -- Code/Update/_1091.php | 13 -- Code/Update/_1092.php | 59 ------ Code/Update/_1093.php | 15 -- Code/Update/_1094.php | 16 -- Code/Update/_1095.php | 16 -- Code/Update/_1096.php | 15 -- Code/Update/_1097.php | 24 --- Code/Update/_1098.php | 26 --- Code/Update/_1099.php | 25 --- Code/Update/_1100.php | 16 -- Code/Update/_1101.php | 13 -- Code/Update/_1102.php | 17 -- Code/Update/_1103.php | 15 -- Code/Update/_1104.php | 15 -- Code/Update/_1105.php | 16 -- Code/Update/_1106.php | 15 -- Code/Update/_1107.php | 34 ---- Code/Update/_1108.php | 18 -- Code/Update/_1109.php | 17 -- Code/Update/_1110.php | 16 -- Code/Update/_1111.php | 15 -- Code/Update/_1112.php | 30 ---- Code/Update/_1113.php | 17 -- Code/Update/_1114.php | 16 -- Code/Update/_1115.php | 16 -- Code/Update/_1116.php | 12 -- Code/Update/_1117.php | 16 -- Code/Update/_1118.php | 16 -- Code/Update/_1119.php | 36 ---- Code/Update/_1120.php | 16 -- Code/Update/_1121.php | 16 -- Code/Update/_1122.php | 18 -- Code/Update/_1123.php | 18 -- Code/Update/_1124.php | 40 ----- Code/Update/_1125.php | 15 -- Code/Update/_1126.php | 16 -- Code/Update/_1127.php | 16 -- Code/Update/_1128.php | 15 -- Code/Update/_1129.php | 15 -- Code/Update/_1130.php | 30 ---- Code/Update/_1131.php | 21 --- Code/Update/_1132.php | 18 -- Code/Update/_1133.php | 38 ---- Code/Update/_1134.php | 21 --- Code/Update/_1135.php | 15 -- Code/Update/_1136.php | 18 -- Code/Update/_1137.php | 16 -- Code/Update/_1138.php | 16 -- Code/Update/_1139.php | 21 --- Code/Update/_1140.php | 29 --- Code/Update/_1141.php | 31 ---- Code/Update/_1142.php | 17 -- Code/Update/_1143.php | 17 -- Code/Update/_1144.php | 29 --- Code/Update/_1145.php | 29 --- Code/Update/_1146.php | 17 -- Code/Update/_1147.php | 17 -- Code/Update/_1148.php | 17 -- Code/Update/_1149.php | 34 ---- Code/Update/_1150.php | 27 --- Code/Update/_1151.php | 24 --- Code/Update/_1152.php | 53 ------ Code/Update/_1153.php | 17 -- Code/Update/_1154.php | 16 -- Code/Update/_1155.php | 17 -- Code/Update/_1156.php | 30 ---- Code/Update/_1157.php | 16 -- Code/Update/_1158.php | 22 --- Code/Update/_1159.php | 25 --- Code/Update/_1160.php | 15 -- Code/Update/_1161.php | 42 ----- Code/Update/_1162.php | 21 --- Code/Update/_1163.php | 22 --- Code/Update/_1164.php | 44 ----- Code/Update/_1165.php | 22 --- Code/Update/_1166.php | 16 -- Code/Update/_1167.php | 26 --- Code/Update/_1168.php | 23 --- Code/Update/_1169.php | 25 --- Code/Update/_1170.php | 21 --- Code/Update/_1171.php | 22 --- Code/Update/_1172.php | 28 --- Code/Update/_1173.php | 26 --- Code/Update/_1174.php | 31 ---- Code/Update/_1175.php | 27 --- Code/Update/_1176.php | 20 --- Code/Update/_1177.php | 65 ------- Code/Update/_1178.php | 44 ----- Code/Update/_1179.php | 47 ----- Code/Update/_1180.php | 33 ---- Code/Update/_1181.php | 14 -- Code/Update/_1182.php | 17 -- Code/Update/_1183.php | 25 --- Code/Update/_1184.php | 17 -- Code/Update/_1185.php | 17 -- Code/Update/_1186.php | 17 -- Code/Update/_1187.php | 22 --- Code/Update/_1188.php | 18 -- Code/Update/_1189.php | 22 --- Code/Update/_1190.php | 18 -- Code/Update/_1191.php | 396 ----------------------------------------- Code/Update/_1192.php | 21 --- Code/Update/_1193.php | 21 --- Code/Update/_1194.php | 23 --- Code/Update/_1195.php | 21 --- Code/Update/_1196.php | 44 ----- Code/Update/_1197.php | 17 -- Code/Update/_1198.php | 24 --- Code/Update/_1199.php | 19 -- Code/Web/WebServer.php | 5 +- boot.php | 20 ++- 204 files changed, 34 insertions(+), 4524 deletions(-) delete mode 100644 Code/Update/_1000.php delete mode 100644 Code/Update/_1001.php delete mode 100644 Code/Update/_1002.php delete mode 100644 Code/Update/_1003.php delete mode 100644 Code/Update/_1004.php delete mode 100644 Code/Update/_1005.php delete mode 100644 Code/Update/_1006.php delete mode 100644 Code/Update/_1007.php delete mode 100644 Code/Update/_1008.php delete mode 100644 Code/Update/_1009.php delete mode 100644 Code/Update/_1010.php delete mode 100644 Code/Update/_1011.php delete mode 100644 Code/Update/_1012.php delete mode 100644 Code/Update/_1013.php delete mode 100644 Code/Update/_1014.php delete mode 100644 Code/Update/_1015.php delete mode 100644 Code/Update/_1016.php delete mode 100644 Code/Update/_1017.php delete mode 100644 Code/Update/_1018.php delete mode 100644 Code/Update/_1019.php delete mode 100644 Code/Update/_1020.php delete mode 100644 Code/Update/_1021.php delete mode 100644 Code/Update/_1022.php delete mode 100644 Code/Update/_1023.php delete mode 100644 Code/Update/_1024.php delete mode 100644 Code/Update/_1025.php delete mode 100644 Code/Update/_1026.php delete mode 100644 Code/Update/_1027.php delete mode 100644 Code/Update/_1028.php delete mode 100644 Code/Update/_1029.php delete mode 100644 Code/Update/_1030.php delete mode 100644 Code/Update/_1031.php delete mode 100644 Code/Update/_1032.php delete mode 100644 Code/Update/_1033.php delete mode 100644 Code/Update/_1034.php delete mode 100644 Code/Update/_1035.php delete mode 100644 Code/Update/_1036.php delete mode 100644 Code/Update/_1037.php delete mode 100644 Code/Update/_1038.php delete mode 100644 Code/Update/_1039.php delete mode 100644 Code/Update/_1040.php delete mode 100644 Code/Update/_1041.php delete mode 100644 Code/Update/_1042.php delete mode 100644 Code/Update/_1043.php delete mode 100644 Code/Update/_1044.php delete mode 100644 Code/Update/_1045.php delete mode 100644 Code/Update/_1046.php delete mode 100644 Code/Update/_1047.php delete mode 100644 Code/Update/_1048.php delete mode 100644 Code/Update/_1049.php delete mode 100644 Code/Update/_1050.php delete mode 100644 Code/Update/_1051.php delete mode 100644 Code/Update/_1052.php delete mode 100644 Code/Update/_1053.php delete mode 100644 Code/Update/_1054.php delete mode 100644 Code/Update/_1055.php delete mode 100644 Code/Update/_1056.php delete mode 100644 Code/Update/_1057.php delete mode 100644 Code/Update/_1058.php delete mode 100644 Code/Update/_1059.php delete mode 100644 Code/Update/_1060.php delete mode 100644 Code/Update/_1061.php delete mode 100644 Code/Update/_1062.php delete mode 100644 Code/Update/_1063.php delete mode 100644 Code/Update/_1064.php delete mode 100644 Code/Update/_1065.php delete mode 100644 Code/Update/_1066.php delete mode 100644 Code/Update/_1067.php delete mode 100644 Code/Update/_1068.php delete mode 100644 Code/Update/_1069.php delete mode 100644 Code/Update/_1070.php delete mode 100644 Code/Update/_1071.php delete mode 100644 Code/Update/_1072.php delete mode 100644 Code/Update/_1073.php delete mode 100644 Code/Update/_1074.php delete mode 100644 Code/Update/_1075.php delete mode 100644 Code/Update/_1076.php delete mode 100644 Code/Update/_1077.php delete mode 100644 Code/Update/_1078.php delete mode 100644 Code/Update/_1079.php delete mode 100644 Code/Update/_1080.php delete mode 100644 Code/Update/_1081.php delete mode 100644 Code/Update/_1082.php delete mode 100644 Code/Update/_1083.php delete mode 100644 Code/Update/_1084.php delete mode 100644 Code/Update/_1085.php delete mode 100644 Code/Update/_1086.php delete mode 100644 Code/Update/_1087.php delete mode 100644 Code/Update/_1088.php delete mode 100644 Code/Update/_1089.php delete mode 100644 Code/Update/_1090.php delete mode 100644 Code/Update/_1091.php delete mode 100644 Code/Update/_1092.php delete mode 100644 Code/Update/_1093.php delete mode 100644 Code/Update/_1094.php delete mode 100644 Code/Update/_1095.php delete mode 100644 Code/Update/_1096.php delete mode 100644 Code/Update/_1097.php delete mode 100644 Code/Update/_1098.php delete mode 100644 Code/Update/_1099.php delete mode 100644 Code/Update/_1100.php delete mode 100644 Code/Update/_1101.php delete mode 100644 Code/Update/_1102.php delete mode 100644 Code/Update/_1103.php delete mode 100644 Code/Update/_1104.php delete mode 100644 Code/Update/_1105.php delete mode 100644 Code/Update/_1106.php delete mode 100644 Code/Update/_1107.php delete mode 100644 Code/Update/_1108.php delete mode 100644 Code/Update/_1109.php delete mode 100644 Code/Update/_1110.php delete mode 100644 Code/Update/_1111.php delete mode 100644 Code/Update/_1112.php delete mode 100644 Code/Update/_1113.php delete mode 100644 Code/Update/_1114.php delete mode 100644 Code/Update/_1115.php delete mode 100644 Code/Update/_1116.php delete mode 100644 Code/Update/_1117.php delete mode 100644 Code/Update/_1118.php delete mode 100644 Code/Update/_1119.php delete mode 100644 Code/Update/_1120.php delete mode 100644 Code/Update/_1121.php delete mode 100644 Code/Update/_1122.php delete mode 100644 Code/Update/_1123.php delete mode 100644 Code/Update/_1124.php delete mode 100644 Code/Update/_1125.php delete mode 100644 Code/Update/_1126.php delete mode 100644 Code/Update/_1127.php delete mode 100644 Code/Update/_1128.php delete mode 100644 Code/Update/_1129.php delete mode 100644 Code/Update/_1130.php delete mode 100644 Code/Update/_1131.php delete mode 100644 Code/Update/_1132.php delete mode 100644 Code/Update/_1133.php delete mode 100644 Code/Update/_1134.php delete mode 100644 Code/Update/_1135.php delete mode 100644 Code/Update/_1136.php delete mode 100644 Code/Update/_1137.php delete mode 100644 Code/Update/_1138.php delete mode 100644 Code/Update/_1139.php delete mode 100644 Code/Update/_1140.php delete mode 100644 Code/Update/_1141.php delete mode 100644 Code/Update/_1142.php delete mode 100644 Code/Update/_1143.php delete mode 100644 Code/Update/_1144.php delete mode 100644 Code/Update/_1145.php delete mode 100644 Code/Update/_1146.php delete mode 100644 Code/Update/_1147.php delete mode 100644 Code/Update/_1148.php delete mode 100644 Code/Update/_1149.php delete mode 100644 Code/Update/_1150.php delete mode 100644 Code/Update/_1151.php delete mode 100644 Code/Update/_1152.php delete mode 100644 Code/Update/_1153.php delete mode 100644 Code/Update/_1154.php delete mode 100644 Code/Update/_1155.php delete mode 100644 Code/Update/_1156.php delete mode 100644 Code/Update/_1157.php delete mode 100644 Code/Update/_1158.php delete mode 100644 Code/Update/_1159.php delete mode 100644 Code/Update/_1160.php delete mode 100644 Code/Update/_1161.php delete mode 100644 Code/Update/_1162.php delete mode 100644 Code/Update/_1163.php delete mode 100644 Code/Update/_1164.php delete mode 100644 Code/Update/_1165.php delete mode 100644 Code/Update/_1166.php delete mode 100644 Code/Update/_1167.php delete mode 100644 Code/Update/_1168.php delete mode 100644 Code/Update/_1169.php delete mode 100644 Code/Update/_1170.php delete mode 100644 Code/Update/_1171.php delete mode 100644 Code/Update/_1172.php delete mode 100644 Code/Update/_1173.php delete mode 100644 Code/Update/_1174.php delete mode 100644 Code/Update/_1175.php delete mode 100644 Code/Update/_1176.php delete mode 100644 Code/Update/_1177.php delete mode 100644 Code/Update/_1178.php delete mode 100644 Code/Update/_1179.php delete mode 100644 Code/Update/_1180.php delete mode 100644 Code/Update/_1181.php delete mode 100644 Code/Update/_1182.php delete mode 100644 Code/Update/_1183.php delete mode 100644 Code/Update/_1184.php delete mode 100644 Code/Update/_1185.php delete mode 100644 Code/Update/_1186.php delete mode 100644 Code/Update/_1187.php delete mode 100644 Code/Update/_1188.php delete mode 100644 Code/Update/_1189.php delete mode 100644 Code/Update/_1190.php delete mode 100644 Code/Update/_1191.php delete mode 100644 Code/Update/_1192.php delete mode 100644 Code/Update/_1193.php delete mode 100644 Code/Update/_1194.php delete mode 100644 Code/Update/_1195.php delete mode 100644 Code/Update/_1196.php delete mode 100644 Code/Update/_1197.php delete mode 100644 Code/Update/_1198.php delete mode 100644 Code/Update/_1199.php diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index df4d75e1b..f7546e25f 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -1751,7 +1751,7 @@ class Activity // information $ret = self::encode_person($sys, true, true); - $ret['type'] = ((Channel::is_group($sys['channel_id'])) ? 'Group' : 'Service'); + $ret['type'] = self::xchan_type_to_type(intval($sys['xchan_type'])); $ret['id'] = z_root(); $ret['alsoKnownAs'] = z_root() . '/channel/sys'; $auto_follow = false; @@ -3044,7 +3044,7 @@ class Activity if ( $generator && array_key_exists('type', $generator) - && in_array($generator['type'], ['Application', 'Service']) && array_key_exists('name', $generator) + && in_array($generator['type'], ['Application', 'Service', 'Organization']) && array_key_exists('name', $generator) ) { $s['app'] = escape_tags($generator['name']); } @@ -4267,6 +4267,22 @@ class Activity } } + public static function xchan_type_to_type($type) + { + switch ($type) { + case XCHAN_TYPE_GROUP; + return 'Group'; + case XCHAN_TYPE_SERVICE; + return 'Service'; + case XCHAN_TYPE_ORGANIZATION; + return 'Organization'; + case XCHAN_TYPE_APPLICATION; + return 'Application'; + default: + return 'Person'; + } + } + public static function get_cached_actor($id) { return (XConfig::Get($id, 'system', 'actor_record')); diff --git a/Code/Lib/Apps.php b/Code/Lib/Apps.php index 65d3f0063..9ef0bdcb4 100644 --- a/Code/Lib/Apps.php +++ b/Code/Lib/Apps.php @@ -76,6 +76,7 @@ class Apps } $default_apps = [ + 'Admin', 'Channel Home', 'Connections', 'Directory', diff --git a/Code/Update/_1000.php b/Code/Update/_1000.php deleted file mode 100644 index 51aa6f385..000000000 --- a/Code/Update/_1000.php +++ /dev/null @@ -1,15 +0,0 @@ - 0 "); - - if ($r1 && $r2 && $r3) { - return UPDATE_SUCCESS; - } - return UPDATE_FAILED; - } -} diff --git a/Code/Update/_1137.php b/Code/Update/_1137.php deleted file mode 100644 index 4a351c529..000000000 --- a/Code/Update/_1137.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Thu, 17 Feb 2022 12:08:59 -0800 Subject: [PATCH 02/40] more site channel stuff --- Code/Lib/Channel.php | 25 +- Code/Lib/System.php | 9 +- boot.php | 2748 +++++++++++++++++++++--------------------- composer.json | 22 +- 4 files changed, 1404 insertions(+), 1400 deletions(-) diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index fb2131798..789f40434 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -89,9 +89,25 @@ class Channel $sys = self::get_system(); if ($sys) { - if (isset($sys['channel_pubkey']) && $sys['channel_pubkey'] === get_config('system', 'pubkey')) { - return; - } else { + // upgrade the default network drivers if this looks like an upgraded zot6-based platform. + + if ($sys['xchan_network'] !== 'nomad') { + $chans = q("select * from channel where true"); + if ($chans) { + foreach ($chans as $chan) { + q("update hubloc set hubloc_network = 'nomad' where xchan_hash = '%s'", + dbesc($chan['channel_hash']) + ); + q("update hubloc set xchan_network = 'nomad' where xchan_hash = '%s'", + dbesc($chan['channel_hash']) + ); + } + } + } + + // fix lost system keys, since we cannot communicate without them + + if (!(isset($sys['channel_pubkey']) && $sys['channel_pubkey'] === get_config('system', 'pubkey'))) { // upgrade the sys channel and return $pubkey = get_config('system', 'pubkey'); $prvkey = get_config('system', 'prvkey'); @@ -139,8 +155,9 @@ class Channel dbesc($sys['channel_hash']) ); - return; } + App::$sys_channel = $sys; + return; } self::create([ diff --git a/Code/Lib/System.php b/Code/Lib/System.php index cb3f2922b..f96a67cff 100644 --- a/Code/Lib/System.php +++ b/Code/Lib/System.php @@ -20,8 +20,8 @@ class System public static function get_site_name() { - if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['sitename']) { - return App::$config['system']['sitename']; + if (is_array(App::$sys_channel) && isset(App::$sys_channel['channel_name'])) { + return App::$sys_channel['channel_name']; } return ''; } @@ -52,9 +52,8 @@ class System public static function get_project_icon() { - $sys = Channel::get_system(); - if ($sys) { - return z_root() . '/photo/profile/l/' . $sys['channel_id']; + if (isset(App::$sys_channel['xchan_photo_l'])) { + return App::$sys_channel['xchan_photo_l']); } if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('icon', App::$config['system'])) { return App::$config['system']['icon']; diff --git a/boot.php b/boot.php index 261443015..bf13518f3 100755 --- a/boot.php +++ b/boot.php @@ -16,7 +16,7 @@ use Code\Lib\Navbar; use Code\Lib\Stringsjs; use Code\Extend\Hook; use Code\Lib\Head; - + /** * @file boot.php * @@ -41,10 +41,10 @@ define ( 'ACTIVITYPUB_ENABLED', true ); require_once('vendor/autoload.php'); if (file_exists('addon/vendor/autoload.php')) { - require_once('addon/vendor/autoload.php'); + require_once('addon/vendor/autoload.php'); } if (file_exists('addon/version.php')) { - require_once('addon/version.php'); + require_once('addon/version.php'); } require_once('include/config.php'); @@ -77,7 +77,7 @@ define ( 'TEMPLATE_BUILD_PATH', 'cache/smarty3' ); //define ( 'USE_BEARCAPS', true); -// Many of these directory settings are no longer used, but may still be referenced in code. +// Many of these directory settings are no longer used, but may still be referenced in code. // The only ones of consequence in 2021 are DIRECTORY_MODE_NORMAL and DIRECTORY_MODE_STANDALONE. define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // A directory client @@ -141,13 +141,13 @@ define ('MAX_EVENT_REPEAT_COUNT', 512); */ if (! defined('STORAGE_DEFAULT_PERMISSIONS')) { - define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 ); + define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 ); } // imported followers for friend suggestions. if (! defined('MAX_IMPORTED_FOLLOW')) { - define ( 'MAX_IMPORTED_FOLLOW', 10); + define ( 'MAX_IMPORTED_FOLLOW', 10); } /** @@ -232,7 +232,7 @@ define ( 'PAGE_ADULT', 0x0020 ); define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds define ( 'PAGE_SYSTEM', 0x1000 ); define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the - // default channel of any accounts with the admin role. + // default channel of any accounts with the admin role. define ( 'PAGE_REMOVED', 0x8000 ); @@ -261,7 +261,7 @@ define ( 'PHOTO_RES_PROFILE_48', 6 ); // square 48 px define ( 'PHOTO_RES_COVER_1200', 7 ); // 1200w x 435h (2.75:1) define ( 'PHOTO_RES_COVER_850', 8 ); // 850w x 310h -define ( 'PHOTO_RES_COVER_425', 9 ); // 425w x 160h +define ( 'PHOTO_RES_COVER_425', 9 ); // 425w x 160h /** @@ -600,11 +600,11 @@ define ( 'ITEM_MODERATED', 0x0004); define ( 'ITEM_SPAM', 0x0008); define ( 'ITEM_DELETED', 0x0010); define ( 'ITEM_UNPUBLISHED', 0x0020); -define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item +define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item define ( 'ITEM_DELAYED_PUBLISH', 0x0080); -define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED -define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche -define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker +define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED +define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche +define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed define ( 'ITEM_DOC', 0x1000); // hubzilla only, define here so that item import does the right thing define ( 'ITEM_CARD', 0x2000); @@ -634,99 +634,99 @@ define ( 'DBTYPE_POSTGRES', 1 ); function sys_boot() { - // this file may not exist - - @include('.htstartup.php'); + // this file may not exist - // our central App object + @include('.htstartup.php'); - App::init(); + // our central App object - /* - * Load the configuration file which contains our DB credentials. - * Ignore errors. If the file doesn't exist or is empty, we are running in - * installation mode. - */ + App::init(); - App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); + /* + * Load the configuration file which contains our DB credentials. + * Ignore errors. If the file doesn't exist or is empty, we are running in + * installation mode. + */ + + App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); $db_host = $db_user = $db_pass = $db_data = EMPTY_STR; $db_port = $db_type = 0; - @include('.htconfig.php'); + @include('.htconfig.php'); - // allow somebody to set some initial settings + // allow somebody to set some initial settings - if (file_exists('.htpreconfig.php')) { - @include('.htpreconfig.php'); - } + if (file_exists('.htpreconfig.php')) { + @include('.htpreconfig.php'); + } - if (isset($default_timezone)) { - App::$config['system']['timezone'] = $default_timezone; - } + if (isset($default_timezone)) { + App::$config['system']['timezone'] = $default_timezone; + } - App::$timezone = (isset(App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC'); - date_default_timezone_set(App::$timezone); + App::$timezone = (isset(App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC'); + date_default_timezone_set(App::$timezone); - if (! defined('DEFAULT_PLATFORM_ICON')) { - define( 'DEFAULT_PLATFORM_ICON', '/images/z1-32.png' ); - } + if (! defined('DEFAULT_PLATFORM_ICON')) { + define( 'DEFAULT_PLATFORM_ICON', '/images/z1-32.png' ); + } - if (! defined('DEFAULT_NOTIFY_ICON')) { - define( 'DEFAULT_NOTIFY_ICON', '/images/z1-64.png' ); - } + if (! defined('DEFAULT_NOTIFY_ICON')) { + define( 'DEFAULT_NOTIFY_ICON', '/images/z1-64.png' ); + } - /* - * Try to open the database; - */ + /* + * Try to open the database; + */ - require_once('include/dba/dba_driver.php'); + require_once('include/dba/dba_driver.php'); - if (! App::$install) { - DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install); - if (! DBA::$dba->connected) { - system_unavailable(); - } + if (! App::$install) { + DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install); + if (! DBA::$dba->connected) { + system_unavailable(); + } - unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); + unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); - /* - * Load configs from db. Overwrite configs from .htconfig.php - */ + /* + * Load configs from db. Overwrite configs from .htconfig.php + */ - load_config('system'); - load_config('feature'); + load_config('system'); + load_config('feature'); - App::$session = new Session(); - App::$session->init(); - Hook::load(); - /** - * @hooks 'startup' - */ - $arr = []; - Hook::call('startup',$arr); - } + App::$session = new Session(); + App::$session->init(); + Hook::load(); + /** + * @hooks 'startup' + */ + $arr = []; + Hook::call('startup',$arr); + } } function startup() { - error_reporting(E_ERROR | E_PARSE); + error_reporting(E_ERROR | E_PARSE); - // Some hosting providers block/disable this - @set_time_limit(0); + // Some hosting providers block/disable this + @set_time_limit(0); - if (function_exists ('ini_set')) { - // This has to be quite large - @ini_set('pcre.backtrack_limit', 5000000); + if (function_exists ('ini_set')) { + // This has to be quite large + @ini_set('pcre.backtrack_limit', 5000000); - // Use cookies to store the session ID on the client side - @ini_set('session.use_only_cookies', 1); + // Use cookies to store the session ID on the client side + @ini_set('session.use_only_cookies', 1); - // Disable transparent Session ID support - @ini_set('session.use_trans_sid', 0); - } + // Disable transparent Session ID support + @ini_set('session.use_trans_sid', 0); + } } @@ -744,591 +744,591 @@ function startup() { */ class App { - public static $install = false; // true if we are installing the software - public static $account = null; // account record of the logged-in account - public static $channel = null; // channel record of the current channel of the logged-in account - public static $observer = null; // xchan record of the page observer - public static $profile_uid = 0; // If applicable, the channel_id of the "page owner" - public static $sys_channel = null; // cache sys channel lookups here - public static $poi = null; // "person of interest", generally a referenced connection or directory entry - private static $oauth_key = null; // consumer_id of oauth request, if used - public static $layout = []; // Comanche parsed template - public static $pdl = null; // Comanche page description - private static $perms = null; // observer permissions - private static $widgets = []; // widgets for this page - public static $config = []; // config cache - - public static $override_intltext_templates = []; - public static $override_markup_templates = []; - public static $override_templateroot = null; - public static $override_helproot = null; - public static $override_helpfiles = []; - - public static $session = null; - public static $groups; - public static $language; - public static $langsave; - public static $rtl = false; - public static $addons_admin; - public static $module_loaded = false; - public static $query_string; - public static $page; - public static $profile; - public static $user; - public static $cid; - public static $contact; - public static $contacts; - public static $content; - public static $data = []; - public static $error = false; - public static $emojitab = false; - public static $cmd; - public static $argv; - public static $argc; - public static $module; - public static $pager; - public static $strings; - public static $stringsave; // used in push_lang() and pop_lang() - public static $hooks; - public static $timezone; - public static $interactive = true; - public static $addons; - private static $apps = []; - public static $identities; - public static $css_sources = []; - public static $js_sources = []; - public static $linkrel = []; - public static $theme_info = []; - public static $is_sys = false; - public static $nav_sel; - public static $comanche; - public static $httpheaders = null; - public static $httpsig = null; - public static $channel_links; - public static $category; - - // Allow themes to control internal parameters - // by changing App values in theme.php - - public static $sourcename = ''; - public static $videowidth = 425; - public static $videoheight = 350; - public static $force_max_items = 0; - public static $theme_thread_allow = true; - - public static $meta; - - /** - * @brief An array for all theme-controllable parameters - * - * Mostly unimplemented yet. Only options 'template_engine' and - * beyond are used. - */ - private static $theme = [ - 'sourcename' => '', - 'videowidth' => 425, - 'videoheight' => 350, - 'force_max_items' => 0, - 'thread_allow' => true, - 'stylesheet' => '', - 'template_engine' => 'smarty3', - ]; - - /** - * @brief An array of registered template engines ('name'=>'class name') - */ - public static $template_engines = []; - /** - * @brief An array of instanced template engines ('name'=>'instance') - */ - public static $template_engine_instance = []; - - private static $ldelim = [ - 'internal' => '', - 'smarty3' => '{{' - ]; - private static $rdelim = [ - 'internal' => '', - 'smarty3' => '}}' - ]; - - // These represent the URL which was used to access the page - - private static $scheme; - private static $hostname; - private static $path; - - // This is our standardised URL - regardless of what was used - // to access the page - - private static $baseurl; - - /** - * App constructor. - */ - - public static function init() { - // we'll reset this after we read our config file - date_default_timezone_set('UTC'); - - self::$config = [ - 'system' => [] - ]; - self::$page = []; - self::$pager= []; - - self::$query_string = ''; - - startup(); - - set_include_path( - 'include' . PATH_SEPARATOR - . 'library' . PATH_SEPARATOR - . '.' - ); - - // normally self::$hostname (also scheme and port) will be filled in during startup. - // Set it manually from $_SERVER variables only if it wasn't. - - if (! self::$hostname) { - self::$hostname = punify(get_host()); - self::$scheme = 'http'; - - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { - self::$scheme = 'https'; - } - elseif (isset($_SERVER['SERVER_PORT']) && (intval($_SERVER['SERVER_PORT']) === 443)) { - self::$scheme = 'https'; - } - - if (isset($_SERVER['SERVER_PORT']) && intval($_SERVER['SERVER_PORT']) !== 80 && intval($_SERVER['SERVER_PORT']) !== 443) { - self::$hostname .= ':' . $_SERVER['SERVER_PORT']; - } - } - - /* - * Figure out if we are running at the top of a domain - * or in a sub-directory and adjust accordingly - */ - $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\'); - if (isset($path) && strlen($path) && ($path != self::$path)) { - self::$path = $path; - } - - // Rewrite rules on the server will convert incoming paths to a request parameter. - // Strip this path information from our stored copy of the query_string, in case - // we need to re-use the rest of the original query. - - if (isset($_SERVER['QUERY_STRING']) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") { - self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4)); - // removing leading '/' - maybe a nginx problem - if (substr(self::$query_string, 0, 1) == "/") { - self::$query_string = substr(self::$query_string, 1); - } - // change the first & to ? - self::$query_string = preg_replace('/&/','?',self::$query_string,1); - } - - // Here is where start breaking out the URL path information to both route the - // web request based on the leading path component, and also to use remaining - // path components as C-style arguments to our individual controller modules. - - if (isset($_GET['req'])) { - self::$cmd = escape_tags(trim($_GET['req'],'/\\')); - } - - // support both unix and fediverse style "homedir" - - if ((substr(self::$cmd, 0, 1) === '~') || (substr(self::$cmd, 0, 1) === '@')) { - self::$cmd = 'channel/' . substr(self::$cmd, 1); - } - - /* - * Break the URL path into C style argc/argv style arguments for our - * modules. Given "http://example.com/module/arg1/arg2", self::$argc - * will be 3 (integer) and self::$argv will contain: - * [0] => 'module' - * [1] => 'arg1' - * [2] => 'arg2' - * - * There will always be one argument. If provided a naked domain - * URL, self::$argv[0] is set to "home". - * - * If $argv[0] has a period in it, for example foo.json; rewrite - * to module = 'foo' and set $_REQUEST['module_format'] = 'json'; - * - * As a result, say you offered a feed for member bob. Most applications - * would address it as /feed/bob.xml or /feed/bob.json - * We would address it as /feed.xml/bob and /feed.json/bob because - * you're altering the output format of the feed module, and bob is - * just an identifier or variable. - */ - - self::$argv = explode('/', self::$cmd); - - self::$argc = count(self::$argv); - if ((array_key_exists('0', self::$argv)) && strlen(self::$argv[0])) { - if(strpos(self::$argv[0],'.')) { - $_REQUEST['module_format'] = substr(self::$argv[0],strpos(self::$argv[0],'.')+1); - self::$argv[0] = substr(self::$argv[0],0,strpos(self::$argv[0],'.')); - } - - self::$module = str_replace(".", "_", self::$argv[0]); - self::$module = str_replace("-", "_", self::$module); - if(strpos(self::$module,'_') === 0) - self::$module = substr(self::$module,1); - } else { - self::$argc = 1; - self::$argv = array('home'); - self::$module = 'home'; - } - - - /* - * See if there is any page number information, and initialise - * pagination - */ - - self::$pager['unset'] = ((array_key_exists('page',$_REQUEST)) ? false : true); - self::$pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1); - self::$pager['itemspage'] = 60; - self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage']; - self::$pager['total'] = 0; - - if (self::$pager['start'] < 0) { - self::$pager['start'] = 0; - } - - self::$meta = new HttpMeta(); - - /* - * register template engines (probably just smarty, but this can be extended) - */ - - self::register_template_engine(get_class(new SmartyTemplate())); - - } - - public static function get_baseurl($ssl = false) { - if(is_array(self::$config) - && array_key_exists('system',self::$config) - && is_array(self::$config['system']) - && array_key_exists('baseurl',self::$config['system']) - && strlen(self::$config['system']['baseurl'])) { - // get_baseurl() is a heavily used function. - // Do not use punify() here until we find a library that performs better than what we have now. - // $url = punify(self::$config['system']['baseurl']); - $url = self::$config['system']['baseurl']; - $url = trim($url,'\\/'); - return $url; - } - - $scheme = self::$scheme; - - self::$baseurl = $scheme . "://" . punify(self::$hostname) . ((isset(self::$path) && strlen(self::$path)) ? '/' . self::$path : '' ); - - return self::$baseurl; - } - - public static function set_baseurl($url) { - if(is_array(self::$config) - && array_key_exists('system',self::$config) - && is_array(self::$config['system']) - && array_key_exists('baseurl',self::$config['system']) - && strlen(self::$config['system']['baseurl'])) { - $url = punify(self::$config['system']['baseurl']); - $url = trim($url,'\\/'); - } - - $parsed = @parse_url($url); - - self::$baseurl = $url; - - if($parsed !== false) { - self::$scheme = $parsed['scheme']; - - self::$hostname = punify($parsed['host']); - if(x($parsed,'port')) - self::$hostname .= ':' . $parsed['port']; - if(x($parsed,'path')) - self::$path = trim($parsed['path'],'\\/'); - } - } - - public static function get_scheme() { - return self::$scheme; - } - - public static function get_hostname() { - return self::$hostname; - } - - public static function set_hostname($h) { - self::$hostname = $h; - } - - public static function set_path($p) { - self::$path = trim(trim($p), '/'); - } - - public static function get_path() { - return self::$path; - } - - public static function get_channel_links() { - $s = ''; - $x = self::$channel_links; - if ($x && is_array($x) && count($x)) { - foreach ($x as $y) { - if ($s) { - $s .= ','; - } - $s .= '<' . $y['href'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"'; - } - } - return $s; - } - public static function set_account($acct) { - self::$account = $acct; - } - - public static function get_account() { - return self::$account; - } - - public static function set_channel($channel) { - self::$channel = $channel; - } - - public static function get_channel() { - return self::$channel; - } - - public static function set_observer($xchan) { - self::$observer = $xchan; - } - - - public static function get_observer() { - return self::$observer; - } - - public static function set_perms($perms) { - self::$perms = $perms; - } - - public static function get_perms() { - return self::$perms; - } - - public static function set_oauth_key($consumer_id) { - self::$oauth_key = $consumer_id; - } - - public static function get_oauth_key() { - return self::$oauth_key; - } - - public static function get_apps() { - return self::$apps; - } - - public static function set_apps($arr) { - self::$apps = $arr; - } - - public static function set_groups($g) { - self::$groups = $g; - } - - public static function get_groups() { - return self::$groups; - } - - public static function set_pager_total($n) { - self::$pager['total'] = intval($n); - } - - public static function set_pager_itemspage($n) { - self::$pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0); - self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage']; - } - - public static function build_pagehead() { - - $user_scalable = ((local_channel()) ? get_pconfig(local_channel(),'system','user_scalable', 0) : 0); - - $preload_images = ((local_channel()) ? get_pconfig(local_channel(),'system','preload_images',0) : 0); - - - $interval = ((local_channel()) ? get_pconfig(local_channel(),'system','update_interval', 30000) : 30000); - if ($interval < 15000) { - $interval = 15000; - } - - $alerts_interval = intval(get_config('system','alerts_interval',10000)); - if ($alerts_interval < 5000) { - $alerts_interval = 5000; - } - - if (! x(self::$page,'title')) { - self::$page['title'] = ((array_path_exists('system/sitename',self::$config)) ? self::$config['system']['sitename'] : EMPTY_STR); - } - - if (! self::$meta->get_field('og:title')) { - self::$meta->set('og:title',self::$page['title']); - } - - // webmanifest - - Head::add_link( [ 'rel' => 'manifest', 'href' => z_root() . '/manifest.webmanifest' ] ); - self::$meta->set('application-name', System::get_platform_name() ); - - self::$meta->set('generator', System::get_platform_name()); - - $i = head_get_icon(); - if (! $i) { - $i = System::get_site_icon(); - } - if ($i) { - Head::add_link(['rel' => 'shortcut icon', 'href' => $i ]); - Head::add_link(['rel' => 'icon', 'sizes' => '64x64', 'href' => System::get_site_icon() ]); - Head::add_link(['rel' => 'icon', 'sizes' => '192x192', 'href' => 'images/' . System::get_platform_name() . '.svg' ]); - } - - $x = [ 'header' => '' ]; - /** - * @hooks build_pagehead - * Called when creating the HTML page header. - * * \e string \b header - Return the HTML header which should be added - */ - Hook::call('build_pagehead', $x); - - /* put the head template at the beginning of page['htmlhead'] - * since the code added by the modules frequently depends on it - * being first - */ - - if (! isset(self::$page['htmlhead'])) { - self::$page['htmlhead'] = EMPTY_STR; // needed to silence warning - } - - self::$page['htmlhead'] = replace_macros(Theme::get_template('head.tpl'), - [ - '$preload_images' => $preload_images, - '$user_scalable' => $user_scalable, - '$query' => urlencode(self::$query_string), - '$baseurl' => self::get_baseurl(), - '$local_channel' => local_channel(), - '$metas' => self::$meta->get(), - '$plugins' => $x['header'], - '$update_interval' => $interval, - '$alerts_interval' => $alerts_interval, - '$head_css' => Head::get_css(), - '$head_js' => Head::get_js(), - '$linkrel' => Head::get_links(), - '$js_strings' => Stringsjs::strings(), - '$zid' => Channel::get_my_address(), - '$channel_id' => ((isset(self::$profile) && is_array(self::$profile) && array_key_exists('uid',self::$profile)) ? self::$profile['uid'] : '') - ] - ) . self::$page['htmlhead']; - - // always put main.js at the end - self::$page['htmlhead'] .= Head::get_main_js(); - } - - /** - * @brief Register template engine class. - * - * If $name is "", is used class static property $class::$name. - * - * @param string $class - * @param string $name - */ - public static function register_template_engine($class, $name = '') { - if (! $name) { - $v = get_class_vars($class); - if (x($v, "name")) { - $name = $v['name']; - } - } - if (! $name) { - echo "template engine $class cannot be registered without a name.\n"; - killme(); - } - self::$template_engines[$name] = $class; - } - - /** - * @brief Return template engine instance. - * - * If $name is not defined, return engine defined by theme, or default. - * - * @param string $name Template engine name - * - * @return void Template Engine instance - */ - public static function template_engine($name = '') { - if ($name !== '') { - $template_engine = $name; - } - else { - $template_engine = 'smarty3'; - if (x(self::$theme, 'template_engine')) { - $template_engine = self::$theme['template_engine']; - } - } - - if (isset(self::$template_engines[$template_engine])) { - if (isset(self::$template_engine_instance[$template_engine])) { - return self::$template_engine_instance[$template_engine]; - } - else { - $class = self::$template_engines[$template_engine]; - $obj = new $class(); - self::$template_engine_instance[$template_engine] = $obj; - return $obj; - } - } - - // If we fell through to this step, it is considered fatal. - - echo "template engine $template_engine is not registered!\n"; - killme(); - } - - /** - * @brief Returns the active template engine. - * - * @return string - */ - public static function get_template_engine() { - return self::$theme['template_engine']; - } - - public static function set_template_engine($engine = 'smarty3') { - self::$theme['template_engine'] = $engine; - } - - public static function get_template_ldelim($engine = 'smarty3') { - return self::$ldelim[$engine]; - } - - public static function get_template_rdelim($engine = 'smarty3') { - return self::$rdelim[$engine]; - } - - public static function head_set_icon($icon) { - self::$data['pageicon'] = $icon; - } - - public static function head_get_icon() { - $icon = self::$data['pageicon']; - if ($icon && ! strpos($icon,'://')) { - $icon = z_root() . $icon; - } - return $icon; - } + public static $install = false; // true if we are installing the software + public static $account = null; // account record of the logged-in account + public static $channel = null; // channel record of the current channel of the logged-in account + public static $observer = null; // xchan record of the page observer + public static $profile_uid = 0; // If applicable, the channel_id of the "page owner" + public static $sys_channel = null; // cache sys channel lookups here + public static $poi = null; // "person of interest", generally a referenced connection or directory entry + private static $oauth_key = null; // consumer_id of oauth request, if used + public static $layout = []; // Comanche parsed template + public static $pdl = null; // Comanche page description + private static $perms = null; // observer permissions + private static $widgets = []; // widgets for this page + public static $config = []; // config cache + + public static $override_intltext_templates = []; + public static $override_markup_templates = []; + public static $override_templateroot = null; + public static $override_helproot = null; + public static $override_helpfiles = []; + + public static $session = null; + public static $groups; + public static $language; + public static $langsave; + public static $rtl = false; + public static $addons_admin; + public static $module_loaded = false; + public static $query_string; + public static $page; + public static $profile; + public static $user; + public static $cid; + public static $contact; + public static $contacts; + public static $content; + public static $data = []; + public static $error = false; + public static $emojitab = false; + public static $cmd; + public static $argv; + public static $argc; + public static $module; + public static $pager; + public static $strings; + public static $stringsave; // used in push_lang() and pop_lang() + public static $hooks; + public static $timezone; + public static $interactive = true; + public static $addons; + private static $apps = []; + public static $identities; + public static $css_sources = []; + public static $js_sources = []; + public static $linkrel = []; + public static $theme_info = []; + public static $is_sys = false; + public static $nav_sel; + public static $comanche; + public static $httpheaders = null; + public static $httpsig = null; + public static $channel_links; + public static $category; + + // Allow themes to control internal parameters + // by changing App values in theme.php + + public static $sourcename = ''; + public static $videowidth = 425; + public static $videoheight = 350; + public static $force_max_items = 0; + public static $theme_thread_allow = true; + + public static $meta; + + /** + * @brief An array for all theme-controllable parameters + * + * Mostly unimplemented yet. Only options 'template_engine' and + * beyond are used. + */ + private static $theme = [ + 'sourcename' => '', + 'videowidth' => 425, + 'videoheight' => 350, + 'force_max_items' => 0, + 'thread_allow' => true, + 'stylesheet' => '', + 'template_engine' => 'smarty3', + ]; + + /** + * @brief An array of registered template engines ('name'=>'class name') + */ + public static $template_engines = []; + /** + * @brief An array of instanced template engines ('name'=>'instance') + */ + public static $template_engine_instance = []; + + private static $ldelim = [ + 'internal' => '', + 'smarty3' => '{{' + ]; + private static $rdelim = [ + 'internal' => '', + 'smarty3' => '}}' + ]; + + // These represent the URL which was used to access the page + + private static $scheme; + private static $hostname; + private static $path; + + // This is our standardised URL - regardless of what was used + // to access the page + + private static $baseurl; + + /** + * App constructor. + */ + + public static function init() { + // we'll reset this after we read our config file + date_default_timezone_set('UTC'); + + self::$config = [ + 'system' => [] + ]; + self::$page = []; + self::$pager= []; + + self::$query_string = ''; + + startup(); + + set_include_path( + 'include' . PATH_SEPARATOR + . 'library' . PATH_SEPARATOR + . '.' + ); + + // normally self::$hostname (also scheme and port) will be filled in during startup. + // Set it manually from $_SERVER variables only if it wasn't. + + if (! self::$hostname) { + self::$hostname = punify(get_host()); + self::$scheme = 'http'; + + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { + self::$scheme = 'https'; + } + elseif (isset($_SERVER['SERVER_PORT']) && (intval($_SERVER['SERVER_PORT']) === 443)) { + self::$scheme = 'https'; + } + + if (isset($_SERVER['SERVER_PORT']) && intval($_SERVER['SERVER_PORT']) !== 80 && intval($_SERVER['SERVER_PORT']) !== 443) { + self::$hostname .= ':' . $_SERVER['SERVER_PORT']; + } + } + + /* + * Figure out if we are running at the top of a domain + * or in a sub-directory and adjust accordingly + */ + $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\'); + if (isset($path) && strlen($path) && ($path != self::$path)) { + self::$path = $path; + } + + // Rewrite rules on the server will convert incoming paths to a request parameter. + // Strip this path information from our stored copy of the query_string, in case + // we need to re-use the rest of the original query. + + if (isset($_SERVER['QUERY_STRING']) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") { + self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4)); + // removing leading '/' - maybe a nginx problem + if (substr(self::$query_string, 0, 1) == "/") { + self::$query_string = substr(self::$query_string, 1); + } + // change the first & to ? + self::$query_string = preg_replace('/&/','?',self::$query_string,1); + } + + // Here is where start breaking out the URL path information to both route the + // web request based on the leading path component, and also to use remaining + // path components as C-style arguments to our individual controller modules. + + if (isset($_GET['req'])) { + self::$cmd = escape_tags(trim($_GET['req'],'/\\')); + } + + // support both unix and fediverse style "homedir" + + if ((substr(self::$cmd, 0, 1) === '~') || (substr(self::$cmd, 0, 1) === '@')) { + self::$cmd = 'channel/' . substr(self::$cmd, 1); + } + + /* + * Break the URL path into C style argc/argv style arguments for our + * modules. Given "http://example.com/module/arg1/arg2", self::$argc + * will be 3 (integer) and self::$argv will contain: + * [0] => 'module' + * [1] => 'arg1' + * [2] => 'arg2' + * + * There will always be one argument. If provided a naked domain + * URL, self::$argv[0] is set to "home". + * + * If $argv[0] has a period in it, for example foo.json; rewrite + * to module = 'foo' and set $_REQUEST['module_format'] = 'json'; + * + * As a result, say you offered a feed for member bob. Most applications + * would address it as /feed/bob.xml or /feed/bob.json + * We would address it as /feed.xml/bob and /feed.json/bob because + * you're altering the output format of the feed module, and bob is + * just an identifier or variable. + */ + + self::$argv = explode('/', self::$cmd); + + self::$argc = count(self::$argv); + if ((array_key_exists('0', self::$argv)) && strlen(self::$argv[0])) { + if(strpos(self::$argv[0],'.')) { + $_REQUEST['module_format'] = substr(self::$argv[0],strpos(self::$argv[0],'.')+1); + self::$argv[0] = substr(self::$argv[0],0,strpos(self::$argv[0],'.')); + } + + self::$module = str_replace(".", "_", self::$argv[0]); + self::$module = str_replace("-", "_", self::$module); + if(strpos(self::$module,'_') === 0) + self::$module = substr(self::$module,1); + } else { + self::$argc = 1; + self::$argv = array('home'); + self::$module = 'home'; + } + + + /* + * See if there is any page number information, and initialise + * pagination + */ + + self::$pager['unset'] = ((array_key_exists('page',$_REQUEST)) ? false : true); + self::$pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1); + self::$pager['itemspage'] = 60; + self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage']; + self::$pager['total'] = 0; + + if (self::$pager['start'] < 0) { + self::$pager['start'] = 0; + } + + self::$meta = new HttpMeta(); + + /* + * register template engines (probably just smarty, but this can be extended) + */ + + self::register_template_engine(get_class(new SmartyTemplate())); + + } + + public static function get_baseurl($ssl = false) { + if(is_array(self::$config) + && array_key_exists('system',self::$config) + && is_array(self::$config['system']) + && array_key_exists('baseurl',self::$config['system']) + && strlen(self::$config['system']['baseurl'])) { + // get_baseurl() is a heavily used function. + // Do not use punify() here until we find a library that performs better than what we have now. + // $url = punify(self::$config['system']['baseurl']); + $url = self::$config['system']['baseurl']; + $url = trim($url,'\\/'); + return $url; + } + + $scheme = self::$scheme; + + self::$baseurl = $scheme . "://" . punify(self::$hostname) . ((isset(self::$path) && strlen(self::$path)) ? '/' . self::$path : '' ); + + return self::$baseurl; + } + + public static function set_baseurl($url) { + if(is_array(self::$config) + && array_key_exists('system',self::$config) + && is_array(self::$config['system']) + && array_key_exists('baseurl',self::$config['system']) + && strlen(self::$config['system']['baseurl'])) { + $url = punify(self::$config['system']['baseurl']); + $url = trim($url,'\\/'); + } + + $parsed = @parse_url($url); + + self::$baseurl = $url; + + if($parsed !== false) { + self::$scheme = $parsed['scheme']; + + self::$hostname = punify($parsed['host']); + if(x($parsed,'port')) + self::$hostname .= ':' . $parsed['port']; + if(x($parsed,'path')) + self::$path = trim($parsed['path'],'\\/'); + } + } + + public static function get_scheme() { + return self::$scheme; + } + + public static function get_hostname() { + return self::$hostname; + } + + public static function set_hostname($h) { + self::$hostname = $h; + } + + public static function set_path($p) { + self::$path = trim(trim($p), '/'); + } + + public static function get_path() { + return self::$path; + } + + public static function get_channel_links() { + $s = ''; + $x = self::$channel_links; + if ($x && is_array($x) && count($x)) { + foreach ($x as $y) { + if ($s) { + $s .= ','; + } + $s .= '<' . $y['href'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"'; + } + } + return $s; + } + public static function set_account($acct) { + self::$account = $acct; + } + + public static function get_account() { + return self::$account; + } + + public static function set_channel($channel) { + self::$channel = $channel; + } + + public static function get_channel() { + return self::$channel; + } + + public static function set_observer($xchan) { + self::$observer = $xchan; + } + + + public static function get_observer() { + return self::$observer; + } + + public static function set_perms($perms) { + self::$perms = $perms; + } + + public static function get_perms() { + return self::$perms; + } + + public static function set_oauth_key($consumer_id) { + self::$oauth_key = $consumer_id; + } + + public static function get_oauth_key() { + return self::$oauth_key; + } + + public static function get_apps() { + return self::$apps; + } + + public static function set_apps($arr) { + self::$apps = $arr; + } + + public static function set_groups($g) { + self::$groups = $g; + } + + public static function get_groups() { + return self::$groups; + } + + public static function set_pager_total($n) { + self::$pager['total'] = intval($n); + } + + public static function set_pager_itemspage($n) { + self::$pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0); + self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage']; + } + + public static function build_pagehead() { + + $user_scalable = ((local_channel()) ? get_pconfig(local_channel(),'system','user_scalable', 0) : 0); + + $preload_images = ((local_channel()) ? get_pconfig(local_channel(),'system','preload_images',0) : 0); + + + $interval = ((local_channel()) ? get_pconfig(local_channel(),'system','update_interval', 30000) : 30000); + if ($interval < 15000) { + $interval = 15000; + } + + $alerts_interval = intval(get_config('system','alerts_interval',10000)); + if ($alerts_interval < 5000) { + $alerts_interval = 5000; + } + + if (! x(self::$page,'title')) { + self::$page['title'] = ((array_path_exists('system/sitename',self::$config)) ? self::$config['system']['sitename'] : EMPTY_STR); + } + + if (! self::$meta->get_field('og:title')) { + self::$meta->set('og:title',self::$page['title']); + } + + // webmanifest + + Head::add_link( [ 'rel' => 'manifest', 'href' => z_root() . '/manifest.webmanifest' ] ); + self::$meta->set('application-name', System::get_platform_name() ); + + self::$meta->set('generator', System::get_platform_name()); + + $i = head_get_icon(); + if (! $i) { + $i = System::get_site_icon(); + } + if ($i) { + Head::add_link(['rel' => 'shortcut icon', 'href' => $i ]); + Head::add_link(['rel' => 'icon', 'sizes' => '64x64', 'href' => System::get_site_icon() ]); + Head::add_link(['rel' => 'icon', 'sizes' => '192x192', 'href' => 'images/' . System::get_platform_name() . '.svg' ]); + } + + $x = [ 'header' => '' ]; + /** + * @hooks build_pagehead + * Called when creating the HTML page header. + * * \e string \b header - Return the HTML header which should be added + */ + Hook::call('build_pagehead', $x); + + /* put the head template at the beginning of page['htmlhead'] + * since the code added by the modules frequently depends on it + * being first + */ + + if (! isset(self::$page['htmlhead'])) { + self::$page['htmlhead'] = EMPTY_STR; // needed to silence warning + } + + self::$page['htmlhead'] = replace_macros(Theme::get_template('head.tpl'), + [ + '$preload_images' => $preload_images, + '$user_scalable' => $user_scalable, + '$query' => urlencode(self::$query_string), + '$baseurl' => self::get_baseurl(), + '$local_channel' => local_channel(), + '$metas' => self::$meta->get(), + '$plugins' => $x['header'], + '$update_interval' => $interval, + '$alerts_interval' => $alerts_interval, + '$head_css' => Head::get_css(), + '$head_js' => Head::get_js(), + '$linkrel' => Head::get_links(), + '$js_strings' => Stringsjs::strings(), + '$zid' => Channel::get_my_address(), + '$channel_id' => ((isset(self::$profile) && is_array(self::$profile) && array_key_exists('uid',self::$profile)) ? self::$profile['uid'] : '') + ] + ) . self::$page['htmlhead']; + + // always put main.js at the end + self::$page['htmlhead'] .= Head::get_main_js(); + } + + /** + * @brief Register template engine class. + * + * If $name is "", is used class static property $class::$name. + * + * @param string $class + * @param string $name + */ + public static function register_template_engine($class, $name = '') { + if (! $name) { + $v = get_class_vars($class); + if (x($v, "name")) { + $name = $v['name']; + } + } + if (! $name) { + echo "template engine $class cannot be registered without a name.\n"; + killme(); + } + self::$template_engines[$name] = $class; + } + + /** + * @brief Return template engine instance. + * + * If $name is not defined, return engine defined by theme, or default. + * + * @param string $name Template engine name + * + * @return void Template Engine instance + */ + public static function template_engine($name = '') { + if ($name !== '') { + $template_engine = $name; + } + else { + $template_engine = 'smarty3'; + if (x(self::$theme, 'template_engine')) { + $template_engine = self::$theme['template_engine']; + } + } + + if (isset(self::$template_engines[$template_engine])) { + if (isset(self::$template_engine_instance[$template_engine])) { + return self::$template_engine_instance[$template_engine]; + } + else { + $class = self::$template_engines[$template_engine]; + $obj = new $class(); + self::$template_engine_instance[$template_engine] = $obj; + return $obj; + } + } + + // If we fell through to this step, it is considered fatal. + + echo "template engine $template_engine is not registered!\n"; + killme(); + } + + /** + * @brief Returns the active template engine. + * + * @return string + */ + public static function get_template_engine() { + return self::$theme['template_engine']; + } + + public static function set_template_engine($engine = 'smarty3') { + self::$theme['template_engine'] = $engine; + } + + public static function get_template_ldelim($engine = 'smarty3') { + return self::$ldelim[$engine]; + } + + public static function get_template_rdelim($engine = 'smarty3') { + return self::$rdelim[$engine]; + } + + public static function head_set_icon($icon) { + self::$data['pageicon'] = $icon; + } + + public static function head_get_icon() { + $icon = self::$data['pageicon']; + if ($icon && ! strpos($icon,'://')) { + $icon = z_root() . $icon; + } + return $icon; + } } // End App class @@ -1348,23 +1348,23 @@ class App { * @return bool|int */ function x($s, $k = null) { - if($k != null) { - if((is_array($s)) && (array_key_exists($k, $s))) { - if($s[$k]) - return (int) 1; - return (int) 0; - } - return false; - } - else { - if(isset($s)) { - if($s) { - return (int) 1; - } - return (int) 0; - } - return false; - } + if($k != null) { + if((is_array($s)) && (array_key_exists($k, $s))) { + if($s[$k]) + return (int) 1; + return (int) 0; + } + return false; + } + else { + if(isset($s)) { + if($s) { + return (int) 1; + } + return (int) 0; + } + return false; + } } @@ -1374,25 +1374,25 @@ function x($s, $k = null) { * @ref include/system_unavailable.php will handle everything further. */ function system_unavailable() { - include('include/system_unavailable.php'); - system_down(); - killme(); + include('include/system_unavailable.php'); + system_down(); + killme(); } function clean_urls() { - // if(App::$config['system']['clean_urls']) - return true; - // return false; + // if(App::$config['system']['clean_urls']) + return true; + // return false; } function z_path() { - $base = z_root(); - if(! clean_urls()) - $base .= '/?q='; + $base = z_root(); + if(! clean_urls()) + $base .= '/?q='; - return $base; + return $base; } /** @@ -1403,7 +1403,7 @@ function z_path() { * @return string */ function z_root() { - return App::get_baseurl(); + return App::get_baseurl(); } /** @@ -1414,18 +1414,18 @@ function z_root() { * @return string */ function absurl($path) { - if (strpos($path, '/') === 0) { - return z_path() . $path; - } + if (strpos($path, '/') === 0) { + return z_path() . $path; + } - return $path; + return $path; } function os_mkdir($path, $mode = 0777, $recursive = false) { - $oldumask = @umask(0); - $result = @mkdir($path, $mode, $recursive); - @umask($oldumask); - return $result; + $oldumask = @umask(0); + $result = @mkdir($path, $mode, $recursive); + @umask($oldumask); + return $result; } @@ -1436,18 +1436,18 @@ function os_mkdir($path, $mode = 0777, $recursive = false) { * @return bool */ function rrmdir($path) { - if (is_dir($path) === true) { - $files = array_diff(scandir($path), array('.', '..')); - foreach ($files as $file) { - rrmdir(realpath($path) . '/' . $file); - } - return rmdir($path); - } - elseif (is_file($path) === true) { - return unlink($path); - } + if (is_dir($path) === true) { + $files = array_diff(scandir($path), array('.', '..')); + foreach ($files as $file) { + rrmdir(realpath($path) . '/' . $file); + } + return rmdir($path); + } + elseif (is_file($path) === true) { + return unlink($path); + } - return false; + return false; } @@ -1457,13 +1457,13 @@ function rrmdir($path) { * @return bool */ function is_ajax() { - return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); + return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); } function killme_if_ajax() { - if (is_ajax()) { - killme(); - } + if (is_ajax()) { + killme(); + } } /** @@ -1473,46 +1473,46 @@ function killme_if_ajax() { */ function check_config() { - $saved = get_config('system','urlverify'); - if (! $saved) { - set_config('system','urlverify', bin2hex(z_root())); - } - - if(($saved) && ($saved != bin2hex(z_root()))) { - // our URL changed. Do something. + $saved = get_config('system','urlverify'); + if (! $saved) { + set_config('system','urlverify', bin2hex(z_root())); + } - $oldurl = hex2bin($saved); - logger('Baseurl changed!'); + if(($saved) && ($saved != bin2hex(z_root()))) { + // our URL changed. Do something. - $oldhost = substr($oldurl, strpos($oldurl, '//') + 2); - $host = substr(z_root(), strpos(z_root(), '//') + 2); + $oldurl = hex2bin($saved); + logger('Baseurl changed!'); - $is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$host)) ? true : false); - $was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$oldhost)) ? true : false); - // only change the url to an ip address if it was already an ip and not a dns name - if((! $is_ip_addr) || ($is_ip_addr && $was_ip_addr)) { - fix_system_urls($oldurl,z_root()); - set_config('system', 'urlverify', bin2hex(z_root())); - } - else - logger('Attempt to change baseurl from a DNS name to an IP address was refused.'); - } + $oldhost = substr($oldurl, strpos($oldurl, '//') + 2); + $host = substr(z_root(), strpos(z_root(), '//') + 2); - // This will actually set the url to the one stored in .htconfig, and ignore what - // we're passing - unless we are installing and it has never been set. + $is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$host)) ? true : false); + $was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$oldhost)) ? true : false); + // only change the url to an ip address if it was already an ip and not a dns name + if((! $is_ip_addr) || ($is_ip_addr && $was_ip_addr)) { + fix_system_urls($oldurl,z_root()); + set_config('system', 'urlverify', bin2hex(z_root())); + } + else + logger('Attempt to change baseurl from a DNS name to an IP address was refused.'); + } - App::set_baseurl(z_root()); + // This will actually set the url to the one stored in .htconfig, and ignore what + // we're passing - unless we are installing and it has never been set. - // Ensure the site has a system channel and that it has been upgraded. - // This function will only do work if work is required. - - Channel::create_system(); - - $x = new DB_Upgrade(DB_UPDATE_VERSION); + App::set_baseurl(z_root()); - Hook::load(); + // Ensure the site has a system channel and that it has been upgraded. + // This function will only do work if work is required. - check_cron_broken(); + Channel::create_system(); + + $x = new DB_Upgrade(DB_UPDATE_VERSION); + + Hook::load(); + + check_cron_broken(); } @@ -1520,132 +1520,132 @@ function check_config() { function fix_system_urls($oldurl, $newurl) { - logger('fix_system_urls: renaming ' . $oldurl . ' to ' . $newurl); + logger('fix_system_urls: renaming ' . $oldurl . ' to ' . $newurl); - // Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change - // This should fix URL changes on our site, but other sites will end up with orphan hublocs which they will try to contact and will - // cause wasted communications. - // What we need to do after fixing this up is to send a revocation of the old URL to every other site that we communicate with so - // that they can clean up their hubloc tables (this includes directories). - // It's a very expensive operation so you don't want to have to do it often or after your site gets to be large. + // Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change + // This should fix URL changes on our site, but other sites will end up with orphan hublocs which they will try to contact and will + // cause wasted communications. + // What we need to do after fixing this up is to send a revocation of the old URL to every other site that we communicate with so + // that they can clean up their hubloc tables (this includes directories). + // It's a very expensive operation so you don't want to have to do it often or after your site gets to be large. - $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s'", - dbesc($oldurl . '%') - ); + $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s'", + dbesc($oldurl . '%') + ); - if($r) { - foreach($r as $rv) { - $channel_address = substr($rv['hubloc_addr'],0,strpos($rv['hubloc_addr'],'@')); + if($r) { + foreach($r as $rv) { + $channel_address = substr($rv['hubloc_addr'],0,strpos($rv['hubloc_addr'],'@')); - // get the associated channel. If we don't have a local channel, do nothing for this entry. + // get the associated channel. If we don't have a local channel, do nothing for this entry. - $c = q("select * from channel where channel_hash = '%s' limit 1", - dbesc($rv['hubloc_hash']) - ); - if(! $c) - continue; + $c = q("select * from channel where channel_hash = '%s' limit 1", + dbesc($rv['hubloc_hash']) + ); + if(! $c) + continue; - $parsed = @parse_url($newurl); - if(! $parsed) - continue; - $newhost = $parsed['host']; + $parsed = @parse_url($newurl); + if(! $parsed) + continue; + $newhost = $parsed['host']; - // sometimes parse_url returns unexpected results. + // sometimes parse_url returns unexpected results. - if(strpos($newhost,'/') !== false) - $newhost = substr($newhost,0,strpos($newhost,'/')); + if(strpos($newhost,'/') !== false) + $newhost = substr($newhost,0,strpos($newhost,'/')); - $rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : ''); + $rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : ''); - // paths aren't going to work. You have to be at the (sub)domain root - // . (($parsed['path']) ? $parsed['path'] : ''); + // paths aren't going to work. You have to be at the (sub)domain root + // . (($parsed['path']) ? $parsed['path'] : ''); - // The xchan_url might point to another nomadic identity clone + // The xchan_url might point to another nomadic identity clone - $replace_xchan_url = ((strpos($rv['xchan_url'],$oldurl) !== false) ? true : false); + $replace_xchan_url = ((strpos($rv['xchan_url'],$oldurl) !== false) ? true : false); - $x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'", - dbesc($channel_address . '@' . $rhs), - dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rv['xchan_url']) : $rv['xchan_url']), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_connurl'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_follow'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_connpage'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])), - dbesc(datetime_convert()), - dbesc($rv['xchan_hash']) - ); + $x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'", + dbesc($channel_address . '@' . $rhs), + dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rv['xchan_url']) : $rv['xchan_url']), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_connurl'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_follow'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_connpage'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])), + dbesc(datetime_convert()), + dbesc($rv['xchan_hash']) + ); - $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_site_id = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'", - dbesc($channel_address . '@' . $rhs), - dbesc($newurl), - dbesc(str_replace($oldurl,$newurl,$rv['hubloc_id_url'])), - dbesc(Libzot::sign($newurl,$c[0]['channel_prvkey'])), - dbesc(Libzot::make_xchan_hash($newurl,Config::Get('system','pubkey'))), - dbesc($newhost), - dbesc($newurl . '/post'), - dbesc($rv['xchan_hash']), - dbesc($oldurl) - ); + $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_site_id = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'", + dbesc($channel_address . '@' . $rhs), + dbesc($newurl), + dbesc(str_replace($oldurl,$newurl,$rv['hubloc_id_url'])), + dbesc(Libzot::sign($newurl,$c[0]['channel_prvkey'])), + dbesc(Libzot::make_xchan_hash($newurl,Config::Get('system','pubkey'))), + dbesc($newhost), + dbesc($newurl . '/post'), + dbesc($rv['xchan_hash']), + dbesc($oldurl) + ); - $z = q("update profile set photo = '%s', thumb = '%s' where uid = %d", - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), - intval($c[0]['channel_id']) - ); + $z = q("update profile set photo = '%s', thumb = '%s' where uid = %d", + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), + intval($c[0]['channel_id']) + ); - $m = q("select abook_id, abook_instance from abook where abook_instance like '%s' and abook_channel = %d", - dbesc('%' . $oldurl . '%'), - intval($c[0]['channel_id']) - ); - if($m) { - foreach($m as $mm) { - q("update abook set abook_instance = '%s' where abook_id = %d", - dbesc(str_replace($oldurl,$newurl,$mm['abook_instance'])), - intval($mm['abook_id']) - ); - } - } + $m = q("select abook_id, abook_instance from abook where abook_instance like '%s' and abook_channel = %d", + dbesc('%' . $oldurl . '%'), + intval($c[0]['channel_id']) + ); + if($m) { + foreach($m as $mm) { + q("update abook set abook_instance = '%s' where abook_id = %d", + dbesc(str_replace($oldurl,$newurl,$mm['abook_instance'])), + intval($mm['abook_id']) + ); + } + } - Run::Summon( [ 'Notifier', 'refresh_all', $c[0]['channel_id'] ]); - } - } + Run::Summon( [ 'Notifier', 'refresh_all', $c[0]['channel_id'] ]); + } + } - // fix links in apps + // fix links in apps - $a = q("select id, app_url, app_photo from app where app_url like '%s' OR app_photo like '%s'", - dbesc('%' . $oldurl . '%'), - dbesc('%' . $oldurl . '%') - ); - if($a) { - foreach($a as $aa) { - q("update app set app_url = '%s', app_photo = '%s' where id = %d", - dbesc(str_replace($oldurl,$newurl,$aa['app_url'])), - dbesc(str_replace($oldurl,$newurl,$aa['app_photo'])), - intval($aa['id']) - ); - } - } + $a = q("select id, app_url, app_photo from app where app_url like '%s' OR app_photo like '%s'", + dbesc('%' . $oldurl . '%'), + dbesc('%' . $oldurl . '%') + ); + if($a) { + foreach($a as $aa) { + q("update app set app_url = '%s', app_photo = '%s' where id = %d", + dbesc(str_replace($oldurl,$newurl,$aa['app_url'])), + dbesc(str_replace($oldurl,$newurl,$aa['app_photo'])), + intval($aa['id']) + ); + } + } - // now replace any remote xchans whose photos are stored locally (which will be most if not all remote xchans) + // now replace any remote xchans whose photos are stored locally (which will be most if not all remote xchans) - $r = q("select * from xchan where xchan_photo_l like '%s'", - dbesc($oldurl . '%') - ); + $r = q("select * from xchan where xchan_photo_l like '%s'", + dbesc($oldurl . '%') + ); - if($r) { - foreach($r as $rv) { - $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'", - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), - dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])), - dbesc($rv['xchan_hash']) - ); - } - } + if($r) { + foreach($r as $rv) { + $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'", + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])), + dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])), + dbesc($rv['xchan_hash']) + ); + } + } } @@ -1664,81 +1664,81 @@ function fix_system_urls($oldurl, $newurl) { */ function login($register = false, $form_id = 'main-login', $hiddens = false, $login_page = true) { - $o = ''; - $reg = null; + $o = ''; + $reg = null; - // Here's the current description of how the register link works (2018-05-15) + // Here's the current description of how the register link works (2018-05-15) - // Register links are enabled on the site home page and login page and navbar. - // They are not shown by default on other pages which may require login. + // Register links are enabled on the site home page and login page and navbar. + // They are not shown by default on other pages which may require login. - // system.register_link can over-ride the default behaviour and redirect to an arbitrary - // webpage for paid/custom or organisational registrations, regardless of whether - // registration is allowed. + // system.register_link can over-ride the default behaviour and redirect to an arbitrary + // webpage for paid/custom or organisational registrations, regardless of whether + // registration is allowed. - // system.register_link may or may not be the same destination as system.sellpage + // system.register_link may or may not be the same destination as system.sellpage - // system.sellpage is the destination linked from the /pubsites page on other sites. If - // system.sellpage is not set, the 'register' link in /pubsites will go to 'register' on your - // site. - - // If system.register_link is set to the word 'none', no registration link will be shown on - // your site. + // system.sellpage is the destination linked from the /pubsites page on other sites. If + // system.sellpage is not set, the 'register' link in /pubsites will go to 'register' on your + // site. + + // If system.register_link is set to the word 'none', no registration link will be shown on + // your site. - // If the site supports SSL and this isn't a secure connection, reload the page using https - - if (intval($_SERVER['SERVER_PORT']) === 80 && strpos(z_root(), 'https://') !== false) { - goaway(z_root() . '/' . App::$query_string); - } + // If the site supports SSL and this isn't a secure connection, reload the page using https - $register_policy = get_config('system','register_policy'); + if (intval($_SERVER['SERVER_PORT']) === 80 && strpos(z_root(), 'https://') !== false) { + goaway(z_root() . '/' . App::$query_string); + } - $reglink = get_config('system', 'register_link', z_root() . '/register'); + $register_policy = get_config('system','register_policy'); - if($reglink !== 'none') { - $reg = [ - 'title' => t('Create an account to access services and applications'), - 'desc' => t('Register'), - 'link' => $reglink - ]; - } + $reglink = get_config('system', 'register_link', z_root() . '/register'); - $dest_url = z_root() . '/' . App::$query_string; + if($reglink !== 'none') { + $reg = [ + 'title' => t('Create an account to access services and applications'), + 'desc' => t('Register'), + 'link' => $reglink + ]; + } - if(local_channel()) { - $tpl = Theme::get_template('logout.tpl'); - } - else { - $tpl = Theme::get_template('login.tpl'); - if(strlen(App::$query_string)) - $_SESSION['login_return_url'] = App::$query_string; - } + $dest_url = z_root() . '/' . App::$query_string; - $o .= replace_macros($tpl, [ - '$dest_url' => $dest_url, - '$login_page' => $login_page, - '$logout' => t('Logout'), - '$login' => t('Login'), - '$remote_login' => t('Remote Authentication'), - '$form_id' => $form_id, - '$lname' => [ 'username', t('Login/Email') , '', '' ], - '$lpassword' => [ 'password', t('Password'), '', '' ], - '$remember_me' => [ (($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '', [ t('No'),t('Yes') ] ], - '$hiddens' => $hiddens, - '$register' => $reg, - '$lostpass' => t('Forgot your password?'), - '$lostlink' => t('Password Reset'), - ]); + if(local_channel()) { + $tpl = Theme::get_template('logout.tpl'); + } + else { + $tpl = Theme::get_template('login.tpl'); + if(strlen(App::$query_string)) + $_SESSION['login_return_url'] = App::$query_string; + } - /** - * @hooks login_hook - * Called when generating the login form. - * * \e string with parsed HTML - */ - Hook::call('login_hook', $o); + $o .= replace_macros($tpl, [ + '$dest_url' => $dest_url, + '$login_page' => $login_page, + '$logout' => t('Logout'), + '$login' => t('Login'), + '$remote_login' => t('Remote Authentication'), + '$form_id' => $form_id, + '$lname' => [ 'username', t('Login/Email') , '', '' ], + '$lpassword' => [ 'password', t('Password'), '', '' ], + '$remember_me' => [ (($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '', [ t('No'),t('Yes') ] ], + '$hiddens' => $hiddens, + '$register' => $reg, + '$lostpass' => t('Forgot your password?'), + '$lostlink' => t('Password Reset'), + ]); - return $o; + /** + * @hooks login_hook + * Called when generating the login form. + * * \e string with parsed HTML + */ + Hook::call('login_hook', $o); + + return $o; } @@ -1747,16 +1747,16 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo */ function killme() { - register_shutdown_function('shutdown'); - exit; + register_shutdown_function('shutdown'); + exit; } /** * @brief Redirect to another URL and terminate this process. */ function goaway($s) { - header("Location: $s"); - killme(); + header("Location: $s"); + killme(); } function shutdown() { @@ -1774,13 +1774,13 @@ function shutdown() { function get_account_id() { - if(isset($_SESSION['account_id']) && intval($_SESSION['account_id'])) - return intval($_SESSION['account_id']); + if(isset($_SESSION['account_id']) && intval($_SESSION['account_id'])) + return intval($_SESSION['account_id']); - if(App::$account) - return intval(App::$account['account_id']); + if(App::$account) + return intval(App::$account['account_id']); - return false; + return false; } /** @@ -1796,12 +1796,12 @@ function get_account_id() { */ function local_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] - && array_key_exists('uid',$_SESSION) && intval($_SESSION['uid'])) - return intval($_SESSION['uid']); + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + && array_key_exists('uid',$_SESSION) && intval($_SESSION['uid'])) + return intval($_SESSION['uid']); - return false; + return false; } /** @@ -1817,30 +1817,30 @@ function local_channel() { * @return string|bool visitor_id or false */ function remote_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] - && array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id']) - return $_SESSION['visitor_id']; + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + && array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id']) + return $_SESSION['visitor_id']; - return false; + return false; } function can_view_public_stream() { - if (observer_prohibited(true)) { - return false; - } + if (observer_prohibited(true)) { + return false; + } - if (! (intval(get_config('system','open_pubstream',0)))) { - if (! local_channel()) { - return false; - } - } + if (! (intval(get_config('system','open_pubstream',0)))) { + if (! local_channel()) { + return false; + } + } + + $public_stream_mode = intval(get_config('system','public_stream_mode',PUBLIC_STREAM_NONE)); + return (($public_stream_mode) ? true : false); - $public_stream_mode = intval(get_config('system','public_stream_mode',PUBLIC_STREAM_NONE)); - return (($public_stream_mode) ? true : false); - } @@ -1856,25 +1856,25 @@ function can_view_public_stream() { */ function notice($s) { - if (! session_id()) { - return; - } + if (! session_id()) { + return; + } - if (! x($_SESSION, 'sysmsg')) { - $_SESSION['sysmsg'] = []; - } + if (! x($_SESSION, 'sysmsg')) { + $_SESSION['sysmsg'] = []; + } - // ignore duplicated error messages which haven't yet been displayed - // - typically seen as multiple 'permission denied' messages - // as a result of auto-reloading a protected page with &JS=1 + // ignore duplicated error messages which haven't yet been displayed + // - typically seen as multiple 'permission denied' messages + // as a result of auto-reloading a protected page with &JS=1 - if (in_array($s, $_SESSION['sysmsg'])) { - return; - } + if (in_array($s, $_SESSION['sysmsg'])) { + return; + } - if (App::$interactive) { - $_SESSION['sysmsg'][] = $s; - } + if (App::$interactive) { + $_SESSION['sysmsg'][] = $s; + } } /** @@ -1888,21 +1888,21 @@ function notice($s) { * @param string $s Text to display */ function info($s) { - if (! session_id()) { - return; - } - - if (! x($_SESSION, 'sysmsg_info')) { - $_SESSION['sysmsg_info'] = []; - } + if (! session_id()) { + return; + } - if (in_array($s, $_SESSION['sysmsg_info'])) { - return; - } + if (! x($_SESSION, 'sysmsg_info')) { + $_SESSION['sysmsg_info'] = []; + } - if (App::$interactive) { - $_SESSION['sysmsg_info'][] = $s; - } + if (in_array($s, $_SESSION['sysmsg_info'])) { + return; + } + + if (App::$interactive) { + $_SESSION['sysmsg_info'][] = $s; + } } /** @@ -1911,7 +1911,7 @@ function info($s) { * @return int */ function get_max_import_size() { - return(intval(get_config('system', 'max_import_size'))); + return(intval(get_config('system', 'max_import_size'))); } @@ -1930,72 +1930,72 @@ function get_max_import_size() { */ function proc_run() { - $args = func_get_args(); + $args = func_get_args(); - if (! count($args)) - return; + if (! count($args)) + return; - $args = flatten_array_recursive($args); + $args = flatten_array_recursive($args); - $arr = [ - 'args' => $args, - 'run_cmd' => true - ]; + $arr = [ + 'args' => $args, + 'run_cmd' => true + ]; - /** - * @hooks proc_run - * Called when invoking PHP sub processes. - * * \e array \b args - * * \e boolean \b run_cmd - */ + /** + * @hooks proc_run + * Called when invoking PHP sub processes. + * * \e array \b args + * * \e boolean \b run_cmd + */ - Hook::call('proc_run', $arr); + Hook::call('proc_run', $arr); - if (! $arr['run_cmd']) { - return; - } + if (! $arr['run_cmd']) { + return; + } - if (count($args) > 1 && $args[0] === 'php') { - $php = check_php_cli(); - if (! $php) { - return; - } - $args[0] = $php; - } + if (count($args) > 1 && $args[0] === 'php') { + $php = check_php_cli(); + if (! $php) { + return; + } + $args[0] = $php; + } - $args = array_map('escapeshellarg',$args); - $cmdline = implode(' ', $args); + $args = array_map('escapeshellarg',$args); + $cmdline = implode(' ', $args); - if (is_windows()) { - $cwd = getcwd(); - $cmd = "cmd /c start \"title\" /D \"$cwd\" /b $cmdline"; - proc_close(proc_open($cmd, [], $foo)); - } - else { - if (get_config('system','use_proc_open')) - proc_close(proc_open($cmdline ." &", [], $foo)); - else - exec($cmdline . ' > /dev/null &'); - } + if (is_windows()) { + $cwd = getcwd(); + $cmd = "cmd /c start \"title\" /D \"$cwd\" /b $cmdline"; + proc_close(proc_open($cmd, [], $foo)); + } + else { + if (get_config('system','use_proc_open')) + proc_close(proc_open($cmdline ." &", [], $foo)); + else + exec($cmdline . ' > /dev/null &'); + } } function check_php_cli() { - $cfg = (isset(App::$config['system']['php_path'])) - ? App::$config['system']['php_path'] - : NULL; + $cfg = (isset(App::$config['system']['php_path'])) + ? App::$config['system']['php_path'] + : NULL; - if (isset($cfg) && is_executable(realpath($cfg))) { - return realpath($cfg); - } + if (isset($cfg) && is_executable(realpath($cfg))) { + return realpath($cfg); + } - $path = shell_exec('which php'); - if ($path && is_executable(realpath(trim($path)))) { - return realpath(trim($path)); - } + $path = shell_exec('which php'); + if ($path && is_executable(realpath(trim($path)))) { + return realpath(trim($path)); + } - logger('PHP command line interpreter not found.'); - throw new Exception('interpreter not found.'); + logger('PHP command line interpreter not found.'); + throw new Exception('interpreter not found.'); } @@ -2009,7 +2009,7 @@ function check_php_cli() { * */ function is_windows() { - return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); + return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); } /** @@ -2021,23 +2021,23 @@ function is_windows() { */ function is_site_admin() { - if(! session_id()) - return false; + if(! session_id()) + return false; - if(isset($_SESSION['delegate'])) - return false; + if(isset($_SESSION['delegate'])) + return false; - if(isset($_SESSION['authenticated']) && intval($_SESSION['authenticated'])) { + if(isset($_SESSION['authenticated']) && intval($_SESSION['authenticated'])) { if (is_array(App::$account) && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN)) { - return true; + return true; } // the system channel is by definition an administrator if (isset(App::$sys_channel) && array_key_exists('channel_id', App::$sys_channel) && intval(App::$sys_channel['channel_id']) === local_channel()) { return true; } } - - return false; + + return false; } /** @@ -2049,40 +2049,40 @@ function is_site_admin() { */ function is_developer() { - if(! session_id()) - return false; + if(! session_id()) + return false; - if(isset($_SESSION['authenticated']) - && (intval($_SESSION['authenticated'])) - && (is_array(App::$account)) - && (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) - return true; + if(isset($_SESSION['authenticated']) + && (intval($_SESSION['authenticated'])) + && (is_array(App::$account)) + && (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) + return true; - return false; + return false; } function load_contact_links($uid) { - $ret = []; + $ret = []; - if(! $uid || x(App::$contacts,'empty')) - return; + if(! $uid || x(App::$contacts,'empty')) + return; -// logger('load_contact_links'); +// logger('load_contact_links'); - $r = q("SELECT abook_id, abook_flags, abook_self, abook_incl, abook_excl, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_addr, xchan_network, xchan_type from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ", - intval($uid) - ); - if($r) { - foreach($r as $rv) { - $ret[$rv['xchan_hash']] = $rv; - } - } - else - $ret['empty'] = true; + $r = q("SELECT abook_id, abook_flags, abook_self, abook_incl, abook_excl, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_addr, xchan_network, xchan_type from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ", + intval($uid) + ); + if($r) { + foreach($r as $rv) { + $ret[$rv['xchan_hash']] = $rv; + } + } + else + $ret['empty'] = true; - App::$contacts = $ret; + App::$contacts = $ret; } @@ -2095,25 +2095,25 @@ function load_contact_links($uid) { * @return string */ function build_querystring($params, $name = null) { - $ret = ''; - foreach($params as $key => $val) { - if(is_array($val)) { - if($name === null) { - $ret .= build_querystring($val, $key); - } else { - $ret .= build_querystring($val, $name . "[$key]"); - } - } else { - $val = urlencode($val); - if($name != null) { - $ret .= $name . "[$key]" . "=$val&"; - } else { - $ret .= "$key=$val&"; - } - } - } + $ret = ''; + foreach($params as $key => $val) { + if(is_array($val)) { + if($name === null) { + $ret .= build_querystring($val, $key); + } else { + $ret .= build_querystring($val, $name . "[$key]"); + } + } else { + $val = urlencode($val); + if($name != null) { + $ret .= $name . "[$key]" . "=$val&"; + } else { + $ret .= "$key=$val&"; + } + } + } - return $ret; + return $ret; } @@ -2121,18 +2121,18 @@ function build_querystring($params, $name = null) { * @brief Much better way of dealing with c-style args. */ function argc() { - return App::$argc; + return App::$argc; } function argv($x) { - if(array_key_exists($x,App::$argv)) - return App::$argv[$x]; + if(array_key_exists($x,App::$argv)) + return App::$argv[$x]; - return ''; + return ''; } function dba_timer() { - return microtime(true); + return microtime(true); } /** @@ -2143,11 +2143,11 @@ function dba_timer() { * @return string xchan_hash from observer, otherwise empty string if no observer */ function get_observer_hash() { - $observer = App::get_observer(); - if (is_array($observer)) { - return $observer['xchan_hash']; - } - return ''; + $observer = App::get_observer(); + if (is_array($observer)) { + return $observer['xchan_hash']; + } + return ''; } /** @@ -2158,18 +2158,18 @@ function get_observer_hash() { * @return string */ function curPageURL() { - $pageURL = 'http'; - if ($_SERVER["HTTPS"] == "on") { - $pageURL .= "s"; - } - $pageURL .= "://"; - if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") { - $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; - } else { - $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; - } + $pageURL = 'http'; + if ($_SERVER["HTTPS"] == "on") { + $pageURL .= "s"; + } + $pageURL .= "://"; + if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") { + $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; + } else { + $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; + } - return $pageURL; + return $pageURL; } /** @@ -2184,9 +2184,9 @@ function curPageURL() { * @return mixed */ function get_custom_nav($navname) { - if (! $navname) - return App::$page['nav']; - // load custom nav menu by name here + if (! $navname) + return App::$page['nav']; + // load custom nav menu by name here return EMPTY_STR; } @@ -2199,54 +2199,54 @@ function get_custom_nav($navname) { */ function load_pdl() { - App::$comanche = new Comanche(); + App::$comanche = new Comanche(); - if (! count(App::$layout)) { + if (! count(App::$layout)) { - $arr = [ - 'module' => App::$module, - 'layout' => '' - ]; - /** - * @hooks load_pdl - * Called when we load a PDL file or description. - * * \e string \b module - * * \e string \b layout - */ - Hook::call('load_pdl', $arr); - $layout = $arr['layout']; + $arr = [ + 'module' => App::$module, + 'layout' => '' + ]; + /** + * @hooks load_pdl + * Called when we load a PDL file or description. + * * \e string \b module + * * \e string \b layout + */ + Hook::call('load_pdl', $arr); + $layout = $arr['layout']; - $n = 'mod_' . App::$module . '.pdl' ; - $u = App::$comanche->get_channel_id(); - if($u) - $s = get_pconfig($u, 'system', $n); - if(! (isset($s) && $s)) - $s = $layout; + $n = 'mod_' . App::$module . '.pdl' ; + $u = App::$comanche->get_channel_id(); + if($u) + $s = get_pconfig($u, 'system', $n); + if(! (isset($s) && $s)) + $s = $layout; - if((! $s) && (($p = Theme::include($n)) != '')) - $s = @file_get_contents($p); - elseif(file_exists('addon/'. App::$module . '/' . $n)) - $s = @file_get_contents('addon/'. App::$module . '/' . $n); + if((! $s) && (($p = Theme::include($n)) != '')) + $s = @file_get_contents($p); + elseif(file_exists('addon/'. App::$module . '/' . $n)) + $s = @file_get_contents('addon/'. App::$module . '/' . $n); - $arr = [ - 'module' => App::$module, - 'layout' => $s - ]; - Hook::call('alter_pdl',$arr); - $s = $arr['layout']; + $arr = [ + 'module' => App::$module, + 'layout' => $s + ]; + Hook::call('alter_pdl',$arr); + $s = $arr['layout']; - if($s) { - App::$comanche->parse($s); - App::$pdl = $s; - } - } + if($s) { + App::$comanche->parse($s); + App::$pdl = $s; + } + } } function exec_pdl() { - if(App::$pdl) { - App::$comanche->parse(App::$pdl,1); - } + if(App::$pdl) { + App::$comanche->parse(App::$pdl,1); + } } @@ -2258,180 +2258,180 @@ function exec_pdl() { */ function construct_page() { - Hook::call('page_end', App::$page['content']); + Hook::call('page_end', App::$page['content']); - exec_pdl(); + exec_pdl(); - $comanche = ((isset(App::$layout) && is_array(App::$layout) && count(App::$layout)) ? true : false); + $comanche = ((isset(App::$layout) && is_array(App::$layout) && count(App::$layout)) ? true : false); - require_once(Theme::include('theme_init.php')); + require_once(Theme::include('theme_init.php')); - $installing = false; + $installing = false; - $uid = ((App::$profile_uid) ? App::$profile_uid : local_channel()); + $uid = ((App::$profile_uid) ? App::$profile_uid : local_channel()); - $navbar = get_config('system','navbar','default'); - if($uid) { - $navbar = get_pconfig($uid,'system','navbar',$navbar); - } + $navbar = get_config('system','navbar','default'); + if($uid) { + $navbar = get_pconfig($uid,'system','navbar',$navbar); + } - if($comanche && isset(App::$layout['navbar'])) { - $navbar = App::$layout['navbar']; - } + if($comanche && isset(App::$layout['navbar'])) { + $navbar = App::$layout['navbar']; + } - if (App::$module == 'setup') { - $installing = true; - } - else { - Navbar::render($navbar); - } + if (App::$module == 'setup') { + $installing = true; + } + else { + Navbar::render($navbar); + } - $current_theme = Theme::current(); + $current_theme = Theme::current(); - // logger('current_theme: ' . print_r($current_theme,true)); - // Theme::debug(); + // logger('current_theme: ' . print_r($current_theme,true)); + // Theme::debug(); - if (($p = Theme::include($current_theme[0] . '.js')) != '') - Head::add_js('/' . $p); + if (($p = Theme::include($current_theme[0] . '.js')) != '') + Head::add_js('/' . $p); - if (($p = Theme::include('mod_' . App::$module . '.php')) != '') - require_once($p); + if (($p = Theme::include('mod_' . App::$module . '.php')) != '') + require_once($p); - if (isset(App::$page['template_style'])) - Head::add_css(App::$page['template_style'] . '.css'); - else - Head::add_css(((isset(App::$page['template'])) ? App::$page['template'] : 'default' ) . '.css'); + if (isset(App::$page['template_style'])) + Head::add_css(App::$page['template_style'] . '.css'); + else + Head::add_css(((isset(App::$page['template'])) ? App::$page['template'] : 'default' ) . '.css'); - if (($p = Theme::include('mod_' . App::$module . '.css')) != '') - Head::add_css('mod_' . App::$module . '.css'); + if (($p = Theme::include('mod_' . App::$module . '.css')) != '') + Head::add_css('mod_' . App::$module . '.css'); - Head::add_css(Theme::url($installing)); + Head::add_css(Theme::url($installing)); - if (($p = Theme::include('mod_' . App::$module . '.js')) != '') - Head::add_js('mod_' . App::$module . '.js'); + if (($p = Theme::include('mod_' . App::$module . '.js')) != '') + Head::add_js('mod_' . App::$module . '.js'); - App::build_pagehead(); + App::build_pagehead(); - if (isset(App::$page['pdl_content']) && App::$page['pdl_content']) { - App::$page['content'] = App::$comanche->region(App::$page['content']); - } + if (isset(App::$page['pdl_content']) && App::$page['pdl_content']) { + App::$page['content'] = App::$comanche->region(App::$page['content']); + } - // Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'. - // The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave - // App::$page['nav'] empty and put the default content from App::$page['nav'] and App::$page['section'] - // into a new region called App::$data['content']. It is presumed that the chosen layout file for this comanche page - // has a '' element instead of a '
'. + // Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'. + // The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave + // App::$page['nav'] empty and put the default content from App::$page['nav'] and App::$page['section'] + // into a new region called App::$data['content']. It is presumed that the chosen layout file for this comanche page + // has a '' element instead of a '
'. - // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the - // layout completely with a new layout definition, or replace/remove existing content. + // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the + // layout completely with a new layout definition, or replace/remove existing content. - if ($comanche) { - $arr = [ - 'module' => App::$module, - 'layout' => App::$layout - ]; - /** - * @hooks construct_page - * General purpose hook to provide content to certain page regions. - * Called when constructing the Comanche page. - * * \e string \b module - * * \e string \b layout - */ - Hook::call('construct_page', $arr); - App::$layout = ((isset($arr['layout']) && is_array($arr['layout'])) ? $arr['layout'] : []); + if ($comanche) { + $arr = [ + 'module' => App::$module, + 'layout' => App::$layout + ]; + /** + * @hooks construct_page + * General purpose hook to provide content to certain page regions. + * Called when constructing the Comanche page. + * * \e string \b module + * * \e string \b layout + */ + Hook::call('construct_page', $arr); + App::$layout = ((isset($arr['layout']) && is_array($arr['layout'])) ? $arr['layout'] : []); - foreach(App::$layout as $k => $v) { - if((strpos($k, 'region_') === 0) && strlen($v)) { - if(strpos($v, '$region_') !== false) { - $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', array(App::$comanche,'replace_region'), $v); - } + foreach(App::$layout as $k => $v) { + if((strpos($k, 'region_') === 0) && strlen($v)) { + if(strpos($v, '$region_') !== false) { + $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', array(App::$comanche,'replace_region'), $v); + } - // And a couple of convenience macros - if(strpos($v, '$htmlhead') !== false) { - $v = str_replace('$htmlhead', App::$page['htmlhead'], $v); - } - if(strpos($v, '$nav') !== false) { - $v = str_replace('$nav', App::$page['nav'], $v); - } - if(strpos($v, '$content') !== false) { - $v = str_replace('$content', App::$page['content'], $v); - } + // And a couple of convenience macros + if(strpos($v, '$htmlhead') !== false) { + $v = str_replace('$htmlhead', App::$page['htmlhead'], $v); + } + if(strpos($v, '$nav') !== false) { + $v = str_replace('$nav', App::$page['nav'], $v); + } + if(strpos($v, '$content') !== false) { + $v = str_replace('$content', App::$page['content'], $v); + } - App::$page[substr($k, 7)] = $v; - } - } - } + App::$page[substr($k, 7)] = $v; + } + } + } - $page = App::$page; - $profile = App::$profile; + $page = App::$page; + $profile = App::$profile; - // There's some experimental support for right-to-left text in the view/php/default.php page template. - // In v1.9 we started providing direction preference in the per language hstrings.php file - // This requires somebody with fluency in a RTL language to make happen + // There's some experimental support for right-to-left text in the view/php/default.php page template. + // In v1.9 we started providing direction preference in the per language hstrings.php file + // This requires somebody with fluency in a RTL language to make happen - $page['direction'] = 0; // ((App::$rtl) ? 1 : 0); + $page['direction'] = 0; // ((App::$rtl) ? 1 : 0); - header("Content-type: text/html; charset=utf-8"); + header("Content-type: text/html; charset=utf-8"); - // security headers - see https://securityheaders.io + // security headers - see https://securityheaders.io - if (App::get_scheme() === 'https' && isset(App::$config['system']['transport_security_header']) && App::$config['system']['transport_security_header']) { - header("Strict-Transport-Security: max-age=31536000"); - } + if (App::get_scheme() === 'https' && isset(App::$config['system']['transport_security_header']) && App::$config['system']['transport_security_header']) { + header("Strict-Transport-Security: max-age=31536000"); + } - if (isset(App::$config['system']['content_security_policy']) && App::$config['system']['content_security_policy']) { - $cspsettings = Array ( - 'script-src' => Array ("'self'","'unsafe-inline'","'unsafe-eval'"), - 'style-src' => Array ("'self'","'unsafe-inline'") - ); - Hook::call('content_security_policy',$cspsettings); + if (isset(App::$config['system']['content_security_policy']) && App::$config['system']['content_security_policy']) { + $cspsettings = Array ( + 'script-src' => Array ("'self'","'unsafe-inline'","'unsafe-eval'"), + 'style-src' => Array ("'self'","'unsafe-inline'") + ); + Hook::call('content_security_policy',$cspsettings); - // Legitimate CSP directives (cxref: https://content-security-policy.com/) - $validcspdirectives=Array( - "default-src", "script-src", "style-src", - "img-src", "connect-src", "font-src", - "object-src", "media-src", 'frame-src', - 'sandbox', 'report-uri', 'child-src', - 'form-action', 'frame-ancestors', 'plugin-types' - ); - $cspheader = "Content-Security-Policy:"; - foreach ($cspsettings as $cspdirective => $csp) { - if (! in_array($cspdirective,$validcspdirectives)) { - logger("INVALID CSP DIRECTIVE: ".$cspdirective,LOGGER_DEBUG); - continue; - } - $cspsettingsarray = array_unique($cspsettings[$cspdirective]); - $cspsetpolicy = implode(' ',$cspsettingsarray); - if ($cspsetpolicy) { - $cspheader .= " $cspdirective $cspsetpolicy;"; - } - } - header($cspheader); - } + // Legitimate CSP directives (cxref: https://content-security-policy.com/) + $validcspdirectives=Array( + "default-src", "script-src", "style-src", + "img-src", "connect-src", "font-src", + "object-src", "media-src", 'frame-src', + 'sandbox', 'report-uri', 'child-src', + 'form-action', 'frame-ancestors', 'plugin-types' + ); + $cspheader = "Content-Security-Policy:"; + foreach ($cspsettings as $cspdirective => $csp) { + if (! in_array($cspdirective,$validcspdirectives)) { + logger("INVALID CSP DIRECTIVE: ".$cspdirective,LOGGER_DEBUG); + continue; + } + $cspsettingsarray = array_unique($cspsettings[$cspdirective]); + $cspsetpolicy = implode(' ',$cspsettingsarray); + if ($cspsetpolicy) { + $cspheader .= " $cspdirective $cspsetpolicy;"; + } + } + header($cspheader); + } - if (isset(App::$config['system']['x_security_headers']) && App::$config['system']['x-security_headers']) { - header("X-Frame-Options: SAMEORIGIN"); - header("X-Xss-Protection: 1; mode=block;"); - header("X-Content-Type-Options: nosniff"); - } + if (isset(App::$config['system']['x_security_headers']) && App::$config['system']['x-security_headers']) { + header("X-Frame-Options: SAMEORIGIN"); + header("X-Xss-Protection: 1; mode=block;"); + header("X-Content-Type-Options: nosniff"); + } - if (isset(App::$config['system']['perm_policy_header']) && App::$config['system']['perm_policy_header']) { - header("Permissions-Policy: " . App::$config['system']['perm_policy_header']); - } - else { - // opt-out this site from federated browser surveillance - header("Permissions-Policy: interest-cohort=()"); - } + if (isset(App::$config['system']['perm_policy_header']) && App::$config['system']['perm_policy_header']) { + header("Permissions-Policy: " . App::$config['system']['perm_policy_header']); + } + else { + // opt-out this site from federated browser surveillance + header("Permissions-Policy: interest-cohort=()"); + } - if (isset(App::$config['system']['public_key_pins']) && App::$config['system']['public_key_pins']) { - header("Public-Key-Pins: " . App::$config['system']['public_key_pins']); - } + if (isset(App::$config['system']['public_key_pins']) && App::$config['system']['public_key_pins']) { + header("Public-Key-Pins: " . App::$config['system']['public_key_pins']); + } - require_once(Theme::include( - ((isset(App::$page['template']) && App::$page['template']) ? App::$page['template'] : 'default' ) . '.php' ) - ); + require_once(Theme::include( + ((isset(App::$page['template']) && App::$page['template']) ? App::$page['template'] : 'default' ) . '.php' ) + ); } /** @@ -2440,7 +2440,7 @@ function construct_page() { * @return string */ function appdirpath() { - return dirname(__FILE__); + return dirname(__FILE__); } /** @@ -2450,7 +2450,7 @@ function appdirpath() { */ function head_set_icon($icon) { - App::$data['pageicon'] = $icon; + App::$data['pageicon'] = $icon; } @@ -2461,11 +2461,11 @@ function head_set_icon($icon) { */ function head_get_icon() { - $icon = ((isset(App::$data['pageicon'])) ? App::$data['pageicon'] : EMPTY_STR); - if($icon && ! strpos($icon, '://')) - $icon = z_root() . $icon; + $icon = ((isset(App::$data['pageicon'])) ? App::$data['pageicon'] : EMPTY_STR); + if($icon && ! strpos($icon, '://')) + $icon = z_root() . $icon; - return $icon; + return $icon; } /** @@ -2474,10 +2474,10 @@ function head_get_icon() { * @return string */ function get_directory_realm() { - if($x = get_config('system', 'directory_realm')) - return $x; + if($x = get_config('system', 'directory_realm')) + return $x; - return DIRECTORY_REALM; + return DIRECTORY_REALM; } /** @@ -2486,27 +2486,27 @@ function get_directory_realm() { * @return string relative date of last completed poller execution */ function get_poller_runtime() { - $t = get_config('system', 'lastpoll'); + $t = get_config('system', 'lastpoll'); - return relative_date($t); + return relative_date($t); } function z_get_upload_dir() { - $upload_dir = get_config('system','uploaddir'); - if(! $upload_dir) - $upload_dir = ini_get('upload_tmp_dir'); - if(! $upload_dir) - $upload_dir = sys_get_temp_dir(); + $upload_dir = get_config('system','uploaddir'); + if(! $upload_dir) + $upload_dir = ini_get('upload_tmp_dir'); + if(! $upload_dir) + $upload_dir = sys_get_temp_dir(); - return $upload_dir; + return $upload_dir; } function z_get_temp_dir() { - $temp_dir = get_config('system','tempdir'); - if(! $temp_dir) - $temp_dir = sys_get_temp_dir(); + $temp_dir = get_config('system','tempdir'); + if(! $temp_dir) + $temp_dir = sys_get_temp_dir(); - return $temp_dir; + return $temp_dir; } @@ -2516,15 +2516,15 @@ function z_get_temp_dir() { * Notify admin if not. */ function z_check_cert() { - if(strpos(z_root(), 'https://') !== false) { - $x = z_fetch_url(z_root() . '/siteinfo.json'); - if(! $x['success']) { - $recurse = 0; - $y = z_fetch_url(z_root() . '/siteinfo.json', false, $recurse, ['novalidate' => true]); - if($y['success']) - cert_bad_email(); - } - } + if(strpos(z_root(), 'https://') !== false) { + $x = z_fetch_url(z_root() . '/siteinfo.json'); + if(! $x['success']) { + $recurse = 0; + $y = z_fetch_url(z_root() . '/siteinfo.json', false, $recurse, ['novalidate' => true]); + if($y['success']) + cert_bad_email(); + } + } } @@ -2534,19 +2534,19 @@ function z_check_cert() { * If a hub is available over https it must have a publicly valid certificate. */ function cert_bad_email() { - return z_mail( - [ - 'toEmail' => App::$config['system']['admin_email'], - 'messageSubject' => sprintf(t('[$Projectname] Website SSL error for %s'), App::get_hostname()), - 'textVersion' => replace_macros(Theme::get_email_template('cert_bad_eml.tpl'), - [ - '$sitename' => App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$error' => t('Website SSL certificate is not valid. Please correct.') - ] - ) - ] - ); + return z_mail( + [ + 'toEmail' => App::$config['system']['admin_email'], + 'messageSubject' => sprintf(t('[$Projectname] Website SSL error for %s'), App::get_hostname()), + 'textVersion' => replace_macros(Theme::get_email_template('cert_bad_eml.tpl'), + [ + '$sitename' => App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$error' => t('Website SSL certificate is not valid. Please correct.') + ] + ) + ] + ); } @@ -2557,46 +2557,46 @@ function cert_bad_email() { */ function check_cron_broken() { - $d = get_config('system','lastcron'); + $d = get_config('system','lastcron'); - if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) { - Run::Summon( [ 'Cron' ] ); - set_config('system','lastcron',datetime_convert()); - } + if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) { + Run::Summon( [ 'Cron' ] ); + set_config('system','lastcron',datetime_convert()); + } - $t = get_config('system','lastcroncheck'); - if(! $t) { - // never checked before. Start the timer. - set_config('system','lastcroncheck',datetime_convert()); - return true; - } + $t = get_config('system','lastcroncheck'); + if(! $t) { + // never checked before. Start the timer. + set_config('system','lastcroncheck',datetime_convert()); + return true; + } - if($t > datetime_convert('UTC','UTC','now - 3 days')) { - // Wait for 3 days before we do anything so as not to swamp the admin with messages - return true; - } + if($t > datetime_convert('UTC','UTC','now - 3 days')) { + // Wait for 3 days before we do anything so as not to swamp the admin with messages + return true; + } - set_config('system','lastcroncheck',datetime_convert()); + set_config('system','lastcroncheck',datetime_convert()); - if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) { - // Scheduled tasks have run successfully in the last 3 days. - return true; - } + if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) { + // Scheduled tasks have run successfully in the last 3 days. + return true; + } - return z_mail( - [ - 'toEmail' => App::$config['system']['admin_email'], - 'messageSubject' => sprintf(t('[$Projectname] Cron tasks not running on %s'), App::get_hostname()), - 'textVersion' => replace_macros(Theme::get_email_template('cron_bad_eml.tpl'), - [ - '$sitename' => App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$error' => t('Cron/Scheduled tasks not running.'), - '$lastdate' => (($d)? $d : t('never')) - ] - ) - ] - ); + return z_mail( + [ + 'toEmail' => App::$config['system']['admin_email'], + 'messageSubject' => sprintf(t('[$Projectname] Cron tasks not running on %s'), App::get_hostname()), + 'textVersion' => replace_macros(Theme::get_email_template('cron_bad_eml.tpl'), + [ + '$sitename' => App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$error' => t('Cron/Scheduled tasks not running.'), + '$lastdate' => (($d)? $d : t('never')) + ] + ) + ] + ); } @@ -2607,54 +2607,54 @@ function check_cron_broken() { * @return bool */ function observer_prohibited($allow_account = false) { - if($allow_account) { - return (((get_config('system', 'block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false ); - } - return (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false ); + if($allow_account) { + return (((get_config('system', 'block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false ); + } + return (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false ); } function get_safemode() { - if (! array_key_exists('safemode', $_SESSION)) { - $_SESSION['safemode'] = 1; - } - return intval($_SESSION['safemode']); + if (! array_key_exists('safemode', $_SESSION)) { + $_SESSION['safemode'] = 1; + } + return intval($_SESSION['safemode']); } function supported_imagetype($x) { - return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]); + return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]); } function get_host() { - if ($host = ((isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : EMPTY_STR)) { - $elements = explode(',', $host); - $host = trim(end($elements)); - } - else { - if (! $host = ((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : EMPTY_STR)) { - if (! $host = ((isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : EMPTY_STR)) { - $host = ((isset($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''); - } - } - } + if ($host = ((isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : EMPTY_STR)) { + $elements = explode(',', $host); + $host = trim(end($elements)); + } + else { + if (! $host = ((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : EMPTY_STR)) { + if (! $host = ((isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : EMPTY_STR)) { + $host = ((isset($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''); + } + } + } - // Remove port number from host - if (strpos($host,':') !== false) { - $host = substr($host,0,strpos($host,':')); - } - return trim($host); + // Remove port number from host + if (strpos($host,':') !== false) { + $host = substr($host,0,strpos($host,':')); + } + return trim($host); } function get_loadtime($module) { - $n = 'loadtime_' . $module; - if (isset($_SESSION[$n])) { - return $_SESSION[$n]; - } - if (local_channel()) { - $x = PConfig::Get(local_channel(),'system',$n, false); - if ($x) { - return ($x); - } - } - return datetime_convert(); + $n = 'loadtime_' . $module; + if (isset($_SESSION[$n])) { + return $_SESSION[$n]; + } + if (local_channel()) { + $x = PConfig::Get(local_channel(),'system',$n, false); + if ($x) { + return ($x); + } + } + return datetime_convert(); } \ No newline at end of file diff --git a/composer.json b/composer.json index fa884020c..e461a6ec7 100644 --- a/composer.json +++ b/composer.json @@ -1,31 +1,19 @@ { - "name" : "zot/zap", + "name" : "streams/streams", "type" : "application", - "description" : "Zot social server", + "description" : "social server", "keywords" : [ "identity", "decentralisation", "permission", "SSO", - "ZOT", - "ZOT6", "Nomad", "Fediverse", "activitypub" ], - "homepage" : "http://codeberg.org/zot/zap/", - "license" : "Unlicense", - "authors" : [{ - "name" : "Mike Macgirvin", - "role" : "founder" - } - ], - "support" : { - "issues" : "https://z.macgirvin.com/channel/zap", - "source" : "https://codeberg.org/zot/zap/" - }, + "homepage" : "http://codeberg.org/streams/streams/", "require" : { - "php" : ">=7.4", + "php" : ">=8.0", "ext-curl" : "*", "ext-gd" : "*", "ext-mbstring" : "*", @@ -74,7 +62,7 @@ }, "minimum-stability" : "stable", "config" : { - "platform": { "php": "7.4" }, + "platform": { "php": "8.0" }, "notify-on-install" : false, "optimize-autoloader" : true } From 3e383fd71d8a36befca5b5799d1cc76f95d6c0e1 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 17 Feb 2022 12:39:21 -0800 Subject: [PATCH 03/40] more unbranding --- Code/Lib/Stringsjs.php | 4 ++-- Code/Lib/System.php | 5 +---- Code/Module/Photo.php | 2 -- boot.php | 9 ++++----- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Code/Lib/Stringsjs.php b/Code/Lib/Stringsjs.php index 7ec6cb5a2..6bd24e120 100644 --- a/Code/Lib/Stringsjs.php +++ b/Code/Lib/Stringsjs.php @@ -3,14 +3,14 @@ namespace Code\Lib; use Code\Render\Theme; - +use Code\Lib\System; class Stringsjs { public static function strings() { return replace_macros(Theme::get_template('js_strings.tpl'), array( - '$icon' => '/images/' . PLATFORM_NAME . '-64.png', + '$icon' => System::get_project_icon(), '$delitem' => t('Delete this item?'), '$comment' => t('Comment'), '$showmore' => sprintf(t('%s show all'), ''), diff --git a/Code/Lib/System.php b/Code/Lib/System.php index f96a67cff..2c8517a32 100644 --- a/Code/Lib/System.php +++ b/Code/Lib/System.php @@ -53,7 +53,7 @@ class System public static function get_project_icon() { if (isset(App::$sys_channel['xchan_photo_l'])) { - return App::$sys_channel['xchan_photo_l']); + return App::$sys_channel['xchan_photo_l']; } if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('icon', App::$config['system'])) { return App::$config['system']['icon']; @@ -101,9 +101,6 @@ class System public static function get_site_icon() { - if (is_array(App::$config) && is_array(App::$config['system']) && isset(App::$config['system']['site_icon_url']) && App::$config['system']['site_icon_url']) { - return App::$config['system']['site_icon_url']; - } return self::get_project_icon(); } diff --git a/Code/Module/Photo.php b/Code/Module/Photo.php index 32996d226..abdace5ab 100644 --- a/Code/Module/Photo.php +++ b/Code/Module/Photo.php @@ -22,8 +22,6 @@ class Photo extends Controller public function init() { - - if (ActivityStreams::is_as_request()) { $sigdata = HTTPSig::verify(EMPTY_STR); if ($sigdata['portable_id'] && $sigdata['header_valid']) { diff --git a/boot.php b/boot.php index bf13518f3..f1230270c 100755 --- a/boot.php +++ b/boot.php @@ -1182,9 +1182,8 @@ class App { // webmanifest Head::add_link( [ 'rel' => 'manifest', 'href' => z_root() . '/manifest.webmanifest' ] ); - self::$meta->set('application-name', System::get_platform_name() ); - - self::$meta->set('generator', System::get_platform_name()); + self::$meta->set('application-name', System::get_project_name() ); + self::$meta->set('generator', System::get_project_name()); $i = head_get_icon(); if (! $i) { @@ -1192,8 +1191,8 @@ class App { } if ($i) { Head::add_link(['rel' => 'shortcut icon', 'href' => $i ]); - Head::add_link(['rel' => 'icon', 'sizes' => '64x64', 'href' => System::get_site_icon() ]); - Head::add_link(['rel' => 'icon', 'sizes' => '192x192', 'href' => 'images/' . System::get_platform_name() . '.svg' ]); + Head::add_link(['rel' => 'icon', 'sizes' => '64x64', 'href' => str_replace('/l/','/64/', System::get_site_icon()) ]); + Head::add_link(['rel' => 'icon', 'sizes' => '192x192', 'href' => str_replace('/l/','/192/', System::get_site_icon()) ]); } $x = [ 'header' => '' ]; From 63799fcbeb49c39f1c20001ff4460fb6484c29c8 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 17 Feb 2022 17:38:12 -0800 Subject: [PATCH 04/40] js variable scope --- view/tpl/jot-header.tpl | 112 ++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 83e87f003..2899224fe 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -1,9 +1,9 @@ "; + $o .= replace_macros(Theme::get_template('sitentry_header.tpl'), [ + '$dirlbl' => t('Affiliated Sites'), + '$desc' => $desc, + '$entries' => $j, + ]); + + if (!$j) { + $o .= '
'; + } + } return $o; } diff --git a/include/items.php b/include/items.php index e2e12dde7..622fd57b5 100644 --- a/include/items.php +++ b/include/items.php @@ -4133,7 +4133,7 @@ function fetch_post_tags($items, $link = false) { } else { if ($t['oid'] == $items[$x]['id']) { - if (! is_array($items[$x]['term'])) { + if (! (isset($items[$x]['term']) && is_array($items[$x]['term']))) { $items[$x]['term'] = []; } $items[$x]['term'][] = $t; diff --git a/view/tpl/sitesajax.tpl b/view/tpl/sitesajax.tpl new file mode 100644 index 000000000..d8b04c00f --- /dev/null +++ b/view/tpl/sitesajax.tpl @@ -0,0 +1,3 @@ +{{foreach $entries as $entry}} +{{include file="sitentry.tpl"}} +{{/foreach}} \ No newline at end of file From f897c008d470c83fbef3500e640784f4b8ea4a35 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 27 Feb 2022 12:15:20 -0800 Subject: [PATCH 33/40] fix missing author in rare cases and update strings for this repository --- Code/Lib/Activity.php | 3 +- Code/Lib/Libzot.php | 13 +- Code/Lib/Zotfinger.php | 3 +- util/messages.po | 1022 ++++++++++++++++++++-------------------- util/run_xgettext.sh | 4 +- version.php | 2 +- 6 files changed, 529 insertions(+), 518 deletions(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 550d46729..29fed0c06 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -3619,7 +3619,8 @@ class Activity $item['obj_type'] = 'Answer'; } } - } else { + } + else { if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || ($is_system && $pubstream)) { logger('allowed: permission allowed', LOGGER_DATA); $allowed = true; diff --git a/Code/Lib/Libzot.php b/Code/Lib/Libzot.php index db3f41585..755073743 100644 --- a/Code/Lib/Libzot.php +++ b/Code/Lib/Libzot.php @@ -1400,6 +1400,7 @@ class Libzot if ($has_data) { if (in_array($env['type'], ['activity', 'response'])) { + if (!(is_array($AS->actor) && isset($AS->actor['id']))) { logger('No author!'); return; @@ -1409,7 +1410,17 @@ class Libzot "select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'", dbesc($AS->actor['id']) ); - + if (! $r) { + // Author is unknown to this site. Perform channel discovery and try again. + $z = discover_by_webbie($AS->actor['id']); + if ($z) { + $r = q( + "select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'", + dbesc($AS->actor['id']) + ); + } + } + if ($r) { $r = self::zot_record_preferred($r); $arr['author_xchan'] = $r['hubloc_hash']; diff --git a/Code/Lib/Zotfinger.php b/Code/Lib/Zotfinger.php index 91964a3c9..3721347dd 100644 --- a/Code/Lib/Zotfinger.php +++ b/Code/Lib/Zotfinger.php @@ -34,7 +34,8 @@ class Zotfinger '(request-target)' => 'post ' . get_request_string($resource) ]; $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], Channel::url($channel), false); - } else { + } + else { $h = ['Accept: application/x-nomad+json, application/x-zot+json']; } diff --git a/util/messages.po b/util/messages.po index 964d952a5..b9dedfe02 100644 --- a/util/messages.po +++ b/util/messages.po @@ -1,14 +1,14 @@ -# zap -# Copyright (C) 2010-2020 zap -# This file is distributed under the same license as the zap package. +# streams +# Copyright (C) 2010-2022 streams +# This file is distributed under the same license as the streams package. # Nobody, 2010 # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 22.02.19\n" +"Project-Id-Version: 22.02.25\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-02-18 15:07-0800\n" +"POT-Creation-Date: 2022-02-24 16:01-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -27,7 +27,7 @@ msgstr "" #: Code/Module/Editwebpage.php:45 Code/Module/Hcard.php:19 #: Code/Module/Layouts.php:41 Code/Module/Menu.php:100 #: Code/Module/Profile.php:30 Code/Module/Webpages.php:48 -#: extend/addon/a/gallery/Mod_Gallery.php:52 +#: extend/addon/a/gallery/Mod_Gallery.php:54 msgid "Requested profile is not available." msgstr "" @@ -76,14 +76,14 @@ msgstr "" msgid "Edit visibility" msgstr "" -#: Code/Lib/Libprofile.php:305 include/connections.php:179 +#: Code/Lib/Libprofile.php:305 include/connections.php:183 #: include/conversation.php:998 msgid "Direct Message" msgstr "" #: Code/Lib/Libprofile.php:318 Code/Module/Directory.php:404 #: Code/Module/Fedi_id.php:55 Code/Widget/Follow.php:41 -#: Code/Widget/Suggestions.php:49 include/connections.php:151 +#: Code/Widget/Suggestions.php:49 include/connections.php:155 #: include/conversation.php:978 msgid "Connect" msgstr "" @@ -313,12 +313,12 @@ msgstr "" #: Code/Module/Mitem.php:192 Code/Module/Mitem.php:271 #: Code/Module/Mitem.php:272 Code/Module/Photos.php:738 #: Code/Module/Profiles.php:728 Code/Module/Settings/Permcats.php:117 -#: Code/Module/Settings/Display.php:117 Code/Module/Settings/Channel.php:420 +#: Code/Module/Settings/Channel.php:420 Code/Module/Settings/Display.php:118 #: Code/Module/Zot_probe.php:22 Code/Module/Sources.php:132 #: Code/Module/Sources.php:168 Code/Storage/Browser.php:435 boot.php:1718 -#: extend/addon/a/content_import/Mod_content_import.php:138 #: extend/addon/a/content_import/Mod_content_import.php:139 -#: extend/addon/a/zotpost/Mod_zotpost.php:78 include/conversation.php:1436 +#: extend/addon/a/content_import/Mod_content_import.php:140 +#: extend/addon/a/zotpost/Mod_zotpost.php:79 include/conversation.php:1436 #: include/conversation.php:1441 view/theme/redbasic/php/config.php:102 msgid "No" msgstr "" @@ -337,12 +337,12 @@ msgstr "" #: Code/Module/Mitem.php:192 Code/Module/Mitem.php:271 #: Code/Module/Mitem.php:272 Code/Module/Photos.php:738 #: Code/Module/Profiles.php:728 Code/Module/Settings/Permcats.php:117 -#: Code/Module/Settings/Display.php:117 Code/Module/Settings/Channel.php:420 +#: Code/Module/Settings/Channel.php:420 Code/Module/Settings/Display.php:118 #: Code/Module/Zot_probe.php:22 Code/Module/Sources.php:132 #: Code/Module/Sources.php:168 Code/Storage/Browser.php:435 boot.php:1718 -#: extend/addon/a/content_import/Mod_content_import.php:138 #: extend/addon/a/content_import/Mod_content_import.php:139 -#: extend/addon/a/zotpost/Mod_zotpost.php:78 include/conversation.php:1436 +#: extend/addon/a/content_import/Mod_content_import.php:140 +#: extend/addon/a/zotpost/Mod_zotpost.php:79 include/conversation.php:1436 #: include/conversation.php:1441 view/theme/redbasic/php/config.php:102 msgid "Yes" msgstr "" @@ -504,7 +504,7 @@ msgstr "" #: Code/Lib/ThreadItem.php:286 Code/Module/Admin/Profs.php:103 #: Code/Module/Admin/Profs.php:124 Code/Module/Filer.php:62 -#: Code/Widget/Notes.php:26 extend/addon/a/queueworker/Mod_Queueworker.php:116 +#: Code/Widget/Notes.php:26 extend/addon/a/queueworker/Mod_Queueworker.php:118 #: include/text.php:1053 include/text.php:1066 msgid "Save" msgstr "" @@ -678,11 +678,11 @@ msgid "Comment" msgstr "" #: Code/Lib/ThreadItem.php:954 Code/Lib/Stringsjs.php:31 -#: Code/Module/Admin/Themes.php:172 Code/Module/Admin/Security.php:172 -#: Code/Module/Admin/Profs.php:195 Code/Module/Admin/Logs.php:87 -#: Code/Module/Admin/Channels.php:175 Code/Module/Admin/Addons.php:438 +#: Code/Module/Admin/Security.php:172 Code/Module/Admin/Profs.php:195 +#: Code/Module/Admin/Logs.php:87 Code/Module/Admin/Channels.php:175 #: Code/Module/Admin/Accounts.php:181 Code/Module/Admin/Account_edit.php:81 -#: Code/Module/Admin/Site.php:281 Code/Module/Affinity.php:89 +#: Code/Module/Admin/Site.php:281 Code/Module/Admin/Addons.php:440 +#: Code/Module/Admin/Themes.php:172 Code/Module/Affinity.php:89 #: Code/Module/Ap_probe.php:27 Code/Module/Appman.php:163 #: Code/Module/Cal.php:363 Code/Module/Chat.php:214 Code/Module/Chat.php:250 #: Code/Module/Connect.php:99 Code/Module/Connedit.php:853 @@ -700,22 +700,22 @@ msgstr "" #: Code/Module/Settings/Tokens.php:317 Code/Module/Settings/Permcats.php:146 #: Code/Module/Settings/Oauth2.php:115 Code/Module/Settings/Oauth.php:98 #: Code/Module/Settings/Network.php:48 Code/Module/Settings/Features.php:66 -#: Code/Module/Settings/Featured.php:63 Code/Module/Settings/Display.php:208 -#: Code/Module/Settings/Account.php:117 Code/Module/Settings/Channel.php:631 +#: Code/Module/Settings/Featured.php:63 Code/Module/Settings/Account.php:117 +#: Code/Module/Settings/Channel.php:631 Code/Module/Settings/Display.php:209 #: Code/Module/Setup.php:334 Code/Module/Setup.php:379 #: Code/Module/Zot_probe.php:23 Code/Module/Xchan.php:18 #: Code/Module/Thing.php:364 Code/Module/Thing.php:419 #: Code/Module/Zotfinger.php:30 Code/Module/Superblock.php:257 #: Code/Module/Sources.php:133 Code/Module/Sources.php:171 #: Code/Widget/Eventstools.php:22 -#: extend/addon/a/content_import/Mod_content_import.php:143 -#: extend/addon/a/faces/faces.php:126 extend/addon/a/faces/Mod_Faces.php:181 +#: extend/addon/a/content_import/Mod_content_import.php:144 +#: extend/addon/a/faces/Mod_Faces.php:183 extend/addon/a/faces/faces.php:126 #: extend/addon/a/flashcards/Mod_Flashcards.php:265 -#: extend/addon/a/followlist/Mod_followlist.php:137 -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:56 -#: extend/addon/a/logrot/logrot.php:36 extend/addon/a/nsfw/Mod_Nsfw.php:50 -#: extend/addon/a/openstreetmap/openstreetmap.php:206 -#: extend/addon/a/zotpost/Mod_zotpost.php:82 +#: extend/addon/a/followlist/Mod_followlist.php:139 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:58 +#: extend/addon/a/logrot/logrot.php:37 extend/addon/a/nsfw/Mod_Nsfw.php:52 +#: extend/addon/a/openstreetmap/openstreetmap.php:207 +#: extend/addon/a/zotpost/Mod_zotpost.php:83 #: view/theme/redbasic/php/config.php:97 msgid "Submit" msgstr "" @@ -1541,7 +1541,7 @@ msgstr "" #: Code/Module/Connections.php:35 Code/Module/Connedit.php:341 #: Code/Module/Cover_photo.php:340 Code/Module/Cover_photo.php:354 #: Code/Module/Defperms.php:179 Code/Module/Defperms.php:185 -#: Code/Module/Display.php:514 Code/Module/Editblock.php:79 +#: Code/Module/Display.php:512 Code/Module/Editblock.php:79 #: Code/Module/Editlayout.php:77 Code/Module/Editlayout.php:100 #: Code/Module/Editpost.php:26 Code/Module/Editwebpage.php:82 #: Code/Module/Editwebpage.php:103 Code/Module/Editwebpage.php:122 @@ -1572,10 +1572,10 @@ msgstr "" #: Code/Module/Suggestions.php:35 Code/Module/Webpages.php:143 #: Code/Module/Viewconnections.php:37 Code/Module/Viewconnections.php:42 #: Code/Module/Sources.php:92 Code/Web/WebServer.php:72 include/items.php:3857 -#: include/photos.php:40 include/attach.php:163 include/attach.php:212 -#: include/attach.php:290 include/attach.php:416 include/attach.php:431 -#: include/attach.php:438 include/attach.php:517 include/attach.php:1134 -#: include/attach.php:1211 include/attach.php:1382 +#: include/attach.php:163 include/attach.php:212 include/attach.php:290 +#: include/attach.php:416 include/attach.php:431 include/attach.php:438 +#: include/attach.php:517 include/attach.php:1139 include/attach.php:1216 +#: include/attach.php:1387 include/photos.php:40 msgid "Permission denied." msgstr "" @@ -1654,7 +1654,7 @@ msgid "This email was sent by %1$s at %2$s." msgstr "" #: Code/Lib/Enotify.php:80 Code/Module/Home.php:144 Code/Module/Home.php:153 -#: extend/addon/a/opensearch/Mod_opensearch.php:28 +#: extend/addon/a/opensearch/Mod_opensearch.php:30 msgid "$Projectname" msgstr "" @@ -2008,7 +2008,7 @@ msgstr "" #: Code/Lib/Apps.php:361 Code/Module/Affinity.php:68 #: Code/Module/Connections.php:367 Code/Module/Connedit.php:677 #: Code/Module/Stream.php:139 Code/Widget/Affinity.php:33 -#: Code/Widget/Activity_filter.php:150 include/connections.php:968 +#: Code/Widget/Activity_filter.php:150 include/connections.php:972 msgid "Connections" msgstr "" @@ -2017,7 +2017,7 @@ msgid "Content Filter" msgstr "" #: Code/Lib/Apps.php:363 -#: extend/addon/a/content_import/Mod_content_import.php:136 +#: extend/addon/a/content_import/Mod_content_import.php:137 msgid "Content Import" msgstr "" @@ -2047,7 +2047,7 @@ msgstr "" msgid "Files" msgstr "" -#: Code/Lib/Apps.php:370 extend/addon/a/followlist/Mod_followlist.php:130 +#: Code/Lib/Apps.php:370 extend/addon/a/followlist/Mod_followlist.php:132 msgid "Followlist" msgstr "" @@ -2059,8 +2059,8 @@ msgstr "" msgid "Future Posting" msgstr "" -#: Code/Lib/Apps.php:373 extend/addon/a/gallery/Mod_Gallery.php:139 -#: extend/addon/a/gallery/gallery.php:47 +#: Code/Lib/Apps.php:373 extend/addon/a/gallery/Mod_Gallery.php:141 +#: extend/addon/a/gallery/gallery.php:49 msgid "Gallery" msgstr "" @@ -2196,7 +2196,7 @@ msgid "Secrets" msgstr "" #: Code/Lib/Apps.php:408 Code/Lib/Navbar.php:118 -#: Code/Module/Admin/Themes.php:139 Code/Module/Admin/Addons.php:341 +#: Code/Module/Admin/Addons.php:343 Code/Module/Admin/Themes.php:139 #: Code/Widget/Newmember.php:57 Code/Widget/Settings_menu.php:138 msgid "Settings" msgstr "" @@ -2246,7 +2246,7 @@ msgstr "" msgid "Wiki" msgstr "" -#: Code/Lib/Apps.php:421 extend/addon/a/zotpost/Mod_zotpost.php:55 +#: Code/Lib/Apps.php:421 extend/addon/a/zotpost/Mod_zotpost.php:56 msgid "ZotPost" msgstr "" @@ -2254,7 +2254,7 @@ msgstr "" msgid "Installed" msgstr "" -#: Code/Lib/Apps.php:598 Code/Module/Admin/Addons.php:422 +#: Code/Lib/Apps.php:598 Code/Module/Admin/Addons.php:424 msgid "Install" msgstr "" @@ -2485,7 +2485,7 @@ msgstr "" msgid "Available Apps" msgstr "" -#: Code/Lib/Navbar.php:332 Code/Module/Apporder.php:49 +#: Code/Lib/Navbar.php:332 Code/Module/Apporder.php:53 msgid "Arrange Apps" msgstr "" @@ -2606,7 +2606,7 @@ msgstr "" #: Code/Module/Connedit.php:640 Code/Module/Filestorage.php:233 #: Code/Module/Photos.php:744 Code/Module/Photos.php:1129 #: Code/Module/Thing.php:357 Code/Module/Thing.php:412 -#: extend/addon/a/faces/Mod_Faces.php:173 +#: extend/addon/a/faces/Mod_Faces.php:175 #: extend/addon/a/flashcards/Mod_Flashcards.php:257 msgid "Permissions" msgstr "" @@ -2775,9 +2775,9 @@ msgstr "" msgid "network" msgstr "" -#: Code/Module/Admin.php:94 Code/Module/Admin/Themes.php:82 -#: Code/Module/Admin/Addons.php:262 Code/Module/Display.php:69 -#: Code/Module/Display.php:517 Code/Module/Filestorage.php:41 +#: Code/Module/Admin.php:94 Code/Module/Admin/Addons.php:264 +#: Code/Module/Admin/Themes.php:82 Code/Module/Display.php:69 +#: Code/Module/Display.php:515 Code/Module/Filestorage.php:41 #: Code/Module/Inspect.php:35 Code/Module/Search.php:189 #: Code/Module/Viewsrc.php:29 Code/Module/Thing.php:110 #: extend/addon/a/flashcards/Mod_Flashcards.php:287 @@ -2818,11 +2818,11 @@ msgstr "" msgid "Your software should be updated" msgstr "" -#: Code/Module/Admin.php:173 Code/Module/Admin/Themes.php:136 -#: Code/Module/Admin/Themes.php:170 Code/Module/Admin/Security.php:138 +#: Code/Module/Admin.php:173 Code/Module/Admin/Security.php:138 #: Code/Module/Admin/Logs.php:85 Code/Module/Admin/Channels.php:173 -#: Code/Module/Admin/Addons.php:338 Code/Module/Admin/Addons.php:436 #: Code/Module/Admin/Accounts.php:179 Code/Module/Admin/Site.php:279 +#: Code/Module/Admin/Addons.php:340 Code/Module/Admin/Addons.php:438 +#: Code/Module/Admin/Themes.php:136 Code/Module/Admin/Themes.php:170 msgid "Administration" msgstr "" @@ -2858,51 +2858,6 @@ msgstr "" msgid "Repository version (dev)" msgstr "" -#: Code/Module/Admin/Themes.php:31 -msgid "Theme settings updated." -msgstr "" - -#: Code/Module/Admin/Themes.php:71 -msgid "No themes found." -msgstr "" - -#: Code/Module/Admin/Themes.php:107 Code/Module/Admin/Addons.php:306 -msgid "Disable" -msgstr "" - -#: Code/Module/Admin/Themes.php:110 Code/Module/Admin/Addons.php:309 -msgid "Enable" -msgstr "" - -#: Code/Module/Admin/Themes.php:129 -msgid "Screenshot" -msgstr "" - -#: Code/Module/Admin/Themes.php:137 Code/Module/Admin/Themes.php:171 -#: Code/Widget/Admin.php:37 -msgid "Themes" -msgstr "" - -#: Code/Module/Admin/Themes.php:138 Code/Module/Admin/Addons.php:340 -msgid "Toggle" -msgstr "" - -#: Code/Module/Admin/Themes.php:148 Code/Module/Admin/Addons.php:348 -msgid "Author: " -msgstr "" - -#: Code/Module/Admin/Themes.php:149 Code/Module/Admin/Addons.php:349 -msgid "Maintainer: " -msgstr "" - -#: Code/Module/Admin/Themes.php:176 -msgid "[Experimental]" -msgstr "" - -#: Code/Module/Admin/Themes.php:177 -msgid "[Unsupported]" -msgstr "" - #: Code/Module/Admin/Security.php:129 msgid "" "By default, unfiltered HTML is allowed in embedded media. This is inherently " @@ -3286,7 +3241,7 @@ msgid "Use a photo from your albums" msgstr "" #: Code/Module/Admin/Profile_photo.php:478 -#: Code/Module/Admin/Cover_photo.php:382 Code/Module/Admin/Addons.php:423 +#: Code/Module/Admin/Cover_photo.php:382 Code/Module/Admin/Addons.php:425 #: Code/Module/Card_edit.php:142 Code/Module/Cdav.php:1066 #: Code/Module/Cdav.php:1374 Code/Module/Connedit.php:890 #: Code/Module/Cover_photo.php:428 Code/Module/Editblock.php:156 @@ -3579,99 +3534,6 @@ msgid "" "channel on this site will be permanently deleted!\\n\\nAre you sure?" msgstr "" -#: Code/Module/Admin/Addons.php:286 -#, php-format -msgid "Plugin %s disabled." -msgstr "" - -#: Code/Module/Admin/Addons.php:290 -#, php-format -msgid "Plugin %s enabled." -msgstr "" - -#: Code/Module/Admin/Addons.php:339 Code/Module/Admin/Addons.php:437 -#: Code/Widget/Admin.php:36 -msgid "Addons" -msgstr "" - -#: Code/Module/Admin/Addons.php:350 -msgid "Minimum project version: " -msgstr "" - -#: Code/Module/Admin/Addons.php:351 -msgid "Maximum project version: " -msgstr "" - -#: Code/Module/Admin/Addons.php:352 -msgid "Minimum PHP version: " -msgstr "" - -#: Code/Module/Admin/Addons.php:353 -msgid "Compatible Server Roles: " -msgstr "" - -#: Code/Module/Admin/Addons.php:354 -msgid "Requires: " -msgstr "" - -#: Code/Module/Admin/Addons.php:355 Code/Module/Admin/Addons.php:442 -msgid "Disabled - version incompatibility" -msgstr "" - -#: Code/Module/Admin/Addons.php:410 -msgid "Enter the public git repository URL of the addon repo." -msgstr "" - -#: Code/Module/Admin/Addons.php:411 -msgid "Addon repo git URL" -msgstr "" - -#: Code/Module/Admin/Addons.php:412 -msgid "Custom repo name" -msgstr "" - -#: Code/Module/Admin/Addons.php:412 -msgid "(optional)" -msgstr "" - -#: Code/Module/Admin/Addons.php:413 -msgid "Download Addon Repo" -msgstr "" - -#: Code/Module/Admin/Addons.php:421 -msgid "Install new repo" -msgstr "" - -#: Code/Module/Admin/Addons.php:445 -msgid "Manage Repos" -msgstr "" - -#: Code/Module/Admin/Addons.php:446 -msgid "Installed Addon Repositories" -msgstr "" - -#: Code/Module/Admin/Addons.php:447 -msgid "Install a New Addon Repository" -msgstr "" - -#: Code/Module/Admin/Addons.php:453 Code/Module/Cdav.php:1061 -#: Code/Module/Cdav.php:1372 Code/Module/Connedit.php:888 -#: Code/Module/Profiles.php:852 Code/Module/Settings/Oauth2.php:57 -#: Code/Module/Settings/Oauth2.php:145 Code/Module/Settings/Oauth.php:48 -#: Code/Module/Settings/Oauth.php:126 -msgid "Update" -msgstr "" - -#: Code/Module/Admin/Addons.php:454 -msgid "Switch branch" -msgstr "" - -#: Code/Module/Admin/Addons.php:455 Code/Module/Photos.php:1076 -#: Code/Module/Tagrm.php:151 Code/Module/Superblock.php:236 -#: Code/Module/Superblock.php:253 -msgid "Remove" -msgstr "" - #: Code/Module/Admin/Accounts.php:44 #, php-format msgid "%s account blocked/unblocked" @@ -3814,7 +3676,7 @@ msgstr "" msgid "Default" msgstr "" -#: Code/Module/Admin/Site.php:224 Code/Module/Settings/Display.php:151 +#: Code/Module/Admin/Site.php:224 Code/Module/Settings/Display.php:152 #, php-format msgid "%s - (Incompatible)" msgstr "" @@ -3971,7 +3833,7 @@ msgid "Minimum age (in years) for who may register on this site." msgstr "" #: Code/Module/Admin/Site.php:302 -msgid "Which best describes the types of account offered by this hub?" +msgid "Which best describes the types of account offered by this site?" msgstr "" #: Code/Module/Admin/Site.php:302 @@ -4265,6 +4127,144 @@ msgstr "" msgid "Region or country - shared with other sites" msgstr "" +#: Code/Module/Admin/Addons.php:288 +#, php-format +msgid "Plugin %s disabled." +msgstr "" + +#: Code/Module/Admin/Addons.php:292 +#, php-format +msgid "Plugin %s enabled." +msgstr "" + +#: Code/Module/Admin/Addons.php:308 Code/Module/Admin/Themes.php:107 +msgid "Disable" +msgstr "" + +#: Code/Module/Admin/Addons.php:311 Code/Module/Admin/Themes.php:110 +msgid "Enable" +msgstr "" + +#: Code/Module/Admin/Addons.php:341 Code/Module/Admin/Addons.php:439 +#: Code/Widget/Admin.php:36 +msgid "Addons" +msgstr "" + +#: Code/Module/Admin/Addons.php:342 Code/Module/Admin/Themes.php:138 +msgid "Toggle" +msgstr "" + +#: Code/Module/Admin/Addons.php:350 Code/Module/Admin/Themes.php:148 +msgid "Author: " +msgstr "" + +#: Code/Module/Admin/Addons.php:351 Code/Module/Admin/Themes.php:149 +msgid "Maintainer: " +msgstr "" + +#: Code/Module/Admin/Addons.php:352 +msgid "Minimum project version: " +msgstr "" + +#: Code/Module/Admin/Addons.php:353 +msgid "Maximum project version: " +msgstr "" + +#: Code/Module/Admin/Addons.php:354 +msgid "Minimum PHP version: " +msgstr "" + +#: Code/Module/Admin/Addons.php:355 +msgid "Compatible Server Roles: " +msgstr "" + +#: Code/Module/Admin/Addons.php:356 +msgid "Requires: " +msgstr "" + +#: Code/Module/Admin/Addons.php:357 Code/Module/Admin/Addons.php:444 +msgid "Disabled - version incompatibility" +msgstr "" + +#: Code/Module/Admin/Addons.php:412 +msgid "Enter the public git repository URL of the addon repo." +msgstr "" + +#: Code/Module/Admin/Addons.php:413 +msgid "Addon repo git URL" +msgstr "" + +#: Code/Module/Admin/Addons.php:414 +msgid "Custom repo name" +msgstr "" + +#: Code/Module/Admin/Addons.php:414 +msgid "(optional)" +msgstr "" + +#: Code/Module/Admin/Addons.php:415 +msgid "Download Addon Repo" +msgstr "" + +#: Code/Module/Admin/Addons.php:423 +msgid "Install new repo" +msgstr "" + +#: Code/Module/Admin/Addons.php:447 +msgid "Manage Repos" +msgstr "" + +#: Code/Module/Admin/Addons.php:448 +msgid "Installed Addon Repositories" +msgstr "" + +#: Code/Module/Admin/Addons.php:449 +msgid "Install a New Addon Repository" +msgstr "" + +#: Code/Module/Admin/Addons.php:455 Code/Module/Cdav.php:1061 +#: Code/Module/Cdav.php:1372 Code/Module/Connedit.php:888 +#: Code/Module/Profiles.php:852 Code/Module/Settings/Oauth2.php:57 +#: Code/Module/Settings/Oauth2.php:145 Code/Module/Settings/Oauth.php:48 +#: Code/Module/Settings/Oauth.php:126 +msgid "Update" +msgstr "" + +#: Code/Module/Admin/Addons.php:456 +msgid "Switch branch" +msgstr "" + +#: Code/Module/Admin/Addons.php:457 Code/Module/Photos.php:1076 +#: Code/Module/Tagrm.php:151 Code/Module/Superblock.php:236 +#: Code/Module/Superblock.php:253 +msgid "Remove" +msgstr "" + +#: Code/Module/Admin/Themes.php:31 +msgid "Theme settings updated." +msgstr "" + +#: Code/Module/Admin/Themes.php:71 +msgid "No themes found." +msgstr "" + +#: Code/Module/Admin/Themes.php:129 +msgid "Screenshot" +msgstr "" + +#: Code/Module/Admin/Themes.php:137 Code/Module/Admin/Themes.php:171 +#: Code/Widget/Admin.php:37 +msgid "Themes" +msgstr "" + +#: Code/Module/Admin/Themes.php:176 +msgid "[Experimental]" +msgstr "" + +#: Code/Module/Admin/Themes.php:177 +msgid "[Unsupported]" +msgstr "" + #: Code/Module/Affinity.php:34 msgid "Friend Zoom settings updated." msgstr "" @@ -4410,21 +4410,21 @@ msgstr "" msgid "Location (URL) to purchase app" msgstr "" -#: Code/Module/Apporder.php:50 +#: Code/Module/Apporder.php:54 msgid "Change order of pinned navbar apps" msgstr "" -#: Code/Module/Apporder.php:50 +#: Code/Module/Apporder.php:54 msgid "Change order of app tray apps" msgstr "" -#: Code/Module/Apporder.php:51 +#: Code/Module/Apporder.php:55 msgid "" "Use arrows to move the corresponding app left (top) or right (bottom) in the " "navbar" msgstr "" -#: Code/Module/Apporder.php:52 +#: Code/Module/Apporder.php:56 msgid "Use arrows to move the corresponding app up or down in the app tray" msgstr "" @@ -4675,8 +4675,8 @@ msgstr "" msgid "CardDAV App" msgstr "" -#: Code/Module/Cdav.php:893 extend/addon/a/fuzzloc/Mod_Fuzzloc.php:37 -#: extend/addon/a/gallery/Mod_Gallery.php:61 +#: Code/Module/Cdav.php:893 extend/addon/a/fuzzloc/Mod_Fuzzloc.php:39 +#: extend/addon/a/gallery/Mod_Gallery.php:63 msgid "Not Installed" msgstr "" @@ -4777,19 +4777,19 @@ msgid "Note" msgstr "" #: Code/Module/Cdav.php:1365 Code/Module/Connedit.php:881 -#: Code/Module/Profiles.php:845 include/connections.php:839 +#: Code/Module/Profiles.php:845 include/connections.php:843 #: include/event.php:1515 msgid "Mobile" msgstr "" #: Code/Module/Cdav.php:1366 Code/Module/Connedit.php:882 -#: Code/Module/Profiles.php:846 include/connections.php:840 +#: Code/Module/Profiles.php:846 include/connections.php:844 #: include/event.php:1516 msgid "Home" msgstr "" #: Code/Module/Cdav.php:1367 Code/Module/Connedit.php:883 -#: Code/Module/Profiles.php:847 include/connections.php:843 +#: Code/Module/Profiles.php:847 include/connections.php:847 #: include/event.php:1519 msgid "Work" msgstr "" @@ -4797,8 +4797,8 @@ msgstr "" #: Code/Module/Cdav.php:1368 Code/Module/Connedit.php:884 #: Code/Module/Profiles.php:848 Code/Module/Profiles.php:989 #: Code/Module/Profiles.php:1007 Code/Module/Profiles.php:1077 -#: Code/Module/Profiles.php:1114 include/connections.php:846 -#: include/connections.php:852 include/event.php:1522 include/event.php:1528 +#: Code/Module/Profiles.php:1114 include/connections.php:850 +#: include/connections.php:856 include/event.php:1522 include/event.php:1528 msgid "Other" msgstr "" @@ -4913,7 +4913,7 @@ msgstr "" msgid "Reset form" msgstr "" -#: Code/Module/Channel.php:562 Code/Module/Display.php:442 +#: Code/Module/Channel.php:562 Code/Module/Display.php:440 msgid "" "You must enable javascript for your browser to be able to view this content." msgstr "" @@ -5546,7 +5546,7 @@ msgstr "" msgid "Do not import posts with this text" msgstr "" -#: Code/Module/Connedit.php:842 extend/addon/a/zotpost/Mod_zotpost.php:70 +#: Code/Module/Connedit.php:842 extend/addon/a/zotpost/Mod_zotpost.php:71 msgid "Nickname" msgstr "" @@ -5650,8 +5650,8 @@ msgid "%1$s updated their %2$s" msgstr "" #: Code/Module/Defperms.php:106 Code/Module/Settings/Channel.php:365 -#: extend/addon/a/faces/faces.php:209 extend/addon/a/logrot/logrot.php:55 -#: extend/addon/a/openstreetmap/openstreetmap.php:223 +#: extend/addon/a/faces/faces.php:209 extend/addon/a/logrot/logrot.php:56 +#: extend/addon/a/openstreetmap/openstreetmap.php:224 msgid "Settings updated." msgstr "" @@ -5770,50 +5770,50 @@ msgstr "" msgid "No entries (some entries may be hidden)." msgstr "" -#: Code/Module/Display.php:395 +#: Code/Module/Display.php:393 #, php-format msgid "\"%1$s\", shared by %2$s with %3$s" msgstr "" -#: Code/Module/Display.php:396 +#: Code/Module/Display.php:394 #, php-format msgid "%1$s shared this post with %2$s" msgstr "" -#: Code/Module/Display.php:400 +#: Code/Module/Display.php:398 msgid "Not much to read, click to see the post." msgstr "" -#: Code/Module/Display.php:404 +#: Code/Module/Display.php:402 #, php-format msgid "%1$s shared a reaction to \"%2$s\"" msgstr "" -#: Code/Module/Display.php:405 +#: Code/Module/Display.php:403 #, php-format msgid "%s shared a reaction to this post/conversation" msgstr "" -#: Code/Module/Display.php:412 +#: Code/Module/Display.php:410 #, php-format msgid "%1$s commented \"%2$s\"" msgstr "" -#: Code/Module/Display.php:413 +#: Code/Module/Display.php:411 #, php-format msgid "%s shared a comment of this post/conversation" msgstr "" -#: Code/Module/Display.php:417 +#: Code/Module/Display.php:415 #, php-format msgid "%1$s wrote this: \"%2$s\"" msgstr "" -#: Code/Module/Display.php:459 +#: Code/Module/Display.php:457 msgid "Article" msgstr "" -#: Code/Module/Display.php:512 +#: Code/Module/Display.php:510 msgid "Item has been removed." msgstr "" @@ -6163,7 +6163,7 @@ msgstr "" msgid "Move to directory" msgstr "" -#: Code/Module/Filestorage.php:242 extend/addon/a/faces/Mod_Faces.php:180 +#: Code/Module/Filestorage.php:242 extend/addon/a/faces/Mod_Faces.php:182 #: extend/addon/a/flashcards/Mod_Flashcards.php:264 msgid "Set/edit permissions" msgstr "" @@ -7129,14 +7129,6 @@ msgstr "" msgid "A notification with that id was not found for channel '%s'" msgstr "" -#: Code/Module/Oexchange.php:30 -msgid "Unable to find your site." -msgstr "" - -#: Code/Module/Oexchange.php:44 -msgid "Post successful." -msgstr "" - #: Code/Module/Page.php:188 msgid "" "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " @@ -8425,101 +8417,6 @@ msgstr "" msgid "Please save/submit changes to any panel before opening another." msgstr "" -#: Code/Module/Settings/Display.php:160 -#, php-format -msgid "%s - (Experimental)" -msgstr "" - -#: Code/Module/Settings/Display.php:203 -msgid "Display Settings" -msgstr "" - -#: Code/Module/Settings/Display.php:204 -msgid "Theme Settings" -msgstr "" - -#: Code/Module/Settings/Display.php:205 -msgid "Custom Theme Settings" -msgstr "" - -#: Code/Module/Settings/Display.php:206 -msgid "Content Settings" -msgstr "" - -#: Code/Module/Settings/Display.php:212 -msgid "Display Theme:" -msgstr "" - -#: Code/Module/Settings/Display.php:213 -msgid "Select scheme" -msgstr "" - -#: Code/Module/Settings/Display.php:215 -msgid "Preload images before rendering the page" -msgstr "" - -#: Code/Module/Settings/Display.php:215 -msgid "" -"The subjective page load time will be longer but the page will be ready when " -"displayed" -msgstr "" - -#: Code/Module/Settings/Display.php:216 -msgid "Enable user zoom on mobile devices" -msgstr "" - -#: Code/Module/Settings/Display.php:217 -msgid "Update notifications every xx seconds" -msgstr "" - -#: Code/Module/Settings/Display.php:217 -msgid "Minimum of 15 seconds, no maximum" -msgstr "" - -#: Code/Module/Settings/Display.php:218 -msgid "Maximum number of conversations to load at any time:" -msgstr "" - -#: Code/Module/Settings/Display.php:218 -msgid "Maximum of 100 items" -msgstr "" - -#: Code/Module/Settings/Display.php:219 -msgid "Show emoticons (smilies) as images" -msgstr "" - -#: Code/Module/Settings/Display.php:220 -msgid "Provide channel menu in navigation bar" -msgstr "" - -#: Code/Module/Settings/Display.php:220 -msgid "Default: channel menu located in app menu" -msgstr "" - -#: Code/Module/Settings/Display.php:221 -msgid "System Page Layout Editor - (advanced)" -msgstr "" - -#: Code/Module/Settings/Display.php:224 -msgid "Channel page max height of content (in pixels)" -msgstr "" - -#: Code/Module/Settings/Display.php:224 Code/Module/Settings/Display.php:225 -msgid "click to expand content exceeding this height" -msgstr "" - -#: Code/Module/Settings/Display.php:225 -msgid "Stream page max height of content (in pixels)" -msgstr "" - -#: Code/Module/Settings/Display.php:226 -msgid "Indent threaded comments this many pixels from the parent" -msgstr "" - -#: Code/Module/Settings/Display.php:226 -msgid "0-20" -msgstr "" - #: Code/Module/Settings/Account.php:26 msgid "Not valid email." msgstr "" @@ -9037,6 +8934,101 @@ msgstr "" msgid "This varies by country/culture" msgstr "" +#: Code/Module/Settings/Display.php:161 +#, php-format +msgid "%s - (Experimental)" +msgstr "" + +#: Code/Module/Settings/Display.php:204 +msgid "Display Settings" +msgstr "" + +#: Code/Module/Settings/Display.php:205 +msgid "Theme Settings" +msgstr "" + +#: Code/Module/Settings/Display.php:206 +msgid "Custom Theme Settings" +msgstr "" + +#: Code/Module/Settings/Display.php:207 +msgid "Content Settings" +msgstr "" + +#: Code/Module/Settings/Display.php:213 +msgid "Display Theme:" +msgstr "" + +#: Code/Module/Settings/Display.php:214 +msgid "Select scheme" +msgstr "" + +#: Code/Module/Settings/Display.php:216 +msgid "Preload images before rendering the page" +msgstr "" + +#: Code/Module/Settings/Display.php:216 +msgid "" +"The subjective page load time will be longer but the page will be ready when " +"displayed" +msgstr "" + +#: Code/Module/Settings/Display.php:217 +msgid "Enable user zoom on mobile devices" +msgstr "" + +#: Code/Module/Settings/Display.php:218 +msgid "Update notifications every xx seconds" +msgstr "" + +#: Code/Module/Settings/Display.php:218 +msgid "Minimum of 15 seconds, no maximum" +msgstr "" + +#: Code/Module/Settings/Display.php:219 +msgid "Maximum number of conversations to load at any time:" +msgstr "" + +#: Code/Module/Settings/Display.php:219 +msgid "Maximum of 100 items" +msgstr "" + +#: Code/Module/Settings/Display.php:220 +msgid "Show emoticons (smilies) as images" +msgstr "" + +#: Code/Module/Settings/Display.php:221 +msgid "Provide channel menu in navigation bar" +msgstr "" + +#: Code/Module/Settings/Display.php:221 +msgid "Default: channel menu located in app menu" +msgstr "" + +#: Code/Module/Settings/Display.php:222 +msgid "System Page Layout Editor - (advanced)" +msgstr "" + +#: Code/Module/Settings/Display.php:225 +msgid "Channel page max height of content (in pixels)" +msgstr "" + +#: Code/Module/Settings/Display.php:225 Code/Module/Settings/Display.php:226 +msgid "click to expand content exceeding this height" +msgstr "" + +#: Code/Module/Settings/Display.php:226 +msgid "Stream page max height of content (in pixels)" +msgstr "" + +#: Code/Module/Settings/Display.php:227 +msgid "Indent threaded comments this many pixels from the parent" +msgstr "" + +#: Code/Module/Settings/Display.php:227 +msgid "0-20" +msgstr "" + #: Code/Module/Setup.php:194 msgid "$Projectname Server - Setup" msgstr "" @@ -9761,7 +9753,7 @@ msgstr "" msgid "Access list: %s" msgstr "" -#: Code/Module/Stream.php:349 extend/addon/a/zotpost/Mod_zotpost.php:30 +#: Code/Module/Stream.php:349 extend/addon/a/zotpost/Mod_zotpost.php:31 msgid "Invalid channel." msgstr "" @@ -10822,19 +10814,19 @@ msgstr "" msgid "never" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:28 +#: extend/addon/a/content_import/Mod_content_import.php:29 msgid "No server specified" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:74 +#: extend/addon/a/content_import/Mod_content_import.php:75 msgid "Posts imported" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:114 +#: extend/addon/a/content_import/Mod_content_import.php:115 msgid "Files imported" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:123 +#: extend/addon/a/content_import/Mod_content_import.php:124 msgid "" "This addon app copies existing content and file storage to a cloned/copied " "channel. Once the app is installed, visit the newly installed app. This will " @@ -10842,137 +10834,137 @@ msgid "" "range of files/conversations to copy." msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:137 +#: extend/addon/a/content_import/Mod_content_import.php:138 msgid "" "This will import all your conversations and cloud files from a cloned " "channel on another server. This may take a while if you have lots of posts " "and or files." msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:138 +#: extend/addon/a/content_import/Mod_content_import.php:139 msgid "Include posts" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:138 +#: extend/addon/a/content_import/Mod_content_import.php:139 msgid "Conversations, Articles, Cards, and other posted content" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:139 +#: extend/addon/a/content_import/Mod_content_import.php:140 msgid "Include files" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:139 +#: extend/addon/a/content_import/Mod_content_import.php:140 msgid "Files, Photos and other cloud storage" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:140 +#: extend/addon/a/content_import/Mod_content_import.php:141 msgid "Original Server base URL" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:141 +#: extend/addon/a/content_import/Mod_content_import.php:142 msgid "Since modified date yyyy-mm-dd" msgstr "" -#: extend/addon/a/content_import/Mod_content_import.php:142 +#: extend/addon/a/content_import/Mod_content_import.php:143 msgid "Until modified date yyyy-mm-dd" msgstr "" +#: extend/addon/a/faces/Mod_Faces.php:63 +#: extend/addon/a/flashcards/Mod_Flashcards.php:55 +msgid "Profile Unavailable." +msgstr "" + +#: extend/addon/a/faces/Mod_Faces.php:1697 +msgid "Face detection is not activated" +msgstr "" + +#: extend/addon/a/faces/Mod_Faces.php:1707 +msgid "Face detection is still busy" +msgstr "" + #: extend/addon/a/faces/faces.php:238 msgid "Errors encountered deleting all rows of database table " msgstr "" -#: extend/addon/a/faces/Mod_Faces.php:61 -#: extend/addon/a/flashcards/Mod_Flashcards.php:55 -msgid "Profile Unavailable." -msgstr "" - -#: extend/addon/a/faces/Mod_Faces.php:1695 -msgid "Face detection is not activated" -msgstr "" - -#: extend/addon/a/faces/Mod_Faces.php:1705 -msgid "Face detection is still busy" -msgstr "" - #: extend/addon/a/flashcards/Mod_Flashcards.php:222 msgid "Not allowed." msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:73 +#: extend/addon/a/followlist/Mod_followlist.php:75 msgid "Adding connections" msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:87 +#: extend/addon/a/followlist/Mod_followlist.php:89 msgid "Connect failed: " msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:87 +#: extend/addon/a/followlist/Mod_followlist.php:89 msgid " Reason: " msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:90 +#: extend/addon/a/followlist/Mod_followlist.php:92 msgid "Finished adding connections" msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:97 +#: extend/addon/a/followlist/Mod_followlist.php:99 msgid "" "This app allows you to connect to everybody in a pre-defined ActivityPub " "collection or CSV file, such as follower/following lists. Install the app " "and revisit this page to input the source URL." msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:131 +#: extend/addon/a/followlist/Mod_followlist.php:133 #, php-format msgid "You may import up to %d records" msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:134 +#: extend/addon/a/followlist/Mod_followlist.php:136 msgid "" "Enter the URL of an ActivityPub followers/following collection to import" msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:135 +#: extend/addon/a/followlist/Mod_followlist.php:137 msgid "Or upload an ActivityPub or CSV followers file from your device" msgstr "" -#: extend/addon/a/followlist/Mod_followlist.php:136 +#: extend/addon/a/followlist/Mod_followlist.php:138 msgid "URL of followers/following list" msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:24 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:26 msgid "Fuzzloc Settings updated." msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:37 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:39 msgid "Fuzzy Location App" msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:38 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:40 msgid "" "Blur your precise location if your channel uses browser location mapping" msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:43 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:45 msgid "Minimum offset in meters" msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:47 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:49 msgid "Maximum offset in meters" msgstr "" -#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:53 +#: extend/addon/a/fuzzloc/Mod_Fuzzloc.php:55 msgid "Fuzzy Location" msgstr "" -#: extend/addon/a/gallery/Mod_Gallery.php:61 +#: extend/addon/a/gallery/Mod_Gallery.php:63 msgid "Gallery App" msgstr "" -#: extend/addon/a/gallery/Mod_Gallery.php:62 +#: extend/addon/a/gallery/Mod_Gallery.php:64 msgid "A simple gallery for your photo albums" msgstr "" -#: extend/addon/a/gallery/gallery.php:50 +#: extend/addon/a/gallery/gallery.php:52 msgid "Photo Gallery" msgstr "" @@ -10984,52 +10976,22 @@ msgstr "" msgid "Authentication successful but rejected: account creation is disabled." msgstr "" -#: extend/addon/a/logrot/logrot.php:37 +#: extend/addon/a/logrot/logrot.php:38 msgid "Logfile archive directory" msgstr "" -#: extend/addon/a/logrot/logrot.php:37 +#: extend/addon/a/logrot/logrot.php:38 msgid "Directory to store rotated logs" msgstr "" -#: extend/addon/a/logrot/logrot.php:38 +#: extend/addon/a/logrot/logrot.php:39 msgid "Logfile size in bytes before rotating, example 10M" msgstr "" -#: extend/addon/a/logrot/logrot.php:39 +#: extend/addon/a/logrot/logrot.php:40 msgid "Number of logfiles to retain" msgstr "" -#: extend/addon/a/nsfw/Mod_Nsfw.php:20 -msgid "NSFW Settings saved." -msgstr "" - -#: extend/addon/a/nsfw/Mod_Nsfw.php:30 -msgid "" -"This addon app looks in posts for the words/text you specify below, and " -"collapses any content containing those keywords so it is not displayed at " -"inappropriate times, such as sexual innuendo that may be improper in a work " -"setting. It is polite and recommended to tag any content containing nudity " -"with #NSFW. This filter can also match any other word/text you specify, and " -"can thereby be used as a general purpose content filter." -msgstr "" - -#: extend/addon/a/nsfw/Mod_Nsfw.php:42 -msgid "Comma separated list of keywords to hide" -msgstr "" - -#: extend/addon/a/nsfw/Mod_Nsfw.php:42 -msgid "Word, /regular-expression/, lang=xx, lang!=xx" -msgstr "" - -#: extend/addon/a/nsfw/Mod_Nsfw.php:50 -msgid "Not Safe For Work Settings" -msgstr "" - -#: extend/addon/a/nsfw/Mod_Nsfw.php:50 -msgid "General Purpose Content Filter" -msgstr "" - #: extend/addon/a/nsfw/nsfw.php:162 msgid "Conversation muted" msgstr "" @@ -11043,8 +11005,34 @@ msgstr "" msgid "%s - view" msgstr "" -#: extend/addon/a/opensearch/Mod_opensearch.php:29 -msgid "Search $Projectname" +#: extend/addon/a/nsfw/Mod_Nsfw.php:22 +msgid "NSFW Settings saved." +msgstr "" + +#: extend/addon/a/nsfw/Mod_Nsfw.php:32 +msgid "" +"This addon app looks in posts for the words/text you specify below, and " +"collapses any content containing those keywords so it is not displayed at " +"inappropriate times, such as sexual innuendo that may be improper in a work " +"setting. It is polite and recommended to tag any content containing nudity " +"with #NSFW. This filter can also match any other word/text you specify, and " +"can thereby be used as a general purpose content filter." +msgstr "" + +#: extend/addon/a/nsfw/Mod_Nsfw.php:44 +msgid "Comma separated list of keywords to hide" +msgstr "" + +#: extend/addon/a/nsfw/Mod_Nsfw.php:44 +msgid "Word, /regular-expression/, lang=xx, lang!=xx" +msgstr "" + +#: extend/addon/a/nsfw/Mod_Nsfw.php:52 +msgid "Not Safe For Work Settings" +msgstr "" + +#: extend/addon/a/nsfw/Mod_Nsfw.php:52 +msgid "General Purpose Content Filter" msgstr "" #: extend/addon/a/opensearch/opensearch.php:34 @@ -11058,92 +11046,96 @@ msgctxt "opensearch" msgid "$Projectname" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:145 +#: extend/addon/a/opensearch/Mod_opensearch.php:31 +msgid "Search $Projectname" +msgstr "" + +#: extend/addon/a/openstreetmap/openstreetmap.php:146 msgid "View Larger" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:207 +#: extend/addon/a/openstreetmap/openstreetmap.php:208 msgid "Tile Server URL" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:207 +#: extend/addon/a/openstreetmap/openstreetmap.php:208 msgid "" "A list of public tile servers" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:208 +#: extend/addon/a/openstreetmap/openstreetmap.php:209 msgid "Nominatim (reverse geocoding) Server URL" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:208 +#: extend/addon/a/openstreetmap/openstreetmap.php:209 msgid "" "A list of Nominatim servers" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:209 +#: extend/addon/a/openstreetmap/openstreetmap.php:210 msgid "Default zoom" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:209 +#: extend/addon/a/openstreetmap/openstreetmap.php:210 msgid "" "The default zoom level. (1:world, 18:highest, also depends on tile server)" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:210 +#: extend/addon/a/openstreetmap/openstreetmap.php:211 msgid "Include marker on map" msgstr "" -#: extend/addon/a/openstreetmap/openstreetmap.php:210 +#: extend/addon/a/openstreetmap/openstreetmap.php:211 msgid "Include a marker on the map." msgstr "" -#: extend/addon/a/qrator/Mod_qrator.php:10 -msgid "QR Generator (Qrator)" -msgstr "" - -#: extend/addon/a/qrator/Mod_qrator.php:11 -msgid "Enter some text" -msgstr "" - #: extend/addon/a/qrator/qrator.php:44 msgid "QR code" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:77 -msgid "Max queueworker threads" +#: extend/addon/a/qrator/Mod_qrator.php:12 +msgid "QR Generator (Qrator)" +msgstr "" + +#: extend/addon/a/qrator/Mod_qrator.php:13 +msgid "Enter some text" msgstr "" #: extend/addon/a/queueworker/Mod_Queueworker.php:79 +msgid "Max queueworker threads" +msgstr "" + +#: extend/addon/a/queueworker/Mod_Queueworker.php:81 msgid "Minimum 4, default 4" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:90 +#: extend/addon/a/queueworker/Mod_Queueworker.php:92 msgid "Assume workers dead after" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:92 +#: extend/addon/a/queueworker/Mod_Queueworker.php:94 msgid "Minimum 120, default 300 seconds" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:103 +#: extend/addon/a/queueworker/Mod_Queueworker.php:105 msgid "Pause before starting next task" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:105 +#: extend/addon/a/queueworker/Mod_Queueworker.php:107 msgid "Minimum 100, default 100 microseconds" msgstr "" -#: extend/addon/a/queueworker/Mod_Queueworker.php:113 +#: extend/addon/a/queueworker/Mod_Queueworker.php:115 msgid "Queueworker Settings" msgstr "" -#: extend/addon/a/rainbowtag/Mod_Rainbowtag.php:15 +#: extend/addon/a/rainbowtag/Mod_Rainbowtag.php:17 msgid "Add some colour to tag clouds" msgstr "" -#: extend/addon/a/rainbowtag/Mod_Rainbowtag.php:34 +#: extend/addon/a/rainbowtag/Mod_Rainbowtag.php:36 msgid "Rainbow Tag" msgstr "" @@ -11172,79 +11164,79 @@ msgstr "" msgid "Post to Zot" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:25 +#: extend/addon/a/zotpost/Mod_zotpost.php:26 msgid "Channel is required." msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:38 +#: extend/addon/a/zotpost/Mod_zotpost.php:39 msgid "Zotpost Settings saved." msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:46 +#: extend/addon/a/zotpost/Mod_zotpost.php:47 msgid "" "This addon app allows you to cross-post to other Zot services and channels. " "After installing the app, select it to configure the destination settings " "and preferences." msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:66 +#: extend/addon/a/zotpost/Mod_zotpost.php:67 msgid "Zot server URL" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:66 +#: extend/addon/a/zotpost/Mod_zotpost.php:67 msgid "https://example.com" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:70 +#: extend/addon/a/zotpost/Mod_zotpost.php:71 msgid "Zot channel name" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:74 +#: extend/addon/a/zotpost/Mod_zotpost.php:75 msgid "Zot password" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:78 +#: extend/addon/a/zotpost/Mod_zotpost.php:79 msgid "Send public postings to Zot channel by default" msgstr "" -#: extend/addon/a/zotpost/Mod_zotpost.php:82 +#: extend/addon/a/zotpost/Mod_zotpost.php:83 msgid "Zotpost Settings" msgstr "" -#: include/connections.php:200 +#: include/connections.php:204 msgid "New window" msgstr "" -#: include/connections.php:201 +#: include/connections.php:205 msgid "Open the selected location in a different window or browser tab" msgstr "" -#: include/connections.php:841 include/event.php:1517 +#: include/connections.php:845 include/event.php:1517 msgid "Home, Voice" msgstr "" -#: include/connections.php:842 include/event.php:1518 +#: include/connections.php:846 include/event.php:1518 msgid "Home, Fax" msgstr "" -#: include/connections.php:844 include/event.php:1520 +#: include/connections.php:848 include/event.php:1520 msgid "Work, Voice" msgstr "" -#: include/connections.php:845 include/event.php:1521 +#: include/connections.php:849 include/event.php:1521 msgid "Work, Fax" msgstr "" -#: include/connections.php:956 +#: include/connections.php:960 msgid "No connections" msgstr "" -#: include/connections.php:987 +#: include/connections.php:991 #, php-format msgid "View all %s connections" msgstr "" -#: include/connections.php:1024 +#: include/connections.php:1028 #, php-format msgid "Network: %s" msgstr "" @@ -11853,6 +11845,72 @@ msgctxt "edit_activity" msgid "Comment" msgstr "" +#: include/attach.php:285 include/attach.php:411 +msgid "Item was not found." +msgstr "" + +#: include/attach.php:303 +msgid "Unknown error." +msgstr "" + +#: include/attach.php:606 +msgid "No source file." +msgstr "" + +#: include/attach.php:630 +msgid "Cannot locate file to replace" +msgstr "" + +#: include/attach.php:651 +msgid "Cannot locate file to revise/update" +msgstr "" + +#: include/attach.php:815 +#, php-format +msgid "File exceeds size limit of %d" +msgstr "" + +#: include/attach.php:838 +#, php-format +msgid "You have reached your limit of %1$.0f Mbytes attachment storage." +msgstr "" + +#: include/attach.php:1045 +msgid "File upload failed. Possible system limit or action terminated." +msgstr "" + +#: include/attach.php:1076 +msgid "Stored file could not be verified. Upload failed." +msgstr "" + +#: include/attach.php:1154 include/attach.php:1171 +msgid "Path not available." +msgstr "" + +#: include/attach.php:1221 include/attach.php:1392 +msgid "Empty pathname" +msgstr "" + +#: include/attach.php:1249 +msgid "duplicate filename or path" +msgstr "" + +#: include/attach.php:1274 +msgid "Path not found." +msgstr "" + +#: include/attach.php:1345 +msgid "mkdir failed." +msgstr "" + +#: include/attach.php:1348 +msgid "database storage failed." +msgstr "" + +#: include/attach.php:1398 +msgid "Empty path" +msgstr "" + #: include/photos.php:158 #, php-format msgid "Image exceeds website size limit of %lu bytes" @@ -11870,12 +11928,18 @@ msgstr "" msgid "a new photo" msgstr "" -#: include/photos.php:420 +#: include/photos.php:416 #, php-format msgctxt "photo_upload" msgid "%1$s posted %2$s to %3$s" msgstr "" +#: include/photos.php:419 +#, php-format +msgctxt "photo_upload" +msgid "%1$s posted %2$s" +msgstr "" + #: include/photos.php:764 msgid "Upload New Photos" msgstr "" @@ -11926,72 +11990,6 @@ msgstr "" msgid "This api method requires authentication" msgstr "" -#: include/attach.php:285 include/attach.php:411 -msgid "Item was not found." -msgstr "" - -#: include/attach.php:303 -msgid "Unknown error." -msgstr "" - -#: include/attach.php:606 -msgid "No source file." -msgstr "" - -#: include/attach.php:630 -msgid "Cannot locate file to replace" -msgstr "" - -#: include/attach.php:651 -msgid "Cannot locate file to revise/update" -msgstr "" - -#: include/attach.php:810 -#, php-format -msgid "File exceeds size limit of %d" -msgstr "" - -#: include/attach.php:833 -#, php-format -msgid "You have reached your limit of %1$.0f Mbytes attachment storage." -msgstr "" - -#: include/attach.php:1040 -msgid "File upload failed. Possible system limit or action terminated." -msgstr "" - -#: include/attach.php:1071 -msgid "Stored file could not be verified. Upload failed." -msgstr "" - -#: include/attach.php:1149 include/attach.php:1166 -msgid "Path not available." -msgstr "" - -#: include/attach.php:1216 include/attach.php:1387 -msgid "Empty pathname" -msgstr "" - -#: include/attach.php:1244 -msgid "duplicate filename or path" -msgstr "" - -#: include/attach.php:1269 -msgid "Path not found." -msgstr "" - -#: include/attach.php:1340 -msgid "mkdir failed." -msgstr "" - -#: include/attach.php:1343 -msgid "database storage failed." -msgstr "" - -#: include/attach.php:1393 -msgid "Empty path" -msgstr "" - #: include/auth.php:209 msgid "Delegation session ended." msgstr "" @@ -12372,7 +12370,7 @@ msgstr[0] "" msgstr[1] "" #: view/theme/redbasic/php/config.php:20 view/theme/redbasic/php/config.php:23 -msgid "Focus (Hubzilla default)" +msgid "Focus (default)" msgstr "" #: view/theme/redbasic/php/config.php:101 diff --git a/util/run_xgettext.sh b/util/run_xgettext.sh index d881145ef..72b62a3a5 100755 --- a/util/run_xgettext.sh +++ b/util/run_xgettext.sh @@ -4,7 +4,7 @@ VINFO=`echo ", YEAR./Nobody, 2010/g" "$OUTFILE" sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE" sed -i "s/PACKAGE/$PROJECTNAME/g" "$OUTFILE" diff --git a/version.php b/version.php index 78c85c7a9..ed1975bc0 100644 --- a/version.php +++ b/version.php @@ -1,2 +1,2 @@ Date: Sun, 27 Feb 2022 21:58:50 -0800 Subject: [PATCH 34/40] enhance the messagefilter --- Code/Lib/MessageFilter.php | 131 ++++++++++++++++++++++++++++++++++++- include/items.php | 3 +- 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/Code/Lib/MessageFilter.php b/Code/Lib/MessageFilter.php index 97b049b02..6d64f93fc 100644 --- a/Code/Lib/MessageFilter.php +++ b/Code/Lib/MessageFilter.php @@ -2,6 +2,7 @@ namespace Code\Lib; +require_once('include/html2plain.php'); class MessageFilter { @@ -10,7 +11,6 @@ class MessageFilter public static function evaluate($item, $incl, $excl) { - require_once('include/html2plain.php'); $text = prepare_text($item['body'],((isset($item['mimetype'])) ? $item['mimetype'] : 'text/x-multicode')); $text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text); @@ -45,6 +45,14 @@ class MessageFilter return false; } } + } elseif (substr($word, 0, 2) === '?+') { + if (self::test_condition(substr($word, 2), $item['obj'])) { + return false; + } + } elseif (substr($word, 0, 1) === '?') { + if (self::test_condition(substr($word, 1), $item)) { + return false; + } } elseif ((strpos($word, '/') === 0) && preg_match($word, $text)) { return false; } elseif ((strpos($word, 'lang=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 5))) == 0)) { @@ -77,6 +85,14 @@ class MessageFilter return true; } } + } elseif (substr($word, 0, 2) === '?+') { + if (self::test_condition(substr($word, 2), $item['obj'])) { + return true; + } + } elseif (substr($word, 0, 1) === '?') { + if (self::test_condition(substr($word, 1), $item)) { + return true; + } } elseif ((strpos($word, '/') === 0) && preg_match($word, $text)) { return true; } elseif ((strpos($word, 'lang=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 5))) == 0)) { @@ -93,4 +109,117 @@ class MessageFilter return false; } + + + /** + * @brief Test for Conditional Execution conditions. Shamelessly ripped off from Code/Render/Comanche + * + * This is extensible. The first version of variable testing supports tests of the forms: + * + * - ?foo ~= baz which will check if item.foo contains the string 'baz'; + * - ?foo == baz which will check if item.foo is the string 'baz'; + * - ?foo != baz which will check if item.foo is not the string 'baz'; + * - ?foo >= 3 which will check if item.foo is greater than or equal to 3; + * - ?foo > 3 which will check if item.foo is greater than 3; + * - ?foo <= 3 which will check if item.foo is less than or equal to 3; + * - ?foo < 3 which will check if item.foo is less than 3; + * + * - ?foo {} baz which will check if 'baz' is an array element in item.foo + * - ?foo {*} baz which will check if 'baz' is an array key in item.foo + * - ?foo which will check for a return of a true condition for item.foo; + * + * The values 0, '', an empty array, and an unset value will all evaluate to false. + * + * @param string $s + * @param array $item + * @return bool + */ + public static function test_condition($s,$item) + { + + if (preg_match('/(.*?)\s\~\=\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if (stripos($x, trim($matches[2])) !== false) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\=\=\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x == trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\!\=\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x != trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\>\=\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x >= trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\<\=\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x <= trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\>\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x > trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\>\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x < trim($matches[2])) { + return true; + } + return false; + } + + if (preg_match('/[\$](.*?)\s\{\}\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if (is_array($x) && in_array(trim($matches[2]), $x)) { + return true; + } + return false; + } + + if (preg_match('/(.*?)\s\{\*\}\s(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if (is_array($x) && array_key_exists(trim($matches[2]), $x)) { + return true; + } + return false; + } + + if (preg_match('/(.*?)$/', $s, $matches)) { + $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR); + if ($x) { + return true; + } + return false; + } + return false; + } + + + + } diff --git a/include/items.php b/include/items.php index 622fd57b5..9b9a56827 100644 --- a/include/items.php +++ b/include/items.php @@ -3500,11 +3500,10 @@ function post_is_importable($channel_id,$item,$abook) { if (! ($ab['abook_incl'] || $ab['abook_excl']) ) { continue; } - $evaluator = MessageFilter::evaluate($item,$ab['abook_incl'],$ab['abook_excl']); // A negative assessment for any individual connections // is an instant fail - if (! $evaluater) { + if (! $evaluator) { return false; } } From 3d6523772cd6441d7e7595e7b701208b6ac21469 Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 28 Feb 2022 13:17:27 -0800 Subject: [PATCH 35/40] postgres: get rid of binary fields. --- Code/Module/Admin/Site.php | 5 ++--- include/dba/dba_pdo.php | 22 ++-------------------- install/schema_postgres.sql | 12 ++++++------ 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/Code/Module/Admin/Site.php b/Code/Module/Admin/Site.php index d85adb905..67fcd7b78 100644 --- a/Code/Module/Admin/Site.php +++ b/Code/Module/Admin/Site.php @@ -160,7 +160,6 @@ class Site set_config('system', 'language', $language); set_config('system', 'theme', $theme); - // set_config('system','site_channel', $site_channel); set_config('system', 'maximagesize', $maximagesize); set_config('system', 'register_policy', $register_policy); @@ -286,8 +285,8 @@ class Site '$advanced' => t('Advanced'), '$baseurl' => z_root(), '$sitename' => ['sitename', t("Site name"), htmlspecialchars(get_config('system', 'sitename', App::get_hostname()), ENT_QUOTES, 'UTF-8'), ''], - '$admininfo' => ['admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode may be used here.")], - '$siteinfo' => ['siteinfo', t('Site Information'), get_config('system', 'siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode may be used here.")], + '$admininfo' => ['admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. Multicode may be used here.")], + '$siteinfo' => ['siteinfo', t('Site Information'), get_config('system', 'siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. Multicode may be used here.")], '$language' => ['language', t("System language"), get_config('system', 'language', 'en'), "", $lang_choices], '$theme' => ['theme', t("System theme"), get_config('system', 'theme'), t("Default system theme - may be over-ridden by user profiles - change theme settings"), $theme_choices], // '$theme_mobile' => [ 'theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile ], diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index 3101ec48b..cd47a3ade 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -167,32 +167,14 @@ class dba_pdo extends dba_driver } } - // These two functions assume that postgres standard_conforming_strings is set to off; - // which we perform during DB open. - public function escapebin($str) { - if ($this->driver_dbtype === 'pgsql') { - return "\\\\x" . bin2hex($str); - } else { - return $this->escape($str); - } + return $this->escape($str); } public function unescapebin($str) { - if (gettype($str) === 'resource') { - $x = ''; - while (!feof($str)) { - $x .= fread($str, 8192); - } - if (substr($x, 0, 2) === '\\x') { - $x = hex2bin(substr($x, 2)); - } - return $x; - } else { - return $str; - } + return $str; } diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 0864d0fd7..d6f113c86 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -176,7 +176,7 @@ CREATE TABLE "attach" ( "os_storage" smallint NOT NULL DEFAULT '0', "os_path" text NOT NULL, "display_path" text NOT NULL, - "content" bytea NOT NULL, + "content" text NOT NULL, "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "allow_cid" text NOT NULL, @@ -885,7 +885,7 @@ CREATE TABLE "photo" ( "height" numeric(6) NOT NULL, "width" numeric(6) NOT NULL, "filesize" bigint NOT NULL DEFAULT '0', - "content" bytea NOT NULL, + "content" text NOT NULL, "imgscale" numeric(3) NOT NULL DEFAULT '0', "profile" numeric(1) NOT NULL DEFAULT '0', "photo_usage" smallint NOT NULL DEFAULT '0', @@ -1370,7 +1370,7 @@ CREATE UNIQUE INDEX addressbooks_ukey CREATE TABLE cards ( id SERIAL NOT NULL, addressbookid INTEGER NOT NULL, - carddata BYTEA, + carddata text, uri VARCHAR(200), lastmodified INTEGER, etag VARCHAR(32), @@ -1399,7 +1399,7 @@ CREATE INDEX addressbookchanges_addressbookid_synctoken_ix CREATE TABLE calendarobjects ( id SERIAL NOT NULL, - calendardata BYTEA, + calendardata text NOT NULL, uri VARCHAR(200), calendarid INTEGER NOT NULL, lastmodified INTEGER, @@ -1496,7 +1496,7 @@ CREATE INDEX calendarchanges_calendarid_synctoken_ix CREATE TABLE schedulingobjects ( id SERIAL NOT NULL, principaluri VARCHAR(255), - calendardata BYTEA, + calendardata text, uri VARCHAR(200), lastmodified INTEGER, etag VARCHAR(32), @@ -1553,7 +1553,7 @@ CREATE TABLE propertystorage ( path VARCHAR(1024) NOT NULL, name VARCHAR(100) NOT NULL, valuetype INT, - value BYTEA + value text ); ALTER TABLE ONLY propertystorage From e311856ec05fc58dea60611c000a20952c424ef0 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 1 Mar 2022 15:45:04 -0800 Subject: [PATCH 36/40] caldav is not supported. --- Code/Lib/System.php | 3 ++- Code/Module/Cdav.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Code/Lib/System.php b/Code/Lib/System.php index 2c8517a32..dc6820e1c 100644 --- a/Code/Lib/System.php +++ b/Code/Lib/System.php @@ -32,7 +32,8 @@ class System $name = self::get_site_name(); if ($name) { $words = explode(' ', $name); - $project = strtolower(URLify::transliterate($words[0])); + // restrict result to characters allowed by the nodeinfo specification + $project = preg_replace('/[^a-z0-9-]/', '-', strtolower(URLify::transliterate($words[0]))); } if (!$project) { $project = self::get_platform_name(); diff --git a/Code/Module/Cdav.php b/Code/Module/Cdav.php index fee892b06..bf92a313a 100644 --- a/Code/Module/Cdav.php +++ b/Code/Module/Cdav.php @@ -35,6 +35,7 @@ use Code\Lib\Libacl; use Code\Lib\Head; use Code\Lib\Features; use Code\Render\Theme; +use Code\Lib\Config; require_once('include/event.php'); @@ -50,6 +51,10 @@ class Cdav extends Controller $record = null; $channel_login = false; + if (! Config::Get('system','cdav')) { + http_status_exit(404, 'Not found'); + } + if ((argv(1) !== 'calendar') && (argv(1) !== 'addressbook')) { foreach (['REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION'] as $head) { /* Basic authentication */ @@ -252,6 +257,11 @@ class Cdav extends Controller return; } + if (! Config::Get('system','cdav')) { + http_status_exit(404, 'Not found'); + } + + if ((argv(1) === 'addressbook') && (!Apps::system_app_installed(local_channel(), 'CardDAV'))) { return; } @@ -886,6 +896,10 @@ class Cdav extends Controller return; } + if (! Config::Get('system','cdav')) { + http_status_exit(404, 'Not found'); + } + if ((argv(1) === 'addressbook') && (!Apps::system_app_installed(local_channel(), 'CardDAV'))) { // Do not display any associated widgets at this point App::$pdl = ''; From b23863654e156b53d2f0d7d7e6c9c4fe8d22539b Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 2 Mar 2022 10:13:46 -0800 Subject: [PATCH 37/40] re-rooted namespaces --- Code/Lib/Oembed.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Lib/Oembed.php b/Code/Lib/Oembed.php index e56ff34f0..c91684b6c 100644 --- a/Code/Lib/Oembed.php +++ b/Code/Lib/Oembed.php @@ -3,6 +3,8 @@ namespace Code\Lib; use App; +use DOMDocument; +use DOMXPath; use Code\Lib\Cache; use Code\Extend\Hook; use Code\Render\Theme; From ad4f0a0f8e9d8f3a77be2f8d450297173fca78bd Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 2 Mar 2022 14:22:01 -0800 Subject: [PATCH 38/40] namespace issue --- Code/Lib/Xprof.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Lib/Xprof.php b/Code/Lib/Xprof.php index 0880bbd99..55b7a6b1c 100644 --- a/Code/Lib/Xprof.php +++ b/Code/Lib/Xprof.php @@ -1,5 +1,5 @@ Date: Wed, 2 Mar 2022 14:54:19 -0800 Subject: [PATCH 39/40] cleanup --- Code/Lib/Account.php | 6 +++--- Code/Lib/Channel.php | 2 +- Code/Module/Settings/Channel.php | 1 - Code/Render/Theme.php | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Code/Lib/Account.php b/Code/Lib/Account.php index b3661d55c..de415db26 100644 --- a/Code/Lib/Account.php +++ b/Code/Lib/Account.php @@ -186,20 +186,20 @@ class Account { set_config('system', 'prvkey', $hostkey['prvkey']); } - $invite_result = check_account_invite($invite_code); + $invite_result = self::check_invite($invite_code); if ($invite_result['error']) { $result['message'] = $invite_result['message']; return $result; } - $email_result = check_account_email($email); + $email_result = self::check_email($email); if ($email_result['error']) { $result['message'] = $email_result['message']; return $result; } - $password_result = check_account_password($password); + $password_result = self::check_password($password); if ($password_result['error']) { $result['message'] = $password_result['message']; diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index 5755ee690..6c100e17e 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -187,7 +187,7 @@ class Channel self::create([ 'account_id' => 'xxx', // Typecast trickery: account_id is required. This will create an identity with an (integer) account_id of 0 'nickname' => 'sys', - 'name' => 'System', + 'name' => ucfirst(basename(z_root())), 'permissions_role' => 'social', 'pageflags' => 0, 'publish' => 0, diff --git a/Code/Module/Settings/Channel.php b/Code/Module/Settings/Channel.php index d6284d467..777587f9f 100644 --- a/Code/Module/Settings/Channel.php +++ b/Code/Module/Settings/Channel.php @@ -296,7 +296,6 @@ class Channel if ($username != $channel['channel_name']) { $name_change = true; - require_once('include/channel.php'); $err = Zlib\Channel::validate_channelname($username); if ($err) { notice($err); diff --git a/Code/Render/Theme.php b/Code/Render/Theme.php index e3c0349df..dbbd4c4c5 100644 --- a/Code/Render/Theme.php +++ b/Code/Render/Theme.php @@ -209,10 +209,10 @@ class Theme if ($newroot != '' && substr($newroot, -1) != '/') { $newroot .= '/'; } - $template = $t->Theme::get_email_template($s, $newroot); + $template = $t->get_email_template($s, $newroot); } - $template = $t->Theme::get_email_template($s, $root); - return $template; + $template = $t->get_email_template($s, $root); + return $template; } } From dfc0a92665837fa8f710b1b6b20ff05061014497 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 3 Mar 2022 13:41:01 -0800 Subject: [PATCH 40/40] symfony uuid returns an object - cast to string --- include/event.php | 2 +- include/text.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/event.php b/include/event.php index ff2fa5dd5..1f45e26fe 100644 --- a/include/event.php +++ b/include/event.php @@ -587,7 +587,7 @@ function event_store_event($arr) $hash = $arr['event_hash']; } else { try { - $hash = Uuid::v4(); + $hash = (string) Uuid::v4(); } catch (UnsatisfiedDependencyException $e) { $hash = random_string(48); } diff --git a/include/text.php b/include/text.php index e3c899630..0fd06f5a8 100644 --- a/include/text.php +++ b/include/text.php @@ -614,7 +614,7 @@ function item_message_id() { try { - $hash = Uuid::v4(); + $hash = (string) Uuid::v4(); } catch (UnsatisfiedDependencyException $e) { $hash = random_string(48); } @@ -635,7 +635,7 @@ function photo_new_resource() { try { - $hash = Uuid::v4(); + $hash = (string) Uuid::v4(); } catch (UnsatisfiedDependencyException $e) { $hash = random_string(48); } @@ -670,7 +670,7 @@ function new_uuid() { try { - $hash = Uuid::v4(); + $hash = (string) Uuid::v4(); } catch (UnsatisfiedDependencyException $e) { $hash = random_string(48); }