Merge branch 'master' of alternc.org:alternc
This commit is contained in:
commit
9489d4f77c
|
@ -605,6 +605,7 @@ nightlybuild/READMEFIRST -text
|
|||
nightlybuild/build.sh -text
|
||||
nightlybuild/mchroot.sh -text
|
||||
nightlybuild/nightly.key -text
|
||||
phpunit/tests/_datasets/domaines.yml -text
|
||||
po/alternc-admintools.pot -text
|
||||
po/fr/LC_MESSAGES/.svnignore -text
|
||||
po/fr/LC_MESSAGES/alternc-admintools.po -text
|
||||
|
@ -614,7 +615,6 @@ roundcube/class/m_roundcube.php -text
|
|||
roundcube/roundcube-install -text
|
||||
roundcube/roundcube_alternc_logo.png -text
|
||||
roundcube/templates/apache2/roundcube.conf -text
|
||||
roundcube/templates/logrotate.d/roundcube-core -text
|
||||
roundcube/templates/roundcube/main.inc.php -text
|
||||
roundcube/templates/roundcube/plugins/managesieve/config.inc.php -text
|
||||
roundcube/templates/roundcube/plugins/password/config.inc.php -text
|
||||
|
@ -663,6 +663,7 @@ src/quota-warning.sh -text
|
|||
src/quota_delete -text
|
||||
src/quota_edit -text
|
||||
src/quota_get -text
|
||||
src/quota_get_all -text
|
||||
src/quota_init -text
|
||||
src/rebuild_all_webconf.sh -text
|
||||
src/sendmail -text
|
||||
|
|
|
@ -35,24 +35,18 @@ if (!$admin->enabled) {
|
|||
}
|
||||
|
||||
$fields = array (
|
||||
"d" => array ("request", "array", array()),
|
||||
"accountList" => array ("request", "array", array()),
|
||||
"del_confirm" => array("request", "string", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
||||
if($del_confirm == "y"){
|
||||
if (!is_array($accountList)) {
|
||||
$accountList[] = $accountList;
|
||||
}
|
||||
|
||||
reset($accountList);
|
||||
while (list($key,$val)=each($accountList)) {
|
||||
$error = "";
|
||||
foreach ($accountList as $key => $val) {
|
||||
if (!$admin->checkcreator($val)) {
|
||||
__("This page is restricted to authorized staff");
|
||||
exit();
|
||||
}
|
||||
$error = "";
|
||||
if (!($u=$admin->get($val)) || !$admin->del_mem($val)) {
|
||||
$error .= sprintf(_("Member '%s' does not exist"),$val)."<br />";
|
||||
} else {
|
||||
|
@ -77,12 +71,14 @@ if($del_confirm == "y"){
|
|||
<input type="hidden" name="del_confirm" value="y" />
|
||||
<p class="alert alert-warning"><?php __("WARNING : Confirm the deletion of the users"); ?></p>
|
||||
<p>
|
||||
<ul>
|
||||
<?php
|
||||
foreach($accountList as $userid){
|
||||
$membre = $admin->get($userid);
|
||||
echo "<input type=\"hidden\" name=\"d[]\" value=\"$userid\" />".$membre['login']."<br/>";
|
||||
echo "<li><input type=\"hidden\" name=\"accountList[]\" value=\"$userid\" />".$membre['login']."</li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</p>
|
||||
<blockquote>
|
||||
<input type="submit" class="inb ok" name="confirm" value="<?php __("Yes, delete those accounts"); ?>" />
|
||||
|
|
|
@ -174,7 +174,7 @@ if (!is_array($accountList) || empty($accountList)) {
|
|||
<?php if ($val["su"]) { ?>
|
||||
<td id="user_<?php echo $val["uid"]; ?>"> </td>
|
||||
<?php } else { ?>
|
||||
<td><input type="checkbox" class="inc" name="d[]" id="user_<?php echo $val["uid"]; ?>" value="<?php echo $val["uid"]; ?>" /></td>
|
||||
<td><input type="checkbox" class="inc" name="accountList[]" id="user_<?php echo $val["uid"]; ?>" value="<?php echo $val["uid"]; ?>" /></td>
|
||||
<?php } // val['su'] ?>
|
||||
<td <?php if ($val["su"]) echo 'style="color: red"'; ?>><label for="user_<?php echo $val["uid"]; ?>"><b><?php echo $val["login"] ?></b></label></td>
|
||||
<td><a title="<?php __("Send an email"); ?>" href="mailto:<?php echo $val["mail"]; ?>"><?php echo $val["nom"] . " " . $val["prenom"] ?></a> </td>
|
||||
|
@ -250,7 +250,7 @@ if ($mem->user["admlist"] == 1) { // SHORT MODE
|
|||
if ($val["su"]) {
|
||||
echo '<td> </td>';
|
||||
} else {
|
||||
echo '<td align="center"><input type="checkbox" class="inc" name="d[]" value="' . $val["uid"] . '" id="id_c_' . $val["uid"] . '" /></td>';
|
||||
echo '<td align="center"><input type="checkbox" class="inc" name="accountList[]" value="' . $val["uid"] . '" id="id_c_' . $val["uid"] . '" /></td>';
|
||||
} // if $val["su"]
|
||||
?>
|
||||
<td align="center">
|
||||
|
|
|
@ -51,7 +51,7 @@ if ($newlogin) {
|
|||
// Add an account
|
||||
if ($mail->add_slave_account($newlogin,$newpass)) {
|
||||
$error=_("The requested account address has been created. It is now allowed.");
|
||||
$newlogin=false;$newpass=false;
|
||||
$newlogin='';$newpass='';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ function var_input($infotype, $name, $value='') {
|
|||
break;
|
||||
case "boolean":
|
||||
echo "<input type='hidden' name='$name' value='0' />"; // This way, there is allways something send, even if checkbox is unchecked
|
||||
echo "<input type='checkbox' id='add_$id' name='$name' value='1' ";cbox($value);echo " />";
|
||||
echo "<input type='checkbox' id='add_$id' name='$name' value='1' ";cbox((bool)$value);echo " />";
|
||||
break;
|
||||
default:
|
||||
echo "WTF ? Dunno what to do with a ".$infotype['type'];
|
||||
|
@ -251,7 +251,7 @@ foreach ( $variables->strata_order as $strata) {
|
|||
foreach ($allvars['FQDN_CREATOR'] as $ttk => $ttv ) {
|
||||
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
|
||||
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
edit_var($ttv[$var]);
|
||||
}
|
||||
echo "<br/>";
|
||||
|
@ -267,7 +267,7 @@ foreach ( $variables->strata_order as $strata) {
|
|||
foreach ($allvars['FQDN'] as $ttk => $ttv ) {
|
||||
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
|
||||
echo sprintf(_("Overwritted by %s"), $panel_url[$ttk])." → ";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
edit_var($ttv[$var]);
|
||||
}
|
||||
echo "<br/>";
|
||||
|
@ -283,7 +283,7 @@ foreach ( $variables->strata_order as $strata) {
|
|||
foreach ($allvars['CREATOR'] as $ttk => $ttv ) {
|
||||
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
|
||||
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
edit_var($ttv[$var]);
|
||||
}
|
||||
echo "<br/>";
|
||||
|
@ -299,7 +299,7 @@ foreach ( $variables->strata_order as $strata) {
|
|||
foreach ($allvars['MEMBER'] as $ttk => $ttv ) {
|
||||
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
|
||||
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
|
||||
edit_var($ttv[$var]);
|
||||
}
|
||||
echo "<br/>";
|
||||
|
|
|
@ -92,7 +92,7 @@ echo _("See the vars for the account")." ";
|
|||
echo "<select name='member_id'>";eoption($ml, $member_id);echo "</select>";
|
||||
echo " "._("logged via")." ";
|
||||
echo "<select name='fqdn_id'>";eoption($dom->get_panel_url_list(), $fqdn_id );echo "</select> ";
|
||||
echo "<input type='submit' class='ina' value=\""; echo ehe(_("View")); echo "\" />";
|
||||
echo "<input type='submit' class='ina' value=\""; ehe(_("View")); echo "\" />";
|
||||
|
||||
?>
|
||||
</form>
|
||||
|
|
|
@ -37,14 +37,17 @@ if (!isset($charset) || ! $charset) $charset="UTF-8";
|
|||
if (file_exists("styles/style-custom.css") ) {
|
||||
echo '<link rel="stylesheet" href="styles/style-custom.css" type="text/css" />';
|
||||
}
|
||||
|
||||
$favicon = variable_get('favicon', 'favicon.ico' ,'You can specify a favicon, for example /images/my_logo.ico', array(array('desc'=>'URL','type'=>'string')));
|
||||
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="styles/style-empty.css" type="text/css" title="Default - Desktop TNG"/>
|
||||
<link rel="alternate stylesheet" href="styles/style-bluedesktop10.css" type="text/css" title="Blue Desktop 1.0" />
|
||||
<link rel="alternate stylesheet" href="styles/style-hw.css" type="text/css" title="Halloween" />
|
||||
|
||||
<link rel="Shortcut Icon" href="favicon.ico" type="image/ico" />
|
||||
<link rel="icon" href="favicon.ico" type="image/ico" />
|
||||
<link rel="Shortcut Icon" href="<?php echo $favicon;?>" type="image/ico" />
|
||||
<link rel="icon" href="<?php echo $favicon;?>" type="image/ico" />
|
||||
|
||||
<script src="js/alternc.js" type="text/javascript" ></script>
|
||||
<script src="js/jquery.min_embedded.js" type="text/javascript"></script>
|
||||
|
|
|
@ -35,8 +35,9 @@ reset($_POST);
|
|||
while (list($key,$val)=each($_POST)) {
|
||||
if (substr($key,0,4)=="del_") {
|
||||
// Effacement du dossier $val
|
||||
$r=$hta->DelDir($val);
|
||||
if (!$r) {
|
||||
// $r=$hta->DelDir($val);
|
||||
$return = $hta->DelDir($val);
|
||||
if (!$return) {
|
||||
$error.= $err->errstr()."<br />";
|
||||
} else {
|
||||
$error.= sprintf(_("The protected folder %s has been successfully unprotected"),$val)."<br />";
|
||||
|
|
|
@ -143,7 +143,7 @@ class system_bind {
|
|||
*
|
||||
* @global m_dom $dom
|
||||
* @param string $domain
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
function get_domain_summary($domain=false) {
|
||||
global $dom;
|
||||
|
|
|
@ -863,27 +863,6 @@ function display_browser($dir="", $caller="main.dir", $width=350, $height=450) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Insere un $wrap_string tous les $max caracteres dans $message
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $max
|
||||
* @param string $wrap_string
|
||||
* @return string
|
||||
*/
|
||||
function auto_wrap($message="",$max=10,$wrap_string="<wbr/>") {
|
||||
$cpt = 0;
|
||||
$mot = split(" ",$message);
|
||||
while (isset($mot[$cpt]) && ($mot[$cpt] != "")){
|
||||
if(@strlen($mot[$cpt]) > $max){
|
||||
$nvmot = chunk_split ($mot[$cpt], $max, $wrap_string );
|
||||
$message = str_replace($mot[$cpt], $nvmot, $message);
|
||||
}
|
||||
$cpt++;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts HSV to RGB values
|
||||
* -----------------------------------------------------
|
||||
|
|
|
@ -50,7 +50,7 @@ class m_action {
|
|||
function do_action() {
|
||||
global $err, $L_INOTIFY_DO_ACTION;
|
||||
$err->log("action", "do_action");
|
||||
if( ! touch($L_INOTIFY_DO_ACTION) ){
|
||||
if( ! @touch($L_INOTIFY_DO_ACTION) ){
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -569,11 +569,11 @@ class m_admin {
|
|||
* @param int $duration
|
||||
* @param string $notes
|
||||
* @param integer $force
|
||||
* @param boolean $create_dom
|
||||
* @param string $create_dom
|
||||
* @param int $db_server_id
|
||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||
*/
|
||||
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) {
|
||||
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom='', $db_server_id) {
|
||||
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks,$action;
|
||||
$err->log("admin","add_mem",$login."/".$mail);
|
||||
if (!$this->enabled) {
|
||||
|
@ -1135,7 +1135,7 @@ EOF;
|
|||
function checkalldom() {
|
||||
global $db,$L_NS1,$L_NS2,$L_MX,$L_PUBLIC_IP;
|
||||
$checked=array();
|
||||
$r=$db->query("SELECT * FROM domaines ORDER BY domaine;");
|
||||
$db->query("SELECT * FROM domaines ORDER BY domaine;");
|
||||
$dl=array();
|
||||
while ($db->next_record()) {
|
||||
$dl[$db->Record["domaine"]]=$db->Record;
|
||||
|
@ -1179,6 +1179,9 @@ EOF;
|
|||
// Check the IP:
|
||||
$out=array();
|
||||
exec("dig +short A ".escapeshellarg($d["sub"].(($d["sub"]!="")?".":"").$c["domaine"]),$out);
|
||||
if (! is_array($out)) { // exec dig can fail
|
||||
$errno=1; $errstr.="Fail to get the DNS information. Try again.\n";
|
||||
} else {
|
||||
if (!in_array($L_PUBLIC_IP,$out)) {
|
||||
$errstr.="subdomain '".$d["sub"]."' don't point to $L_PUBLIC_IP but to ".implode(",",$out)."\n";
|
||||
$errno=1;
|
||||
|
@ -1186,6 +1189,7 @@ EOF;
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dontexist) {
|
||||
$errno=2;
|
||||
$errstr="Domain don't exist anymore !";
|
||||
|
@ -1362,7 +1366,6 @@ EOF;
|
|||
global $db,$classes,$hooks;
|
||||
$tmp1=array();
|
||||
$tmp2=array();
|
||||
$tmp3=array();
|
||||
$policies=array();
|
||||
$db->query("SELECT * FROM policy;");
|
||||
while ($db->next_record()) {
|
||||
|
|
|
@ -100,8 +100,8 @@ class m_bro {
|
|||
* @global m_mem $mem
|
||||
* @param string $dir Dossier absolu que l'on souhaite vérifier
|
||||
* @param integer $strip
|
||||
* @return false|string Retourne le nom du dossier vrifi, relatif au
|
||||
* dossier de l'utilisateur courant, ventuellement corrig.
|
||||
* @return false|string Retourne le nom du dossier vérifié, relatif au
|
||||
* dossier de l'utilisateur courant, éventuellement corrigé.
|
||||
* ou FALSE si le dossier n'est pas dans le dossier de l'utilisateur.
|
||||
*/
|
||||
function convertabsolute($dir,$strip = 1) {
|
||||
|
@ -260,10 +260,14 @@ class m_bro {
|
|||
*/
|
||||
function SetPrefs($editsizex, $editsizey, $listmode, $showicons, $downfmt, $createfile, $showtype, $editor_font, $editor_size, $golastdir) {
|
||||
global $db,$cuid;
|
||||
$editsizex=intval($editsizex); $editsizey=intval($editsizey);
|
||||
$listmode=intval($listmode); $showicons=intval($showicons);
|
||||
$showtype=intval($showtype); $downfmt=intval($downfmt);
|
||||
$createfile=intval($createfile); $golastdir=intval($golastdir);
|
||||
$editsizex = intval($editsizex);
|
||||
$editsizey = intval($editsizey);
|
||||
$listmode = intval($listmode);
|
||||
$showicons = intval($showicons);
|
||||
$showtype = intval($showtype);
|
||||
$downfmt = intval($downfmt);
|
||||
$createfile = intval($createfile);
|
||||
$golastdir = intval($golastdir);
|
||||
$db->query("SELECT * FROM browser WHERE uid = '".intval($cuid)."';");
|
||||
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, '".intval($cuid)."','Arial, Helvetica, Sans-serif','12px',1);");
|
||||
|
|
|
@ -435,7 +435,7 @@ class m_dom {
|
|||
$this->lock();
|
||||
|
||||
// function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="")
|
||||
if (! $this->add_domain($domain, true, false, 1) ) {
|
||||
if (! $this->add_domain($domain, true, false, true) ) {
|
||||
$err->raise('dom', "Error adding domain");
|
||||
return false;
|
||||
}
|
||||
|
@ -646,13 +646,13 @@ class m_dom {
|
|||
* appellée lors de l'installation d'un nouveau domaine.</p>
|
||||
*
|
||||
* @param string $dom nom fqdn du domaine à installer
|
||||
* @param integer $dns 1 ou 0 pour héberger le DNS du domaine ou pas.
|
||||
* @param integer $noerase 1 ou 0 pour rendre le domaine inamovible ou non
|
||||
* @param integer $force 1 ou 0, si 1, n'effectue pas les tests de DNS.
|
||||
* @param boolean $dns 1 ou 0 pour héberger le DNS du domaine ou pas.
|
||||
* @param boolean $noerase 1 ou 0 pour rendre le domaine inamovible ou non
|
||||
* @param boolean $force 1 ou 0, si 1, n'effectue pas les tests de DNS.
|
||||
* force ne devrait être utilisé que par le super-admin.
|
||||
$ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*/
|
||||
function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") {
|
||||
function add_domain($domain,$dns,$noerase=false,$force=false,$isslave=false,$slavedom="") {
|
||||
global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro,$hooks;
|
||||
$err->log("dom","add_domain",$domain);
|
||||
|
||||
|
@ -1608,6 +1608,10 @@ class m_dom {
|
|||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_domain_all_summary() {
|
||||
global $db,$err;
|
||||
$res=array();
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
class m_hta {
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -50,11 +49,17 @@ class m_hta {
|
|||
|
||||
/**
|
||||
* Password kind used in this class (hook for admin class)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function alternc_password_policy() {
|
||||
return array("hta"=>"Protected folders passwords");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function hook_menu() {
|
||||
$obj = array(
|
||||
'title' => _("Protected folders"),
|
||||
|
@ -67,11 +72,16 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Create a protected folder (.htaccess et .htpasswd)
|
||||
* @param string $dir Folder to protect (relative to user root)
|
||||
* @return boolean TRUE if the folder has been protected, or FALSE if an error occurred
|
||||
*
|
||||
* @global m_mem $mem
|
||||
* @global m_bro $bro
|
||||
* @global m_err $err
|
||||
* @param string $dir
|
||||
* @return boolean
|
||||
*/
|
||||
function CreateDir($dir) {
|
||||
global $mem,$bro,$err;
|
||||
|
@ -110,12 +120,13 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Returns the list of all user folder currently protected by a .htpasswd file
|
||||
*
|
||||
* @global m_err $err
|
||||
* @global m_mem $mem
|
||||
* @return array Array containing user folder list
|
||||
*/
|
||||
|
||||
function ListDir(){
|
||||
global$err,$mem;
|
||||
$err->log("hta","listdir");
|
||||
|
@ -137,11 +148,13 @@ class m_hta {
|
|||
return $r;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Tells if a folder is protected.
|
||||
*
|
||||
* @global m_mem $mem
|
||||
* @global m_err $err
|
||||
* @param string $dir Folder to check
|
||||
* @return boolean if the folder is protected, or FALSE if it is not
|
||||
* @return boolean If the folder is protected, or FALSE if it is not
|
||||
*/
|
||||
function is_protected($dir){
|
||||
global $mem,$err;
|
||||
|
@ -155,9 +168,11 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Returns the list of login for a protected folder.
|
||||
*
|
||||
* @global m_mem $mem
|
||||
* @global m_err $err
|
||||
* @param string $dir The folder to lookup (relative to user root)
|
||||
* @return array An array containing the list of logins from the .htpasswd file, or FALSE
|
||||
*/
|
||||
|
@ -176,7 +191,7 @@ class m_hta {
|
|||
if (!$file) {
|
||||
return false;
|
||||
}
|
||||
// TODO: Tester la validit<EFBFBD> du .htpasswd
|
||||
// TODO: Tester la validité du .htpasswd
|
||||
while (!feof($file)) {
|
||||
$s = fgets($file,1024);
|
||||
$t = explode(":",$s);
|
||||
|
@ -190,35 +205,79 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Unprotect a folder
|
||||
*
|
||||
* @global m_mem $mem
|
||||
* @global m_bro $bro
|
||||
* @global m_err $err
|
||||
* @param string $dir Folder to unprotect, relative to user root
|
||||
* @param boolean $skip For testing purpose mainly, skips the full user path search
|
||||
* @return boolean TRUE if the folder has been unprotected, or FALSE if an error occurred
|
||||
*/
|
||||
function DelDir($dir) {
|
||||
function DelDir($dir,$skip = 0) {
|
||||
global $mem,$bro,$err;
|
||||
$err->log("hta","deldir",$dir);
|
||||
$dir=$bro->convertabsolute($dir,0);
|
||||
$dir = $bro->convertabsolute($dir,$skip);
|
||||
if (!$dir) {
|
||||
$err->raise("hta",printf(("The folder '%s' does not exist"),$dir));
|
||||
return false;
|
||||
}
|
||||
if (!@unlink("$dir/.htaccess")) {
|
||||
$err->raise("hta",printf(_("I cannot delete the file '%s/.htaccess'"),$dir));
|
||||
return false;
|
||||
$htaccess_file = "$dir/.htaccess";
|
||||
if( !is_readable($htaccess_file)){
|
||||
$err->raise("hta",printf(_("I cannot read the file '%s'"),$htaccess_file));
|
||||
}
|
||||
if (!@unlink("$dir/.htpasswd")) {
|
||||
$fileLines = file($htaccess_file);
|
||||
$patternList = array(
|
||||
"AuthUserFile.*$",
|
||||
"AuthName.*$",
|
||||
"AuthType Basic.*$",
|
||||
"require valid-user.*$"
|
||||
);
|
||||
$count_lines = 0;
|
||||
foreach($fileLines as $key => $line){
|
||||
foreach ($patternList as $pattern) {
|
||||
if(preg_match("/".$pattern."/", $line)){
|
||||
$count_lines++;
|
||||
unset($fileLines[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If no changes
|
||||
if( ! $count_lines ){
|
||||
$err->raise("hta",printf(_("Unexpected: No changes made to '%s'"),$htaccess_file));
|
||||
}
|
||||
// If file is empty, remove it
|
||||
if( !count($fileLines)){
|
||||
if( ! unlink( $htaccess_file)){
|
||||
$err->raise("hta",printf(_("I could not delete the file '%s'"),$htaccess_file));
|
||||
}
|
||||
}else{
|
||||
file_put_contents($htaccess_file, implode("\n",$fileLines));
|
||||
}
|
||||
$htpasswd_file = "$dir/.htpasswd";
|
||||
$perms = substr(sprintf('%o', fileperms($dir)), -4);
|
||||
if( ! is_writable($htpasswd_file)){
|
||||
$err->raise("hta",printf(_("I cannot read the file '%s'"),$htpasswd_file));
|
||||
}
|
||||
else if ( ! unlink($htpasswd_file)) {
|
||||
$err->raise("hta",printf(_("I cannot delete the file '%s/.htpasswd'"),$dir));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Add a user to a protected folder
|
||||
*
|
||||
* @global m_err $err
|
||||
* @global m_bro $bro
|
||||
* @global m_admin $admin
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $dir
|
||||
* @param string $password The password to add (cleartext)
|
||||
* @param string $dir The folder we add it to (relative to user root).
|
||||
* @return boolean TRUE if the user has been added, or FALSE if an error occurred
|
||||
|
@ -276,9 +335,13 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
*/
|
||||
/**
|
||||
* Delete a user from a protected folder.
|
||||
*
|
||||
* @global m_bro $bro
|
||||
* @global m_err $err
|
||||
* @param array $lst An array with login to delete.
|
||||
* @param string $dir The folder, relative to user root, where we want to delete users.
|
||||
* @return boolean TRUE if users has been deleted, or FALSE if an error occurred.
|
||||
|
@ -316,14 +379,23 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Change the password of a user in a protected folder
|
||||
* @param string $user The users whose password should be changed
|
||||
* @param string $newpass The new password of this user
|
||||
* @param string $dir The folder, relative to user root, in which we will change a password
|
||||
* @return boolean TRUE if the password has been changed, or FALSE if an error occurred
|
||||
*/
|
||||
/**
|
||||
* Change the password of a user in a protected folder
|
||||
*
|
||||
* @global m_bro $bro
|
||||
* @global m_err $err
|
||||
* @global m_admin $admin
|
||||
* @param string $user
|
||||
* @param string $newpass
|
||||
* @param string $dir
|
||||
* @return boolean
|
||||
*/
|
||||
function change_pass($user,$newpass,$dir) {
|
||||
global $bro,$err,$admin;
|
||||
$err->log("hta","change_pass",$user."/".$dir);
|
||||
|
@ -363,14 +435,15 @@ class m_hta {
|
|||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Check that a .htaccess file is valid (for authentication)
|
||||
*
|
||||
* @global m_err $err
|
||||
* @param type $absolute
|
||||
* @param string $absolute Folder we want to check (relative to user root)
|
||||
* @return boolean TRUE is the .htaccess is protecting this folder, or FALSE else
|
||||
* @access private
|
||||
*/
|
||||
function _reading_htaccess($absolute) {
|
||||
private function _reading_htaccess($absolute) {
|
||||
global $err;
|
||||
$err->log("hta","_reading_htaccess",$absolute);
|
||||
$file = fopen("$absolute/.htaccess","r+");
|
||||
|
|
|
@ -669,6 +669,7 @@ ORDER BY
|
|||
$db->query("UPDATE mailbox SET quota=".intval($quotamb)." WHERE address_id=".$mail_id.";");
|
||||
}
|
||||
|
||||
$recipients=preg_replace('/[\r\t\s]/', "\n", $recipients); // Handle space AND new line
|
||||
$r=explode("\n",$recipients);
|
||||
$red="";
|
||||
foreach($r as $m) {
|
||||
|
|
|
@ -372,7 +372,7 @@ class m_variables {
|
|||
$output = "";
|
||||
if (isset($tab[$strata][$id][$varname]['value'])) {
|
||||
$v = $tab[$strata][$id][$varname]['value'];
|
||||
$output .= $this->display_valueraw_html($v, $varname);
|
||||
$output .= $this->display_valueraw_html($v, $varname, false);
|
||||
} else {
|
||||
$output .= "<em>"._("None defined")."</em>";
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1,2 +1,2 @@
|
|||
alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh, /usr/lib/alternc/mem_add, /usr/lib/alternc/mem_del, /usr/lib/alternc/quota_edit, /usr/lib/alternc/quota_get, /usr/lib/alternc/du.pl, /usr/lib/alternc/update_mails.sh
|
||||
alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh, /usr/lib/alternc/mem_add, /usr/lib/alternc/mem_del, /usr/lib/alternc/quota_edit, /usr/lib/alternc/quota_get, /usr/lib/alternc/du.pl, /usr/lib/alternc/update_mails.sh, /usr/sbin/repquota
|
||||
vmail ALL = NOPASSWD : /usr/lib/dovecot/deliver
|
||||
|
|
|
@ -216,14 +216,13 @@ CREATE TABLE IF NOT EXISTS sub_domaines (
|
|||
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
compte int(10) unsigned NOT NULL default '0',
|
||||
domaine varchar(255) NOT NULL default '',
|
||||
sub varchar(100) NOT NULL default '',
|
||||
sub varchar(255) NOT NULL default '',
|
||||
valeur varchar(255) default NULL,
|
||||
type varchar(30) NOT NULL default 'LOCAL',
|
||||
web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE',
|
||||
web_result varchar(255) not null default '',
|
||||
enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (compte,domaine,sub,type,valeur)
|
||||
PRIMARY KEY (id)
|
||||
-- ,FOREIGN KEY (type) REFERENCES (domaines_type)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
|
@ -716,8 +715,7 @@ CREATE TABLE IF NOT EXISTS `default_subdomains` (
|
|||
`domain_type_parameter` varchar(255) NOT NULL,
|
||||
`concerned` enum('BOTH','MAIN','SLAVE') NOT NULL DEFAULT 'MAIN',
|
||||
`enabled` boolean not null default true,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_row` (`sub`,`domain_type`,`domain_type_parameter`,`concerned`)
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM COMMENT='Contains the defaults subdomains created on domains creation';
|
||||
|
||||
INSERT IGNORE INTO `default_subdomains` (`sub`, `domain_type`, `domain_type_parameter`, `concerned`) VALUES
|
||||
|
|
|
@ -156,4 +156,4 @@ $mem = new \m_mem();
|
|||
$err = new \m_err();
|
||||
$authip = new \m_authip();
|
||||
$hooks = new \m_hooks();
|
||||
|
||||
$bro = new \m_bro();
|
||||
|
|
|
@ -21,13 +21,24 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase
|
|||
* @return \PHPUnit_Extensions_Database_DataSet_YamlDataSet
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function loadDataSet($file_name)
|
||||
public function loadDataSet($fileList)
|
||||
{
|
||||
if (empty($fileList)) {
|
||||
throw new \Exception("No files specified");
|
||||
}
|
||||
if( !is_array($fileList)){
|
||||
$fileList = array($fileList);
|
||||
}
|
||||
$datasetList = array();
|
||||
foreach ($fileList as $file_name) {
|
||||
$file = PHPUNIT_DATASETS_PATH."/$file_name";
|
||||
if( !is_file($file) ){
|
||||
throw new \Exception("missing $file");
|
||||
}
|
||||
$dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file);
|
||||
$datasetList[] = $dataSet;
|
||||
}
|
||||
$compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList);
|
||||
return $dataSet;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
domaines:
|
||||
-
|
||||
id : 1
|
||||
compte : 2001
|
||||
domaine : example.tld
|
||||
gesdns : 1
|
||||
gesmx : 1
|
||||
noerase : 0
|
||||
dns_action : OK
|
||||
dns_result : 0
|
||||
zonettl : 86400
|
|
@ -1,6 +1,6 @@
|
|||
membres:
|
||||
-
|
||||
uid : 0
|
||||
uid : 2000
|
||||
login : admin
|
||||
pass : admin
|
||||
enabled : 1
|
||||
|
@ -11,6 +11,7 @@ membres:
|
|||
lastfail : 0
|
||||
lastip : 127.0.0.1
|
||||
-
|
||||
uid : 2001
|
||||
login : phpunit
|
||||
pass : phpunit
|
||||
enabled : 1
|
||||
|
|
|
@ -9,6 +9,9 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
|||
*/
|
||||
protected $object;
|
||||
|
||||
const PATH_HTACCESS = "/tmp/.htaccess";
|
||||
const PATH_HTPASSWD = "/tmp/.htpasswd";
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
|
@ -16,6 +19,10 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
|||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
touch(self::PATH_HTACCESS);
|
||||
touch(self::PATH_HTPASSWD);
|
||||
$file_content = "AuthUserFile \"/tmp/.htpasswd\"\nAuthName \"Restricted area\"\nAuthType Basic\nrequire valid-user\n";
|
||||
file_put_contents(self::PATH_HTACCESS,$file_content);
|
||||
$this->object = new m_hta;
|
||||
}
|
||||
|
||||
|
@ -26,6 +33,12 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
|||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
if(file_exists(self::PATH_HTACCESS)){
|
||||
unlink (self::PATH_HTACCESS);
|
||||
}
|
||||
if(file_exists(self::PATH_HTPASSWD)){
|
||||
unlink (self::PATH_HTPASSWD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,14 +127,26 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @covers m_hta::DelDir
|
||||
* @todo Implement testDelDir().
|
||||
*/
|
||||
public function testDelDir()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$result = $this->object->DelDir("/tmp",TRUE);
|
||||
$this->assertTrue($result);
|
||||
$this->assertFileNotExists(self::PATH_HTACCESS);
|
||||
$this->assertFileNotExists(self::PATH_HTPASSWD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_hta::DelDir
|
||||
*/
|
||||
public function testDelDirNotEmpty()
|
||||
{
|
||||
file_put_contents(self::PATH_HTACCESS, "\nphpunit", FILE_APPEND);
|
||||
$result = $this->object->DelDir("/tmp",TRUE);
|
||||
$this->assertTrue($result);
|
||||
$this->assertFileExists(self::PATH_HTACCESS);
|
||||
$this->assertFileNotExists(self::PATH_HTPASSWD);
|
||||
$this->assertTrue("phpunit" == trim(file_get_contents(self::PATH_HTACCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58.
|
||||
*/
|
||||
class m_mailTest extends PHPUnit_Framework_TestCase
|
||||
class m_mailTest extends AlterncTest
|
||||
{
|
||||
/**
|
||||
* @var m_mail
|
||||
|
@ -19,6 +19,15 @@ class m_mailTest extends PHPUnit_Framework_TestCase
|
|||
$this->object = new m_mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
public function getDataSet()
|
||||
{
|
||||
return parent::loadDataSet("domaines.yml");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
|
@ -310,10 +319,7 @@ class m_mailTest extends PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testCreate_alias()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
// Test #1580
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ then
|
|||
# cp -f /etc/alternc/templates/roundcube/avelsieve-config.php /etc/alternc/templates/roundcube/apache.conf /etc/roundcube/
|
||||
# cp -f /etc/alternc/templates/javascript-common/javascript-common.conf /etc/javascript-common/
|
||||
|
||||
LOGIN="2000_roundcube"
|
||||
LOGIN="0000_roundcube"
|
||||
PASSWORD="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)'`"
|
||||
DESKEY="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..24)'`"
|
||||
|
||||
|
@ -40,7 +40,6 @@ then
|
|||
# Configuration template location
|
||||
TEMPLATE_DIR="/etc/alternc/templates"
|
||||
CONFIG_FILES="etc/roundcube/main.inc.php etc/roundcube/plugins/password/config.inc.php etc/roundcube/plugins/managesieve/config.inc.php"
|
||||
LOGROTATE_FILES="etc/logrotate.d/roundcube-core"
|
||||
|
||||
cat > $SED_SCRIPT <<EOF
|
||||
s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\;
|
||||
|
@ -62,14 +61,6 @@ EOF
|
|||
|
||||
echo " Done"
|
||||
|
||||
for file in $LOGROTATE_FILES; do
|
||||
TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
|
||||
echo -n " $file"
|
||||
if [ -f "$TEMPLATE" ]; then
|
||||
cat $TEMPLATE > /$file
|
||||
fi
|
||||
done
|
||||
|
||||
echo " Done"
|
||||
|
||||
. /usr/lib/alternc/functions.sh
|
||||
|
@ -99,10 +90,3 @@ EOF
|
|||
|
||||
fi
|
||||
|
||||
#This is necessary because upgrading roundcube from 7.1 to 7.2 changes this setting
|
||||
if [ "$1" = "end" ]; then
|
||||
chown alternc-roundcube:root /etc/roundcube/main.inc.php
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<VirtualHost *:80>
|
||||
ServerName %%fqdn%%
|
||||
AssignUserId alternc-roundcube nogroup
|
||||
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
|
||||
AssignUserId www-data www-data
|
||||
SetEnv LOGIN "0000-roundcube"
|
||||
|
||||
DocumentRoot /var/lib/roundcube
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
######
|
||||
# Configuration file of Roundcube's logrotate for AlternC
|
||||
#
|
||||
# /!\ WARNING /!\ Do not edit this file, edit the one in
|
||||
# /etc/alternc/templates/logrotate.d/ and launch alternc.install again.
|
||||
######
|
||||
|
||||
/var/log/roundcube/password /var/log/roundcube/errors /var/log/roundcube/sendmail /var/log/roundcube/userlogins {
|
||||
create 0640 alternc-roundcube root
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
rotate 52
|
||||
weekly
|
||||
}
|
|
@ -25,6 +25,8 @@ if ( $nb != 1 ){
|
|||
}
|
||||
|
||||
#we check that for that type only one option is specified
|
||||
# FIXME je doute que ca fasse un truc pertinent ce morceau
|
||||
$nb2=0;
|
||||
foreach($options as $opt => $val){
|
||||
$nb2=count($options[$opt]);
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ function FixQuotaDovecot($conditions){
|
|||
}
|
||||
|
||||
#We construct a sql query to get the mailbox root based on the option.
|
||||
// FIXME where does $opt come from ??
|
||||
switch($opt){
|
||||
case "m":
|
||||
if (!filter_var($val,FILTER_VALIDATE_EMAIL)) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
# List quotas of all users in 3 columns :
|
||||
# id used quota
|
||||
|
||||
source /etc/alternc/local.sh
|
||||
|
||||
#checking if quotas are installed
|
||||
command -v /usr/sbin/repquota >/dev/null || { echo "Quotas uninstalled"; exit 0; }
|
||||
|
||||
get_quota() {
|
||||
quotadir="$1"
|
||||
if [ "$quotadir" = "/" ] ; then
|
||||
sudo repquota -g -v -n -p "$quotadir" 2>/dev/null || (echo "Error: can't get quota"; exit 1)
|
||||
else
|
||||
sudo repquota -g -v -n -p "$quotadir" 2>/dev/null || get_quota "$(dirname $quotadir)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Some help : this is what we must parse
|
||||
# Block limits File limits
|
||||
#Group used soft hard grace used soft hard grace
|
||||
#----------------------------------------------------------------------
|
||||
#root -- 1612116 0 0 96181 0 0
|
||||
#adm -- 14532 0 0 226 0 0
|
||||
|
||||
get_quota "$ALTERNC_HTML" | egrep "^\#[0-9]+"|while read gid blank bused bsoft bhard bgrace fused fsoft fhard fgrace ; do
|
||||
echo ${gid/\#/} $bused $bhard
|
||||
done
|
||||
|
|
@ -6,12 +6,22 @@ require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
|||
global $db;
|
||||
|
||||
echo "\n---------------------------\n Generating size-cache for web accounts\n\n";
|
||||
$r=mysql_query("SELECT uid,login FROM membres;");
|
||||
while ($c=mysql_fetch_array($r)) {
|
||||
echo $c["login"]; flush();
|
||||
$size=exec("sudo /usr/lib/alternc/du.pl ".ALTERNC_HTML."/".substr($c["login"],0,1)."/".$c["login"]);
|
||||
$db->query("REPLACE INTO size_web SET uid='".$c["uid"]."',size='$size';");
|
||||
echo " done ($size KB) \n"; flush();
|
||||
exec("/usr/lib/alternc/quota_get_all", $list_quota_tmp);
|
||||
$list_quota=array();
|
||||
foreach ($list_quota_tmp as $qt) {
|
||||
$qt = explode(" ", $qt);
|
||||
$list_quota[$qt[0]] = array('used'=>$qt[1], 'quota'=>$qt[2]);
|
||||
}
|
||||
|
||||
if ($db->query("SELECT uid,login FROM membres;")) {
|
||||
$db2 = new DB_system();
|
||||
while ($db->next_record()) {
|
||||
if (isset($list_quota[$db->f('uid')])) {
|
||||
$qu=$list_quota[$db->f('uid')];
|
||||
$db2->query("INSERT OR REPLACE INTO size_web SET uid='".intval($db->f('uid'))."',size='".intval($qu['used'])."';");
|
||||
echo $db->f('login')." (".$qu['used']." B)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n---------------------------\n Generating size-cache for MySQL databases\n\n";
|
||||
|
|
Loading…
Reference in New Issue