예제 #1
0
 public static function getPostsForEvent($event_id)
 {
     $app = \Slim\Slim::getInstance();
     //return all post
     $allGetVars = $app->request->get();
     //default startAt = 0, limit = 15
     $startAt = @$allGetVars['startAt'] ? intval($allGetVars['startAt']) : 0;
     $limit = @$allGetVars['limit'] ? $allGetVars['limit'] : 15;
     $orderBy = @$allGetVars['orderBy'] ? $allGetVars['orderBy'] : "datetime";
     if (!filter_var($event_id, FILTER_VALIDATE_INT) || !filter_var($limit, FILTER_VALIDATE_INT)) {
         $app->render(400, ['Status' => 'Invalid event id.']);
         return;
     }
     if ($orderBy != "post_id") {
         $orderBy = "datetime";
     }
     $event = \relive\models\Event::find($event_id);
     if ($event) {
         $event->rankPoints = $event->rankPoints + 1;
         $event->save();
         $crawljob = \relive\models\CrawlJob::where('event_id', '=', $event_id)->first();
         if ($crawljob) {
             $crawljob->delay = 10;
             $crawljob->save();
         }
         $posts = \relive\models\Post::whereIn('post_id', function ($query) use($event_id) {
             $query->select('post_id')->from('posteventrelationships')->where('event_id', '=', $event_id)->where('isFiltered', False);
         })->orderBy('datetime', 'desc')->offset($startAt)->limit($limit)->get();
         echo json_encode($posts, JSON_UNESCAPED_SLASHES);
     } else {
         $app->render(404, ['Status', 'Event not found.']);
     }
 }
예제 #2
0
}
if (!isset($_SESSION['login'])) {
    include './relive/templates/login.php';
} else {
    if (isset($_GET)) {
        if (isset($_GET['publish'])) {
            $event = \relive\models\Event::find($_GET['event_id']);
            $event->isPublished = 1;
            if (isset($_GET['start'])) {
                $event->startDate = strtotime($_GET['start']);
            }
            if (isset($_GET['end'])) {
                $event->endDate = strtotime($_GET['end']);
            }
            \relive\misc\FacebookPagePoster::post($event->event_id);
            \relive\models\CrawlJob::create(['event_id' => $event->event_id]);
            $event->save();
        }
        if (isset($_GET['deleteevent'])) {
            $event_id = $_GET['event_id'];
            \relive\models\Event::find($event_id)->delete();
            \relive\models\Post::whereNotIn('post_id', function ($query) {
                $query->select('post_id')->from('posteventrelationships');
            })->delete();
        }
        if (isset($_GET['post_id'])) {
            if (isset($_GET['filter'])) {
                $post = \relive\models\PostEventRelationship::whereIn('post_id', function ($query) {
                    $query->select('post_id')->from('reports')->where('post_id', '=', $_GET['post_id']);
                })->first();
                $post->isFiltered = 1;
예제 #3
0
             if ($event->endDate + 86400 < $currentTime) {
                 print "[" . date('c') . "]\t" . "Setting isActive to false for event:" . $event->event_id . "->" . $event->eventName . "\n";
                 $job->isActive = 0;
             }
             $job->delay = $job->delay * 2;
             $job->save();
         }
         unset($crawling[$job->crawler_id]);
         if ($objPQ->valid()) {
             $top = $objPQ->top();
         } else {
             break;
         }
     }
 }
 $jobs = \relive\models\CrawlJob::where('isActive', '=', 1)->where('delay', '<', 1440)->get();
 $currentTime = time();
 foreach ($jobs as $job) {
     if (!@$crawling[$job->crawler_id]) {
         $crawling[$job->crawler_id] = $job->delay;
         $objPQ->insert($job, $currentTime + $job->delay * 60);
     } else {
         if ($crawling[$job->crawler_id] > $job->delay) {
             $newObjPQ = new PQCrawlJob();
             $newObjPQ->setExtractFlags(PQCrawlJob::EXTR_BOTH);
             foreach ($objPQ as $obj) {
                 if ($obj['data']->event_id == $job->event_id) {
                     $crawling[$job->crawler_id] = $job->delay;
                     $newObjPQ->insert($job, $currentTime + $job->delay * 60);
                 } else {
                     $newObjPQ->insert($obj['data'], $obj['priority']);
예제 #4
0
<?php

require_once '/var/www/vendor/autoload.php';
use relive\Crawlers\TwitterCrawler;
use relive\Crawlers\InstagramCrawler;
use relive\Crawlers\GPlusCrawler;
$twitter = TwitterCrawler::getInstance();
$instagram = InstagramCrawler::getInstance();
$gplus = GPlusCrawler::getInstance();
$jobs = \relive\models\CrawlJob::where('isActive', '=', 1)->get();
foreach ($jobs as $job) {
    $event = \relive\models\Event::find($job->event_id);
    $hashtagRelationships = \relive\models\EventHashtagRelationship::where('event_id', '=', $job->event_id)->get();
    foreach ($hashtagRelationships as $hashtagRelationship) {
        $hashtag = \relive\models\Hashtag::find($hashtagRelationship->hashtag_id);
        $twitter->recentCrawl($event, $hashtag->hashtag);
        $instagram->recentCrawl($event, $hashtag->hashtag);
        $gplus->recentCrawl($event, $hashtag->hashtag);
    }
}