Ticket #594: patch-594

File patch-594, 14.6 KB (added by nahuel, 7 years ago)

Voila les modifications :)

Line 
1Index: debian/prerm
2===================================================================
3--- debian/prerm        (revision 904)
4+++ debian/prerm        (working copy)
5@@ -16,9 +16,9 @@
6     rmdir -p /var/alternc/bureau 2> /dev/null || true
7     rm -f /var/alternc/dns/bureau
8     rm -f /var/alternc/dns/$FQDN_LETTER/$FQDN
9-    rmdir -p /var/alternc/html/r/root 2> /dev/null || true
10+    rmdir -p /var/alternc/html/a/admin 2> /dev/null || true
11     rm -f /var/alternc/apacheconf/override_php.conf
12-    rmdir -p /var/alternc/htm/r/root 2> /dev/null || true
13+    rmdir -p /var/alternc/htm/a/admin 2> /dev/null || true
14     ;;
15 
16 upgrade)
17Index: bureau/admin/mail_list.php
18===================================================================
19--- bureau/admin/mail_list.php  (revision 904)
20+++ bureau/admin/mail_list.php  (working copy)
21@@ -34,9 +34,8 @@
22 }
23 include("head.php");
24 
25-if(!$res=$mail->enum_doms_mails($domain,1)) {
26+if(!$res=$mail->enum_doms_mails($domain,1,$letter)) {
27   $error=$err->errstr();
28-
29 ?>
30 </head>
31 <body>
32@@ -45,7 +44,7 @@
33 if ($error) {
34   echo "<p class=\"error\">$error</p>";
35 }
36-echo "<p><a href=\"mail_add.php?domain=$domain\">".sprintf(_("Add a mailbox on <b>%s</b>"),$domain)."</a><br /";
37+echo "<p><a href=\"mail_add.php?domain=$domain\">".sprintf(_("Add a mailbox on <b>%s</b>"),$domain)."</a><br />";
38 echo "   <a href=\"mail_add.php?many=1&amp;domain=$domain\">".sprintf(_("Add many mailboxes on <b>%s</b>"),$domain)."</a></p>";
39 ?>
40 
41@@ -64,10 +63,23 @@
42   echo "<p class=\"error\">$error</p>";
43 }
44 
45-echo "<p><a href=\"mail_add.php?domain=$domain\">".sprintf(_("Add a mailbox on <b>%s</b>"),$domain)."</a><br /";
46+echo "<p><a href=\"mail_add.php?domain=$domain\">".sprintf(_("Add a mailbox on <b>%s</b>"),$domain)."</a><br />";
47 echo "   <a href=\"mail_add.php?many=1&amp;domain=$domain\">".sprintf(_("Add many mailboxes on <b>%s</b>"),$domain)."</a></p>";
48+
49+if(!$letters=$mail->enum_doms_mails_letters($domain))
50+  $error=$err->errstr();
51+else{
52+  for($i=0;$i<count($letters);$i++){
53+    $val=$letters[$i];
54+    echo "   <a href=\"mail_list.php?domain=$domain&amp;letter=$val\">$val&nbsp;</a></p>";
55+  }
56+  echo "   <a href=\"mail_list.php?domain=$domain\">".sprintf(_("All"))."</a></p>";
57+}
58+
59+
60 ?>
61 
62+
63 <form method="post" action="mail_dodel.php" id="main">
64 
65 <table cellspacing="0" cellpadding="4">
66Index: bureau/class/m_mail.php
67===================================================================
68--- bureau/class/m_mail.php     (revision 904)
69+++ bureau/class/m_mail.php     (working copy)
70@@ -73,7 +73,26 @@
71   }
72 
73   /* ----------------------------------------------------------------- */
74-  /** Retourne la liste des mails du domaine $dom
75+  /** Retourne la liste des lettres pour lesquelles un domaine $dom a
76+   * des e-mails
77+   * Retourne un tableau indexé où se trouvent les lettres
78+   * @param string $dom Domaine dont on veut les premières lettres des mails
79+  * @return array Tableau de lettres ou FALSE si erreur
80+   */
81+  function enum_doms_mails_letters($dom) {
82+    global $err,$cuid,$db;
83+    $err->log("mail","enum_doms_mails_letters",$dom);
84+    $db->query("SELECT LEFT(mail,1) as letter FROM mail_domain where uid='$cuid' AND type=0 and mail like '%@$dom' GROUP BY letter ORDER BY letter;");
85+    $res=array();
86+    while($db->next_record()) {
87+      $res[]=$db->f("letter");
88+    }
89+    return $res;
90+  }
91+
92+  /* ----------------------------------------------------------------- */
93+  /** Retourne la liste des mails du domaine $dom et si une lettre est
94+   * définie, cela retourne les mail qui commencent par celle ci
95    * Retourne un tableau indexé de tableaux associatifs sous la forme :
96    * $a["mail"]=Adresse email
97    * $a["pop"]=1 ou 0 selon s'il s'agit d'un compte pop ou pas
98@@ -83,10 +102,10 @@
99    * @return array Tableau de mails comme indiqué ci-dessus ou FALSE si une erreur
100    *  s'est produite
101    */
102-  function enum_doms_mails($dom,$sort=0) {
103+  function enum_doms_mails($dom,$sort=0,$letter="") {
104     global $err,$cuid,$db;
105     $err->log("mail","enum_doms_mails",$dom);
106-    $db->query("SELECT mail,pop,alias FROM mail_domain WHERE mail LIKE '%@$dom' AND uid='$cuid' AND type=0;");
107+    $db->query("SELECT mail,pop,alias FROM mail_domain WHERE mail LIKE '$letter%@$dom' AND uid='$cuid' AND type=0;");
108     $res=array(); $i=0;
109     while ($db->next_record()) {
110       if ($db->f("pop")) {
111Index: tools/get_domains_by_account
112===================================================================
113--- tools/get_domains_by_account        (revision 904)
114+++ tools/get_domains_by_account        (working copy)
115@@ -56,7 +56,7 @@
116 HELP=$($gettext "Gives domains and sub-domains attached to an account.")
117 USAGE=`$printf "$($gettext "Usage: %s account.")" $PROG_NAME`
118 NOT_FOUND_MSG=$($gettext "does not exist.")
119-NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.")
120+NON_ADMIN_MSG=$($gettext "You have to be admin (uid 0) to execute this program.")
121 MISSING_PROG=$($gettext "Unable to execute")
122 MISSING_CONF_FILE=`$printf "$($gettext "Can't find %s. Are you sure AlterncC is properly installed?")" $ALTERNC_CONF_FILE`
123 MYSQL_UNREACHABLE_DATABASE=`$printf "$($gettext "Cannot access accounts database. Please check either %s or Mysql state.")" $ALTERNC_CONF_FILE`
124@@ -65,8 +65,8 @@
125 #-------------------------
126 # Main
127 #-------------------------
128-# Must be root
129-[ "`$id -u`" != "0" ] && { echo $NON_ROOT_MSG ; exit 1 ; }
130+# Must be admin
131+[ "`$id -u`" != "0" ] && { echo $NON_ADMIN_MSG ; exit 1 ; }
132 # Must have minimum 1 parameter
133 [ -z "$1" ] && { echo $USAGE ; exit 1 ; }
134 # Handle -h and --help flags
135Index: tools/top_http_users
136===================================================================
137--- tools/top_http_users        (revision 904)
138+++ tools/top_http_users        (working copy)
139@@ -88,7 +88,7 @@
140        NON_COMPATIBLE_MSG=$($gettext "The -n and -z options are not compatible.")
141        NON_NUM_MSG_FOR_N=$($gettext "The -n option requieres a number as argument.")
142        LOCKFILE_CREATION_FAILED=`$printf "$($gettext "%s is allready beeing executed.")" $PROG_NAME`
143-       NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.")
144+       NON_ADMIN_MSG=$($gettext "You have to be admin (uid 0) to execute this program.")
145        MISSING_PROG=$($gettext "Unable to execute")
146        HIT_RES_MSG=`$printf "$($gettext "Top %s domains served by apache, sorted by number of lines in log (using gzipped logs: %s):")" $NB_USERS $($gettext "$USE_GZ_LOGS")`
147        SIZE_RES_MSG=`$printf "$($gettext "Top %s domains served by apache, sorted by size (using gzipped logs: %s):")" $NB_USERS $($gettext "$USE_GZ_LOGS")`
148@@ -123,8 +123,8 @@
149 # Main
150 #-------------------------
151 set_messages
152-# Must be root
153-[ "`$id -u`" -ne 0 ] && { echo $NON_ROOT_MSG ; exit 1 ; }
154+# Must be admin
155+[ "`$id -u`" -ne 0 ] && { echo $NON_ADMIN_MSG ; exit 1 ; }
156 
157 # Parse args
158 IS_N_PARAM=false
159Index: tools/top_mysql_users
160===================================================================
161--- tools/top_mysql_users       (revision 904)
162+++ tools/top_mysql_users       (working copy)
163@@ -86,7 +86,7 @@
164        NON_COMPATIBLE_MSG=$($gettext "The -n and -z options are not compatible.")
165        NON_NUM_MSG_FOR_N=$($gettext "The -n option requieres a number as argument.")
166        LOCKFILE_CREATION_FAILED=`$printf "$($gettext "%s is allready beeing executed.")" $PROG_NAME`
167-       NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.")
168+       NON_ADMIN_MSG=$($gettext "You have to be admin (uid 0) to execute this program.")
169        HIT_RES_MSG=`$printf "$($gettext "Top %s mysql users, sorted by connexion number (using gzipped logs: %s):")" $NB_USERS $($gettext "$USE_GZ_LOGS")`
170        MISSING_CONF_FILE=`$printf "$($gettext "Can't find %s. Are you sure AlterncC is properly installed?")" $ALTERNC_CONF_FILE`
171        UNKNOWN_OPTION=$($gettext "Unknown %s option.")
172@@ -109,8 +109,8 @@
173 # Main
174 #-------------------------
175 set_messages
176-# Must be root
177-[ "`$id -u`" != "0" ] && { echo $NON_ROOT_MSG ; exit 1 ; }
178+# Must be admin
179+[ "`$id -u`" != "0" ] && { echo $NON_ADMIN_MSG ; exit 1 ; }
180 
181 # Parse args
182 IS_N_PARAM=false
183Index: tools/get_account_by_domain
184===================================================================
185--- tools/get_account_by_domain (revision 904)
186+++ tools/get_account_by_domain (working copy)
187@@ -58,7 +58,7 @@
188 HELP=$($gettext "Gives account hosting domain or sub-domain.")
189 USAGE=`$printf "$($gettext "Usage: %s [domain|sub-domain].")" $PROG_NAME`
190 NOT_FOUND_MSG=$($gettext "does not exist.")
191-NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.")
192+NON_ADMIN_MSG=$($gettext "You have to be admin (uid 0) to execute this program.")
193 MISSING_PROG=$($gettext "Unable to execute")
194 MISSING_CONF_FILE=`$printf "$($gettext "Can't find %s. Are you sure AlterncC is properly installed?")" $ALTERNC_CONF_FILE`
195 MYSQL_UNREACHABLE_DATABASE=`$printf "$($gettext "Cannot access accounts database. Please check either %s or Mysql state.")" $ALTERNC_CONF_FILE`
196@@ -67,8 +67,8 @@
197 #-------------------------
198 # Main
199 #-------------------------
200-# Must be root
201-[ "`$id -u`" != "0" ] && { echo $NON_ROOT_MSG ; exit 1 ; }
202+# Must be admin
203+[ "`$id -u`" != "0" ] && { echo $NON_ADMIN_MSG ; exit 1 ; }
204 # Must have minimum 1 parameter
205 [ -z "$1" ] && { echo $USAGE ; exit 1 ; }
206 # Handle -h and --help flags
207Index: tools/top_ftp_users
208===================================================================
209--- tools/top_ftp_users (revision 904)
210+++ tools/top_ftp_users (working copy)
211@@ -87,7 +87,7 @@
212        NON_COMPATIBLE_MSG=$($gettext "The -n and -z options are not compatible.")
213        NON_NUM_MSG_FOR_N=$($gettext "The -n option requieres a number as argument.")
214        LOCKFILE_CREATION_FAILED=`$printf "$($gettext "%s is allready beeing executed.")" $PROG_NAME`
215-       NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.")
216+       NON_ADMIN_MSG=$($gettext "You have to be admin (uid 0) to execute this program.")
217        HIT_RES_MSG=`$printf "$($gettext "Top %s ftp users, sorted by connection number (using gzipped logs: %s):")" $NB_USERS $($gettext "$USE_GZ_LOGS")`
218        SIZE_RES_MSG=`$printf "$($gettext "Top %s ftp users, sorted by size (using gzipped logs: %s):")" $NB_USERS $($gettext "$USE_GZ_LOGS")`
219        MISSING_CONF_FILE=`$printf "$($gettext "Can't find %s. Are you sure AlterncC is properly installed?")" $ALTERNC_CONF_FILE`
220@@ -112,8 +112,8 @@
221 # Main
222 #-------------------------
223 set_messages
224-# Must be root
225-[ "`$id -u`" != "0" ] && { echo $NON_ROOT_MSG ; exit 1 ; }
226+# Must be admin
227+[ "`$id -u`" != "0" ] && { echo $NON_ADMIN_MSG ; exit 1 ; }
228 
229 # Parse args
230 IS_N_PARAM=false
231Index: TODO
232===================================================================
233--- TODO        (revision 904)
234+++ TODO        (working copy)
235@@ -22,8 +22,8 @@
236 
237 ** Utilisation d'AlternC : (sans développement)
238 - Documentation utilisateur d'AlternC (pour ceux qui utilisent bêtement la bête en tant qu'utilisateur sans privilege)
239-- Documentation Administrateur AlternC (pour ceux qui utilisent bêtement un compte root d'AlternC)
240-- Documentation du mainteneur de serveur (pour ceux qui sont root sur le serveur)
241+- Documentation Administrateur AlternC (pour ceux qui utilisent bêtement un compte admin d'AlternC)
242+- Documentation du mainteneur de serveur (pour ceux qui sont admin sur le serveur)
243 - Documentation de l'API (pour ceux qui veulent pouvoir personnaliser leur bureau, le piloter à distance etc.)
244 
245 ** Développement d'AlternC :
246Index: install/newone.php
247===================================================================
248--- install/newone.php  (revision 904)
249+++ install/newone.php  (working copy)
250@@ -37,17 +37,17 @@
251 $admin->enabled=1;
252 
253 // On crée le compte admin :
254-if (!$admin->add_mem("root","root","Administrateur", "Admin", "root@".$L_FQDN)) {
255+if (!$admin->add_mem("admin","admin","Administrateur", "Admin", "postmaster@".$L_FQDN)) {
256        echo $err->errstr()."\n";
257        exit();
258 }
259 
260-$db->query("update membres set su=1 where login='root';");
261+$db->query("update membres set su=1 where login='admin';");
262 
263 // On lui attribue des quotas par defaut
264 // 10 domains, 10 stats, 10 bases mysql, 20 ftp et 100 emails
265-$db->query("update quotas,membres set quotas.total=10 where (quotas.name='stats' or quotas.name='sta2' or quotas.name='mysql' or quotas.name='dom') and quotas.uid=membres.uid and membres.login='root' ;");
266-$db->query("update quotas,membres set quotas.total=20 where quotas.name='ftp' and quotas.uid=membres.uid and membres.login='root' ;");
267-$db->query("update quotas,membres set quotas.total=100 where quotas.name='mail' and quotas.uid=membres.uid and membres.login='root' ;");
268+$db->query("update quotas,membres set quotas.total=10 where (quotas.name='stats' or quotas.name='sta2' or quotas.name='mysql' or quotas.name='dom') and quotas.uid=membres.uid and membres.login='admin' ;");
269+$db->query("update quotas,membres set quotas.total=20 where quotas.name='ftp' and quotas.uid=membres.uid and membres.login='admin' ;");
270+$db->query("update quotas,membres set quotas.total=100 where quotas.name='mail' and quotas.uid=membres.uid and membres.login='admin' ;");
271 
272 ?>
273Index: install/reset_root.php
274===================================================================
275--- install/reset_root.php      (revision 904)
276+++ install/reset_root.php      (working copy)
277@@ -36,8 +36,8 @@
278 // On passe super-admin
279 $admin->enabled=1;
280 
281-// On remet le pass root a zero
282-if (!$admin->update_mem(2000,"root@".$L_FQDN,"Administrateur", "Admin", 'root', 1, 1)) {
283+// On remet le pass admin a zero
284+if (!$admin->update_mem(2000,"postmaster@".$L_FQDN,"Administrateur", "Admin", 'admin', 1, 1)) {
285        echo "erreur : ".$err->errstr()."<br>\n";
286        exit();
287 }
288Index: install/alternc.install
289===================================================================
290--- install/alternc.install     (revision 904)
291+++ install/alternc.install     (working copy)
292@@ -209,18 +209,18 @@
293 # Add basedir protection
294 /usr/lib/alternc/basedir_prot.sh
295 
296-# Creating root user if needed
297-HAS_ROOT="`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'root'" | tail -1`"
298+# Creating admin user if needed
299+HAS_ROOT="`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'admin'" | tail -1`"
300 if [ "$HAS_ROOT" != "1" ]; then
301-    echo "Creating root user..."
302+    echo "Creating admin user..."
303     su - www-data -c /usr/share/alternc/install/newone.php
304     echo ""
305     echo "*******************************************"
306     echo "*                                         *"
307-    echo "*               Root account              *"
308+    echo "*               Admin account             *"
309     echo "*               ------------              *"
310     echo "*                                         *"
311-    echo "* user: root               password: root *"
312+    echo "* user: admin             password: admin *"
313     echo "*                                         *"
314     echo "* Please change this as soon as possible! *"
315     echo "*                                         *"