AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / include / lib / pclzip_callback.lib.php
1 <?php\r
2 /************************************************************************/\r
3 /* AContent                                                             */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2010                                                   */\r
6 /* Inclusive Design Institute                                           */\r
7 /*                                                                      */\r
8 /* This program is free software. You can redistribute it and/or        */\r
9 /* modify it under the terms of the GNU General Public License          */\r
10 /* as published by the Free Software Foundation.                        */\r
11 /************************************************************************/\r
12 \r
13 /**\r
14 * File utility functions \r
15 * @access       public\r
16 * @author       Cindy Qi Li\r
17 */\r
18 \r
19 if (!defined('TR_INCLUDE_PATH')) exit;\r
20 \r
21 /**\r
22 * This function gets used by PclZip when creating a zip archive.\r
23 * @access  public\r
24 * @return  int                          whether or not to include the file\r
25 * @author  Joel Kronenberg\r
26 */\r
27 function preImportCallBack($p_event, &$p_header) {\r
28         global $IllegalExtentions;\r
29 \r
30         if ($p_header['folder'] == 1) {\r
31                 return 1;\r
32         }\r
33 \r
34         $path_parts = pathinfo($p_header['filename']);\r
35         $ext = $path_parts['extension'];\r
36 \r
37         if (in_array($ext, $IllegalExtentions)) {\r
38                 return 0;\r
39         }\r
40 \r
41         return 1;\r
42 }\r
43 \r
44 /**\r
45 * This function gets used by PclZip when extracting a zip archive.\r
46 * @see file_manager/zip.php\r
47 * @access  public\r
48 * @return  int                          whether or not to include the file\r
49 * @author  Joel Kronenberg\r
50 */\r
51 function preExtractCallBack($p_event, &$p_header) {\r
52         global $translated_file_names;\r
53 \r
54         if ($p_header['folder'] == 1) {\r
55                 return 1;\r
56         }\r
57 \r
58         if ($translated_file_names[$p_header['index']] == '') {\r
59                 return 0;\r
60         }\r
61 \r
62         if ($translated_file_names[$p_header['index']]) {\r
63                 $p_header['filename'] = substr($p_header['filename'], 0, -strlen($p_header['stored_filename']));\r
64                 $p_header['filename'] .= $translated_file_names[$p_header['index']];\r
65         }\r
66         return 1;\r
67 }\r
68 \r
69 ?>\r