dolibarr  16.0.5
frmupload.php
1 <?php
2 /* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
4  *
5  * Source modified from part of fckeditor (http://www.fckeditor.net)
6  * retrieved as GPL v2 or later
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 define('NOTOKENRENEWAL', 1); // Disables token renewal
23 
24 require '../../../../main.inc.php';
25 
26 ?>
27 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
28 <!--
29  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
30  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
31  *
32  * == BEGIN LICENSE ==
33  *
34  * Licensed under the terms of any of the following licenses at your
35  * choice:
36  *
37  * - GNU General Public License Version 2 or later (the "GPL")
38  * https://www.gnu.org/licenses/gpl.html
39  *
40  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
41  * https://www.gnu.org/licenses/lgpl.html
42  *
43  * - Mozilla Public License Version 1.1 or later (the "MPL")
44  * http://www.mozilla.org/MPL/MPL-1.1.html
45  *
46  * == END LICENSE ==
47  *
48  * Page used to upload new files in the current folder.
49 -->
50 <html>
51  <head>
52  <title>File Upload</title>
53  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
54 <?php
55 print '<!-- Includes CSS for Dolibarr theme -->'."\n";
56 // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
57 $themepath = dol_buildpath($conf->css, 1);
58 $themesubdir = '';
59 if (!empty($conf->modules_parts['theme'])) { // This slow down
60  foreach ($conf->modules_parts['theme'] as $reldir) {
61  if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
62  $themepath = dol_buildpath($reldir.$conf->css, 1);
63  $themesubdir = $reldir;
64  break;
65  }
66  }
67 }
68 
69 //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
70 print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
71 ?>
72  <link href="browser.css" type="text/css" rel="stylesheet" >
73  <script type="text/javascript" src="js/common.js"></script>
74  <script type="text/javascript">
75 
76 function SetCurrentFolder( resourceType, folderPath )
77 {
78  var sUrl = oConnector.ConnectorUrl + 'Command=FileUpload' ;
79  sUrl += '&Type=' + resourceType ;
80  sUrl += '&CurrentFolder=' + encodeURIComponent( folderPath );
81 
82  document.getElementById('frmUpload').action = sUrl ;
83 }
84 
85 function OnSubmit()
86 {
87  console.log("Click on OnSubmit");
88  if ( document.getElementById('NewFile').value.length == 0 )
89  {
90  alert( 'Please select a file from your computer' );
91  return false ;
92  }
93 
94  // Set the interface elements.
95  document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder (Upload in progress, please wait...)' ;
96  document.getElementById('btnUpload').disabled = true ;
97 
98  return true ;
99 }
100 
101 function OnUploadCompleted( errorNumber, data )
102 {
103  console.log("errorNumber = "+errorNumber);
104 
105  // Reset the Upload Worker Frame.
106  window.parent.frames['frmUploadWorker'].location = 'javascript:void(0)' ;
107 
108  // Reset the upload form (On IE we must do a little trick to avoid problems).
109  if ( document.all )
110  document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
111  else
112  document.getElementById('frmUpload').reset();
113 
114  // Reset the interface elements.
115  document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
116  document.getElementById('btnUpload').disabled = false ;
117 
118  switch ( errorNumber )
119  {
120  case 0:
121  window.parent.frames['frmResourcesList'].Refresh();
122  break;
123  case 1: // Custom error.
124  alert( data );
125  break;
126  case 201:
127  window.parent.frames['frmResourcesList'].Refresh();
128  alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + data + '"' );
129  break;
130  case 202:
131  alert( 'Invalid file (Bad extension)' );
132  break;
133  default:
134  alert( 'Error on file upload. Error number: ' + errorNumber );
135  break;
136  }
137 }
138 
139 window.onload = function()
140 {
141  window.top.IsLoadedUpload = true ;
142 }
143  </script>
144  </head>
145  <body>
146  <form id="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
147  <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
148  <table class="fullHeight" cellspacing="0" cellpadding="0" width="100%" border="0">
149  <tr>
150  <td class="nowrap valignmiddle">
151  <table width="100%" class="inline-block valignmiddle">
152  <tr>
153  <td><input id="NewFile" name="NewFile" type="file"></td>
154  <td class="nowrap">&nbsp;<input id="btnUpload" type="submit" value="Upload" class="flat button"></td>
155  </tr>
156  </table>
157  <!-- Section for upload result message -->
158  <span id="eUploadMessage"></span><br>
159  </td>
160  </tr>
161  </table>
162  </form>
163  </body>
164 </html>
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
name
$conf db name
Definition: repair.php:122
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119