getMessage()."\n"); } }; // End function validate //Clear session session_start(); $_SESSION = array(); session_destroy(); try{ $user = $_POST["user"]; $pass = $_POST["pass"]; } catch(Exception $e){ $user=false; } if($user){ if (validate($user, $pass)) include ("logout.php"); else include ("login.php"); } else include ("login.php"); ?>
settings->title; } zip_entry_close($zip_entry); } } zip_close($zip); } return $rsc_name; } // try catch(Exception $e) { echo 'Caught exception: '.$e->getMessage()."\n"; return $dir; } } function replaceAccents($str) { $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ"); $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"); return str_replace($search, $replace, $str); } function adding_resource_json($file_json, $library, $file_name, $id, $title){ $temp_array=$file_json; if ( isset($temp_array[$library])){ $temp_array[$library]+=array($file_name=>array('id'=>$id, 'title'=> $title)); }else { $temp_array+=array($library=>array($file_name=>array('id'=>$id, 'title'=> $title))); } //echo "se añadieron cosas"; return $temp_array; } function resource_not_in_json($file_json, $library, $file_name){ $finded=false; $temp_array = $file_json; if ( isset($temp_array[$library][$file_name])){ $identificador=$temp_array[$library][$file_name]['id']; $titulo=$temp_array[$library][$file_name]['title']; $finded=true; return array($file_json, $finded, $identificador, $titulo); }else{ $identificador=false; $titulo=false; } return array($file_json, $finded, $identificador, $titulo); } function CreateButton($dir, $resource, $class, $locale, $activities_orig, $library, $temp_array){ //echo "$resource\n"; //print_r ($activities_orig); //$file_json="/net/server-sync/share/jclic-aula/jclic_uploads/0rig_jclic/jclic_files.json"; $resource_finded=array(false,false); //var_dump($temp_array); if ($class=="html"){ //echo "HTML"; $resource_dir=$resource; $indexfile="$dir/$resource_dir/index.html"; $file_name="$dir/$resource_dir"; $added=false; //print("$indexfile"); $resource_finded=resource_not_in_json($temp_array, $library, $file_name); //var_dump($resource_finded); if ($resource_finded[1]){ $indent=$resource_finded[2]; $title=$resource_finded[3]; //echo "encontrado html"; }else{ $added=true; if(is_file($indexfile)){ $file=fopen($indexfile,r); while (!feof($file)){ $read = fgets($file,255); if (stristr($read,"")){ $title=strip_tags($read); } } fclose($file); // echo "falta este html"; }else{ $title=""; } //echo $title; $title=trim($title); if (in_array($indent,$activities_orig)){ return($indent); }else{ //print ($title); if ((strcasecmp( $title, 'sin nombre' ) == 0) || (strcasecmp( $rsc_name, 'sense nom' ) == 0)){ $title=$resource_dir; } $indent=$resource; if ($added) { $temp_array=adding_resource_json($temp_array, $library, $file_name, $indent, $title); } } } print("<div class='click_banner5' id=$indent onClick='document.location=\"$dir/$resource_dir\"'>\n"); print("<div class='rsc_name_new'><span>$title </span></div>"); print("</div>"); } else{ //echo "JCLIC"; //Debemos transformarlo en HTML5 con el python crado cuando se haga click sobre él /*if ( strcasecmp( $resource, 'menu' ) == 0){ $resource="menu_llx"; }*/ //var_dump($resource); $file_name="$dir/$resource"; $finded="False"; $resource_finded=resource_not_in_json($temp_array, $library, $file_name); //var_dump($resource_finded); //print($library); //var_dump($file_name); if ($resource_finded[1]){ $indent=$resource_finded[2]; $title=$resource_finded[3]; //echo "encontrado jclic"; }else{ $rsc_name=getNameFromZip($dir, $resource); $title=$rsc_name; $title=(string)$title; $title=replaceAccents($title); $path_parts = pathinfo($resource); $indent=$path_parts['filename']; $cool_extensions = Array('jclic','zip','inst'); if (in_array(pathinfo($indent, PATHINFO_EXTENSION), $cool_extensions)){ $indent = pathinfo($indent, PATHINFO_FILENAME); } if ( (strcasecmp( $title, 'Sin nombre' ) == 0) || (strcasecmp( $title, 'sense nom' ) == 0) || (strcasecmp( $title, '' ) == 0)){ $title=$indent; } $title = preg_replace("/[^a-zA-Z 0-9]+/", "", $title ); $temp_array=adding_resource_json($temp_array, $library, $file_name, $indent, $title); //var_dump($temp_array); } if (in_array($indent,$activities_orig)){ $finded="True"; } //var_dump($finded); if ($finded=="False"){ if (!$rsc_name){$rsc_name=$dir;} //print("<div class='click_banner' id='".str_replace(".", "_", $resource)."'' onClick='carga(\"$dir/$resource\")'>"); //print("<div class='click_banner' id='".str_replace(".", "_", $resource)."'' onClick='exec(\"python /var/www/jclic-aula/helper.py $dir/$resource\")'>"); $path=$dir/$resource; if ($locale=="valencia") { $alert_lang="Tens un Jclic antic, estem transforman-lo a HTML5"; }else{ $alert_lang="Tienes un jclic antiguo, estamos transformandolo a HTML5"; } print("<div class='click_banner' id='$indent' onClick='execute(\"$dir/$resource\", \"$alert_lang\", \"$indent\")'>"); print("<div class='rsc_name_new'>$title</div>"); print("</div>"); } } //var_dump($temp_array); return array($indent, $temp_array); } function LoadResourcesFromDir($jclicdirectory, $locale,$activities_orig, $library, $temp_array){ $rscfound=0; // Resources found //var_dump($jclicdirectory); $jclicconten = opendir($jclicdirectory); //print_r ($activities_orig); $activities=array(); $lista = array(); while($jclicfile = readdir($jclicconten)) { //print ("leyendo"); if (substr("$jclicfile", 0, 1) != ".") { $ext_path=pathinfo($jclicfile, PATHINFO_EXTENSION); if (strcasecmp( $ext_path, 'inst' ) !== 0){ $lista[] = $jclicfile; } } } //print_r($lista); if(count($lista)>0) { sort($lista); $title2=""; // Search .html $resource=""; foreach($lista as $item){ //var_dump($item); if(($item=="index.html") && (strstr($jclicdirectory,'jclic_upload'))){ $resource=$item; //echo "2222222222222"; break; } } //var_dump($resource); if (($resource!="") && (strstr($jclicdirectory,'jclic_upload'))){ // Found .html // Button for resource list ($title2, $temp_array)=CreateButton($jclicdirectory, $resource, "html", $locale,$activities_orig, $library, $temp_array); $activities[] = $title2; } else{ // Not found .html... search jclic.jclic foreach($lista as $item){ if($item=="jclic.jclic"){ $resource=$item; break; } } if($resource!=""){ // Found jclic.jclic //Button for jclic.jclic; list ($title2, $temp_array)=CreateButton($jclicdirectory, $resource, "jclic",$locale ,$activities_orig, $library, $temp_array); $activities[] = trim($title2); } else { foreach($lista as $item){ if((substr($item, -6 )==".jclic")){ $resource=$item; //var_dump($item); break; } } if($resource!=""){ // Found any .jclic //Button for *.jclic //list ($title2, $temp_array)=CreateButton($jclicdirectory, $resource, "jclic",$locale ,$activities_orig, $library, $temp_array); //$activities[] = trim($title2); } else { foreach($lista as $item){ //var_dump($item); if(strpos($item, '.jclic')){ //echo "FOUND JCLIC LISTS!!!!!"; //echo "$resource"; //$resource=substr($item, 0, -4); if ($item!=""){ // Button for .jclic.zip list ($title2, $temp_array)=CreateButton($jclicdirectory, $item, "jclic",$locale ,$activities_orig, $library, $temp_array); $activities[] = trim($title2); //echo "$title2"; //echo "1111111111111111"; // Increasing number of elements $rscfound++; } }else{ //if((substr($item, -4)==".zip")){ //var_dump($item); $itemdir="$jclicdirectory/$item"; //var_dump($itemdir); if(is_dir($itemdir) && (strstr($jclicdirectory,'jclic_upload'))){ $index_file="$jclicdirectory/$item/index.html"; if (!strstr($itemdir,'0rig')){ if(is_file($index_file)){ if ($item!=""){ // Button for .jclic.zip list ($title2, $temp_array)=CreateButton($jclicdirectory, $item, "html",$locale, $activities_orig, $library, $temp_array); $activities[] = trim($title2); //echo "$title2"; //echo "222222222222222"; // Increasing number of elements $rscfound++; } } else { //lista directorio que no posee Index.html y lo creara //echo "Crear INDEX excepto 0rig"; $item_library="/net/server-sync/share/jclic-aula/$jclicdirectory/$item/$item.jclic"; $item_library2="/net/server-sync/share/jclic-aula/$jclicdirectory/$item/library.jclic"; //var_dump($item_library); if (file_exists($item_library)){ $item_extended="$item/$item.jclic"; //echo "existe"; }else{ if (file_exists($item_library2)){ $item_extended="$item/library.jclic"; //echo "existe2"; }else{ $item_extended="$item/$item.jclic.zip"; //echo "existe3"; } } //var_dump($item_extended); list ($title2, $temp_array)=CreateButton($jclicdirectory, $item_extended, "jclic",$locale ,$activities_orig, $library, $temp_array); $activities[] = trim($title2); $rscfound++; } //break; } } } } /*if ($resource!=""){ -------> MOVED UP // Button for .jclic.zip CreateButton($jclicdirectory, $resource, "jclic"); }*/ } } } } //print_r($activities); //var_dump($temp_array); return array($rscfound,$activities,$temp_array); } function LoadResourcesFromMainDir($basePath, $locale){ // Loads any jclic resource from basepath //echo "aquiii " ; //echo $basePath; $numrsc=0; // loop through the array of files and print them all $rootdirectory = opendir($basePath); //Read directory while($jclicdirectory = readdir($rootdirectory)) { //Only list directories (or zips) //echo($jclicdirectory." is ".mime_content_type($jclicdirectory)."<br/>"); if (filetype($jclicdirectory) == "dir" || filetype($jclicdirectory) == "link") { //if (substr($jclicdirectory, -4)==".zip") echo "ES UN ZIP"; //Only enter non hide directory if (substr("$jclicdirectory", 0, 1) != "."&&$jclicdirectory!="jclic_uploads") { $rscs=LoadResourcesFromDir($jclicdirectory, $locale); $numrsc+=$rscs; } } // if filetype... } // While if($numrsc==0){ if ($locale=="valencia") echo "<div class='rscinfo'>No hi ha recursos disponibles en esta secció</div>"; else echo "<div class='rscinfo'>No hay recursos disponibles en esta sección</div>"; } } //obtener el locale $locale= get_locale(); // buscar title $titles = array(); $titles = preg_find("/\.title/", "./"); foreach ($titles as $title) { $txt=""; // comprobamos si no tiene extension "localizada" if ( ereg("\.title$", $title) ) { // lo mostraremos solamente si no existe version especifica para nuestro "locale" $testfile=$title . "." . $locale ; if ( ! is_file( $testfile ) ) $txt = file_get_contents($title); // en caso contrario, se muestra sólo si tiene extension para el "locale" actual } elseif ( ereg("\.title." . $locale, $title) ) { $txt = file_get_contents($title); } echo "<h1>$txt</h1>"; } //comprueba directorios y subdirectorios function expandDirectories($base_dir) { $directories = array(); $jclic_biblio_list = array(); foreach(scandir($base_dir) as $file) { if($file == '.' || $file == '..') continue; $dir = $base_dir.DIRECTORY_SEPARATOR.$file; if(is_dir($dir)) { $directories []= $dir; $aux=expandDirectories($dir); $directories = array_merge($directories, $aux[0]); if (!empty($aux[1])){ //print ("ADDING"); $jclic_biblio_list = array_merge($jclic_biblio_list, $aux[1]); } } else if (strpos($dir, 'jclic.zip')!== false){ //print ($dir); $jclic_biblio_list[] = $dir; } } //print_r($jclic_biblio_list); $num_files=count($jclic_biblio_list); return array ($dir, $jclic_biblio_list, $num_files); } /*function CreateButtonBiblio($dir, $resource, $class, $locale, $activities_orig){ }*/ ?> <div id="custom_links" class="links"> <?php //json de actividades ya instaladas $file_json="/net/server-sync/share/jclic-aula/jclic_uploads/0rig_jclic/jclic_files.json"; if (file_exists($file_json)) { $str = file_get_contents($file_json); $temp_array = json_decode($str, true); }else{ $temp_array=array(); } //vector de actividades ya mostradas anteriormente y que no se deben de mostrar de nuevo puesto que ya existen en HTML5 $activities=array(); $library="jclic_uploads"; list ($numrsc, $activities, $temp_array)=LoadResourcesFromDir("jclic_uploads", $locale,$activities, $library,$temp_array); //print_r ($activities); //BIBLIOTECAS ADICIONALES CON SUBDIRECTORIOS $main_directory="/net/server-sync/share/jclic-aula"; $main_directory=$main_directory . "/"; $files=glob($main_directory . "*"); //print_r ($files); foreach($files as $file){ if (is_dir($file)){ //print ($file); //introducir vector de librerias usadas y definidas por el administrador en pantalla login $libraries=['Murcia','elteumestre_JClic_Infantil_Primaria_13.7','ratoli']; foreach($libraries as $library){ if (strpos($file, $library)!== false){ //print ($file); $listado=expandDirectories($file); //print_r ($listado[1]); $list_activities=$listado[1]; $num_jclic=$listado[2]; //Sabiendo el numero de jclics lo escribo en el fichero $filename=basename($file); $filename = $main_directory . "jclic_uploads/0rig_jclic/num_jclics_" . $filename . ".txt"; $fh = fopen($filename, "a"); fwrite($fh, $num_jclic); fwrite($fh, "\n"); fclose($fh); // //print_r($list_activities); foreach($list_activities as $activitie){ $direct=dirname($activitie); //print $direct; //print ($library); list ($numrsc0, $activities0, $temp_array)=LoadResourcesFromDir($direct, $locale,$activities, $library,$temp_array); $numrsc=$numrsc+$numrsc0; } } } } } //BIBLIOTECAS_ADICIONALES_FIN $library="main_directory"; //echo "aqui"; $main_directory="/net/server-sync/share/jclic-aula"; list ($numrsc0, $activities0, $temp_array)=LoadResourcesFromDir($main_directory, $locale,$activities,$library,$temp_array); $numrsc=$numrsc+$numrsc0; $str = json_encode($temp_array); $file = fopen($file_json,'w'); fwrite($file, $str); fclose($file); /*if (json_decode($str) != null){ $file = fopen($file_json,'w'); fwrite($file, $str); fclose($file); }*/ if($numrsc==0){ if ($locale=="valencia") echo "<div class='rscinfo' id='rscpersonal'>No hi ha recursos disponibles en esta secció</div>"; else echo "<div class='rscinfo' id='rscpersonal'>No hay recursos disponibles en esta sección</div>"; } ?> </div> <?php if (isset($_SESSION['role'])&&($_SESSION['role']="admin")) { ?> <div class="dropzone upload" id="files_upload"> <div class="dz-message"> <?php if ($locale=="valencia") echo "Arrossega nous recursos fins aci"; else echo "Arrastra nuevos recursos hasta aquí"; ?> </div> </div> <?php } ?> </div> <div id="foot"> <div class="vers">Running Lliurex <?php $vers = shell_exec('lliurex-version'); echo $vers; ?></div> </div> </div> <!-- Template for Dropzone items --> <div id="template" class="dz-preview dz-file-preview"> <div class="dz-details"> <div class="dz-filename"><span data-dz-name></span></div> <img data-dz-thumbnail /> </div> <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div> <div class="dz-success-mark"><span>✔</span></div> <div class="dz-error-mark"><span>✘</span></div> <div class="dz-error-message"><span data-dz-errormessage></span></div> </div> <!-- End for template --> </body> </html>