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 | // Gestion des onglets |
---|
17 | if (!isset($_GET['tab'])) |
---|
18 | $page['tab'] = 'pfi'; |
---|
19 | else |
---|
20 | $page['tab'] = $_GET['tab']; |
---|
21 | |
---|
22 | $tabsheet = new tabsheet(); |
---|
23 | $tabsheet->add('pfi', |
---|
24 | l10n('pfi_ajout'), |
---|
25 | $my_base_url.'&tab=pfi'); |
---|
26 | $tabsheet->add('help', |
---|
27 | l10n('help'), |
---|
28 | $my_base_url.'&tab=help'); |
---|
29 | $tabsheet->select($page['tab']); |
---|
30 | $tabsheet->assign(); |
---|
31 | |
---|
32 | switch ($page['tab']) |
---|
33 | { |
---|
34 | // Onglet gestion de onglet ajout icône |
---|
35 | case 'pfi': |
---|
36 | $blockdesc = 'pfi'; |
---|
37 | $template->assign( |
---|
38 | $blockdesc, |
---|
39 | array( |
---|
40 | 'meta'=>l10n('pfi_name'), |
---|
41 | )); |
---|
42 | |
---|
43 | $filename = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'favicon.ico'; |
---|
44 | if (file_exists($filename)) {$template->assign('ICO',$filename);} |
---|
45 | |
---|
46 | if (isset($_POST['submitpfi']) and !is_adviser()) |
---|
47 | { |
---|
48 | |
---|
49 | $content_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR; |
---|
50 | $tmp_file = $_FILES['pfi']['tmp_name']; |
---|
51 | if( !is_uploaded_file($tmp_file) ) |
---|
52 | { |
---|
53 | array_push( $page['errors'], l10n('pfi_erreur_vide') ); |
---|
54 | break; |
---|
55 | } |
---|
56 | |
---|
57 | $type_file = strrchr($_FILES['pfi']['name'], '.'); |
---|
58 | if( !strstr($type_file, 'ico')) |
---|
59 | { |
---|
60 | array_push( $page['errors'], l10n('pfi_erreur_ext')); |
---|
61 | break; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | $taille_maxi = 5120; |
---|
66 | $taille = filesize($_FILES['pfi']['tmp_name']); |
---|
67 | if($taille>$taille_maxi) |
---|
68 | { |
---|
69 | array_push($page['errors'], l10n('pfi_erreur_taille')); |
---|
70 | break; |
---|
71 | } |
---|
72 | |
---|
73 | $filename = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'favicon.ico'; |
---|
74 | if (file_exists($filename)) |
---|
75 | { |
---|
76 | array_push($page['infos'], l10n('pfi_erreur_exist')); |
---|
77 | } |
---|
78 | |
---|
79 | $name_file = $_FILES['pfi']['name']; |
---|
80 | if( preg_match('#[\x00-\x1F\x7F-\x9F/\\\\]#', $name_file) ) |
---|
81 | { |
---|
82 | array_push( $page['infos'], l10n('pfi_erreur_nom') ); |
---|
83 | break; |
---|
84 | } |
---|
85 | else if( |
---|
86 | !move_uploaded_file($tmp_file, $content_dir . 'favicon.ico') ) |
---|
87 | { |
---|
88 | array_push( $page['errors'], l10n('pfi_erreur_mouve') ); |
---|
89 | break; |
---|
90 | } |
---|
91 | array_push( $page['infos'], l10n('pfi_ok') ); |
---|
92 | |
---|
93 | |
---|
94 | } |
---|
95 | |
---|
96 | break; |
---|
97 | |
---|
98 | case 'help': |
---|
99 | $blockdesc = 'help'; |
---|
100 | $template->assign( |
---|
101 | $blockdesc, |
---|
102 | array( |
---|
103 | 'meta'=>l10n('pfi_name'), |
---|
104 | )); |
---|
105 | |
---|
106 | break; |
---|
107 | |
---|
108 | } |
---|
109 | |
---|
110 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
111 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
112 | ?> |
---|