{"action":"created","comment":{"url":"https://api.github.com/repos/ternel/weekend-website/pulls/comments/59860791","id":59860791,"diff_hunk":"@@ -157,4 +161,63 @@ private function checkTomorrowNotWorkingDay()\n \n         return array_search($tomorrow, $this->getHolidays());\n     }\n+\n+    /**\n+     * Avoid calling ip file every day & every hit\n+     *\n+     * @param $easterDate\n+     * @param $year\n+     * @return bool\n+     */\n+    private function isAlsacianHolidaysDate($easterDate, $year)\n+    {\n+        //3 days before easter, can't $easterDay - 2 if easter is the first day of month\n+         return date('d-m-Y') == date('d-m-Y', mktime(0, 0, 0, 12, 26, $year)) ||\n+            date('d-m-Y') == date('d-m-Y', mktime($easterDate - (3600 * 2 * 24)));\n+    }\n+\n+    /**\n+     * We call ipinfo if we are on alsacian holidays\n+     *\n+     * @param $easterDate\n+     * @param $year\n+     * @return array\n+     */\n+    private function addAlsacianHolidays($easterDate, $year)\n+    {\n+        //3 days before easter, can't $easterDay - 2 if easter is the first day of month\n+        $alsacianHolidays = [\n+            'vendredisaint' => date('d-m-Y', mktime($easterDate - (3600 * 2 * 24))),\n+            'saintetienne' => date('d-m-Y', mktime(0, 0, 0, 12, 26, $year))\n+        ];\n+\n+        //fast ip\n+        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {\n+            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];\n+        }elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {\n+            $ip = $_SERVER['HTTP_CLIENT_IP'];\n+        }else{\n+            $ip = $_SERVER['REMOTE_ADDR'];\n+        }\n+\n+        //we allow only 3 districts\n+        $districsAllowed = [\n+            '67',\n+            '68',\n+            '90',\n+            '57'\n+        ];\n+\n+        //yolo json\n+        $json = json_decode(file_get_contents('http://ipinfo.io/' . $ip . '/json'));","path":"src/Ternel/Weekend.php","position":69,"original_position":69,"commit_id":"5017293fafcdda0cf53426e3f94b5ad7048bca66","original_commit_id":"5017293fafcdda0cf53426e3f94b5ad7048bca66","user":{"login":"damienalexandre","id":225704,"avatar_url":"https://avatars.githubusercontent.com/u/225704?v=3","gravatar_id":"","url":"https://api.github.com/users/damienalexandre","html_url":"https://github.com/damienalexandre","followers_url":"https://api.github.com/users/damienalexandre/followers","following_url":"https://api.github.com/users/damienalexandre/following{/other_user}","gists_url":"https://api.github.com/users/damienalexandre/gists{/gist_id}","starred_url":"https://api.github.com/users/damienalexandre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damienalexandre/subscriptions","organizations_url":"https://api.github.com/users/damienalexandre/orgs","repos_url":"https://api.github.com/users/damienalexandre/repos","events_url":"https://api.github.com/users/damienalexandre/events{/privacy}","received_events_url":"https://api.github.com/users/damienalexandre/received_events","type":"User","site_admin":false},"body":"You should add a try/catch around this because the rate limite is 1,000 Daily Requests, and this website is so popular it might break really really fast :+1: ","created_at":"2016-04-15T11:25:23Z","updated_at":"2016-04-15T11:25:23Z","html_url":"https://github.com/ternel/weekend-website/pull/9#discussion_r59860791","pull_request_url":"https://api.github.com/repos/ternel/weekend-website/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/comments/59860791"},"html":{"href":"https://github.com/ternel/weekend-website/pull/9#discussion_r59860791"},"pull_request":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/ternel/weekend-website/pulls/9","id":66575963,"html_url":"https://github.com/ternel/weekend-website/pull/9","diff_url":"https://github.com/ternel/weekend-website/pull/9.diff","patch_url":"https://github.com/ternel/weekend-website/pull/9.patch","issue_url":"https://api.github.com/repos/ternel/weekend-website/issues/9","number":9,"state":"open","locked":false,"title":"#4 Alsacian holidays","user":{"login":"pgrimaud","id":1866496,"avatar_url":"https://avatars.githubusercontent.com/u/1866496?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrimaud","html_url":"https://github.com/pgrimaud","followers_url":"https://api.github.com/users/pgrimaud/followers","following_url":"https://api.github.com/users/pgrimaud/following{/other_user}","gists_url":"https://api.github.com/users/pgrimaud/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrimaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrimaud/subscriptions","organizations_url":"https://api.github.com/users/pgrimaud/orgs","repos_url":"https://api.github.com/users/pgrimaud/repos","events_url":"https://api.github.com/users/pgrimaud/events{/privacy}","received_events_url":"https://api.github.com/users/pgrimaud/received_events","type":"User","site_admin":false},"body":"- Tests needed\r\n- Drunk\r\n- Vive l'alsace","created_at":"2016-04-15T00:47:28Z","updated_at":"2016-04-15T11:25:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c33a50cc9eadbda6c4cc308e295631fad9d893f9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ternel/weekend-website/pulls/9/commits","review_comments_url":"https://api.github.com/repos/ternel/weekend-website/pulls/9/comments","review_comment_url":"https://api.github.com/repos/ternel/weekend-website/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ternel/weekend-website/issues/9/comments","statuses_url":"https://api.github.com/repos/ternel/weekend-website/statuses/5017293fafcdda0cf53426e3f94b5ad7048bca66","head":{"label":"pgrimaud:alsacian-holidays","ref":"alsacian-holidays","sha":"5017293fafcdda0cf53426e3f94b5ad7048bca66","user":{"login":"pgrimaud","id":1866496,"avatar_url":"https://avatars.githubusercontent.com/u/1866496?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrimaud","html_url":"https://github.com/pgrimaud","followers_url":"https://api.github.com/users/pgrimaud/followers","following_url":"https://api.github.com/users/pgrimaud/following{/other_user}","gists_url":"https://api.github.com/users/pgrimaud/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrimaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrimaud/subscriptions","organizations_url":"https://api.github.com/users/pgrimaud/orgs","repos_url":"https://api.github.com/users/pgrimaud/repos","events_url":"https://api.github.com/users/pgrimaud/events{/privacy}","received_events_url":"https://api.github.com/users/pgrimaud/received_events","type":"User","site_admin":false},"repo":{"id":56277333,"name":"weekend-website","full_name":"pgrimaud/weekend-website","owner":{"login":"pgrimaud","id":1866496,"avatar_url":"https://avatars.githubusercontent.com/u/1866496?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrimaud","html_url":"https://github.com/pgrimaud","followers_url":"https://api.github.com/users/pgrimaud/followers","following_url":"https://api.github.com/users/pgrimaud/following{/other_user}","gists_url":"https://api.github.com/users/pgrimaud/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrimaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrimaud/subscriptions","organizations_url":"https://api.github.com/users/pgrimaud/orgs","repos_url":"https://api.github.com/users/pgrimaud/repos","events_url":"https://api.github.com/users/pgrimaud/events{/privacy}","received_events_url":"https://api.github.com/users/pgrimaud/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pgrimaud/weekend-website","description":"estcequecestbientotleweekend.fr","fork":true,"url":"https://api.github.com/repos/pgrimaud/weekend-website","forks_url":"https://api.github.com/repos/pgrimaud/weekend-website/forks","keys_url":"https://api.github.com/repos/pgrimaud/weekend-website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pgrimaud/weekend-website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pgrimaud/weekend-website/teams","hooks_url":"https://api.github.com/repos/pgrimaud/weekend-website/hooks","issue_events_url":"https://api.github.com/repos/pgrimaud/weekend-website/issues/events{/number}","events_url":"https://api.github.com/repos/pgrimaud/weekend-website/events","assignees_url":"https://api.github.com/repos/pgrimaud/weekend-website/assignees{/user}","branches_url":"https://api.github.com/repos/pgrimaud/weekend-website/branches{/branch}","tags_url":"https://api.github.com/repos/pgrimaud/weekend-website/tags","blobs_url":"https://api.github.com/repos/pgrimaud/weekend-website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pgrimaud/weekend-website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pgrimaud/weekend-website/git/refs{/sha}","trees_url":"https://api.github.com/repos/pgrimaud/weekend-website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pgrimaud/weekend-website/statuses/{sha}","languages_url":"https://api.github.com/repos/pgrimaud/weekend-website/languages","stargazers_url":"https://api.github.com/repos/pgrimaud/weekend-website/stargazers","contributors_url":"https://api.github.com/repos/pgrimaud/weekend-website/contributors","subscribers_url":"https://api.github.com/repos/pgrimaud/weekend-website/subscribers","subscription_url":"https://api.github.com/repos/pgrimaud/weekend-website/subscription","commits_url":"https://api.github.com/repos/pgrimaud/weekend-website/commits{/sha}","git_commits_url":"https://api.github.com/repos/pgrimaud/weekend-website/git/commits{/sha}","comments_url":"https://api.github.com/repos/pgrimaud/weekend-website/comments{/number}","issue_comment_url":"https://api.github.com/repos/pgrimaud/weekend-website/issues/comments{/number}","contents_url":"https://api.github.com/repos/pgrimaud/weekend-website/contents/{+path}","compare_url":"https://api.github.com/repos/pgrimaud/weekend-website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pgrimaud/weekend-website/merges","archive_url":"https://api.github.com/repos/pgrimaud/weekend-website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pgrimaud/weekend-website/downloads","issues_url":"https://api.github.com/repos/pgrimaud/weekend-website/issues{/number}","pulls_url":"https://api.github.com/repos/pgrimaud/weekend-website/pulls{/number}","milestones_url":"https://api.github.com/repos/pgrimaud/weekend-website/milestones{/number}","notifications_url":"https://api.github.com/repos/pgrimaud/weekend-website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pgrimaud/weekend-website/labels{/name}","releases_url":"https://api.github.com/repos/pgrimaud/weekend-website/releases{/id}","deployments_url":"https://api.github.com/repos/pgrimaud/weekend-website/deployments","created_at":"2016-04-14T23:56:58Z","updated_at":"2016-04-14T23:57:00Z","pushed_at":"2016-04-15T09:16:56Z","git_url":"git://github.com/pgrimaud/weekend-website.git","ssh_url":"git@github.com:pgrimaud/weekend-website.git","clone_url":"https://github.com/pgrimaud/weekend-website.git","svn_url":"https://github.com/pgrimaud/weekend-website","homepage":"http://estcequecestbientotleweekend.fr","size":24,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ternel:master","ref":"master","sha":"3e22eed8f7b2d4a19786ceab54782d730c8f532f","user":{"login":"ternel","id":359558,"avatar_url":"https://avatars.githubusercontent.com/u/359558?v=3","gravatar_id":"","url":"https://api.github.com/users/ternel","html_url":"https://github.com/ternel","followers_url":"https://api.github.com/users/ternel/followers","following_url":"https://api.github.com/users/ternel/following{/other_user}","gists_url":"https://api.github.com/users/ternel/gists{/gist_id}","starred_url":"https://api.github.com/users/ternel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ternel/subscriptions","organizations_url":"https://api.github.com/users/ternel/orgs","repos_url":"https://api.github.com/users/ternel/repos","events_url":"https://api.github.com/users/ternel/events{/privacy}","received_events_url":"https://api.github.com/users/ternel/received_events","type":"User","site_admin":false},"repo":{"id":6472516,"name":"weekend-website","full_name":"ternel/weekend-website","owner":{"login":"ternel","id":359558,"avatar_url":"https://avatars.githubusercontent.com/u/359558?v=3","gravatar_id":"","url":"https://api.github.com/users/ternel","html_url":"https://github.com/ternel","followers_url":"https://api.github.com/users/ternel/followers","following_url":"https://api.github.com/users/ternel/following{/other_user}","gists_url":"https://api.github.com/users/ternel/gists{/gist_id}","starred_url":"https://api.github.com/users/ternel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ternel/subscriptions","organizations_url":"https://api.github.com/users/ternel/orgs","repos_url":"https://api.github.com/users/ternel/repos","events_url":"https://api.github.com/users/ternel/events{/privacy}","received_events_url":"https://api.github.com/users/ternel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ternel/weekend-website","description":"estcequecestbientotleweekend.fr","fork":false,"url":"https://api.github.com/repos/ternel/weekend-website","forks_url":"https://api.github.com/repos/ternel/weekend-website/forks","keys_url":"https://api.github.com/repos/ternel/weekend-website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ternel/weekend-website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ternel/weekend-website/teams","hooks_url":"https://api.github.com/repos/ternel/weekend-website/hooks","issue_events_url":"https://api.github.com/repos/ternel/weekend-website/issues/events{/number}","events_url":"https://api.github.com/repos/ternel/weekend-website/events","assignees_url":"https://api.github.com/repos/ternel/weekend-website/assignees{/user}","branches_url":"https://api.github.com/repos/ternel/weekend-website/branches{/branch}","tags_url":"https://api.github.com/repos/ternel/weekend-website/tags","blobs_url":"https://api.github.com/repos/ternel/weekend-website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ternel/weekend-website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ternel/weekend-website/git/refs{/sha}","trees_url":"https://api.github.com/repos/ternel/weekend-website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ternel/weekend-website/statuses/{sha}","languages_url":"https://api.github.com/repos/ternel/weekend-website/languages","stargazers_url":"https://api.github.com/repos/ternel/weekend-website/stargazers","contributors_url":"https://api.github.com/repos/ternel/weekend-website/contributors","subscribers_url":"https://api.github.com/repos/ternel/weekend-website/subscribers","subscription_url":"https://api.github.com/repos/ternel/weekend-website/subscription","commits_url":"https://api.github.com/repos/ternel/weekend-website/commits{/sha}","git_commits_url":"https://api.github.com/repos/ternel/weekend-website/git/commits{/sha}","comments_url":"https://api.github.com/repos/ternel/weekend-website/comments{/number}","issue_comment_url":"https://api.github.com/repos/ternel/weekend-website/issues/comments{/number}","contents_url":"https://api.github.com/repos/ternel/weekend-website/contents/{+path}","compare_url":"https://api.github.com/repos/ternel/weekend-website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ternel/weekend-website/merges","archive_url":"https://api.github.com/repos/ternel/weekend-website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ternel/weekend-website/downloads","issues_url":"https://api.github.com/repos/ternel/weekend-website/issues{/number}","pulls_url":"https://api.github.com/repos/ternel/weekend-website/pulls{/number}","milestones_url":"https://api.github.com/repos/ternel/weekend-website/milestones{/number}","notifications_url":"https://api.github.com/repos/ternel/weekend-website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ternel/weekend-website/labels{/name}","releases_url":"https://api.github.com/repos/ternel/weekend-website/releases{/id}","deployments_url":"https://api.github.com/repos/ternel/weekend-website/deployments","created_at":"2012-10-31T10:56:31Z","updated_at":"2015-07-29T09:46:05Z","pushed_at":"2016-04-15T09:16:57Z","git_url":"git://github.com/ternel/weekend-website.git","ssh_url":"git@github.com:ternel/weekend-website.git","clone_url":"https://github.com/ternel/weekend-website.git","svn_url":"https://github.com/ternel/weekend-website","homepage":"http://estcequecestbientotleweekend.fr","size":242,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/9"},"html":{"href":"https://github.com/ternel/weekend-website/pull/9"},"issue":{"href":"https://api.github.com/repos/ternel/weekend-website/issues/9"},"comments":{"href":"https://api.github.com/repos/ternel/weekend-website/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ternel/weekend-website/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/ternel/weekend-website/statuses/5017293fafcdda0cf53426e3f94b5ad7048bca66"}}}}