From 147d7f3bbf6c785f2c1eb7cdcfaa0a47e0ee43d3 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 6 Feb 2011 15:50:50 -0800 Subject: [PATCH 01/12] theme name cleanup - rename default to loozah, provide sane fallbacks and change system primary theme. Provide indication on contact edit page of last update success/failure - can be extended later to show actual timestamp of last successful update. --- boot.php | 32 +++++++++++++++++++- database.sql | 1 + htconfig.php | 4 +++ include/poller.php | 16 ++++++++-- index.php | 13 +------- mod/contacts.php | 11 +++++-- update.php | 7 +++++ view/de/htconfig.tpl | 10 ++++++ view/en/htconfig.tpl | 4 +++ view/fr/htconfig.tpl | 9 ++++++ view/it/htconfig.tpl | 9 ++++++ view/theme/clean/style.css | 2 +- view/theme/darkness/style.css | 2 +- view/theme/default/dfrn.gif | Bin 109 -> 0 bytes view/theme/default/friendika16.gif | Bin 1071 -> 0 bytes view/theme/duepuntozero/style.css | 3 +- view/theme/goldenrod/style.css | 2 +- view/theme/{default => loozah}/ff-16.jpg | Bin view/theme/{default => loozah}/lock.cur | Bin view/theme/{default => loozah}/login-bg.gif | Bin view/theme/{default => loozah}/style.css | 4 ++- view/theme/shady/style.css | 2 +- view/theme/three-d/style.css | 2 +- 23 files changed, 107 insertions(+), 26 deletions(-) delete mode 100644 view/theme/default/dfrn.gif delete mode 100644 view/theme/default/friendika16.gif rename view/theme/{default => loozah}/ff-16.jpg (100%) rename view/theme/{default => loozah}/lock.cur (100%) rename view/theme/{default => loozah}/login-bg.gif (100%) rename view/theme/{default => loozah}/style.css (99%) diff --git a/boot.php b/boot.php index 4fc35be9bb..ae6d534d61 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1035 ); +define ( 'BUILD_ID', 1036 ); define ( 'FRIENDIKA_VERSION', '2.10.0905' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); @@ -2275,3 +2275,33 @@ function proc_run($cmd){ proc_close(proc_open($cmdline." &",array(),$foo)); }} +/* + * Return full URL to theme which is currently in effect. + * Provide a sane default if nothing is chosen or the specified theme does not exist. + */ + +if(! function_exists('current_theme_url')) { +function current_theme_url() { + + $app_base_themes = array('duepuntozero', 'loozah'); + + $a = get_app(); + + $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); + $theme_name = ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); + + if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css')) + return($a->get_baseurl() . '/view/theme/' . $theme_name . '/style.css'); + + foreach($app_base_themes as $t) { + if(file_exists('view/theme/' . $t . '/style.css')) + return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); + } + + $fallback = glob('view/theme/*/style.css'); + if(count($fallback)) + return($a->get_baseurl() . $fallback[0]); + + +}} + diff --git a/database.sql b/database.sql index 817fd09226..83e0e4b6f4 100644 --- a/database.sql +++ b/database.sql @@ -77,6 +77,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `subhub` tinyint(1) NOT NULL DEFAULT '0', `hub-verify` char(255) NOT NULL, `last-update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `success_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `name-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `uri-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `avatar-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', diff --git a/htconfig.php b/htconfig.php index 5f5c76cbd7..fb62245d21 100644 --- a/htconfig.php +++ b/htconfig.php @@ -64,6 +64,10 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com'; $a->config['system']['rino_encrypt'] = true; +// default system theme + +$a->config['system']['theme'] = 'duepuntozero'; + // Addons or plugins are configured here. // This is a comma seperated list of addons to enable. Example: diff --git a/include/poller.php b/include/poller.php index 20c84990e0..1d88fe447f 100644 --- a/include/poller.php +++ b/include/poller.php @@ -239,6 +239,7 @@ function poller_run($argv, $argc){ $xml = post_url($contact['poll'],$postvars); } else { + // $contact['network'] !== 'dfrn' $xml = fetch_url($contact['poll']); @@ -246,8 +247,14 @@ function poller_run($argv, $argc){ logger('poller: received xml : ' . $xml, LOGGER_DATA); - if(! strlen($xml)) + if(! strstr($xml,'module != 'install') require_once('nav.php'); /** - * * Build the page - now that we have all the components - * Make sure the desired theme exists, though if the default theme doesn't exist we're stuffed. - * */ -$default_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : 'default'); -if((x($_SESSION,'theme')) && (! file_exists('view/theme/' . $_SESSION['theme'] . '/style.css'))) - unset($_SESSION['theme']); - -$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array( - '$stylesheet' => $a->get_baseurl() . '/view/theme/' - . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $default_theme) - . '/style.css' - )); +$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => current_theme_url())); $page = $a->page; $profile = $a->profile; diff --git a/mod/contacts.php b/mod/contacts.php index 61d9ce3986..36f42f8e59 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -245,6 +245,13 @@ function contacts_content(&$a) { $sparkle = ''; } + $last_update = (($r[0]['last-update'] == '0000-00-00 00:00:00') + ? t('Never') + : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')); + + if($r[0]['last-update'] !== '0000-00-00 00:00:00') + $last_update .= ' ' . (($r[0]['last-update'] == $r[0]['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); + $o .= replace_macros($tpl,array( '$header' => t('Contact Editor'), '$visit' => t('Visit $name\'s profile'), @@ -254,9 +261,7 @@ function contacts_content(&$a) { '$poll_interval' => contact_poll_interval($r[0]['priority']), '$lastupdtext' => t('Last updated: '), '$updpub' => t('Update public posts: '), - '$last_update' => (($r[0]['last-update'] == '0000-00-00 00:00:00') - ? t('Never') - : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')), + '$last_update' => $last_update, '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($r[0]['profile-id'],(($r[0]['network'] !== 'dfrn') ? true : false)), '$contact_id' => $r[0]['id'], diff --git a/update.php b/update.php index f909837470..2ca008cdad 100644 --- a/update.php +++ b/update.php @@ -342,3 +342,10 @@ function update_1034() { q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE"); } + + +function update_1035() { + + q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` "); + +} \ No newline at end of file diff --git a/view/de/htconfig.tpl b/view/de/htconfig.tpl index c7c19bf69e..d3bb6b411e 100644 --- a/view/de/htconfig.tpl +++ b/view/de/htconfig.tpl @@ -62,3 +62,13 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com'; $a->config['system']['rino_encrypt'] = true; +// default system theme + +$a->config['system']['theme'] = 'duepuntozero'; + +// Addons or plugins are configured here. +// This is a comma seperated list of addons to enable. Example: +// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; + +$a->config['system']['addon'] = 'js_upload'; + diff --git a/view/en/htconfig.tpl b/view/en/htconfig.tpl index 0182dbe5c0..d3bb6b411e 100644 --- a/view/en/htconfig.tpl +++ b/view/en/htconfig.tpl @@ -62,6 +62,10 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com'; $a->config['system']['rino_encrypt'] = true; +// default system theme + +$a->config['system']['theme'] = 'duepuntozero'; + // Addons or plugins are configured here. // This is a comma seperated list of addons to enable. Example: // $a->config['system']['addon'] = 'js_upload,randplace,oembed'; diff --git a/view/fr/htconfig.tpl b/view/fr/htconfig.tpl index c7c19bf69e..d31d5a39ff 100644 --- a/view/fr/htconfig.tpl +++ b/view/fr/htconfig.tpl @@ -62,3 +62,12 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com'; $a->config['system']['rino_encrypt'] = true; +// default system theme + +$a->config['system']['theme'] = 'duepuntozero'; + +// Addons or plugins are configured here. +// This is a comma seperated list of addons to enable. Example: +// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; + +$a->config['system']['addon'] = 'js_upload'; diff --git a/view/it/htconfig.tpl b/view/it/htconfig.tpl index 78e014cc17..180f7885cc 100644 --- a/view/it/htconfig.tpl +++ b/view/it/htconfig.tpl @@ -62,3 +62,12 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com'; $a->config['system']['rino_encrypt'] = true; +// default system theme + +$a->config['system']['theme'] = 'duepuntozero'; + +// Addons or plugins are configured here. +// This is a comma seperated list of addons to enable. Example: +// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; + +$a->config['system']['addon'] = 'js_upload'; diff --git a/view/theme/clean/style.css b/view/theme/clean/style.css index ea8f54ddf3..4730b5c2fd 100644 --- a/view/theme/clean/style.css +++ b/view/theme/clean/style.css @@ -1,4 +1,4 @@ -@import url('../default/style.css'); +@import url('../loozah/style.css'); footer { background: #CCC; diff --git a/view/theme/darkness/style.css b/view/theme/darkness/style.css index 3aff559d3e..828fdd1040 100644 --- a/view/theme/darkness/style.css +++ b/view/theme/darkness/style.css @@ -1,4 +1,4 @@ -@import url('../default/style.css'); +@import url('../loozah/style.css'); nav { background: #CCC; diff --git a/view/theme/default/dfrn.gif b/view/theme/default/dfrn.gif deleted file mode 100644 index 104f42e51c65b05e9b12b9c48a3e892e0da30a8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 109 zcmZ?wbhEHb6l4%&Sjfb{!0`V+2!nv)PZmZl1||j_peRsQkb!~8t|!0g^upejIl@*A zAEULZ-?%VEFgA$HJf4R$1ozRmIh3 z3#w{9R44}bMHya>?URTf5X7Gf@K7Xth6+doI1!YDh!Y1C4xI>K5Wu24mlFZIw}|ou z)&SHRtZ;2wI4bGbzK#Xq6o%U&}%+C*%F8Y5KB?x|-Un>FExwmJA#T#3nTA z5ix8m#XIukZ52T?L6}Jejqz}G7w*J_qy%-Lhzkll2;%08A|3?wAQ*>227??1T@d3i zlp%Z^K4QjOX%vN8!lJ0C%x+}g>^>j#r{w_k5* zYHaRm>gnxn9%||}^bR&O+#db5yL;p2O?qV1K0Z!&%=I-&H0?`N+JZw!xdWA~ez z%=!!SE&9hD?bF{+-TPsBYI@daGX8A7zqqux^v7>AGn9!nS}e<(e?M7SrLAkU#ll*x z%-S0J7q@PIWU<+wZEss_HrtlnW_N5kC_71#6d#(RoD@ydB*{@UNAZWDoQ%`S(hTcl zI48?849Bn>!*MLf$HlqaF1OodMFSj);6)g|0F(eezvM zog}uw8y-LT3l}5PT6dRpQpJY5rw!RUgY-~iYskS%2{nsJ%L9IUo-^C(U&ZToYuaN5 z%e^x660w0u&0RhRWv4EvOuC{4Oz7n8K6NzGeCd@hGq$`}toq?< N$B=gYV6YTu{sA)P Date: Sun, 6 Feb 2011 19:15:20 -0800 Subject: [PATCH 02/12] fix contact photo updates - a result of baseurl being wrong for cmdline processes --- boot.php | 40 +++++++++++++++++++++++++++++----------- include/poller.php | 1 - update.php | 16 +++++++++++++++- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/boot.php b/boot.php index ae6d534d61..5327688ddd 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1036 ); +define ( 'BUILD_ID', 1037 ); define ( 'FRIENDIKA_VERSION', '2.10.0905' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); @@ -215,9 +215,19 @@ class App { $this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http' ); - if(x($_SERVER,'SERVER_NAME')) + if(x($_SERVER,'SERVER_NAME')) { $this->hostname = $_SERVER['SERVER_NAME']; + /** + * Figure out if we are running at the top of a domain + * or in a sub-directory and adjust accordingly + */ + + $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\'); + if(isset($path) && strlen($path) && ($path != $this->path)) + $this->path = $path; + } + set_include_path("include/$this->hostname" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . '.' ); if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") @@ -225,14 +235,6 @@ class App { if(x($_GET,'q')) $this->cmd = trim($_GET['q'],'/\\'); - /** - * Figure out if we are running at the top of a domain - * or in a sub-directory and adjust accordingly - */ - - $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\'); - if(isset($path) && strlen($path) && ($path != $this->path)) - $this->path = $path; /** @@ -295,8 +297,20 @@ class App { } function set_baseurl($url) { + $parsed = parse_url($url); + $this->baseurl = $url; - $this->hostname = basename($url); + + if($parsed) { + $this->scheme = $parsed['scheme']; + + $this->hostname = $parsed['host']; + if($parsed['port']) + $this->hostname .= ':' . $parsed['port']; + if($parsed['path']) + $this->path = trim($parsed['path'],'\\/'); + } + } function get_hostname() { @@ -406,8 +420,12 @@ function system_unavailable() { if(! function_exists('check_config')) { function check_config(&$a) { + load_config('system'); + if(! x($_SERVER,'SERVER_NAME')) + return; + $build = get_config('system','build'); if(! x($build)) $build = set_config('system','build',BUILD_ID); diff --git a/include/poller.php b/include/poller.php index 1d88fe447f..66df080a9d 100644 --- a/include/poller.php +++ b/include/poller.php @@ -28,7 +28,6 @@ function poller_run($argv, $argc){ // run queue delivery process in the background $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - //proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo)); proc_run($php_path,"include/queue.php"); // clear old cache diff --git a/update.php b/update.php index 2ca008cdad..e51e8ac33e 100644 --- a/update.php +++ b/update.php @@ -348,4 +348,18 @@ function update_1035() { q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` "); -} \ No newline at end of file +} + +function update_1036() { + + $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' "); + if(count($r)) { + foreach($r as $rr) { + q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(str_replace('include/photo','photo',$rr['photo'])), + dbesc(str_replace('include/photo','photo',$rr['thumb'])), + dbesc(str_replace('include/photo','photo',$rr['micro'])), + intval($rr['id'])); + } + } +} From 0d9ed4873801a669ff9530a5fa434252a1be2a57 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 6 Feb 2011 22:41:07 -0800 Subject: [PATCH 03/12] functionise birthday --- boot.php | 43 +++++++++++++++++++++++++++++++++++++++++++ include/items.php | 39 +-------------------------------------- include/notifier.php | 8 ++++++-- 3 files changed, 50 insertions(+), 40 deletions(-) diff --git a/boot.php b/boot.php index 5327688ddd..4dcd6db660 100644 --- a/boot.php +++ b/boot.php @@ -2323,3 +2323,46 @@ function current_theme_url() { }} +if(! function_exists('feed_birthday')) { +function feed_birthday($uid,$tz) { + + /** + * + * Determine the next birthday, but only if the birthday is published + * in the default profile. We _could_ also look for a private profile that the + * recipient can see, but somebody could get mad at us if they start getting + * public birthday greetings when they haven't made this info public. + * + * Assuming we are able to publish this info, we are then going to convert + * the start time from the owner's timezone to UTC. + * + * This will potentially solve the problem found with some social networks + * where birthdays are converted to the viewer's timezone and salutations from + * elsewhere in the world show up on the wrong day. We will convert it to the + * viewer's timezone also, but first we are going to convert it from the birthday + * person's timezone to GMT - so the viewer may find the birthday starting at + * 6:00PM the day before, but that will correspond to midnight to the birthday person. + * + */ + + $birthday = ''; + + $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", + intval($uid) + ); + + if($p && count($p)) { + $tmp_dob = substr($p[0]['dob'],5); + if(intval($tmp_dob)) { + $y = datetime_convert($tz,$tz,'now','Y'); + $bd = $y . '-' . $tmp_dob . ' 00:00'; + $t_dob = strtotime($bd); + $now = strtotime(datetime_convert($tz,$tz,'now')); + if($t_dob < $now) + $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; + $birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME); + } + } + + return $birthday; +}} \ No newline at end of file diff --git a/include/items.php b/include/items.php index 15fd262f4c..5b99ca1714 100644 --- a/include/items.php +++ b/include/items.php @@ -37,44 +37,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) else killme(); - - /** - * - * Determine the next birthday, but only if the birthday is published - * in the default profile. We _could_ also look for a private profile that the - * recipient can see, but somebody could get mad at us if they start getting - * public birthday greetings when they haven't made this info public. - * - * Assuming we are able to publish this info, we are then going to convert - * the start time from the owner's timezone to UTC. - * - * This will potentially solve the problem found with some social networks - * where birthdays are converted to the viewer's timezone and salutations from - * elsewhere in the world show up on the wrong day. We will convert it to the - * viewer's timezone also, but first we are going to convert it from the birthday - * person's timezone to GMT - so the viewer may find the birthday starting at - * 6:00PM the day before, but that will correspond to midnight to the birthday person. - * - */ - - $birthday = ''; - - $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", - intval($owner_id) - ); - - if($p && count($p)) { - $tmp_dob = substr($p[0]['dob'],5); - if(intval($tmp_dob)) { - $y = datetime_convert($owner_tz,$owner_tz,'now','Y'); - $bd = $y . '-' . $tmp_dob . ' 00:00'; - $t_dob = strtotime($bd); - $now = strtotime(datetime_convert($owner_tz,$owner_tz,'now')); - if($t_dob < $now) - $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; - $birthday = datetime_convert($owner_tz,'UTC',$bd,ATOM_TIME); - } - } + $birthday = feed_birthday($owner_id,$owner_tz); if($dfrn_id && $dfrn_id != '*') { diff --git a/include/notifier.php b/include/notifier.php index 07bde7c4d6..ca0aa0df38 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -87,7 +87,7 @@ function notifier_run($argv, $argc){ } } - $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` + $r = q("SELECT `contact`.*, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid) @@ -194,6 +194,10 @@ function notifier_run($argv, $argc){ } } + $birthday = feed_birthday($owner['uid'],$owner['timezone']); + if($birthday) + $birthday = '' . xmlify($birthday) . ''; + $atom .= replace_macros($feed_template, array( '$version' => xmlify(FRIENDIKA_VERSION), '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ), @@ -208,7 +212,7 @@ function notifier_run($argv, $argc){ '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , - '$birthday' => '' + '$birthday' => $birthday )); if($cmd === 'mail') { From 118f1d7e0a517d5c2734c6c40d6e4c44c09d1cc5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 6 Feb 2011 23:04:10 -0800 Subject: [PATCH 04/12] don't show logout link on 'home' link if remote_user --- boot.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/boot.php b/boot.php index 4dcd6db660..87ea65b96c 100644 --- a/boot.php +++ b/boot.php @@ -762,7 +762,7 @@ function login($register = false) { $lostpass = t('Forgot your password?'); $lostlink = t('Password Reset'); - if(x($_SESSION,'authenticated')) { + if(local_user())) { $tpl = load_view_file("view/logout.tpl"); } else { @@ -772,12 +772,12 @@ function login($register = false) { $o = replace_macros($tpl,array( '$register_html' => $register_html, - '$classname' => $classname, - '$namelabel' => $namelabel, - '$passlabel' => $passlabel, - '$login' => $login, - '$lostpass' => $lostpass, - '$lostlink' => $lostlink + '$classname' => $classname, + '$namelabel' => $namelabel, + '$passlabel' => $passlabel, + '$login' => $login, + '$lostpass' => $lostpass, + '$lostlink' => $lostlink )); return $o; From 7dd56fa14c784a95695aece6dfe5cac145452ffe Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 6 Feb 2011 23:06:50 -0800 Subject: [PATCH 05/12] one less paren --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 87ea65b96c..509fe22878 100644 --- a/boot.php +++ b/boot.php @@ -762,7 +762,7 @@ function login($register = false) { $lostpass = t('Forgot your password?'); $lostlink = t('Password Reset'); - if(local_user())) { + if(local_user()) { $tpl = load_view_file("view/logout.tpl"); } else { From 18c5d1ff90dd364328032b3f0092ac5176ebc4c5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 7 Feb 2011 17:06:04 -0800 Subject: [PATCH 06/12] feed cleanup --- boot.php | 43 +++++++++++++++++++++++++- include/items.php | 72 ++++++++++++++------------------------------ include/notifier.php | 18 +++-------- mod/dfrn_poll.php | 2 +- 4 files changed, 70 insertions(+), 65 deletions(-) diff --git a/boot.php b/boot.php index 509fe22878..c8722caa7b 100644 --- a/boot.php +++ b/boot.php @@ -2365,4 +2365,45 @@ function feed_birthday($uid,$tz) { } return $birthday; -}} \ No newline at end of file +}} + +/** + * return atom link elements for all of our hubs + */ + +if(! function_exists('feed_hublinks')) { +function feed_hublinks() { + + $hub = get_config('system','huburl'); + + $hubxml = ''; + if(strlen($hub)) { + $hubs = explode(',', $hub); + if(count($hubs)) { + foreach($hubs as $h) { + $h = trim($h); + if(! strlen($h)) + continue; + $hubxml .= '' . "\n" ; + } + } + } + return $hubxml; +}} + +/* return atom link elements for salmon endpoints */ + +if(! function_exists('feed_salmonlinks')) { +function feed_salmonlinks($nick) { + + $a = get_app(); + + $salmon = '' . "\n" ; + + // old style links that status.net still needed as of 12/2010 + + $salmon .= ' ' . "\n" ; + $salmon .= ' ' . "\n" ; + return $salmon; +}} + diff --git a/include/items.php b/include/items.php index 5b99ca1714..9c29e65586 100644 --- a/include/items.php +++ b/include/items.php @@ -9,37 +9,27 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) // default permissions - anonymous user - $sql_extra = " - AND `allow_cid` = '' - AND `allow_gid` = '' - AND `deny_cid` = '' - AND `deny_gid` = '' - "; - - if(strlen($owner_nick) && ! intval($owner_nick)) { - $r = q("SELECT `uid`, `nickname`, `timezone` FROM `user` WHERE `nickname` = '%s' LIMIT 1", - dbesc($owner_nick) - ); - if(count($r)) { - $owner_id = $r[0]['uid']; - $owner_nick = $r[0]['nickname']; - $owner_tz = $r[0]['timezone']; - } - } - - $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", - intval($owner_id) - ); - if(count($r)) { - $owner = $r[0]; - $owner['nickname'] = $owner_nick; - } - else + if(! strlen($owner_nick)) killme(); - $birthday = feed_birthday($owner_id,$owner_tz); + $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; - if($dfrn_id && $dfrn_id != '*') { + $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone` + FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` + WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1", + dbesc($owner_nick) + ); + + if(! count($r)) + killme(); + + $owner = $r[0]; + $owner_id = $owner['user_uid']; + $owner_nick = $owner['nickname']; + + $birthday = feed_birthday($owner_id,$owner['timezone']); + + if(strlen($dfrn_id)) { $sql_extra = ''; switch($direction) { @@ -65,7 +55,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) ); if(! count($r)) - return false; + killme(); $contact = $r[0]; $groups = init_groups_visitor($contact['id']); @@ -119,7 +109,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) ); // Will check further below if this actually returned results. - // We will provide an empty feed in any case. + // We will provide an empty feed if that is the case. $items = $r; @@ -127,25 +117,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) $atom = ''; - $hub = get_config('system','huburl'); - - $hubxml = ''; - if(strlen($hub)) { - $hubs = explode(',', $hub); - if(count($hubs)) { - foreach($hubs as $h) { - $h = trim($h); - if(! strlen($h)) - continue; - $hubxml .= '' . "\n" ; - } - } - } - - $salmon = '' . "\n" ; - $salmon .= '' . "\n" ; - $salmon .= '' . "\n" ; + $hubxml = feed_hublinks(); + $salmon = feed_salmonlinks($owner_nick); $atom .= replace_macros($feed_template, array( '$version' => xmlify(FRIENDIKA_VERSION), @@ -178,7 +152,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) // public feeds get html, our own nodes use bbcode - if($dfrn_id === '*') { + if($dfrn_id === '') { $type = 'html'; } else { diff --git a/include/notifier.php b/include/notifier.php index ca0aa0df38..b6c4ca5712 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -179,23 +179,13 @@ function notifier_run($argv, $argc){ $mail_template = load_view_file('view/atom_mail.tpl'); $atom = ''; - $hubxml = ''; $slaps = array(); - if(strlen($hub)) { - $hubs = explode(',', $hub); - if(count($hubs)) { - foreach($hubs as $h) { - $h = trim($h); - if(! strlen($h)) - continue; - $hubxml .= '' . "\n" ; - } - } - } + $hubxml = feed_hublinks(); $birthday = feed_birthday($owner['uid'],$owner['timezone']); - if($birthday) + + if(strlen($birthday)) $birthday = '' . xmlify($birthday) . ''; $atom .= replace_macros($feed_template, array( @@ -398,7 +388,7 @@ function notifier_run($argv, $argc){ * */ - $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 150 : intval(get_config('system','maxdeliver'))); + $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 150 : intval(get_config('system','maxpubdeliver'))); /** * diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 85e7fc0afd..334e103079 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -28,7 +28,7 @@ function dfrn_poll_init(&$a) { if(($dfrn_id === '') && (! x($_POST,'dfrn_id')) && ($a->argc > 1)) { logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] ); header("Content-type: application/atom+xml"); - $o = get_feed_for($a, '*', $a->argv[1],$last_update); + $o = get_feed_for($a, '', $a->argv[1],$last_update); echo $o; killme(); } From 9f5d3000c74253a1284abda16006d74df84073fe Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 7 Feb 2011 21:16:39 -0800 Subject: [PATCH 07/12] don't change photo visibility if only album name was changed --- include/items.php | 6 +++--- mod/photos.php | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/items.php b/include/items.php index 9c29e65586..5d9eaaaf3f 100644 --- a/include/items.php +++ b/include/items.php @@ -859,12 +859,12 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { } -/* +/** * * consume_feed - process atom feed and update anything/everything we might need to update * - * $xml = the (atom) feed to consume - no RSS spoken here, it might partially work since simplepie - * handles both, but we don't claim it will work well, and are reasonably certain it won't. + * $xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds. + * * $importer = the contact_record (joined to user_record) of the local user who owns this relationship. * It is this person's stuff that is going to be updated. * $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity diff --git a/mod/photos.php b/mod/photos.php index 1a1ebaac19..9acde458df 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -268,6 +268,13 @@ foreach($_FILES AS $key => $val) { intval($page_owner_uid) ); } + + /* Don't make the item visible if the only change was the album name */ + + $visibility = 0; + if($p[0]['desc'] !== $desc || strlen($rawtags)) + $visibility = 1; + if(! $item_id) { // Create item container @@ -297,6 +304,7 @@ foreach($_FILES AS $key => $val) { $arr['deny_cid'] = $p[0]['deny_cid']; $arr['deny_gid'] = $p[0]['deny_gid']; $arr['last-child'] = 1; + $arr['visible'] = $visibility; $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' . '[/url]'; From d37ee1b399c7f03e301b9cb70ed32b95ebaa65b5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 7 Feb 2011 23:20:38 -0800 Subject: [PATCH 08/12] at least one server is giving CURL a second set of headers (and it isn't a 100 continue which we've already accounted for) --- boot.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boot.php b/boot.php index c8722caa7b..3714f588b4 100644 --- a/boot.php +++ b/boot.php @@ -626,7 +626,16 @@ function fetch_url($url,$binary = false, &$redirects = 0) { } } $a->set_curl_code($http_code); + $body = substr($s,strlen($header)+4); + + /* one more try to make sure there are no more headers */ + + if(strpos($body,'HTTP/') === 0) { + $header = substr($body,0,strpos($body,"\r\n\r\n")); + $body = substr($body,strlen($header)+4); + } + $a->set_curl_headers($header); curl_close($ch); @@ -690,6 +699,14 @@ function post_url($url,$params, $headers = null, &$redirects = 0) { } $a->set_curl_code($http_code); $body = substr($s,strlen($header)+4); + + /* one more try to make sure there are no more headers */ + + if(strpos($body,'HTTP/') === 0) { + $header = substr($body,0,strpos($body,"\r\n\r\n")); + $body = substr($body,strlen($header)+4); + } + $a->set_curl_headers($header); curl_close($ch); From e06cd399b7d90d0083ef70d0db8d284d22aa3f19 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 7 Feb 2011 23:28:41 -0800 Subject: [PATCH 09/12] close tag on favicon link missing --- view/de/head.tpl | 2 +- view/en/head.tpl | 2 +- view/fr/head.tpl | 2 +- view/it/head.tpl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/de/head.tpl b/view/de/head.tpl index 50dd9cab6b..c3ec3d2c9e 100644 --- a/view/de/head.tpl +++ b/view/de/head.tpl @@ -1,7 +1,7 @@ - +