1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00

Added addons with subfolder. earlier:addons/addon-name.php, now:addon/subfolder/addon-name.php

This commit is contained in:
Anmol 2015-12-08 18:27:50 +05:30
parent e083418678
commit 9c7a6ebdbe
1330 changed files with 143256 additions and 0 deletions

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;
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

View file

View file

@ -0,0 +1,337 @@
<?php
/**
* Name: Diaspora Post Connector
* Description: Post to Diaspora
* Version: 0.1
* Author: Michael Vogel <heluecht@pirati.ca>
*/
function diaspost_load() {
register_hook('post_local', 'addon/diaspost/diaspost.php', 'diaspost_post_local');
register_hook('notifier_normal', 'addon/diaspost/diaspost.php', 'diaspost_send');
register_hook('jot_networks', 'addon/diaspost/diaspost.php', 'diaspost_jot_nets');
register_hook('feature_settings', 'addon/diaspost/diaspost.php', 'diaspost_settings');
register_hook('feature_settings_post', 'addon/diaspost/diaspost.php', 'diaspost_settings_post');
}
function diaspost_unload() {
unregister_hook('post_local', 'addon/diaspost/diaspost.php', 'diaspost_post_local');
unregister_hook('notifier_normal', 'addon/diaspost/diaspost.php', 'diaspost_send');
unregister_hook('jot_networks', 'addon/diaspost/diaspost.php', 'diaspost_jot_nets');
unregister_hook('feature_settings', 'addon/diaspost/diaspost.php', 'diaspost_settings');
unregister_hook('feature_settings_post', 'addon/diaspost/diaspost.php', 'diaspost_settings_post');
}
function diaspost_jot_nets(&$a,&$b) {
if((! local_channel()) || (! perm_is_allowed(local_channel(),'','view_stream')))
return;
$diaspost_post = get_pconfig(local_channel(),'diaspost','post');
if(intval($diaspost_post) == 1) {
$diaspost_defpost = get_pconfig(local_channel(),'diaspost','post_by_default');
$selected = ((intval($diaspost_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspost_enable"' . $selected . ' value="1" /> <img src="addon/diaspost/diaspora.png" /> ' . t('Post to Diaspora') . '</div>';
}
}
function diaspost_queue_hook(&$a,&$b) {
$hostname = $a->get_hostname();
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_DIASPORA2)
);
if(! count($qi))
return;
require_once('include/queue_fn.php');
foreach($qi as $x) {
if($x['network'] !== NETWORK_DIASPORA2)
continue;
logger('diaspost_queue: run');
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
if(! count($r))
continue;
$userdata = $r[0];
$diaspost_username = get_pconfig($userdata['uid'],'diaspost','diaspost_username');
$diaspost_password = z_unobscure(get_pconfig($userdata['uid'],'diaspost','diaspost_password'));
$diaspost_url = get_pconfig($userdata['uid'],'diaspost','diaspost_url');
$success = false;
if($diaspost_url && $diaspost_username && $diaspost_password) {
require_once("addon/diaspost/diasphp.php");
logger('diaspost_queue: able to post for user '.$diaspost_username);
$z = unserialize($x['content']);
$post = $z['post'];
logger('diaspost_queue: post: '.$post, LOGGER_DATA);
try {
logger('diaspost_queue: prepare', LOGGER_DEBUG);
$conn = new Diasphp($diaspost_url);
logger('diaspost_queue: try to log in '.$diaspost_username, LOGGER_DEBUG);
$conn->login($diaspost_username, $diaspost_password);
logger('diaspost_queue: try to send '.$body, LOGGER_DEBUG);
$conn->post($post, $hostname);
logger('diaspost_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG);
$success = true;
remove_queue_item($x['id']);
} catch (Exception $e) {
logger("diaspost_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), LOGGER_DEBUG);
}
} else
logger('diaspost_queue: send '.$userdata['uid'].' missing username or password', LOGGER_DEBUG);
if (!$success) {
logger('diaspost_queue: delayed');
update_queue_time($x['id']);
}
}
}
function diaspost_settings(&$a,&$s) {
if(! local_channel())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
//$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/diaspost/diaspost.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variables */
$enabled = get_pconfig(local_channel(),'diaspost','post');
$checked = (($enabled) ? '1' : false);
$css = (($enabled) ? '' : '-disabled');
$def_enabled = get_pconfig(local_channel(),'diaspost','post_by_default');
$def_checked = (($def_enabled) ? 1 : false);
$diaspost_username = get_pconfig(local_channel(), 'diaspost', 'diaspost_username');
$diaspost_password = z_unobscure(get_pconfig(local_channel(), 'diaspost', 'diaspost_password'));
$diaspost_url = get_pconfig(local_channel(), 'diaspost', 'diaspost_url');
$status = "";
if ($diaspost_username AND $diaspost_password AND $diaspost_url) {
try {
require_once("addon/diaspost/diasphp.php");
$conn = new Diasphp($diaspost_url);
$conn->login($diaspost_username, $diaspost_password);
} catch (Exception $e) {
$status = t("Can't login to your Diaspora account. Please check username and password and ensure you used the complete address (including http...)");
}
}
/* Add some HTML to the existing form */
if ($status) {
$sc .= '<div class="section-content-danger-wrapper">';
$sc .= '<strong>' . $status . '</strong>';
$sc .= '</div>';
}
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('diaspost', t('Enable Diaspost Post Plugin'), $checked, '', array(t('No'),t('Yes'))),
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('diaspost_username', t('Diaspora username'), $diaspost_username, '')
));
$sc .= replace_macros(get_markup_template('field_password.tpl'), array(
'$field' => array('diaspost_password', t('Diaspora password'), $diaspost_password, '')
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('diaspost_url', t('Diaspora site URL'), $diaspost_url, 'Example: https://joindiaspora.com')
));
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('diaspost_bydefault', t('Post to Diaspora by default'), $def_checked, '', array(t('No'),t('Yes'))),
));
$s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
'$addon' => array('diaspost', '<img src="addon/diaspost/diaspora.png" style="width:auto; height:1em; margin:-3px 5px 0px 0px;">' . t('Diaspost Post Settings'), '', t('Submit')),
'$content' => $sc
));
return;
}
function diaspost_settings_post(&$a,&$b) {
if(x($_POST,'diaspost-submit')) {
set_pconfig(local_channel(),'diaspost','post',intval($_POST['diaspost']));
set_pconfig(local_channel(),'diaspost','post_by_default',intval($_POST['diaspost_bydefault']));
set_pconfig(local_channel(),'diaspost','diaspost_username',trim($_POST['diaspost_username']));
set_pconfig(local_channel(),'diaspost','diaspost_password',z_obscure(trim($_POST['diaspost_password'])));
set_pconfig(local_channel(),'diaspost','diaspost_url',trim($_POST['diaspost_url']));
}
}
function diaspost_post_local(&$a,&$b) {
if($b['created'] != $b['edited'])
return;
if(! perm_is_allowed($b['uid'],'','view_stream'))
return;
if((! local_channel()) || (local_channel() != $b['uid']))
return;
if($b['item_private'])
return;
$diaspost_post = intval(get_pconfig(local_channel(),'diaspost','post'));
$diaspost_enable = (($diaspost_post && x($_REQUEST,'diaspost_enable')) ? intval($_REQUEST['diaspost_enable']) : 0);
if($_REQUEST['api_source'] && intval(get_pconfig(local_channel(),'diaspost','post_by_default')))
$diaspost_enable = 1;
if(! $diaspost_enable)
return;
if(strlen($b['postopts']))
$b['postopts'] .= ',';
$b['postopts'] .= 'diaspost';
}
function diaspost_send(&$a,&$b) {
$hostname = 'hubzilla ' . '(' . $a->get_hostname() . ')';
logger('diaspost_send: invoked',LOGGER_DEBUG);
if($b['mid'] != $b['parent_mid'])
return;
if((! is_item_normal($b)) || $b['item_private'] || ($b['created'] !== $b['edited']))
return;
if(! perm_is_allowed($b['uid'],'','view_stream'))
return;
if(! strstr($b['postopts'],'diaspost'))
return;
logger('diaspost_send: prepare posting', LOGGER_DEBUG);
$diaspost_username = get_pconfig($b['uid'],'diaspost','diaspost_username');
$diaspost_password = z_unobscure(get_pconfig($b['uid'],'diaspost','diaspost_password'));
$diaspost_url = get_pconfig($b['uid'],'diaspost','diaspost_url');
if($diaspost_url && $diaspost_username && $diaspost_password) {
logger('diaspost_send: all values seem to be okay', LOGGER_DEBUG);
require_once('include/bb2diaspora.php');
$tag_arr = array();
$tags = '';
$x = preg_match_all('/\#\[(.*?)\](.*?)\[/',$b['tag'],$matches,PREG_SET_ORDER);
if($x) {
foreach($matches as $mtch) {
$tag_arr[] = $mtch[2];
}
}
if(count($tag_arr))
$tags = implode(',',$tag_arr);
$title = $b['title'];
$body = $b['body'];
// Insert a newline before and after a quote
$body = str_ireplace("[quote", "\n\n[quote", $body);
$body = str_ireplace("[/quote]", "[/quote]\n\n", $body);
// strip bookmark indicators
$body = preg_replace('/\#\^\[([zu])rl/i', '[$1rl', $body);
$body = preg_replace('/\#\^http/i', 'http', $body);
if(intval(get_pconfig($item['uid'],'system','prevent_tag_hijacking'))) {
$new_tag = html_entity_decode('&#x22d5;',ENT_COMPAT,'UTF-8');
$new_mention = html_entity_decode('&#xff20;',ENT_COMPAT,'UTF-8');
// #-tags
$body = preg_replace('/\#\[url/i', $new_tag . '[url', $body);
$body = preg_replace('/\#\[zrl/i', $new_tag . '[zrl', $body);
// @-mentions
$body = preg_replace('/\@\!?\[url/i', $new_mention . '[url', $body);
$body = preg_replace('/\@\!?\[zrl/i', $new_mention . '[zrl', $body);
}
// remove multiple newlines
do {
$oldbody = $body;
$body = str_replace("\n\n\n", "\n\n", $body);
} while ($oldbody != $body);
// convert to markdown
$body = bb2diaspora($body, false, true);
// Adding the title
if(strlen($title))
$body = "## ".html_entity_decode($title)."\n\n".$body;
require_once("addon/diaspost/diasphp.php");
try {
logger('diaspost_send: prepare', LOGGER_DEBUG);
$conn = new Diasphp($diaspost_url);
logger('diaspost_send: try to log in '.$diaspost_username, LOGGER_DEBUG);
$conn->login($diaspost_username, $diaspost_password);
logger('diaspost_send: try to send '.$body, LOGGER_DEBUG);
//throw new Exception('Test');
$conn->post($body, $hostname);
logger('diaspost_send: success');
} catch (Exception $e) {
logger("diaspost_send: Error submitting the post: " . $e->getMessage());
// logger('diaspost_send: requeueing '.$b['uid'], LOGGER_DEBUG);
// $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
// if (count($r))
// $a->contact = $r[0]["id"];
// $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $body));
// require_once('include/queue_fn.php');
// add_to_queue($a->contact,NETWORK_DIASPORA2,$s);
// notice(t('Diaspost post failed. Queued for retry.').EOL);
}
}
}

View file

@ -0,0 +1,204 @@
<?php
/**
* Name: DirStats
* Description: Show some statistics about the directory.
* This will list the number of Hubzilla, Friendica and Diaspora
* hubs that your own hub is aware of.
* As the name suggets, this is intended for directory servers, where
* this will provide accurate counts of all known Red hubs and channels.
*
* If you are not a directory server - and for Friendica and Diaspora
* even if you are - these counts are merely those your own hub is aware of
* and not all that exist in the network.
*
* Version: 1.0
* Author: Thomas Willingham <zot:beardyunixer@beardyunixer.com>
*/
function dirstats_load() {
register_hook('cron_daily', 'addon/dirstats/dirstats.php', 'dirstats_cron');
}
function dirstats_unload() {
unregister_hook('cron_daily', 'addon/dirstats/dirstats.php', 'dirstats_cron');
}
function dirstats_module() {}
function dirstats_init() {
if(! get_config('dirstats','hubcount'))
dirstats_cron($a,$b);
}
function dirstats_content(&$a) {
$hubcount = get_config('dirstats','hubcount');
$zotcount = get_config('dirstats','zotcount');
$friendicacount = get_config('dirstats','friendicacount');
$diasporacount = get_config('dirstats','diasporacount');
$channelcount = get_config('dirstats','channelcount');
$friendicachannelcount = get_config('dirstats','friendicachannelcount');
$diasporachannelcount = get_config('dirstats','diasporachannelcount');
$over35s = get_config('dirstats','over35s');
$under35s = get_config('dirstats','under35s');
$average = get_config('dirstats','averageage');
$chatrooms = get_config('dirstats','chatrooms');
$tags = get_config('dirstats','tags');
$ob = $a->get_observer();
$observer = $ob['xchan_hash'];
// Requested by Martin
$fountainofyouth = get_xconfig($observer, 'dirstats', 'averageage');
if (intval($fountainofyouth))
$average = $fountainofyouth;
if (argv(1) == 'json') {
$dirstats = array (
'hubcount' => $hubcount,
'zotcount' => $zotcount,
'friendicacount' => $friendicacount,
'diasporacount' => $diasporacount,
'channelcount' => $channelcount,
'friendicachannelcount' => $friendicachannelcount,
'diasporachannelcount' => $diasporachannelcount,
'over35s' => $over35s,
'under35s' => $under35s,
'average' => $average,
'chatrooms' => $chatrooms,
'tags' => $tags
);
echo json_return_and_die($dirstats);
}
// Used by Hubzilla News
elseif (argv(1) == 'genpost' && get_config('dirstats','allowfiledump')) {
$result = '[b]Hub count[/b] : ' . $hubcount . "\xA" .
'[b]Hubzilla Hubs[/b] : ' . $zotcount . "\xA" .
'[b]Friendica Hubs[/b] : ' . $friendicacount . "\xA" .
'[b]Diaspora Pods[/b] : ' . $diasporacount . "\xA" .
'[b]Hubzilla Channels[/b] : ' . $channelcount . "\xA" .
'[b]Friendica Profiles[/b] : ' . $friendicachannelcount . "\xA" .
'[b]Diaspora Profiles[/b] : ' . $diasporachannelcount . "\xA" .
'[b]People aged 35 and above[/b] : ' . $over35s . "\xA" .
'[b]People aged 34 and below[/b] : ' . $under35s . "\xA" .
'[b]Average Age[/b] : ' . $average . "\xA" .
'[b]Known Chatrooms[/b] : ' . $chatrooms . "\xA" .
'[b]Unique Profile Tags[/b] : ' . $tags . "\xA";
file_put_contents('genpost', $result);
}
else {
$tpl = get_markup_template( "dirstats.tpl", "addon/dirstats/" );
return replace_macros($tpl, array(
'$title' => t('Hubzilla Directory Stats'),
'$hubtitle' => t('Total Hubs'),
'$hubcount' => $hubcount,
'$zotlabel' => t('Hubzilla Hubs'),
'$zotcount' => $zotcount,
'$friendicalabel' => t('Friendica Hubs'),
'$friendicacount' => $friendicacount,
'$diasporalabel' => t('Diaspora Pods'),
'$diasporacount' => $diasporacount,
'$zotchanlabel' => t('Hubzilla Channels'),
'$channelcount' => $channelcount,
'$friendicachanlabel' => t('Friendica Channels'),
'$friendicachannelcount' => $friendicachannelcount,
'$diasporachanlabel' => t('Diaspora Channels'),
'$diasporachannelcount' => $diasporachannelcount,
'$over35label' => t('Aged 35 and above'),
'$over35s' => $over35s,
'$under35label' => t('Aged 34 and under'),
'$under35s' => $under35s,
'$averageagelabel' => t('Average Age'),
'$average' => $average,
'$chatlabel' => t('Known Chatrooms'),
'$chatrooms' => $chatrooms,
'$tagslabel' => t('Known Tags'),
'$tags' => $tags,
'$disclaimer' => t('Please note Diaspora and Friendica statistics are merely those **this directory** is aware of, and not all those known in the network. This also applies to chatrooms,')
));
}
}
function dirstats_cron(&$a, $b) {
// Some hublocs are immortal and won't ever die - they all have null date for hubloc_connected and hubloc_updated
$r = q("SELECT count(distinct hubloc_host) as total FROM `hubloc` where not (hubloc_flags & %d) > 0 and not (hubloc_connected = %d and hubloc_updated = %d)",
intval(HUBLOC_FLAGS_DELETED),
dbesc(NULL_DATE),
dbesc(NULL_DATE)
);
if ($r) {
$hubcount = $r[0]['total'];
set_config('dirstats','hubcount',$hubcount);
}
$r = q("SELECT count(distinct hubloc_host) as total FROM `hubloc` where hubloc_network = 'zot' and not (hubloc_flags & %d) > 0 and not (hubloc_connected = %d and hubloc_updated = %d)",
intval(HUBLOC_FLAGS_DELETED),
dbesc(NULL_DATE),
dbesc(NULL_DATE)
);
if ($r) {
$zotcount = $r[0]['total'];
set_config('dirstats','zotcount',$zotcount);
}
$r = q("SELECT count(distinct hubloc_host) as total FROM `hubloc` where hubloc_network = 'friendica-over-diaspora'");
if ($r){
$friendicacount = $r[0]['total'];
set_config('dirstats','friendicacount',$friendicacount);
}
$r = q("SELECT count(distinct hubloc_host) as total FROM `hubloc` where hubloc_network = 'diaspora'");
if ($r) {
$diasporacount = $r[0]['total'];
set_config('dirstats','diasporacount',$diasporacount);
}
$r = q("SELECT count(distinct xchan_hash) as total FROM `xchan` where xchan_network = 'zot' and not (xchan_flags & %d) > 0",
intval(XCHAN_FLAGS_DELETED)
);
if ($r) {
$channelcount = $r[0]['total'];
set_config('dirstats','channelcount',$channelcount);
}
$r = q("SELECT count(distinct xchan_hash) as total FROM `xchan` where xchan_network = 'friendica-over-diaspora'");
if ($r) {
$friendicachannelcount = $r[0]['total'];
set_config('dirstats','friendicachannelcount',$friendicachannelcount);
}
$r = q("SELECT count(distinct xchan_hash) as total FROM `xchan` where xchan_network = 'diaspora'");
if ($r) {
$diasporachannelcount = $r[0]['total'];
set_config('dirstats','diasporachannelcount',$diasporachannelcount);
}
$r = q("select count(xprof_hash) as total from `xprof` where xprof_age >=35");
if ($r) {
$over35s = $r[0]['total'];
set_config('dirstats','over35s',$over35s);
}
$r = q("select count(xprof_hash) as total from `xprof` where xprof_age <=34 and xprof_age >=1");
if ($r) {
$under35s = $r[0]['total'];
set_config('dirstats','under35s',$under35s);
}
$r = q("select sum(xprof_age) as sum from xprof");
if ($r) {
$rr = q("select count(xprof_hash) as total from `xprof` where xprof_age >=1");
$total = $r[0]['sum'];
$number = $rr[0]['total'];
if($number)
$average = $total / $number;
else
$average = 0;
set_config('dirstats','averageage',$average);
}
$r = q("select count(distinct xchat_url) as total from `xchat`");
if ($r) {
$chatrooms = $r[0]['total'];
set_config('dirstats','chatrooms',$chatrooms);
}
$r = q("select count(distinct xtag_term) as total from xtag where xtag_flags = 0");
if ($r) {
$tags = $r[0]['total'];
set_config('dirstats','tags',$tags);
}
}

View file

@ -0,0 +1,20 @@
<div class="generic-content-wrapper">
<h1>{{$title}}</h1>
<ul>{{$hubtitle}} : {{$hubcount}}</ul>
<ul>{{$zotlabel}} : {{$zotcount}}</ul>
<ul>{{$friendicalabel}} : {{$friendicacount}}</ul>
<ul>{{$diasporalabel}} : {{$diasporacount}}</ul>
<p></p>
<ul>{{$zotchanlabel}} : {{$channelcount}}</ul>
<ul>{{$friendicachanlabel}} : {{$friendicachannelcount}}</ul>
<ul>{{$diasporachanlabel}} : {{$diasporachannelcount}}</ul>
<p></p>
<ul>{{$over35label}} : {{$over35s}}</ul>
<ul>{{$under35label}} : {{$under35s}}</ul>
<ul>{{$averageagelabel}} : {{$average}}</ul>
<p></p>
<ul>{{$chatlabel}} : {{$chatrooms}}</ul>
<ul>{{$tagslabel}} : {{$tags}}</ul>
<p>{{$disclaimer}}</p>
</div>

View file

@ -0,0 +1,3 @@
url: $baseurl/donate
name: Support Hubzilla
photo: $baseurl/addon/donate/donate.png

View file

@ -0,0 +1,75 @@
<?php
/**
* Name: Donate
* Description: Support the Redmatrix/Hubzilla projects
* Version: 1.0
* Author: Macgirvin
*
*/
function load(){}
function unload(){}
function donate_module(){}
function donate_content(&$a) {
/* Format - array( display name, paypal id, description of services or skills you provide to the matrix) */
$contributors = array(
array('The Redmatrix/Hubzilla Projects', 'max@macgirvin.com', t('Project Servers and Resources')),
array('Mike Macgirvin','mike@macgirvin.com',t('Project Creator and Tech Lead')),
array('Thomas Willingham','beardyunixer@beardyunixer.com',t('Admin, developer, directorymin, support bloke')),
/* Developers and public hubs - add your donatable resource here */
);
$sponsors = array(
'Leila',
'Rose',
'Pierre',
'Jared',
'Erik',
'Chris',
'DuckDuckGo',
'Nicholas',
'Michael',
'Troilus',
'Steve',
'Jakob Jensen'
);
call_hooks('donate_contributors',$contributors);
call_hooks('donate_sponsors',$sponsors);
$sponsors[] = t('And the hundreds of other people and organisations who helped make the Hubzilla possible.');
$text .= '<p>' . t('The Redmatrix/Hubzilla projects are provided primarily by volunteers giving their time and expertise - and often paying out of pocket for services they share with others.') . '</p>';
$text .= '<p>' . t('There is no corporate funding and no ads, and we do not collect and sell your personal information. (We don\'t control your personal information - <strong>you do</strong>.)') . '</p>';
$text .= '<p>' . t('Help support our ground-breaking work in decentralisation, web identity, and privacy.') . '</p>';
$text .= '<p>' . t('Your donations keep servers and services running and also helps us to provide innovative new features and continued development.') . '</p>';
$o = replace_macros(get_markup_template('donate.tpl','addon/donate'),array(
'$header' => t('Donate'),
'$text' => $text,
'$choice' => t('Choose a project, developer, or public hub to support with a one-time donation'),
'$onetime' => t('Donate Now'),
'$repeat' => t('<strong><em>Or</em></strong> become a project sponsor (Hubzilla Project only)'),
'$note' => t('Please indicate if you would like your first name or full name (or nothing) to appear in our sponsor listing'),
'$subscribe' => t('Sponsor'),
'$contributors' => $contributors,
'$sponsors' => $sponsors,
'$thanks' => t('Special thanks to: '),
));
call_hooks('donate_plugin',$o);
return $o;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View file

@ -0,0 +1,64 @@
<h2>{{$header}}</h2>
<div class="descriptive-text">{{$text}}</div>
<br />
<img src="addon/donate/tipping.jpg" alt="Donations" style="max-width: 95%;"/>
<br />
<br />
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_donations" name="cmd">
<div class="descriptive-text">{{$choice}}</div>
<br />
<select name="business">
{{foreach $contributors as $c}}
<option value="{{$c[1]}}" title="{{$c.2}}" {{if $c[1] === 'max@macgirvin.com'}}selected="selected"{{/if}} >{{$c[0]}}</option>
{{/foreach}}
</select>
<br /><br /><br />
<input type="hidden" value="US" name="lc">
<input type="hidden" value="Hubzilla Donation" name="item_name">
<input type="hidden" value="0" name="no_note">
<input type="hidden" value="USD" name="currency_code">
<input type="submit" name="submit" value="{{$onetime}}" class="btn btn-default" />
</form>
<br /><br /><br />
<p>
{{$repeat}}
</p>
<p>
{{$note}}
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="FHV36KE28CYM8" />
<br />
<input type="hidden" name="on0" value="Recurring Donation Options" />
<select name="os0">
<option value="Option 1">Option 1 : $ 3.00USD - monthly</option>
<option value="Option 2">Option 2 : $ 5.00USD - monthly</option>
<option value="Option 3">Option 3 : $10.00USD - monthly</option>
<option value="Option 4">Option 4 : $20.00USD - monthly</option>
</select>
<br />
<br />
<br />
<input type="hidden" name="currency_code" value="USD" />
<input type="submit" name="submit" value="{{$subscribe}}" class="btn btn-default" />
</form>
<br /><br />
{{$thanks}}
<ul>
{{foreach $sponsors as $s}}
<li>{{$s}}</li>
{{/foreach}}
</ul>

View file

View file

@ -0,0 +1,229 @@
<?php
/**
* Name: Dreamwidth Post feature
* Description: Post to dreamwidth
* Version: 1.0
* Author: Tony Baldwin <https://red.free-haven.org/channel/tony>
* Author: Michael Johnston
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
require_once('include/permissions.php');
function dwpost_load() {
register_hook('post_local', 'addon/dwpost/dwpost.php', 'dwpost_post_local');
register_hook('notifier_normal', 'addon/dwpost/dwpost.php', 'dwpost_send');
register_hook('jot_networks', 'addon/dwpost/dwpost.php', 'dwpost_jot_nets');
register_hook('feature_settings', 'addon/dwpost/dwpost.php', 'dwpost_settings');
register_hook('feature_settings_post', 'addon/dwpost/dwpost.php', 'dwpost_settings_post');
}
function dwpost_unload() {
unregister_hook('post_local', 'addon/dwpost/dwpost.php', 'dwpost_post_local');
unregister_hook('notifier_normal', 'addon/dwpost/dwpost.php', 'dwpost_send');
unregister_hook('jot_networks', 'addon/dwpost/dwpost.php', 'dwpost_jot_nets');
unregister_hook('feature_settings', 'addon/dwpost/dwpost.php', 'dwpost_settings');
unregister_hook('feature_settings_post', 'addon/dwpost/dwpost.php', 'dwpost_settings_post');
}
function dwpost_jot_nets(&$a,&$b) {
if((! local_channel()) || (! perm_is_allowed(local_channel(),'','view_stream')))
return;
$dw_post = get_pconfig(local_channel(),'dwpost','post');
if(intval($dw_post) == 1) {
$dw_defpost = get_pconfig(local_channel(),'dwpost','post_by_default');
$selected = ((intval($dw_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="dwpost_enable" ' . $selected . ' value="1" /> '
. t('Post to Dreamwidth') . '</div>';
}
}
function dwpost_settings(&$a,&$s) {
if(! local_channel())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
//$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dwpost/dwpost.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variables */
$enabled = get_pconfig(local_channel(),'dwpost','post');
$checked = (($enabled) ? 1 : false);
$def_enabled = get_pconfig(local_channel(),'dwpost','post_by_default');
$def_checked = (($def_enabled) ? 1 : false);
$dw_username = get_pconfig(local_channel(), 'dwpost', 'dw_username');
$dw_password = z_unobscure(get_pconfig(local_channel(), 'dwpost', 'dw_password'));
/* Add some HTML to the existing form */
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('dwpost', t('Enable Dreamwidth Post Plugin'), $checked, '', array(t('No'),t('Yes'))),
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('dw_username', t('Dreamwidth username'), $dw_username, '')
));
$sc .= replace_macros(get_markup_template('field_password.tpl'), array(
'$field' => array('dw_password', t('Dreamwidth password'), $dw_password, '')
));
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('dw_bydefault', t('Post to Dreamwidth by default'), $def_checked, '', array(t('No'),t('Yes'))),
));
$s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
'$addon' => array('dwpost',t('Dreamwidth Post Settings'), '', t('Submit')),
'$content' => $sc
));
}
function dwpost_settings_post(&$a,&$b) {
if(x($_POST,'dwpost-submit')) {
set_pconfig(local_channel(),'dwpost','post',intval($_POST['dwpost']));
set_pconfig(local_channel(),'dwpost','post_by_default',intval($_POST['dw_bydefault']));
set_pconfig(local_channel(),'dwpost','dw_username',trim($_POST['dw_username']));
set_pconfig(local_channel(),'dwpost','dw_password',z_obscure(trim($_POST['dw_password'])));
}
}
function dwpost_post_local(&$a,&$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
if($b['edit'])
return;
if((! local_channel()) || (local_channel() != $b['uid']))
return;
if($b['item_private'] || $b['parent'])
return;
logger('Dreamwidth xpost invoked');
$dw_post = intval(get_pconfig(local_channel(),'dwpost','post'));
$dw_enable = (($dw_post && x($_REQUEST,'dwpost_enable')) ? intval($_REQUEST['dwpost_enable']) : 0);
if($_REQUEST['api_source'] && intval(get_pconfig(local_channel(),'dwpost','post_by_default')))
$dw_enable = 1;
if(! $dw_enable)
return;
if(strlen($b['postopts']))
$b['postopts'] .= ',';
$b['postopts'] .= 'dwpost';
}
function dwpost_send(&$a,&$b) {
if((! is_item_normal($b)) || $b['item_private'] || ($b['created'] !== $b['edited']))
return;
if(! perm_is_allowed($b['uid'],'','view_stream'))
return;
if(! strstr($b['postopts'],'dwpost'))
return;
if($b['parent'] != $b['id'])
return;
// dreamwidth post in the LJ user's timezone.
// Hopefully the person's Friendica account
// will be set to the same thing.
$tz = 'UTC';
$x = q("select channel_timezone from channel where channel_id = %d limit 1",
intval($b['uid'])
);
if($x && strlen($x[0]['channel_timezone']))
$tz = $x[0]['channel_timezone'];
$dw_username = get_pconfig($b['uid'],'dwpost','dw_username');
$dw_password = z_unobscure(get_pconfig($b['uid'],'dwpost','dw_password'));
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
if($dw_username && $dw_password && $dw_blog) {
require_once('include/bbcode.php');
require_once('include/datetime.php');
$title = $b['title'];
$post = bbcode($b['body']);
$post = xmlify($post);
$tags = dwpost_get_tags($b['tag']);
$date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s');
$year = intval(substr($date,0,4));
$mon = intval(substr($date,5,2));
$day = intval(substr($date,8,2));
$hour = intval(substr($date,11,2));
$min = intval(substr($date,14,2));
$xml = <<< EOT
<?xml version="1.0" encoding="utf-8"?>
<methodCall><methodName>LJ.XMLRPC.postevent</methodName>
<params><param>
<value><struct>
<member><name>year</name><value><int>$year</int></value></member>
<member><name>mon</name><value><int>$mon</int></value></member>
<member><name>day</name><value><int>$day</int></value></member>
<member><name>hour</name><value><int>$hour</int></value></member>
<member><name>min</name><value><int>$min</int></value></member>
<member><name>event</name><value><string>$post</string></value></member>
<member><name>username</name><value><string>$dw_username</string></value></member>
<member><name>password</name><value><string>$dw_password</string></value></member>
<member><name>subject</name><value><string>$title</string></value></member>
<member><name>lineendings</name><value><string>unix</string></value></member>
<member><name>ver</name><value><int>1</int></value></member>
<member><name>props</name>
<value><struct>
<member><name>useragent</name><value><string>Friendica</string></value></member>
<member><name>taglist</name><value><string>$tags</string></value></member>
</struct></value></member>
</struct></value>
</param></params>
</methodCall>
EOT;
logger('dwpost: data: ' . $xml, LOGGER_DATA);
if($dw_blog !== 'test')
$x = z_post_url($dw_blog,$xml,array('headers' => array("Content-Type: text/xml")));
logger('posted to dreamwidth: ' . print_r($x,true), LOGGER_DEBUG);
}
}
function dwpost_get_tags($post)
{
preg_match_all("/\]([^\[#]+)\[/",$post,$matches);
$tags = implode(', ',$matches[1]);
return $tags;
}

View file

@ -0,0 +1,46 @@
# ADDON dwpost
# Copyright (C)
# This file is distributed under the same license as the Friendica dwpost 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"
#: dwpost.php:39
msgid "Post to Dreamwidth"
msgstr ""
#: dwpost.php:70
msgid "Dreamwidth Post Settings"
msgstr ""
#: dwpost.php:72
msgid "Enable dreamwidth Post Plugin"
msgstr ""
#: dwpost.php:77
msgid "dreamwidth username"
msgstr ""
#: dwpost.php:82
msgid "dreamwidth password"
msgstr ""
#: dwpost.php:87
msgid "Post to dreamwidth by default"
msgstr ""
#: dwpost.php:93
msgid "Submit"
msgstr ""

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Missatge a Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Configuració d'enviaments a Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Habilitat el plugin d'enviaments a Dreamwidth";
$a->strings["dreamwidth username"] = "Nom d'usuari a Dreamwidth";
$a->strings["dreamwidth password"] = "Contrasenya a Dreamwidth";
$a->strings["Post to dreamwidth by default"] = "Enviar per defecte a Dreamwidth";
$a->strings["Submit"] = "Enviar";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Poslat na Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Nastavení Dreamwidth příspěvků";
$a->strings["Enable dreamwidth Post Plugin"] = "Povolit dreamwidth Plugin";
$a->strings["dreamwidth username"] = "dreamwidth uživatelské jméno";
$a->strings["dreamwidth password"] = "dreamwidth heslo";
$a->strings["Post to dreamwidth by default"] = "Defaultně umístit na dreamwidth";
$a->strings["Submit"] = "Odeslat";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "In Dreamwidth veröffentlichen";
$a->strings["Dreamwidth Post Settings"] = "Dreamwidth Veröffentlichungs-Einstellungen";
$a->strings["Enable dreamwidth Post Plugin"] = "Dreamwidth Post Plugin aktivieren";
$a->strings["dreamwidth username"] = "Dreamwidth Benutzername";
$a->strings["dreamwidth password"] = "Dreamwidth Passwort";
$a->strings["Post to dreamwidth by default"] = "Standardmäßig bei Dreamwidth veröffentlichen";
$a->strings["Submit"] = "Senden";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Afiŝi al Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Agordoj por Afiŝoj al Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Ŝalti la Dreamwidth Kromprogramon";
$a->strings["dreamwidth username"] = "Dreamwidth salutnomo";
$a->strings["dreamwidth password"] = "Dreamwidth pasvorto";
$a->strings["Post to dreamwidth by default"] = "Defaŭlte afiŝi al Dreamwidth";
$a->strings["Submit"] = "Sendi";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Publicar en Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Configuración de las publicaciones en Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Activar el módulo de publicación en Dreamwidth";
$a->strings["dreamwidth username"] = "Nombre de usuario de Dreamwidth";
$a->strings["dreamwidth password"] = "Contraseña de Dreamwidth";
$a->strings["Post to dreamwidth by default"] = "Publicar en Dreamwidth por defecto";
$a->strings["Submit"] = "Envíar";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Poster vers Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Réglages Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Activer \"Poster vers Dreamwidth\"";
$a->strings["dreamwidth username"] = "Nom d'utilisateur Dreamwidth";
$a->strings["dreamwidth password"] = "Mot de passe";
$a->strings["Post to dreamwidth by default"] = "Poster vers Dreamwidth par défaut";
$a->strings["Submit"] = "Envoyer";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "";
$a->strings["Dreamwidth Post Settings"] = "";
$a->strings["Enable dreamwidth Post Plugin"] = "";
$a->strings["dreamwidth username"] = "";
$a->strings["dreamwidth password"] = "";
$a->strings["Post to dreamwidth by default"] = "";
$a->strings["Submit"] = "Senda inn";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Posta su Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Impostazioni post Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Abilita il plugin dreamwidth";
$a->strings["dreamwidth username"] = "dreamwidth username";
$a->strings["dreamwidth password"] = "Password dreamwidth";
$a->strings["Post to dreamwidth by default"] = "Invia a dreamwidth per impostazione predefinita";
$a->strings["Submit"] = "Invia";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "";
$a->strings["Dreamwidth Post Settings"] = "";
$a->strings["Enable dreamwidth Post Plugin"] = "";
$a->strings["dreamwidth username"] = "";
$a->strings["dreamwidth password"] = "";
$a->strings["Post to dreamwidth by default"] = "";
$a->strings["Submit"] = "Lagre";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Opublikuj na Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "";
$a->strings["Enable dreamwidth Post Plugin"] = "";
$a->strings["dreamwidth username"] = "";
$a->strings["dreamwidth password"] = "";
$a->strings["Post to dreamwidth by default"] = "";
$a->strings["Submit"] = "Potwierdź";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "Publicar no Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Configurações de publicação no Dreamwidth";
$a->strings["Enable dreamwidth Post Plugin"] = "Habilitar o plugin de publicação no Dreamwidth";
$a->strings["dreamwidth username"] = "Nome de usuário do Dreamwidth";
$a->strings["dreamwidth password"] = "Senha do Dreamwidth";
$a->strings["Post to dreamwidth by default"] = "Publicar no Dreamwidth por padrão";
$a->strings["Submit"] = "Enviar";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "";
$a->strings["Dreamwidth Post Settings"] = "Dreamwidth настройки сообщений";
$a->strings["Enable dreamwidth Post Plugin"] = "Включить dreamwidth плагин сообщений";
$a->strings["dreamwidth username"] = "dreamwidth имя пользователя";
$a->strings["dreamwidth password"] = "dreamwidth пароль";
$a->strings["Post to dreamwidth by default"] = "";
$a->strings["Submit"] = "Подтвердить";

View file

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

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Dreamwidth"] = "转播到Dreamwidth";
$a->strings["Dreamwidth Post Settings"] = "Dreamwidth转播设置";
$a->strings["Enable dreamwidth Post Plugin"] = "使Dreamwidth转播插件可用";
$a->strings["dreamwidth username"] = "Dreamwidth用户名";
$a->strings["dreamwidth password"] = "Dreamwidth密码";
$a->strings["Post to dreamwidth by default"] = "默认地转播到Dreamwidth";
$a->strings["Submit"] = "提交";

View file

@ -0,0 +1,25 @@
<?php
/**
* Name: Embedly
* Description: Use oohemebed.com to resolve oembeds that can't be discovered directly
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*
*/
function embedly_load() {
register_hook('oembed_probe','addon/embedly/embedly.php','embedly_oembed_probe');
}
function embedly_unload() {
unregister_hook('oembed_probe','addon/embedly/embedly.php','embedly_oembed_probe');
}
function embedly_oembed_probe($a,$b) {
// try oohembed service
$ourl = "http://oohembed.com/oohembed/?url=".$b['url'].'&maxwidth=' . $b['videowidth'];
$result = z_fetch_url($ourl);
if($result['success'])
$b['embed'] = $result['body'];
}

View file

@ -0,0 +1,22 @@
<?php
/**
* Name: external cron
* Description: Use external server or service to run poller regularly
* Version: 1.0
* Author: Mike Macgirvin <mike@zothub.com>
*
* Notes: External service needs to make a web request to http(s)://yoursite/extcron
*/
function extcron_load() {}
function extcron_unload() {}
function extcron_module() {}
function extcron_init(&$a) {
proc_run('php','include/poller.php');
killme();
}

View file

@ -0,0 +1,3 @@
2013-09-22 Version 0.1 Tobias Diekershoff
initial version of the widget
* add a flattr button to left or right aside of the channel view

View file

@ -0,0 +1,76 @@
Flattr Widget for The Hubzilla
================================
This widget is ment to add a [flattr][1] button for one thing to the
left/right aside area of a red# channel. For example this could be the flattr
thing for your blog (on a blog channel).
What can be configured?
* static button from your server or dynamic button generated using the flattr
API
* left or right aside area
* URL and Title of the thing you want to be flattred.
If none are set, the channel URL and the title "_Channel Name_ on The Red
Matrix" will be used.
There will also be a widget that adds the flattr button to each posting
separetely.
Screenshots
-----------
_At the moment the screenshots will only show in your red# admin panel._
![Dynamic flattr button in channel view](/addon/flattrwidget/img/red-flattr-widget.png)
Dynamic flattr button generated from the flattr API displaying the number of
flattrs received.
![Static flattr button in channel view](/addon/flattrwidget/img/red-flattr-widget2.png)
Static flattr buttton, the image is hosted on your server for privacy of the
visitors.
Feedback
--------
You can send feedback, bug reports etc, for this widget to [my red# stuff
feedback channel][3], you can also leave a flattr there if you like.
Author
------
Original Author: [Tobias Diekershoff][TD]
License
-------
This widget id licensed under the [MIT][2] license.
Copyright (c) 2013, Tobias Diekershoff
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
The _flattr_ button located in the img directory was retrieved from the flattr
homepage.
[1]: https://flattr.com
[2]: http://opensource.org/licenses/mit-license.php
[3]: https://diekershoff.de/channel/basredstuff
[TD]: https://diekershoff.de/channel/bavatar

View file

@ -0,0 +1,129 @@
<?php
/* Name: Flattr Widget
* Description: Add a Flattr Button to the left/right aside are to allow the flattring of one thing (e.g. the for a blog)
* Version: 0.1
* Screenshot: img/red-flattr-widget.png
* Depends: Core
* Recommends: None
* Category: Widget, flattr, Payment
* Author: Tobias Diekershoff <https://diekershoff.de/channel/bavatar>
* Maintainer: Tobias Diekershoff <https://diekershoff.de/channel/bavatar>
*/
function flattrwidget_load() {
register_hook('construct_page', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_construct_page');
register_hook('feature_settings', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_settings');
register_hook('feature_settings_post', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_settings_post');
}
function flattrwidget_unload() {
unregister_hook('construct_page', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_construct_page');
unregister_hook('feature_settings', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_settings');
unregister_hook('feature_settings_post', 'addon/flattrwidget/flattrwidget.php', 'flattrwidget_settings_post');
}
function flattrwidget_construct_page(&$a,&$b) {
if (! $b['module']=='channel')
return;
$id = $a->profile['profile_uid'];
$enable = intval(get_pconfig($id,'flattrwidget','enable'));
if (! $enable)
return;
$a->page['htmlhead'] .= '<link rel="stylesheet" href="'.$a->get_baseurl().'/addon/flattrwidget/style.css'.'" media="all" />';
// get alignment and static/dynamic from the settings
// align is either "aside" or "right_aside"
// sd is either static or dynamic
$lr = get_pconfig( $id, 'flattrwidget', 'align');
$sd = get_pconfig( $id, 'flattrwidget', 'sd');
// title of the thing for the things page on flattr
$ftitle = get_pconfig( $id, 'flattrwidget', 'title');
// URL of the thing
$thing = get_pconfig( $id, 'flattrwidget', 'thing');
// flattr user the thing belongs to
$user = get_pconfig( $id, 'flattrwidget', 'user');
// title for the flattr button itself
$title = t('Flattr this!');
// construct the link for the button
$link = 'https://flattr.com/submit/auto?user_id='.$user.'&url=' . rawurlencode($thing).'&title='.rawurlencode($ftitle);
if ($sd == 'static') {
// static button graphic from the img folder
$img = $a->get_baseurl() .'/addon/flattrwidget/img/flattr-badge-large.png';
$code = '<a href="'.$link.'" target="_blank"><img src="'.$img.'" alt="'.$title.'" title="'.$title.'" border="0"></a>';
} else {
$code = '<script id=\'fbdu5zs\'>(function(i){var f,s=document.getElementById(i);f=document.createElement(\'iframe\');f.src=\'//api.flattr.com/button/view/?uid='.$user.'&url='.rawurlencode($thing).'&title='.rawurlencode($ftitle).'\';f.title=\''.$title.'\';f.height=72;f.width=65;f.style.borderWidth=0;s.parentNode.insertBefore(f,s);})(\'fbdu5zs\');</script>';
// dynamic button from flattr API
}
// put the widget content together
$flattrwidget = '<div id="flattr-widget">'.$code.'</div>';
// place the widget into the selected aside area
if ($lr=='right_aside') {
$b['layout']['region_right_aside'] = $flattrwidget . $b['layout']['region_right_aside'];
} else {
$b['layout']['region_aside'] = $flattrwidget . $b['layout']['region_aside'];
}
}
function flattrwidget_settings_post($a,$s) {
if(! local_channel() || (! x($_POST,'flattrwidget-submit')))
return;
$c = $a->get_channel();
set_pconfig( local_channel(), 'flattrwidget', 'align', $_POST['flattrwidget-align'] );
set_pconfig( local_channel(), 'flattrwidget', 'sd', $_POST['flattrwidget-static'] );
$thing = $_POST['flattrwidget-thing'];
if ($thing == '') {
$thing = $a->get_baseurl().'/channel/'.$c['channel_address'];
}
set_pconfig( local_channel(), 'flattrwidget', 'thing', $thing);
set_pconfig( local_channel(), 'flattrwidget', 'user', $_POST['flattrwidget-user']);
$ftitle = $_POST['flattrwidget-thingtitle'];
if ($ftitle == '') {
$ftitle = $c['channel_name'].' on The Hubzilla';
}
set_pconfig( local_channel(), 'flattrwidget', 'title', $ftitle);
set_pconfig( local_channel(), 'flattrwidget', 'enable', intval($_POST['flattrwidget-enable']));
info(t('Flattr widget settings updated.').EOL);
}
function flattrwidget_settings(&$a,&$s) {
$id = local_channel();
if (! $id)
return;
//$a->page['htmlhead'] .= '<link rel="stylesheet" href="'.$a->get_baseurl().'/addon/flattrwidget/style.css'.'" media="all" />';
$lr = get_pconfig( $id, 'flattrwidget', 'align');
$sd = get_pconfig( $id, 'flattrwidget', 'sd');
$thing = get_pconfig( $id, 'flattrwidget', 'thing');
$user = get_pconfig( $id, 'flattrwidget', 'user');
$ftitle = get_pconfig( $id, 'flattrwidget', 'title');
$enable = intval(get_pconfig(local_channel(),'flattrwidget','enable'));
$enable_checked = (($enable) ? 1 : false);
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('flattrwidget-user', t('Flattr user'), $user, '')
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('flattrwidget-thing', t('URL of the Thing to flattr'), $thing, t('If empty channel URL is used'))
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('flattrwidget-thingtitle', t('Title of the Thing to flattr'), $ftitle, t('If empty "channel name on The Hubzilla" will be used'))
));
$sc .= replace_macros(get_markup_template('field_select.tpl'), array(
'$field' => array('flattrwidget-static', t('Static or dynamic flattr button'), $sd, '', array('static'=>t('static'), 'dynamic'=>t('dynamic')))
));
$sc .= replace_macros(get_markup_template('field_select.tpl'), array(
'$field' => array('flattrwidget-align', t('Alignment of the widget'), $lr, '', array('aside'=>t('left'), 'right_aside'=>t('right')))
));
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('flattrwidget-enable', t('Enable Flattr widget'), $enable_checked, '', array(t('No'),t('Yes'))),
));
$s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
'$addon' => array('flattrwidget',t('Flattr Widget Settings'), '', t('Submit')),
'$content' => $sc
));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

View file

@ -0,0 +1,7 @@
This addon requires a fortune server. You may use the DB supplied here to create one.
gunzip the fortunate.sql.gz and import into your database.
Copy cookie.php to the top level Friendica directory.
Edit fortunate.php and change FORTUNATE_SERVER definition to your hostname. Change the http in that file to https if your server doesn't support http.
Many additional options are available if you examine cookie.php - a clever developer can provide a settings page to tailor this to one's liking. Also several languages are supported, and it would be convenient to set this to the current Friendica language if that is amongst those supported.

View file

@ -0,0 +1,351 @@
<?php
set_time_limit(0);
error_reporting(0);
require(".htconfig.php");
$db = @new mysqli($db_host,$db_user,$db_pass,$db_data);
header( "Content-type: text/html; charset=utf-8");
header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
header( "Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
header( "Cache-Control: post-check=0, pre-check=0", FALSE );
header( "Pragma: no-cache" ); // HTTP/1.0
$lang = 'en';
$offensive = $_GET['off'];
if($offensive == 'o')
$adult = 2;
elseif($offensive == 'a')
$adult = 1;
else
$adult = 0;
$length = (($_GET['length']) ? intval($_GET['length']) : 0);
$numlines = ((intval($_GET['numlines'])) ? intval($_GET['numlines']) : 0);
$cat = (($_GET['cat'] == '1') ? 1 : 0);
$equal = (($_GET['equal'] == '1') ? 1 : 0);
$stats = (($_GET['stats'] == '1') ? 1 : 0);
if(strlen($_GET['lang']))
$lang = @$db->real_escape_string($_GET['lang']);
if(strlen($_GET['pattern']))
$pattern = @$db->real_escape_string($_GET['pattern']);
if(strlen($_GET['regex']))
$regex = @$db->real_escape_string($_GET['regex']);
if(strlen($_GET['db']))
$table = @$db->real_escape_string($_GET['db']);
else
$table = '';
if($length < 0)
$length = 0;
if($numlines < 0)
$numlines = 0;
function do_query($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
global $db;
$rnd = mt_rand();
$r = array();
$typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
$lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
if($adult == 2)
$adultsql = " AND offensive = 1 ";
elseif($adult == 1)
$adultsql = "";
else
$adultsql = " AND offensive = 0 ";
if($numlines)
$lengthsql .=
" AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
$langsql = (($lang === 'any') ? '' : " AND lang = '$lang' ");
$patsql = '';
if(strlen($pattern))
$patsql = " AND MATCH text AGAINST ('$pattern') ";
$regexsql = '';
if(strlen($regex))
$regexsql = " AND text REGEXP '$regex' ";
$eqsql = '';
if($equal) {
$catsavail = array();
$res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
$typesql
$adultsql
$lengthsql
$langsql
$patsql
$regexsql ");
if($res->num_rows) {
while($x = $res->fetch_array(MYSQL_ASSOC))
$catsavail[] = $x['category'];
$eqsql = " AND `category` = '"
. $catsavail[mt_rand(0,$res->num_rows - 1)] . "' ";
}
}
$order = (($patsql && $limit == 1) ? "" : "ORDER BY RAND($rnd)" );
$result = @$db->query("SELECT `text`, `category` FROM `fortune`
$typesql
$adultsql
$lengthsql
$langsql
$patsql
$regexsql
$eqsql
$order
LIMIT $limit");
if($result->num_rows) {
while($x = $result->fetch_array(MYSQL_ASSOC))
$r[] = fortune_to_html($x['text'])
.(($cat) ? "<br />[{$x['category']}]<br />" : "");
}
return $r;
}
function do_stats($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
global $db;
$rnd = mt_rand();
$r = array();
$typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
$lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
if($adult == 2)
$adultsql = " AND offensive = 1 ";
elseif($adult == 1)
$adultsql = "";
else
$adultsql = " AND offensive = 0 ";
if($numlines)
$lengthsql .=
" AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
$langsql = " AND lang = '$lang' ";
$patsql = '';
if(strlen($pattern))
$patsql = " AND MATCH text AGAINST ('$pattern') ";
$regexsql = '';
if(strlen($regex))
$regexsql = " AND text REGEXP '$regex' ";
$eqsql = '';
$result = @$db->query("SELECT `text`, `category` FROM `fortune`
$typesql
$adultsql
$lengthsql
$langsql
$patsql
$regexsql
$eqsql");
echo '<br />' . $result->num_rows . ' matching quotations.<br />';
$res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
$typesql
$adultsql
$lengthsql
$langsql
$patsql
$regexsql ");
if($res->num_rows) {
echo '<br />Matching Databases:<br />';
while($x = $res->fetch_array(MYSQL_ASSOC))
echo $x['category'].'<br />';
}
else
echo '<br />No matching databases using those search parameters - please refine your options.<br />';
}
function fortune_to_html($s) {
// First pass - escape all the HTML entities, and while we're at it
// get rid of any MS-DOS end-of-line characters and expand tabs to
// 8 non-breaking spaces, and translate linefeeds to <br />.
// We also get rid of ^G which used to sound the terminal beep or bell
// on ASCII terminals and were humourous in some fortunes.
// We could map these to autoplay a short sound file but browser support
// is still sketchy and then there's the issue of where to locate the
// URL, and a lot of people find autoplay sounds downright annoying.
// So for now, just remove them.
$s = str_replace(
array("&",
"<",
">",
'"',
"\007",
"\t",
"\r",
"\n"),
array("&amp;",
"&lt;",
"&gt;",
"&quot;",
"",
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
"",
"<br />"),
$s);
// Replace pseudo diacritics
// These were used to produce accented characters. For instance an accented
// e would have been encoded by '^He - the backspace moving the cursor
// backward so both the single quote and the e would appear in the same
// character position. Umlauts were quite clever - they used a double quote
// as the accent mark over a normal character.
$s = preg_replace("/'\010([a-zA-Z])/","&\\1acute;",$s);
$s = preg_replace("/\&quot;\010([a-zA-Z])/","&\\1uml;",$s);
$s = preg_replace("/\`\010([a-zA-Z])/","&\\1grave;",$s);
$s = preg_replace("/\^\010([a-zA-Z])/","&\\1circ;",$s);
$s = preg_replace("/\~\010([a-zA-Z])/","&\\1tilde;",$s);
// Ignore multiple underlines for the same character. These were
// most useful when sent to a line printer back in the day as it
// would type over the same character a number of times making it
// much darker (e.g. bold). I think there are only one or two
// instances of this in the current (2008) fortune cookie database.
$s = preg_replace("/(_\010)+/","_\010",$s);
// Map the characters which sit underneath a backspace.
// If you can come up with a regex to do all of the following
// madness - be my guest.
// It's not as simple as you think. We need to take something
// that has been backspaced over an arbitrary number of times
// and wrap a forward looking matching number of characters in
// HTML, whilst deciding if it's intended as an underline or
// strikeout sequence.
// Essentially we produce a string of '1' and '0' characters
// the same length as the source text.
// Any position which is marked '1' has been backspaced over.
$cursor = 0;
$dst = $s;
$bs_found = false;
for($x = 0; $x < strlen($s); $x ++) {
if($s[$x] == "\010" && $cursor) {
$bs_found = true;
$cursor --;
$dst[$cursor] = '1';
$dst[$x] = '0';
$continue;
}
else {
if($bs_found) {
$bs_found = false;
$cursor = $x;
}
$dst[$cursor] = '0';
$cursor ++;
}
}
$out = '';
$strike = false;
$bold = false;
// Underline sequence, convert to bold to avoid confusion with links.
// These were generally used for emphasis so it's a reasonable choice.
// Please note that this logic will fail if there is an underline sequence
// and also a strikeout sequence in the same fortune.
if(strstr($s,"_\010")) {
$len = 0;
for($x = 0; $x < strlen($s); $x ++) {
if($dst[$x] == '1') {
$len ++;
$bold = true;
}
else {
if($bold) {
$out .= '<strong>';
while($s[$x] == "\010")
$x ++;
$out .= substr($s,$x,$len);
$out .= '</strong>';
$x = $x + $len - 1;
$len = 0;
$bold = false;
}
else
$out .= $s[$x];
}
}
}
// These aren't seen very often these days - simulation of
// backspace/replace. You could occasionally see the original text
// on slower terminals before it got replaced. Once modems reached
// 4800/9600 baud in the late 70's and early 80's the effect was
// mostly lost - but if you find a really old fortune file you might
// encounter a few of these.
else {
for($x = 0; $x < strlen($s); $x ++) {
if($dst[$x] == '1') {
if($strike)
$out .= $s[$x];
else
$out .= '<strike>'.$s[$x];
$strike = true;
}
else {
if($strike)
$out .= '</strike>';
$strike = false;
$out .= $s[$x];
}
}
}
// Many of the underline sequences are also wrapped in asterisks,
// which was yet another way of marking ASCII as 'bold'.
// So if it's an underline sequence, and there are asterisks
// on both ends, strip the asterisks as we've already emboldened the text.
$out = preg_replace('/\*(<strong>[^<]*<\/strong>)\*/',"\\1",$out);
// Finally, remove the backspace characters which we don't need anymore.
return str_replace("\010","",$out);
}
$result1 = do_query($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);
if(count($result1))
echo $result1[0];
if($stats)
do_stats($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);

View file

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

View file

@ -0,0 +1,7 @@
.fortunate {
margin-top: 25px;
margin-left: 100px;
margin-bottom: 25px;
color: #000088;
font-size: 14px;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* Name: Fortunate
* Description: Add a random fortune cookie at the bottom of every pages. [Requires manual confguration.]
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
function fortunate_load() {
register_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
}
function fortunate_unload() {
unregister_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
}
function fortunate_module(){}
function fortunate_fetch(&$a,&$b) {
$fort_server = get_config('fortunate','server');
if(! $fort_server)
return;
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
. $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
$s = z_fetch_url('http://' . $fort_server . '/cookie.php?numlines=4&equal=1&rand=' . mt_rand());
if($s['success'])
$b .= '<div class="fortunate">' . $s['body'] . '</div>';
}
function fortunate_content(&$a) {
// $o = '';
// fortunate_fetch($a,$o);
// return $o;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -0,0 +1,75 @@
<?php
require_once('include/cli_startup.php');
cli_startup();
$a = get_app();
$photo_id = $argv[1];
$channel_address = $argv[2];
$fr_server = urldecode($argv[3]);
require_once('include/photos.php');
$cookies = 'store/[data]/frphoto_cookie_' . $channel_address;
$c = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1",
dbesc($channel_address)
);
if(! $c) {
logger('frphotohelper: channel not found');
killme();
}
$channel = $c[0];
$ch = curl_init($fr_server . '/api/friendica/photo?f=&photo_id=' . $photo_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Hubzilla');
$output = curl_exec($ch);
curl_close($ch);
$j = json_decode($output,true);
// logger('frphotohelper: ' . print_r($j,true));
$args = array();
$args['data'] = base64_decode($j['data']);
$args['filename'] = $j['filename'];
$args['resource_id'] = $j['resource-id'];
$args['scale'] = $j['scale'];
$args['album'] = $j['album'];
$args['visible'] = 0;
$args['created'] = $j['created'];
$args['edited'] = $j['edited'];
$args['title'] = $j['title'];
$args['description'] = $j['desc'];
if($j['allow_cid'] || $j['allow_gid'] || $j['deny_cid'] || $j['deny_gid'])
$args['contact_allow'] = $channel['channel_hash'];
$args['type'] = $j['type'];
$r = q("select * from photo where resource_id = '%s' and uid = %d limit 1",
dbesc($args['resource_id']),
intval($channel['channel_id'])
);
if($r) {
killme();
}
$ret = photo_upload($channel,$channel,$args);
logger('photo_import: ' . print_r($ret,true));
killme();

View file

@ -0,0 +1,98 @@
<?php
/**
* Name: Friendica Photo Migrator
* Description: Migrate photo albums from Friendica to a Red channel
* Version: 1.0
* Author: Mike Macgirvin
*/
function frphotos_install() {}
function frphotos_uninstall() {}
function frphotos_module() {}
function frphotos_init(&$a) {
if(! local_channel())
return;
if(intval(get_pconfig(local_channel(),'frphotos','complete')))
return;
$channel = $a->get_channel();
$fr_server = $_REQUEST['fr_server'];
$fr_username = $_REQUEST['fr_username'];
$fr_password = $_REQUEST['fr_password'];
$cookies = 'store/[data]/frphoto_cookie_' . $channel['channel_address'];
if($fr_server && $fr_username && $fr_password) {
$ch = curl_init($fr_server . '/api/friendica/photos/list');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $fr_username . ':' . $fr_password);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Hubzilla');
$output = curl_exec($ch);
curl_close($ch);
$j = json_decode($output,true);
// echo print_r($j,true);
$total = 0;
if(count($j)) {
foreach($j as $jj) {
$r = q("select uid from photo where resource_id = '%s' and uid = %d limit 1",
dbesc($jj),
intval($channel['channel_id'])
);
if($r)
continue;
$total ++;
proc_run('php','addon/frphotos/frphotohelper.php',$jj, $channel['channel_address'], urlencode($fr_server));
sleep(3);
}
}
if($total) {
set_pconfig(local_channel(),'frphotos','complete','1');
}
@unlink($cookies);
goaway(z_root() . '/photos/' . $channel['channel_address']);
}
}
function frphotos_content(&$a) {
if(! local_channel()) {
notice( t('Permission denied') . EOL);
return;
}
if(intval(get_pconfig(local_channel(),'frphotos','complete'))) {
info('Friendica photos have already been imported into this channel.');
return;
}
$o = replace_macros(get_markup_template('frphotos.tpl','addon/frphotos'),array(
'$header' => t('Friendica Photo Album Import'),
'$desc' => t('This will import all your Friendica photo albums to this Red channel.'),
'$fr_server' => array('fr_server', t('Friendica Server base URL'),'',''),
'$fr_username' => array('fr_username', t('Friendica Login Username'),'',''),
'$fr_password' => array('fr_password', t('Friendica Login Password'),'',''),
'$submit' => t('Submit'),
));
return $o;
}

View file

@ -0,0 +1,13 @@
<h3>{{$header}}</h3>
<p class="descriptive-text">{{$desc}}</p>
<form action="frphotos" method="post" autocomplete="off" >
{{include file="field_input.tpl" field=$fr_server}}
{{include file="field_input.tpl" field=$fr_username}}
{{include file="field_password.tpl" field=$fr_password}}
<input type="submit" name="submit" value="{{$submit}}" />
</form>

View file

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

View file

@ -0,0 +1,185 @@
<?php
/**
* Name: Hexit
* Description: Hexadecimal Conversion Tool
* Version: 1.0
* Author: Macgirvin
*
*/
function hexit_load() {}
function hexit_unload() {}
function hexit_module() {}
function hexit_content(&$a) {
$o .= <<< EOT
<script type="text/javascript">
/**
* A function for converting hex <-> dec w/o loss of precision.
*
* The problem is that parseInt("0x12345...") isn't precise enough to convert
* 64-bit integers correctly.
*
* Internally, this uses arrays to encode decimal digits starting with the least
* significant:
* 8 = [8]
* 16 = [6, 1]
* 1024 = [4, 2, 0, 1]
*/
// Adds two arrays for the given base (10 or 16), returning the result.
// This turns out to be the only "primitive" operation we need.
function add(x, y, base) {
var z = [];
var n = Math.max(x.length, y.length);
var carry = 0;
var i = 0;
while (i < n || carry) {
var xi = i < x.length ? x[i] : 0;
var yi = i < y.length ? y[i] : 0;
var zi = carry + xi + yi;
z.push(zi % base);
carry = Math.floor(zi / base);
i++;
}
return z;
}
// Returns a*x, where x is an array of decimal digits and a is an ordinary
// JavaScript number. base is the number base of the array x.
function multiplyByNumber(num, x, base) {
if (num < 0) return null;
if (num == 0) return [];
var result = [];
var power = x;
while (true) {
if (num & 1) {
result = add(result, power, base);
}
num = num >> 1;
if (num === 0) break;
power = add(power, power, base);
}
return result;
}
function parseToDigitsArray(str, base) {
var digits = str.split('');
var ary = [];
for (var i = digits.length - 1; i >= 0; i--) {
var n = parseInt(digits[i], base);
if (isNaN(n)) return null;
ary.push(n);
}
return ary;
}
function convertBase(str, fromBase, toBase) {
var digits = parseToDigitsArray(str, fromBase);
if (digits === null) return null;
var outArray = [];
var power = [1];
for (var i = 0; i < digits.length; i++) {
// invariant: at this point, fromBase^i = power
if (digits[i]) {
outArray = add(outArray, multiplyByNumber(digits[i], power, toBase), toBase);
}
power = multiplyByNumber(fromBase, power, toBase);
}
var out = '';
for (var i = outArray.length - 1; i >= 0; i--) {
out += outArray[i].toString(toBase);
}
return out;
}
function decToHex(decStr) {
var hex = convertBase(decStr, 10, 16);
return hex ? '0x' + hex : null;
}
function hexToDec(hexStr) {
if (hexStr.substring(0, 2) === '0x') hexStr = hexStr.substring(2);
hexStr = hexStr.toLowerCase();
return convertBase(hexStr, 16, 10);
}
function str_or_null(x) {
return x === null ? 'null' : x;
}
// "1.234e+5" -> "12340"
function expandExponential(x) {
var pos = x.indexOf("e");
if (pos === -1) pos = x.indexOf("E");
if (pos === -1) return x;
var base = x.substring(0, pos);
var pow = parseInt(x.substring(pos + 1), 10);
if (pow < 0) return x; // not supported.
var dotPos = base.indexOf('.');
if (dotPos === -1) dotPos = base.length;
var ret = base.replace('.', '');
while (ret.length < dotPos + pow) ret += '0';
return ret;
}
function boldDifference(correct, actual) {
for (var i = 0, j = 0; i < correct.length && j < actual.length; i++, j++) {
if (correct[i] !== actual[j]) {
break;
}
}
if (j < actual.length) {
return actual.substring(0, j) + '<b>' + actual.substring(j) + '</b>';
} else {
return actual;
}
}
function convert() {
var input = document.getElementById("in").value;
if (input) {
var aHex = str_or_null(decToHex(input));
var aDec = str_or_null(hexToDec(input));
var bHex = '0x' + (parseInt(input, 10)).toString(16);
var bDec = "" + expandExponential("" +parseInt(input, 16));
var html = '<p></p><p>To Decimal(' + input + ') = ' + aDec + '</p>';
html += '<p>To Hex(' + input + ') = ' + aHex + '</p>';
document.getElementById('result').innerHTML = html;
}
}
convert();
</script>
<h2>Hexit</h2>
<p>Type in a hex or decimal string:</p>
<input type="text" size=40 id="in" onkeyup="convert()" value="" />
<p id="result"></p>
EOT;
return $o;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

View file

@ -0,0 +1,229 @@
<?php
/**
* Name: Insanejournal Post feature
* Description: Post to Insanejournal
* Version: 1.0
* Author: Tony Baldwin <https://red.free-haven.org/channel/tony>
* Author: Michael Johnston
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
require_once('include/permissions.php');
function ijpost_load() {
register_hook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local');
register_hook('notifier_normal', 'addon/ijpost/ijpost.php', 'ijpost_send');
register_hook('jot_networks', 'addon/ijpost/ijpost.php', 'ijpost_jot_nets');
register_hook('feature_settings', 'addon/ijpost/ijpost.php', 'ijpost_settings');
register_hook('feature_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post');
}
function ijpost_unload() {
unregister_hook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local');
unregister_hook('notifier_normal', 'addon/ijpost/ijpost.php', 'ijpost_send');
unregister_hook('jot_networks', 'addon/ijpost/ijpost.php', 'ijpost_jot_nets');
unregister_hook('feature_settings', 'addon/ijpost/ijpost.php', 'ijpost_settings');
unregister_hook('feature_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post');
}
function ijpost_jot_nets(&$a,&$b) {
if((! local_channel()) || (! perm_is_allowed(local_channel(),'','view_stream')))
return;
$ij_post = get_pconfig(local_channel(),'ijpost','post');
if(intval($ij_post) == 1) {
$ij_defpost = get_pconfig(local_channel(),'ijpost','post_by_default');
$selected = ((intval($ij_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="ijpost_enable" ' . $selected . ' value="1" /> '
. t('Post to Insanejournal') . '</div>';
}
}
function ijpost_settings(&$a,&$s) {
if(! local_channel())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
//$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/ijpost/ijpost.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variables */
$enabled = get_pconfig(local_channel(),'ijpost','post');
$checked = (($enabled) ? 1 : false);
$def_enabled = get_pconfig(local_channel(),'ijpost','post_by_default');
$def_checked = (($def_enabled) ? 1 : false);
$ij_username = get_pconfig(local_channel(), 'ijpost', 'ij_username');
$ij_password = z_unobscure(get_pconfig(local_channel(), 'ijpost', 'ij_password'));
/* Add some HTML to the existing form */
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('ijpost', t('Enable InsaneJournal Post Plugin'), $checked, '', array(t('No'),t('Yes'))),
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('ij_username', t('InsaneJournal username'), $ij_username, '')
));
$sc .= replace_macros(get_markup_template('field_password.tpl'), array(
'$field' => array('ij_password', t('InsaneJournal password'), $ij_password, '')
));
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('ij_bydefault', t('Post to InsaneJournal by default'), $def_checked, '', array(t('No'),t('Yes'))),
));
$s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
'$addon' => array('ijpost',t('InsaneJournal Post Settings'), '', t('Submit')),
'$content' => $sc
));
}
function ijpost_settings_post(&$a,&$b) {
if(x($_POST,'ijpost-submit')) {
set_pconfig(local_channel(),'ijpost','post',intval($_POST['ijpost']));
set_pconfig(local_channel(),'ijpost','post_by_default',intval($_POST['ij_bydefault']));
set_pconfig(local_channel(),'ijpost','ij_username',trim($_POST['ij_username']));
set_pconfig(local_channel(),'ijpost','ij_password',z_obscure(trim($_POST['ij_password'])));
info( t('Insane Journal Settings saved.') . EOL);
}
}
function ijpost_post_local(&$a,&$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
if($b['edit'])
return;
if((! local_channel()) || (local_channel() != $b['uid']))
return;
if($b['item_private'] || $b['parent'])
return;
$ij_post = intval(get_pconfig(local_channel(),'ijpost','post'));
$ij_enable = (($ij_post && x($_REQUEST,'ijpost_enable')) ? intval($_REQUEST['ijpost_enable']) : 0);
if($_REQUEST['api_source'] && intval(get_pconfig(local_channel(),'ijpost','post_by_default')))
$ij_enable = 1;
if(! $ij_enable)
return;
if(strlen($b['postopts']))
$b['postopts'] .= ',';
$b['postopts'] .= 'ijpost';
}
function ijpost_send(&$a,&$b) {
if((! is_item_normal($b)) || $b['item_private'] || ($b['created'] !== $b['edited']))
return;
if(! perm_is_allowed($b['uid'],'','view_stream'))
return;
if(! strstr($b['postopts'],'ijpost'))
return;
if($b['parent'] != $b['id'])
return;
logger('Insanejournal xpost invoked');
// insanejournal post in the LJ user's timezone.
// Hopefully the person's Friendica account
// will be set to the same thing.
$tz = 'UTC';
$x = q("select channel_timezone from channel where channel_id = %d limit 1",
intval($b['uid'])
);
if($x && strlen($x[0]['channel_timezone']))
$tz = $x[0]['channel_timezone'];
$ij_username = get_pconfig($b['uid'],'ijpost','ij_username');
$ij_password = z_unobscure(get_pconfig($b['uid'],'ijpost','ij_password'));
$ij_blog = 'http://www.insanejournal.com/interface/xmlrpc';
if($ij_username && $ij_password && $ij_blog) {
require_once('include/bbcode.php');
require_once('include/datetime.php');
$title = $b['title'];
$post = bbcode($b['body']);
$post = xmlify($post);
$tags = ijpost_get_tags($b['tag']);
$date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s');
$year = intval(substr($date,0,4));
$mon = intval(substr($date,5,2));
$day = intval(substr($date,8,2));
$hour = intval(substr($date,11,2));
$min = intval(substr($date,14,2));
$xml = <<< EOT
<?xml version="1.0" encoding="utf-8"?>
<methodCall><methodName>LJ.XMLRPC.postevent</methodName>
<params><param>
<value><struct>
<member><name>year</name><value><int>$year</int></value></member>
<member><name>mon</name><value><int>$mon</int></value></member>
<member><name>day</name><value><int>$day</int></value></member>
<member><name>hour</name><value><int>$hour</int></value></member>
<member><name>min</name><value><int>$min</int></value></member>
<member><name>event</name><value><string>$post</string></value></member>
<member><name>username</name><value><string>$ij_username</string></value></member>
<member><name>password</name><value><string>$ij_password</string></value></member>
<member><name>subject</name><value><string>$title</string></value></member>
<member><name>lineendings</name><value><string>unix</string></value></member>
<member><name>ver</name><value><int>1</int></value></member>
<member><name>props</name>
<value><struct>
<member><name>useragent</name><value><string>Hubzilla</string></value></member>
<member><name>taglist</name><value><string>$tags</string></value></member>
</struct></value></member>
</struct></value>
</param></params>
</methodCall>
EOT;
logger('ijpost: data: ' . $xml, LOGGER_DATA);
if($ij_blog !== 'test')
$x = z_post_url($ij_blog,$xml,array('headers' => array("Content-Type: text/xml")));
logger('posted to insanejournal: ' . print_r($x,true), LOGGER_DEBUG);
}
}
function ijpost_get_tags($post)
{
preg_match_all("/\]([^\[#]+)\[/",$post,$matches);
$tags = implode(', ',$matches[1]);
return $tags;
}

View file

@ -0,0 +1,46 @@
# ADDON ijpost
# Copyright (C)
# This file is distributed under the same license as the Friendica ijpost 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"
#: ijpost.php:39
msgid "Post to Insanejournal"
msgstr ""
#: ijpost.php:70
msgid "InsaneJournal Post Settings"
msgstr ""
#: ijpost.php:72
msgid "Enable InsaneJournal Post Plugin"
msgstr ""
#: ijpost.php:77
msgid "InsaneJournal username"
msgstr ""
#: ijpost.php:82
msgid "InsaneJournal password"
msgstr ""
#: ijpost.php:87
msgid "Post to InsaneJournal by default"
msgstr ""
#: ijpost.php:93
msgid "Submit"
msgstr ""

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Enviament a Insanejournal";
$a->strings["InsaneJournal Post Settings"] = "Ajustos d'Enviament a Insanejournal";
$a->strings["Enable InsaneJournal Post Plugin"] = "Habilita el Plugin d'Enviaments a Insanejournal";
$a->strings["InsaneJournal username"] = "Nom d'usuari de Insanejournal";
$a->strings["InsaneJournal password"] = "Contrasenya de Insanejournal";
$a->strings["Post to InsaneJournal by default"] = "Enviar per defecte a Insanejournal";
$a->strings["Submit"] = "Enviar";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Odeslat na Insanejournal";
$a->strings["InsaneJournal Post Settings"] = "Nastavení příspěvků pro InsaneJournal";
$a->strings["Enable InsaneJournal Post Plugin"] = "Povolit Insanejournal plugin";
$a->strings["InsaneJournal username"] = "Insanejournal uživatelské jméno";
$a->strings["InsaneJournal password"] = "Insanejournal heslo";
$a->strings["Post to InsaneJournal by default"] = "Defaultně zasílat příspěvky na InsaneJournal";
$a->strings["Submit"] = "Odeslat";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Auf InsaneJournal posten.";
$a->strings["InsaneJournal Post Settings"] = "InsaneJournal Beitrags-Einstellungen";
$a->strings["Enable InsaneJournal Post Plugin"] = "InsaneJournal Plugin aktivieren";
$a->strings["InsaneJournal username"] = "InsaneJournal Benutzername";
$a->strings["InsaneJournal password"] = "InsaneJournal Passwort";
$a->strings["Post to InsaneJournal by default"] = "Standardmäßig auf InsaneJournal posten.";
$a->strings["Submit"] = "Senden";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Afiŝi al Insanejournal";
$a->strings["InsaneJournal Post Settings"] = "Agordoj pri Insaenejournal Afiŝoj";
$a->strings["Enable InsaneJournal Post Plugin"] = "Ŝalti la InsaneJournal afiŝo kromprogramon.";
$a->strings["InsaneJournal username"] = "Salutnomo ĉe InsaneJournal";
$a->strings["InsaneJournal password"] = "Pasvorto ĉe InsaneJournal";
$a->strings["Post to InsaneJournal by default"] = "Defaŭlte afiŝi ĉe InsaneJournal";
$a->strings["Submit"] = "Sendi";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Publicar en Insanejournal";
$a->strings["InsaneJournal Post Settings"] = "Configuración de publicación en Insanejournal";
$a->strings["Enable InsaneJournal Post Plugin"] = "Activar el módulo de publicación en Insanejournal";
$a->strings["InsaneJournal username"] = "Nombre de usuario de Insanejournal";
$a->strings["InsaneJournal password"] = "Contraseña de Insanejournal";
$a->strings["Post to InsaneJournal by default"] = "Publicar en Insanejournal por defecto";
$a->strings["Submit"] = "Envíar";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "Publier vers InsaneJournal";
$a->strings["InsaneJournal Post Settings"] = "Réglages InsaneJournal";
$a->strings["Enable InsaneJournal Post Plugin"] = "Activer le connecteur InsaneJournal";
$a->strings["InsaneJournal username"] = "Utilisateur InsaneJournal";
$a->strings["InsaneJournal password"] = "Mot de passe InsaneJournal";
$a->strings["Post to InsaneJournal by default"] = "Publier sur InsaneJournal par défaut";
$a->strings["Submit"] = "Envoyer";

View file

@ -0,0 +1,9 @@
<?php
$a->strings["Post to Insanejournal"] = "";
$a->strings["InsaneJournal Post Settings"] = "";
$a->strings["Enable InsaneJournal Post Plugin"] = "";
$a->strings["InsaneJournal username"] = "";
$a->strings["InsaneJournal password"] = "";
$a->strings["Post to InsaneJournal by default"] = "";
$a->strings["Submit"] = "Senda inn";

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