From 4a2d83fcfff548e50d3138ff617c0acd99445e03 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 19 Dec 2010 13:41:55 -0800 Subject: [PATCH 1/9] don't send any private messages over the facebook channel --- mod/item.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mod/item.php b/mod/item.php index 99721794a1..f0c2cc644d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -55,6 +55,17 @@ function item_post(&$a) { $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); + if(($parent_item) && + (($parent_item['private']) + || strlen($parent_item['allow_cid']) + || strlen($parent_item['allow_gid']) + || strlen($parent_item['deny_cid']) + || strlen($parent_item['deny_gid']) + ) + ) { + $private = 1; + } + $title = notags(trim($_POST['title'])); $body = escape_tags(trim($_POST['body'])); $location = notags(trim($_POST['location'])); @@ -242,7 +253,6 @@ function item_post(&$a) { ); // Inherit ACL's from the parent item. - // TODO merge with subsequent UPDATE operation and save a db write $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d WHERE `id` = %d LIMIT 1", @@ -327,7 +337,7 @@ function item_post(&$a) { * Post to Facebook stream */ - if((local_user()) && (local_user() == $profile_uid)) { + if((local_user()) && (local_user() == $profile_uid) && (! $private)) { $appid = get_config('system', 'facebook_appid' ); $secret = get_config('system', 'facebook_secret' ); if($appid && $secret) { From 24a9a41f969cfd7625847c77a949e4b279f68406 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 19 Dec 2010 17:46:26 -0800 Subject: [PATCH 2/9] added "secret" profile search keywords --- INSTALL | 1 + boot.php | 2 +- database.sql | 1 + mod/directory.php | 2 +- mod/profiles.php | 5 ++++- update.php | 4 ++++ view/en/profile_edit.tpl | 8 ++++++++ view/theme/default/style.css | 9 +++++++++ 8 files changed, 29 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index ceb73c3b9c..577f3f354c 100644 --- a/INSTALL +++ b/INSTALL @@ -23,6 +23,7 @@ encryption support - PHP *command line* access with register_argc_argv set to true in the php.ini file - curl, gd, mysql, and openssl extensions + - some form of email server or email gateway such that PHP mail() works - mcrypt (optional; used for end-to-end message encryption) - Mysql 5.x diff --git a/boot.php b/boot.php index 1870e059e9..329165ef8f 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1024 ); +define ( 'BUILD_ID', 1025 ); define ( 'DFRN_PROTOCOL_VERSION', '2.0' ); define ( 'EOL', "
\r\n" ); diff --git a/database.sql b/database.sql index dab7c179d9..30edf4189b 100644 --- a/database.sql +++ b/database.sql @@ -292,6 +292,7 @@ CREATE TABLE IF NOT EXISTS `profile` ( `sexual` char(255) NOT NULL, `politic` char(255) NOT NULL, `religion` char(255) NOT NULL, + `keywords` text NOT NULL, `about` text NOT NULL, `summary` char(255) NOT NULL, `music` text NOT NULL, diff --git a/mod/directory.php b/mod/directory.php index e9bbf47ab7..449c89174d 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -37,7 +37,7 @@ function directory_content(&$a) { if($search) $search = dbesc($search); - $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`) AGAINST ('$search' IN BOOLEAN MODE) " : ""); + $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra "); diff --git a/mod/profiles.php b/mod/profiles.php index e675af2e48..e99e0f288c 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -52,7 +52,7 @@ function profiles_post(&$a) { $region = notags(trim($_POST['region'])); $postal_code = notags(trim($_POST['postal_code'])); $country_name = notags(trim($_POST['country_name'])); - + $keywords = notags(trim($_POST['keywords'])); $marital = notags(trim($_POST['marital'])); if($marital != $orig[0]['marital']) $maritalchanged = true; @@ -138,6 +138,7 @@ function profiles_post(&$a) { `homepage` = '%s', `politic` = '%s', `religion` = '%s', + `keywords` = '%s', `about` = '%s', `interest` = '%s', `contact` = '%s', @@ -165,6 +166,7 @@ function profiles_post(&$a) { dbesc($homepage), dbesc($politic), dbesc($religion), + dbesc($keywords), dbesc($about), dbesc($interest), dbesc($contact), @@ -369,6 +371,7 @@ function profiles_content(&$a) { '$homepage' => $r[0]['homepage'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], + '$keywords' => $r[0]['keywords'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], diff --git a/update.php b/update.php index c5aa561946..382c83e5a0 100644 --- a/update.php +++ b/update.php @@ -243,3 +243,7 @@ function update_1023() { ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` "); } +function update_1024() { + q("ALTER TABLE `profile` ADD `keywords` TEXT NOT NULL AFTER `religion` "); +} + diff --git a/view/en/profile_edit.tpl b/view/en/profile_edit.tpl index c5b24a88ac..ec6cf260a9 100644 --- a/view/en/profile_edit.tpl +++ b/view/en/profile_edit.tpl @@ -40,6 +40,7 @@ $gender
$dob $age
+
$hide_friends @@ -126,6 +127,13 @@ $sexual
+
+ + +
(Used for searching public profiles, never shown to others)
+
+ +
diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 491486794f..627915e643 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -720,6 +720,7 @@ input#dfrn-url { #profile-edit-sexual-label, #profile-edit-politic-label, #profile-edit-religion-label, +#profile-edit-keywords-label, #profile-edit-homepage-label { float: left; width: 175px; @@ -738,6 +739,7 @@ input#dfrn-url { #sexual-select, #profile-edit-politic, #profile-edit-religion, +#profile-edit-keywords, #profile-in-dir-yes, #profile-in-dir-no, #profile-in-netdir-yes, @@ -768,6 +770,12 @@ input#dfrn-url { margin-left: 20px; } +#profile-edit-keywords-desc { + float: left; + margin-left: 20px; +} + + #profile-edit-homepage { float: left; margin-bottom: 35px; @@ -800,6 +808,7 @@ input#dfrn-url { #profile-edit-sexual-end, #profile-edit-politic-end, #profile-edit-religion-end, +#profile-edit-keywords-end, #profile-edit-homepage-end, #profile-in-dir-break, #profile-in-dir-end, From 2d9718fee9f5c07fe8098b892f9b096fcc68c43e Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 19 Dec 2010 19:04:37 -0800 Subject: [PATCH 3/9] do a slightly better job at finding relevant content from scraping submitted links --- mod/parse_url.php | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index aa71893ab4..acfe624cb2 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -6,6 +6,8 @@ function parse_url_content(&$a) { $url = trim($_GET['url']); + $text = null; + $template = "%s%s"; if($url) @@ -34,15 +36,38 @@ function parse_url_content(&$a) { } } - $items = $dom->getElementsByTagName('p'); - if($items) { - foreach($items as $item) { - $text = $item->textContent; - $text = strip_tags($text); - if(strlen($text) < 100) - continue; - $text = substr($text,0,250) . '...' ; - break; + + $divs = $dom->getElementsByTagName('div'); + if($divs) { + foreach($divs as $div) { + $class = $div->getAttribute('class'); + if($class && stristr($class,'article')) { + $items = $div->getElementsByTagName('p'); + if($items) { + foreach($items as $item) { + $text = $item->textContent; + $text = strip_tags($text); + if(strlen($text) < 100) + continue; + $text = substr($text,0,250) . '...' ; + break; + } + } + } + } + } + + if(! $text) { + $items = $dom->getElementsByTagName('p'); + if($items) { + foreach($items as $item) { + $text = $item->textContent; + $text = strip_tags($text); + if(strlen($text) < 100) + continue; + $text = substr($text,0,250) . '...' ; + break; + } } } From b9ca44678d572bfcb2714fb536890fd8ee9e99b1 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 19 Dec 2010 19:55:03 -0800 Subject: [PATCH 4/9] match the documentation --- include/profile_selectors.php | 2 +- mod/directory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/profile_selectors.php b/include/profile_selectors.php index f4b30f2118..92579f64aa 100644 --- a/include/profile_selectors.php +++ b/include/profile_selectors.php @@ -16,7 +16,7 @@ function gender_selector($current="",$suffix="") { function sexpref_selector($current="",$suffix="") { $o = ''; - $select = array('', t('Males'), t('Females'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); + $select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); $o .= " +
+ + +
(to prevent spam abuse)
+
+
+ + + + $profile_in_dir $profile_in_net_dir + +
diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 627915e643..8ad6ee5936 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -496,6 +496,7 @@ input#dfrn-url { #settings-password-end, #settings-confirm-end, #settings-openid-end, +#settings-maxreq-end, #notify1-end, #notify2-end, #notify3-end, @@ -515,6 +516,7 @@ input#dfrn-url { #settings-password-label, #settings-confirm-label, #settings-openid-label, +#settings-maxreq-label, #settings-label-notify1, #settings-label-notify2, #settings-label-notify3, @@ -533,6 +535,7 @@ input#dfrn-url { #theme-select, #settings-password, #settings-confirm, +#settings-maxreq, #notify1, #notify2, #notify3, @@ -548,7 +551,10 @@ input#dfrn-url { width: 127px; } - +#settings-maxreq-desc { + float: left; + margin-left: 20px; +} #settings-theme-label, #settings-defloc-label { From 0ff3ae55872cb911b48a3f780545940ec7f8b0fe Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 20 Dec 2010 03:13:42 -0800 Subject: [PATCH 7/9] change heading to reflect new scope --- view/en/settings.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/en/settings.tpl b/view/en/settings.tpl index a02e8ec080..85587afbfa 100644 --- a/view/en/settings.tpl +++ b/view/en/settings.tpl @@ -54,7 +54,7 @@ $theme
-

Privacy Settings

+

Security and Privacy Settings

From 1a9f8eacc4bc2b7a67894018b63fc7b0864d760a Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 20 Dec 2010 14:21:12 -0800 Subject: [PATCH 8/9] missing key --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 9f6f88d689..39bd34696f 100644 --- a/boot.php +++ b/boot.php @@ -1924,7 +1924,7 @@ function profile_sidebar($profile) { $gender = ((x($profile,'gender') == 1) ? '
' . t('Gender:') . ' ' . $profile['gender'] . '
' : ''); - $pubkey = ((x($profile,'key') == 1) ? '' : ''); + $pubkey = ((x($profile,'pubkey') == 1) ? '' : ''); $marital = ((x($profile,'marital') == 1) ? '
' . t('Status:') . ' ' . $profile['marital'] . '
' : ''); From ddec422de6707809aceb541e1191073b43aec18a Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 20 Dec 2010 19:38:34 -0800 Subject: [PATCH 9/9] begin plugin api --- boot.php | 60 ++++++++++++++++++++++++++++++++++++++-- database.sql | 8 ++++++ mod/parse_url.php | 5 ++-- update.php | 10 +++++++ view/en/profile_edit.tpl | 2 +- 5 files changed, 80 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index 39bd34696f..9cc4d0f34f 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1026 ); +define ( 'BUILD_ID', 1027 ); define ( 'DFRN_PROTOCOL_VERSION', '2.0' ); define ( 'EOL', "
\r\n" ); @@ -174,8 +174,10 @@ class App { public $pager; public $strings; public $path; + public $hooks; public $interactive = true; + private $scheme; private $hostname; private $baseurl; @@ -1945,4 +1947,58 @@ function profile_sidebar($profile) { )); return $o; -}} \ No newline at end of file +}} + + +if(! function_exists('register_hook')) { +function register_hook($hook,$file,$function) { + + $r = q("INSERT INTO `hook` (`hook`, `file`, `function`) VALUES ( '%s', '%s', '%s' ) ", + dbesc($hook), + dbesc($file), + dbesc($function) + ); + return $r; +}} + +if(! function_exists('unregister_hook')) { +function unregister_hook($hook,$file,$function) { + + $r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", + dbesc($hook), + dbesc($file), + dbesc($function) + ); + return $r; +}} + + +if(! function_exists('load_hooks')) { +function load_hooks() { + $a = get_app(); + $r = q("SELECT * FROM `hook` WHERE 1"); + if(count($r)) { + foreach($r as $rr) { + $a->hooks[] = array($rr['hook'], $rr['file'], $rr['function']); + } + } +}} + + +if(! function_exists('call_hooks')) { +function call_hooks($name, $data = null) { + $a = get_app(); + + if(count($a->hooks)) { + foreach($a->hooks as $hook) { + if($hook[0] === $name) { + @require_once($hook[1]); + if(function_exists($hook[2])) { + $func = $hook[2]; + $func($a,$data); + } + } + } + } +}} + diff --git a/database.sql b/database.sql index 10bb417aca..08902d8930 100644 --- a/database.sql +++ b/database.sql @@ -433,3 +433,11 @@ CREATE TABLE IF NOT EXISTS `pconfig` ( ) ENGINE = MYISAM DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `hook` ( +`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , +`hook` CHAR( 255 ) NOT NULL , +`file` CHAR( 255 ) NOT NULL , +`function` CHAR( 255 ) NOT NULL +) ENGINE = MYISAM DEFAULT CHARSET=utf8; + + diff --git a/mod/parse_url.php b/mod/parse_url.php index acfe624cb2..1561eb8a3b 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -2,6 +2,7 @@ require_once('library/HTML5/Parser.php'); + function parse_url_content(&$a) { $url = trim($_GET['url']); @@ -16,13 +17,13 @@ function parse_url_content(&$a) { echo ''; killme(); } - + if(! $s) { echo sprintf($template,$url,$url,''); killme(); } - $dom = HTML5_Parser::parse($s); + $dom = @HTML5_Parser::parse($s); if(! $dom) return $ret; diff --git a/update.php b/update.php index 5b4d99603c..81c5f0aeae 100644 --- a/update.php +++ b/update.php @@ -251,3 +251,13 @@ function update_1025() { q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` "); } +function update_1026() { + q("CREATE TABLE IF NOT EXISTS `hook` ( + `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , + `hook` CHAR( 255 ) NOT NULL , + `file` CHAR( 255 ) NOT NULL , + `function` CHAR( 255 ) NOT NULL + ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); +} + + diff --git a/view/en/profile_edit.tpl b/view/en/profile_edit.tpl index ec6cf260a9..50227b7f3b 100644 --- a/view/en/profile_edit.tpl +++ b/view/en/profile_edit.tpl @@ -94,7 +94,7 @@ $hide_friends
- + $marital