aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOlivier Migeot <olivier@migeot.org>2011-10-04 11:45:57 +0200
committerOlivier Migeot <olivier@migeot.org>2011-10-04 11:45:57 +0200
commit273594af62c960b5a52da5ec1cf6d6bd450415ba (patch)
tree5f79914d28c343f7642ecb13b99f9e0e3f5090a7 /include
parent1548449586f17c0ef9bfab0ffb16f2a495fc6082 (diff)
parentdfd5cc57c2134067dc6229b8583b5e808f160004 (diff)
downloadvolse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.tar.gz
volse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.tar.bz2
volse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php57
-rw-r--r--include/EmailNotification.php7
-rw-r--r--include/Scrape.php56
-rw-r--r--include/acl.js240
-rw-r--r--include/ajaxupload.js695
-rw-r--r--include/api.php145
-rw-r--r--include/auth.php8
-rw-r--r--include/bb2diaspora.php81
-rw-r--r--include/bbcode.php104
-rw-r--r--include/contact_selectors.php15
-rw-r--r--include/conversation.php556
-rw-r--r--include/country.js438
-rw-r--r--include/crypto.php68
-rw-r--r--include/delivery.php476
-rw-r--r--include/diaspora.php513
-rw-r--r--include/email.php35
-rw-r--r--include/group.php34
-rw-r--r--include/html2bbcode.php8
-rw-r--r--include/items.php134
-rw-r--r--include/jquery.htmlstream.js157
-rw-r--r--include/jquery.js154
-rw-r--r--include/main.js406
-rw-r--r--include/nav.php45
-rw-r--r--include/network.php122
-rw-r--r--include/notifier.php222
-rw-r--r--include/pgettext.php23
-rw-r--r--include/poller.php34
-rw-r--r--include/profile_advanced.php76
-rw-r--r--include/queue.php66
-rw-r--r--include/salmon.php16
-rw-r--r--include/template_processor.php42
-rw-r--r--include/text.php141
-rw-r--r--include/zotfns.php195
33 files changed, 2219 insertions, 3150 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 4ca77d065..45920041e 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -85,3 +85,60 @@ function unmark_for_death($contact) {
);
}}
+if(! function_exists('contact_photo_menu')){
+function contact_photo_menu($contact) {
+
+ $a = get_app();
+
+ $contact_url="";
+ $pm_url="";
+ $status_link="";
+ $photos_link="";
+ $posts_link="";
+
+ $sparkle = false;
+ if($contact['network'] === NETWORK_DFRN) {
+ $sparkle = true;
+ $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+ }
+ else
+ $profile_link = $contact['url'];
+
+ if($profile_link === 'mailbox')
+ $profile_link = '';
+
+ if($sparkle) {
+ $status_link = $profile_link . "?url=status";
+ $photos_link = $profile_link . "?url=photos";
+ $profile_link = $profile_link . "?url=profile";
+ $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+ }
+
+ $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
+ $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
+
+ $menu = Array(
+ t("View status") => $status_link,
+ t("View profile") => $profile_link,
+ t("View photos") => $photos_link,
+ t("View recent") => $posts_link,
+ t("Edit contact") => $contact_url,
+ t("Send PM") => $pm_url,
+ );
+
+
+ $args = array('contact' => $contact, 'menu' => $menu);
+
+ call_hooks('contact_photo_menu', $args);
+
+ $o = "";
+ foreach($menu as $k=>$v){
+ if ($v!="") {
+ if(($k !== t("View recent")) && ($k !== t("Send PM")))
+ $o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
+ else
+ $o .= "<li><a href=\"$v\">$k</a></li>\n";
+ }
+ }
+ return $o;
+}}
diff --git a/include/EmailNotification.php b/include/EmailNotification.php
index 78912c0b9..8861e8f5d 100644
--- a/include/EmailNotification.php
+++ b/include/EmailNotification.php
@@ -1,4 +1,7 @@
<?php
+
+require_once('include/email.php');
+
class EmailNotification {
/**
* Send a multipart/alternative message with Text and HTML versions
@@ -12,6 +15,10 @@ class EmailNotification {
* @param textVersion text only version of the message
*/
static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
+
+ $fromName = email_header_encode($fromName,'UTF-8');
+ $messageSubject = email_header_encode($messageSubject,'UTF-8');
+
// generate a mime boundary
$mimeBoundary =rand(0,9)."-"
diff --git a/include/Scrape.php b/include/Scrape.php
index cc46af644..642b8e624 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -249,20 +249,6 @@ function scrape_feed($url) {
return $ret;
- $items = $dom->getElementsByTagName('img');
-
- // get img elements (twitter)
-
- if($items) {
- foreach($items as $item) {
- $x = $item->getAttribute('id');
- if($x === 'profile-image') {
- $ret['photo'] = $item->getAttribute('src');
- }
- }
- }
-
-
$head = $dom->getElementsByTagName('base');
if($head) {
foreach($head as $head0) {
@@ -332,10 +318,12 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if(! $url)
return $result;
+ $network = null;
$diaspora = false;
$diaspora_base = '';
$diaspora_guid = '';
$diaspora_key = '';
+ $has_lrdd = false;
$email_conversant = false;
$twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
@@ -352,6 +340,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$links = lrdd($url);
if(count($links)) {
+ $has_lrdd = true;
+
logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA);
foreach($links as $link) {
if($link['@attributes']['rel'] === NAMESPACE_ZOT)
@@ -426,7 +416,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$addr = $orig_url;
$network = NETWORK_MAIL;
$name = substr($url,0,strpos($url,'@'));
- $profile = 'http://' . substr($url,strpos($url,'@')+1);
+ $phost = substr($url,strpos($url,'@')+1);
+ $profile = 'http://' . $phost;
// fix nick character range
$vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url));
$notify = 'smtp ' . random_string();
@@ -437,8 +428,15 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$adr = imap_rfc822_parse_adrlist($x->from,'');
elseif(stristr($x->to,$orig_url))
$adr = imap_rfc822_parse_adrlist($x->to,'');
- if(isset($adr) && strlen($adr[0]->personal))
- $vcard['fn'] = notags($adr[0]->personal);
+ if(isset($adr)) {
+ foreach($adr as $feadr) {
+ if((strcasecmp($feadr->mailbox,$name) == 0)
+ &&(strcasecmp($feadr->host,$phost) == 0)
+ && (strlen($feadr->personal))) {
+ $vcard['fn'] = notags($feadr->personal);
+ }
+ }
+ }
}
imap_close($mbox);
}
@@ -467,7 +465,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if(strlen($dfrn)) {
- $ret = scrape_dfrn($dfrn);
+ $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn);
if(is_array($ret) && x($ret,'dfrn-request')) {
$network = NETWORK_DFRN;
$request = $ret['dfrn-request'];
@@ -484,8 +482,10 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if($diaspora && $diaspora_base && $diaspora_guid) {
- if($mode == PROBE_DIASPORA || ! $notify)
+ if($mode == PROBE_DIASPORA || ! $notify) {
$notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
+ $batch = $diaspora_base . 'receive/public' ;
+ }
if(strpos($url,'@'))
$addr = str_replace('acct:', '', $url);
}
@@ -493,7 +493,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
if($diaspora)
$network = NETWORK_DIASPORA;
- else
+ elseif($has_lrdd)
$network = NETWORK_OSTATUS;
$priority = 0;
@@ -520,6 +520,9 @@ function probe_url($url, $mode = PROBE_NORMAL) {
else
$poll = $tapi . '?screen_name=' . $tid;
$profile = 'http://twitter.com/#!/' . $tid;
+ $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid;
+ $vcard['nick'] = $tid;
+ $vcard['fn'] = $tid . '@twitter';
}
if(! x($vcard,'fn'))
@@ -530,7 +533,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if($twitter || ! $poll)
$check_feed = true;
- if((! isset($vcard)) || (! $profile))
+ if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile))
$check_feed = true;
if(($at_addr) && (! count($links)))
$check_feed = false;
@@ -637,7 +640,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
}
if(! $network)
- $network = 'feed';
+ $network = NETWORK_FEED;
if(! $priority)
$priority = 2;
}
@@ -651,14 +654,19 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if(! $profile)
$profile = $url;
- $vcard['fn'] = notags($vcard['fn']);
- $vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
+ // No human could be associated with this link, use the URL as the contact name
+ if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn')))
+ $vcard['fn'] = $url;
+ $vcard['fn'] = notags($vcard['fn']);
+ $vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
+
$result['name'] = $vcard['fn'];
$result['nick'] = $vcard['nick'];
$result['url'] = $profile;
$result['addr'] = $addr;
+ $result['batch'] = $batch;
$result['notify'] = $notify;
$result['poll'] = $poll;
$result['request'] = $request;
diff --git a/include/acl.js b/include/acl.js
deleted file mode 100644
index 82b631ee9..000000000
--- a/include/acl.js
+++ /dev/null
@@ -1,240 +0,0 @@
-function ACL(backend_url, preset){
- that = this;
-
- that.url = backend_url;
-
- that.kp_timer = null;
-
- if (preset==undefined) preset = [];
- that.allow_cid = (preset[0] || []);
- that.allow_gid = (preset[1] || []);
- that.deny_cid = (preset[2] || []);
- that.deny_gid = (preset[3] || []);
- that.group_uids = [];
- that.nw = 4; //items per row. should be calulated from #acl-list.width
-
- that.list_content = $("#acl-list-content");
- that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html());
- that.showall = $("#acl-showall");
-
- if (preset.length==0) that.showall.addClass("selected");
-
- /*events*/
- that.showall.click(that.on_showall);
- $(".acl-button-show").live('click', that.on_button_show);
- $(".acl-button-hide").live('click', that.on_button_hide);
- $("#acl-search").keypress(that.on_search);
- $("#acl-wrapper").parents("form").submit(that.on_submit);
-
- /* startup! */
- that.get(0,100);
-}
-
-ACL.prototype.on_submit = function(){
- aclfileds = $("#acl-fields").html("");
- $(that.allow_gid).each(function(i,v){
- aclfileds.append("<input type='hidden' name='group_allow[]' value='"+v+"'>");
- });
- $(that.allow_cid).each(function(i,v){
- aclfileds.append("<input type='hidden' name='contact_allow[]' value='"+v+"'>");
- });
- $(that.deny_gid).each(function(i,v){
- aclfileds.append("<input type='hidden' name='group_deny[]' value='"+v+"'>");
- });
- $(that.deny_cid).each(function(i,v){
- aclfileds.append("<input type='hidden' name='contact_deny[]' value='"+v+"'>");
- });
-}
-
-ACL.prototype.search = function(){
- var srcstr = $("#acl-search").val();
- that.list_content.html("");
- that.get(0,100, srcstr);
-}
-
-ACL.prototype.on_search = function(event){
- if (that.kp_timer) clearTimeout(that.kp_timer);
- that.kp_timer = setTimeout( that.search, 1000);
-}
-
-ACL.prototype.on_showall = function(event){
- event.stopPropagation();
- if (that.showall.hasClass("selected")){
- return false;
- }
- that.showall.addClass("selected");
-
- that.allow_cid = [];
- that.allow_gid = [];
- that.deny_cid = [];
- that.deny_gid = [];
-
- that.updateview();
-
- return false;
-}
-
-ACL.prototype.on_button_show = function(event){
- event.stopPropagation();
-
- /*that.showall.removeClass("selected");
- $(this).siblings(".acl-button-hide").removeClass("selected");
- $(this).toggleClass("selected");*/
-
- that.set_allow($(this).parent().attr('id'));
-
- return false;
-}
-ACL.prototype.on_button_hide = function(event){
- event.stopPropagation();
-
- /*that.showall.removeClass("selected");
- $(this).siblings(".acl-button-show").removeClass("selected");
- $(this).toggleClass("selected");*/
-
- that.set_deny($(this).parent().attr('id'));
-
- return false;
-}
-
-ACL.prototype.set_allow = function(itemid){
- type = itemid[0];
- id = parseInt(itemid.substr(1));
- switch(type){
- case "g":
- if (that.allow_gid.indexOf(id)<0){
- that.allow_gid.push(id)
- }else {
- that.allow_gid.remove(id);
- }
- if (that.deny_gid.indexOf(id)>=0) that.deny_gid.remove(id);
- break;
- case "c":
- if (that.allow_cid.indexOf(id)<0){
- that.allow_cid.push(id)
- } else {
- that.allow_cid.remove(id);
- }
- if (that.deny_cid.indexOf(id)>=0) that.deny_cid.remove(id);
- break;
- }
- that.updateview();
-}
-
-ACL.prototype.set_deny = function(itemid){
- type = itemid[0];
- id = parseInt(itemid.substr(1));
- switch(type){
- case "g":
- if (that.deny_gid.indexOf(id)<0){
- that.deny_gid.push(id)
- } else {
- that.deny_gid.remove(id);
- }
- if (that.allow_gid.indexOf(id)>=0) that.allow_gid.remove(id);
- break;
- case "c":
- if (that.deny_cid.indexOf(id)<0){
- that.deny_cid.push(id)
- } else {
- that.deny_cid.remove(id);
- }
- if (that.allow_cid.indexOf(id)>=0) that.allow_cid.remove(id);
- break;
- }
- that.updateview();
-}
-
-ACL.prototype.updateview = function(){
- if (that.allow_gid.length==0 && that.allow_cid.length==0 &&
- that.deny_gid.length==0 && that.deny_cid.length==0){
- that.showall.addClass("selected");
- /* jot acl */
- $('#jot-perms-icon').removeClass('lock').addClass('unlock');
- $('#jot-public').show();
- $('.profile-jot-net input').attr('disabled', false);
- if(editor != false) {
- $('#profile-jot-desc').html(ispublic);
- }
-
- } else {
- that.showall.removeClass("selected");
- /* jot acl */
- $('#jot-perms-icon').removeClass('unlock').addClass('lock');
- $('#jot-public').hide();
- $('.profile-jot-net input').attr('disabled', 'disabled');
- $('#profile-jot-desc').html('&nbsp;');
- }
-
- $("#acl-list-content .acl-list-item").each(function(){
- itemid = $(this).attr('id');
- type = itemid[0];
- id = parseInt(itemid.substr(1));
-
- btshow = $(this).children(".acl-button-show").removeClass("selected");
- bthide = $(this).children(".acl-button-hide").removeClass("selected");
-
- switch(type){
- case "g":
- var uclass = "";
- if (that.allow_gid.indexOf(id)>=0){
- btshow.addClass("selected");
- bthide.removeClass("selected");
- uclass="groupshow";
- }
- if (that.deny_gid.indexOf(id)>=0){
- btshow.removeClass("selected");
- bthide.addClass("selected");
- uclass="grouphide";
- }
-
- $(that.group_uids[id]).each(function(i,v){
- $("#c"+v).removeClass("groupshow grouphide").addClass(uclass);
- });
-
- break;
- case "c":
- if (that.allow_cid.indexOf(id)>=0){
- btshow.addClass("selected");
- bthide.removeClass("selected");
- }
- if (that.deny_cid.indexOf(id)>=0){
- btshow.removeClass("selected");
- bthide.addClass("selected");
- }
- }
-
- });
-
-}
-
-
-ACL.prototype.get = function(start,count, search){
- var postdata = {
- start:start,
- count:count,
- search:search,
- }
-
- $.ajax({
- type:'POST',
- url: that.url,
- data: postdata,
- dataType: 'json',
- success:that.populate
- });
-}
-
-ACL.prototype.populate = function(data){
- var height = Math.ceil(data.tot / that.nw) * 42;
- that.list_content.height(height);
- $(data.items).each(function(){
- html = "<div class='acl-list-item {4} {5}' id='{2}{3}'>"+that.item_tpl+"</div>";
- html = html.format( this.photo, this.name, this.type, this.id, '', this.network );
- if (this.uids!=undefined) that.group_uids[this.id] = this.uids;
- //console.log(html);
- that.list_content.append(html);
- });
- that.updateview();
-}
-
diff --git a/include/ajaxupload.js b/include/ajaxupload.js
deleted file mode 100644
index 67c4a56fb..000000000
--- a/include/ajaxupload.js
+++ /dev/null
@@ -1,695 +0,0 @@
-/**
- * AJAX Upload ( http://valums.com/ajax-upload/ )
- * Copyright (c) Andris Valums
- * Licensed under the MIT license ( http://valums.com/mit-license/ )
- * Thanks to Gary Haran, David Mark, Corey Burns and others for contributions.
- */
-
-(function () {
- /* global window */
- /* jslint browser: true, devel: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true */
-
- /**
- * Wrapper for FireBug's console.log
- */
- function log(){
- if (typeof(console) != 'undefined' && typeof(console.log) == 'function'){
- Array.prototype.unshift.call(arguments, '[Ajax Upload]');
- console.log( Array.prototype.join.call(arguments, ' '));
- }
- }
-
- /**
- * Attaches event to a dom element.
- * @param {Element} el
- * @param type event name
- * @param fn callback This refers to the passed element
- */
- function addEvent(el, type, fn){
- if (el.addEventListener) {
- el.addEventListener(type, fn, false);
- } else if (el.attachEvent) {
- el.attachEvent('on' + type, function(){
- fn.call(el);
- });
- } else {
- throw new Error('not supported or DOM not loaded');
- }
- }
-
- /**
- * Attaches resize event to a window, limiting
- * number of event fired. Fires only when encounteres
- * delay of 100 after series of events.
- *
- * Some browsers fire event multiple times when resizing
- * http://www.quirksmode.org/dom/events/resize.html
- *
- * @param fn callback This refers to the passed element
- */
- function addResizeEvent(fn){
- var timeout;
-
- addEvent(window, 'resize', function(){
- if (timeout){
- clearTimeout(timeout);
- }
- timeout = setTimeout(fn, 100);
- });
- }
-
- // Needs more testing, will be rewriten for next version
- // getOffset function copied from jQuery lib (http://jquery.com/)
- if (document.documentElement.getBoundingClientRect){
- // Get Offset using getBoundingClientRect
- // http://ejohn.org/blog/getboundingclientrect-is-awesome/
- var getOffset = function(el){
- var box = el.getBoundingClientRect();
- var doc = el.ownerDocument;
- var body = doc.body;
- var docElem = doc.documentElement; // for ie
- var clientTop = docElem.clientTop || body.clientTop || 0;
- var clientLeft = docElem.clientLeft || body.clientLeft || 0;
-
- // In Internet Explorer 7 getBoundingClientRect property is treated as physical,
- // while others are logical. Make all logical, like in IE8.
- var zoom = 1;
- if (body.getBoundingClientRect) {
- var bound = body.getBoundingClientRect();
- zoom = (bound.right - bound.left) / body.clientWidth;
- }
-
- if (zoom > 1) {
- clientTop = 0;
- clientLeft = 0;
- }
-
- var top = box.top / zoom + (window.pageYOffset || docElem && docElem.scrollTop / zoom || body.scrollTop / zoom) - clientTop, left = box.left / zoom + (window.pageXOffset || docElem && docElem.scrollLeft / zoom || body.scrollLeft / zoom) - clientLeft;
-
- return {
- top: top,
- left: left
- };
- };
- } else {
- // Get offset adding all offsets
- var getOffset = function(el){
- var top = 0, left = 0;
- do {
- top += el.offsetTop || 0;
- left += el.offsetLeft || 0;
- el = el.offsetParent;
- } while (el);
-
- return {
- left: left,
- top: top
- };
- };
- }
-
- /**
- * Returns left, top, right and bottom properties describing the border-box,
- * in pixels, with the top-left relative to the body
- * @param {Element} el
- * @return {Object} Contains left, top, right,bottom
- */
- function getBox(el){
- var left, right, top, bottom;
- var offset = getOffset(el);
- left = offset.left;
- top = offset.top;
-
- right = left + el.offsetWidth;
- bottom = top + el.offsetHeight;
-
- return {
- left: left,
- right: right,
- top: top,
- bottom: bottom
- };
- }
-
- /**
- * Helper that takes object literal
- * and add all properties to element.style
- * @param {Element} el
- * @param {Object} styles
- */
- function addStyles(el, styles){
- for (var name in styles) {
- if (styles.hasOwnProperty(name)) {
- el.style[name] = styles[name];
- }
- }
- }
-
- /**
- * Function places an absolutely positioned
- * element on top of the specified element
- * copying position and dimentions.
- * @param {Element} from
- * @param {Element} to
- */
- function copyLayout(from, to){
- var box = getBox(from);
-
- addStyles(to, {
- position: 'absolute',
- left : box.left + 'px',
- top : box.top + 'px',
- width : from.offsetWidth + 'px',
- height : from.offsetHeight + 'px'
- });
- to.title = from.title;
-
- }
-
- /**
- * Creates and returns element from html chunk
- * Uses innerHTML to create an element
- */
- var toElement = (function(){
- var div = document.createElement('div');
- return function(html){
- div.innerHTML = html;
- var el = div.firstChild;
- return div.removeChild(el);
- };
- })();
-
- /**
- * Function generates unique id
- * @return unique id
- */
- var getUID = (function(){
- var id = 0;
- return function(){
- return 'ValumsAjaxUpload' + id++;
- };
- })();
-
- /**
- * Get file name from path
- * @param {String} file path to file
- * @return filename
- */
- function fileFromPath(file){
- return file.replace(/.*(\/|\\)/, "");
- }
-
- /**
- * Get file extension lowercase
- * @param {String} file name
- * @return file extenstion
- */
- function getExt(file){
- return (-1 !== file.indexOf('.')) ? file.replace(/.*[.]/, '') : '';
- }
-
- function hasClass(el, name){
- var re = new RegExp('\\b' + name + '\\b');
- return re.test(el.className);
- }
- function addClass(el, name){
- if ( ! hasClass(el, name)){
- el.className += ' ' + name;
- }
- }
- function removeClass(el, name){
- var re = new RegExp('\\b' + name + '\\b');
- el.className = el.className.replace(re, '');
- }
-
- function removeNode(el){
- el.parentNode.removeChild(el);
- }
-
- /**
- * Easy styling and uploading
- * @constructor
- * @param button An element you want convert to
- * upload button. Tested dimentions up to 500x500px
- * @param {Object} options See defaults below.
- */
- window.AjaxUpload = function(button, options){
- this._settings = {
- // Location of the server-side upload script
- action: 'upload.php',
- // File upload name
- name: 'userfile',
- // Additional data to send
- data: {},
- // Submit file as soon as it's selected
- autoSubmit: true,
- // The type of data that you're expecting back from the server.
- // html and xml are detected automatically.
- // Only useful when you are using json data as a response.
- // Set to "json" in that case.
- responseType: false,
- // Class applied to button when mouse is hovered
- hoverClass: 'hover',
- // Class applied to button when button is focused
- focusClass: 'focus',
- // Class applied to button when AU is disabled
- disabledClass: 'disabled',
- // When user selects a file, useful with autoSubmit disabled
- // You can return false to cancel upload
- onChange: function(file, extension){
- },
- // Callback to fire before file is uploaded
- // You can return false to cancel upload
- onSubmit: function(file, extension){
- },
- // Fired when file upload is completed
- // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
- onComplete: function(file, response){
- }
- };
-
- // Merge the users options with our defaults
- for (var i in options) {
- if (options.hasOwnProperty(i)){
- this._settings[i] = options[i];
- }
- }
-
- // button isn't necessary a dom element
- if (button.jquery){
- // jQuery object was passed
- button = button[0];
- } else if (typeof button == "string") {
- if (/^#.*/.test(button)){
- // If jQuery user passes #elementId don't break it
- button = button.slice(1);
- }
-
- button = document.getElementById(button);
- }
-
- if ( ! button || button.nodeType !== 1){
- throw new Error("Please make sure that you're passing a valid element");
- }
-
- if ( button.nodeName.toUpperCase() == 'A'){
- // disable link
- addEvent(button, 'click', function(e){
- if (e && e.preventDefault){
- e.preventDefault();
- } else if (window.event){
- window.event.returnValue = false;
- }
- });
- }
-
- // DOM element
- this._button = button;
- // DOM element
- this._input = null;
- // If disabled clicking on button won't do anything
- this._disabled = false;
-
- // if the button was disabled before refresh if will remain
- // disabled in FireFox, let's fix it
- this.enable();
-
- this._rerouteClicks();
- };
-
- // assigning methods to our class
- AjaxUpload.prototype = {
- setData: function(data){
- this._settings.data = data;
- },
- disable: function(){
- addClass(this._button, this._settings.disabledClass);
- this._disabled = true;
-
- var nodeName = this._button.nodeName.toUpperCase();
- if (nodeName == 'INPUT' || nodeName == 'BUTTON'){
- this._button.setAttribute('disabled', 'disabled');
- }
-
- // hide input
- if (this._input){
- // We use visibility instead of display to fix problem with Safari 4
- // The problem is that the value of input doesn't change if it
- // has display none when user selects a file
- this._input.parentNode.style.visibility = 'hidden';
- }
- },
- enable: function(){
- removeClass(this._button, this._settings.disabledClass);
- this._button.removeAttribute('disabled');
- this._disabled = false;
-
- },
- /**
- * Creates invisible file input
- * that will hover above the button
- * <div><input type='file' /></div>
- */
- _createInput: function(){
- var self = this;
-
- var input = document.createElement("input");
- input.setAttribute('type', 'file');
- input.setAttribute('name', this._settings.name);
-
- addStyles(input, {
- 'position' : 'absolute',
- // in Opera only 'browse' button
- // is clickable and it is located at
- // the right side of the input
- 'right' : 0,
- 'margin' : 0,
- 'padding' : 0,
- 'fontSize' : '480px',
- // in Firefox if font-family is set to
- // 'inherit' the input doesn't work
- 'fontFamily' : 'sans-serif',
- 'cursor' : 'pointer'
- });
-
- var div = document.createElement("div");
- addStyles(div, {
- 'display' : 'block',
- 'position' : 'absolute',
- 'overflow' : 'hidden',
- 'margin' : 0,
- 'padding' : 0,
- 'opacity' : 0,
- // Make sure browse button is in the right side
- // in Internet Explorer
- 'direction' : 'ltr',
- //Max zIndex supported by Opera 9.0-9.2
- 'zIndex': 2147483583,
- 'cursor' : 'pointer'
-
- });
-
- // Make sure that element opacity exists.
- // Otherwise use IE filter
- if ( div.style.opacity !== "0") {
- if (typeof(div.filters) == 'undefined'){
- throw new Error('Opacity not supported by the browser');
- }
- div.style.filter = "alpha(opacity=0)";
- }
-
- addEvent(input, 'change', function(){
-
- if ( ! input || input.value === ''){
- return;
- }
-
- // Get filename from input, required
- // as some browsers have path instead of it
- var file = fileFromPath(input.value);
-
- if (false === self._settings.onChange.call(self, file, getExt(file))){
- self._clearInput();
- return;
- }
-
- // Submit form when value is changed
- if (self._settings.autoSubmit) {
- self.submit();
- }
- });
-
- addEvent(input, 'mouseover', function(){
- addClass(self._button, self._settings.hoverClass);
- });
-
- addEvent(input, 'mouseout', function(){
- removeClass(self._button, self._settings.hoverClass);
- removeClass(self._button, self._settings.focusClass);
-
- // We use visibility instead of display to fix problem with Safari 4
- // The problem is that the value of input doesn't change if it
- // has display none when user selects a file
- input.parentNode.style.visibility = 'hidden';
-
- });
-
- addEvent(input, 'focus', function(){
- addClass(self._button, self._settings.focusClass);
- });
-
- addEvent(input, 'blur', function(){
- removeClass(self._button, self._settings.focusClass);
- });
-
- div.appendChild(input);
- document.body.appendChild(div);
-
- this._input = input;
- },
- _clearInput : function(){
- if (!this._input){
- return;
- }
-
- // this._input.value = ''; Doesn't work in IE6
- removeNode(this._input.parentNode);
- this._input = null;
- this._createInput();
-
- removeClass(this._button, this._settings.hoverClass);
- removeClass(this._button, this._settings.focusClass);
- },
- /**
- * Function makes sure that when user clicks upload button,
- * the this._input is clicked instead
- */
- _rerouteClicks: function(){
- var self = this;
-
- // IE will later display 'access denied' error
- // if you use using self._input.click()
- // other browsers just ignore click()
-
- addEvent(self._button, 'mouseover', function(){
- if (self._disabled){
- return;
- }
-
- if ( ! self._input){
- self._createInput();
- }
-
- var div = self._input.parentNode;
- copyLayout(self._button, div);
- div.style.visibility = 'visible';
-
- });
-
-
- // commented because we now hide input on mouseleave
- /**
- * When the window is resized the elements
- * can be misaligned if button position depends
- * on window size
- */
- //addResizeEvent(function(){
- // if (self._input){
- // copyLayout(self._button, self._input.parentNode);
- // }
- //});
-
- },
- /**
- * Creates iframe with unique name
- * @return {Element} iframe
- */
- _createIframe: function(){
- // We can't use getTime, because it sometimes return
- // same value in safari :(
- var id = getUID();
-
- // We can't use following code as the name attribute
- // won't be properly registered in IE6, and new window
- // on form submit will open
- // var iframe = document.createElement('iframe');
- // iframe.setAttribute('name', id);
-
- var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
- // src="javascript:false; was added
- // because it possibly removes ie6 prompt
- // "This page contains both secure and nonsecure items"
- // Anyway, it doesn't do any harm.
- iframe.setAttribute('id', id);
-
- iframe.style.display = 'none';
- document.body.appendChild(iframe);
-
- return iframe;
- },
- /**
- * Creates form, that will be submitted to iframe
- * @param {Element} iframe Where to submit
- * @return {Element} form
- */
- _createForm: function(iframe){
- var settings = this._settings;
-
- // We can't use the following code in IE6
- // var form = document.createElement('form');
- // form.setAttribute('method', 'post');
- // form.setAttribute('enctype', 'multipart/form-data');
- // Because in this case file won't be attached to request
- var form = toElement('<form method="post" enctype="multipart/form-data"></form>');
-
- form.setAttribute('action', settings.action);
- form.setAttribute('target', iframe.name);
- form.style.display = 'none';
- document.body.appendChild(form);
-
- // Create hidden input element for each data key
- for (var prop in settings.data) {
- if (settings.data.hasOwnProperty(prop)){
- var el = document.createElement("input");
- el.setAttribute('type', 'hidden');
- el.setAttribute('name', prop);
- el.setAttribute('value', settings.data[prop]);
- form.appendChild(el);
- }
- }
- return form;
- },
- /**
- * Gets response from iframe and fires onComplete event when ready
- * @param iframe
- * @param file Filename to use in onComplete callback
- */
- _getResponse : function(iframe, file){
- // getting response
- var toDeleteFlag = false, self = this, settings = this._settings;
-
- addEvent(iframe, 'load', function(){
-
- if (// For Safari
- iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" ||
- // For FF, IE
- iframe.src == "javascript:'<html></html>';"){
- // First time around, do not delete.
- // We reload to blank page, so that reloading main page
- // does not re-submit the post.
-
- if (toDeleteFlag) {
- // Fix busy state in FF3
- setTimeout(function(){
- removeNode(iframe);
- }, 0);
- }
-
- return;
- }
-
- var doc = iframe.contentDocument ? iframe.contentDocument : window.frames[iframe.id].document;
-
- // fixing Opera 9.26,10.00
- if (doc.readyState && doc.readyState != 'complete') {
- // Opera fires load event multiple times
- // Even when the DOM is not ready yet
- // this fix should not affect other browsers
- return;
- }
-
- // fixing Opera 9.64
- if (doc.body && doc.body.innerHTML == "false") {
- // In Opera 9.64 event was fired second time
- // when body.innerHTML changed from false
- // to server response approx. after 1 sec
- return;
- }
-
- var response;
-
- if (doc.XMLDocument) {
- // response is a xml document Internet Explorer property
- response = doc.XMLDocument;
- } else if (doc.body){
- // response is html document or plain text
- response = doc.body.innerHTML;
-
- if (settings.responseType && settings.responseType.toLowerCase() == 'json') {
- // If the document was sent as 'application/javascript' or
- // 'text/javascript', then the browser wraps the text in a <pre>
- // tag and performs html encoding on the contents. In this case,
- // we need to pull the original text content from the text node's
- // nodeValue property to retrieve the unmangled content.
- // Note that IE6 only understands text/html
- if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE') {
- doc.normalize();
- response = doc.body.firstChild.firstChild.nodeValue;
- }
-
- if (response) {
- response = eval("(" + response + ")");
- } else {
- response = {};
- }
- }
- } else {
- // response is a xml document
- response = doc;
- }
-
- settings.onComplete.call(self, file, response);
-
- // Reload blank page, so that reloading main page
- // does not re-submit the post. Also, remember to
- // delete the frame
- toDeleteFlag = true;
-
- // Fix IE mixed content issue
- iframe.src = "javascript:'<html></html>';";
- });
- },
- /**
- * Upload file contained in this._input
- */
- submit: function(){
- var self = this, settings = this._settings;
-
- if ( ! this._input || this._input.value === ''){
- return;
- }
-
- var file = fileFromPath(this._input.value);
-
- // user returned false to cancel upload
- if (false === settings.onSubmit.call(this, file, getExt(file))){
- this._clearInput();
- return;
- }
-
- // sending request
- var iframe = this._createIframe();
- var form = this._createForm(iframe);
-
- // assuming following structure
- // div -> input type='file'
- removeNode(this._input.parentNode);
- removeClass(self._button, self._settings.hoverClass);
- removeClass(self._button, self._settings.focusClass);
-
- form.appendChild(this._input);
-
- form.submit();
-
- // request set, clean up
- removeNode(form); form = null;
- removeNode(this._input); this._input = null;
-
- // Get response from iframe and fire onComplete event when ready
- this._getResponse(iframe, file);
-
- // get ready for next request
- this._createInput();
- }
- };
-})();
diff --git a/include/api.php b/include/api.php
index aa42313b2..74b4aaf6e 100644
--- a/include/api.php
+++ b/include/api.php
@@ -1,6 +1,7 @@
<?php
require_once("bbcode.php");
require_once("datetime.php");
+ require_once("conversation.php");
/*
* Twitter-Like API
@@ -8,7 +9,7 @@
*/
$API = Array();
-
+ $called_api = Null;
function api_date($str){
//Wed May 23 06:01:13 +0000 2007
@@ -54,7 +55,7 @@
// process normal login request
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
dbesc(trim($user)),
dbesc(trim($user)),
dbesc($encrypted)
@@ -103,9 +104,10 @@
* MAIN API ENTRY POINT *
**************************/
function api_call(&$a){
- GLOBAL $API;
+ GLOBAL $API, $called_api;
foreach ($API as $p=>$info){
if (strpos($a->query_string, $p)===0){
+ $called_api= explode("/",$p);
#unset($_SERVER['PHP_AUTH_USER']);
if ($info['auth']===true && local_user()===false) {
api_login($a);
@@ -131,7 +133,7 @@
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break;
case "json":
- header ("Content-Type: application/json");
+ //header ("Content-Type: application/json");
foreach($r as $rr)
return json_encode($rr);
break;
@@ -193,6 +195,7 @@
* Returns user info array.
*/
function api_get_user(&$a, $contact_id = Null){
+ global $called_api;
$user = null;
$extra_query = "";
@@ -209,16 +212,20 @@
if(is_null($user) && x($_GET, 'screen_name')) {
$user = dbesc($_GET['screen_name']);
$extra_query = "AND `contact`.`nick` = '%s' ";
+ if (local_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(local_user());
+
}
- if (is_null($user) && $a->argc > 3){
- list($user, $null) = explode(".",$a->argv[3]);
+ if (is_null($user) && $a->argc > (count($called_api)-1)){
+ $argid = count($called_api);
+ list($user, $null) = explode(".",$a->argv[$argid]);
if(is_numeric($user)){
$user = intval($user);
$extra_query = "AND `contact`.`id` = %d ";
} else {
$user = dbesc($user);
$extra_query = "AND `contact`.`nick` = '%s' ";
+ if (local_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(local_user());
}
}
@@ -301,6 +308,7 @@
}
$ret = Array(
+ 'self' => intval($uinfo[0]['self']),
'uid' => intval($uinfo[0]['uid']),
'id' => intval($uinfo[0]['cid']),
'name' => $uinfo[0]['name'],
@@ -321,7 +329,7 @@
'followers_count' => intval($countfollowers),
'favourites_count' => intval($starred),
'contributors_enabled' => false,
- 'follow_request_sent' => false,
+ 'follow_request_sent' => true,
'profile_background_color' => 'cfe8f6',
'profile_text_color' => '000000',
'profile_link_color' => 'FF8500',
@@ -458,6 +466,7 @@
}
return null;
}
+
// TODO - media uploads
function api_statuses_update(&$a, $type) {
if (local_user()===false) return false;
@@ -467,7 +476,32 @@
// logger('api_post: ' . print_r($_POST,true));
- $_POST['body'] = urldecode(requestdata('status'));
+ if(requestdata('htmlstatus')) {
+ require_once('library/HTMLPurifier.auto.php');
+ require_once('include/html2bbcode.php');
+
+ $txt = requestdata('htmlstatus');
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+
+ $txt = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $txt = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Cache.DefinitionImpl', null);
+
+
+ $purifier = new HTMLPurifier($config);
+ $txt = $purifier->purify($txt);
+
+ $_POST['body'] = html2bbcode($txt);
+ }
+
+ }
+ else
+ $_POST['body'] = urldecode(requestdata('status'));
$parent = requestdata('in_reply_to_status_id');
if(ctype_digit($parent))
@@ -616,6 +650,7 @@
$user_info = api_get_user($a);
// get last newtork messages
+
// params
$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
@@ -664,6 +699,12 @@
$user_info = api_get_user($a);
// get last newtork messages
+
+ logger("api_statuses_user_timeline: local_user: ". local_user() .
+ "\nuser_info: ".print_r($user_info, true) .
+ "\n_REQUEST: ".print_r($_REQUEST, true),
+ LOGGER_DEBUG);
+
// params
$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
@@ -672,6 +713,7 @@
$start = $page*$count;
+ if ($user_info['self']==1) $sql_extra = "AND `item`.`wall` = 1 ";
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
@@ -679,14 +721,15 @@
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d
+ AND `item`.`contact-id` = %d
AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `item`.`wall` = 1
AND `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra
AND `item`.`id`>%d
ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
- intval($user_info['uid']),
+ intval(local_user()),
+ intval($user_info['id']),
intval($since_id),
intval($start), intval($count)
);
@@ -711,33 +754,41 @@
if (local_user()===false) return false;
$user_info = api_get_user($a);
- // get last newtork messages
+ // in friendika starred item are private
+ // return favorites only for self
+ logger('api_favorites: self:' . $user_info['self']);
- // params
- $count = (x($_GET,'count')?$_GET['count']:20);
- $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
- if ($page<0) $page=0;
-
- $start = $page*$count;
-
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`
- WHERE `item`.`uid` = %d
- AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `item`.`starred` = 1
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- $sql_extra
- ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
- intval($user_info['uid']),
- intval($start), intval($count)
- );
-
- $ret = api_format_items($r,$user_info);
+ if ($user_info['self']==0) {
+ $ret = array();
+ } else {
+
+
+ // params
+ $count = (x($_GET,'count')?$_GET['count']:20);
+ $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+ if ($page<0) $page=0;
+
+ $start = $page*$count;
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+ `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item`, `contact`
+ WHERE `item`.`uid` = %d
+ AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `item`.`starred` = 1
+ AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $sql_extra
+ ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
+ intval($user_info['uid']),
+ intval($start), intval($count)
+ );
+ $ret = api_format_items($r,$user_info);
+
+ }
$data = array('$statuses' => $ret);
switch($type){
@@ -762,6 +813,7 @@
$ret = Array();
foreach($r as $item) {
+ localize_item($item);
$status_user = (($item['cid']==$user_info['id'])?$user_info: api_item_get_user($a,$item));
$status = array(
'created_at'=> api_date($item['created']),
@@ -819,15 +871,21 @@
if (local_user()===false) return false;
$user_info = api_get_user($a);
+
+ // friends and followers only for self
+ if ($user_info['self']==0){
+ return false;
+ }
+
if (x($_GET,'cursor') && $_GET['cursor']=='undefined'){
/* this is to stop Hotot to load friends multiple times
* I'm not sure if I'm missing return something or
* is a bug in hotot. Workaround, meantime
*/
- $ret=Array();
- $data = array('$users' => $ret);
- return api_apply_template("friends", $type, $data);
+ /*$ret=Array();
+ return array('$users' => $ret);*/
+ return false;
}
if($qtype == 'friends')
@@ -845,15 +903,18 @@
}
- $data = array('$users' => $ret);
- return api_apply_template("friends", $type, $data);
+ return array('$users' => $ret);
}
function api_statuses_friends(&$a, $type){
- return api_statuses_f($a,$type,"friends");
+ $data = api_statuses_f($a,$type,"friends");
+ if ($data===false) return false;
+ return api_apply_template("friends", $type, $data);
}
function api_statuses_followers(&$a, $type){
- return api_statuses_f($a,$type,"followers");
+ $data = api_statuses_f($a,$type,"followers");
+ if ($data===false) return false;
+ return api_apply_template("friends", $type, $data);
}
api_register_func('api/statuses/friends','api_statuses_friends',true);
api_register_func('api/statuses/followers','api_statuses_followers',true);
diff --git a/include/auth.php b/include/auth.php
index 768af626f..1f16b3504 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -48,7 +48,8 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
goaway(z_root());
}
- $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
+ FROM `user` WHERE `uid` = %d AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
intval($_SESSION['uid'])
);
@@ -183,8 +184,9 @@ else {
// process normal login request
- $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
+ FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
+ AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
dbesc(trim($_POST['openid_url'])),
dbesc(trim($_POST['openid_url'])),
dbesc($encrypted)
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 5ce34d666..c72c78445 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -3,6 +3,21 @@
require_once("include/oembed.php");
require_once('include/event.php');
+require_once('library/markdown.php');
+require_once('include/html2bbcode.php');
+
+function diaspora2bb($s) {
+
+ $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
+ $s = Markdown($s);
+ $s = html2bbcode($s);
+
+// $s = preg_replace('/\[url=(.+?)\<em\>(.+?)\]/ism','[url=$1_$2]',$s);
+// $s = preg_replace('/\[url=(.+?)\<\/em\>(.+?)\]/ism','[url=$1_$2]',$s);
+
+ return $s;
+
+}
function stripdcode_br_cb($s) {
@@ -15,12 +30,18 @@ function stripdcode_br_cb($s) {
function bb2diaspora($Text,$preserve_nl = false) {
+ $ev = bbtoevent($Text);
+
// Replace any html brackets with HTML Entities to prevent executing HTML or script
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
$Text = str_replace("<", "&lt;", $Text);
$Text = str_replace(">", "&gt;", $Text);
+ // If we find any event code, turn it into an event.
+ // After we're finished processing the bbcode we'll
+ // replace all of the event code with a reformatted version.
+
if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
@@ -35,8 +56,9 @@ function bb2diaspora($Text,$preserve_nl = false) {
// [img]pathtoimage[/img]
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text);
- $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '[$2]($1)', $Text);
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '[$1]($1)', $Text);
+ $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[#$2]($1)', $Text);
+ $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[$2]($1)', $Text);
// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text);
// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text);
@@ -137,23 +159,60 @@ function bb2diaspora($Text,$preserve_nl = false) {
// oembed tag
-// $Text = oembed_bbcode2html($Text);
+ // $Text = oembed_bbcode2html($Text);
// If we found an event earlier, strip out all the event code and replace with a reformatted version.
-// if(x($ev,'desc') && x($ev,'start')) {
-// $sub = format_event_html($ev);
+ if(x($ev,'desc') && x($ev,'start')) {
- // $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
- //$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
-// $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
-// $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
-// $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
-// }
+ $sub = format_event_diaspora($ev);
+
+ $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
+ $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
+ $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
+ $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
+ $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
+ }
+ $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
+ $Text = preg_replace('/\[(.*?)\]\((.*?)\\\\_(.*?)\)/ism','[$1]($2_$3)',$Text);
call_hooks('bb2diaspora',$Text);
return $Text;
}
+
+function format_event_diaspora($ev) {
+
+ if(! ((is_array($ev)) && count($ev)))
+ return '';
+
+ $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
+
+ $o = 'Friendika event notification:' . "\n";
+
+ $o .= '**' . bb2diaspora($ev['desc']) . '**' . "\n";
+
+ $o .= t('Starts:') . ' '
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
+ $ev['start'] , $bd_format ))
+ : day_translate(datetime_convert('UTC', 'UTC',
+ $ev['start'] , $bd_format)))
+ . "\n";
+
+ if(! $ev['nofinish'])
+ $o .= t('Finishes:') . ' '
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
+ $ev['finish'] , $bd_format ))
+ : day_translate(datetime_convert('UTC', 'UTC',
+ $ev['finish'] , $bd_format )))
+ . "\n";
+
+ if(strlen($ev['location']))
+ $o .= t('Location:') . bb2diaspora($ev['location'])
+ . "\n";
+
+ $o .= "\n";
+ return $o;
+}
diff --git a/include/bbcode.php b/include/bbcode.php
index 3619015ca..9abc7c439 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -15,6 +15,13 @@ function stripcode_br_cb($s) {
function bbcode($Text,$preserve_nl = false) {
+ // If we find any event code, turn it into an event.
+ // After we're finished processing the bbcode we'll
+ // replace all of the event code with a reformatted version.
+
+ $ev = bbtoevent($Text);
+
+
// Replace any html brackets with HTML Entities to prevent executing HTML or script
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
@@ -27,11 +34,6 @@ function bbcode($Text,$preserve_nl = false) {
if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
- // If we find any event code, turn it into an event.
- // After we're finished processing the bbcode we'll
- // replace all of the event code with a reformatted version.
-
- $ev = bbtoevent($Text);
// Set up the parameters for a URL search string
$URLSearchString = "^\[\]";
@@ -41,67 +43,67 @@ function bbcode($Text,$preserve_nl = false) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+\,]+)/", ' <a href="$2" target="external-link">$2</a>', $Text);
+ $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="external-link">$2</a>', $Text);
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="external-link">$1</a>', $Text);
- $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '<a href="$1" target="external-link">$2</a>', $Text);
- //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="external-link">$1</a>', $Text);
+ $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
+ //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
// Perform MAIL Search
- $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
+ $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text);
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
// Check for bold text
- $Text = preg_replace("(\[b\](.*?)\[\/b\])is",'<strong>$1</strong>',$Text);
+ $Text = preg_replace("(\[b\](.*?)\[\/b\])ism",'<strong>$1</strong>',$Text);
// Check for Italics text
- $Text = preg_replace("(\[i\](.*?)\[\/i\])is",'<em>$1</em>',$Text);
+ $Text = preg_replace("(\[i\](.*?)\[\/i\])ism",'<em>$1</em>',$Text);
// Check for Underline text
- $Text = preg_replace("(\[u\](.*?)\[\/u\])is",'<u>$1</u>',$Text);
+ $Text = preg_replace("(\[u\](.*?)\[\/u\])ism",'<u>$1</u>',$Text);
// Check for strike-through text
- $Text = preg_replace("(\[s\](.*?)\[\/s\])is",'<strike>$1</strike>',$Text);
+ $Text = preg_replace("(\[s\](.*?)\[\/s\])ism",'<strike>$1</strike>',$Text);
// Check for over-line text
- $Text = preg_replace("(\[o\](.*?)\[\/o\])is",'<span class="overline">$1</span>',$Text);
+ $Text = preg_replace("(\[o\](.*?)\[\/o\])ism",'<span class="overline">$1</span>',$Text);
// Check for colored text
- $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])is","<span style=\"color: $1;\">$2</span>",$Text);
+ $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","<span style=\"color: $1;\">$2</span>",$Text);
// Check for sized text
- $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])is","<span style=\"font-size: $1;\">$2</span>",$Text);
+ $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text);
// Check for list text
- $Text = preg_replace("/\[list\](.*?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/s",'<ul class="listlowerroman">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
- $Text = preg_replace("/\[li\](.*?)\[\/li\]/s", '<li>$1</li>' ,$Text);
+ $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/sm",'<ul class="listlowerroman">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/sm", '<ul class="listupperroman">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/sm", '<ul class="listloweralpha">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/sm", '<ul class="listupperalpha">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[li\](.*?)\[\/li\]/sm", '<li>$1</li>' ,$Text);
- $Text = preg_replace("/\[td\](.*?)\[\/td\]/s", '<td>$1</td>' ,$Text);
- $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/s", '<tr>$1</tr>' ,$Text);
- $Text = preg_replace("/\[table\](.*?)\[\/table\]/s", '<table>$1</table>' ,$Text);
+ $Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '<td>$1</td>' ,$Text);
+ $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>' ,$Text);
+ $Text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>' ,$Text);
- $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/s", '<table border="1" >$1</table>' ,$Text);
- $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/s", '<table border="0" >$1</table>' ,$Text);
+ $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table border="1" >$1</table>' ,$Text);
+ $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table border="0" >$1</table>' ,$Text);
// $Text = str_replace("[*]", "<li>", $Text);
// Check for font change text
- $Text = preg_replace("(\[font=(.*?)\](.*?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);
+ $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm","<span style=\"font-family: $1;\">$2</span>",$Text);
// Declare the format for [code] layout
- $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/is",'stripcode_br_cb',$Text);
+ $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism",'stripcode_br_cb',$Text);
$CodeLayout = '<code>$1</code>';
// Check for [code] text
- $Text = preg_replace("/\[code\](.*?)\[\/code\]/is","$CodeLayout", $Text);
+ $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text);
@@ -109,22 +111,23 @@ function bbcode($Text,$preserve_nl = false) {
// Declare the format for [quote] layout
$QuoteLayout = '<blockquote>$1</blockquote>';
// Check for [quote] text
- $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/is","$QuoteLayout", $Text);
+ $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism","$QuoteLayout", $Text);
+ // [img=widthxheight]image source[/img]
+ $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+
// Images
// [img]pathtoimage[/img]
- $Text = preg_replace("/\[img\](.*?)\[\/img\]/", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
// html5 video and audio
- $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
+ $Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
- $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
+ $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
- $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
+ $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
- // [img=widthxheight]image source[/img]
- $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text);
if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
// use oembed for youtube links
@@ -132,13 +135,15 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
} else {
// Youtube extensions
- $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
- $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
- $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<iframe width="425" height="349" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $Text);
+ $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
+ $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
+ $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
+ $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
}
-// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
+// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
+
// oembed tag
$Text = oembed_bbcode2html($Text);
@@ -148,14 +153,15 @@ function bbcode($Text,$preserve_nl = false) {
if(x($ev,'desc') && x($ev,'start')) {
$sub = format_event_html($ev);
- $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
- $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
- $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
- $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
- $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
+ $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",$sub,$Text);
+ $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",'',$Text);
+ $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text);
+ $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text);
+ $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
}
-
+ // fix any escaped ampersands that may have been converted into links
+ $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
call_hooks('bbcode',$Text);
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
index ac1e38e4f..1303acf74 100644
--- a/include/contact_selectors.php
+++ b/include/contact_selectors.php
@@ -46,10 +46,11 @@ function contact_reputation($current) {
}
-function contact_poll_interval($current) {
+function contact_poll_interval($current, $disabled = false) {
+ $dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = '';
- $o .= '<select id="contact-poll-interval" name="poll" />' . "\r\n";
+ $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
$rep = array(
0 => t('Frequently'),
@@ -67,3 +68,13 @@ function contact_poll_interval($current) {
$o .= "</select>\r\n";
return $o;
}
+
+
+function network_to_name($s) {
+
+ call_hooks('network_to_name', $s);
+
+ return str_replace(array(NETWORK_DFRN,NETWORK_OSTATUS,NETWORK_FEED,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_FACEBOOK,NETWORK_ZOT),
+ array(t('Friendika'),t('OStatus'),t('RSS/Atom'),t('Email'),t('Diaspora'),t('Facebook'),t('Zot!')),$s);
+
+}
diff --git a/include/conversation.php b/include/conversation.php
index 0d901a3c0..10b34ebe6 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -80,6 +80,7 @@ function localize_item(&$item){
}
+
}
/**
@@ -110,7 +111,7 @@ function conversation(&$a, $items, $mode, $update) {
}
if($mode === 'notes') {
- $profile_owner = $a->profile['profile_uid'];
+ $profile_owner = local_user();
$page_writeable = true;
}
@@ -133,16 +134,17 @@ function conversation(&$a, $items, $mode, $update) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
- $like_tpl = get_markup_template('like.tpl');
- $noshare_tpl = get_markup_template('like_noshare.tpl');
$tpl = get_markup_template('wall_item.tpl');
$wallwall = get_markup_template('wallwall_item.tpl');
- $droptpl = get_markup_template('wall_item_drop.tpl');
- $fakedrop = get_markup_template('wall_fake_drop.tpl');
$alike = array();
$dlike = array();
+
+ // array with html for each thread (parent+comments)
+ $threads = array();
+ $threadsid = -1;
+
if(count($items)) {
if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
@@ -153,6 +155,7 @@ function conversation(&$a, $items, $mode, $update) {
$tpl = get_markup_template('search_item.tpl');
foreach($items as $item) {
+ $threadsid++;
$comment = '';
$owner_url = '';
@@ -194,344 +197,389 @@ function conversation(&$a, $items, $mode, $update) {
$location = '<span class="smalltext">' . $coord . '</span>';
}
- $drop = '';
localize_item($item);
if($mode === 'network-new')
- $t = $droptpl;
+ $dropping = true;
else
- $t = $fakedrop;
+ $dropping = false;
- $drop = replace_macros($t,array('$id' => $item['id']));
- $lock = '<div class="wall-item-lock"></div>';
- $star = '';
+
+ $drop = array(
+ 'dropping' => $dropping,
+ 'select' => t('Select'),
+ 'delete' => t('Delete'),
+ );
+
+ $star = false;
+ $isstarred = "unstarred";
+
+ $lock = false;
+ $likebuttons = false;
+ $shareable = false;
$body = prepare_body($item,true);
- $o .= replace_macros($tpl,array(
+ $tmp_item = replace_macros($tpl,array(
'$id' => $item['item_id'],
- '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
+ '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
- '$name' => $profile_name,
+ '$name' => template_escape($profile_name),
'$sparkle' => $sparkle,
'$lock' => $lock,
'$thumb' => $profile_avatar,
- '$title' => $item['title'],
- '$body' => $body,
+ '$title' => template_escape($item['title']),
+ '$body' => template_escape($body),
'$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- '$location' => $location,
+ '$lock' => $lock,
+ '$location' => template_escape($location),
'$indent' => '',
+ '$owner_name' => template_escape($owner_name),
'$owner_url' => $owner_url,
'$owner_photo' => $owner_photo,
- '$owner_name' => $owner_name,
+ '$plink' => get_plink($item),
+ '$edpost' => false,
+ '$isstarred' => $isstarred,
'$star' => $star,
'$drop' => $drop,
- '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'] . '">' . t('View in context') . '</a>'
+ '$vote' => $likebuttons,
+ '$like' => '',
+ '$dislike' => '',
+ '$comment' => '',
+ '$conv' => array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context')),
+ '$wait' => t('Please wait'),
));
- }
+ $arr = array('item' => $item, 'output' => $tmp_item);
+ call_hooks('display_item', $arr);
- return $o;
- }
+ $threads[$threadsid] .= $arr['output'];
+ }
+ }
+ else
+ {
+ // Normal View
- // Normal View
+ // Figure out how many comments each parent has
+ // (Comments all have gravity of 6)
+ // Store the result in the $comments array
+ $comments = array();
+ foreach($items as $item) {
+ if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
+ if(! x($comments,$item['parent']))
+ $comments[$item['parent']] = 1;
+ else
+ $comments[$item['parent']] += 1;
+ }
+ }
- // Figure out how many comments each parent has
- // (Comments all have gravity of 6)
- // Store the result in the $comments array
+ // map all the like/dislike activities for each parent item
+ // Store these in the $alike and $dlike arrays
- $comments = array();
- foreach($items as $item) {
- if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
- if(! x($comments,$item['parent']))
- $comments[$item['parent']] = 1;
- else
- $comments[$item['parent']] += 1;
+ foreach($items as $item) {
+ like_puller($a,$item,$alike,'like');
+ like_puller($a,$item,$dlike,'dislike');
}
- }
-
- // map all the like/dislike activities for each parent item
- // Store these in the $alike and $dlike arrays
- foreach($items as $item) {
- like_puller($a,$item,$alike,'like');
- like_puller($a,$item,$dlike,'dislike');
- }
+ $comments_collapsed = false;
+ $blowhard = 0;
+ $blowhard_count = 0;
- $comments_collapsed = false;
- $blowhard = 0;
- $blowhard_count = 0;
- foreach($items as $item) {
+ foreach($items as $item) {
- $comment = '';
- $template = $tpl;
- $commentww = '';
- $sparkle = '';
- $owner_url = $owner_photo = $owner_name = '';
+ $comment = '';
+ $template = $tpl;
+ $commentww = '';
+ $sparkle = '';
+ $owner_url = $owner_photo = $owner_name = '';
- // We've already parsed out like/dislike for special treatment. We can ignore them now
+ // We've already parsed out like/dislike for special treatment. We can ignore them now
- if(((activity_match($item['verb'],ACTIVITY_LIKE))
- || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
- && ($item['id'] != $item['parent']))
- continue;
+ if(((activity_match($item['verb'],ACTIVITY_LIKE))
+ || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
+ && ($item['id'] != $item['parent']))
+ continue;
- $toplevelpost = (($item['id'] == $item['parent']) ? true : false);
- $toplevelprivate = false;
+ $toplevelpost = (($item['id'] == $item['parent']) ? true : false);
+ $toplevelprivate = false;
- // Take care of author collapsing and comment collapsing
- // If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
- // If there are more than two comments, squash all but the last 2.
-
- if($toplevelpost) {
- $toplevelprivate = (($toplevelpost && $item['private']) ? true : false);
- $item_writeable = (($item['writable'] || $item['self']) ? true : false);
-
- if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile') && ($mode != 'notes')) {
- $blowhard_count ++;
- if($blowhard_count == 3) {
- $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent']
- . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\'); $(\'#icollapse-wrapper-' . $item['parent'] . '\').hide();" >'
- . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-'
- . $item['parent'] . '" style="display: none;" >';
+ // Take care of author collapsing and comment collapsing
+ // If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
+ // If there are more than two comments, squash all but the last 2.
+
+ if($toplevelpost) {
+ $toplevelprivate = (($toplevelpost && $item['private']) ? true : false);
+ $item_writeable = (($item['writable'] || $item['self']) ? true : false);
+
+ /*if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile') && ($mode != 'notes')) {
+ $blowhard_count ++;
+ if($blowhard_count == 3) {
+ $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent']
+ . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\'); $(\'#icollapse-wrapper-' . $item['parent'] . '\').hide();" >'
+ . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-'
+ . $item['parent'] . '" style="display: none;" >';
+ }
}
+ else {
+ $blowhard = $item['cid'];
+ if($blowhard_count >= 3)
+ $o .= '</div>';
+ $blowhard_count = 0;
+ }*/
+
+ $comments_seen = 0;
+ $comments_collapsed = false;
+
+ $threadsid++;
+ $threads[$threadsid] = "";
}
else {
- $blowhard = $item['cid'];
- if($blowhard_count >= 3)
- $o .= '</div>';
- $blowhard_count = 0;
+ // prevent private email from leaking into public conversation
+ if((! $toplevelpost) && (! toplevelprivate) && ($item['private']) && ($profile_owner != local_user()))
+ continue;
+ $comments_seen ++;
+ }
+
+ $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false);
+ $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
+
+ if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+ if(! $comments_collapsed) {
+ $threads[$threadsid] .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent']
+ . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\'); $(\'#ccollapse-wrapper-' . $item['parent'] . '\').hide();" >'
+ . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'
+ . '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
+ $comments_collapsed = true;
+ }
}
-
- $comments_seen = 0;
- $comments_collapsed = false;
- }
- else {
- // prevent private email from leaking into public conversation
- if((! $toplevelpost) && (! toplevelprivate) && ($item['private']) && ($profile_owner != local_user()))
- continue;
- $comments_seen ++;
- }
-
- $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false);
- $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
-
- if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
- if(! $comments_collapsed) {
- $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent']
- . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\'); $(\'#ccollapse-wrapper-' . $item['parent'] . '\').hide();" >'
- . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'
- . '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
- $comments_collapsed = true;
+ if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
+ $threads[$threadsid] .= '</div>';
}
- }
- if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
- $o .= '</div>';
- }
- $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
+ $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
- $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
- || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
- ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
- : '<div class="wall-item-lock"></div>');
+ $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
+ || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
+ ? t('Private Message')
+ : false);
- // Top-level wall post not written by the wall owner (wall-to-wall)
- // First figure out who owns it.
+ // Top-level wall post not written by the wall owner (wall-to-wall)
+ // First figure out who owns it.
- $osparkle = '';
+ $osparkle = '';
- if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
+ if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
- if($item['wall']) {
+ if($item['wall']) {
- // On the network page, I am the owner. On the display page it will be the profile owner.
- // This will have been stored in $a->page_contact by our calling page.
- // Put this person on the left of the wall-to-wall notice.
+ // On the network page, I am the owner. On the display page it will be the profile owner.
+ // This will have been stored in $a->page_contact by our calling page.
+ // Put this person on the left of the wall-to-wall notice.
- $owner_url = $a->page_contact['url'];
- $owner_photo = $a->page_contact['thumb'];
- $owner_name = $a->page_contact['name'];
- $template = $wallwall;
- $commentww = 'ww';
- }
- if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
-
- // Could be anybody.
-
- $owner_url = $item['owner-link'];
- $owner_photo = $item['owner-avatar'];
- $owner_name = $item['owner-name'];
- $template = $wallwall;
- $commentww = 'ww';
- // If it is our contact, use a friendly redirect link
- if((link_compare($item['owner-link'],$item['url']))
- && ($item['network'] === 'dfrn')) {
- $owner_url = $redirect_url;
- $osparkle = ' sparkle';
+ $owner_url = $a->page_contact['url'];
+ $owner_photo = $a->page_contact['thumb'];
+ $owner_name = $a->page_contact['name'];
+ $template = $wallwall;
+ $commentww = 'ww';
+ }
+ if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
+
+ // Could be anybody.
+
+ $owner_url = $item['owner-link'];
+ $owner_photo = $item['owner-avatar'];
+ $owner_name = $item['owner-name'];
+ $template = $wallwall;
+ $commentww = 'ww';
+ // If it is our contact, use a friendly redirect link
+ if((link_compare($item['owner-link'],$item['url']))
+ && ($item['network'] === 'dfrn')) {
+ $owner_url = $redirect_url;
+ $osparkle = ' sparkle';
+ }
}
}
- }
+ $likebuttons = '';
+ $shareable = ((($profile_owner == local_user()) && ($mode != 'display') && (! $item['private'])) ? true : false);
- $likebuttons = '';
+ if($page_writeable) {
+ if($toplevelpost) {
+ $likebuttons = array(
+ 'like' => array( t("I like this \x28toggle\x29"), t("like")),
+ 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")),
+ );
+ if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share'));
+ }
- if($page_writeable) {
- if($toplevelpost) {
- $likebuttons = replace_macros((($item['private'] || ($profile_owner != local_user())) ? $noshare_tpl : $like_tpl),array(
- '$id' => $item['id'],
- '$likethis' => t("I like this \x28toggle\x29"),
- '$nolike' => t("I don't like this \x28toggle\x29"),
- '$share' => t('Share'),
- '$wait' => t('Please wait')
- ));
+ if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
+ $comment = replace_macros($cmnt_tpl,array(
+ '$return_path' => '',
+ '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
+ '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'),
+ '$id' => $item['item_id'],
+ '$parent' => $item['parent'],
+ '$profile_uid' => $profile_owner,
+ '$mylink' => $a->contact['url'],
+ '$mytitle' => t('This is you'),
+ '$myphoto' => $a->contact['thumb'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
+ '$ww' => (($mode === 'network') ? $commentww : '')
+ ));
+ }
}
- if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
- $comment = replace_macros($cmnt_tpl,array(
- '$return_path' => '',
- '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
- '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'),
- '$id' => $item['item_id'],
- '$parent' => $item['parent'],
- '$profile_uid' => $profile_owner,
- '$mylink' => $a->contact['url'],
- '$mytitle' => t('This is you'),
- '$myphoto' => $a->contact['thumb'],
- '$comment' => t('Comment'),
- '$submit' => t('Submit'),
- '$ww' => (($mode === 'network') ? $commentww : '')
- ));
+ $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes'))
+ ? array($a->get_baseurl()."/editpost/".$item['id'], t("Edit"))
+ : False);
+
+
+ $drop = '';
+ $dropping = false;
+
+ if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+ $dropping = true;
+
+ $drop = array(
+ 'dropping' => $dropping,
+ 'select' => t('Select'),
+ 'delete' => t('Delete'),
+ );
+
+ $star = false;
+ $isstarred = "unstarred";
+ if ($profile_owner == local_user() && $toplevelpost) {
+ $isstarred = (($item['starred']) ? "starred" : "unstarred");
+
+ $star = array(
+ 'do' => t("add star"),
+ 'undo' => t("remove star"),
+ 'toggle' => t("toggle star status"),
+ 'classdo' => (($item['starred']) ? "hidden" : ""),
+ 'classundo' => (($item['starred']) ? "" : "hidden"),
+ 'starred' => t('starred'),
+ );
}
- }
- $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes'))
- ? '<a class="editpost icon pencil" href="' . $a->get_baseurl() . '/editpost/' . $item['id']
- . '" title="' . t('Edit') . '"></a>'
- : '');
- $drop = '';
- $dropping = false;
+ $photo = $item['photo'];
+ $thumb = $item['thumb'];
- if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
- $dropping = true;
+ // Post was remotely authored.
- $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$select' => t('Select'), '$delete' => t('Delete')));
+ $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
- $star = (($profile_owner == local_user() && $toplevelpost) ? '<a href="#" id="starred-' . $item['id'] . '" onclick="dostar(' . $item['id'] . '); return false;" class="star-item icon ' . (($item['starred']) ? 'starred' : 'unstarred') . '" title="' . t('toggle star status') . '"></a>' : '');
+ $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
+ $sp = false;
+ $profile_link = best_link_url($item,$sp);
+ if($sp)
+ $sparkle = ' sparkle';
- $photo = $item['photo'];
- $thumb = $item['thumb'];
+ if($profile_link === 'mailbox')
+ $profile_link = '';
- // Post was remotely authored.
+ $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
+ if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
+ $profile_avatar = $a->contacts[$normalised]['thumb'];
+ else
+ $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
- $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
- $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
- $sp = false;
- $profile_link = best_link_url($item,$sp);
- if($sp)
- $sparkle = ' sparkle';
- if($profile_link === 'mailbox')
- $profile_link = '';
- $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
- if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
- $profile_avatar = $a->contacts[$normalised]['thumb'];
- else
- $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
+ $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
+ $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
+ $location = (($item['location']) ? '<a target="map" title="' . $item['location']
+ . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+ $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord']
+ . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
+ if($coord) {
+ if($location)
+ $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+ else
+ $location = '<span class="smalltext">' . $coord . '</span>';
+ }
+ $indent = (($toplevelpost) ? '' : ' comment');
+ if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
+ $indent .= ' shiny';
+ //
+ localize_item($item);
- $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
- $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
+ // Build the HTML
- $location = (($item['location']) ? '<a target="map" title="' . $item['location']
- . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
- $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord']
- . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
- if($coord) {
- if($location)
- $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
- else
- $location = '<span class="smalltext">' . $coord . '</span>';
- }
+ $body = prepare_body($item,true);
+
+
+ $tmp_item = replace_macros($template,array(
+ '$body' => template_escape($body),
+ '$id' => $item['item_id'],
+ '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
+ '$olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
+ '$to' => t('to'),
+ '$wall' => t('Wall-to-Wall'),
+ '$vwall' => t('via Wall-To-Wall:'),
+ '$profile_url' => $profile_link,
+ '$item_photo_menu' => item_photo_menu($item),
+ '$name' => template_escape($profile_name),
+ '$thumb' => $profile_avatar,
+ '$osparkle' => $osparkle,
+ '$sparkle' => $sparkle,
+ '$title' => template_escape($item['title']),
+ '$ago' => ((($item['app']) && ($item['id'] == $item['parent'])) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
+ '$lock' => $lock,
+ '$location' => template_escape($location),
+ '$indent' => $indent,
+ '$owner_url' => $owner_url,
+ '$owner_photo' => $owner_photo,
+ '$owner_name' => template_escape($owner_name),
+ '$plink' => get_plink($item),
+ '$edpost' => $edpost,
+ '$isstarred' => $isstarred,
+ '$star' => $star,
+ '$drop' => $drop,
+ '$vote' => $likebuttons,
+ '$like' => $like,
+ '$dislike' => $dislike,
+ '$comment' => $comment,
+ '$wait' => t('Please wait'),
+
+ ));
- $indent = (($toplevelpost) ? '' : ' comment');
-
- if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
- $indent .= ' shiny';
-
- //
- localize_item($item);
-
- // Build the HTML
-
- $body = prepare_body($item,true);
-
-
- $tmp_item = replace_macros($template,array(
- '$id' => $item['item_id'],
- '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
- '$olinktitle' => sprintf( t('View %s\'s profile'), $owner_name),
- '$to' => t('to'),
- '$wall' => t('Wall-to-Wall'),
- '$vwall' => t('via Wall-To-Wall:'),
- '$profile_url' => $profile_link,
- '$item_photo_menu' => item_photo_menu($item),
- '$name' => $profile_name,
- '$thumb' => $profile_avatar,
- '$osparkle' => $osparkle,
- '$sparkle' => $sparkle,
- '$title' => $item['title'],
- '$body' => $body,
- '$ago' => ((($item['app']) && ($item['id'] == $item['parent'])) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- '$lock' => $lock,
- '$location' => $location,
- '$indent' => $indent,
- '$owner_url' => $owner_url,
- '$owner_photo' => $owner_photo,
- '$owner_name' => $owner_name,
- '$plink' => get_plink($item),
- '$edpost' => $edpost,
- '$star' => $star,
- '$drop' => $drop,
- '$vote' => $likebuttons,
- '$like' => $like,
- '$dislike' => $dislike,
- '$comment' => $comment
- ));
-
-
- $arr = array('item' => $item, 'output' => $tmp_item);
- call_hooks('display_item', $arr);
-
- $o .= $arr['output'];
+ $arr = array('item' => $item, 'output' => $tmp_item);
+ call_hooks('display_item', $arr);
+
+ $threads[$threadsid] .= $arr['output'];
+ }
}
}
// if author collapsing is in force but didn't get closed, close it off now.
- if($blowhard_count >= 3)
- $o .= '</div>';
+ /*if($blowhard_count >= 3)
+ $threads[$threadsid] .= '</div>';*/
- if($dropping)
- $o .= '<div id="item-delete-selected" class="fakelink" onclick="deleteCheckedItems();"><div id="item-delete-selected-icon" class="icon drophide" title="' . t('Delete Selected Items') . '" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></div><div id="item-delete-selected-desc" >' . t('Delete Selected Items') . '</div></div><div id="item-delete-selected-end"></div>';
+ $page_template = get_markup_template("conversation.tpl");
+ $o .= replace_macros($page_template, array(
+ '$threads' => $threads,
+ '$dropping' => ($dropping?t('Delete Selected Items'):False),
+ ));
return $o;
}
@@ -728,7 +776,7 @@ function status_editor($a,$x, $notes_cid = 0) {
if($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
- $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+ $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
. t("Post to Email") . '</div>';
}
diff --git a/include/country.js b/include/country.js
deleted file mode 100644
index 07ab29ba6..000000000
--- a/include/country.js
+++ /dev/null
@@ -1,438 +0,0 @@
-//<!-- Docs at: http://www.microcosmotalk.com/tech/scripts/
-// NOTE:
-// This code is placed into the public domain and may be used in any manner desired.
-//
-// Jim Carlock obtained the list of country names and state names from an HTML
-// document at Microsoft's website.
-//
-// Thursday, January 13, 2005, 7:00:52 PM
-//
-var gLngMaxStateLength=0;
-var gLngMaxCountryLength=0;
-var gLngNumberCountries=252;
-var gLngNumberStates=0;
-var gLngSelectedCountry=0;
-var gLngSelectedState=0;
-var gArCountryInfo;
-var gArStateInfo;
-// NOTE:
-// Some editors may exhibit problems viewing 2803 characters...
-var sCountryString = "|Afghanistan|Albania|Algeria|American Samoa|Angola|Anguilla|Antartica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier Island|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Cayman Islands|Central African Republic|Chad|Chile|China|Christmas Island|Clipperton Island|Cocos (Keeling) Islands|Colombia|Comoros|Congo, Democratic Republic of the|Congo, Republic of the|Cook Islands|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Cyprus|Czech Republic|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Europa Island|Falkland Islands (Islas Malvinas)|Faroe Islands|Fiji|Finland|France|French Guiana|French Polynesia|French Southern and Antarctic Lands|Gabon|Gambia, The|Gaza Strip|Georgia|Germany|Ghana|Gibraltar|Glorioso Islands|Greece|Greenland|Grenada|Guadeloupe|Guam|Guatemala|Guernsey|Guinea|Guinea-Bissau|Guyana|Haiti|Heard Island and McDonald Islands|Holy See (Vatican City)|Honduras|Hong Kong|Howland Island|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Ireland, Northern|Israel|Italy|Jamaica|Jan Mayen|Japan|Jarvis Island|Jersey|Johnston Atoll|Jordan|Juan de Nova Island|Kazakhstan|Kenya|Kiribati|Korea, North|Korea, South|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macau|Macedonia, Former Yugoslav Republic of|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Man, Isle of|Marshall Islands|Martinique|Mauritania|Mauritius|Mayotte|Mexico|Micronesia, Federated States of|Midway Islands|Moldova|Monaco|Mongolia|Montserrat|Morocco|Mozambique|Namibia|Nauru|Nepal|Netherlands|Netherlands Antilles|New Caledonia|New Zealand|Nicaragua|Niger|Nigeria|Niue|Norfolk Island|Northern Mariana Islands|Norway|Oman|Pakistan|Palau|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Pitcaim Islands|Poland|Portugal|Puerto Rico|Qatar|Reunion|Romainia|Russia|Rwanda|Saint Helena|Saint Kitts and Nevis|Saint Lucia|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Scotland|Senegal|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Georgia and South Sandwich Islands|Spain|Spratly Islands|Sri Lanka|Sudan|Suriname|Svalbard|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Tobago|Toga|Tokelau|Tonga|Trinidad|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|Uruguay|USA|Uzbekistan|Vanuatu|Venezuela|Vietnam|Virgin Islands|Wales|Wallis and Futuna|West Bank|Western Sahara|Yemen|Yugoslavia|Zambia|Zimbabwe";
-var aStates = new Array();
-
-aStates[0]="";
-aStates[1]="|Badakhshan|Badghis|Baghlan|Balkh|Bamian|Farah|Faryab|Ghazni|Ghowr|Helmand|Herat|Jowzjan|Kabol|Kandahar|Kapisa|Konar|Kondoz|Laghman|Lowgar|Nangarhar|Nimruz|Oruzgan|Paktia|Paktika|Parvan|Samangan|Sar-e Pol|Takhar|Vardak|Zabol";
-aStates[2]="|Berat|Bulqize|Delvine|Devoll (Bilisht)|Diber (Peshkopi)|Durres|Elbasan|Fier|Gjirokaster|Gramsh|Has (Krume)|Kavaje|Kolonje (Erseke)|Korce|Kruje|Kucove|Kukes|Kurbin|Lezhe|Librazhd|Lushnje|Malesi e Madhe (Koplik)|Mallakaster (Ballsh)|Mat (Burrel)|Mirdite (Rreshen)|Peqin|Permet|Pogradec|Puke|Sarande|Shkoder|Skrapar (Corovode)|Tepelene|Tirane (Tirana)|Tirane (Tirana)|Tropoje (Bajram Curri)|Vlore";
-aStates[3]="|Adrar|Ain Defla|Ain Temouchent|Alger|Annaba|Batna|Bechar|Bejaia|Biskra|Blida|Bordj Bou Arreridj|Bouira|Boumerdes|Chlef|Constantine|Djelfa|El Bayadh|El Oued|El Tarf|Ghardaia|Guelma|Illizi|Jijel|Khenchela|Laghouat|M'Sila|Mascara|Medea|Mila|Mostaganem|Naama|Oran|Ouargla|Oum el Bouaghi|Relizane|Saida|Setif|Sidi Bel Abbes|Skikda|Souk Ahras|Tamanghasset|Tebessa|Tiaret|Tindouf|Tipaza|Tissemsilt|Tizi Ouzou|Tlemcen";
-aStates[4]="|Eastern|Manu'a|Rose Island|Swains Island|Western";
-aStates[5]="|Andorra la Vella|Bengo|Benguela|Bie|Cabinda|Canillo|Cuando Cubango|Cuanza Norte|Cuanza Sul|Cunene|Encamp|Escaldes-Engordany|Huambo|Huila|La Massana|Luanda|Lunda Norte|Lunda Sul|Malanje|Moxico|Namibe|Ordino|Sant Julia de Loria|Uige|Zaire";
-aStates[6]="|Anguilla";
-aStates[7]="|Antartica";
-aStates[8]="|Barbuda|Redonda|Saint George|Saint John|Saint Mary|Saint Paul|Saint Peter|Saint Philip";
-aStates[9]="|Antartica e Islas del Atlantico Sur|Buenos Aires|Buenos Aires Capital Federal|Catamarca|Chaco|Chubut|Cordoba|Corrientes|Entre Rios|Formosa|Jujuy|La Pampa|La Rioja|Mendoza|Misiones|Neuquen|Rio Negro|Salta|San Juan|San Luis|Santa Cruz|Santa Fe|Santiago del Estero|Tierra del Fuego|Tucuman";
-aStates[10]="|Aragatsotn|Ararat|Armavir|Geghark'unik'|Kotayk'|Lorri|Shirak|Syunik'|Tavush|Vayots' Dzor|Yerevan";
-aStates[11]="|Aruba";
-aStates[12]="|Ashmore and Cartier Island";
-aStates[13]="|Australian Capital Territory|New South Wales|Northern Territory|Queensland|South Australia|Tasmania|Victoria|Western Australia";
-aStates[14]="|Burgenland|Kaernten|Niederoesterreich|Oberoesterreich|Salzburg|Steiermark|Tirol|Vorarlberg|Wien";
-aStates[15]="|Abseron Rayonu|Agcabadi Rayonu|Agdam Rayonu|Agdas Rayonu|Agstafa Rayonu|Agsu Rayonu|Ali Bayramli Sahari|Astara Rayonu|Baki Sahari|Balakan Rayonu|Barda Rayonu|Beylaqan Rayonu|Bilasuvar Rayonu|Cabrayil Rayonu|Calilabad Rayonu|Daskasan Rayonu|Davaci Rayonu|Fuzuli Rayonu|Gadabay Rayonu|Ganca Sahari|Goranboy Rayonu|Goycay Rayonu|Haciqabul Rayonu|Imisli Rayonu|Ismayilli Rayonu|Kalbacar Rayonu|Kurdamir Rayonu|Lacin Rayonu|Lankaran Rayonu|Lankaran Sahari|Lerik Rayonu|Masalli Rayonu|Mingacevir Sahari|Naftalan Sahari|Naxcivan Muxtar Respublikasi|Neftcala Rayonu|Oguz Rayonu|Qabala Rayonu|Qax Rayonu|Qazax Rayonu|Qobustan Rayonu|Quba Rayonu|Qubadli Rayonu|Qusar Rayonu|Saatli Rayonu|Sabirabad Rayonu|Saki Rayonu|Saki Sahari|Salyan Rayonu|Samaxi Rayonu|Samkir Rayonu|Samux Rayonu|Siyazan Rayonu|Sumqayit Sahari|Susa Rayonu|Susa Sahari|Tartar Rayonu|Tovuz Rayonu|Ucar Rayonu|Xacmaz Rayonu|Xankandi Sahari|Xanlar Rayonu|Xizi Rayonu|Xocali Rayonu|Xocavand Rayonu|Yardimli Rayonu|Yevlax Rayonu|Yevlax Sahari|Zangilan Rayonu|Zaqatala Rayonu|Zardab Rayonu";
-aStates[16]="|Acklins and Crooked Islands|Bimini|Cat Island|Exuma|Freeport|Fresh Creek|Governor's Harbour|Green Turtle Cay|Harbour Island|High Rock|Inagua|Kemps Bay|Long Island|Marsh Harbour|Mayaguana|New Providence|Nicholls Town and Berry Islands|Ragged Island|Rock Sound|San Salvador and Rum Cay|Sandy Point";
-aStates[17]="|Al Hadd|Al Manamah|Al Mintaqah al Gharbiyah|Al Mintaqah al Wusta|Al Mintaqah ash Shamaliyah|Al Muharraq|Ar Rifa' wa al Mintaqah al Janubiyah|Jidd Hafs|Juzur Hawar|Madinat 'Isa|Madinat Hamad|Sitrah";
-aStates[18]="|Barisal|Chittagong|Dhaka|Khulna|Rajshahi|Sylhet";
-aStates[19]="|Bridgetown|Christ Church|Saint Andrew|Saint George|Saint James|Saint John|Saint Joseph|Saint Lucy|Saint Michael|Saint Peter|Saint Philip|Saint Thomas";
-aStates[20]="|Brestskaya (Brest)|Homyel'skaya (Homyel')|Horad Minsk|Hrodzyenskaya (Hrodna)|Mahilyowskaya (Mahilyow)|Minskaya|Vitsyebskaya (Vitsyebsk)";
-aStates[21]="|Antwerpen|Brabant Wallon|Brussels Capitol Region|Hainaut|Liege|Limburg|Luxembourg|Namur|Oost-Vlaanderen|Vlaams Brabant|West-Vlaanderen";
-aStates[22]="|Belize|Cayo|Corozal|Orange Walk|Stann Creek|Toledo";
-aStates[23]="|Alibori|Atakora|Atlantique|Borgou|Collines|Couffo|Donga|Littoral|Mono|Oueme|Plateau|Zou";
-aStates[24]="|Devonshire|Hamilton|Hamilton|Paget|Pembroke|Saint George|Saint Georges|Sandys|Smiths|Southampton|Warwick";
-aStates[25]="|Bumthang|Chhukha|Chirang|Daga|Geylegphug|Ha|Lhuntshi|Mongar|Paro|Pemagatsel|Punakha|Samchi|Samdrup Jongkhar|Shemgang|Tashigang|Thimphu|Tongsa|Wangdi Phodrang";
-aStates[26]="|Beni|Chuquisaca|Cochabamba|La Paz|Oruro|Pando|Potosi|Santa Cruz|Tarija";
-aStates[27]="|Federation of Bosnia and Herzegovina|Republika Srpska";
-aStates[28]="|Central|Chobe|Francistown|Gaborone|Ghanzi|Kgalagadi|Kgatleng|Kweneng|Lobatse|Ngamiland|North-East|Selebi-Pikwe|South-East|Southern";
-aStates[29]="|Acre|Alagoas|Amapa|Amazonas|Bahia|Ceara|Distrito Federal|Espirito Santo|Goias|Maranhao|Mato Grosso|Mato Grosso do Sul|Minas Gerais|Para|Paraiba|Parana|Pernambuco|Piaui|Rio de Janeiro|Rio Grande do Norte|Rio Grande do Sul|Rondonia|Roraima|Santa Catarina|Sao Paulo|Sergipe|Tocantins";
-aStates[30]="|Anegada|Jost Van Dyke|Tortola|Virgin Gorda";
-aStates[31]="|Belait|Brunei and Muara|Temburong|Tutong";
-aStates[32]="|Blagoevgrad|Burgas|Dobrich|Gabrovo|Khaskovo|Kurdzhali|Kyustendil|Lovech|Montana|Pazardzhik|Pernik|Pleven|Plovdiv|Razgrad|Ruse|Shumen|Silistra|Sliven|Smolyan|Sofiya|Sofiya-Grad|Stara Zagora|Turgovishte|Varna|Veliko Turnovo|Vidin|Vratsa|Yambol";
-aStates[33]="|Bale|Bam|Banwa|Bazega|Bougouriba|Boulgou|Boulkiemde|Comoe|Ganzourgou|Gnagna|Gourma|Houet|Ioba|Kadiogo|Kenedougou|Komandjari|Kompienga|Kossi|Koupelogo|Kouritenga|Kourweogo|Leraba|Loroum|Mouhoun|Nahouri|Namentenga|Naumbiel|Nayala|Oubritenga|Oudalan|Passore|Poni|Samentenga|Sanguie|Seno|Sissili|Soum|Sourou|Tapoa|Tuy|Yagha|Yatenga|Ziro|Zondomo|Zoundweogo";
-aStates[34]="|Ayeyarwady|Bago|Chin State|Kachin State|Kayah State|Kayin State|Magway|Mandalay|Mon State|Rakhine State|Sagaing|Shan State|Tanintharyi|Yangon";
-aStates[35]="|Bubanza|Bujumbura|Bururi|Cankuzo|Cibitoke|Gitega|Karuzi|Kayanza|Kirundo|Makamba|Muramvya|Muyinga|Mwaro|Ngozi|Rutana|Ruyigi";
-aStates[36]="|Banteay Mean Cheay|Batdambang|Kampong Cham|Kampong Chhnang|Kampong Spoe|Kampong Thum|Kampot|Kandal|Kaoh Kong|Keb|Kracheh|Mondol Kiri|Otdar Mean Cheay|Pailin|Phnum Penh|Pouthisat|Preah Seihanu (Sihanoukville)|Preah Vihear|Prey Veng|Rotanah Kiri|Siem Reab|Stoeng Treng|Svay Rieng|Takev";
-aStates[37]="|Adamaoua|Centre|Est|Extreme-Nord|Littoral|Nord|Nord-Ouest|Ouest|Sud|Sud-Ouest";
-aStates[38]="|Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland|Northwest Territories|Nova Scotia|Nunavut|Ontario|Prince Edward Island|Quebec|Saskatchewan|Yukon Territory";
-aStates[39]="|Boa Vista|Brava|Maio|Mosteiros|Paul|Porto Novo|Praia|Ribeira Grande|Sal|Santa Catarina|Santa Cruz|Sao Domingos|Sao Filipe|Sao Nicolau|Sao Vicente|Tarrafal";
-aStates[40]="|Creek|Eastern|Midland|South Town|Spot Bay|Stake Bay|West End|Western";
-aStates[41]="|Bamingui-Bangoran|Bangui|Basse-Kotto|Gribingui|Haut-Mbomou|Haute-Kotto|Haute-Sangha|Kemo-Gribingui|Lobaye|Mbomou|Nana-Mambere|Ombella-Mpoko|Ouaka|Ouham|Ouham-Pende|Sangha|Vakaga";
-aStates[42]="|Batha|Biltine|Borkou-Ennedi-Tibesti|Chari-Baguirmi|Guera|Kanem|Lac|Logone Occidental|Logone Oriental|Mayo-Kebbi|Moyen-Chari|Ouaddai|Salamat|Tandjile";
-aStates[43]="|Aisen del General Carlos Ibanez del Campo|Antofagasta|Araucania|Atacama|Bio-Bio|Coquimbo|Libertador General Bernardo O'Higgins|Los Lagos|Magallanes y de la Antartica Chilena|Maule|Region Metropolitana (Santiago)|Tarapaca|Valparaiso";
-aStates[44]="|Anhui|Beijing|Chongqing|Fujian|Gansu|Guangdong|Guangxi|Guizhou|Hainan|Hebei|Heilongjiang|Henan|Hubei|Hunan|Jiangsu|Jiangxi|Jilin|Liaoning|Nei Mongol|Ningxia|Qinghai|Shaanxi|Shandong|Shanghai|Shanxi|Sichuan|Tianjin|Xinjiang|Xizang (Tibet)|Yunnan|Zhejiang";
-aStates[45]="|Christmas Island";
-aStates[46]="|Clipperton Island";
-aStates[47]="|Direction Island|Home Island|Horsburgh Island|North Keeling Island|South Island|West Island";
-aStates[48]="|Amazonas|Antioquia|Arauca|Atlantico|Bolivar|Boyaca|Caldas|Caqueta|Casanare|Cauca|Cesar|Choco|Cordoba|Cundinamarca|Distrito Capital de Santa Fe de Bogota|Guainia|Guaviare|Huila|La Guajira|Magdalena|Meta|Narino|Norte de Santander|Putumayo|Quindio|Risaralda|San Andres y Providencia|Santander|Sucre|Tolima|Valle del Cauca|Vaupes|Vichada";
-// <!-- -->
-aStates[49]="|Anjouan (Nzwani)|Domoni|Fomboni|Grande Comore (Njazidja)|Moheli (Mwali)|Moroni|Moutsamoudou";
-aStates[50]="|Bandundu|Bas-Congo|Equateur|Kasai-Occidental|Kasai-Oriental|Katanga|Kinshasa|Maniema|Nord-Kivu|Orientale|Sud-Kivu";
-aStates[51]="|Bouenza|Brazzaville|Cuvette|Kouilou|Lekoumou|Likouala|Niari|Plateaux|Pool|Sangha";
-aStates[52]="|Aitutaki|Atiu|Avarua|Mangaia|Manihiki|Manuae|Mauke|Mitiaro|Nassau Island|Palmerston|Penrhyn|Pukapuka|Rakahanga|Rarotonga|Suwarrow|Takutea";
-aStates[53]="|Alajuela|Cartago|Guanacaste|Heredia|Limon|Puntarenas|San Jose";
-aStates[54]="|Abengourou|Abidjan|Aboisso|Adiake'|Adzope|Agboville|Agnibilekrou|Ale'pe'|Bangolo|Beoumi|Biankouma|Bocanda|Bondoukou|Bongouanou|Bouafle|Bouake|Bouna|Boundiali|Dabakala|Dabon|Daloa|Danane|Daoukro|Dimbokro|Divo|Duekoue|Ferkessedougou|Gagnoa|Grand Bassam|Grand-Lahou|Guiglo|Issia|Jacqueville|Katiola|Korhogo|Lakota|Man|Mankono|Mbahiakro|Odienne|Oume|Sakassou|San-Pedro|Sassandra|Seguela|Sinfra|Soubre|Tabou|Tanda|Tiassale|Tiebissou|Tingrela|Touba|Toulepleu|Toumodi|Vavoua|Yamoussoukro|Zuenoula";
-aStates[55]="|Bjelovarsko-Bilogorska Zupanija|Brodsko-Posavska Zupanija|Dubrovacko-Neretvanska Zupanija|Istarska Zupanija|Karlovacka Zupanija|Koprivnicko-Krizevacka Zupanija|Krapinsko-Zagorska Zupanija|Licko-Senjska Zupanija|Medimurska Zupanija|Osjecko-Baranjska Zupanija|Pozesko-Slavonska Zupanija|Primorsko-Goranska Zupanija|Sibensko-Kninska Zupanija|Sisacko-Moslavacka Zupanija|Splitsko-Dalmatinska Zupanija|Varazdinska Zupanija|Viroviticko-Podravska Zupanija|Vukovarsko-Srijemska Zupanija|Zadarska Zupanija|Zagreb|Zagrebacka Zupanija";
-aStates[56]="|Camaguey|Ciego de Avila|Cienfuegos|Ciudad de La Habana|Granma|Guantanamo|Holguin|Isla de la Juventud|La Habana|Las Tunas|Matanzas|Pinar del Rio|Sancti Spiritus|Santiago de Cuba|Villa Clara";
-aStates[57]="|Famagusta|Kyrenia|Larnaca|Limassol|Nicosia|Paphos";
-aStates[58]="|Brnensky|Budejovicky|Jihlavsky|Karlovarsky|Kralovehradecky|Liberecky|Olomoucky|Ostravsky|Pardubicky|Plzensky|Praha|Stredocesky|Ustecky|Zlinsky";
-aStates[59]="|Arhus|Bornholm|Fredericksberg|Frederiksborg|Fyn|Kobenhavn|Kobenhavns|Nordjylland|Ribe|Ringkobing|Roskilde|Sonderjylland|Storstrom|Vejle|Vestsjalland|Viborg";
-aStates[60]="|'Ali Sabih|Dikhil|Djibouti|Obock|Tadjoura";
-aStates[61]="|Saint Andrew|Saint David|Saint George|Saint John|Saint Joseph|Saint Luke|Saint Mark|Saint Patrick|Saint Paul|Saint Peter";
-aStates[62]="|Azua|Baoruco|Barahona|Dajabon|Distrito Nacional|Duarte|El Seibo|Elias Pina|Espaillat|Hato Mayor|Independencia|La Altagracia|La Romana|La Vega|Maria Trinidad Sanchez|Monsenor Nouel|Monte Cristi|Monte Plata|Pedernales|Peravia|Puerto Plata|Salcedo|Samana|San Cristobal|San Juan|San Pedro de Macoris|Sanchez Ramirez|Santiago|Santiago Rodriguez|Valverde";
-// <!-- -->
-aStates[63]="|Azuay|Bolivar|Canar|Carchi|Chimborazo|Cotopaxi|El Oro|Esmeraldas|Galapagos|Guayas|Imbabura|Loja|Los Rios|Manabi|Morona-Santiago|Napo|Orellana|Pastaza|Pichincha|Sucumbios|Tungurahua|Zamora-Chinchipe";
-aStates[64]="|Ad Daqahliyah|Al Bahr al Ahmar|Al Buhayrah|Al Fayyum|Al Gharbiyah|Al Iskandariyah|Al Isma'iliyah|Al Jizah|Al Minufiyah|Al Minya|Al Qahirah|Al Qalyubiyah|Al Wadi al Jadid|As Suways|Ash Sharqiyah|Aswan|Asyut|Bani Suwayf|Bur Sa'id|Dumyat|Janub Sina'|Kafr ash Shaykh|Matruh|Qina|Shamal Sina'|Suhaj";
-aStates[65]="|Ahuachapan|Cabanas|Chalatenango|Cuscatlan|La Libertad|La Paz|La Union|Morazan|San Miguel|San Salvador|San Vicente|Santa Ana|Sonsonate|Usulutan";
-aStates[66]="|Annobon|Bioko Norte|Bioko Sur|Centro Sur|Kie-Ntem|Litoral|Wele-Nzas";
-aStates[67]="|Akale Guzay|Barka|Denkel|Hamasen|Sahil|Semhar|Senhit|Seraye";
-aStates[68]="|Harjumaa (Tallinn)|Hiiumaa (Kardla)|Ida-Virumaa (Johvi)|Jarvamaa (Paide)|Jogevamaa (Jogeva)|Laane-Virumaa (Rakvere)|Laanemaa (Haapsalu)|Parnumaa (Parnu)|Polvamaa (Polva)|Raplamaa (Rapla)|Saaremaa (Kuessaare)|Tartumaa (Tartu)|Valgamaa (Valga)|Viljandimaa (Viljandi)|Vorumaa (Voru)"
-aStates[69]="|Adis Abeba (Addis Ababa)|Afar|Amara|Dire Dawa|Gambela Hizboch|Hareri Hizb|Oromiya|Sumale|Tigray|YeDebub Biheroch Bihereseboch na Hizboch";
-aStates[70]="|Europa Island";
-aStates[71]="|Falkland Islands (Islas Malvinas)"
-aStates[72]="|Bordoy|Eysturoy|Mykines|Sandoy|Skuvoy|Streymoy|Suduroy|Tvoroyri|Vagar";
-aStates[73]="|Central|Eastern|Northern|Rotuma|Western";
-aStates[74]="|Aland|Etela-Suomen Laani|Ita-Suomen Laani|Lansi-Suomen Laani|Lappi|Oulun Laani";
-aStates[75]="|Alsace|Aquitaine|Auvergne|Basse-Normandie|Bourgogne|Bretagne|Centre|Champagne-Ardenne|Corse|Franche-Comte|Haute-Normandie|Ile-de-France|Languedoc-Roussillon|Limousin|Lorraine|Midi-Pyrenees|Nord-Pas-de-Calais|Pays de la Loire|Picardie|Poitou-Charentes|Provence-Alpes-Cote d'Azur|Rhone-Alpes";
-aStates[76]="|French Guiana";
-aStates[77]="|Archipel des Marquises|Archipel des Tuamotu|Archipel des Tubuai|Iles du Vent|Iles Sous-le-Vent";
-aStates[78]="|Adelie Land|Ile Crozet|Iles Kerguelen|Iles Saint-Paul et Amsterdam";
-aStates[79]="|Estuaire|Haut-Ogooue|Moyen-Ogooue|Ngounie|Nyanga|Ogooue-Ivindo|Ogooue-Lolo|Ogooue-Maritime|Woleu-Ntem";
-aStates[80]="|Banjul|Central River|Lower River|North Bank|Upper River|Western";
-aStates[81]="|Gaza Strip";
-aStates[82]="|Abashis|Abkhazia or Ap'khazet'is Avtonomiuri Respublika (Sokhumi)|Adigenis|Ajaria or Acharis Avtonomiuri Respublika (Bat'umi)|Akhalgoris|Akhalk'alak'is|Akhalts'ikhis|Akhmetis|Ambrolauris|Aspindzis|Baghdat'is|Bolnisis|Borjomis|Ch'khorotsqus|Ch'okhatauris|Chiat'ura|Dedop'listsqaros|Dmanisis|Dushet'is|Gardabanis|Gori|Goris|Gurjaanis|Javis|K'arelis|K'ut'aisi|Kaspis|Kharagaulis|Khashuris|Khobis|Khonis|Lagodekhis|Lanch'khut'is|Lentekhis|Marneulis|Martvilis|Mestiis|Mts'khet'is|Ninotsmindis|Onis|Ozurget'is|P'ot'i|Qazbegis|Qvarlis|Rust'avi|Sach'kheris|Sagarejos|Samtrediis|Senakis|Sighnaghis|T'bilisi|T'elavis|T'erjolis|T'et'ritsqaros|T'ianet'is|Tqibuli|Ts'ageris|Tsalenjikhis|Tsalkis|Tsqaltubo|Vanis|Zestap'onis|Zugdidi|Zugdidis";
-aStates[83]="|Baden-Wuerttemberg|Bayern|Berlin|Brandenburg|Bremen|Hamburg|Hessen|Mecklenburg-Vorpommern|Niedersachsen|Nordrhein-Westfalen|Rheinland-Pfalz|Saarland|Sachsen|Sachsen-Anhalt|Schleswig-Holstein|Thueringen";
-aStates[84]="|Ashanti|Brong-Ahafo|Central|Eastern|Greater Accra|Northern|Upper East|Upper West|Volta|Western";
-aStates[85]="|Gibraltar";
-aStates[86]="|Ile du Lys|Ile Glorieuse";
-aStates[87]="|Aitolia kai Akarnania|Akhaia|Argolis|Arkadhia|Arta|Attiki|Ayion Oros (Mt. Athos)|Dhodhekanisos|Drama|Evritania|Evros|Evvoia|Florina|Fokis|Fthiotis|Grevena|Ilia|Imathia|Ioannina|Irakleion|Kardhitsa|Kastoria|Kavala|Kefallinia|Kerkyra|Khalkidhiki|Khania|Khios|Kikladhes|Kilkis|Korinthia|Kozani|Lakonia|Larisa|Lasithi|Lesvos|Levkas|Magnisia|Messinia|Pella|Pieria|Preveza|Rethimni|Rodhopi|Samos|Serrai|Thesprotia|Thessaloniki|Trikala|Voiotia|Xanthi|Zakinthos";
-aStates[88]="|Avannaa (Nordgronland)|Kitaa (Vestgronland)|Tunu (Ostgronland)"
-aStates[89]="|Carriacou and Petit Martinique|Saint Andrew|Saint David|Saint George|Saint John|Saint Mark|Saint Patrick";
-aStates[90]="|Basse-Terre|Grande-Terre|Iles de la Petite Terre|Iles des Saintes|Marie-Galante";
-aStates[91]="|Guam";
-aStates[92]="|Alta Verapaz|Baja Verapaz|Chimaltenango|Chiquimula|El Progreso|Escuintla|Guatemala|Huehuetenango|Izabal|Jalapa|Jutiapa|Peten|Quetzaltenango|Quiche|Retalhuleu|Sacatepequez|San Marcos|Santa Rosa|Solola|Suchitepequez|Totonicapan|Zacapa";
-aStates[93]="|Castel|Forest|St. Andrew|St. Martin|St. Peter Port|St. Pierre du Bois|St. Sampson|St. Saviour|Torteval|Vale";
-aStates[94]="|Beyla|Boffa|Boke|Conakry|Coyah|Dabola|Dalaba|Dinguiraye|Dubreka|Faranah|Forecariah|Fria|Gaoual|Gueckedou|Kankan|Kerouane|Kindia|Kissidougou|Koubia|Koundara|Kouroussa|Labe|Lelouma|Lola|Macenta|Mali|Mamou|Mandiana|Nzerekore|Pita|Siguiri|Telimele|Tougue|Yomou";
-aStates[95]="|Bafata|Biombo|Bissau|Bolama-Bijagos|Cacheu|Gabu|Oio|Quinara|Tombali";
-aStates[96]="|Barima-Waini|Cuyuni-Mazaruni|Demerara-Mahaica|East Berbice-Corentyne|Essequibo Islands-West Demerara|Mahaica-Berbice|Pomeroon-Supenaam|Potaro-Siparuni|Upper Demerara-Berbice|Upper Takutu-Upper Essequibo";
-aStates[97]="|Artibonite|Centre|Grand'Anse|Nord|Nord-Est|Nord-Ouest|Ouest|Sud|Sud-Est";
-aStates[98]="|Heard Island and McDonald Islands";
-aStates[99]="|Holy See (Vatican City)"
-aStates[100]="|Atlantida|Choluteca|Colon|Comayagua|Copan|Cortes|El Paraiso|Francisco Morazan|Gracias a Dios|Intibuca|Islas de la Bahia|La Paz|Lempira|Ocotepeque|Olancho|Santa Barbara|Valle|Yoro";
-aStates[101]="|Hong Kong";
-aStates[102]="|Howland Island";
-aStates[103]="|Bacs-Kiskun|Baranya|Bekes|Bekescsaba|Borsod-Abauj-Zemplen|Budapest|Csongrad|Debrecen|Dunaujvaros|Eger|Fejer|Gyor|Gyor-Moson-Sopron|Hajdu-Bihar|Heves|Hodmezovasarhely|Jasz-Nagykun-Szolnok|Kaposvar|Kecskemet|Komarom-Esztergom|Miskolc|Nagykanizsa|Nograd|Nyiregyhaza|Pecs|Pest|Somogy|Sopron|Szabolcs-Szatmar-Bereg|Szeged|Szekesfehervar|Szolnok|Szombathely|Tatabanya|Tolna|Vas|Veszprem|Veszprem|Zala|Zalaegerszeg";
-aStates[104]="|Akranes|Akureyri|Arnessysla|Austur-Bardhastrandarsysla|Austur-Hunavatnssysla|Austur-Skaftafellssysla|Borgarfjardharsysla|Dalasysla|Eyjafjardharsysla|Gullbringusysla|Hafnarfjordhur|Husavik|Isafjordhur|Keflavik|Kjosarsysla|Kopavogur|Myrasysla|Neskaupstadhur|Nordhur-Isafjardharsysla|Nordhur-Mulasys-la|Nordhur-Thingeyjarsysla|Olafsfjordhur|Rangarvallasysla|Reykjavik|Saudharkrokur|Seydhisfjordhur|Siglufjordhur|Skagafjardharsysla|Snaefellsnes-og Hnappadalssysla|Strandasysla|Sudhur-Mulasysla|Sudhur-Thingeyjarsysla|Vesttmannaeyjar|Vestur-Bardhastrandarsysla|Vestur-Hunavatnssysla|Vestur-Isafjardharsysla|Vestur-Skaftafellssysla";
-aStates[105]="|Andaman and Nicobar Islands|Andhra Pradesh|Arunachal Pradesh|Assam|Bihar|Chandigarh|Chhattisgarh|Dadra and Nagar Haveli|Daman and Diu|Delhi|Goa|Gujarat|Haryana|Himachal Pradesh|Jammu and Kashmir|Jharkhand|Karnataka|Kerala|Lakshadweep|Madhya Pradesh|Maharashtra|Manipur|Meghalaya|Mizoram|Nagaland|Orissa|Pondicherry|Punjab|Rajasthan|Sikkim|Tamil Nadu|Tripura|Uttar Pradesh|Uttaranchal|West Bengal";
-aStates[106]="|Aceh|Bali|Banten|Bengkulu|East Timor|Gorontalo|Irian Jaya|Jakarta Raya|Jambi|Jawa Barat|Jawa Tengah|Jawa Timur|Kalimantan Barat|Kalimantan Selatan|Kalimantan Tengah|Kalimantan Timur|Kepulauan Bangka Belitung|Lampung|Maluku|Maluku Utara|Nusa Tenggara Barat|Nusa Tenggara Timur|Riau|Sulawesi Selatan|Sulawesi Tengah|Sulawesi Tenggara|Sulawesi Utara|Sumatera Barat|Sumatera Selatan|Sumatera Utara|Yogyakarta";
-aStates[107]="|Ardabil|Azarbayjan-e Gharbi|Azarbayjan-e Sharqi|Bushehr|Chahar Mahall va Bakhtiari|Esfahan|Fars|Gilan|Golestan|Hamadan|Hormozgan|Ilam|Kerman|Kermanshah|Khorasan|Khuzestan|Kohgiluyeh va Buyer Ahmad|Kordestan|Lorestan|Markazi|Mazandaran|Qazvin|Qom|Semnan|Sistan va Baluchestan|Tehran|Yazd|Zanjan";
-aStates[108]="|Al Anbar|Al Basrah|Al Muthanna|Al Qadisiyah|An Najaf|Arbil|As Sulaymaniyah|At Ta'mim|Babil|Baghdad|Dahuk|Dhi Qar|Diyala|Karbala'|Maysan|Ninawa|Salah ad Din|Wasit";
-aStates[109]="|Carlow|Cavan|Clare|Cork|Donegal|Dublin|Galway|Kerry|Kildare|Kilkenny|Laois|Leitrim|Limerick|Longford|Louth|Mayo|Meath|Monaghan|Offaly|Roscommon|Sligo|Tipperary|Waterford|Westmeath|Wexford|Wicklow";
-aStates[110]="|Antrim|Ards|Armagh|Ballymena|Ballymoney|Banbridge|Belfast|Carrickfergus|Castlereagh|Coleraine|Cookstown|Craigavon|Derry|Down|Dungannon|Fermanagh|Larne|Limavady|Lisburn|Magherafelt|Moyle|Newry and Mourne|Newtownabbey|North Down|Omagh|Strabane";
-aStates[111]="|Central|Haifa|Jerusalem|Northern|Southern|Tel Aviv";
-aStates[112]="|Abruzzi|Basilicata|Calabria|Campania|Emilia-Romagna|Friuli-Venezia Giulia|Lazio|Liguria|Lombardia|Marche|Molise|Piemonte|Puglia|Sardegna|Sicilia|Toscana|Trentino-Alto Adige|Umbria|Valle d'Aosta|Veneto";
-aStates[113]="|Clarendon|Hanover|Kingston|Manchester|Portland|Saint Andrew|Saint Ann|Saint Catherine|Saint Elizabeth|Saint James|Saint Mary|Saint Thomas|Trelawny|Westmoreland";
-aStates[114]="|Jan Mayen";
-aStates[115]="|Aichi|Akita|Aomori|Chiba|Ehime|Fukui|Fukuoka|Fukushima|Gifu|Gumma|Hiroshima|Hokkaido|Hyogo|Ibaraki|Ishikawa|Iwate|Kagawa|Kagoshima|Kanagawa|Kochi|Kumamoto|Kyoto|Mie|Miyagi|Miyazaki|Nagano|Nagasaki|Nara|Niigata|Oita|Okayama|Okinawa|Osaka|Saga|Saitama|Shiga|Shimane|Shizuoka|Tochigi|Tokushima|Tokyo|Tottori|Toyama|Wakayama|Yamagata|Yamaguchi|Yamanashi";
-aStates[116]="|Jarvis Island";
-aStates[117]="|Jersey";
-aStates[118]="|Johnston Atoll";
-aStates[119]="|'Amman|Ajlun|Al 'Aqabah|Al Balqa'|Al Karak|Al Mafraq|At Tafilah|Az Zarqa'|Irbid|Jarash|Ma'an|Madaba";
-aStates[120]="|Juan de Nova Island";
-aStates[121]="|Almaty|Aqmola|Aqtobe|Astana|Atyrau|Batys Qazaqstan|Bayqongyr|Mangghystau|Ongtustik Qazaqstan|Pavlodar|Qaraghandy|Qostanay|Qyzylorda|Shyghys Qazaqstan|Soltustik Qazaqstan|Zhambyl";
-aStates[122]="|Central|Coast|Eastern|Nairobi Area|North Eastern|Nyanza|Rift Valley|Western";
-aStates[123]="|Abaiang|Abemama|Aranuka|Arorae|Banaba|Banaba|Beru|Butaritari|Central Gilberts|Gilbert Islands|Kanton|Kiritimati|Kuria|Line Islands|Line Islands|Maiana|Makin|Marakei|Nikunau|Nonouti|Northern Gilberts|Onotoa|Phoenix Islands|Southern Gilberts|Tabiteuea|Tabuaeran|Tamana|Tarawa|Tarawa|Teraina";
-aStates[124]="|Chagang-do (Chagang Province)|Hamgyong-bukto (North Hamgyong Province)|Hamgyong-namdo (South Hamgyong Province)|Hwanghae-bukto (North Hwanghae Province)|Hwanghae-namdo (South Hwanghae Province)|Kaesong-si (Kaesong City)|Kangwon-do (Kangwon Province)|Namp'o-si (Namp'o City)|P'yongan-bukto (North P'yongan Province)|P'yongan-namdo (South P'yongan Province)|P'yongyang-si (P'yongyang City)|Yanggang-do (Yanggang Province)"
-aStates[125]="|Ch'ungch'ong-bukto|Ch'ungch'ong-namdo|Cheju-do|Cholla-bukto|Cholla-namdo|Inch'on-gwangyoksi|Kangwon-do|Kwangju-gwangyoksi|Kyonggi-do|Kyongsang-bukto|Kyongsang-namdo|Pusan-gwangyoksi|Soul-t'ukpyolsi|Taegu-gwangyoksi|Taejon-gwangyoksi|Ulsan-gwangyoksi";
-aStates[126]="|Al 'Asimah|Al Ahmadi|Al Farwaniyah|Al Jahra'|Hawalli";
-aStates[127]="|Batken Oblasty|Bishkek Shaary|Chuy Oblasty (Bishkek)|Jalal-Abad Oblasty|Naryn Oblasty|Osh Oblasty|Talas Oblasty|Ysyk-Kol Oblasty (Karakol)"
-aStates[128]="|Attapu|Bokeo|Bolikhamxai|Champasak|Houaphan|Khammouan|Louangnamtha|Louangphabang|Oudomxai|Phongsali|Salavan|Savannakhet|Viangchan|Viangchan|Xaignabouli|Xaisomboun|Xekong|Xiangkhoang";
-aStates[129]="|Aizkraukles Rajons|Aluksnes Rajons|Balvu Rajons|Bauskas Rajons|Cesu Rajons|Daugavpils|Daugavpils Rajons|Dobeles Rajons|Gulbenes Rajons|Jekabpils Rajons|Jelgava|Jelgavas Rajons|Jurmala|Kraslavas Rajons|Kuldigas Rajons|Leipaja|Liepajas Rajons|Limbazu Rajons|Ludzas Rajons|Madonas Rajons|Ogres Rajons|Preilu Rajons|Rezekne|Rezeknes Rajons|Riga|Rigas Rajons|Saldus Rajons|Talsu Rajons|Tukuma Rajons|Valkas Rajons|Valmieras Rajons|Ventspils|Ventspils Rajons";
-aStates[130]="|Beyrouth|Ech Chimal|Ej Jnoub|El Bekaa|Jabal Loubnane";
-aStates[131]="|Berea|Butha-Buthe|Leribe|Mafeteng|Maseru|Mohales Hoek|Mokhotlong|Qacha's Nek|Quthing|Thaba-Tseka";
-aStates[132]="|Bomi|Bong|Grand Bassa|Grand Cape Mount|Grand Gedeh|Grand Kru|Lofa|Margibi|Maryland|Montserrado|Nimba|River Cess|Sinoe";
-aStates[133]="|Ajdabiya|Al 'Aziziyah|Al Fatih|Al Jabal al Akhdar|Al Jufrah|Al Khums|Al Kufrah|An Nuqat al Khams|Ash Shati'|Awbari|Az Zawiyah|Banghazi|Darnah|Ghadamis|Gharyan|Misratah|Murzuq|Sabha|Sawfajjin|Surt|Tarabulus|Tarhunah|Tubruq|Yafran|Zlitan";
-aStates[134]="|Balzers|Eschen|Gamprin|Mauren|Planken|Ruggell|Schaan|Schellenberg|Triesen|Triesenberg|Vaduz";
-aStates[135]="|Akmenes Rajonas|Alytaus Rajonas|Alytus|Anyksciu Rajonas|Birstonas|Birzu Rajonas|Druskininkai|Ignalinos Rajonas|Jonavos Rajonas|Joniskio Rajonas|Jurbarko Rajonas|Kaisiadoriu Rajonas|Kaunas|Kauno Rajonas|Kedainiu Rajonas|Kelmes Rajonas|Klaipeda|Klaipedos Rajonas|Kretingos Rajonas|Kupiskio Rajonas|Lazdiju Rajonas|Marijampole|Marijampoles Rajonas|Mazeikiu Rajonas|Moletu Rajonas|Neringa Pakruojo Rajonas|Palanga|Panevezio Rajonas|Panevezys|Pasvalio Rajonas|Plunges Rajonas|Prienu Rajonas|Radviliskio Rajonas|Raseiniu Rajonas|Rokiskio Rajonas|Sakiu Rajonas|Salcininku Rajonas|Siauliai|Siauliu Rajonas|Silales Rajonas|Silutes Rajonas|Sirvintu Rajonas|Skuodo Rajonas|Svencioniu Rajonas|Taurages Rajonas|Telsiu Rajonas|Traku Rajonas|Ukmerges Rajonas|Utenos Rajonas|Varenos Rajonas|Vilkaviskio Rajonas|Vilniaus Rajonas|Vilnius|Zarasu Rajonas";
-aStates[136]="|Diekirch|Grevenmacher|Luxembourg";
-aStates[137]="|Macau";
-aStates[138]="|Aracinovo|Bac|Belcista|Berovo|Bistrica|Bitola|Blatec|Bogdanci|Bogomila|Bogovinje|Bosilovo|Brvenica|Cair (Skopje)|Capari|Caska|Cegrane|Centar (Skopje)|Centar Zupa|Cesinovo|Cucer-Sandevo|Debar|Delcevo|Delogozdi|Demir Hisar|Demir Kapija|Dobrusevo|Dolna Banjica|Dolneni|Dorce Petrov (Skopje)|Drugovo|Dzepciste|Gazi Baba (Skopje)|Gevgelija|Gostivar|Gradsko|Ilinden|Izvor|Jegunovce|Kamenjane|Karbinci|Karpos (Skopje)|Kavadarci|Kicevo|Kisela Voda (Skopje)|Klecevce|Kocani|Konce|Kondovo|Konopiste|Kosel|Kratovo|Kriva Palanka|Krivogastani|Krusevo|Kuklis|Kukurecani|Kumanovo|Labunista|Lipkovo|Lozovo|Lukovo|Makedonska Kamenica|Makedonski Brod|Mavrovi Anovi|Meseista|Miravci|Mogila|Murtino|Negotino|Negotino-Poloska|Novaci|Novo Selo|Oblesevo|Ohrid|Orasac|Orizari|Oslomej|Pehcevo|Petrovec|Plasnia|Podares|Prilep|Probistip|Radovis|Rankovce|Resen|Rosoman|Rostusa|Samokov|Saraj|Sipkovica|Sopiste|Sopotnika|Srbinovo|Star Dojran|Staravina|Staro Nagoricane|Stip|Struga|Strumica|Studenicani|Suto Orizari (Skopje)|Sveti Nikole|Tearce|Tetovo|Topolcani|Valandovo|Vasilevo|Veles|Velesta|Vevcani|Vinica|Vitoliste|Vranestica|Vrapciste|Vratnica|Vrutok|Zajas|Zelenikovo|Zileno|Zitose|Zletovo|Zrnovci";
-aStates[139]="|Antananarivo|Antsiranana|Fianarantsoa|Mahajanga|Toamasina|Toliara";
-aStates[140]="|Balaka|Blantyre|Chikwawa|Chiradzulu|Chitipa|Dedza|Dowa|Karonga|Kasungu|Likoma|Lilongwe|Machinga (Kasupe)|Mangochi|Mchinji|Mulanje|Mwanza|Mzimba|Nkhata Bay|Nkhotakota|Nsanje|Ntcheu|Ntchisi|Phalombe|Rumphi|Salima|Thyolo|Zomba";
-aStates[141]="|Johor|Kedah|Kelantan|Labuan|Melaka|Negeri Sembilan|Pahang|Perak|Perlis|Pulau Pinang|Sabah|Sarawak|Selangor|Terengganu|Wilayah Persekutuan";
-aStates[142]="|Alifu|Baa|Dhaalu|Faafu|Gaafu Alifu|Gaafu Dhaalu|Gnaviyani|Haa Alifu|Haa Dhaalu|Kaafu|Laamu|Lhaviyani|Maale|Meemu|Noonu|Raa|Seenu|Shaviyani|Thaa|Vaavu";
-aStates[143]="|Gao|Kayes|Kidal|Koulikoro|Mopti|Segou|Sikasso|Tombouctou";
-aStates[144]="|Valletta";
-aStates[145]="|Man, Isle of";
-aStates[146]="|Ailinginae|Ailinglaplap|Ailuk|Arno|Aur|Bikar|Bikini|Bokak|Ebon|Enewetak|Erikub|Jabat|Jaluit|Jemo|Kili|Kwajalein|Lae|Lib|Likiep|Majuro|Maloelap|Mejit|Mili|Namorik|Namu|Rongelap|Rongrik|Toke|Ujae|Ujelang|Utirik|Wotho|Wotje";
-aStates[147]="|Martinique";
-aStates[148]="|Adrar|Assaba|Brakna|Dakhlet Nouadhibou|Gorgol|Guidimaka|Hodh Ech Chargui|Hodh El Gharbi|Inchiri|Nouakchott|Tagant|Tiris Zemmour|Trarza";
-aStates[149]="|Agalega Islands|Black River|Cargados Carajos Shoals|Flacq|Grand Port|Moka|Pamplemousses|Plaines Wilhems|Port Louis|Riviere du Rempart|Rodrigues|Savanne";
-aStates[150]="|Mayotte";
-aStates[151]="|Aguascalientes|Baja California|Baja California Sur|Campeche|Chiapas|Chihuahua|Coahuila de Zaragoza|Colima|Distrito Federal|Durango|Guanajuato|Guerrero|Hidalgo|Jalisco|Mexico|Michoacan de Ocampo|Morelos|Nayarit|Nuevo Leon|Oaxaca|Puebla|Queretaro de Arteaga|Quintana Roo|San Luis Potosi|Sinaloa|Sonora|Tabasco|Tamaulipas|Tlaxcala|Veracruz-Llave|Yucatan|Zacatecas";
-aStates[152]="|Chuuk (Truk)|Kosrae|Pohnpei|Yap";
-aStates[153]="|Midway Islands";
-aStates[154]="|Balti|Cahul|Chisinau|Chisinau|Dubasari|Edinet|Gagauzia|Lapusna|Orhei|Soroca|Tighina|Ungheni";
-aStates[155]="|Fontvieille|La Condamine|Monaco-Ville|Monte-Carlo";
-aStates[156]="|Arhangay|Bayan-Olgiy|Bayanhongor|Bulgan|Darhan|Dornod|Dornogovi|Dundgovi|Dzavhan|Erdenet|Govi-Altay|Hentiy|Hovd|Hovsgol|Omnogovi|Ovorhangay|Selenge|Suhbaatar|Tov|Ulaanbaatar|Uvs";
-aStates[157]="|Saint Anthony|Saint Georges|Saint Peter's";
-aStates[158]="|Agadir|Al Hoceima|Azilal|Ben Slimane|Beni Mellal|Boulemane|Casablanca|Chaouen|El Jadida|El Kelaa des Srarhna|Er Rachidia|Essaouira|Fes|Figuig|Guelmim|Ifrane|Kenitra|Khemisset|Khenifra|Khouribga|Laayoune|Larache|Marrakech|Meknes|Nador|Ouarzazate|Oujda|Rabat-Sale|Safi|Settat|Sidi Kacem|Tan-Tan|Tanger|Taounate|Taroudannt|Tata|Taza|Tetouan|Tiznit";
-aStates[159]="|Cabo Delgado|Gaza|Inhambane|Manica|Maputo|Nampula|Niassa|Sofala|Tete|Zambezia";
-aStates[160]="|Caprivi|Erongo|Hardap|Karas|Khomas|Kunene|Ohangwena|Okavango|Omaheke|Omusati|Oshana|Oshikoto|Otjozondjupa";
-aStates[161]="|Aiwo|Anabar|Anetan|Anibare|Baiti|Boe|Buada|Denigomodu|Ewa|Ijuw|Meneng|Nibok|Uaboe|Yaren";
-aStates[162]="|Bagmati|Bheri|Dhawalagiri|Gandaki|Janakpur|Karnali|Kosi|Lumbini|Mahakali|Mechi|Narayani|Rapti|Sagarmatha|Seti";
-aStates[163]="|Drenthe|Flevoland|Friesland|Gelderland|Groningen|Limburg|Noord-Brabant|Noord-Holland|Overijssel|Utrecht|Zeeland|Zuid-Holland";
-aStates[164]="|Netherlands Antilles";
-aStates[165]="|Iles Loyaute|Nord|Sud";
-aStates[166]="|Akaroa|Amuri|Ashburton|Bay of Islands|Bruce|Buller|Chatham Islands|Cheviot|Clifton|Clutha|Cook|Dannevirke|Egmont|Eketahuna|Ellesmere|Eltham|Eyre|Featherston|Franklin|Golden Bay|Great Barrier Island|Grey|Hauraki Plains|Hawera|Hawke's Bay|Heathcote|Hikurangi|Hobson|Hokianga|Horowhenua|Hurunui|Hutt|Inangahua|Inglewood|Kaikoura|Kairanga|Kiwitea|Lake|Mackenzie|Malvern|Manaia|Manawatu|Mangonui|Maniototo|Marlborough|Masterton|Matamata|Mount Herbert|Ohinemuri|Opotiki|Oroua|Otamatea|Otorohanga|Oxford|Pahiatua|Paparua|Patea|Piako|Pohangina|Raglan|Rangiora|Rangitikei|Rodney|Rotorua|Runanga|Saint Kilda|Silverpeaks|Southland|Stewart Island|Stratford|Strathallan|Taranaki|Taumarunui|Taupo|Tauranga|Thames-Coromandel|Tuapeka|Vincent|Waiapu|Waiheke|Waihemo|Waikato|Waikohu|Waimairi|Waimarino|Waimate|Waimate West|Waimea|Waipa|Waipawa|Waipukurau|Wairarapa South|Wairewa|Wairoa|Waitaki|Waitomo|Waitotara|Wallace|Wanganui|Waverley|Westland|Whakatane|Whangarei|Whangaroa|Woodville";
-aStates[167]="|Atlantico Norte|Atlantico Sur|Boaco|Carazo|Chinandega|Chontales|Esteli|Granada|Jinotega|Leon|Madriz|Managua|Masaya|Matagalpa|Nueva Segovia|Rio San Juan|Rivas";
-aStates[168]="|Agadez|Diffa|Dosso|Maradi|Niamey|Tahoua|Tillaberi|Zinder";
-aStates[169]="|Abia|Abuja Federal Capital Territory|Adamawa|Akwa Ibom|Anambra|Bauchi|Bayelsa|Benue|Borno|Cross River|Delta|Ebonyi|Edo|Ekiti|Enugu|Gombe|Imo|Jigawa|Kaduna|Kano|Katsina|Kebbi|Kogi|Kwara|Lagos|Nassarawa|Niger|Ogun|Ondo|Osun|Oyo|Plateau|Rivers|Sokoto|Taraba|Yobe|Zamfara";
-aStates[170]="|Niue";
-aStates[171]="|Norfolk Island";
-aStates[172]="|Northern Islands|Rota|Saipan|Tinian";
-aStates[173]="|Akershus|Aust-Agder|Buskerud|Finnmark|Hedmark|Hordaland|More og Romsdal|Nord-Trondelag|Nordland|Oppland|Oslo|Ostfold|Rogaland|Sogn og Fjordane|Sor-Trondelag|Telemark|Troms|Vest-Agder|Vestfold";
-aStates[174]="|Ad Dakhiliyah|Al Batinah|Al Wusta|Ash Sharqiyah|Az Zahirah|Masqat|Musandam|Zufar";
-aStates[175]="|Balochistan|Federally Administered Tribal Areas|Islamabad Capital Territory|North-West Frontier Province|Punjab|Sindh";
-aStates[176]="|Aimeliik|Airai|Angaur|Hatobohei|Kayangel|Koror|Melekeok|Ngaraard|Ngarchelong|Ngardmau|Ngatpang|Ngchesar|Ngeremlengui|Ngiwal|Palau Island|Peleliu|Sonsoral|Tobi";
-aStates[177]="|Bocas del Toro|Chiriqui|Cocle|Colon|Darien|Herrera|Los Santos|Panama|San Blas|Veraguas";
-aStates[178]="|Bougainville|Central|Chimbu|East New Britain|East Sepik|Eastern Highlands|Enga|Gulf|Madang|Manus|Milne Bay|Morobe|National Capital|New Ireland|Northern|Sandaun|Southern Highlands|West New Britain|Western|Western Highlands";
-aStates[179]="|Alto Paraguay|Alto Parana|Amambay|Asuncion (city)|Boqueron|Caaguazu|Caazapa|Canindeyu|Central|Concepcion|Cordillera|Guaira|Itapua|Misiones|Neembucu|Paraguari|Presidente Hayes|San Pedro";
-aStates[180]="|Amazonas|Ancash|Apurimac|Arequipa|Ayacucho|Cajamarca|Callao|Cusco|Huancavelica|Huanuco|Ica|Junin|La Libertad|Lambayeque|Lima|Loreto|Madre de Dios|Moquegua|Pasco|Piura|Puno|San Martin|Tacna|Tumbes|Ucayali";
-aStates[181]="|Abra|Agusan del Norte|Agusan del Sur|Aklan|Albay|Angeles|Antique|Aurora|Bacolod|Bago|Baguio|Bais|Basilan|Basilan City|Bataan|Batanes|Batangas|Batangas City|Benguet|Bohol|Bukidnon|Bulacan|Butuan|Cabanatuan|Cadiz|Cagayan|Cagayan de Oro|Calbayog|Caloocan|Camarines Norte|Camarines Sur|Camiguin|Canlaon|Capiz|Catanduanes|Cavite|Cavite City|Cebu|Cebu City|Cotabato|Dagupan|Danao|Dapitan|Davao City Davao|Davao del Sur|Davao Oriental|Dipolog|Dumaguete|Eastern Samar|General Santos|Gingoog|Ifugao|Iligan|Ilocos Norte|Ilocos Sur|Iloilo|Iloilo City|Iriga|Isabela|Kalinga-Apayao|La Carlota|La Union|Laguna|Lanao del Norte|Lanao del Sur|Laoag|Lapu-Lapu|Legaspi|Leyte|Lipa|Lucena|Maguindanao|Mandaue|Manila|Marawi|Marinduque|Masbate|Mindoro Occidental|Mindoro Oriental|Misamis Occidental|Misamis Oriental|Mountain|Naga|Negros Occidental|Negros Oriental|North Cotabato|Northern Samar|Nueva Ecija|Nueva Vizcaya|Olongapo|Ormoc|Oroquieta|Ozamis|Pagadian|Palawan|Palayan|Pampanga|Pangasinan|Pasay|Puerto Princesa|Quezon|Quezon City|Quirino|Rizal|Romblon|Roxas|Samar|San Carlos (in Negros Occidental)|San Carlos (in Pangasinan)|San Jose|San Pablo|Silay|Siquijor|Sorsogon|South Cotabato|Southern Leyte|Sultan Kudarat|Sulu|Surigao|Surigao del Norte|Surigao del Sur|Tacloban|Tagaytay|Tagbilaran|Tangub|Tarlac|Tawitawi|Toledo|Trece Martires|Zambales|Zamboanga|Zamboanga del Norte|Zamboanga del Sur";
-aStates[182]="|Pitcaim Islands";
-aStates[183]="|Dolnoslaskie|Kujawsko-Pomorskie|Lodzkie|Lubelskie|Lubuskie|Malopolskie|Mazowieckie|Opolskie|Podkarpackie|Podlaskie|Pomorskie|Slaskie|Swietokrzyskie|Warminsko-Mazurskie|Wielkopolskie|Zachodniopomorskie";
-aStates[184]="|Acores (Azores)|Aveiro|Beja|Braga|Braganca|Castelo Branco|Coimbra|Evora|Faro|Guarda|Leiria|Lisboa|Madeira|Portalegre|Porto|Santarem|Setubal|Viana do Castelo|Vila Real|Viseu";
-aStates[185]="|Adjuntas|Aguada|Aguadilla|Aguas Buenas|Aibonito|Anasco|Arecibo|Arroyo|Barceloneta|Barranquitas|Bayamon|Cabo Rojo|Caguas|Camuy|Canovanas|Carolina|Catano|Cayey|Ceiba|Ciales|Cidra|Coamo|Comerio|Corozal|Culebra|Dorado|Fajardo|Florida|Guanica|Guayama|Guayanilla|Guaynabo|Gurabo|Hatillo|Hormigueros|Humacao|Isabela|Jayuya|Juana Diaz|Juncos|Lajas|Lares|Las Marias|Las Piedras|Loiza|Luquillo|Manati|Maricao|Maunabo|Mayaguez|Moca|Morovis|Naguabo|Naranjito|Orocovis|Patillas|Penuelas|Ponce|Quebradillas|Rincon|Rio Grande|Sabana Grande|Salinas|San German|San Juan|San Lorenzo|San Sebastian|Santa Isabel|Toa Alta|Toa Baja|Trujillo Alto|Utuado|Vega Alta|Vega Baja|Vieques|Villalba|Yabucoa|Yauco";
-aStates[186]="|Ad Dawhah|Al Ghuwayriyah|Al Jumayliyah|Al Khawr|Al Wakrah|Ar Rayyan|Jarayan al Batinah|Madinat ash Shamal|Umm Salal";
-aStates[187]="|Reunion";
-aStates[188]="|Alba|Arad|Arges|Bacau|Bihor|Bistrita-Nasaud|Botosani|Braila|Brasov|Bucuresti|Buzau|Calarasi|Caras-Severin|Cluj|Constanta|Covasna|Dimbovita|Dolj|Galati|Giurgiu|Gorj|Harghita|Hunedoara|Ialomita|Iasi|Maramures|Mehedinti|Mures|Neamt|Olt|Prahova|Salaj|Satu Mare|Sibiu|Suceava|Teleorman|Timis|Tulcea|Vaslui|Vilcea|Vrancea";
-aStates[189]="|Adygeya (Maykop)|Aginskiy Buryatskiy (Aginskoye)|Altay (Gorno-Altaysk)|Altayskiy (Barnaul)|Amurskaya (Blagoveshchensk)|Arkhangel'skaya|Astrakhanskaya|Bashkortostan (Ufa)|Belgorodskaya|Bryanskaya|Buryatiya (Ulan-Ude)|Chechnya (Groznyy)|Chelyabinskaya|Chitinskaya|Chukotskiy (Anadyr')|Chuvashiya (Cheboksary)|Dagestan (Makhachkala)|Evenkiyskiy (Tura)|Ingushetiya (Nazran')|Irkutskaya|Ivanovskaya|Kabardino-Balkariya (Nal'chik)|Kaliningradskaya|Kalmykiya (Elista)|Kaluzhskaya|Kamchatskaya (Petropavlovsk-Kamchatskiy)|Karachayevo-Cherkesiya (Cherkessk)|Kareliya (Petrozavodsk)|Kemerovskaya|Khabarovskiy|Khakasiya (Abakan)|Khanty-Mansiyskiy (Khanty-Mansiysk)|Kirovskaya|Komi (Syktyvkar)|Komi-Permyatskiy (Kudymkar)|Koryakskiy (Palana)|Kostromskaya|Krasnodarskiy|Krasnoyarskiy|Kurganskaya|Kurskaya|Leningradskaya|Lipetskaya|Magadanskaya|Mariy-El (Yoshkar-Ola)|Mordoviya (Saransk)|Moskovskaya|Moskva (Moscow)|Murmanskaya|Nenetskiy (Nar'yan-Mar)|Nizhegorodskaya|Novgorodskaya|Novosibirskaya|Omskaya|Orenburgskaya|Orlovskaya (Orel)|Penzenskaya|Permskaya|Primorskiy (Vladivostok)|Pskovskaya|Rostovskaya|Ryazanskaya|Sakha (Yakutsk)|Sakhalinskaya (Yuzhno-Sakhalinsk)|Samarskaya|Sankt-Peterburg (Saint Petersburg)|Saratovskaya|Severnaya Osetiya-Alaniya [North Ossetia] (Vladikavkaz)|Smolenskaya|Stavropol'skiy|Sverdlovskaya (Yekaterinburg)|Tambovskaya|Tatarstan (Kazan')|Taymyrskiy (Dudinka)|Tomskaya|Tul'skaya|Tverskaya|Tyumenskaya|Tyva (Kyzyl)|Udmurtiya (Izhevsk)|Ul'yanovskaya|Ust'-Ordynskiy Buryatskiy (Ust'-Ordynskiy)|Vladimirskaya|Volgogradskaya|Vologodskaya|Voronezhskaya|Yamalo-Nenetskiy (Salekhard)|Yaroslavskaya|Yevreyskaya";
-aStates[190]="|Butare|Byumba|Cyangugu|Gikongoro|Gisenyi|Gitarama|Kibungo|Kibuye|Kigali Rurale|Kigali-ville|Ruhengeri|Umutara";
-aStates[191]="|Ascension|Saint Helena|Tristan da Cunha";
-aStates[192]="|Christ Church Nichola Town|Saint Anne Sandy Point|Saint George Basseterre|Saint George Gingerland|Saint James Windward|Saint John Capisterre|Saint John Figtree|Saint Mary Cayon|Saint Paul Capisterre|Saint Paul Charlestown|Saint Peter Basseterre|Saint Thomas Lowland|Saint Thomas Middle Island|Trinity Palmetto Point";
-aStates[193]="|Anse-la-Raye|Castries|Choiseul|Dauphin|Dennery|Gros Islet|Laborie|Micoud|Praslin|Soufriere|Vieux Fort";
-aStates[194]="|Miquelon|Saint Pierre";
-aStates[195]="|Charlotte|Grenadines|Saint Andrew|Saint David|Saint George|Saint Patrick";
-aStates[196]="|A'ana|Aiga-i-le-Tai|Atua|Fa'asaleleaga|Gaga'emauga|Gagaifomauga|Palauli|Satupa'itea|Tuamasaga|Va'a-o-Fonoti|Vaisigano";
-aStates[197]="|Acquaviva|Borgo Maggiore|Chiesanuova|Domagnano|Faetano|Fiorentino|Monte Giardino|San Marino|Serravalle";
-aStates[198]="|Principe|Sao Tome";
-aStates[199]="|'Asir|Al Bahah|Al Hudud ash Shamaliyah|Al Jawf|Al Madinah|Al Qasim|Ar Riyad|Ash Sharqiyah (Eastern Province)|Ha'il|Jizan|Makkah|Najran|Tabuk";
-aStates[200]="|Aberdeen City|Aberdeenshire|Angus|Argyll and Bute|City of Edinburgh|Clackmannanshire|Dumfries and Galloway|Dundee City|East Ayrshire|East Dunbartonshire|East Lothian|East Renfrewshire|Eilean Siar (Western Isles)|Falkirk|Fife|Glasgow City|Highland|Inverclyde|Midlothian|Moray|North Ayrshire|North Lanarkshire|Orkney Islands|Perth and Kinross|Renfrewshire|Shetland Islands|South Ayrshire|South Lanarkshire|Stirling|The Scottish Borders|West Dunbartonshire|West Lothian";
-aStates[201]="|Dakar|Diourbel|Fatick|Kaolack|Kolda|Louga|Saint-Louis|Tambacounda|Thies|Ziguinchor";
-aStates[202]="|Anse aux Pins|Anse Boileau|Anse Etoile|Anse Louis|Anse Royale|Baie Lazare|Baie Sainte Anne|Beau Vallon|Bel Air|Bel Ombre|Cascade|Glacis|Grand' Anse (on Mahe)|Grand' Anse (on Praslin)|La Digue|La Riviere Anglaise|Mont Buxton|Mont Fleuri|Plaisance|Pointe La Rue|Port Glaud|Saint Louis|Takamaka";
-aStates[203]="|Eastern|Northern|Southern|Western";
-aStates[204]="|Singapore";
-aStates[205]="|Banskobystricky|Bratislavsky|Kosicky|Nitriansky|Presovsky|Trenciansky|Trnavsky|Zilinsky";
-aStates[206]="|Ajdovscina|Beltinci|Bled|Bohinj|Borovnica|Bovec|Brda|Brezice|Brezovica|Cankova-Tisina|Celje|Cerklje na Gorenjskem|Cerknica|Cerkno|Crensovci|Crna na Koroskem|Crnomelj|Destrnik-Trnovska Vas|Divaca|Dobrepolje|Dobrova-Horjul-Polhov Gradec|Dol pri Ljubljani|Domzale|Dornava|Dravograd|Duplek|Gorenja Vas-Poljane|Gorisnica|Gornja Radgona|Gornji Grad|Gornji Petrovci|Grosuplje|Hodos Salovci|Hrastnik|Hrpelje-Kozina|Idrija|Ig|Ilirska Bistrica|Ivancna Gorica|Izola|Jesenice|Jursinci|Kamnik|Kanal|Kidricevo|Kobarid|Kobilje|Kocevje|Komen|Koper|Kozje|Kranj|Kranjska Gora|Krsko|Kungota|Kuzma|Lasko|Lenart|Lendava|Litija|Ljubljana|Ljubno|Ljutomer|Logatec|Loska Dolina|Loski Potok|Luce|Lukovica|Majsperk|Maribor|Medvode|Menges|Metlika|Mezica|Miren-Kostanjevica|Mislinja|Moravce|Moravske Toplice|Mozirje|Murska Sobota|Muta|Naklo|Nazarje|Nova Gorica|Novo Mesto|Odranci|Ormoz|Osilnica|Pesnica|Piran|Pivka|Podcetrtek|Podvelka-Ribnica|Postojna|Preddvor|Ptuj|Puconci|Race-Fram|Radece|Radenci|Radlje ob Dravi|Radovljica|Ravne-Prevalje|Ribnica|Rogasevci|Rogaska Slatina|Rogatec|Ruse|Semic|Sencur|Sentilj|Sentjernej|Sentjur pri Celju|Sevnica|Sezana|Skocjan|Skofja Loka|Skofljica|Slovenj Gradec|Slovenska Bistrica|Slovenske Konjice|Smarje pri Jelsah|Smartno ob Paki|Sostanj|Starse|Store|Sveti Jurij|Tolmin|Trbovlje|Trebnje|Trzic|Turnisce|Velenje|Velike Lasce|Videm|Vipava|Vitanje|Vodice|Vojnik|Vrhnika|Vuzenica|Zagorje ob Savi|Zalec|Zavrc|Zelezniki|Ziri|Zrece";
-aStates[207]="|Bellona|Central|Choiseul (Lauru)|Guadalcanal|Honiara|Isabel|Makira|Malaita|Rennell|Temotu|Western";
-aStates[208]="|Awdal|Bakool|Banaadir|Bari|Bay|Galguduud|Gedo|Hiiraan|Jubbada Dhexe|Jubbada Hoose|Mudug|Nugaal|Sanaag|Shabeellaha Dhexe|Shabeellaha Hoose|Sool|Togdheer|Woqooyi Galbeed";
-aStates[209]="|Eastern Cape|Free State|Gauteng|KwaZulu-Natal|Mpumalanga|North-West|Northern Cape|Northern Province|Western Cape";
-aStates[210]="|Bird Island|Bristol Island|Clerke Rocks|Montagu Island|Saunders Island|South Georgia|Southern Thule|Traversay Islands";
-aStates[211]="|Andalucia|Aragon|Asturias|Baleares (Balearic Islands)|Canarias (Canary Islands)|Cantabria|Castilla y Leon|Castilla-La Mancha|Cataluna|Ceuta|Communidad Valencian|Extremadura|Galicia|Islas Chafarinas|La Rioja|Madrid|Melilla|Murcia|Navarra|Pais Vasco (Basque Country)|Penon de Alhucemas|Penon de Velez de la Gomera";
-aStates[212]="|Spratly Islands";
-aStates[213]="|Central|Eastern|North Central|North Eastern|North Western|Northern|Sabaragamuwa|Southern|Uva|Western";
-aStates[214]="|A'ali an Nil|Al Bahr al Ahmar|Al Buhayrat|Al Jazirah|Al Khartum|Al Qadarif|Al Wahdah|An Nil al Abyad|An Nil al Azraq|Ash Shamaliyah|Bahr al Jabal|Gharb al Istiwa'iyah|Gharb Bahr al Ghazal|Gharb Darfur|Gharb Kurdufan|Janub Darfur|Janub Kurdufan|Junqali|Kassala|Nahr an Nil|Shamal Bahr al Ghazal|Shamal Darfur|Shamal Kurdufan|Sharq al Istiwa'iyah|Sinnar|Warab";
-aStates[215]="|Brokopondo|Commewijne|Coronie|Marowijne|Nickerie|Para|Paramaribo|Saramacca|Sipaliwini|Wanica";
-aStates[216]="|Barentsoya|Bjornoya|Edgeoya|Hopen|Kvitoya|Nordaustandet|Prins Karls Forland|Spitsbergen";
-aStates[217]="|Hhohho|Lubombo|Manzini|Shiselweni";
-aStates[218]="|Blekinge|Dalarnas|Gavleborgs|Gotlands|Hallands|Jamtlands|Jonkopings|Kalmar|Kronobergs|Norrbottens|Orebro|Ostergotlands|Skane|Sodermanlands|Stockholms|Uppsala|Varmlands|Vasterbottens|Vasternorrlands|Vastmanlands|Vastra Gotalands";
-aStates[219]="|Aargau|Ausser-Rhoden|Basel-Landschaft|Basel-Stadt|Bern|Fribourg|Geneve|Glarus|Graubunden|Inner-Rhoden|Jura|Luzern|Neuchatel|Nidwalden|Obwalden|Sankt Gallen|Schaffhausen|Schwyz|Solothurn|Thurgau|Ticino|Uri|Valais|Vaud|Zug|Zurich";
-aStates[220]="|Al Hasakah|Al Ladhiqiyah|Al Qunaytirah|Ar Raqqah|As Suwayda'|Dar'a|Dayr az Zawr|Dimashq|Halab|Hamah|Hims|Idlib|Rif Dimashq|Tartus";
-aStates[221]="|Chang-hua|Chi-lung|Chia-i|Chia-i|Chung-hsing-hsin-ts'un|Hsin-chu|Hsin-chu|Hua-lien|I-lan|Kao-hsiung|Kao-hsiung|Miao-li|Nan-t'ou|P'eng-hu|P'ing-tung|T'ai-chung|T'ai-chung|T'ai-nan|T'ai-nan|T'ai-pei|T'ai-pei|T'ai-tung|T'ao-yuan|Yun-lin";
-aStates[222]="|Viloyati Khatlon|Viloyati Leninobod|Viloyati Mukhtori Kuhistoni Badakhshon";
-aStates[223]="|Arusha|Dar es Salaam|Dodoma|Iringa|Kagera|Kigoma|Kilimanjaro|Lindi|Mara|Mbeya|Morogoro|Mtwara|Mwanza|Pemba North|Pemba South|Pwani|Rukwa|Ruvuma|Shinyanga|Singida|Tabora|Tanga|Zanzibar Central/South|Zanzibar North|Zanzibar Urban/West";
-aStates[224]="|Amnat Charoen|Ang Thong|Buriram|Chachoengsao|Chai Nat|Chaiyaphum|Chanthaburi|Chiang Mai|Chiang Rai|Chon Buri|Chumphon|Kalasin|Kamphaeng Phet|Kanchanaburi|Khon Kaen|Krabi|Krung Thep Mahanakhon (Bangkok)|Lampang|Lamphun|Loei|Lop Buri|Mae Hong Son|Maha Sarakham|Mukdahan|Nakhon Nayok|Nakhon Pathom|Nakhon Phanom|Nakhon Ratchasima|Nakhon Sawan|Nakhon Si Thammarat|Nan|Narathiwat|Nong Bua Lamphu|Nong Khai|Nonthaburi|Pathum Thani|Pattani|Phangnga|Phatthalung|Phayao|Phetchabun|Phetchaburi|Phichit|Phitsanulok|Phra Nakhon Si Ayutthaya|Phrae|Phuket|Prachin Buri|Prachuap Khiri Khan|Ranong|Ratchaburi|Rayong|Roi Et|Sa Kaeo|Sakon Nakhon|Samut Prakan|Samut Sakhon|Samut Songkhram|Sara Buri|Satun|Sing Buri|Sisaket|Songkhla|Sukhothai|Suphan Buri|Surat Thani|Surin|Tak|Trang|Trat|Ubon Ratchathani|Udon Thani|Uthai Thani|Uttaradit|Yala|Yasothon";
-aStates[225]="|Tobago";
-aStates[226]="|De La Kara|Des Plateaux|Des Savanes|Du Centre|Maritime";
-aStates[227]="|Atafu|Fakaofo|Nukunonu";
-aStates[228]="|Ha'apai|Tongatapu|Vava'u";
-aStates[229]="|Arima|Caroni|Mayaro|Nariva|Port-of-Spain|Saint Andrew|Saint David|Saint George|Saint Patrick|San Fernando|Victoria";
-aStates[230]="|Ariana|Beja|Ben Arous|Bizerte|El Kef|Gabes|Gafsa|Jendouba|Kairouan|Kasserine|Kebili|Mahdia|Medenine|Monastir|Nabeul|Sfax|Sidi Bou Zid|Siliana|Sousse|Tataouine|Tozeur|Tunis|Zaghouan";
-aStates[231]="|Adana|Adiyaman|Afyon|Agri|Aksaray|Amasya|Ankara|Antalya|Ardahan|Artvin|Aydin|Balikesir|Bartin|Batman|Bayburt|Bilecik|Bingol|Bitlis|Bolu|Burdur|Bursa|Canakkale|Cankiri|Corum|Denizli|Diyarbakir|Duzce|Edirne|Elazig|Erzincan|Erzurum|Eskisehir|Gaziantep|Giresun|Gumushane|Hakkari|Hatay|Icel|Igdir|Isparta|Istanbul|Izmir|Kahramanmaras|Karabuk|Karaman|Kars|Kastamonu|Kayseri|Kilis|Kirikkale|Kirklareli|Kirsehir|Kocaeli|Konya|Kutahya|Malatya|Manisa|Mardin|Mugla|Mus|Nevsehir|Nigde|Ordu|Osmaniye|Rize|Sakarya|Samsun|Sanliurfa|Siirt|Sinop|Sirnak|Sivas|Tekirdag|Tokat|Trabzon|Tunceli|Usak|Van|Yalova|Yozgat|Zonguldak";
-aStates[232]="|Ahal Welayaty|Balkan Welayaty|Dashhowuz Welayaty|Lebap Welayaty|Mary Welayaty";
-aStates[233]="|Tuvalu";
-aStates[234]="|Adjumani|Apac|Arua|Bugiri|Bundibugyo|Bushenyi|Busia|Gulu|Hoima|Iganga|Jinja|Kabale|Kabarole|Kalangala|Kampala|Kamuli|Kapchorwa|Kasese|Katakwi|Kibale|Kiboga|Kisoro|Kitgum|Kotido|Kumi|Lira|Luwero|Masaka|Masindi|Mbale|Mbarara|Moroto|Moyo|Mpigi|Mubende|Mukono|Nakasongola|Nebbi|Ntungamo|Pallisa|Rakai|Rukungiri|Sembabule|Soroti|Tororo";
-aStates[235]="|Avtonomna Respublika Krym (Simferopol')|Cherkas'ka (Cherkasy)|Chernihivs'ka (Chernihiv)|Chernivets'ka (Chernivtsi)|Dnipropetrovs'ka (Dnipropetrovs'k)|Donets'ka (Donets'k)|Ivano-Frankivs'ka (Ivano-Frankivs'k)|Kharkivs'ka (Kharkiv)|Khersons'ka (Kherson)|Khmel'nyts'ka (Khmel'nyts'kyy)|Kirovohrads'ka (Kirovohrad)|Kyyiv|Kyyivs'ka (Kiev)|L'vivs'ka (L'viv)|Luhans'ka (Luhans'k)|Mykolayivs'ka (Mykolayiv)|Odes'ka (Odesa)|Poltavs'ka (Poltava)|Rivnens'ka (Rivne)|Sevastopol'|Sums'ka (Sumy)|Ternopil's'ka (Ternopil')|Vinnyts'ka (Vinnytsya)|Volyns'ka (Luts'k)|Zakarpats'ka (Uzhhorod)|Zaporiz'ka (Zaporizhzhya)|Zhytomyrs'ka (Zhytomyr)"
-aStates[236]="|'Ajman|Abu Zaby (Abu Dhabi)|Al Fujayrah|Ash Shariqah (Sharjah)|Dubayy (Dubai)|Ra's al Khaymah|Umm al Qaywayn";
-aStates[237]="|Barking and Dagenham|Barnet|Barnsley|Bath and North East Somerset|Bedfordshire|Bexley|Birmingham|Blackburn with Darwen|Blackpool|Bolton|Bournemouth|Bracknell Forest|Bradford|Brent|Brighton and Hove|Bromley|Buckinghamshire|Bury|Calderdale|Cambridgeshire|Camden|Cheshire|City of Bristol|City of Kingston upon Hull|City of London|Cornwall|Coventry|Croydon|Cumbria|Darlington|Derby|Derbyshire|Devon|Doncaster|Dorset|Dudley|Durham|Ealing|East Riding of Yorkshire|East Sussex|Enfield|Essex|Gateshead|Gloucestershire|Greenwich|Hackney|Halton|Hammersmith and Fulham|Hampshire|Haringey|Harrow|Hartlepool|Havering|Herefordshire|Hertfordshire|Hillingdon|Hounslow|Isle of Wight|Islington|Kensington and Chelsea|Kent|Kingston upon Thames|Kirklees|Knowsley|Lambeth|Lancashire|Leeds|Leicester|Leicestershire|Lewisham|Lincolnshire|Liverpool|Luton|Manchester|Medway|Merton|Middlesbrough|Milton Keynes|Newcastle upon Tyne|Newham|Norfolk|North East Lincolnshire|North Lincolnshire|North Somerset|North Tyneside|North Yorkshire|Northamptonshire|Northumberland|Nottingham|Nottinghamshire|Oldham|Oxfordshire|Peterborough|Plymouth|Poole|Portsmouth|Reading|Redbridge|Redcar and Cleveland|Richmond upon Thames|Rochdale|Rotherham|Rutland|Salford|Sandwell|Sefton|Sheffield|Shropshire|Slough|Solihull|Somerset|South Gloucestershire|South Tyneside|Southampton|Southend-on-Sea|Southwark|St. Helens|Staffordshire|Stockport|Stockton-on-Tees|Stoke-on-Trent|Suffolk|Sunderland|Surrey|Sutton|Swindon|Tameside|Telford and Wrekin|Thurrock|Torbay|Tower Hamlets|Trafford|Wakefield|Walsall|Waltham Forest|Wandsworth|Warrington|Warwickshire|West Berkshire|West Sussex|Westminster|Wigan|Wiltshire|Windsor and Maidenhead|Wirral|Wokingham|Wolverhampton|Worcestershire|York";
-aStates[238]="|Artigas|Canelones|Cerro Largo|Colonia|Durazno|Flores|Florida|Lavalleja|Maldonado|Montevideo|Paysandu|Rio Negro|Rivera|Rocha|Salto|San Jose|Soriano|Tacuarembo|Treinta y Tres";
-aStates[239]="|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming";
-aStates[240]="|Andijon Wiloyati|Bukhoro Wiloyati|Farghona Wiloyati|Jizzakh Wiloyati|Khorazm Wiloyati (Urganch)|Namangan Wiloyati|Nawoiy Wiloyati|Qashqadaryo Wiloyati (Qarshi)|Qoraqalpoghiston (Nukus)|Samarqand Wiloyati|Sirdaryo Wiloyati (Guliston)|Surkhondaryo Wiloyati (Termiz)|Toshkent Shahri|Toshkent Wiloyati";
-aStates[241]="|Malampa|Penama|Sanma|Shefa|Tafea|Torba";
-aStates[242]="|Amazonas|Anzoategui|Apure|Aragua|Barinas|Bolivar|Carabobo|Cojedes|Delta Amacuro|Dependencias Federales|Distrito Federal|Falcon|Guarico|Lara|Merida|Miranda|Monagas|Nueva Esparta|Portuguesa|Sucre|Tachira|Trujillo|Vargas|Yaracuy|Zulia";
-aStates[243]="|An Giang|Ba Ria-Vung Tau|Bac Giang|Bac Kan|Bac Lieu|Bac Ninh|Ben Tre|Binh Dinh|Binh Duong|Binh Phuoc|Binh Thuan|Ca Mau|Can Tho|Cao Bang|Da Nang|Dac Lak|Dong Nai|Dong Thap|Gia Lai|Ha Giang|Ha Nam|Ha Noi|Ha Tay|Ha Tinh|Hai Duong|Hai Phong|Ho Chi Minh|Hoa Binh|Hung Yen|Khanh Hoa|Kien Giang|Kon Tum|Lai Chau|Lam Dong|Lang Son|Lao Cai|Long An|Nam Dinh|Nghe An|Ninh Binh|Ninh Thuan|Phu Tho|Phu Yen|Quang Binh|Quang Nam|Quang Ngai|Quang Ninh|Quang Tri|Soc Trang|Son La|Tay Ninh|Thai Binh|Thai Nguyen|Thanh Hoa|Thua Thien-Hue|Tien Giang|Tra Vinh|Tuyen Quang|Vinh Long|Vinh Phuc|Yen Bai";
-aStates[244]="|Saint Croix|Saint John|Saint Thomas";
-aStates[245]="|Blaenau Gwent|Bridgend|Caerphilly|Cardiff|Carmarthenshire|Ceredigion|Conwy|Denbighshire|Flintshire|Gwynedd|Isle of Anglesey|Merthyr Tydfil|Monmouthshire|Neath Port Talbot|Newport|Pembrokeshire|Powys|Rhondda Cynon Taff|Swansea|The Vale of Glamorgan|Torfaen|Wrexham";
-aStates[246]="|Alo|Sigave|Wallis";
-aStates[247]="|West Bank";
-aStates[248]="|Western Sahara";
-aStates[249]="|'Adan|'Ataq|Abyan|Al Bayda'|Al Hudaydah|Al Jawf|Al Mahrah|Al Mahwit|Dhamar|Hadhramawt|Hajjah|Ibb|Lahij|Ma'rib|Sa'dah|San'a'|Ta'izz";
-aStates[250]="|Kosovo|Montenegro|Serbia|Vojvodina";
-aStates[251]="|Central|Copperbelt|Eastern|Luapula|Lusaka|North-Western|Northern|Southern|Western";
-aStates[252]="|Bulawayo|Harare|ManicalandMashonaland Central|Mashonaland East|Mashonaland West|Masvingo|Matabeleland North|Matabeleland South|Midlands";
-
-/*
- * gArCountryInfo
- * (0) Country name
- * (1) Name length
- * (2) Number of states
- * (3) Max state length
- */
-gLngNumberCountries = sCountryString.split("|").length;
-//gArCountryInfo = new Array(gLngNumberCountries);
-gArCountryInfo=sCountryString.split("|");
-/*
- * gArStateInfo[country][statenames][namelengths]
- * (0) Country
- * (1) States (Multi-sized Array)
- * (0) name
- * (1) nameLength
- */
-gArStateInfo = new Array(gLngNumberCountries);
-
-/*
- * fInitgArStateInfo()
- * purpose: build gArStateInfo array
- * gArStateInfo[Country][States][1]
- * (0) State name
- * (1) State name length
- * gArStateInfo[i] is an array of state names
- * gArStateInfo[i][j]=state name, name length
- */
-function fInitgArStateInfo() {
- var i=0, j=0, sStateName="", iNumberOfStates=0;
- var iMaxLength=0, iLength=0;
- var oldNumber=0;
-
- for (i=0;i<gLngNumberCountries;i++) {
- // i is selected country
- iNumberOfStates=aStates[i].split("|").length+1;
- gLngNumberStates=gLngNumberStates+iNumberOfStates;
- gArStateInfo[i]=new Array(iNumberOfStates);
- iMaxLength=0;
-
- // Add the additional information
- for (j=0;j<iNumberOfStates;j++) {
- if (iLength>iMaxLength) {
- iMaxLength=iLength;
- gArStateInfo[i][j][0]=sStateName;
- }
- }
- gArCountryInfo[i][3]=parseInt(iMaxLength);
- }
- Update_Globals();
- return;
-}
-
-/*
- * Working on this one.
- * Fills in region from the arrays
- *
- */
-function xFillState() {
- var i=0;
-
- // reset region
- document.form1.region.options.length=0;
-
- // get selected country
- gLngSelectedCountry=document.form1.country_name.selectedIndex;
-
- // get number of states for selected country
- gLngNumberStates=gArCountryInfo[[gLngSelectedCountry][2]];
-
- // update options in region
- for (i=0;i<gLngNumberStates;i++) {
- document.form1.region.options[i]=new
- Option(gArStateInfo[[gLngSelectedCountry][i][0]]);
- }
- gLngSelectedState=
- document.form1.region.options.selectedIndex;
-
- return;
-}
-
-/*
- * FillStates() function works.
- * Fills region from aStates
- */
-function Fill_States(current) {
- var i=0, iLen=0, iNumStates=0;
-
- // reset region
- document.form1.region.options.length=0;
- // get selected country
- gLngSelectedCountry=document.form1.country_name.selectedIndex;
- iNumStates = aStates[gLngSelectedCountry].split("|").length;
-
- // update the text boxes
-
- // fill the state combobox with the list of states
- for (i=0;i<iNumStates;i++) {
- document.form1.region.options[i]=new
- Option(aStates[document.form1.country_name.selectedIndex].split("|")[i]);
-
- sRegionName=document.form1.region.options[i];
- if(sRegionName.text == current) {
- document.form1.region.selectedIndex = i;
- }
-
- }
-
- return;
-}
-
-/*
- * FillCountry()
- * gArCountryInfo matrix holds the following information:
- * (0) Country name
- * (1) Name length
- * (2) Number of states
- * (3) Max state length
- */
-function Fill_Country(current) {
- var i=0;
- var sCountryName="";
-
- // reset country_name.options
- document.form1.country_name.options.length=0;
- // get number of countries from the string
-
- // ----------------------------------------------------
- // gArCountryInfo = new Array(gLngNumberCountries, 4);
- // ----------------------------------------------------
- for (i=0;i<gLngNumberCountries;i++) {
- gArCountryInfo[i]=new Array(4);
- }
-
- for (i=0;i<gLngNumberCountries;i++) {
- document.form1.country_name.options[i]=new Option(sCountryString.split("|")[i]);
- sCountryName=document.form1.country_name.options[i];
- if(sCountryName.text == current) {
- document.form1.country_name.selectedIndex = i;
- }
- gArCountryInfo[i]=
- [sCountryName,
- parseInt(sCountryName.length),
- aStates,
- 0];
- }
-
- fInitgArStateInfo();
-
- return;
-}
-
-function Update_Globals() {
- gLngSelectedCountry=parseInt(document.form1.country_name.selectedIndex);
- gLngSelectedState=parseInt(document.form1.region.selectedIndex);
- return;
-}
-
-
-//-->
diff --git a/include/crypto.php b/include/crypto.php
index a20606db5..0feb45c24 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -225,3 +225,71 @@ function pkcs5_unpad($text)
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false;
return substr($text, 0, -1 * $pad);
}
+
+function AES256CBC_encrypt($data,$key,$iv) {
+ return mcrypt_encrypt(
+ MCRYPT_RIJNDAEL_128,
+ str_pad($key,32,"\0"),
+ pkcs5_pad($data,16),
+ MCRYPT_MODE_CBC,
+ str_pad($iv,16,"\0"));
+}
+
+function AES256CBC_decrypt($data,$key,$iv) {
+ return pkcs5_unpad(mcrypt_decrypt(
+ MCRYPT_RIJNDAEL_128,
+ str_pad($key,32,"\0"),
+ $data,
+ MCRYPT_MODE_CBC,
+ str_pad($iv,16,"\0")));
+}
+
+function aes_encapsulate($data,$pubkey) {
+ $key = random_string(32,RANDOM_STRING_TEXT);
+ $iv = random_string(16,RANDOM_STRING_TEXT);
+ $result['data'] = base64url_encode(AES256CBC_encrypt($data,$key,$iv),true);
+ openssl_public_encrypt($key,$k,$pubkey);
+ $result['key'] = base64url_encode($k,true);
+ openssl_public_encrypt($iv,$i,$pubkey);
+ $result['iv'] = base64url_encode($i,true);
+ return $result;
+}
+
+function aes_unencapsulate($data,$prvkey) {
+ openssl_private_decrypt(base64url_decode($data['key']),$k,$prvkey);
+ openssl_private_decrypt(base64url_decode($data['iv']),$i,$prvkey);
+ return AES256CBC_decrypt(base64url_decode($data['data']),$k,$i);
+}
+
+
+// This has been superceded.
+
+function zot_encapsulate($data,$envelope,$pubkey) {
+$res = aes_encapsulate($data,$pubkey);
+
+return <<< EOT
+<?xml version='1.0' encoding='UTF-8'?>
+<zot:msg xmlns:zot='http://purl.org/zot/1.0'>
+ <zot:key>{$res['key']}</zot:key>
+ <zot:iv>{$res['iv']}</zot:iv>
+ <zot:env>$s1</zot:env>
+ <zot:sig key_id="$keyid">$sig</zot:sig>
+ <zot:alg>AES-256-CBC</zot:alg>
+ <zot:data type='application/magic-envelope+xml'>{$res['data']}</zot:data>
+</zot:msg>
+EOT;
+
+}
+
+// so has this
+
+function zot_unencapsulate($data,$prvkey) {
+ $ret = array();
+ $c = array();
+ $x = parse_xml_string($data);
+ $c = array('key' => $x->key,'iv' => $x->iv,'data' => $x->data);
+ openssl_private_decrypt(base64url_decode($x->sender),$s,$prvkey);
+ $ret['sender'] = $s;
+ $ret['data'] = aes_unencapsulate($x,$prvkey);
+ return $ret;
+} \ No newline at end of file
diff --git a/include/delivery.php b/include/delivery.php
new file mode 100644
index 000000000..46112d78e
--- /dev/null
+++ b/include/delivery.php
@@ -0,0 +1,476 @@
+<?php
+require_once("boot.php");
+
+function delivery_run($argv, $argc){
+ global $a, $db;
+
+ if(is_null($a)){
+ $a = new App;
+ }
+
+ if(is_null($db)) {
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ }
+
+ require_once("session.php");
+ require_once("datetime.php");
+ require_once('include/items.php');
+ require_once('include/bbcode.php');
+ require_once('include/diaspora.php');
+
+ load_config('config');
+ load_config('system');
+
+ load_hooks();
+
+ if($argc < 3)
+ return;
+
+ $a->set_baseurl(get_config('system','url'));
+
+ logger('delivery: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
+
+ $cmd = $argv[1];
+ $item_id = intval($argv[2]);
+ $contact_id = intval($argv[3]);
+
+ // Some other process may have delivered this item already.
+
+ $r = q("select * from deliverq where cmd = '%s' and item = %d and contact = %d limit 1",
+ dbesc($cmd),
+ dbesc($item_id),
+ dbesc($contact_id)
+ );
+ if(! count($r)) {
+ return;
+ }
+
+ // It's ours to deliver. Remove it from the queue.
+
+ q("delete from deliverq where cmd = '%s' and item = %d and contact = %d limit 1",
+ dbesc($cmd),
+ dbesc($item_id),
+ dbesc($contact_id)
+ );
+
+ if((! $item_id) || (! $contact_id))
+ return;
+
+ $expire = false;
+ $top_level = false;
+ $recipients = array();
+ $url_recipients = array();
+
+ $normal_mode = true;
+
+ $recipients[] = $contact_id;
+
+ if($cmd === 'expire') {
+ $normal_mode = false;
+ $expire = true;
+ $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
+ AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 30 MINUTE",
+ intval($item_id)
+ );
+ $uid = $item_id;
+ $item_id = 0;
+ if(! count($items))
+ return;
+ }
+ else {
+
+ // find ancestors
+ $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
+ intval($item_id)
+ );
+
+ if((! count($r)) || (! intval($r[0]['parent']))) {
+ return;
+ }
+
+ $target_item = $r[0];
+ $parent_id = intval($r[0]['parent']);
+ $uid = $r[0]['uid'];
+ $updated = $r[0]['edited'];
+
+ if(! $parent_id)
+ return;
+
+
+ $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
+ FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d ORDER BY `id` ASC",
+ intval($parent_id)
+ );
+
+ if(! count($items)) {
+ return;
+ }
+
+ $icontacts = null;
+ $contacts_arr = array();
+ foreach($items as $item)
+ if(! in_array($item['contact-id'],$contacts_arr))
+ $contacts_arr[] = intval($item['contact-id']);
+ if(count($contacts_arr)) {
+ $str_contacts = implode(',',$contacts_arr);
+ $icontacts = q("SELECT * FROM `contact`
+ WHERE `id` IN ( $str_contacts ) "
+ );
+ }
+ if( ! ($icontacts && count($icontacts)))
+ return;
+
+
+ // avoid race condition with deleting entries
+
+ if($items[0]['deleted']) {
+ foreach($items as $item)
+ $item['deleted'] = 1;
+ }
+
+ if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
+ logger('delivery: top level post');
+ $top_level = true;
+ }
+ }
+
+ $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
+ `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
+ `user`.`page-flags`, `user`.`prvnets`
+ FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
+ WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
+ intval($uid)
+ );
+
+ if(! count($r))
+ return;
+
+ $owner = $r[0];
+
+ $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
+
+ $public_message = true;
+
+ // fill this in with a single salmon slap if applicable
+
+ $slap = '';
+
+ require_once('include/group.php');
+
+ $parent = $items[0];
+
+ // This is IMPORTANT!!!!
+
+ // We will only send a "notify owner to relay" or followup message if the referenced post
+ // originated on our system by virtue of having our hostname somewhere
+ // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere.
+ // if $parent['wall'] == 1 we will already have the parent message in our array
+ // and we will relay the whole lot.
+
+ // expire sends an entire group of expire messages and cannot be forwarded.
+ // However the conversation owner will be a part of the conversation and will
+ // be notified during this run.
+ // Other DFRN conversation members will be alerted during polled updates.
+
+ // Diaspora members currently are not notified of expirations, and other networks have
+ // either limited or no ability to process deletions. We should at least fix Diaspora
+ // by stringing togther an array of retractions and sending them onward.
+
+
+ $localhost = $a->get_hostname();
+ if(strpos($localhost,':'))
+ $localhost = substr($localhost,0,strpos($localhost,':'));
+
+ /**
+ *
+ * Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes
+ * have been known to cause runaway conditions which affected several servers, along with
+ * permissions issues.
+ *
+ */
+
+ if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
+ logger('relay denied for delivery agent.');
+
+ /* no relay allowed for direct contact delivery */
+ return;
+ }
+
+ if((strlen($parent['allow_cid']))
+ || (strlen($parent['allow_gid']))
+ || (strlen($parent['deny_cid']))
+ || (strlen($parent['deny_gid']))) {
+ $public_message = false; // private recipients, not public
+ }
+
+ $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
+ intval($contact_id)
+ );
+
+ if(count($r))
+ $contact = $r[0];
+
+ $hubxml = feed_hublinks();
+
+ logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA);
+
+ require_once('include/salmon.php');
+
+ if($contact['self'])
+ return;
+
+ $deliver_status = 0;
+
+ switch($contact['network']) {
+
+ case NETWORK_DFRN :
+ logger('notifier: dfrndelivery: ' . $contact['name']);
+
+ $feed_template = get_markup_template('atom_feed.tpl');
+ $mail_template = get_markup_template('atom_mail.tpl');
+
+ $atom = '';
+
+
+ $birthday = feed_birthday($owner['uid'],$owner['timezone']);
+
+ if(strlen($birthday))
+ $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
+
+ $atom .= replace_macros($feed_template, array(
+ '$version' => xmlify(FRIENDIKA_VERSION),
+ '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
+ '$feed_title' => xmlify($owner['name']),
+ '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
+ '$hub' => $hubxml,
+ '$salmon' => '', // private feed, we don't use salmon here
+ '$name' => xmlify($owner['name']),
+ '$profile_page' => xmlify($owner['url']),
+ '$photo' => xmlify($owner['photo']),
+ '$thumb' => xmlify($owner['thumb']),
+ '$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
+ ));
+
+ foreach($items as $item) {
+ if(! $item['parent'])
+ continue;
+
+ // private emails may be in included in public conversations. Filter them.
+ if(($public_message) && $item['private'])
+ continue;
+
+ $item_contact = get_item_contact($item,$icontacts);
+ if(! $item_contact)
+ continue;
+
+ $atom .= atom_entry($item,'text',$item_contact,$owner,true);
+
+ }
+
+ $atom .= '</feed>' . "\r\n";
+
+ logger('notifier: ' . $atom, LOGGER_DATA);
+
+ $deliver_status = dfrn_deliver($owner,$contact,$atom);
+
+ logger('notifier: dfrn_delivery returns ' . $deliver_status);
+
+ if($deliver_status == (-1)) {
+ logger('notifier: delivery failed: queuing message');
+ // queue message for redelivery
+ q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
+ VALUES ( %d, '%s', '%s', '%s') ",
+ intval($contact['id']),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($atom)
+ );
+ }
+ break;
+
+ case NETWORK_OSTATUS :
+
+ // Do not send to otatus if we are not configured to send to public networks
+ if($owner['prvnets'])
+ break;
+ if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
+ break;
+
+ // only send salmon if public - e.g. if it's ok to notify
+ // a public hub, it's ok to send a salmon
+
+ if(($public_message) && (! $expire)) {
+ $slaps = array();
+
+ foreach($items as $item) {
+ if(! $item['parent'])
+ continue;
+
+ // private emails may be in included in public conversations. Filter them.
+ if(($public_message) && $item['private'])
+ continue;
+
+ $item_contact = get_item_contact($item,$icontacts);
+ if(! $item_contact)
+ continue;
+
+ if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
+ $slaps[] = atom_entry($item,'html',$item_contact,$owner,true);
+ }
+
+ logger('notifier: slapdelivery: ' . $contact['name']);
+ foreach($slaps as $slappy) {
+ if($contact['notify']) {
+ $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ if($deliver_status == (-1)) {
+ // queue message for redelivery
+ q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
+ VALUES ( %d, '%s', '%s', '%s') ",
+ intval($contact['id']),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($slappy)
+ );
+ }
+ }
+ }
+ }
+
+ break;
+
+ case NETWORK_MAIL :
+
+ if(get_config('system','dfrn_only'))
+ break;
+ // WARNING: does not currently convert to RFC2047 header encodings, etc.
+
+ $addr = $contact['addr'];
+ if(! strlen($addr))
+ break;
+
+ if($cmd === 'wall-new' || $cmd === 'comment-new') {
+
+ $it = null;
+ if($cmd === 'wall-new')
+ $it = $items[0];
+ else {
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($argv[2]),
+ intval($uid)
+ );
+ if(count($r))
+ $it = $r[0];
+ }
+ if(! $it)
+ break;
+
+
+ $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if(! count($local_user))
+ break;
+
+ $reply_to = '';
+ $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if($r1 && $r1[0]['reply_to'])
+ $reply_to = $r1[0]['reply_to'];
+
+ $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ;
+ $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n";
+ if($reply_to)
+ $headers .= 'Reply-to: ' . $reply_to . "\n";
+ $headers .= 'Message-id: <' . $it['uri'] . '>' . "\n";
+ if($it['uri'] !== $it['parent-uri']) {
+ $header .= 'References: <' . $it['parent-uri'] . '>' . "\n";
+ if(! strlen($it['title'])) {
+ $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
+ dbesc($it['parent-uri'])
+ );
+ if(count($r)) {
+ $subtitle = $r[0]['title'];
+ if($subtitle) {
+ if(strncasecmp($subtitle,'RE:',3))
+ $subject = $subtitle;
+ else
+ $subject = 'Re: ' . $subtitle;
+ }
+ }
+ }
+ }
+ $headers .= 'MIME-Version: 1.0' . "\n";
+ $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
+ $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
+ $html = prepare_body($it);
+ $message = '<html><body>' . $html . '</body></html>';
+ logger('notifier: email delivery to ' . $addr);
+ mail($addr, $subject, $message, $headers);
+ }
+ break;
+
+ case NETWORK_DIASPORA :
+ if($public_message)
+ $loc = 'public batch ' . $contact['batch'];
+ else
+ $loc = $contact['name'];
+
+ logger('delivery: diaspora batch deliver: ' . $loc);
+
+ if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
+ break;
+
+ if((! $contact['pubkey']) && (! $public_message))
+ break;
+
+ if($target_item['verb'] === ACTIVITY_DISLIKE) {
+ // unsupported
+ break;
+ }
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
+ logger('delivery: diaspora retract: ' . $loc);
+ // diaspora delete,
+ diaspora_send_retraction($target_item,$owner,$contact,$public_message);
+ break;
+ }
+ elseif($target_item['parent'] != $target_item['id']) {
+
+ logger('delivery: diaspora relay: ' . $loc);
+
+ // we are the relay - send comments, likes and unlikes to our conversants
+ diaspora_send_relay($target_item,$owner,$contact,$public_message);
+ break;
+ }
+ elseif(($top_level) && (! $walltowall)) {
+ // currently no workable solution for sending walltowall
+ logger('delivery: diaspora status: ' . $loc);
+ diaspora_send_status($target_item,$owner,$contact,$public_message);
+ break;
+ }
+
+ logger('delivery: diaspora unknown mode: ' . $contact['name']);
+
+ break;
+
+ case NETWORK_FEED :
+ case NETWORK_FACEBOOK :
+ if(get_config('system','dfrn_only'))
+ break;
+ default:
+ break;
+ }
+
+ return;
+}
+
+if (array_search(__file__,get_included_files())===0){
+ delivery_run($argv,$argc);
+ killme();
+}
diff --git a/include/diaspora.php b/include/diaspora.php
index 75d47e05a..1ae8ca800 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -3,35 +3,57 @@
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/bb2diaspora.php');
+require_once('include/contact_selectors.php');
+
+
+function diaspora_dispatch_public($msg) {
+
+ $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ",
+ dbesc(NETWORK_DIASPORA),
+ dbesc($msg['author'])
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ logger('diaspora_public: delivering to: ' . $rr['username']);
+ diaspora_dispatch($rr,$msg);
+ }
+ }
+ else
+ logger('diaspora_public: no subscribers');
+}
+
+
function diaspora_dispatch($importer,$msg) {
+ $ret = 0;
+
$parsed_xml = parse_xml_string($msg['message'],false);
$xmlbase = $parsed_xml->post;
if($xmlbase->request) {
- diaspora_request($importer,$xmlbase->request);
+ $ret = diaspora_request($importer,$xmlbase->request);
}
elseif($xmlbase->status_message) {
- diaspora_post($importer,$xmlbase->status_message);
+ $ret = diaspora_post($importer,$xmlbase->status_message);
}
elseif($xmlbase->comment) {
- diaspora_comment($importer,$xmlbase->comment,$msg);
+ $ret = diaspora_comment($importer,$xmlbase->comment,$msg);
}
elseif($xmlbase->like) {
- diaspora_like($importer,$xmlbase->like,$msg);
+ $ret = diaspora_like($importer,$xmlbase->like,$msg);
}
elseif($xmlbase->retraction) {
- diaspora_retraction($importer,$xmlbase->retraction,$msg);
+ $ret = diaspora_retraction($importer,$xmlbase->retraction,$msg);
}
elseif($xmlbase->photo) {
- diaspora_photo($importer,$xmlbase->photo,$msg);
+ $ret = diaspora_photo($importer,$xmlbase->photo,$msg);
}
else {
logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase,true));
}
- return;
+ return $ret;
}
function diaspora_get_contact_by_handle($uid,$handle) {
@@ -46,6 +68,7 @@ function diaspora_get_contact_by_handle($uid,$handle) {
}
function find_diaspora_person_by_handle($handle) {
+ $update = false;
$r = q("select * from fcontact where network = '%s' and addr = '%s' limit 1",
dbesc(NETWORK_DIASPORA),
dbesc($handle)
@@ -53,18 +76,14 @@ function find_diaspora_person_by_handle($handle) {
if(count($r)) {
// update record occasionally so it doesn't get stale
$d = strtotime($r[0]['updated'] . ' +00:00');
- if($d < strtotime('now - 14 days')) {
- q("delete from fcontact where id = %d limit 1",
- intval($r[0]['id'])
- );
- }
- else
+ if($d > strtotime('now - 14 days'))
return $r[0];
+ $update = true;
}
require_once('include/Scrape.php');
$r = probe_url($handle, PROBE_DIASPORA);
if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) {
- add_fcontact($r);
+ add_fcontact($r,$update);
return ($r);
}
return false;
@@ -81,9 +100,60 @@ function get_diaspora_key($uri) {
}
-function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
+function diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey) {
+ $a = get_app();
+
+ logger('diaspora_pubmsg_build: ' . $msg, LOGGER_DATA);
+
+
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+// $b64_data = base64_encode($msg);
+// $b64url_data = base64url_encode($b64_data);
+
+ $b64url_data = base64url_encode($msg);
+
+ $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
+
+ $type = 'application/xml';
+ $encoding = 'base64url';
+ $alg = 'RSA-SHA256';
+
+ $signable_data = $data . '.' . base64url_encode($type) . '.'
+ . base64url_encode($encoding) . '.' . base64url_encode($alg) ;
+
+ $signature = rsa_sign($signable_data,$prvkey);
+ $sig = base64url_encode($signature);
+
+$magic_env = <<< EOT
+<?xml version='1.0' encoding='UTF-8'?>
+<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
+ <header>
+ <author_id>$handle</author_id>
+ </header>
+ <me:env>
+ <me:encoding>base64url</me:encoding>
+ <me:alg>RSA-SHA256</me:alg>
+ <me:data type="application/xml">$data</me:data>
+ <me:sig>$sig</me:sig>
+ </me:env>
+</diaspora>
+EOT;
+
+ logger('diaspora_pubmsg_build: magic_env: ' . $magic_env, LOGGER_DATA);
+ return $magic_env;
+
+}
+
+
+
+
+function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey,$public = false) {
$a = get_app();
+ if($public)
+ return diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey);
+
logger('diaspora_msg_build: ' . $msg, LOGGER_DATA);
$inner_aes_key = random_string(32);
@@ -96,7 +166,7 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$outer_iv = random_string(16);
$b_outer_iv = base64_encode($outer_iv);
- $handle = 'acct:' . $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
$padded_data = pkcs5_pad($msg,16);
$inner_encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $padded_data, MCRYPT_MODE_CBC, $inner_iv);
@@ -105,16 +175,14 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$b64url_data = base64url_encode($b64_data);
- $b64url_stripped = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
- $lines = str_split($b64url_stripped,60);
- $data = implode("\n",$lines);
- $data = $data . (($data[-1] != "\n") ? "\n" : '') ;
- $type = 'application/atom+xml';
+ $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
+
+ $type = 'application/xml';
$encoding = 'base64url';
$alg = 'RSA-SHA256';
- $signable_data = $data . '.' . base64url_encode($type) . "\n" . '.'
- . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
+ $signable_data = $data . '.' . base64url_encode($type) . '.'
+ . base64url_encode($encoding) . '.' . base64url_encode($alg) ;
$signature = rsa_sign($signable_data,$prvkey);
$sig = base64url_encode($signature);
@@ -123,10 +191,7 @@ $decrypted_header = <<< EOT
<decrypted_header>
<iv>$b_inner_iv</iv>
<aes_key>$b_inner_aes_key</aes_key>
- <author>
- <name>{$user['username']}</name>
- <uri>$handle</uri>
- </author>
+ <author_id>$handle</author_id>
</decrypted_header>
EOT;
@@ -139,10 +204,9 @@ EOT;
$encrypted_outer_key_bundle = '';
openssl_public_encrypt($outer_json,$encrypted_outer_key_bundle,$pubkey);
- logger('outer_bundle_encrypt: ' . openssl_error_string());
$b64_encrypted_outer_key_bundle = base64_encode($encrypted_outer_key_bundle);
- logger('outer_bundle: ' . $b64_encrypted_outer_key_bundle . ' key: ' . $pubkey);
+ logger('outer_bundle: ' . $b64_encrypted_outer_key_bundle . ' key: ' . $pubkey, LOGGER_DATA);
$encrypted_header_json_object = json_encode(array('aes_key' => base64_encode($encrypted_outer_key_bundle),
'ciphertext' => base64_encode($ciphertext)));
@@ -152,15 +216,15 @@ EOT;
$magic_env = <<< EOT
<?xml version='1.0' encoding='UTF-8'?>
-<entry xmlns='http://www.w3.org/2005/Atom'>
+<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
$encrypted_header
- <me:env xmlns:me="http://salmon-protocol.org/ns/magic-env">
+ <me:env>
<me:encoding>base64url</me:encoding>
<me:alg>RSA-SHA256</me:alg>
- <me:data type="application/atom+xml">$data</me:data>
+ <me:data type="application/xml">$data</me:data>
<me:sig>$sig</me:sig>
</me:env>
-</entry>
+</diaspora>
EOT;
logger('diaspora_msg_build: magic_env: ' . $magic_env, LOGGER_DATA);
@@ -185,50 +249,67 @@ EOT;
function diaspora_decode($importer,$xml) {
+ $public = false;
$basedom = parse_xml_string($xml);
- $atom = $basedom->children(NAMESPACE_ATOM1);
+ $children = $basedom->children('https://joindiaspora.com/protocol');
- // Diaspora devs: This is kind of sucky - 'encrypted_header' does not belong in the atom namespace
+ if($children->header) {
+ $public = true;
+ $author_link = str_replace('acct:','',$children->header->author_id);
+ }
+ else {
- $encrypted_header = json_decode(base64_decode($atom->encrypted_header));
+ $encrypted_header = json_decode(base64_decode($children->encrypted_header));
- $encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
- $ciphertext = base64_decode($encrypted_header->ciphertext);
+ $encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
+ $ciphertext = base64_decode($encrypted_header->ciphertext);
+
+ $outer_key_bundle = '';
+ openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
+
+ $j_outer_key_bundle = json_decode($outer_key_bundle);
+
+ $outer_iv = base64_decode($j_outer_key_bundle->iv);
+ $outer_key = base64_decode($j_outer_key_bundle->key);
+
+ $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv);
- $outer_key_bundle = '';
- openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
- $j_outer_key_bundle = json_decode($outer_key_bundle);
+ $decrypted = pkcs5_unpad($decrypted);
- $outer_iv = base64_decode($j_outer_key_bundle->iv);
- $outer_key = base64_decode($j_outer_key_bundle->key);
+ /**
+ * $decrypted now contains something like
+ *
+ * <decrypted_header>
+ * <iv>8e+G2+ET8l5BPuW0sVTnQw==</iv>
+ * <aes_key>UvSMb4puPeB14STkcDWq+4QE302Edu15oaprAQSkLKU=</aes_key>
- $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv);
+***** OBSOLETE
+ * <author>
+ * <name>Ryan Hughes</name>
+ * <uri>acct:galaxor@diaspora.pirateship.org</uri>
+ * </author>
- $decrypted = pkcs5_unpad($decrypted);
+***** CURRENT
- /**
- * $decrypted now contains something like
- *
- * <decrypted_header>
- * <iv>8e+G2+ET8l5BPuW0sVTnQw==</iv>
- * <aes_key>UvSMb4puPeB14STkcDWq+4QE302Edu15oaprAQSkLKU=</aes_key>
- * <author>
- * <name>Ryan Hughes</name>
- * <uri>acct:galaxor@diaspora.pirateship.org</uri>
- * </author>
- * </decrypted_header>
- */
+ * <author_id>galaxor@diaspora.priateship.org</author_id>
- logger('decrypted: ' . $decrypted);
- $idom = parse_xml_string($decrypted,false);
+***** END DIFFS
- $inner_iv = base64_decode($idom->iv);
- $inner_aes_key = base64_decode($idom->aes_key);
+ * </decrypted_header>
+ */
- $author_link = str_replace('acct:','',$idom->author->uri);
+ logger('decrypted: ' . $decrypted, LOGGER_DEBUG);
+ $idom = parse_xml_string($decrypted,false);
+
+ $inner_iv = base64_decode($idom->iv);
+ $inner_aes_key = base64_decode($idom->aes_key);
+
+ $author_link = str_replace('acct:','',$idom->author_id);
+
+ }
$dom = $basedom->children(NAMESPACE_SALMON_ME);
@@ -255,16 +336,6 @@ function diaspora_decode($importer,$xml) {
// strip whitespace so our data element will return to one big base64 blob
$data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data);
- // Add back the 60 char linefeeds
-
- // This completely violates the entire principle of salmon magic signatures,
- // which was to have a message signing format that was completely ambivalent to linefeeds
- // and transport whitespace mangling, and base64 wrapping rules. Guess what? PHP and Ruby
- // use different linelengths for base64 output.
-
- $lines = str_split($data,60);
- $data = implode("\n",$lines);
-
// stash away some other stuff for later
@@ -273,22 +344,25 @@ function diaspora_decode($importer,$xml) {
$encoding = $base->encoding;
$alg = $base->alg;
- // I can't even begin to tell you how sucky this is. Please read the spec.
- $signed_data = $data . (($data[-1] != "\n") ? "\n" : '') . '.' . base64url_encode($type) . "\n" . '.' . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
+ $signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
// decode the data
$data = base64url_decode($data);
- // Now pull out the inner encrypted blob
- $inner_encrypted = base64_decode($data);
+ if($public) {
+ $inner_decrypted = $data;
+ }
+ else {
- $inner_decrypted =
- $inner_decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $inner_encrypted, MCRYPT_MODE_CBC, $inner_iv);
+ // Decode the encrypted blob
- $inner_decrypted = pkcs5_unpad($inner_decrypted);
+ $inner_encrypted = base64_decode($data);
+ $inner_decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $inner_encrypted, MCRYPT_MODE_CBC, $inner_iv);
+ $inner_decrypted = pkcs5_unpad($inner_decrypted);
+ }
if(! $author_link) {
logger('mod-diaspora: Could not retrieve author URI.');
@@ -321,7 +395,6 @@ function diaspora_decode($importer,$xml) {
}
-
function diaspora_request($importer,$xml) {
$sender_handle = unxmlify($xml->sender_handle);
@@ -332,7 +405,6 @@ function diaspora_request($importer,$xml) {
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
-
if($contact) {
// perhaps we were already sharing with this person. Now they're sharing with us.
@@ -357,13 +429,16 @@ function diaspora_request($importer,$xml) {
return;
}
- $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
- VALUES ( %d, '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
+ $batch = (($ret['batch']) ? $ret['batch'] : implode('/', array_slice(explode('/',$ret['url']),0,3)) . '/receive/public');
+
+ $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
+ VALUES ( %d, '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
intval($importer['uid']),
dbesc($ret['network']),
dbesc($ret['addr']),
datetime_convert(),
dbesc($ret['url']),
+ dbesc($batch),
dbesc($ret['name']),
dbesc($ret['nick']),
dbesc($ret['photo']),
@@ -398,6 +473,7 @@ function diaspora_request($importer,$xml) {
function diaspora_post($importer,$xml) {
+ $a = get_app();
$guid = notags(unxmlify($xml->guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
@@ -407,8 +483,7 @@ function diaspora_post($importer,$xml) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_post: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$message_id = $diaspora_handle . ':' . $guid;
@@ -417,8 +492,10 @@ function diaspora_post($importer,$xml) {
dbesc($message_id),
dbesc($guid)
);
- if(count($r))
+ if(count($r)) {
+ logger('diaspora_post: message exists: ' . $guid);
return;
+ }
// allocate a guid on our system - we aren't fixing any collisions.
// we're ignoring them
@@ -435,32 +512,7 @@ function diaspora_post($importer,$xml) {
$created = unxmlify($xml->created_at);
$private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
- $body = unxmlify($xml->raw_message);
-
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
- $maxlen = get_max_import_size();
- if($maxlen && (strlen($body) > $maxlen))
- $body = substr($body,0, $maxlen);
-
- if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
-
- $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
- '[youtube]$1[/youtube]', $body);
-
- $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
- '[youtube]$1[/youtube]', $body);
-
- $body = oembed_html2bbcode($body);
-
- $config = HTMLPurifier_Config::createDefault();
- $config->set('Cache.DefinitionImpl', null);
- $purifier = new HTMLPurifier($config);
- $body = $purifier->purify($body);
-
- $body = html2bbcode($body);
- }
+ $body = diaspora2bb($xml->raw_message);
$datarray = array();
$datarray['uid'] = $importer['uid'];
@@ -478,8 +530,16 @@ function diaspora_post($importer,$xml) {
$datarray['author-link'] = $contact['url'];
$datarray['author-avatar'] = $contact['thumb'];
$datarray['body'] = $body;
+ $datarray['app'] = 'Diaspora';
+
+ $message_id = item_store($datarray);
- item_store($datarray);
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
return;
@@ -487,6 +547,7 @@ function diaspora_post($importer,$xml) {
function diaspora_comment($importer,$xml,$msg) {
+ $a = get_app();
$guid = notags(unxmlify($xml->guid));
$parent_guid = notags(unxmlify($xml->parent_guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
@@ -499,13 +560,23 @@ function diaspora_comment($importer,$xml,$msg) {
$text = $xml->text;
$contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
- if(! $contact)
+ if(! $contact) {
+ logger('diaspora_comment: cannot find contact: ' . $msg['author']);
return;
+ }
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_comment: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
+ }
+
+ $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
+ intval($importer['uid']),
+ dbesc($guid)
+ );
+ if(count($r)) {
+ logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
+ return;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -537,7 +608,7 @@ function diaspora_comment($importer,$xml,$msg) {
}
}
- if(! rsa_verify($author_signed_data,$author_signature,$key,'sha')) {
+ if(! rsa_verify($author_signed_data,$author_signature,$key,'sha256')) {
logger('diaspora_comment: verification failed.');
return;
}
@@ -550,7 +621,7 @@ function diaspora_comment($importer,$xml,$msg) {
$key = $msg['key'];
- if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha')) {
+ if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha256')) {
logger('diaspora_comment: owner verification failed.');
return;
}
@@ -558,32 +629,7 @@ function diaspora_comment($importer,$xml,$msg) {
// Phew! Everything checks out. Now create an item.
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
- $body = $text;
-
- $maxlen = get_max_import_size();
- if($maxlen && (strlen($body) > $maxlen))
- $body = substr($body,0, $maxlen);
-
- if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
-
- $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
- '[youtube]$1[/youtube]', $body);
-
- $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
- '[youtube]$1[/youtube]', $body);
-
- $body = oembed_html2bbcode($body);
-
- $config = HTMLPurifier_Config::createDefault();
- $config->set('Cache.DefinitionImpl', null);
- $purifier = new HTMLPurifier($config);
- $body = $purifier->purify($body);
-
- $body = html2bbcode($body);
- }
+ $body = diaspora2bb($text);
$message_id = $diaspora_handle . ':' . $guid;
@@ -608,9 +654,17 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['author-link'] = $person['url'];
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$datarray['body'] = $body;
+ $datarray['app'] = 'Diaspora';
$message_id = item_store($datarray);
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
+
if(! $parent_author_signature) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($message_id),
@@ -630,6 +684,7 @@ function diaspora_comment($importer,$xml,$msg) {
function diaspora_photo($importer,$xml,$msg) {
+ $a = get_app();
$remote_photo_path = notags(unxmlify($xml->remote_photo_path));
$remote_photo_name = notags(unxmlify($xml->remote_photo_name));
@@ -651,8 +706,7 @@ function diaspora_photo($importer,$xml,$msg) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_photo: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -697,13 +751,14 @@ function diaspora_like($importer,$xml,$msg) {
return;
$contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
- if(! $contact)
+ if(! $contact) {
+ logger('diaspora_like: cannot find contact: ' . $msg['author']);
return;
+ }
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_like: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -759,20 +814,20 @@ function diaspora_like($importer,$xml,$msg) {
}
}
- if(! rsa_verify($author_signed_data,$author_signature,$key,'sha')) {
+ if(! rsa_verify($author_signed_data,$author_signature,$key,'sha256')) {
logger('diaspora_like: verification failed.');
return;
}
if($parent_author_signature) {
-// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle;
+
+ $owner_signed_data = $guid . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
$key = $msg['key'];
- if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha')) {
+ if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha256')) {
logger('diaspora_like: owner verification failed.');
return;
}
@@ -826,6 +881,8 @@ EOT;
$plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
+ $arr['app'] = 'Diaspora';
+
$arr['private'] = $parent_item['private'];
$arr['verb'] = $activity;
$arr['object-type'] = $objtype;
@@ -836,6 +893,14 @@ EOT;
$message_id = item_store($arr);
+
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
+
if(! $parent_author_signature) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($message_id),
@@ -883,7 +948,7 @@ function diaspora_retraction($importer,$xml) {
}
}
- http_exit_status(202);
+ return 202;
// NOTREACHED
}
@@ -923,7 +988,7 @@ function diaspora_unshare($me,$contact) {
-function diaspora_send_status($item,$owner,$contact) {
+function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
@@ -947,11 +1012,12 @@ function diaspora_send_status($item,$owner,$contact) {
}
}
- $body = xmlify(bb2diaspora($body));
+ $body = xmlify(html_entity_decode(bb2diaspora($body)));
+
$public = (($item['private']) ? 'false' : 'true');
require_once('include/datetime.php');
- $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d h:i:s \U\T\C');
+ $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
$tpl = get_markup_template('diaspora_post.tpl');
$msg = replace_macros($tpl, array(
@@ -964,19 +1030,19 @@ function diaspora_send_status($item,$owner,$contact) {
logger('diaspora_send_status: ' . $owner['username'] . ' -> ' . $contact['name'] . ' base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- $return_code = diaspora_transmit($owner,$contact,$slap);
+ $return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
if(count($images)) {
- diaspora_send_images($item,$owner,$contact,$images);
+ diaspora_send_images($item,$owner,$contact,$images,$public_batch);
}
return $return_code;
}
-function diaspora_send_images($item,$owner,$contact,$images) {
+function diaspora_send_images($item,$owner,$contact,$images,$public_batch = false) {
$a = get_app();
if(! count($images))
return;
@@ -1003,19 +1069,19 @@ function diaspora_send_images($item,$owner,$contact,$images) {
'$guid' => xmlify($r[0]['guid']),
'$handle' => xmlify($image['handle']),
'$public' => xmlify($public),
- '$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d h:i:s \U\T\C'))
+ '$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d H:i:s \U\T\C'))
));
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- diaspora_transmit($owner,$contact,$slap);
+ diaspora_transmit($owner,$contact,$slap,$public_batch);
}
}
-function diaspora_send_followup($item,$owner,$contact) {
+function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
@@ -1040,7 +1106,7 @@ function diaspora_send_followup($item,$owner,$contact) {
$like = false;
}
- $text = bb2diaspora($item['body']);
+ $text = html_entity_decode(bb2diaspora($item['body']));
// sign it
@@ -1049,7 +1115,7 @@ function diaspora_send_followup($item,$owner,$contact) {
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -1063,13 +1129,13 @@ function diaspora_send_followup($item,$owner,$contact) {
logger('diaspora_followup: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_send_relay($item,$owner,$contact) {
+function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$a = get_app();
@@ -1085,14 +1151,6 @@ function diaspora_send_relay($item,$owner,$contact) {
else
return;
- // fetch the original signature
- $r = q("select * from sign where iid = %d limit 1",
- intval($item['id'])
- );
- if(! count($r))
- return;
- $orig_sign = $r[0];
-
if($item['verb'] === ACTIVITY_LIKE) {
$tpl = get_markup_template('diaspora_like_relay.tpl');
$like = true;
@@ -1104,16 +1162,61 @@ function diaspora_send_relay($item,$owner,$contact) {
$like = false;
}
- $text = bb2diaspora($item['body']);
+ $body = $item['body'];
- // sign it
+ $text = html_entity_decode(bb2diaspora($body));
- if($like)
- $parent_signed_text = $orig_sign['signed_text'];
- else
- $parent_signed_text = $orig_sign['signed_text'];
+ // fetch the original signature if somebody sent the post to us to relay
+ // If we are relaying for a reply originating on our own account, there wasn't a 'send to relay'
+ // action. It wasn't needed. In that case create the original signature and the
+ // owner (parent author) signature
+ // comments from other networks will be relayed under our name, with a brief
+ // preamble to describe what's happening and noting the real author
+
+ $r = q("select * from sign where iid = %d limit 1",
+ intval($item['id'])
+ );
+ if(count($r)) {
+ $orig_sign = $r[0];
+ $signed_text = $orig_sign['signed_text'];
+ $authorsig = $orig_sign['signature'];
+ $handle = $orig_sign['signer'];
+ }
+ else {
+
+ $itemcontact = q("select * from contact where `id` = %d limit 1",
+ intval($item['contact-id'])
+ );
+ if(count($itemcontact)) {
+ if(! $itemcontact[0]['self']) {
+ $prefix = sprintf( t('[Relayed] Comment authored by %s from network %s'),
+ '['. $item['author-name'] . ']' . '(' . $item['author-link'] . ')',
+ network_to_name($itemcontact['network'])) . "\n";
+ $body = $prefix . $body;
+ }
+ }
+ else {
+
+ if($like)
+ $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
+ else
+ $signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
+
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
+
+ q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
+ intval($item['id']),
+ dbesc($signed_text),
+ dbesc(base64_encode($authorsig)),
+ dbesc($myaddr)
+ );
+ $handle = $myaddr;
+ }
+ }
- $parentauthorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
+ // sign it
+
+ $parentauthorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -1121,29 +1224,22 @@ function diaspora_send_relay($item,$owner,$contact) {
'$target_type' =>xmlify($target_type),
'$authorsig' => xmlify($orig_sign['signature']),
'$parentsig' => xmlify($parentauthorsig),
- '$text' => xmlify($text),
+ '$body' => xmlify($text),
'$positive' => xmlify($positive),
- '$diaspora_handle' => xmlify($myaddr)
+ '$handle' => xmlify($handle)
));
- // fetch the original signature
- $r = q("select * from sign where iid = %d limit 1",
- intval($item['id'])
- );
- if(! count($r))
- return;
-
logger('diaspora_relay_comment: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_send_retraction($item,$owner,$contact) {
+function diaspora_send_retraction($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
@@ -1155,32 +1251,35 @@ function diaspora_send_retraction($item,$owner,$contact) {
'$handle' => $myaddr
));
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_transmit($owner,$contact,$slap) {
+function diaspora_transmit($owner,$contact,$slap,$public_batch) {
$a = get_app();
-
- post_url($contact['notify'] . '/',$slap);
+ $logid = random_string(4);
+ logger('diaspora_transmit: ' . $logid . ' ' . (($public_batch) ? $contact['batch'] : $contact['notify']));
+ post_url((($public_batch) ? $contact['batch'] : $contact['notify']) . '/',$slap);
$return_code = $a->get_curl_code();
- logger('diaspora_transmit: returns: ' . $return_code);
+ logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code);
- if(! $return_code) {
+ if((! $return_code) || (($curl_stat == 503) && (stristr($a->get_curl_headers(),'retry-after')))) {
logger('diaspora_transmit: queue message');
// queue message for redelivery
- q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
- VALUES ( %d, '%s', '%s', '%s') ",
+ q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`,`batch`)
+ VALUES ( %d, '%s', '%s', '%s', %d) ",
intval($contact['id']),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- dbesc($slap)
+ dbesc($slap),
+ intval($public_batch)
);
}
+
return(($return_code) ? $return_code : (-1));
}
diff --git a/include/email.php b/include/email.php
index 1f485e430..3e6a8186d 100644
--- a/include/email.php
+++ b/include/email.php
@@ -4,7 +4,7 @@ function email_connect($mailbox,$username,$password) {
if(! function_exists('imap_open'))
return false;
- $mbox = imap_open($mailbox,$username,$password);
+ $mbox = @imap_open($mailbox,$username,$password);
return $mbox;
}
@@ -14,19 +14,19 @@ function email_poll($mbox,$email_addr) {
if(! ($mbox && $email_addr))
return array();
- $search1 = imap_search($mbox,'FROM "' . $email_addr . '"', SE_UID);
+ $search1 = @imap_search($mbox,'FROM "' . $email_addr . '"', SE_UID);
if(! $search1)
$search1 = array();
- $search2 = imap_search($mbox,'TO "' . $email_addr . '"', SE_UID);
+ $search2 = @imap_search($mbox,'TO "' . $email_addr . '"', SE_UID);
if(! $search2)
$search2 = array();
- $search3 = imap_search($mbox,'CC "' . $email_addr . '"', SE_UID);
+ $search3 = @imap_search($mbox,'CC "' . $email_addr . '"', SE_UID);
if(! $search3)
$search3 = array();
- $search4 = imap_search($mbox,'BCC "' . $email_addr . '"', SE_UID);
+ $search4 = @imap_search($mbox,'BCC "' . $email_addr . '"', SE_UID);
if(! $search4)
$search4 = array();
@@ -45,12 +45,12 @@ function construct_mailbox_name($mailacct) {
function email_msg_meta($mbox,$uid) {
- $ret = (($mbox && $uid) ? imap_fetch_overview($mbox,$uid,FT_UID) : array(array()));
+ $ret = (($mbox && $uid) ? @imap_fetch_overview($mbox,$uid,FT_UID) : array(array()));
return ((count($ret)) ? $ret[0] : array());
}
function email_msg_headers($mbox,$uid) {
- $raw_header = (($mbox && $uid) ? imap_fetchheader($mbox,$uid,FT_UID) : '');
+ $raw_header = (($mbox && $uid) ? @imap_fetchheader($mbox,$uid,FT_UID) : '');
$raw_header = str_replace("\r",'',$raw_header);
$ret = array();
$h = split("\n",$raw_header);
@@ -74,7 +74,7 @@ function email_msg_headers($mbox,$uid) {
function email_get_msg($mbox,$uid) {
$ret = array();
- $struc = (($mbox && $uid) ? imap_fetchstructure($mbox,$uid,FT_UID) : null);
+ $struc = (($mbox && $uid) ? @imap_fetchstructure($mbox,$uid,FT_UID) : null);
if(! $struc)
return $ret;
@@ -103,8 +103,8 @@ function email_get_part($mbox,$uid,$p,$partno) {
// DECODE DATA
$data = ($partno)
- ? imap_fetchbody($mbox,$uid,$partno, FT_UID|FT_PEEK)
- : imap_body($mbox,$uid,FT_UID|FT_PEEK);
+ ? @imap_fetchbody($mbox,$uid,$partno, FT_UID|FT_PEEK)
+ : @imap_body($mbox,$uid,FT_UID|FT_PEEK);
// Any part may be encoded, even plain text messages, so check everything.
if ($p->encoding==4)
@@ -169,6 +169,17 @@ function email_get_part($mbox,$uid,$p,$partno) {
function email_header_encode($in_str, $charset) {
$out_str = $in_str;
+ $need_to_convert = false;
+
+ for($x = 0; $x < strlen($in_str); $x ++) {
+ if((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) {
+ $need_to_convert = true;
+ }
+ }
+
+ if(! $need_to_convert)
+ return $in_str;
+
if ($out_str && $charset) {
// define start delimimter, end delimiter and spacer
@@ -205,4 +216,6 @@ function email_header_encode($in_str, $charset) {
$out_str = $start . $out_str . $end;
}
return $out_str;
-} \ No newline at end of file
+}
+
+
diff --git a/include/group.php b/include/group.php
index f21ce42e0..e3c7d33d4 100644
--- a/include/group.php
+++ b/include/group.php
@@ -6,8 +6,26 @@ function group_add($uid,$name) {
$ret = false;
if(x($uid) && x($name)) {
$r = group_byname($uid,$name); // check for dups
- if($r !== false)
+ if($r !== false) {
+
+ // This could be a problem.
+ // Let's assume we've just created a group which we once deleted
+ // all the old members are gone, but the group remains so we don't break any security
+ // access lists. What we're doing here is reviving the dead group, but old content which
+ // was restricted to this group may now be seen by the new group members.
+
+ $z = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1",
+ intval($r)
+ );
+ if(count($z) && $z[0]['deleted']) {
+ $r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($name)
+ );
+ notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
+ }
return true;
+ }
$r = q("INSERT INTO `group` ( `uid`, `name` )
VALUES( %d, '%s' ) ",
intval($uid),
@@ -124,7 +142,7 @@ function group_public_members($gid) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d
- AND ( `contact`.`network` = '%s' OR `contact`.`notify` = '' )",
+ AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ",
intval($gid),
intval(local_user()),
dbesc(NETWORK_OSTATUS)
@@ -146,15 +164,15 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0
$createtext = t('Create a new group');
$linktext= t('Everybody');
- $selected = (($group_id == 0) ? ' class="group-selected" ' : '');
+ $selected = (($group_id == 0) ? ' group-selected' : '');
$o .= <<< EOT
-<div id="group-sidebar">
+<div id="group-sidebar" class="widget">
<h3>Groups</h3>
<div id="sidebar-group-list">
<ul id="sidebar-group-ul">
- <li class="sidebar-group-li" ><a href="$every" $selected >$linktext</a></li>
+ <li class="sidebar-group-li" ><a href="$every" class="sidebar-group-element$selected" >$linktext</a></li>
EOT;
@@ -167,13 +185,13 @@ EOT;
if(count($r)) {
foreach($r as $rr) {
- $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : '');
+ $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
$o .= ' <li class="sidebar-group-li">'
. (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit')
- . "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "")
+ . "\" class=\"groupsideedit\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "")
. (($cid) ? '<input type="checkbox" class="' . (($selected) ? 'ticked' : 'unticked') . '" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" '
. ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '')
- . "<a href=\"$each/{$rr['id']}\" $selected >{$rr['name']}</a></li>\r\n";
+ . "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element" . $selected ."\" >{$rr['name']}</a></li>\r\n";
}
}
$o .= " </ul>\r\n </div>";
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index d4e8cce66..8025c336b 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -24,6 +24,10 @@ function html2bbcode($s) {
'/\<u\>(.*?)\<\/u\>/is',
'/\<ul\>(.*?)\<\/ul\>/is',
'/\<li\>(.*?)\<\/li\>/is',
+ '/\<img(.*?)width: *([0-9]+)(.*?)height: *([0-9]+)(.*?)src=\"(.*?)\" (.*?)\>/is',
+ '/\<img(.*?)height: *([0-9]+)(.*?)width: *([0-9]+)(.*?)src=\"(.*?)\" (.*?)\>/is',
+ '/\<img(.*?)src=\"(.*?)\"(.*?)width: *([0-9]+)(.*?)height: *([0-9]+)(.*?)\>/is',
+ '/\<img(.*?)src=\"(.*?)\"(.*?)height: *([0-9]+)(.*?)width: *([0-9]+)(.*?)\>/is',
'/\<img(.*?) src=\"(.*?)\" (.*?)\>/is',
'/\<div(.*?)\>(.*?)\<\/div\>/is',
'/\<br(.*?)\>/is',
@@ -50,6 +54,10 @@ function html2bbcode($s) {
'[u]$1[/u]',
'[list]$1[/list]',
'[*]$1',
+ '[img=$2x$4]$6[/img]',
+ '[img=$4x$2]$6[/img]',
+ '[img=$4x$6]$2[/img]',
+ '[img=$6x$4]$2[/img]',
'[img]$2[/img]',
'$2',
"\n",
diff --git a/include/items.php b/include/items.php
index 150be2707..d907aeddb 100644
--- a/include/items.php
+++ b/include/items.php
@@ -20,6 +20,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
for($x = 2; $x < $a->argc; $x++) {
if($a->argv[$x] == 'converse')
$converse = true;
+ if($a->argv[$x] == 'starred')
+ $starred = true;
}
}
@@ -112,8 +114,10 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
`contact`.`name`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
+ `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`parent` != 0
AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
@@ -363,6 +367,22 @@ function get_atom_elements($feed,$item) {
$res['app'] = 'OStatus';
}
+ // base64 encoded json structure representing Diaspora signature
+
+ $dsig = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_signature');
+ if($dsig) {
+ $res['dsprsig'] = unxmlify($dsig[0]['data']);
+ }
+
+ $dguid = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_guid');
+ if($dguid)
+ $res['guid'] = unxmlify($dguid[0]['data']);
+
+ $bm = $item->get_item_tags(NAMESPACE_DFRN,'bookmark');
+ if($bm)
+ $res['bookmark'] = ((unxmlify($bm[0]['data']) === 'true') ? 1 : 0);
+
+
/**
* If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it.
*/
@@ -659,6 +679,15 @@ function encode_rel_links($links) {
function item_store($arr,$force_parent = false) {
+ // If a Diaspora signature structure was passed in, pull it out of the
+ // item array and set it aside for later storage.
+
+ $dsprsig = null;
+ if(x($arr,'dsprsig')) {
+ $dsprsig = json_decode(base64_decode($arr['dsprsig']));
+ unset($arr['dsprsig']);
+ }
+
if($arr['gravity'])
$arr['gravity'] = intval($arr['gravity']);
elseif($arr['parent-uri'] == $arr['uri'])
@@ -688,6 +717,7 @@ function item_store($arr,$force_parent = false) {
$arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
+ $arr['commented'] = datetime_convert();
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
@@ -708,6 +738,7 @@ function item_store($arr,$force_parent = false) {
$arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 );
+ $arr['bookmark'] = ((x($arr,'bookmark')) ? intval($arr['bookmark']) : 0 );
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
$arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : '');
@@ -776,6 +807,14 @@ function item_store($arr,$force_parent = false) {
}
}
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($arr['uri']),
+ dbesc($arr['uid'])
+ );
+ if($r && count($r)) {
+ logger('item-store: duplicate item ignored. ' . print_r($arr,true));
+ return 0;
+ }
call_hooks('post_remote',$arr);
@@ -835,6 +874,24 @@ function item_store($arr,$force_parent = false) {
intval($current_post)
);
+ // update the commented timestamp on the parent
+
+ q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($parent_id)
+ );
+
+ if($dsprsig) {
+ q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
+ intval($current_post),
+ dbesc($dsprsig->signed_text),
+ dbesc($dsprsig->signature),
+ dbesc($dsprsig->signer)
+ );
+ }
+
+
/**
* If this is now the last-child, force all _other_ children of this parent to *not* be last-child
*/
@@ -894,7 +951,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
if(! $curl_stat)
return(-1); // timed out
- logger('dfrn_deliver: ' . $xml);
+ logger('dfrn_deliver: ' . $xml, LOGGER_DATA);
if(! $xml)
return 3;
@@ -958,7 +1015,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$key = substr(random_string(),0,16);
$data = bin2hex(aes_encrypt($postvars['data'],$key));
$postvars['data'] = $data;
- logger('rino: sent key = ' . $key);
+ logger('rino: sent key = ' . $key, LOGGER_DEBUG);
if($dfrn_version >= 2.1) {
@@ -993,6 +1050,9 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
if((! $curl_stat) || (! strlen($xml)))
return(-1); // timed out
+ if(($curl_stat == 503) && (stristr($a->get_curl_headers(),'retry-after')))
+ return(-1);
+
if(strpos($xml,'<?xml') === false) {
logger('dfrn_deliver: phase 2: no valid XML returned');
logger('dfrn_deliver: phase 2: returned XML: ' . $xml, LOGGER_DATA);
@@ -1439,6 +1499,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee
lose_follower($importer,$contact,$datarray,$item);
return;
}
+
+ if(activity_match($datarray['verb'],ACTIVITY_REQ_FRIEND)) {
+ logger('consume-feed: New friend request');
+ new_follower($importer,$contact,$datarray,$item,true);
+ return;
+ }
+ if(activity_match($datarray['verb'],ACTIVITY_UNFRIEND)) {
+ lose_sharer($importer,$contact,$datarray,$item);
+ return;
+ }
+
+
+
+
if(! is_array($contact))
return;
@@ -1470,7 +1544,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee
}
}
-function new_follower($importer,$contact,$datarray,$item) {
+function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
$url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar']));
@@ -1480,14 +1554,14 @@ function new_follower($importer,$contact,$datarray,$item) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
if(is_array($contact)) {
- if($contact['network'] == 'stat' && $contact['rel'] == CONTACT_IS_SHARING) {
+ if(($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
+ || ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
$r = q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval(CONTACT_IS_FRIEND),
intval($contact['id']),
intval($importer['uid'])
);
}
-
// send email notification to owner?
}
else {
@@ -1503,13 +1577,12 @@ function new_follower($importer,$contact,$datarray,$item) {
dbesc($name),
dbesc($nick),
dbesc($photo),
- dbesc('stat'),
- intval(CONTACT_IS_FOLLOWER)
+ dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS),
+ intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER)
);
- $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 AND `rel` = %d LIMIT 1",
+ $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
intval($importer['uid']),
- dbesc($url),
- intval(CONTACT_IS_FOLLOWER)
+ dbesc($url)
);
if(count($r))
$contact_record = $r[0];
@@ -1541,7 +1614,7 @@ function new_follower($importer,$contact,$datarray,$item) {
'$sitename' => $a->config['sitename']
));
$res = mail($r[0]['email'],
- t("You have a new follower at ") . $a->config['sitename'],
+ (($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'],
$email,
'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
@@ -1565,14 +1638,32 @@ function lose_follower($importer,$contact,$datarray,$item) {
}
}
+function lose_sharer($importer,$contact,$datarray,$item) {
-function subscribe_to_hub($url,$importer,$contact) {
+ if(($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
+ q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d LIMIT 1",
+ intval(CONTACT_IS_FOLLOWER),
+ intval($contact['id'])
+ );
+ }
+ else {
+ contact_remove($contact['id']);
+ }
+}
+
+
+function subscribe_to_hub($url,$importer,$contact,$submode = 'subscribe') {
if(is_array($importer)) {
$r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
}
+
+ // Diaspora has different message-ids in feeds than they do
+ // through the direct Diaspora protocol. If we try and use
+ // the feed, we'll get duplicates. So don't.
+
if((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
return;
@@ -1582,7 +1673,7 @@ function subscribe_to_hub($url,$importer,$contact) {
$verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string());
- $params= 'hub.mode=subscribe&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token;
+ $params= 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token;
logger('subscribe_to_hub: subscribing ' . $contact['name'] . ' to hub ' . $url . ' with verifier ' . $verify_token);
@@ -1670,10 +1761,21 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
$o .= '<dfrn:private>1</dfrn:private>' . "\r\n";
if($item['extid'])
- $o .= '<dfrn:extid>' . $item['extid'] . '</dfrn:extid>' . "\r\n";
+ $o .= '<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>' . "\r\n";
+ if($item['bookmark'])
+ $o .= '<dfrn:bookmark>true</dfrn:bookmark>' . "\r\n";
if($item['app'])
- $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . $item['app'] . '" ></statusnet:notice_info>';
+ $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
+
+ if($item['guid'])
+ $o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n";
+
+ if($item['signed_text']) {
+ $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
+ $o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n";
+ }
+
$verb = construct_verb($item);
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
$actobj = construct_activity_object($item);
diff --git a/include/jquery.htmlstream.js b/include/jquery.htmlstream.js
deleted file mode 100644
index c62c538f7..000000000
--- a/include/jquery.htmlstream.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/* jQuery ajax stream plugin
-* Version 0.1
-* Copyright (C) 2009 Chris Tarquini
-* Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License (http://creativecommons.org/licenses/by-sa/3.0/)
-* Permissions beyond the scope of this license may be available by contacting petros000[at]hotmail.com.
-*/
-
-(function($) {
-
-// Save the original AJAX function
-var ajax_old = $.ajax;
-var get_old = $.get;
-var post_old = $.post;
-var active = true;
-// Add our settings
-$.ajaxSetup({stream: false,pollInterval: 500/*, onDataRecieved: function(){}*/ });
-$.enableAjaxStream = function(enable)
-{
-if(typeof enable == 'undefined') enable = !active;
-if(!enable)
-{
-$.ajax = ajax_old;
-$.get = get_old;
-$.post = post_old;
-active = false;
-}
-else
-{
-$.ajax = ajax_stream;
-$.get = ajax_get_stream;
-$.post = ajax_post_stream;
-active = true;
-}
-
-}
-var ajax_stream = $.ajax = function(options)
-{
-//copied from original ajax function
- options = jQuery.extend(true, options, jQuery.extend(true, {}, jQuery.ajaxSettings, options));
-if(options.stream)
-{
-var timer = 0;
-var offset = 0;
-var xmlhttp = null;
-var lastlen = 0;
-var done = false;
-var hook = function(xhr)
-{
-xmlhttp = xhr;
-checkagain();
-}
-var fix = function(){ check('stream'); };// fixes weird bug with random numbers as arg
-var checkagain = function(){if(!done) timer = setTimeout(fix,options.pollInterval);}
-var check = function(status)
-{
-if(typeof status == 'undefined') status = "stream";
-if(xmlhttp.status < 3) return; //only get the latest packet if data has been sent
-var text = xmlhttp.responseText;
-if(status == 'stream') //if we arent streaming then just flush the buffer
-{
-if(text.length <= lastlen) { checkagain(); return;}
-lastlength = text.length;
-if(offset == text.length) { checkagain(); return;}
-}
-var pkt = text.substr(offset);
-offset = text.length;
-if($.isFunction(options.OnDataRecieved))
-{
-options.OnDataRecieved(pkt, status, xmlhttp.responseText, xmlhttp);
-}
-if(xmlhttp.status != 4)
-checkagain();
-}
-var complete = function(xhr,s)
-{
-clearTimeout(timer);//done..stop polling
-done = true;
-// send final call
-check(s);
-}
-// If the complete callback is set create a new callback that calls the users and outs
-if($.isFunction(options.success))
-{
-var oc = options.success;
-options.success = function(xhr,s){ complete(xhr,s); oc(xhr,s);};
-
-}
-else options.success = complete;
-// Set up our hook on the beforeSend
-if($.isFunction(options.beforeSend))
-{
-var obs = options.beforeSend;
-options.beforeSend = function(xhr){ obs(xhr); hook(xhr);};
-}
-else options.beforeSend = hook;
-
-}
-ajax_old(options);
-}
-
-var ajax_get_stream = $.get = function(url,data,callback,type,stream)
-{
- if($.isFunction(data))
- {
- var orgcb = callback;
- callback = data;
- if($.isFunction(orgcb))
- {
- stream = orgcb;
- }
- data = null;
- }
- if($.isFunction(type))
- {
- stream = type;
- type = undefined;
- }
- var dostream = $.isFunction(stream);
- return jQuery.ajax({
- type: "GET",
- url: url,
- data: data,
- success: callback,
- dataType: type,
- stream: dostream,
- OnDataRecieved: stream
- });
-
-}
-
-var ajax_post_stream = $.post = function(url,data,callback,type,stream)
-{
- if($.isFunction(data))
- {
- var orgcb = callback;
- callback = data;
- }
- if($.isFunction(type))
- {
- stream = type;
- type = undefined;
- }
- var dostream = $.isFunction(stream);
- return jQuery.ajax({
- type: "POST",
- url: url,
- data: data,
- success: callback,
- dataType: type,
- stream: dostream,
- OnDataRecieved: stream
- });
-
-}
-
-})(jQuery);
-
diff --git a/include/jquery.js b/include/jquery.js
deleted file mode 100644
index 7c2430802..000000000
--- a/include/jquery.js
+++ /dev/null
@@ -1,154 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.4.2
- * http://jquery.com/
- *
- * Copyright 2010, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2010, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Sat Feb 13 22:33:48 2010 -0500
- */
-(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
-e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
-j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
-"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
-true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
-Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
-(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
-a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
-"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
-function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
-c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
-L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
-"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
-a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
-d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
-a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
-!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
-true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
-var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
-parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
-false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
-s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
-applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
-else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
-a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
-w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
-cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
-i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
-" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
-this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
-e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
-c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
-a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
-function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
-k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
-C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
-null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
-e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
-f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
-if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
-fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
-d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
-"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
-a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
-isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
-{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
-if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
-e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
-"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
-d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
-!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
-toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
-u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
-function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
-if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
-e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
-t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
-g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
-for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
-1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
-CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
-relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
-l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
-h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
-CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
-g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
-text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
-setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
-h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
-m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
-"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
-h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
-!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
-h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
-q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
-if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
-(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
-function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
-gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
-c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
-{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
-"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
-d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
-a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
-1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
-a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
-c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
-wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
-prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
-this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
-return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
-""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
-this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
-u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
-1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
-return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
-""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
-c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
-c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
-function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
-Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
-"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
-a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
-a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
-"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
-serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
-function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
-global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
-e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
-"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
-false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
-false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
-c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
-d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
-g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
-1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
-"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
-if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
-this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
-"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
-animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
-j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
-this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
-"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
-c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
-this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
-this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
-e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
-c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
-function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
-this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
-k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
-f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
-a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
-c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
-d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
-f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
-"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
-e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
diff --git a/include/main.js b/include/main.js
deleted file mode 100644
index d59c99223..000000000
--- a/include/main.js
+++ /dev/null
@@ -1,406 +0,0 @@
-
- function openClose(theID) {
- if(document.getElementById(theID).style.display == "block") {
- document.getElementById(theID).style.display = "none"
- }
- else {
- document.getElementById(theID).style.display = "block"
- }
- }
-
- function openMenu(theID) {
- document.getElementById(theID).style.display = "block"
- }
-
- function closeMenu(theID) {
- document.getElementById(theID).style.display = "none"
- }
-
-
- var src = null;
- var prev = null;
- var livetime = null;
- var msie = false;
- var stopped = false;
- var timer = null;
- var pr = 0;
- var liking = 0;
- var in_progress = false;
- var langSelect = false;
- var commentBusy = false;
-
- $(function() {
- $.ajaxSetup({cache: false});
-
- msie = $.browser.msie ;
-
-
- /* setup onoff widgets */
- $(".onoff input").each(function(){
- val = $(this).val();
- id = $(this).attr("id");
- $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
-
- });
- $(".onoff > a").click(function(event){
- event.preventDefault();
- var input = $(this).siblings("input");
- var val = 1-input.val();
- var id = input.attr("id");
- $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
- $("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
- input.val(val);
- //console.log(id);
- });
-
- /* setup field_richtext */
- setupFieldRichtext();
-
- /* load tinyMCE if needed and setup field_richtext */
- /*if(typeof tinyMCE == "undefined") {
- window.tinyMCEPreInit = {
- suffix:"",
- base: baseurl+"/library/tinymce/jscripts/tiny_mce/",
- query:"",
- };
- $.getScript(baseurl +"/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js", setupFieldRichtext);
- } else {
- }*/
-
-
-
- /* nav update event */
- $('nav').bind('nav-update', function(e,data){;
- var net = $(data).find('net').text();
- if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
- $('#net-update').html(net);
- var home = $(data).find('home').text();
- if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
- $('#home-update').html(home);
- var mail = $(data).find('mail').text();
- if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
- $('#mail-update').html(mail);
- var intro = $(data).find('intro').text();
- if(intro == 0) { intro = ''; $('#notify-update').hide() } else { $('#notify-update').show() }
- $('#notify-update').html(intro);
- });
-
-
- NavUpdate();
- // Allow folks to stop the ajax page updates with the pause/break key
- $(document).keypress(function(event) {
- if(event.keyCode == '19') {
- event.preventDefault();
- if(stopped == false) {
- stopped = true;
- $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
- }
- else {
- stopped = false;
- $('#pause').html('');
- }
- }
- else {
- // any key to resume
- if(stopped == true) {
- stopped = false;
- $('#pause').html('');
- }
- }
-
- });
- });
-
- function NavUpdate() {
-
- if($('#live-network').length) { src = 'network'; liveUpdate(); }
- if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
- if($('#live-community').length) { src = 'community'; liveUpdate(); }
- if($('#live-display').length) {
- if(liking) {
- liking = 0;
- window.location.href=window.location.href
- }
- }
- if($('#live-photos').length) {
- if(liking) {
- liking = 0;
- window.location.href=window.location.href
- }
- }
-
- if(! stopped) {
- $.get("ping",function(data) {
- $(data).find('result').each(function() {
- // send nav-update event
- $('nav').trigger('nav-update', this);
- });
- }) ;
- }
- timer = setTimeout(NavUpdate,30000);
- }
-
- function liveUpdate() {
- if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
- if(($('.comment-edit-text-full').length) || (in_progress)) {
- livetime = setTimeout(liveUpdate, 10000);
- return;
- }
- prev = 'live-' + src;
-
- in_progress = true;
- var udargs = ((netargs.length) ? '/' + netargs : '');
- var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
-
- $.get(update_url,function(data) {
- in_progress = false;
- $('.ccollapse-wrapper',data).each(function() {
- var ident = $(this).attr('id');
- var is_hidden = $('#' + ident).is(':hidden');
- if($('#' + ident).length) {
- $('#' + ident).replaceWith($(this));
- if(is_hidden)
- $('#' + ident).hide();
- }
- });
- $('.wall-item-outside-wrapper',data).each(function() {
- var ident = $(this).attr('id');
- if($('#' + ident).length == 0) {
- $('img',this).each(function() {
- $(this).attr('src',$(this).attr('dst'));
- });
- $('#' + prev).after($(this));
- }
- else {
-
- $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
- if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
- $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
- $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
- $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
- $('#' + ident + ' ' + '.my-comment-photo').each(function() {
- $(this).attr('src',$(this).attr('dst'));
- });
- }
- prev = ident;
- });
- $('.like-rotator').hide();
- if(commentBusy) {
- commentBusy = false;
- $('body').css('cursor', 'auto');
- }
- });
- }
-
- function imgbright(node) {
- $(node).removeClass("drophide").addClass("drop");
- }
-
- function imgdull(node) {
- $(node).removeClass("drop").addClass("drophide");
- }
-
- // Since our ajax calls are asynchronous, we will give a few
- // seconds for the first ajax call (setting like/dislike), then
- // run the updater to pick up any changes and display on the page.
- // The updater will turn any rotators off when it's done.
- // This function will have returned long before any of these
- // events have completed and therefore there won't be any
- // visible feedback that anything changed without all this
- // trickery. This still could cause confusion if the "like" ajax call
- // is delayed and NavUpdate runs before it completes.
-
- function dolike(ident,verb) {
- $('#like-rotator-' + ident.toString()).show();
- $.get('like/' + ident.toString() + '?verb=' + verb );
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,3000);
- liking = 1;
- }
-
- function dostar(ident) {
- $('#like-rotator-' + ident.toString()).show();
- $.get('starred/' + ident.toString(), function(data) {
- if(data.match(/1/)) {
- $('#starred-' + ident.toString()).addClass('starred');
- $('#starred-' + ident.toString()).removeClass('unstarred');
- }
- else {
- $('#starred-' + ident.toString()).addClass('unstarred');
- $('#starred-' + ident.toString()).removeClass('starred');
- }
- $('#like-rotator-' + ident.toString()).hide();
- });
- }
-
- function getPosition(e) {
- var cursor = {x:0, y:0};
- if ( e.pageX || e.pageY ) {
- cursor.x = e.pageX;
- cursor.y = e.pageY;
- }
- else {
- if( e.clientX || e.clientY ) {
- cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
- cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
- }
- else {
- if( e.x || e.y ) {
- cursor.x = e.x;
- cursor.y = e.y;
- }
- }
- }
- return cursor;
- }
-
- var lockvisible = false;
-
- function lockview(event,id) {
- event = event || window.event;
- cursor = getPosition(event);
- if(lockvisible) {
- lockviewhide();
- }
- else {
- lockvisible = true;
- $.get('lockview/' + id, function(data) {
- $('#panel').html(data);
- $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
- $('#panel').show();
- });
- }
- }
-
- function lockviewhide() {
- lockvisible = false;
- $('#panel').hide();
- }
-
- function post_comment(id) {
- commentBusy = true;
- $('body').css('cursor', 'wait');
- $.post(
- "item",
- $("#comment-edit-form-" + id).serialize(),
- function(data) {
- if(data.success) {
- $("#comment-edit-wrapper-" + id).hide();
- $("#comment-edit-text-" + id).val('');
- var tarea = document.getElementById("comment-edit-text-" + id);
- if(tarea)
- commentClose(tarea,id);
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
- }
- if(data.reload) {
- window.location.href=data.reload;
- }
- },
- "json"
- );
- return false;
- }
-
-
- function bin2hex(s){
- // Converts the binary representation of data to hex
- //
- // version: 812.316
- // discuss at: http://phpjs.org/functions/bin2hex
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + bugfixed by: Onno Marsman
- // + bugfixed by: Linuxworld
- // * example 1: bin2hex('Kev');
- // * returns 1: '4b6576'
- // * example 2: bin2hex(String.fromCharCode(0x00));
- // * returns 2: '00'
- var v,i, f = 0, a = [];
- s += '';
- f = s.length;
-
- for (i = 0; i<f; i++) {
- a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
- }
-
- return a.join('');
- }
-
- function groupChangeMember(gid,cid) {
- $('body .fakelink').css('cursor', 'wait');
- $.get('group/' + gid + '/' + cid, function(data) {
- $('#group-update-wrapper').html(data);
- $('body .fakelink').css('cursor', 'auto');
- });
- }
-
- function profChangeMember(gid,cid) {
- $('body .fakelink').css('cursor', 'wait');
- $.get('profperm/' + gid + '/' + cid, function(data) {
- $('#prof-update-wrapper').html(data);
- $('body .fakelink').css('cursor', 'auto');
- });
- }
-
- function contactgroupChangeMember(gid,cid) {
- $('body').css('cursor', 'wait');
- $.get('contactgroup/' + gid + '/' + cid, function(data) {
- $('body').css('cursor', 'auto');
- });
- }
-
-
-function checkboxhighlight(box) {
- if($(box).is(':checked')) {
- $(box).addClass('checkeditem');
- }
- else {
- $(box).removeClass('checkeditem');
- }
-}
-
-function setupFieldRichtext(){
- tinyMCE.init({
- theme : "advanced",
- mode : "specific_textareas",
- editor_selector: "fieldRichtext",
- plugins : "bbcode,paste",
- theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
- theme_advanced_buttons2 : "",
- theme_advanced_buttons3 : "",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "center",
- theme_advanced_blockformats : "blockquote,code",
- paste_text_sticky : true,
- entity_encoding : "raw",
- add_unload_trigger : false,
- remove_linebreaks : false,
- force_p_newlines : false,
- force_br_newlines : true,
- forced_root_block : '',
- convert_urls: false,
- content_css: baseurl+"/view/custom_tinymce.css",
- theme_advanced_path : false,
- });
-}
-
-/**
- * sprintf in javascript
- * "{0} and {1}".format('zero','uno');
- **/
-String.prototype.format = function() {
- var formatted = this;
- for (var i = 0; i < arguments.length; i++) {
- var regexp = new RegExp('\\{'+i+'\\}', 'gi');
- formatted = formatted.replace(regexp, arguments[i]);
- }
- return formatted;
-};
-// Array Remove
-Array.prototype.remove = function(item) {
- to=undefined; from=this.indexOf(item);
- var rest = this.slice((to || from) + 1 || this.length);
- this.length = from < 0 ? this.length + from : from;
- return this.push.apply(this, rest);
-};
-
diff --git a/include/nav.php b/include/nav.php
index 895c321e6..16ec941aa 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -37,11 +37,29 @@ function nav(&$a) {
* Display login or logout
*/
+ $nav['usermenu']=array();
+ $userinfo = null;
+
if(local_user()) {
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
+
+ // user menu
+ $nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations'));
+ $nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
+ $nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
+ $nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
+ $nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
+
+ // user info
+ $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
+ $userinfo = array(
+ 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
+ 'name' => $a->user['username'],
+ );
+
}
else {
- $nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'nav-selected':''), t('Sign in'));
+ $nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'selected':''), t('Sign in'));
}
@@ -63,7 +81,7 @@ function nav(&$a) {
if(! get_config('system','hide_help'))
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
- if($a->apps)
+ if(count($a->apps)>0)
$nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
$nav['search'] = array('search', t('Search'), "", t('Search site content'));
@@ -137,8 +155,31 @@ function nav(&$a) {
'$sitelocation' => $sitelocation,
'$nav' => $nav,
'$banner' => $banner,
+ '$emptynotifications' => t('Nothing new here'),
+ '$userinfo' => $userinfo,
+ '$sel' => $a->nav_sel,
+ '$apps' => $a->apps,
));
call_hooks('page_header', $a->page['nav']);
+}
+/*
+ * Set a menu item in navbar as selected
+ *
+ */
+function nav_set_selected($item){
+ $a = get_app();
+ $a->nav_sel = array(
+ 'community' => null,
+ 'network' => null,
+ 'home' => null,
+ 'profiles' => null,
+ 'notifications' => null,
+ 'messages' => null,
+ 'directory' => null,
+ 'settings' => null,
+ 'contacts' => null,
+ );
+ $a->nav_sel[$item] = 'selected';
}
diff --git a/include/network.php b/include/network.php
index f0dd828d1..ec99d1e0d 100644
--- a/include/network.php
+++ b/include/network.php
@@ -9,37 +9,37 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
$a = get_app();
- $ch = curl_init($url);
+ $ch = @curl_init($url);
if(($redirects > 8) || (! $ch))
return false;
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
+ @curl_setopt($ch, CURLOPT_HEADER, true);
+ @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
+ @curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
if(intval($timeout)) {
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+ @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}
else {
$curl_time = intval(get_config('system','curl_timeout'));
- curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
+ @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
}
// by default we will allow self-signed certs
// but you can override this
$check_cert = get_config('system','verifyssl');
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
+ @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
$prx = get_config('system','proxy');
if(strlen($prx)) {
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ch, CURLOPT_PROXY, $prx);
- $prxusr = get_config('system','proxyuser');
+ @curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
+ @curl_setopt($ch, CURLOPT_PROXY, $prx);
+ $prxusr = @get_config('system','proxyuser');
if(strlen($prxusr))
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
+ @curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
}
if($binary)
- curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
+ @curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$a->set_curl_code(0);
@@ -49,7 +49,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
$s = @curl_exec($ch);
$base = $s;
- $curl_info = curl_getinfo($ch);
+ $curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code'];
$header = '';
@@ -80,7 +80,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
$a->set_curl_headers($header);
- curl_close($ch);
+ @curl_close($ch);
return($body);
}}
@@ -259,22 +259,29 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
// or if the resultant personal XRD doesn't contain a supported
// subscription/friend-request attribute.
+// amended 7/9/2011 to return an hcard which could save potentially loading
+// a lengthy content page to scrape dfrn attributes
+
if(! function_exists('webfinger_dfrn')) {
-function webfinger_dfrn($s) {
+function webfinger_dfrn($s,&$hcard) {
if(! strstr($s,'@')) {
return $s;
}
+ $profile_link = '';
+
$links = webfinger($s);
logger('webfinger_dfrn: ' . $s . ':' . print_r($links,true), LOGGER_DATA);
if(count($links)) {
- foreach($links as $link)
+ foreach($links as $link) {
if($link['@attributes']['rel'] === NAMESPACE_DFRN)
- return $link['@attributes']['href'];
- foreach($links as $link)
+ $profile_link = $link['@attributes']['href'];
if($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB)
- return 'stat:' . $link['@attributes']['template'];
+ $profile_link = 'stat:' . $link['@attributes']['template'];
+ if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
+ $hcard = $link['@attributes']['href'];
+ }
}
- return '';
+ return $profile_link;
}}
// Given an email style address, perform webfinger lookup and
@@ -536,7 +543,7 @@ function fetch_xrd_links($url) {
$aliases = array($alias);
else
$aliases = $alias;
- if($aliases && count($aliases)) {
+ if(is_array($aliases) && count($aliases)) {
foreach($aliases as $alias) {
$links[]['@attributes'] = array('rel' => 'alias' , 'href' => $alias);
}
@@ -694,24 +701,59 @@ function parse_xml_string($s,$strict = true) {
return $x;
}}
-function add_fcontact($arr) {
-
- $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
- `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
- values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
- dbesc($arr['url']),
- dbesc($arr['name']),
- dbesc($arr['photo']),
- dbesc($arr['request']),
- dbesc($arr['nick']),
- dbesc($arr['addr']),
- dbesc($arr['notify']),
- dbesc($arr['poll']),
- dbesc($arr['confirm']),
- dbesc($arr['network']),
- dbesc($arr['alias']),
- dbesc($arr['pubkey']),
- dbesc(datetime_convert())
- );
+function add_fcontact($arr,$update = false) {
+
+ if($update) {
+ $r = q("UPDATE `fcontact` SET
+ `name` = '%s',
+ `photo` = '%s',
+ `request` = '%s',
+ `nick` = '%s',
+ `addr` = '%s',
+ `batch` = '%s',
+ `notify` = '%s',
+ `poll` = '%s',
+ `confirm` = '%s',
+ `alias` = '%s',
+ `pubkey` = '%s',
+ `updated` = '%s'
+ WHERE `url` = '%s' AND `network` = '%s' LIMIT 1",
+ dbesc($arr['name']),
+ dbesc($arr['photo']),
+ dbesc($arr['request']),
+ dbesc($arr['nick']),
+ dbesc($arr['addr']),
+ dbesc($arr['batch']),
+ dbesc($arr['notify']),
+ dbesc($arr['poll']),
+ dbesc($arr['confirm']),
+ dbesc($arr['network']),
+ dbesc($arr['alias']),
+ dbesc($arr['pubkey']),
+ dbesc(datetime_convert()),
+ dbesc($arr['url']),
+ dbesc($arr['network'])
+ );
+ }
+ else {
+ $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
+ `batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
+ values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
+ dbesc($arr['url']),
+ dbesc($arr['name']),
+ dbesc($arr['photo']),
+ dbesc($arr['request']),
+ dbesc($arr['nick']),
+ dbesc($arr['addr']),
+ dbesc($arr['batch']),
+ dbesc($arr['notify']),
+ dbesc($arr['poll']),
+ dbesc($arr['confirm']),
+ dbesc($arr['network']),
+ dbesc($arr['alias']),
+ dbesc($arr['pubkey']),
+ dbesc(datetime_convert())
+ );
+ }
return $r;
}
diff --git a/include/notifier.php b/include/notifier.php
index 7b645844f..d1cd1cc73 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -1,6 +1,21 @@
<?php
+
require_once("boot.php");
+/*
+ * This file was at one time responsible for doing all deliveries, but this caused
+ * big problems on shared hosting systems, where the process might get killed by the
+ * hosting provider and nothing would get delivered.
+ * It now only delivers one message under certain cases, and invokes a queued
+ * delivery mechanism (include/deliver.php) to deliver individual contacts at
+ * controlled intervals.
+ * This has a much better chance of surviving random processes getting killed
+ * by the hosting provider.
+ * A lot of this code is duplicated in include/deliver.php until we have time to go back
+ * and re-structure the delivery procedure based on the obstacles that have been thrown at
+ * us by hosting providers.
+ */
+
function notifier_run($argv, $argc){
global $a, $db;
@@ -35,7 +50,6 @@ function notifier_run($argv, $argc){
$cmd = $argv[1];
switch($cmd) {
-
case 'mail':
default:
$item_id = intval($argv[2]);
@@ -46,6 +60,8 @@ function notifier_run($argv, $argc){
}
$expire = false;
+ $mail = false;
+ $fsuggest = false;
$top_level = false;
$recipients = array();
$url_recipients = array();
@@ -54,6 +70,7 @@ function notifier_run($argv, $argc){
if($cmd === 'mail') {
$normal_mode = false;
+ $mail = true;
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
@@ -69,7 +86,7 @@ function notifier_run($argv, $argc){
$normal_mode = false;
$expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
- AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP - INTERVAL 10 MINUTE",
+ AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
intval($item_id)
);
$uid = $item_id;
@@ -79,6 +96,8 @@ function notifier_run($argv, $argc){
}
elseif($cmd === 'suggest') {
$normal_mode = false;
+ $fsuggest = true;
+
$suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
@@ -104,7 +123,11 @@ function notifier_run($argv, $argc){
$uid = $r[0]['uid'];
$updated = $r[0]['edited'];
- $items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id` ASC",
+ if(! $parent_id)
+ return;
+
+ $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
+ FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d ORDER BY `id` ASC",
intval($parent_id)
);
@@ -119,8 +142,11 @@ function notifier_run($argv, $argc){
$item['deleted'] = 1;
}
- if(count($items) == 1 && $items[0]['uri'] === $items[0]['parent-uri'])
+ if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
+ logger('notifier: top level post');
$top_level = true;
+ }
+
}
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
@@ -136,6 +162,8 @@ function notifier_run($argv, $argc){
$owner = $r[0];
+ $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
+
$hub = get_config('system','huburl');
// If this is a public conversation, notify the feed hub
@@ -144,7 +172,7 @@ function notifier_run($argv, $argc){
// fill this in with a single salmon slap if applicable
$slap = '';
- if($cmd != 'mail' && $cmd != 'suggest') {
+ if(! ($mail || $fsuggest)) {
require_once('include/group.php');
@@ -235,7 +263,6 @@ function notifier_run($argv, $argc){
$r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0");
-
if(count($r))
$contacts = $r;
}
@@ -270,7 +297,7 @@ function notifier_run($argv, $argc){
'$birthday' => $birthday
));
- if($cmd === 'mail') {
+ if($mail) {
$public_message = false; // mail is not public
$body = fix_private_photos($item['body'],$owner['uid']);
@@ -286,7 +313,7 @@ function notifier_run($argv, $argc){
'$parent_id' => xmlify($item['parent-uri'])
));
}
- elseif($cmd === 'suggest') {
+ elseif($fsuggest) {
$public_message = false; // suggestions are not public
$sugg_template = get_markup_template('atom_suggest.tpl');
@@ -374,17 +401,45 @@ function notifier_run($argv, $argc){
dbesc($recip_str)
);
- // delivery loop
require_once('include/salmon.php');
+ $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
+
+ // delivery loop
+
if(count($r)) {
+
+ foreach($r as $contact) {
+ if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) {
+ if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
+ continue;
+ q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
+ dbesc($cmd),
+ intval($item_id),
+ intval($contact['id'])
+ );
+ }
+ }
+
foreach($r as $contact) {
if($contact['self'])
continue;
+ // potentially more than one recipient. Start a new process and space them out a bit.
+ // we will deliver single recipient types of message and email receipients here.
+
+ if((! $mail) && (! $fsuggest) && (! $followup)) {
+ proc_run('php','include/delivery.php',$cmd,$item_id,$contact['id']);
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ continue;
+ }
+
$deliver_status = 0;
+ logger("main delivery by notifier: followup=$followup mail=$mail fsuggest=$fsuggest");
+
switch($contact['network']) {
case NETWORK_DFRN:
logger('notifier: dfrndelivery: ' . $contact['name']);
@@ -533,9 +588,19 @@ function notifier_run($argv, $argc){
break;
case NETWORK_DIASPORA:
require_once('include/diaspora.php');
+
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
+ // special handling for followup to public post
+ // all other public posts processed as public batches further below
+
+ if($public_message) {
+ if($followup)
+ diaspora_send_followup($target_item,$owner,$contact, true);
+ break;
+ }
+
if(! $contact['pubkey'])
break;
@@ -558,7 +623,8 @@ function notifier_run($argv, $argc){
diaspora_send_relay($target_item,$owner,$contact);
break;
}
- elseif($top_level) {
+ elseif(($top_level) && (! $walltowall)) {
+ // currently no workable solution for sending walltowall
diaspora_send_status($target_item,$owner,$contact);
break;
}
@@ -589,109 +655,77 @@ function notifier_run($argv, $argc){
}
}
- if((strlen($hub)) && ($public_message)) {
- $hubs = explode(',', $hub);
- if(count($hubs)) {
- foreach($hubs as $h) {
- $h = trim($h);
- if(! strlen($h))
- continue;
- $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
- post_url($h,$params);
- logger('pubsub: publish: ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
- if(count($hubs) > 1)
- sleep(7); // try and avoid multiple hubs responding at precisely the same time
- }
- }
- }
if($public_message) {
- /**
- *
- * If you have less than 999 dfrn friends and it's a public message,
- * we'll just go ahead and push them out securely with dfrn/rino or Diaspora.
- * If you've got more than that, you'll have to rely on PuSH delivery.
- *
- */
-
- $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 999 : intval(get_config('system','maxpubdeliver')));
-
- /**
- *
- * Only get the bare essentials and go back for the full record.
- * If you've got a lot of friends and we grab all the details at once it could exhaust memory.
- *
- */
-
- $r = q("SELECT `id`, `name` FROM `contact`
- WHERE `network` in ('%s','%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
- AND `rel` != %d ",
- dbesc(NETWORK_DFRN),
+ $r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
+ AND `uid` = %d AND `rel` != %d ORDER BY rand() ",
dbesc(NETWORK_DIASPORA),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)
);
+
+ $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
+ WHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
+ AND `rel` != %d order by rand() ",
+ dbesc(NETWORK_DFRN),
+ intval($owner['uid']),
+ intval(CONTACT_IS_SHARING)
+ );
- if((count($r)) && (($max_allowed == 0) || (count($r) < $max_allowed))) {
+ $r = array_merge($r2,$r1);
- logger('pubdeliver: ' . print_r($r,true));
+ if(count($r)) {
+ logger('pubdeliver: ' . print_r($r,true), LOGGER_DEBUG);
+
+ // throw everything into the queue in case we get killed
foreach($r as $rr) {
+ if((! $mail) && (! $fsuggest) && (! $followup)) {
+ q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
+ dbesc($cmd),
+ intval($item_id),
+ intval($rr['id'])
+ );
+ }
+ }
- /* Don't deliver to folks who have already been delivered to */
+ foreach($r as $rr) {
+
+ // except for Diaspora batch jobs
+ // Don't deliver to folks who have already been delivered to
- if(in_array($rr['id'],$conversants))
+ if(($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
+ logger('notifier: already delivered id=' . $rr['id']);
continue;
+ }
- $n = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($rr['id'])
- );
+ if((! $mail) && (! $fsuggest) && (! $followup)) {
+ logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']);
+ proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ }
+ }
+ }
- if(count($n)) {
- $contact = $n[0];
- switch($contact['network']) {
- case NETWORK_DFRN :
- logger('notifier: dfrnpubdelivery: ' . $contact['name']);
- $deliver_status = dfrn_deliver($owner,$contact,$atom);
- break;
- case NETWORK_DIASPORA :
- require_once('include/diaspora.php');
- if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
- break;
-
- if(! $contact['pubkey'])
- break;
-
- if($target_item['verb'] === ACTIVITY_DISLIKE) {
- // unsupported
- break;
- }
- elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
- // diaspora delete,
- diaspora_send_retraction($target_item,$owner,$contact);
- break;
- }
- elseif($followup) {
- // send comments, likes and retractions of likes to owner to relay
- diaspora_send_followup($target_item,$owner,$contact);
- break;
- }
- elseif($target_item['parent'] != $target_item['id']) {
- // we are the relay - send comments, likes and unlikes to our conversants
- diaspora_send_relay($target_item,$owner,$contact);
- break;
- }
- elseif($top_level) {
- diaspora_send_status($target_item,$owner,$contact);
- break;
- }
- default:
- break;
- }
+
+ if(strlen($hub)) {
+ $hubs = explode(',', $hub);
+ if(count($hubs)) {
+ foreach($hubs as $h) {
+ $h = trim($h);
+ if(! strlen($h))
+ continue;
+ $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
+ post_url($h,$params);
+ logger('pubsub: publish: ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
+ if(count($hubs) > 1)
+ sleep(7); // try and avoid multiple hubs responding at precisely the same time
}
}
}
+
}
return;
diff --git a/include/pgettext.php b/include/pgettext.php
index 49f100737..83e76ba9d 100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -90,8 +90,11 @@ if(! function_exists('load_translation_table')) {
function load_translation_table($lang) {
global $a;
- if(file_exists("view/$lang/strings.php"))
+ if(file_exists("view/$lang/strings.php")) {
include("view/$lang/strings.php");
+ }
+ else
+ $a->strings = array();
}}
// translate string if translation exists
@@ -110,12 +113,15 @@ function t($s) {
if(! function_exists('tt')){
function tt($singular, $plural, $count){
-
+ global $lang;
$a = get_app();
if(x($a->strings,$singular)) {
$t = $a->strings[$singular];
- $k = string_plural_select($count);
+ $f = 'string_plural_select_' . str_replace('-','_',$lang);
+ if(! function_exists($f))
+ $f = 'string_plural_select_default';
+ $k = $f($count);
return is_array($t)?$t[$k]:$t;
}
@@ -124,4 +130,13 @@ function tt($singular, $plural, $count){
} else {
return $singular;
}
-}} \ No newline at end of file
+}}
+
+// provide a fallback which will not collide with
+// a function defined in any language file
+
+if(! function_exists('string_plural_select_default')) {
+function string_plural_select_default($n) {
+ return ($n != 1);
+}}
+
diff --git a/include/poller.php b/include/poller.php
index e80b696bf..89a3408ec 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -38,6 +38,18 @@ function poller_run($argv, $argc){
proc_run('php',"include/queue.php");
+ // expire any expired accounts
+
+ q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
+ AND `account_expires_on` != '0000-00-00 00:00:00'
+ AND `account_expires_on` < UTC_TIMESTAMP() ");
+
+ $abandon_days = intval(get_config('system','account_abandon_days'));
+ if($abandon_days < 1)
+ $abandon_days = 0;
+
+
+
// once daily run expire in background
$d1 = get_config('system','last_expire_day');
@@ -86,11 +98,17 @@ function poller_run($argv, $argc){
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
- $contacts = q("SELECT `id` FROM `contact`
+ $abandon_sql = (($abandon_days)
+ ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days))
+ : ''
+ );
+
+ $contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND `network` != '%s'
$sql_extra
- AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()",
+ AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
+ AND `user`.`account_expired` = 0 $abandon_sql ORDER BY RAND()",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
dbesc(NETWORK_DIASPORA)
@@ -137,6 +155,8 @@ function poller_run($argv, $argc){
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
$hub_update = true;
}
+ else
+ $hub_update = false;
/**
* Based on $contact['priority'], should we poll this site now? Or later?
@@ -472,21 +492,25 @@ function poller_run($argv, $argc){
consume_feed($xml,$importer,$contact,$hub,1);
+ $hubmode = 'subscribe';
+ if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
+ $hubmode = 'unsubscribe';
- if((strlen($hub)) && ($hub_update) && (($contact['rel'] == CONTACT_IS_FRIEND) || (($contact['network'] === NETWORK_OSTATUS) && (! $contact['readonly'])))) {
- logger('poller: subscribing to hub(s) : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
+ if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
+ logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
$h = trim($h);
if(! strlen($h))
continue;
- subscribe_to_hub($h,$importer,$contact);
+ subscribe_to_hub($h,$importer,$contact,$hubmode);
}
}
}
}
+
$updated = datetime_convert();
$r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1",
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index c1dfad66f..22e035fe6 100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -12,8 +12,8 @@ if($a->profile['name']) {
$o .= <<< EOT
<div id="advanced-profile-name-wrapper" >
-<div id="advanced-profile-name-text">$lbl_fullname</div>
-<div id="advanced-profile-name">$fullname</div>
+<div id="advanced-profile-name-text" class="advanced-profile-label">$lbl_fullname</div>
+<div id="advanced-profile-name" class="advanced-profile-content">$fullname</div>
</div>
<div id="advanced-profile-name-end"></div>
EOT;
@@ -25,8 +25,8 @@ if($a->profile['gender']) {
$o .= <<< EOT
<div id="advanced-profile-gender-wrapper" >
-<div id="advanced-profile-gender-text">$lbl_gender</div>
-<div id="advanced-profile-gender">$gender</div>
+<div id="advanced-profile-gender-text" class="advanced-profile-label">$lbl_gender</div>
+<div id="advanced-profile-gender" class="advanced-profile-content">$gender</div>
</div>
<div id="advanced-profile-gender-end"></div>
EOT;
@@ -37,7 +37,7 @@ if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
$o .= <<< EOT
<div id="advanced-profile-dob-wrapper" >
-<div id="advanced-profile-dob-text">$lbl_birthday</div>
+<div id="advanced-profile-dob-text" class="advanced-profile-label">$lbl_birthday</div>
EOT;
// If no year, add an arbitrary one so just we can parse the month and day.
@@ -45,7 +45,7 @@ EOT;
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
-$o .= '<div id="advanced-profile-dob">'
+$o .= '<div id="advanced-profile-dob" class="advanced-profile-content">'
. ((intval($a->profile['dob']))
? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
: day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],6) . ' 00:00 +00:00',$short_bd_format)))
@@ -59,8 +59,8 @@ if($age = age($a->profile['dob'],$a->profile['timezone'],'')) {
$lbl_age = t('Age:');
$o .= <<< EOT
<div id="advanced-profile-age-wrapper" >
-<div id="advanced-profile-age-text">$lbl_age</div>
-<div id="advanced-profile-age">$age</div>
+<div id="advanced-profile-age-text" class="advanced-profile-label">$lbl_age</div>
+<div id="advanced-profile-age" class="advanced-profile-content">$age</div>
</div>
<div id="advanced-profile-age-end"></div>
EOT;
@@ -72,8 +72,8 @@ if($a->profile['marital']) {
$o .= <<< EOT
<div id="advanced-profile-marital-wrapper" >
-<div id="advanced-profile-marital-text">$lbl_marital</div>
-<div id="advanced-profile-marital">$marital</div>
+<div id="advanced-profile-marital-text" class="advanced-profile-label">$lbl_marital</div>
+<div id="advanced-profile-marital" class="advanced-profile-content">$marital</div>
EOT;
if($a->profile['with']) {
@@ -92,8 +92,8 @@ if($a->profile['sexual']) {
$o .= <<< EOT
<div id="advanced-profile-sexual-wrapper" >
-<div id="advanced-profile-sexual-text">$lbl_sexual</div>
-<div id="advanced-profile-sexual">$sexual</div>
+<div id="advanced-profile-sexual-text" class="advanced-profile-label">$lbl_sexual</div>
+<div id="advanced-profile-sexual" class="advanced-profile-content">$sexual</div>
</div>
<div id="advanced-profile-sexual-end"></div>
EOT;
@@ -104,8 +104,8 @@ if($a->profile['homepage']) {
$homepage = linkify($a->profile['homepage']);
$o .= <<< EOT
<div id="advanced-profile-homepage-wrapper" >
-<div id="advanced-profile-homepage-text">$lbl_homepage</div>
-<div id="advanced-profile-homepage">$homepage</div>
+<div id="advanced-profile-homepage-text" class="advanced-profile-label">$lbl_homepage</div>
+<div id="advanced-profile-homepage" class="advanced-profile-content">$homepage</div>
</div>
<div id="advanced-profile-homepage-end"></div>
EOT;
@@ -116,8 +116,8 @@ if($a->profile['politic']) {
$politic = $a->profile['politic'];
$o .= <<< EOT
<div id="advanced-profile-politic-wrapper" >
-<div id="advanced-profile-politic-text">$lbl_politic</div>
-<div id="advanced-profile-politic">$politic</div>
+<div id="advanced-profile-politic-text" class="advanced-profile-label">$lbl_politic</div>
+<div id="advanced-profile-politic" class="advanced-profile-content">$politic</div>
</div>
<div id="advanced-profile-politic-end"></div>
EOT;
@@ -128,8 +128,8 @@ if($a->profile['religion']) {
$religion = $a->profile['religion'];
$o .= <<< EOT
<div id="advanced-profile-religion-wrapper" >
-<div id="advanced-profile-religion-text">$lbl_religion</div>
-<div id="advanced-profile-religion">$religion</div>
+<div id="advanced-profile-religion-text" class="advanced-profile-label">$lbl_religion</div>
+<div id="advanced-profile-religion" class="advanced-profile-content">$religion</div>
</div>
<div id="advanced-profile-religion-end"></div>
EOT;
@@ -138,9 +138,9 @@ if($txt = prepare_text($a->profile['about'])) {
$lbl_about = t('About:');
$o .= <<< EOT
<div id="advanced-profile-about-wrapper" >
-<div id="advanced-profile-about-text">$lbl_about</div>
+<div id="advanced-profile-about-text" class="advanced-profile-label">$lbl_about</div>
<br />
-<div id="advanced-profile-about">$txt</div>
+<div id="advanced-profile-about" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-about-end"></div>
EOT;
@@ -150,9 +150,9 @@ if($txt = prepare_text($a->profile['interest'])) {
$lbl_interests = t('Hobbies/Interests:');
$o .= <<< EOT
<div id="advanced-profile-interest-wrapper" >
-<div id="advanced-profile-interest-text">$lbl_interests</div>
+<div id="advanced-profile-interest-text" class="advanced-profile-label">$lbl_interests</div>
<br />
-<div id="advanced-profile-interest">$txt</div>
+<div id="advanced-profile-interest" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-interest-end"></div>
EOT;
@@ -162,9 +162,9 @@ if($txt = prepare_text($a->profile['contact'])) {
$lbl_contact = t('Contact information and Social Networks:');
$o .= <<< EOT
<div id="advanced-profile-contact-wrapper" >
-<div id="advanced-profile-contact-text">$lbl_contact</div>
+<div id="advanced-profile-contact-text" class="advanced-profile-label">$lbl_contact</div>
<br />
-<div id="advanced-profile-contact">$txt</div>
+<div id="advanced-profile-contact" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-contact-end"></div>
EOT;
@@ -174,9 +174,9 @@ if($txt = prepare_text($a->profile['music'])) {
$lbl_music = t('Musical interests:');
$o .= <<< EOT
<div id="advanced-profile-music-wrapper" >
-<div id="advanced-profile-music-text">$lbl_music</div>
+<div id="advanced-profile-music-text" class="advanced-profile-label">$lbl_music</div>
<br />
-<div id="advanced-profile-music">$txt</div>
+<div id="advanced-profile-music" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-music-end"></div>
EOT;
@@ -186,9 +186,9 @@ if($txt = prepare_text($a->profile['book'])) {
$lbl_book = t('Books, literature:');
$o .= <<< EOT
<div id="advanced-profile-book-wrapper" >
-<div id="advanced-profile-book-text">$lbl_book</div>
+<div id="advanced-profile-book-text" class="advanced-profile-label">$lbl_book</div>
<br />
-<div id="advanced-profile-book">$txt</div>
+<div id="advanced-profile-book" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-book-end"></div>
EOT;
@@ -198,9 +198,9 @@ if($txt = prepare_text($a->profile['tv'])) {
$lbl_tv = t('Television:');
$o .= <<< EOT
<div id="advanced-profile-tv-wrapper" >
-<div id="advanced-profile-tv-text">$lbl_tv</div>
+<div id="advanced-profile-tv-text" class="advanced-profile-label">$lbl_tv</div>
<br />
-<div id="advanced-profile-tv">$txt</div>
+<div id="advanced-profile-tv" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-tv-end"></div>
EOT;
@@ -210,9 +210,9 @@ if($txt = prepare_text($a->profile['film'])) {
$lbl_film = t('Film/dance/culture/entertainment:');
$o .= <<< EOT
<div id="advanced-profile-film-wrapper" >
-<div id="advanced-profile-film-text">$lbl_film</div>
+<div id="advanced-profile-film-text" class="advanced-profile-label">$lbl_film</div>
<br />
-<div id="advanced-profile-film">$txt</div>
+<div id="advanced-profile-film" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-film-end"></div>
EOT;
@@ -222,9 +222,9 @@ if($txt = prepare_text($a->profile['romance'])) {
$lbl_romance = t('Love/Romance:');
$o .= <<< EOT
<div id="advanced-profile-romance-wrapper" >
-<div id="advanced-profile-romance-text">$lbl_romance</div>
+<div id="advanced-profile-romance-text" class="advanced-profile-label">$lbl_romance</div>
<br />
-<div id="advanced-profile-romance">$txt</div>
+<div id="advanced-profile-romance" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-romance-end"></div>
EOT;
@@ -234,9 +234,9 @@ if($txt = prepare_text($a->profile['work'])) {
$lbl_work = t('Work/employment:');
$o .= <<< EOT
<div id="advanced-profile-work-wrapper" >
-<div id="advanced-profile-work-text">$lbl_work</div>
+<div id="advanced-profile-work-text" class="advanced-profile-label">$lbl_work</div>
<br />
-<div id="advanced-profile-work">$txt</div>
+<div id="advanced-profile-work" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-work-end"></div>
EOT;
@@ -246,9 +246,9 @@ if($txt = prepare_text($a->profile['education'])) {
$lbl_education = t('School/education:');
$o .= <<< EOT
<div id="advanced-profile-education-wrapper" >
-<div id="advanced-profile-education-text">$lbl_education</div>
+<div id="advanced-profile-education-text" class="advanced-profile-label">$lbl_education</div>
<br />
-<div id="advanced-profile-education">$txt</div>
+<div id="advanced-profile-education" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-education-end"></div>
EOT;
diff --git a/include/queue.php b/include/queue.php
index da5028aee..d312b50f5 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -3,18 +3,18 @@ require_once("boot.php");
require_once('include/queue_fn.php');
function queue_run($argv, $argc){
- global $a, $db;
+ global $a, $db;
- if(is_null($a)){
- $a = new App;
- }
+ if(is_null($a)){
+ $a = new App;
+ }
- if(is_null($db)){
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
- };
+ if(is_null($db)){
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
require_once("session.php");
@@ -29,10 +29,27 @@ function queue_run($argv, $argc){
load_hooks();
+ if($argc > 1)
+ $queue_id = intval($argv[1]);
+ else
+ $queue_id = 0;
+
$deadguys = array();
logger('queue: start');
+ $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
+
+ $r = q("select * from deliverq where 1");
+ if(count($r)) {
+ foreach($r as $rr) {
+ logger('queue: deliverq');
+ proc_run('php','include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ }
+ }
+
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
LEFT JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
@@ -44,13 +61,19 @@ function queue_run($argv, $argc){
q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
}
- $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
+ if($queue_id)
+ $r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1",
+ intval($queue_id)
+ );
+ else
+ $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
if(! count($r)){
return;
}
- call_hooks('queue_predeliver', $a, $r);
+ if(! $queue_id)
+ call_hooks('queue_predeliver', $a, $r);
// delivery loop
@@ -63,9 +86,16 @@ function queue_run($argv, $argc){
// queue_predeliver hooks may have changed the queue db details,
// so check again if this entry still needs processing
- $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
- intval($q_item['id'])
- );
+ if($queue_id) {
+ $qi = q("select * from queue where `id` = %d limit 1",
+ intval($queue_id)
+ );
+ }
+ else {
+ $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
+ intval($q_item['id'])
+ );
+ }
if(! count($qi))
continue;
@@ -83,7 +113,8 @@ function queue_run($argv, $argc){
continue;
}
- $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ $u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
+ FROM `user` WHERE `uid` = %d LIMIT 1",
intval($c[0]['uid'])
);
if(! count($u)) {
@@ -92,6 +123,7 @@ function queue_run($argv, $argc){
}
$data = $qi[0]['content'];
+ $public = $qi[0]['batch'];
$contact = $c[0];
$owner = $u[0];
@@ -124,7 +156,7 @@ function queue_run($argv, $argc){
case NETWORK_DIASPORA:
if($contact['notify']) {
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
- $deliver_status = diaspora_transmit($owner,$contact['notify'],$data);
+ $deliver_status = diaspora_transmit($owner,$contact,$data,$public);
if($deliver_status == (-1))
update_queue_time($q_item['id']);
diff --git a/include/salmon.php b/include/salmon.php
index 4043b4f1d..3d525f51a 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -73,6 +73,13 @@ function slapper($owner,$url,$slap) {
if(! strlen($url))
return;
+
+ if(! $owner['sprvkey']) {
+ logger(sprintf("slapper: user '%s' (%d) does not have a salmon private key. Send failed.",
+ $owner['username'],$owner['uid']));
+ return;
+ }
+
// add all namespaces to item
$namespaces = <<< EOT
@@ -102,11 +109,11 @@ EOT;
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
- $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),true),$owner['sprvkey']);
+ $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey']));
- $signature2 = base64url_encode(rsa_sign($data . $precomputed),$owner['sprvkey']);
+ $signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey']));
- $signature3 = base64url_encode(rsa_sign($data),$owner['sprvkey']);
+ $signature3 = base64url_encode(rsa_sign($data,$owner['sprvkey']));
$salmon_tpl = get_markup_template('magicsig.tpl');
@@ -180,6 +187,9 @@ EOT;
logger('slapper returned ' . $return_code);
if(! $return_code)
return(-1);
+ if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
+ return(-1);
+
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
}
diff --git a/include/template_processor.php b/include/template_processor.php
index 83f680f02..63d75eaa4 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -1,5 +1,6 @@
<?php
+
class Template {
var $r;
var $search;
@@ -8,18 +9,23 @@
var $nodes = array();
var $done = false;
var $d = false;
+ var $lang = null;
+
private function _preg_error(){
switch(preg_last_error()){
- case PREG_INTERNAL_ERROR: die('PREG_INTERNAL_ERROR'); break;
- case PREG_BACKTRACK_LIMIT_ERROR: die('PREG_BACKTRACK_LIMIT_ERROR'); break;
- case PREG_RECURSION_LIMIT_ERROR: die('PREG_RECURSION_LIMIT_ERROR'); break;
- case PREG_BAD_UTF8_ERROR: die('PREG_BAD_UTF8_ERROR'); break;
- case PREG_BAD_UTF8_OFFSET_ERROR: die('PREG_BAD_UTF8_OFFSET_ERROR'); break;
+ case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break;
+ case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break;
+ case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break;
+ case PREG_BAD_UTF8_ERROR: echo('PREG_BAD_UTF8_ERROR'); break;
+ case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break;
default:
//die("Unknown preg error.");
return;
}
+ echo "<hr><pre>";
+ debug_print_backtrace();
+ die();
}
private function _build_replace($r, $prefix){
@@ -153,7 +159,8 @@
krsort($this->nodes);
return $s;
}
-
+
+
public function replace($s, $r) {
$this->r = $r;
$this->search = array();
@@ -166,14 +173,35 @@
$s = preg_replace_callback('/\|\|([0-9]+)\|\|/', array($this, "_replcb_node"), $s);
if ($s==Null) $this->_preg_error();
+ // remove comments block
+ $s = preg_replace('/{#[^#]*#}/', "" , $s);
+
// replace strings recursively (limit to 10 loops)
$os = ""; $count=0;
while($os!=$s && $count<10){
$os=$s; $count++;
$s = str_replace($this->search,$this->replace, $s);
}
- return $s;
+ return template_unescape($s);
}
}
$t = new Template;
+
+
+
+
+function template_escape($s) {
+
+ return str_replace(array('$','{{'),array('!_Doll^Ars1Az_!','!_DoubLe^BraceS4Rw_!'),$s);
+
+
+}
+
+function template_unescape($s) {
+
+ return str_replace(array('!_Doll^Ars1Az_!','!_DoubLe^BraceS4Rw_!'),array('$','{{'),$s);
+
+
+
+}
diff --git a/include/text.php b/include/text.php
index 66447069e..656cd8809 100644
--- a/include/text.php
+++ b/include/text.php
@@ -388,11 +388,13 @@ function get_intltext_template($s) {
if(! function_exists('get_markup_template')) {
function get_markup_template($s) {
-
+ $a=get_app();
$theme = current_theme();
if(file_exists("view/theme/$theme/$s"))
return file_get_contents("view/theme/$theme/$s");
+ elseif (x($a->theme_info,"extends") && file_exists("view/theme/".$a->theme_info["extends"]."/$s"))
+ return file_get_contents("view/theme/".$a->theme_info["extends"]."/$s");
else
return file_get_contents("view/$s");
@@ -482,13 +484,12 @@ function get_tags($s) {
// we might be inside a bbcode color tag - leave it alone
continue;
}
+ if(substr($mtch,-1,1) === '.')
+ $mtch = substr($mtch,0,-1);
// ignore strictly numeric tags like #1
if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1)))
continue;
- if(substr($mtch,-1,1) === '.')
- $ret[] = substr($mtch,0,-1);
- else
- $ret[] = $mtch;
+ $ret[] = $mtch;
}
}
return $ret;
@@ -539,22 +540,30 @@ function contact_block() {
$total = intval($r[0]['total']);
}
if(! $total) {
- $o .= '<h4 class="contact-h4">' . t('No contacts') . '</h4>';
- return $o;
- }
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d",
- intval($a->profile['uid']),
- intval($shown)
- );
- if(count($r)) {
- $o .= '<h4 class="contact-h4">' . sprintf( tt('%d Contact','%d Contacts', $total),$total) . '</h4><div id="contact-block">';
- foreach($r as $rr) {
- $o .= micropro($rr,true,'mpfriend');
- }
- $o .= '</div><div id="contact-block-end"></div>';
- $o .= '<div id="viewcontacts"><a id="viewcontacts-link" href="viewcontacts/' . $a->profile['nickname'] . '">' . t('View Contacts') . '</a></div>';
+ $contacts = t('No contacts');
+ $micropro = Null;
+ } else {
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d",
+ intval($a->profile['uid']),
+ intval($shown)
+ );
+ if(count($r)) {
+ $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
+ $micropro = Array();
+ foreach($r as $rr) {
+ $micropro[] = micropro($rr,true,'mpfriend');
+ }
+ }
}
+
+ $tpl = get_markup_template('contact_block.tpl');
+ $o = replace_macros($tpl, array(
+ '$contacts' => $contacts,
+ '$nickname' => $a->profile['nickname'],
+ '$viewcontacts' => t('View Contacts'),
+ '$micropro' => $micropro,
+ ));
$arr = array('contacts' => $r, 'output' => $o);
@@ -571,11 +580,13 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = $contact['url'];
$sparkle = '';
+ $redir = false;
if($redirect) {
$a = get_app();
$redirect_url = $a->get_baseurl() . '/redir/' . $contact['id'];
if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === 'dfrn')) {
+ $redir = true;
$url = $redirect_url;
$sparkle = ' sparkle';
}
@@ -586,6 +597,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($textmode) {
return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle
. (($click) ? ' fakelink' : '') . '" '
+ . (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click
. '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
. '" >'. $contact['name'] . '</a></div>' . "\r\n";
@@ -593,6 +605,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
else {
return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle
. (($click) ? ' fakelink' : '') . '" '
+ . (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="'
. $contact['micro'] . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
. '" /></a></div>' . "\r\n";
@@ -602,12 +615,14 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if(! function_exists('search')) {
-function search($s,$id='search-box',$url='/search') {
+function search($s,$id='search-box',$url='/search',$save = false) {
$a = get_app();
$o = '<div id="' . $id . '">';
$o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >';
$o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
$o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />';
+ if($save)
+ $o .= '<input type="submit" name="save" id="search-save" value="' . t('Save') . '" />';
$o .= '</form></div>';
return $o;
}}
@@ -630,7 +645,8 @@ function valid_email($x){
if(! function_exists('linkify')) {
function linkify($s) {
- $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
+ $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
+ $s = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$s);
return($s);
}}
@@ -651,7 +667,7 @@ if(! function_exists('smilies')) {
function smilies($s) {
$a = get_app();
- return str_replace(
+ $s = str_replace(
array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O',
'~friendika', 'Diaspora*' ),
array(
@@ -675,6 +691,10 @@ function smilies($s) {
'<a href="http://joindiaspora.com">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
), $s);
+
+ call_hooks('smilie', $s);
+ return $s;
+
}}
@@ -816,9 +836,14 @@ function feed_salmonlinks($nick) {
if(! function_exists('get_plink')) {
function get_plink($item) {
$a = get_app();
- $plink = (((x($item,'plink')) && (! $item['private'])) ? '<div class="wall-item-links-wrapper"><a href="'
- . $item['plink'] . '" title="' . t('link to source') . '" target="external-link" class="icon remote-link"></a></div>' : '');
- return $plink;
+ if (x($item,'plink') && (! $item['private'])){
+ return array(
+ 'href' => $item['plink'],
+ 'title' => t('link to source'),
+ );
+ } else {
+ return false;
+ }
}}
if(! function_exists('unamp')) {
@@ -837,10 +862,16 @@ function lang_selector() {
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
$langs = glob('view/*/strings.php');
if(is_array($langs) && count($langs)) {
+ $langs[] = '';
if(! in_array('view/en/strings.php',$langs))
$langs[] = 'view/en/';
asort($langs);
foreach($langs as $l) {
+ if($l == '') {
+ $default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
+ $o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
+ continue;
+ }
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === $lang) ? ' selected="selected" ' : '');
@@ -909,6 +940,60 @@ function base64url_decode($s) {
return base64_decode(strtr($s,'-_','+/'));
}
-function cc_license() {
-return '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
-}
+
+if (!function_exists('str_getcsv')) {
+ function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\', $eol = '\n') {
+ if (is_string($input) && !empty($input)) {
+ $output = array();
+ $tmp = preg_split("/".$eol."/",$input);
+ if (is_array($tmp) && !empty($tmp)) {
+ while (list($line_num, $line) = each($tmp)) {
+ if (preg_match("/".$escape.$enclosure."/",$line)) {
+ while ($strlen = strlen($line)) {
+ $pos_delimiter = strpos($line,$delimiter);
+ $pos_enclosure_start = strpos($line,$enclosure);
+ if (
+ is_int($pos_delimiter) && is_int($pos_enclosure_start)
+ && ($pos_enclosure_start < $pos_delimiter)
+ ) {
+ $enclosed_str = substr($line,1);
+ $pos_enclosure_end = strpos($enclosed_str,$enclosure);
+ $enclosed_str = substr($enclosed_str,0,$pos_enclosure_end);
+ $output[$line_num][] = $enclosed_str;
+ $offset = $pos_enclosure_end+3;
+ } else {
+ if (empty($pos_delimiter) && empty($pos_enclosure_start)) {
+ $output[$line_num][] = substr($line,0);
+ $offset = strlen($line);
+ } else {
+ $output[$line_num][] = substr($line,0,$pos_delimiter);
+ $offset = (
+ !empty($pos_enclosure_start)
+ && ($pos_enclosure_start < $pos_delimiter)
+ )
+ ?$pos_enclosure_start
+ :$pos_delimiter+1;
+ }
+ }
+ $line = substr($line,$offset);
+ }
+ } else {
+ $line = preg_split("/".$delimiter."/",$line);
+
+ /*
+ * Validating against pesky extra line breaks creating false rows.
+ */
+ if (is_array($line) && !empty($line[0])) {
+ $output[$line_num] = $line;
+ }
+ }
+ }
+ return $output;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/include/zotfns.php b/include/zotfns.php
deleted file mode 100644
index b23fce82a..000000000
--- a/include/zotfns.php
+++ /dev/null
@@ -1,195 +0,0 @@
-<?php
-
-
-require_once('include/salmon.php');
-require_once('include/crypto.php');
-
-
-function zot_get($url,$args) {
- $argstr = '';
- foreach($args as $k => $v) {
- if($argstr)
- $argstr .= '&';
- $argstr .= $k . '=' . $v;
- }
- $s = fetch_url($url . '?' . $argstr);
- if($s) {
- $j = json_decode($s);
- if($j)
- return($j);
- }
- return false;
-}
-
-function zot_post($url,$args) {
- $s = post_url($url,$args);
- if($s) {
- $j = json_decode($s);
- if($j)
- return($j);
- }
- return false;
-}
-
-
-function zot_prv_encode($s,$prvkey) {
- $x = '';
- $res = openssl_private_encrypt($s,$x,$prvkey);
- return base64url_encode($y);
-}
-function zot_pub_encode($s,$pubkey) {
- $x = '';
- $res = openssl_public_encrypt($s,$x,$pubkey);
- return base64url_encode($x);
-}
-
-function zot_prv_decode($s,$prvkey) {
- $s = base64url_decode($s);
- $x = '';
- openssl_private_decrypt($s,$x,$prvkey);
- return $x;
-}
-
-function zot_pub_decode($s,$pubkey) {
- $s = base64url_decode($s);
- $x = '';
- openssl_public_decrypt($s,$x,$pubkey);
- return $x;
-}
-
-
-function zot_getzid($url,$myaddress,$myprvkey) {
- $ret = array();
- $j = zot_get($url,array('sender' => $myaddress));
- if($j->zid_encoded)
- $ret['zid'] = zot_prv_decode($j->zid_encoded,$myprvkey);
- if($j->zkey_encoded)
- $ret['zkey'] = zot_prv_decode($j->zkey_encoded,$myprvkey);
- return $ret;
-}
-
-function zot_post_init($url,$zid,$myprvkey,$theirpubkey) {
- $ret = array();
-
- $zinit = random_string(32);
-
- $j = zot_get($url,array('zid' => $zid,'zinit' => $zinit));
-
- $a = get_app();
- if(! $a->get_curl_code())
- return ZCURL_TIMEOUT;
- if(! $j->zinit) {
- logger('zot_post_init: no zinit returned.');
- return false;
- }
- if(zot_pub_decode($j->zinit,$thierpubkey) !== $zinit) {
- logger('zot_post_init: incorrect zinit returned.');
- return false;
- }
-
- if($j->challenge) {
- $s = zot_prv_decode($j->challenge,$myprvkey);
- $s1 = substr($s,0,strpos($s,'.'));
- if($s1 != $zid) {
- logger("zot_post_init: incorrect zid returned");
- return false;
- }
- $ret['result'] = substr($s,strpos($s,'.') + 1);
- $ret['perms'] = $j->perms;
- }
- return $ret;
-}
-
-
-function zot_encrypt_data($data,&$key) {
- $key = random_string();
- return aes_encrypt($data,$key);
-}
-
-
-// encrypt the data prior to calling this function so it only need be done once per message
-// regardless of the number of recipients.
-
-function zot_post_data($url,$zid,$myprvkey,$theirpubkey,$encrypted_data,$key, $intro = false) {
- $i = zot_post_init($url,$zid,$myprvkey,$theirpubkey);
- if($i === ZCURL_TIMEOUT)
- return ZCURL_TIMEOUT;
-
- if((! $i) || (! array_key_exists('perms',$i)) || (! array_key_exists('result',$i)))
- return false;
- if((! stristr($i['perms'],'post')) && ($intro === false)) {
- logger("zot_post_data: no permission to post: url=$url zid=$zid");
- return false;
- }
- $p = array();
- $p['zid'] = $zid;
- $p['result'] = zot_pub_encode($i['result'],$theirpubkey);
- $p['aes_key'] = zot_prv_encode($key,$myprvkey);
- $p['data'] = $encrypted_data;
- $s = zot_post($url,$p);
- $a = get_app();
- if(! $a->get_curl_code())
- return ZCURL_TIMEOUT;
-
- if($s) {
- $j = json_decode($s);
- return $j;
- }
- return false;
-}
-
-function zot_deliver($recipients,$myprvkey,$data) {
-
- if(is_array($recipients) && count($recipients)) {
-
- $key = '';
- $encrypted = zot_encrypt_data($data,$key);
-
-
- foreach($recipients as $r) {
- $result = zot_post_data(
- $r['post'],
- $r['zid'],
- $myprvkey,
- $r['pubkey'],
- $encrypted,
- $key
- );
- if($result === false) {
- // post failed
- logger('zot_deliver: failed: ' . print_r($r,true));
- }
- elseif($result === ZCURL_TIMEOUT) {
- // queue for redelivery
- }
- elseif($result->error) {
- // failed at other end
- logger('zot_deliver: remote failure: ' . $result->error . ' ' . print_r($r,true));
- }
- elseif($result->success) {
- logger('zot_deliver: success ' . print_r($r,true, LOGGER_DEBUG));
- }
- else
- logger('zot_deliver: unknown failure.');
- }
- }
-}
-
-
-function zot_new_contact($user,$cc) {
-
- $zid = random_string(32);
- $zkey = random_string(32);
-
- logger("zot_new_contact: zid=$zid zkey=$zkey uid={$user['uid']} " . print_r($cc,true));
-
- $ret = array();
- $ret['zid_encoded'] = zot_pub_encode($zid,$cc['pubkey']);
- $ret['zkey_encoded'] = zot_pub_encode($zkey,$cc['pubkey']);
- return $ret;
-
-
-
-
-
-} \ No newline at end of file