Show
Ignore:
Timestamp:
04/10/08 20:40:08 (8 months ago)
Author:
anarcat
Message:

crude implementation of permission change in the file browser

Contributed by: Mathieu Lutfy
Sponsored by: Koumbit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/class/m_bro.php

    r2101 r2105  
    383383      } 
    384384    } 
     385    return true; 
     386  } 
     387 
     388  /* ----------------------------------------------------------------- */ 
     389  /** Change les droits d'acces aux fichier de $d du dossier $R en $p 
     390   * @param string $R dossier dans lequel se trouve les fichiers à renommer. 
     391   * @param array of string $old Ancien nom des fichiers 
     392   * @param array of string $new Nouveau nom des fichiers 
     393   * @return boolean TRUE si les fichiers ont été renommés, FALSE si une erreur s'est produite. 
     394   */ 
     395  function ChangePermissions($R,$d,$perm) { 
     396    global $err; 
     397    $absolute=$this->convertabsolute($R,0); 
     398    if (!$absolute) { 
     399      $err->raise("bro",1); 
     400      return false; 
     401    } 
     402    for ($i=0;$i<count($d);$i++) { 
     403      $d[$i]=ssla($d[$i]); // strip slashes if needed 
     404      if (!strpos($d[$i],"/")) {  // caractère / interdit dans le nom du fichier 
     405        // @rename($absolute."/".$old[$i],$absolute."/".$old[$i].$alea); 
     406        $m = fileperms($absolute."/". $d[$i]); 
     407 
     408        // pour l'instant on se limite a "write" pour owner, puisque c'est le seul 
     409        // cas interessant compte tenu de la conf de Apache pour AlternC.. 
     410        if ($perm[$i]['w']) { 
     411          $m = $m | 128; 
     412        } else { 
     413          $m = $m ^ 128; 
     414        } 
     415        $m = $m | ($perm[$i]['w'] ? 128 : 0); // 0600 
     416        chmod($absolute."/".$d[$i], $m); 
     417        echo "chmod " . sprintf('%o', $m) . " file, was " . sprintf('%o', fileperms($absolute."/". $d[$i])). " -- " . $perm[$i]['w']; 
     418      } 
     419    } 
     420 
    385421    return true; 
    386422  }