aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/DB_Upgrade.php105
-rw-r--r--Zotlabs/Lib/ThreadItem.php1
-rw-r--r--Zotlabs/Web/WebServer.php17
-rwxr-xr-xboot.php90
-rw-r--r--include/conversation.php112
-rw-r--r--util/db_update.php3
6 files changed, 129 insertions, 199 deletions
diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php
new file mode 100644
index 000000000..13adaced5
--- /dev/null
+++ b/Zotlabs/Lib/DB_Upgrade.php
@@ -0,0 +1,105 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+
+class DB_Upgrade {
+
+
+ function __construct($db_revision) {
+
+ $build = get_config('system','db_version',0);
+ if(! intval($build))
+ $build = set_config('system','db_version',$db_revision);
+
+ if($build == $db_revision) {
+ // Nothing to be done.
+ return;
+ }
+ else {
+ $stored = intval($build);
+ if(! $stored) {
+ logger('Critical: check_config unable to determine database schema version');
+ return;
+ }
+
+ $current = intval($db_revision);
+ if(($stored < $current) && file_exists('install/update.php')) {
+
+ Config::Load('database');
+
+ // We're reporting a different version than what is currently installed.
+ // Run any existing update scripts to bring the database up to current.
+
+ require_once('install/update.php');
+
+ // make sure that boot.php and update.php are the same release, we might be
+ // updating from git right this very second and the correct version of the update.php
+ // file may not be here yet. This can happen on a very busy site.
+
+ if($db_revision == UPDATE_VERSION) {
+ for($x = $stored; $x < $current; $x ++) {
+ if(function_exists('update_r' . $x)) {
+ // There could be a lot of processes running or about to run.
+ // We want exactly one process to run the update command.
+ // So store the fact that we're taking responsibility
+ // after first checking to see if somebody else already has.
+
+ // If the update fails or times-out completely you may need to
+ // delete the config entry to try again.
+
+ if(get_config('database','update_r' . $x))
+ break;
+ set_config('database','update_r' . $x, '1');
+ // call the specific update
+
+ $func = 'update_r' . $x;
+ $retval = $func();
+ if($retval) {
+
+ // Prevent sending hundreds of thousands of emails by creating
+ // a lockfile.
+
+ $lockfile = 'store/[data]/mailsent';
+
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400)))
+ return;
+ @unlink($lockfile);
+ //send the administrator an e-mail
+ file_put_contents($lockfile, $x);
+
+ $r = q("select account_language from account where account_email = '%s' limit 1",
+ dbesc(App::$config['system']['admin_email'])
+ );
+ push_lang(($r) ? $r[0]['account_language'] : 'en');
+
+ z_mail(
+ [
+ 'toEmail' => \App::$config['system']['admin_email'],
+ 'messageSubject' => sprintf( t('Update Error at %s'), z_root()),
+ 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'),
+ [
+ '$sitename' => \App::$config['system']['sitename'],
+ '$siteurl' => z_root(),
+ '$update' => $x,
+ '$error' => sprintf( t('Update %s failed. See error logs.'), $x)
+ ]
+ )
+ ]
+ );
+
+ //try the logger
+ logger('CRITICAL: Update Failed: ' . $x);
+ pop_lang();
+ }
+ else {
+ set_config('database','update_r' . $x, 'success');
+ }
+ }
+ }
+ set_config('system','db_version', $db_revision);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index c3464b86b..5910ea672 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -338,7 +338,6 @@ class ThreadItem {
'profile_url' => $profile_link,
'thread_action_menu' => thread_action_menu($item,$conv->get_mode()),
'thread_author_menu' => thread_author_menu($item,$conv->get_mode()),
- 'item_photo_menu' => item_photo_menu($item),
'dreport' => $dreport,
'name' => $profile_name,
'thumb' => $profile_avatar,
diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php
index 5bb0e08e8..9c9f0483a 100644
--- a/Zotlabs/Web/WebServer.php
+++ b/Zotlabs/Web/WebServer.php
@@ -79,11 +79,6 @@ class WebServer {
if(! x($_SESSION, 'sysmsg_info'))
$_SESSION['sysmsg_info'] = array();
- /*
- * check_config() is responsible for running update scripts. These automatically
- * update the DB schema whenever we push a new one out. It also checks to see if
- * any plugins have been added or removed and reacts accordingly.
- */
if(\App::$install) {
@@ -91,8 +86,16 @@ class WebServer {
if(\App::$module != 'view')
\App::$module = 'setup';
}
- else
- check_config($a);
+ else {
+
+ /*
+ * check_config() is responsible for running update scripts. These automatically
+ * update the DB schema whenever we push a new one out. It also checks to see if
+ * any plugins have been added or removed and reacts accordingly.
+ */
+
+ check_config();
+ }
nav_set_selected('nothing');
diff --git a/boot.php b/boot.php
index b9c5bfd89..da5d571b2 100755
--- a/boot.php
+++ b/boot.php
@@ -1394,11 +1394,7 @@ function is_ajax() {
// base url for use in cmdline programs which don't have
// $_SERVER variables, and synchronising the state of installed plugins.
-function check_config(&$a) {
-
- $build = get_config('system','db_version');
- if(! intval($build))
- $build = set_config('system','db_version',DB_UPDATE_VERSION);
+function check_config() {
$saved = get_config('system','urlverify');
if(! $saved)
@@ -1436,88 +1432,8 @@ function check_config(&$a) {
if (! $syschan_exists)
create_sys_channel();
- if($build != DB_UPDATE_VERSION) {
- $stored = intval($build);
- if(! $stored) {
- logger('Critical: check_config unable to determine database schema version');
- return;
- }
- $current = intval(DB_UPDATE_VERSION);
- if(($stored < $current) && file_exists('install/update.php')) {
-
- load_config('database');
-
- // We're reporting a different version than what is currently installed.
- // Run any existing update scripts to bring the database up to current.
- require_once('install/update.php');
-
- // make sure that boot.php and update.php are the same release, we might be
- // updating right this very second and the correct version of the update.php
- // file may not be here yet. This can happen on a very busy site.
-
- if(DB_UPDATE_VERSION == UPDATE_VERSION) {
- for($x = $stored; $x < $current; $x ++) {
- if(function_exists('update_r' . $x)) {
- // There could be a lot of processes running or about to run.
- // We want exactly one process to run the update command.
- // So store the fact that we're taking responsibility
- // after first checking to see if somebody else already has.
-
- // If the update fails or times-out completely you may need to
- // delete the config entry to try again.
-
- if(get_config('database','update_r' . $x))
- break;
- set_config('database','update_r' . $x, '1');
- // call the specific update
-
- $func = 'update_r' . $x;
- $retval = $func();
- if($retval) {
-
- // Prevent sending hundreds of thousands of emails by creating
- // a lockfile.
-
- $lockfile = 'store/[data]/mailsent';
-
- if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400)))
- return;
- @unlink($lockfile);
- //send the administrator an e-mail
- file_put_contents($lockfile, $x);
-
- $r = q("select account_language from account where account_email = '%s' limit 1",
- dbesc(App::$config['system']['admin_email'])
- );
- push_lang(($r) ? $r[0]['account_language'] : 'en');
-
-
- $email_tpl = get_intltext_template("update_fail_eml.tpl");
- $email_msg = replace_macros($email_tpl, array(
- '$sitename' => App::$config['system']['sitename'],
- '$siteurl' => z_root(),
- '$update' => $x,
- '$error' => sprintf( t('Update %s failed. See error logs.'), $x)
- ));
-
- $subject = email_header_encode(sprintf(t('Update Error at %s'), z_root()));
-
- mail(App::$config['system']['admin_email'], $subject, $email_msg,
- 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
- . 'Content-type: text/plain; charset=UTF-8' . "\n"
- . 'Content-transfer-encoding: 8bit' );
- //try the logger
- logger('CRITICAL: Update Failed: ' . $x);
- pop_lang();
- }
- else
- set_config('database','update_r' . $x, 'success');
- }
- }
- set_config('system','db_version', DB_UPDATE_VERSION);
- }
- }
- }
+ $x = new \Zotlabs\Lib\DB_Upgrade(DB_UPDATE_VERSION);
+
/**
*
diff --git a/include/conversation.php b/include/conversation.php
index da4f974a6..b4f959afa 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -2,10 +2,6 @@
require_once('include/items.php');
-// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
-// is identical to the code in mod/message.php for 'item_extract_images' and
-// 'item_redir_and_replace_images'
-
function item_extract_images($body) {
@@ -375,13 +371,14 @@ function localize_item(&$item){
* * \e array \b children
* @return number
*/
+
function count_descendants($item) {
$total = count($item['children']);
- if ($total > 0) {
- foreach ($item['children'] as $child) {
- if (! visible_activity($child))
+ if($total > 0) {
+ foreach($item['children'] as $child) {
+ if(! visible_activity($child))
$total --;
$total += count_descendants($child);
@@ -408,8 +405,8 @@ function visible_activity($item) {
if(intval($item['item_notshown']))
return false;
- foreach ($hidden_activities as $act) {
- if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) {
+ foreach($hidden_activities as $act) {
+ if((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) {
return false;
}
}
@@ -875,98 +872,6 @@ function best_link_url($item) {
-function item_photo_menu($item){
-
- $contact = null;
-
- $ssl_state = false;
-
- $sub_link="";
- $poke_link="";
- $contact_url="";
- $pm_url="";
- $vsrc_link = "";
- $follow_url = "";
-
- $local_channel = local_channel();
-
- if($local_channel) {
- $ssl_state = true;
- if(! count(App::$contacts))
- load_contact_links($local_channel);
- $channel = App::get_channel();
- $channel_hash = (($channel) ? $channel['channel_hash'] : '');
- }
-
- if(($local_channel) && $local_channel == $item['uid']) {
- $vsrc_link = 'javascript:viewsrc(' . $item['id'] . '); return false;';
- if($item['parent'] == $item['id'] && $channel && ($channel_hash != $item['author_xchan'])) {
- $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
- }
- if($channel) {
- $unsub_link = 'javascript:dounsubthread(' . $item['id'] . '); return false;';
- }
- }
-
- $profile_link = chanlink_hash($item['author_xchan']);
- if($item['uid'] > 0)
- $pm_url = z_root() . '/mail/new/?f=&hash=' . $item['author_xchan'];
-
- if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts))
- $contact = App::$contacts[$item['author_xchan']];
- else
- if($local_channel && $item['author']['xchan_addr'])
- $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr'];
-
- if($contact) {
- $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id'];
- if (! intval($contact['abook_self']))
- $contact_url = z_root() . '/connedit/' . $contact['abook_id'];
- $posts_link = z_root() . '/network/?cid=' . $contact['abook_id'];
-
- $clean_url = normalise_link($item['author-link']);
- }
-
- $rating_enabled = get_config('system','rating_enabled');
-
- $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : '');
-
- $post_menu = Array(
- t("View Source") => $vsrc_link,
- t("Follow Thread") => $sub_link,
- t("Unfollow Thread") => $unsub_link,
- );
-
- $author_menu = array(
- t("View Profile") => $profile_link,
- t("Activity/Posts") => $posts_link,
- t("Connect") => $follow_url,
- t("Edit Connection") => $contact_url,
- t("Message") => $pm_url,
- t('Ratings') => $ratings_url,
- t("Poke") => $poke_link
- );
-
-
- $args = array('item' => $item, 'post_menu' => $post_menu, 'author_menu' => $author_menu);
-
- call_hooks('item_photo_menu', $args);
-
- $menu = array_merge($args['post_menu'],$args['author_menu']);
-
- $o = "";
- foreach($menu as $k=>$v){
- if(strpos($v,'javascript:') === 0) {
- $v = substr($v,11);
- $o .= "<li><a href=\"#\" onclick=\"$v\">$k</a></li>\n";
- }
- elseif ($v!="") $o .= "<li><a href=\"$v\">$k</a></li>\n";
- }
-
- return $o;
-}
-
-
function thread_action_menu($item,$mode = '') {
$menu = [];
@@ -1026,14 +931,15 @@ function thread_author_menu($item, $mode = '') {
}
$profile_link = chanlink_hash($item['author_xchan']);
+
if($item['uid'] > 0)
- $pm_url = z_root() . '/mail/new/?f=&hash=' . $item['author_xchan'];
+ $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']);
if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts))
$contact = App::$contacts[$item['author_xchan']];
else
if($local_channel && $item['author']['xchan_addr'])
- $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr'];
+ $follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']);
if($contact) {
$poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id'];
diff --git a/util/db_update.php b/util/db_update.php
index ceef061c1..8fc7c7616 100644
--- a/util/db_update.php
+++ b/util/db_update.php
@@ -9,6 +9,7 @@ require_once('boot.php');
require_once('include/cli_startup.php');
cli_startup();
+$build = get_config('system','db_version');
echo "Old DB VERSION: " . $build . "\n";
echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
@@ -16,7 +17,7 @@ echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
if($build != DB_UPDATE_VERSION) {
echo "Updating database...";
- check_config($a);
+ check_config();
echo "Done\n";
}