1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00
This commit is contained in:
Andrew Manning 2016-01-11 20:50:17 -05:00
commit b73d5bd454
1389 changed files with 143257 additions and 59 deletions

View file

@ -1,4 +1,4 @@
location YNH_WWW_PATH / {
location YNH_WWW_PATH {
# Path to source
alias YNH_WWW_ALIAS/ ;

View file

@ -1 +0,0 @@
../extend/addon/official/adultphotoflag

View file

@ -1 +0,0 @@
../extend/addon/official/bbmath

View file

@ -1 +0,0 @@
../extend/addon/official/bookmarker

View file

@ -1 +0,0 @@
../extend/addon/official/buglink

View file

@ -1 +0,0 @@
../extend/addon/official/calc

View file

@ -1 +0,0 @@
../extend/addon/official/chords

View file

@ -1 +0,0 @@
../extend/addon/official/custom_home

View file

@ -1 +0,0 @@
../extend/addon/official/diaspora

View file

@ -1 +0,0 @@
../extend/addon/official/diaspost

View file

@ -1 +0,0 @@
../extend/addon/official/dirstats

View file

@ -1 +0,0 @@
../extend/addon/official/donate

View file

@ -1 +0,0 @@
../extend/addon/official/dwpost

View file

@ -1 +0,0 @@
../extend/addon/official/embedly

View file

@ -1 +0,0 @@
../extend/addon/official/extcron

View file

@ -1 +0,0 @@
../extend/addon/official/flattrwidget

View file

@ -1 +0,0 @@
../extend/addon/official/fortunate

View file

@ -1 +0,0 @@
../extend/addon/official/frphotos

View file

@ -1 +0,0 @@
../extend/addon/official/hexit

View file

@ -1 +0,0 @@
../extend/addon/official/ijpost

View file

@ -1 +0,0 @@
../extend/addon/official/irc

View file

@ -1 +0,0 @@
../extend/addon/official/jappixmini

View file

@ -1 +0,0 @@
../extend/addon/official/js_upload

View file

@ -1 +0,0 @@
../extend/addon/official/ldapauth

View file

@ -1 +0,0 @@
../extend/addon/official/libertree

View file

@ -1 +0,0 @@
../extend/addon/official/likebanner

View file

@ -1 +0,0 @@
../extend/addon/official/ljpost

View file

@ -1 +0,0 @@
../extend/addon/official/mahjongg

View file

@ -1 +0,0 @@
../extend/addon/official/mailhost

View file

@ -1 +0,0 @@
../extend/addon/official/morechoice

View file

@ -1 +0,0 @@
../extend/addon/official/moremoods

View file

@ -1 +0,0 @@
../extend/addon/official/nofed

View file

@ -1 +0,0 @@
../extend/addon/official/nsabait

View file

@ -1 +0,0 @@
../extend/addon/official/nsfw

View file

@ -1 +0,0 @@
../extend/addon/official/openclipatar

View file

@ -1 +0,0 @@
../extend/addon/official/openstreetmap

View file

@ -1 +0,0 @@
../extend/addon/official/piwik

View file

@ -1 +0,0 @@
../extend/addon/official/planets

View file

@ -1 +0,0 @@
../extend/addon/official/pumpio

View file

@ -1 +0,0 @@
../extend/addon/official/qrator

View file

@ -1 +0,0 @@
../extend/addon/official/rainbowtag

View file

@ -1 +0,0 @@
../extend/addon/official/randpost

View file

@ -1 +0,0 @@
../extend/addon/official/redphotos

View file

@ -1 +0,0 @@
../extend/addon/official/redred

View file

@ -1 +0,0 @@
../extend/addon/official/rtof

View file

@ -1 +0,0 @@
../extend/addon/official/sendzid

View file

@ -1 +0,0 @@
../extend/addon/official/smiley_pack

View file

@ -1 +0,0 @@
../extend/addon/official/smileybutton

View file

@ -1 +0,0 @@
../extend/addon/official/startpage

View file

@ -1 +0,0 @@
../extend/addon/official/statistics_json

View file

@ -1 +0,0 @@
../extend/addon/official/statusnet

View file

@ -1 +0,0 @@
../extend/addon/official/superblock

View file

@ -1 +0,0 @@
../extend/addon/official/tictac

View file

@ -1 +0,0 @@
../extend/addon/official/torch

View file

@ -1 +0,0 @@
../extend/addon/official/tour

View file

@ -1 +0,0 @@
../extend/addon/official/twitter

View file

@ -1 +0,0 @@
../extend/addon/official/upload_limits

View file

@ -1 +0,0 @@
../extend/addon/official/visage

View file

@ -1 +0,0 @@
../extend/addon/official/wppost

24
sources/addons/.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
favicon.*
.htconfig.php
\#*
*.log
*.out
*.version*
favicon.*
*~
#ignore reports, should be generted with every build
report/
#ignore config files from eclipse, we don't want IDE files in our repository
.project
.buildpath
.externalToolBuilders
.settings
#ignore OSX .DS_Store files
.DS_Store
/nbproject/private/
#Kdevelop project files
*.kdev4

6
sources/addons/README.md Normal file
View file

@ -0,0 +1,6 @@
hubzilla-addons
================
These are addons for hubzilla sites (see https://github.com/redmatrix/hubzilla )

View file

@ -0,0 +1,28 @@
<?php
/**
* Name: Adult Photo Flag
* Description: Provides an optional feature to hide individual photos from the default album view
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*/
function adultphotoflag_load() {
register_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
}
function adultphotoflag_unload() {
unregister_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
}
function adultphotoflag_get_features(&$a,&$b) {
$b['tools'][] = array(
'adult_photo_flagging',
t('Flag Adult Photos'),
t('Provide photo edit option to hide inappropriate photos from default album view'),false);
}

View file

@ -0,0 +1,3 @@
Adds a new tag, [tex] that can be used in bbcode. Note that you still also have to use $...$ to get equations correct, i.e. [tex] doesn't eneter math-mode by default.
Requires images and tmp directory in your Red root directory (e.g. /var/www/red). Must be writable by server (e.g chown -R www-data tmp images). Also requires latex and imagemagick to be installed.

View file

@ -0,0 +1,22 @@
<?php
/**
*
* Name: bbmath
* Description: Display math
* Version: 0.0
* Author: Stefan Parviainen <pafcu@iki.fi>
*
*/
require_once('phplatex.php');
function bbmath_load() {
register_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
}
function bbmath_unload() {
unregister_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
}
function bbmath_bbcode($a,&$text) {
$text = preg_replace_callback('|\[tex\](.*?)\[/tex\]|',function($m) { return texify($m[1]); },$text);
}

View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View file

@ -0,0 +1,139 @@
<?php
# Written by scarfboy@gmail.com. Some modification by Stefan Parviainen.
# Use at your own risk.
# Licensed under the GPL, see gpl.txt.
#In case these are elsewhere
$path_to_latex = '/usr/bin/latex';
$path_to_dvips = '/usr/bin/dvips';
$path_to_convert = '/usr/bin/convert';
$imgfmt="png"; #literally used in extensions, and in parameters to convert. Should be either png or gif.
function phplatex_cleantmp($tempfname,$todir) {
#specifically removes the various files that probably got created for a specific run, based on the run's filename.
//global $imgfmt; // Global doesn't work for some reason
$imgfmt="png"; #literally used in extensions, and in parameters to convert. Should be either png or gif.
if (chdir($todir)===FALSE) { return '[directory access error, fix permissions (and empty tmp manually this time)]'; }
error_reporting(0); #at least one of these probably will not exist, but disable the error reporting related to that.
unlink($tempfname); #the longer/cleaner way would be check for existance for each
unlink($tempfname.".tex"); unlink($tempfname.".log");
unlink($tempfname.".aux"); unlink($tempfname.".dvi");
unlink($tempfname.".ps"); unlink($tempfname.".".$imgfmt);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
#try-catch would have been nice. This is rather overkill too, the way I use it.
return '';
}
function phplatex_colorhex($r,$g,$b) {
#there has to be a better way of doing this. It's not even particularly clean.
$hex=array("","","");
if(strlen($hex[0]=dechex(min(256*$r,255)))==1){ $hex[0]="0".$hex[0]; }
if(strlen($hex[1]=dechex(min(256*$g,255)))==1){ $hex[1]="0".$hex[1]; }
if(strlen($hex[2]=dechex(min(256*$b,255)))==1){ $hex[2]="0".$hex[2]; }
return implode("",$hex);
}
function texify($string,$dpi='90', $r=0.0,$g=0.0,$b=0.0, $br=1.0,$bg=1.0,$bb=1.0,$extraprelude="", $sharpen=FALSE) {
//global $imgfmt,$path_to_latex,$path_to_dvips,$path_to_convert;
// For some reason the globals don't work
$path_to_latex = '/usr/bin/latex';
$path_to_dvips = '/usr/bin/dvips';
$path_to_convert = '/usr/bin/convert';
$imgfmt="png"; #literally used in extensions, and in parameters to convert. Should be either png or gif.
if ($dpi>300) $dpi=300;
$back=phplatex_colorhex($br,$bg,$bb);
$fore=phplatex_colorhex($r,$g,$b);
# Figure out TeX, either to get the right cache entry or to, you know, compile
# Semi-common (ams) symbol packages are included.
$totex = "\\documentclass[14pt,landscape]{extarticle}\n".
"\\usepackage{color}\n".
"\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n".
$extraprelude."\n".
"\\pagestyle{empty}\n". #removes header/footer; necessary for trim
"\\begin{document}\n".
"\\color[rgb]{".$r.",".$g.",".$b."}\n".
"\\pagecolor[rgb]{".$br.",".$bg.",".$bb."}\n".
$string."\n".
"\\end{document}\n";
$strhash = sha1($totex).'.'.$dpi; #file cache entry string: 40-char hash string plus size
$stralt = str_replace("&","&amp;", preg_replace("/[\"\n]/","",$string)); #stuck in the alt and title attributes
#May need some extra safety.
$heredir=getcwd();
#Experiment: Tries to adjust vertical positioning, so that rendered TeX text looks natural enough inline with HTML text
#Only descenders are really a problem since HTML's leeway is upwards.
#TODO: This can always use more work.
# Avoid using characters that are part of TeX commands.
# Some things vary per font, e.g. the slash. In the default CM it is a descender, in Times and others it isn't.
$ascenders ="/(b|d|f|h|i|j|k|l|t|A|B|C|D|E|F|G|H|I|J|L|K|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|\[|\]|\\{|\\}|\(|\)|\/|0|1|2|3|4|5|6|7|8|9|\\#|\*|\?|'|\\\\'|\\\\`|\\\\v)/";
$monoliners="/(a|c|e|m|n|o|r|s|u|v|w|x|z|-|=|\+|:|.)/";
$descenders="/(g|j|p|\/|q|y|Q|,|;|\[|\]|\\{|\\}|\(|\)|\#|\\\\LaTeX|\\\\TeX|\\\\c\{)/";
$deepdescenders="/(\[|\]|\\{|\\}|\(|\)|\\int)/";
$ba = preg_match_all($ascenders, $string,$m);
$bm = preg_match_all($monoliners, $string,$m);
$bd = preg_match_all($descenders, $string,$m);
$dd = preg_match_all($deepdescenders, $string,$m);
if ($dd>0) $verticalalign="vertical-align: -25%"; # deep descenders: move down
else if ($bd>0 && $ba==0) $verticalalign="vertical-align: -15%"; # descenders: move down
else if ($bd==0 && $ba>0) $verticalalign="vertical-align: 0%"; # ascenders only: move up/do nothing?
else if ($bd==0 && $ba==0) $verticalalign="vertical-align: 0%"; # neither vertical-align: 0%
else $verticalalign="vertical-align: -15%"; # both ascender and regular descender
#check image cache, return link if exists
#the vertical-align is to fix text baseline/descender(/tail) details in and on-average sort of way
if (file_exists($heredir.'/images/'.$strhash.'.'.$imgfmt))
return '<img style="'.$verticalalign.'" title="'.$stralt.'" alt="'.$stralt.'" src="images/'.$strhash.'.'.$imgfmt.'">';
#chdir to have superfluous files be created in tmp. (you stiill have to empty this yourself)
error_reporting(0); # not checking existence myself, that would be double.
if (chdir("tmp")===FALSE) { return '[directory access error, fix permissions]'; } #I should chech whether file creation is allowed to give a nice error for that problem case
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); # TODO: set old value
$tfn = tempnam(getcwd(), 'PTX'); #file in tmp dir
#write temporary .tex file
if ( ($tex = fopen($tfn.'.tex', "w"))==FALSE) { return '[file access error] '.phplatex_cleantmp($tfn,$heredir); }
fwrite($tex, $totex);
fclose($tex);
#Run latex to create a .dvi. Have it try to fix minor errors instead of breaking/pausing on them.
exec($path_to_latex.' --interaction=nonstopmode '.$tfn.'.tex');
if (!file_exists($tfn.".dvi")) {
$log = file_get_contents($tfn.'.log'); #The log always exists, but now it's actually interesting since it'll contain an error
return '[latex error, code follows]<pre>'.$totex.'</pre><p><b>Log file:</b><pre>'.$log.'</pre></p> '.phplatex_cleantmp($tfn,$heredir);
}
#DVI -> PostScript. Since dvips uses lpr, which may be configured to actually print by default, force writing to a file with -o
exec($path_to_dvips.' '.$tfn.'.dvi -o '.$tfn.'.ps');
if ( !file_exists($tfn.'.ps')) {
return '[dvi2ps error] '.phplatex_cleantmp($tfn,$heredir);
}
#PostScript -> image. Trim based on corner pixel, and set transparent color.
exec($path_to_convert.' -transparent-color "#'.$back.'" -colorspace RGB -density '.$dpi.' -trim +page '.$tfn.'.ps -transparent "#'.$back.'" '.$tfn.'.'.$imgfmt);
#Note: +page OR -page +0+0 OR +repage moves the image to the cropped area (kills offset)
#Older code tried: exec('/usr/bin/mogrify -density 90 -trim +page -format $imgfmt '.$tfn.'.ps');
# It seems some versions of convert may not have -trim. Old versions?
if (!file_exists($tfn.'.'.$imgfmt)) {
return '[image convert error] '.phplatex_cleantmp($tfn,$heredir);
}
#Copy result image to chache.
copy($tfn.'.'.$imgfmt, $heredir.'/images/'.$strhash.'.'.$imgfmt);
#Clean up temporary files, and return link to just-created image
return phplatex_cleantmp($tfn,$heredir).'<img style="'.$verticalalign.'" title="'.$stralt.'" alt="LaTeX formula: '.$stralt.'" src="images/'.$strhash.'.'.$imgfmt.'">';
}
?>

View file

@ -0,0 +1,41 @@
<?php
/**
* Name: bookmarker
* Description: replace #^ with bookmark icon
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*
*/
function bookmarker_install() {
register_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body', 10);
}
function bookmarker_uninstall() {
unregister_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body');
}
function bookmarker_prepare_body(&$a,&$b) {
if(get_pconfig(local_channel(),'bookmarker','disable'))
return;
if(! strpos($b['html'],'bookmark-identifier'))
return;
if(! function_exists('redbasic_init'))
return;
$id = $b['item']['id'];
if(local_channel())
$link = '<a class="fakelink" onclick="itemBookmark(' . $id . '); return false;" title="' . t('Save Bookmarks') . '" href="#"><i class="icon-bookmark"></i></a> ';
else
$link = '<i class="icon-bookmark"></i></a> ';
$b['html'] = str_replace('<span class="bookmark-identifier">#^</span>',$link,$b['html']);
}

BIN
sources/addons/buglink/bug-x.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

View file

@ -0,0 +1,15 @@
<?php
/**
* Name: BugLink
* Description: Show link to Red bug site at bottom of page
* Version: 1.0
* Author: Mike Macgirvin <mike@macgirvin.com>
*/
function buglink_load() { register_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
function buglink_unload() { unregister_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
function buglink_active(&$a,&$b) { $b .= '<div style="position: fixed; bottom: 5px; left: 5px;" class="hidden-xs"><a href="https://github.com/redmatrix/hubzilla/issues" target="_blank" title="' . t('Report Bug') . '"><img src="addon/buglink/bug-x.gif" alt="' . t('Report Bug') . '" /></a></div>'; }

View file

@ -0,0 +1,22 @@
# ADDON buglink
# Copyright (C)
# This file is distributed under the same license as the Friendica buglink addon package.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-27 05:01-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: buglink.php:15
msgid "Report Bug"
msgstr ""

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Informar de problema";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Nahlásit chybu";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Fehlerreport erstellen";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Skribi cimraporton";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Informe de errores";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Signaler un bug";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Tilkynna bilun";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Segnala un Bug";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Zgłoś problem";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Relate um Bug";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "Сообщить об ошибке";

View file

@ -0,0 +1,2 @@
<?php

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Report Bug"] = "报案程序错误";

View file

@ -0,0 +1,3 @@
url: $baseurl/calc
name: Calculator
photo: $baseurl/addon/calc/calc.png

368
sources/addons/calc/calc.php Executable file
View file

@ -0,0 +1,368 @@
<?php
/**
* Name: Calculator App
* Description: Simple Calculator Application
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*/
function calc_load() {
register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
}
function calc_unload() {
unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
}
function calc_app_menu($a,&$b) {
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
}
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
<style>
td, th {
padding: 5px;
}
</style>
<h3>Calculator</h3>
<br /><br />
<table>
<tbody><tr><td>
<table style="background-color: #af9999;" border="1">
<tbody><tr><td>
<table border="1" style="padding: 2px;" 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

@ -0,0 +1,9 @@
Chord Generator
===============
Before enabling the plugin compile the chord generator binary.
g++ chord-generator.cpp -o chord
The example is for Linux. Compilation instructions may vary on Windows or other platforms.

BIN
sources/addons/chords/chord Executable file

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,3 @@
url: $baseurl/chords
name: Guitar Chords
photo: $baseurl/addon/chords/chords.png

129
sources/addons/chords/chords.php Executable file
View file

@ -0,0 +1,129 @@
<?php
/**
* Name: Chord Generator
* Description: Guitar Chord Generator Application
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*/
function chords_load() {
register_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
}
function chords_unload() {
unregister_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
}
function chords_app_menu($a,&$b) {
$b['app_menu'][] = '<div class="app-title"><a href="chords">Guitar Chords</a></div>';
}
function chords_module() {}
function chords_content($a) {
$o .= '<h3>Guitar Chords</h3>';
$o .= 'The complete online guitar chord dictionary<br />';
$args = '';
$l = '';
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['chord']) && strlen($_POST['chord']))
$args .= escapeshellarg(ucfirst(trim($_POST['chord'])));
if((strlen($args)) && (isset($_POST['tuning'])) && (strlen($_POST['tuning'])))
$args .= ' '.escapeshellarg($_POST['tuning']);
if((strlen($args)) && (isset($_POST['lefty'])))
$args .= ' lefty';
}
if((! strlen($args)) && (! stristr(basename($_SERVER['QUERY_STRING']),'chords')) && strlen(basename($_SERVER['QUERY_STRING'])))
$args = escapeshellarg(ucfirst(basename($_SERVER['QUERY_STRING'])));
$tunings = array("","openg", "opene", "dadgad");
$tnames = array("Em11 [Standard] (EADGBE)",
"G/D [Drop D] (DGDGBD)","Open E (EBEG#BE)","Dsus4 (DADGAD)");
$t = ((isset($_POST['tuning'])) ? $_POST['tuning'] : '');
if(isset($_POST['lefty']) && $_POST['lefty'] == '1')
$l = 'checked="checked"';
$ch = ((isset($_POST['chord'])) ? $_POST['chord'] : '');
$o .= <<< EOT
<form action="chords" method="post">
Chord name: (ex: Em7) <input type="text" name="chord" value="$ch" onfocus="this.select();" size="16" />
&nbsp;&nbsp;Tuning: <select name="tuning" size="5">
EOT;
for($x = 0; $x < count($tunings); $x ++) {
$o .= '<option value="'.$tunings[$x].'"'.
(($tunings[$x] == $t) ? 'selected="selected"' : '').
'>'.$tnames[$x].'</option>';
}
$o .= <<< EOT
</select>
Left-Handed: <input type="checkbox" name="lefty" value="1" $l />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<br /><br />
EOT;
if(strlen($args)) {
$o .= '<pre>';
$o .= shell_exec("addon/chords/chord ".$args);
$o .= '</pre>';
}
else {
$o .= <<< EOT
<p>
This is a fairly comprehensive and complete guitar chord dictionary which will list most of the available ways to play a certain chord, starting from the base of the fingerboard up to a few frets beyond the twelfth fret (beyond which everything repeats). A couple of non-standard tunings are provided for the benefit of slide players, etc.
<p />
<p>
Chord names start with a root note (A-G) and may include sharps (#) and flats (b). This software will parse most of the standard naming conventions such as maj, min, dim, sus(2 or 4), aug, with optional repeating elements.
</p>
<p>
Valid examples include A, A7, Am7, Amaj7, Amaj9, Ammaj7, Aadd4, Asus2Add4, E7b13b11 ...
</p>
Quick Reference:<br />
EOT;
$keys = array('A','Bb','B', 'C','Db','D','Eb','E','F','Gb','G','Ab');
$o .= '<table border="1">';
$o .= "<tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/$k\"> $k </a></td>";
$o .= "</tr><tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/{$k}m\"> {$k}m </a></td>";
$o .= "</tr><tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/{$k}7\"> {$k}7 </a></td>";
$o .= "</tr>";
$o .= "</table>";
}
return $o;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,12 @@
Configure a custom page to be used for a logged out user when viewing the home page.
util/config system custom_home landingpage
landingpage is a relative link.
EG, util/config system custom_home channel/me will send logged out users to example.com/channel/me
To set a random channel (replacing random_channel_home) use:
util/config system custom_home random

View file

@ -0,0 +1,40 @@
<?php
/**
* Name: Custom Home
* Description: Set a custom home page or display a random channel from this server on the home page.
* Version: 1.0
* Author: Thomas Willingham <zot:beardyunixer@beardyunixer.com>
*/
function custom_home_load() {
register_hook('home_mod_content', 'addon/custom_home/custom_home.php', 'custom_home_home');
logger("loaded custom_home");
}
function custom_home_unload() {
unregister_hook('home_mod_content', 'addon/custom_home/custom_home.php', 'custom_home_home');
unregister_hook('home_content', 'addon/custom_home/custom_home.php', 'custom_home_home');
logger("removed custom_home");
}
function custom_home_home(&$a, &$o){
$x = get_config('system','custom_home');
if($x) {
if ($x == "random") {
$rand = db_getfunc('rand');
$r = q("select channel_address from channel where channel_r_stream = 1 and channel_address != 'sys' order by $rand limit 1");
$x = z_root() . '/channel/' . $r[0]['channel_address'];
}
else {
$x = z_root() . '/' . $x;
}
goaway(zid($x));
}
//If nothing is set
return $o;
}

View file

@ -0,0 +1,30 @@
<?php
/**
* Name: Dfedfix
* Description: Fix Diaspora federation until the proper fix is deployed
* Version: 1.0
* Author: Mike Macgirvin
*/
function dfedfix_load() {
register_hook('personal_xrd', 'addon/dfedfix/dfedfix.php', 'dfedfix_personal_xrd');
}
function dfedfix_unload() {
unregister_hook('personal_xrd', 'addon/dfedfix/dfedfix.php', 'dfedfix_personal_xrd');
}
function dfedfix_personal_xrd(&$a,&$b) {
logger('dfedfix: ' . print_r($b,true));
$x = $b['xml'];
$x = str_replace('</Subject>','</Subject>
<Alias>' . z_root() . '/channel/' . $b['user']['channel_address'] . '</Alias>',$x);
$x = str_replace('.AQAB" />','.AQAB "/>
<Link rel="salmon" href="' . z_root() . '/receive/users/' . $b['user']['channel_guid'] . str_replace('.','',$a->get_hostname()) . '"/>',$x);
$b['xml'] = $x;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
<?php /** @file */
require_once('include/bb2diaspora.php');
// used in Diaspora communications to provide a server copy of a sent post in XML format.
function p_init(&$a) {
if(argc() < 2)
http_status_exit(401);
$mid = str_replace('.xml','',argv(1));
$r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1",
dbesc($mid)
);
if((! $r) || (! perm_is_allowed($r[0]['uid'],'','view_stream')))
http_status_exit(404);
$c = q("select * from channel where channel_id = %d limit 1",
intval($r[0]['uid'])
);
if(! $c)
http_status_exit(404);
$myaddr = $c[0]['channel_address'] . '@' . $a->get_hostname();
$item = $r[0];
$title = $item['title'];
$body = bb2diaspora_itembody($item);
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
$tpl = get_markup_template('diaspora_post.tpl');
$msg = replace_macros($tpl, array(
'$body' => xmlify($body),
'$guid' => $item['mid'],
'$handle' => xmlify($myaddr),
'$public' => 'true',
'$created' => $created,
'$provider' => (($item['app']) ? $item['app'] : t('$projectname'))
));
header('Content-type: text/xml');
echo $msg;
killme();
}

View file

@ -0,0 +1,75 @@
<?php
/**
* Diaspora endpoint
*/
require_once('include/crypto.php');
require_once('addon/diaspora/diaspora.php');
function receive_post(&$a) {
$public = false;
logger('diaspora_receive: ' . print_r($a->argv, true), LOGGER_DEBUG);
if((argc() == 2) && (argv(1) === 'public')) {
$public = true;
}
else {
if(argc() != 3 || argv(1) !== 'users')
http_status_exit(500);
$guid = argv(2);
$hn = str_replace('.','',$a->get_hostname());
if(($x = strpos($guid,$hn)) > 0)
$guid = substr($guid,0,$x);
// Diaspora sites *may* provide a truncated guid.
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND channel_removed = 0 LIMIT 1",
dbesc($guid . '%')
);
if(! $r)
http_status_exit(500);
$importer = $r[0];
}
// It is an application/x-www-form-urlencoded that has been urlencoded twice.
logger('mod-diaspora: receiving post', LOGGER_DEBUG);
$xml = urldecode($_POST['xml']);
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
if(! $xml)
http_status_exit(500);
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
$msg = diaspora_decode($importer,$xml);
logger('mod-diaspora: decoded', LOGGER_DEBUG);
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if(! is_array($msg))
http_status_exit(500);
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0;
if($public)
diaspora_dispatch_public($msg);
else
$ret = diaspora_dispatch($importer,$msg);
http_status_exit(($ret) ? $ret : 200);
// NOTREACHED
}

View file

@ -0,0 +1,107 @@
<?php
/**
* Ein fies zusammengehackter PHP-Diaspory-Client, der direkt von diesem abgeschaut ist:
* https://github.com/Javafant/diaspy/blob/master/client.py
*/
class Diasphp {
function __construct($pod) {
$this->token_regex = '/content="(.*?)" name="csrf-token/';
$this->pod = $pod;
$this->cookiejar = tempnam(sys_get_temp_dir(), 'cookies');
}
function _fetch_token() {
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/stream");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
$output = curl_exec ($ch);
curl_close($ch);
// Token holen und zurückgeben
preg_match($this->token_regex, $output, $matches);
return $matches[1];
}
function login($username, $password) {
$datatopost = array(
'user[username]' => $username,
'user[password]' => $password,
'authenticity_token' => $this->_fetch_token()
);
$poststr = http_build_query($datatopost);
// Adresse per cURL abrufen
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/users/sign_in");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $poststr);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_exec ($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if($info['http_code'] != 302) {
throw new Exception('Login error '.print_r($info, true));
}
// Das Objekt zurückgeben, damit man Aurufe verketten kann.
return $this;
}
function post($text, $provider = "diasphp") {
// post-daten vorbereiten
$datatopost = json_encode(array(
'aspect_ids' => 'public',
'status_message' => array('text' => $text,
'provider_display_name' => $provider)
));
// header vorbereiten
$headers = array(
'Content-Type: application/json',
'accept: application/json',
'x-csrf-token: '.$this->_fetch_token()
);
// Adresse per cURL abrufen
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/status_messages");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_exec ($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if($info['http_code'] != 201) {
throw new Exception('Post error '.print_r($info, true));
}
// Ende der möglichen Kette, gib mal "true" zurück.
return true;
}
}
?>

Some files were not shown because too many files have changed in this diff Show more