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,6 +1,9 @@
<?php
/*
$Id: m_bro.php,v 1.15 2005/12/18 09:51:32 benjamin Exp $
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2000-2012 by the AlternC Development Team.
https://alternc.org/
----------------------------------------------------------------------
LICENSE
@ -16,8 +19,7 @@
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file:
Purpose of file:
Purpose of file: file browser class.
----------------------------------------------------------------------
*/
@ -25,59 +27,53 @@
@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.
@ -248,6 +252,7 @@ class m_bro {
}
}
/* ----------------------------------------------------------------- */
/** 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.
@ -273,6 +278,7 @@ class m_bro {
}
}
/* ----------------------------------------------------------------- */
/** Retourne la taille du fichier $file
* si $file est un dossier, retourne la taille de ce dossier et de tous
@ -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
@ -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.
@ -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
@ -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
// 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
@ -659,6 +669,7 @@ class m_bro {
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
@ -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)
/* ----------------------------------------------------------------- */
@ -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)) {
@ -785,6 +803,10 @@ class m_bro {
return false;
}
/* ----------------------------------------------------------------- */
/**
*/
function download_link($dir,$file){
global $err;
$err->log("bro","download_link");
@ -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";
@ -968,11 +990,12 @@ function alternc_export_conf() {
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/";
@ -989,10 +1012,8 @@ function alternc_export_data($dir){
}
}
}
} /* Class Browser */
} /* Classe BROUTEUR */
?>

View File

@ -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);
$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;

View File

@ -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);