Alternc  latest
Alternc logiel libre pour l'hébergement
sql_list.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  * List and manage the MySQL databases of an account
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 $rdb=$mysql->get_dblist();
30 $r=$mysql->get_userslist();
31 
32 ?>
33 <h3><?php __("MySQL Databases"); ?></h3>
34 <hr id="topbar"/>
35 <br />
36 <?php
37  // If the db exists, we look at users
38  if (!$rdb || empty($rdb)) {
39  $msg->raise("INFO", "mysql", _("You have no database at the moment."));
40  } else if(!$r || empty($r)){
41  $msg->raise("INFO", "mysql", _("You have no sql user at the moment."));
42  }
43 
44 echo $msg->msg_html_all();
45 ?>
46 
47 <?php
48 if($rdb){
49 ?>
50 <form method="post" action="sql_del.php" name="main" id="main">
51  <?php csrf_get(); ?>
52 <table class="tlist">
53  <tr><th>&nbsp;</th><th><?php __("Database"); ?></th><?php if ( variable_get('sql_allow_users_backups') ) { ?><th><?php __("Backup"); ?></th><?php } ?><th><?php __("Restore"); ?></th><th><?php __("Show Settings"); ?></th><th><?php __("Size"); ?></th></tr>
54 
55 <?php
56 for($i=0;$i<count($rdb);$i++) {
57  $val=$rdb[$i];
58  $val['size'] = $mysql->get_db_size($val['db']);
59 ?>
60  <tr class="lst">
61  <td align="center"><input type="checkbox" class="inc" id="del_<?php echo $val["db"]; ?>" name="del_<?php echo $val["db"]; ?>" value="<?php echo ($val["db"]); ?>" /></td>
62  <td><label for="del_<?php echo $val["db"]; ?>"><?php echo $val["db"]; ?></label></td>
63 <?php if ( variable_get('sql_allow_users_backups') ) { ?>
64  <td><div class="ina backup"><a href="sql_bck.php?id=<?php echo $val["db"] ?>"><?php __("Backup"); ?></a></div></td>
65 <?php } // sql_allow_users_backups ?>
66  <td><div class="ina restore"><a href="sql_restore.php?id=<?php echo $val["db"] ?>"><?php __("Restore"); ?></a></div></td>
67  <td><div class="ina settings"><a href="sql_getparam.php?dbname=<?php echo $val["db"] ?>"><?php __("Show Settings"); ?></a></div></td>
68  <td><code><?php echo format_size($val["size"]); ?></code></td>
69  </tr>
70 <?php
71 
72 
73  }
74 ?>
75 <tr><td colspan="6">
76  <button type="submit" name="sub" class="inb delete"><?php __("Delete the checked databases"); ?></button>
77 </td></tr>
78 </table>
79 </form>
80 <?php
81 }
82 ?>
83 <p>&nbsp;</p>
84 
85 <?php if ($quota->cancreate("mysql")) {
86  $q=$quota->getquota("mysql");
87  if($q['u'] == 0 ){
88 ?>
89 <p> <span class="ina"><a href="sql_doadd.php"><?php __("Create a new MySQL database"); ?></a></span> </p>
90 <?php }else{
91 ?>
92 <form method="post" action="sql_doadd.php" id="main2" name="main2">
93  <?php csrf_get(); ?>
94 <table class="tedit">
95 <tr>
96  <th><label for="dbn"><?php __("MySQL Database"); ?></label></th>
97  <td>
98  <?php
99  // Set a maximum length for the database name if we want the mysql user to be automatically created.
100  $max_dbsufix_size=(variable_get("sql_max_database_length", 16)-strlen($mem->user["login"].'_'));
101  ?>
102  <span class="int" id="dbnpfx"><?php echo $mem->user["login"]; ?>_</span><input type="text" class="int" name="dbn" id="dbn" value="" size="20" maxlength="<?php echo $max_dbsufix_size ;?>" />
103  </td>
104 </tr>
105 </table>
106 <br />
107 <input type="submit" class="inb add" name="submit" value="<?php __("Create this new MySQL database."); ?>" onClick="return false_if_empty('dbn', '<?php echo addslashes(_("Can't have empty MySQL suffix"));?>');" />
108 </form>
109 <?php
110 }
111 }
112 ?>
113 <?php include_once("foot.php"); ?>
$mem
Definition: bootstrap.php:71
$msg
Definition: bootstrap.php:75
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:85
format_size($size, $html=0)
Definition: functions.php:430
__($str)
Definition: functions.php:404
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
$q
Definition: menu_aws.php:32
$i
$rdb
List and manage the MySQL databases of an account.
Definition: sql_list.php:29
$r
Definition: sql_list.php:30
$val
Definition: tempovars.php:15