mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 13:35:12 +00:00
Merge branch 'psr12' into dev
This commit is contained in:
commit
c5f213e9d8
706 changed files with 64245 additions and 63182 deletions
|
@ -5,5 +5,5 @@ self.addEventListener('install', function(e) {
|
|||
|
||||
self.addEventListener('fetch', function(e) {
|
||||
// nothing here yet
|
||||
return;
|
||||
|
||||
});
|
||||
|
|
|
@ -12,7 +12,8 @@ namespace Zotlabs\Access;
|
|||
* and @ref ::Zotlabs::Lib::Permcat "Permcat"s individual content ACLs are evaluated.
|
||||
* These answer the question "Can Joe view *this* album/photo?".
|
||||
*/
|
||||
class AccessControl {
|
||||
class AccessControl
|
||||
{
|
||||
/**
|
||||
* @brief Allow contacts
|
||||
* @var string
|
||||
|
@ -36,7 +37,7 @@ class AccessControl {
|
|||
/**
|
||||
* @brief Indicates if we are using the default constructor values or
|
||||
* values that have been set explicitly.
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $explicit;
|
||||
|
||||
|
@ -53,14 +54,14 @@ class AccessControl {
|
|||
* * \e string \b channel_deny_cid => string of denied cids
|
||||
* * \e string \b channel_deny_gid => string of denied gids
|
||||
*/
|
||||
function __construct($channel) {
|
||||
public function __construct($channel)
|
||||
{
|
||||
if ($channel) {
|
||||
$this->allow_cid = $channel['channel_allow_cid'];
|
||||
$this->allow_gid = $channel['channel_allow_gid'];
|
||||
$this->deny_cid = $channel['channel_deny_cid'];
|
||||
$this->deny_gid = $channel['channel_deny_gid'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->allow_cid = '';
|
||||
$this->allow_gid = '';
|
||||
$this->deny_cid = '';
|
||||
|
@ -74,9 +75,10 @@ class AccessControl {
|
|||
* @brief Get if we are using the default constructor values
|
||||
* or values that have been set explicitly.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
function get_explicit() {
|
||||
public function get_explicit()
|
||||
{
|
||||
return $this->explicit;
|
||||
}
|
||||
|
||||
|
@ -92,9 +94,10 @@ class AccessControl {
|
|||
* * \e string \b allow_gid => string of allowed gids
|
||||
* * \e string \b deny_cid => string of denied cids
|
||||
* * \e string \b deny_gid => string of denied gids
|
||||
* @param boolean $explicit (optional) default true
|
||||
* @param bool $explicit (optional) default true
|
||||
*/
|
||||
function set($arr, $explicit = true) {
|
||||
public function set($arr, $explicit = true)
|
||||
{
|
||||
$this->allow_cid = $arr['allow_cid'];
|
||||
$this->allow_gid = $arr['allow_gid'];
|
||||
$this->deny_cid = $arr['deny_cid'];
|
||||
|
@ -113,7 +116,8 @@ class AccessControl {
|
|||
* * \e string \b deny_cid => string of denied cids
|
||||
* * \e string \b deny_gid => string of denied gids
|
||||
*/
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
return [
|
||||
'allow_cid' => $this->allow_cid,
|
||||
'allow_gid' => $this->allow_gid,
|
||||
|
@ -137,9 +141,10 @@ class AccessControl {
|
|||
* * \e array|string \b group_allow => array with gids or comma-seperated string
|
||||
* * \e array|string \b contact_deny => array with cids or comma-seperated string
|
||||
* * \e array|string \b group_deny => array with gids or comma-seperated string
|
||||
* @param boolean $explicit (optional) default true
|
||||
* @param bool $explicit (optional) default true
|
||||
*/
|
||||
function set_from_array($arr, $explicit = true) {
|
||||
public function set_from_array($arr, $explicit = true)
|
||||
{
|
||||
$this->allow_cid = perms2str((is_array($arr['contact_allow']))
|
||||
? $arr['contact_allow'] : explode(',', $arr['contact_allow']));
|
||||
$this->allow_gid = perms2str((is_array($arr['group_allow']))
|
||||
|
@ -155,10 +160,10 @@ class AccessControl {
|
|||
/**
|
||||
* @brief Returns true if any access lists component is set.
|
||||
*
|
||||
* @return boolean Return true if any of allow_* deny_* values is set.
|
||||
* @return bool Return true if any of allow_* deny_* values is set.
|
||||
*/
|
||||
function is_private() {
|
||||
public function is_private()
|
||||
{
|
||||
return (($this->allow_cid || $this->allow_gid || $this->deny_cid || $this->deny_gid) ? true : false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ use Zotlabs\Lib\PConfig;
|
|||
*
|
||||
* @see Permissions
|
||||
*/
|
||||
class PermissionLimits {
|
||||
class PermissionLimits
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Get standard permission limits.
|
||||
|
@ -38,16 +39,18 @@ class PermissionLimits {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function Std_Limits() {
|
||||
public static function Std_Limits()
|
||||
{
|
||||
$limits = [];
|
||||
$perms = Permissions::Perms();
|
||||
|
||||
foreach ($perms as $k => $v) {
|
||||
if(strstr($k, 'view'))
|
||||
if (strstr($k, 'view')) {
|
||||
$limits[$k] = PERMS_PUBLIC;
|
||||
else
|
||||
} else {
|
||||
$limits[$k] = PERMS_SPECIFIC;
|
||||
}
|
||||
}
|
||||
|
||||
return $limits;
|
||||
}
|
||||
|
@ -59,7 +62,8 @@ class PermissionLimits {
|
|||
* @param string $perm
|
||||
* @param int $perm_limit one of PERMS_* constants
|
||||
*/
|
||||
static public function Set($channel_id, $perm, $perm_limit) {
|
||||
public static function Set($channel_id, $perm, $perm_limit)
|
||||
{
|
||||
PConfig::Set($channel_id, 'perm_limits', $perm, $perm_limit);
|
||||
}
|
||||
|
||||
|
@ -77,7 +81,8 @@ class PermissionLimits {
|
|||
* * \b int if $perm is set, return one of PERMS_* constants for this permission, default 0
|
||||
* * \b array with all permission limits, if $perm is not set
|
||||
*/
|
||||
static public function Get($channel_id, $perm = '') {
|
||||
public static function Get($channel_id, $perm = '')
|
||||
{
|
||||
|
||||
if (! intval($channel_id)) {
|
||||
return false;
|
||||
|
|
|
@ -7,7 +7,8 @@ namespace Zotlabs\Access;
|
|||
*
|
||||
* @see Permissions
|
||||
*/
|
||||
class PermissionRoles {
|
||||
class PermissionRoles
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief PermissionRoles version.
|
||||
|
@ -16,11 +17,13 @@ class PermissionRoles {
|
|||
*
|
||||
* @return number
|
||||
*/
|
||||
static public function version() {
|
||||
public static function version()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
static function role_perms($role) {
|
||||
public static function role_perms($role)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
|
||||
|
@ -148,8 +151,9 @@ class PermissionRoles {
|
|||
|
||||
$x = get_config('system', 'role_perms');
|
||||
// let system settings over-ride any or all
|
||||
if($x && is_array($x) && array_key_exists($role,$x))
|
||||
if ($x && is_array($x) && array_key_exists($role, $x)) {
|
||||
$ret = array_merge($ret, $x[$role]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hooks get_role_perms
|
||||
|
@ -171,7 +175,8 @@ class PermissionRoles {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function roles() {
|
||||
public static function roles()
|
||||
{
|
||||
$roles = [
|
||||
t('Social Networking') => [
|
||||
'social' => t('Social - Normal'),
|
||||
|
@ -195,5 +200,4 @@ class PermissionRoles {
|
|||
|
||||
return $roles;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ use Zotlabs\Lib as Zlib;
|
|||
* something different for a specific permission within the given role.
|
||||
*
|
||||
*/
|
||||
class Permissions {
|
||||
class Permissions
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Permissions version.
|
||||
|
@ -40,7 +41,8 @@ class Permissions {
|
|||
*
|
||||
* @return number
|
||||
*/
|
||||
static public function version() {
|
||||
public static function version()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -50,7 +52,8 @@ class Permissions {
|
|||
* @param string $filter (optional) only passed to hook permissions_list
|
||||
* @return array Associative array with permissions and short description.
|
||||
*/
|
||||
static public function Perms($filter = '') {
|
||||
public static function Perms($filter = '')
|
||||
{
|
||||
|
||||
$perms = [
|
||||
'view_stream' => t('Grant viewing access to and delivery of your channel stream and posts'),
|
||||
|
@ -88,7 +91,8 @@ class Permissions {
|
|||
*
|
||||
* @return array Associative array with permissions and short description.
|
||||
*/
|
||||
static public function BlockedAnonPerms() {
|
||||
public static function BlockedAnonPerms()
|
||||
{
|
||||
|
||||
$res = [];
|
||||
$perms = PermissionLimits::Std_limits();
|
||||
|
@ -118,7 +122,8 @@ class Permissions {
|
|||
* @param array $arr
|
||||
* @return array
|
||||
*/
|
||||
static public function FilledPerms($arr) {
|
||||
public static function FilledPerms($arr)
|
||||
{
|
||||
if (is_null($arr) || (! is_array($arr))) {
|
||||
btlogger('FilledPerms: ' . print_r($arr, true));
|
||||
$arr = [];
|
||||
|
@ -127,11 +132,12 @@ class Permissions {
|
|||
$everything = self::Perms();
|
||||
$ret = [];
|
||||
foreach ($everything as $k => $v) {
|
||||
if(in_array($k, $arr))
|
||||
if (in_array($k, $arr)) {
|
||||
$ret[$k] = 1;
|
||||
else
|
||||
} else {
|
||||
$ret[$k] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -147,7 +153,8 @@ class Permissions {
|
|||
* * \e string \b name the perm name (e.g. view_stream)
|
||||
* * \e int \b value the value of the perm (e.g. 1)
|
||||
*/
|
||||
static public function OPerms($arr) {
|
||||
public static function OPerms($arr)
|
||||
{
|
||||
$ret = [];
|
||||
if ($arr) {
|
||||
foreach ($arr as $k => $v) {
|
||||
|
@ -161,14 +168,17 @@ class Permissions {
|
|||
* @brief
|
||||
*
|
||||
* @param int $channel_id
|
||||
* @return boolean|array
|
||||
* @return bool|array
|
||||
*/
|
||||
static public function FilledAutoperms($channel_id) {
|
||||
if(! intval(get_pconfig($channel_id,'system','autoperms')))
|
||||
public static function FilledAutoperms($channel_id)
|
||||
{
|
||||
if (! intval(get_pconfig($channel_id, 'system', 'autoperms'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
$r = q("select * from pconfig where uid = %d and cat = 'autoperms'",
|
||||
$r = q(
|
||||
"select * from pconfig where uid = %d and cat = 'autoperms'",
|
||||
intval($channel_id)
|
||||
);
|
||||
if ($r) {
|
||||
|
@ -184,16 +194,19 @@ class Permissions {
|
|||
*
|
||||
* @param array $p1 The perms that have to exist in $p2
|
||||
* @param array $p2 The perms to compare against
|
||||
* @return boolean true if all perms from $p1 exist also in $p2
|
||||
* @return bool true if all perms from $p1 exist also in $p2
|
||||
*/
|
||||
static public function PermsCompare($p1, $p2) {
|
||||
public static function PermsCompare($p1, $p2)
|
||||
{
|
||||
foreach ($p1 as $k => $v) {
|
||||
if(! array_key_exists($k, $p2))
|
||||
if (! array_key_exists($k, $p2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($p1[$k] != $p2[$k])
|
||||
if ($p1[$k] != $p2[$k]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -206,7 +219,8 @@ class Permissions {
|
|||
* * \e array \b perms Permission array
|
||||
* * \e int \b automatic 0 or 1
|
||||
*/
|
||||
static public function connect_perms($channel_id) {
|
||||
public static function connect_perms($channel_id)
|
||||
{
|
||||
|
||||
$my_perms = [];
|
||||
$permcat = null;
|
||||
|
@ -267,7 +281,8 @@ class Permissions {
|
|||
}
|
||||
|
||||
|
||||
static public function serialise($p) {
|
||||
public static function serialise($p)
|
||||
{
|
||||
$n = [];
|
||||
if ($p) {
|
||||
foreach ($p as $k => $v) {
|
||||
|
@ -278,5 +293,4 @@ class Permissions {
|
|||
}
|
||||
return implode(',', $n);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Addon {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
call_hooks('daemon_addon',$argv);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ require_once('include/photos.php');
|
|||
|
||||
class CacheThumb {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if (! $argc == 2) {
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Cache_embeds {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if (! $argc == 2) {
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zotlabs\Lib\Img_cache;
|
|||
|
||||
class Cache_image {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
cli_startup();
|
||||
logger('caching: ' . $argv[1] . ' to ' . $argv[2]);
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Channel_purge {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
cli_startup();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ require_once('include/hubloc.php');
|
|||
|
||||
class Checksites {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
logger('checksites: start');
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once('include/import.php');
|
|||
|
||||
class Content_importer {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
cli_startup();
|
||||
|
||||
$page = $argv[1];
|
||||
|
|
|
@ -8,7 +8,7 @@ use Zotlabs\Lib\ASCollection;
|
|||
|
||||
class Convo {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
logger('convo invoked: ' . print_r($argv,true));
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zotlabs\Lib\Libsync;
|
|||
|
||||
class Cron {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
$maxsysload = intval(get_config('system','maxloadavg'));
|
||||
if($maxsysload < 1)
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zotlabs\Lib\Libzot;
|
|||
|
||||
class Cron_daily {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
logger('cron_daily: start');
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Cron_weekly {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
/**
|
||||
* Cron Weekly
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Cronhooks {
|
||||
|
||||
static public function run($argc,$argv){
|
||||
public static function run($argc, $argv){
|
||||
|
||||
logger('cronhooks: start');
|
||||
|
||||
|
|
|
@ -8,14 +8,16 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
// Handles expiration of stale cookies currently by deleting them and rewriting the file.
|
||||
|
||||
use App;
|
||||
|
||||
class CurlAuth {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if($argc != 2)
|
||||
return;
|
||||
|
||||
\App::$session->start();
|
||||
App::$session->start();
|
||||
|
||||
$_SESSION['authenticated'] = 1;
|
||||
$_SESSION['uid'] = $argv[1];
|
||||
|
@ -46,7 +48,7 @@ class CurlAuth {
|
|||
}
|
||||
}
|
||||
$t = time() + (24 * 3600);
|
||||
file_put_contents($f, $output . 'HttpOnly_' . \App::get_hostname() . "\tFALSE\t/\tTRUE\t$t\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
|
||||
file_put_contents($f, $output . 'HttpOnly_' . App::get_hostname() . "\tFALSE\t/\tTRUE\t$t\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
|
||||
|
||||
file_put_contents($c,$x);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use Zotlabs\Lib\Queue;
|
|||
|
||||
class Deliver {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if($argc < 2)
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Deliver_hooks {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if($argc < 2)
|
||||
return;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Delxitems {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
cli_startup();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Zotlabs\Daemon;
|
||||
|
||||
|
||||
use Zotlabs\Lib\Libzot;;
|
||||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\Libzotdir;
|
||||
use Zotlabs\Lib\Queue;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use Zotlabs\Lib\Queue;
|
|||
|
||||
class Directory {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if ($argc < 2) {
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Expire {
|
||||
|
||||
static public function run($argc,$argv){
|
||||
public static function run($argc, $argv){
|
||||
|
||||
cli_startup();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once('include/import.php');
|
|||
|
||||
class File_importer {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
cli_startup();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use Zotlabs\Lib\Zotfinger;
|
|||
|
||||
class Gprobe {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
|
||||
if ($argc != 2) {
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Importdoc {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
require_once('include/help.php');
|
||||
|
||||
|
@ -13,7 +13,7 @@ class Importdoc {
|
|||
|
||||
}
|
||||
|
||||
static public function update_docs_dir($s) {
|
||||
public static function update_docs_dir($s) {
|
||||
$f = basename($s);
|
||||
$d = dirname($s);
|
||||
if($s === 'doc/html')
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zotlabs\Lib\Libsync;
|
|||
|
||||
class Importfile {
|
||||
|
||||
static public function run($argc,$argv){
|
||||
public static function run($argc, $argv){
|
||||
|
||||
logger('Importfile: ' . print_r($argv,true));
|
||||
|
||||
|
|
|
@ -78,16 +78,16 @@ require_once('include/bbcode.php');
|
|||
|
||||
class Notifier {
|
||||
|
||||
static public $deliveries = [];
|
||||
static public $recipients = [];
|
||||
static public $env_recips = [];
|
||||
static public $packet_type = 'activity';
|
||||
static public $encoding = 'activitystreams';
|
||||
static public $encoded_item = null;
|
||||
static public $channel = null;
|
||||
static public $private = false;
|
||||
public static $deliveries = [];
|
||||
public static $recipients = [];
|
||||
public static $env_recips = [];
|
||||
public static $packet_type = 'activity';
|
||||
public static $encoding = 'activitystreams';
|
||||
public static $encoded_item = null;
|
||||
public static $channel = null;
|
||||
public static $private = false;
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if ($argc < 3) {
|
||||
return;
|
||||
|
|
|
@ -7,7 +7,7 @@ use Zotlabs\Lib\Libzotdir;
|
|||
|
||||
class Onedirsync {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
logger('onedirsync: start ' . intval($argv[1]));
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ require_once('include/socgraph.php');
|
|||
|
||||
class Onepoll {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
logger('onepoll: start');
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Poller {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
$maxsysload = intval(get_config('system','maxloadavg'));
|
||||
if($maxsysload < 1)
|
||||
|
|
|
@ -7,7 +7,7 @@ use Zotlabs\Lib as Zlib;
|
|||
|
||||
class Queue {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if($argc > 1)
|
||||
$queue_id = $argv[1];
|
||||
|
|
|
@ -27,7 +27,7 @@ class Run {
|
|||
'Cron', 'Cron_daily', 'Cron_weekly', 'Delxitems', 'Expire', 'File_importer', 'Importfile'
|
||||
];
|
||||
|
||||
static public function Summon($arr) {
|
||||
public static function Summon($arr) {
|
||||
if (file_exists('maintenance_lock') || file_exists('cache/maintenance_lock')) {
|
||||
return;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Run {
|
|||
proc_run('php','Zotlabs/Daemon/Run.php',$arr);
|
||||
}
|
||||
|
||||
static public function Release($argc,$argv) {
|
||||
public static function Release($argc, $argv) {
|
||||
cli_startup();
|
||||
|
||||
$hookinfo = [
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Thumbnail {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if (! ($argc == 2)) {
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
|
|||
|
||||
class Xchan_photo {
|
||||
|
||||
static public function run($argc,$argv) {
|
||||
public static function run($argc, $argv) {
|
||||
|
||||
if ($argc != 3) {
|
||||
return;
|
||||
|
|
|
@ -10,7 +10,7 @@ use App;
|
|||
*/
|
||||
class Hook {
|
||||
|
||||
static public function register($hook,$file,$function,$version = 1,$priority = 0) {
|
||||
public static function register($hook, $file, $function, $version = 1, $priority = 0) {
|
||||
if (is_array($function)) {
|
||||
$function = serialize($function);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Hook {
|
|||
return $r;
|
||||
}
|
||||
|
||||
static public function register_array($file,$arr) {
|
||||
public static function register_array($file, $arr) {
|
||||
if ($arr) {
|
||||
foreach ($arr as $k => $v) {
|
||||
self::register($k,$file,$v);
|
||||
|
@ -55,7 +55,7 @@ class Hook {
|
|||
}
|
||||
|
||||
|
||||
static public function unregister($hook,$file,$function,$version = 1,$priority = 0) {
|
||||
public static function unregister($hook, $file, $function, $version = 1, $priority = 0) {
|
||||
if (is_array($function)) {
|
||||
$function = serialize($function);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Hook {
|
|||
* @param string $file
|
||||
*/
|
||||
|
||||
static public function unregister_by_file($file) {
|
||||
public static function unregister_by_file($file) {
|
||||
$r = q("DELETE FROM hook WHERE file = '%s' ",
|
||||
dbesc($file)
|
||||
);
|
||||
|
@ -107,7 +107,7 @@ class Hook {
|
|||
* @param int $priority
|
||||
* currently not implemented in this function, would require the hook array to be resorted
|
||||
*/
|
||||
static public function insert($hook, $fn, $version = 0, $priority = 0) {
|
||||
public static function insert($hook, $fn, $version = 0, $priority = 0) {
|
||||
if (is_array($fn)) {
|
||||
$fn = serialize($fn);
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@
|
|||
namespace Zotlabs\Extend;
|
||||
|
||||
|
||||
class Route {
|
||||
class Route
|
||||
{
|
||||
|
||||
static function register($file,$modname) {
|
||||
public static function register($file, $modname)
|
||||
{
|
||||
$rt = self::get();
|
||||
$rt[] = [$file, $modname];
|
||||
self::set($rt);
|
||||
}
|
||||
|
||||
static function unregister($file,$modname) {
|
||||
public static function unregister($file, $modname)
|
||||
{
|
||||
$rt = self::get();
|
||||
if ($rt) {
|
||||
$n = [];
|
||||
|
@ -24,7 +27,8 @@ class Route {
|
|||
}
|
||||
}
|
||||
|
||||
static function unregister_by_file($file) {
|
||||
public static function unregister_by_file($file)
|
||||
{
|
||||
$rt = self::get();
|
||||
if ($rt) {
|
||||
$n = [];
|
||||
|
@ -37,11 +41,13 @@ class Route {
|
|||
}
|
||||
}
|
||||
|
||||
static function get() {
|
||||
public static function get()
|
||||
{
|
||||
return get_config('system', 'routes', []);
|
||||
}
|
||||
|
||||
static function set($r) {
|
||||
public static function set($r)
|
||||
{
|
||||
return set_config('system', 'routes', $r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@
|
|||
namespace Zotlabs\Extend;
|
||||
|
||||
|
||||
class Widget {
|
||||
class Widget
|
||||
{
|
||||
|
||||
static function register($file,$widget) {
|
||||
public static function register($file, $widget)
|
||||
{
|
||||
$rt = self::get();
|
||||
$rt[] = [$file, $widget];
|
||||
self::set($rt);
|
||||
}
|
||||
|
||||
static function unregister($file,$widget) {
|
||||
public static function unregister($file, $widget)
|
||||
{
|
||||
$rt = self::get();
|
||||
if ($rt) {
|
||||
$n = [];
|
||||
|
@ -24,7 +27,8 @@ class Widget {
|
|||
}
|
||||
}
|
||||
|
||||
static function unregister_by_file($file) {
|
||||
public static function unregister_by_file($file)
|
||||
{
|
||||
$rt = self::get();
|
||||
if ($rt) {
|
||||
$n = [];
|
||||
|
@ -37,11 +41,13 @@ class Widget {
|
|||
}
|
||||
}
|
||||
|
||||
static function get() {
|
||||
public static function get()
|
||||
{
|
||||
return get_config('system', 'widgets', []);
|
||||
}
|
||||
|
||||
static function set($r) {
|
||||
public static function set($r)
|
||||
{
|
||||
return set_config('system', 'widgets', $r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
namespace Zotlabs\Identity;
|
||||
|
||||
|
||||
class OAuth2Storage extends \OAuth2\Storage\Pdo {
|
||||
use OAuth2\Storage\Pdo;
|
||||
|
||||
class OAuth2Storage extends Pdo {
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
|
|
|
@ -12,7 +12,8 @@ use Zotlabs\Access\Permissions;
|
|||
use Zotlabs\Daemon\Run;
|
||||
|
||||
|
||||
class Friendica {
|
||||
class Friendica
|
||||
{
|
||||
|
||||
private $data;
|
||||
private $settings;
|
||||
|
@ -24,13 +25,15 @@ class Friendica {
|
|||
private $contacts = null;
|
||||
|
||||
|
||||
function __construct($data, $settings) {
|
||||
public function __construct($data, $settings)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->settings = $settings;
|
||||
$this->extract();
|
||||
}
|
||||
|
||||
function extract() {
|
||||
public function extract()
|
||||
{
|
||||
|
||||
// channel stuff
|
||||
|
||||
|
@ -150,8 +153,7 @@ class Friendica {
|
|||
}
|
||||
if (array_key_exists('content-type', $hdrs)) {
|
||||
$phototype = $hdrs['content-type'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$phototype = 'image/jpeg';
|
||||
}
|
||||
|
||||
|
@ -201,8 +203,7 @@ class Friendica {
|
|||
|
||||
if ($role_permissions) {
|
||||
$myperms = ((array_key_exists('perms_connect', $role_permissions)) ? $role_permissions['perms_connect'] : []);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x = PermissionRoles::role_perms('social');
|
||||
$myperms = $x['perms_connect'];
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class AConfig {
|
||||
|
||||
static public function Load($account_id) {
|
||||
public static function Load($account_id) {
|
||||
return XConfig::Load('a_' . $account_id);
|
||||
}
|
||||
|
||||
static public function Get($account_id,$family,$key,$default = false) {
|
||||
public static function Get($account_id, $family, $key, $default = false) {
|
||||
return XConfig::Get('a_' . $account_id,$family,$key, $default);
|
||||
}
|
||||
|
||||
static public function Set($account_id,$family,$key,$value) {
|
||||
public static function Set($account_id, $family, $key, $value) {
|
||||
return XConfig::Set('a_' . $account_id,$family,$key,$value);
|
||||
}
|
||||
|
||||
static public function Delete($account_id,$family,$key) {
|
||||
public static function Delete($account_id, $family, $key) {
|
||||
return XConfig::Delete('a_' . $account_id,$family,$key);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,8 @@ use Zotlabs\Lib\Activity;
|
|||
* An optional limit to the number of records returned may also be specified.
|
||||
* Use $class->get() to return an array of collection members.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
class ASCollection {
|
||||
class ASCollection
|
||||
{
|
||||
|
||||
private $channel = null;
|
||||
private $nextpage = null;
|
||||
|
@ -26,7 +23,8 @@ class ASCollection {
|
|||
private $history = [];
|
||||
|
||||
|
||||
function __construct($obj, $channel = null, $direction = 0, $limit = 0) {
|
||||
public function __construct($obj, $channel = null, $direction = 0, $limit = 0)
|
||||
{
|
||||
|
||||
$this->channel = $channel;
|
||||
$this->direction = $direction;
|
||||
|
@ -53,8 +51,7 @@ class ASCollection {
|
|||
if (array_key_exists('last', $data) && $data['last']) {
|
||||
$this->nextpage = $data['last'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (array_key_exists('first', $data) && $data['first']) {
|
||||
$this->nextpage = $data['first'];
|
||||
}
|
||||
|
@ -62,8 +59,7 @@ class ASCollection {
|
|||
|
||||
if (isset($data['items']) && is_array($data['items'])) {
|
||||
$this->data = (($this->direction) ? array_reverse($data['items']) : $data['items']);
|
||||
}
|
||||
elseif (isset($data['orderedItems']) && is_array($data['orderedItems'])) {
|
||||
} elseif (isset($data['orderedItems']) && is_array($data['orderedItems'])) {
|
||||
$this->data = (($this->direction) ? array_reverse($data['orderedItems']) : $data['orderedItems']);
|
||||
}
|
||||
|
||||
|
@ -79,11 +75,13 @@ class ASCollection {
|
|||
} while ($x);
|
||||
}
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
function next() {
|
||||
public function next()
|
||||
{
|
||||
|
||||
if (!$this->nextpage) {
|
||||
return false;
|
||||
|
@ -114,8 +112,7 @@ class ASCollection {
|
|||
|
||||
if (isset($data['items']) && is_array($data['items'])) {
|
||||
$this->data = array_merge($this->data, (($this->direction) ? array_reverse($data['items']) : $data['items']));
|
||||
}
|
||||
elseif (isset($data['orderedItems']) && is_array($data['orderedItems'])) {
|
||||
} elseif (isset($data['orderedItems']) && is_array($data['orderedItems'])) {
|
||||
$this->data = array_merge($this->data, (($this->direction) ? array_reverse($data['orderedItems']) : $data['orderedItems']));
|
||||
}
|
||||
|
||||
|
@ -130,26 +127,22 @@ class ASCollection {
|
|||
return true;
|
||||
}
|
||||
|
||||
function setnext($data) {
|
||||
public function setnext($data)
|
||||
{
|
||||
if ($this->direction) {
|
||||
if (array_key_exists('prev', $data) && $data['prev']) {
|
||||
$this->nextpage = $data['prev'];
|
||||
}
|
||||
elseif (array_key_exists('first',$data) && $data['first']) {
|
||||
} elseif (array_key_exists('first', $data) && $data['first']) {
|
||||
$this->nextpage = $data['first'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->nextpage = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (array_key_exists('next', $data) && $data['next']) {
|
||||
$this->nextpage = $data['next'];
|
||||
}
|
||||
elseif (array_key_exists('last',$data) && $data['last']) {
|
||||
} elseif (array_key_exists('last', $data) && $data['last']) {
|
||||
$this->nextpage = $data['last'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->nextpage = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class AbConfig {
|
||||
|
||||
static public function Load($chan,$xhash,$family = '') {
|
||||
public static function Load($chan, $xhash, $family = '') {
|
||||
if($family)
|
||||
$where = sprintf(" and cat = '%s' ",dbesc($family));
|
||||
$r = q("select * from abconfig where chan = %d and xchan = '%s' $where",
|
||||
|
@ -16,7 +16,7 @@ class AbConfig {
|
|||
}
|
||||
|
||||
|
||||
static public function Get($chan,$xhash,$family,$key, $default = false) {
|
||||
public static function Get($chan, $xhash, $family, $key, $default = false) {
|
||||
$r = q("select * from abconfig where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' limit 1",
|
||||
intval($chan),
|
||||
dbesc($xhash),
|
||||
|
@ -30,7 +30,7 @@ class AbConfig {
|
|||
}
|
||||
|
||||
|
||||
static public function Set($chan,$xhash,$family,$key,$value) {
|
||||
public static function Set($chan, $xhash, $family, $key, $value) {
|
||||
|
||||
$dbvalue = ((is_array($value)) ? serialise($value) : $value);
|
||||
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
|
||||
|
@ -60,7 +60,7 @@ class AbConfig {
|
|||
}
|
||||
|
||||
|
||||
static public function Delete($chan,$xhash,$family,$key) {
|
||||
public static function Delete($chan, $xhash, $family, $key) {
|
||||
|
||||
$r = q("delete from abconfig where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' ",
|
||||
intval($chan),
|
||||
|
|
|
@ -5,9 +5,11 @@ namespace Zotlabs\Lib;
|
|||
use Zotlabs\Lib\Libsync;
|
||||
|
||||
|
||||
class AccessList {
|
||||
class AccessList
|
||||
{
|
||||
|
||||
static function add($uid,$name,$public = 0) {
|
||||
public static function add($uid, $name, $public = 0)
|
||||
{
|
||||
|
||||
$ret = false;
|
||||
if ($uid && $name) {
|
||||
|
@ -49,7 +51,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function remove($uid,$name) {
|
||||
public static function remove($uid, $name)
|
||||
{
|
||||
$ret = false;
|
||||
if ($uid && $name) {
|
||||
$r = q("SELECT id, hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
|
||||
|
@ -59,8 +62,7 @@ class AccessList {
|
|||
if ($r) {
|
||||
$group_id = $r[0]['id'];
|
||||
$group_hash = $r[0]['hash'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,8 @@ class AccessList {
|
|||
// returns the integer id of an access group owned by $uid and named $name
|
||||
// or false.
|
||||
|
||||
static function byname($uid,$name) {
|
||||
public static function byname($uid, $name)
|
||||
{
|
||||
if (!($uid && $name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -134,7 +137,8 @@ class AccessList {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function by_id($uid,$id) {
|
||||
public static function by_id($uid, $id)
|
||||
{
|
||||
if (!($uid && $id)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -150,8 +154,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static function rec_byhash($uid,$hash) {
|
||||
public static function rec_byhash($uid, $hash)
|
||||
{
|
||||
if (!($uid && $hash)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -166,7 +170,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function member_remove($uid,$name,$member) {
|
||||
public static function member_remove($uid, $name, $member)
|
||||
{
|
||||
$gid = self::byname($uid, $name);
|
||||
if (!$gid) {
|
||||
return false;
|
||||
|
@ -186,7 +191,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function member_add($uid,$name,$member,$gid = 0) {
|
||||
public static function member_add($uid, $name, $member, $gid = 0)
|
||||
{
|
||||
if (!$gid) {
|
||||
$gid = self::byname($uid, $name);
|
||||
}
|
||||
|
@ -203,8 +209,7 @@ class AccessList {
|
|||
return true; // You might question this, but
|
||||
// we indicate success because the group member was in fact created
|
||||
// -- It was just created at another time
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = q("INSERT INTO pgrp_member (uid, gid, xchan)
|
||||
VALUES( %d, %d, '%s' ) ",
|
||||
intval($uid),
|
||||
|
@ -217,7 +222,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function members($uid, $gid, $total = false, $start = 0, $records = 0) {
|
||||
public static function members($uid, $gid, $total = false, $start = 0, $records = 0)
|
||||
{
|
||||
$ret = [];
|
||||
if ($records) {
|
||||
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($records), intval($start));
|
||||
|
@ -287,7 +293,8 @@ class AccessList {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
static function members_xchan($uid,$gid) {
|
||||
public static function members_xchan($uid, $gid)
|
||||
{
|
||||
$ret = [];
|
||||
if (intval($gid)) {
|
||||
$r = q("SELECT xchan FROM pgrp_member WHERE gid = %d AND uid = %d",
|
||||
|
@ -303,7 +310,8 @@ class AccessList {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
static function select($uid,$group = '') {
|
||||
public static function select($uid, $group = '')
|
||||
{
|
||||
|
||||
$grps = [];
|
||||
|
||||
|
@ -325,7 +333,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function widget($every="connections",$each="lists",$edit = false, $group_id = 0, $cid = '',$mode = 1) {
|
||||
public static function widget($every = "connections", $each = "lists", $edit = false, $group_id = 0, $cid = '', $mode = 1)
|
||||
{
|
||||
|
||||
$o = '';
|
||||
|
||||
|
@ -345,8 +354,7 @@ class AccessList {
|
|||
|
||||
if ($edit) {
|
||||
$groupedit = ['href' => "lists/" . $rr['id'], 'title' => t('edit')];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$groupedit = null;
|
||||
}
|
||||
|
||||
|
@ -375,7 +383,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function expand($g) {
|
||||
public static function expand($g)
|
||||
{
|
||||
if (!(is_array($g) && count($g))) {
|
||||
return [];
|
||||
}
|
||||
|
@ -414,8 +423,7 @@ class AccessList {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x[] = $gv;
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +445,8 @@ class AccessList {
|
|||
}
|
||||
|
||||
|
||||
static function member_of($c) {
|
||||
public static function member_of($c)
|
||||
{
|
||||
$r = q("SELECT pgrp.gname, pgrp.id FROM pgrp LEFT JOIN pgrp_member ON pgrp_member.gid = pgrp.id
|
||||
WHERE pgrp_member.xchan = '%s' AND pgrp.deleted = 0 ORDER BY pgrp.gname ASC ",
|
||||
dbesc($c)
|
||||
|
@ -446,7 +455,8 @@ class AccessList {
|
|||
return $r;
|
||||
}
|
||||
|
||||
static function containing($uid,$c) {
|
||||
public static function containing($uid, $c)
|
||||
{
|
||||
|
||||
$r = q("SELECT gid FROM pgrp_member WHERE uid = %d AND pgrp_member.xchan = '%s' ",
|
||||
intval($uid),
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,9 +9,11 @@ use Zotlabs\Lib\Libsync;
|
|||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\IConfig;
|
||||
|
||||
class ActivityPub {
|
||||
class ActivityPub
|
||||
{
|
||||
|
||||
static public function notifier_process(&$arr) {
|
||||
public static function notifier_process(&$arr)
|
||||
{
|
||||
|
||||
if ($arr['hub']['hubloc_network'] !== 'activitypub') {
|
||||
return;
|
||||
|
@ -70,8 +72,7 @@ class ActivityPub {
|
|||
|
||||
$jmsg = json_encode($msg, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$target_item = $arr['target_item'];
|
||||
|
||||
if (!$target_item['mid']) {
|
||||
|
@ -83,8 +84,7 @@ class ActivityPub {
|
|||
|
||||
if ($signed_msg) {
|
||||
$jmsg = $signed_msg;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// Rewrite outbound mentions so they match the ActivityPub convention, which
|
||||
// is to pretend that the preferred display name doesn't exist and instead use
|
||||
|
@ -164,8 +164,7 @@ class ActivityPub {
|
|||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// public message
|
||||
|
||||
|
@ -179,8 +178,7 @@ class ActivityPub {
|
|||
if ($qi) {
|
||||
$arr['queued'][] = $qi;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s' and xchan_network = 'activitypub' ",
|
||||
dbesc($arr['hub']['hubloc_url'])
|
||||
|
@ -208,7 +206,8 @@ class ActivityPub {
|
|||
}
|
||||
|
||||
|
||||
static function queue_message($msg,$sender,$recip,$message_id = '') {
|
||||
public static function queue_message($msg, $sender, $recip, $message_id = '')
|
||||
{
|
||||
|
||||
$dest_url = $recip['hubloc_callback'];
|
||||
|
||||
|
@ -250,7 +249,8 @@ class ActivityPub {
|
|||
}
|
||||
|
||||
|
||||
static function permissions_update(&$x) {
|
||||
public static function permissions_update(&$x)
|
||||
{
|
||||
|
||||
if ($x['recipient']['xchan_network'] !== 'activitypub') {
|
||||
return;
|
||||
|
@ -260,7 +260,8 @@ class ActivityPub {
|
|||
}
|
||||
|
||||
|
||||
static function permissions_create(&$x) {
|
||||
public static function permissions_create(&$x)
|
||||
{
|
||||
|
||||
// send a follow activity to the followee's inbox
|
||||
|
||||
|
@ -325,7 +326,8 @@ class ActivityPub {
|
|||
}
|
||||
|
||||
|
||||
static function permissions_accept(&$x) {
|
||||
public static function permissions_accept(&$x)
|
||||
{
|
||||
|
||||
// send an accept activity to the followee's inbox
|
||||
|
||||
|
@ -383,7 +385,8 @@ class ActivityPub {
|
|||
|
||||
}
|
||||
|
||||
static function contact_remove($channel_id,$abook) {
|
||||
public static function contact_remove($channel_id, $abook)
|
||||
{
|
||||
|
||||
$recip = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d",
|
||||
intval($abook['abook_id'])
|
||||
|
@ -429,8 +432,7 @@ class ActivityPub {
|
|||
]);
|
||||
del_abconfig($recip[0]['abook_channel'], $recip[0]['xchan_hash'], 'activitypub', 'follow_id');
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// send an unfollow
|
||||
|
||||
|
@ -469,7 +471,8 @@ class ActivityPub {
|
|||
}
|
||||
}
|
||||
|
||||
static function discover($apurl, $force = false) {
|
||||
public static function discover($apurl, $force = false)
|
||||
{
|
||||
|
||||
$person_obj = null;
|
||||
$ap = Activity::fetch($apurl);
|
||||
|
@ -478,8 +481,7 @@ class ActivityPub {
|
|||
if ($AS->is_valid()) {
|
||||
if (ActivityStreams::is_an_actor($AS->type)) {
|
||||
$person_obj = $AS->data;
|
||||
}
|
||||
elseif ($AS->obj && ActivityStreams::is_an_actor($AS->obj['type'])) {
|
||||
} elseif ($AS->obj && ActivityStreams::is_an_actor($AS->obj['type'])) {
|
||||
$person_obj = $AS->obj;
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +495,8 @@ class ActivityPub {
|
|||
return false;
|
||||
}
|
||||
|
||||
static public function move($src,$dst) {
|
||||
public static function move($src, $dst)
|
||||
{
|
||||
|
||||
if (!($src && $dst)) {
|
||||
return;
|
||||
|
|
|
@ -10,8 +10,8 @@ use Zotlabs\Web\HTTPSig;
|
|||
*
|
||||
* Parses an ActivityStream JSON string.
|
||||
*/
|
||||
|
||||
class ActivityStreams {
|
||||
class ActivityStreams
|
||||
{
|
||||
|
||||
public $raw = null;
|
||||
public $data = null;
|
||||
|
@ -43,7 +43,8 @@ class ActivityStreams {
|
|||
*
|
||||
* @param string $string
|
||||
*/
|
||||
function __construct($string,$hub = null,$client = null) {
|
||||
public function __construct($string, $hub = null, $client = null)
|
||||
{
|
||||
|
||||
$this->raw = $string;
|
||||
$this->hub = $hub;
|
||||
|
@ -51,8 +52,7 @@ class ActivityStreams {
|
|||
if (is_array($string)) {
|
||||
$this->data = $string;
|
||||
$this->raw = json_encode($string, JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->data = json_decode($string, true);
|
||||
}
|
||||
|
||||
|
@ -158,14 +158,16 @@ class ActivityStreams {
|
|||
/**
|
||||
* @brief Return if instantiated ActivityStream is valid.
|
||||
*
|
||||
* @return boolean Return true if the JSON string could be decoded.
|
||||
* @return bool Return true if the JSON string could be decoded.
|
||||
*/
|
||||
|
||||
function is_valid() {
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
function set_recips($arr) {
|
||||
public function set_recips($arr)
|
||||
{
|
||||
$this->saved_recips = $arr;
|
||||
}
|
||||
|
||||
|
@ -176,7 +178,8 @@ class ActivityStreams {
|
|||
* @param string $namespace (optional) default empty
|
||||
* @return array
|
||||
*/
|
||||
function collect_recips($base = '', $namespace = '') {
|
||||
public function collect_recips($base = '', $namespace = '')
|
||||
{
|
||||
$x = [];
|
||||
|
||||
$fields = ['to', 'cc', 'bto', 'bcc', 'audience'];
|
||||
|
@ -200,7 +203,8 @@ class ActivityStreams {
|
|||
return $x;
|
||||
}
|
||||
|
||||
function expand($arr,$base = '',$namespace = '') {
|
||||
public function expand($arr, $base = '', $namespace = '')
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
// right now use a hardwired recursion depth of 5
|
||||
|
@ -210,8 +214,7 @@ class ActivityStreams {
|
|||
foreach ($arr as $a) {
|
||||
if (is_array($a)) {
|
||||
$ret[] = $a;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x = $this->get_compound_property($a, $base, $namespace);
|
||||
if ($x) {
|
||||
$ret = array_merge($ret, $x);
|
||||
|
@ -234,7 +237,8 @@ class ActivityStreams {
|
|||
* @return string|NULL
|
||||
*/
|
||||
|
||||
function get_namespace($base, $namespace) {
|
||||
public function get_namespace($base, $namespace)
|
||||
{
|
||||
|
||||
if (!$namespace) {
|
||||
return EMPTY_STR;
|
||||
|
@ -256,15 +260,13 @@ class ActivityStreams {
|
|||
$key = $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($namespace === $ns) {
|
||||
$key = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($namespace === $b['@context']) {
|
||||
$key = '';
|
||||
}
|
||||
|
@ -284,7 +286,8 @@ class ActivityStreams {
|
|||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function get_property_obj($property, $base = '', $namespace = '') {
|
||||
public function get_property_obj($property, $base = '', $namespace = '')
|
||||
{
|
||||
$prefix = $this->get_namespace($base, $namespace);
|
||||
if ($prefix === null) {
|
||||
return null;
|
||||
|
@ -310,18 +313,21 @@ class ActivityStreams {
|
|||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function fetch_property($url,$channel = null,$hub = null) {
|
||||
public function fetch_property($url, $channel = null, $hub = null)
|
||||
{
|
||||
return Activity::fetch($url, $channel, $hub);
|
||||
}
|
||||
|
||||
static function is_an_actor($s) {
|
||||
public static function is_an_actor($s)
|
||||
{
|
||||
if (!$s) {
|
||||
return false;
|
||||
}
|
||||
return (in_array($s, ['Application', 'Group', 'Organization', 'Person', 'Service']));
|
||||
}
|
||||
|
||||
static function is_response_activity($s) {
|
||||
public static function is_response_activity($s)
|
||||
{
|
||||
if (!$s) {
|
||||
return false;
|
||||
}
|
||||
|
@ -329,9 +335,6 @@ class ActivityStreams {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -341,7 +344,8 @@ class ActivityStreams {
|
|||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function get_actor($property,$base='',$namespace = '') {
|
||||
public function get_actor($property, $base = '', $namespace = '')
|
||||
{
|
||||
$x = $this->get_property_obj($property, $base, $namespace);
|
||||
if (self::is_url($x)) {
|
||||
$y = Activity::get_cached_actor($x);
|
||||
|
@ -367,11 +371,12 @@ class ActivityStreams {
|
|||
* @param string $property
|
||||
* @param array $base
|
||||
* @param string $namespace (optional) default empty
|
||||
* @param boolean $first (optional) default false, if true and result is a sequential array return only the first element
|
||||
* @param bool $first (optional) default false, if true and result is a sequential array return only the first element
|
||||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function get_compound_property($property, $base = '', $namespace = '', $first = false) {
|
||||
public function get_compound_property($property, $base = '', $namespace = '', $first = false)
|
||||
{
|
||||
$x = $this->get_property_obj($property, $base, $namespace);
|
||||
if (self::is_url($x)) {
|
||||
$y = $this->fetch_property($x);
|
||||
|
@ -410,10 +415,11 @@ class ActivityStreams {
|
|||
* @brief Check if string starts with http.
|
||||
*
|
||||
* @param string $url
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
static public function is_url($url) {
|
||||
public static function is_url($url)
|
||||
{
|
||||
if (($url) && (!is_array($url)) && ((strpos($url, 'http') === 0) || (strpos($url, 'x-zot') === 0) || (strpos($url, 'bear') === 0))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -429,7 +435,8 @@ class ActivityStreams {
|
|||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function get_primary_type($base = '', $namespace = '') {
|
||||
public function get_primary_type($base = '', $namespace = '')
|
||||
{
|
||||
if (!$base) {
|
||||
$base = $this->data;
|
||||
}
|
||||
|
@ -445,13 +452,15 @@ class ActivityStreams {
|
|||
return $x;
|
||||
}
|
||||
|
||||
function debug() {
|
||||
public function debug()
|
||||
{
|
||||
$x = var_export($this, true);
|
||||
return $x;
|
||||
}
|
||||
|
||||
|
||||
static function is_as_request() {
|
||||
public static function is_as_request()
|
||||
{
|
||||
|
||||
$x = getBestSupportedMimeType([
|
||||
'application/ld+json;profile="https://www.w3.org/ns/activitystreams"',
|
||||
|
|
|
@ -3,15 +3,18 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
|
||||
class Api_router {
|
||||
class Api_router
|
||||
{
|
||||
|
||||
static private $routes = [];
|
||||
private static $routes = [];
|
||||
|
||||
static function register($path,$fn,$auth_required) {
|
||||
public static function register($path, $fn, $auth_required)
|
||||
{
|
||||
self::$routes[$path] = ['func' => $fn, 'auth' => $auth_required];
|
||||
}
|
||||
|
||||
static function find($path) {
|
||||
public static function find($path)
|
||||
{
|
||||
if (array_key_exists($path, self::$routes)) {
|
||||
return self::$routes[$path];
|
||||
}
|
||||
|
@ -25,7 +28,8 @@ class Api_router {
|
|||
return null;
|
||||
}
|
||||
|
||||
static function dbg() {
|
||||
public static function dbg()
|
||||
{
|
||||
return self::$routes;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,22 +9,22 @@ use Zotlabs\Lib\Libsync;
|
|||
* Apps
|
||||
*
|
||||
*/
|
||||
class Apps
|
||||
{
|
||||
|
||||
class Apps {
|
||||
public static $available_apps = null;
|
||||
public static $installed_apps = null;
|
||||
|
||||
static public $available_apps = null;
|
||||
static public $installed_apps = null;
|
||||
|
||||
static public $base_apps = null;
|
||||
public static $base_apps = null;
|
||||
|
||||
|
||||
static public function get_system_apps($translate = true) {
|
||||
public static function get_system_apps($translate = true)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
if (is_dir('apps')) {
|
||||
$files = glob('apps/*.apd');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$files = glob('app/*.apd');
|
||||
}
|
||||
if ($files) {
|
||||
|
@ -56,7 +56,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static public function get_base_apps() {
|
||||
public static function get_base_apps()
|
||||
{
|
||||
|
||||
// to add additional default "base" apps to your site, put their English name, one per line,
|
||||
// into 'cache/default_apps'. This will be merged with the default project base apps.
|
||||
|
@ -94,7 +95,8 @@ class Apps {
|
|||
return $x;
|
||||
}
|
||||
|
||||
static public function import_system_apps() {
|
||||
public static function import_system_apps()
|
||||
{
|
||||
if (!local_channel()) {
|
||||
return;
|
||||
}
|
||||
|
@ -150,7 +152,8 @@ class Apps {
|
|||
* is discovered, or if the version of a system app changes.
|
||||
*/
|
||||
|
||||
static public function check_install_system_app($app) {
|
||||
public static function check_install_system_app($app)
|
||||
{
|
||||
if ((!is_array(self::$available_apps)) || (!count(self::$available_apps))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -179,7 +182,8 @@ class Apps {
|
|||
* is discovered, or if the version of a system app changes.
|
||||
*/
|
||||
|
||||
static public function check_install_personal_app($app) {
|
||||
public static function check_install_personal_app($app)
|
||||
{
|
||||
$installed = false;
|
||||
foreach (self::$installed_apps as $iapp) {
|
||||
if ($iapp['app_id'] == hash('whirlpool', $app['name'])) {
|
||||
|
@ -197,12 +201,14 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_name_compare($a,$b) {
|
||||
public static function app_name_compare($a, $b)
|
||||
{
|
||||
return strcasecmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
|
||||
static public function parse_app_description($f,$translate = true) {
|
||||
public static function parse_app_description($f, $translate = true)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
|
||||
|
@ -301,8 +307,7 @@ class Apps {
|
|||
default:
|
||||
if ($config) {
|
||||
$unset = ((get_config('system', $require[0]) == $require[1]) ? false : true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$unset = ((local_channel() && feature_enabled(local_channel(), $require)) ? false : true);
|
||||
}
|
||||
if ($unset) {
|
||||
|
@ -322,7 +327,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function translate_system_apps(&$arr) {
|
||||
public static function translate_system_apps(&$arr)
|
||||
{
|
||||
$apps = array(
|
||||
'Admin' => t('Site Admin'),
|
||||
'Apps' => t('Apps'),
|
||||
|
@ -405,13 +411,11 @@ class Apps {
|
|||
if (array_key_exists($arr['name'], $apps)) {
|
||||
$arr['name'] = $apps[$arr['name']];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for ($x = 0; $x < count($arr); $x++) {
|
||||
if (array_key_exists($arr[$x]['name'], $apps)) {
|
||||
$arr[$x]['name'] = $apps[$arr[$x]['name']];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Try to guess by app name if not in list
|
||||
$arr[$x]['name'] = t(trim($arr[$x]['name']));
|
||||
}
|
||||
|
@ -422,7 +426,8 @@ class Apps {
|
|||
|
||||
// papp is a portable app
|
||||
|
||||
static public function app_render($papp,$mode = 'view') {
|
||||
public static function app_render($papp, $mode = 'view')
|
||||
{
|
||||
|
||||
/**
|
||||
* modes:
|
||||
|
@ -540,8 +545,7 @@ class Apps {
|
|||
default:
|
||||
if ($config) {
|
||||
$unset = ((get_config('system', $require[0]) === $require[1]) ? false : true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$unset = ((local_channel() && feature_enabled(local_channel(), $require)) ? false : true);
|
||||
}
|
||||
if ($unset) {
|
||||
|
@ -564,8 +568,7 @@ class Apps {
|
|||
}
|
||||
|
||||
$hosturl = z_root() . '/';
|
||||
}
|
||||
elseif (remote_channel()) {
|
||||
} elseif (remote_channel()) {
|
||||
$observer = App::get_observer();
|
||||
if ($observer && $observer['xchan_network'] === 'zot6') {
|
||||
// some folks might have xchan_url redirected offsite, use the connurl
|
||||
|
@ -622,7 +625,8 @@ class Apps {
|
|||
]);
|
||||
}
|
||||
|
||||
static public function app_install($uid,$app) {
|
||||
public static function app_install($uid, $app)
|
||||
{
|
||||
|
||||
if (!is_array($app)) {
|
||||
$r = q("select * from app where app_name = '%s' and app_channel = 0",
|
||||
|
@ -639,8 +643,7 @@ class Apps {
|
|||
|
||||
if (self::app_installed($uid, $app, true)) {
|
||||
$x = self::app_update($app);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x = self::app_store($app);
|
||||
}
|
||||
|
||||
|
@ -658,8 +661,7 @@ class Apps {
|
|||
);
|
||||
if (intval($r[0]['app_system'])) {
|
||||
Libsync::build_sync_packet($uid, array('sysapp' => $r[0]));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Libsync::build_sync_packet($uid, array('app' => $r[0]));
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +673,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function can_delete($uid,$app) {
|
||||
public static function can_delete($uid, $app)
|
||||
{
|
||||
if (!$uid) {
|
||||
return false;
|
||||
}
|
||||
|
@ -688,7 +691,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_destroy($uid,$app) {
|
||||
public static function app_destroy($uid, $app)
|
||||
{
|
||||
|
||||
if ($uid && $app['guid']) {
|
||||
|
||||
|
@ -709,8 +713,7 @@ class Apps {
|
|||
intval($x[0]['id'])
|
||||
);
|
||||
call_hooks('app_destroy', $x[0]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
|
||||
dbesc($app['guid']),
|
||||
intval($uid)
|
||||
|
@ -718,12 +721,10 @@ class Apps {
|
|||
}
|
||||
if (intval($x[0]['app_system'])) {
|
||||
Libsync::build_sync_packet($uid, array('sysapp' => $x));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Libsync::build_sync_packet($uid, array('app' => $x));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self::app_undestroy($uid, $app);
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +732,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static public function app_undestroy($uid,$app) {
|
||||
public static function app_undestroy($uid, $app)
|
||||
{
|
||||
|
||||
// undelete a system app
|
||||
|
||||
|
@ -752,7 +754,8 @@ class Apps {
|
|||
}
|
||||
}
|
||||
|
||||
static public function app_feature($uid,$app,$term) {
|
||||
public static function app_feature($uid, $app, $term)
|
||||
{
|
||||
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
||||
dbesc($app['guid']),
|
||||
intval($uid)
|
||||
|
@ -770,13 +773,13 @@ class Apps {
|
|||
intval($x[0]['oid']),
|
||||
dbesc($term)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
store_item_tag($uid, $r[0]['id'], TERM_OBJ_APP, TERM_CATEGORY, $term, escape_tags(z_root() . '/apps/?f=&cat=' . $term));
|
||||
}
|
||||
}
|
||||
|
||||
static public function app_installed($uid,$app,$bypass_filter = false) {
|
||||
public static function app_installed($uid, $app, $bypass_filter = false)
|
||||
{
|
||||
|
||||
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
||||
dbesc((array_key_exists('guid', $app)) ? $app['guid'] : ''),
|
||||
|
@ -796,7 +799,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static public function addon_app_installed($uid,$app,$bypass_filter = false) {
|
||||
public static function addon_app_installed($uid, $app, $bypass_filter = false)
|
||||
{
|
||||
|
||||
$r = q("select id from app where app_plugin = '%s' and app_channel = %d limit 1",
|
||||
dbesc($app),
|
||||
|
@ -816,7 +820,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static public function system_app_installed($uid,$app,$bypass_filter = false) {
|
||||
public static function system_app_installed($uid, $app, $bypass_filter = false)
|
||||
{
|
||||
|
||||
$r = q("select id from app where app_id = '%s' and app_channel = %d and app_deleted = 0 limit 1",
|
||||
dbesc(hash('whirlpool', $app)),
|
||||
|
@ -835,11 +840,11 @@ class Apps {
|
|||
return (($r) ? true : false);
|
||||
}
|
||||
|
||||
static public function app_list($uid, $deleted = false, $cats = []) {
|
||||
public static function app_list($uid, $deleted = false, $cats = [])
|
||||
{
|
||||
if ($deleted) {
|
||||
$sql_extra = "";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sql_extra = " and app_deleted = 0 ";
|
||||
}
|
||||
if ($cats) {
|
||||
|
@ -887,7 +892,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_search_available($str) {
|
||||
public static function app_search_available($str)
|
||||
{
|
||||
|
||||
// not yet finished
|
||||
// somehow need to account for translations
|
||||
|
@ -900,8 +906,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static public function app_order($uid,$apps,$menu) {
|
||||
public static function app_order($uid, $apps, $menu)
|
||||
{
|
||||
|
||||
if (!$apps)
|
||||
return $apps;
|
||||
|
@ -935,7 +941,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static function find_app_in_array($name,$arr) {
|
||||
public static function find_app_in_array($name, $arr)
|
||||
{
|
||||
if (!$arr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -947,7 +954,8 @@ class Apps {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function moveup($uid,$guid,$menu) {
|
||||
public static function moveup($uid, $guid, $menu)
|
||||
{
|
||||
$syslist = [];
|
||||
|
||||
$conf = (($menu === 'nav_featured_app') ? 'app_order' : 'app_pin_order');
|
||||
|
@ -994,7 +1002,8 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static function movedown($uid,$guid,$menu) {
|
||||
public static function movedown($uid, $guid, $menu)
|
||||
{
|
||||
$syslist = [];
|
||||
|
||||
$conf = (($menu === 'nav_featured_app') ? 'app_order' : 'app_pin_order');
|
||||
|
@ -1041,13 +1050,15 @@ class Apps {
|
|||
|
||||
}
|
||||
|
||||
static public function app_decode($s) {
|
||||
public static function app_decode($s)
|
||||
{
|
||||
$x = base64_decode(str_replace(array('<br>', "\r", "\n", ' '), array('', '', '', ''), $s));
|
||||
return json_decode($x, true);
|
||||
}
|
||||
|
||||
|
||||
static public function app_macros($uid,&$arr) {
|
||||
public static function app_macros($uid, &$arr)
|
||||
{
|
||||
|
||||
if (!intval($uid)) {
|
||||
return;
|
||||
|
@ -1067,7 +1078,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_store($arr) {
|
||||
public static function app_store($arr)
|
||||
{
|
||||
|
||||
// logger('app_store: ' . print_r($arr,true));
|
||||
|
||||
|
@ -1098,7 +1110,7 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
$darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . \App::get_hostname());
|
||||
$darray['app_id'] = ((x($arr, 'guid')) ? $arr['guid'] : random_string() . '.' . App::get_hostname());
|
||||
$darray['app_sig'] = ((x($arr, 'sig')) ? $arr['sig'] : '');
|
||||
$darray['app_author'] = ((x($arr, 'author')) ? $arr['author'] : get_observer_hash());
|
||||
$darray['app_name'] = ((x($arr, 'name')) ? escape_tags($arr['name']) : t('Unknown'));
|
||||
|
@ -1163,7 +1175,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_update($arr) {
|
||||
public static function app_update($arr)
|
||||
{
|
||||
|
||||
// logger('app_update: ' . print_r($arr,true));
|
||||
$darray = [];
|
||||
|
@ -1263,7 +1276,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function app_encode($app,$embed = false) {
|
||||
public static function app_encode($app, $embed = false)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
|
||||
|
@ -1340,7 +1354,8 @@ class Apps {
|
|||
}
|
||||
|
||||
|
||||
static public function papp_encode($papp) {
|
||||
public static function papp_encode($papp)
|
||||
{
|
||||
return chunk_split(base64_encode(json_encode($papp)), 72, "\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ use Zotlabs\Lib\Libsync;
|
|||
/**
|
||||
* @brief A class with chatroom related static methods.
|
||||
*/
|
||||
class Chatroom {
|
||||
class Chatroom
|
||||
{
|
||||
/**
|
||||
* @brief Creates a chatroom.
|
||||
*
|
||||
|
@ -16,7 +17,8 @@ class Chatroom {
|
|||
* * \e boolean \b success - A boolean success status
|
||||
* * \e string \b message - (optional) A string
|
||||
*/
|
||||
static public function create($channel, $arr) {
|
||||
public static function create($channel, $arr)
|
||||
{
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
|
@ -72,7 +74,8 @@ class Chatroom {
|
|||
}
|
||||
|
||||
|
||||
static public function destroy($channel,$arr) {
|
||||
public static function destroy($channel, $arr)
|
||||
{
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
|
@ -112,7 +115,8 @@ class Chatroom {
|
|||
}
|
||||
|
||||
|
||||
static public function enter($observer_xchan, $room_id, $status, $client) {
|
||||
public static function enter($observer_xchan, $room_id, $status, $client)
|
||||
{
|
||||
|
||||
if (!$room_id || !$observer_xchan)
|
||||
return;
|
||||
|
@ -181,7 +185,8 @@ class Chatroom {
|
|||
}
|
||||
|
||||
|
||||
function leave($observer_xchan, $room_id, $client) {
|
||||
public function leave($observer_xchan, $room_id, $client)
|
||||
{
|
||||
if (!$room_id || !$observer_xchan)
|
||||
return;
|
||||
|
||||
|
@ -200,7 +205,8 @@ class Chatroom {
|
|||
}
|
||||
|
||||
|
||||
static public function roomlist($uid) {
|
||||
public static function roomlist($uid)
|
||||
{
|
||||
require_once('include/security.php');
|
||||
$sql_extra = permissions_sql($uid);
|
||||
|
||||
|
@ -211,7 +217,8 @@ class Chatroom {
|
|||
return $r;
|
||||
}
|
||||
|
||||
static public function list_count($uid) {
|
||||
public static function list_count($uid)
|
||||
{
|
||||
require_once('include/security.php');
|
||||
$sql_extra = permissions_sql($uid);
|
||||
|
||||
|
@ -233,7 +240,8 @@ class Chatroom {
|
|||
* @param string $text
|
||||
* @return array
|
||||
*/
|
||||
static public function message($uid, $room_id, $xchan, $text) {
|
||||
public static function message($uid, $room_id, $xchan, $text)
|
||||
{
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
|
||||
use App;
|
||||
|
||||
class Config {
|
||||
|
||||
/**
|
||||
|
@ -14,20 +16,20 @@ class Config {
|
|||
* @param string $family
|
||||
* The category of the configuration value
|
||||
*/
|
||||
static public function Load($family) {
|
||||
if(! array_key_exists($family, \App::$config))
|
||||
\App::$config[$family] = [];
|
||||
public static function Load($family) {
|
||||
if(! array_key_exists($family, App::$config))
|
||||
App::$config[$family] = [];
|
||||
|
||||
if(! array_key_exists('config_loaded', \App::$config[$family])) {
|
||||
if(! array_key_exists('config_loaded', App::$config[$family])) {
|
||||
$r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family));
|
||||
if($r !== false) {
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
$k = $rr['k'];
|
||||
\App::$config[$family][$k] = $rr['v'];
|
||||
App::$config[$family][$k] = $rr['v'];
|
||||
}
|
||||
}
|
||||
\App::$config[$family]['config_loaded'] = true;
|
||||
App::$config[$family]['config_loaded'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ class Config {
|
|||
* @return mixed
|
||||
* Return the set value, or false if the database update failed
|
||||
*/
|
||||
static public function Set($family, $key, $value) {
|
||||
public static function Set($family, $key, $value) {
|
||||
// manage array value
|
||||
$dbvalue = ((is_array($value)) ? serialise($value) : $value);
|
||||
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
|
||||
|
@ -58,7 +60,7 @@ class Config {
|
|||
dbesc($dbvalue)
|
||||
);
|
||||
if($ret) {
|
||||
\App::$config[$family][$key] = $value;
|
||||
App::$config[$family][$key] = $value;
|
||||
$ret = $value;
|
||||
}
|
||||
return $ret;
|
||||
|
@ -71,7 +73,7 @@ class Config {
|
|||
);
|
||||
|
||||
if($ret) {
|
||||
\App::$config[$family][$key] = $value;
|
||||
App::$config[$family][$key] = $value;
|
||||
$ret = $value;
|
||||
}
|
||||
|
||||
|
@ -96,15 +98,15 @@ class Config {
|
|||
* @param string $default (optional) default false
|
||||
* @return mixed Return value or false on error or if not set
|
||||
*/
|
||||
static public function Get($family, $key, $default = false) {
|
||||
if((! array_key_exists($family, \App::$config)) || (! array_key_exists('config_loaded', \App::$config[$family])))
|
||||
public static function Get($family, $key, $default = false) {
|
||||
if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family])))
|
||||
self::Load($family);
|
||||
|
||||
if(array_key_exists('config_loaded', \App::$config[$family])) {
|
||||
if(! array_key_exists($key, \App::$config[$family])) {
|
||||
if(array_key_exists('config_loaded', App::$config[$family])) {
|
||||
if(! array_key_exists($key, App::$config[$family])) {
|
||||
return $default;
|
||||
}
|
||||
return unserialise(\App::$config[$family][$key]);
|
||||
return unserialise(App::$config[$family][$key]);
|
||||
}
|
||||
|
||||
return $default;
|
||||
|
@ -122,12 +124,12 @@ class Config {
|
|||
* The configuration key to delete
|
||||
* @return mixed
|
||||
*/
|
||||
static public function Delete($family, $key) {
|
||||
public static function Delete($family, $key) {
|
||||
|
||||
$ret = false;
|
||||
|
||||
if(array_key_exists($family, \App::$config) && array_key_exists($key, \App::$config[$family]))
|
||||
unset(\App::$config[$family][$key]);
|
||||
if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family]))
|
||||
unset(App::$config[$family][$key]);
|
||||
|
||||
$ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'",
|
||||
dbesc($family),
|
||||
|
@ -150,7 +152,7 @@ class Config {
|
|||
* The configuration key to query
|
||||
* @return mixed
|
||||
*/
|
||||
static private function get_from_storage($family,$key) {
|
||||
private static function get_from_storage($family, $key) {
|
||||
$ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1",
|
||||
dbesc($family),
|
||||
dbesc($key)
|
||||
|
|
|
@ -7,8 +7,8 @@ use Zotlabs\Access\Permissions;
|
|||
use Zotlabs\Daemon\Run;
|
||||
|
||||
|
||||
|
||||
class Connect {
|
||||
class Connect
|
||||
{
|
||||
|
||||
/**
|
||||
* Takes a $channel and a $url/handle and adds a new connection
|
||||
|
@ -21,7 +21,8 @@ class Connect {
|
|||
* This function does NOT send sync packets to clones. The caller is responsible for doing this
|
||||
*/
|
||||
|
||||
static function connect($channel, $url, $sub_channel = false) {
|
||||
public static function connect($channel, $url, $sub_channel = false)
|
||||
{
|
||||
|
||||
$uid = $channel['channel_id'];
|
||||
|
||||
|
@ -242,8 +243,7 @@ class Connect {
|
|||
intval($r[0]['abook_id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// create a new abook record
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use Exception;
|
|||
|
||||
class Crypto {
|
||||
|
||||
static public $openssl_algorithms = [
|
||||
public static $openssl_algorithms = [
|
||||
|
||||
// zot6 nickname, opensslname, keylength, ivlength
|
||||
|
||||
|
@ -16,7 +16,7 @@ class Crypto {
|
|||
];
|
||||
|
||||
|
||||
static public function methods() {
|
||||
public static function methods() {
|
||||
$ret = [];
|
||||
|
||||
foreach(self::$openssl_algorithms as $ossl) {
|
||||
|
@ -28,7 +28,7 @@ class Crypto {
|
|||
}
|
||||
|
||||
|
||||
static public function signing_methods() {
|
||||
public static function signing_methods() {
|
||||
|
||||
$ret = [ 'sha256' ];
|
||||
call_hooks('signing_methods',$ret);
|
||||
|
@ -37,7 +37,7 @@ class Crypto {
|
|||
}
|
||||
|
||||
|
||||
static public function new_keypair($bits) {
|
||||
public static function new_keypair($bits) {
|
||||
|
||||
$openssl_options = [
|
||||
'digest_alg' => 'sha1',
|
||||
|
@ -72,7 +72,7 @@ class Crypto {
|
|||
}
|
||||
|
||||
|
||||
static public function sign($data,$key,$alg = 'sha256') {
|
||||
public static function sign($data, $key, $alg = 'sha256') {
|
||||
|
||||
if (! $key) {
|
||||
return false;
|
||||
|
@ -84,7 +84,7 @@ class Crypto {
|
|||
}
|
||||
|
||||
|
||||
static public function verify($data,$sig,$key,$alg = 'sha256') {
|
||||
public static function verify($data, $sig, $key, $alg = 'sha256') {
|
||||
|
||||
if (! $key) {
|
||||
return false;
|
||||
|
@ -107,7 +107,7 @@ class Crypto {
|
|||
return (($verify > 0) ? true : false);
|
||||
}
|
||||
|
||||
static public function encapsulate($data,$pubkey,$alg) {
|
||||
public static function encapsulate($data, $pubkey, $alg) {
|
||||
|
||||
if (! ($alg && $pubkey)) {
|
||||
return $data;
|
||||
|
@ -164,7 +164,7 @@ class Crypto {
|
|||
}
|
||||
}
|
||||
|
||||
static public function unencapsulate($data,$prvkey) {
|
||||
public static function unencapsulate($data, $prvkey) {
|
||||
|
||||
if (! (is_array($data) && array_key_exists('encrypted',$data) && array_key_exists('alg',$data) && $data['alg'])) {
|
||||
logger('not encrypted');
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
|
||||
class DB_Upgrade {
|
||||
use App;
|
||||
|
||||
class DB_Upgrade
|
||||
{
|
||||
|
||||
public $config_name = '';
|
||||
public $func_prefix = '';
|
||||
|
||||
function __construct($db_revision) {
|
||||
public function __construct($db_revision)
|
||||
{
|
||||
|
||||
$this->config_name = 'db_version';
|
||||
$this->func_prefix = '_';
|
||||
|
@ -20,8 +24,7 @@ class DB_Upgrade {
|
|||
if ($build == $db_revision) {
|
||||
// Nothing to be done.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$stored = intval($build);
|
||||
if (!$stored) {
|
||||
logger('Critical: check_config unable to determine database schema version');
|
||||
|
@ -79,16 +82,16 @@ class DB_Upgrade {
|
|||
file_put_contents($lockfile, $x);
|
||||
|
||||
$r = q("select account_language from account where account_email = '%s' limit 1",
|
||||
dbesc(\App::$config['system']['admin_email'])
|
||||
dbesc(App::$config['system']['admin_email'])
|
||||
);
|
||||
push_lang(($r) ? $r[0]['account_language'] : 'en');
|
||||
z_mail(
|
||||
[
|
||||
'toEmail' => \App::$config['system']['admin_email'],
|
||||
'toEmail' => App::$config['system']['admin_email'],
|
||||
'messageSubject' => sprintf(t('Update Error at %s'), z_root()),
|
||||
'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'),
|
||||
[
|
||||
'$sitename' => \App::$config['system']['sitename'],
|
||||
'$sitename' => App::$config['system']['sitename'],
|
||||
'$siteurl' => z_root(),
|
||||
'$update' => $x,
|
||||
'$error' => sprintf(t('Update %s failed. See error logs.'), $x),
|
||||
|
@ -102,8 +105,7 @@ class DB_Upgrade {
|
|||
//try the logger
|
||||
logger('CRITICAL: Update Failed: ' . $x);
|
||||
pop_lang();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
set_config('database', $s, 'success');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
class DReport {
|
||||
class DReport
|
||||
{
|
||||
|
||||
private $location;
|
||||
private $sender;
|
||||
|
@ -10,7 +11,8 @@ class DReport {
|
|||
private $status;
|
||||
private $date;
|
||||
|
||||
function __construct($location,$sender,$recipient,$message_id,$status = 'deliver') {
|
||||
public function __construct($location, $sender, $recipient, $message_id, $status = 'deliver')
|
||||
{
|
||||
$this->location = $location;
|
||||
$this->sender = $sender;
|
||||
$this->recipient = $recipient;
|
||||
|
@ -20,21 +22,25 @@ class DReport {
|
|||
$this->date = datetime_convert();
|
||||
}
|
||||
|
||||
function update($status) {
|
||||
public function update($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
$this->date = datetime_convert();
|
||||
}
|
||||
|
||||
function set_name($name) {
|
||||
public function set_name($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
function addto_update($status) {
|
||||
public function addto_update($status)
|
||||
{
|
||||
$this->status = $this->status . ' ' . $status;
|
||||
}
|
||||
|
||||
|
||||
function set($arr) {
|
||||
public function set($arr)
|
||||
{
|
||||
$this->location = $arr['location'];
|
||||
$this->sender = $arr['sender'];
|
||||
$this->recipient = $arr['recipient'];
|
||||
|
@ -44,7 +50,8 @@ class DReport {
|
|||
$this->date = $arr['date'];
|
||||
}
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
return array(
|
||||
'location' => $this->location,
|
||||
'sender' => $this->sender,
|
||||
|
@ -60,10 +67,11 @@ class DReport {
|
|||
* @brief decide whether to store a returned delivery report
|
||||
*
|
||||
* @param array $dr
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
static function is_storable($dr) {
|
||||
public static function is_storable($dr)
|
||||
{
|
||||
|
||||
if (get_config('system', 'disable_dreport'))
|
||||
return false;
|
||||
|
|
|
@ -29,7 +29,7 @@ class Enotify {
|
|||
*/
|
||||
|
||||
|
||||
static public function submit($params) {
|
||||
public static function submit($params) {
|
||||
|
||||
logger('notification: entry', LOGGER_DEBUG);
|
||||
|
||||
|
@ -807,7 +807,7 @@ class Enotify {
|
|||
* * \e string \b textVersion text only version of the message
|
||||
* * \e string \b additionalMailHeader additions to the smtp mail header
|
||||
*/
|
||||
static public function send($params) {
|
||||
public static function send($params) {
|
||||
|
||||
$params['sent'] = false;
|
||||
$params['result'] = false;
|
||||
|
@ -862,7 +862,7 @@ class Enotify {
|
|||
return $res;
|
||||
}
|
||||
|
||||
static public function format($item) {
|
||||
public static function format($item) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Description of ExtendedZip
|
||||
*
|
||||
* @author andrew
|
||||
*/
|
||||
class ExtendedZip extends \ZipArchive {
|
||||
class ExtendedZip extends ZipArchive {
|
||||
|
||||
// Member function to add a whole file system subtree to the archive
|
||||
public function addTree($dirname, $localname = '') {
|
||||
|
|
|
@ -28,9 +28,11 @@ namespace Zotlabs\Lib;
|
|||
*
|
||||
*/
|
||||
|
||||
class Hashpath {
|
||||
class Hashpath
|
||||
{
|
||||
|
||||
static function path($url, $prefix = '.', $depth = 1, $mkdir = true) {
|
||||
public static function path($url, $prefix = '.', $depth = 1, $mkdir = true)
|
||||
{
|
||||
$hash = hash('sha256', $url);
|
||||
$start = 0;
|
||||
$slice = 2;
|
||||
|
@ -44,8 +46,7 @@ class Hashpath {
|
|||
$prefix .= '/' . $slug;
|
||||
$start += $slice;
|
||||
$sluglen -= $slice;
|
||||
}
|
||||
while ($sluglen);
|
||||
} while ($sluglen);
|
||||
|
||||
if ($mkdir) {
|
||||
os_mkdir($prefix, STORAGE_DEFAULT_PERMISSIONS, true);
|
||||
|
|
|
@ -6,11 +6,11 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class IConfig {
|
||||
|
||||
static public function Load(&$item) {
|
||||
public static function Load(&$item) {
|
||||
return;
|
||||
}
|
||||
|
||||
static public function Get(&$item, $family, $key, $default = false) {
|
||||
public static function Get(&$item, $family, $key, $default = false) {
|
||||
|
||||
$is_item = false;
|
||||
|
||||
|
@ -76,7 +76,7 @@ class IConfig {
|
|||
*/
|
||||
|
||||
|
||||
static public function Set(&$item, $family, $key, $value, $sharing = false) {
|
||||
public static function Set(&$item, $family, $key, $value, $sharing = false) {
|
||||
|
||||
$dbvalue = ((is_array($value)) ? serialise($value) : $value);
|
||||
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
|
||||
|
@ -137,7 +137,7 @@ class IConfig {
|
|||
|
||||
|
||||
|
||||
static public function Delete(&$item, $family, $key) {
|
||||
public static function Delete(&$item, $family, $key) {
|
||||
|
||||
|
||||
$is_item = false;
|
||||
|
|
|
@ -4,11 +4,13 @@ namespace Zotlabs\Lib;
|
|||
use Zotlabs\Lib\Hashpath;
|
||||
use Zotlabs\Daemon\Run;
|
||||
|
||||
class Img_cache {
|
||||
class Img_cache
|
||||
{
|
||||
|
||||
static $cache_life = 18600 * 7;
|
||||
static public $cache_life = 18600 * 7;
|
||||
|
||||
static function get_filename($url, $prefix = '.') {
|
||||
public static function get_filename($url, $prefix = '.')
|
||||
{
|
||||
return Hashpath::path($url, $prefix);
|
||||
}
|
||||
|
||||
|
@ -17,7 +19,8 @@ class Img_cache {
|
|||
// If we do not, or the cache file is empty or expired, return false
|
||||
// but attempt to fetch the entry in the background
|
||||
|
||||
static function check($url, $prefix = '.') {
|
||||
public static function check($url, $prefix = '.')
|
||||
{
|
||||
|
||||
if (strpos($url, z_root()) !== false) {
|
||||
return false;
|
||||
|
@ -29,8 +32,7 @@ class Img_cache {
|
|||
if ($t && time() - $t >= self::$cache_life) {
|
||||
Run::Summon(['Cache_image', $url, $path]);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return ((filesize($path)) ? true : false);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +43,8 @@ class Img_cache {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function url_to_cache($url,$file) {
|
||||
public static function url_to_cache($url, $file)
|
||||
{
|
||||
|
||||
$fp = fopen($file, 'wb');
|
||||
|
||||
|
|
|
@ -2,15 +2,18 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
class Img_filesize {
|
||||
class Img_filesize
|
||||
{
|
||||
|
||||
private $url;
|
||||
|
||||
function __construct($url) {
|
||||
public function __construct($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
public function getSize()
|
||||
{
|
||||
$size = null;
|
||||
|
||||
if (stripos($this->url, z_root() . '/photo') !== false) {
|
||||
|
@ -24,7 +27,8 @@ class Img_filesize {
|
|||
}
|
||||
|
||||
|
||||
static function getLocalFileSize($url) {
|
||||
public static function getLocalFileSize($url)
|
||||
{
|
||||
|
||||
$fname = basename($url);
|
||||
$resolution = 0;
|
||||
|
|
|
@ -4,9 +4,11 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
|
||||
class JSalmon {
|
||||
class JSalmon
|
||||
{
|
||||
|
||||
static function sign($data,$key_id,$key,$data_type = 'application/x-zot+json') {
|
||||
public static function sign($data, $key_id, $key, $data_type = 'application/x-zot+json')
|
||||
{
|
||||
|
||||
$data = base64url_encode(json_encode($data, true), true); // strip padding
|
||||
$encoding = 'base64url';
|
||||
|
@ -34,7 +36,8 @@ class JSalmon {
|
|||
|
||||
}
|
||||
|
||||
static function verify($x) {
|
||||
public static function verify($x)
|
||||
{
|
||||
|
||||
logger('verify');
|
||||
$ret = ['results' => []];
|
||||
|
@ -64,7 +67,8 @@ class JSalmon {
|
|||
|
||||
}
|
||||
|
||||
static function unpack($data) {
|
||||
public static function unpack($data)
|
||||
{
|
||||
return json_decode(base64url_decode($data), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use Exception;
|
||||
use Zotlabs\Lib\Activity;
|
||||
|
||||
require_once('library/jsonld/jsonld.php');
|
||||
|
||||
class LDSignatures {
|
||||
class LDSignatures
|
||||
{
|
||||
|
||||
|
||||
static function verify($data,$pubkey) {
|
||||
public static function verify($data, $pubkey)
|
||||
{
|
||||
|
||||
$ohash = self::hash(self::signable_options($data['signature']));
|
||||
$dhash = self::hash(self::signable_data($data));
|
||||
|
@ -20,13 +23,15 @@ class LDSignatures {
|
|||
return $x;
|
||||
}
|
||||
|
||||
static function dopplesign(&$data,$channel) {
|
||||
public static function dopplesign(&$data, $channel)
|
||||
{
|
||||
// remove for the time being - performance issues
|
||||
// $data['magicEnv'] = self::salmon_sign($data,$channel);
|
||||
return self::sign($data, $channel);
|
||||
}
|
||||
|
||||
static function sign($data,$channel) {
|
||||
public static function sign($data, $channel)
|
||||
{
|
||||
|
||||
$options = [
|
||||
'type' => 'RsaSignature2017',
|
||||
|
@ -43,7 +48,8 @@ class LDSignatures {
|
|||
}
|
||||
|
||||
|
||||
static function signable_data($data) {
|
||||
public static function signable_data($data)
|
||||
{
|
||||
|
||||
$newdata = [];
|
||||
if ($data) {
|
||||
|
@ -57,7 +63,8 @@ class LDSignatures {
|
|||
}
|
||||
|
||||
|
||||
static function signable_options($options) {
|
||||
public static function signable_options($options)
|
||||
{
|
||||
|
||||
$newopts = ['@context' => 'https://w3id.org/identity/v1'];
|
||||
if ($options) {
|
||||
|
@ -70,12 +77,14 @@ class LDSignatures {
|
|||
return json_encode($newopts, JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
static function hash($obj) {
|
||||
public static function hash($obj)
|
||||
{
|
||||
|
||||
return hash('sha256', self::normalise($obj));
|
||||
}
|
||||
|
||||
static function normalise($data) {
|
||||
public static function normalise($data)
|
||||
{
|
||||
if (is_string($data)) {
|
||||
$data = json_decode($data);
|
||||
}
|
||||
|
@ -87,8 +96,7 @@ class LDSignatures {
|
|||
|
||||
try {
|
||||
$d = jsonld_normalize($data, ['algorithm' => 'URDNA2015', 'format' => 'application/nquads']);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// Don't log the exception - this can exhaust memory
|
||||
// logger('normalise error:' . print_r($e,true));
|
||||
logger('normalise error: ' . print_r($data, true));
|
||||
|
@ -97,7 +105,8 @@ class LDSignatures {
|
|||
return $d;
|
||||
}
|
||||
|
||||
static function salmon_sign($data,$channel) {
|
||||
public static function salmon_sign($data, $channel)
|
||||
{
|
||||
|
||||
$arr = $data;
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
|
@ -128,5 +137,4 @@ class LDSignatures {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -3,14 +3,16 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
|
||||
class LibBlock {
|
||||
class LibBlock
|
||||
{
|
||||
|
||||
static $cache = [];
|
||||
static $empty = [];
|
||||
static public $cache = [];
|
||||
static public $empty = [];
|
||||
|
||||
// This limits the number of DB queries for fetch_by_entity to once per page load.
|
||||
|
||||
static function fetch_from_cache($channel_id,$entity) {
|
||||
public static function fetch_from_cache($channel_id, $entity)
|
||||
{
|
||||
if (!isset(self::$cache[$channel_id])) {
|
||||
if (!isset(self::$empty[$channel_id])) {
|
||||
self::$cache[$channel_id] = self::fetch($channel_id);
|
||||
|
@ -30,7 +32,8 @@ class LibBlock {
|
|||
}
|
||||
|
||||
|
||||
static function store($arr) {
|
||||
public static function store($arr)
|
||||
{
|
||||
|
||||
$arr['block_entity'] = trim($arr['block_entity']);
|
||||
|
||||
|
@ -61,20 +64,21 @@ class LibBlock {
|
|||
dbesc($arr['block_comment']),
|
||||
intval($arr['block_id'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return create_table_from_array('block', $arr);
|
||||
}
|
||||
}
|
||||
|
||||
static function remove($channel_id,$entity) {
|
||||
public static function remove($channel_id, $entity)
|
||||
{
|
||||
return q("delete from block where block_channel_id = %d and block_entity = '%s'",
|
||||
intval($channel_id),
|
||||
dbesc($entity)
|
||||
);
|
||||
}
|
||||
|
||||
static function fetch_by_id($channel_id,$id) {
|
||||
public static function fetch_by_id($channel_id, $id)
|
||||
{
|
||||
if (!intval($channel_id)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -85,7 +89,8 @@ class LibBlock {
|
|||
}
|
||||
|
||||
|
||||
static function fetch_by_entity($channel_id,$entity) {
|
||||
public static function fetch_by_entity($channel_id, $entity)
|
||||
{
|
||||
if (!intval($channel_id)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +99,8 @@ class LibBlock {
|
|||
|
||||
}
|
||||
|
||||
static function fetch($channel_id,$type = false) {
|
||||
public static function fetch($channel_id, $type = false)
|
||||
{
|
||||
if (!intval($channel_id)) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use App;
|
||||
|
||||
class Libprofile {
|
||||
|
||||
class Libprofile
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,8 @@ class Libprofile {
|
|||
* @param string $profile_guid
|
||||
*/
|
||||
|
||||
static function load($nickname, $profile = '') {
|
||||
public static function load($nickname, $profile = '')
|
||||
{
|
||||
|
||||
// logger('Libprofile::load: ' . $nickname . (($profile) ? ' profile: ' . $profile : ''));
|
||||
|
||||
|
@ -174,7 +175,8 @@ class Libprofile {
|
|||
|
||||
}
|
||||
|
||||
static function edit_menu($uid) {
|
||||
public static function edit_menu($uid)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
|
||||
|
@ -192,8 +194,7 @@ class Libprofile {
|
|||
$ret['multi'] = 1;
|
||||
$ret['edit'] = [z_root() . '/profiles', t('Edit Profiles'), '', t('Edit')];
|
||||
$ret['menu']['cr_new'] = t('Create New Profile');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$ret['edit'] = [z_root() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit')];
|
||||
}
|
||||
|
||||
|
@ -230,14 +231,15 @@ class Libprofile {
|
|||
*
|
||||
* @param array $profile
|
||||
* @param int $block
|
||||
* @param boolean $show_connect (optional) default true
|
||||
* @param bool $show_connect (optional) default true
|
||||
* @param mixed $zcard (optional) default false
|
||||
*
|
||||
* @return HTML string suitable for sidebar inclusion
|
||||
* Exceptions: Returns empty string if passed $profile is wrong type or not populated
|
||||
*/
|
||||
|
||||
static function widget($profile, $block = 0, $show_connect = true, $zcard = false) {
|
||||
public static function widget($profile, $block = 0, $show_connect = true, $zcard = false)
|
||||
{
|
||||
|
||||
$observer = App::get_observer();
|
||||
|
||||
|
@ -378,7 +380,8 @@ class Libprofile {
|
|||
return $arr['entry'];
|
||||
}
|
||||
|
||||
static function gender_icon($gender) {
|
||||
public static function gender_icon($gender)
|
||||
{
|
||||
|
||||
// logger('gender: ' . $gender);
|
||||
|
||||
|
@ -401,7 +404,8 @@ class Libprofile {
|
|||
return '';
|
||||
}
|
||||
|
||||
static function pronouns_icon($pronouns) {
|
||||
public static function pronouns_icon($pronouns)
|
||||
{
|
||||
|
||||
|
||||
// This can easily get throw off if the observer language is different
|
||||
|
@ -418,7 +422,8 @@ class Libprofile {
|
|||
}
|
||||
|
||||
|
||||
static function advanced() {
|
||||
public static function advanced()
|
||||
{
|
||||
|
||||
if (!perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_profile'))
|
||||
return '';
|
||||
|
@ -591,21 +596,4 @@ class Libprofile {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -9,7 +9,8 @@ use Zotlabs\Lib\Connect;
|
|||
use Zotlabs\Lib\DReport;
|
||||
use Zotlabs\Daemon\Run;
|
||||
|
||||
class Libsync {
|
||||
class Libsync
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Builds and sends a sync packet.
|
||||
|
@ -23,10 +24,11 @@ class Libsync {
|
|||
*
|
||||
* @param int $uid (optional) default 0
|
||||
* @param array $packet (optional) default null
|
||||
* @param boolean $groups_changed (optional) default false
|
||||
* @param bool $groups_changed (optional) default false
|
||||
*/
|
||||
|
||||
static function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
|
||||
public static function build_sync_packet($uid = 0, $packet = null, $groups_changed = false)
|
||||
{
|
||||
|
||||
//logger('build_sync_packet');
|
||||
|
||||
|
@ -183,7 +185,8 @@ class Libsync {
|
|||
}
|
||||
|
||||
|
||||
static function build_link_packet($uid = 0, $packet = null) {
|
||||
public static function build_link_packet($uid = 0, $packet = null)
|
||||
{
|
||||
|
||||
// logger('build_link_packet');
|
||||
|
||||
|
@ -281,7 +284,8 @@ class Libsync {
|
|||
* @return array
|
||||
*/
|
||||
|
||||
static function process_channel_sync_delivery($sender, $arr, $deliveries) {
|
||||
public static function process_channel_sync_delivery($sender, $arr, $deliveries)
|
||||
{
|
||||
|
||||
require_once('include/import.php');
|
||||
|
||||
|
@ -524,13 +528,11 @@ class Libsync {
|
|||
$h = Libzot::get_hublocs($abook['abook_xchan']);
|
||||
if ($h) {
|
||||
$found = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$xhash = import_author_xchan(encode_item_xchan($abook));
|
||||
if ($xhash) {
|
||||
$found = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('Import of ' . $abook['xchan_addr'] . ' failed.');
|
||||
}
|
||||
}
|
||||
|
@ -574,8 +576,7 @@ class Libsync {
|
|||
$clean['abook_instance'] .= ',';
|
||||
$clean['abook_instance'] .= z_root();
|
||||
$clean['abook_not_here'] = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$clean['abook_not_here'] = 1;
|
||||
if (!($abook['abook_pending'] || $abook['abook_blocked'])) {
|
||||
$reconnect = true;
|
||||
|
@ -826,14 +827,11 @@ class Libsync {
|
|||
|
||||
if ($k === 'name') {
|
||||
$clean['fullname'] = $v;
|
||||
}
|
||||
elseif ($k === 'with') {
|
||||
} elseif ($k === 'with') {
|
||||
$clean['partner'] = $v;
|
||||
}
|
||||
elseif ($k === 'work') {
|
||||
} elseif ($k === 'work') {
|
||||
$clean['employment'] = $v;
|
||||
}
|
||||
elseif (array_key_exists($k,$x[0])) {
|
||||
} elseif (array_key_exists($k, $x[0])) {
|
||||
$clean[$k] = $v;
|
||||
}
|
||||
|
||||
|
@ -845,8 +843,7 @@ class Libsync {
|
|||
if ((strpos($profile['thumb'], '/photo/profile/l/') !== false) || intval($profile['is_default'])) {
|
||||
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
|
||||
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$profile['photo'] = z_root() . '/photo/' . basename($profile['photo']);
|
||||
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
|
||||
}
|
||||
|
@ -886,11 +883,12 @@ class Libsync {
|
|||
*
|
||||
* @param array $sender
|
||||
* @param array $arr
|
||||
* @param boolean $absolute (optional) default false
|
||||
* @param bool $absolute (optional) default false
|
||||
* @return array
|
||||
*/
|
||||
|
||||
static function sync_locations($sender, $arr, $absolute = false) {
|
||||
public static function sync_locations($sender, $arr, $absolute = false)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
$what = EMPTY_STR;
|
||||
|
@ -1038,8 +1036,7 @@ class Libsync {
|
|||
hubloc_change_primary($r[0]);
|
||||
$what .= 'primary_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
elseif((! intval($r[0]['hubloc_primary'])) && ($location['primary'])) {
|
||||
} elseif ((!intval($r[0]['hubloc_primary'])) && ($location['primary'])) {
|
||||
$m = q("update hubloc set hubloc_primary = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['hubloc_id'])
|
||||
|
@ -1049,16 +1046,14 @@ class Libsync {
|
|||
hubloc_change_primary($r[0]);
|
||||
$what .= 'primary_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
elseif($absolute) {
|
||||
} elseif ($absolute) {
|
||||
// Absolute sync - make sure the current primary is correctly reflected in the xchan
|
||||
$pr = hubloc_change_primary($r[0]);
|
||||
if ($pr) {
|
||||
$what .= 'xchan_primary ';
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
elseif(intval($r[0]['hubloc_primary']) && $xchan && $xchan['xchan_url'] !== $r[0]['hubloc_id_url']) {
|
||||
} elseif (intval($r[0]['hubloc_primary']) && $xchan && $xchan['xchan_url'] !== $r[0]['hubloc_id_url']) {
|
||||
$pr = hubloc_change_primary($r[0]);
|
||||
if ($pr) {
|
||||
$what .= 'xchan_primary ';
|
||||
|
@ -1073,8 +1068,7 @@ class Libsync {
|
|||
);
|
||||
$what .= 'undelete_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
elseif((! intval($r[0]['hubloc_deleted'])) && (intval($location['deleted']))) {
|
||||
} elseif ((!intval($r[0]['hubloc_deleted'])) && (intval($location['deleted']))) {
|
||||
logger('deleting hubloc: ' . $r[0]['hubloc_addr']);
|
||||
$n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
|
@ -1146,8 +1140,7 @@ class Libsync {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('No locations to sync!');
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1151,8 @@ class Libsync {
|
|||
}
|
||||
|
||||
|
||||
static function keychange($channel,$arr) {
|
||||
public static function keychange($channel, $arr)
|
||||
{
|
||||
|
||||
// verify the keychange operation
|
||||
if (!Libzot::verify($arr['channel']['channel_pubkey'], $arr['keychange']['new_sig'], $channel['channel_prvkey'])) {
|
||||
|
|
|
@ -20,7 +20,8 @@ use Zotlabs\Daemon\Run;
|
|||
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
class Libzot {
|
||||
class Libzot
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Generates a unique string for use as a zot guid.
|
||||
|
@ -40,7 +41,8 @@ class Libzot {
|
|||
* @returns string
|
||||
*/
|
||||
|
||||
static function new_uid($channel_nick) {
|
||||
public static function new_uid($channel_nick)
|
||||
{
|
||||
$rawstr = z_root() . '/' . $channel_nick . '.' . mt_rand();
|
||||
return (base64url_encode(hash('whirlpool', $rawstr, true), true));
|
||||
}
|
||||
|
@ -59,7 +61,8 @@ class Libzot {
|
|||
* @param string $pubkey
|
||||
*/
|
||||
|
||||
static function make_xchan_hash($guid, $pubkey) {
|
||||
public static function make_xchan_hash($guid, $pubkey)
|
||||
{
|
||||
return base64url_encode(hash('whirlpool', $guid . $pubkey, true));
|
||||
}
|
||||
|
||||
|
@ -74,7 +77,8 @@ class Libzot {
|
|||
*
|
||||
*/
|
||||
|
||||
static function get_hublocs($hash) {
|
||||
public static function get_hublocs($hash)
|
||||
{
|
||||
|
||||
/* Only search for active hublocs - e.g. those that haven't been marked deleted */
|
||||
|
||||
|
@ -106,7 +110,8 @@ class Libzot {
|
|||
* @returns string json encoded zot packet
|
||||
*/
|
||||
|
||||
static function build_packet($channel, $type = 'activity', $recipients = null, $msg = '', $encoding = 'activitystreams', $remote_key = null, $methods = '') {
|
||||
public static function build_packet($channel, $type = 'activity', $recipients = null, $msg = '', $encoding = 'activitystreams', $remote_key = null, $methods = '')
|
||||
{
|
||||
|
||||
$data = [
|
||||
'type' => $type,
|
||||
|
@ -126,8 +131,7 @@ class Libzot {
|
|||
$msg = JSalmon::sign($msg, $actor, $channel['channel_prvkey']);
|
||||
}
|
||||
$data['data'] = $msg;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unset($data['encoding']);
|
||||
}
|
||||
|
||||
|
@ -165,7 +169,8 @@ class Libzot {
|
|||
*
|
||||
*/
|
||||
|
||||
static function best_algorithm($methods) {
|
||||
public static function best_algorithm($methods)
|
||||
{
|
||||
|
||||
$x = [
|
||||
'methods' => $methods,
|
||||
|
@ -209,16 +214,17 @@ class Libzot {
|
|||
/**
|
||||
* @brief send a zot message
|
||||
*
|
||||
* @see z_post_url()
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $data
|
||||
* @param array $channel (required if using zot6 delivery)
|
||||
* @param array $crypto (required if encrypted httpsig, requires hubloc_sitekey and site_crypto elements)
|
||||
* @return array see z_post_url() for returned data format
|
||||
* @see z_post_url()
|
||||
*
|
||||
*/
|
||||
|
||||
static function zot($url, $data, $channel = null,$crypto = null) {
|
||||
public static function zot($url, $data, $channel = null, $crypto = null)
|
||||
{
|
||||
|
||||
if ($channel) {
|
||||
$headers = [
|
||||
|
@ -230,8 +236,7 @@ class Libzot {
|
|||
|
||||
$h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), false, 'sha512',
|
||||
(($crypto) ? ['key' => $crypto['hubloc_sitekey'], 'algorithm' => self::best_algorithm($crypto['site_crypto'])] : false));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$h = [];
|
||||
}
|
||||
|
||||
|
@ -272,7 +277,8 @@ class Libzot {
|
|||
* * otherwise \b false
|
||||
*/
|
||||
|
||||
static function refresh($them, $channel = null, $force = false) {
|
||||
public static function refresh($them, $channel = null, $force = false)
|
||||
{
|
||||
|
||||
$hsig_valid = false;
|
||||
|
||||
|
@ -285,8 +291,7 @@ class Libzot {
|
|||
|
||||
if ($them['hubloc_id_url']) {
|
||||
$url = $them['hubloc_id_url'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = null;
|
||||
|
||||
// if they re-installed the server we could end up with the wrong record - pointing to a hash generated by the old install.
|
||||
|
@ -363,8 +368,7 @@ class Libzot {
|
|||
|
||||
if (array_key_exists('profile', $record['data']) && array_key_exists('next_birthday', $record['data']['profile'])) {
|
||||
$next_birthday = datetime_convert('UTC', 'UTC', $record['data']['profile']['next_birthday']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$next_birthday = NULL_DATE;
|
||||
}
|
||||
|
||||
|
@ -399,14 +403,12 @@ class Libzot {
|
|||
|
||||
if (!$y) {
|
||||
logger('abook update failed');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// if we were just granted read stream permission and didn't have it before, try to pull in some posts
|
||||
if ((!$old_read_stream_perm) && (intval($permissions['view_stream'])))
|
||||
Run::Summon(['Onepoll', $r[0]['abook_id']]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// limit the ability to do connection spamming, this limit is per channel
|
||||
$lim = intval(get_config('system', 'max_connections_per_day', 50));
|
||||
|
@ -539,8 +541,7 @@ class Libzot {
|
|||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -566,7 +567,8 @@ class Libzot {
|
|||
* * otherwise an array with an hubloc record
|
||||
*/
|
||||
|
||||
static function gethub($arr, $multiple = false) {
|
||||
public static function gethub($arr, $multiple = false)
|
||||
{
|
||||
|
||||
if ($arr['id'] && $arr['id_sig'] && $arr['location'] && $arr['location_sig']) {
|
||||
|
||||
|
@ -599,9 +601,8 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static function valid_hub($sender,$site_id) {
|
||||
public static function valid_hub($sender, $site_id)
|
||||
{
|
||||
|
||||
$r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_site_id = '%s' limit 1",
|
||||
dbesc($sender),
|
||||
|
@ -643,7 +644,8 @@ class Libzot {
|
|||
* * \b message (optional) error string only if success is false
|
||||
*/
|
||||
|
||||
static function register_hub($id) {
|
||||
public static function register_hub($id)
|
||||
{
|
||||
|
||||
$id_hash = false;
|
||||
$valid = false;
|
||||
|
@ -671,8 +673,7 @@ class Libzot {
|
|||
$c = self::import_xchan($record['data']);
|
||||
if ($c['success']) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('Failure to verify zot packet');
|
||||
}
|
||||
|
||||
|
@ -698,7 +699,8 @@ class Libzot {
|
|||
* * \e string \b message (optional) error string only if success is false
|
||||
*/
|
||||
|
||||
static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
|
||||
public static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null)
|
||||
{
|
||||
|
||||
/**
|
||||
* @hooks import_xchan
|
||||
|
@ -734,8 +736,7 @@ class Libzot {
|
|||
if (!self::verify($arr['id'], $arr['id_sig'], $arr['public_key'])) {
|
||||
logger('Unable to verify channel signature for ' . $arr['address']);
|
||||
return $ret;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$verified = true;
|
||||
}
|
||||
|
||||
|
@ -784,11 +785,9 @@ class Libzot {
|
|||
|
||||
if ($arr['channel_type'] === 'collection') {
|
||||
$px = 2;
|
||||
}
|
||||
elseif ($arr['channel_type'] === 'group') {
|
||||
} elseif ($arr['channel_type'] === 'group') {
|
||||
$px = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$px = 0;
|
||||
}
|
||||
if (array_key_exists('public_forum', $arr) && intval($arr['public_forum'])) {
|
||||
|
@ -803,8 +802,7 @@ class Libzot {
|
|||
$protocols = implode(',', $arr['protocols']);
|
||||
if ($protocols !== 'zot6') {
|
||||
set_xconfig($xchan_hash, 'system', 'protocols', $protocols);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
del_xconfig($xchan_hash, 'system', 'protocols');
|
||||
}
|
||||
}
|
||||
|
@ -862,8 +860,7 @@ class Libzot {
|
|||
$what .= 'xchan ';
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$import_photos = true;
|
||||
|
||||
if ((($arr['site']['directory_mode'] === 'standalone')
|
||||
|
@ -875,11 +872,9 @@ class Libzot {
|
|||
|
||||
if ($arr['channel_type'] === 'collection') {
|
||||
$px = 2;
|
||||
}
|
||||
elseif ($arr['channel_type'] === 'group') {
|
||||
} elseif ($arr['channel_type'] === 'group') {
|
||||
$px = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$px = 0;
|
||||
}
|
||||
|
||||
|
@ -972,8 +967,7 @@ class Libzot {
|
|||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$photos = import_remote_xchan_photo($arr['photo']['url'], $xchan_hash);
|
||||
}
|
||||
if ($photos) {
|
||||
|
@ -989,8 +983,7 @@ class Libzot {
|
|||
dbesc($photos[3]),
|
||||
dbesc($xchan_hash)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = q("update xchan set xchan_updated = '%s', xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
|
||||
where xchan_hash = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
|
@ -1054,8 +1047,7 @@ class Libzot {
|
|||
$what .= 'profile ';
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('Profile not available - hiding');
|
||||
// they may have made it private
|
||||
$r = q("delete from xprof where xprof_hash = '%s'",
|
||||
|
@ -1079,8 +1071,7 @@ class Libzot {
|
|||
$guid = random_string() . '@' . App::get_hostname();
|
||||
Libzotdir::update_modtime($xchan_hash, $guid, $address, $ud_flags);
|
||||
logger('Changed: ' . $what, LOGGER_DEBUG);
|
||||
}
|
||||
elseif (! $ud_flags) {
|
||||
} elseif (!$ud_flags) {
|
||||
// nothing changed but we still need to update the updates record
|
||||
q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) > 0 ",
|
||||
intval(UPDATE_FLAGS_UPDATED),
|
||||
|
@ -1109,7 +1100,8 @@ class Libzot {
|
|||
* @param array $outq - The queue structure attached to this request
|
||||
*/
|
||||
|
||||
static function process_response($hub, $arr, $outq) {
|
||||
public static function process_response($hub, $arr, $outq)
|
||||
{
|
||||
|
||||
logger('remote: ' . print_r($arr, true), LOGGER_DATA);
|
||||
|
||||
|
@ -1202,14 +1194,15 @@ class Libzot {
|
|||
* If everything checks out on the remote end, we will receive back a packet containing one or more messages,
|
||||
* which will be processed and delivered before this function ultimately returns.
|
||||
*
|
||||
* @see zot_import()
|
||||
*
|
||||
* @param array $arr
|
||||
* decrypted and json decoded notify packet from remote site
|
||||
* @return array from zot_import()
|
||||
* @see zot_import()
|
||||
*
|
||||
*/
|
||||
|
||||
static function fetch($arr,$hub = null) {
|
||||
public static function fetch($arr, $hub = null)
|
||||
{
|
||||
|
||||
logger('zot_fetch: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG);
|
||||
|
||||
|
@ -1239,7 +1232,8 @@ class Libzot {
|
|||
* * [2] => \e string $address
|
||||
*/
|
||||
|
||||
static function import($arr,$hub = null) {
|
||||
public static function import($arr, $hub = null)
|
||||
{
|
||||
|
||||
$env = $arr;
|
||||
$private = false;
|
||||
|
@ -1286,8 +1280,7 @@ class Libzot {
|
|||
|
||||
if (is_array($AS->obj)) {
|
||||
$arr = Activity::decode_note($AS);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr = [];
|
||||
}
|
||||
|
||||
|
@ -1347,8 +1340,7 @@ class Libzot {
|
|||
$deliveries = ids_to_array($r, 'hash');
|
||||
|
||||
// We found somebody on this site that's in the recipient list.
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
logger('public post');
|
||||
|
||||
|
@ -1397,8 +1389,7 @@ class Libzot {
|
|||
// in individual delivery, change owner if needed
|
||||
if ($s) {
|
||||
$arr['owner_xchan'] = $s[0]['hubloc_hash'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['owner_xchan'] = $env['sender'];
|
||||
}
|
||||
|
||||
|
@ -1416,13 +1407,11 @@ class Libzot {
|
|||
$comments_closed_at = datetime_convert('UTC', 'UTC', substr($p, 6));
|
||||
if ($comments_closed_at === $arr['created']) {
|
||||
$arr['item_nocomment'] = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['comments_closed'] = $comments_closed_at;
|
||||
$arr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy']));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['comment_policy'] = $AS->obj['commentPolicy'];
|
||||
}
|
||||
}
|
||||
|
@ -1439,8 +1428,7 @@ class Libzot {
|
|||
|
||||
if ((!$s) || (in_array($s[0]['site_project'], ['', 'osada']))) {
|
||||
$arr['comment_policy'] = 'authenticated';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['comment_policy'] = 'contacts';
|
||||
}
|
||||
}
|
||||
|
@ -1459,8 +1447,7 @@ class Libzot {
|
|||
$relay = (($env['type'] === 'response') ? true : false);
|
||||
|
||||
$result = self::process_delivery($env['sender'], $AS, $arr, $deliveries, $relay, false, $message_request);
|
||||
}
|
||||
elseif ($env['type'] === 'sync') {
|
||||
} elseif ($env['type'] === 'sync') {
|
||||
|
||||
$arr = json_decode($data, true);
|
||||
|
||||
|
@ -1469,8 +1456,7 @@ class Libzot {
|
|||
|
||||
if ($env['encoding'] === 'red') {
|
||||
$result = Libsync::process_channel_sync_delivery($env['sender'], $arr, $deliveries);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('unsupported sync packet encoding ignored.');
|
||||
}
|
||||
}
|
||||
|
@ -1482,7 +1468,8 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
static function is_top_level($env,$act) {
|
||||
public static function is_top_level($env, $act)
|
||||
{
|
||||
if ($env['encoding'] === 'zot' && array_key_exists('flags', $env) && in_array('thread_parent', $env['flags'])) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1499,7 +1486,8 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
static function find_parent($env,$act) {
|
||||
public static function find_parent($env, $act)
|
||||
{
|
||||
if ($act) {
|
||||
if (in_array($act->type, ['Like', 'Dislike']) && is_array($act->obj)) {
|
||||
return $act->obj['id'];
|
||||
|
@ -1528,7 +1516,8 @@ class Libzot {
|
|||
* @return NULL|array
|
||||
*/
|
||||
|
||||
static function public_recips($msg, $act) {
|
||||
public static function public_recips($msg, $act)
|
||||
{
|
||||
|
||||
$check_mentions = false;
|
||||
$include_sys = false;
|
||||
|
@ -1544,8 +1533,7 @@ class Libzot {
|
|||
if (self::is_top_level($msg, $act)) {
|
||||
$check_mentions = true;
|
||||
}
|
||||
}
|
||||
elseif ($msg['type'] === 'mail') {
|
||||
} elseif ($msg['type'] === 'mail') {
|
||||
$perm = 'post_mail';
|
||||
}
|
||||
|
||||
|
@ -1626,8 +1614,7 @@ class Libzot {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// This is a comment. We need to find any parent with ITEM_UPLINK set. But in fact, let's just return
|
||||
// everybody that stored a copy of the parent. This way we know we're covered. We'll check the
|
||||
// comment permissions when we deliver them.
|
||||
|
@ -1671,7 +1658,8 @@ class Libzot {
|
|||
* @return array
|
||||
*/
|
||||
|
||||
static function process_delivery($sender, $act, $msg_arr, $deliveries, $relay, $public = false, $request = false) {
|
||||
public static function process_delivery($sender, $act, $msg_arr, $deliveries, $relay, $public = false, $request = false)
|
||||
{
|
||||
|
||||
$result = [];
|
||||
|
||||
|
@ -1752,8 +1740,7 @@ class Libzot {
|
|||
if ($o) {
|
||||
$act->obj = $o;
|
||||
$arr = array_merge(Activity::decode_note($act), $arr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('Incomplete or corrupt activity');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
|
@ -1832,8 +1819,7 @@ class Libzot {
|
|||
|
||||
if ($arr['owner_xchan'] == $d) {
|
||||
$arr['item_wall'] = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['item_wall'] = 0;
|
||||
}
|
||||
|
||||
|
@ -1872,8 +1858,7 @@ class Libzot {
|
|||
if ((!$allowed) && $permit_mentions) {
|
||||
if ($parent && $parent[0]['owner_xchan'] === $channel['channel_hash']) {
|
||||
$allowed = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$allowed = true;
|
||||
}
|
||||
}
|
||||
|
@ -1881,8 +1866,7 @@ class Libzot {
|
|||
$allowed = false;
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($permit_mentions) {
|
||||
} elseif ($permit_mentions) {
|
||||
$allowed = true;
|
||||
}
|
||||
}
|
||||
|
@ -1904,8 +1888,7 @@ class Libzot {
|
|||
if (get_pconfig($channel['channel_id'], 'system', 'hyperdrive', true)) {
|
||||
$allowed = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$allowed = true;
|
||||
}
|
||||
|
||||
|
@ -1980,8 +1963,7 @@ class Libzot {
|
|||
$arr['obj_type'] = 'Answer';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// We don't seem to have a copy of this conversation or at least the parent
|
||||
// - so request a copy of the entire conversation to date.
|
||||
|
@ -2014,12 +1996,10 @@ class Libzot {
|
|||
if (!$found_report) {
|
||||
$DR->update('conversation fetch failed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('conversation fetch failed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('comment parent not found');
|
||||
}
|
||||
$result[] = $DR->get();
|
||||
|
@ -2037,8 +2017,7 @@ class Libzot {
|
|||
// so just set the owner and route accordingly.
|
||||
$arr['route'] = $r[0]['route'];
|
||||
$arr['owner_xchan'] = $r[0]['owner_xchan'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// going downstream check that we have the same upstream provider that
|
||||
// sent it to us originally. Ignore it if it came from another source
|
||||
|
@ -2051,8 +2030,7 @@ class Libzot {
|
|||
if ($routes) {
|
||||
$last_hop = array_pop($existing_route);
|
||||
$last_prior_route = implode(',', $existing_route);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$last_hop = '';
|
||||
$last_prior_route = '';
|
||||
}
|
||||
|
@ -2126,8 +2104,7 @@ class Libzot {
|
|||
$result[] = $DR->get();
|
||||
|
||||
continue;
|
||||
}
|
||||
// Maybe it has been edited?
|
||||
} // Maybe it has been edited?
|
||||
elseif ($arr['edited'] > $r[0]['edited']) {
|
||||
$arr['id'] = $r[0]['id'];
|
||||
$arr['uid'] = $channel['channel_id'];
|
||||
|
@ -2138,13 +2115,11 @@ class Libzot {
|
|||
if (!$relay) {
|
||||
add_source_route($item_id, $sender);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('update ignored');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('update ignored');
|
||||
$result[] = $DR->get();
|
||||
|
||||
|
@ -2154,8 +2129,7 @@ class Libzot {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['aid'] = $channel['channel_account_id'];
|
||||
$arr['uid'] = $channel['channel_id'];
|
||||
|
||||
|
@ -2220,8 +2194,7 @@ class Libzot {
|
|||
}
|
||||
$DR->update(($item_id) ? 'posted' : 'storage failed: ' . $item_result['message']);
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$DR->update('post ignored');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
|
@ -2252,7 +2225,8 @@ class Libzot {
|
|||
return $result;
|
||||
}
|
||||
|
||||
static public function hyperdrive_enabled($channel,$item) {
|
||||
public static function hyperdrive_enabled($channel, $item)
|
||||
{
|
||||
|
||||
if (get_pconfig($channel['channel_id'], 'system', 'hyperdrive', true)) {
|
||||
return true;
|
||||
|
@ -2260,7 +2234,8 @@ class Libzot {
|
|||
return false;
|
||||
}
|
||||
|
||||
static public function fetch_conversation($channel,$mid) {
|
||||
public static function fetch_conversation($channel, $mid)
|
||||
{
|
||||
|
||||
// Use Zotfinger to create a signed request
|
||||
|
||||
|
@ -2346,8 +2321,7 @@ class Libzot {
|
|||
|
||||
if ($signer) {
|
||||
$arr['owner_xchan'] = $signer[0]['hubloc_hash'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arr['owner_xchan'] = $a['signature']['signer'];
|
||||
}
|
||||
|
||||
|
@ -2384,7 +2358,8 @@ class Libzot {
|
|||
* @param int $uid
|
||||
*/
|
||||
|
||||
static function remove_community_tag($sender, $arr, $uid) {
|
||||
public static function remove_community_tag($sender, $arr, $uid)
|
||||
{
|
||||
|
||||
if (!(activity_match($arr['verb'], ACTIVITY_TAG) && ($arr['obj_type'] == ACTIVITY_OBJ_TAGTERM)))
|
||||
return;
|
||||
|
@ -2448,16 +2423,17 @@ class Libzot {
|
|||
/**
|
||||
* @brief Updates an imported item.
|
||||
*
|
||||
* @see item_store_update()
|
||||
*
|
||||
* @param array $sender
|
||||
* @param array $item
|
||||
* @param array $orig
|
||||
* @param int $uid
|
||||
* @param boolean $tag_delivery
|
||||
* @see item_store_update()
|
||||
*
|
||||
*/
|
||||
|
||||
static function update_imported_item($sender, $item, $orig, $uid, $tag_delivery) {
|
||||
public static function update_imported_item($sender, $item, $orig, $uid, $tag_delivery)
|
||||
{
|
||||
|
||||
// If this is a comment being updated, remove any privacy information
|
||||
// so that item_store_update will set it from the original.
|
||||
|
@ -2493,8 +2469,7 @@ class Libzot {
|
|||
|
||||
if (!$x['item_id']) {
|
||||
logger('update_imported_item: failed: ' . $x['message']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('update_imported_item');
|
||||
}
|
||||
|
||||
|
@ -2512,7 +2487,8 @@ class Libzot {
|
|||
* @return boolean|int post_id
|
||||
*/
|
||||
|
||||
static function delete_imported_item($sender, $act, $item, $uid, $relay) {
|
||||
public static function delete_imported_item($sender, $act, $item, $uid, $relay)
|
||||
{
|
||||
|
||||
logger('invoked', LOGGER_DEBUG);
|
||||
|
||||
|
@ -2523,8 +2499,7 @@ class Libzot {
|
|||
if ($item['verb'] === 'Tombstone') {
|
||||
// The id of the deleted thing is the item mid (activity id)
|
||||
$mid = $item['mid'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// The id is the object id if the type is Undo or Delete
|
||||
$mid = ((is_array($act->obj)) ? $act->obj['id'] : $act->obj);
|
||||
}
|
||||
|
@ -2548,8 +2523,7 @@ class Libzot {
|
|||
|
||||
$post_id = $stored['id'];
|
||||
$item_found = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// this will fail with an ownership issue, so explain the real reason
|
||||
logger('delete received for non-existent item or not owned by sender - ignoring.');
|
||||
|
||||
|
@ -2571,8 +2545,7 @@ class Libzot {
|
|||
dbesc($stored['resource_id']),
|
||||
intval($uid)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('delete linked event: not owner');
|
||||
return;
|
||||
}
|
||||
|
@ -2598,8 +2571,7 @@ class Libzot {
|
|||
intval($stored['uid'])
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($stored['id'] !== $stored['parent']) {
|
||||
q("update item set commented = '%s', changed = '%s' where id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
|
@ -2623,14 +2595,15 @@ class Libzot {
|
|||
/**
|
||||
* @brief Processes delivery of profile.
|
||||
*
|
||||
* @see import_directory_profile()
|
||||
* @param array $sender an associative array
|
||||
* * \e string \b hash a xchan_hash
|
||||
* @param array $arr
|
||||
* @param array $deliveries (unused)
|
||||
* @see import_directory_profile()
|
||||
*/
|
||||
|
||||
static function process_profile_delivery($sender, $arr, $deliveries) {
|
||||
public static function process_profile_delivery($sender, $arr, $deliveries)
|
||||
{
|
||||
|
||||
logger('process_profile_delivery', LOGGER_DEBUG);
|
||||
|
||||
|
@ -2651,7 +2624,8 @@ class Libzot {
|
|||
* @param array $arr
|
||||
* @param array $deliveries (unused) deliveries is irrelevant
|
||||
*/
|
||||
static function process_location_delivery($sender, $arr, $deliveries) {
|
||||
public static function process_location_delivery($sender, $arr, $deliveries)
|
||||
{
|
||||
|
||||
// deliveries is irrelevant
|
||||
logger('process_location_delivery', LOGGER_DEBUG);
|
||||
|
@ -2693,7 +2667,8 @@ class Libzot {
|
|||
* @param array $locations
|
||||
*/
|
||||
|
||||
static function check_location_move($sender_hash, $locations) {
|
||||
public static function check_location_move($sender_hash, $locations)
|
||||
{
|
||||
|
||||
if (!$locations) {
|
||||
return;
|
||||
|
@ -2737,17 +2712,17 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns an array with all known distinct hubs for this channel.
|
||||
*
|
||||
* @see self::get_hublocs()
|
||||
* @param array $channel an associative array which must contain
|
||||
* * \e string \b channel_hash the hash of the channel
|
||||
* @return array an array with associative arrays
|
||||
* @see self::get_hublocs()
|
||||
*/
|
||||
|
||||
static function encode_locations($channel) {
|
||||
public static function encode_locations($channel)
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
$x = self::get_hublocs($channel['channel_hash']);
|
||||
|
@ -2789,7 +2764,8 @@ class Libzot {
|
|||
* @return boolean true if updated or inserted
|
||||
*/
|
||||
|
||||
static function import_site($arr) {
|
||||
public static function import_site($arr)
|
||||
{
|
||||
|
||||
if ((!is_array($arr)) || (!$arr['url']) || (!$arr['site_sig'])) {
|
||||
return false;
|
||||
|
@ -2882,11 +2858,9 @@ class Libzot {
|
|||
}
|
||||
if (array_key_exists('logo', $arr) && $arr['logo']) {
|
||||
$site_logo = $arr['logo'];
|
||||
}
|
||||
elseif (file_exists('images/' . strtolower($site_project) . '.png')) {
|
||||
} elseif (file_exists('images/' . strtolower($site_project) . '.png')) {
|
||||
$site_logo = z_root() . '/images/' . strtolower($site_project) . '.png';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$site_logo = z_root() . '/images/default_profile_photos/red_koala_trans/300.png';
|
||||
}
|
||||
|
||||
|
@ -2936,16 +2910,14 @@ class Libzot {
|
|||
if (!$r) {
|
||||
logger('Update failed. ' . print_r($arr, true));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// update the timestamp to indicate we communicated with this site
|
||||
q("update site set site_dead = 0, site_update = '%s' where site_url = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$update = true;
|
||||
|
||||
$r = site_store_lowlevel(
|
||||
|
@ -2977,13 +2949,14 @@ class Libzot {
|
|||
/**
|
||||
* @brief Returns path to /rpost
|
||||
*
|
||||
* @todo We probably should make rpost discoverable.
|
||||
*
|
||||
* @param array $observer
|
||||
* * \e string \b xchan_url
|
||||
* @return string
|
||||
* @todo We probably should make rpost discoverable.
|
||||
*
|
||||
*/
|
||||
static function get_rpost_path($observer) {
|
||||
public static function get_rpost_path($observer)
|
||||
{
|
||||
if (!$observer) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
@ -3000,7 +2973,8 @@ class Libzot {
|
|||
* @return boolean|string return false or a hash
|
||||
*/
|
||||
|
||||
static function import_author_zot($x) {
|
||||
public static function import_author_zot($x)
|
||||
{
|
||||
|
||||
// Check that we have both a hubloc and xchan record - as occasionally storage calls will fail and
|
||||
// we may only end up with one; which results in posts with no author name or photo and are a bit
|
||||
|
@ -3061,8 +3035,7 @@ class Libzot {
|
|||
if ($r) {
|
||||
logger('found another site that is not dead: ' . $r[0]['hubloc_id_url'], LOGGER_DEBUG, LOG_INFO);
|
||||
$desturl = $r[0]['hubloc_id_url'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
@ -3075,7 +3048,8 @@ class Libzot {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function zotinfo($arr) {
|
||||
public static function zotinfo($arr)
|
||||
{
|
||||
|
||||
$ret = [];
|
||||
|
||||
|
@ -3096,8 +3070,7 @@ class Libzot {
|
|||
);
|
||||
if ($t) {
|
||||
$ztarget_hash = $t[0]['hubloc_hash'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// should probably perform discovery of the requestor (target) but if they actually had
|
||||
// permissions we would know about them and we only want to know who they are to
|
||||
|
@ -3114,23 +3087,20 @@ class Libzot {
|
|||
where channel_hash = '%s' limit 1",
|
||||
dbesc($zhash)
|
||||
);
|
||||
}
|
||||
elseif (strlen($zguid) && strlen($zguid_sig)) {
|
||||
} elseif (strlen($zguid) && strlen($zguid_sig)) {
|
||||
$r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
|
||||
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
|
||||
dbesc($zguid),
|
||||
dbesc($zguid_sig)
|
||||
);
|
||||
}
|
||||
elseif (strlen($zaddr)) {
|
||||
} elseif (strlen($zaddr)) {
|
||||
if (strpos($zaddr, '[system]') === false) { /* normal address lookup */
|
||||
$r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
|
||||
where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
|
||||
dbesc($zaddr),
|
||||
dbesc($zaddr)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
/**
|
||||
* The special address '[system]' will return a system channel if one has been defined,
|
||||
|
@ -3150,8 +3120,7 @@ class Libzot {
|
|||
where channel_removed = 0 order by channel_id limit 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$ret['message'] = 'Invalid request';
|
||||
return ($ret);
|
||||
}
|
||||
|
@ -3346,7 +3315,8 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
static function site_info($force = false) {
|
||||
public static function site_info($force = false)
|
||||
{
|
||||
|
||||
$signing_key = get_config('system', 'prvkey');
|
||||
$sig_method = get_config('system', 'signature_algorithm', 'sha256');
|
||||
|
@ -3367,11 +3337,9 @@ class Libzot {
|
|||
|
||||
if ($dirmode == DIRECTORY_MODE_PRIMARY) {
|
||||
$ret['site']['directory_mode'] = 'primary';
|
||||
}
|
||||
elseif ($dirmode == DIRECTORY_MODE_SECONDARY) {
|
||||
} elseif ($dirmode == DIRECTORY_MODE_SECONDARY) {
|
||||
$ret['site']['directory_mode'] = 'secondary';
|
||||
}
|
||||
elseif ($dirmode == DIRECTORY_MODE_STANDALONE) {
|
||||
} elseif ($dirmode == DIRECTORY_MODE_STANDALONE) {
|
||||
$ret['site']['directory_mode'] = 'standalone';
|
||||
}
|
||||
if ($dirmode != DIRECTORY_MODE_NORMAL) {
|
||||
|
@ -3450,7 +3418,8 @@ class Libzot {
|
|||
* @return string hubloc_url
|
||||
*/
|
||||
|
||||
static function update_hub_connected($hub, $site_id = '') {
|
||||
public static function update_hub_connected($hub, $site_id = '')
|
||||
{
|
||||
|
||||
if ($site_id) {
|
||||
|
||||
|
@ -3466,8 +3435,7 @@ class Libzot {
|
|||
dbesc($site_id)
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$site_id = $hub['hubloc_site_id'];
|
||||
}
|
||||
|
||||
|
@ -3514,7 +3482,8 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
static function sign($data,$key,$alg = 'sha256') {
|
||||
public static function sign($data, $key, $alg = 'sha256')
|
||||
{
|
||||
if (!$key) {
|
||||
return 'no key';
|
||||
}
|
||||
|
@ -3523,7 +3492,8 @@ class Libzot {
|
|||
return $alg . '.' . base64url_encode($sig);
|
||||
}
|
||||
|
||||
static function verify($data,$sig,$key) {
|
||||
public static function verify($data, $sig, $key)
|
||||
{
|
||||
|
||||
$verify = 0;
|
||||
|
||||
|
@ -3546,15 +3516,16 @@ class Libzot {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static function is_zot_request() {
|
||||
public static function is_zot_request()
|
||||
{
|
||||
|
||||
$x = getBestSupportedMimeType(['application/x-zot+json', 'application/x-nomad']);
|
||||
return (($x) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
static public function zot_record_preferred($arr, $check = 'hubloc_network') {
|
||||
public static function zot_record_preferred($arr, $check = 'hubloc_network')
|
||||
{
|
||||
|
||||
if (!$arr) {
|
||||
return $arr;
|
||||
|
@ -3568,7 +3539,8 @@ class Libzot {
|
|||
return $arr[0];
|
||||
}
|
||||
|
||||
static function update_cached_hubloc($hubloc) {
|
||||
public static function update_cached_hubloc($hubloc)
|
||||
{
|
||||
if ($hubloc['hubloc_updated'] > datetime_convert('UTC', 'UTC', 'now - 1 week') || $hubloc['hubloc_url'] === z_root()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\Webfinger;
|
||||
use Zotlabs\Lib\Zotfinger;
|
||||
|
@ -9,7 +10,8 @@ use Zotlabs\Lib\Zotfinger;
|
|||
require_once('include/permissions.php');
|
||||
|
||||
|
||||
class Libzotdir {
|
||||
class Libzotdir
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
|
@ -18,7 +20,8 @@ class Libzotdir {
|
|||
* is if our directory has gone offline for any reason
|
||||
*/
|
||||
|
||||
static function check_upstream_directory() {
|
||||
public static function check_upstream_directory()
|
||||
{
|
||||
|
||||
$directory = get_config('system', 'directory_server');
|
||||
|
||||
|
@ -41,7 +44,8 @@ class Libzotdir {
|
|||
}
|
||||
|
||||
|
||||
static function get_directory_setting($observer, $setting) {
|
||||
public static function get_directory_setting($observer, $setting)
|
||||
{
|
||||
|
||||
|
||||
if ($observer)
|
||||
|
@ -65,7 +69,8 @@ class Libzotdir {
|
|||
/**
|
||||
* @brief Called by the directory_sort widget.
|
||||
*/
|
||||
static function dir_sort_links() {
|
||||
public static function dir_sort_links()
|
||||
{
|
||||
|
||||
$safe_mode = 1;
|
||||
|
||||
|
@ -133,7 +138,8 @@ class Libzotdir {
|
|||
* @param array $ud Entry from update table
|
||||
*/
|
||||
|
||||
static function update_directory_entry($ud) {
|
||||
public static function update_directory_entry($ud)
|
||||
{
|
||||
|
||||
logger('update_directory_entry: ' . print_r($ud, true), LOGGER_DATA);
|
||||
|
||||
|
@ -146,8 +152,7 @@ class Libzotdir {
|
|||
}
|
||||
if (is_array($zf) && array_path_exists('signature/signer', $zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
|
||||
$xc = Libzot::import_xchan($zf['data'], 0, $ud);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
q("update updates set ud_last = '%s' where ud_addr = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($ud['ud_addr'])
|
||||
|
@ -164,10 +169,11 @@ class Libzotdir {
|
|||
* directory and the local hub in this case is any kind of directory server.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param boolean $force
|
||||
* @param bool $force
|
||||
*/
|
||||
|
||||
static function local_dir_update($uid, $force) {
|
||||
public static function local_dir_update($uid, $force)
|
||||
{
|
||||
|
||||
|
||||
logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG);
|
||||
|
@ -232,8 +238,7 @@ class Libzotdir {
|
|||
|
||||
if (perm_is_allowed($uid, '', 'view_profile')) {
|
||||
self::import_directory_profile($hash, $arr['profile'], $address, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// they may have made it private
|
||||
$r = q("delete from xprof where xprof_hash = '%s'",
|
||||
dbesc($hash)
|
||||
|
@ -245,12 +250,11 @@ class Libzotdir {
|
|||
|
||||
}
|
||||
|
||||
$ud_hash = random_string() . '@' . \App::get_hostname();
|
||||
$ud_hash = random_string() . '@' . App::get_hostname();
|
||||
self::update_modtime($hash, $ud_hash, channel_reddress($p[0]), (($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Imports a directory profile.
|
||||
*
|
||||
|
@ -259,10 +263,11 @@ class Libzotdir {
|
|||
* @param string $addr
|
||||
* @param number $ud_flags (optional) UPDATE_FLAGS_UPDATED
|
||||
* @param number $suppress_update (optional) default 0
|
||||
* @return boolean $updated if something changed
|
||||
* @return bool $updated if something changed
|
||||
*/
|
||||
|
||||
static function import_directory_profile($hash, $profile, $addr, $ud_flags = UPDATE_FLAGS_UPDATED, $suppress_update = 0) {
|
||||
public static function import_directory_profile($hash, $profile, $addr, $ud_flags = UPDATE_FLAGS_UPDATED, $suppress_update = 0)
|
||||
{
|
||||
|
||||
logger('import_directory_profile', LOGGER_DEBUG);
|
||||
if (!$hash)
|
||||
|
@ -427,7 +432,8 @@ class Libzotdir {
|
|||
* @param array $keywords
|
||||
*/
|
||||
|
||||
static function import_directory_keywords($hash, $keywords) {
|
||||
public static function import_directory_keywords($hash, $keywords)
|
||||
{
|
||||
|
||||
$existing = [];
|
||||
$r = q("select * from xtag where xtag_hash = '%s' and xtag_flags = 0",
|
||||
|
@ -473,7 +479,8 @@ class Libzotdir {
|
|||
* @param int $flags (optional) default 0
|
||||
*/
|
||||
|
||||
static function update_modtime($hash, $guid, $addr, $flags = 0) {
|
||||
public static function update_modtime($hash, $guid, $addr, $flags = 0)
|
||||
{
|
||||
|
||||
$dirmode = intval(get_config('system', 'directory_mode'));
|
||||
|
||||
|
@ -488,8 +495,7 @@ class Libzotdir {
|
|||
intval($flags),
|
||||
dbesc($addr)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and (ud_flags & %d) = 0 ",
|
||||
intval(UPDATE_FLAGS_UPDATED),
|
||||
dbesc($addr),
|
||||
|
@ -499,8 +505,4 @@ class Libzotdir {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -18,7 +18,8 @@ require_once("include/html2bbcode.php");
|
|||
require_once("include/bbcode.php");
|
||||
|
||||
|
||||
class Markdown {
|
||||
class Markdown
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Convert Markdown to bbcode.
|
||||
|
@ -29,12 +30,13 @@ class Markdown {
|
|||
* and then clean up a few Diaspora specific constructs.
|
||||
*
|
||||
* @param string $s The message as Markdown
|
||||
* @param boolean $use_zrl default false
|
||||
* @param bool $use_zrl default false
|
||||
* @param array $options default empty
|
||||
* @return string The message converted to bbcode
|
||||
*/
|
||||
|
||||
static public function to_bbcode($s, $use_zrl = false, $options = []) {
|
||||
public static function to_bbcode($s, $use_zrl = false, $options = [])
|
||||
{
|
||||
|
||||
if (is_array($s)) {
|
||||
btlogger('markdown_to_bb called with array. ' . print_r($s, true), LOGGER_NORMAL, LOG_WARNING);
|
||||
|
@ -72,8 +74,7 @@ class Markdown {
|
|||
|
||||
if ($options && $options['preserve_lf']) {
|
||||
$s = str_replace(["\r", "\n"], ["", '<br>'], $s);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$s = str_replace("\r", "", $s);
|
||||
}
|
||||
|
||||
|
@ -88,8 +89,7 @@ class Markdown {
|
|||
$s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", ['\\Zotlabs\\Lib\\Markdown', 'use_zrl_cb_img_x'], $s);
|
||||
}
|
||||
$s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", ['\\Zotlabs\\Lib\\Markdown', 'use_zrl_cb_link'], $s);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]', $s);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,8 @@ class Markdown {
|
|||
return $s;
|
||||
}
|
||||
|
||||
static function use_zrl_cb_link($match) {
|
||||
public static function use_zrl_cb_link($match)
|
||||
{
|
||||
$res = '';
|
||||
$is_zid = is_matrix_url(trim($match[0]));
|
||||
|
||||
|
@ -117,7 +118,8 @@ class Markdown {
|
|||
return $res;
|
||||
}
|
||||
|
||||
static function use_zrl_cb_img($match) {
|
||||
public static function use_zrl_cb_img($match)
|
||||
{
|
||||
$res = '';
|
||||
$is_zid = is_matrix_url(trim($match[1]));
|
||||
|
||||
|
@ -129,7 +131,8 @@ class Markdown {
|
|||
return $res;
|
||||
}
|
||||
|
||||
static function use_zrl_cb_img_x($match) {
|
||||
public static function use_zrl_cb_img_x($match)
|
||||
{
|
||||
$res = '';
|
||||
$is_zid = is_matrix_url(trim($match[3]));
|
||||
|
||||
|
@ -148,7 +151,8 @@ class Markdown {
|
|||
* @return string
|
||||
*/
|
||||
|
||||
static public function from_bbcode_share($match) {
|
||||
public static function from_bbcode_share($match)
|
||||
{
|
||||
|
||||
$matches = [];
|
||||
$attributes = $match[1];
|
||||
|
@ -222,7 +226,8 @@ class Markdown {
|
|||
* @return string The message converted to Markdown
|
||||
*/
|
||||
|
||||
static public function from_bbcode($Text, $options = []) {
|
||||
public static function from_bbcode($Text, $options = [])
|
||||
{
|
||||
|
||||
/*
|
||||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||
|
@ -292,7 +297,8 @@ class Markdown {
|
|||
* @return string Markdown representation of the given HTML text, empty on error
|
||||
*/
|
||||
|
||||
static public function from_html($html,$options = []) {
|
||||
public static function from_html($html, $options = [])
|
||||
{
|
||||
$markdown = '';
|
||||
|
||||
if (!$options) {
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace Zotlabs\Lib;
|
|||
* $html = \Michelf\MarkdownExtra::DefaultTransform($markdown);
|
||||
* @endcode
|
||||
*/
|
||||
class MarkdownSoap {
|
||||
class MarkdownSoap
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -34,12 +35,14 @@ class MarkdownSoap {
|
|||
private $token;
|
||||
|
||||
|
||||
function __construct($s) {
|
||||
public function __construct($s)
|
||||
{
|
||||
$this->str = $s;
|
||||
$this->token = random_string(20);
|
||||
}
|
||||
|
||||
function clean() {
|
||||
public function clean()
|
||||
{
|
||||
|
||||
$x = $this->extract_code($this->str);
|
||||
|
||||
|
@ -55,13 +58,14 @@ class MarkdownSoap {
|
|||
/**
|
||||
* @brief Extracts code blocks and privately escapes them from processing.
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @see encode_code()
|
||||
* @see putback_code()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
*/
|
||||
function extract_code($s) {
|
||||
public function extract_code($s)
|
||||
{
|
||||
|
||||
$text = preg_replace_callback('{
|
||||
(?:\n\n|\A\n?)
|
||||
|
@ -78,45 +82,52 @@ class MarkdownSoap {
|
|||
return $text;
|
||||
}
|
||||
|
||||
function encode_code($matches) {
|
||||
public function encode_code($matches)
|
||||
{
|
||||
return $this->token . ';' . base64_encode($matches[0]) . ';';
|
||||
}
|
||||
|
||||
function decode_code($matches) {
|
||||
public function decode_code($matches)
|
||||
{
|
||||
return base64_decode($matches[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put back the code blocks.
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @see extract_code()
|
||||
* @see decode_code()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
*/
|
||||
function putback_code($s) {
|
||||
public function putback_code($s)
|
||||
{
|
||||
$text = preg_replace_callback('{' . $this->token . '\;(.*?)\;}xm', [$this, 'decode_code'], $s);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function purify($s) {
|
||||
public function purify($s)
|
||||
{
|
||||
$s = $this->protect_autolinks($s);
|
||||
$s = purify_html($s);
|
||||
$s = $this->unprotect_autolinks($s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function protect_autolinks($s) {
|
||||
public function protect_autolinks($s)
|
||||
{
|
||||
$s = preg_replace('/\<(https?\:\/\/)(.*?)\>/', '[$1$2]($1$2)', $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function unprotect_autolinks($s) {
|
||||
public function unprotect_autolinks($s)
|
||||
{
|
||||
return $s;
|
||||
}
|
||||
|
||||
function escape($s) {
|
||||
public function escape($s)
|
||||
{
|
||||
return htmlspecialchars($s, ENT_QUOTES, 'UTF-8', false);
|
||||
}
|
||||
|
||||
|
@ -126,7 +137,8 @@ class MarkdownSoap {
|
|||
* @param string $s
|
||||
* @return string
|
||||
*/
|
||||
static public function unescape($s) {
|
||||
public static function unescape($s)
|
||||
{
|
||||
return htmlspecialchars_decode($s, ENT_QUOTES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@ use App;
|
|||
use Zotlabs\Lib\PConfig;
|
||||
|
||||
|
||||
class MastAPI {
|
||||
class MastAPI
|
||||
{
|
||||
|
||||
static function format_channel($channel) {
|
||||
public static function format_channel($channel)
|
||||
{
|
||||
$p = q("select * from profile where uid = %d and is_default = 1",
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
|
@ -66,7 +68,8 @@ class MastAPI {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
static function format_site() {
|
||||
public static function format_site()
|
||||
{
|
||||
|
||||
$register = intval(get_config('system', 'register_policy'));
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Zotlabs\Lib;
|
|||
class MessageFilter {
|
||||
|
||||
|
||||
static public function evaluate($item,$incl,$excl) {
|
||||
public static function evaluate($item, $incl, $excl) {
|
||||
|
||||
require_once('include/html2plain.php');
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class Nodeinfo {
|
||||
|
||||
static public function fetch($url) {
|
||||
public static function fetch($url) {
|
||||
$href = EMPTY_STR;
|
||||
$m = parse_url($url);
|
||||
if ($m['scheme'] && $m['host']) {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
|
||||
/**
|
||||
* @brief Class for handling channel specific configurations.
|
||||
*
|
||||
|
@ -28,19 +30,19 @@ class PConfig {
|
|||
* The channel_id
|
||||
* @return void|false Nothing or false if $uid is null or false
|
||||
*/
|
||||
static public function Load($uid) {
|
||||
public static function Load($uid) {
|
||||
if(is_null($uid) || $uid === false)
|
||||
return false;
|
||||
|
||||
if(! is_array(\App::$config)) {
|
||||
if(! is_array(App::$config)) {
|
||||
btlogger('App::$config not an array');
|
||||
}
|
||||
|
||||
if(! array_key_exists($uid, \App::$config)) {
|
||||
\App::$config[$uid] = [];
|
||||
if(! array_key_exists($uid, App::$config)) {
|
||||
App::$config[$uid] = [];
|
||||
}
|
||||
|
||||
if(! is_array(\App::$config[$uid])) {
|
||||
if(! is_array(App::$config[$uid])) {
|
||||
btlogger('App::$config[$uid] not an array: ' . $uid);
|
||||
}
|
||||
|
||||
|
@ -52,11 +54,11 @@ class PConfig {
|
|||
foreach($r as $rr) {
|
||||
$k = $rr['k'];
|
||||
$c = $rr['cat'];
|
||||
if(! array_key_exists($c, \App::$config[$uid])) {
|
||||
\App::$config[$uid][$c] = [];
|
||||
\App::$config[$uid][$c]['config_loaded'] = true;
|
||||
if(! array_key_exists($c, App::$config[$uid])) {
|
||||
App::$config[$uid][$c] = [];
|
||||
App::$config[$uid][$c]['config_loaded'] = true;
|
||||
}
|
||||
\App::$config[$uid][$c][$k] = $rr['v'];
|
||||
App::$config[$uid][$c][$k] = $rr['v'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,18 +82,18 @@ class PConfig {
|
|||
* Default value to return if key does not exist
|
||||
* @return mixed Stored value or false if it does not exist
|
||||
*/
|
||||
static public function Get($uid, $family, $key, $default = false) {
|
||||
public static function Get($uid, $family, $key, $default = false) {
|
||||
|
||||
if(is_null($uid) || $uid === false)
|
||||
return $default;
|
||||
|
||||
if(! array_key_exists($uid, \App::$config))
|
||||
if(! array_key_exists($uid, App::$config))
|
||||
self::Load($uid);
|
||||
|
||||
if((! array_key_exists($family, \App::$config[$uid])) || (! array_key_exists($key, \App::$config[$uid][$family])))
|
||||
if((! array_key_exists($family, App::$config[$uid])) || (! array_key_exists($key, App::$config[$uid][$family])))
|
||||
return $default;
|
||||
|
||||
return unserialise(\App::$config[$uid][$family][$key]);
|
||||
return unserialise(App::$config[$uid][$family][$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +112,7 @@ class PConfig {
|
|||
* The value to store
|
||||
* @return mixed Stored $value or false
|
||||
*/
|
||||
static public function Set($uid, $family, $key, $value) {
|
||||
public static function Set($uid, $family, $key, $value) {
|
||||
|
||||
// this catches subtle errors where this function has been called
|
||||
// with local_channel() when not logged in (which returns false)
|
||||
|
@ -128,10 +130,10 @@ class PConfig {
|
|||
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
|
||||
|
||||
if(self::Get($uid, $family, $key) === false) {
|
||||
if(! array_key_exists($uid, \App::$config))
|
||||
\App::$config[$uid] = [];
|
||||
if(! array_key_exists($family, \App::$config[$uid]))
|
||||
\App::$config[$uid][$family] = [];
|
||||
if(! array_key_exists($uid, App::$config))
|
||||
App::$config[$uid] = [];
|
||||
if(! array_key_exists($family, App::$config[$uid]))
|
||||
App::$config[$uid][$family] = [];
|
||||
|
||||
$ret = q("INSERT INTO pconfig ( uid, cat, k, v ) VALUES ( %d, '%s', '%s', '%s' ) ",
|
||||
intval($uid),
|
||||
|
@ -154,13 +156,13 @@ class PConfig {
|
|||
// set in the life of this page. We need this to
|
||||
// synchronise channel clones.
|
||||
|
||||
if(! array_key_exists('transient', \App::$config[$uid]))
|
||||
\App::$config[$uid]['transient'] = [];
|
||||
if(! array_key_exists($family, \App::$config[$uid]['transient']))
|
||||
\App::$config[$uid]['transient'][$family] = [];
|
||||
if(! array_key_exists('transient', App::$config[$uid]))
|
||||
App::$config[$uid]['transient'] = [];
|
||||
if(! array_key_exists($family, App::$config[$uid]['transient']))
|
||||
App::$config[$uid]['transient'][$family] = [];
|
||||
|
||||
\App::$config[$uid][$family][$key] = $value;
|
||||
\App::$config[$uid]['transient'][$family][$key] = $value;
|
||||
App::$config[$uid][$family][$key] = $value;
|
||||
App::$config[$uid]['transient'][$family][$key] = $value;
|
||||
|
||||
if($ret)
|
||||
return $value;
|
||||
|
@ -183,18 +185,18 @@ class PConfig {
|
|||
* The configuration key to delete
|
||||
* @return mixed
|
||||
*/
|
||||
static public function Delete($uid, $family, $key) {
|
||||
public static function Delete($uid, $family, $key) {
|
||||
|
||||
if(is_null($uid) || $uid === false)
|
||||
return false;
|
||||
|
||||
$ret = false;
|
||||
|
||||
if(array_key_exists($uid,\App::$config)
|
||||
&& is_array(\App::$config['uid'])
|
||||
&& array_key_exists($family,\App::$config['uid'])
|
||||
&& array_key_exists($key, \App::$config[$uid][$family]))
|
||||
unset(\App::$config[$uid][$family][$key]);
|
||||
if(array_key_exists($uid, App::$config)
|
||||
&& is_array(App::$config['uid'])
|
||||
&& array_key_exists($family, App::$config['uid'])
|
||||
&& array_key_exists($key, App::$config[$uid][$family]))
|
||||
unset(App::$config[$uid][$family][$key]);
|
||||
|
||||
$ret = q("DELETE FROM pconfig WHERE uid = %d AND cat = '%s' AND k = '%s'",
|
||||
intval($uid),
|
||||
|
|
|
@ -157,7 +157,7 @@ class Permcat {
|
|||
return $permcats;
|
||||
}
|
||||
|
||||
static public function find_permcat($arr, $name) {
|
||||
public static function find_permcat($arr, $name) {
|
||||
if((! $arr) || (! $name))
|
||||
return false;
|
||||
|
||||
|
@ -166,11 +166,11 @@ class Permcat {
|
|||
return $p['value'];
|
||||
}
|
||||
|
||||
static public function update($channel_id, $name, $permarr) {
|
||||
public static function update($channel_id, $name, $permarr) {
|
||||
PConfig::Set($channel_id, 'permcat', $name, $permarr);
|
||||
}
|
||||
|
||||
static public function delete($channel_id, $name) {
|
||||
public static function delete($channel_id, $name) {
|
||||
PConfig::Delete($channel_id, 'permcat', $name);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Access\PermissionLimits;
|
||||
use Zotlabs\Access\Permissions;
|
||||
|
||||
require_once("include/permissions.php");
|
||||
require_once("include/language.php");
|
||||
require_once("include/text.php");
|
||||
|
@ -51,7 +55,7 @@ class PermissionDescription {
|
|||
* default permission. You should pass one of the constants from boot.php - PERMS_PUBLIC,
|
||||
* PERMS_NETWORK etc.
|
||||
*
|
||||
* @param integer $perm - a single enumerated constant permission - PERMS_PUBLIC, PERMS_NETWORK etc.
|
||||
* @param int $perm - a single enumerated constant permission - PERMS_PUBLIC, PERMS_NETWORK etc.
|
||||
* @return a new instance of PermissionDescription
|
||||
*/
|
||||
public static function fromStandalonePermission($perm) {
|
||||
|
@ -80,11 +84,11 @@ class PermissionDescription {
|
|||
|
||||
$result = null;
|
||||
|
||||
$global_perms = \Zotlabs\Access\Permissions::Perms();
|
||||
$global_perms = Permissions::Perms();
|
||||
|
||||
if(array_key_exists($permname, $global_perms)) {
|
||||
|
||||
$channelPerm = \Zotlabs\Access\PermissionLimits::Get(\App::$channel['channel_id'], $permname);
|
||||
$channelPerm = PermissionLimits::Get(App::$channel['channel_id'], $permname);
|
||||
|
||||
$result = new PermissionDescription('', $channelPerm);
|
||||
} else {
|
||||
|
@ -107,7 +111,7 @@ class PermissionDescription {
|
|||
case 0: return t('Only me');
|
||||
case PERMS_PUBLIC: return t('Public');
|
||||
case PERMS_NETWORK: return t('Anybody in the $Projectname network');
|
||||
case PERMS_SITE: return sprintf(t('Any account on %s'), \App::get_hostname());
|
||||
case PERMS_SITE: return sprintf(t('Any account on %s'), App::get_hostname());
|
||||
case PERMS_CONTACTS: return t('Any of my connections');
|
||||
case PERMS_SPECIFIC: return t('Only connections I specifically allow');
|
||||
case PERMS_AUTHED: return t('Anybody authenticated (could include visitors from other networks)');
|
||||
|
|
|
@ -6,10 +6,14 @@ use Zotlabs\Lib\Libzot;
|
|||
use Zotlabs\Web\HTTPSig;
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\ActivityStreams;
|
||||
use Zotlabs\Zot6\Receiver;
|
||||
use Zotlabs\Zot6\Zot6Handler;
|
||||
|
||||
class Queue {
|
||||
class Queue
|
||||
{
|
||||
|
||||
static function update($id, $add_priority = 0) {
|
||||
public static function update($id, $add_priority = 0)
|
||||
{
|
||||
|
||||
logger('queue: requeue item ' . $id, LOGGER_DEBUG);
|
||||
|
||||
|
@ -38,7 +42,6 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
|
||||
$y = q("select min(outq_created) as earliest from outq where outq_posturl = '%s'",
|
||||
dbesc($x[0]['outq_posturl'])
|
||||
);
|
||||
|
@ -70,8 +73,7 @@ class Queue {
|
|||
|
||||
if (($might_be_down) || ($since < datetime_convert('UTC', 'UTC', 'now - 12 hour'))) {
|
||||
$next = datetime_convert('UTC', 'UTC', 'now + 1 hour');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$next = datetime_convert('UTC', 'UTC', 'now + ' . intval($add_priority) . ' minutes');
|
||||
}
|
||||
|
||||
|
@ -88,7 +90,8 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
static function remove($id,$channel_id = 0) {
|
||||
public static function remove($id, $channel_id = 0)
|
||||
{
|
||||
logger('queue: remove queue item ' . $id, LOGGER_DEBUG);
|
||||
$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : '');
|
||||
|
||||
|
@ -98,7 +101,8 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
static function remove_by_posturl($posturl) {
|
||||
public static function remove_by_posturl($posturl)
|
||||
{
|
||||
logger('queue: remove queue posturl ' . $posturl, LOGGER_DEBUG);
|
||||
|
||||
q("DELETE FROM outq WHERE outq_posturl = '%s' ",
|
||||
|
@ -107,8 +111,8 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static function set_delivered($id,$channel = 0) {
|
||||
public static function set_delivered($id, $channel = 0)
|
||||
{
|
||||
logger('queue: set delivered ' . $id, LOGGER_DEBUG);
|
||||
$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : '');
|
||||
|
||||
|
@ -123,8 +127,8 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static function insert($arr) {
|
||||
public static function insert($arr)
|
||||
{
|
||||
|
||||
logger('insert: ' . print_r($arr, true), LOGGER_DATA);
|
||||
|
||||
|
@ -157,8 +161,8 @@ class Queue {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static function deliver($outq, $immediate = false) {
|
||||
public static function deliver($outq, $immediate = false)
|
||||
{
|
||||
|
||||
$base = null;
|
||||
$h = parse_url($outq['outq_posturl']);
|
||||
|
@ -190,8 +194,7 @@ class Queue {
|
|||
logger('immediate delivery deferred for site ' . $base);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// zot sites should all have a site record, unless they've been dead for as long as
|
||||
// your site has existed. Since we don't know for sure what these sites are,
|
||||
|
@ -253,8 +256,7 @@ class Queue {
|
|||
do_delivery($piled_up, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('deliver: queue post returned ' . $result['return_code']
|
||||
. ' from ' . $outq['outq_posturl'], LOGGER_DEBUG);
|
||||
self::update($outq['outq_hash'], 10);
|
||||
|
@ -315,8 +317,7 @@ class Queue {
|
|||
do_delivery($piled_up, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('deliver: queue fetch failed' . ' from ' . $outq['outq_posturl'], LOGGER_DEBUG);
|
||||
self::update($outq['outq_hash'], 10);
|
||||
}
|
||||
|
@ -386,16 +387,14 @@ class Queue {
|
|||
do_delivery($piled_up, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($result['return_code'] >= 300) {
|
||||
q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s'",
|
||||
dbesc('delivery rejected' . ' ' . $result['return_code']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($outq['outq_hash'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dr = q("select * from dreport where dreport_queue = '%s'",
|
||||
dbesc($outq['outq_hash'])
|
||||
);
|
||||
|
@ -420,7 +419,7 @@ class Queue {
|
|||
|
||||
if ($outq['outq_posturl'] === z_root() . '/zot') {
|
||||
// local delivery
|
||||
$zot = new \Zotlabs\Zot6\Receiver(new \Zotlabs\Zot6\Zot6Handler(),$outq['outq_notify']);
|
||||
$zot = new Receiver(new Zot6Handler(), $outq['outq_notify']);
|
||||
$result = $zot->run();
|
||||
logger('returned_json: ' . json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DATA);
|
||||
logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']);
|
||||
|
@ -441,8 +440,7 @@ class Queue {
|
|||
do_delivery($piled_up, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger('remote');
|
||||
$channel = null;
|
||||
|
||||
|
@ -468,8 +466,7 @@ class Queue {
|
|||
if ($result['success']) {
|
||||
logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']);
|
||||
Libzot::process_response($outq['outq_posturl'], $result, $outq);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dr = q("select * from dreport where dreport_queue = '%s'",
|
||||
dbesc($outq['outq_hash'])
|
||||
);
|
||||
|
|
|
@ -10,19 +10,19 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class SConfig {
|
||||
|
||||
static public function Load($server_id) {
|
||||
public static function Load($server_id) {
|
||||
return XConfig::Load('s_' . $server_id);
|
||||
}
|
||||
|
||||
static public function Get($server_id,$family,$key,$default = false) {
|
||||
public static function Get($server_id, $family, $key, $default = false) {
|
||||
return XConfig::Get('s_' . $server_id,$family,$key, $default);
|
||||
}
|
||||
|
||||
static public function Set($server_id,$family,$key,$value) {
|
||||
public static function Set($server_id, $family, $key, $value) {
|
||||
return XConfig::Set('s_' . $server_id,$family,$key,$value);
|
||||
}
|
||||
|
||||
static public function Delete($server_id,$family,$key) {
|
||||
public static function Delete($server_id, $family, $key) {
|
||||
return XConfig::Delete('s_' . $server_id,$family,$key);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ use Zotlabs\Lib\Config;
|
|||
* @license http://opensource.org/licenses/mit-license.php The MIT License
|
||||
* @package svgsanitizer
|
||||
*/
|
||||
|
||||
class SvgSanitizer {
|
||||
class SvgSanitizer
|
||||
{
|
||||
|
||||
private $xmlDoc; // PHP XML DOMDocument
|
||||
|
||||
|
@ -61,18 +61,21 @@ class SvgSanitizer {
|
|||
'use' => ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'height', 'id', 'mask', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'transform', 'width', 'x', 'xlink:href', 'y'],
|
||||
];
|
||||
|
||||
function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->xmlDoc = new DOMDocument('1.0', 'UTF-8');
|
||||
$this->xmlDoc->preserveWhiteSpace = false;
|
||||
libxml_use_internal_errors(true);
|
||||
}
|
||||
|
||||
// load XML SVG
|
||||
function load($file) {
|
||||
public function load($file)
|
||||
{
|
||||
$this->xmlDoc->load($file);
|
||||
}
|
||||
|
||||
function loadXML($str) {
|
||||
public function loadXML($str)
|
||||
{
|
||||
if (!$str) {
|
||||
logger('loadxml: empty input', LOGGER_DEBUG);
|
||||
return false;
|
||||
|
@ -84,14 +87,13 @@ class SvgSanitizer {
|
|||
return true;
|
||||
}
|
||||
|
||||
function sanitize()
|
||||
public function sanitize()
|
||||
{
|
||||
// all elements in xml doc
|
||||
$allElements = $this->xmlDoc->getElementsByTagName('*');
|
||||
|
||||
// loop through all elements
|
||||
for($i = 0; $i < $allElements->length; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $allElements->length; $i++) {
|
||||
$this->removedattrs = [];
|
||||
|
||||
$currentNode = $allElements->item($i);
|
||||
|
@ -116,8 +118,7 @@ class SvgSanitizer {
|
|||
// check if attribute isn't in allowlist
|
||||
if (!in_array($attrName, $allowlist_attr_arr)) {
|
||||
$this->removedattrs[] = $attrName;
|
||||
}
|
||||
// check for disallowed functions
|
||||
} // check for disallowed functions
|
||||
elseif (preg_match_all('/([a-zA-Z0-9]+)[\s]*\(/',
|
||||
$currentNode->attributes->item($x)->textContent, $matches, PREG_SET_ORDER)) {
|
||||
if ($attrName === 'text') {
|
||||
|
@ -138,9 +139,7 @@ class SvgSanitizer {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// else remove element
|
||||
} // else remove element
|
||||
else {
|
||||
logger('remove_node: ' . print_r($currentNode, true));
|
||||
$currentNode->parentNode->removeChild($currentNode);
|
||||
|
@ -149,7 +148,8 @@ class SvgSanitizer {
|
|||
return true;
|
||||
}
|
||||
|
||||
function saveSVG() {
|
||||
public function saveSVG()
|
||||
{
|
||||
$this->xmlDoc->formatOutput = true;
|
||||
return ($this->xmlDoc->saveXML());
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@ use App;
|
|||
|
||||
class System {
|
||||
|
||||
static public function get_platform_name() {
|
||||
public static function get_platform_name() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('platform_name',App::$config['system']))
|
||||
return App::$config['system']['platform_name'];
|
||||
return PLATFORM_NAME;
|
||||
}
|
||||
|
||||
static public function get_site_name() {
|
||||
public static function get_site_name() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['sitename'])
|
||||
return App::$config['system']['sitename'];
|
||||
return '';
|
||||
}
|
||||
|
||||
static public function get_banner() {
|
||||
public static function get_banner() {
|
||||
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('banner',App::$config['system']) && App::$config['system']['banner']) {
|
||||
return App::$config['system']['banner'];
|
||||
|
@ -26,14 +26,14 @@ class System {
|
|||
return self::get_site_name();
|
||||
}
|
||||
|
||||
static public function get_project_icon() {
|
||||
public static function get_project_icon() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('icon',App::$config['system'])) {
|
||||
return App::$config['system']['icon'];
|
||||
}
|
||||
return z_root() . '/images/' . PLATFORM_NAME . '-64.png';
|
||||
}
|
||||
|
||||
static public function get_project_favicon() {
|
||||
public static function get_project_favicon() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('favicon',App::$config['system'])) {
|
||||
return App::$config['system']['favicon'];
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class System {
|
|||
}
|
||||
|
||||
|
||||
static public function get_project_version() {
|
||||
public static function get_project_version() {
|
||||
if(array_path_exists('system/hide_version', App::$config) && intval(App::$config['system']['hide_version']))
|
||||
return '';
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('std_version',App::$config['system']))
|
||||
|
@ -50,63 +50,63 @@ class System {
|
|||
return self::get_std_version();
|
||||
}
|
||||
|
||||
static public function get_update_version() {
|
||||
public static function get_update_version() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['hide_version'])
|
||||
return EMPTY_STR;
|
||||
return DB_UPDATE_VERSION;
|
||||
}
|
||||
|
||||
|
||||
static public function get_notify_icon() {
|
||||
public static function get_notify_icon() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['email_notify_icon_url'])
|
||||
return App::$config['system']['email_notify_icon_url'];
|
||||
return self::get_project_icon();
|
||||
}
|
||||
|
||||
static public function get_site_icon() {
|
||||
public static function get_site_icon() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && isset(App::$config['system']['site_icon_url']) && App::$config['system']['site_icon_url'])
|
||||
return App::$config['system']['site_icon_url'];
|
||||
return self::get_project_icon();
|
||||
}
|
||||
|
||||
static public function get_site_favicon() {
|
||||
public static function get_site_favicon() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['site_favicon_url'])
|
||||
return App::$config['system']['site_favicon_url'];
|
||||
return self::get_project_favicon();
|
||||
}
|
||||
|
||||
static public function get_project_link() {
|
||||
public static function get_project_link() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['project_link'])
|
||||
return App::$config['system']['project_link'];
|
||||
return 'https://zotlabs.com/' . PLATFORM_NAME;
|
||||
}
|
||||
|
||||
static public function get_project_srclink() {
|
||||
public static function get_project_srclink() {
|
||||
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['project_srclink'])
|
||||
return App::$config['system']['project_srclink'];
|
||||
return 'https://codeberg.org/zot/' . PLATFORM_NAME;
|
||||
}
|
||||
|
||||
static public function ebs() {
|
||||
public static function ebs() {
|
||||
if(defined('EBSSTATE')) {
|
||||
return EBSSTATE;
|
||||
}
|
||||
return 'armed';
|
||||
}
|
||||
|
||||
static public function get_zot_revision() {
|
||||
public static function get_zot_revision() {
|
||||
$x = [ 'revision' => ZOT_REVISION ];
|
||||
call_hooks('zot_revision',$x);
|
||||
return $x['revision'];
|
||||
}
|
||||
|
||||
static public function get_std_version() {
|
||||
public static function get_std_version() {
|
||||
if(defined('STD_VERSION'))
|
||||
return STD_VERSION;
|
||||
return '0.0.0';
|
||||
}
|
||||
|
||||
static public function compatible_project($p) {
|
||||
public static function compatible_project($p) {
|
||||
|
||||
if (in_array(strtolower($p),['hubzilla', 'zap', 'red', 'misty', 'mistpark', 'redmatrix', 'osada', 'roadhouse'])) {
|
||||
return true;
|
||||
|
|
|
@ -521,7 +521,7 @@ class ThreadItem {
|
|||
$additional_mentions = [];
|
||||
foreach ($item['term'] as $t) {
|
||||
if ($t['ttype'] == TERM_MENTION) {
|
||||
$additional_mentions[] = ((($position = strpos($t['url'],'url=')) !== false) ? urldecode(substr($t['url'],$position + 4)) : $t['url']);;
|
||||
$additional_mentions[] = ((($position = strpos($t['url'],'url=')) !== false) ? urldecode(substr($t['url'],$position + 4)) : $t['url']);
|
||||
}
|
||||
}
|
||||
if ($additional_mentions) {
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
class ThreadListener {
|
||||
|
||||
static public function store($target_id,$portable_id,$ltype = 0) {
|
||||
public static function store($target_id, $portable_id, $ltype = 0) {
|
||||
$x = self::fetch($target_id,$portable_id,$ltype = 0);
|
||||
if(! $x) {
|
||||
$r = q("insert into listeners ( target_id, portable_id, ltype ) values ( '%s', '%s' , %d ) ",
|
||||
|
@ -15,7 +15,7 @@ class ThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
static public function fetch($target_id,$portable_id,$ltype = 0) {
|
||||
public static function fetch($target_id, $portable_id, $ltype = 0) {
|
||||
$x = q("select * from listeners where target_id = '%s' and portable_id = '%s' and ltype = %d limit 1",
|
||||
dbesc($target_id),
|
||||
dbesc($portable_id),
|
||||
|
@ -27,7 +27,7 @@ class ThreadListener {
|
|||
return false;
|
||||
}
|
||||
|
||||
static public function fetch_by_target($target_id,$ltype = 0) {
|
||||
public static function fetch_by_target($target_id, $ltype = 0) {
|
||||
$x = q("select * from listeners where target_id = '%s' and ltype = %d",
|
||||
dbesc($target_id),
|
||||
intval($ltype)
|
||||
|
@ -36,14 +36,14 @@ class ThreadListener {
|
|||
return $x;
|
||||
}
|
||||
|
||||
static public function delete_by_target($target_id, $ltype = 0) {
|
||||
public static function delete_by_target($target_id, $ltype = 0) {
|
||||
return q("delete from listeners where target_id = '%s' and ltype = %d",
|
||||
dbesc($target_id),
|
||||
intval($ltype)
|
||||
);
|
||||
}
|
||||
|
||||
static public function delete_by_pid($portable_id, $ltype = 0) {
|
||||
public static function delete_by_pid($portable_id, $ltype = 0) {
|
||||
return q("delete from listeners where portable_id = '%s' and ltype = %d",
|
||||
dbesc($portable_id),
|
||||
intval($ltype)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
|
||||
require_once('boot.php');
|
||||
require_once('include/text.php');
|
||||
|
||||
|
@ -45,7 +47,7 @@ class ThreadStream {
|
|||
if($this->get_mode() == $mode)
|
||||
return;
|
||||
|
||||
$this->observer = \App::get_observer();
|
||||
$this->observer = App::get_observer();
|
||||
$ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
|
||||
|
||||
switch($mode) {
|
||||
|
@ -62,16 +64,16 @@ class ThreadStream {
|
|||
$this->writable = true;
|
||||
break;
|
||||
case 'channel':
|
||||
$this->profile_owner = \App::$profile['profile_uid'];
|
||||
$this->profile_owner = App::$profile['profile_uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
break;
|
||||
case 'cards':
|
||||
$this->profile_owner = \App::$profile['profile_uid'];
|
||||
$this->profile_owner = App::$profile['profile_uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
$this->reload = $_SESSION['return_url'];
|
||||
break;
|
||||
case 'articles':
|
||||
$this->profile_owner = \App::$profile['profile_uid'];
|
||||
$this->profile_owner = App::$profile['profile_uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
$this->reload = $_SESSION['return_url'];
|
||||
break;
|
||||
|
@ -83,7 +85,7 @@ class ThreadStream {
|
|||
$this->uploadable = perm_is_allowed($this->profile_owner,$ob_hash,'write_storage');
|
||||
break;
|
||||
case 'page':
|
||||
$this->profile_owner = \App::$profile['uid'];
|
||||
$this->profile_owner = App::$profile['uid'];
|
||||
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
|
||||
class Verify {
|
||||
class Verify
|
||||
{
|
||||
|
||||
static function create($type,$channel_id,$token,$meta) {
|
||||
public static function create($type, $channel_id, $token, $meta)
|
||||
{
|
||||
return q("insert into verify ( vtype, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )",
|
||||
dbesc($type),
|
||||
intval($channel_id),
|
||||
|
@ -15,7 +17,8 @@ class Verify {
|
|||
);
|
||||
}
|
||||
|
||||
static function match($type,$channel_id,$token,$meta) {
|
||||
public static function match($type, $channel_id, $token, $meta)
|
||||
{
|
||||
$r = q("select id from verify where vtype = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1",
|
||||
dbesc($type),
|
||||
intval($channel_id),
|
||||
|
@ -31,7 +34,8 @@ class Verify {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function get_meta($type,$channel_id,$token) {
|
||||
public static function get_meta($type, $channel_id, $token)
|
||||
{
|
||||
$r = q("select id, meta from verify where vtype = '%s' and channel = %d and token = '%s' limit 1",
|
||||
dbesc($type),
|
||||
intval($channel_id),
|
||||
|
@ -52,7 +56,8 @@ class Verify {
|
|||
* @param string $type Verify type
|
||||
* @param string $interval SQL compatible time interval
|
||||
*/
|
||||
static function purge($type, $interval) {
|
||||
public static function purge($type, $interval)
|
||||
{
|
||||
q("delete from verify where vtype = '%s' and created < ( %s - INTERVAL %s )",
|
||||
dbesc($type),
|
||||
db_utcnow(),
|
||||
|
|
|
@ -6,15 +6,16 @@ namespace Zotlabs\Lib;
|
|||
* @brief Fetch and return a webfinger for a resource
|
||||
*
|
||||
* @param string $resource - The resource
|
||||
* @return boolean|string false or associative array from result JSON
|
||||
* @return bool|string false or associative array from result JSON
|
||||
*/
|
||||
class Webfinger
|
||||
{
|
||||
|
||||
class Webfinger {
|
||||
private static $server = EMPTY_STR;
|
||||
private static $resource = EMPTY_STR;
|
||||
|
||||
static private $server = EMPTY_STR;
|
||||
static private $resource = EMPTY_STR;
|
||||
|
||||
static function exec($resource) {
|
||||
public static function exec($resource)
|
||||
{
|
||||
|
||||
if (!$resource) {
|
||||
return false;
|
||||
|
@ -46,7 +47,8 @@ class Webfinger {
|
|||
return false;
|
||||
}
|
||||
|
||||
static function parse_resource($resource) {
|
||||
public static function parse_resource($resource)
|
||||
{
|
||||
|
||||
self::$resource = urlencode($resource);
|
||||
|
||||
|
@ -57,17 +59,14 @@ class Webfinger {
|
|||
return false;
|
||||
}
|
||||
self::$server = $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif (strpos($resource,'tag:') === 0) {
|
||||
} elseif (strpos($resource, 'tag:') === 0) {
|
||||
$arr = explode(':', $resource); // split the tag
|
||||
$h = explode(',', $arr[1]); // split the host,date
|
||||
self::$server = $h[0];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x = explode('@', $resource);
|
||||
if (!strlen($x[0])) {
|
||||
// e.g. @dan@pixelfed.org
|
||||
|
@ -76,8 +75,7 @@ class Webfinger {
|
|||
$username = $x[0];
|
||||
if (count($x) > 1) {
|
||||
self::$server = $x[1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (strpos($resource, 'acct:') !== 0) {
|
||||
|
@ -91,7 +89,8 @@ class Webfinger {
|
|||
*
|
||||
*/
|
||||
|
||||
static function zot_url($resource) {
|
||||
public static function zot_url($resource)
|
||||
{
|
||||
|
||||
$arr = self::exec($resource);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class XConfig {
|
|||
* The observer's hash
|
||||
* @return void|false Returns false if xchan is not set
|
||||
*/
|
||||
static public function Load($xchan) {
|
||||
public static function Load($xchan) {
|
||||
|
||||
if(! $xchan)
|
||||
return false;
|
||||
|
@ -76,10 +76,10 @@ class XConfig {
|
|||
* The category of the configuration value
|
||||
* @param string $key
|
||||
* The configuration key to query
|
||||
* @param boolean $default (optional) default false
|
||||
* @param bool $default (optional) default false
|
||||
* @return mixed Stored $value or false if it does not exist
|
||||
*/
|
||||
static public function Get($xchan, $family, $key, $default = false) {
|
||||
public static function Get($xchan, $family, $key, $default = false) {
|
||||
|
||||
if(! $xchan)
|
||||
return $default;
|
||||
|
@ -109,7 +109,7 @@ class XConfig {
|
|||
* The value to store
|
||||
* @return mixed Stored $value or false
|
||||
*/
|
||||
static public function Set($xchan, $family, $key, $value) {
|
||||
public static function Set($xchan, $family, $key, $value) {
|
||||
|
||||
// manage array value
|
||||
$dbvalue = ((is_array($value)) ? serialise($value) : $value);
|
||||
|
@ -159,7 +159,7 @@ class XConfig {
|
|||
* The configuration key to delete
|
||||
* @return mixed
|
||||
*/
|
||||
static public function Delete($xchan, $family, $key) {
|
||||
public static function Delete($xchan, $family, $key) {
|
||||
|
||||
if(isset(App::$config[$xchan]) && isset(App::$config[$xchan][$family]) && isset(App::$config[$xchan][$family][$key]))
|
||||
unset(App::$config[$xchan][$family][$key]);
|
||||
|
|
|
@ -7,7 +7,7 @@ use Zotlabs\Web\HTTPSig;
|
|||
|
||||
class ZotURL {
|
||||
|
||||
static public function fetch($url,$channel,$hub = null) {
|
||||
public static function fetch($url, $channel, $hub = null) {
|
||||
|
||||
$ret = [ 'success' => false ];
|
||||
|
||||
|
@ -66,7 +66,7 @@ class ZotURL {
|
|||
|
||||
}
|
||||
|
||||
static public function is_zoturl($s) {
|
||||
public static function is_zoturl($s) {
|
||||
|
||||
if(strpos($url,'x-zot:') === 0) {
|
||||
return true;
|
||||
|
@ -75,7 +75,7 @@ class ZotURL {
|
|||
}
|
||||
|
||||
|
||||
static public function lookup($portable_id,$hub) {
|
||||
public static function lookup($portable_id, $hub) {
|
||||
|
||||
$r = q("select * from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and site_dead = 0 order by hubloc_primary desc",
|
||||
dbesc($portable_id)
|
||||
|
@ -107,7 +107,7 @@ class ZotURL {
|
|||
}
|
||||
|
||||
|
||||
static public function parse_response($arr) {
|
||||
public static function parse_response($arr) {
|
||||
if(! $arr['success']) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
|
||||
class Zotfinger {
|
||||
class Zotfinger
|
||||
{
|
||||
|
||||
static function exec($resource,$channel = null,$verify = true) {
|
||||
public static function exec($resource, $channel = null, $verify = true)
|
||||
{
|
||||
|
||||
if (!$resource) {
|
||||
return false;
|
||||
|
@ -32,8 +34,7 @@ class Zotfinger {
|
|||
'(request-target)' => 'post ' . get_request_string($resource)
|
||||
];
|
||||
$h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$h = ['Accept: application/x-zot+json'];
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@ require_once('include/acl_selectors.php');
|
|||
* keys however this functionality has grown in an ad-hoc manner and has gotten
|
||||
* quite messy over time.
|
||||
*/
|
||||
class Acl extends Controller
|
||||
{
|
||||
|
||||
class Acl extends Controller {
|
||||
|
||||
function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
// logger('mod_acl: ' . print_r($_REQUEST,true),LOGGER_DATA);
|
||||
|
||||
|
@ -88,7 +89,6 @@ class Acl extends Controller {
|
|||
$sql_extra2 = " AND ( xchan_name LIKE " . protect_sprintf("'%" . dbesc($search) . "%'") . " OR xchan_addr LIKE " . protect_sprintf("'%" . dbesc(punify($search)) . ((strpos($search, '@') === false) ? "%@%'" : "%'")) . ") ";
|
||||
|
||||
|
||||
|
||||
// This horrible mess is needed because position also returns 0 if nothing is found.
|
||||
// Would be MUCH easier if it instead returned a very large value
|
||||
// Otherwise we could just
|
||||
|
@ -104,8 +104,7 @@ class Acl extends Controller {
|
|||
$sql_extra4 = "AND ( xchan_name LIKE " . protect_sprintf("'%" . dbesc($search) . "%'") . " OR xchan_addr LIKE " . protect_sprintf("'%" . dbesc(punify($search)) . ((strpos($search, '@') === false) ? "%@%'" : "%'")) . " OR abook_alias LIKE " . protect_sprintf("'%" . dbesc($search) . "%'") . ") ";
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sql_extra = $sql_extra2 = $sql_extra3 = $sql_extra4 = "";
|
||||
}
|
||||
|
||||
|
@ -159,8 +158,7 @@ class Acl extends Controller {
|
|||
intval(local_channel())
|
||||
);
|
||||
|
||||
}
|
||||
else { // Visitors
|
||||
} else { // Visitors
|
||||
$r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_flags, 0 as abook_self
|
||||
FROM xchan left join xlink on xlink_link = xchan_hash
|
||||
WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc limit $count",
|
||||
|
@ -178,8 +176,7 @@ class Acl extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($type == 'm') {
|
||||
} elseif ($type == 'm') {
|
||||
|
||||
$r = [];
|
||||
$z = q("SELECT xchan_hash as hash, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url
|
||||
|
@ -198,8 +195,7 @@ class Acl extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($type == 'a') {
|
||||
} elseif ($type == 'a') {
|
||||
|
||||
$r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag FROM abook left join xchan on abook_xchan = xchan_hash
|
||||
WHERE abook_channel = %d
|
||||
|
@ -209,8 +205,7 @@ class Acl extends Controller {
|
|||
intval(local_channel())
|
||||
);
|
||||
|
||||
}
|
||||
elseif ($type == 'z') {
|
||||
} elseif ($type == 'z') {
|
||||
$r = q("SELECT xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag FROM xchan left join abook on xchan_hash = abook_xchan
|
||||
WHERE ( abook_channel = %d OR abook_channel IS NULL )
|
||||
and xchan_deleted = 0
|
||||
|
@ -218,9 +213,7 @@ class Acl extends Controller {
|
|||
ORDER BY xchan_name ASC ",
|
||||
intval(local_channel())
|
||||
);
|
||||
}
|
||||
|
||||
elseif ($type == 'x') {
|
||||
} elseif ($type == 'x') {
|
||||
$contacts = [];
|
||||
$r = $this->navbar_complete();
|
||||
if ($r) {
|
||||
|
@ -241,8 +234,7 @@ class Acl extends Controller {
|
|||
'items' => $contacts,
|
||||
];
|
||||
json_return_and_die($o);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = [];
|
||||
}
|
||||
|
||||
|
@ -306,7 +298,8 @@ class Acl extends Controller {
|
|||
}
|
||||
|
||||
|
||||
function navbar_complete() {
|
||||
public function navbar_complete()
|
||||
{
|
||||
|
||||
// logger('navbar_complete');
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ use Zotlabs\Lib\LDSignatures;
|
|||
use Zotlabs\Lib\ThreadListener;
|
||||
use App;
|
||||
|
||||
class Activity extends Controller {
|
||||
class Activity extends Controller
|
||||
{
|
||||
|
||||
function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
|
||||
if (ActivityStreams::is_as_request()) {
|
||||
|
@ -62,8 +64,7 @@ class Activity extends Controller {
|
|||
|
||||
if ($ob_authorize) {
|
||||
$sql_extra = " and item.uid = " . intval($token['uid']) . " ";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sql_extra = item_permissions_sql(0);
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,6 @@ class Activity extends Controller {
|
|||
}
|
||||
|
||||
|
||||
|
||||
goaway(z_root() . '/item/' . argv(1));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,16 +18,18 @@ use Zotlabs\Lib\Config;
|
|||
* @brief Admin area.
|
||||
*
|
||||
*/
|
||||
|
||||
class Admin extends Controller {
|
||||
class Admin extends Controller
|
||||
{
|
||||
|
||||
private $sm = null;
|
||||
|
||||
function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->sm = new SubModule();
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
logger('admin_init', LOGGER_DEBUG);
|
||||
|
||||
|
@ -42,7 +44,8 @@ class Admin extends Controller {
|
|||
}
|
||||
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
logger('admin_post', LOGGER_DEBUG);
|
||||
|
||||
|
@ -62,7 +65,8 @@ class Admin extends Controller {
|
|||
* @return string
|
||||
*/
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
logger('admin_content', LOGGER_DEBUG);
|
||||
|
||||
|
@ -84,16 +88,14 @@ class Admin extends Controller {
|
|||
if ($o === false) {
|
||||
notice(t('Item not found.'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$o = $this->admin_page_summary();
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
echo $o;
|
||||
killme();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +107,8 @@ class Admin extends Controller {
|
|||
* @return string HTML from parsed admin_summary.tpl
|
||||
*/
|
||||
|
||||
function admin_page_summary() {
|
||||
public function admin_page_summary()
|
||||
{
|
||||
|
||||
// list total user accounts, expirations etc.
|
||||
$accounts = [];
|
||||
|
@ -153,8 +156,7 @@ class Admin extends Controller {
|
|||
}
|
||||
}
|
||||
sort($plugins);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$plugins = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
namespace Zotlabs\Module\Admin;
|
||||
|
||||
|
||||
class Account_edit
|
||||
{
|
||||
|
||||
class Account_edit {
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
$account_id = $_REQUEST['aid'];
|
||||
|
||||
|
@ -47,7 +48,8 @@ class Account_edit {
|
|||
}
|
||||
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
if (argc() > 2)
|
||||
$account_id = argv(2);
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ namespace Zotlabs\Module\Admin;
|
|||
|
||||
use App;
|
||||
|
||||
class Accounts {
|
||||
class Accounts
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Handle POST actions on accounts admin page.
|
||||
|
@ -15,7 +16,8 @@ class Accounts {
|
|||
*
|
||||
*/
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
$pending = (x($_POST, 'pending') ? $_POST['pending'] : []);
|
||||
$users = (x($_POST, 'user') ? $_POST['user'] : []);
|
||||
|
@ -72,7 +74,8 @@ class Accounts {
|
|||
* @return string
|
||||
*/
|
||||
|
||||
function get(){
|
||||
public function get()
|
||||
{
|
||||
if (argc() > 2) {
|
||||
$uid = argv(3);
|
||||
$account = q("SELECT * FROM account WHERE account_id = %d",
|
||||
|
|
|
@ -2,16 +2,20 @@
|
|||
|
||||
namespace Zotlabs\Module\Admin;
|
||||
|
||||
use \Zotlabs\Storage\GitRepo;
|
||||
use \Michelf\MarkdownExtra;
|
||||
use App;
|
||||
use PHPGit\Exception\GitException;
|
||||
use Zotlabs\Storage\GitRepo;
|
||||
use Michelf\MarkdownExtra;
|
||||
|
||||
class Addons {
|
||||
class Addons
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
if (argc() > 2 && is_file("addon/" . argv(2) . "/" . argv(2) . ".php")) {
|
||||
@include_once("addon/" . argv(2) . "/" . argv(2) . ".php");
|
||||
|
@ -21,14 +25,12 @@ class Addons {
|
|||
}
|
||||
|
||||
goaway(z_root() . '/admin/addons/' . argv(2));
|
||||
}
|
||||
elseif(argc() > 2) {
|
||||
} elseif (argc() > 2) {
|
||||
switch (argv(2)) {
|
||||
case 'updaterepo':
|
||||
if (array_key_exists('repoName', $_REQUEST)) {
|
||||
$repoName = $_REQUEST['repoName'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
|
||||
}
|
||||
$extendDir = 'cache/git/sys/extend';
|
||||
|
@ -37,8 +39,7 @@ class Addons {
|
|||
if (!mkdir($extendDir, 0770, true)) {
|
||||
logger('Error creating extend folder: ' . $extendDir);
|
||||
json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!symlink(realpath('extend/addon'), $addonDir)) {
|
||||
logger('Error creating symlink to addon folder: ' . $addonDir);
|
||||
json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
|
||||
|
@ -73,7 +74,7 @@ class Addons {
|
|||
} else {
|
||||
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
|
||||
}
|
||||
} catch (\PHPGit\Exception\GitException $e) {
|
||||
} catch (GitException $e) {
|
||||
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
|
||||
}
|
||||
case 'removerepo':
|
||||
|
@ -245,20 +246,21 @@ class Addons {
|
|||
*
|
||||
* @return string with parsed HTML
|
||||
*/
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
/*
|
||||
* Single plugin
|
||||
*/
|
||||
|
||||
if (\App::$argc == 3){
|
||||
$plugin = \App::$argv[2];
|
||||
if (App::$argc == 3) {
|
||||
$plugin = App::$argv[2];
|
||||
if (!is_file("addon/$plugin/$plugin.php")) {
|
||||
notice(t("Item not found."));
|
||||
return '';
|
||||
}
|
||||
|
||||
$enabled = in_array($plugin,\App::$plugins);
|
||||
$enabled = in_array($plugin, App::$plugins);
|
||||
$info = get_plugin_info($plugin);
|
||||
$x = check_plugin_versions($info);
|
||||
|
||||
|
@ -266,11 +268,11 @@ class Addons {
|
|||
|
||||
if ($enabled && !$x) {
|
||||
$enabled = false;
|
||||
$idz = array_search($plugin, \App::$plugins);
|
||||
$idz = array_search($plugin, App::$plugins);
|
||||
if ($idz !== false) {
|
||||
unset(\App::$plugins[$idz]);
|
||||
unset(App::$plugins[$idz]);
|
||||
uninstall_plugin($plugin);
|
||||
set_config("system","addon", implode(", ",\App::$plugins));
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
}
|
||||
}
|
||||
$info['disabled'] = 1 - intval($x);
|
||||
|
@ -279,19 +281,19 @@ class Addons {
|
|||
check_form_security_token_redirectOnErr('/admin/addons', 'admin_addons', 't');
|
||||
$pinstalled = false;
|
||||
// Toggle plugin status
|
||||
$idx = array_search($plugin, \App::$plugins);
|
||||
$idx = array_search($plugin, App::$plugins);
|
||||
if ($idx !== false) {
|
||||
unset(\App::$plugins[$idx]);
|
||||
unset(App::$plugins[$idx]);
|
||||
uninstall_plugin($plugin);
|
||||
$pinstalled = false;
|
||||
info(sprintf(t("Plugin %s disabled."), $plugin));
|
||||
} else {
|
||||
\App::$plugins[] = $plugin;
|
||||
App::$plugins[] = $plugin;
|
||||
install_plugin($plugin);
|
||||
$pinstalled = true;
|
||||
info(sprintf(t("Plugin %s enabled."), $plugin));
|
||||
}
|
||||
set_config("system","addon", implode(", ",\App::$plugins));
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
|
||||
if ($pinstalled) {
|
||||
@require_once("addon/$plugin/$plugin.php");
|
||||
|
@ -303,7 +305,7 @@ class Addons {
|
|||
|
||||
// display plugin details
|
||||
|
||||
if (in_array($plugin, \App::$plugins)){
|
||||
if (in_array($plugin, App::$plugins)) {
|
||||
$status = 'on';
|
||||
$action = t('Disable');
|
||||
} else {
|
||||
|
@ -378,18 +380,18 @@ class Addons {
|
|||
if (is_dir($file)) {
|
||||
list($tmp, $id) = array_map('trim', explode('/', $file));
|
||||
$info = get_plugin_info($id);
|
||||
$enabled = in_array($id,\App::$plugins);
|
||||
$enabled = in_array($id, App::$plugins);
|
||||
$x = check_plugin_versions($info);
|
||||
|
||||
// disable plugins which are installed but incompatible versions
|
||||
|
||||
if ($enabled && !$x) {
|
||||
$enabled = false;
|
||||
$idz = array_search($id, \App::$plugins);
|
||||
$idz = array_search($id, App::$plugins);
|
||||
if ($idz !== false) {
|
||||
unset(\App::$plugins[$idz]);
|
||||
unset(App::$plugins[$idz]);
|
||||
uninstall_plugin($id);
|
||||
set_config("system","addon", implode(", ",\App::$plugins));
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
}
|
||||
}
|
||||
$info['disabled'] = 1 - intval($x);
|
||||
|
@ -457,7 +459,8 @@ class Addons {
|
|||
));
|
||||
}
|
||||
|
||||
function listAddonRepos() {
|
||||
public function listAddonRepos()
|
||||
{
|
||||
$addonrepos = [];
|
||||
$addonDir = 'extend/addon/';
|
||||
if (is_dir($addonDir)) {
|
||||
|
@ -473,7 +476,8 @@ class Addons {
|
|||
return $addonrepos;
|
||||
}
|
||||
|
||||
static public function plugin_sort($a,$b) {
|
||||
public static function plugin_sort($a, $b)
|
||||
{
|
||||
return (strcmp(strtolower($a[2]['name']), strtolower($b[2]['name'])));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,17 @@ use Zotlabs\Daemon\Run;
|
|||
* @brief Admin Module for Channels.
|
||||
*
|
||||
*/
|
||||
|
||||
class Channels {
|
||||
class Channels
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Handle POST actions on channels admin page.
|
||||
*
|
||||
*/
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
$channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() );
|
||||
$channels = (x($_POST, 'channel') ? $_POST['channel'] : array());
|
||||
|
||||
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels');
|
||||
|
||||
|
@ -58,7 +59,8 @@ class Channels {
|
|||
*
|
||||
* @return string with parsed HTML
|
||||
*/
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
if (argc() > 2) {
|
||||
$uid = argv(3);
|
||||
$channel = q("SELECT * FROM channel WHERE channel_id = %d",
|
||||
|
@ -71,15 +73,18 @@ class Channels {
|
|||
}
|
||||
|
||||
switch (argv(2)) {
|
||||
case "delete":{
|
||||
case "delete":
|
||||
{
|
||||
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
|
||||
// delete channel
|
||||
channel_remove($uid, true);
|
||||
|
||||
notice(sprintf(t("Channel '%s' deleted"), $channel[0]['channel_name']) . EOL);
|
||||
}; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case "block":{
|
||||
case "block":
|
||||
{
|
||||
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
|
||||
$pflags = $channel[0]['channel_pageflags'] ^ PAGE_CENSORED;
|
||||
q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
|
||||
|
@ -89,9 +94,11 @@ class Channels {
|
|||
Run::Summon(['Directory', $uid, 'nopush']);
|
||||
|
||||
notice(sprintf((($pflags & PAGE_CENSORED) ? t("Channel '%s' censored") : t("Channel '%s' uncensored")), $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')') . EOL);
|
||||
}; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case "code":{
|
||||
case "code":
|
||||
{
|
||||
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
|
||||
$pflags = $channel[0]['channel_pageflags'] ^ PAGE_ALLOWCODE;
|
||||
q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
|
||||
|
@ -100,7 +107,8 @@ class Channels {
|
|||
);
|
||||
|
||||
notice(sprintf((($pflags & PAGE_ALLOWCODE) ? t("Channel '%s' code allowed") : t("Channel '%s' code disallowed")), $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')') . EOL);
|
||||
}; break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -25,11 +25,11 @@ require_once('include/photos.php');
|
|||
* @return void
|
||||
*
|
||||
*/
|
||||
class Cover_photo
|
||||
{
|
||||
|
||||
|
||||
class Cover_photo {
|
||||
|
||||
function init() {
|
||||
public function init()
|
||||
{
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ class Cover_photo {
|
|||
*
|
||||
*/
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
|
@ -72,7 +73,6 @@ class Cover_photo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
$srcX = intval($_POST['xstart']);
|
||||
$srcY = intval($_POST['ystart']);
|
||||
$srcW = intval($_POST['xfinal']) - $srcX;
|
||||
|
@ -203,8 +203,7 @@ logger('gis: ' . print_r($gis,true));
|
|||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
notice(t('Unable to process image') . EOL);
|
||||
}
|
||||
|
||||
|
@ -233,8 +232,7 @@ logger('gis: ' . print_r($gis,true));
|
|||
if ($x['partial']) {
|
||||
header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
|
||||
json_return_and_die($x);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
|
||||
|
||||
$_FILES['userfile'] = [
|
||||
|
@ -245,8 +243,7 @@ logger('gis: ' . print_r($gis,true));
|
|||
'size' => $x['size']
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!array_key_exists('userfile', $_FILES)) {
|
||||
$_FILES['userfile'] = [
|
||||
'name' => $_FILES['files']['name'],
|
||||
|
@ -275,7 +272,8 @@ logger('gis: ' . print_r($gis,true));
|
|||
*/
|
||||
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
if (!is_site_admin()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
|
@ -302,7 +300,7 @@ logger('gis: ' . print_r($gis,true));
|
|||
if (argc() < 4) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
// check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
|
||||
|
||||
|
@ -335,8 +333,7 @@ logger('gis: ' . print_r($gis,true));
|
|||
|
||||
if (intval($r[0]['os_storage'])) {
|
||||
$data = @file_get_contents(dbunescbin($r[0]['content']));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$data = dbunescbin($r[0]['content']);
|
||||
}
|
||||
|
||||
|
@ -391,15 +388,14 @@ logger('gis: ' . print_r($gis,true));
|
|||
call_hooks('cover_photo_content_end', $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filename = App::$data['imagecrop'] . '-3';
|
||||
$resolution = 3;
|
||||
|
||||
$o .= replace_macros(get_markup_template('admin_cropcover.tpl'), [
|
||||
'$filename' => $filename,
|
||||
'$profile' => intval($_REQUEST['profile']),
|
||||
'$resource' => \App::$data['imagecrop'] . '-3',
|
||||
'$resource' => App::$data['imagecrop'] . '-3',
|
||||
'$image_url' => z_root() . '/photo/' . $filename,
|
||||
'$title' => t('Crop Image'),
|
||||
'$desc' => t('Please adjust the image cropping for optimum viewing.'),
|
||||
|
@ -418,7 +414,8 @@ logger('gis: ' . print_r($gis,true));
|
|||
*
|
||||
*/
|
||||
|
||||
function cover_photo_crop_ui_head($ph, $hash, $smallest){
|
||||
public function cover_photo_crop_ui_head($ph, $hash, $smallest)
|
||||
{
|
||||
|
||||
$max_length = get_config('system', 'max_image_length', MAX_IMAGE_LENGTH);
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
namespace Zotlabs\Module\Admin;
|
||||
|
||||
|
||||
|
||||
class Dbsync {
|
||||
class Dbsync
|
||||
{
|
||||
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
$o = '';
|
||||
|
||||
if (argc() > 3 && intval(argv(3)) && argv(2) === 'mark') {
|
||||
|
@ -30,27 +31,20 @@ class Dbsync {
|
|||
$retval = $c->verify();
|
||||
if ($retval === UPDATE_FAILED) {
|
||||
$o .= sprintf(t('Verification of update %s failed. Check system logs.'), $s);
|
||||
}
|
||||
elseif($retval === UPDATE_SUCCESS) {
|
||||
} elseif ($retval === UPDATE_SUCCESS) {
|
||||
$o .= sprintf(t('Update %s was successfully applied.'), $s);
|
||||
set_config('database', $s, 'success');
|
||||
}
|
||||
else
|
||||
} else
|
||||
$o .= sprintf(t('Verifying update %s did not return a status. Unknown if it succeeded.'), $s);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$o .= sprintf(t('Update %s does not contain a verification function.'), $s);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
$o .= sprintf(t('Update function %s could not be found.'), $s);
|
||||
|
||||
return $o;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// remove the old style config if it exists
|
||||
del_config('database', 'update_r' . intval(argv(3)));
|
||||
set_config('database', '_' . intval(argv(3)), 'success');
|
||||
|
@ -69,15 +63,12 @@ class Dbsync {
|
|||
$retval = $c->run();
|
||||
if ($retval === UPDATE_FAILED) {
|
||||
$o .= sprintf(t('Executing update procedure %s failed. Check system logs.'), $s);
|
||||
}
|
||||
elseif($retval === UPDATE_SUCCESS) {
|
||||
} elseif ($retval === UPDATE_SUCCESS) {
|
||||
$o .= sprintf(t('Update %s was successfully applied.'), $s);
|
||||
set_config('database', $s, 'success');
|
||||
}
|
||||
else
|
||||
} else
|
||||
$o .= sprintf(t('Update %s did not return a status. It cannot be determined if it was successful.'), $s);
|
||||
}
|
||||
else
|
||||
} else
|
||||
$o .= sprintf(t('Update function %s could not be found.'), $s);
|
||||
|
||||
return $o;
|
||||
|
@ -103,8 +94,7 @@ class Dbsync {
|
|||
'$apply' => t('Attempt to execute this update step automatically'),
|
||||
'$failed' => $failed
|
||||
));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return '<div class="generic-content-wrapper-styled"><h3>' . t('No failed updates.') . '</h3></div>';
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace Zotlabs\Module\Admin;
|
||||
|
||||
|
||||
class Logs {
|
||||
|
||||
class Logs
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,8 @@ class Logs {
|
|||
*
|
||||
*/
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
if (x($_POST, 'page_logs')) {
|
||||
check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
|
||||
|
||||
|
@ -35,9 +36,10 @@ class Logs {
|
|||
* @return string
|
||||
*/
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
$log_choices = Array(
|
||||
$log_choices = array(
|
||||
LOGGER_NORMAL => 'Normal',
|
||||
LOGGER_TRACE => 'Trace',
|
||||
LOGGER_DEBUG => 'Debug',
|
||||
|
@ -54,17 +56,14 @@ class Logs {
|
|||
if (!file_exists($f)) {
|
||||
$data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
|
||||
readable.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$fp = fopen($f, 'r');
|
||||
if (!$fp) {
|
||||
$data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$fstat = fstat($fp);
|
||||
$size = $fstat['size'];
|
||||
if($size != 0)
|
||||
{
|
||||
if ($size != 0) {
|
||||
if ($size > 5000000 || $size < 0)
|
||||
$size = 5000000;
|
||||
$seek = fseek($fp, 0 - $size, SEEK_END);
|
||||
|
@ -97,5 +96,4 @@ class Logs {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -19,7 +19,8 @@ require_once('include/photo_factory.php');
|
|||
require_once('include/photos.php');
|
||||
|
||||
|
||||
class Profile_photo {
|
||||
class Profile_photo
|
||||
{
|
||||
|
||||
|
||||
/* @brief Initalize the profile-photo edit view
|
||||
|
@ -28,7 +29,8 @@ class Profile_photo {
|
|||
*
|
||||
*/
|
||||
|
||||
function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
|
@ -46,7 +48,8 @@ class Profile_photo {
|
|||
*
|
||||
*/
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
|
@ -183,8 +186,7 @@ class Profile_photo {
|
|||
|
||||
info(t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
notice(t('Unable to process image') . EOL);
|
||||
}
|
||||
}
|
||||
|
@ -204,8 +206,7 @@ class Profile_photo {
|
|||
if ($_REQUEST['importfile']) {
|
||||
$hash = $_REQUEST['importfile'];
|
||||
$importing = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$matches = [];
|
||||
$partial = false;
|
||||
|
@ -224,8 +225,7 @@ class Profile_photo {
|
|||
if ($x['partial']) {
|
||||
header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
|
||||
json_return_and_die($x);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
|
||||
|
||||
$_FILES['userfile'] = [
|
||||
|
@ -236,8 +236,7 @@ class Profile_photo {
|
|||
'size' => $x['size']
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!array_key_exists('userfile', $_FILES)) {
|
||||
$_FILES['userfile'] = [
|
||||
'name' => $_FILES['files']['name'],
|
||||
|
@ -301,7 +300,8 @@ class Profile_photo {
|
|||
*/
|
||||
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
if (!is_site_admin()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
|
@ -324,7 +324,7 @@ class Profile_photo {
|
|||
if (argc() < 4) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
$resource_id = argv(3);
|
||||
|
||||
|
@ -339,8 +339,7 @@ class Profile_photo {
|
|||
if (($c) && (count($c) === 1) && (intval($c[0]['is_default']))) {
|
||||
$_REQUEST['profile'] = $c[0]['id'];
|
||||
$multi_profiles = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$_REQUEST['profile'] = $pf;
|
||||
}
|
||||
|
||||
|
@ -395,8 +394,7 @@ class Profile_photo {
|
|||
|
||||
if (intval($r[0]['os_storage'])) {
|
||||
$data = @file_get_contents(dbunescbin($r[0]['content']));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$data = dbunescbin($r[0]['content']);
|
||||
}
|
||||
|
||||
|
@ -421,8 +419,7 @@ class Profile_photo {
|
|||
|
||||
if ($multi_profiles) {
|
||||
App::$data['importfile'] = $resource_id;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->profile_photo_crop_ui_head($ph, $hash, $smallest);
|
||||
}
|
||||
|
||||
|
@ -482,8 +479,7 @@ class Profile_photo {
|
|||
|
||||
call_hooks('profile_photo_content_end', $o);
|
||||
return $o;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// present a cropping form
|
||||
|
||||
|
@ -510,7 +506,8 @@ class Profile_photo {
|
|||
*
|
||||
*/
|
||||
|
||||
function profile_photo_crop_ui_head($ph, $hash, $smallest) {
|
||||
public function profile_photo_crop_ui_head($ph, $hash, $smallest)
|
||||
{
|
||||
$max_length = get_config('system', 'max_image_length', MAX_IMAGE_LENGTH);
|
||||
|
||||
if ($max_length > 0) {
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
namespace Zotlabs\Module\Admin;
|
||||
|
||||
|
||||
class Profs {
|
||||
class Profs
|
||||
{
|
||||
|
||||
function post() {
|
||||
public function post()
|
||||
{
|
||||
|
||||
if (array_key_exists('basic', $_REQUEST)) {
|
||||
$arr = explode(',', $_REQUEST['basic']);
|
||||
|
@ -55,8 +57,7 @@ class Profs {
|
|||
dbesc($_REQUEST['field_inputs']),
|
||||
intval($_REQUEST['id'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = q("insert into profdef ( field_name, field_type, field_desc, field_help, field_inputs ) values ( '%s' , '%s', '%s', '%s', '%s' )",
|
||||
dbesc($_REQUEST['field_name']),
|
||||
dbesc($_REQUEST['field_type']),
|
||||
|
@ -73,7 +74,8 @@ class Profs {
|
|||
goaway(z_root() . '/admin/profs');
|
||||
}
|
||||
|
||||
function get() {
|
||||
public function get()
|
||||
{
|
||||
|
||||
if ((argc() > 3) && argv(2) == 'drop' && intval(argv(3))) {
|
||||
$r = q("delete from profdef where id = %d",
|
||||
|
@ -184,7 +186,4 @@ class Profs {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue