aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addon/calc/calc.php356
-rw-r--r--addon/facebook/facebook.php14
-rw-r--r--addon/tictac/tictac.php659
-rw-r--r--boot.php164
-rw-r--r--include/EmailNotification.php61
-rw-r--r--include/bbcode.php2
-rw-r--r--include/main.js9
-rw-r--r--include/nav.php4
-rw-r--r--index.php12
-rw-r--r--mod/apps.php14
-rw-r--r--mod/dfrn_notify.php55
-rw-r--r--mod/display.php3
-rw-r--r--mod/item.php11
-rw-r--r--mod/network.php36
-rw-r--r--mod/photos.php9
-rw-r--r--mod/profile.php10
-rw-r--r--mod/update_network.php2
-rw-r--r--view/comment_item.tpl1
-rw-r--r--view/de/mail_received_eml.tpl13
-rw-r--r--view/en/mail_received_eml.tpl14
-rw-r--r--view/fr/mail_received_eml.tpl13
-rw-r--r--view/it/mail_received_eml.tpl13
22 files changed, 1316 insertions, 159 deletions
diff --git a/addon/calc/calc.php b/addon/calc/calc.php
new file mode 100644
index 000000000..fd6a11777
--- /dev/null
+++ b/addon/calc/calc.php
@@ -0,0 +1,356 @@
+<?php
+
+function calc_install() {
+ register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+}
+
+function calc_uninstall() {
+ unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+
+}
+
+function calc_app_menu($a,&$b) {
+ $b['app_menu'] .= '<a href="calc">Calculator</a><br />';
+}
+
+
+function calc_module() {}
+
+
+
+
+function calc_init($a) {
+
+$x = <<< EOT
+
+<script language="JavaScript">
+/**************************************
+ * www.FemaleNerd.com *
+ **************************************/
+
+// Declare global variables
+var displayText = ""
+var num1
+var num2
+var operatorType
+
+// Write to display
+function addDisplay(n){
+ id = document.getElementById("display");
+id.value = ""
+displayText += n
+id.value = displayText
+}
+
+// Addition
+function addNumbers() {
+if (displayText == "") {
+ displayText = result
+ }
+num1 = parseFloat(displayText)
+operatorType = "add"
+displayText = ""
+}
+
+// Subtraction
+function subtractNumbers() {
+if (displayText == "") {
+ displayText = result
+ }
+num1 = parseFloat(displayText)
+operatorType = "subtract"
+displayText = ""
+}
+
+// Multiplication
+function multiplyNumbers() {
+if (displayText == "") {
+ displayText = result
+ }
+num1 = parseFloat(displayText)
+operatorType = "multiply"
+displayText = ""
+}
+
+// Division
+function divideNumbers() {
+if (displayText == "") {
+ displayText = result
+ }
+num1 = parseFloat(displayText)
+operatorType = "divide"
+displayText = ""
+}
+
+// Sine
+function sin() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = Math.sin(num1)
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Cosine
+function cos() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = Math.cos(num1)
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// ArcSine
+function arcSin() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = Math.asin(num1)
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// ArcCosine
+function arcCos() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = Math.acos(num1)
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Square root
+function sqrt() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = Math.sqrt(num1)
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Square number (number to the power of two)
+function square() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = num1 * num1
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Convert degrees to radians
+function degToRad() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = num1 * Math.PI / 180
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Convert radians to degrees
+function radToDeg() {
+ id = document.getElementById("display");
+if (displayText == "") {
+ num1 = result
+ }
+else {
+ num1 = parseFloat(displayText)
+ }
+if (num1 != "") {
+ result = num1 * 180 / Math.PI
+ id.value = result
+ displayText = ""
+ }
+else {
+ alert("Please write the number first")
+ }
+}
+
+// Calculations
+function calculate() {
+ id = document.getElementById("display");
+
+if (displayText != "") {
+ num2 = parseFloat(displayText)
+// Calc: Addition
+ if (operatorType == "add") {
+ result = num1 + num2
+ id.value = result
+ }
+// Calc: Subtraction
+ if (operatorType == "subtract") {
+ result = num1 - num2
+ id.value = result
+ }
+// Calc: Multiplication
+ if (operatorType == "multiply") {
+ result = num1 * num2
+ id.value = result
+ }
+// Calc: Division
+ if (operatorType == "divide") {
+ result = num1 / num2
+ id.value = result
+ }
+ displayText = ""
+ }
+ else {
+ id.value = "Oops! Error!"
+ }
+}
+
+// Clear the display
+function clearDisplay() {
+ id = document.getElementById("display");
+
+displayText = ""
+id.value = ""
+}
+</script>
+
+EOT;
+$a->page['htmlhead'] .= $x;
+}
+
+function calc_content($app) {
+
+$o = '';
+
+$o .= <<< EOT
+
+<h3>Calculator</h3>
+<br /><br />
+<table>
+<tbody><tr><td>
+<table bgcolor="#af9999" border="1">
+<tbody><tr><td>
+<table border="1" cellpadding="2" cellspacing="2">
+<form name="calc">
+<!--
+<TR><TD VALIGN=top colspan=6 ALIGN="center"> <H2>Calculator</H2> </TD>
+-->
+<tbody><tr>
+ <td colspan="5"><input size="22" id="display" name="display" type="text"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="one" value="&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;" onclick="addDisplay(1)" type="button"></td>
+ <td><input name="two" value="&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;" onclick="addDisplay(2)" type="button"></td>
+ <td><input name="three" value="&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;" onclick="addDisplay(3)" type="button"></td>
+ <td><input name="plus" value="&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;" onclick="addNumbers()" type="button"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="four" value="&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;" onclick="addDisplay(4)" type="button"></td>
+ <td><input name="five" value="&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;" onclick="addDisplay(5)" type="button"></td>
+ <td><input name="six" value="&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;" onclick="addDisplay(6)" type="button"></td>
+ <td><input name="minus" value="&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;" onclick="subtractNumbers()" type="button"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="seven" value="&nbsp;&nbsp;7&nbsp;&nbsp;&nbsp;" onclick="addDisplay(7)" type="button"></td>
+ <td><input name="eight" value="&nbsp;&nbsp;8&nbsp;&nbsp;&nbsp;" onclick="addDisplay(8)" type="button"></td>
+ <td><input name="nine" value="&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;" onclick="addDisplay(9)" type="button"></td>
+ <td><input name="multiplication" value="&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;" onclick="multiplyNumbers()" type="button"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="zero" value="&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;" onclick="addDisplay(0)" type="button"></td>
+ <td><input name="pi" value="&nbsp;Pi&nbsp;&nbsp;" onclick="addDisplay(Math.PI)" type="button"> </td>
+ <td><input name="dot" value="&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;" onclick='addDisplay(".")' type="button"></td>
+ <td><input name="division" value="&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;" onclick="divideNumbers()" type="button"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="sqareroot" value="sqrt" onclick="sqrt()" type="button"></td>
+ <td><input name="squarex" value=" x^2" onclick="square()" type="button"></td>
+ <td><input name="deg-rad" value="d2r&nbsp;" onclick="degToRad()" type="button"></td>
+ <td><input name="rad-deg" value="r2d&nbsp;" onclick="radToDeg()" type="button"></td>
+</tr><tr align="left" valign="middle">
+ <td><input name="sine" value="&nbsp;sin&nbsp;" onclick="sin()" type="button"></td>
+ <td><input name="arcsine" value="asin" onclick="arcSin()" type="button"></td>
+ <td><input name="cosine" value="cos" onclick="cos()" type="button"></td>
+ <td><input name="arccosine" value="acs" onclick="arcCos()" type="button"></td>
+
+</tr><tr align="left" valign="middle">
+ <td colspan="2"><input name="clear" value="&nbsp;&nbsp;Clear&nbsp;&nbsp;" onclick="clearDisplay()" type="button"></td>
+ <td colspan="3"><input name="enter" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" onclick="calculate()" type="button"></td>
+
+</tr></tbody></table>
+</form>
+
+ <!--
+ <TD VALIGN=top>
+ <B>NOTE:</B> All sine and cosine calculations are
+ <br>done in radians. Remember to convert first
+ <br>if using degrees.
+ </TD>
+ -->
+
+</td></tr></tbody></table>
+
+
+</td></tr></tbody></table>
+
+EOT;
+return $o;
+
+}
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php
index 119ee2f3e..c2c5a8876 100644
--- a/addon/facebook/facebook.php
+++ b/addon/facebook/facebook.php
@@ -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
index 000000000..95678302c
--- /dev/null
+++ b/addon/tictac/tictac.php
@@ -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;
+
+ }
+
+
+}
+
diff --git a/boot.php b/boot.php
index 322a4e307..d8abf06b0 100644
--- 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
index 000000000..209d5476a
--- /dev/null
+++ b/include/EmailNotification.php
@@ -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
diff --git a/include/bbcode.php b/include/bbcode.php
index c55ebab00..978b4af69 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -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);
diff --git a/include/main.js b/include/main.js
index abd097e54..824f2dfdf 100644
--- a/include/main.js
+++ b/include/main.js
@@ -108,7 +108,10 @@
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');
@@ -225,6 +228,10 @@
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
}
+ if(data.reload) {
+ window.location.href=data.reload;
+ }
+
},
"json"
);
diff --git a/include/nav.php b/include/nav.php
index 94a71d227..228774d95 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -56,6 +56,10 @@
$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";
diff --git a/index.php b/index.php
index 661676bfd..55edd072e 100644
--- 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
index 000000000..1d08d2e7f
--- /dev/null
+++ b/mod/apps.php
@@ -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
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index b8d86ad24..cd7b0cff0 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -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 ")
diff --git a/mod/display.php b/mod/display.php
index 03003f3c0..bdf6a6f97 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -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'],
diff --git a/mod/item.php b/mod/item.php
index cbdd11eb9..8c6b181c0 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -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
diff --git a/mod/network.php b/mod/network.php
index 3658c601e..79a2f2b38 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -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'],
diff --git a/mod/photos.php b/mod/photos.php
index ebfe714a7..d4835ba5e 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -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'],
diff --git a/mod/profile.php b/mod/profile.php
index 0723d64fb..46d13298e 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -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'],
diff --git a/mod/update_network.php b/mod/update_network.php
index 35e968dba..cf9f11f58 100644
--- a/mod/update_network.php
+++ b/mod/update_network.php
@@ -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) {
diff --git a/view/comment_item.tpl b/view/comment_item.tpl
index 885d735ed..dabbd6e87 100644
--- a/view/comment_item.tpl
+++ b/view/comment_item.tpl
@@ -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
index 6ddd586fc..000000000
--- a/view/de/mail_received_eml.tpl
+++ /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
index 99eb14391..000000000
--- a/view/en/mail_received_eml.tpl
+++ /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
index 6ddd586fc..000000000
--- a/view/fr/mail_received_eml.tpl
+++ /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
index 538d28e1e..000000000
--- a/view/it/mail_received_eml.tpl
+++ /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--