diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/admin.php | 75 | ||||
-rw-r--r-- | mod/channel.php | 5 | ||||
-rwxr-xr-x | mod/events.php | 4 | ||||
-rw-r--r-- | mod/home.php | 3 | ||||
-rw-r--r-- | mod/id.php | 231 | ||||
-rw-r--r-- | mod/item.php | 74 | ||||
-rwxr-xr-x | mod/like.php | 12 | ||||
-rw-r--r-- | mod/match.php | 51 | ||||
-rw-r--r-- | mod/network.php | 21 | ||||
-rw-r--r-- | mod/ping.php | 6 | ||||
-rw-r--r-- | mod/post.php | 529 | ||||
-rw-r--r-- | mod/randprof.php | 3 | ||||
-rw-r--r-- | mod/regdir.php | 45 | ||||
-rw-r--r-- | mod/share.php | 20 | ||||
-rw-r--r-- | mod/sharedwithme.php | 22 | ||||
-rw-r--r-- | mod/siteinfo.php | 7 | ||||
-rw-r--r-- | mod/thing.php | 43 | ||||
-rw-r--r-- | mod/zotfeed.php | 5 |
18 files changed, 586 insertions, 570 deletions
diff --git a/mod/admin.php b/mod/admin.php index e991fee27..fd2ba510b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -73,7 +73,7 @@ function admin_post(&$a){ } /** - * @param App $$a + * @param App &$a * @return string */ function admin_content(&$a) { @@ -84,7 +84,7 @@ function admin_content(&$a) { return login(false); } - /** + /* * Side bar links */ @@ -125,7 +125,7 @@ function admin_content(&$a) { )); - /** + /* * Page content */ $o = ''; @@ -183,7 +183,7 @@ function admin_content(&$a) { /** * @brief Returns content for Admin Summary Page. * - * @param App $$a + * @param App &$a * @return string HTML from parsed admin_summary.tpl */ function admin_page_summary(&$a) { @@ -252,8 +252,9 @@ function admin_page_summary(&$a) { /** - * Admin Site Page - * @param App $a + * @brief POST handler for Admin Site Page. + * + * @param App &$a */ function admin_page_site_post(&$a){ if (!x($_POST, 'page_site')){ @@ -277,15 +278,16 @@ function admin_page_site_post(&$a){ $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); - $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); - $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); - $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); - $block_public = ((x($_POST,'block_public')) ? True : False); - $force_publish = ((x($_POST,'publish_all')) ? True : False); - $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); - $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); - $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); - $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); + $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); + $not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : ''); + $block_public = ((x($_POST,'block_public')) ? True : False); + $force_publish = ((x($_POST,'publish_all')) ? True : False); + $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False); + $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False); + $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); + $no_community_page = !((x($_POST,'no_community_page')) ? True : False); + $default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0); $verifyssl = ((x($_POST,'verifyssl')) ? True : False); $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : ''); @@ -306,6 +308,7 @@ function admin_page_site_post(&$a){ set_config('system', 'sitename', $sitename); set_config('system', 'no_login_on_homepage', $no_login_on_homepage); set_config('system', 'verify_email', $verify_email); + set_config('system', 'default_expire_days', $default_expire_days); if ($banner == '') { del_config('system', 'banner'); @@ -358,6 +361,8 @@ function admin_page_site_post(&$a){ } /** + * @brief Admin page site. + * * @param App $a * @return string */ @@ -475,10 +480,11 @@ function admin_page_site(&$a) { '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), + '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (matrix/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), )); - } + function admin_page_hubloc_post(&$a){ check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc'); require_once('include/zot.php'); @@ -614,7 +620,6 @@ function admin_page_queue($a) { ); } - $r = q("select count(outq_posturl) as total, max(outq_priority) as priority, outq_posturl from outq where outq_delivered = 0 group by outq_posturl order by total desc"); @@ -623,7 +628,6 @@ function admin_page_queue($a) { $r[$x]['connected'] = datetime_convert('UTC',date_default_timezone_get(),$r[$x]['connected'],'Y-m-d'); } - $o = replace_macros(get_markup_template('admin_queue.tpl'), array( '$banner' => t('Queue Statistics'), '$numentries' => t('Total Entries'), @@ -760,13 +764,11 @@ function admin_page_users(&$a){ } -// WEe'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. +// We'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. // That's where we need to be doing last post/channel flags/etc, not here. - $serviceclass = (($_REQUEST['class']) ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : ''); - $order = " order by account_email asc "; if($_REQUEST['order'] === 'expires') $order = " order by account_expires desc "; @@ -800,7 +802,6 @@ function admin_page_users(&$a){ // } // $users = array_map("_setup_users", $users); - $t = get_markup_template('admin_users.tpl'); $o = replace_macros($t, array( // strings // @@ -838,9 +839,9 @@ function admin_page_users(&$a){ /** - * Channels admin page + * @brief Channels admin page. * - * @param App $a + * @param App &$a */ function admin_page_channels_post(&$a) { $channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() ); @@ -869,7 +870,9 @@ function admin_page_channels_post(&$a) { } /** - * @param App $a + * @brief + * + * @param App &$a * @return string */ function admin_page_channels(&$a){ @@ -972,7 +975,7 @@ function admin_page_channels(&$a){ */ function admin_page_plugins(&$a){ - /** + /* * Single plugin */ if ($a->argc == 3){ @@ -1052,7 +1055,7 @@ function admin_page_plugins(&$a){ } - /** + /* * List plugins */ $plugins = array(); @@ -1084,7 +1087,7 @@ function admin_page_plugins(&$a){ * @param string $th * @param int $result */ -function toggle_theme(&$themes,$th,&$result) { +function toggle_theme(&$themes, $th, &$result) { for($x = 0; $x < count($themes); $x ++) { if($themes[$x]['name'] === $th) { if($themes[$x]['allowed']) { @@ -1139,9 +1142,9 @@ function rebuild_theme_table($themes) { /** - * Themes admin page + * @brief Themes admin page. * - * @param App $a + * @param App &$a * @return string */ function admin_page_themes(&$a){ @@ -1171,7 +1174,7 @@ function admin_page_themes(&$a){ return ''; } - /** + /* * Single theme */ @@ -1250,8 +1253,7 @@ function admin_page_themes(&$a){ )); } - - /** + /* * List themes */ @@ -1278,9 +1280,9 @@ function admin_page_themes(&$a){ /** - * Logs admin page + * @brief POST handler for logs admin page. * - * @param App $a + * @param App &$a */ function admin_page_logs_post(&$a) { if (x($_POST, 'page_logs')) { @@ -1300,6 +1302,8 @@ function admin_page_logs_post(&$a) { } /** + * @brief Logs admin page. + * * @param App $a * @return string */ @@ -1432,5 +1436,4 @@ function admin_page_profs(&$a) { '$submit' => t('Save') )); } - }
\ No newline at end of file diff --git a/mod/channel.php b/mod/channel.php index 3fc4a9269..022def2a8 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -158,13 +158,11 @@ function channel_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; - if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 @@ -185,6 +183,7 @@ function channel_content(&$a, $update = 0, $load = false) { intval(ITEM_WALL), intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } } diff --git a/mod/events.php b/mod/events.php index 010f1f7c4..289ddfb15 100755 --- a/mod/events.php +++ b/mod/events.php @@ -548,12 +548,14 @@ function events_content(&$a) { if(! x($orig_event)) $sh_checked = ''; else - $sh_checked = (($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); + $sh_checked = ((($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || (! $orig_event['allow_cid'])) && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); if($orig_event['event_xchan']) $sh_checked .= ' disabled="disabled" '; + + $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); diff --git a/mod/home.php b/mod/home.php index c449a0561..f4358da5c 100644 --- a/mod/home.php +++ b/mod/home.php @@ -185,7 +185,7 @@ function home_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; @@ -221,6 +221,7 @@ function home_content(&$a, $update = 0, $load = false) { $sql_extra3 $sql_extra $sql_nets", intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } // Then fetch all the children of the parents that are on this page $parents_str = ''; diff --git a/mod/id.php b/mod/id.php index 05a2f3dc5..bd4c1fa89 100644 --- a/mod/id.php +++ b/mod/id.php @@ -1,45 +1,51 @@ <?php - - require 'library/openid/provider/provider.php'; - - - - $attrMap = array( - 'namePerson/first' => t('First Name'), - 'namePerson/last' => t('Last Name'), - 'namePerson/friendly' => t('Nickname'), - 'namePerson' => t('Full Name'), - 'contact/internet/email' => t('Email'), - 'contact/email' => t('Email'), - 'media/image/aspect11' => t('Profile Photo'), - 'media/image' => t('Profile Photo'), - 'media/image/default' => t('Profile Photo'), - 'media/image/16x16' => t('Profile Photo 16px'), - 'media/image/32x32' => t('Profile Photo 32px'), - 'media/image/48x48' => t('Profile Photo 48px'), - 'media/image/64x64' => t('Profile Photo 64px'), - 'media/image/80x80' => t('Profile Photo 80px'), - 'media/image/128x128' => t('Profile Photo 128px'), - 'timezone' => t('Timezone'), - 'contact/web/default' => t('Homepage URL'), - 'language/pref' => t('Language'), - 'birthDate/birthYear' => t('Birth Year'), - 'birthDate/birthMonth' => t('Birth Month'), - 'birthDate/birthday' => t('Birth Day'), - 'birthDate' => t('Birthdate'), - 'gender' => t('Gender'), - ); - - - +/** + * @file mod/id.php + * @brief OpenID implementation + */ + +require 'library/openid/provider/provider.php'; + + +$attrMap = array( + 'namePerson/first' => t('First Name'), + 'namePerson/last' => t('Last Name'), + 'namePerson/friendly' => t('Nickname'), + 'namePerson' => t('Full Name'), + 'contact/internet/email' => t('Email'), + 'contact/email' => t('Email'), + 'media/image/aspect11' => t('Profile Photo'), + 'media/image' => t('Profile Photo'), + 'media/image/default' => t('Profile Photo'), + 'media/image/16x16' => t('Profile Photo 16px'), + 'media/image/32x32' => t('Profile Photo 32px'), + 'media/image/48x48' => t('Profile Photo 48px'), + 'media/image/64x64' => t('Profile Photo 64px'), + 'media/image/80x80' => t('Profile Photo 80px'), + 'media/image/128x128' => t('Profile Photo 128px'), + 'timezone' => t('Timezone'), + 'contact/web/default' => t('Homepage URL'), + 'language/pref' => t('Language'), + 'birthDate/birthYear' => t('Birth Year'), + 'birthDate/birthMonth' => t('Birth Month'), + 'birthDate/birthday' => t('Birth Day'), + 'birthDate' => t('Birthdate'), + 'gender' => t('Gender'), +); + + +/** + * @brief Entrypoint for the OpenID implementation. + * + * @param App &$a + */ function id_init(&$a) { - logger('id: ' . print_r($_REQUEST,true)); - + logger('id: ' . print_r($_REQUEST, true)); - if(argc() > 1) + if(argc() > 1) { $which = argv(1); - else { + } else { $a->error = 404; return; } @@ -48,41 +54,45 @@ function id_init(&$a) { $channel = $a->get_channel(); profile_load($a,$which,$profile); - - $op = new MysqlProvider; $op->server(); - } - -function getUserData($handle=null) { - if(! local_channel()) { +/** + * @brief Returns user data needed for OpenID. + * + * If no $handle is provided we will use local_channel() by default. + * + * @param string $handle (default null) + * @return boolean|array + */ +function getUserData($handle = null) { + if (! local_channel()) { notice( t('Permission denied.') . EOL); get_app()->page['content'] = login(); + return false; } // logger('handle: ' . $handle); - if($handle) { + if ($handle) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", dbesc($handle) ); - } - else { + } else { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d", intval(local_channel()) ); } - if(! r) + if (! r) return false; $x = q("select * from account where account_id = %d limit 1", intval($r[0]['channel_account_id']) ); - if($x) + if ($x) $r[0]['email'] = $x[0]['account_email']; $p = q("select * from profile where is_default = 1 and uid = %d limit 1", @@ -90,11 +100,11 @@ function getUserData($handle=null) { ); $gender = ''; - if($p[0]['gender'] == t('Male')) + if ($p[0]['gender'] == t('Male')) $gender = 'M'; - if($p[0]['gender'] == t('Female')) + if ($p[0]['gender'] == t('Female')) $gender = 'F'; - + $r[0]['firstName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],0,strpos($r[0]['channel_name'],' ')) : $r[0]['channel_name']); $r[0]['lastName'] = ((strpos($r[0]['channel_name'],' ')) ? substr($r[0]['channel_name'],strpos($r[0]['channel_name'],' ')+1) : ''); $r[0]['namePerson'] = $r[0]['channel_name']; @@ -113,7 +123,7 @@ function getUserData($handle=null) { $r[0]['birthday'] = ((intval(substr($p[0]['dob'],8,2))) ? intval(substr($p[0]['dob'],8,2)) : ''); $r[0]['birthdate'] = (($r[0]['birthyear'] && $r[0]['birthmonth'] && $r[0]['birthday']) ? $p[0]['dob'] : ''); $r[0]['gender'] = $gender; - + return $r[0]; /* @@ -144,20 +154,20 @@ function getUserData($handle=null) { } - - -class MysqlProvider extends LightOpenIDProvider -{ - +/** + * @brief MySQL provider for OpenID implementation. + * + */ +class MysqlProvider extends LightOpenIDProvider { // See http://openid.net/specs/openid-attribute-properties-list-1_0-01.html // This list contains a few variations of these attributes to maintain // compatibility with legacy clients - private $attrFieldMap = array( - 'namePerson/first' => 'firstName', - 'namePerson/last' => 'lastName', - 'namePerson/friendly' => 'channel_address', + private $attrFieldMap = array( + 'namePerson/first' => 'firstName', + 'namePerson/last' => 'lastName', + 'namePerson/friendly' => 'channel_address', 'namePerson' => 'namePerson', 'contact/internet/email' => 'email', 'contact/email' => 'email', @@ -178,11 +188,9 @@ class MysqlProvider extends LightOpenIDProvider 'birthDate/birthday' => 'birthday', 'birthDate' => 'birthdate', 'gender' => 'gender', - ); - - - function setup($identity, $realm, $assoc_handle, $attributes) - { + ); + + function setup($identity, $realm, $assoc_handle, $attributes) { global $attrMap; // logger('identity: ' . $identity); @@ -190,10 +198,10 @@ class MysqlProvider extends LightOpenIDProvider // logger('assoc_handle: ' . $assoc_handle); // logger('attributes: ' . print_r($attributes,true)); - $data = getUserData($assoc_handle); + $data = getUserData($assoc_handle); -// FIXME this needs to be a template with localised strings +/** @FIXME this needs to be a template with localised strings */ $o .= '<form action="" method="post">' . '<input type="hidden" name="openid.assoc_handle" value="' . $assoc_handle . '">' @@ -203,7 +211,7 @@ class MysqlProvider extends LightOpenIDProvider if($attributes['required'] || $attributes['optional']) { $o .= " It also requests following information (required fields marked with *):" . '<ul>'; - + foreach($attributes['required'] as $attr) { if(isset($this->attrMap[$attr])) { $o .= '<li>' @@ -211,7 +219,7 @@ class MysqlProvider extends LightOpenIDProvider . $this->attrMap[$attr] . ' <span class="required">*</span></li>'; } } - + foreach($attributes['optional'] as $attr) { if(isset($this->attrMap[$attr])) { $o .= '<li>' @@ -228,27 +236,23 @@ class MysqlProvider extends LightOpenIDProvider . '</form>'; get_app()->page['content'] .= $o; + } - } - - function checkid($realm, &$attributes) - { + function checkid($realm, &$attributes) { logger('checkid: ' . $realm); - logger('checkid attrs: ' . print_r($attributes,true)); + if(isset($_POST['cancel'])) { + $this->cancel(); + } - if(isset($_POST['cancel'])) { - $this->cancel(); - } - - $data = getUserData(); - if(! $data) { - return false; - } + $data = getUserData(); + if(! $data) { + return false; + } - $q = get_pconfig(local_channel(),'openid',$realm); + $q = get_pconfig(local_channel(), 'openid', $realm); $attrs = array(); if($q) { @@ -265,57 +269,42 @@ class MysqlProvider extends LightOpenIDProvider $attributes[$attr] = $data[$this->attrFieldMap[$attr]]; } } - - if(isset($_POST['always'])) { + + if(isset($_POST['always'])) { set_pconfig(local_channel(),'openid',$realm,array_keys($attributes)); - } - - return z_root() . '/id/' . $data['channel_address']; - } - - function assoc_handle() - { - logger('assoc_handle'); + } + + return z_root() . '/id/' . $data['channel_address']; + } + + function assoc_handle() { + logger('assoc_handle'); $channel = get_app()->get_channel(); + return z_root() . '/channel/' . $channel['channel_address']; + } - } - - function setAssoc($handle, $data) - { + function setAssoc($handle, $data) { logger('setAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) set_pconfig($channel['channel_id'],'openid','associate',$data); - } - - function getAssoc($handle) - { + } + + function getAssoc($handle) { logger('getAssoc: ' . $handle); $channel = channelx_by_nick(basename($handle)); if($channel) - return get_pconfig($channel['channel_id'],'openid','associate'); + return get_pconfig($channel['channel_id'], 'openid', 'associate'); + return false; - } - - function delAssoc($handle) - { + } + + function delAssoc($handle) { logger('delAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) - return del_pconfig($channel['channel_id'],'openid','associate'); - } - + return del_pconfig($channel['channel_id'], 'openid', 'associate'); + } } - - - - - - - - - - - diff --git a/mod/item.php b/mod/item.php index dad883f50..fa40aea03 100644 --- a/mod/item.php +++ b/mod/item.php @@ -35,6 +35,23 @@ function item_post(&$a) { $channel = null; $observer = null; + + /** + * Is this a reply to something? + */ + + $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); + $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); + + $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false); + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($remote_xchan) + ); + if($r) + $remote_observer = $r[0]; + else + $remote_xchan = $remote_observer = false; + $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); require_once('include/identity.php'); $sys = get_sys_channel(); @@ -116,13 +133,6 @@ function item_post(&$a) { $item_flags = $item_restrict = 0; - /** - * Is this a reply to something? - */ - - $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); - $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); - $route = ''; $parent_item = null; $parent_contact = null; @@ -275,6 +285,9 @@ function item_post(&$a) { $walltowall = false; $walltowall_comment = false; + if($remote_xchan) + $observer = $remote_observer; + if($observer) { logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG); @@ -847,6 +860,13 @@ function item_post(&$a) { 'otype' => 'item' )); } + + if($uid && $uid == $profile_uid && (! $datarray['item_restrict'])) { + q("update channel set channel_lastpost = '%s' where channel_id = %d", + dbesc(datetime_convert()), + intval($uid) + ); + } } // photo comments turn the corresponding item visible to the profile wall @@ -1058,37 +1078,37 @@ function fix_attached_file_permissions($channel,$observer_hash,$body, function item_check_service_class($channel_id,$iswebpage) { $ret = array('success' => false, $message => ''); + if ($iswebpage) { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict & %d)>0 and not (i.item_restrict & %d)>0 and i.uid= %d ", + $r = q("select count(id) as total from item where parent = id + and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ", intval(ITEM_WEBPAGE), intval(ITEM_DELETED), - intval($channel_id) - ); + intval($channel_id) + ); } else { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict=0) and i.uid= %d ", - intval($channel_id) - ); + $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ", + intval($channel_id) + ); } - if(! ($r && count($r))) { - $ret['message'] = t('Unable to obtain identity information from database'); + + if(! $r) { + $ret['message'] = t('Unable to obtain post information from database.'); return $ret; } + if (!$iswebpage) { - if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f top level posts."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']); + return $result; + } } else { - if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f webpages."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']); + return $result; + } } $ret['success'] = true; diff --git a/mod/like.php b/mod/like.php index dc4531fbb..d3b6f3ecf 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,7 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ", dbesc($observer['xchan_hash']), intval($item_id), @@ -316,6 +316,16 @@ function like_content(&$a) { require_once('include/items.php'); foreach($r as $rr) { drop_item($rr['id'],false,DROPITEM_PHASE1); + // set the changed timestamp on the parent so we'll see the update without a page reload + $z = q("update item set changed = '%s' where id = %d and uid = %d", + dbesc(datetime_convert()), + intval($rr['parent']), + intval($rr['uid']) + ); + // Prior activity was a duplicate of the one we're submitting, just undo it; + // don't fall through and create another + if(activity_match($rr['verb'],$activity)) + $multi_undo = false; } if($interactive) diff --git a/mod/match.php b/mod/match.php index 5a01ba645..fd739ba2c 100644 --- a/mod/match.php +++ b/mod/match.php @@ -1,14 +1,20 @@ <?php -// FIXME - this has never been properly ported from Friendica -// It takes keywords from your profile and queries the directory server for -// matching keywords from other profiles. - - +/** + * @brief Controller for /match. + * + * It takes keywords from your profile and queries the directory server for + * matching keywords from other profiles. + * + * @FIXME this has never been properly ported from Friendica. + * + * @param App &$a + * @return void|string + */ function match_content(&$a) { $o = ''; - if(! local_channel()) + if (! local_channel()) return; $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; @@ -18,22 +24,22 @@ function match_content(&$a) { $r = q("SELECT `keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()) ); - if(! count($r)) - return; - if(! $r[0]['keywords']) { - notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); + if (! count($r)) return; + if (! $r[0]['keywords']) { + notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); + return; } $params = array(); $tags = trim($r[0]['keywords']); - - if($tags) { + + if ($tags) { $params['s'] = $tags; - if($a->pager['page'] != 1) + if ($a->pager['page'] != 1) $params['p'] = $a->pager['page']; - + // if(strlen(get_config('system','directory_submit_url'))) // $x = post_url('http://dir.friendica.com/msearch', $params); // else @@ -41,18 +47,14 @@ function match_content(&$a) { $j = json_decode($x); - if($j->total) { + if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } - if(count($j->results)) { - - - + if (count($j->results)) { $tpl = get_markup_template('match.tpl'); - foreach($j->results as $jj) { - + foreach ($j->results as $jj) { $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl,array( '$url' => zid($jj->url), @@ -64,14 +66,13 @@ function match_content(&$a) { '$tags' => $jj->tags )); } - } - else { + } else { info( t('No matches') . EOL); - } - + } } $o .= cleardiv(); $o .= paginate($a); + return $o; } diff --git a/mod/network.php b/mod/network.php index f71a7569a..8db3bfd58 100644 --- a/mod/network.php +++ b/mod/network.php @@ -396,7 +396,7 @@ function network_content(&$a, $update = 0, $load = false) { // which are both ITEM_UNSEEN and have "changed" since that time. Cross fingers... if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; @@ -444,16 +444,15 @@ function network_content(&$a, $update = 0, $load = false) { } else { - if(! $firehose) { - // update - $r = q("SELECT item.parent AS item_id FROM item - left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) - WHERE true $uids AND item.item_restrict = 0 $simple_update - and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets ", - intval(ABOOK_FLAG_BLOCKED) - ); - } + // this is an update + $r = q("SELECT item.parent AS item_id FROM item + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + WHERE true $uids AND item.item_restrict = 0 $simple_update + and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets ", + intval(ABOOK_FLAG_BLOCKED) + ); + $_SESSION['loadtime'] = datetime_convert(); } // Then fetch all the children of the parents that are on this page diff --git a/mod/ping.php b/mod/ping.php index 001c5594d..b676726fe 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -274,7 +274,7 @@ function ping_init(&$a) { $r = q("SELECT * FROM item WHERE item_restrict = 0 and item_unseen = 1 and uid = %d - and author_xchan != '%s' ORDER BY created DESC", + and author_xchan != '%s' ORDER BY created DESC limit 300", intval(local_channel()), dbesc($ob_hash) ); @@ -295,7 +295,7 @@ function ping_init(&$a) { if(argc() > 1 && (argv(1) === 'intros')) { $result = array(); - $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC", + $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC LIMIT 50", intval(local_channel()), intval(ABOOK_FLAG_PENDING), intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED), @@ -327,7 +327,7 @@ function ping_init(&$a) { $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 - ORDER BY `start` DESC ", + ORDER BY `start` DESC LIMIT 1000", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) diff --git a/mod/post.php b/mod/post.php index 31b688221..37002b249 100644 --- a/mod/post.php +++ b/mod/post.php @@ -1,20 +1,21 @@ -<?php /** @file */ +<?php /** - * Zot endpoint + * @file mod/post.php + * + * @brief Zot endpoint. + * */ - require_once('include/zot.php'); - -function post_init(&$a) { - - // Most access to this endpoint is via the post method. - // Here we will pick out the magic auth params which arrive - // as a get request, and the only communications to arrive this way. - /** + * @brief HTTP POST entry point for Zot. + * + * Most access to this endpoint is via the post method. + * Here we will pick out the magic auth params which arrive as a get request, + * and the only communications to arrive this way. + * * Magic Auth * ========== * @@ -24,67 +25,68 @@ function post_init(&$a) { * The endpoint is typically https://$remotesite/post - or whatever was specified as the callback url in prior communications * (we will bootstrap an address and fetch a zot info packet if possible where no prior communications exist) * - * Four GET parameters are supplied: - * - ** auth => the urlencoded webbie (channel@host.domain) of the channel requesting access - ** dest => the desired destination URL (urlencoded) - ** sec => a random string which is also stored on $mysite for use during the verification phase. - ** version => the zot revision - ** delegate => optional urlencoded webbie of a local channel to invoke delegation rights for + * Five GET parameters are supplied: + * * auth => the urlencoded webbie (channel@host.domain) of the channel requesting access + * * dest => the desired destination URL (urlencoded) + * * sec => a random string which is also stored on $mysite for use during the verification phase. + * * version => the zot revision + * * delegate => optional urlencoded webbie of a local channel to invoke delegation rights for * * When this packet is received, an "auth-check" zot message is sent to $mysite. * (e.g. if $_GET['auth'] is foobar@podunk.edu, a zot packet is sent to the podunk.edu zot endpoint, which is typically /post) * If no information has been recorded about the requesting identity a zot information packet will be retrieved before * continuing. - * + * * The sender of this packet is an arbitrary/random site channel. The recipients will be a single recipient corresponding * to the guid and guid_sig we have associated with the requesting auth identity * - * - * { - * "type":"auth_check", - * "sender":{ - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TApz...", - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j..." - * }, - * "recipients":{ - * { - * "guid":"ZHSqb...", - * "guid_sig":"JsAAXi..." - * } - * } - * "callback":"\/post", - * "version":1, - * "secret":"1eaa661", - * "secret_sig":"eKV968b1..." - * } - * + * \code{.json} + * { + * "type":"auth_check", + * "sender":{ + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TApz...", + * "url":"http:\/\/podunk.edu", + * "url_sig":"T8Bp7j..." + * }, + * "recipients":{ + * { + * "guid":"ZHSqb...", + * "guid_sig":"JsAAXi..." + * } + * } + * "callback":"\/post", + * "version":1, + * "secret":"1eaa661", + * "secret_sig":"eKV968b1..." + * } + * \endcode * * auth_check messages MUST use encapsulated encryption. This message is sent to the origination site, which checks the 'secret' to see * if it is the same as the 'sec' which it passed originally. It also checks the secret_sig which is the secret signed by the * destination channel's private key and base64url encoded. If everything checks out, a json packet is returned: * - * { - * "success":1, - * "confirm":"q0Ysovd1u..." - * "service_class":(optional) - * "level":(optional) - * } + * \code{.json} + * { + * "success":1, + * "confirm":"q0Ysovd1u...", + * "service_class":(optional) + * "level":(optional) + * } + * \endcode * * 'confirm' in this case is the base64url encoded RSA signature of the concatenation of 'secret' with the * base64url encoded whirlpool hash of the requestor's guid and guid_sig; signed with the source channel private key. * This prevents a man-in-the-middle from inserting a rogue success packet. Upon receipt and successful * verification of this packet, the destination site will redirect to the original destination URL and indicate a successful remote login. * Service_class can be used by cooperating sites to provide different access rights based on account rights and subscription plans. It is - * a string whose contents are not defined by protocol. Example: "basic" or "gold". - * - * + * a string whose contents are not defined by protocol. Example: "basic" or "gold". * + * @param[in,out] App &$a */ - - if(array_key_exists('auth',$_REQUEST)) { +function post_init(&$a) { + + if (array_key_exists('auth', $_REQUEST)) { $ret = array('success' => false, 'message' => ''); @@ -95,7 +97,7 @@ function post_init(&$a) { $version = $_REQUEST['version']; $delegate = $_REQUEST['delegate']; - $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); + $test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0); // They are authenticating ultimately to the site and not to a particular channel. // Any channel will do, providing it's currently active. We just need to have an @@ -105,10 +107,10 @@ function post_init(&$a) { intval(PAGE_REMOVED) ); - if(! $c) { + if (! $c) { // nobody here logger('mod_zot: auth: unable to find a response channel'); - if($test) { + if ($test) { $ret['message'] .= 'no local channels found.' . EOL; json_return_and_die($ret); } @@ -121,12 +123,12 @@ function post_init(&$a) { dbesc($address) ); - if(! $x) { + if (! $x) { // finger them if they can't be found. - $ret = zot_finger($address,null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) + $ret = zot_finger($address, null); + if ($ret['success']) { + $j = json_decode($ret['body'], true); + if ($j) import_xchan($j); $x = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_addr = '%s' order by hubloc_id desc limit 1", dbesc($address) @@ -166,61 +168,60 @@ function post_init(&$a) { $j = array(); - if(! $already_authed) { + if (! $already_authed) { // Auth packets MUST use ultra top-secret hush-hush mode - e.g. the entire packet is encrypted using the site private key // The actual channel sending the packet ($c[0]) is not important, but this provides a generic zot packet with a sender // which can be verified $p = zot_build_packet($c[0],$type = 'auth_check', array(array('guid' => $x[0]['hubloc_guid'],'guid_sig' => $x[0]['hubloc_guid_sig'])), $x[0]['hubloc_sitekey'], $sec); - if($test) { + if ($test) { $ret['message'] .= 'auth check packet created using sitekey ' . $x[0]['hubloc_sitekey'] . EOL; $ret['message'] .= 'packet contents: ' . $p . EOL; } $result = zot_zot($x[0]['hubloc_callback'],$p); - - if(! $result['success']) { + if (! $result['success']) { logger('mod_zot: auth_check callback failed.'); - if($test) { + if ($test) { $ret['message'] .= 'auth check request to your site returned .' . print_r($result, true) . EOL; json_return_and_die($ret); } goaway($desturl); } - $j = json_decode($result['body'],true); - if(! $j) { + $j = json_decode($result['body'], true); + if (! $j) { logger('mod_zot: auth_check json data malformed.'); if($test) { $ret['message'] .= 'json malformed: ' . $result['body'] . EOL; json_return_and_die($ret); } - } + } } - if($test) { + if ($test) { $ret['message'] .= 'auth check request returned .' . print_r($j, true) . EOL; - } + } - if($already_authed || $j['success']) { - if($j['success']) { + if ($already_authed || $j['success']) { + if ($j['success']) { // legit response, but we do need to check that this wasn't answered by a man-in-middle - if(! rsa_verify($sec . $x[0]['xchan_hash'],base64url_decode($j['confirm']),$x[0]['xchan_pubkey'])) { + if (! rsa_verify($sec . $x[0]['xchan_hash'],base64url_decode($j['confirm']),$x[0]['xchan_pubkey'])) { logger('mod_zot: auth: final confirmation failed.'); - if($test) { + if ($test) { $ret['message'] .= 'final confirmation failed. ' . $sec . print_r($j,true) . print_r($x[0],true); json_return_and_die($ret); } - + goaway($desturl); } - if(array_key_exists('service_class',$j)) + if (array_key_exists('service_class',$j)) $remote_service_class = $j['service_class']; - if(array_key_exists('level',$j)) + if (array_key_exists('level',$j)) $remote_level = $j['level']; - if(array_key_exists('DNT',$j)) + if (array_key_exists('DNT',$j)) $DNT = $j['DNT']; } // everything is good... maybe @@ -229,35 +230,33 @@ function post_init(&$a) { // tell them to logout if they're logged in locally as anything but the target remote account // in which case just shut up because they don't need to be doing this at all. - if($a->channel['channel_hash'] != $x[0]['xchan_hash']) { + if ($a->channel['channel_hash'] != $x[0]['xchan_hash']) { logger('mod_zot: auth: already authenticated locally as somebody else.'); notice( t('Remote authentication blocked. You are logged into this site locally. Please logout and retry.') . EOL); - if($test) { + if ($test) { $ret['message'] .= 'already logged in locally with a conflicting identity.' . EOL; json_return_and_die($ret); } - } goaway($desturl); } - // log them in - if($test) { + if ($test) { $ret['success'] = true; $ret['message'] .= 'Authentication Success!' . EOL; json_return_and_die($ret); } $delegation_success = false; - if($delegate) { + if ($delegate) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1", dbesc($delegate) ); - if($r && intval($r[0]['channel_id'])) { + if ($r && intval($r[0]['channel_id'])) { $allowed = perm_is_allowed($r[0]['channel_id'],$x[0]['xchan_hash'],'delegate'); - if($allowed) { + if ($allowed) { $_SESSION['delegate_channel'] = $r[0]['channel_id']; $_SESSION['delegate'] = $x[0]['xchan_hash']; $_SESSION['account_id'] = intval($r[0]['channel_account_id']); @@ -267,12 +266,9 @@ function post_init(&$a) { } } } - - - $_SESSION['authenticated'] = 1; - if(! $delegation_success) { + if (! $delegation_success) { $_SESSION['visitor_id'] = $x[0]['xchan_hash']; $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = $address; @@ -289,18 +285,15 @@ function post_init(&$a) { $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name'])); logger('mod_zot: auth success from ' . $x[0]['xchan_addr']); - q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", - intval(HUBLOC_WORKS), - intval($x[0]['hubloc_id']) - ); - - + q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", + intval(HUBLOC_WORKS), + intval($x[0]['hubloc_id']) + ); } else { - if($test) { + if ($test) { $ret['message'] .= 'auth failure. ' . print_r($_REQUEST,true) . print_r($j,true) . EOL; json_return_and_die($ret); } - logger('mod_zot: magic-auth failure - not authenticated: ' . $x[0]['xchan_addr']); q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", intval(HUBLOC_RECEIVE_ERROR), @@ -308,11 +301,14 @@ function post_init(&$a) { ); } - // FIXME - we really want to save the return_url in the session before we visit rmagic. - // This does however prevent a recursion if you visit rmagic directly, as it would otherwise send you back here again. - // But z_root() probably isn't where you really want to go. + /** + * @FIXME we really want to save the return_url in the session before we + * visit rmagic. This does however prevent a recursion if you visit + * rmagic directly, as it would otherwise send you back here again. + * But z_root() probably isn't where you really want to go. + */ - if($test) { + if ($test) { $ret['message'] .= 'auth failure fallthrough ' . print_r($_REQUEST,true) . print_r($j,true) . EOL; json_return_and_die($ret); } @@ -322,41 +318,40 @@ function post_init(&$a) { goaway($desturl); } - return; } /** - * @function post_post(&$a) - * zot communications and messaging + * @brief zot communications and messaging. * - * Sender HTTP posts to this endpoint ($site/post typically) with 'data' parameter set to json zot message packet. - * This packet is optionally encrypted, which we will discover if the json has an 'iv' element. - * $contents => array( 'alg' => 'aes256cbc', 'iv' => initialisation vector, 'key' => decryption key, 'data' => encrypted data); - * $contents->iv and $contents->key are random strings encrypted with this site's RSA public key and then base64url encoded. - * Currently only 'aes256cbc' is used, but this is extensible should that algorithm prove inadequate. + * Sender HTTP posts to this endpoint ($site/post typically) with 'data' parameter set to json zot message packet. + * This packet is optionally encrypted, which we will discover if the json has an 'iv' element. + * $contents => array( 'alg' => 'aes256cbc', 'iv' => initialisation vector, 'key' => decryption key, 'data' => encrypted data); + * $contents->iv and $contents->key are random strings encrypted with this site's RSA public key and then base64url encoded. + * Currently only 'aes256cbc' is used, but this is extensible should that algorithm prove inadequate. * - * Once decrypted, one will find the normal json_encoded zot message packet. + * Once decrypted, one will find the normal json_encoded zot message packet. * * Defined packet types are: notify, purge, refresh, force_refresh, auth_check, ping, and pickup * * Standard packet: (used by notify, purge, refresh, force_refresh, and auth_check) - * + * \code{.json} * { - * "type": "notify", - * "sender":{ - * "guid":"kgVFf_1...", - * "guid_sig":"PT9-TApzp...", - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j5...", - * }, - * "recipients": { optional recipient array }, - * "callback":"\/post", - * "version":1, - * "secret":"1eaa...", - * "secret_sig": "df89025470fac8..." + * "type": "notify", + * "sender":{ + * "guid":"kgVFf_1...", + * "guid_sig":"PT9-TApzp...", + * "url":"http:\/\/podunk.edu", + * "url_sig":"T8Bp7j5...", + * }, + * "recipients": { optional recipient array }, + * "callback":"\/post", + * "version":1, + * "secret":"1eaa...", + * "secret_sig": "df89025470fac8..." * } - * + * \endcode + * * Signature fields are all signed with the sender channel private key and base64url encoded. * Recipients are arrays of guid and guid_sig, which were previously signed with the recipients private * key and base64url encoded and later obtained via channel discovery. Absence of recipients indicates @@ -364,108 +359,116 @@ function post_init(&$a) { * * "pickup" packet: * The pickup packet is sent in response to a notify packet from another site - * + * \code{.json} * { - * "type":"pickup", - * "url":"http:\/\/example.com", - * "callback":"http:\/\/example.com\/post", - * "callback_sig":"teE1_fLI...", - * "secret":"1eaa...", - * "secret_sig":"O7nB4_..." + * "type":"pickup", + * "url":"http:\/\/example.com", + * "callback":"http:\/\/example.com\/post", + * "callback_sig":"teE1_fLI...", + * "secret":"1eaa...", + * "secret_sig":"O7nB4_..." * } + * \endcode * - * In the pickup packet, the sig fields correspond to the respective data element signed with this site's system - * private key and then base64url encoded. + * In the pickup packet, the sig fields correspond to the respective data + * element signed with this site's system private key and then base64url encoded. * The "secret" is the same as the original secret from the notify packet. * - * If verification is successful, a json structure is returned - * containing a success indicator and an array of type 'pickup'. - * Each pickup element contains the original notify request and a message field whose contents are - * dependent on the message type + * If verification is successful, a json structure is returned containing a + * success indicator and an array of type 'pickup'. + * Each pickup element contains the original notify request and a message field + * whose contents are dependent on the message type. * - * This JSON array is AES encapsulated using the site public key of the site that sent the initial zot pickup packet. + * This JSON array is AES encapsulated using the site public key of the site + * that sent the initial zot pickup packet. * Using the above example, this would be example.com. - * - * + * + * \code{.json} * { - * "success":1, - * "pickup":{ - * "notify":{ - * "type":"notify", - * "sender":{ - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TApz...", - * "url":"http:\/\/z.podunk.edu", - * "url_sig":"T8Bp7j5D..." - * }, - * "callback":"\/post", - * "version":1, - * "secret":"1eaa661..." - * }, - * "message":{ - * "type":"activity", - * "message_id":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "message_top":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "message_parent":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", - * "created":"2012-11-20 04:04:16", - * "edited":"2012-11-20 04:04:16", - * "title":"", - * "body":"Hi Nickordo", - * "app":"", - * "verb":"post", - * "object_type":"", - * "target_type":"", - * "permalink":"", - * "location":"", - * "longlat":"", - * "owner":{ - * "name":"Indigo", - * "address":"indigo@podunk.edu", - * "url":"http:\/\/podunk.edu", - * "photo":{ - * "mimetype":"image\/jpeg", - * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * "success":1, + * "pickup":{ + * "notify":{ + * "type":"notify", + * "sender":{ + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TApz...", + * "url":"http:\/\/z.podunk.edu", + * "url_sig":"T8Bp7j5D..." * }, - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TAp...", + * "callback":"\/post", + * "version":1, + * "secret":"1eaa661..." * }, - * "author":{ - * "name":"Indigo", - * "address":"indigo@podunk.edu", - * "url":"http:\/\/podunk.edu", - * "photo":{ - * "mimetype":"image\/jpeg", - * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * "message":{ + * "type":"activity", + * "message_id":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "message_top":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "message_parent":"10b049ce384cbb2da9467319bc98169ab36290b8bbb403aa0c0accd9cb072e76@podunk.edu", + * "created":"2012-11-20 04:04:16", + * "edited":"2012-11-20 04:04:16", + * "title":"", + * "body":"Hi Nickordo", + * "app":"", + * "verb":"post", + * "object_type":"", + * "target_type":"", + * "permalink":"", + * "location":"", + * "longlat":"", + * "owner":{ + * "name":"Indigo", + * "address":"indigo@podunk.edu", + * "url":"http:\/\/podunk.edu", + * "photo":{ + * "mimetype":"image\/jpeg", + * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * }, + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TAp...", * }, - * "guid":"kgVFf_...", - * "guid_sig":"PT9-TAp..." + * "author":{ + * "name":"Indigo", + * "address":"indigo@podunk.edu", + * "url":"http:\/\/podunk.edu", + * "photo":{ + * "mimetype":"image\/jpeg", + * "src":"http:\/\/podunk.edu\/photo\/profile\/m\/5" + * }, + * "guid":"kgVFf_...", + * "guid_sig":"PT9-TAp..." + * } * } * } * } - *} + * \endcode * - * Currently defined message types are 'activity', 'mail', 'profile', 'location' and 'channel_sync', - * which each have different content schemas. + * Currently defined message types are 'activity', 'mail', 'profile', 'location' + * and 'channel_sync', which each have different content schemas. * * Ping packet: - * A ping packet does not require any parameters except the type. It may or may not be encrypted. - * + * A ping packet does not require any parameters except the type. It may or may + * not be encrypted. + * + * \code{.json} * { - * "type": "ping" + * "type": "ping" * } - * + * \endcode + * * On receipt of a ping packet a ping response will be returned: * + * \code{.json} * { * "success" : 1, * "site" { - * "url":"http:\/\/podunk.edu", - * "url_sig":"T8Bp7j5...", - * "sitekey": "-----BEGIN PUBLIC KEY----- - * MIICIjANBgkqhkiG9w0BAQE..." - * } + * "url": "http:\/\/podunk.edu", + * "url_sig": "T8Bp7j5...", + * "sitekey": "-----BEGIN PUBLIC KEY----- + * MIICIjANBgkqhkiG9w0BAQE..." + * } * } - * + * \endcode + * * The ping packet can be used to verify that a site has not been re-installed, and to * initiate corrective action if it has. The url_sig is signed with the site private key * and base64url encoded - and this should verify with the enclosed sitekey. Failure to @@ -479,21 +482,19 @@ function post_init(&$a) { * If you have no records which match this url_sig and key - no corrective action should * be taken as this packet may have been returned by an imposter. * + * @param[in,out] App &$a */ - - function post_post(&$a) { - $encrypted_packet = false; $ret = array('success' => false); $data = json_decode($_REQUEST['data'],true); - - /** - * Many message packets will arrive encrypted. The existence of an 'iv' element - * tells us we need to unencapsulate the AES-256-CBC content using the site private key + /* + * Many message packets will arrive encrypted. The existence of an 'iv' + * element tells us we need to unencapsulate the AES-256-CBC content using + * the site private key. */ if($data && array_key_exists('iv',$data)) { @@ -539,12 +540,11 @@ function post_post(&$a) { if($msgtype === 'pickup') { - /** + /* * The 'pickup' message arrives with a tracking ID which is associated with a particular outq_hash * First verify that that the returned signatures verify, then check that we have an outbound queue item * with the correct hash. * If everything verifies, find any/all outbound messages in the queue for this hubloc and send them back - * */ if((! $data['secret']) || (! $data['secret_sig'])) { @@ -597,7 +597,7 @@ function post_post(&$a) { json_return_and_die($ret); } - /** + /* * If we made it to here, the signatures verify, but we still don't know if the tracking ID is valid. * It wouldn't be an error if the tracking ID isn't found, because we may have sent this particular * queue item with another pickup (after the tracking ID for the other pickup was verified). @@ -613,7 +613,7 @@ function post_post(&$a) { json_return_and_die($ret); } - /** + /* * Everything is good if we made it here, so find all messages that are going to this location * and send them all. */ @@ -651,33 +651,31 @@ function post_post(&$a) { $encrypted = crypto_encapsulate(json_encode($ret),$sitekey); json_return_and_die($encrypted); - /** pickup: end */ + /* pickup: end */ } - - - /** + /* * All other message types require us to verify the sender. This is a generic check, so we * will do it once here and bail if anything goes wrong. */ - if(array_key_exists('sender',$data)) { + if (array_key_exists('sender',$data)) { $sender = $data['sender']; - } + } - /** Check if the sender is already verified here */ + /* Check if the sender is already verified here */ $hub = zot_gethub($sender); - if(! $hub) { + if (! $hub) { - /** Have never seen this guid or this guid coming from this location. Check it and register it. */ + /* Have never seen this guid or this guid coming from this location. Check it and register it. */ // (!!) this will validate the sender $result = zot_register_hub($sender); - if((! $result['success']) || (! ($hub = zot_gethub($sender)))) { + if ((! $result['success']) || (! ($hub = zot_gethub($sender)))) { $ret['message'] = 'Hub not available.'; logger('mod_zot: no hub'); json_return_and_die($ret); @@ -695,12 +693,12 @@ function post_post(&$a) { // a dead hub came back to life - reset any tombstones we might have - if($hub['hubloc_status'] & HUBLOC_OFFLINE) { + if ($hub['hubloc_status'] & HUBLOC_OFFLINE) { q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d", intval(HUBLOC_OFFLINE), intval($hub['hubloc_id']) ); - if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { + if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d", intval(HUBLOC_FLAGS_ORPHANCHECK), intval($hub['hubloc_id']) @@ -711,15 +709,13 @@ function post_post(&$a) { intval(XCHAN_FLAGS_ORPHAN), dbesc($hub['hubloc_hash']) ); - } - + } - /** + /* * This hub has now been proven to be valid. * Any hub with the same URL and a different sitekey cannot be valid. * Get rid of them (mark them deleted). There's a good chance they were re-installs. - * */ q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ", @@ -728,15 +724,15 @@ function post_post(&$a) { dbesc($hub['hubloc_sitekey']) ); - // TODO: check which hub is primary and take action if mismatched + /** @TODO check which hub is primary and take action if mismatched */ - if(array_key_exists('recipients',$data)) + if (array_key_exists('recipients', $data)) $recipients = $data['recipients']; - if($msgtype === 'auth_check') { + if ($msgtype === 'auth_check') { - /** + /* * Requestor visits /magic/?dest=somewhere on their own site with a browser * magic redirects them to $destsite/post [with auth args....] * $destsite sends an auth_check packet to originator site @@ -751,12 +747,12 @@ function post_post(&$a) { */ logger('mod_zot: auth_check', LOGGER_DEBUG); - if(! $encrypted_packet) { + if (! $encrypted_packet) { logger('mod_zot: auth_check packet was not encrypted.'); $ret['message'] .= 'no packet encryption' . EOL; json_return_and_die($ret); } - + $arr = $data['sender']; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); @@ -774,7 +770,7 @@ function post_post(&$a) { // First verify their signature. We will have obtained a zot-info packet from them as part of the sender // verification. - if((! $y) || (! rsa_verify($data['secret'],base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) { + if ((! $y) || (! rsa_verify($data['secret'], base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) { logger('mod_zot: auth_check: sender not found or secret_sig invalid.'); $ret['message'] .= 'sender not found or sig invalid ' . print_r($y,true) . EOL; json_return_and_die($ret); @@ -784,14 +780,14 @@ function post_post(&$a) { $ret['message'] .= 'recipients ' . print_r($recipients,true) . EOL; - if($data['recipients']) { + if ($data['recipients']) { $arr = $data['recipients'][0]; - $recip_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); + $recip_hash = make_xchan_hash($arr['guid'], $arr['guid_sig']); $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_hash = '%s' limit 1", dbesc($recip_hash) ); - if(! $c) { + if (! $c) { logger('mod_zot: auth_check: recipient channel not found.'); $ret['message'] .= 'recipient not found.' . EOL; json_return_and_die($ret); @@ -807,7 +803,7 @@ function post_post(&$a) { dbesc($data['secret']), dbesc($data['sender']['url']) ); - if(! $z) { + if (! $z) { logger('mod_zot: auth_check: verification key not found.'); $ret['message'] .= 'verification key not found' . EOL; json_return_and_die($ret); @@ -823,70 +819,66 @@ function post_post(&$a) { logger('mod_zot: auth_check: success', LOGGER_DEBUG); $ret['success'] = true; $ret['confirm'] = $confirm; - if($u && $u[0]['account_service_class']) + if ($u && $u[0]['account_service_class']) $ret['service_class'] = $u[0]['account_service_class']; // Set "do not track" flag if this site or this channel's profile is restricted // in some way - if(intval(get_config('system','block_public'))) + if (intval(get_config('system','block_public'))) $ret['DNT'] = true; - if(! perm_is_allowed($c[0]['channel_id'],'','view_profile')) + if (! perm_is_allowed($c[0]['channel_id'],'','view_profile')) $ret['DNT'] = true; - if(get_pconfig($c[0]['channel_id'],'system','do_not_track')) + if (get_pconfig($c[0]['channel_id'],'system','do_not_track')) $ret['DNT'] = true; - if(get_pconfig($c[0]['channel_id'],'system','hide_online_status')) + if (get_pconfig($c[0]['channel_id'],'system','hide_online_status')) $ret['DNT'] = true; json_return_and_die($ret); - } json_return_and_die($ret); } - if($msgtype === 'request') { + if ($msgtype === 'request') { // request a particular post/conversation by message_id $x = zot_process_message_request($data); json_return_and_die($x); } - - if($msgtype === 'purge') { - if($recipients) { + if ($msgtype === 'purge') { + if ($recipients) { // basically this means "unfriend" - foreach($recipients as $recip) { + foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), dbesc($recip['guid_sig']) ); - if($r) { + if ($r) { $r = q("select abook_id from abook where uid = %d and abook_xchan = '%s' limit 1", intval($r[0]['channel_id']), dbesc(make_xchan_hash($sender['guid'],$sender['guid_sig'])) ); - if($r) { + if ($r) { contact_remove($r[0]['channel_id'],$r[0]['abook_id']); } } } - } - else { + } else { // Unfriend everybody - basically this means the channel has committed suicide $arr = $data['sender']; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); - + require_once('include/Contact.php'); remove_all_xchan_resources($sender_hash); $ret['success'] = true; json_return_and_die($ret); - } } - if(($msgtype === 'refresh') || ($msgtype === 'force_refresh')) { + if (($msgtype === 'refresh') || ($msgtype === 'force_refresh')) { // remote channel info (such as permissions or photo or something) // has been updated. Grab a fresh copy and sync it. @@ -894,11 +886,11 @@ function post_post(&$a) { // force_refresh unconditionally creates a directory update record, // even if no changes were detected upon processing. - if($recipients) { + if ($recipients) { // This would be a permissions update, typically for one connection - foreach($recipients as $recip) { + foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", @@ -910,44 +902,37 @@ function post_post(&$a) { 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] - ),$r[0], (($msgtype === 'force_refresh') ? true : false)); + ), $r[0], (($msgtype === 'force_refresh') ? true : false)); } - } - else { + } else { // system wide refresh - + $x = zot_refresh(array( 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] - ),null,(($msgtype === 'force_refresh') ? true : false)); + ), null, (($msgtype === 'force_refresh') ? true : false)); } $ret['success'] = true; json_return_and_die($ret); } - if($msgtype === 'notify') { + if ($msgtype === 'notify') { $async = get_config('system','queued_fetch'); - if($async) { + if ($async) { // add to receive queue // qreceive_add($data); - } - else { + } else { $x = zot_fetch($data); $ret['delivery_report'] = $x; } $ret['success'] = true; json_return_and_die($ret); - } - // catchall json_return_and_die($ret); - - } - diff --git a/mod/randprof.php b/mod/randprof.php index bddb3251a..9817685c8 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -6,6 +6,7 @@ function randprof_init(&$a) { $x = random_profile(); if($x) goaway(chanlink_url($x)); - // FIXME this doesn't work at the moment as a fallback + + /** FIXME this doesn't work at the moment as a fallback */ goaway($a->get_baseurl() . '/profile'); } diff --git a/mod/regdir.php b/mod/regdir.php index 5331c1dd4..025be220b 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -1,18 +1,17 @@ <?php - /** - * With args, register a directory server for this realm - * With no args, return a JSON array of directory servers for this realm - - * FIXME: Not yet implemented: Some realms may require authentication to join their realm. - * The RED_GLOBAL realm does not require authentication. + * With args, register a directory server for this realm. + * With no args, return a JSON array of directory servers for this realm. + * + * @FIXME Not yet implemented: Some realms may require authentication to join their realm. + * The RED_GLOBAL realm does not require authentication. * We would then need a flag in the site table to indicate that they've been * validated by the PRIMARY directory for that realm. Sites claiming to be PRIMARY - * but are not the realm PRIMARY will be marked invalid. + * but are not the realm PRIMARY will be marked invalid. + * + * @param App &$a */ - - function regdir_init(&$a) { $result = array('success' => false); @@ -31,8 +30,7 @@ function regdir_init(&$a) { if($realm === DIRECTORY_REALM) { $valid = 1; - } - else { + } else { $token = get_config('system','realm_token'); if($token && $access_token != $token) { $result['message'] = 'This realm requires an access token'; @@ -40,19 +38,19 @@ function regdir_init(&$a) { } $valid = 1; } - + $dirmode = intval(get_config('system','directory_mode')); - if($dirmode == DIRECTORY_MODE_NORMAL) { + if ($dirmode == DIRECTORY_MODE_NORMAL) { $ret['message'] = t('This site is not a directory server'); json_return_and_die($ret); } $m = null; - if($url) { + if ($url) { $m = parse_url($url); - if((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { + if ((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { $result['message'] = 'unparseable url'; json_return_and_die($result); } @@ -75,31 +73,28 @@ function regdir_init(&$a) { ); json_return_and_die($result); - } - else { + } else { // We can put this in the sql without the condition after 31 april 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); - if($dirmode == DIRECTORY_MODE_STANDALONE) { + if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); - } - else { + } else { $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' $sql_extra ", dbesc(get_directory_realm()) ); } - if($r) { + if ($r) { $result['success'] = true; $result['directories'] = array(); - foreach($r as $rr) + foreach ($r as $rr) $result['directories'][] = $rr['site_url']; + json_return_and_die($result); } } json_return_and_die($result); - - -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/mod/share.php b/mod/share.php index 923971694..d5a389bdf 100644 --- a/mod/share.php +++ b/mod/share.php @@ -13,7 +13,6 @@ function share_init(&$a) { if(! (local_channel() || remote_channel())) killme(); - $r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1", intval($post_id) ); @@ -30,13 +29,12 @@ function share_init(&$a) { if(! $r) killme(); - // FIXME - we only share bbcode + /** @FIXME we only share bbcode */ if($r[0]['mimetype'] !== 'text/bbcode') killme(); - // FIXME - eventually we want to post remotely via rpost - // on your home site. + /** @FIXME eventually we want to post remotely via rpost on your home site */ // When that works remove this next bit: if(! local_channel()) @@ -64,20 +62,20 @@ function share_init(&$a) { echo $o; killme(); } - + $observer = $a->get_observer(); $parsed = $observer['xchan_url']; if($parsed) { $post_url = $parsed['scheme'] . ':' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '') . '/rpost'; - // FIXME - we were probably called from JS - // so we don't know the return page. - // in fact we won't be able to load the remote page. - // we might need an iframe + + /** + * @FIXME we were probably called from JS so we don't know the return page. + * In fact we won't be able to load the remote page. + * we might need an iframe + */ $x = z_post_url($post_url, array('f' => '', 'body' => $o )); killme(); } - - } diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index b77c9dad1..bee072ea7 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -42,7 +42,7 @@ function sharedwithme_content(&$a) { } //list files - $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", + $r = q("SELECT id, uid, object, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", dbesc(ACTIVITY_POST), dbesc(ACTIVITY_OBJ_FILE), intval(local_channel()), @@ -50,8 +50,10 @@ function sharedwithme_content(&$a) { ); $items =array(); + $ids = ''; if($r) { + foreach($r as $rr) { $object = json_decode($rr['object'],true); @@ -63,10 +65,27 @@ function sharedwithme_content(&$a) { $item['objfilename'] = $object['filename']; $item['objfilesize'] = userReadableSize($object['filesize']); $item['objedited'] = $object['edited']; + $item['unseen'] = $rr['item_unseen']; $items[] = $item; + if($item['unseen'] > 0) { + $ids .= " '" . $rr['id'] . "',"; + } + } + + } + + if($ids) { + + //remove trailing , + $ids = rtrim($ids, ","); + + q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d", + intval(local_channel()) + ); + } $o = profile_tabs($a, $is_owner, $channel['channel_address']); @@ -74,6 +93,7 @@ function sharedwithme_content(&$a) { $o .= replace_macros(get_markup_template('sharedwithme.tpl'), array( '$header' => t('Files: shared with me'), '$name' => t('Name'), + '$label_new' => t('NEW'), '$size' => t('Size'), '$lastmod' => t('Last Modified'), '$dropall' => t('Remove all files'), diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 2ad9f7cde..ab6891e25 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -72,6 +72,8 @@ function siteinfo_init(&$a) { $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat')); $local_posts_stat = intval(get_config('system','local_posts_stat')); $hide_in_statistics = intval(get_config('system','hide_in_statistics')); + $site_expire = intval(get_config('system', 'default_expire_days')); + $data = Array( 'version' => $version, @@ -84,6 +86,7 @@ function siteinfo_init(&$a) { 'language' => get_config('system','language'), 'diaspora_emulation' => get_config('system','diaspora_enabled'), 'rss_connections' => get_config('system','feed_contacts'), + 'expiration' => $site_expire, 'default_service_restrictions' => $service_class, 'admin' => $admin, 'site_name' => (($site_name) ? $site_name : ''), @@ -150,7 +153,7 @@ function siteinfo_content(&$a) { $o = replace_macros(get_markup_template('siteinfo.tpl'), array( '$title' => t('Red'), - '$description' => t('This is a hub of the Red Matrix - a global cooperative network of decentralized privacy enhanced websites.'), + '$description' => t('This is a hub of redmatrix - a global cooperative network of decentralized privacy enhanced websites.'), '$version' => $version, '$tag_txt' => t('Tag: '), '$tag' => $tag, @@ -158,7 +161,7 @@ function siteinfo_content(&$a) { '$lastpoll' => get_poller_runtime(), '$commit' => $commit, '$web_location' => t('Running at web location') . ' ' . z_root(), - '$visit' => t('Please visit <a href="https://redmatrix.me">RedMatrix.me</a> to learn more about the Red Matrix.'), + '$visit' => t('Please visit <a href="https://redmatrix.me">redmatrix.me</a> to learn more about the Red Matrix.'), '$bug_text' => t('Bug reports and issues: please visit'), '$bug_link_url' => 'https://github.com/friendica/red/issues', '$bug_link_text' => 'redmatrix issues', diff --git a/mod/thing.php b/mod/thing.php index 4ec10f5a6..c6b70fbb4 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -1,4 +1,8 @@ -<?php /** @file */ +<?php +/** + * @file mod/thing.php + * @brief + */ require_once('include/items.php'); require_once('include/contact_selectors.php'); @@ -9,9 +13,6 @@ function thing_init(&$a) { if(! local_channel()) return; - - - $account_id = $a->get_account(); $channel = $a->get_channel(); @@ -26,19 +27,18 @@ function thing_init(&$a) { $hash = random_string(); - $verbs = obj_verbs(); - /** + /** * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" * We use the first person form when creating an activity, but the third person for use in activities - * FIXME: There is no accounting for verb gender for languages where this is significant. We may eventually + * @FIXME There is no accounting for verb gender for languages where this is significant. We may eventually * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module. */ $translated_verb = $verbs[$verb][1]; - /** + /* * The site administrator can do things that normals cannot. * This is restricted because it will likely cause * an activitystreams protocol violation and the activity might @@ -50,14 +50,14 @@ function thing_init(&$a) { if(! $translated_verb) { if(is_site_admin()) $translated_verb = $verb; - } - - /** + } + + /* * Things, objects: We do not provide definite (a, an) or indefinite (the) articles or singular/plural designators * That needs to be specified in your thing. e.g. Mike has "a carrot", Greg wants "balls", Bob likes "the Boston Red Sox". */ - /** + /* * Future work on this module might produce more complex activities with targets, e.g. Phillip likes Karen's moustache * and to describe other non-thing objects like channels, such as Karl wants Susan - where Susan represents a channel profile. */ @@ -65,8 +65,6 @@ function thing_init(&$a) { if((! $name) || (! $translated_verb)) return; - - if($term_hash) { $t = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", intval(TERM_OBJ_THING), @@ -115,7 +113,6 @@ function thing_init(&$a) { $local_photo_type = $arr[3]; } - $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_channel()), intval(TERM_OBJ_THING), @@ -159,14 +156,12 @@ function thing_init(&$a) { info( t('Thing added')); - if($activity) { $arr = array(); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); if($local_photo) $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); - $objtype = ACTIVITY_OBJ_THING; $obj = json_encode(array( @@ -182,9 +177,8 @@ function thing_init(&$a) { $arr['owner_xchan'] = $channel['channel_hash']; $arr['author_xchan'] = $channel['channel_hash']; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; - + $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; @@ -212,14 +206,14 @@ function thing_init(&$a) { else $arr['allow_cid'] = '<' . get_observer_hash() . '>'; } - + $ret = post_activity_item($arr); } } function thing_content(&$a) { - + if(argc() == 2) { $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", @@ -249,12 +243,10 @@ function thing_content(&$a) { } $thing_hash = ''; - if(argc() == 3 && argv(1) === 'edit') { $thing_hash = argv(2); - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", intval(TERM_OBJ_THING), dbesc($thing_hash) @@ -265,7 +257,6 @@ function thing_content(&$a) { return ''; } - $o .= replace_macros(get_markup_template('thing_edit.tpl'),array( '$thing_hdr' => t('Edit Thing'), '$multiprof' => feature_enabled(local_channel(),'multi_profiles'), @@ -300,7 +291,6 @@ function thing_content(&$a) { return ''; } - $x = q("delete from obj where obj_obj = '%s' and obj_type = %d and obj_channel = %d", dbesc($thing_hash), intval(TERM_OBJ_THING), @@ -310,6 +300,7 @@ function thing_content(&$a) { dbesc($thing_hash), intval(local_channel()) ); + return $o; } @@ -328,6 +319,4 @@ function thing_content(&$a) { )); return $o; - - } diff --git a/mod/zotfeed.php b/mod/zotfeed.php index 7bf91d4db..78a667330 100644 --- a/mod/zotfeed.php +++ b/mod/zotfeed.php @@ -9,7 +9,7 @@ function zotfeed_init(&$a) { $mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : ''); if(! $mindate) - $mindate = datetime_convert('UTC','UTC', 'now - 1 month'); + $mindate = datetime_convert('UTC','UTC', 'now - 4 days'); if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { $result['message'] = 'Public access denied'; @@ -21,7 +21,7 @@ function zotfeed_init(&$a) { $channel_address = ((argc() > 1) ? argv(1) : ''); if($channel_address) { - $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d)>0 limit 1", + $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d) > 0 limit 1", dbesc(argv(1)), intval(PAGE_REMOVED) ); @@ -30,6 +30,7 @@ function zotfeed_init(&$a) { $x = get_sys_channel(); if($x) $r = array($x); + $mindate = datetime_convert('UTC','UTC', 'now - 2 days'); } if(! $r) { $result['message'] = 'Channel not found.'; |