From 593d7037c581b2274f43735f36b88a488e0ba067 Mon Sep 17 00:00:00 2001 From: olivierm Date: Wed, 2 Mar 2011 14:38:30 +0100 Subject: Slight change in strings (now guess better whether 'likes' are plural or singular) --- view/fr/strings.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/view/fr/strings.php b/view/fr/strings.php index 09fa91f30..9115af770 100644 --- a/view/fr/strings.php +++ b/view/fr/strings.php @@ -16,14 +16,14 @@ $a->strings['last'] = 'last'; $a->strings['next'] = 'next'; $a->strings[' likes this.'] = ' aime ça.'; $a->strings[' doesn\'t like this.'] = ' n\'aime pas ça.'; -$a->strings['people'] = 'personne(s)'; -$a->strings['like this.'] = 'aime(nt) ça.'; -$a->strings['don\'t like this.'] = 'n\'aime(nt) pas ça.'; +$a->strings['people'] = 'personnes'; +$a->strings['like this.'] = 'aiment ça.'; +$a->strings['don\'t like this.'] = 'n\'aiment pas ça.'; $a->strings['and'] = 'et'; $a->strings[', and '] = ', et '; -$a->strings[' other people'] = ' autre(s) personne(s)'; -$a->strings[' like this.'] = ' aime(nt) ça.'; -$a->strings[' don\'t like this.'] = ' n\'aime(nt) pas ça.'; +$a->strings[' other people'] = ' autres personnes'; +$a->strings[' like this.'] = ' aiment ça.'; +$a->strings[' don\'t like this.'] = ' n\'aiment pas ça.'; $a->strings['No contacts'] = 'Aucun contact'; $a->strings['Contacts'] = 'Contacts'; $a->strings['View Contacts'] = 'Voir les contacts'; -- cgit v1.2.3 From 852091757166ffe0115ceade5af10154a2485286 Mon Sep 17 00:00:00 2001 From: olivierm Date: Tue, 8 Mar 2011 14:41:04 +0100 Subject: Autodetect browser language (should we make this optional?) --- index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index bbd2c81cd..24466a85a 100644 --- a/index.php +++ b/index.php @@ -31,10 +31,17 @@ $install = ((file_exists('.htconfig.php')) ? false : true); * * Get the language setting directly from system variables, bypassing get_config() * as database may not yet be configured. + * + * If possible, we use the value from the browser. * */ -$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en'); +if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $langs = preg_split("/[,-]/",$_SERVER['HTTP_ACCEPT_LANGUAGE'],2); + $lang = $langs[0]; +} else { + $lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en'); +} load_translation_table($lang); -- cgit v1.2.3 From 0cf647bf6f199586bad2e13973fe034bf5676eea Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 16:47:41 -0700 Subject: don't let somebody install with a bogus db hostname as this seems to lead to spectacular failure modes --- boot.php | 2 +- include/dba.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index bbaa8324d..806ad5377 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'FRIENDIKA_VERSION', '2.1.915' ); +define ( 'FRIENDIKA_VERSION', '2.1.917' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'DB_UPDATE_VERSION', 1040 ); diff --git a/include/dba.php b/include/dba.php index d75ed560a..1fdddb8a2 100644 --- a/include/dba.php +++ b/include/dba.php @@ -19,6 +19,22 @@ class dba { public $connected = false; function __construct($server,$user,$pass,$db,$install = false) { + $server = trim($server); + $user = trim($user); + $pass = trim($pass); + $db = trim($db); + + if($install) { + if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) { + if(! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) { + notice( sprintf( t('Cannot locate DNS info for database server \'%s\'',$server))); + $this->connected = false; + $this->db = null; + return; + } + } + } + $this->db = @new mysqli($server,$user,$pass,$db); if(! mysqli_connect_errno()) { $this->connected = true; -- cgit v1.2.3 From aebf9bb4d6bf2cf3e86378a369f2d51996f4f6a6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 19:12:46 -0700 Subject: non-code change --- include/dba.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dba.php b/include/dba.php index 1fdddb8a2..e2f369f19 100644 --- a/include/dba.php +++ b/include/dba.php @@ -19,6 +19,7 @@ class dba { public $connected = false; function __construct($server,$user,$pass,$db,$install = false) { + $server = trim($server); $user = trim($user); $pass = trim($pass); @@ -77,7 +78,7 @@ class dba { } else { - /* + /** * If dbfail.out exists, we will write any failed calls directly to it, * regardless of any logging that may or may nor be in effect. * These usually indicate SQL syntax errors that need to be resolved. -- cgit v1.2.3 From 79a6b70a26bdfc8e02b94ecef3d20559590eacc7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 21:53:39 -0700 Subject: friend finder data structures --- boot.php | 2 +- database.sql | 16 ++++++++++++++++ update.php | 22 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index 806ad5377..8cab15ba8 100644 --- a/boot.php +++ b/boot.php @@ -4,7 +4,7 @@ set_time_limit(0); define ( 'FRIENDIKA_VERSION', '2.1.917' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); -define ( 'DB_UPDATE_VERSION', 1040 ); +define ( 'DB_UPDATE_VERSION', 1041 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index f47a5967e..593e56746 100644 --- a/database.sql +++ b/database.sql @@ -479,3 +479,19 @@ CREATE TABLE IF NOT EXISTS `cache` ( `v` TEXT NOT NULL, `updated` DATETIME NOT NULL ) ENGINE = MYISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `fcontact` ( +`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`url` CHAR( 255 ) NOT NULL , +`name` CHAR( 255 ) NOT NULL , +`photo` CHAR( 255 ) NOT NULL +) ENGINE = MYISAM DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `ffinder` ( +`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`uid` INT UNSIGNED NOT NULL , +`cid` INT UNSIGNED NOT NULL , +`fid` INT UNSIGNED NOT NULL +) ENGINE = MYISAM DEFAULT CHARSET=utf8; + diff --git a/update.php b/update.php index fe8052b00..39e678bba 100644 --- a/update.php +++ b/update.php @@ -326,7 +326,7 @@ function update_1033() { `k` CHAR( 255 ) NOT NULL PRIMARY KEY , `v` TEXT NOT NULL, `updated` DATETIME NOT NULL - ) ENGINE = MYISAM DEFAULT CHARSET=utf8;"); + ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); } @@ -377,3 +377,23 @@ function update_1038() { function update_1039() { q("ALTER TABLE `addon` ADD `timestamp` BIGINT NOT NULL DEFAULT '0'"); } + + +function update_1040() { + + q("CREATE TABLE IF NOT EXISTS `fcontact` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `url` CHAR( 255 ) NOT NULL , + `name` CHAR( 255 ) NOT NULL , + `photo` CHAR( 255 ) NOT NULL + ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); + + q("CREATE TABLE IF NOT EXISTS `ffinder` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `uid` INT UNSIGNED NOT NULL , + `cid` INT UNSIGNED NOT NULL , + `fid` INT UNSIGNED NOT NULL + ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); + +} + -- cgit v1.2.3 From f2734681e537031926a1e9c142403048b420deee Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 22:07:56 -0700 Subject: friend finder support functions --- include/fcontact.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/fcontact.php diff --git a/include/fcontact.php b/include/fcontact.php new file mode 100644 index 000000000..8821a985f --- /dev/null +++ b/include/fcontact.php @@ -0,0 +1,41 @@ + Date: Mon, 14 Mar 2011 00:28:49 -0700 Subject: keywords split into public and private. Public will be used by the friend finder. --- database.sql | 3 ++- mod/directory.php | 2 +- mod/profiles.php | 12 ++++++++---- update.php | 4 ++++ view/de/profile_edit.tpl | 16 +++++++++++----- view/en/profile_edit.tpl | 16 +++++++++++----- view/fr/profile_edit.tpl | 16 +++++++++++----- view/it/profile_edit.tpl | 16 +++++++++++----- view/theme/duepuntozero/style.css | 12 ++++++++---- view/theme/loozah/style.css | 12 ++++++++---- 10 files changed, 75 insertions(+), 34 deletions(-) diff --git a/database.sql b/database.sql index 593e56746..3a58decd1 100644 --- a/database.sql +++ b/database.sql @@ -297,7 +297,8 @@ 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, + `pub_keywords` text NOT NULL, + `prv_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 0504ac321..825e2a375 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -40,7 +40,7 @@ function directory_content(&$a) { if($search) $search = dbesc($search); - $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); + $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " ); diff --git a/mod/profiles.php b/mod/profiles.php index 409999a3e..434f58adf 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -55,7 +55,8 @@ 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'])); + $pub_keywords = notags(trim($_POST['pub_keywords'])); + $prv_keywords = notags(trim($_POST['prv_keywords'])); $marital = notags(trim($_POST['marital'])); if($marital != $orig[0]['marital']) $maritalchanged = true; @@ -147,7 +148,8 @@ function profiles_post(&$a) { `homepage` = '%s', `politic` = '%s', `religion` = '%s', - `keywords` = '%s', + `pub_keywords` = '%s', + `prv_keywords` = '%s', `about` = '%s', `interest` = '%s', `contact` = '%s', @@ -176,7 +178,8 @@ function profiles_post(&$a) { dbesc($homepage), dbesc($politic), dbesc($religion), - dbesc($keywords), + dbesc($pub_keywords), + dbesc($prv_keywords), dbesc($about), dbesc($interest), dbesc($contact), @@ -383,7 +386,8 @@ function profiles_content(&$a) { '$homepage' => $r[0]['homepage'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], - '$keywords' => $r[0]['keywords'], + '$pub_keywords' => $r[0]['pub_keywords'], + '$prv_keywords' => $r[0]['prv_keywords'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], diff --git a/update.php b/update.php index 39e678bba..7a885193c 100644 --- a/update.php +++ b/update.php @@ -397,3 +397,7 @@ function update_1040() { } +function update_1041() { + q("ALTER TABLE `profile` CHANGE `keywords` `prv_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL "); + q("ALTER TABLE `profile` ADD `pub_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `religion` "); +} \ No newline at end of file diff --git a/view/de/profile_edit.tpl b/view/de/profile_edit.tpl index 09a761023..840597ddc 100644 --- a/view/de/profile_edit.tpl +++ b/view/de/profile_edit.tpl @@ -134,11 +134,17 @@ $sexual
-
- - -
(Used for searching public profiles, never shown to others)
-
+
+ + +
(Used for suggesting potential friends, can be seen by others)
+
+ +
+ + +
(Used for searching profiles, never shown to others)
+
diff --git a/view/en/profile_edit.tpl b/view/en/profile_edit.tpl index b0d4850d0..6c7d74daf 100644 --- a/view/en/profile_edit.tpl +++ b/view/en/profile_edit.tpl @@ -134,11 +134,17 @@ $sexual
-
- - -
(Used for searching public profiles, never shown to others)
-
+
+ + +
(Used for suggesting potential friends, can be seen by others)
+
+ +
+ + +
(Used for searching profiles, never shown to others)
+
diff --git a/view/fr/profile_edit.tpl b/view/fr/profile_edit.tpl index beff3b8bd..b28255188 100644 --- a/view/fr/profile_edit.tpl +++ b/view/fr/profile_edit.tpl @@ -134,11 +134,17 @@ $sexual
-
- - -
(Used for searching public profiles, never shown to others)
-
+
+ + +
(Used for suggesting potential friends, can be seen by others)
+
+ +
+ + +
(Used for searching profiles, never shown to others)
+
diff --git a/view/it/profile_edit.tpl b/view/it/profile_edit.tpl index efdb5d448..9f2a13790 100644 --- a/view/it/profile_edit.tpl +++ b/view/it/profile_edit.tpl @@ -134,11 +134,17 @@ $sexual
-
- - -
(Usati per la ricerca dei profili pubblci, mai mostrati agli altri)
-
+
+ + +
(Used for suggesting potential friends, can be seen by others)
+
+ +
+ + +
(Usati per la ricerca dei profili, mai mostrati agli altri)
+
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index c54b9835a..ca8764283 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -624,7 +624,8 @@ input#dfrn-url { #profile-edit-sexual-label, #profile-edit-politic-label, #profile-edit-religion-label, -#profile-edit-keywords-label, +#profile-edit-pubkeywords-label, +#profile-edit-prvkeywords-label, #profile-edit-homepage-label { float: left; width: 175px; @@ -644,7 +645,8 @@ input#dfrn-url { #sexual-select, #profile-edit-politic, #profile-edit-religion, -#profile-edit-keywords, +#profile-edit-pubkeywords, +#profile-edit-prvkeywords, #profile-in-dir-yes, #profile-in-dir-no, #profile-in-netdir-yes, @@ -698,7 +700,8 @@ input#dfrn-url { #profile-edit-pdesc-desc, -#profile-edit-keywords-desc { +#profile-edit-pubkeywords-desc, +#profile-edit-prvkeywords-desc { float: left; margin-left: 20px; } @@ -741,7 +744,8 @@ input#dfrn-url { #profile-edit-sexual-end, #profile-edit-politic-end, #profile-edit-religion-end, -#profile-edit-keywords-end, +#profile-edit-pubkeywords-end, +#profile-edit-prvkeywords-end, #profile-edit-homepage-end, #profile-in-dir-break, #profile-in-dir-end, diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index 4461907bb..aadfbd3c4 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -755,7 +755,8 @@ input#dfrn-url { #profile-edit-sexual-label, #profile-edit-politic-label, #profile-edit-religion-label, -#profile-edit-keywords-label, +#profile-edit-pubkeywords-label, +#profile-edit-prvkeywords-label, #profile-edit-homepage-label { float: left; width: 175px; @@ -775,7 +776,8 @@ input#dfrn-url { #sexual-select, #profile-edit-politic, #profile-edit-religion, -#profile-edit-keywords, +#profile-edit-pubkeywords, +#profile-edit-prvkeywords, #profile-in-dir-yes, #profile-in-dir-no, #profile-in-netdir-yes, @@ -806,7 +808,8 @@ input#dfrn-url { margin-left: 20px; } -#profile-edit-keywords-desc { +#profile-edit-pubkeywords-desc, +#profile-edit-prvkeywords-desc { float: left; margin-left: 20px; } @@ -864,7 +867,8 @@ input#dfrn-url { #profile-edit-sexual-end, #profile-edit-politic-end, #profile-edit-religion-end, -#profile-edit-keywords-end, +#profile-edit-pubkeywords-end, +#profile-edit-prvkeywords-end, #profile-edit-homepage-end, #profile-in-dir-break, #profile-in-dir-end, -- cgit v1.2.3 From bae15f9aaee5737b5f2efc9b3acf749c0c61f01e Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Mar 2011 16:18:32 -0700 Subject: revup --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 8cab15ba8..332830103 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'FRIENDIKA_VERSION', '2.1.917' ); +define ( 'FRIENDIKA_VERSION', '2.1.918' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'DB_UPDATE_VERSION', 1041 ); -- cgit v1.2.3 From 852ea1aedd22ea55ae07bcba4eb9bcf0b0018704 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Mar 2011 18:34:58 -0700 Subject: force last-child on foster children, disallow time travel --- include/items.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/items.php b/include/items.php index e930ab5d2..2294fe294 100644 --- a/include/items.php +++ b/include/items.php @@ -401,6 +401,17 @@ function get_atom_elements($feed,$item) { $res['edited'] = $item->get_date('c'); + // Disallow time travelling posts + + $d1 = strtotime($res['created']); + $d2 = strtotime($res['edited']); + $d3 = strtotime('now'); + + if($d1 > $d3) + $res['created'] = datetime_convert(); + if($d2 > $d3) + $res['edited'] = datetime_convert(); + $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); @@ -702,6 +713,18 @@ function item_store($arr,$force_parent = false) { intval($current_post) ); + /** + * If this is now the last-child, force all _other_ children of this parent to *not* be last-child + */ + + if($arr['last-child']) { + $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", + dbesc($arr['uri']), + intval($arr['uid']), + intval($current_post) + ); + } + return $current_post; } -- cgit v1.2.3 From 53dcede27894c655cbe1abaa9149dd0bed043a8d Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Mar 2011 20:19:45 -0700 Subject: pub_keywords -> meta keywords --- boot.php | 2 +- mod/profile.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 332830103..92a0007e5 100644 --- a/boot.php +++ b/boot.php @@ -4,7 +4,7 @@ set_time_limit(0); define ( 'FRIENDIKA_VERSION', '2.1.918' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); -define ( 'DB_UPDATE_VERSION', 1041 ); +define ( 'DB_UPDATE_VERSION', 1042 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/mod/profile.php b/mod/profile.php index 5615573b9..88fc16ebb 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -28,6 +28,11 @@ function profile_init(&$a) { $a->page['htmlhead'] .= '' . "\r\n"; } + $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); + $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords); + if(strlen($keywords)) + $a->page['htmlhead'] .= '' . "\r\n" ; + $a->page['htmlhead'] .= '' . "\r\n" ; $a->page['htmlhead'] .= '' . "\r\n" ; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); -- cgit v1.2.3 From 4cc20f1288a59d6ff48a62da62ec056ebd543e14 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 00:56:25 -0700 Subject: fix youtube videos that use https:// urls --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bbcode.php b/include/bbcode.php index 978b4af69..4caf18766 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -90,7 +90,7 @@ function bbcode($Text) { $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); // Youtube extensions - $Text = preg_replace("/\[youtube\]http:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text); // oembed tag -- cgit v1.2.3 From 73d3758e45f2049ad669225910afeb0d24e25e86 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 15:10:03 -0700 Subject: revup --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 92a0007e5..baecdc9c3 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'FRIENDIKA_VERSION', '2.1.918' ); +define ( 'FRIENDIKA_VERSION', '2.1.919' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'DB_UPDATE_VERSION', 1042 ); -- cgit v1.2.3 From f01538a54f68c172e09aabed90e2651ca2305675 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 17:31:49 -0700 Subject: content expiration --- boot.php | 2 +- database.sql | 1 + include/expire.php | 44 +++++++++++++++++++++++++++++++++++++ include/items.php | 46 +++++++++++++++++++++++++++++++++++++++ include/notifier.php | 34 +++++++++++++++++++---------- include/poller.php | 11 ++++++++++ mod/item.php | 2 +- mod/settings.php | 6 ++++- update.php | 8 ++++++- view/de/settings.tpl | 6 ++++- view/en/settings.tpl | 7 ++++-- view/fr/settings.tpl | 5 ++++- view/it/settings.tpl | 5 ++++- view/theme/duepuntozero/style.css | 4 ++++ view/theme/loozah/style.css | 4 ++++ 15 files changed, 165 insertions(+), 20 deletions(-) create mode 100644 include/expire.php diff --git a/boot.php b/boot.php index baecdc9c3..b03221bf8 100644 --- a/boot.php +++ b/boot.php @@ -4,7 +4,7 @@ set_time_limit(0); define ( 'FRIENDIKA_VERSION', '2.1.919' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); -define ( 'DB_UPDATE_VERSION', 1042 ); +define ( 'DB_UPDATE_VERSION', 1043 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 3a58decd1..0ecf0ea20 100644 --- a/database.sql +++ b/database.sql @@ -379,6 +379,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `page-flags` int(11) unsigned NOT NULL DEFAULT '0', `pwdreset` char(255) NOT NULL, `maxreq` int(11) NOT NULL DEFAULT '10', + `expire` int(11) unsigned NOT NULL DEFAULT '0', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, diff --git a/include/expire.php b/include/expire.php new file mode 100644 index 000000000..3c30e01c1 --- /dev/null +++ b/include/expire.php @@ -0,0 +1,44 @@ +set_baseurl(get_config('system','url')); + + + logger('expire: start'); + + $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); + if(count($r)) { + foreach($r as $rr) { + logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); + item_expire($rr['uid'],$rr['expire']); + } + } + + return; +} + +if (array_search(__file__,get_included_files())===0){ + expire_run($argv,$argc); + killme(); +} diff --git a/include/items.php b/include/items.php index 2294fe294..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -1507,3 +1507,49 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } +function item_expire($uid,$days) { + + if((! $uid) || (! $days)) + return; + + $r = q("SELECT * FROM `item` + WHERE `uid` = %d + AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY + AND `id` = `parent` + AND `deleted` = 0", + intval($uid), + intval($days) + ); + + if(! count($r)) + return; + + logger('expire: # items=' . count($r) ); + + foreach($r as $item) { + + // Only expire posts, not photos and photo comments + + if(strlen($item['resource-id'])) + continue; + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + + // kill the kids + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + + } + + proc_run('php',"include/notifier.php","expire","$uid"); + +} \ No newline at end of file diff --git a/include/notifier.php b/include/notifier.php index 648a07062..ca2304845 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -40,6 +40,7 @@ function notifier_run($argv, $argc){ break; } + $expire = false; $top_level = false; $recipients = array(); $url_recipients = array(); @@ -57,6 +58,17 @@ function notifier_run($argv, $argc){ $item = $message[0]; } + elseif($cmd === 'expire') { + $expire = true; + $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 + AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP - INTERVAL 10 MINUTE", + intval($item_id) + ); + $uid = $item_id; + $item_id = 0; + if(! count($items)) + return; + } else { // find ancestors @@ -76,11 +88,10 @@ function notifier_run($argv, $argc){ intval($parent_id) ); - if(! count($items)){ + if(! count($items)) { return; } - // avoid race condition with deleting entries if($items[0]['deleted']) { @@ -98,11 +109,11 @@ function notifier_run($argv, $argc){ intval($uid) ); - if(count($r)) - $owner = $r[0]; - else { + if(! count($r)) return; - } + + $owner = $r[0]; + $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -117,7 +128,7 @@ function notifier_run($argv, $argc){ $parent = $items[0]; - if($parent['type'] === 'remote') { + if($parent['type'] === 'remote' && (! $expire)) { // local followup to remote post $followup = true; $notify_hub = false; // not public @@ -235,6 +246,7 @@ function notifier_run($argv, $argc){ } else { foreach($items as $item) { + if(! $item['parent']) continue; @@ -242,9 +254,9 @@ function notifier_run($argv, $argc){ if(! $contact) continue; - $atom .= atom_entry($item,'text',$contact,$owner,true); + $atom .= atom_entry($item,'text',$contact,$owner,true); - if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link'])) + if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link']) && (! $expire)) $slaps[] = atom_entry($item,'html',$contact,$owner,true); } } @@ -319,7 +331,7 @@ function notifier_run($argv, $argc){ // only send salmon if public - e.g. if it's ok to notify // a public hub, it's ok to send a salmon - if(count($slaps) && $notify_hub) { + if((count($slaps)) && ($notify_hub) && (! $expire)) { logger('notifier: slapdelivery: ' . $contact['name']); foreach($slaps as $slappy) { if($contact['notify']) { @@ -350,7 +362,7 @@ function notifier_run($argv, $argc){ // send additional slaps to mentioned remote tags (@foo@example.com) - if($slap && count($url_recipients) && $followup && $notify_hub) { + if($slap && count($url_recipients) && $followup && $notify_hub && (! $expire)) { foreach($url_recipients as $url) { if($url) { logger('notifier: urldelivery: ' . $url); diff --git a/include/poller.php b/include/poller.php index a093190a6..8619697d9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -29,6 +29,17 @@ function poller_run($argv, $argc){ proc_run('php',"include/queue.php"); + // once daily run expire in background + + $d1 = get_config('system','last_expire_day'); + $d2 = intval(datetime_convert('UTC','UTC','now','d')); + + if($d2 != intval($d1)) { + set_config('system','last_expire_day',$d2); + proc_run('php','include/expire.php'); + } + + // clear old cache q("DELETE FROM `cache` WHERE `updated` < '%s'", dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); diff --git a/mod/item.php b/mod/item.php index 5989d0967..90fb546bc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -532,7 +532,7 @@ function item_content(&$a) { require_once('include/security.php'); - $uid = $_SESSION['uid']; + $uid = local_user(); if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { diff --git a/mod/settings.php b/mod/settings.php index ebe07612e..85029b3d7 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -63,6 +63,7 @@ function settings_post(&$a) { $defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : ''); $openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : ''); $maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0); + $expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0); $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0); $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0); @@ -139,7 +140,7 @@ function settings_post(&$a) { $openidserver = ''; } - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `openidserver` = '%s' WHERE `uid` = %d LIMIT 1", + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s' WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($openid), @@ -154,6 +155,7 @@ function settings_post(&$a) { intval($allow_location), dbesc($theme), intval($maxreq), + intval($expire), dbesc($openidserver), intval(local_user()) ); @@ -238,6 +240,7 @@ function settings_content(&$a) { $defloc = $a->user['default-location']; $openid = $a->user['openid']; $maxreq = $a->user['maxreq']; + $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); @@ -358,6 +361,7 @@ function settings_content(&$a) { '$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''), '$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : ''), '$maxreq' => $maxreq, + '$expire' => $expire, '$theme' => $theme_selector, '$pagetype' => $pagetype )); diff --git a/update.php b/update.php index 7a885193c..0be919f3f 100644 --- a/update.php +++ b/update.php @@ -400,4 +400,10 @@ function update_1040() { function update_1041() { q("ALTER TABLE `profile` CHANGE `keywords` `prv_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL "); q("ALTER TABLE `profile` ADD `pub_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `religion` "); -} \ No newline at end of file +} + +function update_1042() { + q("ALTER TABLE `user` ADD `expire` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `maxreq` "); +} + + diff --git a/view/de/settings.tpl b/view/de/settings.tpl index 0ef50546f..675ef675f 100644 --- a/view/de/settings.tpl +++ b/view/de/settings.tpl @@ -78,7 +78,7 @@ $profile_in_net_dir
- +
+
Automatically expire (delete) posts older than days
+
+ +
diff --git a/view/en/settings.tpl b/view/en/settings.tpl index 97d67cbf6..39b18c126 100644 --- a/view/en/settings.tpl +++ b/view/en/settings.tpl @@ -76,9 +76,8 @@ $profile_in_dir $profile_in_net_dir -
- +
+
Automatically expire (delete) posts older than days
+
+ +
diff --git a/view/fr/settings.tpl b/view/fr/settings.tpl index 97d67cbf6..eb386579f 100644 --- a/view/fr/settings.tpl +++ b/view/fr/settings.tpl @@ -78,7 +78,7 @@ $profile_in_net_dir
- +
+
Automatically expire (delete) posts older than days
+
+
diff --git a/view/it/settings.tpl b/view/it/settings.tpl index 3b68923cf..87f40f26f 100644 --- a/view/it/settings.tpl +++ b/view/it/settings.tpl @@ -79,7 +79,7 @@ $profile_in_net_dir
- +
+
Automatically expire (delete) posts older than days
+
+
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index ca8764283..54a522881 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -373,6 +373,10 @@ input#dfrn-url { margin-bottom: 30px; } +#settings-expire-end { + margin-bottom: 30px; +} + #settings-username-end, #settings-email-end, #settings-nick-end, diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index aadfbd3c4..f1de801cb 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -506,6 +506,10 @@ input#dfrn-url { margin-bottom: 30px; } +#settings-expire-end { + margin-bottom: 30px; +} + #settings-username-end, #settings-email-end, #settings-nick-end, -- cgit v1.2.3 From e2ea341094c53e78ae7473a83d2b6c85b1cde4eb Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 17:47:49 -0700 Subject: facebook parses out punctuation on the left of links but not on right --- addon/facebook/facebook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index edfc5a374..e1ea6673b 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -225,7 +225,7 @@ function facebook_post_hook(&$a,&$b) { // make links readable before we strip the code - $msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 [$1]',$msg); + $msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 $1',$msg); $msg = preg_replace("/\[img\](.+?)\[\/img\]/is", t('Image: ') . '$1',$msg); -- cgit v1.2.3