]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'themetests' of https://github.com/fabrixxm/friendika into fabrixxm...
authorFriendika <info@friendika.com>
Mon, 21 Feb 2011 21:27:03 +0000 (13:27 -0800)
committerFriendika <info@friendika.com>
Mon, 21 Feb 2011 21:27:03 +0000 (13:27 -0800)
22 files changed:
addon/calc/calc.php [new file with mode: 0644]
addon/facebook/facebook.php
addon/tictac/tictac.php [new file with mode: 0644]
boot.php
include/EmailNotification.php [new file with mode: 0644]
include/bbcode.php
include/main.js
include/nav.php
index.php
mod/apps.php [new file with mode: 0644]
mod/dfrn_notify.php
mod/display.php
mod/item.php
mod/network.php
mod/photos.php
mod/profile.php
mod/update_network.php
view/comment_item.tpl
view/de/mail_received_eml.tpl [deleted file]
view/en/mail_received_eml.tpl [deleted file]
view/fr/mail_received_eml.tpl [deleted file]
view/it/mail_received_eml.tpl [deleted file]

diff --git a/addon/calc/calc.php b/addon/calc/calc.php
new file mode 100644 (file)
index 0000000..fd6a117
--- /dev/null
@@ -0,0 +1,356 @@
+<?php\r
+\r
+function calc_install() {\r
+       register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');\r
+}\r
+\r
+function calc_uninstall() {\r
+       unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');\r
+\r
+}\r
+\r
+function calc_app_menu($a,&$b) {\r
+       $b['app_menu'] .= '<a href="calc">Calculator</a><br />'; \r
+}\r
+\r
+\r
+function calc_module() {}\r
+\r
+\r
+\r
+\r
+function calc_init($a) {\r
+\r
+$x = <<< EOT\r
+\r
+<script language="JavaScript">\r
+/**************************************\r
+ * www.FemaleNerd.com         *\r
+ **************************************/\r
+\r
+// Declare global variables\r
+var displayText = ""\r
+var num1\r
+var num2\r
+var operatorType\r
+\r
+// Write to display\r
+function addDisplay(n){\r
+   id = document.getElementById("display");\r
+id.value = ""\r
+displayText += n\r
+id.value = displayText\r
+}\r
+\r
+// Addition\r
+function addNumbers() {\r
+if (displayText == "") {\r
+  displayText = result\r
+ }\r
+num1 = parseFloat(displayText)\r
+operatorType = "add"\r
+displayText = ""\r
+}\r
+\r
+// Subtraction\r
+function subtractNumbers() {\r
+if (displayText == "") {\r
+  displayText = result\r
+ }\r
+num1 = parseFloat(displayText)\r
+operatorType = "subtract"\r
+displayText = ""\r
+}\r
+\r
+// Multiplication\r
+function multiplyNumbers() {\r
+if (displayText == "") {\r
+  displayText = result\r
+ }\r
+num1 = parseFloat(displayText)\r
+operatorType = "multiply"\r
+displayText = ""\r
+}\r
+\r
+// Division\r
+function divideNumbers() {\r
+if (displayText == "") {\r
+  displayText = result\r
+ }\r
+num1 = parseFloat(displayText)\r
+operatorType = "divide"\r
+displayText = ""\r
+}\r
+\r
+// Sine\r
+function sin() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = Math.sin(num1)\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Cosine\r
+function cos() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = Math.cos(num1)\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// ArcSine\r
+function arcSin() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = Math.asin(num1)\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// ArcCosine\r
+function arcCos() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = Math.acos(num1)\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Square root\r
+function sqrt() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = Math.sqrt(num1)\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Square number (number to the power of two)\r
+function square() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = num1 * num1\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Convert degrees to radians\r
+function degToRad() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = num1 * Math.PI / 180\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Convert radians to degrees\r
+function radToDeg() {\r
+   id = document.getElementById("display");\r
+if (displayText == "") {\r
+  num1 = result\r
+  }\r
+else {\r
+  num1 = parseFloat(displayText)\r
+  }\r
+if (num1 != "") {\r
+  result = num1 * 180 / Math.PI\r
+  id.value = result\r
+  displayText = ""\r
+  }\r
+else {\r
+  alert("Please write the number first")\r
+  }\r
+}\r
+\r
+// Calculations\r
+function calculate() {\r
+   id = document.getElementById("display");\r
+\r
+if (displayText != "") {\r
+  num2 = parseFloat(displayText)\r
+// Calc: Addition\r
+  if (operatorType == "add") {\r
+    result = num1 + num2\r
+    id.value = result\r
+    }\r
+// Calc: Subtraction\r
+  if (operatorType == "subtract") {\r
+    result = num1 - num2\r
+    id.value = result\r
+    }\r
+// Calc: Multiplication\r
+  if (operatorType == "multiply") {\r
+    result = num1 * num2\r
+    id.value = result\r
+    }\r
+// Calc: Division\r
+  if (operatorType == "divide") {\r
+    result = num1 / num2\r
+    id.value = result\r
+    }\r
+  displayText = ""\r
+  }\r
+  else {\r
+  id.value = "Oops! Error!"\r
+  }\r
+}\r
+\r
+// Clear the display\r
+function clearDisplay() {\r
+   id = document.getElementById("display");\r
+\r
+displayText = ""\r
+id.value = ""\r
+}\r
+</script>\r
+\r
+EOT;\r
+$a->page['htmlhead'] .= $x;\r
+}\r
+\r
+function calc_content($app) {\r
+\r
+$o = '';\r
+\r
+$o .=  <<< EOT\r
+\r
+<h3>Calculator</h3>\r
+<br /><br />\r
+<table>\r
+<tbody><tr><td> \r
+<table bgcolor="#af9999" border="1">\r
+<tbody><tr><td>\r
+<table border="1" cellpadding="2" cellspacing="2">\r
+<form name="calc">\r
+<!--\r
+<TR><TD VALIGN=top colspan=6 ALIGN="center"> <H2>Calculator</H2> </TD>\r
+-->\r
+<tbody><tr>\r
+       <td colspan="5"><input size="22" id="display" name="display" type="text"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="one" value="&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;" onclick="addDisplay(1)" type="button"></td>\r
+       <td><input name="two" value="&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;" onclick="addDisplay(2)" type="button"></td>\r
+       <td><input name="three" value="&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;" onclick="addDisplay(3)" type="button"></td>\r
+       <td><input name="plus" value="&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;" onclick="addNumbers()" type="button"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="four" value="&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;" onclick="addDisplay(4)" type="button"></td>\r
+       <td><input name="five" value="&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;" onclick="addDisplay(5)" type="button"></td>\r
+       <td><input name="six" value="&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;" onclick="addDisplay(6)" type="button"></td>\r
+       <td><input name="minus" value="&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;" onclick="subtractNumbers()" type="button"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="seven" value="&nbsp;&nbsp;7&nbsp;&nbsp;&nbsp;" onclick="addDisplay(7)" type="button"></td>\r
+       <td><input name="eight" value="&nbsp;&nbsp;8&nbsp;&nbsp;&nbsp;" onclick="addDisplay(8)" type="button"></td>\r
+       <td><input name="nine" value="&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;" onclick="addDisplay(9)" type="button"></td>\r
+       <td><input name="multiplication" value="&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;" onclick="multiplyNumbers()" type="button"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="zero" value="&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;" onclick="addDisplay(0)" type="button"></td>\r
+       <td><input name="pi" value="&nbsp;Pi&nbsp;&nbsp;" onclick="addDisplay(Math.PI)" type="button"> </td> \r
+       <td><input name="dot" value="&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;" onclick='addDisplay(".")' type="button"></td>\r
+       <td><input name="division" value="&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;" onclick="divideNumbers()" type="button"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="sqareroot" value="sqrt" onclick="sqrt()" type="button"></td>\r
+       <td><input name="squarex" value=" x^2" onclick="square()" type="button"></td>\r
+       <td><input name="deg-rad" value="d2r&nbsp;" onclick="degToRad()" type="button"></td>\r
+       <td><input name="rad-deg" value="r2d&nbsp;" onclick="radToDeg()" type="button"></td>\r
+</tr><tr align="left" valign="middle">\r
+       <td><input name="sine" value="&nbsp;sin&nbsp;" onclick="sin()" type="button"></td>\r
+       <td><input name="arcsine" value="asin" onclick="arcSin()" type="button"></td>\r
+       <td><input name="cosine" value="cos" onclick="cos()" type="button"></td>\r
+       <td><input name="arccosine" value="acs" onclick="arcCos()" type="button"></td>\r
+\r
+</tr><tr align="left" valign="middle">\r
+       <td colspan="2"><input name="clear" value="&nbsp;&nbsp;Clear&nbsp;&nbsp;" onclick="clearDisplay()" type="button"></td>\r
+       <td colspan="3"><input name="enter" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" onclick="calculate()" type="button"></td>\r
+\r
+</tr></tbody></table>\r
+</form>\r
+\r
+       <!--\r
+       <TD VALIGN=top> \r
+               <B>NOTE:</B> All sine and cosine calculations are\r
+               <br>done in radians. Remember to convert first\r
+               <br>if using degrees.\r
+       </TD>\r
+       -->\r
+       \r
+</td></tr></tbody></table>\r
+\r
+\r
+</td></tr></tbody></table>\r
+\r
+EOT;\r
+return $o;\r
+\r
+}\r
index 119ee2f3e5aaccba9e8d87bef3c3dfd595b27cca..c2c5a887686c4835ff53972342b275eb485af5fe 100644 (file)
@@ -112,9 +112,9 @@ function facebook_content(&$a) {
        $o .= '<br />';
 
        $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' 
-               . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook posting') . '</a><br />';
+               . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook post connector') . '</a><br /><br />';
 
-       $o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook posting') . '</a><br />';
+       $o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook post connector') . '</a><br />';
 
 
        return $o;
@@ -123,15 +123,24 @@ function facebook_content(&$a) {
 function facebook_install() {
        register_hook('post_local_end',  'addon/facebook/facebook.php', 'facebook_post_hook');
        register_hook('jot_networks',    'addon/facebook/facebook.php', 'facebook_jot_nets');
+       register_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
 }
 
 
 function facebook_uninstall() {
        unregister_hook('post_local_end',  'addon/facebook/facebook.php', 'facebook_post_hook');
        unregister_hook('jot_networks',    'addon/facebook/facebook.php', 'facebook_jot_nets');
+       unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
 }
 
 
+function facebook_plugin_settings(&$a,&$b) {
+
+       $b .= '<h3>' . t('Facebook') . '</h3>';
+       $b .= '<a href="facebook">' . t('Facebook Connector Settings') . '</a><br />';
+
+}
+
 function facebook_jot_nets(&$a,&$b) {
        if(! local_user())
                return;
@@ -185,6 +194,7 @@ function facebook_post_hook(&$a,&$b) {
                                $msg = preg_replace("/\[img\](.+?)\[\/img\]/is", t('Image: ') . '$1',$msg);
 
                                $msg = trim(strip_tags(bbcode($msg)));
+                               $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
 
                                if (strlen($msg) > FACEBOOK_MAXPOSTLEN) {
                                        $shortlink = "";
diff --git a/addon/tictac/tictac.php b/addon/tictac/tictac.php
new file mode 100644 (file)
index 0000000..9567830
--- /dev/null
@@ -0,0 +1,659 @@
+<?php
+
+
+function tictac_install() {
+       register_hook('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
+}
+
+function tictac_uninstall() {
+       unregister_hook('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
+
+}
+
+function tictac_app_menu($a,&$b) {
+       $b['app_menu'] .= '<a href="tictac">' . t('Three Dimensional Tic-Tac-Toe') . '</a><br />'; 
+}
+
+
+function tictac_module() {
+       return;
+}
+
+
+
+
+
+function tictac_content(&$a) {
+
+       $o = '';
+
+  if($_POST['move']) {
+    $handicap = $a->argv[1];
+    $mefirst = $a->argv[2];
+    $dimen = $a->argv[3];
+    $yours = $a->argv[4];
+    $mine  = $a->argv[5];
+    
+    $yours .= $_POST['move'];
+  }
+  elseif($a->argc > 1) {
+    $handicap = $a->argv[1];
+    $dimen = 3;
+  }
+  else {
+   $dimen = 3;
+  }
+
+  $o .=  '<h3>3D Tic-Tac-Toe</h3><br />';
+
+  $t = new tictac($dimen,$handicap,$mefirst,$yours,$mine);
+  $o .= $t->play();
+
+  $o .=  '<a href="tictac">' . t('New game') . '</a><br />';
+  $o .=  '<a href="tictac/1">' . t('New game with handicap') . '</a><br />';
+  $o .=  '<p>' . t('Three dimensional tic-tac-toe is just like the traditional game except that it is played on multiple levels simultaneously.');
+  $o .= t('In this case there are three levels. You win by getting three in a row on any level, as well as up, down, and diagonally across the different levels.');
+  $o .= '</p><p>'; 
+  $o .= t('The handicap game disables the center position on the middle level because the player claiming this square often has an unfair advantage.');
+  $o .= '</p>';
+
+  return $o;
+
+}
+
+class tictac {
+  private $dimen;
+  private $first_move = true;
+  private $handicap = 0;
+  private $yours;
+  private $mine;
+  private $winning_play;  
+  private $you;
+  private $me;
+  private $debug = 1;
+  private $crosses = array('011','101','110','112','121','211');
+
+/*
+    '001','010','011','012','021',
+    '101','110','111','112','121',
+    '201','210','211','212','221');
+*/
+
+  private $corners = array(
+    '000','002','020','022',
+    '200','202','220','222');
+
+  private $planes = array(
+    array('000','001','002','010','011','012','020','021','022'), // horiz 1
+    array('100','101','102','110','111','112','120','121','122'), // 2
+    array('200','201','202','210','211','212','220','221','222'), // 3
+    array('000','010','020','100','110','120','200','210','220'), // vert left
+    array('000','001','002','100','101','102','200','201','202'), // vert top
+    array('002','012','022','102','112','122','202','212','222'), // vert right
+    array('020','021','022','120','121','122','220','221','222'), // vert bot
+    array('010','011','012','110','111','112','210','211','212'), // left vertx
+    array('001','011','021','101','111','221','201','211','221'), // top vertx
+    array('000','001','002','110','111','112','220','221','222'), // diag top
+    array('020','021','022','110','111','112','200','201','202'), // diag bot
+    array('000','010','020','101','111','121','202','212','222'), // diag left
+    array('002','012','022','101','111','121','200','210','220'), // diag right
+    array('002','011','020','102','111','120','202','211','220'), // diag x
+    array('000','011','022','100','111','122','200','211','222')  // diag x
+    
+  );
+
+
+  private $winner = array(
+     array('000','001','002'),         // board 0 winners  - left corner across
+     array('000','010','020'),         // down
+     array('000','011','022'),         // diag
+     array('001','011','021'),         // middle-top down
+     array('010','011','012'),         // middle-left across
+     array('002','011','020'),         // right-top diag
+     array('002','012','022'),         // right-top down
+     array('020','021','022'),        // bottom-left across
+     array('100','101','102'),      // board 1 winners
+     array('100','110','120'),
+     array('100','111','122'),
+     array('101','111','121'),
+     array('110','111','112'),
+     array('102','111','120'),
+     array('102','112','122'),
+     array('120','121','122'),
+     array('200','201','202'),    // board 2 winners
+     array('200','210','220'),
+     array('200','211','222'),
+     array('201','211','221'),
+     array('210','211','212'),
+     array('202','211','220'),
+     array('202','212','222'),
+     array('220','221','222'),
+     array('000','100','200'),      // top-left corner 3d
+     array('000','101','202'),
+     array('000','110','220'),
+     array('000','111','222'),
+     array('001','101','201'),      // top-middle 3d
+     array('001','111','221'),
+     array('002','102','202'),      // top-right corner 3d
+     array('002','101','200'),
+     array('002','112','222'),
+     array('002','111','220'),
+     array('010','110','210'),      // left-middle 3d
+     array('010','111','212'),
+     array('011','111','211'),      // middle-middle 3d
+     array('012','112','212'),      // right-middle 3d
+     array('012','111','210'),
+     array('020','120','220'),      // bottom-left corner 3d
+     array('020','110','200'),
+     array('020','121','222'),
+     array('020','111','202'),
+     array('021','121','221'),      // bottom-middle 3d
+     array('021','111','201'),
+     array('022','122','222'),      // bottom-right corner 3d
+     array('022','121','220'),
+     array('022','112','202'),
+     array('022','111','200')
+
+  );
+
+  function __construct($dimen,$handicap,$mefirst,$yours,$mine) {
+    $this->dimen = 3;
+    $this->handicap = (($handicap) ? 1 : 0);
+    $this->mefirst = (($mefirst) ? 1 : 0);
+    $this->yours = str_replace('XXX','',$yours);
+    $this->mine  = $mine;
+    $this->you = $this->parse_moves('you');
+    $this->me  = $this->parse_moves('me');
+
+    if(strlen($yours))
+      $this->first_move = false;
+  }
+
+  function play() {
+
+     if($this->first_move) {
+       if(rand(0,1) == 1) {
+         $o .=  '<div class="error-message">' . t('You go first...') . '</div><br />';
+         $this->mefirst = 0;
+         $o .= $this->draw_board();
+         return $o;
+       }
+       $o .=  '<div class="error-message">' . t('I\'m going first this time...') . ' </div><br />';
+       $this->mefirst = 1;
+
+     }
+
+     if($this->check_youwin()) {
+       $o .=  '<div class="error-message">' . t('You won!') . '</div><br />';
+       $o .= $this->draw_board();
+       return $o;
+     }
+
+     if($this->fullboard())
+       $o .=  '<div class="error-message">' . t('"Cat" game!') . '</div><br />';
+
+     $move = $this->winning_move();
+     if(strlen($move)) {
+       $this->mine .= $move;
+       $this->me = $this->parse_moves('me');
+     }
+     else {
+       $move = $this->defensive_move();
+       if(strlen($move)) {
+         $this->mine .= $move;
+         $this->me = $this->parse_moves('me');
+       }
+       else {  
+         $move = $this->offensive_move();
+         if(strlen($move)) {
+           $this->mine .= $move;
+           $this->me = $this->parse_moves('me');
+         }
+       }
+     }
+
+     if($this->check_iwon())
+       $o .=  '<div class="error-message">' . t('I won!') . '</div><br />';
+     if($this->fullboard())
+       $o .=  '<div class="error-message">' . t('"Cat" game!') . '</div><br />';
+     $o .= $this->draw_board();
+       return $o;
+  }
+
+  function parse_moves($player) {
+    if($player == 'me')
+      $str = $this->mine;
+    if($player == 'you')
+      $str = $this->yours;
+    $ret = array();
+      while(strlen($str)) {
+         $ret[] = substr($str,0,3);
+         $str = substr($str,3);
+      }
+    return $ret;
+  }
+
+
+  function check_youwin() {
+    for($x = 0; $x < count($this->winner); $x ++) {
+      if(in_array($this->winner[$x][0],$this->you) && in_array($this->winner[$x][1],$this->you) && in_array($this->winner[$x][2],$this->you)) {
+        $this->winning_play = $this->winner[$x];
+        return true;
+      }
+    }
+    return false;
+  }
+  function check_iwon() {
+    for($x = 0; $x < count($this->winner); $x ++) {
+      if(in_array($this->winner[$x][0],$this->me) && in_array($this->winner[$x][1],$this->me) && in_array($this->winner[$x][2],$this->me)) {
+        $this->winning_play = $this->winner[$x];
+        return true;
+      }
+    }
+    return false;
+  }
+  function defensive_move() {
+
+    for($x = 0; $x < count($this->winner); $x ++) {
+      if(($this->handicap) && in_array('111',$this->winner[$x]))
+        continue;
+      if(in_array($this->winner[$x][0],$this->you) && in_array($this->winner[$x][1],$this->you) && (! in_array($this->winner[$x][2],$this->me)))
+        return($this->winner[$x][2]);
+      if(in_array($this->winner[$x][0],$this->you) && in_array($this->winner[$x][2],$this->you) && (! in_array($this->winner[$x][1],$this->me)))
+        return($this->winner[$x][1]);
+      if(in_array($this->winner[$x][1],$this->you) && in_array($this->winner[$x][2],$this->you) && (! in_array($this->winner[$x][0],$this->me)))
+        return($this->winner[$x][0]);
+     }
+     return '';
+  }
+
+function winning_move() {
+
+    for($x = 0; $x < count($this->winner); $x ++) {
+      if(($this->handicap) && in_array('111',$this->winner[$x]))
+        continue;
+      if(in_array($this->winner[$x][0],$this->me) && in_array($this->winner[$x][1],$this->me) && (! in_array($this->winner[$x][2],$this->you)))
+        return($this->winner[$x][2]);
+      if(in_array($this->winner[$x][0],$this->me) && in_array($this->winner[$x][2],$this->me) && (! in_array($this->winner[$x][1],$this->you)))
+        return($this->winner[$x][1]);
+      if(in_array($this->winner[$x][1],$this->me) && in_array($this->winner[$x][2],$this->me) && (! in_array($this->winner[$x][0],$this->you)))
+        return($this->winner[$x][0]);
+     }
+
+}
+
+  function offensive_move() {
+
+    shuffle($this->planes);
+    shuffle($this->winner);
+    shuffle($this->corners);
+    shuffle($this->crosses);
+
+    if(! count($this->me)) {
+      if($this->handicap) {
+        $p = $this->uncontested_plane();
+        foreach($this->corners as $c)
+          if((in_array($c,$p)) 
+            && (! $this->is_yours($c)) && (! $this->is_mine($c)))
+              return($c);
+      }
+      else {
+        if((! $this->marked_yours(1,1,1)) && (! $this->marked_mine(1,1,1)))
+          return '111';
+        $p = $this->uncontested_plane();
+        foreach($this->crosses as $c)
+          if((in_array($c,$p))
+            && (! $this->is_yours($c)) && (! $this->is_mine($c)))
+            return($c);
+      }
+    }
+
+    if($this->handicap) {
+      if(count($this->me) >= 1) {
+        if(count($this->get_corners($this->me)) == 1) {
+          if(in_array($this->me[0],$this->corners)) {
+            $p = $this->my_best_plane();
+            foreach($this->winner as $w) {
+              if((in_array($w[0],$this->you)) 
+              || (in_array($w[1],$this->you))
+              || (in_array($w[2],$this->you)))
+                continue;        
+              if(in_array($w[0],$this->corners) 
+                && in_array($w[2],$this->corners)
+                && in_array($w[0],$p) && in_array($w[2],$p)) {
+                  if($this->me[0] == $w[0])
+                    return($w[2]);
+                  elseif($this->me[0] == $w[2])
+                    return($w[0]);
+              }
+            }
+          }
+        }
+        else {
+          $r = $this->get_corners($this->me);
+          if(count($r) > 1) {
+            $w1 = array(); $w2 = array();
+            foreach($this->winner as $w) {
+              if(in_array('111',$w))
+                continue;
+              if(($r[0] == $w[0]) || ($r[0] == $w[2]))
+                $w1[] = $w;
+              if(($r[1] == $w[0]) || ($r[1] == $w[2]))
+                $w2[] = $w;
+            }
+            if(count($w1) && count($w2)) {
+              foreach($w1 as $a) {
+                foreach($w2 as $b) {
+                  if((in_array($a[0],$this->you)) 
+                  || (in_array($a[1],$this->you))
+                  || (in_array($a[2],$this->you))
+                  || (in_array($b[0],$this->you))
+                  || (in_array($b[1],$this->you))
+                  || (in_array($b[2],$this->you)))
+                    continue; 
+                  if(($a[0] == $b[0]) && ! $this->is_mine($a[0])) {
+                    return $a[0];
+                  }
+                  elseif(($a[2] == $b[2]) && ! $this->is_mine($a[2])) {
+                    return $a[2];
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
+ //&& (count($this->me) == 1) && (count($this->you) == 1)
+ //     && in_array($this->you[0],$this->corners)
+ //     && $this->is_neighbor($this->me[0],$this->you[0])) {
+
+      // Yuck. You foiled my plan. Since you obviously aren't playing to win, 
+      // I'll try again. You may keep me busy for a few rounds, but I'm 
+      // gonna' get you eventually.
+
+//      $p = $this->uncontested_plane();
+ //     foreach($this->crosses as $c)
+   //     if(in_array($c,$p))
+     //     return($c);
+
+//    }
+
+
+    // find all the winners containing my points.
+    $mywinners = array();
+    foreach($this->winner as $w)
+      foreach($this->me as $m)
+        if((in_array($m,$w)) && (! in_array($w,$mywinners)))
+          $mywinners[] = $w;
+
+    // find all the rules where my points are in the center.
+      $trythese = array();
+      if(count($mywinners)) {
+        foreach($mywinners as $w) {
+          foreach($this->me as $m) {
+            if(($m == $w[1]) && ($this->uncontested_winner($w))
+              && (! in_array($w,$trythese)))
+            $trythese[] = $w;
+          }
+        }
+      }
+
+      $myplanes = array();
+      for($p = 0; $p < count($this->planes); $p ++) {
+        if($this->handicap && in_array('111',$this->planes[$p]))
+          continue;
+        foreach($this->me as $m)
+          if((in_array($m,$this->planes[$p])) 
+            && (! in_array($this->planes[$p],$myplanes)))
+              $myplanes[] = $this->planes[$p];
+      }
+      shuffle($myplanes);
+
+    // find all winners which share an endpoint, and which are uncontested
+      $candidates = array();
+      if(count($trythese) && count($myplanes)) {
+        foreach($trythese as $t) {
+          foreach($this->winner as $w) {
+            if(! $this->uncontested_winner($w))
+              continue;
+            if((in_array($t[0],$w)) || (in_array($t[2],$w))) {
+              foreach($myplanes as $p)
+                if(in_array($w[0],$p) && in_array($w[1],$p) && in_array($w[2],$p) && ($w[1] != $this->me[0]))
+                  if(! in_array($w,$candidates))
+                    $candidates[] = $w;
+            }
+          }
+        }
+      }
+
+      // Find out if we are about to force a win.
+      // Looking for two winning vectors with a common endpoint
+      // and where we own the middle of both - we are now going to 
+      // grab the endpoint. The game isn't yet over but we've already won.
+
+      if(count($candidates)) {
+        foreach($candidates as $c) {
+          if(in_array($c[1],$this->me)) {
+            // return endpoint
+            foreach($trythese as $t)
+              if($t[0] == $c[0])
+                return($t[0]);
+              elseif($t[2] == $c[2])
+                return($t[2]);
+          }
+       }
+
+       // find opponents planes
+      $yourplanes = array();
+      for($p = 0; $p < count($this->planes); $p ++) {
+        if($this->handicap && in_array('111',$this->planes[$p]))
+          continue;
+        if(in_array($this->you[0],$this->planes[$p]))
+          $yourplanes[] = $this->planes[$p];
+      }
+
+      shuffle($this->winner);
+      foreach($candidates as $c) {
+
+         // We now have a list of winning strategy vectors for our second point
+         // Pick one that will force you into defensive mode.
+         // Pick a point close to you so we don't risk giving you two
+         // in a row when you block us. That would force *us* into 
+         // defensive mode.
+         // We want:        or:         not:
+         //           X|O|     X| |       X| |
+         //            |O|     O|O|        |O|
+         //            | |      | |        |O|
+
+         if(count($this->you) == 1) {
+           foreach($this->winner as $w) {
+             if(in_array($this->me[0], $w) && in_array($c[1],$w) 
+               && $this->uncontested_winner($w) 
+               && $this->is_neighbor($this->you[0],$c[1])) {
+                 return($c[1]);
+             }  
+           }
+         }
+       }         
+
+       // You're somewhere else entirely or have made more than one move 
+       // - any strategy vector which puts you on the defense will have to do
+
+       foreach($candidates as $c) {
+         foreach($this->winner as $w) {
+           if(in_array($this->me[0], $w) && in_array($c[1],$w) 
+             && $this->uncontested_winner($w)) {
+                   return($c[1]);
+           }  
+         }
+       }
+     }
+
+    // worst case scenario, no strategy we can play, 
+    // just find an empty space and take it
+
+    for($x = 0; $x < $this->dimen; $x ++)
+      for($y = 0; $y < $this->dimen; $y ++)
+        for($z = 0; $z < $this->dimen; $z ++)
+          if((! $this->marked_yours($x,$y,$z)) 
+            && (! $this->marked_mine($x,$y,$z))) {
+            if($this->handicap && $x == 1 && $y == 1 && $z == 1)
+              continue;
+            return(sprintf("%d%d%d",$x,$y,$z));
+          }
+       
+  return '';
+  }
+
+  function marked_yours($x,$y,$z) {
+   $str = sprintf("%d%d%d",$x,$y,$z);
+   if(in_array($str,$this->you))
+     return true;
+   return false;
+  }
+
+  function marked_mine($x,$y,$z) {
+   $str = sprintf("%d%d%d",$x,$y,$z);
+   if(in_array($str,$this->me))
+     return true;
+   return false;
+  }
+
+  function is_yours($str) {
+   if(in_array($str,$this->you))
+     return true;
+   return false;
+  }
+
+  function is_mine($str) {
+   if(in_array($str,$this->me))
+     return true;
+   return false;
+  }
+
+  function get_corners($a) {
+    $total = array();
+    if(count($a))
+      foreach($a as $b)
+        if(in_array($b,$this->corners))
+          $total[] = $b;
+    return $total;
+  }
+
+  function uncontested_winner($w) {
+    if($this->handicap && in_array('111',$w))
+      return false;
+    $contested = false;
+    if(count($this->you)) {
+      foreach($this->you as $you)
+        if(in_array($you,$w))
+          $contested = true;
+    }
+    return (($contested) ? false : true);
+  }
+
+
+  function is_neighbor($p1,$p2) {
+   list($x1,$y1,$z1) = sscanf($p1, "%1d%1d%1d");
+   list($x2,$y2,$z2) = sscanf($p2, "%1d%1d%1d");
+
+   if((($x1 == $x2) || ($x1 == $x2+1) || ($x1 == $x2-1)) &&
+      (($y1 == $y2) || ($y1 == $y2+1) || ($y1 == $y2-1)) &&
+      (($z1 == $z2) || ($z1 == $z2+1) || ($z1 == $z2-1)))
+     return true;
+   return false;
+
+  }
+
+  function my_best_plane() {
+
+    $second_choice = array();
+    shuffle($this->planes);
+    for($p = 0; $p < count($this->planes); $p ++ ) {
+      $contested = 0;
+      if($this->handicap && in_array('111',$this->planes[$p]))
+        continue;
+      if(! in_array($this->me[0],$this->planes[$p]))
+        continue;
+      foreach($this->you as $m) {
+        if(in_array($m,$this->planes[$p]))
+          $contested ++;   
+      }
+      if(! $contested)
+        return($this->planes[$p]);
+      if($contested == 1)
+        $second_choice = $this->planes[$p];
+    }
+    return $second_choice;
+  }
+
+
+
+
+
+
+
+  function uncontested_plane() {
+    $freeplane = true;
+    shuffle($this->planes);
+    $pl = $this->planes;
+
+    for($p = 0; $p < count($pl); $p ++ ) {
+        if($this->handicap && in_array('111',$pl[$p]))
+          continue;
+       foreach($this->you as $m) {
+         if(in_array($m,$pl[$p]))   
+           $freeplane = false;         
+       }
+       if(! $freeplane) {
+         $freeplane = true;
+         continue;
+       }
+       if($freeplane)
+         return($pl[$p]);
+    }
+    return array();
+  }
+
+  function fullboard() {
+   return false;
+  }
+
+  function draw_board() {
+    if(! strlen($this->yours))
+      $this->yours = 'XXX';
+    $o .=  "<form action=\"tictac/{$this->handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />";
+    for($x = 0; $x < $this->dimen; $x ++) {
+      $o .=  '<table>';
+      for($y = 0; $y < $this->dimen; $y ++) {
+        $o .=  '<tr>';
+        for($z = 0; $z < $this->dimen; $z ++) {
+          $s = sprintf("%d%d%d",$x,$y,$z);
+          $winner = ((is_array($this->winning_play) && in_array($s,$this->winning_play)) ? " color: #FF0000; " : "");
+          $bordertop = (($y != 0) ? " border-top: 2px solid #000;" : "");
+          $borderleft = (($z != 0) ? " border-left: 2px solid #000;" : "");
+          if($this->handicap && $x == 1 && $y == 1 && $z == 1)
+            $o .=  "<td style=\"width: 25px; height: 25px; $bordertop $borderleft\" align=\"center\">&nbsp;</td>";                  
+          elseif($this->marked_yours($x,$y,$z))
+            $o .=  "<td style=\"width: 25px; height: 25px; $bordertop $borderleft $winner\" align=\"center\">X</td>";
+          elseif($this->marked_mine($x,$y,$z))
+            $o .=  "<td style=\"width: 25px; height: 25px; $bordertop $borderleft $winner\" align=\"center\">O</td>";
+          else {
+            $val = sprintf("%d%d%d",$x,$y,$z);
+            $o .=  "<td style=\"width: 25px; height: 25px; $bordertop $borderleft\" align=\"center\"><input type=\"checkbox\" name=\"move\" value=\"$val\" onclick=\"this.form.submit();\" /></td>";
+          }
+        }
+        $o .=  '</tr>';
+      }
+      $o .=  '</table><br />';
+    }
+    $o .=  '</form>';
+       return $o;
+
+  }
+
+
+}
+
index 322a4e307497dafd5095e26abd2dd1f758b3139e..d8abf06b04d736c9fbd0fb08bac51d0762686f14 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -196,6 +196,7 @@ class App {
        public  $timezone;
        public  $interactive = true;
        public  $plugins;
+       public  $apps;
 
        private $scheme;
        private $hostname;
@@ -1380,12 +1381,12 @@ function webfinger($s) {
                $tpl = fetch_lrdd_template($host);
                logger('webfinger: lrdd template: ' . $tpl);
                if(strlen($tpl)) {
-                       $pxrd = str_replace('{uri}', urlencode('acct:'.$s), $tpl);
+                       $pxrd = str_replace('{uri}', urlencode('acct:' . $s), $tpl);
                        logger('webfinger: pxrd: ' . $pxrd);
                        $links = fetch_xrd_links($pxrd);
                        if(! count($links)) {
                                // try with double slashes
-                               $pxrd = str_replace('{uri}', urlencode('acct://'.$s), $tpl);
+                               $pxrd = str_replace('{uri}', urlencode('acct://' . $s), $tpl);
                                logger('webfinger: pxrd: ' . $pxrd);
                                $links = fetch_xrd_links($pxrd);
                        }
@@ -1400,51 +1401,154 @@ function lrdd($uri) {
 
        $a = get_app();
 
+       // default priority is host priority, host-meta first
+
+       $priority = 'host';
+
+       // All we have is an email address. Resource-priority is irrelevant
+       // because our URI isn't directly resolvable.
+
        if(strstr($uri,'@')) {  
                return(webfinger($uri));
        }
-       else {
-               $html = fetch_url($uri);
-               $headers = $a->get_curl_headers();
-               logger('lrdd: headers=' . $headers, LOGGER_DEBUG);
+
+       // get the host meta file
+
+       $host = parse_url($uri);
+
+       if($host) {
+               $url  = ((x($host,'scheme')) ? $host['scheme'] : 'http') . '://';
+               $url .= $host['host'] . '/.well-known/host-meta' ;
+       }
+       else
+               return array();
+
+       logger('lrdd: constructed url: ' . $url);
+
+       $xml = fetch_url($url);
+       $headers = $a->get_curl_headers();
+
+       if (! $xml)
+               return array();
+
+       logger('lrdd: host_meta: ' . $xml, LOGGER_DATA);
+       $h = simplexml_load_string($xml);
+       $arr = convert_xml_element_to_array($h);
+
+       if(isset($arr['xrd']['property'])) {
+               $property = $arr['crd']['property'];
+               if(! isset($property[0]))
+                       $properties = array($property);
+               else
+                       $properties = $property;
+               foreach($properties as $prop)
+                       if((string) $prop['@attributes'] === 'http://lrdd.net/priority/resource')
+                               $priority = 'resource';
+       } 
+
+       // save the links in case we need them
+
+       $links = array();
+
+       if(isset($arr['xrd']['link'])) {
+               $link = $arr['xrd']['link'];
+               if(! isset($link[0]))
+                       $links = array($link);
+               else
+                       $links = $link;
+       }
+
+       // do we have a template or href?
+
+       if(count($links)) {
+               foreach($links as $link) {
+                       if($link['@attributes']['rel'] && attribute_contains($link['@attributes']['rel'],'lrdd')) {
+                               if(x($link['@attributes'],'template'))
+                                       $tpl = $link['@attributes']['template'];
+                               elseif(x($link['@attributes'],'href'))
+                                       $href = $link['@attributes']['href'];
+                       }
+               }               
+       }
+
+       if((! isset($tpl)) || (! strpos($tpl,'{uri}')))
+               $tpl = '';
+
+       if($priority === 'host') {
+               if(strlen($tpl)) 
+                       $pxrd = str_replace('{uri}', urlencode($uri), $tpl);
+               elseif(isset($href))
+                       $pxrd = $href;
+               if(isset($pxrd)) {
+                       logger('lrdd: (host priority) pxrd: ' . $pxrd);
+                       $links = fetch_xrd_links($pxrd);
+                       return $links;
+               }
+
                $lines = explode("\n",$headers);
                if(count($lines)) {
                        foreach($lines as $line) {                              
-                               // TODO alter the following regex to support multiple relations (space separated)
                                if((stristr($line,'link:')) && preg_match('/<([^>].*)>.*rel\=[\'\"]lrdd[\'\"]/',$line,$matches)) {
-                                       $link = $matches[1];
+                                       return(fetch_xrd_links($matches[1]));
                                        break;
                                }
-                               // don't try and run feeds through the html5 parser
-                               if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
-                                       return array();
-                               if(stristr($html,'<rss') || stristr($html,'<feed'))
-                                       return array();
                        }
                }
-               if(! isset($link)) {
-                       // parse the page of the supplied URL looking for rel links
+       }
 
-                       require_once('library/HTML5/Parser.php');
-                       $dom = HTML5_Parser::parse($html);
 
-                       if($dom) {
-                               $items = $dom->getElementsByTagName('link');
+       // priority 'resource'
 
-                               foreach($items as $item) {
-                                       $x = $item->getAttribute('rel');
-                                       if($x == "lrdd") {
-                                               $link = $item->getAttribute('href');
-                                               break;
-                                       }
-                               }
+
+       $html = fetch_url($uri);
+       $headers = $a->get_curl_headers();
+       logger('lrdd: headers=' . $headers, LOGGER_DEBUG);
+
+       require_once('library/HTML5/Parser.php');
+       $dom = @HTML5_Parser::parse($html);
+
+       if($dom) {
+               $items = $dom->getElementsByTagName('link');
+               foreach($items as $item) {
+                       $x = $item->getAttribute('rel');
+                       if($x == "lrdd") {
+                               $pagelink = $item->getAttribute('href');
+                               break;
                        }
                }
+       }
+
+       if(isset($pagelink))
+               return(fetch_xrd_links($pagelink));
 
-               if(isset($link))
-                       return(fetch_xrd_links($link));
+       // next look in HTTP headers
+
+       $lines = explode("\n",$headers);
+       if(count($lines)) {
+               foreach($lines as $line) {                              
+                       // TODO alter the following regex to support multiple relations (space separated)
+                       if((stristr($line,'link:')) && preg_match('/<([^>].*)>.*rel\=[\'\"]lrdd[\'\"]/',$line,$matches)) {
+                               $pagelink = $matches[1];
+                               break;
+                       }
+                       // don't try and run feeds through the html5 parser
+                       if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
+                               return array();
+                       if(stristr($html,'<rss') || stristr($html,'<feed'))
+                               return array();
+               }
        }
+
+       if(isset($pagelink))
+               return(fetch_xrd_links($pagelink));
+
+       // If we haven't found any links, return the host xrd links (which we have already fetched)
+
+       if(isset($links))
+               return $links;
+
        return array();
+
 }}
 
 
@@ -1956,7 +2060,7 @@ function aes_encrypt($val,$ky)
 
 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);
        return($s);
 }}
 
@@ -2453,7 +2557,7 @@ 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') . '"><img src="' . $a->get_baseurl() . '/images/remote-link.gif" alt="' . t('link to source') . '" /></a></div>' : '');
+                       . $item['plink'] . '" title="' . t('link to source') . '" target="external-link" ><img src="' . $a->get_baseurl() . '/images/remote-link.gif" alt="' . t('link to source') . '" /></a></div>' : '');
        return $plink;
 }}
 
diff --git a/include/EmailNotification.php b/include/EmailNotification.php
new file mode 100644 (file)
index 0000000..209d547
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+class EmailNotification {
+       /**
+        * Send a multipart/alternative message with Text and HTML versions
+        *
+        * @param fromName                      name of the sender
+        * @param fromEmail                     email fo the sender
+        * @param replyTo                       replyTo address to direct responses
+        * @param toEmail                       destination email address
+        * @param messageSubject        subject of the message
+        * @param htmlVersion           html version of the message
+        * @param textVersion           text only version of the message
+        */
+       static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
+               logger("sendTextHtmlEmail: BEGIN");
+               logger("fromName:       " . $fromName);
+               logger("fromEmail:      " . $fromEmail);
+               logger("replyTo:        " . $replyTo);
+               logger("toEmail:        " . $toEmail);
+               logger("messageSubject: " . $messageSubject);
+               //logger("htmlVersion:    " . $htmlVersion);
+               //logger("textVersion:    " . $textVersion);
+               
+               // generate a mime boundary
+               $mimeBoundary   =rand(0,9)."-"
+                               .rand(10000000000,9999999999)."-"
+                               .rand(10000000000,9999999999)."=:"
+                               .rand(10000,99999);
+
+               // generate a multipart/alternative message header
+               $messageHeader =
+                       "From: {$fromName} <{$fromEmail}>\n" . 
+                       "Reply-To: {$replyTo}\n" .
+                       "MIME-Version: 1.0\n" .
+                       "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
+
+               // assemble the final multipart message body with the text and html types included
+               $textBody       =       chunk_split(base64_encode($textVersion));
+               $htmlBody       =       chunk_split(base64_encode($htmlVersion));
+               $multipartMessageBody =
+                       "--" . $mimeBoundary . "\n" .                                   // plain text section
+                       "Content-Type: text/plain; charset=UTF-8\n" .
+                       "Content-Transfer-Encoding: base64\n\n" .
+                       $textBody . "\n" .
+                       "--" . $mimeBoundary . "\n" .                                   // text/html section
+                       "Content-Type: text/html; charset=UTF-8\n" .
+                       "Content-Transfer-Encoding: base64\n\n" .
+                       $htmlBody . "\n" .
+                       "--" . $mimeBoundary . "--\n";                                  // message ending
+
+               // send the message
+               $res = mail(
+                       $toEmail,                                                                               // send to address
+                       $messageSubject,                                                                // subject
+                       $multipartMessageBody,                                                  // message body
+                       $messageHeader                                                                  // message headers
+               );
+               logger("sendTextHtmlEmail: END");
+       }
+}
+?>
\ No newline at end of file
index c55ebab00c152c09361c3d763998adbfe5cd41e9..978b4af692bdafd87c0d8337afc8d33743a0e3da 100644 (file)
@@ -22,7 +22,7 @@ function bbcode($Text) {
        // 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\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]+)/", ' <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);
index abd097e54a07bcfd7442377823039f264b52e8b4..824f2dfdfcce3843880a2e5a83ee3bc5dfd46a28 100644 (file)
                prev = 'live-' + src;
 
                in_progress = true;
-               $.get('update_' + src + '?p=' + profile_uid + '&msie=' + ((msie) ? 1 : 0),function(data) {
+               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;
                        $('.wall-item-outside-wrapper',data).each(function() {
                                var ident = $(this).attr('id');
                                        if(timer) clearTimeout(timer);
                                        timer = setTimeout(NavUpdate,10);
                                }
+                               if(data.reload) {
+                                       window.location.href=data.reload;
+                               }
+                                       
                        },
                        "json"  
          );  
index 94a71d227a474e1e4eb91d7cd1079298b2648996..228774d95851b06dbd104bb621ea3a21e36a5063 100644 (file)
                $a->page['nav'] .= '<a id="nav-register-link" class="nav-commlink" href="register" >' 
                        . t('Register') . "</a>\r\n";
 
+       if(strlen($a->apps)) {
+               $a->page['nav'] .= '<a id="nav-apps-link" class="nav-link" href="apps">' . t('Apps') . "</a>\r\n";
+       }
+
        $a->page['nav'] .= '<a id="nav-search-link" class="nav-link" href="search">' . t('Search') . "</a>\r\n";
        $a->page['nav'] .= '<a id="nav-directory-link" class="nav-link" href="directory">' . t('Directory') . "</a>\r\n";
 
index 661676bfd83d766b9ffb0ab1357cd2934392fa60..55edd072e4d9512e937178257f500b7ac1d99968 100644 (file)
--- a/index.php
+++ b/index.php
@@ -113,6 +113,13 @@ else
        check_config($a);
 
 
+$arr = array('app_menu' => $a->apps);
+
+call_hooks('app_menu', $arr);
+
+$a->apps = $arr['app_menu'];
+
+
 /**
  *
  * We have already parsed the server path into $->argc and $a->argv
@@ -132,10 +139,9 @@ else
  * further processing.
  */
 
-
 if(strlen($a->module)) {
        if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
-               include("addon/{$a->module}/{$a->module}.php");
+               include_once("addon/{$a->module}/{$a->module}.php");
                if(function_exists($a->module . '_module'))
                        $a->module_loaded = true;
        }
@@ -155,6 +161,8 @@ if(strlen($a->module)) {
        }
 }
 
+
+
 /* initialise content region */
 
 if(! x($a->page,'content'))
diff --git a/mod/apps.php b/mod/apps.php
new file mode 100644 (file)
index 0000000..1d08d2e
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+
+function apps_content(&$a) {
+
+       $o .= '<h3>' . t('Applications') . '</h3>';
+
+       if($a->apps)
+               $o .= $a->apps;
+
+
+       return $o;
+
+}
\ No newline at end of file
index b8d86ad249081c29fa4f7b3af82234c7a4c1923a..cd7b0cff018ad92265b323f9b8c3f845c53318c1 100644 (file)
@@ -173,22 +173,10 @@ function dfrn_notify_post(&$a) {
                require_once('bbcode.php');
                if($importer['notify-flags'] & NOTIFY_MAIL) {
 
-                       // generate a mime boundary
-                       $msg['mimeboundary']   =rand(0,9)."-"
-                               .rand(10000000000,9999999999)."-"
-                               .rand(10000000000,9999999999)."=:"
-                               .rand(10000,99999);
-
                        // name of the automated email sender
                        $msg['notificationfromname']    = t('Administrator');
                        // noreply address to send from
                        $msg['notificationfromemail']   = t('noreply') . '@' . $a->get_hostname();                              
-                       // message headers
-                       $msg['headers'] =
-                               "From: {$msg['notificationfromname']} <{$msg['notificationfromemail']}>\n" . 
-                               "Reply-To: {$msg['notificationfromemail']}\n" .
-                               "MIME-Version: 1.0\n" .
-                               "Content-Type: multipart/alternative; boundary=\"{$msg['mimeboundary']}\"";
 
                        // text version
                        // process the message body to display properly in text mode
@@ -208,7 +196,7 @@ function dfrn_notify_post(&$a) {
                        //              4) decode any encoded html tags
                        $msg['htmlversion']     
                                = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$msg['body']))));
-                       
+
                        // load the template for private message notifications
                        $tpl = load_view_file('view/mail_received_html_body_eml.tpl');
                        $email_html_body_tpl = replace_macros($tpl,array(
@@ -238,32 +226,17 @@ function dfrn_notify_post(&$a) {
                                '$mimeboundary' => $msg['mimeboundary'],                                // mime message divider
                                '$hostname'             => $a->get_hostname()                                   // name of this host
                        ));
-                       
-                       // load the template for private message notifications
-                       $tpl = load_view_file('view/mail_received_eml.tpl');
-                       
-                       // import the data into the template                    
-                       $email_tpl = replace_macros($tpl, array(
-                               '$siteurl'              => $a->get_baseurl(),                                   // descriptive url of this site
-                               '$email'                => $importer['email'],                                  // email address to send to
-                               '$from'                 => $msg['from-name'],                                   // name of the person sending the message
-                               '$title'                => stripslashes($msg['title']),                 // subject of the message
-                               '$mimeboundary' => $msg['mimeboundary'],                                // mime message divider
-                               '$hostname'             => $a->get_hostname(),                                  // name of this host
-                               '$htmlbody'             => chunk_split(base64_encode($email_html_body_tpl)),
-                               '$textbody'             => chunk_split(base64_encode($email_text_body_tpl))
-                       ));
-                       
-                       logger("message headers: " . $msg['headers']);
-                       logger("message body: " . $mail_tpl);
-                       
-                       
-                       // send the message
-                       $res = mail(
-                               $importer['email'],                                                                     // send to address
-                               t('New mail received at ') . $a->config['sitename'],    // subject
-                               $email_tpl,                                                                                     // message body
-                               $msg['headers']                                                                                 // message headers
+
+                       // use the EmailNotification library to send the message
+                       require_once("include/EmailNotification.php");
+                       EmailNotification::sendTextHtmlEmail(
+                               $msg['notificationfromname'],
+                               $msg['notificationfromemail'],
+                               $msg['notificationfromemail'],
+                               $importer['email'],
+                               t('New mail received at ') . $a->config['sitename'],
+                               $email_html_body_tpl,
+                               $email_text_body_tpl
                        );
                }
                xml_status(0);
@@ -411,7 +384,7 @@ function dfrn_notify_post(&$a) {
                                                                '$email' => $importer['email'],
                                                                '$display' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id, 
                                                                '$from' => $from,
-                                                               '$body' => strip_tags(bbcode(stripslashes($datarray['body'])))
+                                                               '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8')
                                                        ));
        
                                                        $res = mail($importer['email'], $from . t(' commented on an item at ') . $a->config['sitename'],
@@ -477,7 +450,7 @@ function dfrn_notify_post(&$a) {
                                                                '$email' => $importer['email'],
                                                                '$from' => $from,
                                                                '$display' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $r,
-                                                               '$body' => strip_tags(bbcode(stripslashes($datarray['body'])))
+                                                               '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8')
                                                        ));
 
                                                        $res = mail($importer['email'], $from . t(" commented on an item at ") 
index 03003f3c0ca44c4fdd3008e21c2970c663b8ec94..bdf6a6f974f4a19c0f99645c14d00ccdda14a4e5 100644 (file)
@@ -153,7 +153,8 @@ function display_content(&$a) {
                                }
                                if($item['last-child']) {
                                        $comment = replace_macros($cmnt_tpl,array(
-                                               '$return_path' => '', // $_SESSION['return_url'],
+                                               '$return_path' => '', 
+                                               '$jsreload' => $_SESSION['return_url'],
                                                '$type' => 'wall-comment',
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
index cbdd11eb976eecf590eeee067db7a527f7cdc158..8c6b181c0d557dfdbd4631e45fb09359d0375877 100644 (file)
@@ -496,10 +496,17 @@ function item_post(&$a) {
                }
        }
 
-       if((x($_POST,'return')) && strlen($_POST['return']))
+       logger('post_complete');
+       if((x($_POST,'return')) && strlen($_POST['return'])) {
+               logger('return: ' . $_POST['return']);
                goaway($a->get_baseurl() . "/" . $_POST['return'] );
-
+       }
        $json = array('success' => 1);
+       if(x($_POST,'jsreload') && strlen($_POST['jsreload']))
+               $json['reload'] = $a->get_baseurl() . '/' . $_POST['jsreload'];
+
+       logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
+
        echo json_encode($json);
        killme();
        // NOTREACHED
index 3658c601e32f6f712d5eb6e8088ed407d524a5dc..79a2f2b3896c6490acc789abc7b705b197ff3e7d 100644 (file)
@@ -39,22 +39,22 @@ function network_content(&$a, $update = 0) {
        $group = 0;
 
        $nouveau = false;
+       require_once('include/acl_selectors.php');
 
-       if(! $update) {
-               $o .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>';
+       if(($a->argc > 2) && $a->argv[2] === 'new')
+               $nouveau = true;
 
-               if(($a->argc > 2) && $a->argv[2] === 'new')
+       if($a->argc > 1) {
+               if($a->argv[1] === 'new')
                        $nouveau = true;
-
-                       // pull out the group here because the updater might have different args
-               if($a->argc > 1) {
-                       if($a->argv[1] === 'new')
-                               $nouveau = true;
-                       else {
-                               $group = intval($a->argv[1]);
-                               $group_acl = array('allow_gid' => '<' . $group . '>');
-                       }
+               else {
+                       $group = intval($a->argv[1]);
+                       $group_acl = array('allow_gid' => '<' . $group . '>');
                }
+       }
+
+       if(! $update) {
+               $o .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>';
 
                $_SESSION['return_url'] = $a->cmd;
 
@@ -68,7 +68,6 @@ function network_content(&$a, $update = 0) {
                        '$nickname' => $a->user['nickname']
                ));
 
-               require_once('include/acl_selectors.php');
 
                $tpl = load_view_file("view/jot.tpl");
                
@@ -106,10 +105,10 @@ function network_content(&$a, $update = 0) {
                // filtering by group and also you aren't writing a comment (the last
                // criteria is discovered in javascript).
 
-               if($a->pager['start'] == 0 && $a->argc == 1) {
                        $o .= '<div id="live-network"></div>' . "\r\n";
-                       $o .= "<script> var profile_uid = " . $_SESSION['uid'] . "; </script>\r\n";
-               }
+                       $o .= "<script> var profile_uid = " . $_SESSION['uid'] 
+                               . "; var netargs = '" . substr($a->cmd,8) 
+                               . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
 
        }
 
@@ -134,6 +133,8 @@ function network_content(&$a, $update = 0) {
                        intval($_SESSION['uid'])
                );
                if(! count($r)) {
+                       if($update)
+                               killme();
                        notice( t('No such group') . EOL );
                        goaway($a->get_baseurl() . '/network');
                        return; // NOTREACHED
@@ -340,7 +341,8 @@ function network_content(&$a, $update = 0) {
 
                        if($item['last-child']) {
                                $comment = replace_macros($cmnt_tpl,array(
-                                       '$return_path' => '', // $_SESSION['return_url'],
+                                       '$return_path' => '', 
+                                       '$jsreload' => '', // $_SESSION['return_url'],
                                        '$type' => 'net-comment',
                                        '$id' => $item['item_id'],
                                        '$parent' => $item['parent'],
index ebfe714a78dc0ebd0b3e496e6a28a0e955bb265d..d4835ba5ea65edb515a35087c08483f8ac3419e9 100644 (file)
@@ -1049,7 +1049,8 @@ function photos_content(&$a) {
                                if($can_post || can_write_wall($a,$owner_uid)) {
                                        if($link_item['last-child']) {
                                                $o .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => '', // $return_url,
+                                                       '$return_path' => '', 
+                                                       '$jsreload' => $return_url,
                                                        '$type' => 'wall-comment',
                                                        '$id' => $link_item['id'],
                                                        '$parent' => $link_item['id'],
@@ -1088,7 +1089,8 @@ function photos_content(&$a) {
                                if($can_post || can_write_wall($a,$owner_uid)) {
                                        if($link_item['last-child']) {
                                                $o .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => $return_url,
+                                                       '$return_path' => '',
+                                                       '$jsreload' => $return_url,
                                                        '$type' => 'wall-comment',
                                                        '$id' => $link_item['id'],
                                                        '$parent' => $link_item['id'],
@@ -1116,7 +1118,8 @@ function photos_content(&$a) {
 
                                                if($item['last-child']) {
                                                        $comment = replace_macros($cmnt_tpl,array(
-                                                               '$return_path' => $return_url,
+                                                               '$return_path' => '',
+                                                               '$jsreload' => $return_url,
                                                                '$type' => 'wall-comment',
                                                                '$id' => $item['item_id'],
                                                                '$parent' => $item['parent'],
index 0723d64fb85c09ce90a3031fcf52542315ccaf73..46d13298e004e6eb22c35f1401be1f6c41f4437d 100644 (file)
@@ -82,7 +82,6 @@ function profile_content(&$a, $update = 0) {
 
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
        
-
        if(! $update) {
                if(x($_GET,'tab'))
                        $tab = notags(trim($_GET['tab']));
@@ -161,11 +160,11 @@ function profile_content(&$a, $update = 0) {
                // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
                // because browser prefetching might change it on us. We have to deliver it with the page.
 
-               if($tab === 'posts' && (! $a->pager['start'])) {
+               if($tab === 'posts') {
                        $o .= '<div id="live-profile"></div>' . "\r\n";
-                       $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] . "; </script>\r\n";
+                       $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] 
+                               . "; var netargs = ''; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                }
-
        }
 
        // Construct permissions
@@ -293,7 +292,8 @@ function profile_content(&$a, $update = 0) {
                                }
                                if($item['last-child']) {
                                        $comment = replace_macros($cmnt_tpl,array(
-                                               '$return_path' => '', // $_SESSION['return_url'],
+                                               '$return_path' => '', 
+                                               '$jsreload' => '', // $_SESSION['return_url'],
                                                '$type' => 'wall-comment',
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
index 35e968dba994a61aaf50ffec1ba37d959d710f24..cf9f11f586f734d4967a12fbd2c094ac5e39549c 100644 (file)
@@ -3,7 +3,7 @@
 // See update_profile.php for documentation
 
 require_once('mod/network.php');
-
+require_once('include/group.php');
 
 function update_network_content(&$a) {
 
index 885d735eda1b473134dcb780df77e50466cda687..dabbd6e87bc4c6b7f64acd58dd2ab889b6443be0 100644 (file)
@@ -4,6 +4,7 @@
                                <input type="hidden" name="profile_uid" value="$profile_uid" />
                                <input type="hidden" name="parent" value="$parent" />
                                <input type="hidden" name="return" value="$return_path" />
+                               <input type="hidden" name="jsreload" value="$jsreload" />
 
                                <div class="comment-edit-photo" id="comment-edit-photo-$id" >
                                        <a class="comment-edit-photo-link" href="$mylink" title="$mytitle"><img class="my-comment-photo" src="$myphoto" alt="$mytitle" title="$mytitle" /></a>
diff --git a/view/de/mail_received_eml.tpl b/view/de/mail_received_eml.tpl
deleted file mode 100644 (file)
index 6ddd586..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
---$mimeboundary
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$textbody
-
---$mimeboundary
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$htmlbody
-                               
---$mimeboundary--
\ No newline at end of file
diff --git a/view/en/mail_received_eml.tpl b/view/en/mail_received_eml.tpl
deleted file mode 100644 (file)
index 99eb143..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
---$mimeboundary
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$textbody
-
---$mimeboundary
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$htmlbody
-                               
---$mimeboundary--
-
diff --git a/view/fr/mail_received_eml.tpl b/view/fr/mail_received_eml.tpl
deleted file mode 100644 (file)
index 6ddd586..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
---$mimeboundary
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$textbody
-
---$mimeboundary
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$htmlbody
-                               
---$mimeboundary--
\ No newline at end of file
diff --git a/view/it/mail_received_eml.tpl b/view/it/mail_received_eml.tpl
deleted file mode 100644 (file)
index 538d28e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
---$mimeboundary
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$textbody
-
---$mimeboundary
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: base64
-
-$htmlbody
-                               
---$mimeboundary--