mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:35:30 +00:00
zot objs
This commit is contained in:
parent
afa752c008
commit
80bc6137fd
4 changed files with 91 additions and 43 deletions
|
@ -13,6 +13,11 @@ class Share {
|
|||
if(! $post_id)
|
||||
return;
|
||||
|
||||
if(is_array($post_id)) {
|
||||
$this->item = $post_id;
|
||||
return;
|
||||
}
|
||||
|
||||
if(! (local_channel() || remote_channel()))
|
||||
return;
|
||||
|
||||
|
@ -75,9 +80,18 @@ class Share {
|
|||
public function bbcode() {
|
||||
$bb = EMPTY_STR;
|
||||
|
||||
if(! $this->item)
|
||||
if (! $this->item)
|
||||
return $bb;
|
||||
|
||||
if (! $this->item['author']) {
|
||||
$author = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||
dbesc($this->item['author_xchan'])
|
||||
);
|
||||
if ($author) {
|
||||
$this->item['author'] = array_shift($author);
|
||||
}
|
||||
}
|
||||
|
||||
$is_photo = (($this->item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
|
||||
if($is_photo) {
|
||||
$object = json_decode($this->item['obj'],true);
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Web\Controller;
|
||||
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\ActivityStreams;
|
||||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib as Zlib;
|
||||
|
||||
|
||||
class Linkinfo extends Controller {
|
||||
|
@ -19,31 +23,31 @@ class Linkinfo extends Controller {
|
|||
|
||||
$br = "\n";
|
||||
|
||||
if(x($_GET,'binurl'))
|
||||
if (x($_GET,'binurl'))
|
||||
$url = trim(hex2bin($_GET['binurl']));
|
||||
else
|
||||
$url = trim($_GET['url']);
|
||||
|
||||
if(substr($url,0,1) === '!') {
|
||||
if (substr($url,0,1) === '!') {
|
||||
$process_embed = false;
|
||||
$url = substr($url,1);
|
||||
}
|
||||
|
||||
$url = strip_zids($url);
|
||||
|
||||
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
|
||||
if ((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
|
||||
$url = 'http://' . $url;
|
||||
|
||||
|
||||
if($_GET['title'])
|
||||
if ($_GET['title'])
|
||||
$title = strip_tags(trim($_GET['title']));
|
||||
|
||||
if($_GET['description'])
|
||||
if ($_GET['description'])
|
||||
$text = strip_tags(trim($_GET['description']));
|
||||
|
||||
if($_GET['tags']) {
|
||||
if ($_GET['tags']) {
|
||||
$arr_tags = str_getcsv($_GET['tags']);
|
||||
if(count($arr_tags)) {
|
||||
if (count($arr_tags)) {
|
||||
array_walk($arr_tags,'self::arr_add_hashes');
|
||||
$str_tags = $br . implode(' ',$arr_tags) . $br;
|
||||
}
|
||||
|
@ -53,8 +57,8 @@ class Linkinfo extends Controller {
|
|||
|
||||
$zrl = is_matrix_url($url);
|
||||
|
||||
if(! $process_embed) {
|
||||
if($zrl) {
|
||||
if (! $process_embed) {
|
||||
if ($zrl) {
|
||||
echo $br . '[zrl]' . $url . '[/zrl]' . $br;
|
||||
}
|
||||
else {
|
||||
|
@ -64,7 +68,7 @@ class Linkinfo extends Controller {
|
|||
}
|
||||
|
||||
$result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
|
||||
if($result['success']) {
|
||||
if ($result['success']) {
|
||||
$hdrs=array();
|
||||
$h = explode("\n",$result['header']);
|
||||
foreach ($h as $l) {
|
||||
|
@ -73,29 +77,29 @@ class Linkinfo extends Controller {
|
|||
}
|
||||
if (array_key_exists('content-type', $hdrs))
|
||||
$type = $hdrs['content-type'];
|
||||
if($type) {
|
||||
if(stripos($type,'image/') !== false) {
|
||||
if($zrl)
|
||||
if ($type) {
|
||||
if (stripos($type,'image/') !== false) {
|
||||
if ($zrl)
|
||||
echo $br . '[zmg]' . $url . '[/zmg]' . $br;
|
||||
else
|
||||
echo $br . '[img]' . $url . '[/img]' . $br;
|
||||
killme();
|
||||
}
|
||||
if(stripos($type,'video/') !== false) {
|
||||
if($zrl)
|
||||
if (stripos($type,'video/') !== false) {
|
||||
if ($zrl)
|
||||
echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
|
||||
else
|
||||
echo $br . '[video]' . $url . '[/video]' . $br;
|
||||
killme();
|
||||
}
|
||||
if(stripos($type,'audio/') !== false) {
|
||||
if($zrl)
|
||||
if (stripos($type,'audio/') !== false) {
|
||||
if ($zrl)
|
||||
echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
|
||||
else
|
||||
echo $br . '[audio]' . $url . '[/audio]' . $br;
|
||||
killme();
|
||||
}
|
||||
if(strtolower($type) === 'application/pdf' || strtolower($type) === 'application/x-pdf') {
|
||||
if (strtolower($type) === 'application/pdf' || strtolower($type) === 'application/x-pdf') {
|
||||
echo $br . '[embed]' . $url . '[/embed]' . $br;
|
||||
killme();
|
||||
}
|
||||
|
@ -108,20 +112,48 @@ class Linkinfo extends Controller {
|
|||
|
||||
call_hooks('parse_link', $arr);
|
||||
|
||||
if(strlen($arr['text'])) {
|
||||
if (strlen($arr['text'])) {
|
||||
echo $arr['text'];
|
||||
killme();
|
||||
}
|
||||
|
||||
if($process_oembed) {
|
||||
if ($process_oembed) {
|
||||
$x = oembed_process($url);
|
||||
if($x) {
|
||||
if ($x) {
|
||||
echo $x;
|
||||
killme();
|
||||
}
|
||||
}
|
||||
|
||||
if($url && $title && $text) {
|
||||
if ($process_zotobj) {
|
||||
$x = Activity::fetch($url);
|
||||
if (is_array($x)) {
|
||||
$y = new ActivityStreams($x);
|
||||
if ($y->is_valid()) {
|
||||
$z = Activity::decode_note($y);
|
||||
$r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_hash = '%s' OR hubloc_id_url = '%s'",
|
||||
dbesc(is_array($y->actor) ? $y->actor['id'] : $y->actor),
|
||||
dbesc(is_array($y->actor) ? $y->actor['id'] : $y->actor)
|
||||
);
|
||||
|
||||
if ($r) {
|
||||
$r = Libzot::zot_record_preferred($r);
|
||||
if ($z) {
|
||||
$z['author_xchan'] = $r['hubloc_hash'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($z) {
|
||||
$s = new Zlib\Share($z);
|
||||
echo $s->bbcode();
|
||||
killme();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($url && $title && $text) {
|
||||
|
||||
$text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
|
||||
|
||||
|
@ -139,10 +171,10 @@ class Linkinfo extends Controller {
|
|||
|
||||
// If the site uses this platform, use zrl rather than url so they get zids sent to them by default
|
||||
|
||||
if(is_matrix_url($url))
|
||||
if (is_matrix_url($url))
|
||||
$template = str_replace('url','zrl',$template);
|
||||
|
||||
if($siteinfo["title"] == "") {
|
||||
if ($siteinfo["title"] == "") {
|
||||
echo sprintf($template,$url,$url,'') . $str_tags;
|
||||
killme();
|
||||
} else {
|
||||
|
@ -152,12 +184,12 @@ class Linkinfo extends Controller {
|
|||
|
||||
$image = "";
|
||||
|
||||
if(isset($siteinfo['images']) && is_array($siteinfo['images']) && count($siteinfo["images"])) {
|
||||
if (isset($siteinfo['images']) && is_array($siteinfo['images']) && count($siteinfo["images"])) {
|
||||
/* Execute below code only if image is present in siteinfo */
|
||||
|
||||
$total_images = 0;
|
||||
$max_images = get_config('system','max_bookmark_images');
|
||||
if($max_images === false)
|
||||
if ($max_images === false)
|
||||
$max_images = 2;
|
||||
else
|
||||
$max_images = intval($max_images);
|
||||
|
@ -172,16 +204,16 @@ class Linkinfo extends Controller {
|
|||
}
|
||||
$image .= "\n";
|
||||
$total_images ++;
|
||||
if($max_images && $max_images >= $total_images)
|
||||
if ($max_images && $max_images >= $total_images)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($text)) {
|
||||
if (strlen($text)) {
|
||||
$text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
|
||||
}
|
||||
|
||||
if($image) {
|
||||
if ($image) {
|
||||
$text = $br.$br.$image.$text;
|
||||
}
|
||||
$title = str_replace(array("\r","\n"),array('',''),$title);
|
||||
|
@ -216,7 +248,7 @@ class Linkinfo extends Controller {
|
|||
if ($schemearr["port"] != "")
|
||||
$complete .= ":".$schemearr["port"];
|
||||
|
||||
if(strpos($urlarr['path'],'/') !== 0)
|
||||
if (strpos($urlarr['path'],'/') !== 0)
|
||||
$complete .= '/';
|
||||
|
||||
$complete .= $urlarr["path"];
|
||||
|
@ -236,7 +268,7 @@ class Linkinfo extends Controller {
|
|||
|
||||
|
||||
$result = z_fetch_url($url,false,0,array('novalidate' => true));
|
||||
if(! $result['success'])
|
||||
if (! $result['success'])
|
||||
return $siteinfo;
|
||||
|
||||
$header = $result['header'];
|
||||
|
@ -244,7 +276,7 @@ class Linkinfo extends Controller {
|
|||
|
||||
// Check codepage in HTTP headers or HTML if not exist
|
||||
$cp = (preg_match('/Content-Type: text\/html; charset=(.+)\r\n/i', $header, $o) ? $o[1] : '');
|
||||
if(empty($cp))
|
||||
if (empty($cp))
|
||||
$cp = (preg_match('/meta.+content=["|\']text\/html; charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'AUTO');
|
||||
|
||||
$body = mb_convert_encoding($body, 'UTF-8', $cp);
|
||||
|
|
|
@ -10,15 +10,16 @@ namespace Zotlabs\Module;
|
|||
* @todo This setup module could need some love and improvements.
|
||||
*/
|
||||
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Web\Controller;
|
||||
use App;
|
||||
use DBA;
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Web\Controller;
|
||||
|
||||
/**
|
||||
* @brief Initialisation for the setup module.
|
||||
*
|
||||
*/
|
||||
|
||||
class Setup extends Controller {
|
||||
|
||||
private static $install_wizard_pass = 1;
|
||||
|
@ -27,6 +28,7 @@ class Setup extends Controller {
|
|||
* {@inheritDoc}
|
||||
* @see \\Zotlabs\\Web\\Controller::init()
|
||||
*/
|
||||
|
||||
function init() {
|
||||
// Ensure that if somebody hasn't read the install documentation and doesn't have all
|
||||
// the required modules or has a totally borked shared hosting provider and they can't
|
||||
|
@ -63,7 +65,7 @@ class Setup extends Controller {
|
|||
*/
|
||||
function post() {
|
||||
|
||||
switch($this->install_wizard_pass) {
|
||||
switch ($this->install_wizard_pass) {
|
||||
case 1:
|
||||
case 2:
|
||||
return;
|
||||
|
@ -148,7 +150,7 @@ class Setup extends Controller {
|
|||
|
||||
$result = file_put_contents('.htconfig.php', $txt);
|
||||
if(! $result) {
|
||||
\App::$data['txt'] = $txt;
|
||||
App::$data['txt'] = $txt;
|
||||
}
|
||||
|
||||
$errors = $this->load_database($db);
|
||||
|
@ -376,12 +378,12 @@ class Setup extends Controller {
|
|||
* @param string $help optional help string
|
||||
*/
|
||||
function check_add(&$checks, $title, $status, $required, $help = '') {
|
||||
$checks[] = array(
|
||||
$checks[] = [
|
||||
'title' => $title,
|
||||
'status' => $status,
|
||||
'required' => $required,
|
||||
'help' => $help
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,7 +397,7 @@ class Setup extends Controller {
|
|||
|
||||
if(version_compare(PHP_VERSION, '7.1') < 0) {
|
||||
$help .= t('PHP version 7.1 or greater is required.');
|
||||
$this->check_add($checks, t('PHP version'), false, false, $help);
|
||||
$this->check_add($checks, t('PHP version'), false, true, $help);
|
||||
}
|
||||
|
||||
if (strlen($phpath)) {
|
||||
|
@ -412,7 +414,7 @@ class Setup extends Controller {
|
|||
|
||||
if(!$passed) {
|
||||
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
|
||||
$help .= t('If you don\'t have a command line version of PHP installed on server, you will not be able to run background polling via cron.') . EOL;
|
||||
$help .= t('If you do not have a command line version of PHP installed on server, you will not be able to run background tasks - including message delivery.') . EOL;
|
||||
$help .= EOL;
|
||||
$tpl = get_markup_template('field_input.tpl');
|
||||
$help .= replace_macros($tpl, array(
|
||||
|
|
|
@ -1818,4 +1818,4 @@ dl.bb-dl > dd > li {
|
|||
|
||||
.channel-active {
|
||||
border: 3px solid #0275d8;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue