diff --git a/boot.php b/boot.php index 15eaf7970..fbc2e1f71 100644 --- a/boot.php +++ b/boot.php @@ -156,22 +156,21 @@ define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder * Permissions */ -define ( 'PERMS_VISIBLE', 0x0001); // Can be seen in my public address book -define ( 'PERMS_TRANSMIT', 0x0002); // Can post to my stream -define ( 'PERMS_RECEIVE', 0x0004); // Can receive my posts -define ( 'PERMS_COMMENT', 0x0008); // Can comment on my posts -define ( 'PERMS_POSTWALL', 0x0010); // Can post to my wall if I allow wall posts -define ( 'PERMS_TAGWALL', 0x0020); // Can post to my wall via tags (e.g. community groups) -define ( 'PERMS_MAIL', 0x0040); // Can send me email -define ( 'PERMS_SEEABOOK', 0x0080); // Can see my address book if it's not public -define ( 'PERMS_CHAT', 0x0100); // Can IM me (when available) -define ( 'PERMS_SEEPERMS', 0x7000); // Can see these permissions -define ( 'PERMS_FRIEND', PERMS_VISIBLE|PERMS_TRANSMIT|PERMS_RECEIVE|PERMS_COMMENT|PERMS_POSTWALL|PERMS_MAIL| - PERMS_SEEABOOK|PERMS_CHAT|PERMS_SEEPERMS ); // Can do anything but tag post +define ( 'PERMS_R_STREAM', 0x0001); +define ( 'PERMS_R_PROFILE', 0x0002); +define ( 'PERMS_R_PHOTOS', 0x0004); +define ( 'PERMS_R_ABOOK', 0x0008); + + +define ( 'PERMS_W_STREAM', 0x0010); +define ( 'PERMS_W_WALL', 0x0020); +define ( 'PERMS_W_TAGWALL', 0x0040); +define ( 'PERMS_W_COMMENT', 0x0080); +define ( 'PERMS_W_MAIL', 0x0100); +define ( 'PERMS_W_PHOTOS', 0x0200); +define ( 'PERMS_W_CHAT', 0x0400); -define ( 'PERMS_COMMUNITY', PERMS_VISIBLE|PERMS_RECEIVE|PERMS_COMMENT|PERMS_POSTWALL|PERMS_TAGWALL| - PERMS_SEEABOOK|PERMS_SEEPERMS); // Public group profile // General channel permissions @@ -1056,11 +1055,29 @@ if(! function_exists('get_max_import_size')) { if(! function_exists('profile_load')) { function profile_load(&$a, $nickname, $profile = 0) { - if(remote_user()) { - $r = q("SELECT `profile_id` FROM `contact` WHERE `id` = %d LIMIT 1", - intval($_SESSION['visitor_id'])); - if(count($r)) - $profile = $r[0]['profile_id']; + + $user = q("select entity_id from entity where entity_address = '%s' limit 1", + dbesc($nickname) + ); + + if(! ($user && count($user))) { + logger('profile error: ' . $a->query_string, LOGGER_DEBUG); + notice( t('Requested account is not available.') . EOL ); + $a->error = 404; + return; + } + + if(remote_user() && count($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $user[0]['entity_id']) { + $r = q("SELECT `profile_id` FROM `contact` WHERE `id` = %d LIMIT 1", + intval($visitor['cid']) + ); + if(count($r)) + $profile = $r[0]['profile_id']; + break; + } + } } $r = null; @@ -1176,8 +1193,14 @@ if(! function_exists('profile_sidebar')) { // don't show connect link to authenticated visitors either - if((remote_user()) && ($_SESSION['visitor_visiting'] == $profile['uid'])) - $connect = False; + if(remote_user() && count($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $profile['uid']) { + $connect = false; + break; + } + } + } if(get_my_url() && $profile['unkmail']) $wallmessage = t('Message'); @@ -1505,6 +1528,12 @@ if(! function_exists('current_theme')) { if($is_mobile) { $system_theme = ((isset($a->config['system']['mobile-theme'])) ? $a->config['system']['mobile-theme'] : ''); $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme); + + if($theme_name === '---') { + // user has selected to have the mobile theme be the same as the normal one + $system_theme = ''; + $theme_name = ''; + } } else { $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); diff --git a/database.sql b/database.sql index f475fc6a2..8f525b60d 100644 --- a/database.sql +++ b/database.sql @@ -1,29 +1,10 @@ --- phpMyAdmin SQL Dump --- version 3.3.10.4 --- http://www.phpmyadmin.net --- --- Host: newdb.macgirvin.com --- Generation Time: Sep 04, 2012 at 07:07 PM --- Server version: 5.1.53 --- PHP Version: 5.3.13 - SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; --- --- Database: `mpse1` --- - --- -------------------------------------------------------- - --- --- Table structure for table `account` --- CREATE TABLE IF NOT EXISTS `account` ( `account_id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -52,12 +33,6 @@ CREATE TABLE IF NOT EXISTS `account` ( KEY `account_default_entity` (`account_default_entity`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `addon` --- - CREATE TABLE IF NOT EXISTS `addon` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` char(255) NOT NULL, @@ -72,12 +47,6 @@ CREATE TABLE IF NOT EXISTS `addon` ( KEY `installed` (`installed`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `attach` --- - CREATE TABLE IF NOT EXISTS `attach` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -99,12 +68,6 @@ CREATE TABLE IF NOT EXISTS `attach` ( KEY `hash` (`hash`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `auth_codes` --- - CREATE TABLE IF NOT EXISTS `auth_codes` ( `id` varchar(40) NOT NULL, `client_id` varchar(20) NOT NULL, @@ -114,12 +77,6 @@ CREATE TABLE IF NOT EXISTS `auth_codes` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `cache` --- - CREATE TABLE IF NOT EXISTS `cache` ( `k` char(255) NOT NULL, `v` text NOT NULL, @@ -127,12 +84,6 @@ CREATE TABLE IF NOT EXISTS `cache` ( PRIMARY KEY (`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `challenge` --- - CREATE TABLE IF NOT EXISTS `challenge` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `challenge` char(255) NOT NULL, @@ -143,12 +94,6 @@ CREATE TABLE IF NOT EXISTS `challenge` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `clients` --- - CREATE TABLE IF NOT EXISTS `clients` ( `client_id` varchar(20) NOT NULL, `pw` varchar(20) NOT NULL, @@ -159,12 +104,6 @@ CREATE TABLE IF NOT EXISTS `clients` ( PRIMARY KEY (`client_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `config` --- - CREATE TABLE IF NOT EXISTS `config` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cat` char(255) CHARACTER SET ascii NOT NULL, @@ -174,12 +113,6 @@ CREATE TABLE IF NOT EXISTS `config` ( UNIQUE KEY `access` (`cat`,`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `contact` --- - CREATE TABLE IF NOT EXISTS `contact` ( `id` int(11) NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -259,12 +192,6 @@ CREATE TABLE IF NOT EXISTS `contact` ( KEY `aid` (`aid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `conv` --- - CREATE TABLE IF NOT EXISTS `conv` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `guid` char(64) NOT NULL, @@ -279,12 +206,6 @@ CREATE TABLE IF NOT EXISTS `conv` ( KEY `updated` (`updated`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `deliverq` --- - CREATE TABLE IF NOT EXISTS `deliverq` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cmd` char(32) NOT NULL, @@ -295,12 +216,6 @@ CREATE TABLE IF NOT EXISTS `deliverq` ( KEY `contact` (`contact`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `entity` --- - CREATE TABLE IF NOT EXISTS `entity` ( `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `entity_account_id` int(10) unsigned NOT NULL DEFAULT '0', @@ -330,8 +245,11 @@ CREATE TABLE IF NOT EXISTS `entity` ( `entity_r_abook` tinyint(3) unsigned NOT NULL DEFAULT '128', `entity_w_stream` tinyint(3) unsigned NOT NULL DEFAULT '128', `entity_w_wall` tinyint(3) unsigned NOT NULL DEFAULT '128', + `entity_w_tagwall` tinyint(3) unsigned NOT NULL DEFAULT '128', `entity_w_comment` tinyint(3) unsigned NOT NULL DEFAULT '128', `entity_w_mail` tinyint(3) unsigned NOT NULL DEFAULT '128', + `entity_w_photos` tinyint(3) unsigned NOT NULL DEFAULT '128', + `entity_w_chat` tinyint(3) unsigned NOT NULL DEFAULT '128', PRIMARY KEY (`entity_id`), KEY `entity_account_id` (`entity_account_id`), KEY `entity_name` (`entity_name`), @@ -352,15 +270,12 @@ CREATE TABLE IF NOT EXISTS `entity` ( KEY `entity_w_stream` (`entity_w_stream`), KEY `entity_w_wall` (`entity_w_wall`), KEY `entity_w_comment` (`entity_w_comment`), - KEY `entity_w_mail` (`entity_w_mail`) + KEY `entity_w_mail` (`entity_w_mail`), + KEY `entity_w_tagwall` (`entity_w_tagwall`), + KEY `entity_w_photos` (`entity_w_photos`), + KEY `entity_w_chat` (`entity_w_chat`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `event` --- - CREATE TABLE IF NOT EXISTS `event` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, @@ -393,12 +308,6 @@ CREATE TABLE IF NOT EXISTS `event` ( KEY `ignore` (`ignore`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `fcontact` --- - CREATE TABLE IF NOT EXISTS `fcontact` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `url` char(255) NOT NULL, @@ -421,12 +330,6 @@ CREATE TABLE IF NOT EXISTS `fcontact` ( KEY `network` (`network`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `ffinder` --- - CREATE TABLE IF NOT EXISTS `ffinder` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, @@ -438,12 +341,6 @@ CREATE TABLE IF NOT EXISTS `ffinder` ( KEY `fid` (`fid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `fserver` --- - CREATE TABLE IF NOT EXISTS `fserver` ( `id` int(11) NOT NULL AUTO_INCREMENT, `server` char(255) NOT NULL, @@ -455,12 +352,6 @@ CREATE TABLE IF NOT EXISTS `fserver` ( KEY `posturl` (`posturl`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `fsuggest` --- - CREATE TABLE IF NOT EXISTS `fsuggest` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, @@ -474,12 +365,6 @@ CREATE TABLE IF NOT EXISTS `fsuggest` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `gcign` --- - CREATE TABLE IF NOT EXISTS `gcign` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, @@ -489,12 +374,6 @@ CREATE TABLE IF NOT EXISTS `gcign` ( KEY `gcid` (`gcid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `gcontact` --- - CREATE TABLE IF NOT EXISTS `gcontact` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` char(255) NOT NULL, @@ -508,12 +387,6 @@ CREATE TABLE IF NOT EXISTS `gcontact` ( KEY `url` (`url`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `glink` --- - CREATE TABLE IF NOT EXISTS `glink` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cid` int(11) NOT NULL, @@ -529,12 +402,6 @@ CREATE TABLE IF NOT EXISTS `glink` ( KEY `updated` (`updated`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `group` --- - CREATE TABLE IF NOT EXISTS `group` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, @@ -547,12 +414,6 @@ CREATE TABLE IF NOT EXISTS `group` ( KEY `deleted` (`deleted`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `group_member` --- - CREATE TABLE IF NOT EXISTS `group_member` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, @@ -564,12 +425,6 @@ CREATE TABLE IF NOT EXISTS `group_member` ( KEY `contact-id` (`contact-id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `guid` --- - CREATE TABLE IF NOT EXISTS `guid` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `guid` char(64) NOT NULL, @@ -577,12 +432,6 @@ CREATE TABLE IF NOT EXISTS `guid` ( KEY `guid` (`guid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `hook` --- - CREATE TABLE IF NOT EXISTS `hook` ( `id` int(11) NOT NULL AUTO_INCREMENT, `hook` char(255) NOT NULL, @@ -593,12 +442,6 @@ CREATE TABLE IF NOT EXISTS `hook` ( KEY `hook` (`hook`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `hubloc` --- - CREATE TABLE IF NOT EXISTS `hubloc` ( `hubloc_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `hubloc_guid` char(255) NOT NULL DEFAULT '', @@ -616,12 +459,6 @@ CREATE TABLE IF NOT EXISTS `hubloc` ( KEY `hubloc_url_sig` (`hubloc_url_sig`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `intro` --- - CREATE TABLE IF NOT EXISTS `intro` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, @@ -644,12 +481,6 @@ CREATE TABLE IF NOT EXISTS `intro` ( KEY `contact-id` (`contact-id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `item` --- - CREATE TABLE IF NOT EXISTS `item` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uri` char(255) CHARACTER SET ascii NOT NULL, @@ -739,12 +570,6 @@ CREATE TABLE IF NOT EXISTS `item` ( FULLTEXT KEY `deny_gid` (`deny_gid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `item_id` --- - CREATE TABLE IF NOT EXISTS `item_id` ( `iid` int(11) NOT NULL, `uid` int(11) NOT NULL, @@ -756,12 +581,6 @@ CREATE TABLE IF NOT EXISTS `item_id` ( KEY `service` (`service`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `locks` --- - CREATE TABLE IF NOT EXISTS `locks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` char(128) NOT NULL, @@ -769,12 +588,6 @@ CREATE TABLE IF NOT EXISTS `locks` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `mail` --- - CREATE TABLE IF NOT EXISTS `mail` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -808,12 +621,6 @@ CREATE TABLE IF NOT EXISTS `mail` ( KEY `aid` (`aid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `manage` --- - CREATE TABLE IF NOT EXISTS `manage` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, @@ -823,12 +630,6 @@ CREATE TABLE IF NOT EXISTS `manage` ( KEY `mid` (`mid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `notify` --- - CREATE TABLE IF NOT EXISTS `notify` ( `id` int(11) NOT NULL AUTO_INCREMENT, `hash` char(64) NOT NULL, @@ -855,12 +656,6 @@ CREATE TABLE IF NOT EXISTS `notify` ( KEY `otype` (`otype`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `notify-threads` --- - CREATE TABLE IF NOT EXISTS `notify-threads` ( `id` int(11) NOT NULL AUTO_INCREMENT, `notify-id` int(11) NOT NULL, @@ -872,12 +667,6 @@ CREATE TABLE IF NOT EXISTS `notify-threads` ( KEY `receiver-uid` (`receiver-uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `pconfig` --- - CREATE TABLE IF NOT EXISTS `pconfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL DEFAULT '0', @@ -888,12 +677,6 @@ CREATE TABLE IF NOT EXISTS `pconfig` ( UNIQUE KEY `access` (`uid`,`cat`,`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `photo` --- - CREATE TABLE IF NOT EXISTS `photo` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -928,12 +711,6 @@ CREATE TABLE IF NOT EXISTS `photo` ( KEY `aid` (`aid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `profile` --- - CREATE TABLE IF NOT EXISTS `profile` ( `id` int(11) NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -993,12 +770,6 @@ CREATE TABLE IF NOT EXISTS `profile` ( FULLTEXT KEY `prv_keywords` (`prv_keywords`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `profile_check` --- - CREATE TABLE IF NOT EXISTS `profile_check` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, @@ -1014,12 +785,6 @@ CREATE TABLE IF NOT EXISTS `profile_check` ( KEY `expire` (`expire`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `queue` --- - CREATE TABLE IF NOT EXISTS `queue` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cid` int(11) NOT NULL, @@ -1036,12 +801,6 @@ CREATE TABLE IF NOT EXISTS `queue` ( KEY `batch` (`batch`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `register` --- - CREATE TABLE IF NOT EXISTS `register` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `hash` char(255) NOT NULL, @@ -1055,12 +814,6 @@ CREATE TABLE IF NOT EXISTS `register` ( KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `session` --- - CREATE TABLE IF NOT EXISTS `session` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `sid` char(255) NOT NULL, @@ -1071,12 +824,6 @@ CREATE TABLE IF NOT EXISTS `session` ( KEY `expire` (`expire`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `spam` --- - CREATE TABLE IF NOT EXISTS `spam` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, @@ -1091,12 +838,6 @@ CREATE TABLE IF NOT EXISTS `spam` ( KEY `term` (`term`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `term` --- - CREATE TABLE IF NOT EXISTS `term` ( `tid` int(10) unsigned NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', @@ -1115,12 +856,6 @@ CREATE TABLE IF NOT EXISTS `term` ( KEY `aid` (`aid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `tokens` --- - CREATE TABLE IF NOT EXISTS `tokens` ( `id` varchar(40) NOT NULL, `secret` text NOT NULL, @@ -1134,12 +869,6 @@ CREATE TABLE IF NOT EXISTS `tokens` ( KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `user` --- - CREATE TABLE IF NOT EXISTS `user` ( `uid` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(10) unsigned NOT NULL, @@ -1199,12 +928,6 @@ CREATE TABLE IF NOT EXISTS `user` ( KEY `account_id` (`account_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `userd` --- - CREATE TABLE IF NOT EXISTS `userd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` char(255) NOT NULL, diff --git a/include/Contact.php b/include/Contact.php index c141fa188..5e0964d03 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,5 +1,59 @@ get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); else $edpost = false; - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; $drop = array( 'dropping' => $dropping, diff --git a/include/delivery.php b/include/delivery.php index 09448fcae..0d99f48a2 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -322,8 +322,9 @@ function delivery_run($argv, $argc){ dbesc($nickname) ); - if(count($x)) { - if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) { + if($x && count($x)) { + $write_flag = (($x[0]['rel'] == CONTACT_IS_FOLLOWER || $x[0]['rel'] == CONTACT_IS_FRIEND) ? true : false); + if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { q("update contact set writable = 1 where id = %d limit 1", intval($x[0]['id']) ); diff --git a/include/items.php b/include/items.php index 63e9a646d..4acf72d77 100755 --- a/include/items.php +++ b/include/items.php @@ -3557,9 +3557,21 @@ function drop_item($id,$interactive = true) { $owner = $item['uid']; + $cid = 0; + // check if logged in user is either the author or owner of this item - if((local_user() == $item['uid']) || (remote_user() == $item['contact-id']) || (! $interactive)) { + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) { + $cid = $visitor['cid']; + break; + } + } + } + + + if((local_user() == $item['uid']) || ($cid) || (! $interactive)) { // delete the item diff --git a/include/notifier.php b/include/notifier.php index 6e3cede56..15ab67b7b 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -279,7 +279,7 @@ function notifier_run($argv, $argc){ // a delivery fork. private groups (forum_mode == 2) do not uplink if((intval($parent['forum_mode']) == 1) && (! $top_level) && ($cmd !== 'uplink')) { - proc_run('php','include/notifier','uplink',$item_id); + proc_run('php','include/notifier.php','uplink',$item_id); } $conversants = array(); @@ -543,9 +543,9 @@ function notifier_run($argv, $argc){ dbesc($nickname) ); - if(count($x)) { - - if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) { + if($x && count($x)) { + $write_flag = (($x[0]['rel'] == CONTACT_IS_FOLLOWER || $x[0]['rel'] == CONTACT_IS_FRIEND) ? true : false); + if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { q("update contact set writable = 1 where id = %d limit 1", intval($x[0]['id']) ); diff --git a/include/oauth.php b/include/oauth.php index 2724dcf7c..103d4c2fa 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -145,6 +145,7 @@ class FKOAuth1 extends OAuthServer { } $_SESSION['uid'] = $record['uid']; $_SESSION['theme'] = $record['theme']; + $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme'); $_SESSION['authenticated'] = 1; $_SESSION['page_flags'] = $record['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname']; diff --git a/include/security.php b/include/security.php index 497166ec4..bc1e97059 100644 --- a/include/security.php +++ b/include/security.php @@ -181,12 +181,26 @@ function can_write_wall(&$a,$owner) { elseif($verified === 1) return false; else { + $cid = 0; + + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $owner) { + $cid = $visitor['cid']; + break; + } + } + } + + if(! $cid) + return false; + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", intval($owner), - intval(remote_user()), + intval($cid), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND), intval(PAGE_COMMUNITY) diff --git a/mod/community.php b/mod/community.php index 354f68528..4f6c3d3c9 100644 --- a/mod/community.php +++ b/mod/community.php @@ -1,8 +1,10 @@ status == 1) { $_SESSION['authenticated'] = 1; + if(! x($_SESSION,'remote')) + $_SESSION['remote'] = array(); + + $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']); + $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_handle'] = $r[0]['addr']; @@ -516,6 +521,9 @@ function dfrn_poll_content(&$a) { if(((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) { $_SESSION['authenticated'] = 1; + if(! x($_SESSION,'remote')) + $_SESSION['remote'] = array(); + $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']); $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_visiting'] = $r[0]['uid']; diff --git a/mod/directory.php b/mod/directory.php index 4e7626ed5..6054ad8fd 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -9,8 +9,10 @@ function directory_init(&$a) { $a->page['aside'] .= findpeople_widget(); } - else + else { unset($_SESSION['theme']); + unset($_SESSION['mobile-theme']); + } } diff --git a/mod/display.php b/mod/display.php index 7e3514cd3..8193ce377 100644 --- a/mod/display.php +++ b/mod/display.php @@ -35,8 +35,18 @@ function display_content(&$a) { $contact = null; $remote_contact = false; - if(remote_user()) { - $contact_id = $_SESSION['visitor_id']; + $contact_id = 0; + + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $a->profile['uid']) { + $contact_id = $v['cid']; + break; + } + } + } + + if($contact_id) { $groups = init_groups_visitor($contact_id); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), diff --git a/mod/home.php b/mod/home.php index 42669988e..b96e3f29f 100644 --- a/mod/home.php +++ b/mod/home.php @@ -19,6 +19,8 @@ function home_content(&$a) { if(x($_SESSION,'theme')) unset($_SESSION['theme']); + if(x($_SESSION,'mobile-theme')) + unset($_SESSION['mobile-theme']); $o .= '