Commit cb2a3989 authored by ivan zlax's avatar ivan zlax

init, based on ljpost addon

parents
Addons ussr.win
===============
These are addons for ussr.win
# ADDON ljrpost
# Copyright (C)
# This file is distributed under the same license as the Friendica ljpost 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"
#: ljrpost.php:39
msgid "Post to LJRossia"
msgstr ""
#: ljrpost.php:70
msgid "LJRossia Post Settings"
msgstr ""
#: ljrpost.php:72
msgid "Enable LJRossia Post Plugin"
msgstr ""
#: ljrpost.php:77
msgid "LJRossia username"
msgstr ""
#: ljrpost.php:82
msgid "LJRossia password"
msgstr ""
#: ljrpost.php:87
msgid "Post to LJRossia by default"
msgstr ""
#: ljrpost.php:93
msgid "Submit"
msgstr ""
<?php
App::$strings["Post to LJRossia"] = "Missatge a Livejournal";
App::$strings["LJRossia Post Settings"] = "Configuració d'enviaments a Livejournal";
App::$strings["Enable LJRossia Post Plugin"] = "Habilitat el plugin d'enviaments a Livejournal";
App::$strings["LJRossia username"] = "Nom d'usuari a Livejournal";
App::$strings["LJRossia password"] = "Contrasenya a Livejournal";
App::$strings["Post to LJRossia by default"] = "Enviar per defecte a Livejournal";
App::$strings["Submit"] = "Enviar";
<?php
App::$strings["Post to LJRossia"] = "Poslat na LJRossia";
App::$strings["LJRossia Post Settings"] = "Nastavení LJRossia Post";
App::$strings["Enable LJRossia Post Plugin"] = "Povolit LJRossia Post plugin";
App::$strings["LJRossia username"] = "LJRossia uživatelské jméno";
App::$strings["LJRossia password"] = "LJRossia heslo";
App::$strings["Post to LJRossia by default"] = "Defaultně umístit na LJRossia";
App::$strings["Submit"] = "Odeslat";
<?php
App::$strings["Post to LJRossia"] = "In LJRossia veröffentlichen.";
App::$strings["LJRossia Post Settings"] = "LJRossia Veröffentlichungs-Einstellungen";
App::$strings["Enable LJRossia Post Plugin"] = "LJRossia Post Plugin aktivieren";
App::$strings["LJRossia username"] = "LJRossia Benutzername";
App::$strings["LJRossia password"] = "LJRossia Passwort";
App::$strings["Post to LJRossia by default"] = "Standardmäßig bei LJRossia veröffentlichen";
App::$strings["Submit"] = "Senden";
<?php
App::$strings["Post to LJRossia"] = "Afiŝi ĉe LJRossia";
App::$strings["LJRossia Post Settings"] = "Agordoj pri afiŝoj ĉe LJRossia";
App::$strings["Enable LJRossia Post Plugin"] = "Ŝalti la LJRossia-afiŝo kromprogramon.";
App::$strings["LJRossia username"] = "LJRossia Salutnomo";
App::$strings["LJRossia password"] = "LJRossia pasvorto";
App::$strings["Post to LJRossia by default"] = "Defaŭlte afiŝi al LJRossia";
App::$strings["Submit"] = "Sendi";
<?php
App::$strings["Post to LJRossia"] = "Publicar en Livejournal";
App::$strings["LJRossia Post Settings"] = "Configuración de las publicaciones en Livejournal";
App::$strings["Enable LJRossia Post Plugin"] = "Activar el módulo de publicación en Livejournal";
App::$strings["LJRossia username"] = "Nombre de usuario de Livejournal";
App::$strings["LJRossia password"] = "Contraseña de Livejournal";
App::$strings["Post to LJRossia by default"] = "Publicar en Livejournal por defecto";
App::$strings["Submit"] = "Envíar";
<?php
App::$strings["Post to LJRossia"] = "Poster vers LJRossia";
App::$strings["LJRossia Post Settings"] = "Réglages LJRossia";
App::$strings["Enable LJRossia Post Plugin"] = "Activer \"Poster vers LJRossia\"";
App::$strings["LJRossia username"] = "Nom d'utilisateur LJRossia";
App::$strings["LJRossia password"] = "Mot de passe";
App::$strings["Post to LJRossia by default"] = "Poster vers LJRossia par défaut";
App::$strings["Submit"] = "Envoyer";
<?php
App::$strings["Post to LJRossia"] = "";
App::$strings["LJRossia Post Settings"] = "";
App::$strings["Enable LJRossia Post Plugin"] = "";
App::$strings["LJRossia username"] = "";
App::$strings["LJRossia password"] = "";
App::$strings["Post to LJRossia by default"] = "";
App::$strings["Submit"] = "Senda inn";
<?php
App::$strings["Post to LJRossia"] = "Posta su LJRossia";
App::$strings["LJRossia Post Settings"] = "Impostazioni post LJRossia";
App::$strings["Enable LJRossia Post Plugin"] = "Abilita il plugin LJRossia";
App::$strings["LJRossia username"] = "LJRossia username";
App::$strings["LJRossia password"] = "LJRossia password";
App::$strings["Post to LJRossia by default"] = "Posta su LJRossia di default";
App::$strings["Submit"] = "Invia";
<?php
App::$strings["Post to LJRossia"] = "";
App::$strings["LJRossia Post Settings"] = "";
App::$strings["Enable LJRossia Post Plugin"] = "";
App::$strings["LJRossia username"] = "";
App::$strings["LJRossia password"] = "";
App::$strings["Post to LJRossia by default"] = "";
App::$strings["Submit"] = "Lagre";
<?php
App::$strings["Post to LJRossia"] = "Doorplaatsen naar LJRossia";
App::$strings["LJRossia Post Settings"] = "LJRossia (berichten doorplaatsen)";
App::$strings["Enable LJRossia Post Plugin"] = "Doorplaatsen naar LJRossia inschakelen";
App::$strings["LJRossia username"] = "Gebruikersnaam LJRossia";
App::$strings["LJRossia password"] = "Wachtwoord LJRossia";
App::$strings["Post to LJRossia by default"] = "Berichten standaard naar LJRossia doorplaatsen";
App::$strings["Submit"] = "Opslaan";
<?php
App::$strings["Post to LJRossia"] = "Post do LJRossia";
App::$strings["LJRossia Post Settings"] = "Ustawienia postów do LJRossia";
App::$strings["Enable LJRossia Post Plugin"] = "";
App::$strings["LJRossia username"] = "Nazwa użytkownika do LJRossia";
App::$strings["LJRossia password"] = "Hasło do LJRossia";
App::$strings["Post to LJRossia by default"] = "automatycznie publikuj na LJRossia";
App::$strings["Submit"] = "Potwierdź";
<?php
App::$strings["Post to LJRossia"] = "Publicar no LJRossia";
App::$strings["LJRossia Post Settings"] = "Configurações de publicação no LJRossia";
App::$strings["Enable LJRossia Post Plugin"] = "Habilitar o plugin de publicação no LJRossia";
App::$strings["LJRossia username"] = "Nome de usuário do LJRossia";
App::$strings["LJRossia password"] = "Senha do LJRossia";
App::$strings["Post to LJRossia by default"] = "Publicar no LJRossia por padrão";
App::$strings["Submit"] = "Enviar";
<?php
App::$strings["Post to LJRossia"] = "";
App::$strings["LJRossia Post Settings"] = "";
App::$strings["Enable LJRossia Post Plugin"] = "Включить LJRossia плагин сообщений";
App::$strings["LJRossia username"] = "";
App::$strings["LJRossia password"] = "";
App::$strings["Post to LJRossia by default"] = "";
App::$strings["Submit"] = "Подтвердить";
<?php
App::$strings["Submit"] = "Spara";
<?php
App::$strings["Post to LJRossia"] = "转播到LJRossia";
App::$strings["LJRossia Post Settings"] = "LJRossia转播设置";
App::$strings["Enable LJRossia Post Plugin"] = "使Livejournal转播插件可用";
App::$strings["LJRossia username"] = "LJRossia用户名";
App::$strings["LJRossia password"] = "LJRossia密码";
App::$strings["Post to LJRossia by default"] = "默认地转播到LJRossia";
App::$strings["Submit"] = "提交";
<?php
/**
* Name: LJRossia Post feature
* Description: Post to LJRossia
* 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>
* Maintainer: zlax
*/
require_once('include/permissions.php');
function ljrpost_load() {
register_hook('post_local', 'addon/ljrpost/ljrpost.php', 'ljrpost_post_local');
register_hook('notifier_normal', 'addon/ljrpost/ljrpost.php', 'ljrpost_send');
register_hook('jot_networks', 'addon/ljrpost/ljrpost.php', 'ljrpost_jot_nets');
register_hook('feature_settings', 'addon/ljrpost/ljrpost.php', 'ljrpost_settings');
register_hook('feature_settings_post', 'addon/ljrpost/ljrpost.php', 'ljrpost_settings_post');
}
function ljrpost_unload() {
unregister_hook('post_local', 'addon/ljrpost/ljrpost.php', 'ljrpost_post_local');
unregister_hook('notifier_normal', 'addon/ljrpost/ljrpost.php', 'ljrpost_send');
unregister_hook('jot_networks', 'addon/ljrpost/ljrpost.php', 'ljrpost_jot_nets');
unregister_hook('feature_settings', 'addon/ljrpost/ljrpost.php', 'ljrpost_settings');
unregister_hook('feature_settings_post', 'addon/ljrpost/ljrpost.php', 'ljrpost_settings_post');
}
function ljrpost_jot_nets(&$a,&$b) {
if((! local_channel()) || (! perm_is_allowed(local_channel(),'','view_stream',false)))
return;
$ljr_post = get_pconfig(local_channel(),'ljrpost','post');
if(intval($ljr_post) == 1) {
$ljr_defpost = get_pconfig(local_channel(),'ljrpost','post_by_default');
$selected = ((intval($ljr_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="ljrpost_enable" ' . $selected . ' value="1" /> '
. t('Post to LJRossia') . '</div>';
}
}
function ljrpost_settings(&$a,&$s) {
if(! local_channel())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
//App::$page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . z_root() . '/addon/ljrpost/ljrpost.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variables */
$enabled = get_pconfig(local_channel(),'ljrpost','post');
$checked = (($enabled) ? 1 : false);
$def_enabled = get_pconfig(local_channel(),'ljrpost','post_by_default');
$def_checked = (($def_enabled) ? 1 : false);
$ljr_username = get_pconfig(local_channel(), 'ljrpost', 'ljr_username');
$ljr_password = z_unobscure(get_pconfig(local_channel(), 'ljrpost', 'ljr_password'));
/* Add some HTML to the existing form */
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('ljrpost', t('Enable LJRossia Post Plugin'), $checked, '', array(t('No'),t('Yes'))),
));
$sc .= replace_macros(get_markup_template('field_input.tpl'), array(
'$field' => array('ljr_username', t('LJRossia username'), $ljr_username, '')
));
$sc .= replace_macros(get_markup_template('field_password.tpl'), array(
'$field' => array('ljr_password', t('LJRossia password'), $ljr_password, '')
));
$sc .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
'$field' => array('ljr_bydefault', t('Post to LJRossia by default'), $def_checked, '', array(t('No'),t('Yes'))),
));
$s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
'$addon' => array('ljrpost',t('LJRossia Post Settings'), '', t('Submit')),
'$content' => $sc
));
}
function ljrpost_settings_post(&$a,&$b) {
if(x($_POST,'ljrpost-submit')) {
set_pconfig(local_channel(),'ljrpost','post',intval($_POST['ljrpost']));
set_pconfig(local_channel(),'ljrpost','post_by_default',intval($_POST['ljr_bydefault']));
set_pconfig(local_channel(),'ljrpost','ljr_username',trim($_POST['ljr_username']));
set_pconfig(local_channel(),'ljrpost','ljr_password',z_obscure(trim($_POST['ljr_password'])));
}
}
function ljrpost_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('LJRossia xpost invoked');
$ljr_post = intval(get_pconfig(local_channel(),'ljrpost','post'));
$ljr_enable = (($ljr_post && x($_REQUEST,'ljrpost_enable')) ? intval($_REQUEST['ljrpost_enable']) : 0);
if($_REQUEST['api_source'] && intval(get_pconfig(local_channel(),'ljrpost','post_by_default')))
$ljr_enable = 1;
if(! $ljr_enable)
return;
if(strlen($b['postopts']))
$b['postopts'] .= ',';
$b['postopts'] .= 'ljrpost';
}
function ljrpost_send(&$a,&$b) {
if((! is_item_normal($b)) || $b['item_private'] || ($b['created'] !== $b['edited']))
return;
if(! perm_is_allowed($b['uid'],'','view_stream',false))
return;
if(! strstr($b['postopts'],'ljrpost'))
return;
if($b['parent'] != $b['id'])
return;
// LJRossia 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'];
$ljr_username = get_pconfig($b['uid'],'ljrpost','ljr_username');
$ljr_password = z_unobscure(get_pconfig($b['uid'],'ljrpost','ljr_password'));
$ljr_blog = 'https://lj.rossia.org/interface/xmlrpc';
if($ljr_username && $ljr_password && $ljr_blog) {
require_once('include/bbcode.php');
require_once('include/datetime.php');
$title = $b['title'];
$post = bbcode($b['body']);
$post = xmlify($post);
$tags = ljrpost_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>$ljr_username</string></value></member>
<member><name>password</name><value><string>$ljr_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('ljrpost: data: ' . $xml, LOGGER_DATA);
if($ljr_blog !== 'test') {
$recurse = 0;
$x = z_post_url($ljr_blog,$xml,$recurse,array('headers' => array("Content-Type: text/xml")));
}
logger('posted to LJRossia: ' . print_r($x,true), LOGGER_DEBUG);
}
}
function ljrpost_get_tags($post)
{
preg_match_all("/\]([^\[#]+)\[/",$post,$matches);
$tags = implode(', ',$matches[1]);
return $tags;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment