Esempio n. 1
0
 private function createHashtags($post, $twitterPost)
 {
     $hashtags = $twitterPost->entities->hashtags;
     foreach ($hashtags as $tag) {
         $tagText = htmlspecialchars($tag->text, ENT_QUOTES, 'UTF-8');
         $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $tagText]);
         $posthashtagrelationship = \relive\models\PostHashtagRelationship::firstOrCreate(['post_id' => $post->post_id, 'hashtag_id' => $hashtag->hashtag_id]);
     }
 }
Esempio n. 2
0
 public static function getEventWithHashtag($hashtag)
 {
     $app = \Slim\Slim::getInstance();
     if (is_null($hashtag) || strlen($hashtag) > 255 || empty($hashtag)) {
         $app->render(400, ['Status' => 'Invalid input.']);
         return;
     }
     $hashtag = \relive\models\Hashtag::where('hashtag', $hashtag)->get();
     if (count($hashtag) > 0) {
         $hashtagobj = $hashtag->first()->toArray();
         echo json_encode($hashtagobj, JSON_UNESCAPED_SLASHES);
     } else {
         $app->render(404, ['Status', 'Hashtag not found.']);
     }
 }
Esempio n. 3
0
<?php

require_once '/var/www/vendor/autoload.php';
use relive\Crawlers\TwitterCrawler;
use relive\Crawlers\InstagramCrawler;
use relive\Crawlers\GPlusCrawler;
$event_id = $argv[1];
$event = \relive\models\Event::find($event_id);
$twitterCrawler = TwitterCrawler::getInstance();
$instagramCrawler = InstagramCrawler::getInstance();
$gPlusCrawler = GPlusCrawler::getInstance();
$hashtagRelationships = \relive\models\EventHashtagRelationship::where('event_id', '=', $event->event_id)->get();
foreach ($hashtagRelationships as $hashtagRelationship) {
    $hashtag = \relive\models\Hashtag::find($hashtagRelationship->hashtag_id);
    $twitterCrawler->popularCrawl($event, $hashtag->hashtag);
    $instagramCrawler->initialCrawl($event, $hashtag->hashtag);
    $gPlusCrawler->initialCrawl($event, $hashtag->hashtag);
}
Esempio n. 4
0
            }
        }
        if (isset($_GET['updateevent'])) {
            $event_id = $_GET['event_id'];
            $event = \relive\models\Event::find($event_id);
            $event->eventName = $_GET['eventName'];
            $event->startDate = strtotime($_GET['startDate']);
            $event->endDate = strtotime($_GET['endDate']);
            $event->save();
            \relive\models\EventHashtagRelationship::where('event_id', '=', $event_id)->delete();
            $hashtags = array();
            if (isset($_GET['hashtag1']) && $_GET['hashtag1'] !== '') {
                $hashtags[] = $_GET['hashtag1'];
            }
            if (isset($_GET['hashtag2']) && $_GET['hashtag2'] !== '') {
                $hashtags[] = $_GET['hashtag2'];
            }
            if (isset($_GET['hashtag3']) && $_GET['hashtag3'] !== '') {
                $hashtags[] = $_GET['hashtag3'];
            }
            foreach ($hashtags as $tag) {
                $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $tag]);
                $eventhashtagrelationship = \relive\models\EventHashtagRelationship::firstOrCreate(['event_id' => $event_id, 'hashtag_id' => $hashtag->hashtag_id]);
            }
        }
    }
    $unpublishedEvents = \relive\models\Event::where('isPublished', '=', '0')->get();
    $publishedEvents = \relive\models\Event::where('isPublished', '=', '1')->get();
    $reportedPosts = \relive\models\Post::join('reports', 'posts.post_id', '=', 'reports.post_id')->groupBy('posts.post_id')->selectRaw('*,(select count(*) from reports c where c.post_id = posts.post_id) as `count`')->where('isSettled', '=', 0)->orderBy('datetime', 'desc')->get();
    include './relive/templates/moderate.php';
}
Esempio n. 5
0
 private function createHashtags($post, $content)
 {
     preg_match_all('/#([^\\s]+)/', $content, $matches);
     $hashtags = $matches[1];
     foreach ($hashtags as $tag) {
         $tagText = htmlspecialchars($tag, ENT_QUOTES, 'UTF-8');
         $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $tagText]);
         $posthashtagrelationship = \relive\models\PostHashtagRelationship::firstOrCreate(['post_id' => $post->post_id, 'hashtag_id' => $hashtag->hashtag_id]);
     }
 }
Esempio n. 6
0
 public static function addHashtagToEvent($event_id)
 {
     $app = \Slim\Slim::getInstance();
     $allPostVars = $app->request->post();
     $hashtag = @$allPostVars['hashtag'] ? trim($allPostVars['hashtag']) : NULL;
     $hashtag = htmlspecialchars($hashtag, ENT_QUOTES, 'UTF-8');
     if (!filter_var($event_id, FILTER_VALIDATE_INT) || is_null($hashtag) || strlen($hashtag) > 255 || empty($hashtag)) {
         $app->render(400, ['Status' => 'Invalid input.']);
         return;
     }
     $event = \relive\models\Event::find($event_id);
     $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $hashtag]);
     $eventhashtagrelationship = \relive\models\EventHashtagRelationship::firstOrCreate(['event_id' => $event->event_id, 'hashtag_id' => $hashtag->hashtag_id]);
     if ($event) {
         echo json_encode($event, JSON_UNESCAPED_SLASHES);
     } else {
         $app->render(404, ['Status', 'Event not found.']);
     }
 }
Esempio n. 7
0
<?php

require_once '/var/www/vendor/autoload.php';
if (isset($_GET['event_id'])) {
    $event = \relive\models\SearchIndex::find($_GET['event_id']);
}
if ($event) {
    $hashtags = \relive\models\Hashtag::whereIn('hashtag_id', function ($query) use($event) {
        $query->select('hashtag_id')->from('eventhashtagrelationships')->where('event_id', '=', $event->event_id);
    })->select('hashtag')->get();
    $tags = [];
    foreach ($hashtags as $hashtag) {
        array_push($tags, $hashtag->hashtag);
    }
    $keyword = join(',', $tags);
    $posts = \relive\models\Post::whereIn('post_id', function ($query) use($event) {
        $query->select('post_id')->from('posteventrelationships')->where('event_id', '=', $event->event_id)->where('isFiltered', False);
    })->orderBy('datetime', 'desc')->offset(0)->limit(15)->get();
} else {
    header("Location: http://relive.space/");
}
?>
<!DOCTYPE html>
<html lang="en">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb##">
    <meta charset="UTF-8">
    <title>relive</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon" sizes="57x57" href="//relive.space/apple-touch-icon-57x57.png">