{"action":"created","comment":{"url":"https://api.github.com/repos/GodsDev/tools/pulls/comments/211650224","pull_request_review_id":148116384,"id":211650224,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTY1MDIyNA==","diff_hunk":"@@ -888,7 +1178,202 @@ public static function stripAttributes($html, $attributes)\n                 $item->removeAttribute($attribute);\n             }\n         }\n-        return substr($domd->saveXML(), 26, -6);\n+        return substr($domd->saveXML(), 26, -6); //@todo: suboptimal, version-sensitive\n+    }\n+\n+    /**\n+     * Get GoogleAuthenticator hash of given secret and timeslot.\n+     * https://en.wikipedia.org/wiki/Google_Authenticator\n+     *\n+     * @param string $secret 6-8 chars secret\n+     * @param int $timeSlot delta to time slot of floor(time() / 30)\n+     * @return int\n+     */\n+    public function GoogleAuthenticatorCode($secret, $timeSlot = 0)\n+    {\n+        if ($timeSlot < 1000) {\n+            $timeSlot += floor(time() / 30);\n+        }\n+        $data = str_pad(pack('N', $timeSlot), 8, \"\\0\", STR_PAD_LEFT);\n+        $hash = hash_hmac('sha1', $data, $secret, true);\n+        $unpacked = unpack('N', substr($hash, ord(substr($hash, -1)) & 0xF, 4));\n+        return ($unpacked[1] & 0x7FFFFFFF) % 1000000;\n+    }\n+\n+    /**\n+     * Inverse to str_getcsv() - return comma-separated-values out of given array.\n+     * For parameter details see PHP's fputcsv()\n+     * edited version from https://gist.github.com/johanmeiring/2894568\n+     *\n+     * @param array $fields\n+     * @param string $delimiter (optional) default ','\n+     * @param string $enclosure (optional) default '\"'\n+     * @param string $escape_char (optional) default \"\\\\\"\n+     * @result string CSV of given arguments\n+     */\n+    public static function str_putcsv(array $fields, $delimiter = ',', $enclosure = '\"', $escape_char = \"\\\\\")\n+    {\n+        $fp = fopen('php://memory', 'r+b');\n+        fputcsv($fp, $fields, $delimiter, $enclosure, $escape_char);\n+        $size = ftell($fp);\n+        rewind($fp);\n+        $data = fread($fp, $size);\n+        fclose($fp);\n+        return $data;\n+    }\n+\n+    /**\n+     * Short cut for finding a substring within a string and returning all before (or false on no match).\n+     *\n+     * @param string $haystack\n+     * @param string $needle\n+     * @param bool $caseInsensitive (optional) default: false\n+     * @param string $encoding (optional)\n+     * @return string substring before $needle or false is $needle wasn't found\n+     */\n+    public static function str_before($haystack, $needle, $caseInsensitive = false, $encoding = null)\n+    {\n+        $encoding = $encoding ?: mb_internal_encoding();\n+        $function = $caseInsensitive ? 'mb_stripos' : 'mb_strpos';\n+        if (($pos = $function($haystack, $needle, 0, $encoding)) === false) {\n+            return false;\n+        }\n+        return mb_substr($haystack, 0, $pos, $encoding);\n+    }\n+\n+    /**\n+     * Short cut for finding a substring within a string and returning what follows (or false on no match).\n+     *\n+     * @param string $haystack\n+     * @param string $needle\n+     * @param bool $caseInsensitive (optional) default: false\n+     * @param string $encoding (optional)\n+     * @return string substring after $needle or false is $needle wasn't found\n+     */\n+    public static function str_after($haystack, $needle, $caseInsensitive = false, $encoding = null)\n+    {\n+        $encoding = $encoding ?: mb_internal_encoding();\n+        $function = $caseInsensitive ? 'mb_stripos' : 'mb_strpos';\n+        if (($pos = $function($haystack, $needle, 0, $encoding)) === false) {\n+            return false;\n+        }\n+        return substr($haystack, $pos + strlen($needle));\n+    }\n+\n+    /**\n+     * Multibyte version of ucfirst().\n+     *\n+     * @param string $string\n+     * @param string $encoding (optional)\n+     * @result string\n+     */\n+    public static function mb_ucfirst($string, $encoding = null)\n+    {\n+        $encoding = $encoding ?: mb_internal_encoding();\n+        return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding) . mb_substr($string, 1, null, $encoding);\n+    }\n+\n+    /**\n+     * Case-insensitive version of array_search().\n+     *\n+     * @param string $needle\n+     * @param array $haystack\n+     * @param bool $strict (optional)\n+     * @param mixed $encoding (optional)\n+     * @result mixed found key or false if needle not found\n+     */\n+    public static function array_search_i($needle, array $haystack, bool $strict = false, $encoding = null)\n+    {\n+        $encoding = $encoding ?: mb_internal_encoding();\n+        $needle = mb_strtolower($needle, $encoding);\n+        foreach ($haystack as $key => $value) {\n+            if ($needle == mb_strtolower($value, $encoding)) {\n+                return $key;\n+            }\n+        }\n+        return false;\n+    }\n+\n+    /**\n+     * Case-insensitive version of in_array().\n+     *\n+     * @param string $needle\n+     * @param array $haystack\n+     * @param bool $strict (optional) default false\n+     * @param mixed $encoding (optional)\n+     * @result bool true/false whether the needle was found\n+     */\n+    public static function in_array_i($needle, array $haystack, bool $strict = false, $encoding = null)","path":"Class/Tools.php","position":1375,"original_position":1375,"commit_id":"976b6e613f741e1af8514e7232926dcf85fd8a6c","original_commit_id":"976b6e613f741e1af8514e7232926dcf85fd8a6c","user":{"login":"GodsDev","id":2787653,"node_id":"MDQ6VXNlcjI3ODc2NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/2787653?v=4","gravatar_id":"","url":"https://api.github.com/users/GodsDev","html_url":"https://github.com/GodsDev","followers_url":"https://api.github.com/users/GodsDev/followers","following_url":"https://api.github.com/users/GodsDev/following{/other_user}","gists_url":"https://api.github.com/users/GodsDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GodsDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GodsDev/subscriptions","organizations_url":"https://api.github.com/users/GodsDev/orgs","repos_url":"https://api.github.com/users/GodsDev/repos","events_url":"https://api.github.com/users/GodsDev/events{/privacy}","received_events_url":"https://api.github.com/users/GodsDev/received_events","type":"User","site_admin":false},"body":"bool není s PHP/56 kompatible","created_at":"2018-08-21T15:26:26Z","updated_at":"2018-08-21T15:26:47Z","html_url":"https://github.com/GodsDev/tools/pull/4#discussion_r211650224","pull_request_url":"https://api.github.com/repos/GodsDev/tools/pulls/4","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/comments/211650224"},"html":{"href":"https://github.com/GodsDev/tools/pull/4#discussion_r211650224"},"pull_request":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/GodsDev/tools/pulls/4","id":209567821,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5NTY3ODIx","html_url":"https://github.com/GodsDev/tools/pull/4","diff_url":"https://github.com/GodsDev/tools/pull/4.diff","patch_url":"https://github.com/GodsDev/tools/pull/4.patch","issue_url":"https://api.github.com/repos/GodsDev/tools/issues/4","number":4,"state":"open","locked":false,"title":"Develop","user":{"login":"crs2","id":9055279,"node_id":"MDQ6VXNlcjkwNTUyNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/9055279?v=4","gravatar_id":"","url":"https://api.github.com/users/crs2","html_url":"https://github.com/crs2","followers_url":"https://api.github.com/users/crs2/followers","following_url":"https://api.github.com/users/crs2/following{/other_user}","gists_url":"https://api.github.com/users/crs2/gists{/gist_id}","starred_url":"https://api.github.com/users/crs2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crs2/subscriptions","organizations_url":"https://api.github.com/users/crs2/orgs","repos_url":"https://api.github.com/users/crs2/repos","events_url":"https://api.github.com/users/crs2/events{/privacy}","received_events_url":"https://api.github.com/users/crs2/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-20T15:57:22Z","updated_at":"2018-08-21T15:26:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"820c3b1c6b83ba8a80f3f57ab686b6335b0d7ba7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GodsDev/tools/pulls/4/commits","review_comments_url":"https://api.github.com/repos/GodsDev/tools/pulls/4/comments","review_comment_url":"https://api.github.com/repos/GodsDev/tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GodsDev/tools/issues/4/comments","statuses_url":"https://api.github.com/repos/GodsDev/tools/statuses/976b6e613f741e1af8514e7232926dcf85fd8a6c","head":{"label":"GodsDev:develop","ref":"develop","sha":"976b6e613f741e1af8514e7232926dcf85fd8a6c","user":{"login":"GodsDev","id":2787653,"node_id":"MDQ6VXNlcjI3ODc2NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/2787653?v=4","gravatar_id":"","url":"https://api.github.com/users/GodsDev","html_url":"https://github.com/GodsDev","followers_url":"https://api.github.com/users/GodsDev/followers","following_url":"https://api.github.com/users/GodsDev/following{/other_user}","gists_url":"https://api.github.com/users/GodsDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GodsDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GodsDev/subscriptions","organizations_url":"https://api.github.com/users/GodsDev/orgs","repos_url":"https://api.github.com/users/GodsDev/repos","events_url":"https://api.github.com/users/GodsDev/events{/privacy}","received_events_url":"https://api.github.com/users/GodsDev/received_events","type":"User","site_admin":false},"repo":{"id":67627328,"node_id":"MDEwOlJlcG9zaXRvcnk2NzYyNzMyOA==","name":"tools","full_name":"GodsDev/tools","owner":{"login":"GodsDev","id":2787653,"node_id":"MDQ6VXNlcjI3ODc2NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/2787653?v=4","gravatar_id":"","url":"https://api.github.com/users/GodsDev","html_url":"https://github.com/GodsDev","followers_url":"https://api.github.com/users/GodsDev/followers","following_url":"https://api.github.com/users/GodsDev/following{/other_user}","gists_url":"https://api.github.com/users/GodsDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GodsDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GodsDev/subscriptions","organizations_url":"https://api.github.com/users/GodsDev/orgs","repos_url":"https://api.github.com/users/GodsDev/repos","events_url":"https://api.github.com/users/GodsDev/events{/privacy}","received_events_url":"https://api.github.com/users/GodsDev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GodsDev/tools","description":null,"fork":false,"url":"https://api.github.com/repos/GodsDev/tools","forks_url":"https://api.github.com/repos/GodsDev/tools/forks","keys_url":"https://api.github.com/repos/GodsDev/tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GodsDev/tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GodsDev/tools/teams","hooks_url":"https://api.github.com/repos/GodsDev/tools/hooks","issue_events_url":"https://api.github.com/repos/GodsDev/tools/issues/events{/number}","events_url":"https://api.github.com/repos/GodsDev/tools/events","assignees_url":"https://api.github.com/repos/GodsDev/tools/assignees{/user}","branches_url":"https://api.github.com/repos/GodsDev/tools/branches{/branch}","tags_url":"https://api.github.com/repos/GodsDev/tools/tags","blobs_url":"https://api.github.com/repos/GodsDev/tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GodsDev/tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GodsDev/tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/GodsDev/tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GodsDev/tools/statuses/{sha}","languages_url":"https://api.github.com/repos/GodsDev/tools/languages","stargazers_url":"https://api.github.com/repos/GodsDev/tools/stargazers","contributors_url":"https://api.github.com/repos/GodsDev/tools/contributors","subscribers_url":"https://api.github.com/repos/GodsDev/tools/subscribers","subscription_url":"https://api.github.com/repos/GodsDev/tools/subscription","commits_url":"https://api.github.com/repos/GodsDev/tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/GodsDev/tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/GodsDev/tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/GodsDev/tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/GodsDev/tools/contents/{+path}","compare_url":"https://api.github.com/repos/GodsDev/tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GodsDev/tools/merges","archive_url":"https://api.github.com/repos/GodsDev/tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GodsDev/tools/downloads","issues_url":"https://api.github.com/repos/GodsDev/tools/issues{/number}","pulls_url":"https://api.github.com/repos/GodsDev/tools/pulls{/number}","milestones_url":"https://api.github.com/repos/GodsDev/tools/milestones{/number}","notifications_url":"https://api.github.com/repos/GodsDev/tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GodsDev/tools/labels{/name}","releases_url":"https://api.github.com/repos/GodsDev/tools/releases{/id}","deployments_url":"https://api.github.com/repos/GodsDev/tools/deployments","created_at":"2016-09-07T17:05:56Z","updated_at":"2017-09-09T14:24:13Z","pushed_at":"2018-08-21T12:15:36Z","git_url":"git://github.com/GodsDev/tools.git","ssh_url":"git@github.com:GodsDev/tools.git","clone_url":"https://github.com/GodsDev/tools.git","svn_url":"https://github.com/GodsDev/tools","homepage":null,"size":69,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GodsDev:master","ref":"master","sha":"c2f1d9dc187d859e62e09aee18506d02c49deee2","user":{"login":"GodsDev","id":2787653,"node_id":"MDQ6VXNlcjI3ODc2NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/2787653?v=4","gravatar_id":"","url":"https://api.github.com/users/GodsDev","html_url":"https://github.com/GodsDev","followers_url":"https://api.github.com/users/GodsDev/followers","following_url":"https://api.github.com/users/GodsDev/following{/other_user}","gists_url":"https://api.github.com/users/GodsDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GodsDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GodsDev/subscriptions","organizations_url":"https://api.github.com/users/GodsDev/orgs","repos_url":"https://api.github.com/users/GodsDev/repos","events_url":"https://api.github.com/users/GodsDev/events{/privacy}","received_events_url":"https://api.github.com/users/GodsDev/received_events","type":"User","site_admin":false},"repo":{"id":67627328,"node_id":"MDEwOlJlcG9zaXRvcnk2NzYyNzMyOA==","name":"tools","full_name":"GodsDev/tools","owner":{"login":"GodsDev","id":2787653,"node_id":"MDQ6VXNlcjI3ODc2NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/2787653?v=4","gravatar_id":"","url":"https://api.github.com/users/GodsDev","html_url":"https://github.com/GodsDev","followers_url":"https://api.github.com/users/GodsDev/followers","following_url":"https://api.github.com/users/GodsDev/following{/other_user}","gists_url":"https://api.github.com/users/GodsDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GodsDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GodsDev/subscriptions","organizations_url":"https://api.github.com/users/GodsDev/orgs","repos_url":"https://api.github.com/users/GodsDev/repos","events_url":"https://api.github.com/users/GodsDev/events{/privacy}","received_events_url":"https://api.github.com/users/GodsDev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GodsDev/tools","description":null,"fork":false,"url":"https://api.github.com/repos/GodsDev/tools","forks_url":"https://api.github.com/repos/GodsDev/tools/forks","keys_url":"https://api.github.com/repos/GodsDev/tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GodsDev/tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GodsDev/tools/teams","hooks_url":"https://api.github.com/repos/GodsDev/tools/hooks","issue_events_url":"https://api.github.com/repos/GodsDev/tools/issues/events{/number}","events_url":"https://api.github.com/repos/GodsDev/tools/events","assignees_url":"https://api.github.com/repos/GodsDev/tools/assignees{/user}","branches_url":"https://api.github.com/repos/GodsDev/tools/branches{/branch}","tags_url":"https://api.github.com/repos/GodsDev/tools/tags","blobs_url":"https://api.github.com/repos/GodsDev/tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GodsDev/tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GodsDev/tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/GodsDev/tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GodsDev/tools/statuses/{sha}","languages_url":"https://api.github.com/repos/GodsDev/tools/languages","stargazers_url":"https://api.github.com/repos/GodsDev/tools/stargazers","contributors_url":"https://api.github.com/repos/GodsDev/tools/contributors","subscribers_url":"https://api.github.com/repos/GodsDev/tools/subscribers","subscription_url":"https://api.github.com/repos/GodsDev/tools/subscription","commits_url":"https://api.github.com/repos/GodsDev/tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/GodsDev/tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/GodsDev/tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/GodsDev/tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/GodsDev/tools/contents/{+path}","compare_url":"https://api.github.com/repos/GodsDev/tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GodsDev/tools/merges","archive_url":"https://api.github.com/repos/GodsDev/tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GodsDev/tools/downloads","issues_url":"https://api.github.com/repos/GodsDev/tools/issues{/number}","pulls_url":"https://api.github.com/repos/GodsDev/tools/pulls{/number}","milestones_url":"https://api.github.com/repos/GodsDev/tools/milestones{/number}","notifications_url":"https://api.github.com/repos/GodsDev/tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GodsDev/tools/labels{/name}","releases_url":"https://api.github.com/repos/GodsDev/tools/releases{/id}","deployments_url":"https://api.github.com/repos/GodsDev/tools/deployments","created_at":"2016-09-07T17:05:56Z","updated_at":"2017-09-09T14:24:13Z","pushed_at":"2018-08-21T12:15:36Z","git_url":"git://github.com/GodsDev/tools.git","ssh_url":"git@github.com:GodsDev/tools.git","clone_url":"https://github.com/GodsDev/tools.git","svn_url":"https://github.com/GodsDev/tools","homepage":null,"size":69,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/4"},"html":{"href":"https://github.com/GodsDev/tools/pull/4"},"issue":{"href":"https://api.github.com/repos/GodsDev/tools/issues/4"},"comments":{"href":"https://api.github.com/repos/GodsDev/tools/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GodsDev/tools/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/GodsDev/tools/statuses/976b6e613f741e1af8514e7232926dcf85fd8a6c"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"GodsDev"}}