public static function post($event_id) { if (isset($event_id)) { try { $event = Event::findOrFail($event_id); $fb = new \Facebook\Facebook(['app_id' => getenv('FACEBOOK_APP_ID'), 'app_secret' => getenv('FACEBOOK_APP_SECRET'), 'default_graph_version' => 'v2.4', 'default_access_token' => getenv('FACEBOOK_PAGE_TOKEN')]); $fbPageId = getenv('FACEBOOK_PAGE_ID'); $sourceLink = "https://relive.space/event/" . $event->event_id; $fbPostMessage = "The event \"" . $event->eventName . "\" was just added to relive.space!\n\n" . $sourceLink; $response = $fb->post('/' . $fbPageId . '/feed', ['message' => $fbPostMessage]); echo json_encode($response); } catch (ModelNotFoundException $e) { echo "event " . $event_id . " not found!"; } } }
<?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); }
<?php require_once '/var/www/vendor/autoload.php'; use relive\models\Event; //Every 24 hours foreach (Event::all() as $event) { $event->rankPoints = $event->rankPoints / 2; $event->save(); }
} } 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'; }
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.']); } }