XOOPS  2.6.0
ajax_calls.php
Go to the documentation of this file.
1 <?php
2 
3 include('config/config.php');
4 if($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager") die('Access Denied!');
5 include('include/utils.php');
6 
7 if (isset($_SESSION['RF']['language_file']) && file_exists($_SESSION['RF']['language_file'])){
8  include($_SESSION['RF']['language_file']);
9 }
10 else {
11  die('Language file is missing!');
12 }
13 
14 if(isset($_GET['action']))
15 {
16  switch($_GET['action'])
17  {
18  case 'view':
19  if(isset($_GET['type'])) {
20  $_SESSION['RF']["view_type"] = $_GET['type'];
21  }
22  else {
23  die('view type number missing');
24  }
25  break;
26  case 'sort':
27  if(isset($_GET['sort_by'])) {
28  $_SESSION['RF']["sort_by"] = $_GET['sort_by'];
29  }
30 
31  if(isset($_GET['descending'])) {
32  $_SESSION['RF']["descending"] = $_GET['descending'] === "TRUE";
33  }
34  break;
35  case 'image_size': // not used
36  $pos = strpos($_POST['path'],$upload_dir);
37  if ($pos !== FALSE)
38  {
39  $info=getimagesize(substr_replace($_POST['path'],$current_path,$pos,strlen($upload_dir)));
40  echo json_encode($info);
41  }
42  break;
43  case 'save_img':
44  $info=pathinfo($_POST['name']);
45 
46  if (strpos($_POST['path'], '/') === 0
47  || strpos($_POST['path'], '../') !== FALSE
48  || strpos($_POST['path'], './') === 0
49  || strpos($_POST['url'], 'http://featherfiles.aviary.com/') !== 0
50  || $_POST['name'] != fix_filename($_POST['name'], $transliteration)
51  || !in_array(strtolower($info['extension']), array('jpg','jpeg','png')))
52  {
53  die('wrong data');
54  }
55 
56  $image_data = get_file_by_url($_POST['url']);
57  if ($image_data === FALSE)
58  {
60  }
61 
62  file_put_contents($current_path.$_POST['path'].$_POST['name'],$image_data);
63 
64  create_img_gd($current_path.$_POST['path'].$_POST['name'], $thumbs_base_path.$_POST['path'].$_POST['name'], 122, 91);
65  // TODO something with this function cause its blowing my mind
67  break;
68  case 'extract':
69  if(strpos($_POST['path'],'/')===0 || strpos($_POST['path'],'../')!==FALSE || strpos($_POST['path'],'./')===0) {
70  die('wrong path');
71  }
72 
73  $path = $current_path.$_POST['path'];
74  $info = pathinfo($path);
75  $base_folder = $current_path.fix_dirname($_POST['path'])."/";
76 
77  switch($info['extension'])
78  {
79  case "zip":
80  $zip = new ZipArchive;
81  if ($zip->open($path) === TRUE) {
82  //make all the folders
83  for($i = 0; $i < $zip->numFiles; $i++)
84  {
85  $OnlyFileName = $zip->getNameIndex($i);
86  $FullFileName = $zip->statIndex($i);
87  if (substr($FullFileName['name'], -1, 1) =="/")
88  {
89  create_folder($base_folder.$FullFileName['name']);
90  }
91  }
92  //unzip into the folders
93  for($i = 0; $i < $zip->numFiles; $i++)
94  {
95  $OnlyFileName = $zip->getNameIndex($i);
96  $FullFileName = $zip->statIndex($i);
97 
98  if (!(substr($FullFileName['name'], -1, 1) =="/"))
99  {
100  $fileinfo = pathinfo($OnlyFileName);
101  if(in_array(strtolower($fileinfo['extension']),$ext))
102  {
103  copy('zip://'. $path .'#'. $OnlyFileName , $base_folder.$FullFileName['name'] );
104  }
105  }
106  }
107  $zip->close();
108  }
109  else {
110  die(lang_Zip_No_Extract);
111  }
112 
113  break;
114 
115  case "gz":
116  $p = new PharData($path);
117  $p->decompress(); // creates files.tar
118 
119  break;
120 
121  case "tar":
122  // unarchive from the tar
123  $phar = new PharData($path);
124  $phar->decompressFiles();
125  $files = array();
127  $phar->extractTo( $current_path.fix_dirname( $_POST['path'] )."/", $files, TRUE );
128 
129  break;
130 
131  default:
132  die(lang_Zip_Invalid);
133  }
134  break;
135  case 'media_preview':
136  $preview_file = $_GET["file"];
137  $info = pathinfo($preview_file);
138  ?>
139  <div id="jp_container_1" class="jp-video " style="margin:0 auto;">
140  <div class="jp-type-single">
141  <div id="jquery_jplayer_1" class="jp-jplayer"></div>
142  <div class="jp-gui">
143  <div class="jp-video-play">
144  <a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>
145  </div>
146  <div class="jp-interface">
147  <div class="jp-progress">
148  <div class="jp-seek-bar">
149  <div class="jp-play-bar"></div>
150  </div>
151  </div>
152  <div class="jp-current-time"></div>
153  <div class="jp-duration"></div>
154  <div class="jp-controls-holder">
155  <ul class="jp-controls">
156  <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
157  <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
158  <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
159  <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
160  <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
161  <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
162  </ul>
163  <div class="jp-volume-bar">
164  <div class="jp-volume-bar-value"></div>
165  </div>
166  <ul class="jp-toggles">
167  <li><a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen">full screen</a></li>
168  <li><a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen">restore screen</a></li>
169  <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
170  <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
171  </ul>
172  </div>
173  <div class="jp-title" style="display:none;">
174  <ul>
175  <li></li>
176  </ul>
177  </div>
178  </div>
179  </div>
180  <div class="jp-no-solution">
181  <span>Update Required</span>
182  To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
183  </div>
184  </div>
185  </div>
186  <?php
187  if(in_array(strtolower($info['extension']), $ext_music)) {
188  ?>
189 
190  <script type="text/javascript">
191  $(document).ready(function(){
192 
193  $("#jquery_jplayer_1").jPlayer({
194  ready: function () {
195  $(this).jPlayer("setMedia", {
196  title:"<?php $_GET['title']; ?>",
197  mp3: "<?php echo $preview_file; ?>",
198  m4a: "<?php echo $preview_file; ?>",
199  oga: "<?php echo $preview_file; ?>",
200  wav: "<?php echo $preview_file; ?>"
201  });
202  },
203  swfPath: "js",
204  solution:"html,flash",
205  supplied: "mp3, m4a, midi, mid, oga,webma, ogg, wav",
206  smoothPlayBar: TRUE,
207  keyEnabled: FALSE
208  });
209  });
210  </script>
211 
212  <?php
213  } elseif(in_array(strtolower($info['extension']), $ext_video)) {
214  ?>
215 
216  <script type="text/javascript">
217  $(document).ready(function(){
218 
219  $("#jquery_jplayer_1").jPlayer({
220  ready: function () {
221  $(this).jPlayer("setMedia", {
222  title:"<?php $_GET['title']; ?>",
223  m4v: "<?php echo $preview_file; ?>",
224  ogv: "<?php echo $preview_file; ?>"
225  });
226  },
227  swfPath: "js",
228  solution:"html,flash",
229  supplied: "mp4, m4v, ogv, flv, webmv, webm",
230  smoothPlayBar: TRUE,
231  keyEnabled: FALSE
232  });
233 
234  });
235  </script>
236 
237  <?php
238  }
239  break;
240  case 'copy_cut':
241  if ($_POST['sub_action'] != 'copy' && $_POST['sub_action'] != 'cut') {
242  die('wrong sub-action');
243  }
244 
245  if (trim($_POST['path']) == '' || trim($_POST['path_thumb']) == '') {
246  die('no path');
247  }
248 
249  $path = $current_path.$_POST['path'];
250  $info = pathinfo($path);
251  $base_folder = $current_path.fix_dirname($_POST['path'])."/";
252 
253  if (is_dir($path))
254  {
255  // can't copy/cut dirs
256  if ($copy_cut_dirs === FALSE){
257  die(sprintf(lang_Copy_Cut_Not_Allowed, ($_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut)), lang_Folders));
258  }
259 
260  // size over limit
261  if ($copy_cut_max_size !== FALSE && is_int($copy_cut_max_size)){
262  if (($copy_cut_max_size * 1024 * 1024) < foldersize($path)){
263  die(sprintf(lang_Copy_Cut_Size_Limit, ($_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut)), $copy_cut_max_size));
264  }
265  }
266 
267  // file count over limit
268  if ($copy_cut_max_count !== FALSE && is_int($copy_cut_max_count)){
270  die(sprintf(lang_Copy_Cut_Count_Limit, ($_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut)), $copy_cut_max_count));
271  }
272  }
273  }
274  else {
275  // can't copy/cut files
276  if ($copy_cut_files === FALSE){
277  die(sprintf(lang_Copy_Cut_Not_Allowed, ($_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut)), lang_Files));
278  }
279  }
280 
281  $_SESSION['RF']['clipboard']['path'] = $path;
282  $_SESSION['RF']['clipboard']['path_thumb'] = $_POST['path_thumb'];
283  $_SESSION['RF']['clipboard_action'] = $_POST['sub_action'];
284  break;
285  case 'clear_clipboard':
286  $_SESSION['RF']['clipboard'] = NULL;
287  $_SESSION['RF']['clipboard_action'] = NULL;
288  break;
289  default: die('no action passed');
290  }
291 }
292 else
293 {
294  die('no action passed');
295 }
296 
297 ?>
$copy_cut_dirs
Definition: config.php:129
$current_path
Definition: config.php:3
$fixed_image_creation_height
Definition: config.php:220
$relative_image_creation_name_to_prepend
Definition: config.php:229
$path
Definition: execute.php:31
$_SESSION['RF']["verify"]
Definition: dialog.php:4
$ext_video
Definition: config.php:164
$thumbs_base_path
Definition: config.php:67
$i
Definition: dialog.php:68
$relative_image_creation_height
Definition: config.php:232
const lang_Copy_Cut_Count_Limit
Definition: az_AZ.php:70
new_thumbnails_creation($targetPath, $targetFile, $name, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height)
Definition: utils.php:275
const lang_Copy_Cut_Not_Allowed
Definition: az_AZ.php:71
create_img_gd($imgfile, $imgthumb, $newwidth, $newheight="")
Definition: utils.php:43
const lang_Zip_Invalid
Definition: az_AZ.php:74
const lang_Aviary_No_Save
Definition: az_AZ.php:72
foldersize($path)
Definition: utils.php:76
$relative_path_from_current_pos
Definition: config.php:228
$files
Definition: index.php:35
$copy_cut_max_count
Definition: config.php:156
$fixed_image_creation
Definition: config.php:215
create_folder($path=false, $path_thumbs=false)
Definition: utils.php:119
const lang_Zip_No_Extract
Definition: az_AZ.php:73
filescount($path)
Definition: utils.php:98
$relative_image_creation_name_to_append
Definition: config.php:230
if($xoopsUser) $copy_cut_max_size
Definition: config.php:153
$fixed_image_creation_name_to_prepend
Definition: config.php:217
$fixed_image_creation_to_append
Definition: config.php:218
$ext_music
Definition: config.php:165
if(isset($_POST['name'])) $info
Definition: execute.php:57
$copy_cut_files
Definition: config.php:128
$ext
Definition: browse.php:87
$relative_image_creation_width
Definition: config.php:231
$relative_image_creation
Definition: config.php:227
fix_filename($str, $transliteration)
Definition: utils.php:163
const lang_Folders
Definition: az_AZ.php:58
$fixed_path_from_filemanager
Definition: config.php:216
const lang_Copy
Definition: az_AZ.php:59
$transliteration
Definition: config.php:84
check_files_extensions_on_phar($phar, &$files, $basepath, $ext)
Definition: utils.php:141
$fixed_image_creation_width
Definition: config.php:219
get_file_by_url($url)
Definition: utils.php:305
const lang_Copy_Cut_Size_Limit
Definition: az_AZ.php:69
$upload_dir
Definition: config.php:61
const lang_Cut
Definition: az_AZ.php:60
const lang_Files
Definition: az_AZ.php:7