source: branches/2.2/filemanager/inc/after_upload.php @ 4915

Revision 4915, 2.0 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #2199 - Corrigido bug para criar e mover arquivos dentro do filemanager

Line 
1<?php
2session_id($_COOKIE['jupload']);
3session_start();
4$files = $_SESSION['juvar.files'];
5unset($_SESSION['juvar.files']);
6session_write_close();
7
8include_once("../../header.session.inc.php");
9
10$GLOBALS['phpgw_info']['flags'] = array
11        (
12                'currentapp'    => 'filemanager',
13                'noheader'      => True,
14                'nonavbar' => True,
15                'nofooter'      => True,
16                'noappheader'   => True,
17                'enable_browser_class'  => True
18        );
19
20
21include_once("../../header.inc.php");
22
23
24function convert_char( $String )
25{
26                $String = trim( str_replace( "\'", "", $String) );
27                $String = str_replace( "'", "", $String );
28                $String = str_replace( "ç", "c", $String );
29                $String = str_replace( "Ç", "C", $String );
30                $String = ereg_replace( "[áàâã]", "a", $String );
31                $String = ereg_replace( "[ÁÀÂÃ]", "A", $String );
32                $String = ereg_replace( "[éÚê]", "e", $String );
33                $String = ereg_replace( "[ÉÈÊ]", "E", $String );
34                $String = ereg_replace( "[íìîï]", "i", $String );
35                $String = ereg_replace( "[ÍÌÎ]", "I", $String );
36                $String = ereg_replace( "[óòÎõ]", "o", $String );
37                $String = ereg_replace( "[ÓÒÔÕ]", "O", $String );
38                $String = ereg_replace( "[úùû]", "u", $String );
39                $String = ereg_replace( "[ÚÙÛ]", "U", $String );
40               
41                return $String;
42}
43
44$bo = CreateObject('filemanager.bofilemanager');
45
46foreach ($files as $f)
47{
48        $newName = convert_char( $f['name'] );
49       
50        $_array = array(
51                        'from'          => $f['fullName'],
52                        'to'            => $newName,
53                        'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
54        );
55       
56        if ( $bo->vfs->cp($_array) )
57        {
58                $bo->vfs->set_attributes(array(
59                        'string'                => $newName,
60                        'relatives'             => array( RELATIVE_ALL ),
61                        'attributes'    => array( 'mime_type' => $f['mimetype'] )
62                ));
63               
64                $fullName = $f['fullName'];
65               
66                if( file_exists($fullName) )
67                {
68                        exec("rm -f ".escapeshellcmd(escapeshellarg($fullName)));
69                }
70        }
71}
72
73echo "<script type='text/javascript' src='../js/after_upload.js'></script>";
74
75?>
Note: See TracBrowser for help on using the repository browser.