1 | <!DOCTYPE HTML> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
---|
5 | <link rel="stylesheet" type="text/css" href="css/dropzone.css" media="screen" /> |
---|
6 | <link rel="stylesheet" type="text/css" href="css/lliurex.css" media="screen" /> |
---|
7 | <title>Servidor LliureX</title> |
---|
8 | <script language="JavaScript" src="./jclic/jclicplugin.js" type="text/javascript"></script> |
---|
9 | <script type="text/javascript" src="./lib/jquery-3.2.0.min.js"></script> |
---|
10 | <script type="text/javascript" src="./lib/jquery.form.min.js"></script> |
---|
11 | <script type="text/javascript" src="./js/lliurex.js"></script> |
---|
12 | <script type="text/javascript" src="./lib/dropzone.js"></script> |
---|
13 | |
---|
14 | |
---|
15 | <script type="text/javascript"> |
---|
16 | Dropzone.autoDiscover = false; |
---|
17 | //var mydata = new FormData(); |
---|
18 | var index=0; |
---|
19 | |
---|
20 | function doesFileExist(urlToFile) |
---|
21 | { |
---|
22 | console.log(urlToFile); |
---|
23 | var xhr = new XMLHttpRequest(); |
---|
24 | xhr.open('HEAD', urlToFile, false); |
---|
25 | xhr.send(); |
---|
26 | console.log(xhr.status); |
---|
27 | if (xhr.status == "404") { |
---|
28 | console.log("File doesn't exist"); |
---|
29 | return false; |
---|
30 | } else { |
---|
31 | console.log("File exists"); |
---|
32 | return true; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | function execute(jclicpath, alert_lang, ident) |
---|
37 | { |
---|
38 | //console.log(jclicpath); |
---|
39 | var datos = {"argumento":jclicpath}; |
---|
40 | document.body.style.cursor = "progress"; |
---|
41 | var path_server="http://jclic-aula/"; |
---|
42 | var banner = document.getElementById(ident); |
---|
43 | var path1 ="document.location="; |
---|
44 | var path_base=jclicpath.match(/(.*)[\/\\]/)[1]||''; |
---|
45 | //console.log(path_base); |
---|
46 | var filename=jclicpath.replace(/^.*(\\|\/|\:)/, ''); |
---|
47 | path_lock="jclic_uploads/0rig_jclic/"; |
---|
48 | path_base=path_server.concat(path_base); |
---|
49 | //console.log(path_base); |
---|
50 | path_lock=path_server.concat(path_lock); |
---|
51 | path_lock=path_lock.concat(filename); |
---|
52 | path_lock=path_lock.concat(".lock"); |
---|
53 | //console.log(path_lock); |
---|
54 | var result=doesFileExist(path_lock); |
---|
55 | //console.log(result); |
---|
56 | if (result == true){ |
---|
57 | alert(alert_lang); |
---|
58 | document.body.style.cursor = ""; |
---|
59 | window.location.reload(); |
---|
60 | return |
---|
61 | } |
---|
62 | console.log(datos); |
---|
63 | $.ajax({beforeSend: function(){ |
---|
64 | document.getElementById(ident).classList.toggle("click_bannerw"); |
---|
65 | },"url":"http://server/jclic-aula/jclic_html5.php",type: "POST","data":datos, complete: function() { |
---|
66 | document.body.style.cursor = ""; |
---|
67 | banner.className += " click_banner5"; |
---|
68 | //banner.className = "click_banner5"; |
---|
69 | console.log(path_base); |
---|
70 | console.log(filename); |
---|
71 | /*if (path_base == "/net/server-sync/share/jclic-aula" || path_base == "/var/www/jclic-aula"){ |
---|
72 | path_base="jclic_uploads/"; |
---|
73 | path_base=path_base.concat(filename); |
---|
74 | jclicpath=path_base; |
---|
75 | }*/ |
---|
76 | path_base="jclic_uploads/"; |
---|
77 | path_base=path_base.concat(filename); |
---|
78 | jclicpath=path_base; |
---|
79 | jclicpath=jclicpath.split(".jclic.zip").slice(0, -1).join(".") |
---|
80 | path=path1.concat('"'); |
---|
81 | path=path.concat(jclicpath); |
---|
82 | path=path.concat('"'); |
---|
83 | banner.setAttribute('onClick',path) |
---|
84 | }}); |
---|
85 | |
---|
86 | |
---|
87 | //alert(alert_lang) |
---|
88 | //window.location.reload() |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | $(document).ready(function(){ |
---|
94 | |
---|
95 | |
---|
96 | // Get the template HTML and remove it from the doumenthe template HTML and remove it from the doument |
---|
97 | /*var previewNode = $("#template"); |
---|
98 | previewNode.id = ""; |
---|
99 | var previewTemplate = previewNode.parent().innerHTML; |
---|
100 | previewNode.remove(); |
---|
101 | //previewNode.parent().remove(previewNode);*/ |
---|
102 | |
---|
103 | var previewTemplate=$("#template").prop('outerHTML'); |
---|
104 | $("#template").remove(); |
---|
105 | |
---|
106 | $("div#files_upload").dropzone({ |
---|
107 | paramName: "file", |
---|
108 | previewTemplate: previewTemplate, |
---|
109 | url: "upload.php", |
---|
110 | acceptedFiles: ".zip, .jclic", |
---|
111 | addRemoveLinks: true, |
---|
112 | success: function(file, response) { |
---|
113 | $(".dz-preview.dz-processing").hide(500, function(){ |
---|
114 | //$(".dz-message").css("display", "block"); |
---|
115 | $(".dz-message").css("opacity", "50"); |
---|
116 | var rscname=($(response).attr("id")); |
---|
117 | var rsc_div=$("#"+rscname); |
---|
118 | // Only add if is not in GUI |
---|
119 | if (rsc_div.length==0){ |
---|
120 | $("#custom_links").append(response); |
---|
121 | $('#rscpersonal').fadeOut(); |
---|
122 | } |
---|
123 | //var rsc_div=$("div#"+rscname); |
---|
124 | //var rsc_div=$("#"+rsc_div); |
---|
125 | }); |
---|
126 | } |
---|
127 | }); |
---|
128 | |
---|
129 | |
---|
130 | }); |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | |
---|
136 | |
---|
137 | </script> |
---|
138 | <style type="text/css"> |
---|
139 | </style> |
---|
140 | </head> |
---|
141 | |
---|
142 | |
---|
143 | <body> |
---|
144 | |
---|
145 | <!-- TEMPLATE FOR LOGIN PANEL --> |
---|
146 | <div id="wrapper"> |
---|
147 | <?php |
---|
148 | |
---|
149 | function validate($user, $pass){ |
---|
150 | try{ |
---|
151 | |
---|
152 | //$ret=system("python ./validate_user.py $user $pass"); |
---|
153 | $ret=exec("python ./validate_user.py $user $pass"); |
---|
154 | |
---|
155 | //echo "RET IS:$ret\n"; |
---|
156 | if ($ret=="true") { |
---|
157 | //echo "starting session"; |
---|
158 | session_start(); |
---|
159 | $_SESSION['user'] = $user; |
---|
160 | $_SESSION['role'] ="admin"; |
---|
161 | return true; |
---|
162 | } |
---|
163 | else return false; |
---|
164 | |
---|
165 | } |
---|
166 | catch(Exception $e) { |
---|
167 | echo ('Caught exception: '.$e->getMessage()."\n"); |
---|
168 | } |
---|
169 | }; // End function validate |
---|
170 | |
---|
171 | |
---|
172 | //Clear session |
---|
173 | session_start(); |
---|
174 | $_SESSION = array(); |
---|
175 | session_destroy(); |
---|
176 | |
---|
177 | try{ |
---|
178 | $user = $_POST["user"]; |
---|
179 | $pass = $_POST["pass"]; |
---|
180 | } catch(Exception $e){ |
---|
181 | $user=false; |
---|
182 | } |
---|
183 | |
---|
184 | if($user){ |
---|
185 | if (validate($user, $pass)) include ("logout.php"); |
---|
186 | else include ("login.php"); |
---|
187 | } else include ("login.php"); |
---|
188 | |
---|
189 | |
---|
190 | ?> |
---|
191 | <!-- END TEMPLATE FOR LOGIN PANEL --> |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | <!-- TEMPLATE FOR HEADER LLIUREX BANNER PANEL --> |
---|
196 | <div id="header"> |
---|
197 | <div id="lpanel"> |
---|
198 | <ul> |
---|
199 | <div class="hdrbutton"><a href="http://lliurex.net"><img id="llxbt" class="btimg" src="imagen/lliurex.jpg"></a></div> |
---|
200 | <div class="hdrbutton"><a href="http://mestreacasa.gva.es"><img id="mestrebt" class="btimg" src="imagen/mestreacasa.jpg"></a></div> |
---|
201 | <div class="hdrbutton"><a href="http://sai.edu.gva.es"><img id="saibt" class="btimg" src="imagen/sai.gif"></a></div> |
---|
202 | </ul> |
---|
203 | </div><!-- lpanel --> |
---|
204 | |
---|
205 | </div><!-- header --> |
---|
206 | |
---|
207 | <!-- END TEMPLATE FOR HEADER LLIUREX BANNER PANEL --> |
---|
208 | |
---|
209 | |
---|
210 | <!-- TEMPLATE FOR BODY JCLIC APPS PANEL --> |
---|
211 | <div id="notice"> |
---|
212 | <?php |
---|
213 | include_once('get_locale.php'); |
---|
214 | include_once 'preg_find.php'; |
---|
215 | |
---|
216 | function getNameFromZip($dir, $resource){ |
---|
217 | $rsc_name=""; |
---|
218 | //echo "getname**$resource- - \n"; |
---|
219 | try{ |
---|
220 | $zip = zip_open("$dir/$resource"); |
---|
221 | if ($zip){ |
---|
222 | while ($zip_entry = zip_read($zip)){ |
---|
223 | if(substr(zip_entry_name($zip_entry),-6)==".jclic"){ |
---|
224 | //echo "dentrooooo"; |
---|
225 | |
---|
226 | |
---|
227 | if (zip_entry_open($zip, $zip_entry, "r")) { |
---|
228 | |
---|
229 | $data = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); |
---|
230 | $zip_entry_xml=new SimpleXMLElement($data); |
---|
231 | $rsc_name=$zip_entry_xml->settings->title; |
---|
232 | } |
---|
233 | zip_entry_close($zip_entry); |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | zip_close($zip); |
---|
238 | } |
---|
239 | return $rsc_name; |
---|
240 | } // try |
---|
241 | catch(Exception $e) { |
---|
242 | echo 'Caught exception: '.$e->getMessage()."\n"; |
---|
243 | return $dir; |
---|
244 | } |
---|
245 | |
---|
246 | } |
---|
247 | // end function getNameFromZip |
---|
248 | |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | function replaceAccents($str) { |
---|
253 | |
---|
254 | $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ"); |
---|
255 | |
---|
256 | $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,o,O,A,A,A,A,A,E,E,E,E,I,I,I,I,O,O,O,O,U,U,U,U,Y,C,AE,OE"); |
---|
257 | |
---|
258 | return str_replace($search, $replace, $str); |
---|
259 | } |
---|
260 | // end function getNameFromZip |
---|
261 | |
---|
262 | |
---|
263 | |
---|
264 | |
---|
265 | function adding_resource_json($file_json, $library, $file_name, $id, $title){ |
---|
266 | |
---|
267 | $temp_array=$file_json; |
---|
268 | $path_json="/net/server-sync/share/jclic-aula/jclic_uploads/0rig_jclic/jclic_files.json"; |
---|
269 | if ( isset($temp_array[$library])){ |
---|
270 | $temp_array[$library]+=array($file_name=>array('id'=>$id, 'title'=> $title)); |
---|
271 | }else { |
---|
272 | $temp_array+=array($library=>array($file_name=>array('id'=>$id, 'title'=> $title))); |
---|
273 | } |
---|
274 | $jclic_json=fopen($path_json,'w'); |
---|
275 | fwrite($jclic_json, json_encode($temp_array)); |
---|
276 | fclose($jclic_json); |
---|
277 | //echo "se añadieron cosas"; |
---|
278 | return $temp_array; |
---|
279 | } |
---|
280 | // end function adding_resource_json |
---|
281 | |
---|
282 | |
---|
283 | |
---|
284 | |
---|
285 | |
---|
286 | function resource_not_in_json($file_json, $library, $file_name){ |
---|
287 | $finded=false; |
---|
288 | $temp_array = $file_json; |
---|
289 | if ( isset($temp_array[$library][$file_name])){ |
---|
290 | $identificador=$temp_array[$library][$file_name]['id']; |
---|
291 | $titulo=$temp_array[$library][$file_name]['title']; |
---|
292 | $finded=true; |
---|
293 | return array($file_json, $finded, $identificador, $titulo); |
---|
294 | }else{ |
---|
295 | $identificador=false; |
---|
296 | $titulo=false; |
---|
297 | } |
---|
298 | return array($file_json, $finded, $identificador, $titulo); |
---|
299 | } |
---|
300 | // end function adding_resource_json |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | function replace_text($lookfor, $newtext, $filename){ |
---|
305 | try{ |
---|
306 | $filedata = file ($filename); |
---|
307 | $newdata = array(); |
---|
308 | foreach ($filedata as $filerow){ |
---|
309 | if (strstr($filerow, $lookfor) !== false){ |
---|
310 | $filerow = $newtext; |
---|
311 | } |
---|
312 | $newdata[] = $filerow; |
---|
313 | } |
---|
314 | file_put_contents($filename, $newdata); |
---|
315 | return TRUE; |
---|
316 | } // try |
---|
317 | catch(Exception $e) { |
---|
318 | echo 'Caught exception: ', $e->getMessage(), "\n"; |
---|
319 | return FALSE; |
---|
320 | } |
---|
321 | } |
---|
322 | // end function replace_text |
---|
323 | |
---|
324 | |
---|
325 | |
---|
326 | |
---|
327 | |
---|
328 | function CreateButton($dir, $resource, $class, $locale, $activities_orig, $library, $temp_array){ |
---|
329 | //echo "$resource\n"; |
---|
330 | //print_r ($activities_orig); |
---|
331 | //$file_json="/net/server-sync/share/jclic-aula/jclic_uploads/0rig_jclic/jclic_files.json"; |
---|
332 | $index_base="http://server/jclic-aula/jclic/index_base.html"; |
---|
333 | $resource_finded=array(false,false); |
---|
334 | //var_dump($temp_array); |
---|
335 | if ($class=="library"){ |
---|
336 | //echo "library"; |
---|
337 | $indexfile="$dir/$resource"; |
---|
338 | $library_file=basename($indexfile); |
---|
339 | //var_dump("$library_file"); |
---|
340 | $added=false; |
---|
341 | $file_name=dirname($indexfile); |
---|
342 | $resource_finded=resource_not_in_json($temp_array, $library, $file_name); |
---|
343 | if ($resource_finded[1]){ |
---|
344 | $indent=$resource_finded[2]; |
---|
345 | $title=$resource_finded[3]; |
---|
346 | //echo "encontrado index"; |
---|
347 | }else{ |
---|
348 | //No existe en el json el fichero debo anyadirlo con titulo |
---|
349 | $added=true; |
---|
350 | //obtengo nombre de la actividad |
---|
351 | if(is_file($indexfile)){ |
---|
352 | $file=fopen($indexfile,r); |
---|
353 | while (!feof($file)){ |
---|
354 | $read = fgets($file,255); |
---|
355 | if (stristr($read,"<title>")){ |
---|
356 | $title=strip_tags($read); |
---|
357 | } |
---|
358 | } |
---|
359 | fclose($file); |
---|
360 | // echo "falta este html"; |
---|
361 | }else{ |
---|
362 | $title=""; |
---|
363 | } |
---|
364 | //echo $title; |
---|
365 | $title=trim($title); |
---|
366 | |
---|
367 | if (in_array($indent,$activities_orig)){ |
---|
368 | return($indent); |
---|
369 | }else{ |
---|
370 | //print ($title); |
---|
371 | |
---|
372 | if ((strcasecmp( $title, 'sin nombre' ) == 0) || (strcasecmp( $rsc_name, 'sense nom' ) == 0)){ |
---|
373 | $title=$resource_dir; |
---|
374 | } |
---|
375 | $indent=$resource; |
---|
376 | if ($added) { |
---|
377 | $temp_array=adding_resource_json($temp_array, $library, $file_name, $indent, $title); |
---|
378 | } |
---|
379 | } |
---|
380 | } |
---|
381 | //var_dump($title); |
---|
382 | //debo generarle el index si no lo posee ya |
---|
383 | if(!is_file("$file_name/index.html")){ |
---|
384 | copy($index_base,"$file_name/index.html" ); |
---|
385 | $filedata = file ("$file_name/index.html"); |
---|
386 | $newdata = array(); |
---|
387 | $lookfor = "library_file"; |
---|
388 | $newtext = '<div class ="JClic" data-project="'.$library_file.'"></div>'; |
---|
389 | foreach ($filedata as $filerow){ |
---|
390 | if (strstr($filerow, $lookfor) !== false){ |
---|
391 | $filerow = $newtext; |
---|
392 | } |
---|
393 | $newdata[] = $filerow; |
---|
394 | } |
---|
395 | file_put_contents("$file_name/index.html", $newdata); |
---|
396 | } |
---|
397 | print("<div class='click_banner5' id=$indent onClick='document.location=\"$file_name\"'>\n"); |
---|
398 | print("<div class='rsc_name_new'><span>$title </span></div>"); |
---|
399 | print("</div>"); |
---|
400 | |
---|
401 | }else{ |
---|
402 | |
---|
403 | |
---|
404 | if ($class=="html"){ |
---|
405 | //echo "HTML"; |
---|
406 | $resource_dir=$resource; |
---|
407 | $indexfile="$dir/$resource_dir/index.html"; |
---|
408 | $file_name="$dir/$resource_dir"; |
---|
409 | $added=false; |
---|
410 | //print("$indexfile"); |
---|
411 | $resource_finded=resource_not_in_json($temp_array, $library, $file_name); |
---|
412 | //var_dump($resource_finded); |
---|
413 | if ($resource_finded[1]){ |
---|
414 | $indent=$resource_finded[2]; |
---|
415 | $title=$resource_finded[3]; |
---|
416 | //echo "encontrado html"; |
---|
417 | }else{ |
---|
418 | $added=true; |
---|
419 | if(is_file($indexfile)){ |
---|
420 | $file=fopen($indexfile,r); |
---|
421 | while (!feof($file)){ |
---|
422 | $read = fgets($file,255); |
---|
423 | if (stristr($read,"<title>")){ |
---|
424 | $title=strip_tags($read); |
---|
425 | } |
---|
426 | } |
---|
427 | fclose($file); |
---|
428 | // echo "falta este html"; |
---|
429 | }else{ |
---|
430 | $title=""; |
---|
431 | } |
---|
432 | //echo $title; |
---|
433 | $title=trim($title); |
---|
434 | |
---|
435 | if (in_array($indent,$activities_orig)){ |
---|
436 | return($indent); |
---|
437 | }else{ |
---|
438 | //print ($title); |
---|
439 | |
---|
440 | if ((strcasecmp( $title, 'sin nombre' ) == 0) || (strcasecmp( $rsc_name, 'sense nom' ) == 0)){ |
---|
441 | $title=$resource_dir; |
---|
442 | } |
---|
443 | $indent=$resource; |
---|
444 | if ($added) { |
---|
445 | $temp_array=adding_resource_json($temp_array, $library, $file_name, $indent, $title); |
---|
446 | } |
---|
447 | } |
---|
448 | } |
---|
449 | print("<div class='click_banner5' id=$indent onClick='document.location=\"$dir/$resource_dir\"'>\n"); |
---|
450 | print("<div class='rsc_name_new'><span>$title </span></div>"); |
---|
451 | print("</div>"); |
---|
452 | |
---|
453 | } else{ |
---|
454 | //Es un fichero jclic y necesita de un index para ser lanzado, le crearemos una carpeta y le haremos un index |
---|
455 | //echo "JCLIC"; |
---|
456 | $file_name="$dir/$resource"; |
---|
457 | $file_extension=$file_name; |
---|
458 | $folder_name=$file_name; |
---|
459 | //Necesito generar un nombre para la carpeta |
---|
460 | while ($file_extension != ""){ |
---|
461 | $path_parts = pathinfo($folder_name); |
---|
462 | $folder_name = $path_parts['filename']; |
---|
463 | $file_extension = $path_parts['extension']; |
---|
464 | } |
---|
465 | //Ya tengo el nombre de la carpeta, la creo |
---|
466 | $folder_name = preg_replace("/[^a-zA-Z 0-9]+/", "", $folder_name ); |
---|
467 | while(is_dir("$dir/$folder_name")){ |
---|
468 | $folder_name="$folder_name.$folder_name"; |
---|
469 | } |
---|
470 | mkdir("$dir/$folder_name"); |
---|
471 | |
---|
472 | //Sacamos el titulo del banner |
---|
473 | $rsc_name=getNameFromZip($dir, $resource); |
---|
474 | $title=$rsc_name; |
---|
475 | $title=(string)$title; |
---|
476 | $title=replaceAccents($title); |
---|
477 | |
---|
478 | $path_parts = pathinfo($resource); |
---|
479 | $indent=$path_parts['filename']; |
---|
480 | $cool_extensions = Array('jclic','zip','inst'); |
---|
481 | if (in_array(pathinfo($indent, PATHINFO_EXTENSION), $cool_extensions)){ |
---|
482 | $indent = pathinfo($indent, PATHINFO_FILENAME); |
---|
483 | } |
---|
484 | if ( (strcasecmp( $title, 'Sin nombre' ) == 0) || (strcasecmp( $title, 'sense nom' ) == 0)){ |
---|
485 | $title=$indent; |
---|
486 | } |
---|
487 | $title = preg_replace("/[^a-zA-Z 0-9]+/", "", $title ); |
---|
488 | |
---|
489 | //Ya tenemos el titulo, ahora vamos a ponerlo en la ruta que toca antes de almacenarlo |
---|
490 | rename("$file_name","$dir/$folder_name/$resource"); |
---|
491 | $file_name="$dir/$folder_name"; |
---|
492 | |
---|
493 | $temp_array=adding_resource_json($temp_array, $library, $file_name, $indent, $title); |
---|
494 | |
---|
495 | //debo generarle el index si no lo posee ya |
---|
496 | if(!is_file("$file_name/index.html")){ |
---|
497 | copy($index_base,"$file_name/index.html" ); |
---|
498 | $filename = "$file_name/index.html"; |
---|
499 | $lookfor = "library_title"; |
---|
500 | $newtext = '<title>'.$title.'</title>'; |
---|
501 | replace_text($lookfor, $newtext, $filename); |
---|
502 | $lookfor = "library_file"; |
---|
503 | $newtext = '<div class ="JClic" data-project="'.$resource.'"></div>'; |
---|
504 | replace_text($lookfor, $newtext, $filename); |
---|
505 | } |
---|
506 | print("<div class='click_banner5' id=$indent onClick='document.location=\"$file_name\"'>\n"); |
---|
507 | print("<div class='rsc_name_new'><span>$title </span></div>"); |
---|
508 | print("</div>"); |
---|
509 | } |
---|
510 | } |
---|
511 | //var_dump($temp_array); |
---|
512 | return array($indent, $temp_array); |
---|
513 | } |
---|
514 | // end function LoadResourcesFromDir |
---|
515 | |
---|
516 | |
---|
517 | |
---|
518 | |
---|
519 | |
---|
520 | function LoadResourcesFromDir($jclicdirectory, $locale,$activities_orig, $library, $temp_array){ |
---|
521 | |
---|
522 | $rscfound=0; // Resources found |
---|
523 | |
---|
524 | $jclicconten = opendir($jclicdirectory); |
---|
525 | //print_r ($activities_orig); |
---|
526 | $activities=array(); |
---|
527 | $lista = array(); |
---|
528 | |
---|
529 | //READING DIRECTORY |
---|
530 | while($jclicfile = readdir($jclicconten)){ |
---|
531 | //print ("leyendo"); |
---|
532 | if (substr("$jclicfile", 0, 1) != "."){ |
---|
533 | $ext_path=pathinfo($jclicfile, PATHINFO_EXTENSION); |
---|
534 | if (strcasecmp( $ext_path, 'inst' ) !== 0){ |
---|
535 | //No necesito la carpeta 0rig |
---|
536 | if(!strstr($jclicfile, '0rig_jclic')){ |
---|
537 | $lista[] = $jclicfile; |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | } |
---|
542 | //print_r($lista); |
---|
543 | |
---|
544 | if(count($lista)>0){ |
---|
545 | sort($lista); |
---|
546 | $title2=""; |
---|
547 | $resource=""; |
---|
548 | |
---|
549 | foreach($lista as $item){ |
---|
550 | if(strpos($item, '.jclic')){ |
---|
551 | //echo "FOUND JCLIC LISTS!!!!!"; |
---|
552 | if ($item!=""){ |
---|
553 | // Button for .jclic.zip |
---|
554 | list ($title2, $temp_array)=CreateButton($jclicdirectory, $item, "jclic",$locale ,$activities_orig, $library, $temp_array); |
---|
555 | $activities[] = trim($title2); |
---|
556 | // Increasing number of elements |
---|
557 | $rscfound++; |
---|
558 | } |
---|
559 | }else{ |
---|
560 | $itemdir="$jclicdirectory/$item"; |
---|
561 | //var_dump($itemdir); |
---|
562 | if(is_dir($itemdir) && (strstr($jclicdirectory,'jclic_upload'))){ |
---|
563 | $index_file="$jclicdirectory/$item/index.html"; |
---|
564 | if (!strstr($itemdir,'0rig')){ |
---|
565 | if(is_file($index_file)){ |
---|
566 | //echo "posee index"; |
---|
567 | if ($item!=""){ |
---|
568 | // Button for .jclic.zip |
---|
569 | list ($title2, $temp_array)=CreateButton($jclicdirectory, $item, "html",$locale, $activities_orig, $library, $temp_array); |
---|
570 | $activities[] = trim($title2); |
---|
571 | //echo "$title2"; |
---|
572 | //echo "222222222222222"; |
---|
573 | // Increasing number of elements |
---|
574 | $rscfound++; |
---|
575 | } |
---|
576 | } else { |
---|
577 | //lista directorio que no posee Index.html y lo creara |
---|
578 | //echo "Crear INDEX excepto 0rig"; |
---|
579 | //echo "es un directorio"; |
---|
580 | $item_library="$jclicdirectory/$item/$item.jclic"; |
---|
581 | $item_library2="$jclicdirectory/$item/library.jclic"; |
---|
582 | //var_dump($item_library); |
---|
583 | if (file_exists($item_library)){ |
---|
584 | $item_extended="$item/$item.jclic"; |
---|
585 | //echo "existe"; |
---|
586 | }else{ |
---|
587 | if (file_exists($item_library2)){ |
---|
588 | $item_extended="$item/library.jclic"; |
---|
589 | //echo "existe2"; |
---|
590 | }else{ |
---|
591 | $item_extended="$item/$item.jclic.zip"; |
---|
592 | //echo "existe3"; |
---|
593 | } |
---|
594 | } |
---|
595 | //echo "directorio"; |
---|
596 | list ($title2, $temp_array)=CreateButton($jclicdirectory, $item_extended, "library",$locale, $activities_orig, $library, $temp_array); |
---|
597 | $activities[] = trim($title2); |
---|
598 | // Increasing number of elements |
---|
599 | $rscfound++; |
---|
600 | } |
---|
601 | } |
---|
602 | //break; |
---|
603 | } |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | /*if ($resource!=""){ -------> MOVED UP |
---|
608 | // Button for .jclic.zip |
---|
609 | CreateButton($jclicdirectory, $resource, "jclic"); |
---|
610 | }*/ |
---|
611 | |
---|
612 | |
---|
613 | |
---|
614 | |
---|
615 | } |
---|
616 | //print_r($activities); |
---|
617 | //var_dump($temp_array); |
---|
618 | return array($rscfound,$activities,$temp_array); |
---|
619 | |
---|
620 | |
---|
621 | } |
---|
622 | // end function LoadResourcesFromDir |
---|
623 | |
---|
624 | |
---|
625 | ?> |
---|
626 | |
---|
627 | |
---|
628 | |
---|
629 | <!-- DETECTING APPS IN JCLIC FOLDER --> |
---|
630 | <div id="custom_links" class="links"> |
---|
631 | <?php |
---|
632 | |
---|
633 | //<!-- VARIABLES --> |
---|
634 | //json de actividades ya instaladas |
---|
635 | $file_json="/net/server-sync/share/jclic-aula/jclic_uploads/0rig_jclic/jclic_files.json"; |
---|
636 | $main_directory="/net/server-sync/share/jclic-aula"; |
---|
637 | $main_directory=$main_directory . "/"; |
---|
638 | $files=glob($main_directory . "*"); |
---|
639 | $numrsc=0; |
---|
640 | |
---|
641 | //comprobamos que existe el directorio para el json |
---|
642 | if (!is_dir(dirname($file_json))){ |
---|
643 | mkdir(dirname($file_json)); |
---|
644 | } |
---|
645 | |
---|
646 | if (file_exists($file_json)) { |
---|
647 | $str = file_get_contents($file_json); |
---|
648 | $temp_array = json_decode($str, true); |
---|
649 | }else{ |
---|
650 | $temp_array=array(); |
---|
651 | } |
---|
652 | |
---|
653 | //Leemos el vector de actividades, que posee ya los datos del titulo y su index creado |
---|
654 | $activities=array(); |
---|
655 | $library="jclic_uploads"; |
---|
656 | list ($numrsc, $activities, $temp_array)=LoadResourcesFromDir("jclic_uploads", $locale,$activities, $library,$temp_array); |
---|
657 | |
---|
658 | |
---|
659 | if($numrsc==0){ |
---|
660 | if ($locale=="valencia") echo "<div class='rscinfo' id='rscpersonal'>No hi ha recursos disponibles en esta secció</div>"; |
---|
661 | else echo "<div class='rscinfo' id='rscpersonal'>No hay recursos disponibles en esta sección</div>"; |
---|
662 | } |
---|
663 | |
---|
664 | ?> |
---|
665 | </div> <!-- custom_links --> |
---|
666 | |
---|
667 | |
---|
668 | <!-- Template for up jclic applications --> |
---|
669 | <?php |
---|
670 | if (isset($_SESSION['role'])&&($_SESSION['role']="admin")) { |
---|
671 | ?> |
---|
672 | <div id="files_upload" class="dropzone upload"> |
---|
673 | |
---|
674 | <div class="dz-message"> |
---|
675 | <?php |
---|
676 | if ($locale=="valencia") echo "Arrossega nous recursos fins aci"; |
---|
677 | else echo "Arrastra nuevos recursos hasta aquí"; |
---|
678 | ?> |
---|
679 | </div> |
---|
680 | |
---|
681 | </div> |
---|
682 | |
---|
683 | <?php |
---|
684 | } |
---|
685 | ?> |
---|
686 | <!-- END Template for up jclic applications --> |
---|
687 | |
---|
688 | |
---|
689 | </div> <!-- notice --> |
---|
690 | |
---|
691 | <!-- TEMPLATE FOR BODY JCLIC APPS PANEL --> |
---|
692 | |
---|
693 | |
---|
694 | |
---|
695 | <!-- Template for LliureX version --> |
---|
696 | |
---|
697 | <div id="foot"> |
---|
698 | <div class="vers">Running Lliurex <?php $vers = shell_exec('lliurex-version'); echo $vers; ?></div> |
---|
699 | </div> <!-- foot --> |
---|
700 | |
---|
701 | <!-- End for LliureX Version --> |
---|
702 | |
---|
703 | |
---|
704 | |
---|
705 | |
---|
706 | |
---|
707 | <!-- Template for Dropzone items --> |
---|
708 | < |
---|
709 | <div id="template" class="dz-preview dz-file-preview"> |
---|
710 | <div class="dz-details"> |
---|
711 | <div class="dz-filename"><span data-dz-name></span></div> |
---|
712 | |
---|
713 | <img data-dz-thumbnail /> |
---|
714 | </div> |
---|
715 | <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div> |
---|
716 | <div class="dz-success-mark"><span>✔</span></div> |
---|
717 | <div class="dz-error-mark"><span>✘</span></div> |
---|
718 | <div class="dz-error-message"><span data-dz-errormessage></span></div> |
---|
719 | </div> <!-- template --> |
---|
720 | |
---|
721 | <!-- End for Dropzone template --> |
---|
722 | |
---|
723 | </div> <!-- wrapper --> |
---|
724 | |
---|
725 | </body> |
---|
726 | </html> |
---|