Alternc  latest
Alternc logiel libre pour l'hébergement
piwik_userlist.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 Piwik users
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 $userslist = $piwik->users_list();
30 $quotapiwik = $quota->getquota('piwik');
31 
32 // TODO - Put the limit of piwik users (here at 3) as a variable in alternC
33 if ($quotapiwik['t'] > 0 && count($userslist) < 3) {
34 ?>
35 <h3><?php __("Create a new piwik account");?></h3>
36 <?php
37 echo $msg->msg_html_all(true, true);
38 ?>
39 <form method="post" action="piwik_addaccount.php" id="main" name="addaccount" >
40  <?php csrf_get(); ?>
41  <table class="tedit">
42  <tr>
43  <th><label for="account_name"><?php __("Account Name"); ?></label></th>
44  <td><span class="int" id="account_namefx"><?php echo $mem->user["login"]; ?>_</span><input type="text" class="int" name="account_name" size="20" id="account_name" maxlength="32" value=""/>
45  </tr>
46  <tr>
47  <th><label for="account_mail"><?php __("Linked Account Email"); ?></label></th>
48  <td><input type="text" class="int" name="account_mail" size="20" id="account_mail" maxlength="32" value="<?php if (count($userslist) == 0) {echo $mem->user["mail"];}?>"/>
49  </tr>
50  <tr class="trbtn"><td colspan="2">
51  <input type="submit" name="submit" class="inb" value="<?php __("Create"); ?>" />
52  </tr>
53  </table>
54  <i>(<?php ehe("Max. 3 accounts"); ?>)</i>
55 </form>
56 <script type="text/javascript">
57  document.forms['main'].account_name.focus();
58 </script>
59 <br/>
60 <hr/>
61 <?php
62 } else {
63  $msg->raise("INFO", "piwik", _("You cannot add any new Piwik account, your quota is over."));
64 } // cancreate piwik
65 ?>
66 
67 <h3><?php __("Existing Piwik accounts"); ?></h3>
68 <?php
69 echo $msg->msg_html_all(true, true);
70 // printVar($piwik->dev());
71 
72 if (empty($userslist)){
73  $msg->raise("INFO", "piwik", _("No existing Piwik accounts"));
74  echo $msg->msg_html_all();
75 } else {
76 ?>
77 
78 <table class="tlist">
79  <tr><th/><th><?php __("Username");?></th><th align=center><?php __("Connect"); ?></th></tr>
80 <?php
81 
82 $col=1;
83 foreach ($userslist as $user ){
84  unset($piwik_pwd);
85  $form_id="main_".$user->login;
86 
87  $db->query("SELECT passwd FROM piwik_users WHERE login = '$user->login'");
88  if ($db->next_record()) {
89  $piwik_pwd = $db->f('passwd');
90  }
91 
92  $col=3-$col;
93  ?>
94  <tr class="lst_clic<?php echo $col; ?>">
95  <td>
96  <div class="ina">
97  <form method="post" action="piwik_user_dodel.php" name="<?php echo $form_id; ?>" id="<?php echo $form_id; ?>">
98  <?php csrf_get(); ?>
99  <input type="hidden" name="login" value="<?php ehe($user->login);?>" />
100  <input type="button" class="ina" name="delete" value="<?php __("Delete"); ?>" onclick="document.getElementById('<?php echo $form_id; ?>').submit();" style="background: url('/images/delete.png') no-repeat 3px 3px; padding-left: 16px;" />
101  </form>
102  </div>
103  </td>
104  <td><?php echo $user->login ?></td>
105  <!--<td><div class="ina"><a href="<?php printf('%s?module=Login&action=logme&login=%s&password=%s', $piwik->url(), $user->login, $user->password); ?>" target="_blank"><?php __('Connect'); ?></a></td>-->
106  <td>
107  <?php
108  if ($piwik_pwd) {
109  ?>
110  <div class="ina"><a href="<?php printf('%s?module=Login&action=logme&login=%s&password=%s', $piwik->url(), $user->login, $piwik_pwd); ?>" target="_blank"><?php __('Connect'); ?></a>
111  <?php
112  } else {
113  ?>
114  <div class="ina"><img src="images/warning.png" onmouseover='$("#alert_div_msg").show();' onmouseout='$("#alert_div_msg").hide();'></div>
115  <?php } ?>
116  </td>
117  </tr>
118  <?php
119 } // foreach userlist
120 } // empty userlist
121 ?>
122 
123 </table>
124 <div class="ina" id="alert_div_msg" style="display:none;background-color:yellow;padding:5px;border:2px solid black;margin-top:3em;";>
125  <?php __("An error occurred. It was not possible to retrieve the access information to the Piwik interface") ?>
126 </div>
127 <?php include_once("foot.php"); ?>
global $db
Definition: bootstrap.php:26
$mem
Definition: bootstrap.php:71
$msg
Definition: bootstrap.php:75
ehe($str, $display=TRUE)
Echo the HTMLSpecialChars version of a value.
Definition: functions.php:647
__($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
$user
Definition: bootstrap.php:84
$quotapiwik
$userslist
List Piwik users.