diff options
Diffstat (limited to 'controller/ajax.php')
-rw-r--r-- | controller/ajax.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/controller/ajax.php b/controller/ajax.php new file mode 100644 index 0000000..489e814 --- /dev/null +++ b/controller/ajax.php | |||
@@ -0,0 +1,60 @@ | |||
1 | <?php | ||
2 | // controller/ajax.php | ||
3 | |||
4 | // traitement des requêtes AJAX | ||
5 | // -> insertion d'une image dans l'éditeur | ||
6 | if(isset($_GET['action']) && isset($_GET['page']) && $_GET['action'] == 'upload_image') | ||
7 | { | ||
8 | // sécurité !! | ||
9 | if(!isset($_SESSION['admin']) || $_SESSION['admin'] != 1 | ||
10 | || !isset($_FILES['upload']) || empty($_FILES['upload'])) | ||
11 | { | ||
12 | // sans effet? | ||
13 | header('Location: index.php?erreur=image_ajax'); | ||
14 | } | ||
15 | else | ||
16 | { | ||
17 | require('model/Image.php'); | ||
18 | // paramètre "true" parce qu'on reçoit une requête AJAX | ||
19 | $Image = new Image(true); | ||
20 | $Image->upload(); | ||
21 | echo($Image->reponseAjax); // attendu par l'éditeur | ||
22 | } | ||
23 | exit; // stop !! | ||
24 | } | ||
25 | |||
26 | // page restauration quand le fichier zip est lourd | ||
27 | // -> input file onchange | ||
28 | if(isset($_GET['action']) && $_GET['action'] == 'restauration' | ||
29 | && isset($_GET['file_name']) && isset($_GET['file_size'])) | ||
30 | { | ||
31 | if(!isset($_SESSION['admin']) || $_SESSION['admin'] != 1) | ||
32 | { | ||
33 | header('Location: index.php?erreur=file_infos_ajax'); | ||
34 | } | ||
35 | else | ||
36 | { | ||
37 | $_SESSION['fileSize'] = $_GET['file_size']; | ||
38 | $_SESSION['fileName'] = $_GET['file_name']; | ||
39 | //echo("file infos send"); | ||
40 | var_dump($_SESSION['fileName']); | ||
41 | exit(); // stop !! | ||
42 | } | ||
43 | } | ||
44 | // -> input submit onclick | ||
45 | if(isset($_GET['action']) && $_GET['action'] == 'restauration' | ||
46 | && isset($_GET['chunk_name']) && isset($_FILES['blob'])) | ||
47 | { | ||
48 | |||
49 | if(!isset($_SESSION['admin']) || $_SESSION['admin'] != 1) | ||
50 | { | ||
51 | header('Location: index.php?erreur=upload_ajax'); | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | require('controller/backup.php'); | ||
56 | uploadChunkAndMerge(); | ||
57 | echo('file send'); | ||
58 | exit(); // stop !! | ||
59 | } | ||
60 | } \ No newline at end of file | ||