PHP Classes

File: functions.lib

Recommend this page to a friend!
  Classes of AUDUTEAU  >  admin_XML.lib  >  functions.lib  >  Download  
File: functions.lib
Role: ???
Content type: text/plain
Description: Functions
Class: admin_XML.lib
Author: By
Last change:
Date: 21 years ago
Size: 4,764 bytes
 

Contents

Class file image Download
<? /* *************************************************************************** Groupe de functions utiles à l'application tirées de la BAO Interligo à l'adresse http://www.interligo.org *************************************************************************** */ Function MyDelete( $sFile ) { Global $bWindows; # Suppression fichier UMask( ); if( ! $bWindows ) { # Commande unix de suppression if( is_dir( $sFile ) ) { exec( "rm -rf " . $sFile ); } else { exec( "rm -f " . $sFile ); } } else { # Commande windows de suppression if( is_dir( $sFile ) ) { exec( "deltree /Y " . str_replace( "/", "\\", $sFile ) ); exec( "del " . str_replace( "/", "\\", $sFile ) ); } else { exec( "del " . str_replace( "/", "\\", $sFile ) ); } } } Function MyRename( $srcFile, $dstFile ) { if( ! file_exists( $srcFile ) ) return; UMask(); Rename( $srcFile, $dstFile ); } Function MyCopy( $srcFile, $dstFile ) { UMask(); Copy( $srcFile, $dstFile ); } /* *************************************************************************** Groupe de functions utiles à l'application tirées de PhpMyExplorateur à l'adresse http://elegac.free.fr/index.php3 et légèrement transformé *************************************************************************** */ function ExploreRepertoire($chemin,$niveau,$max,$tabniveau,$NbRepTotal,$cheminrelatif,$source) { $NbRep = GetNbRepertoire($chemin); $repind = 0; $handle = @opendir($chemin); $file = @readdir($handle); // repertoire . $file = @readdir($handle); // repertoire .. $niveau++; while ($file = @readdir($handle)) { if(is_dir("$chemin/$file")) { $tabrep[$repind][0] = $file; $tabrep[$repind][1] = 0; // dir $repind++; } else { if (strtolower(GetExtension($file)) == "xml" ) { $tabrep[$repind][0] = $file; $tabrep[$repind][1] = 1; //file $repind++; } } } if(count($tabrep)) usort($tabrep,TriRep); for ( $indice=0; $indice<$repind; $indice++ ) { $NbRepTotal++; print "<table cellpadding=\"0\" border=\"0\" cellspacing=\"0\">"; print "<TR>"; for ( $i=0; $i<$niveau; $i++ ) { if( ($tabniveau[$i]) == 0) { print "<TD WIDTH=\"22\"><IMG SRC=\"./img/blanc.gif\" WIDTH=\"22\" HEIGHT=\"26\"></TD>"; } else { print "<TD bgcolor=\"" . C_bgAction . "\" WIDTH=\"22\"><IMG SRC=\"./img/barre.gif\" WIDTH=\"22\" HEIGHT=\"26\"></TD>"; } if ( ($indice+1) == $NbRep) { print "<TD bgcolor=\"" . C_bgAction . "\" WIDTH=\"22\"><IMG SRC=\"./img/feuille.gif\" WIDTH=\"22\" HEIGHT=\"26\"></TD>"; } else { print "<TD bgcolor=\"" . C_bgAction . "\" WIDTH=\"22\"><IMG SRC=\"./img/croix.gif\" WIDTH=\"22\" HEIGHT=\"26\"></TD>"; } $NbCol = $max - $niveau; } If ( $tabrep[$indice][1] == 0) { print "<TD bgcolor=\"" . C_bgAction . "\" WIDTH=\"22\" VALIGN=\"top\"><IMG SRC=\"./img/dir.gif\"></TD>"; } print "<TD bgcolor=\"" . C_bgAction . "\" VALIGN=\"bottom\""; if( $NbCol > 1 ) { print " COLSPAN=\"" . $NbCol . "\""; } print ">&nbsp;" ; If ( $tabrep[$indice][1] == 0) { print "<b>" . $tabrep[$indice][0] . "</b>"; } else { print "<a href=\"" . C_ADMIN_APP . "?FileName=" . str_replace($cheminrelatif,"",$chemin) . "/" . $tabrep[$indice][0] . "\">" . $tabrep[$indice][0] . "</a>"; } print "</TD></TR>"; print "</TABLE>"; if($indice+1 < $NbRep) { $tabniveau[$niveau] = 1; } else { $tabniveau[$niveau] = 0; } $NbRepTotal = ExploreRepertoire($chemin. "/" . $tabrep[$indice][0],$niveau,$max,$tabniveau,$NbRepTotal,$cheminrelatif,$source); } return $NbRepTotal; } function GetNbRepertoire($chemin) { $Nb = 0; $handle = @opendir($chemin); $file = @readdir($handle); // repertoire . $file = @readdir($handle); // repertoire .. while ($file = @readdir($handle)) if(is_dir("$chemin/$file")) $Nb++; @closedir($handle); return $Nb; } function GetExtension($fichier) { $pos = strrpos($fichier,"."); $extension = substr($fichier,$pos+1,strlen($fichier)-$pos); return $extension; } function GetNiveauMax($chemin,$niveau,$max) { $niveau++; if($max < $niveau) $max = $niveau; $handle = @opendir($chemin); $file = @readdir($handle); // repertoire . $file = @readdir($handle); // repertoire .. while ($file = @readdir($handle)) if(is_dir("$chemin/$file")) $max = GetNiveauMax("$chemin/$file",$niveau,$max); @closedir($handle); return $max; } function TriRep($rep1,$rep2) { $val = strcmp($rep1[0],$rep2[0]) + strcmp($rep1[1],$rep2[1]); return $val; } ?>