METRO-TASK: bro dom & piwik raise() replacement + bro new header
This commit is contained in:
		
							parent
							
								
									a8b05e045c
								
							
						
					
					
						commit
						2d5a76b5f8
					
				|  | @ -1,83 +1,79 @@ | |||
| <?php | ||||
| /* | ||||
|  $Id: m_bro.php,v 1.15 2005/12/18 09:51:32 benjamin Exp $ | ||||
|  ---------------------------------------------------------------------- | ||||
|  LICENSE | ||||
|   ---------------------------------------------------------------------- | ||||
|   AlternC - Web Hosting System | ||||
|   Copyright (C) 2000-2012 by the AlternC Development Team. | ||||
|   https://alternc.org/ | ||||
|   ---------------------------------------------------------------------- | ||||
|   LICENSE | ||||
| 
 | ||||
|  This program is free software; you can redistribute it and/or | ||||
|  modify it under the terms of the GNU General Public License (GPL) | ||||
|  as published by the Free Software Foundation; either version 2 | ||||
|  of the License, or (at your option) any later version. | ||||
|   This program is free software; you can redistribute it and/or | ||||
|   modify it under the terms of the GNU General Public License (GPL) | ||||
|   as published by the Free Software Foundation; either version 2 | ||||
|   of the License, or (at your option) any later version. | ||||
| 
 | ||||
|  This program is distributed in the hope that it will be useful, | ||||
|  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  GNU General Public License for more details. | ||||
|   This program is distributed in the hope that it will be useful, | ||||
|   but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|   GNU General Public License for more details. | ||||
| 
 | ||||
|  To read the license please visit http://www.gnu.org/copyleft/gpl.html | ||||
|  ---------------------------------------------------------------------- | ||||
|  Original Author of file: | ||||
|  Purpose of file: | ||||
|  ---------------------------------------------------------------------- | ||||
|   To read the license please visit http://www.gnu.org/copyleft/gpl.html | ||||
|   ---------------------------------------------------------------------- | ||||
|   Purpose of file: file browser class. | ||||
|   ---------------------------------------------------------------------- | ||||
| */ | ||||
| 
 | ||||
| /* Add the mime type list */ | ||||
| @include("mime.php"); | ||||
| 
 | ||||
| /** | ||||
| * Classe de gestion du navigateur de fichiers en ligne. | ||||
| * | ||||
| * Cette classe permet de grer les fichiers, dossiers ... | ||||
| * d'un membre hberg.<br /> | ||||
| * Copyleft {@link http://alternc.net/ AlternC Team} | ||||
| * | ||||
| * @copyright    AlternC-Team 2002-11-01 http://alternc.net/ | ||||
| * | ||||
| */ | ||||
| 
 | ||||
| 
 | ||||
|  * This class manage the file browser of AlternC | ||||
|  * allow the file and directory management in the user account web folder | ||||
|  */ | ||||
| class m_bro { | ||||
| 
 | ||||
|   /** Mode d'affichage des fichiers en colonne */ | ||||
|   var $l_mode=array(0=>"1 column, detailed",1=>"2 columns, short",2=>"3 columns, short"); | ||||
|   /** How we draw the file in column */ | ||||
|   var $l_mode; | ||||
| 
 | ||||
|   /** Mode de tlchargement d'un dossier compress (zip,bz,tar,..) */ | ||||
|   var $l_tgz=array(0=>"tgz (Linux)",1=>"tar.bz2 (Linux)",2=>"zip (Windows/Dos)",3=>"tar.Z (Unix)"); | ||||
|   /** download mode of a compressed folder */ | ||||
|   var $l_tgz; | ||||
| 
 | ||||
|   /** Faut-il afficher ou non les icones ? */ | ||||
|   var $l_icons=array(0=>"No",1=>"Yes"); | ||||
|   /** Shall we show icons or just names? */ | ||||
|   var $l_icons; | ||||
| 
 | ||||
|   /** Que fait-on aprs la cration d'un fichier ? */ | ||||
|   var $l_createfile=array(0=>"Go back to the file manager",1=>"Edit the newly created file"); | ||||
|   /** What do we do after creating a file? */ | ||||
|   var $l_createfile; | ||||
| 
 | ||||
|   /** Cache des descriptions de fichier extraits de la base | ||||
|    * @access private | ||||
|   /** internal cache | ||||
|    */ | ||||
|   var $mime_desc=array(); | ||||
|   private var $mime_desc=array(); | ||||
| 
 | ||||
|   /** Cache des icones extraits de la base | ||||
|    * @access private | ||||
|   /** internal cache | ||||
|    */ | ||||
|   var $mime_icon=array(); | ||||
|   private var $mime_icon=array(); | ||||
| 
 | ||||
|   /** Cache des types mimes extraits de la base | ||||
|    * @access private | ||||
|   /** internal cache | ||||
|    */ | ||||
|   var $mime_type=array(); | ||||
|   private var $mime_type=array(); | ||||
| 
 | ||||
|   /** Choix des polices d'dition de fichiers */ | ||||
|   /** Font choice in the editor */ | ||||
|   var $l_editor_font=array("Arial, Helvetica, Sans-serif","Times, Bookman, Serif","Courier New, Courier, Fixed"); | ||||
| 
 | ||||
|   /** Choix des tailles de police d'dition de fichiers */ | ||||
|   /** font size in the editor */ | ||||
|   var $l_editor_size=array("18px","14px","12px","10px","8px","0.8em","0.9em","1em","1.1em","1.2em"); | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Constructeur */ | ||||
|   /** Constructor */ | ||||
|   function m_bro() { | ||||
|     $this->l_mode=array( 0=>_("1 column, detailed"), 1=>_("2 columns, short"), 2=>_("3 columns, short") ); | ||||
|     $this->l_tgz=array( 0=>_("tgz (Linux)"), 1=>_("tar.bz2 (Linux)"), 2=>_("zip (Windows/Dos)"), 3=>_("tar.Z (Unix)") ); | ||||
|     $this->l_icons=array( 0=>_("No"), 1=>_("Yes") ); | ||||
|     $this->l_createfile=array( 0=>_("Go back to the file manager"), 1=>_("Edit the newly created file") ); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Vrifie un dossier relatif au dossier de l'utilisateur courant | ||||
|   /** Verifie un dossier relatif au dossier de l'utilisateur courant | ||||
|    * | ||||
|    * @param string $dir Dossier (absolu que l'on souhaite vrifier | ||||
|    * @return string Retourne le nom du dossier vrifi, relatif au | ||||
|  | @ -115,6 +111,8 @@ class m_bro { | |||
|       return $dir; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne le chemin complet vers la racine du repertoire de l'utilisateur. | ||||
|    *  Returns the complete path to the root of the user's directory. | ||||
|    * | ||||
|  | @ -125,6 +123,8 @@ class m_bro { | |||
|     return getuserpath(); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne le chemin complet vers la racine du repertoire de l'utilisateur. | ||||
|    *  Returns the complete path to the root of the user's directory. | ||||
|    * | ||||
|  | @ -146,6 +146,7 @@ class m_bro { | |||
|     return $this->get_user_root($member['login']); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne un tableau contenant la liste des fichiers du dossier courant | ||||
|    * Ce tableau contient tous les paramtres des fichiers du dossier courant | ||||
|  | @ -178,6 +179,7 @@ class m_bro { | |||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne un tableau contenant les prfrences de l'utilisateur courant | ||||
|    * Ce tableau aqssociatif contient les valeurs des champs de la table "browser" | ||||
|  | @ -195,6 +197,7 @@ class m_bro { | |||
|     return $db->Record; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Modifie les prfrences de l'utilisateur courant. | ||||
|    * | ||||
|  | @ -224,6 +227,7 @@ class m_bro { | |||
|     return true; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne le nom du fichier icone associ au fichier donc le nom est $file | ||||
|    * <b>Note</b>: Les fichiers icones sont mis en cache sur la page courante. | ||||
|  | @ -242,12 +246,13 @@ class m_bro { | |||
|       $ext=$t[count($t)-1]; | ||||
|     // Now seek the extension
 | ||||
|     if (!$bro_icon[$ext]) { | ||||
| 	return "file.png"; | ||||
|       return "file.png"; | ||||
|     } else { | ||||
| 	return $bro_icon[$ext].".png"; | ||||
|       return $bro_icon[$ext].".png"; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne le type mime associ au fichier donc le nom est $file | ||||
|    * <b>Note</b>: Les types mimes sont mis en cache sur la page courante. | ||||
|  | @ -267,12 +272,13 @@ class m_bro { | |||
|       $ext=$t[count($t)-1]; | ||||
|     // Now seek the extension
 | ||||
|     if (!$bro_type[$ext]) { | ||||
| 	    return "File"; | ||||
|       return "File"; | ||||
|     } else { | ||||
| 	    return $bro_type[$ext]; | ||||
|       return $bro_type[$ext]; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Retourne la taille du fichier $file | ||||
|    * si $file est un dossier, retourne la taille de ce dossier et de tous | ||||
|  | @ -306,7 +312,7 @@ class m_bro { | |||
|       while (false !== ($file = readdir($handle))) { | ||||
|         $nextpath = $dir . '/' . $file; | ||||
| 
 | ||||
| 	      if ($file != '.' && $file != '..' && !is_link($nextpath)) { | ||||
| 	if ($file != '.' && $file != '..' && !is_link($nextpath)) { | ||||
|           if (is_dir($nextpath)) { | ||||
|             $totalsize += $this->dirsize($nextpath); | ||||
|           } elseif (is_file ($nextpath)) { | ||||
|  | @ -319,6 +325,7 @@ class m_bro { | |||
|     return $totalsize; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Cre le dossier $file dans le dossier (parent) $dir | ||||
|    * @param string $dir dossier dans lequel on veut crer un sous-dossier | ||||
|  | @ -331,15 +338,15 @@ class m_bro { | |||
|     $absolute=$this->convertabsolute($dir."/".$file,0); | ||||
|     #echo "$absolute";
 | ||||
|     if ($absolute && (!file_exists($absolute))) { | ||||
|         if (!mkdir($absolute,00777)) { | ||||
|             $err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); | ||||
| 	        return false; | ||||
|         } | ||||
|         $db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';"); | ||||
|         return true; | ||||
|       if (!mkdir($absolute,00777)) { | ||||
| 	$err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); | ||||
| 	return false; | ||||
|       } | ||||
|       $db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';"); | ||||
|       return true; | ||||
|     } else { | ||||
|         $err->raise("bro",_("File or folder name is incorrect")); | ||||
|         return false; | ||||
|       $err->raise("bro",_("File or folder name is incorrect")); | ||||
|       return false; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | @ -412,7 +419,7 @@ class m_bro { | |||
|       $old[$i]=ssla($old[$i]); // strip slashes if needed
 | ||||
|       $new[$i]=ssla($new[$i]); | ||||
|       if (!strpos($old[$i],"/") && !strpos($new[$i],"/")) {  // caractre / interdit dans old ET dans new...
 | ||||
| 	      @rename($absolute."/".$old[$i],$absolute."/".$old[$i].$alea); | ||||
| 	@rename($absolute."/".$old[$i],$absolute."/".$old[$i].$alea); | ||||
|       } | ||||
|     } | ||||
|     for ($i=0;$i<count($old);$i++) { | ||||
|  | @ -463,6 +470,7 @@ class m_bro { | |||
|     return true; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Change les droits d'acces aux fichier de $d du dossier $R en $p | ||||
|    * @param string $R dossier dans lequel se trouve les fichiers  renommer. | ||||
|  | @ -488,7 +496,7 @@ class m_bro { | |||
|         if ($perm[$i]['w']) { | ||||
|           $m = $m | 128; | ||||
|         } else { | ||||
|                 $m = $m ^ 128; | ||||
| 	  $m = $m ^ 128; | ||||
|         } | ||||
|         $m = $m | ($perm[$i]['w'] ? 128 : 0); // 0600
 | ||||
|         chmod($absolute."/".$d[$i], $m); | ||||
|  | @ -501,6 +509,7 @@ class m_bro { | |||
|     return true; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Recoit un champ file upload (Global) et le stocke dans le dossier $R | ||||
|    * Le champ file-upload originel doit s'appeler "userfile" et doit | ||||
|  | @ -521,8 +530,8 @@ class m_bro { | |||
|           @touch($absolute."/".$_FILES['userfile']['name']); | ||||
|         } | ||||
|         if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) { | ||||
| 			exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -f ".$absolute."/".$_FILES['userfile']['name']); | ||||
| 			return $absolute."/".$_FILES['userfile']['name']; | ||||
| 	  exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -f ".$absolute."/".$_FILES['userfile']['name']); | ||||
| 	  return $absolute."/".$_FILES['userfile']['name']; | ||||
| 	} else { | ||||
| 	  $err->raise("bro",("Cannot create the requested file. Please check permissions.")); | ||||
| 	  return false; | ||||
|  | @ -535,6 +544,8 @@ class m_bro { | |||
|     return $absolute."/".$_FILES['userfile']['name']; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** | ||||
|    * Extract an archive by using GNU and non-GNU tools | ||||
|    * @param string $file is the full or relative path to the archive | ||||
|  | @ -542,8 +553,7 @@ class m_bro { | |||
|    * same directory as the archive by default | ||||
|    * @return boolean != 0 on error | ||||
|    */ | ||||
|   function ExtractFile($file, $dest=null) | ||||
|   { | ||||
|   function ExtractFile($file, $dest=null) { | ||||
|     global $err,$cuid,$mem,$L_ALTERNC_LOC; | ||||
|     $file = $this->convertabsolute($file,0); | ||||
|     if (is_null($dest)) { | ||||
|  | @ -574,17 +584,16 @@ class m_bro { | |||
|       exec($cmd, $void, $ret); | ||||
|     } | ||||
|     if ($ret) { | ||||
|       $err->raise("bro","could not find a way to extract file %s, unsupported format?", $file); | ||||
|       $err->raise("bro",_("I can't find a way to extract the file %s, is it an unsupported compressed format?"), $file); | ||||
|     } | ||||
| 	 | ||||
| 	//fix the perms of the extracted archive
 | ||||
| 	exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -d ".$dest_to_fix); | ||||
|     // fix the perms of the extracted archive TODO: does it work???
 | ||||
|     exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -d ".$dest_to_fix); | ||||
|     return $ret; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /** | ||||
|    * Copy many files from point A to point B | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Copy many files from point A to point B | ||||
|    */ | ||||
|   function CopyFile($d,$old,$new) { | ||||
|     global $err; | ||||
|  | @ -611,6 +620,8 @@ class m_bro { | |||
|     return true; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** | ||||
|    * Copy a source to a destination by either copying recursively a | ||||
|    * directory or by downloading a file with a URL (only http:// is | ||||
|  | @ -621,8 +632,7 @@ class m_bro { | |||
|    * | ||||
|    * Note that we assume that the inputs have been convertabsolute()'d | ||||
|    */ | ||||
|   function CopyOneFile($src, $dest) | ||||
|   { | ||||
|   function CopyOneFile($src, $dest)  { | ||||
|     global $err; | ||||
|     $src = escapeshellarg($src); | ||||
|     $dest = escapeshellarg($dest); | ||||
|  | @ -631,10 +641,10 @@ class m_bro { | |||
|       $err->raise("bro","Errors happened while copying the source to destination. cp return value: %d", $ret); | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|     return true; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Affiche le chemin et les liens de la racine au dossier $path | ||||
|    * Affiche autant de liens HTML (anchor) que le chemin $path contient de | ||||
|  | @ -652,13 +662,14 @@ class m_bro { | |||
|     $R=''; | ||||
|     for($i=0;$i<count($a);$i++) { | ||||
|       if ($a[$i]) { | ||||
| 	      $R.=$a[$i]."/"; | ||||
| 	      $c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a> / "; | ||||
| 	$R.=$a[$i]."/"; | ||||
| 	$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a> / "; | ||||
|       } | ||||
|     } | ||||
|     return $c; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Affiche le contenu d'un fichier pour un champ VALUE de textarea | ||||
|    * Affiche le contenu du fichier $file dans le dossier $R. Le contenu | ||||
|  | @ -675,7 +686,7 @@ class m_bro { | |||
|     if (!strpos($file,"/")) { | ||||
|       $absolute.="/".$file; | ||||
|       if (file_exists($absolute)) { | ||||
| 	    $std=str_replace("<","<",str_replace("&","&",file_get_contents($absolute))); | ||||
| 	$std=str_replace("<","<",str_replace("&","&",file_get_contents($absolute))); | ||||
|       } else { | ||||
| 	$err->raise("bro",_("Cannot read the requested file. Please check permissions.")); | ||||
| 	return false; | ||||
|  | @ -687,11 +698,13 @@ class m_bro { | |||
|     return $std; | ||||
|   } | ||||
| 
 | ||||
|   /** Cache des urls pour VIEW | ||||
|    * @access private | ||||
|    */ | ||||
|   var $cacheurl=array(); | ||||
| 
 | ||||
|   /** Internal cache for viewurl | ||||
|    */ | ||||
|   private var $cacheurl=array(); | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   // Return a browsing url if available.
 | ||||
|   // Maintain a url cache (positive AND negative(-) cache)
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|  | @ -723,7 +736,7 @@ class m_bro { | |||
|         if (!$beg && $tofind) { | ||||
|           $tofind=false; | ||||
|           $this->cacheurl["d".$dir]="-"; | ||||
|               // We did not find it ;(
 | ||||
| 	  // We did not find it ;(
 | ||||
|         } | ||||
|         if (($tt=strrpos($beg,"/"))!==false) { | ||||
|           $end=substr($beg,$tt).$end; // = /topdir$end so $end starts AND ends with /
 | ||||
|  | @ -741,6 +754,10 @@ class m_bro { | |||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** | ||||
|    */ | ||||
|   function can_edit($dir,$name) { | ||||
|     global $mem,$err; | ||||
|     $absolute="$dir/$name"; | ||||
|  | @ -758,8 +775,9 @@ class m_bro { | |||
|     return false; | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * Return a HTML snippet representing an extraction function only if the mimetype of $name is supported | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Return a HTML snippet representing an extraction function only if the mimetype of $name is supported | ||||
|    */ | ||||
|   function is_extractable($dir,$name) { | ||||
|     if ($parts = explode(".", $name)) { | ||||
|  | @ -768,8 +786,8 @@ class m_bro { | |||
|       case "gz": | ||||
|       case "bz": | ||||
|       case "bz2": | ||||
| 	    $ext = array_pop($parts) . $ext; | ||||
| 	    /* FALLTHROUGH */ | ||||
| 	$ext = array_pop($parts) . $ext; | ||||
|       /* FALLTHROUGH */ | ||||
|       case "tar.gz": | ||||
|       case "tar.bz": | ||||
|       case "tar.bz2": | ||||
|  | @ -785,6 +803,10 @@ class m_bro { | |||
|     return false; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** | ||||
|    */ | ||||
|   function download_link($dir,$file){ | ||||
|     global $err; | ||||
|     $err->log("bro","download_link"); | ||||
|  | @ -829,14 +851,14 @@ class m_bro { | |||
|     if (!strpos($file,"/")) { | ||||
|       $absolute.="/".$file; | ||||
|       if (file_exists($absolute)) { | ||||
| 	      $f=@fopen($absolute,"wb"); | ||||
| 	$f=@fopen($absolute,"wb"); | ||||
|        	if ($f) { | ||||
| 	        fputs($f,$texte,strlen($texte)); | ||||
| 	        fclose($f); | ||||
| 	  fputs($f,$texte,strlen($texte)); | ||||
| 	  fclose($f); | ||||
| 	} else { | ||||
| 	  $err->raise("bro",("Cannot edit the requested file. Please check permissions.")); | ||||
| 	  return false; | ||||
| 	      } | ||||
| 	} | ||||
|       } | ||||
|     } else { | ||||
|       $err->raise("bro",_("File or folder name is incorrect")); | ||||
|  | @ -933,9 +955,9 @@ class m_bro { | |||
|     if (is_dir($file)) { | ||||
|       $handle = opendir($file); | ||||
|       while($filename = readdir($handle)) { | ||||
| 	      if ($filename != "." && $filename != "..") { | ||||
| 	        $this->_delete($file."/".$filename); | ||||
| 	      } | ||||
| 	if ($filename != "." && $filename != "..") { | ||||
| 	  $this->_delete($file."/".$filename); | ||||
| 	} | ||||
|       } | ||||
|       closedir($handle); | ||||
|       rmdir($file); | ||||
|  | @ -943,13 +965,13 @@ class m_bro { | |||
|       unlink($file); | ||||
|     } | ||||
|   } | ||||
| /*----------------------------------------------------------*/ | ||||
| /** Function d'exportation de configuration appelé par la classe m_export via un hooks | ||||
| *Produit en sorti un tableau formatté ( pour le moment) en HTML | ||||
| * | ||||
| */ | ||||
| 
 | ||||
| function alternc_export_conf() { | ||||
| 
 | ||||
|   /*----------------------------------------------------------*/ | ||||
|   /** Function d'exportation de configuration appelé par la classe m_export via un hooks | ||||
|    *Produit en sorti un tableau formatté ( pour le moment) en HTML | ||||
|    */ | ||||
|   function alternc_export_conf() { | ||||
|     global $db,$err; | ||||
|     $err->log("bro","export_conf"); | ||||
|     $str="<table border=\"1\"><caption> Browser </caption>\n"; | ||||
|  | @ -958,41 +980,40 @@ function alternc_export_conf() { | |||
|      | ||||
|     $i=1; | ||||
|     foreach ($pref as $k=>$v) { | ||||
|          if (($i % 2)==0){ | ||||
|             $str.="   <$k>$v</$k>\n";  | ||||
|        } | ||||
|         $i++; | ||||
|       if (($i % 2)==0){ | ||||
| 	$str.="   <$k>$v</$k>\n";  | ||||
|       } | ||||
|       $i++; | ||||
|     } | ||||
|     $str.=" </browser>\n"; | ||||
|      | ||||
|     return $str; | ||||
|   } | ||||
| 
 | ||||
| /*----------------------------------------------------------*/ | ||||
| /** Function d'exportation des données appelé par la classe m_export via un hooks | ||||
| *@param : le chemin destination du tarball produit. | ||||
| */ | ||||
| function alternc_export_data($dir){ | ||||
| 
 | ||||
|   /*----------------------------------------------------------*/ | ||||
|   /** Function d'exportation des données appelé par la classe m_export via un hooks | ||||
|    *@param : le chemin destination du tarball produit. | ||||
|    */ | ||||
|   function alternc_export_data($dir){ | ||||
|     global $mem,$L_ALTERNC_LOC,$err; | ||||
|     $err->log("bro","export_data"); | ||||
|     $dir.="html/"; | ||||
|     if(!is_dir($dir)){  | ||||
|         if(!mkdir($dir)) | ||||
|             $err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); | ||||
|       if(!mkdir($dir)) | ||||
| 	$err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); | ||||
|     } | ||||
|     $timestamp=date("H:i:s"); | ||||
| 
 | ||||
|    if(exec("/bin/tar cvf -  ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){ | ||||
|         $err->log("bro","export_data_succes"); | ||||
|     if(exec("/bin/tar cvf -  ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){ | ||||
|       $err->log("bro","export_data_succes"); | ||||
|     }else{ | ||||
|         $err->log("bro","export_data_failed"); | ||||
|       $err->log("bro","export_data_failed"); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| } /* Class Browser */ | ||||
| 
 | ||||
| } /* Classe BROUTEUR */ | ||||
| 
 | ||||
| ?>
 | ||||
|  |  | |||
|  | @ -693,17 +693,17 @@ class m_dom { | |||
|     $err->log("dom","get_sub_domain_all",$dom."/".$sub); | ||||
|     // Locked ?
 | ||||
|     if (!$this->islocked) { | ||||
|       $err->raise("dom",3); | ||||
|       $err->raise("dom",_("--- Program error --- No lock on the domains!")); | ||||
|       return false; | ||||
|     } | ||||
|     $t=checkfqdn($dom); | ||||
|     if ($t) { | ||||
|       $err->raise("dom",3+$t); | ||||
|       $err->raise("dom",_("The domain name is syntaxically incorrect")); | ||||
|       return false; | ||||
|     } | ||||
|     $db->query("select sd.*, dt.description as type_desc, dt.only_dns from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and sub='$sub' and ( length('$type')=0 or type='$type') and (length('$value')=0 or '$value'=valeur) and upper(dt.name)=upper(sd.type);"); | ||||
|     if ($db->num_rows()==0) { | ||||
|       $err->raise("dom",14); | ||||
|       $err->raise("dom",_("The sub-domain does not exist.")); | ||||
|       return false; | ||||
|     } | ||||
|     $db->next_record(); | ||||
|  | @ -735,7 +735,7 @@ class m_dom { | |||
|           $value="/".$value; | ||||
|         } | ||||
|         if (!checkuserpath($value)) { | ||||
|           $err->raise("dom",21); | ||||
|           $err->raise("dom",_("The folder you entered is incorrect or does not exist.")); | ||||
|         return false; | ||||
|         } | ||||
|         return true; | ||||
|  | @ -811,7 +811,7 @@ class m_dom { | |||
|     $err->log("dom","set_sub_domain",$dom."/".$sub."/".$type."/".$dest); | ||||
|     // Locked ?
 | ||||
|     if (!$this->islocked) { | ||||
|       $err->raise("dom",3); | ||||
|       $err->raise("dom",_("--- Program error --- No lock on the domains!")); | ||||
|       return false; | ||||
|     } | ||||
|     $dest=trim($dest); | ||||
|  | @ -823,25 +823,23 @@ class m_dom { | |||
|     $fqdn=checkfqdn($sub); | ||||
|     // Special cases : * (all subdomains at once) and '' empty subdomain are allowed.
 | ||||
|     if (($sub != '*' && $sub!='') && !($fqdn==0 || $fqdn==4)) { | ||||
|       $err->raise("dom",24); | ||||
|       $err->raise("dom",_("There is some forbidden characters in the sub domain (only A-Z 0-9 and - are allowed).")); | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|     if (! $this->check_type_value($type,$dest)) { | ||||
|       // Invalid domain type selected, please check.
 | ||||
|       $err->raise("dom",27); | ||||
|       $err->raise("dom",_("Invalid domain type selected, please check.")); | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|     // On a épuré $dir des problèmes eventuels ... On est en DESSOUS du dossier de l'utilisateur.
 | ||||
|     if ($t=checkfqdn($dom)) { | ||||
|       $err->raise("dom",3+$t); | ||||
|       $err->raise("dom",_("The domain name is syntaxically incorrect")); | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|     if (! $this->can_create_subdomain($dom,$sub,$type,$type_old,$value_old)) { | ||||
|       // The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility
 | ||||
|       $err->raise("dom", 28); | ||||
|     if (! $this->can_create_subdomain($dom,$sub,$type,$type_old,$value_old)) {  | ||||
|       $err->raise("dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility")); | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|  | @ -876,20 +874,18 @@ class m_dom { | |||
|     $err->log("dom","del_sub_domain",$dom."/".$sub); | ||||
|     // Locked ?
 | ||||
|     if (!$this->islocked) { | ||||
|       $err->raise("dom",3); | ||||
|       $err->raise("dom",_("--- Program error --- No lock on the domains!")); | ||||
|       return false; | ||||
|     } | ||||
|     $t=checkfqdn($dom); | ||||
|     if ($t) { | ||||
|       $err->raise("dom",3+$t); | ||||
|       $err->raise("dom",("The domain name is syntaxically incorrect")); | ||||
|       return false; | ||||
|     } | ||||
|     if (!$r=$this->get_sub_domain_all($dom,$sub,$type)) { | ||||
|       // Le sous-domaine n'existe pas, erreur
 | ||||
|       $err->raise("dom",14); | ||||
|       $err->raise("dom",_("The sub-domain does not exist.")); | ||||
|       return false; | ||||
|     } else { | ||||
|       // OK, on valide :
 | ||||
|       $db->query("update sub_domaines set web_action='DELETE' where domaine='$dom' and sub='$sub' and type='$type' and ( length('$value')=0 or valeur='$value') "); | ||||
|       $db->query("update domaines set dns_action='UPDATE' where domaine='$dom';"); | ||||
|     } | ||||
|  | @ -915,39 +911,39 @@ class m_dom { | |||
|     $err->log("dom","edit_domain",$dom."/".$dns."/".$gesmx); | ||||
|     // Locked ?
 | ||||
|     if (!$this->islocked && !$force) { | ||||
|       $err->raise("dom",3); | ||||
|       $err->raise("dom",_("--- Program error --- No lock on the domains!")); | ||||
|       return false; | ||||
|     } | ||||
|     if ($dns == 1 && !$force) { | ||||
|       $this->dns=$this->whois($dom); | ||||
|       $v=checkhostallow($dom,$this->dns); | ||||
|       if ($v==-1) { | ||||
|         $err->raise("dom",7);   // TLD interdit
 | ||||
|         $err->raise("dom",_("The last member of the domain name is incorrect or cannot be hosted in that server.")); | ||||
|         return false; | ||||
|       } | ||||
|       if ($dns && $v==-2) { | ||||
|         $err->raise("dom",12);  // Domaine non trouvé dans le whois
 | ||||
|         $err->raise("dom",_("The domain cannot be found in the whois database.")); | ||||
|         return false; | ||||
|       } | ||||
|       if ($dns && $v==-3) { | ||||
|         $err->raise("dom",23);  // Domaine non trouvé dans le whois
 | ||||
|         $err->raise("dom",_("The DNS of this domain do not match the server's DNS. Please change your domain's DNS (you may need to wait 1 day) before you install it again."));  | ||||
|         return false; | ||||
|       } | ||||
|     } | ||||
|     $t=checkfqdn($dom); | ||||
|     if ($t) { | ||||
|       $err->raise("dom",3+$t); | ||||
|       $err->raise("dom",_("The domain name is syntaxically incorrect")); | ||||
|       return false; | ||||
|     } | ||||
|     if (!$r=$this->get_domain_all($dom)) { | ||||
|       // Le domaine n'existe pas, Failure
 | ||||
|       $err->raise("dom",4,$dom); | ||||
|       $err->raise("dom",_("The domain name %s does not exist"),$dom); | ||||
|       return false; | ||||
|     } | ||||
|     if ($dns!="1") $dns="0"; | ||||
|     // On vérifie que des modifications ont bien eu lieu :)
 | ||||
|     if ($r["dns"]==$dns && $r["mail"]==$gesmx) { | ||||
|       $err->raise("dom",15); | ||||
|       $err->raise("dom",_("No change has been requested...")); | ||||
|       return false; | ||||
|     } | ||||
|        | ||||
|  | @ -955,14 +951,13 @@ class m_dom { | |||
|     if ($dns=="0" && $gesmx=="1" && !$force) { | ||||
|       $vmx = $this->checkmx($dom,$mx); | ||||
|       if ($vmx == 1) { | ||||
|         // Aucun champ mx de spécifié sur le dns
 | ||||
| 	$err->raise("dom",25); | ||||
| 	$err->raise("dom",_("There is no MX record pointing to this server, and you are asking us to host the mail here. Please fix your MX DNS pointer.")); | ||||
| 	return false; | ||||
|       } | ||||
|        | ||||
|       if ($vmx == 2) { | ||||
|         // Serveur non spécifié parmi les champx mx
 | ||||
| 	$err->raise("dom",25); | ||||
| 	$err->raise("dom",_("There is no MX record pointing to this server, and you are asking us to host the mail here. Please fix your MX DNS pointer.")); | ||||
| 	return false; | ||||
|       } | ||||
|     } | ||||
|  | @ -1015,15 +1010,15 @@ class m_dom { | |||
|    */ | ||||
|   function add_slave_ip($ip,$class="32") { | ||||
|   global $db,$err; | ||||
|   if (!checkip($ip)) { | ||||
|     $err->raise("dom",19); | ||||
|   if (!checkip($ip)) { // FIXME: replace by filter_var (same for checkfqdn ?
 | ||||
|     $err->raise("dom",_("The IP address you entered is incorrect.")); | ||||
|     return false; | ||||
|   } | ||||
|   $class=intval($class); | ||||
|   if ($class<8 || $class>32) $class=32; | ||||
|   $db->query("SELECT * FROM slaveip WHERE ip='$ip' AND class='$class';"); | ||||
|   if ($db->next_record()) { | ||||
|     $err->raise("err",22); | ||||
|     $err->raise("err",_("The requested domain is forbidden in this server, please contact the administrator")); | ||||
|     return false; | ||||
|   } | ||||
|   $db->query("INSERT INTO slaveip (ip,class) VALUES ('$ip','$class');"); | ||||
|  | @ -1040,7 +1035,7 @@ class m_dom { | |||
|   function del_slave_ip($ip) { | ||||
|   global $db,$err; | ||||
|   if (!checkip($ip)) { | ||||
|     $err->raise("dom",19); | ||||
|     $err->raise("dom",_("The IP address you entered is incorrect.")); | ||||
|     return false; | ||||
|   } | ||||
|   $db->query("DELETE FROM slaveip WHERE ip='$ip'"); | ||||
|  | @ -1179,7 +1174,7 @@ class m_dom { | |||
|   global $db,$err; | ||||
|   $db->query("SELECT * FROM slaveaccount WHERE login='$login'"); | ||||
|   if ($db->next_record()) { | ||||
|     $err->raise("err",23); | ||||
|     $err->raise("dom",_("The specified slave account already exists")); | ||||
|     return false; | ||||
|   } | ||||
|   $db->query("INSERT INTO slaveaccount (login,pass) VALUES ('$login','$pass')"); | ||||
|  | @ -1210,7 +1205,7 @@ class m_dom { | |||
|     global $db,$err; | ||||
|     $err->log("dom","lock"); | ||||
|     if ($this->islocked) { | ||||
|       $err->raise("dom",17); | ||||
|       $err->raise("dom",_("--- Program error --- Lock already obtained!")); | ||||
|     } | ||||
|     while (file_exists($this->fic_lock_cron)) { | ||||
|       sleep(2); | ||||
|  | @ -1229,7 +1224,7 @@ class m_dom { | |||
|     global $db,$err; | ||||
|     $err->log("dom","unlock"); | ||||
|     if (!$this->islocked) { | ||||
|       $err->raise("dom",3); | ||||
|       $err->raise("dom",_("--- Program error --- No lock on the domains!")); | ||||
|     } | ||||
|     $this->islocked=false; | ||||
|     return true; | ||||
|  |  | |||
|  | @ -280,7 +280,7 @@ class m_piwik { | |||
| 
 | ||||
| 	// We are supposed to chose what's enabled on our php instance :-)
 | ||||
| 	// if (! ini_get('allow_url_fopen')==True) {
 | ||||
|       	//	$err->raise("piwik",2,"PHP var allow_url_fopen is not allowed");
 | ||||
|       	//	$err->raise("piwik",_("Program Error: PHP ini var 'allow_url_fopen' is not allowed"));
 | ||||
| 	//}
 | ||||
| 	echo $url; | ||||
| 	$page_content = file_get_contents($url); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Benjamin Sonntag
						Benjamin Sonntag