mirror of
https://github.com/openvk/openvk
synced 2025-03-31 05:38:12 +03:00
Compare commits
No commits in common. "b9687b1fb28cf45db01813ba83d659d7ac045ae5" and "96d48efbafafead869460304113d26f306b124ad" have entirely different histories.
b9687b1fb2
...
96d48efbaf
5 changed files with 11 additions and 104 deletions
|
@ -48,7 +48,7 @@ final class Newsfeed extends VKAPIRequestHandler
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGlobal(string $fields = "", int $start_from = 0, int $start_time = 0, int $end_time = 0, int $offset = 0, int $count = 30, int $extended = 0, int $rss = 0)
|
function getGlobal(string $fields = "", int $start_from = 0, int $start_time = 0, int $end_time = 0, int $offset = 0, int $count = 30, int $extended = 0)
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
|
||||||
|
@ -74,25 +74,6 @@ final class Newsfeed extends VKAPIRequestHandler
|
||||||
|
|
||||||
$rposts = [];
|
$rposts = [];
|
||||||
$ids = [];
|
$ids = [];
|
||||||
if($rss == 1) {
|
|
||||||
$channel = new \Bhaktaraz\RSSGenerator\Channel();
|
|
||||||
$channel->title("Global Feed — " . OPENVK_ROOT_CONF['openvk']['appearance']['name'])
|
|
||||||
->description('OVK Global feed')
|
|
||||||
->url(ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/feed/all");
|
|
||||||
|
|
||||||
foreach($posts as $item) {
|
|
||||||
$post = (new PostsRepo)->get($item->id);
|
|
||||||
if(!$post || $post->isDeleted()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = $post->toRss();
|
|
||||||
$output->appendTo($channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($posts as $post) {
|
foreach($posts as $post) {
|
||||||
$rposts[] = (new PostsRepo)->get($post->id)->getPrettyId();
|
$rposts[] = (new PostsRepo)->get($post->id)->getPrettyId();
|
||||||
$ids[] = $post->id;
|
$ids[] = $post->id;
|
||||||
|
|
|
@ -20,7 +20,7 @@ use openvk\Web\Models\Repositories\Audios as AudiosRepo;
|
||||||
|
|
||||||
final class Wall extends VKAPIRequestHandler
|
final class Wall extends VKAPIRequestHandler
|
||||||
{
|
{
|
||||||
function get(int $owner_id, string $domain = "", int $offset = 0, int $count = 30, int $extended = 0, string $filter = "all", int $rss = 0): object
|
function get(int $owner_id, string $domain = "", int $offset = 0, int $count = 30, int $extended = 0, string $filter = "all"): object
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
|
||||||
|
@ -86,8 +86,6 @@ final class Wall extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$iteratorv = iterator_to_array($iteratorv);
|
|
||||||
|
|
||||||
foreach($iteratorv as $post) {
|
foreach($iteratorv as $post) {
|
||||||
$from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId();
|
$from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId();
|
||||||
|
|
||||||
|
@ -219,20 +217,6 @@ final class Wall extends VKAPIRequestHandler
|
||||||
$attachments = NULL; # free attachments so it will not clone everythingg
|
$attachments = NULL; # free attachments so it will not clone everythingg
|
||||||
}
|
}
|
||||||
|
|
||||||
if($rss == 1) {
|
|
||||||
$channel = new \Bhaktaraz\RSSGenerator\Channel();
|
|
||||||
$channel->title($wallOnwer->getCanonicalName() . " — " . OPENVK_ROOT_CONF['openvk']['appearance']['name'])
|
|
||||||
->description('Wall of ' . $wallOnwer->getCanonicalName())
|
|
||||||
->url(ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/wall" . $wallOnwer->getRealId());
|
|
||||||
|
|
||||||
foreach($iteratorv as $item) {
|
|
||||||
$output = $item->toRss();
|
|
||||||
$output->appendTo($channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($extended == 1) {
|
if($extended == 1) {
|
||||||
$profiles = array_unique($profiles);
|
$profiles = array_unique($profiles);
|
||||||
$groups = array_unique($groups);
|
$groups = array_unique($groups);
|
||||||
|
|
|
@ -373,47 +373,6 @@ class Post extends Postable
|
||||||
|
|
||||||
return $user->getId() == $this->getOwner(false)->getId();
|
return $user->getId() == $this->getOwner(false)->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toRss(): \Bhaktaraz\RSSGenerator\Item
|
|
||||||
{
|
|
||||||
$domain = ovk_scheme(true).$_SERVER["HTTP_HOST"];
|
|
||||||
$description = $this->getText(false);
|
|
||||||
$description_html = $description;
|
|
||||||
$url = $domain."/wall".$this->getPrettyId();
|
|
||||||
|
|
||||||
$author = $this->getOwner();
|
|
||||||
$author_name = htmlspecialchars($author->getCanonicalName(), ENT_DISALLOWED | ENT_XHTML);
|
|
||||||
if($this->isExplicit())
|
|
||||||
$description_html .= "<br /><b>".tr('contains_nsfw').".</b><br />";
|
|
||||||
|
|
||||||
foreach($this->getChildren() as $child) {
|
|
||||||
if($child instanceof Photo) {
|
|
||||||
$child_page = $domain.$child->getPageURL();
|
|
||||||
$child_url = $child->getURLBySizeId('large');
|
|
||||||
$description_html .= "<br /><a href='$child_page'><img src='$child_url'></a>";
|
|
||||||
} elseif($child instanceof Video) {
|
|
||||||
$child_page = $domain.'/video'.$child->getPrettyId();
|
|
||||||
$description_html .= "<br /><a href='$child_page'>Video</a>";
|
|
||||||
} elseif($child instanceof Audio) {
|
|
||||||
$description_html .= "<br />Audio";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$description_html .= "<br />".tr('author').": <img width='15px' src='".$author->getAvatarURL()."'><a href='".$author->getURL()."'>" . $author_name . "</a>";
|
|
||||||
if($this->hasSource()) {
|
|
||||||
$description_html .= "<br />".tr('source').": ".htmlspecialchars($this->getSource(), ENT_DISALLOWED | ENT_XHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
$item = new \Bhaktaraz\RSSGenerator\Item();
|
|
||||||
$item->title(str_replace("\n", "", ovk_proc_strtr($description, 79)))
|
|
||||||
->url($url)
|
|
||||||
->guid($url)
|
|
||||||
->creator($author_name)
|
|
||||||
->pubDate($this->getPublicationTime()->timestamp())
|
|
||||||
->content(str_replace("\n", "<br />", $description_html));
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
use Traits\TRichText;
|
use Traits\TRichText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
|
|
||||||
$userValidated = 1;
|
$userValidated = 1;
|
||||||
$cacheTime = 0; # Force no cache
|
$cacheTime = 0; # Force no cache
|
||||||
if(!property_exists($this, 'silent') && $this->user->identity->onlineStatus() == 0 && !($this->user->identity->isDeleted() || $this->user->identity->isBanned())) {
|
if($this->user->identity->onlineStatus() == 0 && !($this->user->identity->isDeleted() || $this->user->identity->isBanned())) {
|
||||||
$this->user->identity->setOnline(time());
|
$this->user->identity->setOnline(time());
|
||||||
$this->user->identity->setClient_name(NULL);
|
$this->user->identity->setClient_name(NULL);
|
||||||
$this->user->identity->save(false);
|
$this->user->identity->save(false);
|
||||||
|
|
|
@ -10,7 +10,6 @@ use WhichBrowser;
|
||||||
|
|
||||||
final class VKAPIPresenter extends OpenVKPresenter
|
final class VKAPIPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
protected $silent = true;
|
|
||||||
private function logRequest(string $object, string $method): void
|
private function logRequest(string $object, string $method): void
|
||||||
{
|
{
|
||||||
$date = date(DATE_COOKIE);
|
$date = date(DATE_COOKIE);
|
||||||
|
@ -223,13 +222,9 @@ final class VKAPIPresenter extends OpenVKPresenter
|
||||||
if(!is_callable([$handler, $method]))
|
if(!is_callable([$handler, $method]))
|
||||||
$this->badMethod($object, $method);
|
$this->badMethod($object, $method);
|
||||||
|
|
||||||
$has_rss = false;
|
|
||||||
$route = new \ReflectionMethod($handler, $method);
|
$route = new \ReflectionMethod($handler, $method);
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach($route->getParameters() as $parameter) {
|
foreach($route->getParameters() as $parameter) {
|
||||||
if($parameter->getName() == 'rss')
|
|
||||||
$has_rss = true;
|
|
||||||
|
|
||||||
$val = $this->requestParam($parameter->getName());
|
$val = $this->requestParam($parameter->getName());
|
||||||
if(is_null($val)) {
|
if(is_null($val)) {
|
||||||
if($parameter->allowsNull())
|
if($parameter->allowsNull())
|
||||||
|
@ -265,27 +260,15 @@ final class VKAPIPresenter extends OpenVKPresenter
|
||||||
$this->fail($ex->getCode(), $ex->getMessage(), $object, $method);
|
$this->fail($ex->getCode(), $ex->getMessage(), $object, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = NULL;
|
$result = json_encode([
|
||||||
|
"response" => $res,
|
||||||
|
]);
|
||||||
|
|
||||||
if($this->queryParam("rss") == '1' && $has_rss) {
|
if($callback) {
|
||||||
$feed = new \Bhaktaraz\RSSGenerator\Feed();
|
$result = $callback . '(' . $result . ')';
|
||||||
$res->appendTo($feed);
|
header('Content-Type: application/javascript');
|
||||||
|
} else
|
||||||
$result = strval($feed);
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
header("Content-Type: application/rss+xml;charset=UTF-8");
|
|
||||||
} else {
|
|
||||||
$result = json_encode([
|
|
||||||
"response" => $res,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if($callback) {
|
|
||||||
$result = $callback . '(' . $result . ')';
|
|
||||||
header('Content-Type: application/javascript');
|
|
||||||
} else {
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$size = strlen($result);
|
$size = strlen($result);
|
||||||
header("Content-Length: $size");
|
header("Content-Length: $size");
|
||||||
|
|
Loading…
Reference in a new issue