{"action":"created","comment":{"url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/comments/64722149","id":64722149,"diff_hunk":"@@ -165,38 +165,49 @@ private function createDeleteForm(Advert $advert)\n     public function uploadAction() \n     {\n         if (empty($_FILES['upload'])) {\n-            echo json_encode(['error'=>'No files found for upload.']);\n-            return; \n+            return new JsonResponse(['error'=>'No files found for upload.']);\n         }\n-        $image = $_FILES['upload'];\n-        $name = $image['name'];\n-        $success = null;\n-        \n-        $random = mt_rand ( 00000 , 99999 );\n-        $newname = $random . '_' . $name;\n-        $url = \"bundles/front/images/uploads/\" . $newname ;\n-\n-        if (move_uploaded_file($image['tmp_name'], $url))   {\n-            $funcNum = $_GET['CKEditorFuncNum'];\n-            $CKEditor = $_GET['CKEditor'] ;\n-            $url = \"../../bundles/front/images/uploads/\" . $newname;\n-            $message = \"Le fichier a bien été intégré !\";\n-            return new response (\"<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>\");\n-        } else {\n-            $success = false;\n+        $extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' );\n+        $extension_upload = strtolower(  substr(  strrchr($_FILES['upload']['name'], '.')  ,1)  );\n+\n+        if ( in_array($extension_upload,$extensions_valides) ) {\n+            $image = $_FILES['upload'];\n+            $name = $image['name'];\n+            $success = null;\n+            \n+            $dateupload = new \\DateTime();\n+            $dateupload = $dateupload->format('Y-m-d');\n+            $user = $this->getUser()->getId();\n+\n+            $newname = $dateupload . '_' . $user . '_' . $name;\n+            $url = \"bundles/front/images/uploads/\" . $newname ;\n+\n+            if (move_uploaded_file($image['tmp_name'], $url))   {\n+                $funcNum = $_GET['CKEditorFuncNum'];\n+                $CKEditor = $_GET['CKEditor'] ;\n+                $url = \"../../bundles/front/images/uploads/\" . $newname;\n+                $message = \"Le fichier a bien été intégré !\";\n+                return new response (\"<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>\");\n+            } else {\n+                $success = false;\n+            }\n+\n+            // check and process based on successful status \n+            if ($success === true) {\n+               // here for save data\n+            } elseif ($success === false) {\n+                $output = ['error'=>'Error while uploading images. Contact the system administrator'];\n+            } else {\n+                $output = ['error'=>'No files were processed.'];\n+            }\n+\n+            // return a json encoded response for plugin to process successfully\n+            return new JsonResponse($output);\n         }\n-\n-        // check and process based on successful status \n-        if ($success === true) {\n-           \n-        } elseif ($success === false) {\n-            $output = ['error'=>'Error while uploading images. Contact the system administrator'];\n-        } else {\n-            $output = ['error'=>'No files were processed.'];\n+        else{\n+            return new JsonResponse(['error'=>'Seuls les formats .jpg, .jpeg, .gif, .png sont accepté.']);","path":"ADAM/src/AppBundle/Controller/AdvertController.php","position":null,"original_position":70,"commit_id":"16ae4024cdf40605237993aede8cdb316eb56e4f","original_commit_id":"1c4f76a028e7101c56f0f40eb257941620219866","user":{"login":"maxime121294","id":10925177,"avatar_url":"https://avatars.githubusercontent.com/u/10925177?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime121294","html_url":"https://github.com/maxime121294","followers_url":"https://api.github.com/users/maxime121294/followers","following_url":"https://api.github.com/users/maxime121294/following{/other_user}","gists_url":"https://api.github.com/users/maxime121294/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime121294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime121294/subscriptions","organizations_url":"https://api.github.com/users/maxime121294/orgs","repos_url":"https://api.github.com/users/maxime121294/repos","events_url":"https://api.github.com/users/maxime121294/events{/privacy}","received_events_url":"https://api.github.com/users/maxime121294/received_events","type":"User","site_admin":false},"body":"Petite faute d'orthographe : \"acceptés\" 😉","created_at":"2016-05-26T10:15:12Z","updated_at":"2016-05-26T10:15:12Z","html_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36#discussion_r64722149","pull_request_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/comments/64722149"},"html":{"href":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36#discussion_r64722149"},"pull_request":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36","id":70091382,"html_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36","diff_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36.diff","patch_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36.patch","issue_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/36","number":36,"state":"open","locked":false,"title":"Feature/IvoryCKEditorBundle","user":{"login":"amandlabeautin","id":10925167,"avatar_url":"https://avatars.githubusercontent.com/u/10925167?v=3","gravatar_id":"","url":"https://api.github.com/users/amandlabeautin","html_url":"https://github.com/amandlabeautin","followers_url":"https://api.github.com/users/amandlabeautin/followers","following_url":"https://api.github.com/users/amandlabeautin/following{/other_user}","gists_url":"https://api.github.com/users/amandlabeautin/gists{/gist_id}","starred_url":"https://api.github.com/users/amandlabeautin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amandlabeautin/subscriptions","organizations_url":"https://api.github.com/users/amandlabeautin/orgs","repos_url":"https://api.github.com/users/amandlabeautin/repos","events_url":"https://api.github.com/users/amandlabeautin/events{/privacy}","received_events_url":"https://api.github.com/users/amandlabeautin/received_events","type":"User","site_admin":false},"body":"- mise en place de la librairie dateTimePicker (permet de sélectionner\nl’heure et le jour de l’événement)","created_at":"2016-05-14T12:55:22Z","updated_at":"2016-05-26T10:15:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79ab6a2c89bb05997afd437b9a013789acf21600","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36/commits","review_comments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36/comments","review_comment_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/comments{/number}","comments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/36/comments","statuses_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/statuses/16ae4024cdf40605237993aede8cdb316eb56e4f","head":{"label":"maxime121294:feature/IvoryCKEditorBundle","ref":"feature/IvoryCKEditorBundle","sha":"16ae4024cdf40605237993aede8cdb316eb56e4f","user":{"login":"maxime121294","id":10925177,"avatar_url":"https://avatars.githubusercontent.com/u/10925177?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime121294","html_url":"https://github.com/maxime121294","followers_url":"https://api.github.com/users/maxime121294/followers","following_url":"https://api.github.com/users/maxime121294/following{/other_user}","gists_url":"https://api.github.com/users/maxime121294/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime121294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime121294/subscriptions","organizations_url":"https://api.github.com/users/maxime121294/orgs","repos_url":"https://api.github.com/users/maxime121294/repos","events_url":"https://api.github.com/users/maxime121294/events{/privacy}","received_events_url":"https://api.github.com/users/maxime121294/received_events","type":"User","site_admin":false},"repo":{"id":52089577,"name":"PlateformeDesAnciensMIAGE","full_name":"maxime121294/PlateformeDesAnciensMIAGE","owner":{"login":"maxime121294","id":10925177,"avatar_url":"https://avatars.githubusercontent.com/u/10925177?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime121294","html_url":"https://github.com/maxime121294","followers_url":"https://api.github.com/users/maxime121294/followers","following_url":"https://api.github.com/users/maxime121294/following{/other_user}","gists_url":"https://api.github.com/users/maxime121294/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime121294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime121294/subscriptions","organizations_url":"https://api.github.com/users/maxime121294/orgs","repos_url":"https://api.github.com/users/maxime121294/repos","events_url":"https://api.github.com/users/maxime121294/events{/privacy}","received_events_url":"https://api.github.com/users/maxime121294/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE","description":"Projet de M1 MIAGE","fork":false,"url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE","forks_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/forks","keys_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/teams","hooks_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/hooks","issue_events_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/events{/number}","events_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/events","assignees_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/assignees{/user}","branches_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/branches{/branch}","tags_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/tags","blobs_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/statuses/{sha}","languages_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/languages","stargazers_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/stargazers","contributors_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/contributors","subscribers_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/subscribers","subscription_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/subscription","commits_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/contents/{+path}","compare_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/merges","archive_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/downloads","issues_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues{/number}","pulls_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls{/number}","milestones_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/milestones{/number}","notifications_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/labels{/name}","releases_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/releases{/id}","deployments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/deployments","created_at":"2016-02-19T13:31:09Z","updated_at":"2016-03-17T10:53:33Z","pushed_at":"2016-05-26T10:13:07Z","git_url":"git://github.com/maxime121294/PlateformeDesAnciensMIAGE.git","ssh_url":"git@github.com:maxime121294/PlateformeDesAnciensMIAGE.git","clone_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE.git","svn_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE","homepage":null,"size":3591,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"maxime121294:develop","ref":"develop","sha":"cea8b96e93d4bd6f7680059efcf92d75d9e38207","user":{"login":"maxime121294","id":10925177,"avatar_url":"https://avatars.githubusercontent.com/u/10925177?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime121294","html_url":"https://github.com/maxime121294","followers_url":"https://api.github.com/users/maxime121294/followers","following_url":"https://api.github.com/users/maxime121294/following{/other_user}","gists_url":"https://api.github.com/users/maxime121294/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime121294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime121294/subscriptions","organizations_url":"https://api.github.com/users/maxime121294/orgs","repos_url":"https://api.github.com/users/maxime121294/repos","events_url":"https://api.github.com/users/maxime121294/events{/privacy}","received_events_url":"https://api.github.com/users/maxime121294/received_events","type":"User","site_admin":false},"repo":{"id":52089577,"name":"PlateformeDesAnciensMIAGE","full_name":"maxime121294/PlateformeDesAnciensMIAGE","owner":{"login":"maxime121294","id":10925177,"avatar_url":"https://avatars.githubusercontent.com/u/10925177?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime121294","html_url":"https://github.com/maxime121294","followers_url":"https://api.github.com/users/maxime121294/followers","following_url":"https://api.github.com/users/maxime121294/following{/other_user}","gists_url":"https://api.github.com/users/maxime121294/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime121294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime121294/subscriptions","organizations_url":"https://api.github.com/users/maxime121294/orgs","repos_url":"https://api.github.com/users/maxime121294/repos","events_url":"https://api.github.com/users/maxime121294/events{/privacy}","received_events_url":"https://api.github.com/users/maxime121294/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE","description":"Projet de M1 MIAGE","fork":false,"url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE","forks_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/forks","keys_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/teams","hooks_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/hooks","issue_events_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/events{/number}","events_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/events","assignees_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/assignees{/user}","branches_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/branches{/branch}","tags_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/tags","blobs_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/statuses/{sha}","languages_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/languages","stargazers_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/stargazers","contributors_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/contributors","subscribers_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/subscribers","subscription_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/subscription","commits_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/contents/{+path}","compare_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/merges","archive_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/downloads","issues_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues{/number}","pulls_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls{/number}","milestones_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/milestones{/number}","notifications_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/labels{/name}","releases_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/releases{/id}","deployments_url":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/deployments","created_at":"2016-02-19T13:31:09Z","updated_at":"2016-03-17T10:53:33Z","pushed_at":"2016-05-26T10:13:07Z","git_url":"git://github.com/maxime121294/PlateformeDesAnciensMIAGE.git","ssh_url":"git@github.com:maxime121294/PlateformeDesAnciensMIAGE.git","clone_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE.git","svn_url":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE","homepage":null,"size":3591,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36"},"html":{"href":"https://github.com/maxime121294/PlateformeDesAnciensMIAGE/pull/36"},"issue":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/36"},"comments":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/maxime121294/PlateformeDesAnciensMIAGE/statuses/16ae4024cdf40605237993aede8cdb316eb56e4f"}}}}
{"actor":{"display_login":"maxime121294"}}