From 938fcba146de8ac0dee11f4ded3297ed7ce03ea6 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Mon, 18 Feb 2013 10:01:28 +0000 Subject: [PATCH] Adieu, menulist.txt ! Bonjour, menu avec des hooks magique dans les classes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus simple à gérer pour modifier le html, plus facile à surcharger dans l'optique de permettre de mettre des préférences. Active se souvenir pour la session des préférences de menu. Passe le stockage dans la session de php serialize à json --- .gitattributes | 17 ----- awstats/bureau/class/m_aws.php | 10 +++ bureau/admin/adm_menulist.php | 120 -------------------------------- bureau/admin/adm_panel.php | 1 - bureau/admin/js/alternc.js | 2 +- bureau/admin/main.php | 2 +- bureau/admin/menu.php | 84 ++++++++++++++++------ bureau/admin/menu_adm.php | 53 -------------- bureau/admin/menu_aide.php | 31 --------- bureau/admin/menu_brouteur.php | 32 --------- bureau/admin/menu_cron.php | 40 ----------- bureau/admin/menu_dom.php | 53 -------------- bureau/admin/menu_ftp.php | 48 ------------- bureau/admin/menu_ip.php | 34 --------- bureau/admin/menu_lang.php | 15 ---- bureau/admin/menu_logs.php | 37 ---------- bureau/admin/menu_mail.php | 55 --------------- bureau/admin/menu_mem.php | 36 ---------- bureau/admin/menu_piwik.php | 42 ----------- bureau/admin/menu_quota.php | 81 --------------------- bureau/admin/menu_sql.php | 43 ------------ bureau/admin/menu_web.php | 33 --------- bureau/class/config.php | 2 +- bureau/class/m_admin.php | 68 ++++++++++++++++++ bureau/class/m_authip.php | 11 +++ bureau/class/m_bro.php | 12 ++++ bureau/class/m_cron.php | 10 +++ bureau/class/m_dom.php | 32 +++++++++ bureau/class/m_ftp.php | 43 ++++++++++-- bureau/class/m_hta.php | 11 +++ bureau/class/m_log.php | 11 +++ bureau/class/m_mail.php | 20 ++++++ bureau/class/m_mem.php | 18 +++-- bureau/class/m_mysql.php | 34 +++++++++ bureau/class/m_piwik.php | 16 +++++ bureau/class/m_quota.php | 22 ++++++ debian/alternc-awstats.postinst | 9 --- debian/alternc-awstats.postrm | 5 -- debian/alternc.preinst | 7 -- etc/alternc/menulist.txt | 14 ---- 40 files changed, 373 insertions(+), 841 deletions(-) delete mode 100644 bureau/admin/adm_menulist.php delete mode 100644 bureau/admin/menu_adm.php delete mode 100644 bureau/admin/menu_aide.php delete mode 100644 bureau/admin/menu_brouteur.php delete mode 100644 bureau/admin/menu_cron.php delete mode 100644 bureau/admin/menu_dom.php delete mode 100644 bureau/admin/menu_ftp.php delete mode 100644 bureau/admin/menu_ip.php delete mode 100644 bureau/admin/menu_lang.php delete mode 100644 bureau/admin/menu_logs.php delete mode 100644 bureau/admin/menu_mail.php delete mode 100644 bureau/admin/menu_mem.php delete mode 100644 bureau/admin/menu_piwik.php delete mode 100644 bureau/admin/menu_quota.php delete mode 100644 bureau/admin/menu_sql.php delete mode 100644 bureau/admin/menu_web.php delete mode 100644 etc/alternc/menulist.txt diff --git a/.gitattributes b/.gitattributes index d825f9d9..9eba31e9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -78,7 +78,6 @@ bureau/admin/adm_edit.php -text bureau/admin/adm_email.php -text bureau/admin/adm_list.php -text bureau/admin/adm_login.php -text -bureau/admin/adm_menulist.php -text bureau/admin/adm_mxaccount.php -text bureau/admin/adm_panel.php -text bureau/admin/adm_passpolicy.php -text @@ -310,21 +309,6 @@ bureau/admin/mem_logout.php -text bureau/admin/mem_param.php -text bureau/admin/mem_passwd.php -text bureau/admin/menu.php -text -bureau/admin/menu_adm.php -text -bureau/admin/menu_aide.php -text -bureau/admin/menu_brouteur.php -text -bureau/admin/menu_cron.php -text -bureau/admin/menu_dom.php -text -bureau/admin/menu_ftp.php -text -bureau/admin/menu_ip.php -text -bureau/admin/menu_lang.php -text -bureau/admin/menu_logs.php -text -bureau/admin/menu_mail.php -text -bureau/admin/menu_mem.php -text -bureau/admin/menu_piwik.php -text -bureau/admin/menu_quota.php -text -bureau/admin/menu_sql.php -text -bureau/admin/menu_web.php -text bureau/admin/mxlist.php -text bureau/admin/nowebmail.php -text bureau/admin/phpinfo.php -text @@ -481,7 +465,6 @@ etc/alternc/apache2.conf -text etc/alternc/apache_logformat.conf -text etc/alternc/dbusers.cnf.sample -text etc/alternc/functions_hosting/hosting_massvhost.sh -text -etc/alternc/menulist.txt -text etc/alternc/phpmyadmin.inc.php -text etc/alternc/postfix-slave.cf -text etc/alternc/postfix.cf -text diff --git a/awstats/bureau/class/m_aws.php b/awstats/bureau/class/m_aws.php index ec8853be..6426bf1c 100644 --- a/awstats/bureau/class/m_aws.php +++ b/awstats/bureau/class/m_aws.php @@ -54,6 +54,16 @@ class m_aws { function m_aws() { } + function hook_menu() { + $obj = array( + 'title' => _("Web Statistics"), + 'ico' => 'images/stat.png', + 'link' => 'aws_list.php', + 'pos' => 80, + ) ; + + return $obj; + } /* ----------------------------------------------------------------- */ /** diff --git a/bureau/admin/adm_menulist.php b/bureau/admin/adm_menulist.php deleted file mode 100644 index 1d8b7362..00000000 --- a/bureau/admin/adm_menulist.php +++ /dev/null @@ -1,120 +0,0 @@ - - -

-
- _("Domains"), - "menu_adm" => _("Administration"), - "menu_mail" => _("Email Addresses"), - "menu_brouteur" => _("File browser"), - "menu_web" => _("Protected folders"), - "menu_ftp" => _("FTP accounts"), - "menu_cron" => _("Scheduled tasks"), - "menu_sql" => _("Databases"), - "menu_quota" => _("Show my quotas"), - "menu_ip" => _("Access security"), - "menu_logs" => _("Logs"), - "menu_aide" => _("Online help"), - "menu_lang" => _("Languages"), - "menu_mem" => _("Settings"), - "menu_piwik" => _("Piwik statistics"), - "menu_admin" => _("Administration"), - "menu_mailman" => _("Mailing lists"), - "menu_aws" => _("Web Statistics"), - ); - -function tr($name) { - global $menus; - $name=basename($name,".php"); - if (isset($menus[$name])) return $menus[$name]; - else return _("Module")." ".$name; -} - -$menu_diff=array_diff($menu_available,$menu_activated); - -__("Edit the file /etc/alternc/menulist.txt to enable, disable ou change order of menu entry."); -?> -

- -

- -

- - - - diff --git a/bureau/admin/adm_panel.php b/bureau/admin/adm_panel.php index 4c09a36f..d1cdc742 100644 --- a/bureau/admin/adm_panel.php +++ b/bureau/admin/adm_panel.php @@ -67,7 +67,6 @@ if (isset($error) && $error) {
  • -
  •  Refresh"); + $("#"+id).html(" Refresh"); $("#inp"+id).focus(); $("#inp"+id).select(); if (field1 != "") { $(field1).val( $("#inp"+id).val() ); } diff --git a/bureau/admin/main.php b/bureau/admin/main.php index e37b6b2c..a762fc48 100644 --- a/bureau/admin/main.php +++ b/bureau/admin/main.php @@ -83,7 +83,7 @@ echo "
    "; if($admin->enabled) { $expiring = $admin->renew_get_expiring_accounts(); - if(count($expiring) > 0) { + if(!empty($expiring) ) { echo "

    " . _("Expired or about to expire accounts") . "

    \n"; echo "\n"; echo "\n"; diff --git a/bureau/admin/menu.php b/bureau/admin/menu.php index e031874f..7b5f57b5 100644 --- a/bureau/admin/menu.php +++ b/bureau/admin/menu.php @@ -33,21 +33,72 @@ require_once("../class/config.php"); "/>

    user["login"]); ?>

    -getquota("",true); // rebuild quota -$MENUPATH=ALTERNC_PANEL."/admin/"; -$file=file("/etc/alternc/menulist.txt", FILE_SKIP_EMPTY_LINES); -foreach($file as $v) { - $v=trim($v); - if ( file_exists($MENUPATH.$v)) include($MENUPATH.$v); +$obj_menu = $menu->getmenu(); + +foreach ($obj_menu as $k => $m ) { + echo ""; + if (! $m['visibility']) echo "\n"; + } + ?>

    "/>
    @@ -56,13 +107,4 @@ echo "$L_VERSION"; ?>

    - - - diff --git a/bureau/admin/menu_adm.php b/bureau/admin/menu_adm.php deleted file mode 100644 index 960afd3e..00000000 --- a/bureau/admin/menu_adm.php +++ /dev/null @@ -1,53 +0,0 @@ -checkRight()) { ?> - - diff --git a/bureau/admin/menu_aide.php b/bureau/admin/menu_aide.php deleted file mode 100644 index 4f72c01b..00000000 --- a/bureau/admin/menu_aide.php +++ /dev/null @@ -1,31 +0,0 @@ - - diff --git a/bureau/admin/menu_brouteur.php b/bureau/admin/menu_brouteur.php deleted file mode 100644 index 2904636d..00000000 --- a/bureau/admin/menu_brouteur.php +++ /dev/null @@ -1,32 +0,0 @@ - - diff --git a/bureau/admin/menu_cron.php b/bureau/admin/menu_cron.php deleted file mode 100644 index c9933b30..00000000 --- a/bureau/admin/menu_cron.php +++ /dev/null @@ -1,40 +0,0 @@ -getquota("cron"); -if ($q['t'] > 0 || $q['u'] > 0) { - -?> - - diff --git a/bureau/admin/menu_dom.php b/bureau/admin/menu_dom.php deleted file mode 100644 index dbc09646..00000000 --- a/bureau/admin/menu_dom.php +++ /dev/null @@ -1,53 +0,0 @@ -getquota("dom"); - -if ($q["t"] > 0 || $q['u'] > 0) -{ - -?> - - diff --git a/bureau/admin/menu_ftp.php b/bureau/admin/menu_ftp.php deleted file mode 100644 index 141993c8..00000000 --- a/bureau/admin/menu_ftp.php +++ /dev/null @@ -1,48 +0,0 @@ -getquota("ftp"); -if ($q["t"] > 0 || $q['u'] > 0) { - -?> - - diff --git a/bureau/admin/menu_ip.php b/bureau/admin/menu_ip.php deleted file mode 100644 index 673cedef..00000000 --- a/bureau/admin/menu_ip.php +++ /dev/null @@ -1,34 +0,0 @@ - - diff --git a/bureau/admin/menu_lang.php b/bureau/admin/menu_lang.php deleted file mode 100644 index 54dd190a..00000000 --- a/bureau/admin/menu_lang.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/bureau/admin/menu_logs.php b/bureau/admin/menu_logs.php deleted file mode 100644 index 1c14d257..00000000 --- a/bureau/admin/menu_logs.php +++ /dev/null @@ -1,37 +0,0 @@ - - - - - diff --git a/bureau/admin/menu_mail.php b/bureau/admin/menu_mail.php deleted file mode 100644 index aa0ddace..00000000 --- a/bureau/admin/menu_mail.php +++ /dev/null @@ -1,55 +0,0 @@ -getquota("mail"); -$r = $quota->getquota("dom"); -// there are some existing mail, or there is a domain AND quota authorize mail -if ($q["u"] > 0 || ( $r["u"] > 0 && $q['t'] > 0 )) { - -?> - - diff --git a/bureau/admin/menu_mem.php b/bureau/admin/menu_mem.php deleted file mode 100644 index 1fec1e39..00000000 --- a/bureau/admin/menu_mem.php +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/bureau/admin/menu_piwik.php b/bureau/admin/menu_piwik.php deleted file mode 100644 index 634b573c..00000000 --- a/bureau/admin/menu_piwik.php +++ /dev/null @@ -1,42 +0,0 @@ -getquota("piwik"); -if (!empty($piwik->piwik_server_uri) && ($q["t"] > 0 || $r["u"] > 0)) { -?> - - diff --git a/bureau/admin/menu_quota.php b/bureau/admin/menu_quota.php deleted file mode 100644 index 3940d72c..00000000 --- a/bureau/admin/menu_quota.php +++ /dev/null @@ -1,81 +0,0 @@ - - diff --git a/bureau/admin/menu_sql.php b/bureau/admin/menu_sql.php deleted file mode 100644 index ef384c0d..00000000 --- a/bureau/admin/menu_sql.php +++ /dev/null @@ -1,43 +0,0 @@ -getquota("mysql"); -if ($q["t"] > 0 || $q['u'] >0) { -?> - - diff --git a/bureau/admin/menu_web.php b/bureau/admin/menu_web.php deleted file mode 100644 index af988a56..00000000 --- a/bureau/admin/menu_web.php +++ /dev/null @@ -1,33 +0,0 @@ - - diff --git a/bureau/class/config.php b/bureau/class/config.php index 0a6fb5ac..cc32bd3b 100644 --- a/bureau/class/config.php +++ b/bureau/class/config.php @@ -28,7 +28,7 @@ ---------------------------------------------------------------------- */ -/* * / +/* */ // To enable dispay of PHP errors ini_set('display_errors', true); /* */ diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index f83ecb0b..54ca119e 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -64,6 +64,74 @@ class m_admin { ); } + function hook_menu() { + global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN; + if (!$mem->checkRight()) return false; + + $obj = array( + 'title' => _("Administration"), + 'ico' => 'images/admin.png', + 'link' => 'toggle', + 'class' => 'adminmenu', + 'pos' => 10, + 'links' => + array( + array( + 'txt' => _("Manage AlternC accounts"), + 'url' => 'adm_list.php', + 'class' => 'adminmenu' + ), + array( + 'txt' => _("User Quotas"), + 'url' => 'quotas_users.php?mode=4', + 'class' => 'adminmenu' + ), + ) + ) ; + + if ($cuid == 2000) { + $obj['links'][] = + array( + 'txt' => _("Admin Control Panel"), + 'url' => 'adm_panel.php', + 'class' => 'adminmenu' + ); + $obj['links'][] = + array( + 'txt' => _("PhpMyAdmin"), + 'url' => '/alternc-sql/', + 'class' => 'adminmenu' + ); + $obj['links'][] = + array( + 'txt' => ($debug_alternc->status)?_("Switch debug Off"):_("Switch debug On"), + 'url' => "alternc_debugme.php?enable=".($debug_alternc->status?"0":"1"), + 'class' => 'adminmenu' + ); + if (empty($L_INOTIFY_UPDATE_DOMAIN) || file_exists("$L_INOTIFY_UPDATE_DOMAIN") ) { + $obj['links'][] = + array( + 'txt' => _("Applying..."), + 'url' => 'javascript:alert(\''._("Domain changes are already applying").'\');', + 'class' => 'adminmenu', + ); + } else { + $obj['links'][] = + array( + 'txt' => _("Apply changes"), + 'url' => 'adm_update_domains.php', + 'class' => 'adminmenu', + 'onclick' => 'return confirm("'.addslashes(_("Server configuration changes are applied every 5 minutes. Do you want to do it right now?")).'");', + ); + + } // L_INOTIFY_UPDATE_DOMAIN + + } // cuid == 2000 + + + return $obj; + } + /* ----------------------------------------------------------------- */ /** Returns the known information about a hosted account diff --git a/bureau/class/m_authip.php b/bureau/class/m_authip.php index ead2b312..e0caaac9 100644 --- a/bureau/class/m_authip.php +++ b/bureau/class/m_authip.php @@ -35,6 +35,17 @@ class m_authip { return $this->list_ip(true); } + function hook_menu() { + $obj = array( + 'title' => _("Access security"), + 'ico' => 'images/ip.png', + 'link' => 'ip_main.php', + 'pos' => 120, + ) ; + + return $obj; + } + /* * Retourne la liste des ip spécifiées par cet utilisateur * diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index 58aba874..a6e20923 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -71,6 +71,18 @@ class m_bro { $this->l_createfile=array( 0=>_("Go back to the file manager"), 1=>_("Edit the newly created file") ); } + function hook_menu() { + $obj = array( + 'title' => _("File browser"), + 'ico' => 'images/folder.png', + 'link' => 'bro_main.php', + 'pos' => 40, + ) ; + + return $obj; + } + + /* ----------------------------------------------------------------- */ /** Verifie un dossier relatif au dossier de l'utilisateur courant diff --git a/bureau/class/m_cron.php b/bureau/class/m_cron.php index 9364fbcd..0186aa06 100644 --- a/bureau/class/m_cron.php +++ b/bureau/class/m_cron.php @@ -67,6 +67,16 @@ class m_cron { return $r; } + function hook_menu() { + $obj = array( + 'title' => _("Scheduled tasks"), + 'ico' => 'images/schedule.png', + 'link' => 'cron.php', + 'pos' => 90, + ) ; + + return $obj; + } /*---------------------------------------------------------------------------*/ /** update the crontab diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index ca44f430..2076458b 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -85,6 +85,38 @@ class m_dom { function m_dom() { } + function hook_menu() { + global $quota; + $obj = array( + 'title' => _("Domains"), + 'ico' => 'images/dom.png', + 'link' => 'toggle', + 'pos' => 20, + 'links' => array(), + ) ; + + if ( $quota->cancreate("dom") ) { + $obj['links'][] = + array ( + 'ico' => 'images/new.png', + 'txt' => _("Add a domain"), + 'url' => "dom_add.php", + ); + } + + foreach ($this->enum_domains() as $d) { + $obj['links'][] = + array ( + 'txt' => htmlentities($d), + 'url' => "dom_edit.php?domain=".urlencode($d), + ); + } + + return $obj; + } + + + /* ----------------------------------------------------------------- */ /** * Retourne un tableau contenant les types de domaines diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 9d0a38e1..5f3f7a4c 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -45,6 +45,38 @@ class m_ftp { return array("ftp"=>"FTP accounts"); } + function hook_menu() { + global $quota; + $q = $quota->getquota("ftp"); + + $obj = array( + 'title' => _("FTP accounts"), + 'ico' => 'images/ftp.png', + 'link' => 'toggle', + 'pos' => 60, + 'links' => array(), + ) ; + + if ( $quota->cancreate("ftp") ) { + $obj['links'][] = + array ( + 'ico' => 'images/new.png', + 'txt' => _("Create a new ftp account"), + 'url' => "ftp_edit.php?create=1", + 'class' => '', + ); + } + + if ( $q['u'] > 0 ) { // if there are some FTP accounts + $obj['links'][] = + array ( + 'txt' => _("FTP accounts list"), + 'url' => "ftp_list.php" + ); + } + + return $obj; + } // Return the values needed to activate security access. See get_auth_class() // in authip for more informations @@ -352,17 +384,14 @@ class m_ftp { } /* ----------------------------------------------------------------- */ - /** Fonction appellée par domains quand un deomaine est supprimé pour le membre + /** Fonction appellée par domains quand un domaine est supprimé pour le membre * @param string $dom Domaine à détruire. * @access private */ function alternc_del_domain($dom) { global $db,$err,$cuid; - $err->log("ftp","del_dom",$dom); - $db->query("SELECT COUNT(*) AS cnt FROM ftpusers WHERE uid='$cuid' AND name LIKE '$dom%'"); - $db->next_record(); - $cnt=$db->Record["cnt"]; - $db->query("DELETE FROM ftpusers WHERE uid='$cuid' AND name LIKE '$dom%'"); + $err->log("ftp","alternc_del_domain",$dom); + $db->query("DELETE FROM ftpusers WHERE uid='$cuid' AND ( name LIKE '$dom\_%' OR name LIKE '$dom') "); return true; } @@ -373,7 +402,7 @@ class m_ftp { */ function alternc_del_member() { global $db,$err,$cuid; - $err->log("ftp","del_member"); + $err->log("ftp","alternc_del_member"); $db->query("DELETE FROM ftpusers WHERE uid='$cuid'"); return true; } diff --git a/bureau/class/m_hta.php b/bureau/class/m_hta.php index 01bb4288..bbf14f52 100644 --- a/bureau/class/m_hta.php +++ b/bureau/class/m_hta.php @@ -55,6 +55,17 @@ class m_hta { return array("hta"=>"Protected folders passwords"); } + function hook_menu() { + $obj = array( + 'title' => _("Protected folders"), + 'ico' => 'images/password.png', + 'link' => 'hta_list.php', + 'pos' => 50, + ) ; + + return $obj; + } + /*---------------------------------------------------------------------------*/ /** diff --git a/bureau/class/m_log.php b/bureau/class/m_log.php index b0ecf725..1f27335b 100644 --- a/bureau/class/m_log.php +++ b/bureau/class/m_log.php @@ -55,6 +55,17 @@ class m_log { }//list_logs + function hook_menu() { + $obj = array( + 'title' => _("Logs"), + 'ico' => 'images/logs.png', + 'link' => 'logs_list.php', + 'pos' => 130, + ) ; + + return $obj; + } + function list_logs_directory_all($dirs){ global $err; $err->log("log","get_logs_directory_all"); diff --git a/bureau/class/m_mail.php b/bureau/class/m_mail.php index cc4333b6..383483d0 100644 --- a/bureau/class/m_mail.php +++ b/bureau/class/m_mail.php @@ -90,6 +90,26 @@ class m_mail { $this->srv_pop3s = variable_get('mail_human_pop3s', $L_FQDN,'Human name for POP3s mail server'); } + function hook_menu() { + $obj = array( + 'title' => _("Email Addresses"), + 'ico' => 'images/mail.png', + 'link' => 'toggle', + 'pos' => 30, + 'links' => array(), + ) ; + + foreach ($this->enum_domains() as $d) { + $obj['links'][] = + array ( + 'txt' => htmlentities($d["domaine"]).' '.htmlentities("(".$d["nb_mail"].")"), + 'url' => "mail_list.php?domain_id=".urlencode($d['id']), + ); + } + + return $obj; + } + // FIXME documenter function catchall_getinfos($domain_id) { global $dom, $db; diff --git a/bureau/class/m_mem.php b/bureau/class/m_mem.php index 1e625054..2262aa77 100644 --- a/bureau/class/m_mem.php +++ b/bureau/class/m_mem.php @@ -58,6 +58,16 @@ class m_mem { return array("mem"=>"AlternC's account password"); } + function hook_menu() { + $obj = array( + 'title' => _("Settings"), + 'ico' => 'images/config.png', + 'link' => 'mem_param.php', + 'pos' => 160, + ) ; + + return $obj; + } /* ----------------------------------------------------------------- */ /** Check that the current user is an admnistrator. @@ -589,8 +599,8 @@ Cordially. return false; } $j=$_SESSION[$sid]; - $j=unserialize($j); - if ( ! empty( $j[$v] ) ) { // si on a bien qque chose a retourner :) + $j=json_decode($j, true); + if ( ! empty($j[$v] ) ) { // si on a bien qque chose a retourner :) return $j[$v]; } return false; @@ -600,14 +610,14 @@ Cordially. $sid=$_COOKIE['session']; $p=Array(); if ( ! empty($_SESSION[$sid]) ) { - $p = unserialize($_SESSION[$sid]); + $p = json_decode($_SESSION[$sid], true); } if (! $ecrase && (isset($p[$k]) && is_array($p[$k])) && is_array($v) ) { $v=array_merge($p[$k], $v); // overwrite entry with the same name } $p[$k]=$v; - $_SESSION[$sid]=serialize($p); + $_SESSION[$sid]=json_encode($p); return true; } diff --git a/bureau/class/m_mysql.php b/bureau/class/m_mysql.php index ff83b91f..3fbfde28 100644 --- a/bureau/class/m_mysql.php +++ b/bureau/class/m_mysql.php @@ -108,6 +108,40 @@ class m_mysql { $this->dbus = new DB_users(); } + function hook_menu() { + global $quota; + $q = $quota->getquota("mysql"); + + $obj = array( + 'title' => _("MySQL"), + 'ico' => 'images/mysql.png', + 'link' => 'toggle', + 'pos' => 100, + 'links' => array(), + ) ; + + $obj['links'][] = + array ( + 'txt' => _("Databases"), + 'url' => "sql_list.php", + ); + $obj['links'][] = + array ( + 'txt' => _("MySQL Users"), + 'url' => "sql_users_list.php", + ); + if ($q["u"] > 0 ) { + $obj['links'][] = + array ( + 'txt' => _("PhpMyAdmin"), + 'url' => "sql_admin.php", + 'target' => '_blank', + ); + } + return $obj; + } + + /* ----------------------------------------------------------------- */ /** diff --git a/bureau/class/m_piwik.php b/bureau/class/m_piwik.php index 69ec4c8a..8fcb0224 100644 --- a/bureau/class/m_piwik.php +++ b/bureau/class/m_piwik.php @@ -31,6 +31,22 @@ class m_piwik { var $piwik_admin_token; + function hook_menu() { + global $quota; + $obj = array( + 'title' => _("Piwik statistics"), + 'ico' => 'images/stat.png', + 'link' => 'toggle', + 'pos' => 115, + 'links' => array( + array( 'txt' => _("Piwik Users"), 'url' => 'piwik_userlist.php'), + array( 'txt' => _("Piwik Sites"), 'url' => 'piwik_sitelist.php'), + ), + ) ; + + return $obj; + } + /*---------------------------------------------------------------------------*/ /** Constructor */ diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 113b1565..877b76de 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -55,6 +55,28 @@ class m_quota { _("quota_web"); } + function hook_menu() { + global $quota; + $obj = array( + 'title' => _("Show my quotas"), + 'ico' => 'images/quota.png', + 'link' => 'quota_show.php', + 'pos' => 110, + 'divclass' => 'menu-quota', + 'links' => array(), + ) ; + + $q=$quota->getquota(); + + foreach ( array('web', 'bw_web') as $key ) { + if ( empty($q[$key]["t"])) continue; + $usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100); + $obj['links'][] = array( 'txt'=>_("quota_".$key) . " " . sprintf(_("%s%% of %s"),$usage_percent,format_size($q[$key]["t"]*1024)), 'url'=>($key == 'bw_web' ? 'stats_show_per_month.php' : 'quota_show.php') ); + $obj['links'][] = array( 'txt'=>'progressbar', 'total' => $q[$key]["t"], 'used' => $q[$key]["u"]); + } + + return $obj; + } /* ----------------------------------------------------------------- */ /** Check if a user can use a ressource. diff --git a/debian/alternc-awstats.postinst b/debian/alternc-awstats.postinst index d604e058..1d3bab1e 100755 --- a/debian/alternc-awstats.postinst +++ b/debian/alternc-awstats.postinst @@ -3,7 +3,6 @@ # Uses debconf . /usr/share/debconf/confmodule -MENUFILE="/etc/alternc/menulist.txt" LOGAPACHE="/etc/alternc/awstats.log.alternc.conf" APACHEROTATE="/etc/logrotate.d/apache2" @@ -73,14 +72,6 @@ EOF # Update rights on previous user's awstats configuration files chown alterncpanel:alterncpanel /etc/awstats/awstats.*.conf > /dev/null 2>&1 - # ADD menu item : - if ! grep -q "^menu_aws.php$" "$MENUFILE"; then - rm -f $MENUFILE.alternc_awstats - sed -e "s/menu_cron.php/&\\ -menu_aws.php/" <$MENUFILE >$MENUFILE.alternc_awstats - mv -f $MENUFILE.alternc_awstats $MENUFILE - fi - echo "**********************************************" echo "* ALTERNC-AWSTATS *" echo "* Add an autorized user called 'admin' in *" diff --git a/debian/alternc-awstats.postrm b/debian/alternc-awstats.postrm index 30395efa..a085579f 100755 --- a/debian/alternc-awstats.postrm +++ b/debian/alternc-awstats.postrm @@ -9,11 +9,6 @@ case "$1" in # unconfigure /etc/alternc/templates/apache-ssl/httpd.conf alternc.install - if grep -qs "menu_aws.php" $MENUFILE; then - rm -f $MENUFILE.alternc_awstats - cat $MENUFILE | grep -v "menu_aws.php" >$MENUFILE.alternc_awstats - mv -f $MENUFILE.alternc_awstats $MENUFILE - fi ;; purge) #/usr/lib/alternc/quota_delete aws diff --git a/debian/alternc.preinst b/debian/alternc.preinst index 437ed092..965e8c65 100644 --- a/debian/alternc.preinst +++ b/debian/alternc.preinst @@ -69,13 +69,6 @@ case "$1" in echo "/etc/bind/master was not empty. Please remove it manually." fi - if [ ! -e /etc/alternc/menulist.txt ]; then - if [ -f /var/alternc/bureau/admin/menulist.txt ]; then - mv -f /var/alternc/bureau/admin/menulist.txt \ - /etc/alternc/menulist.txt - fi - fi - ;; abort-upgrade) diff --git a/etc/alternc/menulist.txt b/etc/alternc/menulist.txt deleted file mode 100644 index 0e8b1adf..00000000 --- a/etc/alternc/menulist.txt +++ /dev/null @@ -1,14 +0,0 @@ -menu_adm.php -menu_dom.php -menu_mail.php -menu_brouteur.php -menu_web.php -menu_ftp.php -menu_cron.php -menu_sql.php -menu_quota.php -menu_ip.php -menu_logs.php -menu_aide.php -menu_lang.php -menu_mem.php
    "._("uid").""._("Last name, surname").""._("Expiry")."