diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acctlink.php | 16 | ||||
-rw-r--r-- | mod/acl.php | 2 | ||||
-rw-r--r-- | mod/admin.php | 2 | ||||
-rw-r--r-- | mod/community.php | 2 | ||||
-rw-r--r-- | mod/dfrn_confirm.php | 9 | ||||
-rw-r--r-- | mod/dfrn_notify.php | 10 | ||||
-rw-r--r-- | mod/dfrn_request.php | 16 | ||||
-rw-r--r-- | mod/follow.php | 224 | ||||
-rwxr-xr-x[-rw-r--r--] | mod/install.php | 29 | ||||
-rw-r--r-- | mod/item.php | 47 | ||||
-rwxr-xr-x[-rw-r--r--] | mod/like.php | 125 | ||||
-rw-r--r-- | mod/message.php | 3 | ||||
-rw-r--r-- | mod/network.php | 6 | ||||
-rw-r--r-- | mod/notes.php | 2 | ||||
-rw-r--r-- | mod/profile.php | 2 | ||||
-rw-r--r-- | mod/profiles.php | 15 | ||||
-rw-r--r-- | mod/register.php | 329 | ||||
-rw-r--r-- | mod/search.php | 11 | ||||
-rw-r--r-- | mod/settings.php | 18 |
19 files changed, 283 insertions, 585 deletions
diff --git a/mod/acctlink.php b/mod/acctlink.php new file mode 100644 index 000000000..a2365803a --- /dev/null +++ b/mod/acctlink.php @@ -0,0 +1,16 @@ +<?php + +require_once('include/Scrape.php'); + +function acctlink_init(&$a) { + + if(x($_GET,'addr')) { + $addr = trim($_GET['addr']); + $res = probe_url($addr); + //logger('acctlink: ' . print_r($res,true)); + if($res['url']) { + goaway($res['url']); + killme(); + } + } +} diff --git a/mod/acl.php b/mod/acl.php index 168b1f59f..1e8898ab6 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -135,7 +135,7 @@ function acl_init(&$a){ foreach($r as $g) { $x['photos'][] = $g['micro']; $x['links'][] = $g['url']; - $x['suggestions'][] = $g['name']; // sprintf( t('%s [%s]'),$g['name'],$g['url']); + $x['suggestions'][] = $g['name']; $x['data'][] = intval($g['id']); } } diff --git a/mod/admin.php b/mod/admin.php index d19118b78..6b1a53a30 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -98,7 +98,7 @@ function admin_content(&$a) { 'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"), - 'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update") + //'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update") ); /* get plugins admin page */ diff --git a/mod/community.php b/mod/community.php index bfe5a3089..fb28f7805 100644 --- a/mod/community.php +++ b/mod/community.php @@ -63,7 +63,7 @@ function community_content(&$a, $update = 0) { } $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`hidewall` diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 564ae5ca2..76b99cbca 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -202,6 +202,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if($user[0]['page-flags'] == PAGE_COMMUNITY) $params['page'] = 1; + if($user[0]['page-flags'] == PAGE_PRVGROUP) + $params['page'] = 2; logger('dfrn_confirm: Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); @@ -537,6 +539,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $page = ((x($_POST,'page')) ? intval($_POST['page']) : 0 ); $version_id = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); + $forum = (($page == 1) ? 1 : 0); + $prv = (($page == 2) ? 1 : 0); + logger('dfrn_confirm: requestee contacted: ' . $node); logger('dfrn_confirm: request: POST=' . print_r($_POST,true), LOGGER_DATA); @@ -691,6 +696,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { `pending` = 0, `duplex` = %d, `forum` = %d, + `prv` = %d, `network` = '%s' WHERE `id` = %d LIMIT 1 ", dbesc($photos[0]), @@ -701,7 +707,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) { dbesc(datetime_convert()), dbesc(datetime_convert()), intval($duplex), - intval($page), + intval($forum), + intval($prv), dbesc(NETWORK_DFRN), intval($dfrn_record) ); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 65d39d5fe..e55da5572 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -17,6 +17,9 @@ function dfrn_notify_post(&$a) { $ssl_policy = ((x($_POST,'ssl_policy')) ? notags(trim($_POST['ssl_policy'])): 'none'); $page = ((x($_POST,'page')) ? intval($_POST['page']) : 0); + $forum = (($page == 1) ? 1 : 0); + $prv = (($page == 2) ? 1 : 0); + $writable = (-1); if($dfrn_version >= 2.21) { $writable = (($perm === 'rw') ? 1 : 0); @@ -88,10 +91,11 @@ function dfrn_notify_post(&$a) { $importer = $r[0]; - if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $page)) { - q("UPDATE `contact` SET `writable` = %d, forum = %d WHERE `id` = %d LIMIT 1", + if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) { + q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d LIMIT 1", intval(($writable == (-1)) ? $importer['writable'] : $writable), - intval($page), + intval($forum), + intval($prv), intval($importer['id']) ); if($writable != (-1)) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index b809929d7..896fe1792 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -68,7 +68,7 @@ function dfrn_request_post(&$a) { $dfrn_url = notags(trim($_POST['dfrn_url'])); $aes_allow = (((x($_POST,'aes_allow')) && ($_POST['aes_allow'] == 1)) ? 1 : 0); $confirm_key = ((x($_POST,'confirm_key')) ? $_POST['confirm_key'] : ""); - + $hidden = ((x($_POST,'hidden-contact')) ? intval($_POST['hidden-contact']) : 0); $contact_record = null; if(x($dfrn_url)) { @@ -98,8 +98,9 @@ function dfrn_request_post(&$a) { } if(is_array($contact_record)) { - $r = q("UPDATE `contact` SET `ret-aes` = %d WHERE `id` = %d LIMIT 1", + $r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d LIMIT 1", intval($aes_allow), + intval($hidden), intval($contact_record['id']) ); } @@ -144,8 +145,8 @@ function dfrn_request_post(&$a) { */ $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site-pubkey`, - `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`) - VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`) + VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", intval(local_user()), datetime_convert(), dbesc($dfrn_url), @@ -160,7 +161,8 @@ function dfrn_request_post(&$a) { $parms['dfrn-poll'], $parms['dfrn-poco'], dbesc(NETWORK_DFRN), - intval($aes_allow) + intval($aes_allow), + intval($hidden) ); } @@ -649,6 +651,8 @@ function dfrn_request_content(&$a) { $o = replace_macros($tpl,array( '$dfrn_url' => $dfrn_url, '$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ), + '$hidethem' => t('Hide this contact'), + '$hidechecked' => '', '$confirm_key' => $confirm_key, '$welcome' => sprintf( t('Welcome home %s.'), $a->user['username']), '$please' => sprintf( t('Please confirm your introduction/connection request to %s.'), $dfrn_url), @@ -680,7 +684,7 @@ function dfrn_request_content(&$a) { $auto_confirm = false; if(count($r)) { - if($r[0]['page-flags'] != PAGE_NORMAL) + if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP)) $auto_confirm = true; if(! $auto_confirm) { diff --git a/mod/follow.php b/mod/follow.php index cdecd5f2a..5e48174c9 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -1,6 +1,7 @@ <?php require_once('Scrape.php'); +require_once('include/follow.php'); function follow_init(&$a) { @@ -11,230 +12,19 @@ function follow_init(&$a) { } $uid = local_user(); - $url = $orig_url = notags(trim($_REQUEST['url'])); + $url = notags(trim($_REQUEST['url'])); $return_url = $_SESSION['return_url']; - // remove ajax junk, e.g. Twitter + $result = new_contact($uid,$url,true); - $url = str_replace('/#!/','/',$url); - - if(! allowed_url($url)) { - notice( t('Disallowed profile URL.') . EOL); - goaway($return_url); - // NOTREACHED - } - - - if(! $url) { - notice( t('Connect URL missing.') . EOL); - goaway($return_url); - // NOTREACHED - } - - $arr = array('url' => $url, 'contact' => array()); - - call_hooks('follow', $arr); - - if(x($arr['contact'],'name')) - $ret = $arr['contact']; - else - $ret = probe_url($url); - - if($ret['network'] === NETWORK_DFRN) { - if(strlen($a->path)) - $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']); - else - $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); - - goaway($ret['request'] . "&addr=$myaddr"); - - // NOTREACHED - } - else { - if(get_config('system','dfrn_only')) { - notice( t('This site is not configured to allow communications with other networks.') . EOL); - notice( t('No compatible communication protocols or feeds were discovered.') . EOL); - goaway($return_url); - } - } - - // This extra param just confuses things, remove it - if($ret['network'] === NETWORK_DIASPORA) - $ret['url'] = str_replace('?absolute=true','',$ret['url']); - - - // do we have enough information? - - if(! ((x($ret,'name')) && (x($ret,'poll')) && ((x($ret,'url')) || (x($ret,'addr'))))) { - notice( t('The profile address specified does not provide adequate information.') . EOL); - if(! x($ret,'poll')) - notice( t('No compatible communication protocols or feeds were discovered.') . EOL); - if(! x($ret,'name')) - notice( t('An author or name was not found.') . EOL); - if(! x($ret,'url')) - notice( t('No browser URL could be matched to this address.') . EOL); - if(strpos($url,'@') !== false) { - notice( t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL); - notice( t('Use mailto: in front of address to force email check.') . EOL); - } - goaway($return_url); - } - - if($ret['network'] === NETWORK_OSTATUS && get_config('system','ostatus_disabled')) { - notice( t('The profile address specified belongs to a network which has been disabled on this site.') . EOL); - $ret['notify'] = ''; - } - - if(! $ret['notify']) { - notice( t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL); - } - - $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0); - $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0); - - if($ret['network'] === NETWORK_MAIL) { - $writeable = 1; - - } - if($ret['network'] === NETWORK_DIASPORA) - $writeable = 1; - - // check if we already have a contact - // the poll url is more reliable than the profile url, as we may have - // indirect links or webfinger links - - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1", - intval($uid), - dbesc($ret['poll']) - ); - - - if(count($r)) { - // update contact - if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { - q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval(CONTACT_IS_FRIEND), - intval($r[0]['id']), - intval($uid) - ); - } - } - else { - - $new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); - if($ret['network'] === NETWORK_DIASPORA) - $new_relation = CONTACT_IS_FOLLOWER; - - // create contact record - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, - `writable`, `hidden`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0 ) ", - intval($uid), - dbesc(datetime_convert()), - dbesc($ret['url']), - dbesc(normalise_link($ret['url'])), - dbesc($ret['addr']), - dbesc($ret['alias']), - dbesc($ret['batch']), - dbesc($ret['notify']), - dbesc($ret['poll']), - dbesc($ret['poco']), - dbesc($ret['name']), - dbesc($ret['nick']), - dbesc($ret['photo']), - dbesc($ret['network']), - dbesc($ret['pubkey']), - intval($new_relation), - intval($ret['priority']), - intval($writeable), - intval($hidden) - ); - } - - $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", - dbesc($ret['url']), - intval($uid) - ); - - if(! count($r)) { - notice( t('Unable to retrieve contact information.') . EOL); + if($result['success'] == false) { + if($result['message']) + notice($result['message']); goaway($return_url); - // NOTREACHED - } - - $contact = $r[0]; - $contact_id = $r[0]['id']; - - - $g = q("select def_gid from user where uid = %d limit 1", - intval($uid) - ); - if($g && intval($g[0]['def_gid'])) { - require_once('include/group.php'); - group_add_member($uid,'',$contact_id,$g[0]['def_gid']); } - require_once("Photo.php"); - - $photos = import_profile_photo($ret['photo'],$uid,$contact_id); - - $r = q("UPDATE `contact` SET `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', - `name-date` = '%s', - `uri-date` = '%s', - `avatar-date` = '%s' - WHERE `id` = %d LIMIT 1 - ", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($contact_id) - ); - - - // pull feed and consume it, which should subscribe to the hub. - - proc_run('php',"include/poller.php","$contact_id"); - - // create a follow slap - - $tpl = get_markup_template('follow_slap.tpl'); - $slap = replace_macros($tpl, array( - '$name' => $a->user['username'], - '$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'], - '$photo' => $a->contact['photo'], - '$thumb' => $a->contact['thumb'], - '$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME), - '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . random_string(), - '$title' => '', - '$type' => 'text', - '$content' => t('following'), - '$nick' => $a->user['nickname'], - '$verb' => ACTIVITY_FOLLOW, - '$ostat_follow' => '' - )); - - $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", - intval($uid) - ); - - if(count($r)) { - if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) { - require_once('include/salmon.php'); - slapper($r[0],$contact['notify'],$slap); - } - if($contact['network'] == NETWORK_DIASPORA) { - require_once('include/diaspora.php'); - $ret = diaspora_share($a->user,$contact); - logger('mod_follow: diaspora_share returns: ' . $ret); - } - } + info( t('Contact added') . EOL); if(strstr($return_url,'contacts')) goaway($a->get_baseurl() . '/contacts/' . $contact_id); diff --git a/mod/install.php b/mod/install.php index 6d6232a95..cb21a71eb 100644..100755 --- a/mod/install.php +++ b/mod/install.php @@ -184,15 +184,16 @@ function install_content(&$a) { check_php($phpath, $checks); - check_htaccess($checks); - + check_htaccess($checks); + function check_passed($v, $c){ if ($c['required']) $v = $v && $c['status']; return $v; } $checkspassed = array_reduce($checks, "check_passed", true); - + + $tpl = get_markup_template('install_checks.tpl'); $o .= replace_macros($tpl, array( @@ -381,6 +382,7 @@ function check_funcs(&$checks) { check_add($ck_funcs, t('Apache mod_rewrite module'), true, true, ""); } } + if(! function_exists('curl_init')){ $ck_funcs[0]['status']= false; $ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.'); @@ -421,21 +423,26 @@ function check_htconfig(&$checks) { $help .= t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Friendica top folder.').EOL; $help .= t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.').EOL; } - + check_add($checks, t('.htconfig.php is writable'), $status, false, $help); - + } function check_htaccess(&$checks) { $a = get_app(); $status = true; $help = ""; - $test = fetch_url($a->get_baseurl()."/install/testrewrite"); - if ($test!="ok") { - $status = false; - $help = t('Url rewrite in .htconfig is not working. Check your server configuration.'); - } - check_add($checks, t('Url rewrite is working'), $status, true, $help); + if (function_exists('curl_init')){ + $test = fetch_url($a->get_baseurl()."/install/testrewrite"); + if ($test!="ok") { + $status = false; + $help = t('Url rewrite in .htaccess is not working. Check your server configuration.'); + } + check_add($checks, t('Url rewrite is working'), $status, true, $help); + } else { + // cannot check modrewrite if libcurl is not installed + } + } diff --git a/mod/item.php b/mod/item.php index df242d6f7..c1c0b14ec 100644 --- a/mod/item.php +++ b/mod/item.php @@ -262,17 +262,17 @@ function item_post(&$a) { } } - if(strlen($categories)) { - // get the "fileas" tags for this post - $filedas = file_tag_file_to_list($categories, 'file'); + if(strlen($categories)) { + // get the "fileas" tags for this post + $filedas = file_tag_file_to_list($categories, 'file'); } - // save old and new categories, so we can determine what needs to be deleted from pconfig - $categories_old = $categories; - $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category'); - $categories_new = $categories; - if(strlen($filedas)) { - // append the fileas stuff to the new categories list - $categories .= file_tag_list_to_file($filedas, 'file'); + // save old and new categories, so we can determine what needs to be deleted from pconfig + $categories_old = $categories; + $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category'); + $categories_new = $categories; + if(strlen($filedas)) { + // append the fileas stuff to the new categories list + $categories .= file_tag_list_to_file($filedas, 'file'); } // Work around doubled linefeeds in Tinymce 3.5b2 @@ -453,6 +453,7 @@ function item_post(&$a) { $tagged = array(); + $private_forum = false; if(count($tags)) { foreach($tags as $tag) { @@ -471,11 +472,22 @@ function item_post(&$a) { continue; $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); - if($success) + if($success['replaced']) $tagged[] = $tag; + if(is_array($success['contact']) && intval($success['contact']['prv'])) { + $private_forum = true; + $private_id = $success['contact']['id']; + } } } + if(($private_forum) && (! $parent) && (! $private)) { + // we tagged a private forum in a top level post and the message was public. + // Restrict it. + $private = 1; + $str_contact_allow = '<' . $private_id . '>'; + } + $attachments = ''; $match = false; @@ -725,16 +737,16 @@ function item_post(&$a) { if($datarray['verb'] === ACTIVITY_LIKE) $signed_text = $datarray['guid'] . ';' . 'Post' . ';' . $parent_item['guid'] . ';' . 'true' . ';' . $myaddr; else - $signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $myaddr; + $signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $myaddr; $authorsig = base64_encode(rsa_sign($signed_text,$a->user['prvkey'],'sha256')); q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($post_id), - dbesc($signed_text), - dbesc(base64_encode($authorsig)), - dbesc($myaddr) - ); + dbesc($signed_text), + dbesc(base64_encode($authorsig)), + dbesc($myaddr) + ); } } else { @@ -893,6 +905,7 @@ function item_content(&$a) { function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { $replaced = false; + $r = null; //is it a hash tag? if(strpos($tag,'#') === 0) { @@ -1023,5 +1036,5 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { } } - return $replaced; + return array('replaced' => $replaced, 'contact' => $r[0]); } diff --git a/mod/like.php b/mod/like.php index 6b97fafb5..942a04fe7 100644..100755 --- a/mod/like.php +++ b/mod/like.php @@ -104,7 +104,8 @@ function like_content(&$a) { return; } - $r = q("SELECT `id` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0 + + $r = q("SELECT * FROM `item` WHERE `verb` = '%s' AND `deleted` = 0 AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s') LIMIT 1", dbesc($activity), intval($contact['id']), @@ -112,13 +113,70 @@ function like_content(&$a) { dbesc($item_id) ); if(count($r)) { + $like_item = $r[0]; + // Already voted, undo it $r = q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), - intval($r[0]['id']) + intval($like_item['id']) ); - proc_run('php',"include/notifier.php","like","$post_id"); + // Clean up the `sign` table + $r = q("DELETE FROM `sign` WHERE `iid` = %d", + intval($like_item['id']) + ); + + // Save the author information for the unlike in case we need to relay to Diaspora + // Note that we can only create a signature for a user of the local server. We don't have + // a key for remote users. That is ok, because if a remote user is "unlike"ing a post, it + // means we are the relay, and for relayable_retractions, Diaspora + // only checks the parent_author_signature if it doesn't have to relay further + // + // If $item['resource-id'] exists, it means the item is a photo. Diaspora doesn't support + // likes on photos, so don't bother. + + if(($activity === ACTIVITY_LIKE) && (! $item['resource-id'])) { + $signed_text = $like_item['guid'] . ';' . 'Like'; + + if( $contact['network'] === NETWORK_DIASPORA) + $diaspora_handle = $contact['addr']; + else { // Only works for NETWORK_DFRN + $contact_baseurl_start = strpos($contact['url'],'://') + 3; + $contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start; + $contact_baseurl = substr($contact['url'], $contact_baseurl_start, $contact_baseurl_length); + $diaspora_handle = $contact['nick'] . '@' . $contact_baseurl; + + // Get contact's private key if he's a user of the local Friendica server + $r = q("SELECT `contact`.`uid` FROM `contact` WHERE `url` = '%s' AND `self` = 1 LIMIT 1", + dbesc($contact['url']) + ); + + if( $r) { + $contact_uid = $r['uid']; + $r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1", + intval($contact_uid) + ); + + if( $r) + $authorsig = base64_encode(rsa_sign($signed_text,$r['prvkey'],'sha256')); + } + } + + if(! isset($authorsig)) + $authorsig = ''; + + q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", + intval($like_item['id']), + dbesc($signed_text), + dbesc($authorsig), + dbesc($diaspora_handle) + ); + } + + +// proc_run('php',"include/notifier.php","like","$post_id"); // $post_id isn't defined here! + $like_item_id = $like_item['id']; + proc_run('php',"include/notifier.php","like","$like_item_id"); return; } @@ -191,6 +249,65 @@ EOT; ); } + + // Save the author information for the like in case we need to relay to Diaspora + // Note that we can only create a signature for a user of the local server. We don't have + // a key for remote users. That is ok, because if a remote user is "unlike"ing a post, it + // means we are the relay, and for relayable_retractions, Diaspora + // only checks the parent_author_signature if it doesn't have to relay further + + if(($activity === ACTIVITY_LIKE) && ($post_type === t('status'))) { + if( $contact['network'] === NETWORK_DIASPORA) + $diaspora_handle = $contact['addr']; + else { // Only works for NETWORK_DFRN + $contact_baseurl_start = strpos($contact['url'],'://') + 3; + $contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start; + $contact_baseurl = substr($contact['url'], $contact_baseurl_start, $contact_baseurl_length); + $diaspora_handle = $contact['nick'] . '@' . $contact_baseurl; + + // Get contact's private key if he's a user of the local Friendica server + $r = q("SELECT `contact`.`uid` FROM `contact` WHERE `url` = '%s' AND `self` = 1 LIMIT 1", + dbesc($contact['url']) + ); + + if( $r) { + $contact_uid = $r['uid']; + $r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1", + intval($contact_uid) + ); + + if( $r) + $contact_uprvkey = $r['prvkey']; + } + } + + $r = q("SELECT guid, parent FROM `item` WHERE id = %d LIMIT 1", + intval($post_id) + ); + if( $r) { + $p = q("SELECT guid FROM `item` WHERE id = %d AND parent = %d LIMIT 1", + intval($r[0]['parent']), + intval($r[0]['parent']) + ); + if( $p) { + $signed_text = $r[0]['guid'] . ';Post;' . $p[0]['guid'] . ';true;' . $diaspora_handle; + + if(isset($contact_uprvkey)) + $authorsig = base64_encode(rsa_sign($signed_text,$contact_uprvkey,'sha256')); + else + $authorsig = ''; + + q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", + intval($post_id), + dbesc($signed_text), + dbesc($authorsig), + dbesc($diaspora_handle) + ); + } + } + } + + $arr['id'] = $post_id; call_hooks('post_local_end', $arr); @@ -199,4 +316,4 @@ EOT; killme(); // return; // NOTREACHED -}
\ No newline at end of file +} diff --git a/mod/message.php b/mod/message.php index 71f83b47a..fb2241985 100644 --- a/mod/message.php +++ b/mod/message.php @@ -211,7 +211,8 @@ function message_content(&$a) { '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), - '$wait' => t('Please wait') + '$wait' => t('Please wait'), + '$submit' => t('Submit') )); return $o; diff --git a/mod/network.php b/mod/network.php index a94272a42..b998a3107 100644 --- a/mod/network.php +++ b/mod/network.php @@ -437,8 +437,8 @@ function network_content(&$a, $update = 0) { else $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . '\\]%')), - dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + dbesc(protect_sprintf('%' . $myurl . ']%')), + dbesc(protect_sprintf('%' . $diasp_url . ']%')) ); } @@ -534,7 +534,7 @@ function network_content(&$a, $update = 0) { $parents_str = implode(', ', $parents_arr); $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item`, `contact` diff --git a/mod/notes.php b/mod/notes.php index 703c898e6..625bbd2ee 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -117,7 +117,7 @@ function notes_content(&$a,$update = false) { $parents_str = implode(', ', $parents_arr); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` diff --git a/mod/profile.php b/mod/profile.php index 69f044e89..7658a9647 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -242,7 +242,7 @@ function profile_content(&$a, $update = 0) { $parents_str = implode(', ', $parents_arr); $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item`, `contact` diff --git a/mod/profiles.php b/mod/profiles.php index ca3890eb9..6a8ce9e1e 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -62,9 +62,15 @@ function profiles_post(&$a) { $pub_keywords = notags(trim($_POST['pub_keywords'])); $prv_keywords = notags(trim($_POST['prv_keywords'])); $marital = notags(trim($_POST['marital'])); + $howlong = notags(trim($_POST['howlong'])); $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); + if(! strlen($howlong)) + $howlong = '0000-00-00 00:00:00'; + else + $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong); + // linkify the relationship target if applicable $withchanged = false; @@ -120,6 +126,7 @@ function profiles_post(&$a) { $sexual = notags(trim($_POST['sexual'])); $homepage = notags(trim($_POST['homepage'])); + $hometown = notags(trim($_POST['hometown'])); $politic = notags(trim($_POST['politic'])); $religion = notags(trim($_POST['religion'])); @@ -207,8 +214,10 @@ function profiles_post(&$a) { `country-name` = '%s', `marital` = '%s', `with` = '%s', + `howlong` = '%s', `sexual` = '%s', `homepage` = '%s', + `hometown` = '%s', `politic` = '%s', `religion` = '%s', `pub_keywords` = '%s', @@ -237,8 +246,10 @@ function profiles_post(&$a) { dbesc($country_name), dbesc($marital), dbesc($with), + dbesc($howlong), dbesc($sexual), dbesc($homepage), + dbesc($hometown), dbesc($politic), dbesc($religion), dbesc($pub_keywords), @@ -558,8 +569,10 @@ function profiles_content(&$a) { '$lbl_marital' => t('<span class="heart">♥</span> Marital Status:'), '$lbl_with' => t("Who: \x28if applicable\x29"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), + '$lbl_howlong' => t('Since [date]:'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), + '$lbl_hometown' => t('Hometown:'), '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), '$lbl_pubkey' => t('Public Keywords:'), @@ -595,9 +608,11 @@ function profiles_content(&$a) { '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$with' => strip_tags($r[0]['with']), + '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], + '$hometown' => $r[0]['hometown'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$pub_keywords' => $r[0]['pub_keywords'], diff --git a/mod/register.php b/mod/register.php index 58bba8533..d52b5a6e1 100644 --- a/mod/register.php +++ b/mod/register.php @@ -43,326 +43,49 @@ function register_post(&$a) { break; } - $using_invites = get_config('system','invitation_only'); - $num_invites = get_config('system','number_invites'); - + require_once('include/user.php'); - $invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : ''); - $username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : ''); - $nickname = ((x($_POST,'nickname')) ? notags(trim($_POST['nickname'])) : ''); - $email = ((x($_POST,'email')) ? notags(trim($_POST['email'])) : ''); - $openid_url = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : ''); - $photo = ((x($_POST,'photo')) ? notags(trim($_POST['photo'])) : ''); - $publish = ((x($_POST,'profile_publish_reg') && intval($_POST['profile_publish_reg'])) ? 1 : 0); - - $netpublish = ((strlen(get_config('system','directory_submit_url'))) ? $publish : 0); - - $tmp_str = $openid_url; - - if($using_invites) { - if(! $invite_id) { - notice( t('An invitation is required.') . EOL); - return; - } - $r = q("select * from register where `hash` = '%s' limit 1", dbesc($invite_id)); - if(! results($r)) { - notice( t('Invitation could not be verified.') . EOL); - return; - } - } - - if((! x($username)) || (! x($email)) || (! x($nickname))) { - if($openid_url) { - if(! validate_url($tmp_str)) { - notice( t('Invalid OpenID url') . EOL); - return; - } - $_SESSION['register'] = 1; - $_SESSION['openid'] = $openid_url; - require_once('library/openid.php'); - $openid = new LightOpenID; - $openid->identity = $openid_url; - $openid->returnUrl = $a->get_baseurl() . '/openid'; - $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson'); - $openid->optional = array('namePerson/first','media/image/aspect11','media/image/default'); - goaway($openid->authUrl()); - // NOTREACHED - } + $arr = $_POST; - notice( t('Please enter the required information.') . EOL ); - return; - } + $arr['blocked'] = $blocked; + $arr['verified'] = $verified; - if(! validate_url($tmp_str)) - $openid_url = ''; - - - $err = ''; - - // collapse multiple spaces in name - $username = preg_replace('/ +/',' ',$username); - - if(mb_strlen($username) > 48) - $err .= t('Please use a shorter name.') . EOL; - if(mb_strlen($username) < 3) - $err .= t('Name too short.') . EOL; - - // I don't really like having this rule, but it cuts down - // on the number of auto-registrations by Russian spammers - - // Using preg_match was completely unreliable, due to mixed UTF-8 regex support - // $no_utf = get_config('system','no_utf'); - // $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' ); - - // So now we are just looking for a space in the full name. - - $loose_reg = get_config('system','no_regfullname'); - if(! $loose_reg) { - $username = mb_convert_case($username,MB_CASE_TITLE,'UTF-8'); - if(! strpos($username,' ')) - $err .= t("That doesn't appear to be your full \x28First Last\x29 name.") . EOL; - } + $result = create_user($arr); - - if(! allowed_email($email)) - $err .= t('Your email domain is not among those allowed on this site.') . EOL; - - if((! valid_email($email)) || (! validate_email($email))) - $err .= t('Not a valid email address.') . EOL; - - // Disallow somebody creating an account using openid that uses the admin email address, - // since openid bypasses email verification. We'll allow it if there is not yet an admin account. - - if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0) && strlen($openid_url)) { - $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1", - dbesc($email) - ); - if(count($r)) - $err .= t('Cannot use that email.') . EOL; - } - - $nickname = $_POST['nickname'] = strtolower($nickname); - - if(! preg_match("/^[a-z][a-z0-9\-\_]*$/",$nickname)) - $err .= t('Your "nickname" can only contain "a-z", "0-9", "-", and "_", and must also begin with a letter.') . EOL; - $r = q("SELECT `uid` FROM `user` - WHERE `nickname` = '%s' LIMIT 1", - dbesc($nickname) - ); - if(count($r)) - $err .= t('Nickname is already registered. Please choose another.') . EOL; - - // Check deleted accounts that had this nickname. Doesn't matter to us, - // but could be a security issue for federated platforms. - - $r = q("SELECT * FROM `userd` - WHERE `username` = '%s' LIMIT 1", - dbesc($nickname) - ); - if(count($r)) - $err .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL; - - if(strlen($err)) { - notice( $err ); - return; - } - - - $new_password = autoname(6) . mt_rand(100,9999); - $new_password_encoded = hash('whirlpool',$new_password); - - require_once('include/crypto.php'); - - $result = new_keypair(1024); - - if($result === false) { - notice( t('SERIOUS ERROR: Generation of security keys failed.') . EOL); + if(! $result['success']) { + notice($result['message']); return; } - $prvkey = $result['prvkey']; - $pubkey = $result['pubkey']; - - /** - * - * Create another keypair for signing/verifying - * salmon protocol messages. We have to use a slightly - * less robust key because this won't be using openssl - * but the phpseclib. Since it is PHP interpreted code - * it is not nearly as efficient, and the larger keys - * will take several minutes each to process. - * - */ - - $sres = new_keypair(512); - $sprvkey = $sres['prvkey']; - $spubkey = $sres['pubkey']; - - $r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`, - `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone` ) - VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC' )", - dbesc(generate_user_guid()), - dbesc($username), - dbesc($new_password_encoded), - dbesc($email), - dbesc($openid_url), - dbesc($nickname), - dbesc($pubkey), - dbesc($prvkey), - dbesc($spubkey), - dbesc($sprvkey), - dbesc(datetime_convert()), - intval($verified), - intval($blocked) - ); - - if($r) { - $r = q("SELECT `uid` FROM `user` - WHERE `username` = '%s' AND `password` = '%s' LIMIT 1", - dbesc($username), - dbesc($new_password_encoded) - ); - if($r !== false && count($r)) - $newuid = intval($r[0]['uid']); - } - else { - notice( t('An error occurred during registration. Please try again.') . EOL ); - return; - } - - /** - * if somebody clicked submit twice very quickly, they could end up with two accounts - * due to race condition. Remove this one. - */ - - $r = q("SELECT `uid` FROM `user` - WHERE `nickname` = '%s' ", - dbesc($nickname) - ); - if((count($r) > 1) && $newuid) { - $err .= t('Nickname is already registered. Please choose another.') . EOL; - q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", - intval($newuid) - ); - notice ($err); - return; - } - - if(x($newuid) !== false) { - $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` ) - VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ", - intval($newuid), - 'default', - 1, - dbesc($username), - dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), - dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), - intval($publish), - intval($netpublish) - - ); - if($r === false) { - notice( t('An error occurred creating your default profile. Please try again.') . EOL ); - // Start fresh next time. - $r = q("DELETE FROM `user` WHERE `uid` = %d", - intval($newuid)); - return; - } - $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`, - `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date`, `closeness` ) - VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0 ) ", - intval($newuid), - datetime_convert(), - dbesc($username), - dbesc($nickname), - dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), - dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), - dbesc($a->get_baseurl() . "/photo/micro/{$newuid}.jpg"), - dbesc($a->get_baseurl() . "/profile/$nickname"), - dbesc(normalise_link($a->get_baseurl() . "/profile/$nickname")), - dbesc($a->get_baseurl() . "/dfrn_request/$nickname"), - dbesc($a->get_baseurl() . "/dfrn_notify/$nickname"), - dbesc($a->get_baseurl() . "/dfrn_poll/$nickname"), - dbesc($a->get_baseurl() . "/dfrn_confirm/$nickname"), - dbesc($a->get_baseurl() . "/poco/$nickname"), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()) - ); - - - } - - // if we have no OpenID photo try to look up an avatar - if(! strlen($photo)) - $photo = avatar_img($email); - - // unless there is no avatar-plugin loaded - if(strlen($photo)) { - require_once('include/Photo.php'); - $photo_failure = false; - - $filename = basename($photo); - $img_str = fetch_url($photo,true); - $img = new Photo($img_str); - if($img->is_valid()) { - - $img->scaleImageSquare(175); - - $hash = photo_new_resource(); - - $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); - - if($r === false) - $photo_failure = true; - - $img->scaleImage(80); - - $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 ); - - if($r === false) - $photo_failure = true; - - $img->scaleImage(48); - - $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 ); - - if($r === false) - $photo_failure = true; - - if(! $photo_failure) { - q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ", - dbesc($hash) - ); - } - } - } - + $user = $result['user']; + if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) { - $url = $a->get_baseurl() . "/profile/$nickname"; + $url = $a->get_baseurl() . '/profile/' . $user['nickname']; proc_run('php',"include/directory.php","$url"); } + $using_invites = get_config('system','invitation_only'); + $num_invites = get_config('system','number_invites'); + $invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : ''); - call_hooks('register_account', $newuid); if( $a->config['register_policy'] == REGISTER_OPEN ) { if($using_invites && $invite_id) { q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); - set_pconfig($newuid,'system','invites_remaining',$num_invites); + set_pconfig($user['uid'],'system','invites_remaining',$num_invites); } $email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), - '$username' => $username, - '$email' => $email, - '$password' => $new_password, - '$uid' => $newuid )); + '$username' => $user['username'], + '$email' => $user['email'], + '$password' => $result['password'], + '$uid' => $user['uid'] )); - $res = mail($email, sprintf(t('Registration details for %s'), $a->config['sitename']), + $res = mail($user['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" @@ -387,8 +110,8 @@ function register_post(&$a) { $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), - intval($newuid), - dbesc($new_password), + intval($user['uid']), + dbesc($result['password']), dbesc($lang) ); @@ -402,17 +125,17 @@ function register_post(&$a) { if($using_invites && $invite_id) { q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); - set_pconfig($newuid,'system','invites_remaining',$num_invites); + set_pconfig($user['uid'],'system','invites_remaining',$num_invites); } $email_tpl = get_intltext_template("register_verify_eml.tpl"); $email_tpl = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), - '$username' => $username, - '$email' => $email, - '$password' => $new_password, - '$uid' => $newuid, + '$username' => $user['username'], + '$email' => $user['email'], + '$password' => $result['password'], + '$uid' => $user['uid'], '$hash' => $hash )); diff --git a/mod/search.php b/mod/search.php index d4cd9d967..320ffddce 100644 --- a/mod/search.php +++ b/mod/search.php @@ -110,18 +110,19 @@ function search_content(&$a) { if (get_config('system','use_fulltext_engine')) { if($tag) - $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.preg_quote($search)); + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); else - $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(preg_quote($search))); + $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search))); } else { if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\[')); else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } + // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member @@ -145,7 +146,7 @@ function search_content(&$a) { } $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname` diff --git a/mod/settings.php b/mod/settings.php index b5214e917..92593d7a8 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -445,7 +445,7 @@ function settings_post(&$a) { if($page_flags == PAGE_PRVGROUP) { $hidewall = 1; - if((! str_contact_allow) && (! str_group_allow) && (! str_contact_deny) && (! $str_group_deny)) { + if((! $str_contact_allow) && (! $str_group_allow) && (! $str_contact_deny) && (! $str_group_deny)) { if($def_gid) { info( t('Private forum has no privacy permissions. Using default privacy group.'). EOL); $str_group_allow = '<' . $def_gid . '>'; @@ -837,27 +837,26 @@ function settings_content(&$a) { $pageset_tpl = get_markup_template('pagetypes.tpl'); $pagetype = replace_macros($pageset_tpl,array( - '$page_normal' => array('page-flags', t('Normal Account'), PAGE_NORMAL, + '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, t('This account is a normal personal profile'), ($a->user['page-flags'] == PAGE_NORMAL)), - '$page_soapbox' => array('page-flags', t('Soapbox Account'), PAGE_SOAPBOX, + '$page_soapbox' => array('page-flags', t('Soapbox Page'), PAGE_SOAPBOX, t('Automatically approve all connection/friend requests as read-only fans'), ($a->user['page-flags'] == PAGE_SOAPBOX)), - '$page_community' => array('page-flags', t('Community/Celebrity Account'), PAGE_COMMUNITY, + '$page_community' => array('page-flags', t('Community Forum/Celebrity Account'), PAGE_COMMUNITY, t('Automatically approve all connection/friend requests as read-write fans'), ($a->user['page-flags'] == PAGE_COMMUNITY)), - '$page_freelove' => array('page-flags', t('Automatic Friend Account'), PAGE_FREELOVE, + '$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE, t('Automatically approve all connection/friend requests as friends'), ($a->user['page-flags'] == PAGE_FREELOVE)), - '$page_prvgroup' => array('page-flags', t('Private Forum'), PAGE_PRVGROUP, - t('Private forum - approved members only [Experimental]'), + '$page_prvgroup' => array('page-flags', t('Private Forum [Experimental]'), PAGE_PRVGROUP, + t('Private forum - approved members only'), ($a->user['page-flags'] == PAGE_PRVGROUP)), - '$experimental' => ( (intval(get_config('system','prvgroup_testing'))) ? 'true' : ''), )); @@ -1026,7 +1025,8 @@ function settings_content(&$a) { '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''), - '$h_advn' => t('Advanced Page Settings'), + '$h_advn' => t('Advanced Account/Page Type Settings'), + '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, |