|
24 | 24 | throw new Exception(__('401 - Accès non autorisé', __FILE__)); |
25 | 25 | } |
26 | 26 |
|
27 | | - if (init('action') == 'getScriptContent') { |
28 | | - $path = init('path'); |
29 | | - if (!file_exists($path)) { |
30 | | - throw new Exception(__('Aucun fichier trouvé : ', __FILE__) . $path); |
31 | | - } |
32 | | - if (!is_readable($path)) { |
33 | | - throw new Exception(__('Impossible de lire : ', __FILE__) . $path); |
34 | | - } |
35 | | - if (is_dir($path)) { |
36 | | - throw new Exception(__('Impossible de lire un dossier : ', __FILE__) . $path); |
37 | | - } |
38 | | - $pathinfo = pathinfo($path); |
39 | | - $return = array( |
40 | | - 'content' => file_get_contents($path), |
41 | | - 'extension' => $pathinfo['extension'] |
42 | | - ); |
43 | | - ajax::success($return); |
44 | | - } |
45 | | - |
46 | | - if (init('action') == 'saveScriptContent') { |
47 | | - $path = init('path'); |
48 | | - if (!file_exists($path)) { |
49 | | - throw new Exception(__('Aucun fichier trouvé : ', __FILE__) . $path); |
50 | | - } |
51 | | - if (!is_writable($path)) { |
52 | | - throw new Exception(__('Impossible d\'écrire dans : ', __FILE__) . $path); |
53 | | - } |
54 | | - if (is_dir($path)) { |
55 | | - throw new Exception(__('Impossible d\'écrire un dossier : ', __FILE__) . $path); |
56 | | - } |
57 | | - file_put_contents($path, init('content')); |
58 | | - chmod($path, 0770); |
59 | | - ajax::success(); |
60 | | - } |
61 | | - |
62 | | - if (init('action') == 'removeScript') { |
63 | | - $path = init('path'); |
64 | | - if (!file_exists($path)) { |
65 | | - throw new Exception(__('Aucun fichier trouvé : ', __FILE__) . $path); |
66 | | - } |
67 | | - if (!is_writable($path)) { |
68 | | - throw new Exception(__('Impossible d\'écrire dans : ', __FILE__) . $path); |
69 | | - } |
70 | | - if (is_dir($path)) { |
71 | | - throw new Exception(__('Impossible de supprimer un dossier : ', __FILE__) . $path); |
72 | | - } |
73 | | - if(!unlink($path)){ |
74 | | - throw new Exception(__('Impossible de supprimer le fichier : ', __FILE__) . $path); |
75 | | - } |
76 | | - ajax::success(); |
77 | | - } |
78 | | - |
79 | | - |
80 | | - if (init('action') == 'addUserScript') { |
81 | | - $path = realpath(calculPath(config::byKey('userScriptDir', 'script'))); |
82 | | - $path .= '/' . init('name'); |
83 | | - if (!touch($path)) { |
84 | | - throw new Exception(__('Impossible d\'écrire dans : ', __FILE__) . $path); |
85 | | - } |
86 | | - ajax::success($path); |
87 | | - } |
88 | | - |
89 | 27 | throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action')); |
90 | 28 | } catch (Exception $e) { |
91 | | - ajax::error(displayExeption($e), $e->getCode()); |
| 29 | + ajax::error(displayException($e), $e->getCode()); |
92 | 30 | } |
93 | | -?> |
0 commit comments