diff --git a/boot.php b/boot.php index ace358faa7..749ef6e3f3 100755 --- a/boot.php +++ b/boot.php @@ -9,7 +9,7 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '2.3.1279' ); +define ( 'FRIENDICA_VERSION', '2.3.1280' ); define ( 'DFRN_PROTOCOL_VERSION', '2.22' ); define ( 'DB_UPDATE_VERSION', 1131 ); @@ -1209,7 +1209,7 @@ function current_theme(){ $a = get_app(); $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); - $theme_name = ((is_array($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); + $theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css')) return($theme_name); @@ -1335,7 +1335,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ array( 'label' => t('Profile'), 'url' => $url.'/?tab=profile', - 'sel' => (($tab=='profile')?'active':''), + 'sel' => ((isset($tab) && $tab=='profile')?'active':''), ), array( 'label' => t('Photos'), diff --git a/include/contact_widgets.php b/include/contact_widgets.php index caa0572d20..605a3eb78e 100755 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -75,4 +75,33 @@ function networks_widget($baseurl,$selected = '') { )); } +function fileas_widget($baseurl,$selected = '') { + $a = get_app(); + if(! local_user()) + return ''; + + $saved = get_pconfig(local_user(),'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = file_tag_decode($mtch[1]); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('fileas_widget.tpl'),array( + '$title' => t('File Selections'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} diff --git a/include/conversation.php b/include/conversation.php index 526c6ea005..a420e9923a 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -375,7 +375,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comments[$item['parent']] = 1; else $comments[$item['parent']] += 1; - } + } elseif(! x($comments,$item['parent'])) + $comments[$item['parent']] = 0; // avoid notices later on } // map all the like/dislike activities for each parent item @@ -571,6 +572,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'classundo' => (($item['starred']) ? "" : "hidden"), 'starred' => t('starred'), 'tagger' => t("add tag"), + 'filer' => t("file as"), 'classtagger' => "", ); } @@ -873,6 +875,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$vidurl' => t("Please enter a video link/URL:"), '$audurl' => t("Please enter an audio link/URL:"), '$term' => t('Tag term:'), + '$fileas' => t('File as:'), '$whereareu' => t('Where are you right now?'), '$title' => t('Enter a title for this item') )); @@ -915,7 +918,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $o .= replace_macros($tpl,array( '$return_path' => $a->cmd, '$action' => $a->get_baseurl().'/item', - '$share' => (($x['button']) ? $x['button'] : t('Share')), + '$share' => (x($x,'button') ? $x['button'] : t('Share')), '$upload' => t('Upload photo'), '$shortupload' => t('upload photo'), '$attach' => t('Attach file'), @@ -980,8 +983,8 @@ function conv_sort($arr,$order) { usort($parents,'sort_thr_commented'); if(count($parents)) - foreach($parents as $x) - $x['children'] = array(); + foreach($parents as $i=>$_x) + $parents[$i]['children'] = array(); foreach($arr as $x) { if($x['id'] != $x['parent']) { diff --git a/include/event.php b/include/event.php index 4a9a9a0041..29202baddf 100755 --- a/include/event.php +++ b/include/event.php @@ -163,7 +163,7 @@ function bbtoevent($s) { if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; $match = ''; - $ev['nofinish'] = (($ev['start'] && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0); + $ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0); return $ev; } diff --git a/include/items.php b/include/items.php index 1a7aa6c460..70c72ae165 100755 --- a/include/items.php +++ b/include/items.php @@ -682,7 +682,7 @@ function item_store($arr,$force_parent = false) { unset($arr['dsprsig']); } - if($arr['gravity']) + if(x($arr, 'gravity')) $arr['gravity'] = intval($arr['gravity']); elseif($arr['parent-uri'] === $arr['uri']) $arr['gravity'] = 0; @@ -742,6 +742,7 @@ function item_store($arr,$force_parent = false) { if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; + $parent_deleted = 0; $allow_cid = $arr['allow_cid']; $allow_gid = $arr['allow_gid']; $deny_cid = $arr['deny_cid']; @@ -800,6 +801,8 @@ function item_store($arr,$force_parent = false) { logger('item_store: item parent was not found - ignoring item'); return 0; } + + $parent_deleted = 0; } } diff --git a/include/oembed.php b/include/oembed.php index 5c3c595f57..52068efc76 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -62,7 +62,7 @@ function oembed_fetch_url($embedurl){ function oembed_format_object($j){ $embedurl = $j->embedurl; - $jhtml = oembed_iframe($j->embedurl,$j->width,$j->height ); + $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) ); $ret=""; switch ($j->type) { case "video": { diff --git a/include/security.php b/include/security.php index 8c536b656a..6ea515bffe 100755 --- a/include/security.php +++ b/include/security.php @@ -288,3 +288,49 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) } +/* + * Functions used to protect against Cross-Site Request Forgery + * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key. + * In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes; + * or if the security token is used for ajax-calls that happen several times), but only valid for a certain amout of time (3hours). + * The "typename" seperates the security tokens of different types of forms. This could be relevant in the following case: + * A security token is used to protekt a link from CSRF (e.g. the "delete this profile"-link). + * If the new page contains by any chance external elements, then the used security token is exposed by the referrer. + * Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are, + * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). + */ +function get_form_security_token($typename = "") { + $a = get_app(); + + $timestamp = time(); + $sec_hash = hash('whirlpool', $a->user["guid"] . $a->user["prvkey"] . session_id() . $timestamp . $typename); + + return $timestamp . "." . $sec_hash; +} + +function check_form_security_token($typename = "", $formname = 'form_security_token') { + if (!x($_REQUEST, $formname)) return false; + $hash = $_REQUEST[$formname]; + + $max_livetime = 10800; // 3 hours + + $a = get_app(); + + $x = explode(".", $hash); + if (time() > (IntVal($x[0]) + $max_livetime)) return false; + + $sec_hash = hash('whirlpool', $a->user["guid"] . $a->user["prvkey"] . session_id() . $x[0] . $typename); + + return ($sec_hash == $x[1]); +} + +function check_form_security_std_err_msg() { + return t('The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before subitting it.') . EOL; +} +function check_form_security_token_redirectOnErr($err_redirect, $typename = "", $formname = 'form_security_token') { + if (!check_form_security_token($typename, $formname)) { + $a = get_app(); + notice( check_form_security_std_err_msg() ); + goaway($a->get_baseurl() . $err_redirect ); + } +} diff --git a/include/template_processor.php b/include/template_processor.php index 8671587fc4..7f7b0b55bd 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -80,8 +80,13 @@ */ private function _replcb_for($args){ $m = array_map('trim', explode(" as ", $args[2])); - list($keyname, $varname) = explode("=>",$m[1]); - if (is_null($varname)) { $varname=$keyname; $keyname=""; } + $x = explode("=>",$m[1]); + if (count($x) == 1) { + $varname = $x[0]; + $keyname = ""; + } else { + list($keyname, $varname) = $x; + } if ($m[0]=="" || $varname=="" || is_null($varname)) die("template error: 'for ".$m[0]." as ".$varname."'") ; //$vals = $this->r[$m[0]]; $vals = $this->_get_var($m[0]); diff --git a/include/text.php b/include/text.php index 2663bdebaa..c44b4d1789 100644 --- a/include/text.php +++ b/include/text.php @@ -1294,7 +1294,7 @@ function file_tag_save_file($uid,$item,$file) { if(count($r)) { if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) q("update item set file = '%s' where id = %d and uid = %d limit 1", - dbesc($r[0]['file'] . '[' . $file_tag_encode($file) . ']'), + dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'), intval($item), intval($uid) ); diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index 44d1473a99..183f2bc68d 100755 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -44,61 +44,79 @@ _dfrn_html2bbcode : function(s) { s = tinymce.trim(s); - function rep(re, str) { - - //modify code to keep stuff intact within [code][/code] blocks - //Waitman Gobble NO WARRANTY - - - var o = new Array(); - var x = s.split("[code]"); - var i = 0; - - var si = ""; - si = x.shift(); - si = si.replace(re,str); - o.push(si); - - for (i = 0; i < x.length; i++) { - var no = new Array(); - var j = x.shift(); - var g = j.split("[/code]"); - no.push(g.shift()); - si = g.shift(); - si = si.replace(re,str); - no.push(si); - o.push(no.join("[/code]")); - } - - s = o.join("[code]"); - - }; - - - - - /* oembed */ - function _h2b_cb(match) { - function s_h2b(data) { - match = data; + function rep(re, str) { + + //modify code to keep stuff intact within [code][/code] blocks + //Waitman Gobble NO WARRANTY + + + var o = new Array(); + var x = s.split("[code]"); + var i = 0; + + var si = ""; + si = x.shift(); + si = si.replace(re,str); + o.push(si); + + for (i = 0; i < x.length; i++) { + var no = new Array(); + var j = x.shift(); + var g = j.split("[/code]"); + no.push(g.shift()); + si = g.shift(); + si = si.replace(re,str); + no.push(si); + o.push(no.join("[/code]")); + } + + s = o.join("[code]"); + + }; + + + + + /* oembed */ + function _h2b_cb(match) { + /* + function s_h2b(data) { + match = data; } $.ajax({ - type:"POST", + type:"POST", url: 'oembed/h2b', - data: {text: match}, - async: false, - success: s_h2b, - dataType: 'html' - }); - return match; - } + data: {text: match}, + async: false, + success: s_h2b, + dataType: 'html' + }); + */ + + var f, g, tof = [], tor = []; + var find_spanc = /]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:]*>(.*?)<\/span *>)*.*?)<\/span *>/ig; + while (f = find_spanc.exec(match)) { + var find_a = /]* rel=[\"']oembed[\"'][^>]*)>.*?<\/a *>/ig; + if (g = find_a.exec(f[1])) { + var find_href = /href=[\"']([^\"']*)[\"']/ig; + var m2 = find_href.exec(g[1]); + if (m2[1]) { + tof.push(f[0]); + tor.push("[EMBED]" + m2[1] + "[/EMBED]"); + } + } + } + for (var i = 0; i < tof.length; i++) match = match.replace(tof[i], tor[i]); + + return match; + } if (s.indexOf('class="oembed')>=0){ //alert("request oembed html2bbcode"); s = _h2b_cb(s); } - - /* /oembed */ - + + /* /oembed */ + // example: to [b] rep(/(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]"); @@ -111,16 +129,16 @@ rep(//gi,"[img=$3x$2]$1[/img]"); rep(//gi,"[img=$2x$3]$1[/img]"); rep(//gi,"[img]$1[/img]"); - - rep(/
    (.*?)<\/ul>/gi,"[list]$1[/list]"); - rep(/
      (.*?)<\/ul>/gi,"[list=]$1[/list]"); - rep(/
        (.*?)<\/ul>/gi,"[list=1]$1[/list]"); - rep(/
          (.*?)<\/ul>/gi,"[list=i]$1[/list]"); - rep(/
            (.*?)<\/ul>/gi,"[list=I]$1[/list]"); - rep(/
              (.*?)<\/ul>/gi,"[list=a]$1[/list]"); - rep(/
                (.*?)<\/ul>/gi,"[list=A]$1[/list]"); - rep(/
              • (.*?)<\/li>/gi,'[li]$1[/li]'); - + + rep(/
                  (.*?)<\/ul>/gi,"[list]$1[/list]"); + rep(/
                    (.*?)<\/ul>/gi,"[list=]$1[/list]"); + rep(/
                      (.*?)<\/ul>/gi,"[list=1]$1[/list]"); + rep(/
                        (.*?)<\/ul>/gi,"[list=i]$1[/list]"); + rep(/
                          (.*?)<\/ul>/gi,"[list=I]$1[/list]"); + rep(/
                            (.*?)<\/ul>/gi,"[list=a]$1[/list]"); + rep(/
                              (.*?)<\/ul>/gi,"[list=A]$1[/list]"); + rep(/
                            • (.*?)<\/li>/gi,'[li]$1[/li]'); + rep(/(.*?)<\/code>/gi,"[code]$1[/code]"); rep(/<\/(strong|b)>/gi,"[/b]"); rep(/<(strong|b)>/gi,"[b]"); @@ -149,42 +167,42 @@ // BBCode -> HTML from DFRN dialect _dfrn_bbcode2html : function(s) { s = tinymce.trim(s); - - - function rep(re, str) { - - //modify code to keep stuff intact within [code][/code] blocks - //Waitman Gobble NO WARRANTY - - - var o = new Array(); - var x = s.split("[code]"); - var i = 0; - - var si = ""; - si = x.shift(); - si = si.replace(re,str); - o.push(si); - - for (i = 0; i < x.length; i++) { - var no = new Array(); - var j = x.shift(); - var g = j.split("[/code]"); - no.push(g.shift()); - si = g.shift(); - si = si.replace(re,str); - no.push(si); - o.push(no.join("[/code]")); - } - - s = o.join("[code]"); - - }; - - - - - + + + function rep(re, str) { + + //modify code to keep stuff intact within [code][/code] blocks + //Waitman Gobble NO WARRANTY + + + var o = new Array(); + var x = s.split("[code]"); + var i = 0; + + var si = ""; + si = x.shift(); + si = si.replace(re,str); + o.push(si); + + for (i = 0; i < x.length; i++) { + var no = new Array(); + var j = x.shift(); + var g = j.split("[/code]"); + no.push(g.shift()); + si = g.shift(); + si = si.replace(re,str); + no.push(si); + o.push(no.join("[/code]")); + } + + s = o.join("[code]"); + + }; + + + + + // example: [b] to rep(/\n/gi,"
                              "); rep(/\[b\]/gi,""); @@ -193,43 +211,43 @@ rep(/\[\/i\]/gi,""); rep(/\[u\]/gi,""); rep(/\[\/u\]/gi,""); - rep(/\[hr\]/gi,"
                              "); + rep(/\[hr\]/gi,"
                              "); rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"$2"); rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2"); rep(/\[url\](.*?)\[\/url\]/gi,"
                              $1"); rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); rep(/\[img\](.*?)\[\/img\]/gi,""); - - rep(/\[list\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[list=\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[list=1\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[list=i\](.*?)\[\/list\]/gi,'
                                $1
                              '); - rep(/\[list=I\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[list=a\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[list=A\](.*?)\[\/list\]/gi, '
                                $1
                              '); - rep(/\[li\](.*?)\[\/li\]/gi, '
                            • $1
                            • '); + + rep(/\[list\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[list=\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[list=1\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[list=i\](.*?)\[\/list\]/gi,'
                                $1
                              '); + rep(/\[list=I\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[list=a\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[list=A\](.*?)\[\/list\]/gi, '
                                $1
                              '); + rep(/\[li\](.*?)\[\/li\]/gi, '
                            • $1
                            • '); rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2"); rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"$2"); rep(/\[code\](.*?)\[\/code\]/gi,"$1"); rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"
                              $1
                              "); - - /* oembed */ - function _b2h_cb(match, url) { - url = bin2hex(url); - function s_b2h(data) { - match = data; - } - $.ajax({ - url: 'oembed/b2h?url=' + url, - async: false, - success: s_b2h, - dataType: 'html' - }); - return match; - } - s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb); - - /* /oembed */ + + /* oembed */ + function _b2h_cb(match, url) { + url = bin2hex(url); + function s_b2h(data) { + match = data; + } + $.ajax({ + url: 'oembed/b2h?url=' + url, + async: false, + success: s_b2h, + dataType: 'html' + }); + return match; + } + s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb); + + /* /oembed */ return s; } diff --git a/mod/contacts.php b/mod/contacts.php index 001bf12af4..38ca570ddf 100755 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -445,7 +445,7 @@ function contacts_content(&$a) { $r = q("SELECT COUNT(*) AS `total` FROM `contact` - WHERE `uid` = %d AND `pending` = 0 $sql_extra $sql_extra2 ", + WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); if(count($r)) { $a->set_pager_total($r[0]['total']); @@ -454,7 +454,7 @@ function contacts_content(&$a) { - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) @@ -465,8 +465,6 @@ function contacts_content(&$a) { if(count($r)) { foreach($r as $rr) { - if($rr['self']) - continue; switch($rr['rel']) { case CONTACT_IS_FRIEND: diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index bc159137df..4acb5c9bb5 100755 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -43,7 +43,7 @@ function dfrn_request_post(&$a) { return; - if($_POST['cancel']) { + if(x($_POST, 'cancel')) { goaway(z_root()); } @@ -666,7 +666,11 @@ function dfrn_request_content(&$a) { $page_desc = sprintf( t('Diaspora members: Please do not use this form. Instead, enter "%s" into your Diaspora search bar.'), $target_addr) . EOL . EOL; - $page_desc .= t("Please enter your 'Identity Address' from one of the following supported social networks:"); + $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); + + $emailnet = t("Connect as an email follower \x28Coming soon\x29"); + + $invite_desc = t('If you are not yet a member of the free social web, follow this link to find a public Friendica site and join us today.'); $o .= replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), @@ -682,6 +686,8 @@ function dfrn_request_content(&$a) { '$diaspora' => t('Diaspora'), '$diasnote' => t('- please share from your own site as noted above'), '$your_address' => t('Your Identity Address:'), + '$invite_desc' => $invite_desc, + '$emailnet' => $emailnet, '$submit' => t('Submit Request'), '$cancel' => t('Cancel'), '$nickname' => $a->argv[1], diff --git a/mod/filer.php b/mod/filer.php new file mode 100755 index 0000000000..a9e2135361 --- /dev/null +++ b/mod/filer.php @@ -0,0 +1,23 @@ +argc > 1) ? notags(trim($a->argv[1])) : 0); + + logger('filer: tag ' . $term . ' item ' . $item_id); + + if($item_id && strlen($term)) + file_tag_save_file(local_user(),$item_id,$term); + + killme(); +} diff --git a/mod/message.php b/mod/message.php index 57d45ee3c7..65f692f3d5 100755 --- a/mod/message.php +++ b/mod/message.php @@ -192,9 +192,9 @@ function message_content(&$a) { $a->set_pager_total($r[0]['total']); $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, - `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` + `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network` FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `created` DESC LIMIT %d , %d ", + WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", intval(local_user()), dbesc($myprofile), intval($a->pager['start']), diff --git a/mod/network.php b/mod/network.php index 861b5ab73d..4f58fc4fbc 100755 --- a/mod/network.php +++ b/mod/network.php @@ -44,8 +44,9 @@ function network_init(&$a) { } $a->page['aside'] .= group_side('network','network',true,$group_id); - $a->page['aside'] .= networks_widget($a->get_baseurl() . '/network',(($_GET['nets']) ? $_GET['nets'] : '')); + $a->page['aside'] .= networks_widget($a->get_baseurl() . '/network',(x($_GET, 'nets') ? $_GET['nets'] : '')); $a->page['aside'] .= saved_searches($search); + $a->page['aside'] .= fileas_widget($a->get_baseurl() . '/network',(x($_GET, 'file') ? $_GET['file'] : '')); } @@ -132,15 +133,15 @@ function network_content(&$a, $update = 0) { $starred_active = 'active'; } - if($_GET['bmark']) { + if(x($_GET,'bmark')) { $bookmarked_active = 'active'; } - if($_GET['conv']) { + if(x($_GET,'conv')) { $conv_active = 'active'; } - if($_GET['spam']) { + if(x($_GET,'spam')) { $spam_active = 'active'; } @@ -248,7 +249,7 @@ function network_content(&$a, $update = 0) { $def_acl = array('allow_cid' => '<' . intval($cid) . '>'); if(! $update) { - if(group) { + if($group) { if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { notice( sprintf( tt('Warning: This group contains %s member from an insecure network.', 'Warning: This group contains %s members from an insecure network.', @@ -498,7 +499,9 @@ function network_content(&$a, $update = 0) { $items = conv_sort($items,$ordering); - } + } else { + $items = array(); + } } diff --git a/mod/parse_url.php b/mod/parse_url.php index e0b378f685..27dac4d5d3 100755 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -188,7 +188,7 @@ function parse_url_content(&$a) { if(! $text) { logger('parsing meta'); - $items = $domhead->getElementsByTagName('meta'); + $items = (isset($domhead) && is_object($domhead) ? $domhead->getElementsByTagName('meta') : null); if($items) { foreach($items as $item) { $property = $item->getAttribute('property'); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index e3dbdaf39c..d1fd08eba6 100755 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -15,11 +15,13 @@ function profile_photo_init(&$a) { function profile_photo_post(&$a) { - if(! local_user()) { - notice ( t('Permission denied.') . EOL ); - return; - } - + if(! local_user()) { + notice ( t('Permission denied.') . EOL ); + return; + } + + check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo'); + if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) { // phase 2 - we have finished cropping @@ -148,7 +150,9 @@ function profile_photo_content(&$a) { notice( t('Permission denied.') . EOL ); return; }; - + + check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo'); + $resource_id = $a->argv[2]; //die(":".local_user()); $r=q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC", @@ -203,6 +207,7 @@ function profile_photo_content(&$a) { '$lbl_upfile' => t('Upload File:'), '$title' => t('Upload Profile Photo'), '$submit' => t('Upload'), + '$form_security_token' => get_form_security_token("profile_photo"), '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '') )); @@ -218,6 +223,7 @@ function profile_photo_content(&$a) { '$image_url' => $a->get_baseurl() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), + '$form_security_token' => get_form_security_token("profile_photo"), '$done' => t('Done Editing') )); return $o; diff --git a/mod/profiles.php b/mod/profiles.php index ccd7d54741..b307a2d43b 100755 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -21,6 +21,9 @@ function profiles_post(&$a) { notice( t('Profile not found.') . EOL); return; } + + check_form_security_token_redirectOnErr('/profiles', 'profile_edit'); + $is_default = (($orig[0]['is-default']) ? 1 : 0); $profile_name = notags(trim($_POST['profile_name'])); @@ -240,6 +243,8 @@ function profiles_content(&$a) { goaway($a->get_baseurl() . '/profiles'); return; // NOTREACHED } + + check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't'); // move every contact using this profile as their default to the user default @@ -264,6 +269,8 @@ function profiles_content(&$a) { if(($a->argc > 1) && ($a->argv[1] === 'new')) { + + check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user())); @@ -291,10 +298,13 @@ function profiles_content(&$a) { info( t('New profile created.') . EOL); if(count($r3) == 1) goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']); + goaway($a->get_baseurl() . '/profiles'); - } + } if(($a->argc > 2) && ($a->argv[1] === 'clone')) { + + check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user())); @@ -330,9 +340,11 @@ function profiles_content(&$a) { info( t('New profile created.') . EOL); if(count($r3) == 1) goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']); - goaway($a->get_baseurl() . '/profiles'); - return; // NOTREACHED - } + + goaway($a->get_baseurl() . '/profiles'); + + return; // NOTREACHED + } if(($a->argc > 1) && (intval($a->argv[1]))) { @@ -371,6 +383,9 @@ function profiles_content(&$a) { $is_default = (($r[0]['is-default']) ? 1 : 0); $tpl = get_markup_template("profile_edit.tpl"); $o .= replace_macros($tpl,array( + '$form_security_token' => get_form_security_token("profile_edit"), + '$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"), + '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$viewprof' => t('View this profile'), @@ -460,7 +475,8 @@ function profiles_content(&$a) { $o .= replace_macros($tpl_header,array( '$header' => t('Edit/Manage Profiles'), '$chg_photo' => t('Change profile photo'), - '$cr_new' => t('Create New Profile') + '$cr_new' => t('Create New Profile'), + '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new") )); diff --git a/mod/settings.php b/mod/settings.php index 2ef582fdfe..f42fdb3973 100755 --- a/mod/settings.php +++ b/mod/settings.php @@ -53,6 +53,8 @@ function settings_post(&$a) { $old_page_flags = $a->user['page-flags']; if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){ + check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth'); + $key = $_POST['remove']; q("DELETE FROM tokens WHERE id='%s' AND uid=%d", dbesc($key), @@ -63,6 +65,8 @@ function settings_post(&$a) { if(($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) { + check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth'); + $name = ((x($_POST,'name')) ? $_POST['name'] : ''); $key = ((x($_POST,'key')) ? $_POST['key'] : ''); $secret = ((x($_POST,'secret')) ? $_POST['secret'] : ''); @@ -105,13 +109,18 @@ function settings_post(&$a) { } if(($a->argc > 1) && ($a->argv[1] == 'addon')) { + check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon'); + call_hooks('plugin_settings_post', $_POST); return; } if(($a->argc > 1) && ($a->argv[1] == 'connectors')) { - - if(x($_POST['imap-submit'])) { + + check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors'); + + if(x($_POST, 'imap-submit')) { + $mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : ''); $mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : ''); $mail_ssl = ((x($_POST,'mail_ssl')) ? strtolower(trim($_POST['mail_ssl'])) : ''); @@ -185,7 +194,8 @@ function settings_post(&$a) { return; } - + check_form_security_token_redirectOnErr('/settings', 'settings'); + call_hooks('settings_post', $_POST); if((x($_POST,'npassword')) || (x($_POST,'confirm'))) { @@ -460,6 +470,7 @@ function settings_content(&$a) { if(($a->argc > 2) && ($a->argv[2] === 'add')) { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_oauth"), '$tabs' => $tabs, '$title' => t('Add application'), '$submit' => t('Submit'), @@ -486,6 +497,7 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_oauth"), '$tabs' => $tabs, '$title' => t('Add application'), '$submit' => t('Update'), @@ -500,6 +512,8 @@ function settings_content(&$a) { } if(($a->argc > 3) && ($a->argv[2] === 'delete')) { + check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't'); + $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc($a->argv[3]), local_user()); @@ -518,6 +532,7 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_oauth.tpl"); $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => $a->get_baseurl(), '$title' => t('Connected Apps'), '$add' => t('Add application'), @@ -544,6 +559,7 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_addons.tpl"); $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_addons"), '$title' => t('Plugin Settings'), '$tabs' => $tabs, '$settings_addons' => $settings_addons @@ -586,28 +602,28 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_connectors.tpl"); $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_connectors"), + '$title' => t('Connector Settings'), '$tabs' => $tabs, - '$diasp_enabled' => $diasp_enabled, - '$ostat_enabled' => $ostat_enabled, - - '$h_imap' => t('Email/Mailbox Setup'), - '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), - '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk,''), - '$mail_disabled' => (($mail_disabled) ? t('Email access is disabled on this site.') : ''), - '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''), - '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''), - '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')), - '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''), - '$mail_pass' => array('mail_pass', t('Email password:'), '', ''), - '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), '', 'Optional'), - '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''), - '$mail_action' => array('mail_action', t('Action after import:'), $mail_action, '', array(0=>t('None'), 1=>t('Delete'), 2=>t('Mark as seen'), 3=>t('Move to folder'))), - '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''), - '$submit' => t('Submit'), - + '$diasp_enabled' => $diasp_enabled, + '$ostat_enabled' => $ostat_enabled, + '$h_imap' => t('Email/Mailbox Setup'), + '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), + '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk,''), + '$mail_disabled' => (($mail_disabled) ? t('Email access is disabled on this site.') : ''), + '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''), + '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''), + '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')), + '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''), + '$mail_pass' => array('mail_pass', t('Email password:'), '', ''), + '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), '', 'Optional'), + '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''), + '$mail_action' => array('mail_action', t('Action after import:'), $mail_action, '', array(0=>t('None'), 1=>t('Delete'), 2=>t('Mark as seen'), 3=>t('Move to folder'))), + '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''), + '$submit' => t('Submit'), '$settings_connectors' => $settings_connectors )); @@ -805,6 +821,7 @@ function settings_content(&$a) { '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(), '$uid' => local_user(), + '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, diff --git a/view/auto_request.tpl b/view/auto_request.tpl index 204fcf2475..2958397c92 100755 --- a/view/auto_request.tpl +++ b/view/auto_request.tpl @@ -7,8 +7,15 @@ $page_desc
                            • $friendica
                            • $diaspora $diasnote
                            • $statusnet
                            • +
                            • $emailnet

                            +

                            +$invite_desc +

                            +

                            +$desc +

                            diff --git a/view/cropbody.tpl b/view/cropbody.tpl index c9c0f84de1..b484d15bf7 100755 --- a/view/cropbody.tpl +++ b/view/cropbody.tpl @@ -40,6 +40,7 @@ $desc + diff --git a/view/dfrn_request.tpl b/view/dfrn_request.tpl index cd98a4daab..d8aa8b1818 100755 --- a/view/dfrn_request.tpl +++ b/view/dfrn_request.tpl @@ -7,7 +7,11 @@ $page_desc
                          • $friendica
                          • $diaspora $diasnote
                          • $statusnet
                          • +
                          • $emailnet
                          +$invite_desc +

                          +

                          $desc

                          diff --git a/view/fileas_widget.tpl b/view/fileas_widget.tpl new file mode 100755 index 0000000000..54fba7435f --- /dev/null +++ b/view/fileas_widget.tpl @@ -0,0 +1,12 @@ +
                          +

                          $title

                          +
                          $desc
                          + + + +
                          diff --git a/view/jot-header.tpl b/view/jot-header.tpl index d6b172b6af..88df73494f 100755 --- a/view/jot-header.tpl +++ b/view/jot-header.tpl @@ -262,6 +262,18 @@ function enableOnUser(){ } } + function itemFiler(id) { + reply = prompt("$fileas"); + if(reply && reply.length) { + commentBusy = true; + $('body').css('cursor', 'wait'); + $.get('filer/' + id + '?term=' + reply); + if(timer) clearTimeout(timer); + timer = setTimeout(NavUpdate,3000); + liking = 1; + } + } + function jotClearLocation() { $('#jot-coord').val(''); $('#profile-nolocation-wrapper').hide(); diff --git a/view/profile_edit.tpl b/view/profile_edit.tpl index 8dab726492..e5c7162d03 100755 --- a/view/profile_edit.tpl +++ b/view/profile_edit.tpl @@ -5,9 +5,9 @@ $default @@ -17,6 +17,7 @@ $default
                          +
                          diff --git a/view/profile_listing_header.tpl b/view/profile_listing_header.tpl index 09e4fc9b24..61a2737929 100755 --- a/view/profile_listing_header.tpl +++ b/view/profile_listing_header.tpl @@ -3,6 +3,6 @@ $chg_photo

                          diff --git a/view/profile_photo.tpl b/view/profile_photo.tpl index f258b5b86d..0b3a1cac17 100755 --- a/view/profile_photo.tpl +++ b/view/profile_photo.tpl @@ -1,6 +1,7 @@

                          $title

                          +
                          diff --git a/view/settings.tpl b/view/settings.tpl index 46c737b23a..25479b5bff 100755 --- a/view/settings.tpl +++ b/view/settings.tpl @@ -5,7 +5,7 @@ $tabs $nickname_block - +

                          $h_pass

                          diff --git a/view/settings_addons.tpl b/view/settings_addons.tpl index 2cbfd17e92..28fca53620 100755 --- a/view/settings_addons.tpl +++ b/view/settings_addons.tpl @@ -4,6 +4,7 @@ $tabs + $settings_addons diff --git a/view/settings_connectors.tpl b/view/settings_connectors.tpl index 9493c8bf77..43c0346bba 100755 --- a/view/settings_connectors.tpl +++ b/view/settings_connectors.tpl @@ -6,6 +6,7 @@ $tabs
                          $ostat_enabled
                          + $settings_connectors diff --git a/view/settings_oauth.tpl b/view/settings_oauth.tpl index 0de0dbe98a..da1398ab96 100755 --- a/view/settings_oauth.tpl +++ b/view/settings_oauth.tpl @@ -4,7 +4,8 @@ $tabs - + + {{ endfor }} diff --git a/view/settings_oauth_edit.tpl b/view/settings_oauth_edit.tpl index 98b7457aa4..d293413867 100755 --- a/view/settings_oauth_edit.tpl +++ b/view/settings_oauth_edit.tpl @@ -3,6 +3,8 @@ $tabs

                          $title

                          + + {{ inc field_input.tpl with $field=$name }}{{ endinc }} {{ inc field_input.tpl with $field=$key }}{{ endinc }} {{ inc field_input.tpl with $field=$secret }}{{ endinc }} diff --git a/view/theme/duepuntozero/file.gif b/view/theme/duepuntozero/file.gif new file mode 100644 index 0000000000..7885b998d5 Binary files /dev/null and b/view/theme/duepuntozero/file.gif differ diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index acd97eb941..10ddb00909 100755 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -309,7 +309,7 @@ div.wall-item-content-wrapper.shiny { margin-bottom: 10px; } -.group-selected, .nets-selected { +.group-selected, .nets-selected, .fileas-selected { padding: 3px; -moz-border-radius: 3px; border-radius: 3px; @@ -1024,6 +1024,10 @@ input#dfrn-url { float: left; } +.filer-item { + margin-left: 10px; + float: left; +} .wall-item-links-wrapper { float: left; @@ -1864,11 +1868,11 @@ a.mail-list-link { margin-top: 10px; } -.nets-ul { +.nets-ul, .fileas-ul { list-style-type: none; } -.nets-ul li { +.nets-ul li, .fileas-ul li { margin-top: 10px; } @@ -1879,6 +1883,14 @@ a.mail-list-link { margin-left: 42px; } +.fileas-link { + margin-left: 24px; +} + +.fileas-all { + margin-left: 0px; +} + #search-save { margin-left: 5px; } @@ -2902,6 +2914,11 @@ aside input[type='text'] { .tagged { background-position: -48px -48px; } +.filer-icon { + display: block; width: 16px; height: 16px; + background-image: url('file.gif'); +} + .icon.dim { opacity: 0.3;filter:alpha(opacity=30); } .attachtype { diff --git a/view/theme/duepuntozero/wall_item.tpl b/view/theme/duepuntozero/wall_item.tpl index 51e36b6f4f..2c88fc598e 100755 --- a/view/theme/duepuntozero/wall_item.tpl +++ b/view/theme/duepuntozero/wall_item.tpl @@ -56,6 +56,7 @@ {{ if $item.star }} + {{ endif }}
                          diff --git a/view/theme/greenzero/file.gif b/view/theme/greenzero/file.gif new file mode 100644 index 0000000000..e388a13c0b Binary files /dev/null and b/view/theme/greenzero/file.gif differ