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 <?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 LICENSE
@ -16,8 +19,7 @@
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:
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
@ -25,59 +27,53 @@
@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.
@ -248,6 +252,7 @@ class m_bro {
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** 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.
@ -273,6 +278,7 @@ class m_bro {
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** 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
@ -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
@ -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.
@ -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
@ -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
@ -659,6 +669,7 @@ class m_bro {
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
@ -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)
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
@ -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)) {
@ -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");
@ -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";
@ -968,11 +990,12 @@ function alternc_export_conf() {
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/";
@ -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); $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);