. * */ use Friendica\App; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Post; function share_init(App $a) { $post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0); if (!$post_id || !local_user()) { System::exit(); } $fields = ['private', 'body', 'uri']; $item = Post::selectFirst($fields, ['id' => $post_id]); if (!DBA::isResult($item) || $item['private'] == Item::PRIVATE) { System::exit(); } if (strpos($item['body'], "[/share]") !== false) { $pos = strpos($item['body'], "[share"); $o = substr($item['body'], $pos); } else { $o = "[share message_id='" . $item['uri'] . "'][/share]"; } echo $o; System::exit(); }