This commit is contained in:
Alan Garcia 2014-03-26 15:04:12 +00:00
parent 02f735ecdf
commit 62dde928c5
11 changed files with 29 additions and 32 deletions

View File

@ -309,6 +309,8 @@ function getuserpath($user = null) {
function cbox($test, $echo = TRUE) { function cbox($test, $echo = TRUE) {
if ($test) { if ($test) {
$return = " checked=\"checked\""; $return = " checked=\"checked\"";
} else {
$return='';
} }
if( $echo ){ if( $echo ){
echo $return; echo $return;
@ -328,6 +330,8 @@ function cbox($test, $echo = TRUE) {
function selected($bool, $echo = TRUE) { function selected($bool, $echo = TRUE) {
if ($bool) { if ($bool) {
$return = " selected=\"selected\""; $return = " selected=\"selected\"";
} else {
$return='';
} }
if( $echo ){ if( $echo ){
echo $return; echo $return;
@ -851,7 +855,7 @@ function display_browser($dir="", $caller="main.dir", $width=350, $height=450) {
document.write('&nbsp;<input type=\"button\" id=\"bt".$bid."\" value=\""._("Choose a folder...")."\" class=\"ina\">'); document.write('&nbsp;<input type=\"button\" id=\"bt".$bid."\" value=\""._("Choose a folder...")."\" class=\"ina\">');
document.write('<div id=\"".$bid."\" title=\""._("Choose a folder...")."\" style=\"display: none; bgcolor:red;\">'); document.write('<div id=\"".$bid."\" title=\""._("Choose a folder...")."\" style=\"display: none; bgcolor:red;\">');
document.write(' <iframe src=\"/browseforfolder2.php?caller=".$caller."&amp;file=".ehe($dir, 0)."&amp;bid=".$bid."\" width=\"".($width-40)."\" height=\"".($height-64)."\" frameborder=\"no\" id=\"browseiframe\"></iframe>'); document.write(' <iframe src=\"/browseforfolder2.php?caller=".$caller."&amp;file=".ehe($dir, false)."&amp;bid=".$bid."\" width=\"".($width-40)."\" height=\"".($height-64)."\" frameborder=\"no\" id=\"browseiframe\"></iframe>');
document.write('</div>'); document.write('</div>');
// --> // -->
</script> </script>

View File

@ -251,7 +251,6 @@ class m_authip {
*/ */
function get_auth_class() { function get_auth_class() {
global $hooks; global $hooks;
$authclass=array();
$authclass = $hooks->invoke('authip_class'); $authclass = $hooks->invoke('authip_class');
// Je rajoute la class DANS l'objet parce que // Je rajoute la class DANS l'objet parce que

View File

@ -182,7 +182,7 @@ class m_bro {
global $db,$cuid,$err; global $db,$cuid,$err;
$db->query("UPDATE browser SET lastdir='$dir' WHERE uid='$cuid';"); $db->query("UPDATE browser SET lastdir='$dir' WHERE uid='$cuid';");
$absolute=$this->convertabsolute($dir,0); $absolute=$this->convertabsolute($dir,0);
if (! file_exists($absolute)) { if (!$absolute || !file_exists($absolute)) {
$err->raise('bro',_("This directory do not exist")); $err->raise('bro',_("This directory do not exist"));
return false; return false;
} }
@ -239,11 +239,11 @@ class m_bro {
$listmode=intval($listmode); $showicons=intval($showicons); $listmode=intval($listmode); $showicons=intval($showicons);
$showtype=intval($showtype); $downfmt=intval($downfmt); $showtype=intval($showtype); $downfmt=intval($downfmt);
$createfile=intval($createfile); $golastdir=intval($golastdir); $createfile=intval($createfile); $golastdir=intval($golastdir);
$db->query("SELECT * FROM browser WHERE uid='$cuid';"); $db->query("SELECT * FROM browser WHERE uid='".intval($cuid)."';");
if ($db->num_rows()==0) { if ($db->num_rows()==0) {
$db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size, golastdir) VALUES (70, 21, 0, 0, 0, 0, 0, '".$this->uid."','Arial, Helvetica, Sans-serif','12px',1);"); $db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size, golastdir) VALUES (70, 21, 0, 0, 0, 0, 0, '".intval($cuid)."','Arial, Helvetica, Sans-serif','12px',1);");
} }
$db->query("UPDATE browser SET editsizex='$editsizex', editsizey='$editsizey', listmode='$listmode', showicons='$showicons', downfmt='$downfmt', createfile='$createfile', showtype='$showtype', editor_font='$editor_font', editor_size='$editor_size', golastdir='$golastdir' WHERE uid='$cuid';"); $db->query("UPDATE browser SET editsizex='$editsizex', editsizey='$editsizey', listmode='$listmode', showicons='$showicons', downfmt='$downfmt', createfile='$createfile', showtype='$showtype', editor_font='$editor_font', editor_size='$editor_size', golastdir='$golastdir' WHERE uid='".intval($cuid)."';");
return true; return true;
} }
@ -721,11 +721,11 @@ class m_bro {
function content($R,$file) { function content($R,$file) {
global $err; global $err;
$absolute=$this->convertabsolute($R,0); $absolute=$this->convertabsolute($R,0);
$std="";
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)));
return $std;
} else { } else {
$err->raise("bro",_("Cannot read the requested file. Please check the permissions")); $err->raise("bro",_("Cannot read the requested file. Please check the permissions"));
return false; return false;
@ -734,7 +734,6 @@ class m_bro {
$err->raise("bro",_("File or folder name is incorrect")); $err->raise("bro",_("File or folder name is incorrect"));
return false; return false;
} }
return $std;
} }
@ -970,7 +969,7 @@ class m_bro {
header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip"); header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip");
header("Content-Type: application/x-zip"); header("Content-Type: application/x-zip");
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
$d=escapeshellarg($this->convertabsolute($dir,0)); $d=escapeshellarg($this->convertabsolute($dir,false));
set_time_limit(0); set_time_limit(0);
passthru("/usr/bin/zip -r - $d"); passthru("/usr/bin/zip -r - $d");
} }
@ -1020,7 +1019,7 @@ class m_bro {
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";
$str=" <browser>\n"; $str.=" <browser>\n";
$pref=$this->GetPrefs(); $pref=$this->GetPrefs();
$i=1; $i=1;

View File

@ -11,7 +11,6 @@ Class m_export {
function export_conf(){ function export_conf(){
global $hooks; global $hooks;
$conf = array();
$conf=$hooks->invoke('alternc_export_conf'); $conf=$hooks->invoke('alternc_export_conf');
return $conf; return $conf;
} }

View File

@ -271,7 +271,6 @@ class m_ftp {
$err->raise("ftp",_("The chosen prefix is not allowed")); $err->raise("ftp",_("The chosen prefix is not allowed"));
return false; return false;
} }
$lo=$mem->user["login"];
$full_login=$prefixe; $full_login=$prefixe;
if ($login) $full_login.="_".$login; if ($login) $full_login.="_".$login;
@ -362,7 +361,6 @@ class m_ftp {
} }
$db->query("SELECT login FROM membres WHERE uid='$cuid';"); $db->query("SELECT login FROM membres WHERE uid='$cuid';");
$db->next_record(); $db->next_record();
$lo=$db->f("login");
$absolute=getuserpath()."/$dir"; $absolute=getuserpath()."/$dir";
if (!file_exists($absolute)) { if (!file_exists($absolute)) {
system("/bin/mkdir -p $absolute"); // FIXME replace with action system("/bin/mkdir -p $absolute"); // FIXME replace with action
@ -397,7 +395,6 @@ class m_ftp {
function is_ftp($dir) { function is_ftp($dir) {
global $mem,$db,$err; global $mem,$db,$err;
$err->log("ftp","is_ftp",$dir); $err->log("ftp","is_ftp",$dir);
$lo=$mem->user["login"];
if (substr($dir,0,1)=="/") $dir=substr($dir,1); if (substr($dir,0,1)=="/") $dir=substr($dir,1);
$db->query("SELECT id FROM ftpusers WHERE homedir='".getuserpath()."/$dir';"); $db->query("SELECT id FROM ftpusers WHERE homedir='".getuserpath()."/$dir';");
if ($db->num_rows()) { if ($db->num_rows()) {

View File

@ -88,7 +88,7 @@ class m_hooks {
// First, build the list of script we want to launch // First, build the list of script we want to launch
$to_launch=array(); $to_launch=array();
if (is_file($scripts)) { if (is_file($scripts)) {
if (is_executable($script)) { if (is_executable($scripts)) {
$to_launch[]=$scripts; $to_launch[]=$scripts;
} }
} else if (is_dir($scripts)) { } else if (is_dir($scripts)) {

View File

@ -147,11 +147,9 @@ class m_hta {
global $mem,$err; global $mem,$err;
$err->log("hta","is_protected",$dir); $err->log("hta","is_protected",$dir);
$absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; $absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
$sortie=array();
if (file_exists("$absolute/.htpasswd")){ if (file_exists("$absolute/.htpasswd")){
return true; return true;
} } else {
else {
return false; return false;
} }
} }

View File

@ -34,7 +34,9 @@ class m_lxc implements vm {
public $IP; public $IP;
public $KEY;
public $PORT; public $PORT;
public $maxtime;
public $TIMEOUT = 5; public $TIMEOUT = 5;
public $error = array(); public $error = array();
@ -107,7 +109,6 @@ class m_lxc implements vm {
$this->error[] = 'Unable to send data'; $this->error[] = 'Unable to send data';
return FALSE; return FALSE;
} }
$resp = '';
$resp = fgets($fp, 8192); $resp = fgets($fp, 8192);
fclose ($fp); fclose ($fp);
@ -147,14 +148,14 @@ class m_lxc implements vm {
return $this->error; return $this->error;
} else { } else {
$data = unserialize($res); $data = unserialize($res);
$error = $data['error']; $error = (int)$data['error'];
$hostname = $data['hostname']; $hostname = $data['hostname'];
$msg = $data['msg']; $msg = $data['msg'];
$date_start = 'NOW()'; $date_start = 'NOW()';
$uid = $mem->user['uid']; $uid = $mem->user['uid'];
if ((int)$data['error'] != 0) { if ($error != 0) {
$err->raise('lxc', _($data['msg'])); $err->raise('lxc', _($msg));
return FALSE; return FALSE;
} }
$db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES ('$hostname', $date_start, '$uid', '$res')"); $db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES ('$hostname', $date_start, '$uid', '$res')");

View File

@ -76,6 +76,7 @@ class m_mail {
var $srv_pop3s; var $srv_pop3s;
var $cache_domain_mail_size = array(); var $cache_domain_mail_size = array();
var $enum_domains=array();
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* Constructeur * Constructeur
@ -674,7 +675,7 @@ ORDER BY
} }
} }
$db->query("DELETE FROM recipient WHERE address_id=".$mail_id.";"); $db->query("DELETE FROM recipient WHERE address_id=".$mail_id.";");
if ($m) { if (isset($m) && $m) {
$db->query("INSERT INTO recipient SET address_id=".$mail_id.", recipients='".addslashes($red)."';"); $db->query("INSERT INTO recipient SET address_id=".$mail_id.", recipients='".addslashes($red)."';");
} }
return true; return true;
@ -738,13 +739,11 @@ ORDER BY
$err->log("mail","export"); $err->log("mail","export");
$domain=$this->enum_domains(); $domain=$this->enum_domains();
$str="<mail>\n"; $str="<mail>\n";
$onepop=false;
foreach ($domain as $d) { foreach ($domain as $d) {
$str.=" <domain>\n <name>".xml_entities($d["domain"])."</name>\n"; $str.=" <domain>\n <name>".xml_entities($d["domain"])."</name>\n";
$s=$this->enum_domain_mails($d["id"]); $s=$this->enum_domain_mails($d["id"]);
if (count($s)) { if (count($s)) {
while (list($key,$val)=each($s)){ while (list($key,$val)=each($s)){
$test=$this->get_details($val['id']);
$str.=" <address>\n"; $str.=" <address>\n";
$str.=" <name>".xml_entities($val["address"])."</name>\n"; $str.=" <name>".xml_entities($val["address"])."</name>\n";
$str.=" <enabled>".xml_entities($val["enabled"])."</enabled>\n"; $str.=" <enabled>".xml_entities($val["enabled"])."</enabled>\n";

View File

@ -486,9 +486,9 @@ Cordially.
$db->next_record(); $db->next_record();
// un cookie de 20 caractères pour le mail // un cookie de 20 caractères pour le mail
$COOKIE=substr(md5(uniqid(rand(),1)),0,20); $COOKIE=substr(md5(uniqid(rand(), true)),0,20);
// et de 6 pour la clé à entrer. ca me semble suffisant... // et de 6 pour la clé à entrer. ca me semble suffisant...
$KEY=substr(md5(uniqid(rand(),1)),0,6); $KEY=substr(md5(uniqid(rand(), true)),0,6);
$link="https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE"; $link="https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE";
$txt=sprintf(_("Hello, $txt=sprintf(_("Hello,

View File

@ -8,6 +8,7 @@ if (!$admin->enabled) {
} }
$db->query("SELECT id,hostname FROM stats;"); $db->query("SELECT id,hostname FROM stats;");
$d=array();
while ($db->next_record()) { while ($db->next_record()) {
$d[]=$db->Record; $d[]=$db->Record;
} }