source: trunk/plugins/MootoolsFileManager/backend.php @ 1287

Last change on this file since 1287 was 1245, checked in by gogo, 10 years ago

ticket:1502

Add support for attributes being set in MootoolsFileManager? for images.
Split out the "modes" of MootoolsFileManager? into different javascript files.

File size: 4.0 KB
Line 
1<?php
2/**
3* Unified backend for ImageManager
4*
5* Image Manager was originally developed by:
6*   Xiang Wei Zhuo, email: xiangweizhuo(at)hotmail.com Wei Shou.
7*
8* Unified backend sponsored by DTLink Software, http://www.dtlink.com
9* Implementation by Yermo Lamers, http://www.formvista.com
10*
11* (c) DTLink, LLC 2005.
12* Distributed under the same terms as HTMLArea itself.
13* This notice MUST stay intact for use (see license.txt).
14*
15* DESCRIPTION:
16*
17* Instead of using separate URL's for each function, ImageManager now
18* routes all requests to the server through this single, replaceable,
19* entry point. backend.php expects at least two URL variable parameters:
20*
21* __plugin=ImageManager   for future expansion; identify the plugin being requested.
22* __function=thumbs|images|editorFrame|editor|manager  function being called.
23*
24* Having a single entry point that strictly adheres to a defined interface will
25* make the backend code much easier to maintain and expand. It will make it easier
26* on integrators, not to mention it'll make it easier to have separate
27* implementations of the backend in different languages (Perl, Python, ASP, etc.)
28*
29* @see config.inc.php
30*/
31
32// Strip slashes if MQGPC is on
33set_magic_quotes_runtime(0);
34if(get_magic_quotes_gpc())
35{
36  $to_clean = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
37  while(count($to_clean))
38  {
39    $cleaning =& $to_clean[array_pop($junk = array_keys($to_clean))];
40    unset($to_clean[array_pop($junk = array_keys($to_clean))]);
41    foreach(array_keys($cleaning) as $k)
42    {
43      if(is_array($cleaning[$k]))
44      {
45        $to_clean[] =& $cleaning[$k];
46      }
47      else
48      {
49        $cleaning[$k] = stripslashes($cleaning[$k]);
50      }
51    }
52  }
53}
54
55function size_to_bytes($s)
56{
57  if(preg_match('/([0-9\.])+([a-zA-Z]+)/', $s, $M))
58  {
59    switch(strtolower($M))
60    {     
61      case 'm':
62        return floor(floatval($M[1]) * 1024 * 1024);
63       
64      case 'b':
65        return intval($M[1]);
66       
67      case 'kb':
68        return floor(floatval($M[1]) * 1024);     
69    }
70  }
71 
72  if(floatval($s) < 10)   return floor(floatval($s) * 1024 * 1024);
73  if(floatval($s) < 1024) return floor(floatval($s) * 1024); // Kilobytes
74  return intval($s); // Bytes
75}
76
77require_once('config.php');
78
79switch ( @$_REQUEST[ "__function" ] )
80{
81  case 'read-config':       
82    // This is used so that the javascript can read the config
83    // so we don't have to have a js config and a php config duplicating
84    // settings
85    echo xinha_to_js($IMConfig);
86    break;
87
88  case 'image-manager':
89    include('mootools-filemanager/Backend/FileManager.php');
90
91    $browser = new FileManager(array(
92      'directory'     => $IMConfig['images_dir'],
93      'baseURL'       => $IMConfig['images_url'],
94     
95      'assetBasePath' => $IMConfig['base_url'] .'/mootools-filemanager/Assets',
96     
97      'upload'        => $IMConfig['allow_images_upload'],
98      'maxUploadSize' => size_to_bytes($IMConfig['max_images_upload_size']),
99     
100      'suggestedMaxImageDimension' => $IMConfig['suggested_images_image_dimension'],
101           
102      'destroy'       => $IMConfig['allow_images_delete'],
103      'filter'        => 'image/',
104           
105    ));
106
107    $browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
108    break;
109 
110  case 'file-manager':
111    include('mootools-filemanager/Backend/FileManager.php');
112
113    $browser = new FileManager(array(
114      'directory'     => $IMConfig['files_dir'],
115      'baseURL'       => $IMConfig['files_url'],
116     
117      'assetBasePath' => $IMConfig['base_url'] .'/mootools-filemanager/Assets',
118     
119      'upload'        => $IMConfig['allow_files_upload'],
120      'maxUploadSize' => size_to_bytes($IMConfig['max_files_upload_size']),
121     
122      'suggestedMaxImageDimension' => $IMConfig['suggested_files_image_dimension'],
123           
124      'destroy'       => $IMConfig['allow_files_delete'],
125     // 'filter'        => $IMConfig['files_filter'],
126           
127    ));
128
129    $browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
130    break;
131}
132
133?>
Note: See TracBrowser for help on using the repository browser.