Alternc  latest
Alternc logiel libre pour l'hébergement
adm_dodefquotas.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Change the default quotas
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 
28 if (!$admin->enabled) {
29  $msg->raise("ERROR", "admin", _("This page is restricted to authorized staff"));
30  echo $msg->msg_html_all();
31  exit();
32 }
33 $fields = array (
34  "action" => array ("post", "string", ""),
35  "type" => array ("post", "string", ""),
36  "del_confirm" => array ("post", "string", ""),
37 );
39 
40 if($action == "add") {
41 
42  if($quota->addtype($type)) {
43  $msg->raise("INFO", "admin", _("Account type"). " \"".htmlentities($type)."\" "._("added"));
44  } else {
45  $msg->raise("ERROR", "admin", _("Account type"). " \"".htmlentities($type)."\" "._("could not be added"));
46  }
47  include("adm_defquotas.php");
48 } else if($action == "delete") {
49  if($del_confirm == "y"){
50  if(!empty($type)) {
51  if($quota->deltype($type)) {
52  $msg->raise("INFO", "admin", _("Account type"). " \"".htmlentities($type)."\" "._("deleted"));
53  } else {
54  $msg->raise("ERROR", "admin", _("Account type"). " \"".htmlentities($type)."\" "._("could not be deleted"));
55  }
56  }
57  include("adm_defquotas.php");
58  }else{
59  include("head.php");
60  ?>
61  <h3><?php printf(_("Deleting quota %s"),$type); ?> : </h3>
62 
63  <form action="adm_dodefquotas.php" method="post">
64  <?php csrf_get(); ?>
65  <input type="hidden" name="action" value="delete" />
66  <input type="hidden" name="type" value="<?php echo $type ?>" />
67  <input type="hidden" name="del_confirm" value="y" />
68  <p class="alert alert-warning"><?php __("WARNING: Confirm the deletion of the quota"); ?></p>
69  <p><?php echo $type; ?></p>
70  <blockquote>
71  <input type="submit" class="inb ok" name="confirm" value="<?php __("Yes, delete this default quota"); ?>" />&nbsp;&nbsp;
72  <input type="button" class="inb cancel" name="cancel" value="<?php __("No, don't delete this default quota"); ?>" onclick="document.location='adm_defquotas.php';" />
73  </blockquote>
74  </form>
75  <?php
76  include("foot.php");
77  }
78 } else if($action == "modify") {
79  reset($_POST);
80  $c=array();
81  foreach($_POST as $key => $val) {
82  if($key == "action")
83  continue;
84 
85  list($type, $q) = explode(":", $key, 2);
86  $c[$type][$q] = abs(floatval($val));
87  }
88 
89  if($quota->setdefaults($c)) {
90  $msg->raise("INFO", "admin", _("Default quotas successfully changed"));
91  } else {
92  $msg->raise("ERROR", "admin", _("Default quotas could not be set."));
93  }
94  include("adm_panel.php");
95 }
96 ?>
exit
Definition: adm_doadd.php:70
if(! $admin->enabled) $fields
Change the default quotas.
$msg
Definition: bootstrap.php:75
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159