44
55if ($ redis ) {
66
7- $ keys = $ redis ->keys ($ server ['filter ' ]);
7+ if (!empty ($ server ['keys ' ])) {
8+ $ keys = $ redis ->keys ($ server ['filter ' ]);
9+ } else {
10+ $ next = 0 ;
11+ $ keys = array ();
12+
13+ while (true ) {
14+ $ r = $ redis ->scan ($ next , 'MATCH ' , $ server ['filter ' ], 'COUNT ' , $ server ['scansize ' ]);
15+
16+ $ next = $ r [0 ];
17+ $ keys = array_merge ($ keys , $ r [1 ]);
18+
19+ if ($ next == 0 ) {
20+ break ;
21+ }
22+ }
23+ }
824
925 sort ($ keys );
1026
@@ -83,7 +99,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
8399
84100 ?>
85101 <li<?php echo empty ($ class ) ? '' : ' class=" ' .implode (' ' , $ class ).'" ' ?> >
86- <a href="http://github.com/?view&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &key=<?php echo urlencode ($ fullkey )?> "><?php echo format_html ($ name )?> <?php if ($ len !== false ) { ?> <span class="info">(<?php echo $ len?> )</span><?php } ?> </a>
102+ <a href="http://github.com/?view&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> & key=<?php echo urlencode ($ fullkey )?> "><?php echo format_html ($ name )?> <?php if ($ len !== false ) { ?> <span class="info">(<?php echo $ len?> )</span><?php } ?> </a>
87103 </li>
88104 <?php
89105 }
@@ -93,7 +109,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
93109 ?>
94110 <li class="folder<?php echo ($ fullkey === '' ) ? '' : ' collapsed ' ?> <?php echo $ islast ? ' last ' : '' ?> ">
95111 <div class="icon"><?php echo format_html ($ name )?> <span class="info">(<?php echo count ($ item )?> )</span>
96- <?php if ($ fullkey !== '' ) { ?> <a href="http://github.com/delete.php?s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &tree=<?php echo urlencode ($ fullkey )?> :" class="deltree"><img src="http://github.com/images/delete.png" width="10" height="10" title="Delete tree" alt="[X]"></a><?php } ?>
112+ <?php if ($ fullkey !== '' ) { ?> <a href="http://github.com/delete.php?s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> & tree=<?php echo urlencode ($ fullkey )?> :" class="deltree"><img src="http://github.com/images/delete.png" width="10" height="10" title="Delete tree" alt="[X]"></a><?php } ?>
97113 </div><ul>
98114 <?php
99115
@@ -144,32 +160,43 @@ function print_namespace($item, $name, $fullkey, $islast) {
144160?>
145161<div id="sidebar">
146162
147- <h1 class="logo"><a href="http://github.com/?overview&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> ">phpRedisAdmin</a></h1>
163+ <h1 class="logo"><a href="http://github.com/?overview&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> ">phpRedisAdmin</a></h1>
148164
149165<p>
150166<select id="server">
151167<?php foreach ($ config ['servers ' ] as $ i => $ srv ) { ?>
152168<option value="<?php echo $ i?> " <?php echo ($ server ['id ' ] == $ i ) ? 'selected="selected" ' : '' ?> ><?php echo isset ($ srv ['name ' ]) ? format_html ($ srv ['name ' ]) : $ srv ['host ' ].': ' .$ srv ['port ' ]?> </option>
153169<?php } ?>
154170</select>
155- </p>
156171
157- <?php if ($ redis ): ?>
172+ <?php if ($ redis ) { ?>
173+
174+ <?php
175+ $ databases = $ redis ->config ('GET ' , 'databases ' );
176+ $ databases = $ databases ['databases ' ];
177+ if ($ databases > 1 ) { ?>
178+ <select id="database">
179+ <?php for ($ d = 0 ; $ d < $ databases ; ++$ d ) { ?>
180+ <option value="<?php echo $ d?> " <?php echo ($ server ['db ' ] == $ d ) ? 'selected="selected" ' : '' ?> >database <?php echo $ d?> </option>
181+ <?php } ?>
182+ </select>
183+ <?php } ?>
184+ </p>
158185
159186<p>
160187<?php if (isset ($ login )) { ?>
161188<a href="logout.php"><img src="images/logout.png" width="16" height="16" title="Logout" alt="[L]"></a>
162189<?php } ?>
163- <a href="http://github.com/?info&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> "><img src="http://github.com/images/info.png" width="16" height="16" title="Info" alt="[I]"></a>
164- <a href="http://github.com/?export&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> "><img src="http://github.com/images/export.png" width="16" height="16" title="Export" alt="[E]"></a>
165- <a href="http://github.com/?import&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> "><img src="http://github.com/images/import.png" width="16" height="16" title="Import" alt="[I]"></a>
190+ <a href="http://github.com/?info&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> "><img src="http://github.com/images/info.png" width="16" height="16" title="Info" alt="[I]"></a>
191+ <a href="http://github.com/?export&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> "><img src="http://github.com/images/export.png" width="16" height="16" title="Export" alt="[E]"></a>
192+ <a href="http://github.com/?import&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> "><img src="http://github.com/images/import.png" width="16" height="16" title="Import" alt="[I]"></a>
166193<?php if (isset ($ server ['flush ' ]) && $ server ['flush ' ]) { ?>
167- <a href="http://github.com/?flush&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> " id="flush"><img src="http://github.com/images/flush.png" width="16" height="16" title="Flush" alt="[F]"></a>
194+ <a href="http://github.com/?flush&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> " id="flush"><img src="http://github.com/images/flush.png" width="16" height="16" title="Flush" alt="[F]"></a>
168195<?php } ?>
169196</p>
170197
171198<p>
172- <a href="http://github.com/?edit&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> " class="add">Add another key</a>
199+ <a href="http://github.com/?edit&s=%3Cspan%20class="pl-ent"><?php echo $ server ['id ' ]?> &d= <?php echo $ server [ ' db ' ] ?> " class="add">Add another key</a>
173200</p>
174201
175202<p>
@@ -187,9 +214,10 @@ function print_namespace($item, $name, $fullkey, $islast) {
187214</ul>
188215</div><!-- #keys -->
189216
190- <?php else : ?>
217+ <?php } else { ?>
218+ </p>
191219<div style="color:red">Can't connect to this server</div>
192- <?php endif ; ?>
220+ <?php } ?>
193221
194222<div id="frame">
195223<iframe src="<?php echo format_html ($ iframe )?> " id="iframe" frameborder="0" scrolling="0"></iframe>
0 commit comments