Merge branch 'develop' into notices-again

This commit is contained in:
Michael Vogel 2018-07-24 04:19:48 +02:00 committed by GitHub
commit 429b9c9f4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 529 additions and 498 deletions

View file

@ -40,7 +40,6 @@ use Friendica\Core\Cache;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Item;
use Friendica\Model\Term;
@ -119,7 +118,7 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data)
$rules = Cache::get('rules_' . local_user());
if (!isset($rules)) {
$rules = DBA::inArray(DBA::select(
$rules = DBA::toArray(DBA::select(
'advancedcontentfilter_rules',
['name', 'expression', 'serialized'],
['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'));
}
$rules = DBA::inArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
$rules = DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()]));
return json_encode($rules);
}
@ -414,7 +413,7 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
$params = ['order' => ['uid' => true]];
$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']));
}

View file

@ -13,7 +13,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
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();
$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."));
return;
}
@ -95,7 +94,7 @@ function catavatar_addon_settings_post(App $a, &$s)
$condition = ['uid' => local_user(), 'contact-id' => $self['id']];
$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.'));
return;
}

View file

@ -1,11 +1,11 @@
#curweather-network img {
float: left;
margin: 30px 10px;
}
ul.curweather-details li {
list-type: none;
}
p.curweather-footer {
div.curweather-footer {
margin-top: 10px;
font-size: 0.8em;
}

View file

@ -21,203 +21,203 @@ use Friendica\Util\Network;
// get the weather data from OpenWeatherMap
function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) {
$url = "http://api.openweathermap.org/data/2.5/weather?q=".$loc."&appid=".$appid."&lang=".$lang."&units=".$units."&mode=xml";
$cached = Cache::get('curweather'.md5($url));
$now = new DateTime();
if (!is_null($cached)) {
$cdate = PConfig::get(local_user(), 'curweather', 'last');
$cached = unserialize($cached);
if ($cdate + $cachetime > $now->getTimestamp()) {
return $cached;
}
}
try {
$res = new SimpleXMLElement(Network::fetchUrl($url));
} catch (Exception $e) {
if (!$_SESSION['curweather_notice_shown']) {
info(L10n::t('Error fetching weather data. Error was: '.$e->getMessage()));
$_SESSION['curweather_notice_shown'] = true;
}
return false;
}
unset($_SESSION['curweather_notice_shown']);
if ((string)$res->temperature['unit']==='metric') {
$tunit = '°C';
$wunit = 'm/s';
} else {
$tunit = '°F';
$wunit = 'mph';
}
if ( trim((string)$res->weather['value']) == trim((string)$res->clouds['name']) ) {
$desc = (string)$res->clouds['name'];
} else {
$desc = (string)$res->weather['value'].', '.(string)$res->clouds['name'];
}
$r = [
'city'=> (string) $res->city['name'][0],
'country' => (string) $res->city->country[0],
'lat' => (string) $res->city->coord['lat'],
'lon' => (string) $res->city->coord['lon'],
'temperature' => (string) $res->temperature['value'][0].$tunit,
'pressure' => (string) $res->pressure['value'].(string)$res->pressure['unit'],
'humidity' => (string) $res->humidity['value'].(string)$res->humidity['unit'],
'descripion' => $desc,
'wind' => (string)$res->wind->speed['name'].' ('.(string)$res->wind->speed['value'].$wunit.')',
'update' => (string)$res->lastupdate['value'],
'icon' => (string)$res->weather['icon']
];
PConfig::set(local_user(), 'curweather', 'last', $now->getTimestamp());
Cache::set('curweather'.md5($url), serialize($r), CACHE_HOUR);
return $r;
$url = "http://api.openweathermap.org/data/2.5/weather?q=".$loc."&appid=".$appid."&lang=".$lang."&units=".$units."&mode=xml";
$cached = Cache::get('curweather'.md5($url));
$now = new DateTime();
if (!is_null($cached)) {
$cdate = PConfig::get(local_user(), 'curweather', 'last');
$cached = unserialize($cached);
if ($cdate + $cachetime > $now->getTimestamp()) {
return $cached;
}
}
try {
$res = new SimpleXMLElement(Network::fetchUrl($url));
} catch (Exception $e) {
if (!$_SESSION['curweather_notice_shown']) {
info(L10n::t('Error fetching weather data. Error was: '.$e->getMessage()));
$_SESSION['curweather_notice_shown'] = true;
}
return false;
}
unset($_SESSION['curweather_notice_shown']);
if ((string)$res->temperature['unit']==='metric') {
$tunit = '°C';
$wunit = 'm/s';
} else {
$tunit = '°F';
$wunit = 'mph';
}
if ( trim((string)$res->weather['value']) == trim((string)$res->clouds['name']) ) {
$desc = (string)$res->clouds['name'];
} else {
$desc = (string)$res->weather['value'].', '.(string)$res->clouds['name'];
}
$r = [
'city'=> (string) $res->city['name'][0],
'country' => (string) $res->city->country[0],
'lat' => (string) $res->city->coord['lat'],
'lon' => (string) $res->city->coord['lon'],
'temperature' => (string) $res->temperature['value'][0].$tunit,
'pressure' => (string) $res->pressure['value'].(string)$res->pressure['unit'],
'humidity' => (string) $res->humidity['value'].(string)$res->humidity['unit'],
'descripion' => $desc,
'wind' => (string)$res->wind->speed['name'].' ('.(string)$res->wind->speed['value'].$wunit.')',
'update' => (string)$res->lastupdate['value'],
'icon' => (string)$res->weather['icon']
];
PConfig::set(local_user(), 'curweather', 'last', $now->getTimestamp());
Cache::set('curweather'.md5($url), serialize($r), CACHE_HOUR);
return $r;
}
function curweather_install()
{
Addon::registerHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init');
Addon::registerHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings');
Addon::registerHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post');
Addon::registerHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init');
Addon::registerHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings');
Addon::registerHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post');
}
function curweather_uninstall() {
Addon::unregisterHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init');
Addon::unregisterHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings');
Addon::unregisterHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post');
Addon::unregisterHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init');
Addon::unregisterHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings');
Addon::unregisterHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post');
}
function curweather_network_mod_init(&$fk_app,&$b) {
if(! intval(PConfig::get(local_user(),'curweather','curweather_enable')))
return;
if(! intval(PConfig::get(local_user(),'curweather','curweather_enable')))
return;
$fk_app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
$fk_app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
// $rpt value is needed for location
// $lang will be taken from the browser session to honour user settings
// TODO $lang does not work if the default settings are used
// and not all response strings are translated
// $units can be set in the settings by the user
// $appid is configured by the admin in the admin panel
// those parameters will be used to get: cloud status, temperature, preassure
// and relative humidity for display, also the relevent area of the map is
// linked from lat/log of the reply of OWMp
$rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc');
// $rpt value is needed for location
// $lang will be taken from the browser session to honour user settings
// TODO $lang does not work if the default settings are used
// and not all response strings are translated
// $units can be set in the settings by the user
// $appid is configured by the admin in the admin panel
// those parameters will be used to get: cloud status, temperature, preassure
// and relative humidity for display, also the relevent area of the map is
// linked from lat/log of the reply of OWMp
$rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc');
// set the language to the browsers language and use metric units
$lang = $_SESSION['language'];
$units = PConfig::get( local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather','appid');
$cachetime = intval(Config::get('curweather','cachetime'));
if ($units==="")
$units = 'metric';
$ok = true;
// set the language to the browsers language and use metric units
$lang = $_SESSION['language'];
$units = PConfig::get( local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather','appid');
$cachetime = intval(Config::get('curweather','cachetime'));
if ($units==="")
$units = 'metric';
$ok = true;
$res = getWeather($rpt, $units, $lang, $appid, $cachetime);
if ($res===false)
$ok = false;
$res = getWeather($rpt, $units, $lang, $appid, $cachetime);
if ($res===false)
$ok = false;
if ($ok) {
$t = get_markup_template("widget.tpl", "addon/curweather/" );
$curweather = replace_macros ($t, [
'$title' => L10n::t("Current Weather"),
'$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'),
'$city' => $res['city'],
'$lon' => $res['lon'],
'$lat' => $res['lat'],
'$description' => $res['descripion'],
'$temp' => $res['temperature'],
'$relhumidity' => ['caption'=>L10n::t('Relative Humidity'), 'val'=>$res['humidity']],
'$pressure' => ['caption'=>L10n::t('Pressure'), 'val'=>$res['pressure']],
'$wind' => ['caption'=>L10n::t('Wind'), 'val'=> $res['wind']],
'$lastupdate' => L10n::t('Last Updated').': '.$res['update'].'UTC',
'$databy' => L10n::t('Data by'),
'$showonmap' => L10n::t('Show on map')
]);
} else {
$t = get_markup_template('widget-error.tpl', 'addon/curweather/');
$curweather = replace_macros( $t, [
'$problem' => L10n::t('There was a problem accessing the weather data. But have a look'),
'$rpt' => $rpt,
'$atOWM' => L10n::t('at OpenWeatherMap')
]);
}
if ($ok) {
$t = get_markup_template("widget.tpl", "addon/curweather/" );
$curweather = replace_macros ($t, [
'$title' => L10n::t("Current Weather"),
'$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'),
'$city' => $res['city'],
'$lon' => $res['lon'],
'$lat' => $res['lat'],
'$description' => $res['descripion'],
'$temp' => $res['temperature'],
'$relhumidity' => ['caption'=>L10n::t('Relative Humidity'), 'val'=>$res['humidity']],
'$pressure' => ['caption'=>L10n::t('Pressure'), 'val'=>$res['pressure']],
'$wind' => ['caption'=>L10n::t('Wind'), 'val'=> $res['wind']],
'$lastupdate' => L10n::t('Last Updated').': '.$res['update'].'UTC',
'$databy' => L10n::t('Data by'),
'$showonmap' => L10n::t('Show on map')
]);
} else {
$t = get_markup_template('widget-error.tpl', 'addon/curweather/');
$curweather = replace_macros( $t, [
'$problem' => L10n::t('There was a problem accessing the weather data. But have a look'),
'$rpt' => $rpt,
'$atOWM' => L10n::t('at OpenWeatherMap')
]);
}
$fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
$fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
}
function curweather_addon_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'curweather-settings-submit')))
return;
PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc']));
PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable']));
PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
info(L10n::t('Current Weather settings updated.') . EOL);
if(! local_user() || (! x($_POST,'curweather-settings-submit')))
return;
PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc']));
PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable']));
PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
info(L10n::t('Current Weather settings updated.') . EOL);
}
function curweather_addon_settings(&$a,&$s) {
if(! local_user())
return;
/* Get the current state of our config variable */
$curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc');
$curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather','appid');
if ($appid=="") {
$noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.');
} else {
$noappidtext = '';
}
$enable = intval(PConfig::get(local_user(),'curweather','curweather_enable'));
$enable_checked = (($enable) ? ' checked="checked" ' : '');
// load template and replace the macros
$t = get_markup_template("settings.tpl", "addon/curweather/" );
$s = replace_macros ($t, [
'$submit' => L10n::t('Save Settings'),
'$header' => L10n::t('Current Weather').' '.L10n::t('Settings'),
'$noappidtext' => $noappidtext,
'$info' => L10n::t('Enter either the name of your location or the zip code.'),
'$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
'$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in &deg;C or &deg;F'), ['metric'=>'°C', 'imperial'=>'°F']],
'$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, '']
]);
return;
if(! local_user())
return;
/* Get the current state of our config variable */
$curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc');
$curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather','appid');
if ($appid=="") {
$noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.');
} else {
$noappidtext = '';
}
$enable = intval(PConfig::get(local_user(),'curweather','curweather_enable'));
$enable_checked = (($enable) ? ' checked="checked" ' : '');
// load template and replace the macros
$t = get_markup_template("settings.tpl", "addon/curweather/" );
$s = replace_macros ($t, [
'$submit' => L10n::t('Save Settings'),
'$header' => L10n::t('Current Weather').' '.L10n::t('Settings'),
'$noappidtext' => $noappidtext,
'$info' => L10n::t('Enter either the name of your location or the zip code.'),
'$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
'$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in &deg;C or &deg;F'), ['metric'=>'°C', 'imperial'=>'°F']],
'$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, '']
]);
return;
}
// Config stuff for the admin panel to let the admin of the node set a APPID
// for accessing the API of openweathermap
function curweather_addon_admin_post (&$a) {
if(! is_site_admin())
return;
if ($_POST['curweather-submit']) {
Config::set('curweather','appid',trim($_POST['appid']));
Config::set('curweather','cachetime',trim($_POST['cachetime']));
info(L10n::t('Curweather settings saved.'.EOL));
}
if(! is_site_admin())
return;
if ($_POST['curweather-submit']) {
Config::set('curweather','appid',trim($_POST['appid']));
Config::set('curweather','cachetime',trim($_POST['cachetime']));
info(L10n::t('Curweather settings saved.'.EOL));
}
}
function curweather_addon_admin (&$a, &$o) {
if(! is_site_admin())
return;
$appid = Config::get('curweather','appid');
$cachetime = Config::get('curweather','cachetime');
$t = get_markup_template("admin.tpl", "addon/curweather/" );
$o = replace_macros ($t, [
'$submit' => L10n::t('Save Settings'),
'$cachetime' => [
'cachetime',
L10n::t('Caching Interval'),
$cachetime,
L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), [
'0'=>L10n::t('no cache'),
'300'=>'5 '.L10n::t('minutes'),
'900'=>'15 '.L10n::t('minutes'),
'1800'=>'30 '.L10n::t('minutes'),
'3600'=>'60 '.L10n::t('minutes')
]
],
'$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')]
]);
if(! is_site_admin())
return;
$appid = Config::get('curweather','appid');
$cachetime = Config::get('curweather','cachetime');
$t = get_markup_template("admin.tpl", "addon/curweather/" );
$o = replace_macros ($t, [
'$submit' => L10n::t('Save Settings'),
'$cachetime' => [
'cachetime',
L10n::t('Caching Interval'),
$cachetime,
L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), [
'0'=>L10n::t('no cache'),
'300'=>'5 '.L10n::t('minutes'),
'900'=>'15 '.L10n::t('minutes'),
'1800'=>'30 '.L10n::t('minutes'),
'3600'=>'60 '.L10n::t('minutes')
]
],
'$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')]
]);
}

View file

@ -1,17 +1,24 @@
<div id="curweather-network" class="widget">
<div class="title tool">
<div class="title tool clear">
<h3 title="{{$lastupdate}}">{{$title}}: {{$city}}</h3>
</div>
<p>
<div class="pull-left">
<img src="{{$icon}}" title="{{$description}}">
</div>
<div class="pull-right">
<ul class="curweather-details">
<li><strong>{{$temp}}</strong></li>
<li>{{$relhumidity['caption']}}: {{$relhumidity['val']}}</li>
<li>{{$pressure['caption']}}: {{$pressure['val']}}</li>
<li>{{$wind['caption']}}: {{$wind['val']}}</li>
</ul></p>
<p class="curweather-footer">
{{$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>
</p>
<li><strong>{{$temp}}</strong></li>
<li>{{$relhumidity['caption']}}: {{$relhumidity['val']}}</li>
<li>{{$pressure['caption']}}: {{$pressure['val']}}</li>
<li>{{$wind['caption']}}: {{$wind['val']}}</li>
</ul>
</div>
<div class="clear"></div>
<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 class="clear"></div>

View file

@ -9,57 +9,67 @@
require_once 'addon/diaspora/Diaspora_Connection.php';
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Queue;
function diaspora_install() {
Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
function diaspora_install()
{
Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
Addon::registerHook('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
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() {
Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
function diaspora_uninstall()
{
Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
Addon::unregisterHook('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
Addon::unregisterHook('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
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)
{
if (!local_user()) {
return;
}
function diaspora_jot_nets(&$a,&$b) {
if(! local_user())
return;
$diaspora_post = PConfig::get(local_user(), 'diaspora', 'post');
$diaspora_post = PConfig::get(local_user(),'diaspora','post');
if(intval($diaspora_post) == 1) {
$diaspora_defpost = PConfig::get(local_user(),'diaspora','post_by_default');
$selected = ((intval($diaspora_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspora_enable"' . $selected . ' value="1" /> '
. L10n::t('Post to Diaspora') . '</div>';
}
if (intval($diaspora_post) == 1) {
$diaspora_defpost = PConfig::get(local_user(), 'diaspora', 'post_by_default');
$selected = ((intval($diaspora_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspora_enable"' . $selected . ' value="1" /> '
. L10n::t('Post to Diaspora') . '</div>';
}
}
function diaspora_queue_hook(&$a,&$b) {
function diaspora_queue_hook(App $a, &$b) {
$hostname = $a->get_hostname();
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_DIASPORA2)
DBA::escape(NETWORK_DIASPORA2)
);
if(! count($qi))
return;
foreach($qi as $x) {
if($x['network'] !== NETWORK_DIASPORA2)
if (!DBA::isResult($qi)) {
return;
}
foreach ($qi as $x) {
if ($x['network'] !== NETWORK_DIASPORA2) {
continue;
}
logger('diaspora_queue: run');
@ -67,19 +77,21 @@ function diaspora_queue_hook(&$a,&$b) {
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
if(! count($r))
if (!DBA::isResult($r)) {
continue;
}
$userdata = $r[0];
$handle = PConfig::get($userdata['uid'],'diaspora','handle');
$password = PConfig::get($userdata['uid'],'diaspora','password');
$aspect = PConfig::get($userdata['uid'],'diaspora','aspect');
$handle = PConfig::get($userdata['uid'], 'diaspora', 'handle');
$password = PConfig::get($userdata['uid'], 'diaspora', 'password');
$aspect = PConfig::get($userdata['uid'], 'diaspora', 'aspect');
$success = false;
if ($handle && $password) {
logger('diaspora_queue: able to post for user '.$handle);
logger('diaspora_queue: able to post for user '.$handle);
$z = unserialize($x['content']);
@ -115,10 +127,11 @@ function diaspora_queue_hook(&$a,&$b) {
}
}
function diaspora_settings(&$a,&$s) {
if(! local_user())
function diaspora_settings(App $a, &$s)
{
if (! local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
@ -141,7 +154,8 @@ function diaspora_settings(&$a,&$s) {
$status = "";
$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('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']);
@ -153,6 +167,7 @@ function diaspora_settings(&$a,&$s) {
$conn = new Diaspora_Connection($handle, $password);
$conn->logIn();
$aspects = $conn->getAspects();
if (!$aspects) {
$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) {
if(x($_POST,'diaspora-submit')) {
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','handle',trim($_POST['handle']));
PConfig::set(local_user(),'diaspora','password',trim($_POST['password']));
PConfig::set(local_user(),'diaspora','aspect',trim($_POST['aspect']));
function diaspora_settings_post(App $a, &$b)
{
if (!empty($_POST['diaspora-submit'])) {
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', 'handle' , trim($_POST['handle']));
PConfig::set(local_user(),'diaspora', 'password' , trim($_POST['password']));
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']) {
return;
}
@ -271,29 +284,28 @@ function diaspora_post_local(&$a,&$b) {
$b['postopts'] .= 'diaspora';
}
function diaspora_send(&$a,&$b) {
function diaspora_send(App $a, array &$b)
{
$hostname = $a->get_hostname();
logger('diaspora_send: invoked');
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
}
if(! strstr($b['postopts'],'diaspora')) {
if (!strstr($b['postopts'],'diaspora')) {
return;
}
if($b['parent'] != $b['id']) {
if ($b['parent'] != $b['id']) {
return;
}
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
$self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return;
}
@ -311,13 +323,15 @@ function diaspora_send(&$a,&$b) {
$tags = '';
$x = preg_match_all('/\#\[(.*?)\](.*?)\[/',$b['tag'],$matches,PREG_SET_ORDER);
if($x) {
foreach($matches as $mtch) {
if ($x) {
foreach ($matches as $mtch) {
$tag_arr[] = $mtch[2];
}
}
if(count($tag_arr))
if (count($tag_arr)) {
$tags = implode(',',$tag_arr);
}
$title = $b['title'];
$body = $b['body'];
@ -334,17 +348,18 @@ function diaspora_send(&$a,&$b) {
// remove multiple newlines
do {
$oldbody = $body;
$body = str_replace("\n\n\n", "\n\n", $body);
} while ($oldbody != $body);
$body = str_replace("\n\n\n", "\n\n", $body);
} while ($oldbody != $body);
// convert to markdown
$body = BBCode::toMarkdown($body);
// Adding the title
if(strlen($title))
if (strlen($title)) {
$body = "## ".html_entity_decode($title)."\n\n".$body;
}
require_once("addon/diaspora/diasphp.php");
require_once "addon/diaspora/diasphp.php";
try {
logger('diaspora_send: prepare', LOGGER_DEBUG);

View file

@ -11,7 +11,7 @@ use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Model\Profile;
use Friendica\Util\Temporal;
@ -100,14 +100,14 @@ function forumdirectory_content(&$a)
if (strlen($search)) {
$sql_extra = " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,"
. "`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 ";
$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 ");
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$a->set_pager_total($r[0]['total']);
}
@ -120,7 +120,7 @@ function forumdirectory_content(&$a)
intval($a->pager['itemspage'])
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
if (in_array('small', $a->argv)) {
$photo = 'thumb';
} else {

View file

@ -5,9 +5,12 @@
* Version: 1.1
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
/**
* Installs the addon hook
@ -29,7 +32,7 @@ function gravatar_uninstall() {
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');
}
@ -93,7 +96,7 @@ function gravatar_addon_admin (&$a, &$o) {
// Check if Libravatar is enabled and show warning
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
dbesc('libravatar')
DBA::escape('libravatar')
);
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>';

View file

@ -15,7 +15,6 @@ use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
function ifttt_install()
@ -102,7 +101,7 @@ function ifttt_post(App $a)
$nickname = $a->argv[1];
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBM::is_result($user)) {
if (!DBA::isResult($user)) {
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
return;
}

View file

@ -67,6 +67,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\Network;
@ -195,7 +196,7 @@ function jappixmini_init()
$role = $_REQUEST["role"];
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)) {
killme();
}
@ -204,7 +205,7 @@ function jappixmini_init()
$decrypt_func = openssl_public_decrypt;
$key = $r[0]["pubkey"];
} 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)) {
killme();
}
@ -524,7 +525,7 @@ function jappixmini_script(App $a)
$key = $row['k'];
$pos = strpos($key, ":");
$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))
$name = $r[0]["name"];
@ -593,7 +594,7 @@ function jappixmini_cron(App $a, $d)
// 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'",
intval($uid), dbesc(NETWORK_DFRN));
intval($uid), DBA::escape(NETWORK_DFRN));
foreach ($contacts as $contact_row) {
$request = $contact_row["request"];
if (!$request) {

View file

@ -5,9 +5,12 @@
* Version: 1.1
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
/**
* Installs the addon hook
@ -29,7 +32,7 @@ function libravatar_uninstall()
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');
}
@ -96,7 +99,7 @@ function libravatar_addon_admin(&$a, &$o)
// Libravatar falls back to gravatar, so show warning about gravatar addon if enabled
$r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
dbesc('gravatar')
DBA::escape('gravatar')
);
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>';

View file

@ -11,7 +11,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
use Friendica\Util\Network;
use Friendica\Model\Item;
@ -120,10 +120,10 @@ function mailstream_post_hook(&$a, &$item) {
$message_id = mailstream_generate_id($a, $item['uri']);
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
intval($item['contact-id']), dbesc($item['uri']), dbesc($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']));
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']), DBA::escape($item['uri']));
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;
}
$ms_item = $r[0];
@ -132,7 +132,7 @@ function mailstream_post_hook(&$a, &$item) {
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
$user = mailstream_get_user($item['uid']);
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;
}
mailstream_send($a, $ms_item['message-id'], $item, $user);
@ -141,7 +141,7 @@ function mailstream_post_hook(&$a, &$item) {
function mailstream_get_user($uid) {
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
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 $r[0];
@ -173,7 +173,7 @@ function mailstream_do_images($a, &$item, &$attachments) {
function mailstream_sender($item) {
$r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$contact = $r[0];
if ($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
for ($i = 0; ($i < 100) && $parent; $i++) {
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
if (!DBM::is_result($parent_item)) {
if (!DBA::isResult($parent_item)) {
break;
}
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);
} 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) {
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
// we'll just try to send it over and over again and it'll fail
// 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);
foreach ($ms_item_ids as $ms_item_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']]);
$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);
}
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']));
}
}

View file

@ -10,7 +10,6 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
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
`account_expires_on` > '%s' AND
`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) {
notification([
'uid' => $rr['uid'],
@ -82,8 +81,8 @@ function public_server_cron($a, $b)
$nologin = Config::get('public_server', 'nologin', false);
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'",
dbesc(NULL_DATE), intval($nologin), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
DBA::escape(NULL_DATE), intval($nologin), DBA::escape(NULL_DATE));
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
DBA::update('user', $fields, ['uid' => $rr['uid']]);
@ -94,8 +93,8 @@ function public_server_cron($a, $b)
$flagusers = Config::get('public_server', 'flagusers', false);
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",
intval($flagusers), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
intval($flagusers), DBA::escape(NULL_DATE));
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
DBA::update('user', $fields, ['uid' => $rr['uid']]);
@ -107,8 +106,8 @@ function public_server_cron($a, $b)
$flagpostsexpire = Config::get('public_server', '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",
intval($flagposts), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
intval($flagposts), DBA::escape(NULL_DATE));
if (DBA::isResult($r)) {
foreach ($r as $rr) {
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
}

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -14,7 +15,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
@ -59,7 +59,7 @@ function pumpio_uninstall()
function pumpio_module() {}
function pumpio_content(&$a)
function pumpio_content(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
@ -92,7 +92,7 @@ function pumpio_check_item_notification($a, &$notification_data)
$notification_data["profiles"][] = "https://".$hostname."/".$username;
}
function pumpio_registerclient(&$a, $host)
function pumpio_registerclient(App $a, $host)
{
$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
session_start();
@ -211,13 +211,14 @@ function pumpio_connect(&$a)
return $o;
}
function pumpio_jot_nets(&$a, &$b)
function pumpio_jot_nets(App $a, &$b)
{
if (!local_user()) {
if (! local_user()) {
return;
}
$pumpio_post = PConfig::get(local_user(), 'pumpio', 'post');
if (intval($pumpio_post) == 1) {
$pumpio_defpost = PConfig::get(local_user(), 'pumpio', 'post_by_default');
$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()) {
return;
@ -326,28 +327,29 @@ 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>';
}
function pumpio_settings_post(&$a, &$b)
function pumpio_settings_post(App $a, array &$b)
{
if (x($_POST, 'pumpio-submit')) {
if (x($_POST, 'pumpio_delete')) {
PConfig::set(local_user(), 'pumpio', 'consumer_key', '');
PConfig::set(local_user(), 'pumpio', 'consumer_secret', '');
PConfig::set(local_user(), 'pumpio', 'oauth_token', '');
if (!empty($_POST['pumpio-submit'])) {
if (!empty($_POST['pumpio_delete'])) {
PConfig::set(local_user(), 'pumpio', 'consumer_key' , '');
PConfig::set(local_user(), 'pumpio', 'consumer_secret' , '');
PConfig::set(local_user(), 'pumpio', 'oauth_token' , '');
PConfig::set(local_user(), 'pumpio', 'oauth_token_secret', '');
PConfig::set(local_user(), 'pumpio', 'post', false);
PConfig::set(local_user(), 'pumpio', 'import', false);
PConfig::set(local_user(), 'pumpio', 'host', '');
PConfig::set(local_user(), 'pumpio', 'user', '');
PConfig::set(local_user(), 'pumpio', 'public', false);
PConfig::set(local_user(), 'pumpio', 'mirror', false);
PConfig::set(local_user(), 'pumpio', 'post_by_default', false);
PConfig::set(local_user(), 'pumpio', 'lastdate', 0);
PConfig::set(local_user(), 'pumpio', 'last_id', '');
PConfig::set(local_user(), 'pumpio', 'post' , false);
PConfig::set(local_user(), 'pumpio', 'import' , false);
PConfig::set(local_user(), 'pumpio', 'host' , '');
PConfig::set(local_user(), 'pumpio', 'user' , '');
PConfig::set(local_user(), 'pumpio', 'public' , false);
PConfig::set(local_user(), 'pumpio', 'mirror' , false);
PConfig::set(local_user(), 'pumpio', 'post_by_default' , false);
PConfig::set(local_user(), 'pumpio', 'lastdate' , 0);
PConfig::set(local_user(), 'pumpio', 'last_id' , '');
} else {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
if (strstr($user, "@")) {
$pos = strpos($user, "@");
if ($pos > 0) {
$user = substr($user, 0, $pos);
}
@ -358,13 +360,13 @@ function pumpio_settings_post(&$a, &$b)
$host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host);
PConfig::set(local_user(), 'pumpio', 'post',intval($_POST['pumpio']));
PConfig::set(local_user(), 'pumpio', 'import', $_POST['pumpio_import']);
PConfig::set(local_user(), 'pumpio', 'host', $host);
PConfig::set(local_user(), 'pumpio', 'user', $user);
PConfig::set(local_user(), 'pumpio', 'public', $_POST['pumpio_public']);
PConfig::set(local_user(), 'pumpio', 'mirror', $_POST['pumpio_mirror']);
PConfig::set(local_user(), 'pumpio', 'post_by_default',intval($_POST['pumpio_bydefault']));
PConfig::set(local_user(), 'pumpio', 'post' , intval($_POST['pumpio']));
PConfig::set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import']);
PConfig::set(local_user(), 'pumpio', 'host' , $host);
PConfig::set(local_user(), 'pumpio', 'user' , $user);
PConfig::set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public']);
PConfig::set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror']);
PConfig::set(local_user(), 'pumpio', 'post_by_default', intval($_POST['pumpio_bydefault']));
if (!$_POST['pumpio_mirror']) {
PConfig::delete(local_user(), 'pumpio', 'lastdate');
@ -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');
}
function pumpio_post_local(&$a, &$b)
function pumpio_post_local(App $a, array &$b)
{
if (!local_user() || (local_user() != $b['uid'])) {
return;
@ -388,7 +390,7 @@ function pumpio_post_local(&$a, &$b)
$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'))) {
$pumpio_enable = 1;
@ -405,12 +407,10 @@ function pumpio_post_local(&$a, &$b)
$b['postopts'] .= 'pumpio';
}
function pumpio_send(&$a, &$b)
function pumpio_send(App $a, array &$b)
{
if (!PConfig::get($b["uid"], 'pumpio', 'import')) {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
}
if (!PConfig::get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
return;
}
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];
$orig_post = Item::selectFirst([], $condition);
if (!DBM::is_result($orig_post)) {
if (!DBA::isResult($orig_post)) {
logger("pumpio_send: no pumpio post ".$b["parent"]);
return;
} else {
@ -572,7 +572,7 @@ function pumpio_send(&$a, &$b)
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
$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"];
}
@ -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
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]);
if (!DBM::is_result($orig_post)) {
if (!DBA::isResult($orig_post)) {
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));
$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"];
}
@ -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'");
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
return;
}
@ -682,7 +682,7 @@ function pumpio_sync(&$a)
logger('pumpio: cron_start');
$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) {
logger('pumpio: mirroring user '.$rr['uid']);
pumpio_fetchtimeline($a, $rr['uid']);
@ -697,11 +697,11 @@ function pumpio_sync(&$a)
$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() ");
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
foreach ($r as $rr) {
if ($abandon_days != 0) {
$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');
continue;
}
@ -730,12 +730,12 @@ function pumpio_sync(&$a)
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");
}
function pumpio_fetchtimeline(&$a, $uid)
function pumpio_fetchtimeline(App $a, $uid)
{
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$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
// Two queries for speed issues
$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]);
if (!DBM::is_result($orig_post)) {
if (!DBA::isResult($orig_post)) {
return;
}
}
@ -883,11 +883,11 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id)
$contactid = $self[0]['id'];
} else {
$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)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$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']]);
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']);
} else {
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');
@ -917,9 +917,9 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
// Searching for the liked post
// Two queries for speed issues
$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]);
if (!DBM::is_result($orig_post)) {
if (!DBA::isResult($orig_post)) {
return;
}
}
@ -938,11 +938,11 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
$post->actor->image->url = $self[0]['photo'];
} else {
$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)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$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",
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
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
`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)",
intval($uid),
dbesc(DateTimeFormat::utcNow()),
dbesc($contact->url),
dbesc(normalise_link($contact->url)),
dbesc(str_replace("acct:", "", $contact->id)),
dbesc(''),
dbesc($contact->id), // What is it for?
dbesc('pump.io ' . $contact->id), // What is it for?
dbesc($contact->displayName),
dbesc($contact->preferredUsername),
dbesc($contact->image->url),
dbesc(NETWORK_PUMPIO),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape($contact->url),
DBA::escape(normalise_link($contact->url)),
DBA::escape(str_replace("acct:", "", $contact->id)),
DBA::escape(''),
DBA::escape($contact->id), // What is it for?
DBA::escape('pump.io ' . $contact->id), // What is it for?
DBA::escape($contact->displayName),
DBA::escape($contact->preferredUsername),
DBA::escape($contact->image->url),
DBA::escape(NETWORK_PUMPIO),
intval(CONTACT_IS_FRIEND),
intval(1),
dbesc($contact->location->displayName),
dbesc($contact->summary),
DBA::escape($contact->location->displayName),
DBA::escape($contact->summary),
intval(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)
);
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
return false;
}
@ -1075,7 +1075,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
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
$condition = ['uri' => $post->object->id, 'uid' => $uid];
@ -1092,7 +1092,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id)
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');
@ -1171,19 +1171,19 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
} elseif ($contact_id == 0) {
// 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",
dbesc(normalise_link($post->actor->url)),
DBA::escape(normalise_link($post->actor->url)),
intval($uid)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$contact_id = $r[0]['id'];
} else {
$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)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$contact_id = $r[0]['id'];
} else {
$contact_id = $self[0]['id'];
@ -1285,12 +1285,12 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
return $top_item;
}
function pumpio_fetchinbox(&$a, $uid)
function pumpio_fetchinbox(App $a, $uid)
{
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$lastdate = PConfig::get($uid, 'pumpio', 'lastdate');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");
@ -1304,7 +1304,7 @@ function pumpio_fetchinbox(&$a, $uid)
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
WHERE `thread`.`network` = '%s' AND `thread`.`uid` = %d AND `item`.`extid` != ''
ORDER BY `thread`.`commented` DESC LIMIT 10",
dbesc(NETWORK_PUMPIO),
DBA::escape(NETWORK_PUMPIO),
intval($uid)
);
@ -1347,19 +1347,19 @@ function pumpio_fetchinbox(&$a, $uid)
}
}
foreach ($lastitems AS $item) {
foreach ($lastitems as $item) {
pumpio_fetchallcomments($a, $uid, $item["uri"]);
}
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');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");
@ -1376,7 +1376,7 @@ function pumpio_getallusers(&$a, $uid)
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $users);
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $users);
} else {
$success = false;
}
@ -1385,25 +1385,26 @@ function pumpio_getallusers(&$a, $uid)
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $users);
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $users);
} else {
$success = false;
}
}
if (!empty($users->items)) {
foreach ($users->items AS $user) {
foreach ($users->items as $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'",
dbesc(NETWORK_PUMPIO)
DBA::escape(NETWORK_PUMPIO)
);
if (!DBM::is_result($qi)) {
if (!DBA::isResult($qi)) {
return;
}
@ -1418,7 +1419,7 @@ function pumpio_queue_hook(&$a, &$b)
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
continue;
}
@ -1426,10 +1427,10 @@ function pumpio_queue_hook(&$a, &$b)
//logger('pumpio_queue: fetching userdata '.print_r($userdata, true));
$oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token");
$oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token");
$oauth_token_secret = PConfig::get($userdata['uid'], "pumpio", "oauth_token_secret");
$consumer_key = PConfig::get($userdata['uid'], "pumpio","consumer_key");
$consumer_secret = PConfig::get($userdata['uid'], "pumpio","consumer_secret");
$consumer_key = PConfig::get($userdata['uid'], "pumpio", "consumer_key");
$consumer_secret = PConfig::get($userdata['uid'], "pumpio", "consumer_secret");
$host = PConfig::get($userdata['uid'], "pumpio", "host");
$user = PConfig::get($userdata['uid'], "pumpio", "user");
@ -1481,7 +1482,7 @@ function pumpio_queue_hook(&$a, &$b)
}
}
function pumpio_getreceiver(&$a, $b)
function pumpio_getreceiver(App $a, array $b)
{
$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",
intval($cid),
intval($b["uid"]),
dbesc(NETWORK_PUMPIO)
DBA::escape(NETWORK_PUMPIO)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$receiver["bcc"][] = [
"displayName" => $r[0]["name"],
"objectType" => "person",
@ -1525,7 +1526,7 @@ function pumpio_getreceiver(&$a, $b)
"FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
"AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
intval($gid),
dbesc(NETWORK_PUMPIO)
DBA::escape(NETWORK_PUMPIO)
);
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",
intval($cid),
intval($b["uid"]),
dbesc(NETWORK_PUMPIO)
DBA::escape(NETWORK_PUMPIO)
);
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$receiver["to"][] = [
"displayName" => $r[0]["name"],
"objectType" => "person",
@ -1566,12 +1567,12 @@ function pumpio_getreceiver(&$a, $b)
return $receiver;
}
function pumpio_fetchallcomments(&$a, $uid, $id)
function pumpio_fetchallcomments(App $a, $uid, $id)
{
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$ckey = PConfig::get($uid, 'pumpio', 'consumer_key');
$csecret = PConfig::get($uid, 'pumpio', 'consumer_secret');
$otoken = PConfig::get($uid, 'pumpio', 'oauth_token');
$osecret = PConfig::get($uid, 'pumpio', 'oauth_token_secret');
$hostname = PConfig::get($uid, 'pumpio', 'host');
$username = PConfig::get($uid, "pumpio", "user");
@ -1585,7 +1586,7 @@ function pumpio_fetchallcomments(&$a, $uid, $id)
// Fetching the original post
$condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
$item = Item::selectFirst(['extid'], $condition);
if (!DBM::is_result($item)) {
if (!DBA::isResult($item)) {
return false;
}

View file

@ -6,10 +6,12 @@
* Author: Zach <https://f.shmuz.in/profile/techcity>
*
*/
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
function remote_permissions_install() {
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
$nick = $r[0]['nick'];
$r = q("SELECT uid FROM user WHERE nickname = '%s' LIMIT 1",
dbesc($nick)
DBA::escape($nick)
);
if(! $r)
return;
@ -104,15 +106,15 @@ function remote_permissions_content($a, $item_copy) {
if($item_copy['uri'] === $item_copy['parent-uri']) {
// 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",
dbesc($item_copy['uri'])
DBA::escape($item_copy['uri'])
);
}
else {
// Lockview for a comment
$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",
dbesc($item_copy['uri']),
dbesc($item_copy['parent-uri'])
DBA::escape($item_copy['uri']),
DBA::escape($item_copy['parent-uri'])
);
}
if($r) {
@ -130,7 +132,7 @@ function remote_permissions_content($a, $item_copy) {
if(count($allowed_groups)) {
$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)
$allow[] = $rr['contact-id'];
@ -139,7 +141,7 @@ function remote_permissions_content($a, $item_copy) {
if(count($deny_groups)) {
$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)
$deny[] = $rr['contact-id'];
@ -149,7 +151,7 @@ function remote_permissions_content($a, $item_copy) {
if($allow)
{
$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)
$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
// those
$r = q("SELECT `uid` FROM item WHERE uri = '%s' OR guid = '%s'",
dbesc($item_copy['uri']),
dbesc($item_copy['guid'])
DBA::escape($item_copy['uri']),
DBA::escape($item_copy['guid'])
);
if(! $r)
return;
@ -173,7 +175,7 @@ function remote_permissions_content($a, $item_copy) {
$allow[] = $rr['uid'];
$r = q("SELECT username FROM user WHERE uid IN ( %s )",
dbesc(implode(', ', $allow))
DBA::escape(implode(', ', $allow))
);
if(! $r)
return;

View file

@ -48,7 +48,6 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@ -465,7 +464,7 @@ function statusnet_post_hook(App $a, &$b)
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
$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"]);
return;
} else {
@ -686,7 +685,7 @@ function statusnet_prepare_body(App $a, &$b)
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
$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"]);
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
@ -731,7 +730,7 @@ function statusnet_cron(App $a, $b)
logger('statusnet: cron_start');
$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) {
logger('statusnet: fetching for user ' . $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);
$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) {
if ($abandon_days != 0) {
$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');
continue;
}
@ -900,48 +899,48 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
"location" => $contact->location, "about" => $contact->description,
"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;
}
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);
return -1;
}
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
// create contact record
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
`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 ) ",
intval($uid),
dbesc(DateTimeFormat::utcNow()),
dbesc($contact->statusnet_profile_url),
dbesc(normalise_link($contact->statusnet_profile_url)),
dbesc(statusnet_address($contact)),
dbesc(normalise_link($contact->statusnet_profile_url)),
dbesc(''),
dbesc(''),
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->profile_image_url),
dbesc(NETWORK_STATUSNET),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape($contact->statusnet_profile_url),
DBA::escape(normalise_link($contact->statusnet_profile_url)),
DBA::escape(statusnet_address($contact)),
DBA::escape(normalise_link($contact->statusnet_profile_url)),
DBA::escape(''),
DBA::escape(''),
DBA::escape($contact->name),
DBA::escape($contact->screen_name),
DBA::escape($contact->profile_image_url),
DBA::escape(NETWORK_STATUSNET),
intval(CONTACT_IS_FRIEND),
intval(1),
dbesc($contact->location),
dbesc($contact->description),
DBA::escape($contact->location),
DBA::escape($contact->description),
intval(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),
dbesc(NETWORK_STATUSNET));
DBA::escape(NETWORK_STATUSNET));
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
return false;
}
@ -956,10 +955,10 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
`micro` = '%s',
`avatar-date` = '%s'
WHERE `id` = %d",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
dbesc(DateTimeFormat::utcNow()),
DBA::escape($photos[0]),
DBA::escape($photos[1]),
DBA::escape($photos[2]),
DBA::escape(DateTimeFormat::utcNow()),
intval($contact_id)
);
} else {
@ -987,19 +986,19 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
`location` = '%s',
`about` = '%s'
WHERE `id` = %d",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
dbesc(DateTimeFormat::utcNow()),
dbesc(DateTimeFormat::utcNow()),
dbesc(DateTimeFormat::utcNow()),
dbesc($contact->statusnet_profile_url),
dbesc(normalise_link($contact->statusnet_profile_url)),
dbesc(statusnet_address($contact)),
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->location),
dbesc($contact->description),
DBA::escape($photos[0]),
DBA::escape($photos[1]),
DBA::escape($photos[2]),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape($contact->statusnet_profile_url),
DBA::escape(normalise_link($contact->statusnet_profile_url)),
DBA::escape(statusnet_address($contact)),
DBA::escape($contact->name),
DBA::escape($contact->screen_name),
DBA::escape($contact->location),
DBA::escape($contact->description),
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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$self = $r[0];
} else {
return;
@ -1087,11 +1086,11 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$fields = ['uri', 'parent-uri', 'parent'];
$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]);
}
if (DBM::is_result($item)) {
if (DBA::isResult($item)) {
$postarray['thr-parent'] = $item['uri'];
$postarray['parent-uri'] = $item['parent-uri'];
$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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$contactid = $r[0]["id"];
$postarray['owner-name'] = $r[0]["name"];
@ -1213,7 +1212,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
intval($own_contact),
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$nick = $r[0]["nick"];
} else {
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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$self = $r[0];
} else {
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",
intval($uid));
if (!DBM::is_result($u)) {
if (!DBA::isResult($u)) {
logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
return;
}
@ -1521,8 +1520,8 @@ function statusnet_fetch_own_contact(App $a, $uid)
$contact_id = statusnet_fetch_contact($uid, $user, true);
} else {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc($own_url));
if (DBM::is_result($r)) {
intval($uid), DBA::escape($own_url));
if (DBA::isResult($r)) {
$contact_id = $r[0]["id"];
} else {
PConfig::delete($uid, 'statusnet', 'own_url');

View file

@ -6,9 +6,11 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Model\User;
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');
}
@ -51,7 +53,7 @@ function testdrive_register_account($a,$b) {
return;
$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)
);
@ -79,7 +81,7 @@ function testdrive_cron($a,$b) {
]);
q("update user set expire_notification_sent = '%s' where uid = %d",
dbesc(DateTimeFormat::utcNow()),
DBA::escape(DateTimeFormat::utcNow()),
intval($rr['uid'])
);

View file

@ -72,7 +72,6 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
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",
intval($notification_data["uid"]),
dbesc("twitter::".$own_id)
DBA::escape("twitter::".$own_id)
);
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
FROM `contact` WHERE `uid` = %d AND `nick` = '%s'",
intval($uid),
dbesc($nickname));
if (DBM::is_result($r)) {
DBA::escape($nickname));
if (DBA::isResult($r)) {
$contact["contact"] = $r[0];
}
}
@ -468,7 +467,7 @@ function twitter_post_hook(App $a, &$b)
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
$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"]);
return;
} else {
@ -622,7 +621,7 @@ function twitter_post_hook(App $a, &$b)
logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
$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"];
}
@ -677,7 +676,7 @@ function twitter_cron(App $a, $b)
logger('twitter: cron_start');
$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) {
logger('twitter: fetching for user ' . $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);
$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) {
if ($abandon_days != 0) {
$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');
continue;
}
@ -751,7 +750,7 @@ function twitter_expire(App $a, $b)
logger('twitter_expire: expire_start');
$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) {
logger('twitter_expire: user ' . $rr['uid']);
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()];
$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"]);
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
$nicknameplain = "@" . $nicknameplain;
@ -923,9 +922,9 @@ function twitter_fetchtimeline(App $a, $uid)
function twitter_queue_hook(App $a, &$b)
{
$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;
}
@ -940,7 +939,7 @@ function twitter_queue_hook(App $a, &$b)
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
if (!DBM::is_result($r)) {
if (!DBA::isResult($r)) {
continue;
}
@ -1019,11 +1018,11 @@ function twitter_fetch_contact($uid, $data, $create_user)
}
$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;
}
if (!DBM::is_result($contact)) {
if (!DBA::isResult($contact)) {
// create contact record
$fields['uid'] = $uid;
$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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$self = $r[0];
} else {
return;
@ -1354,11 +1353,11 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis
$fields = ['uri', 'parent-uri', 'parent'];
$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]);
}
if (DBM::is_result($parent_item)) {
if (DBA::isResult($parent_item)) {
$postarray['thr-parent'] = $parent_item['uri'];
$postarray['parent-uri'] = $parent_item['parent-uri'];
$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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$contactid = $r[0]["id"];
$postarray['owner-name'] = $r[0]["name"];
@ -1575,7 +1574,7 @@ function twitter_fetchhometimeline(App $a, $uid)
intval($own_contact),
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$own_id = $r[0]["nick"];
} else {
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",
intval($uid));
if (DBM::is_result($r)) {
if (DBA::isResult($r)) {
$self = $r[0];
} else {
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",
intval($uid));
if (!DBM::is_result($u)) {
if (!DBA::isResult($u)) {
logger("twitter_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
return;
}
@ -1661,7 +1660,7 @@ function twitter_fetchhometimeline(App $a, $uid)
if ($postarray['uri'] == $postarray['parent-uri']) {
$contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
if (DBM::is_result($contact)) {
if (DBA::isResult($contact)) {
$notify = Item::isRemoteSelf($contact, $postarray);
}
}
@ -1752,8 +1751,8 @@ function twitter_fetch_own_contact(App $a, $uid)
} else {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid),
dbesc("twitter::" . $own_id));
if (DBM::is_result($r)) {
DBA::escape("twitter::" . $own_id));
if (DBA::isResult($r)) {
$contact_id = $r[0]["id"];
} else {
PConfig::delete($uid, 'twitter', 'own_id');

View file

@ -9,7 +9,7 @@
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Model\Item;
use Friendica\Database\DBM;
use Friendica\Database\DBA;
function viewsrc_install() {
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']) {
$item = Item::selectFirstForUser(local_user(), ['id'], ['uid' => local_user(), 'guid' => $b['item']['guid']]);
if (!DBM::is_result($item)) {
if (!DBA::isResult($item)) {
return;
}

View file

@ -1,6 +1,7 @@
<?php
use Friendica\Core\L10n;
use Friendica\Database\DBA;
function like_widget_name() {
return "Shows likes";
@ -37,7 +38,7 @@ function like_widget_content(&$a, $conf){
// count likes
$r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
intval($conf['uid']),
dbesc($args[0])
DBA::escape($args[0])
);
$likes = $r[0]['c'];
$iid = $r[0]['id'];
@ -45,7 +46,7 @@ function like_widget_content(&$a, $conf){
// count dislikes
$r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
intval($conf['uid']),
dbesc($args[0])
DBA::escape($args[0])
);
$dislikes = $r[0]['c'];

View file

@ -5,21 +5,23 @@
* Version: 1.0
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrix/>
*/
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
function widgets_install() {
Addon::registerHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
Addon::registerHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
logger("installed widgets");
}
function widgets_uninstall() {
Addon::unregisterHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
Addon::unregisterHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
}
function widgets_settings_post(){
if(! local_user())
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'",
dbesc($_GET['k'])
DBA::escape($_GET['k'])
);
if (!count($r)){
if($a->argv[2]=="cb"){header('HTTP/1.0 400 Bad Request'); killme();}