1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $template, $conf, $user, $page; |
---|
5 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
6 | load_language('plugin.lang', PFI_PATH); |
---|
7 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
8 | |
---|
9 | // +-----------------------------------------------------------------------+ |
---|
10 | // | Check Access and exit when user status is not ok | |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | check_status(ACCESS_ADMINISTRATOR); |
---|
13 | |
---|
14 | //-------------------------------------------------------- sections definitions |
---|
15 | |
---|
16 | if (!is_webmaster()) |
---|
17 | { |
---|
18 | array_push($page['errors'], l10n('This section is reserved for the webmaster')); |
---|
19 | } |
---|
20 | else |
---|
21 | { |
---|
22 | // Gest Tab |
---|
23 | if (!isset($_GET['tab'])) |
---|
24 | $page['tab'] = 'pfi'; |
---|
25 | else |
---|
26 | $page['tab'] = $_GET['tab']; |
---|
27 | |
---|
28 | $tabsheet = new tabsheet(); |
---|
29 | $tabsheet->add('pfi', |
---|
30 | l10n('pfi_ajout'), |
---|
31 | $my_base_url.'&tab=pfi'); |
---|
32 | $tabsheet->add('help', |
---|
33 | l10n('help'), |
---|
34 | $my_base_url.'&tab=help'); |
---|
35 | $tabsheet->select($page['tab']); |
---|
36 | $tabsheet->assign(); |
---|
37 | |
---|
38 | switch ($page['tab']) |
---|
39 | { |
---|
40 | // Onglet gestion de onglet ajout icône |
---|
41 | case 'pfi': |
---|
42 | $blockdesc = 'pfi'; |
---|
43 | $template->assign( |
---|
44 | $blockdesc, |
---|
45 | array( |
---|
46 | 'meta'=>l10n('pfi_name'), |
---|
47 | )); |
---|
48 | |
---|
49 | $filename = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'favicon.ico'; |
---|
50 | if (file_exists($filename)) {$template->assign('ICO',$filename);} |
---|
51 | |
---|
52 | if (isset($_POST['submitpfi'])) |
---|
53 | { |
---|
54 | |
---|
55 | $content_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR; |
---|
56 | $tmp_file = $_FILES['pfi']['tmp_name']; |
---|
57 | |
---|
58 | if ($_FILES['pfi']['error'] !== UPLOAD_ERR_OK) |
---|
59 | { |
---|
60 | include_once(PHPWG_ROOT_PATH .'admin/include/functions_upload.inc.php'); |
---|
61 | $error_message = file_upload_error_message($_FILES['pfi']['error']); |
---|
62 | array_push( $page['errors'], $error_message); |
---|
63 | break; |
---|
64 | } |
---|
65 | |
---|
66 | if( !is_uploaded_file($tmp_file) ) |
---|
67 | { |
---|
68 | array_push( $page['errors'], l10n('pfi_erreur_vide') ); |
---|
69 | break; |
---|
70 | } |
---|
71 | |
---|
72 | $type_file = strrchr($_FILES['pfi']['name'], '.'); |
---|
73 | if( !strstr($type_file, 'ico')) |
---|
74 | { |
---|
75 | array_push( $page['errors'], l10n('pfi_erreur_ext')); |
---|
76 | break; |
---|
77 | } |
---|
78 | |
---|
79 | $taille_maxi = 5120; |
---|
80 | $taille = filesize($_FILES['pfi']['tmp_name']); |
---|
81 | if($taille>$taille_maxi) |
---|
82 | { |
---|
83 | array_push($page['errors'], l10n('pfi_erreur_taille')); |
---|
84 | break; |
---|
85 | } |
---|
86 | |
---|
87 | $filename = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'favicon.ico'; |
---|
88 | if (file_exists($filename)) |
---|
89 | { |
---|
90 | array_push($page['infos'], l10n('pfi_erreur_exist')); |
---|
91 | } |
---|
92 | |
---|
93 | $name_file = $_FILES['pfi']['name']; |
---|
94 | if( preg_match('#[\x00-\x1F\x7F-\x9F/\\\\]#', $name_file) ) |
---|
95 | { |
---|
96 | array_push( $page['infos'], l10n('pfi_erreur_nom') ); |
---|
97 | break; |
---|
98 | } |
---|
99 | else if( |
---|
100 | !move_uploaded_file($tmp_file, $content_dir . 'favicon.ico') ) |
---|
101 | { |
---|
102 | array_push( $page['errors'], l10n('pfi_erreur_mouve') ); |
---|
103 | break; |
---|
104 | } |
---|
105 | array_push( $page['infos'], l10n('pfi_ok') ); |
---|
106 | } |
---|
107 | break; |
---|
108 | |
---|
109 | case 'help': |
---|
110 | $blockdesc = 'help'; |
---|
111 | $template->assign( |
---|
112 | $blockdesc, |
---|
113 | array( |
---|
114 | 'meta'=>l10n('pfi_name'), |
---|
115 | )); |
---|
116 | |
---|
117 | break; |
---|
118 | |
---|
119 | } |
---|
120 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
121 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
122 | } |
---|
123 | ?> |
---|