And again some removed notices #660
|
@ -40,7 +40,6 @@ use Friendica\Core\Cache;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Term;
|
use Friendica\Model\Term;
|
||||||
|
@ -119,7 +118,7 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data)
|
||||||
|
|
||||||
$rules = Cache::get('rules_' . local_user());
|
$rules = Cache::get('rules_' . local_user());
|
||||||
if (!isset($rules)) {
|
if (!isset($rules)) {
|
||||||
$rules = DBA::inArray(DBA::select(
|
$rules = DBA::toArray(DBA::select(
|
||||||
'advancedcontentfilter_rules',
|
'advancedcontentfilter_rules',
|
||||||
['name', 'expression', 'serialized'],
|
['name', 'expression', 'serialized'],
|
||||||
['uid' => local_user(), 'active' => true]
|
['uid' => local_user(), 'active' => true]
|
||||||
|
@ -300,7 +299,7 @@ function advancedcontentfilter_get_rules()
|
||||||
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
|
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules = DBA::inArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
|
$rules = DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
|
||||||
|
|
||||||
return json_encode($rules);
|
return json_encode($rules);
|
||||||
}
|
}
|
||||||
|
@ -414,7 +413,7 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
|
||||||
$params = ['order' => ['uid' => true]];
|
$params = ['order' => ['uid' => true]];
|
||||||
$item = Item::selectFirstForUser(local_user(), [], $condition, $params);
|
$item = Item::selectFirstForUser(local_user(), [], $condition, $params);
|
||||||
|
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid']));
|
throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
|
@ -86,7 +85,7 @@ function catavatar_addon_settings_post(App $a, &$s)
|
||||||
$url = $a->get_baseurl() . '/catavatar/' . local_user() . '?ts=' . time();
|
$url = $a->get_baseurl() . '/catavatar/' . local_user() . '?ts=' . time();
|
||||||
|
|
||||||
$self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
|
$self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
|
||||||
if (!DBM::is_result($self)) {
|
if (!DBA::isResult($self)) {
|
||||||
notice(L10n::t("The cat hadn't found itself."));
|
notice(L10n::t("The cat hadn't found itself."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +94,7 @@ function catavatar_addon_settings_post(App $a, &$s)
|
||||||
|
|
||||||
$condition = ['uid' => local_user(), 'contact-id' => $self['id']];
|
$condition = ['uid' => local_user(), 'contact-id' => $self['id']];
|
||||||
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
||||||
if (!DBM::is_result($photo)) {
|
if (!DBA::isResult($photo)) {
|
||||||
notice(L10n::t('There was an error, the cat ran away.'));
|
notice(L10n::t('There was an error, the cat ran away.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#curweather-network img {
|
#curweather-network img {
|
||||||
float: left;
|
float: left;
|
||||||
margin: 30px 10px;
|
|
||||||
}
|
}
|
||||||
ul.curweather-details li {
|
ul.curweather-details li {
|
||||||
list-type: none;
|
list-type: none;
|
||||||
}
|
}
|
||||||
p.curweather-footer {
|
div.curweather-footer {
|
||||||
|
margin-top: 10px;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
<div id="curweather-network" class="widget">
|
<div id="curweather-network" class="widget">
|
||||||
<div class="title tool">
|
<div class="title tool clear">
|
||||||
<h3 title="{{$lastupdate}}">{{$title}}: {{$city}}</h3>
|
<h3 title="{{$lastupdate}}">{{$title}}: {{$city}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<div class="pull-left">
|
||||||
<img src="{{$icon}}" title="{{$description}}">
|
<img src="{{$icon}}" title="{{$description}}">
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
<ul class="curweather-details">
|
<ul class="curweather-details">
|
||||||
<li><strong>{{$temp}}</strong></li>
|
<li><strong>{{$temp}}</strong></li>
|
||||||
<li>{{$relhumidity['caption']}}: {{$relhumidity['val']}}</li>
|
<li>{{$relhumidity['caption']}}: {{$relhumidity['val']}}</li>
|
||||||
<li>{{$pressure['caption']}}: {{$pressure['val']}}</li>
|
<li>{{$pressure['caption']}}: {{$pressure['val']}}</li>
|
||||||
<li>{{$wind['caption']}}: {{$wind['val']}}</li>
|
<li>{{$wind['caption']}}: {{$wind['val']}}</li>
|
||||||
</ul></p>
|
</ul>
|
||||||
<p class="curweather-footer">
|
</div>
|
||||||
{{$databy}}: <a href="http://openweathermap.org">OpenWeatherMap</a>. <a href="http://openweathermap.org/weathermap?basemap=map&cities=true&layer=temperature&lat={{$lat}}&lon={{$lon}}&zoom=10">{{$showonmap}}</a>
|
<div class="clear"></div>
|
||||||
</p>
|
<div class="curweather-footer pull-left">
|
||||||
|
{{$databy}}: <a href="http://openweathermap.org">OpenWeatherMap</a>.
|
||||||
|
</div>
|
||||||
|
<div class="curweather-footer pull-right">
|
||||||
|
<a href="http://openweathermap.org/weathermap?basemap=map&cities=true&layer=temperature&lat={{$lat}}&lon={{$lon}}&zoom=10">{{$showonmap}}</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
|
@ -9,15 +9,16 @@
|
||||||
|
|
||||||
require_once 'addon/diaspora/Diaspora_Connection.php';
|
require_once 'addon/diaspora/Diaspora_Connection.php';
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Queue;
|
use Friendica\Model\Queue;
|
||||||
|
|
||||||
function diaspora_install() {
|
function diaspora_install()
|
||||||
|
{
|
||||||
Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
||||||
|
@ -25,7 +26,9 @@ function diaspora_install() {
|
||||||
Addon::registerHook('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
Addon::registerHook('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
||||||
Addon::registerHook('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
Addon::registerHook('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
||||||
}
|
}
|
||||||
function diaspora_uninstall() {
|
|
||||||
|
function diaspora_uninstall()
|
||||||
|
{
|
||||||
Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
||||||
|
@ -34,32 +37,39 @@ function diaspora_uninstall() {
|
||||||
Addon::unregisterHook('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
Addon::unregisterHook('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function diaspora_jot_nets(App $a, &$b)
|
||||||
function diaspora_jot_nets(&$a,&$b) {
|
{
|
||||||
if(! local_user())
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$diaspora_post = PConfig::get(local_user(), 'diaspora', 'post');
|
$diaspora_post = PConfig::get(local_user(), 'diaspora', 'post');
|
||||||
|
|
||||||
if (intval($diaspora_post) == 1) {
|
if (intval($diaspora_post) == 1) {
|
||||||
$diaspora_defpost = PConfig::get(local_user(), 'diaspora', 'post_by_default');
|
$diaspora_defpost = PConfig::get(local_user(), 'diaspora', 'post_by_default');
|
||||||
|
|
||||||
$selected = ((intval($diaspora_defpost) == 1) ? ' checked="checked" ' : '');
|
$selected = ((intval($diaspora_defpost) == 1) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspora_enable"' . $selected . ' value="1" /> '
|
$b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspora_enable"' . $selected . ' value="1" /> '
|
||||||
. L10n::t('Post to Diaspora') . '</div>';
|
. L10n::t('Post to Diaspora') . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_queue_hook(&$a,&$b) {
|
function diaspora_queue_hook(App $a, &$b) {
|
||||||
$hostname = $a->get_hostname();
|
$hostname = $a->get_hostname();
|
||||||
|
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||||
dbesc(NETWORK_DIASPORA2)
|
DBA::escape(NETWORK_DIASPORA2)
|
||||||
);
|
);
|
||||||
if(! count($qi))
|
|
||||||
|
if (!DBA::isResult($qi)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($qi as $x) {
|
foreach ($qi as $x) {
|
||||||
if($x['network'] !== NETWORK_DIASPORA2)
|
if ($x['network'] !== NETWORK_DIASPORA2) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
logger('diaspora_queue: run');
|
logger('diaspora_queue: run');
|
||||||
|
|
||||||
|
@ -67,8 +77,10 @@ function diaspora_queue_hook(&$a,&$b) {
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
||||||
intval($x['cid'])
|
intval($x['cid'])
|
||||||
);
|
);
|
||||||
if(! count($r))
|
|
||||||
|
if (!DBA::isResult($r)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$userdata = $r[0];
|
$userdata = $r[0];
|
||||||
|
|
||||||
|
@ -115,10 +127,11 @@ function diaspora_queue_hook(&$a,&$b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_settings(&$a,&$s) {
|
function diaspora_settings(App $a, &$s)
|
||||||
|
{
|
||||||
if(! local_user())
|
if (! local_user()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||||
|
|
||||||
|
@ -141,7 +154,8 @@ function diaspora_settings(&$a,&$s) {
|
||||||
$status = "";
|
$status = "";
|
||||||
|
|
||||||
$r = q("SELECT `addr` FROM `contact` WHERE `self` AND `uid` = %d", intval(local_user()));
|
$r = q("SELECT `addr` FROM `contact` WHERE `self` AND `uid` = %d", intval(local_user()));
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
|
if (DBA::isResult($r)) {
|
||||||
$status = L10n::t("Please remember: You can always be reached from Diaspora with your Friendica handle %s. ", $r[0]['addr']);
|
$status = L10n::t("Please remember: You can always be reached from Diaspora with your Friendica handle %s. ", $r[0]['addr']);
|
||||||
$status .= L10n::t('This connector is only meant if you still want to use your old Diaspora account for some time. ');
|
$status .= L10n::t('This connector is only meant if you still want to use your old Diaspora account for some time. ');
|
||||||
$status .= L10n::t('However, it is preferred that you tell your Diaspora contacts the new handle %s instead.', $r[0]['addr']);
|
$status .= L10n::t('However, it is preferred that you tell your Diaspora contacts the new handle %s instead.', $r[0]['addr']);
|
||||||
|
@ -153,6 +167,7 @@ function diaspora_settings(&$a,&$s) {
|
||||||
$conn = new Diaspora_Connection($handle, $password);
|
$conn = new Diaspora_Connection($handle, $password);
|
||||||
$conn->logIn();
|
$conn->logIn();
|
||||||
$aspects = $conn->getAspects();
|
$aspects = $conn->getAspects();
|
||||||
|
|
||||||
if (!$aspects) {
|
if (!$aspects) {
|
||||||
$status = L10n::t("Can't login to your Diaspora account. Please check handle (in the format user@domain.tld) and password.");
|
$status = L10n::t("Can't login to your Diaspora account. Please check handle (in the format user@domain.tld) and password.");
|
||||||
}
|
}
|
||||||
|
@ -225,21 +240,19 @@ function diaspora_settings(&$a,&$s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function diaspora_settings_post(&$a,&$b) {
|
function diaspora_settings_post(App $a, &$b)
|
||||||
|
{
|
||||||
if(x($_POST,'diaspora-submit')) {
|
if (!empty($_POST['diaspora-submit'])) {
|
||||||
|
|
||||||
PConfig::set(local_user(),'diaspora', 'post' , intval($_POST['diaspora']));
|
PConfig::set(local_user(),'diaspora', 'post' , intval($_POST['diaspora']));
|
||||||
PConfig::set(local_user(),'diaspora', 'post_by_default', intval($_POST['diaspora_bydefault']));
|
PConfig::set(local_user(),'diaspora', 'post_by_default', intval($_POST['diaspora_bydefault']));
|
||||||
PConfig::set(local_user(),'diaspora', 'handle' , trim($_POST['handle']));
|
PConfig::set(local_user(),'diaspora', 'handle' , trim($_POST['handle']));
|
||||||
PConfig::set(local_user(),'diaspora', 'password' , trim($_POST['password']));
|
PConfig::set(local_user(),'diaspora', 'password' , trim($_POST['password']));
|
||||||
PConfig::set(local_user(),'diaspora', 'aspect' , trim($_POST['aspect']));
|
PConfig::set(local_user(),'diaspora', 'aspect' , trim($_POST['aspect']));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_post_local(&$a,&$b) {
|
function diaspora_post_local(App $a, array &$b)
|
||||||
|
{
|
||||||
if ($b['edit']) {
|
if ($b['edit']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,10 +284,8 @@ function diaspora_post_local(&$a,&$b) {
|
||||||
$b['postopts'] .= 'diaspora';
|
$b['postopts'] .= 'diaspora';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function diaspora_send(App $a, array &$b)
|
||||||
|
{
|
||||||
|
|
||||||
function diaspora_send(&$a,&$b) {
|
|
||||||
$hostname = $a->get_hostname();
|
$hostname = $a->get_hostname();
|
||||||
|
|
||||||
logger('diaspora_send: invoked');
|
logger('diaspora_send: invoked');
|
||||||
|
@ -294,6 +305,7 @@ function diaspora_send(&$a,&$b) {
|
||||||
// Dont't post if the post doesn't belong to us.
|
// Dont't post if the post doesn't belong to us.
|
||||||
// This is a check for forum postings
|
// This is a check for forum postings
|
||||||
$self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
|
$self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
|
||||||
|
|
||||||
if ($b['contact-id'] != $self['id']) {
|
if ($b['contact-id'] != $self['id']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -316,8 +328,10 @@ function diaspora_send(&$a,&$b) {
|
||||||
$tag_arr[] = $mtch[2];
|
$tag_arr[] = $mtch[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count($tag_arr))
|
|
||||||
|
if (count($tag_arr)) {
|
||||||
$tags = implode(',',$tag_arr);
|
$tags = implode(',',$tag_arr);
|
||||||
|
}
|
||||||
|
|
||||||
$title = $b['title'];
|
$title = $b['title'];
|
||||||
$body = $b['body'];
|
$body = $b['body'];
|
||||||
|
@ -341,10 +355,11 @@ function diaspora_send(&$a,&$b) {
|
||||||
$body = BBCode::toMarkdown($body);
|
$body = BBCode::toMarkdown($body);
|
||||||
|
|
||||||
// Adding the title
|
// Adding the title
|
||||||
if(strlen($title))
|
if (strlen($title)) {
|
||||||
$body = "## ".html_entity_decode($title)."\n\n".$body;
|
$body = "## ".html_entity_decode($title)."\n\n".$body;
|
||||||
|
}
|
||||||
|
|
||||||
require_once("addon/diaspora/diasphp.php");
|
require_once "addon/diaspora/diasphp.php";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger('diaspora_send: prepare', LOGGER_DEBUG);
|
logger('diaspora_send: prepare', LOGGER_DEBUG);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
|
||||||
|
@ -100,14 +100,14 @@ function forumdirectory_content(&$a)
|
||||||
if (strlen($search)) {
|
if (strlen($search)) {
|
||||||
$sql_extra = " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,"
|
$sql_extra = " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,"
|
||||||
. "`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` )"
|
. "`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` )"
|
||||||
. " AGAINST ('" . dbesc($search) . "' IN BOOLEAN MODE) ";
|
. " AGAINST ('" . DBA::escape($search) . "' IN BOOLEAN MODE) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$publish = Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ";
|
$publish = Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ";
|
||||||
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`"
|
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`"
|
||||||
. " WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
|
. " WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$a->set_pager_total($r[0]['total']);
|
$a->set_pager_total($r[0]['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ function forumdirectory_content(&$a)
|
||||||
intval($a->pager['itemspage'])
|
intval($a->pager['itemspage'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
if (in_array('small', $a->argv)) {
|
if (in_array('small', $a->argv)) {
|
||||||
$photo = 'thumb';
|
$photo = 'thumb';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
* Version: 1.1
|
* Version: 1.1
|
||||||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs the addon hook
|
* Installs the addon hook
|
||||||
|
@ -29,7 +32,7 @@ function gravatar_uninstall() {
|
||||||
logger("unregistered gravatar in avatar_lookup hook");
|
logger("unregistered gravatar in avatar_lookup hook");
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravatar_load_config(\Friendica\App $a)
|
function gravatar_load_config(App $a)
|
||||||
{
|
{
|
||||||
$a->loadConfigFile(__DIR__. '/config/gravatar.ini.php');
|
$a->loadConfigFile(__DIR__. '/config/gravatar.ini.php');
|
||||||
}
|
}
|
||||||
|
@ -93,7 +96,7 @@ function gravatar_addon_admin (&$a, &$o) {
|
||||||
|
|
||||||
// Check if Libravatar is enabled and show warning
|
// Check if Libravatar is enabled and show warning
|
||||||
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
|
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
|
||||||
dbesc('libravatar')
|
DBA::escape('libravatar')
|
||||||
);
|
);
|
||||||
if (count($r)) {
|
if (count($r)) {
|
||||||
$o = '<h5>' .L10n::t('Information') .'</h5><p>' .L10n::t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
|
$o = '<h5>' .L10n::t('Information') .'</h5><p>' .L10n::t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
|
||||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
|
||||||
function ifttt_install()
|
function ifttt_install()
|
||||||
|
@ -102,7 +101,7 @@ function ifttt_post(App $a)
|
||||||
$nickname = $a->argv[1];
|
$nickname = $a->argv[1];
|
||||||
|
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
||||||
if (!DBM::is_result($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
|
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ function jappixmini_init()
|
||||||
|
|
||||||
$role = $_REQUEST["role"];
|
$role = $_REQUEST["role"];
|
||||||
if ($role == "pub") {
|
if ($role == "pub") {
|
||||||
$r = q("SELECT * FROM `contact` WHERE LENGTH(`pubkey`) AND `dfrn-id`='%s' LIMIT 1", dbesc($dfrn_id));
|
$r = q("SELECT * FROM `contact` WHERE LENGTH(`pubkey`) AND `dfrn-id`='%s' LIMIT 1", DBA::escape($dfrn_id));
|
||||||
if (!count($r)) {
|
if (!count($r)) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@ function jappixmini_init()
|
||||||
$decrypt_func = openssl_public_decrypt;
|
$decrypt_func = openssl_public_decrypt;
|
||||||
$key = $r[0]["pubkey"];
|
$key = $r[0]["pubkey"];
|
||||||
} else if ($role == "prv") {
|
} else if ($role == "prv") {
|
||||||
$r = q("SELECT * FROM `contact` WHERE LENGTH(`prvkey`) AND `issued-id`='%s' LIMIT 1", dbesc($dfrn_id));
|
$r = q("SELECT * FROM `contact` WHERE LENGTH(`prvkey`) AND `issued-id`='%s' LIMIT 1", DBA::escape($dfrn_id));
|
||||||
if (!count($r)) {
|
if (!count($r)) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
@ -524,7 +525,7 @@ function jappixmini_script(App $a)
|
||||||
$key = $row['k'];
|
$key = $row['k'];
|
||||||
$pos = strpos($key, ":");
|
$pos = strpos($key, ":");
|
||||||
$dfrn_id = substr($key, $pos + 1);
|
$dfrn_id = substr($key, $pos + 1);
|
||||||
$r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')", dbesc($dfrn_id), dbesc($dfrn_id));
|
$r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')", DBA::escape($dfrn_id), DBA::escape($dfrn_id));
|
||||||
if (count($r))
|
if (count($r))
|
||||||
$name = $r[0]["name"];
|
$name = $r[0]["name"];
|
||||||
|
|
||||||
|
@ -593,7 +594,7 @@ function jappixmini_cron(App $a, $d)
|
||||||
|
|
||||||
// for each user, go through list of contacts
|
// for each user, go through list of contacts
|
||||||
$contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'",
|
$contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'",
|
||||||
intval($uid), dbesc(NETWORK_DFRN));
|
intval($uid), DBA::escape(NETWORK_DFRN));
|
||||||
foreach ($contacts as $contact_row) {
|
foreach ($contacts as $contact_row) {
|
||||||
$request = $contact_row["request"];
|
$request = $contact_row["request"];
|
||||||
if (!$request) {
|
if (!$request) {
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
* Version: 1.1
|
* Version: 1.1
|
||||||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs the addon hook
|
* Installs the addon hook
|
||||||
|
@ -29,7 +32,7 @@ function libravatar_uninstall()
|
||||||
logger("unregistered libravatar in avatar_lookup hook");
|
logger("unregistered libravatar in avatar_lookup hook");
|
||||||
}
|
}
|
||||||
|
|
||||||
function libravatar_load_config(\Friendica\App $a)
|
function libravatar_load_config(App $a)
|
||||||
{
|
{
|
||||||
$a->loadConfigFile(__DIR__. '/config/libravatar.ini.php');
|
$a->loadConfigFile(__DIR__. '/config/libravatar.ini.php');
|
||||||
}
|
}
|
||||||
|
@ -96,7 +99,7 @@ function libravatar_addon_admin(&$a, &$o)
|
||||||
|
|
||||||
// Libravatar falls back to gravatar, so show warning about gravatar addon if enabled
|
// Libravatar falls back to gravatar, so show warning about gravatar addon if enabled
|
||||||
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
|
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
|
||||||
dbesc('gravatar')
|
DBA::escape('gravatar')
|
||||||
);
|
);
|
||||||
if (count($r)) {
|
if (count($r)) {
|
||||||
$o = '<h5>' .L10n::t('Information') .'</h5><p>' .L10n::t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
|
$o = '<h5>' .L10n::t('Information') .'</h5><p>' .L10n::t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
|
||||||
|
@ -120,10 +120,10 @@ function mailstream_post_hook(&$a, &$item) {
|
||||||
$message_id = mailstream_generate_id($a, $item['uri']);
|
$message_id = mailstream_generate_id($a, $item['uri']);
|
||||||
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
|
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
|
||||||
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
|
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
|
||||||
intval($item['contact-id']), dbesc($item['uri']), dbesc($message_id));
|
intval($item['contact-id']), DBA::escape($item['uri']), DBA::escape($message_id));
|
||||||
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
|
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), DBA::escape($item['uri']));
|
||||||
if (count($r) != 1) {
|
if (count($r) != 1) {
|
||||||
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_NORMAL);
|
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$ms_item = $r[0];
|
$ms_item = $r[0];
|
||||||
|
@ -132,7 +132,7 @@ function mailstream_post_hook(&$a, &$item) {
|
||||||
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
|
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
|
||||||
$user = mailstream_get_user($item['uid']);
|
$user = mailstream_get_user($item['uid']);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
logger('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_NORMAL);
|
logger('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mailstream_send($a, $ms_item['message-id'], $item, $user);
|
mailstream_send($a, $ms_item['message-id'], $item, $user);
|
||||||
|
@ -141,7 +141,7 @@ function mailstream_post_hook(&$a, &$item) {
|
||||||
function mailstream_get_user($uid) {
|
function mailstream_get_user($uid) {
|
||||||
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
|
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
|
||||||
if (count($r) != 1) {
|
if (count($r) != 1) {
|
||||||
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL);
|
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $r[0];
|
return $r[0];
|
||||||
|
@ -173,7 +173,7 @@ function mailstream_do_images($a, &$item, &$attachments) {
|
||||||
|
|
||||||
function mailstream_sender($item) {
|
function mailstream_sender($item) {
|
||||||
$r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']);
|
$r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']);
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
if ($contact['name'] != $item['author-name']) {
|
if ($contact['name'] != $item['author-name']) {
|
||||||
return $contact['name'] . ' - ' . $item['author-name'];
|
return $contact['name'] . ' - ' . $item['author-name'];
|
||||||
|
@ -214,7 +214,7 @@ function mailstream_subject($item) {
|
||||||
// Don't look more than 100 levels deep for a subject, in case of loops
|
// Don't look more than 100 levels deep for a subject, in case of loops
|
||||||
for ($i = 0; ($i < 100) && $parent; $i++) {
|
for ($i = 0; ($i < 100) && $parent; $i++) {
|
||||||
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
|
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
|
||||||
if (!DBM::is_result($parent_item)) {
|
if (!DBA::isResult($parent_item)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($parent_item['thr-parent'] === $parent) {
|
if ($parent_item['thr-parent'] === $parent) {
|
||||||
|
@ -300,14 +300,14 @@ function mailstream_send($a, $message_id, $item, $user) {
|
||||||
}
|
}
|
||||||
logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG);
|
logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG);
|
||||||
} catch (phpmailerException $e) {
|
} catch (phpmailerException $e) {
|
||||||
logger('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_NORMAL);
|
logger('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_INFO);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
logger('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_NORMAL);
|
logger('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_INFO);
|
||||||
}
|
}
|
||||||
// In case of failure, still set the item to completed. Otherwise
|
// In case of failure, still set the item to completed. Otherwise
|
||||||
// we'll just try to send it over and over again and it'll fail
|
// we'll just try to send it over and over again and it'll fail
|
||||||
// every time.
|
// every time.
|
||||||
q('UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = "%s"', dbesc($message_id));
|
q('UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = "%s"', DBA::escape($message_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,7 +334,7 @@ function mailstream_cron($a, $b) {
|
||||||
logger('mailstream_cron processing ' . count($ms_item_ids) . ' items', LOGGER_DEBUG);
|
logger('mailstream_cron processing ' . count($ms_item_ids) . ' items', LOGGER_DEBUG);
|
||||||
foreach ($ms_item_ids as $ms_item_id) {
|
foreach ($ms_item_ids as $ms_item_id) {
|
||||||
if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) {
|
if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) {
|
||||||
logger('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_NORMAL);
|
logger('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_INFO);
|
||||||
}
|
}
|
||||||
$item = Item::selectFirst([], ['id' => $ms_item_id['id']]);
|
$item = Item::selectFirst([], ['id' => $ms_item_id['id']]);
|
||||||
$users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid']));
|
$users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid']));
|
||||||
|
@ -343,7 +343,7 @@ function mailstream_cron($a, $b) {
|
||||||
mailstream_send($a, $ms_item_id['message-id'], $item, $user);
|
mailstream_send($a, $ms_item_id['message-id'], $item, $user);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger('mailstream_cron: Unable to find item ' . $ms_item_id['id'], LOGGER_NORMAL);
|
logger('mailstream_cron: Unable to find item ' . $ms_item_id['id'], LOGGER_INFO);
|
||||||
q("UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = %d", intval($ms_item['message-id']));
|
q("UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = %d", intval($ms_item['message-id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
function public_server_install()
|
function public_server_install()
|
||||||
|
@ -58,9 +57,9 @@ function public_server_cron($a, $b)
|
||||||
$r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
|
$r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
|
||||||
`account_expires_on` > '%s' AND
|
`account_expires_on` > '%s' AND
|
||||||
`expire_notification_sent` <= '%s'",
|
`expire_notification_sent` <= '%s'",
|
||||||
dbesc(NULL_DATE), dbesc(NULL_DATE));
|
DBA::escape(NULL_DATE), DBA::escape(NULL_DATE));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
notification([
|
notification([
|
||||||
'uid' => $rr['uid'],
|
'uid' => $rr['uid'],
|
||||||
|
@ -82,8 +81,8 @@ function public_server_cron($a, $b)
|
||||||
$nologin = Config::get('public_server', 'nologin', false);
|
$nologin = Config::get('public_server', 'nologin', false);
|
||||||
if ($nologin) {
|
if ($nologin) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
|
||||||
dbesc(NULL_DATE), intval($nologin), dbesc(NULL_DATE));
|
DBA::escape(NULL_DATE), intval($nologin), DBA::escape(NULL_DATE));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||||
|
@ -94,8 +93,8 @@ function public_server_cron($a, $b)
|
||||||
$flagusers = Config::get('public_server', 'flagusers', false);
|
$flagusers = Config::get('public_server', 'flagusers', false);
|
||||||
if ($flagusers) {
|
if ($flagusers) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' AND `page-flags` = 0",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' AND `page-flags` = 0",
|
||||||
intval($flagusers), dbesc(NULL_DATE));
|
intval($flagusers), DBA::escape(NULL_DATE));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||||
|
@ -107,8 +106,8 @@ function public_server_cron($a, $b)
|
||||||
$flagpostsexpire = Config::get('public_server', 'flagpostsexpire');
|
$flagpostsexpire = Config::get('public_server', 'flagpostsexpire');
|
||||||
if ($flagposts && $flagpostsexpire) {
|
if ($flagposts && $flagpostsexpire) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' and `expire` = 0 AND `page-flags` = 0",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' and `expire` = 0 AND `page-flags` = 0",
|
||||||
intval($flagposts), dbesc(NULL_DATE));
|
intval($flagposts), DBA::escape(NULL_DATE));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
|
@ -14,7 +15,6 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
|
@ -59,7 +59,7 @@ function pumpio_uninstall()
|
||||||
|
|
||||||
function pumpio_module() {}
|
function pumpio_module() {}
|
||||||
|
|
||||||
function pumpio_content(&$a)
|
function pumpio_content(App $a)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.') . EOL);
|
||||||
|
@ -92,7 +92,7 @@ function pumpio_check_item_notification($a, &$notification_data)
|
||||||
$notification_data["profiles"][] = "https://".$hostname."/".$username;
|
$notification_data["profiles"][] = "https://".$hostname."/".$username;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_registerclient(&$a, $host)
|
function pumpio_registerclient(App $a, $host)
|
||||||
{
|
{
|
||||||
$url = "https://".$host."/api/client/register";
|
$url = "https://".$host."/api/client/register";
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ function pumpio_registerclient(&$a, $host)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_connect(&$a)
|
function pumpio_connect(App $a)
|
||||||
{
|
{
|
||||||
// Start a session. This is necessary to hold on to a few keys the callback script will also need
|
// Start a session. This is necessary to hold on to a few keys the callback script will also need
|
||||||
session_start();
|
session_start();
|
||||||
|
@ -211,13 +211,14 @@ function pumpio_connect(&$a)
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_jot_nets(&$a, &$b)
|
function pumpio_jot_nets(App $a, &$b)
|
||||||
{
|
{
|
||||||
if (! local_user()) {
|
if (! local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pumpio_post = PConfig::get(local_user(), 'pumpio', 'post');
|
$pumpio_post = PConfig::get(local_user(), 'pumpio', 'post');
|
||||||
|
|
||||||
if (intval($pumpio_post) == 1) {
|
if (intval($pumpio_post) == 1) {
|
||||||
$pumpio_defpost = PConfig::get(local_user(), 'pumpio', 'post_by_default');
|
$pumpio_defpost = PConfig::get(local_user(), 'pumpio', 'post_by_default');
|
||||||
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
||||||
|
@ -226,7 +227,7 @@ function pumpio_jot_nets(&$a, &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_settings(&$a, &$s)
|
function pumpio_settings(App $a, &$s)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -326,10 +327,10 @@ function pumpio_settings(&$a, &$s)
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_settings_post(&$a, &$b)
|
function pumpio_settings_post(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if (x($_POST, 'pumpio-submit')) {
|
if (!empty($_POST['pumpio-submit'])) {
|
||||||
if (x($_POST, 'pumpio_delete')) {
|
if (!empty($_POST['pumpio_delete'])) {
|
||||||
PConfig::set(local_user(), 'pumpio', 'consumer_key' , '');
|
PConfig::set(local_user(), 'pumpio', 'consumer_key' , '');
|
||||||
PConfig::set(local_user(), 'pumpio', 'consumer_secret' , '');
|
PConfig::set(local_user(), 'pumpio', 'consumer_secret' , '');
|
||||||
PConfig::set(local_user(), 'pumpio', 'oauth_token' , '');
|
PConfig::set(local_user(), 'pumpio', 'oauth_token' , '');
|
||||||
|
@ -348,6 +349,7 @@ function pumpio_settings_post(&$a, &$b)
|
||||||
$user = $_POST['pumpio_user'];
|
$user = $_POST['pumpio_user'];
|
||||||
if (strstr($user, "@")) {
|
if (strstr($user, "@")) {
|
||||||
$pos = strpos($user, "@");
|
$pos = strpos($user, "@");
|
||||||
|
|
||||||
if ($pos > 0) {
|
if ($pos > 0) {
|
||||||
$user = substr($user, 0, $pos);
|
$user = substr($user, 0, $pos);
|
||||||
}
|
}
|
||||||
|
@ -375,12 +377,12 @@ function pumpio_settings_post(&$a, &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_load_config(\Friendica\App $a)
|
function pumpio_load_config(App $a)
|
||||||
{
|
{
|
||||||
$a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
|
$a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_post_local(&$a, &$b)
|
function pumpio_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if (!local_user() || (local_user() != $b['uid'])) {
|
if (!local_user() || (local_user() != $b['uid'])) {
|
||||||
return;
|
return;
|
||||||
|
@ -388,7 +390,7 @@ function pumpio_post_local(&$a, &$b)
|
||||||
|
|
||||||
$pumpio_post = intval(PConfig::get(local_user(), 'pumpio', 'post'));
|
$pumpio_post = intval(PConfig::get(local_user(), 'pumpio', 'post'));
|
||||||
|
|
||||||
$pumpio_enable = (($pumpio_post && x($_REQUEST, 'pumpio_enable')) ? intval($_REQUEST['pumpio_enable']) : 0);
|
$pumpio_enable = (($pumpio_post && !empty($_REQUEST['pumpio_enable'])) ? intval($_REQUEST['pumpio_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(PConfig::get(local_user(), 'pumpio', 'post_by_default'))) {
|
if ($b['api_source'] && intval(PConfig::get(local_user(), 'pumpio', 'post_by_default'))) {
|
||||||
$pumpio_enable = 1;
|
$pumpio_enable = 1;
|
||||||
|
@ -405,13 +407,11 @@ function pumpio_post_local(&$a, &$b)
|
||||||
$b['postopts'] .= 'pumpio';
|
$b['postopts'] .= 'pumpio';
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_send(&$a, &$b)
|
function pumpio_send(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if (!PConfig::get($b["uid"], 'pumpio', 'import')) {
|
if (!PConfig::get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
logger("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA);
|
logger("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA);
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ function pumpio_send(&$a, &$b)
|
||||||
$condition = ['id' => $b['parent'], 'network' => NETWORK_PUMPIO];
|
$condition = ['id' => $b['parent'], 'network' => NETWORK_PUMPIO];
|
||||||
$orig_post = Item::selectFirst([], $condition);
|
$orig_post = Item::selectFirst([], $condition);
|
||||||
|
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
logger("pumpio_send: no pumpio post ".$b["parent"]);
|
logger("pumpio_send: no pumpio post ".$b["parent"]);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -572,7 +572,7 @@ function pumpio_send(&$a, &$b)
|
||||||
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$a->contact = $r[0]["id"];
|
$a->contact = $r[0]["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ function pumpio_send(&$a, &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_action(&$a, $uid, $uri, $action, $content = "")
|
function pumpio_action(App $a, $uid, $uri, $action, $content = "")
|
||||||
{
|
{
|
||||||
// Don't do likes and other stuff if you don't import the timeline
|
// Don't do likes and other stuff if you don't import the timeline
|
||||||
if (!PConfig::get($uid, 'pumpio', 'import')) {
|
if (!PConfig::get($uid, 'pumpio', 'import')) {
|
||||||
|
@ -600,7 +600,7 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "")
|
||||||
|
|
||||||
$orig_post = Item::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
|
$orig_post = Item::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
|
||||||
|
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "")
|
||||||
logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
|
logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true));
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$a->contact = $r[0]["id"];
|
$a->contact = $r[0]["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,11 +660,11 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_sync(&$a)
|
function pumpio_sync(App $a)
|
||||||
{
|
{
|
||||||
$r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'");
|
$r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'");
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ function pumpio_sync(&$a)
|
||||||
logger('pumpio: cron_start');
|
logger('pumpio: cron_start');
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('pumpio: mirroring user '.$rr['uid']);
|
logger('pumpio: mirroring user '.$rr['uid']);
|
||||||
pumpio_fetchtimeline($a, $rr['uid']);
|
pumpio_fetchtimeline($a, $rr['uid']);
|
||||||
|
@ -697,11 +697,11 @@ function pumpio_sync(&$a)
|
||||||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if ($abandon_days != 0) {
|
if ($abandon_days != 0) {
|
||||||
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
||||||
if (!DBM::is_result($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -730,12 +730,12 @@ function pumpio_sync(&$a)
|
||||||
Config::set('pumpio', 'last_poll', time());
|
Config::set('pumpio', 'last_poll', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_cron(&$a, $b)
|
function pumpio_cron(App $a, $b)
|
||||||
{
|
{
|
||||||
Worker::add(PRIORITY_MEDIUM,"addon/pumpio/pumpio_sync.php");
|
Worker::add(PRIORITY_MEDIUM,"addon/pumpio/pumpio_sync.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_fetchtimeline(&$a, $uid)
|
function pumpio_fetchtimeline(App $a, $uid)
|
||||||
{
|
{
|
||||||
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
||||||
|
@ -865,14 +865,14 @@ function pumpio_fetchtimeline(&$a, $uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dounlike(&$a, $uid, $self, $post, $own_id)
|
function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
|
||||||
{
|
{
|
||||||
// Searching for the unliked post
|
// Searching for the unliked post
|
||||||
// Two queries for speed issues
|
// Two queries for speed issues
|
||||||
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,11 +883,11 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id)
|
||||||
$contactid = $self[0]['id'];
|
$contactid = $self[0]['id'];
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc(normalise_link($post->actor->url)),
|
DBA::escape(normalise_link($post->actor->url)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contactid = $r[0]['id'];
|
$contactid = $r[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,14 +898,14 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id)
|
||||||
|
|
||||||
Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||||
} else {
|
} else {
|
||||||
logger("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
logger("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = true)
|
function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = true)
|
||||||
{
|
{
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
|
||||||
|
@ -917,9 +917,9 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
|
||||||
// Searching for the liked post
|
// Searching for the liked post
|
||||||
// Two queries for speed issues
|
// Two queries for speed issues
|
||||||
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
$orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
$orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -938,11 +938,11 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
|
||||||
$post->actor->image->url = $self[0]['photo'];
|
$post->actor->image->url = $self[0]['photo'];
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc(normalise_link($post->actor->url)),
|
DBA::escape(normalise_link($post->actor->url)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contactid = $r[0]['id'];
|
$contactid = $r[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,39 +1015,39 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
|
||||||
intval($uid), dbesc(normalise_link($contact->url)));
|
intval($uid), DBA::escape(normalise_link($contact->url)));
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
// create contact record
|
// create contact record
|
||||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||||
`location`, `about`, `writable`, `blocked`, `readonly`, `pending` )
|
`location`, `about`, `writable`, `blocked`, `readonly`, `pending` )
|
||||||
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)",
|
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
dbesc($contact->url),
|
DBA::escape($contact->url),
|
||||||
dbesc(normalise_link($contact->url)),
|
DBA::escape(normalise_link($contact->url)),
|
||||||
dbesc(str_replace("acct:", "", $contact->id)),
|
DBA::escape(str_replace("acct:", "", $contact->id)),
|
||||||
dbesc(''),
|
DBA::escape(''),
|
||||||
dbesc($contact->id), // What is it for?
|
DBA::escape($contact->id), // What is it for?
|
||||||
dbesc('pump.io ' . $contact->id), // What is it for?
|
DBA::escape('pump.io ' . $contact->id), // What is it for?
|
||||||
dbesc($contact->displayName),
|
DBA::escape($contact->displayName),
|
||||||
dbesc($contact->preferredUsername),
|
DBA::escape($contact->preferredUsername),
|
||||||
dbesc($contact->image->url),
|
DBA::escape($contact->image->url),
|
||||||
dbesc(NETWORK_PUMPIO),
|
DBA::escape(NETWORK_PUMPIO),
|
||||||
intval(CONTACT_IS_FRIEND),
|
intval(CONTACT_IS_FRIEND),
|
||||||
intval(1),
|
intval(1),
|
||||||
dbesc($contact->location->displayName),
|
DBA::escape($contact->location->displayName),
|
||||||
dbesc($contact->summary),
|
DBA::escape($contact->summary),
|
||||||
intval(1)
|
intval(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
dbesc(normalise_link($contact->url)),
|
DBA::escape(normalise_link($contact->url)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,7 +1075,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
|
||||||
return $contact_id;
|
return $contact_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dodelete(&$a, $uid, $self, $post, $own_id)
|
function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
|
||||||
{
|
{
|
||||||
// Two queries for speed issues
|
// Two queries for speed issues
|
||||||
$condition = ['uri' => $post->object->id, 'uid' => $uid];
|
$condition = ['uri' => $post->object->id, 'uid' => $uid];
|
||||||
|
@ -1092,7 +1092,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
|
function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
|
||||||
{
|
{
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
|
||||||
|
@ -1171,19 +1171,19 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
||||||
} elseif ($contact_id == 0) {
|
} elseif ($contact_id == 0) {
|
||||||
// Take an existing contact, the contact of the note or - as a fallback - the id of the user
|
// Take an existing contact, the contact of the note or - as a fallback - the id of the user
|
||||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc(normalise_link($post->actor->url)),
|
DBA::escape(normalise_link($post->actor->url)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact_id = $r[0]['id'];
|
$contact_id = $r[0]['id'];
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc(normalise_link($post->actor->url)),
|
DBA::escape(normalise_link($post->actor->url)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact_id = $r[0]['id'];
|
$contact_id = $r[0]['id'];
|
||||||
} else {
|
} else {
|
||||||
$contact_id = $self[0]['id'];
|
$contact_id = $self[0]['id'];
|
||||||
|
@ -1285,7 +1285,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
||||||
return $top_item;
|
return $top_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_fetchinbox(&$a, $uid)
|
function pumpio_fetchinbox(App $a, $uid)
|
||||||
{
|
{
|
||||||
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
||||||
|
@ -1304,7 +1304,7 @@ function pumpio_fetchinbox(&$a, $uid)
|
||||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||||
WHERE `thread`.`network` = '%s' AND `thread`.`uid` = %d AND `item`.`extid` != ''
|
WHERE `thread`.`network` = '%s' AND `thread`.`uid` = %d AND `item`.`extid` != ''
|
||||||
ORDER BY `thread`.`commented` DESC LIMIT 10",
|
ORDER BY `thread`.`commented` DESC LIMIT 10",
|
||||||
dbesc(NETWORK_PUMPIO),
|
DBA::escape(NETWORK_PUMPIO),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1347,14 +1347,14 @@ function pumpio_fetchinbox(&$a, $uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lastitems AS $item) {
|
foreach ($lastitems as $item) {
|
||||||
pumpio_fetchallcomments($a, $uid, $item["uri"]);
|
pumpio_fetchallcomments($a, $uid, $item["uri"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PConfig::set($uid, 'pumpio', 'last_id', $last_id);
|
PConfig::set($uid, 'pumpio', 'last_id', $last_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_getallusers(&$a, $uid)
|
function pumpio_getallusers(App &$a, $uid)
|
||||||
{
|
{
|
||||||
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
||||||
|
@ -1392,18 +1392,19 @@ function pumpio_getallusers(&$a, $uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($users->items)) {
|
if (!empty($users->items)) {
|
||||||
foreach ($users->items AS $user) {
|
foreach ($users->items as $user) {
|
||||||
pumpio_get_contact($uid, $user);
|
pumpio_get_contact($uid, $user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_queue_hook(&$a, &$b)
|
function pumpio_queue_hook(App $a, array &$b)
|
||||||
{
|
{
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||||
dbesc(NETWORK_PUMPIO)
|
DBA::escape(NETWORK_PUMPIO)
|
||||||
);
|
);
|
||||||
if (!DBM::is_result($qi)) {
|
|
||||||
|
if (!DBA::isResult($qi)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,7 +1419,7 @@ function pumpio_queue_hook(&$a, &$b)
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
||||||
intval($x['cid'])
|
intval($x['cid'])
|
||||||
);
|
);
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1482,7 @@ function pumpio_queue_hook(&$a, &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_getreceiver(&$a, $b)
|
function pumpio_getreceiver(App $a, array $b)
|
||||||
{
|
{
|
||||||
$receiver = [];
|
$receiver = [];
|
||||||
|
|
||||||
|
@ -1507,10 +1508,10 @@ function pumpio_getreceiver(&$a, $b)
|
||||||
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval($b["uid"]),
|
intval($b["uid"]),
|
||||||
dbesc(NETWORK_PUMPIO)
|
DBA::escape(NETWORK_PUMPIO)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$receiver["bcc"][] = [
|
$receiver["bcc"][] = [
|
||||||
"displayName" => $r[0]["name"],
|
"displayName" => $r[0]["name"],
|
||||||
"objectType" => "person",
|
"objectType" => "person",
|
||||||
|
@ -1525,7 +1526,7 @@ function pumpio_getreceiver(&$a, $b)
|
||||||
"FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
|
"FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
|
||||||
"AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
|
"AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
|
||||||
intval($gid),
|
intval($gid),
|
||||||
dbesc(NETWORK_PUMPIO)
|
DBA::escape(NETWORK_PUMPIO)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($r AS $row)
|
foreach ($r AS $row)
|
||||||
|
@ -1550,10 +1551,10 @@ function pumpio_getreceiver(&$a, $b)
|
||||||
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval($b["uid"]),
|
intval($b["uid"]),
|
||||||
dbesc(NETWORK_PUMPIO)
|
DBA::escape(NETWORK_PUMPIO)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$receiver["to"][] = [
|
$receiver["to"][] = [
|
||||||
"displayName" => $r[0]["name"],
|
"displayName" => $r[0]["name"],
|
||||||
"objectType" => "person",
|
"objectType" => "person",
|
||||||
|
@ -1566,7 +1567,7 @@ function pumpio_getreceiver(&$a, $b)
|
||||||
return $receiver;
|
return $receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_fetchallcomments(&$a, $uid, $id)
|
function pumpio_fetchallcomments(App $a, $uid, $id)
|
||||||
{
|
{
|
||||||
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
|
||||||
|
@ -1585,7 +1586,7 @@ function pumpio_fetchallcomments(&$a, $uid, $id)
|
||||||
// Fetching the original post
|
// Fetching the original post
|
||||||
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
|
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
|
||||||
$item = Item::selectFirst(['extid'], $condition);
|
$item = Item::selectFirst(['extid'], $condition);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
* Author: Zach <https://f.shmuz.in/profile/techcity>
|
* Author: Zach <https://f.shmuz.in/profile/techcity>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
function remote_permissions_install() {
|
function remote_permissions_install() {
|
||||||
Addon::registerHook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
|
Addon::registerHook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
|
||||||
|
@ -84,7 +86,7 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
// The contact lives here. Get his/her user info
|
// The contact lives here. Get his/her user info
|
||||||
$nick = $r[0]['nick'];
|
$nick = $r[0]['nick'];
|
||||||
$r = q("SELECT uid FROM user WHERE nickname = '%s' LIMIT 1",
|
$r = q("SELECT uid FROM user WHERE nickname = '%s' LIMIT 1",
|
||||||
dbesc($nick)
|
DBA::escape($nick)
|
||||||
);
|
);
|
||||||
if(! $r)
|
if(! $r)
|
||||||
return;
|
return;
|
||||||
|
@ -104,15 +106,15 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
if($item_copy['uri'] === $item_copy['parent-uri']) {
|
if($item_copy['uri'] === $item_copy['parent-uri']) {
|
||||||
// Lockview for a top-level post
|
// Lockview for a top-level post
|
||||||
$r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s' AND type = 'wall' LIMIT 1",
|
$r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s' AND type = 'wall' LIMIT 1",
|
||||||
dbesc($item_copy['uri'])
|
DBA::escape($item_copy['uri'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Lockview for a comment
|
// Lockview for a comment
|
||||||
$r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s'
|
$r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s'
|
||||||
AND parent = ( SELECT id FROM item WHERE uri = '%s' AND type = 'wall' ) LIMIT 1",
|
AND parent = ( SELECT id FROM item WHERE uri = '%s' AND type = 'wall' ) LIMIT 1",
|
||||||
dbesc($item_copy['uri']),
|
DBA::escape($item_copy['uri']),
|
||||||
dbesc($item_copy['parent-uri'])
|
DBA::escape($item_copy['parent-uri'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if($r) {
|
if($r) {
|
||||||
|
@ -130,7 +132,7 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
|
|
||||||
if(count($allowed_groups)) {
|
if(count($allowed_groups)) {
|
||||||
$r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
|
$r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
|
||||||
dbesc(implode(', ', $allowed_groups))
|
DBA::escape(implode(', ', $allowed_groups))
|
||||||
);
|
);
|
||||||
foreach($r as $rr)
|
foreach($r as $rr)
|
||||||
$allow[] = $rr['contact-id'];
|
$allow[] = $rr['contact-id'];
|
||||||
|
@ -139,7 +141,7 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
|
|
||||||
if(count($deny_groups)) {
|
if(count($deny_groups)) {
|
||||||
$r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
|
$r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
|
||||||
dbesc(implode(', ', $deny_groups))
|
DBA::escape(implode(', ', $deny_groups))
|
||||||
);
|
);
|
||||||
foreach($r as $rr)
|
foreach($r as $rr)
|
||||||
$deny[] = $rr['contact-id'];
|
$deny[] = $rr['contact-id'];
|
||||||
|
@ -149,7 +151,7 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
if($allow)
|
if($allow)
|
||||||
{
|
{
|
||||||
$r = q("SELECT name FROM contact WHERE id IN ( %s )",
|
$r = q("SELECT name FROM contact WHERE id IN ( %s )",
|
||||||
dbesc(implode(', ', array_diff($allow, $deny)))
|
DBA::escape(implode(', ', array_diff($allow, $deny)))
|
||||||
);
|
);
|
||||||
foreach($r as $rr)
|
foreach($r as $rr)
|
||||||
$allow_names[] = $rr['name'];
|
$allow_names[] = $rr['name'];
|
||||||
|
@ -162,8 +164,8 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
// will have different URIs than the original. We can match the GUID for
|
// will have different URIs than the original. We can match the GUID for
|
||||||
// those
|
// those
|
||||||
$r = q("SELECT `uid` FROM item WHERE uri = '%s' OR guid = '%s'",
|
$r = q("SELECT `uid` FROM item WHERE uri = '%s' OR guid = '%s'",
|
||||||
dbesc($item_copy['uri']),
|
DBA::escape($item_copy['uri']),
|
||||||
dbesc($item_copy['guid'])
|
DBA::escape($item_copy['guid'])
|
||||||
);
|
);
|
||||||
if(! $r)
|
if(! $r)
|
||||||
return;
|
return;
|
||||||
|
@ -173,7 +175,7 @@ function remote_permissions_content($a, $item_copy) {
|
||||||
$allow[] = $rr['uid'];
|
$allow[] = $rr['uid'];
|
||||||
|
|
||||||
$r = q("SELECT username FROM user WHERE uid IN ( %s )",
|
$r = q("SELECT username FROM user WHERE uid IN ( %s )",
|
||||||
dbesc(implode(', ', $allow))
|
DBA::escape(implode(', ', $allow))
|
||||||
);
|
);
|
||||||
if(! $r)
|
if(! $r)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,7 +48,6 @@ use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -465,7 +464,7 @@ function statusnet_post_hook(App $a, &$b)
|
||||||
|
|
||||||
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
||||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
|
logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -686,7 +685,7 @@ function statusnet_prepare_body(App $a, &$b)
|
||||||
|
|
||||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||||
if (DBM::is_result($orig_post)) {
|
if (DBA::isResult($orig_post)) {
|
||||||
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
|
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
|
||||||
|
|
||||||
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
|
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
|
||||||
|
@ -731,7 +730,7 @@ function statusnet_cron(App $a, $b)
|
||||||
logger('statusnet: cron_start');
|
logger('statusnet: cron_start');
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('statusnet: fetching for user ' . $rr['uid']);
|
logger('statusnet: fetching for user ' . $rr['uid']);
|
||||||
statusnet_fetchtimeline($a, $rr['uid']);
|
statusnet_fetchtimeline($a, $rr['uid']);
|
||||||
|
@ -746,11 +745,11 @@ function statusnet_cron(App $a, $b)
|
||||||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if ($abandon_days != 0) {
|
if ($abandon_days != 0) {
|
||||||
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
||||||
if (!DBM::is_result($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -900,48 +899,48 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
||||||
"location" => $contact->location, "about" => $contact->description,
|
"location" => $contact->location, "about" => $contact->description,
|
||||||
"addr" => statusnet_address($contact), "generation" => 3]);
|
"addr" => statusnet_address($contact), "generation" => 3]);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), DBA::escape(normalise_link($contact->statusnet_profile_url)), DBA::escape(NETWORK_STATUSNET));
|
||||||
|
|
||||||
if (!DBM::is_result($r) && !$create_user) {
|
if (!DBA::isResult($r) && !$create_user) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBM::is_result($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
if (DBA::isResult($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
||||||
logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
|
logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
// create contact record
|
// create contact record
|
||||||
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||||
`location`, `about`, `writable`, `blocked`, `readonly`, `pending` )
|
`location`, `about`, `writable`, `blocked`, `readonly`, `pending` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
dbesc($contact->statusnet_profile_url),
|
DBA::escape($contact->statusnet_profile_url),
|
||||||
dbesc(normalise_link($contact->statusnet_profile_url)),
|
DBA::escape(normalise_link($contact->statusnet_profile_url)),
|
||||||
dbesc(statusnet_address($contact)),
|
DBA::escape(statusnet_address($contact)),
|
||||||
dbesc(normalise_link($contact->statusnet_profile_url)),
|
DBA::escape(normalise_link($contact->statusnet_profile_url)),
|
||||||
dbesc(''),
|
DBA::escape(''),
|
||||||
dbesc(''),
|
DBA::escape(''),
|
||||||
dbesc($contact->name),
|
DBA::escape($contact->name),
|
||||||
dbesc($contact->screen_name),
|
DBA::escape($contact->screen_name),
|
||||||
dbesc($contact->profile_image_url),
|
DBA::escape($contact->profile_image_url),
|
||||||
dbesc(NETWORK_STATUSNET),
|
DBA::escape(NETWORK_STATUSNET),
|
||||||
intval(CONTACT_IS_FRIEND),
|
intval(CONTACT_IS_FRIEND),
|
||||||
intval(1),
|
intval(1),
|
||||||
dbesc($contact->location),
|
DBA::escape($contact->location),
|
||||||
dbesc($contact->description),
|
DBA::escape($contact->description),
|
||||||
intval(1)
|
intval(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
|
||||||
dbesc($contact->statusnet_profile_url),
|
DBA::escape($contact->statusnet_profile_url),
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc(NETWORK_STATUSNET));
|
DBA::escape(NETWORK_STATUSNET));
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,10 +955,10 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
||||||
`micro` = '%s',
|
`micro` = '%s',
|
||||||
`avatar-date` = '%s'
|
`avatar-date` = '%s'
|
||||||
WHERE `id` = %d",
|
WHERE `id` = %d",
|
||||||
dbesc($photos[0]),
|
DBA::escape($photos[0]),
|
||||||
dbesc($photos[1]),
|
DBA::escape($photos[1]),
|
||||||
dbesc($photos[2]),
|
DBA::escape($photos[2]),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
intval($contact_id)
|
intval($contact_id)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -987,19 +986,19 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
|
||||||
`location` = '%s',
|
`location` = '%s',
|
||||||
`about` = '%s'
|
`about` = '%s'
|
||||||
WHERE `id` = %d",
|
WHERE `id` = %d",
|
||||||
dbesc($photos[0]),
|
DBA::escape($photos[0]),
|
||||||
dbesc($photos[1]),
|
DBA::escape($photos[1]),
|
||||||
dbesc($photos[2]),
|
DBA::escape($photos[2]),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
dbesc($contact->statusnet_profile_url),
|
DBA::escape($contact->statusnet_profile_url),
|
||||||
dbesc(normalise_link($contact->statusnet_profile_url)),
|
DBA::escape(normalise_link($contact->statusnet_profile_url)),
|
||||||
dbesc(statusnet_address($contact)),
|
DBA::escape(statusnet_address($contact)),
|
||||||
dbesc($contact->name),
|
DBA::escape($contact->name),
|
||||||
dbesc($contact->screen_name),
|
DBA::escape($contact->screen_name),
|
||||||
dbesc($contact->location),
|
DBA::escape($contact->location),
|
||||||
dbesc($contact->description),
|
DBA::escape($contact->description),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1024,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$self = $r[0];
|
$self = $r[0];
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -1087,11 +1086,11 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
||||||
$fields = ['uri', 'parent-uri', 'parent'];
|
$fields = ['uri', 'parent-uri', 'parent'];
|
||||||
$item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
$item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
||||||
|
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
$item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
$item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBM::is_result($item)) {
|
if (DBA::isResult($item)) {
|
||||||
$postarray['thr-parent'] = $item['uri'];
|
$postarray['thr-parent'] = $item['uri'];
|
||||||
$postarray['parent-uri'] = $item['parent-uri'];
|
$postarray['parent-uri'] = $item['parent-uri'];
|
||||||
$postarray['parent'] = $item['parent'];
|
$postarray['parent'] = $item['parent'];
|
||||||
|
@ -1109,7 +1108,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contactid = $r[0]["id"];
|
$contactid = $r[0]["id"];
|
||||||
|
|
||||||
$postarray['owner-name'] = $r[0]["name"];
|
$postarray['owner-name'] = $r[0]["name"];
|
||||||
|
@ -1213,7 +1212,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
||||||
intval($own_contact),
|
intval($own_contact),
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$nick = $r[0]["nick"];
|
$nick = $r[0]["nick"];
|
||||||
} else {
|
} else {
|
||||||
logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
|
logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
|
||||||
|
@ -1223,7 +1222,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$self = $r[0];
|
$self = $r[0];
|
||||||
} else {
|
} else {
|
||||||
logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
||||||
|
@ -1232,7 +1231,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
|
||||||
|
|
||||||
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
if (!DBM::is_result($u)) {
|
if (!DBA::isResult($u)) {
|
||||||
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1521,8 +1520,8 @@ function statusnet_fetch_own_contact(App $a, $uid)
|
||||||
$contact_id = statusnet_fetch_contact($uid, $user, true);
|
$contact_id = statusnet_fetch_contact($uid, $user, true);
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($uid), dbesc($own_url));
|
intval($uid), DBA::escape($own_url));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact_id = $r[0]["id"];
|
$contact_id = $r[0]["id"];
|
||||||
} else {
|
} else {
|
||||||
PConfig::delete($uid, 'statusnet', 'own_url');
|
PConfig::delete($uid, 'statusnet', 'own_url');
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ function testdrive_uninstall() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testdrive_load_config(\Friendica\App $a)
|
function testdrive_load_config(App $a)
|
||||||
{
|
{
|
||||||
$a->loadConfigFile(__DIR__. '/config/testdrive.ini.php');
|
$a->loadConfigFile(__DIR__. '/config/testdrive.ini.php');
|
||||||
}
|
}
|
||||||
|
@ -51,7 +53,7 @@ function testdrive_register_account($a,$b) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$r = q("UPDATE user set account_expires_on = '%s' where uid = %d",
|
$r = q("UPDATE user set account_expires_on = '%s' where uid = %d",
|
||||||
dbesc(DateTimeFormat::convert('now +' . $days . ' days')),
|
DBA::escape(DateTimeFormat::convert('now +' . $days . ' days')),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ function testdrive_cron($a,$b) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
q("update user set expire_notification_sent = '%s' where uid = %d",
|
q("update user set expire_notification_sent = '%s' where uid = %d",
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
DBA::escape(DateTimeFormat::utcNow()),
|
||||||
intval($rr['uid'])
|
intval($rr['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
|
@ -143,7 +142,7 @@ function twitter_check_item_notification(App $a, &$notification_data)
|
||||||
|
|
||||||
$own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($notification_data["uid"]),
|
intval($notification_data["uid"]),
|
||||||
dbesc("twitter::".$own_id)
|
DBA::escape("twitter::".$own_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($own_user) {
|
if ($own_user) {
|
||||||
|
@ -184,8 +183,8 @@ function twitter_follow(App $a, &$contact)
|
||||||
$r = q("SELECT name,nick,url,addr,batch,notify,poll,request,confirm,poco,photo,priority,network,alias,pubkey
|
$r = q("SELECT name,nick,url,addr,batch,notify,poll,request,confirm,poco,photo,priority,network,alias,pubkey
|
||||||
FROM `contact` WHERE `uid` = %d AND `nick` = '%s'",
|
FROM `contact` WHERE `uid` = %d AND `nick` = '%s'",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc($nickname));
|
DBA::escape($nickname));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact["contact"] = $r[0];
|
$contact["contact"] = $r[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,7 +467,7 @@ function twitter_post_hook(App $a, &$b)
|
||||||
|
|
||||||
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
|
||||||
$orig_post = Item::selectFirst([], $condition);
|
$orig_post = Item::selectFirst([], $condition);
|
||||||
if (!DBM::is_result($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
logger("twitter_post_hook: no parent found " . $b["thr-parent"]);
|
logger("twitter_post_hook: no parent found " . $b["thr-parent"]);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -622,7 +621,7 @@ function twitter_post_hook(App $a, &$b)
|
||||||
logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
|
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$a->contact = $r[0]["id"];
|
$a->contact = $r[0]["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,7 +676,7 @@ function twitter_cron(App $a, $b)
|
||||||
logger('twitter: cron_start');
|
logger('twitter: cron_start');
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1'");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1'");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('twitter: fetching for user ' . $rr['uid']);
|
logger('twitter: fetching for user ' . $rr['uid']);
|
||||||
Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int) $rr['uid']);
|
Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int) $rr['uid']);
|
||||||
|
@ -692,11 +691,11 @@ function twitter_cron(App $a, $b)
|
||||||
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if ($abandon_days != 0) {
|
if ($abandon_days != 0) {
|
||||||
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
||||||
if (!DBM::is_result($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -751,7 +750,7 @@ function twitter_expire(App $a, $b)
|
||||||
logger('twitter_expire: expire_start');
|
logger('twitter_expire: expire_start');
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('twitter_expire: user ' . $rr['uid']);
|
logger('twitter_expire: user ' . $rr['uid']);
|
||||||
Item::expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
Item::expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
||||||
|
@ -774,7 +773,7 @@ function twitter_prepare_body(App $a, &$b)
|
||||||
|
|
||||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||||
$orig_post = Item::selectFirst(['author-link'], $condition);
|
$orig_post = Item::selectFirst(['author-link'], $condition);
|
||||||
if (DBM::is_result($orig_post)) {
|
if (DBA::isResult($orig_post)) {
|
||||||
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||||
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
|
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
|
||||||
$nicknameplain = "@" . $nicknameplain;
|
$nicknameplain = "@" . $nicknameplain;
|
||||||
|
@ -923,9 +922,9 @@ function twitter_fetchtimeline(App $a, $uid)
|
||||||
function twitter_queue_hook(App $a, &$b)
|
function twitter_queue_hook(App $a, &$b)
|
||||||
{
|
{
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||||
dbesc(NETWORK_TWITTER)
|
DBA::escape(NETWORK_TWITTER)
|
||||||
);
|
);
|
||||||
if (!DBM::is_result($qi)) {
|
if (!DBA::isResult($qi)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,7 +939,7 @@ function twitter_queue_hook(App $a, &$b)
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
||||||
intval($x['cid'])
|
intval($x['cid'])
|
||||||
);
|
);
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,11 +1018,11 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
|
$contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
|
||||||
if (!DBM::is_result($contact) && !$create_user) {
|
if (!DBA::isResult($contact) && !$create_user) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBM::is_result($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
// create contact record
|
// create contact record
|
||||||
$fields['uid'] = $uid;
|
$fields['uid'] = $uid;
|
||||||
$fields['created'] = DateTimeFormat::utcNow();
|
$fields['created'] = DateTimeFormat::utcNow();
|
||||||
|
@ -1083,7 +1082,7 @@ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$self = $r[0];
|
$self = $r[0];
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -1354,11 +1353,11 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis
|
||||||
|
|
||||||
$fields = ['uri', 'parent-uri', 'parent'];
|
$fields = ['uri', 'parent-uri', 'parent'];
|
||||||
$parent_item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
$parent_item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
|
||||||
if (!DBM::is_result($parent_item)) {
|
if (!DBA::isResult($parent_item)) {
|
||||||
$parent_item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
$parent_item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBM::is_result($parent_item)) {
|
if (DBA::isResult($parent_item)) {
|
||||||
$postarray['thr-parent'] = $parent_item['uri'];
|
$postarray['thr-parent'] = $parent_item['uri'];
|
||||||
$postarray['parent-uri'] = $parent_item['parent-uri'];
|
$postarray['parent-uri'] = $parent_item['parent-uri'];
|
||||||
$postarray['parent'] = $parent_item['parent'];
|
$postarray['parent'] = $parent_item['parent'];
|
||||||
|
@ -1376,7 +1375,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contactid = $r[0]["id"];
|
$contactid = $r[0]["id"];
|
||||||
|
|
||||||
$postarray['owner-name'] = $r[0]["name"];
|
$postarray['owner-name'] = $r[0]["name"];
|
||||||
|
@ -1575,7 +1574,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
||||||
intval($own_contact),
|
intval($own_contact),
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$own_id = $r[0]["nick"];
|
$own_id = $r[0]["nick"];
|
||||||
} else {
|
} else {
|
||||||
logger("twitter_fetchhometimeline: Own twitter contact not found for user " . $uid, LOGGER_DEBUG);
|
logger("twitter_fetchhometimeline: Own twitter contact not found for user " . $uid, LOGGER_DEBUG);
|
||||||
|
@ -1585,7 +1584,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
||||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$self = $r[0];
|
$self = $r[0];
|
||||||
} else {
|
} else {
|
||||||
logger("twitter_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
logger("twitter_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
|
||||||
|
@ -1594,7 +1593,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
||||||
|
|
||||||
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
if (!DBM::is_result($u)) {
|
if (!DBA::isResult($u)) {
|
||||||
logger("twitter_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
logger("twitter_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1661,7 +1660,7 @@ function twitter_fetchhometimeline(App $a, $uid)
|
||||||
|
|
||||||
if ($postarray['uri'] == $postarray['parent-uri']) {
|
if ($postarray['uri'] == $postarray['parent-uri']) {
|
||||||
$contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
|
$contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
|
||||||
if (DBM::is_result($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$notify = Item::isRemoteSelf($contact, $postarray);
|
$notify = Item::isRemoteSelf($contact, $postarray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1752,8 +1751,8 @@ function twitter_fetch_own_contact(App $a, $uid)
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc("twitter::" . $own_id));
|
DBA::escape("twitter::" . $own_id));
|
||||||
if (DBM::is_result($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$contact_id = $r[0]["id"];
|
$contact_id = $r[0]["id"];
|
||||||
} else {
|
} else {
|
||||||
PConfig::delete($uid, 'twitter', 'own_id');
|
PConfig::delete($uid, 'twitter', 'own_id');
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
function viewsrc_install() {
|
function viewsrc_install() {
|
||||||
Addon::registerHook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
Addon::registerHook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
||||||
|
@ -43,7 +43,7 @@ function viewsrc_item_photo_menu(&$a, &$b)
|
||||||
|
|
||||||
if (local_user() != $b['item']['uid']) {
|
if (local_user() != $b['item']['uid']) {
|
||||||
$item = Item::selectFirstForUser(local_user(), ['id'], ['uid' => local_user(), 'guid' => $b['item']['guid']]);
|
$item = Item::selectFirstForUser(local_user(), ['id'], ['uid' => local_user(), 'guid' => $b['item']['guid']]);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
function like_widget_name() {
|
function like_widget_name() {
|
||||||
return "Shows likes";
|
return "Shows likes";
|
||||||
|
@ -37,7 +38,7 @@ function like_widget_content(&$a, $conf){
|
||||||
// count likes
|
// count likes
|
||||||
$r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
|
$r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
|
||||||
intval($conf['uid']),
|
intval($conf['uid']),
|
||||||
dbesc($args[0])
|
DBA::escape($args[0])
|
||||||
);
|
);
|
||||||
$likes = $r[0]['c'];
|
$likes = $r[0]['c'];
|
||||||
$iid = $r[0]['id'];
|
$iid = $r[0]['id'];
|
||||||
|
@ -45,7 +46,7 @@ function like_widget_content(&$a, $conf){
|
||||||
// count dislikes
|
// count dislikes
|
||||||
$r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
|
$r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
|
||||||
intval($conf['uid']),
|
intval($conf['uid']),
|
||||||
dbesc($args[0])
|
DBA::escape($args[0])
|
||||||
);
|
);
|
||||||
$dislikes = $r[0]['c'];
|
$dislikes = $r[0]['c'];
|
||||||
|
|
||||||
|
|
|
@ -5,21 +5,23 @@
|
||||||
* Version: 1.0
|
* Version: 1.0
|
||||||
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrix/>
|
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrix/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
function widgets_install() {
|
function widgets_install() {
|
||||||
Addon::registerHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
|
Addon::registerHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
|
||||||
Addon::registerHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
|
Addon::registerHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
|
||||||
logger("installed widgets");
|
logger("installed widgets");
|
||||||
}
|
}
|
||||||
|
|
||||||
function widgets_uninstall() {
|
function widgets_uninstall() {
|
||||||
Addon::unregisterHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
|
Addon::unregisterHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
|
||||||
Addon::unregisterHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
|
Addon::unregisterHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function widgets_settings_post(){
|
function widgets_settings_post(){
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
@ -89,7 +91,7 @@ function widgets_content(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM pconfig WHERE uid IN (SELECT uid FROM pconfig WHERE v='%s')AND cat='widgets'",
|
$r = q("SELECT * FROM pconfig WHERE uid IN (SELECT uid FROM pconfig WHERE v='%s')AND cat='widgets'",
|
||||||
dbesc($_GET['k'])
|
DBA::escape($_GET['k'])
|
||||||
);
|
);
|
||||||
if (!count($r)){
|
if (!count($r)){
|
||||||
if($a->argv[2]=="cb"){header('HTTP/1.0 400 Bad Request'); killme();}
|
if($a->argv[2]=="cb"){header('HTTP/1.0 400 Bad Request'); killme();}
|
||||||
|
|
Loading…
Reference in a new issue