METRO-TASK: bro dom & piwik raise() replacement + bro new header

This commit is contained in:
Benjamin Sonntag 2012-08-27 08:18:25 +00:00
parent a8b05e045c
commit 2d5a76b5f8
3 changed files with 170 additions and 154 deletions

View File

@ -1,83 +1,79 @@
<?php <?php
/* /*
$Id: m_bro.php,v 1.15 2005/12/18 09:51:32 benjamin Exp $ ----------------------------------------------------------------------
---------------------------------------------------------------------- AlternC - Web Hosting System
LICENSE Copyright (C) 2000-2012 by the AlternC Development Team.
https://alternc.org/
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL) modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html To read the license please visit http://www.gnu.org/copyleft/gpl.html
---------------------------------------------------------------------- ----------------------------------------------------------------------
Original Author of file: Purpose of file: file browser class.
Purpose of file: ----------------------------------------------------------------------
----------------------------------------------------------------------
*/ */
/* Add the mime type list */ /* Add the mime type list */
@include("mime.php"); @include("mime.php");
/** /**
* Classe de gestion du navigateur de fichiers en ligne. * This class manage the file browser of AlternC
* * allow the file and directory management in the user account web folder
* 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/
*
*/
class m_bro { class m_bro {
/** Mode d'affichage des fichiers en colonne */ /** How we draw the file in column */
var $l_mode=array(0=>"1 column, detailed",1=>"2 columns, short",2=>"3 columns, short"); var $l_mode;
/** Mode de tlchargement d'un dossier compress (zip,bz,tar,..) */ /** download mode of a compressed folder */
var $l_tgz=array(0=>"tgz (Linux)",1=>"tar.bz2 (Linux)",2=>"zip (Windows/Dos)",3=>"tar.Z (Unix)"); var $l_tgz;
/** Faut-il afficher ou non les icones ? */ /** Shall we show icons or just names? */
var $l_icons=array(0=>"No",1=>"Yes"); var $l_icons;
/** Que fait-on aprs la cration d'un fichier ? */ /** What do we do after creating a file? */
var $l_createfile=array(0=>"Go back to the file manager",1=>"Edit the newly created file"); var $l_createfile;
/** Cache des descriptions de fichier extraits de la base /** internal cache
* @access private
*/ */
var $mime_desc=array(); private var $mime_desc=array();
/** Cache des icones extraits de la base /** internal cache
* @access private
*/ */
var $mime_icon=array(); private var $mime_icon=array();
/** Cache des types mimes extraits de la base /** internal cache
* @access private
*/ */
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"); 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"); var $l_editor_size=array("18px","14px","12px","10px","8px","0.8em","0.9em","1em","1.1em","1.2em");
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Constructeur */ /** Constructor */
function m_bro() { 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 * @param string $dir Dossier (absolu que l'on souhaite vrifier
* @return string Retourne le nom du dossier vrifi, relatif au * @return string Retourne le nom du dossier vrifi, relatif au
@ -115,6 +111,8 @@ class m_bro {
return $dir; return $dir;
} }
/* ----------------------------------------------------------------- */
/** Retourne le chemin complet vers la racine du repertoire de l'utilisateur. /** Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
* Returns the complete path to the root of the user's directory. * Returns the complete path to the root of the user's directory.
* *
@ -125,6 +123,8 @@ class m_bro {
return getuserpath(); return getuserpath();
} }
/* ----------------------------------------------------------------- */
/** Retourne le chemin complet vers la racine du repertoire de l'utilisateur. /** Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
* Returns the complete path to the root of the user's directory. * 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']); return $this->get_user_root($member['login']);
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Retourne un tableau contenant la liste des fichiers du dossier courant /** Retourne un tableau contenant la liste des fichiers du dossier courant
* Ce tableau contient tous les paramtres 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 /** Retourne un tableau contenant les prfrences de l'utilisateur courant
* Ce tableau aqssociatif contient les valeurs des champs de la table "browser" * Ce tableau aqssociatif contient les valeurs des champs de la table "browser"
@ -195,6 +197,7 @@ class m_bro {
return $db->Record; return $db->Record;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Modifie les prfrences de l'utilisateur courant. /** Modifie les prfrences de l'utilisateur courant.
* *
@ -224,6 +227,7 @@ class m_bro {
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Retourne le nom du fichier icone associ au fichier donc le nom est $file /** 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. * <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]; $ext=$t[count($t)-1];
// Now seek the extension // Now seek the extension
if (!$bro_icon[$ext]) { if (!$bro_icon[$ext]) {
return "file.png"; return "file.png";
} else { } else {
return $bro_icon[$ext].".png"; return $bro_icon[$ext].".png";
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Retourne le type mime associ au fichier donc le nom est $file /** 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. * <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]; $ext=$t[count($t)-1];
// Now seek the extension // Now seek the extension
if (!$bro_type[$ext]) { if (!$bro_type[$ext]) {
return "File"; return "File";
} else { } else {
return $bro_type[$ext]; return $bro_type[$ext];
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Retourne la taille du fichier $file /** Retourne la taille du fichier $file
* si $file est un dossier, retourne la taille de ce dossier et de tous * 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))) { while (false !== ($file = readdir($handle))) {
$nextpath = $dir . '/' . $file; $nextpath = $dir . '/' . $file;
if ($file != '.' && $file != '..' && !is_link($nextpath)) { if ($file != '.' && $file != '..' && !is_link($nextpath)) {
if (is_dir($nextpath)) { if (is_dir($nextpath)) {
$totalsize += $this->dirsize($nextpath); $totalsize += $this->dirsize($nextpath);
} elseif (is_file ($nextpath)) { } elseif (is_file ($nextpath)) {
@ -319,6 +325,7 @@ class m_bro {
return $totalsize; return $totalsize;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Cre le dossier $file dans le dossier (parent) $dir /** Cre le dossier $file dans le dossier (parent) $dir
* @param string $dir dossier dans lequel on veut crer un sous-dossier * @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); $absolute=$this->convertabsolute($dir."/".$file,0);
#echo "$absolute"; #echo "$absolute";
if ($absolute && (!file_exists($absolute))) { if ($absolute && (!file_exists($absolute))) {
if (!mkdir($absolute,00777)) { if (!mkdir($absolute,00777)) {
$err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); $err->raise("bro",_("Cannot create the requested directory. Please check permissions."));
return false; return false;
} }
$db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';"); $db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';");
return true; return true;
} else { } else {
$err->raise("bro",_("File or folder name is incorrect")); $err->raise("bro",_("File or folder name is incorrect"));
return false; return false;
} }
} }
@ -412,7 +419,7 @@ class m_bro {
$old[$i]=ssla($old[$i]); // strip slashes if needed $old[$i]=ssla($old[$i]); // strip slashes if needed
$new[$i]=ssla($new[$i]); $new[$i]=ssla($new[$i]);
if (!strpos($old[$i],"/") && !strpos($new[$i],"/")) { // caractre / interdit dans old ET dans new... 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++) { for ($i=0;$i<count($old);$i++) {
@ -463,6 +470,7 @@ class m_bro {
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Change les droits d'acces aux fichier de $d du dossier $R en $p /** 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. * @param string $R dossier dans lequel se trouve les fichiers renommer.
@ -488,7 +496,7 @@ class m_bro {
if ($perm[$i]['w']) { if ($perm[$i]['w']) {
$m = $m | 128; $m = $m | 128;
} else { } else {
$m = $m ^ 128; $m = $m ^ 128;
} }
$m = $m | ($perm[$i]['w'] ? 128 : 0); // 0600 $m = $m | ($perm[$i]['w'] ? 128 : 0); // 0600
chmod($absolute."/".$d[$i], $m); chmod($absolute."/".$d[$i], $m);
@ -501,6 +509,7 @@ class m_bro {
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Recoit un champ file upload (Global) et le stocke dans le dossier $R /** Recoit un champ file upload (Global) et le stocke dans le dossier $R
* Le champ file-upload originel doit s'appeler "userfile" et doit * Le champ file-upload originel doit s'appeler "userfile" et doit
@ -521,8 +530,8 @@ class m_bro {
@touch($absolute."/".$_FILES['userfile']['name']); @touch($absolute."/".$_FILES['userfile']['name']);
} }
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $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']); exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -f ".$absolute."/".$_FILES['userfile']['name']);
return $absolute."/".$_FILES['userfile']['name']; return $absolute."/".$_FILES['userfile']['name'];
} else { } else {
$err->raise("bro",("Cannot create the requested file. Please check permissions.")); $err->raise("bro",("Cannot create the requested file. Please check permissions."));
return false; return false;
@ -535,6 +544,8 @@ class m_bro {
return $absolute."/".$_FILES['userfile']['name']; return $absolute."/".$_FILES['userfile']['name'];
} }
/* ----------------------------------------------------------------- */
/** /**
* Extract an archive by using GNU and non-GNU tools * Extract an archive by using GNU and non-GNU tools
* @param string $file is the full or relative path to the archive * @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 * same directory as the archive by default
* @return boolean != 0 on error * @return boolean != 0 on error
*/ */
function ExtractFile($file, $dest=null) function ExtractFile($file, $dest=null) {
{
global $err,$cuid,$mem,$L_ALTERNC_LOC; global $err,$cuid,$mem,$L_ALTERNC_LOC;
$file = $this->convertabsolute($file,0); $file = $this->convertabsolute($file,0);
if (is_null($dest)) { if (is_null($dest)) {
@ -574,17 +584,16 @@ class m_bro {
exec($cmd, $void, $ret); exec($cmd, $void, $ret);
} }
if ($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 TODO: does it work???
//fix the perms of the extracted archive exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -d ".$dest_to_fix);
exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -d ".$dest_to_fix);
return $ret; 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) { function CopyFile($d,$old,$new) {
global $err; global $err;
@ -611,6 +620,8 @@ class m_bro {
return true; return true;
} }
/* ----------------------------------------------------------------- */
/** /**
* Copy a source to a destination by either copying recursively a * Copy a source to a destination by either copying recursively a
* directory or by downloading a file with a URL (only http:// is * 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 * Note that we assume that the inputs have been convertabsolute()'d
*/ */
function CopyOneFile($src, $dest) function CopyOneFile($src, $dest) {
{
global $err; global $err;
$src = escapeshellarg($src); $src = escapeshellarg($src);
$dest = escapeshellarg($dest); $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); $err->raise("bro","Errors happened while copying the source to destination. cp return value: %d", $ret);
return false; return false;
} }
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Affiche le chemin et les liens de la racine au dossier $path /** Affiche le chemin et les liens de la racine au dossier $path
* Affiche autant de liens HTML (anchor) que le chemin $path contient de * Affiche autant de liens HTML (anchor) que le chemin $path contient de
@ -652,13 +662,14 @@ class m_bro {
$R=''; $R='';
for($i=0;$i<count($a);$i++) { for($i=0;$i<count($a);$i++) {
if ($a[$i]) { if ($a[$i]) {
$R.=$a[$i]."/"; $R.=$a[$i]."/";
$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a>&nbsp;/&nbsp;"; $c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a>&nbsp;/&nbsp;";
} }
} }
return $c; return $c;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Affiche le contenu d'un fichier pour un champ VALUE de textarea /** Affiche le contenu d'un fichier pour un champ VALUE de textarea
* Affiche le contenu du fichier $file dans le dossier $R. Le contenu * Affiche le contenu du fichier $file dans le dossier $R. Le contenu
@ -675,7 +686,7 @@ class m_bro {
if (!strpos($file,"/")) { if (!strpos($file,"/")) {
$absolute.="/".$file; $absolute.="/".$file;
if (file_exists($absolute)) { if (file_exists($absolute)) {
$std=str_replace("<","&lt;",str_replace("&","&amp;",file_get_contents($absolute))); $std=str_replace("<","&lt;",str_replace("&","&amp;",file_get_contents($absolute)));
} else { } else {
$err->raise("bro",_("Cannot read the requested file. Please check permissions.")); $err->raise("bro",_("Cannot read the requested file. Please check permissions."));
return false; return false;
@ -687,11 +698,13 @@ class m_bro {
return $std; 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. // Return a browsing url if available.
// Maintain a url cache (positive AND negative(-) cache) // Maintain a url cache (positive AND negative(-) cache)
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
@ -723,7 +736,7 @@ class m_bro {
if (!$beg && $tofind) { if (!$beg && $tofind) {
$tofind=false; $tofind=false;
$this->cacheurl["d".$dir]="-"; $this->cacheurl["d".$dir]="-";
// We did not find it ;( // We did not find it ;(
} }
if (($tt=strrpos($beg,"/"))!==false) { if (($tt=strrpos($beg,"/"))!==false) {
$end=substr($beg,$tt).$end; // = /topdir$end so $end starts AND ends with / $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) { function can_edit($dir,$name) {
global $mem,$err; global $mem,$err;
$absolute="$dir/$name"; $absolute="$dir/$name";
@ -758,8 +775,9 @@ class m_bro {
return false; 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) { function is_extractable($dir,$name) {
if ($parts = explode(".", $name)) { if ($parts = explode(".", $name)) {
@ -768,8 +786,8 @@ class m_bro {
case "gz": case "gz":
case "bz": case "bz":
case "bz2": case "bz2":
$ext = array_pop($parts) . $ext; $ext = array_pop($parts) . $ext;
/* FALLTHROUGH */ /* FALLTHROUGH */
case "tar.gz": case "tar.gz":
case "tar.bz": case "tar.bz":
case "tar.bz2": case "tar.bz2":
@ -785,6 +803,10 @@ class m_bro {
return false; return false;
} }
/* ----------------------------------------------------------------- */
/**
*/
function download_link($dir,$file){ function download_link($dir,$file){
global $err; global $err;
$err->log("bro","download_link"); $err->log("bro","download_link");
@ -829,14 +851,14 @@ class m_bro {
if (!strpos($file,"/")) { if (!strpos($file,"/")) {
$absolute.="/".$file; $absolute.="/".$file;
if (file_exists($absolute)) { if (file_exists($absolute)) {
$f=@fopen($absolute,"wb"); $f=@fopen($absolute,"wb");
if ($f) { if ($f) {
fputs($f,$texte,strlen($texte)); fputs($f,$texte,strlen($texte));
fclose($f); fclose($f);
} else { } else {
$err->raise("bro",("Cannot edit the requested file. Please check permissions.")); $err->raise("bro",("Cannot edit the requested file. Please check permissions."));
return false; return false;
} }
} }
} else { } else {
$err->raise("bro",_("File or folder name is incorrect")); $err->raise("bro",_("File or folder name is incorrect"));
@ -933,9 +955,9 @@ class m_bro {
if (is_dir($file)) { if (is_dir($file)) {
$handle = opendir($file); $handle = opendir($file);
while($filename = readdir($handle)) { while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") { if ($filename != "." && $filename != "..") {
$this->_delete($file."/".$filename); $this->_delete($file."/".$filename);
} }
} }
closedir($handle); closedir($handle);
rmdir($file); rmdir($file);
@ -943,13 +965,13 @@ class m_bro {
unlink($file); 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; global $db,$err;
$err->log("bro","export_conf"); $err->log("bro","export_conf");
$str="<table border=\"1\"><caption> Browser </caption>\n"; $str="<table border=\"1\"><caption> Browser </caption>\n";
@ -958,41 +980,40 @@ function alternc_export_conf() {
$i=1; $i=1;
foreach ($pref as $k=>$v) { foreach ($pref as $k=>$v) {
if (($i % 2)==0){ if (($i % 2)==0){
$str.=" <$k>$v</$k>\n"; $str.=" <$k>$v</$k>\n";
} }
$i++; $i++;
} }
$str.=" </browser>\n"; $str.=" </browser>\n";
return $str; 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 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 alternc_export_data($dir){
global $mem,$L_ALTERNC_LOC,$err; global $mem,$L_ALTERNC_LOC,$err;
$err->log("bro","export_data"); $err->log("bro","export_data");
$dir.="html/"; $dir.="html/";
if(!is_dir($dir)){ if(!is_dir($dir)){
if(!mkdir($dir)) if(!mkdir($dir))
$err->raise("bro",_("Cannot create the requested directory. Please check permissions.")); $err->raise("bro",_("Cannot create the requested directory. Please check permissions."));
} }
$timestamp=date("H:i:s"); $timestamp=date("H:i:s");
if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){ if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
$err->log("bro","export_data_succes"); $err->log("bro","export_data_succes");
}else{ }else{
$err->log("bro","export_data_failed"); $err->log("bro","export_data_failed");
} }
} }
} /* Class Browser */
} /* Classe BROUTEUR */
?>

View File

@ -693,17 +693,17 @@ class m_dom {
$err->log("dom","get_sub_domain_all",$dom."/".$sub); $err->log("dom","get_sub_domain_all",$dom."/".$sub);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$t=checkfqdn($dom); $t=checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom",3+$t); $err->raise("dom",_("The domain name is syntaxically incorrect"));
return false; 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);"); $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) { if ($db->num_rows()==0) {
$err->raise("dom",14); $err->raise("dom",_("The sub-domain does not exist."));
return false; return false;
} }
$db->next_record(); $db->next_record();
@ -735,7 +735,7 @@ class m_dom {
$value="/".$value; $value="/".$value;
} }
if (!checkuserpath($value)) { if (!checkuserpath($value)) {
$err->raise("dom",21); $err->raise("dom",_("The folder you entered is incorrect or does not exist."));
return false; return false;
} }
return true; return true;
@ -811,7 +811,7 @@ class m_dom {
$err->log("dom","set_sub_domain",$dom."/".$sub."/".$type."/".$dest); $err->log("dom","set_sub_domain",$dom."/".$sub."/".$type."/".$dest);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$dest=trim($dest); $dest=trim($dest);
@ -823,25 +823,23 @@ class m_dom {
$fqdn=checkfqdn($sub); $fqdn=checkfqdn($sub);
// Special cases : * (all subdomains at once) and '' empty subdomain are allowed. // Special cases : * (all subdomains at once) and '' empty subdomain are allowed.
if (($sub != '*' && $sub!='') && !($fqdn==0 || $fqdn==4)) { 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; return false;
} }
if (! $this->check_type_value($type,$dest)) { if (! $this->check_type_value($type,$dest)) {
// Invalid domain type selected, please check. $err->raise("dom",_("Invalid domain type selected, please check."));
$err->raise("dom",27);
return false; return false;
} }
// On a épuré $dir des problèmes eventuels ... On est en DESSOUS du dossier de l'utilisateur. // On a épuré $dir des problèmes eventuels ... On est en DESSOUS du dossier de l'utilisateur.
if ($t=checkfqdn($dom)) { if ($t=checkfqdn($dom)) {
$err->raise("dom",3+$t); $err->raise("dom",_("The domain name is syntaxically incorrect"));
return false; return false;
} }
if (! $this->can_create_subdomain($dom,$sub,$type,$type_old,$value_old)) { 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", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
$err->raise("dom", 28);
return false; return false;
} }
@ -876,20 +874,18 @@ class m_dom {
$err->log("dom","del_sub_domain",$dom."/".$sub); $err->log("dom","del_sub_domain",$dom."/".$sub);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$t=checkfqdn($dom); $t=checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom",3+$t); $err->raise("dom",("The domain name is syntaxically incorrect"));
return false; return false;
} }
if (!$r=$this->get_sub_domain_all($dom,$sub,$type)) { if (!$r=$this->get_sub_domain_all($dom,$sub,$type)) {
// Le sous-domaine n'existe pas, erreur $err->raise("dom",_("The sub-domain does not exist."));
$err->raise("dom",14);
return false; return false;
} else { } 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 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';"); $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); $err->log("dom","edit_domain",$dom."/".$dns."/".$gesmx);
// Locked ? // Locked ?
if (!$this->islocked && !$force) { if (!$this->islocked && !$force) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
if ($dns == 1 && !$force) { if ($dns == 1 && !$force) {
$this->dns=$this->whois($dom); $this->dns=$this->whois($dom);
$v=checkhostallow($dom,$this->dns); $v=checkhostallow($dom,$this->dns);
if ($v==-1) { 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; return false;
} }
if ($dns && $v==-2) { 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; return false;
} }
if ($dns && $v==-3) { 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; return false;
} }
} }
$t=checkfqdn($dom); $t=checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom",3+$t); $err->raise("dom",_("The domain name is syntaxically incorrect"));
return false; return false;
} }
if (!$r=$this->get_domain_all($dom)) { if (!$r=$this->get_domain_all($dom)) {
// Le domaine n'existe pas, Failure // Le domaine n'existe pas, Failure
$err->raise("dom",4,$dom); $err->raise("dom",_("The domain name %s does not exist"),$dom);
return false; return false;
} }
if ($dns!="1") $dns="0"; if ($dns!="1") $dns="0";
// On vérifie que des modifications ont bien eu lieu :) // On vérifie que des modifications ont bien eu lieu :)
if ($r["dns"]==$dns && $r["mail"]==$gesmx) { if ($r["dns"]==$dns && $r["mail"]==$gesmx) {
$err->raise("dom",15); $err->raise("dom",_("No change has been requested..."));
return false; return false;
} }
@ -955,14 +951,13 @@ class m_dom {
if ($dns=="0" && $gesmx=="1" && !$force) { if ($dns=="0" && $gesmx=="1" && !$force) {
$vmx = $this->checkmx($dom,$mx); $vmx = $this->checkmx($dom,$mx);
if ($vmx == 1) { if ($vmx == 1) {
// Aucun champ mx de spécifié sur le dns $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."));
$err->raise("dom",25);
return false; return false;
} }
if ($vmx == 2) { if ($vmx == 2) {
// Serveur non spécifié parmi les champx mx // 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; return false;
} }
} }
@ -1015,15 +1010,15 @@ class m_dom {
*/ */
function add_slave_ip($ip,$class="32") { function add_slave_ip($ip,$class="32") {
global $db,$err; global $db,$err;
if (!checkip($ip)) { if (!checkip($ip)) { // FIXME: replace by filter_var (same for checkfqdn ?
$err->raise("dom",19); $err->raise("dom",_("The IP address you entered is incorrect."));
return false; return false;
} }
$class=intval($class); $class=intval($class);
if ($class<8 || $class>32) $class=32; if ($class<8 || $class>32) $class=32;
$db->query("SELECT * FROM slaveip WHERE ip='$ip' AND class='$class';"); $db->query("SELECT * FROM slaveip WHERE ip='$ip' AND class='$class';");
if ($db->next_record()) { 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; return false;
} }
$db->query("INSERT INTO slaveip (ip,class) VALUES ('$ip','$class');"); $db->query("INSERT INTO slaveip (ip,class) VALUES ('$ip','$class');");
@ -1040,7 +1035,7 @@ class m_dom {
function del_slave_ip($ip) { function del_slave_ip($ip) {
global $db,$err; global $db,$err;
if (!checkip($ip)) { if (!checkip($ip)) {
$err->raise("dom",19); $err->raise("dom",_("The IP address you entered is incorrect."));
return false; return false;
} }
$db->query("DELETE FROM slaveip WHERE ip='$ip'"); $db->query("DELETE FROM slaveip WHERE ip='$ip'");
@ -1179,7 +1174,7 @@ class m_dom {
global $db,$err; global $db,$err;
$db->query("SELECT * FROM slaveaccount WHERE login='$login'"); $db->query("SELECT * FROM slaveaccount WHERE login='$login'");
if ($db->next_record()) { if ($db->next_record()) {
$err->raise("err",23); $err->raise("dom",_("The specified slave account already exists"));
return false; return false;
} }
$db->query("INSERT INTO slaveaccount (login,pass) VALUES ('$login','$pass')"); $db->query("INSERT INTO slaveaccount (login,pass) VALUES ('$login','$pass')");
@ -1210,7 +1205,7 @@ class m_dom {
global $db,$err; global $db,$err;
$err->log("dom","lock"); $err->log("dom","lock");
if ($this->islocked) { if ($this->islocked) {
$err->raise("dom",17); $err->raise("dom",_("--- Program error --- Lock already obtained!"));
} }
while (file_exists($this->fic_lock_cron)) { while (file_exists($this->fic_lock_cron)) {
sleep(2); sleep(2);
@ -1229,7 +1224,7 @@ class m_dom {
global $db,$err; global $db,$err;
$err->log("dom","unlock"); $err->log("dom","unlock");
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
} }
$this->islocked=false; $this->islocked=false;
return true; return true;

View File

@ -280,7 +280,7 @@ class m_piwik {
// We are supposed to chose what's enabled on our php instance :-) // We are supposed to chose what's enabled on our php instance :-)
// if (! ini_get('allow_url_fopen')==True) { // 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; echo $url;
$page_content = file_get_contents($url); $page_content = file_get_contents($url);