[TASK] Disable compression for inlineJs in Backend
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_superadmin.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Super Admin class has functions for the administration of multiple TYPO3 sites in folders
29 * See 'misc/superadmin.php' for details on how to use!
30 *
31 * Revised for TYPO3 3.6 February/2004 by Kasper Skårhøj
32 * XHTML Compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37
38 // *******************************
39 // Set error reporting
40 // *******************************
41 error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
42
43 define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation.
44
45
46 // Dependency:
47 $path_t3lib = './typo3_src/t3lib/';
48 include_once($path_t3lib . 'class.t3lib_div.php');
49 include_once($path_t3lib . 'class.t3lib_db.php');
50 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
51
52
53 t3lib_div::deprecationLog('class.t3lib_superadmin.php is deprecated since TYPO3 4.5, this file will be removed in TYPO3 4.7.');
54
55
56 /**
57 * Debug function. Substitute since no config_default.php file is included anywhere
58 *
59 * @param mixed Debug var
60 * @param string Header string
61 * @return void
62 */
63 function debug($p1, $p2 = '') {
64 t3lib_div::debug($p1, $p2);
65 }
66
67
68 /**
69 * Super Admin class has functions for the administration of multiple TYPO3 sites in folders
70 * NOTICE: Only compliant with single MySQL database usage per installation!
71 *
72 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
73 * @package TYPO3
74 * @subpackage t3lib
75 */
76 class t3lib_superadmin {
77
78 // External, static:
79 var $targetWindow = 'superAdminWindow';
80 var $targetWindowAdmin = 'superAdminWindowAdmin';
81 var $targetWindowInstall = 'superAdminWindowInstall';
82 var $scriptName = 'superadmin.php';
83
84 // GP vars:
85 var $show; // "menu", "all", "admin", "info", "rmTempCached", "localext"
86 var $type; // "phpinfo", "page" - default renders a frameset
87 var $exp; // Additional parameter, typically a md5-hash pointing to an installation of TYPO3
88
89 // Internal, static:
90 var $parentDirs = array(); // Configured directories to search
91 var $globalSiteInfo = array(); // Array with information about found TYPO3 installations
92
93 var $currentUrl = '';
94 var $mapDBtoKey = array();
95 var $collectAdminPasswords = array();
96 var $changeAdminPasswords = array();
97 var $collectInstallPasswords = array();
98
99 // Control:
100 var $full = 0; // If set, the full information array per site is printed.
101
102 var $noCVS = 0; // See tools/em/index.php....
103
104
105 /**********************************
106 *
107 * Initialize stuff
108 *
109 **********************************/
110
111 /**
112 * Constructor, setting GP vars
113 *
114 * @return void
115 */
116 function __construct() {
117 $this->show = t3lib_div::_GP('show');
118 $this->type = t3lib_div::_GP('type');
119 $this->exp = t3lib_div::_GP('exp');
120 }
121
122 /**
123 * Compatibility constructor.
124 *
125 * @deprecated since TYPO3 4.6 and will be removed in TYPO3 4.8. Use __construct() instead.
126 */
127 public function t3lib_superadmin() {
128 t3lib_div::logDeprecatedFunction();
129 // Note: we cannot call $this->__construct() here because it would call the derived class constructor and cause recursion
130 // This code uses official PHP behavior (http://www.php.net/manual/en/language.oop5.basic.php) when $this in the
131 // statically called non-static method inherits $this from the caller's scope.
132 t3lib_superadmin::__construct();
133 }
134
135 /**
136 * Initialize with configuration - from the 'superadmin.php' script. See misc/superadmin.php for example.
137 *
138 * @param array Numerical array with arrays having two keys, 'dir' and 'url' where 'dir' is the absolute path to a directory with TYPO3 installations inside.
139 * @return void
140 */
141 function init($parentDirs) {
142 $this->parentDirs = $parentDirs;
143 }
144
145
146 /**************************
147 *
148 * Main functions
149 *
150 **************************/
151
152 /**
153 * Main function, creating HTML content; frameset, menu, content frames.
154 * Outputs the full HTML to browser.
155 *
156 * @return void
157 */
158 function defaultSet() {
159
160 // Creating content based on "type" variable:
161 switch ($this->type) {
162 case 'phpinfo':
163 phpinfo();
164 break;
165 case 'page':
166 ?>
167 <!DOCTYPE html
168 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
169 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
170 <html>
171 <head>
172 <style type="text/css">
173 .redclass {
174 color: red;
175 }
176
177 P {
178 font-family: Verdana, Arial, Helvetica, sans-serif;
179 font-size: 11px
180 }
181
182 BODY {
183 font-family: Verdana, Arial, Helvetica, sans-serif;
184 font-size: 10px
185 }
186
187 H1 {
188 font-family: Verdana, Arial, Helvetica, sans-serif;
189 font-size: 20px;
190 color: #000066;
191 }
192
193 H2 {
194 font-family: Verdana, Arial, Helvetica, sans-serif;
195 font-size: 17px;
196 color: #000066;
197 }
198
199 H3 {
200 font-family: Verdana, Arial, Helvetica, sans-serif;
201 font-size: 14px;
202 color: #000066;
203 }
204
205 H4 {
206 font-family: Verdana, Arial, Helvetica, sans-serif;
207 font-size: 11px;
208 color: maroon;
209 }
210
211 TD {
212 font-family: Verdana, Arial, Helvetica, sans-serif;
213 font-size: 10px
214 }
215 </style>
216 <title>TYPO3 Super Admin</title>
217 </head>
218 <body>
219 <?php
220 echo $this->make();
221 ?>
222 </body>
223 </html>
224 <?php
225 break;
226 default:
227 ?>
228 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
229 <html>
230 <head>
231 <title>TYPO3 Super Admin</title>
232 </head>
233 <frameset cols="250,*">
234 <frame name="TSAmenu" src="superadmin.php?type=page&show=menu" marginwidth="10" marginheight="10"
235 scrolling="auto" frameborder="0">
236 <frame name="TSApage" src="superadmin.php?type=page" marginwidth="10" marginheight="10"
237 scrolling="auto" frameborder="0">
238 </frameset>
239 </html>
240 <?php
241 break;
242 }
243 }
244
245 /**
246 * Main function, creating page content.
247 *
248 * @return string HTML content.
249 */
250 function make() {
251
252 $retVal = '';
253
254 // Creating information about the sites found:
255 $content = $this->initProcess();
256
257 // Output mode:
258 switch ($this->show) {
259 case 'menu':
260 $lines = array();
261 $lines[] = $this->setMenuItem('info', 'INFO');
262 $lines[] = $this->setMenuItem('update', 'UPDATE');
263 $lines[] = '';
264 $lines[] = '<a href="' . htmlspecialchars($this->scriptName . '?type=page') . '" target="TSApage">Default</a>';
265 $lines[] = '<a href="' . htmlspecialchars($this->scriptName . '?type=page&show=all') . '" target="TSApage">All details</a>';
266 $lines[] = '<a href="' . htmlspecialchars($this->scriptName . '?type=page&show=admin') . '" target="TSApage">Admin logins</a>';
267 $lines[] = '<a href="' . htmlspecialchars($this->scriptName . '?type=phpinfo') . '" target="TSApage">phpinfo()</a>';
268 $lines[] = '<a href="' . htmlspecialchars($this->scriptName . '?type=page&show=localext') . '" target="TSApage">Local extensions</a>';
269 $lines[] = '';
270 $content = implode('<br />', $lines);
271 $content .= '<hr />';
272 $content .= $this->menuContent($this->exp);
273 $retVal = '<h2 align="center">TYPO3<br />Super Admin</h2>' . $content;
274 break;
275 case 'all':
276 $retVal = '
277 <h1>All details:</h1>
278 <h2>Overview:</h2>
279 ' . $this->makeTable() . '
280 <br /><hr /><br />
281 <h1>Details per site:</h1>
282 ' . $content;
283 break;
284 case 'admin':
285 $content = $this->setNewPasswords();
286 $this->makeTable();
287 $retVal = $content . '
288 <h1>Admin options:</h1>
289
290 <h2>Admin logins:</h2>
291 ' . $this->makeAdminLogin() . '
292 <br /><hr /><br />
293
294 <h2>TBE Admin Passwords:</h2>
295 ' . t3lib_div::view_array($this->collectAdminPasswords) . '
296 <br /><hr /><br />
297
298 <h2>Install Tool Passwords:</h2>
299 ' . t3lib_div::view_array($this->collectInstallPasswords) . '
300 <br /><hr /><br />
301
302 <h2>Change TBE Admin Passwords:</h2>
303 ' . $this->changeAdminPasswordsForm() . '
304 <br /><hr /><br />';
305 break;
306 case 'info':
307 $retVal = '
308 <h1>Single site details</h1>
309 ' . $this->singleSite($this->exp) .
310 '<br />';
311 break;
312 case 'rmTempCached':
313 $retVal = '
314 <h1>Removing temp_CACHED_*.php files</h1>
315 ' . $this->rmCachedFiles($this->exp) .
316 '<br />';
317 break;
318 case 'localext':
319 $retVal = '
320 <h1>Local Extensions Found:</h1>
321 ' . $this->localExtensions() .
322 '<br />';
323 break;
324 default:
325 $retVal = '
326 <h1>Default info:</h1>' .
327 $content;
328 break;
329 }
330 return $retVal;
331 }
332
333
334 /********************************
335 *
336 * Output preparation
337 *
338 *******************************/
339
340 /**
341 * Creates menu item from input.
342 *
343 * @param string Value for "&exp" parameter
344 * @param string The label
345 * @return string Wrapped value
346 */
347 function setMenuItem($code, $label) {
348 $out = '<a href="' . htmlspecialchars($this->scriptName . '?type=page&show=menu&exp=' . $code) . '" target="TSAmenu">' . htmlspecialchars($label) . '</a>';
349 if ($code == $this->exp) {
350 $out = '<span style="color:red;">&gt;&gt;</span>' . $out;
351 }
352 return $out;
353 }
354
355 /**
356 * Wrap string in red span tag (for errors)
357 *
358 * @param string Input string
359 * @return string Output string
360 */
361 function error($str) {
362 $out = '<span style="color:red; font-size: 14px; font-weight: bold;">' . htmlspecialchars($str) . '</span>';
363 return $out;
364 }
365
366 /**
367 * Wraps input string in <h2>
368 *
369 * @param string Input string
370 * @return string Output string, wrapped in <h2>
371 */
372 function headerParentDir($str) {
373 $out = '<h2>' . htmlspecialchars($str) . '</h2>';
374 return $out;
375 }
376
377 /**
378 * Wraps input string in <h3>
379 *
380 * @param string Input string
381 * @return string Output string, wrapped in <h3>
382 */
383 function headerSiteDir($str) {
384 $out = '<h3>' . htmlspecialchars($str) . '</h3>';
385 return $out;
386 }
387
388
389 /********************************
390 *
391 * Collection information
392 *
393 *******************************/
394
395 /**
396 * Traverses the parent dirs, collecting the list of TYPO3 installations into $this->globalSiteInfo
397 *
398 * @return string HTML content (The default view seen when starting the superadmin.php script)
399 */
400 function initProcess() {
401 $content = '';
402
403 foreach ($this->parentDirs as $k => $v) {
404 $dir = rtrim($v['dir'], '/');
405 $baseUrl = rtrim($v['url'], '/');
406 $content .= '<br /><br /><br />';
407 $content .= $this->headerParentDir($dir);
408 if (@is_dir($dir)) {
409 $in_dirs = t3lib_div::get_dirs($dir);
410 asort($in_dirs);
411 $dirArr = array();
412 foreach ($in_dirs as $k => $v) {
413 if (substr($v, 0, 9) != 'typo3_src') {
414 $this->currentUrl = $baseUrl . '/' . $v;
415 $content .= $this->headerSiteDir($v);
416 $content .= $this->processSiteDir($dir . '/' . $v, $dir);
417 }
418 }
419 } else {
420 $content .= $this->error('"' . $dir . '" was not a directory!');
421 }
422 }
423
424 return $content;
425 }
426
427 /**
428 * Creating information array for a specific TYPO3 installation
429 * Information about site is stored in ->globalSiteInfo array
430 *
431 * @param string Absolute path to installation (PATH_site)
432 * @param string Directory of main directory (level under PATH_site)
433 * @return string HTML content with information about the site.
434 * @access private
435 * @see initProcess()
436 */
437 function processSiteDir($path, $dir) {
438 $out = '';
439 if (@is_dir($path)) {
440 $localconf = $path . '/typo3conf/localconf.php';
441 if (@is_file($localconf)) {
442 $key = md5($localconf);
443 $this->includeLocalconf($localconf);
444
445 $this->mapDBtoKey[$this->globalSiteInfo[$key]['siteInfo']['TYPO3_db']] = $key;
446 $this->globalSiteInfo[$key]['siteInfo']['MAIN_DIR'] = $dir;
447 $this->globalSiteInfo[$key]['siteInfo']['SA_PATH'] = $path;
448 $this->globalSiteInfo[$key]['siteInfo']['URL'] = $this->currentUrl . '/';
449 $this->globalSiteInfo[$key]['siteInfo']['ADMIN_URL'] = $this->currentUrl . '/' . TYPO3_mainDir;
450 $this->globalSiteInfo[$key]['siteInfo']['INSTALL_URL'] = $this->currentUrl . '/' . TYPO3_mainDir . 'install/';
451
452 // Connect to database:
453 $conMsg = $this->connectToDatabase($this->globalSiteInfo[$key]['siteInfo']);
454 if (!$conMsg) {
455 $this->getDBInfo($key);
456 $out .= '';
457 } else {
458 $out = $conMsg;
459 }
460
461 // Show details:
462 if ($this->full) {
463 $out .= t3lib_div::view_array($this->globalSiteInfo[$key]);
464 } else {
465 $out .= t3lib_div::view_array($this->globalSiteInfo[$key]['siteInfo']);
466 }
467 } else {
468 $out = $this->error($localconf . ' is not a file!');
469 }
470 } else {
471 $out = $this->error($path . ' is not a directory!');
472 }
473 return $out;
474 }
475
476 /**
477 * Includes "localconf" of a TYPO3 installation an loads $this->globalSiteInfo with this information.
478 *
479 * @param string Absolute path to localconf.php file to include.
480 * @return array Array with information about the site.
481 * @access private
482 * @see processSiteDir()
483 */
484 function includeLocalconf($localconf) {
485 $TYPO3_CONF_VARS = array();
486 $typo_db = '';
487 $typo_db_username = '';
488 $typo_db_password = '';
489 $typo_db_host = '';
490
491 include($localconf);
492
493 $siteInfo = array();
494 $siteInfo['sitename'] = $TYPO3_CONF_VARS['SYS']['sitename'];
495 $siteInfo['TYPO3_db'] = $typo_db;
496 $siteInfo['TYPO3_db_username'] = $typo_db_username;
497 $siteInfo['TYPO3_db_password'] = $typo_db_password;
498 $siteInfo['TYPO3_db_host'] = $typo_db_host;
499 $siteInfo['installToolPassword'] = $TYPO3_CONF_VARS['BE']['installToolPassword'];
500 $siteInfo['warningEmailAddress'] = $TYPO3_CONF_VARS['BE']['warning_email_addr'];
501 $siteInfo['warningMode'] = $TYPO3_CONF_VARS['BE']['warning_mode'];
502
503 $this->globalSiteInfo[md5($localconf)] = array('siteInfo' => $siteInfo, 'TYPO3_CONF_VARS' => $TYPO3_CONF_VARS);
504 return $siteInfo;
505 }
506
507 /**
508 * Connects to a MySQL database with the TYPO3 db host/username/password and database as found in the localconf.php file!
509 * This is NOT compatible with DBAL and connection will obviously just fail with an error message if it turns out that the _DEFAULT handler of a site is not in a MySQL database
510 *
511 * @param array $siteInfo array, containing username/password/host/database values.
512 * @return string Array message if any
513 */
514 function connectToDatabase($siteInfo) {
515 if (@mysql_pconnect($siteInfo['TYPO3_db_host'], $siteInfo['TYPO3_db_username'], $siteInfo['TYPO3_db_password'])) {
516 if (!$siteInfo['TYPO3_db']) {
517 return $this->error('No database selected');
518 } elseif (!mysql_select_db($siteInfo['TYPO3_db'])) {
519 return $this->error('Cannot connect to the current database, "' . $siteInfo['TYPO3_db'] . '"');
520 }
521 } else {
522 return $this->error('The current username, password or host was not accepted when the connection to the database was attempted to be established!');
523 }
524 }
525
526
527 /**
528 * Get database information, assuming standard tables like "be_users"
529 * Adding the information to ->globalSiteInfo
530 *
531 * @param string Key for site in ->globalSiteInfo
532 * @return void
533 * @access private
534 * @see processSiteDir()
535 */
536 function getDBInfo($key) {
537 $DB = $this->globalSiteInfo[$key]['siteInfo']['TYPO3_db'];
538
539 // Non-admin users
540 $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin=0 AND deleted=0');
541 $res = mysql($DB, $query);
542 $row = mysql_fetch_row($res);
543 $this->globalSiteInfo[$key]['siteInfo']['BE_USERS_NONADMIN'] = $row[0];
544
545 // Admin users
546 $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin!=0 AND deleted=0');
547 $res = mysql($DB, $query);
548 $row = mysql_fetch_row($res);
549 $this->globalSiteInfo[$key]['siteInfo']['BE_USERS_ADMIN'] = $row[0];
550
551 // Select Admin users
552 $query = $GLOBALS['TYPO3_DB']->SELECTquery('uid,username,password,email,realName,disable', 'be_users', 'admin!=0 AND deleted=0');
553 $res = mysql($DB, $query);
554 while ($row = mysql_fetch_assoc($res)) {
555 $this->globalSiteInfo[$key]['siteInfo']['ADMINS'][] = $row;
556 }
557 }
558
559
560 /******************************
561 *
562 * Content: Installation Overview
563 *
564 ******************************/
565
566 /**
567 * Creates big table with information about all installations in ->globalSiteInfo
568 *
569 * @return string HTML table
570 */
571 function makeTable() {
572
573 // Header row
574 $info = array();
575 $info[] = 'Site:';
576 $info[] = 'Path:';
577 $info[] = 'Database:';
578 $info[] = 'Username';
579 $info[] = 'Password';
580 $info[] = 'Host';
581 $info[] = 'Links (new win)';
582 $info[] = '#Users NA/A';
583 $info[] = 'Admin be_users Info';
584 $info[] = 'Install Tool Password';
585 $info[] = 'Warning email address';
586 $info[] = 'W.mode';
587 $mainArrRows[] = '
588 <tr bgcolor="#eeeeee">
589 <td nowrap="nowrap" valign="top">' . implode('</td>
590 <td nowrap="nowrap" valign="top">', $info) . '</td>
591 </tr>';
592
593 // Traverse globalSiteInfo for each site:
594 foreach ($this->globalSiteInfo as $k => $all) {
595 $info = array();
596
597 // Sitename and Database details:
598 $info[] = htmlspecialchars($all['siteInfo']['sitename']);
599 $info[] = '<span style="color:#666666;">' . htmlspecialchars($all['siteInfo']['MAIN_DIR']) . '</span>' . htmlspecialchars(substr($all['siteInfo']['SA_PATH'], strlen($all['siteInfo']['MAIN_DIR'])));
600 $info[] = htmlspecialchars($all['siteInfo']['TYPO3_db']);
601 $info[] = htmlspecialchars($all['siteInfo']['TYPO3_db_username']);
602 $info[] = htmlspecialchars($all['siteInfo']['TYPO3_db_password']);
603 $info[] = htmlspecialchars($all['siteInfo']['TYPO3_db_host']);
604
605 // URL
606 $info[] = '<a href="' . htmlspecialchars($all['siteInfo']['URL']) . '" target="' . $this->targetWindow . '">Site</a>' .
607 ' / <a href="' . htmlspecialchars($all['siteInfo']['ADMIN_URL']) . '" target="' . $this->targetWindowAdmin . '">Admin</a>' .
608 ' / <a href="' . htmlspecialchars($all['siteInfo']['INSTALL_URL']) . '" target="' . $this->targetWindowInstall . '">Install</a>';
609 $info[] = htmlspecialchars($all['siteInfo']['BE_USERS_NONADMIN'] . '/' . $all['siteInfo']['BE_USERS_ADMIN']);
610
611 // Admin
612 if (is_array($all['siteInfo']['ADMINS'])) {
613 $lines = array();
614 foreach ($all['siteInfo']['ADMINS'] as $vArr) {
615 $lines[] = htmlspecialchars($vArr['password'] . ' - ' . $vArr['username'] . ' (' . $vArr['realName'] . ', ' . $vArr['email'] . ')');
616 $this->collectAdminPasswords[$vArr['password']][] = array(
617 'path' => $all['siteInfo']['SA_PATH'],
618 'site' => $all['siteInfo']['sitename'],
619 'database' => $all['siteInfo']['TYPO3_db'],
620 'user' => $vArr['username'],
621 'name_email' => $vArr['realName'] . ', ' . $vArr['email']
622 );
623 $this->changeAdminPasswords[$vArr['password']][] = $all['siteInfo']['TYPO3_db'] . ':' . $vArr['uid'] . ':' . $vArr['username'];
624 }
625 $info[] = implode('<br />', $lines);
626 } else {
627 $info[] = $this->error('No DB connection!');
628 }
629 // Install
630 $info[] = htmlspecialchars($all['siteInfo']['installToolPassword']);
631 $this->collectInstallPasswords[$all['siteInfo']['installToolPassword']][] = $all['siteInfo']['SA_PATH'] . ' - ' . $all['siteInfo']['sitename'] . ' - (' . $all['siteInfo']['TYPO3_db'] . ')';
632
633 $info[] = htmlspecialchars($all['siteInfo']['warningEmailAddress']);
634 $info[] = htmlspecialchars($all['siteInfo']['warningMode']);
635
636 // compile
637 $mainArrRows[] = '
638 <tr>
639 <td nowrap="nowrap" valign="top">' . implode('</td>
640 <td nowrap="nowrap" valign="top">', $info) . '</td>
641 </tr>';
642 }
643
644 // Compile / return table finally:
645 $table = '<table border="1" cellpadding="1" cellspacing="1">' . implode('', $mainArrRows) . '</table>';
646 return $table;
647 }
648
649
650 /******************************
651 *
652 * Content: Local extensions
653 *
654 ******************************/
655
656 /**
657 * Based on the globalSiteInfo array, this prints information about local extensions for each site.
658 * In particular version number and most recent mod-time is interesting!
659 *
660 * @return string HTML
661 */
662 function localExtensions() {
663 $this->extensionInfoArray = array();
664
665 // Traverse $this->globalSiteInfo for local extensions:
666 foreach ($this->globalSiteInfo as $k => $all) {
667 if ($all['siteInfo']['SA_PATH']) {
668 $extDir = $all['siteInfo']['SA_PATH'] . '/typo3conf/ext/';
669 if (@is_dir($extDir)) {
670 $this->extensionInfoArray['site'][$k] = array();
671
672 // Get extensions in local directory
673 $extensions = t3lib_div::get_dirs($extDir);
674 if (is_array($extensions)) {
675 foreach ($extensions as $extKey) {
676 // Getting and setting information for extension:
677 $eInfo = $this->getExtensionInfo($extDir, $extKey, $k);
678 $this->extensionInfoArray['site'][$k][$extKey] = $eInfo;
679 $this->extensionInfoArray['ext'][$extKey][$k] = $eInfo;
680 }
681 }
682 }
683 }
684 }
685
686 // Display results:
687 $out = '';
688 $headerRow = '
689 <tr bgcolor="#ccccee" style="font-weight:bold;">
690 <td>Extension key</td>
691 <td>Path</td>
692 <td>Title</td>
693 <td>Ver.</td>
694 <td>Files</td>
695 <td><span title="If M, then there is a manual.">M</span></td>
696 <td>Last mod. time</td>
697 <td>Hash off all file mod. times:</td>
698 <td>TYPO3 ver. req.</td>
699 <td>CGL compliance</td>
700 </tr>
701 ';
702
703 // PER EXTENSION:
704 if (is_array($this->extensionInfoArray['ext'])) {
705 $extensionKeysCollect = array();
706
707 ksort($this->extensionInfoArray['ext']);
708 reset($this->extensionInfoArray['ext']);
709 $rows = array(
710 'reg' => array(),
711 'user' => array()
712 );
713
714 foreach ($this->extensionInfoArray['ext'] as $extKey => $instances) {
715 $mtimes = array();
716
717 // Find most recent mtime of the options:
718 foreach ($instances as $k => $eInfo) {
719 $mtimes[] = $eInfo['mtime'];
720 }
721 // Max mtime:
722 $maxMtime = max($mtimes);
723 $c = 0;
724
725 // So, traverse all sites with the extension present:
726 foreach ($instances as $k => $eInfo) {
727 // Set background color if mtime matches
728 if ($maxMtime == $eInfo['mtime']) {
729 $this->extensionInfoArray['site'][$k][$extKey]['_highlight'] = 1;
730 $bgCol = $eInfo['dirtype'] == 'link' ? ' bgcolor="#ffcccc"' : ' bgcolor="#eeeeee"';
731 } else {
732 $bgCol = ' style="color: #999999; font-style: italic;"';
733 }
734
735 // Make row:
736 $type = substr($extKey, 0, 5) != 'user_' ? 'reg' : 'user';
737 if ($type == 'reg') {
738 $extensionKeysCollect[] = $extKey;
739 }
740
741 if (!is_array($eInfo)) {
742 // Standard listing:
743 $rows[$type][] = '
744 <tr>
745 ' . (!$c ? '<td rowspan="' . count($instances) . '">' . htmlspecialchars($extKey) . '</td>' : '') . '
746 <td nowrap="nowrap" bgcolor="#ccddcc">' . htmlspecialchars($this->globalSiteInfo[$k]['siteInfo']['SA_PATH']) . '</td>
747 <td nowrap="nowrap" bgcolor="#ccddcc" colspan="8"><em>' . htmlspecialchars($eInfo) . '</em></td>
748 </tr>
749 ';
750 } else {
751 // Standard listing:
752 $rows[$type][] = '
753 <tr>
754 ' . (!$c ? '<td rowspan="' . count($instances) . '">' . htmlspecialchars($extKey) . '</td>' : '') . '
755 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($this->globalSiteInfo[$k]['siteInfo']['SA_PATH']) . '</td>
756 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['title']) . '</td>
757 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['version']) . '</td>
758 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['numberfiles']) . '</td>
759 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['manual'] ? 'M' : '-') . '</td>
760 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['mtime'] ? date('d-m-y H:i:s', $eInfo['mtime']) : '') . '</td>
761 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['mtime_hash']) . '</td>
762
763 <td' . $bgCol . '>' . htmlspecialchars($eInfo['TYPO3_version']) . '</td>
764 <td' . $bgCol . '><img src="clear.gif" width="150" height="1" alt="" /><br />' . htmlspecialchars($eInfo['CGLcompliance'] . ($eInfo['CGLcompliance_note'] ? ' - ' . $eInfo['CGLcompliance_note'] : '')) . '</td>
765 </tr>
766 ';
767 }
768 $c++;
769 }
770 }
771
772 // Extensions with registered extension keys:
773 $out .= '
774 <h3>Registered extensions:</h3>
775 <table border="1">' . $headerRow . implode('', $rows['reg']) . '</table>';
776
777 // List of those extension keys in a form field:
778 $extensionKeysCollect = array_unique($extensionKeysCollect);
779 asort($extensionKeysCollect);
780 $out .= '<form action=""><textarea cols="80" rows="10">' . implode(LF, $extensionKeysCollect) . '</textarea></form>';
781
782 // USER extension (prefixed "user_")
783 $out .= '<br />
784 <h3>User extensions:</h3>
785 <table border="1">' . $headerRow . implode('', $rows['user']) . '</table>';
786 }
787
788 // PER SITE:
789 if (is_array($this->extensionInfoArray['site'])) {
790 $rows = array();
791 foreach ($this->extensionInfoArray['site'] as $k => $extensions) {
792
793 // So, traverse all sites with the extension present:
794 $c = 0;
795 foreach ($extensions as $extKey => $eInfo) {
796
797 // Set background color if mtime matches
798 if ($eInfo['_highlight']) {
799 $bgCol = $eInfo['dirtype'] == 'link' ? ' bgcolor="#ffcccc"' : ' bgcolor="#eeeeee"';
800 } else {
801 $bgCol = ' style="color: #999999; font-style: italic;"';
802 }
803
804 // Make row:
805 $rows[] = '
806 <tr>
807 ' . (!$c ? '<td rowspan="' . count($extensions) . '">' . htmlspecialchars($this->globalSiteInfo[$k]['siteInfo']['SA_PATH']) . '</td>' : '') . '
808 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($extKey) . '</td>
809 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['title']) . '</td>
810 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['version']) . '</td>
811 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['numberfiles']) . '</td>
812 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['mtime'] ? date('d-m-y H:i:s', $eInfo['mtime']) : '') . '</td>
813 <td nowrap="nowrap"' . $bgCol . '>' . htmlspecialchars($eInfo['mtime_hash']) . '</td>
814 </tr>
815 ';
816 $c++;
817 }
818 }
819 $out .= '<br />
820 <h3>Sites:</h3>
821 <table border="1">' . implode('', $rows) . '</table>';
822 }
823
824 // Return content
825 return $out;
826 }
827
828 /**
829 * Gets information for an extension, eg. version and most-recently-edited-script
830 *
831 * @param string Path to local extension folder
832 * @param string Extension key
833 * @param string Key to globalSiteInformation array
834 * @return array Information array (unless an error occured)
835 */
836 function getExtensionInfo($path, $extKey, $k) {
837 $file = $path . $extKey . '/ext_emconf.php';
838 if (@is_file($file)) {
839 $_EXTKEY = $extKey;
840 $EM_CONF = array();
841 include($file);
842
843 $eInfo = array();
844 // Info from emconf:
845 $eInfo['title'] = $EM_CONF[$extKey]['title'];
846 $eInfo['version'] = $EM_CONF[$extKey]['version'];
847 $eInfo['CGLcompliance'] = $EM_CONF[$extKey]['CGLcompliance'];
848 $eInfo['CGLcompliance_note'] = $EM_CONF[$extKey]['CGLcompliance_note'];
849 $eInfo['TYPO3_version'] = $EM_CONF[$extKey]['TYPO3_version'];
850 $filesHash = unserialize($EM_CONF[$extKey]['_md5_values_when_last_written']);
851
852 if (!is_array($filesHash) || count($filesHash) < 500) {
853
854 // Get all files list (may take LOONG time):
855 $extPath = $path . $extKey . '/';
856 $fileArr = array();
857 $fileArr = $this->removePrefixPathFromList($this->getAllFilesAndFoldersInPath($fileArr, $extPath), $extPath);
858
859 if (!is_array($fileArr)) {
860 debug(array($fileArr, $extKey, $extPath, $this->getAllFilesAndFoldersInPath(array(), $extPath)), 'ERROR');
861 }
862
863 // Number of files:
864 $eInfo['numberfiles'] = count($fileArr);
865 $eInfo['dirtype'] = filetype($path . $extKey);
866
867 // Most recent modification:
868 $eInfo['mtime_files'] = $this->findMostRecent($fileArr, $extPath);
869 if (count($eInfo['mtime_files'])) {
870 $eInfo['mtime'] = max($eInfo['mtime_files']);
871 }
872 $eInfo['mtime_hash'] = md5(implode(',', $eInfo['mtime_files']));
873 } else {
874 $eInfo['mtime_hash'] = 'No calculation done, too many files in extension: ' . count($filesHash);
875 }
876
877 $eInfo['manual'] = @is_file($path . $extKey . '/doc/manual.sxw');
878
879 return $eInfo;
880 } else {
881 return 'ERROR: No emconf.php file: ' . $file;
882 }
883 }
884
885 /**
886 * Recursively gather all files and folders of extension path.
887 *
888 * @param array Array of files to which new files are added
889 * @param string Path to look up files in
890 * @param string List of file extensions to include. Blank = all
891 * @param boolean If set, directories are included as well.
892 * @return array $fileArr with new entries added.
893 */
894 function getAllFilesAndFoldersInPath($fileArr, $extPath, $extList = '', $regDirs = 0) {
895 if ($regDirs) {
896 $fileArr[] = $extPath;
897 }
898 $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($extPath, $extList, 1, 1));
899
900 $dirs = t3lib_div::get_dirs($extPath);
901 if (is_array($dirs)) {
902 foreach ($dirs as $subdirs) {
903 if ($subdirs && (strcmp($subdirs, 'CVS') || !$this->noCVS)) {
904 $fileArr = $this->getAllFilesAndFoldersInPath($fileArr, $extPath . $subdirs . '/', $extList, $regDirs);
905 }
906 }
907 }
908 return $fileArr;
909 }
910
911 /**
912 * Creates an array with modification times of all files in $fileArr
913 *
914 * @param array Files in extension (rel path)
915 * @param string Abs path prefix for files.
916 * @return array Array with modification times of files (filenames are keys)
917 */
918 function findMostRecent($fileArr, $extPath) {
919 $mtimeArray = array();
920 foreach ($fileArr as $fN) {
921 if ($fN != 'ext_emconf.php') {
922 $mtime = filemtime($extPath . $fN);
923 $mtimeArray[$fN] = $mtime;
924 }
925 }
926 return $mtimeArray;
927 }
928
929 /**
930 * Removes the absolute part of all files/folders in fileArr
931 *
932 * @param array File array
933 * @param string Prefix to remove
934 * @return array Modified file array (or error string)
935 */
936 function removePrefixPathFromList($fileArr, $extPath) {
937 foreach ($fileArr as $k => $absFileRef) {
938 if (t3lib_div::isFirstPartOfStr($absFileRef, $extPath)) {
939 $fileArr[$k] = substr($absFileRef, strlen($extPath));
940 } else {
941 return 'ERROR: One or more of the files was NOT prefixed with the prefix-path!';
942 }
943 }
944 return $fileArr;
945 }
946
947
948 /******************************
949 *
950 * Content: Other
951 *
952 ******************************/
953
954 /**
955 * Shows detailed information for a single installation of TYPO3
956 *
957 * @param string KEY pointing to installation
958 * @return string HTML content
959 */
960 function singleSite($exp) {
961 $all = $this->globalSiteInfo[$exp];
962
963 // General information:
964 $content = '
965 <h2>' . htmlspecialchars($all['siteInfo']['sitename'] . ' (DB: ' . $all['siteInfo']['TYPO3_db']) . ')</h2>
966 <hr />
967
968 <h3>Main details:</h3>
969
970 LINKS: <a href="' . htmlspecialchars($all['siteInfo']['URL']) . '" target="' . $this->targetWindow . '">Site</a> / <a href="' . htmlspecialchars($all['siteInfo']['ADMIN_URL']) . '" target="' . $this->targetWindowAdmin . '">Admin</a> / <a href="' . htmlspecialchars($all['siteInfo']['INSTALL_URL']) . '" target="' . $this->targetWindowInstall . '">Install</a>
971 <br /><br />';
972
973 // Add all information in globalSiteInfo array:
974 $content .= t3lib_div::view_array($all);
975
976 // Last-login:
977 $content .= '
978 <h3>Login-Log for last month:</h3>';
979 $content .= $this->loginLog($all['siteInfo']['TYPO3_db']);
980
981 // Return content
982 return $content;
983 }
984
985 /**
986 * Get last-login log for database.
987 *
988 * @param string Database
989 * @return string HTML
990 */
991 function loginLog($DB) {
992 // Non-admin users
993 //1=login, 2=logout, 3=failed login (+ errorcode 3), 4=failure_warning_email sent
994 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
995 'sys_log.*, be_users.username AS username, be_users.admin AS admin',
996 'sys_log,be_users',
997 'be_users.uid=sys_log.userid AND sys_log.type=255 AND sys_log.tstamp > ' . ($GLOBALS['EXEC_TIME'] - (60 * 60 * 24 * 30)),
998 '',
999 'sys_log.tstamp DESC'
1000 );
1001 $res = mysql($DB, $query);
1002
1003 $dayRef = '';
1004 $lines = array();
1005
1006 while ($row = mysql_fetch_assoc($res)) {
1007 $day = date('d-m-Y', $row['tstamp']);
1008 if ($dayRef != $day) {
1009 $lines[] = '
1010 <h4>' . $day . ':</h4>';
1011 $dayRef = $day;
1012 }
1013 $theLine = date('H:i', $row['tstamp']) . ': ' . str_pad(substr($row['username'], 0, 10), 10) . ' ' . $this->log_getDetails($row['details'], unserialize($row['log_data']));
1014 $theLine = htmlspecialchars($theLine);
1015 $lines[] = $row['admin'] ? '<span class="redclass">' . $theLine . '</span>' : $theLine;
1016 }
1017 return '<pre>' . implode(LF, $lines) . '</pre>';
1018 }
1019
1020 /**
1021 * Compile log details into template string
1022 *
1023 * @param string Log message (template)
1024 * @param array Data array to insert in log message
1025 * @return string Log details.
1026 */
1027 function log_getDetails($text, $data) {
1028 // $code is used later on to substitute errormessages with language-corrected values...
1029 if (is_array($data)) {
1030 return sprintf($text, $data[0], $data[1], $data[2], $data[3], $data[4]);
1031 } else {
1032 return $text;
1033 }
1034 }
1035
1036
1037 /**
1038 * Removing temp_CACHED files for installation
1039 *
1040 * @param string KEY pointing to installation
1041 * @return string HTML content
1042 */
1043 function rmCachedFiles($exp) {
1044 $all = $this->globalSiteInfo[$exp];
1045 $content = '
1046 <h2>' . htmlspecialchars($all['siteInfo']['sitename'] . ' (DB: ' . $all['siteInfo']['TYPO3_db']) . ')</h2>
1047 <hr />
1048 <h3>typo3conf/temp_CACHED_* files:</h3>';
1049
1050 $path = $all['siteInfo']['SA_PATH'] . '/typo3conf/';
1051 if (@is_dir($path)) {
1052 $filesInDir = t3lib_div::getFilesInDir($path, 'php', 1);
1053
1054 foreach ($filesInDir as $kk => $vv) {
1055 if (t3lib_div::isFirstPartOfStr(basename($vv), 'temp_CACHED_')) {
1056 if (strstr(basename($vv), 'ext_localconf.php') || strstr(basename($vv), 'ext_tables.php')) {
1057 $content .= 'REMOVED: ' . $vv . '<br />';
1058 unlink($vv);
1059 if (file_exists($vv)) {
1060 $content .= $this->error('ERROR: File still exists, so could not be removed anyways!') . '<br />';
1061 }
1062 }
1063 }
1064 }
1065 } else {
1066 $content .= $this->error('ERROR: ' . $path . ' was not a directory!');
1067 }
1068
1069 return $content;
1070 }
1071
1072 /**
1073 * Menu for either update/information, showing links for each installation found
1074 *
1075 * @param string Action key "update" or "info"
1076 * @return string HTML output.
1077 */
1078 function menuContent($exp) {
1079 if ($exp) {
1080
1081 // Initialize:
1082 $lines = array();
1083 $head = '';
1084
1085 foreach ($this->globalSiteInfo as $k => $all) {
1086
1087 // Setting section header, if needed.
1088 if ($head != $all['siteInfo']['MAIN_DIR']) {
1089 $lines[] = '
1090 <h4 style="white-space: nowrap;">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($all['siteInfo']['MAIN_DIR'], -18)) . '</h4>';
1091 $head = $all['siteInfo']['MAIN_DIR']; // Set new head...
1092 }
1093
1094 // Display mode:
1095 switch ($exp) {
1096 case 'update':
1097
1098 // Label:
1099 $label = $all['siteInfo']['sitename'] ? $all['siteInfo']['sitename'] : '(DB: ' . $all['siteInfo']['TYPO3_db'] . ')';
1100 $lines[] = '
1101 <hr />
1102 <strong>' . htmlspecialchars($label) . '</strong> (' . htmlspecialchars(substr($all['siteInfo']['SA_PATH'], strlen($all['siteInfo']['MAIN_DIR']) + 1)) . ')<br />';
1103
1104 // To avoid "visited links" display on next hit:
1105 $tempVal = '&_someUniqueValue=' . $GLOBALS['EXEC_TIME'];
1106
1107 // Add links for update:
1108 $url = $this->scriptName . '?type=page&show=rmTempCached&exp=' . $k . $tempVal;
1109 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="TSApage">Remove temp_CACHED files</a></span>';
1110
1111 $url = $all['siteInfo']['INSTALL_URL'] . 'index.php?TYPO3_INSTALL[type]=database&TYPO3_INSTALL[database_type]=import|CURRENT_STATIC' . "&presetWholeTable=1" . $tempVal . '#bottom';
1112 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="TSApage">CURRENT_STATIC</a></span>';
1113
1114 $url = $all['siteInfo']['INSTALL_URL'] . 'index.php?TYPO3_INSTALL[type]=database&TYPO3_INSTALL[database_type]=cmpFile|CURRENT_TABLES' . $tempVal . '#bottom';
1115 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="TSApage">CURRENT_TABLES</a></span>';
1116
1117 // Cache
1118 $url = $all['siteInfo']['INSTALL_URL'] . 'index.php?TYPO3_INSTALL[type]=database&TYPO3_INSTALL[database_type]=cache|' .
1119 "&PRESET[database_clearcache][cache_pages]=1" .
1120 '&PRESET[database_clearcache][cache_pagesection]=1' .
1121 "&PRESET[database_clearcache][cache_hash]=1" .
1122 $tempVal .
1123 '#bottom';
1124 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="TSApage">Clear cache</a></span>';
1125
1126 // Admin link
1127 $url = $all['siteInfo']['ADMIN_URL'] . 'index.php';
1128 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="' . $this->targetWindowAdmin . '">Admin -></a></span>';
1129 break;
1130 case 'info':
1131 // item
1132 $label = $all['siteInfo']['sitename'] ? $all['siteInfo']['sitename'] : '(DB: ' . $all['siteInfo']['TYPO3_db'] . ')';
1133
1134 $url = $this->scriptName . '?type=page&show=info&exp=' . $k;
1135 $lines[] = '<span style="white-space: nowrap;"><a href="' . htmlspecialchars($url) . '" target="TSApage">' . htmlspecialchars($label) . '</a> (' . htmlspecialchars(substr($all['siteInfo']['SA_PATH'], strlen($all['siteInfo']['MAIN_DIR']) + 1)) . '/)</span>';
1136 break;
1137 }
1138 }
1139
1140 // Return result.
1141 return implode('<br />', $lines) . '<br />';
1142 }
1143 }
1144
1145 /**
1146 * Create list of admin logins.
1147 *
1148 * @return string HTML table
1149 */
1150 function makeAdminLogin() {
1151
1152 // Initialize:
1153 $lines = array();
1154 $head = '';
1155
1156 // Traverse installations found:
1157 foreach ($this->globalSiteInfo as $k => $all) {
1158
1159 // Setting section header, if needed.
1160 if ($head != $all['siteInfo']['MAIN_DIR']) {
1161 $lines[] = '
1162 <tr>
1163 <td colspan="2"><br />
1164 <h4>' . htmlspecialchars($all['siteInfo']['MAIN_DIR']) . '</h4>
1165 </td>
1166 </tr>';
1167 $head = $all['siteInfo']['MAIN_DIR'];
1168 }
1169
1170 // item
1171 $label = $all['siteInfo']['sitename'] ? $all['siteInfo']['sitename'] : '(DB: ' . $all['siteInfo']['TYPO3_db'] . ')';
1172 $unique = md5(microtime());
1173
1174 $opts = array();
1175 $defUName = '';
1176
1177 if (is_array($all['siteInfo']['ADMINS'])) {
1178
1179 foreach ($all['siteInfo']['ADMINS'] as $vArr) {
1180 $chalVal = md5($vArr['username'] . ':' . $vArr['password'] . ':' . $unique);
1181 $opts[] = '<option value="' . $chalVal . '">' . htmlspecialchars($vArr['username'] . ($vArr['disable'] ? ' [DISABLED]' : '')) . '</option>';
1182 if (!$defUName) {
1183 $defUName = $vArr['username'];
1184 }
1185 }
1186 }
1187 if (count($opts) > 1) {
1188 $userident = '
1189 <select name="userident" onchange="document[\'' . $k . '\'].username.value=this.options[this.selectedIndex].text;">
1190 ' . implode('
1191 ', $opts) . '
1192 </select>
1193 ';
1194 } else {
1195 $userident = '
1196 (' . $defUName . ')<br />
1197 <input type="hidden" name="userident" value="' . $chalVal . '" />';
1198 }
1199
1200 $form = '
1201 <form name="' . $k . '" action="' . $all['siteInfo']['ADMIN_URL'] . 'index.php" target="EXTERnalWindow" method="post">
1202 <input type="submit" name="submit" value="Login" />
1203 <input type="hidden" name="username" value="' . $defUName . '" />
1204 <input type="hidden" name="challenge" value="' . $unique . '" />
1205 <input type="hidden" name="redirect_url" value="" />
1206 <input type="hidden" name="login_status" value="login" />
1207 ' . trim($userident) . '
1208 </form>';
1209
1210 $lines[] = '
1211 <tr>
1212 <td><strong>' . htmlspecialchars($label) . '</strong></td>
1213 <td nowrap="nowrap">' . trim($form) . '</td>
1214 </tr>';
1215 }
1216
1217 // Return login table:
1218 return '<table border="1" cellpadding="5" cellspacing="1">' . implode('', $lines) . '</table>';
1219 }
1220
1221 /**
1222 * For for changing admin passwords
1223 *
1224 * @return string Form content.
1225 */
1226 function changeAdminPasswordsForm() {
1227 $content = '';
1228
1229 foreach ($this->changeAdminPasswords as $k => $p) {
1230 $content .= '
1231 <h3>' . $k . '</h3>';
1232
1233 foreach ($p as $kk => $pp) {
1234 $content .= '<span style="white-space: nowrap;">';
1235 $content .= '<input type="checkbox" name="SETFIELDS[]" value="' . $pp . '" /> ' . $pp . ' - ';
1236 $content .= htmlspecialchars(implode(' - ', $this->collectAdminPasswords[$k][$kk]));
1237 $content .= '</span><br />';
1238 }
1239 }
1240
1241 $content .= 'New password: <input type="text" name="NEWPASS" /><br />';
1242 $content .= 'New password (md5): <input type="text" name="NEWPASS_md5" /><br />
1243 (This overrules any plain password above!)
1244 <br />';
1245 $content = '
1246 <form action="' . htmlspecialchars($this->scriptName . '?type=page&show=admin') . '" method="post">
1247 ' . $content . '
1248 <input type="submit" name="Set" />
1249 </form>
1250 ';
1251
1252 return $content;
1253 }
1254
1255 /**
1256 * Setting new passwords
1257 *
1258 * @return string Status
1259 * @see changeAdminPasswordsForm()
1260 */
1261 function setNewPasswords() {
1262 $whichFields = t3lib_div::_POST('SETFIELDS');
1263 $pass = trim(t3lib_div::_POST('NEWPASS'));
1264 $passMD5 = t3lib_div::_POST('NEWPASS_md5');
1265
1266 $content = '';
1267 $updatedFlag = 0;
1268 if (($pass || $passMD5) && is_array($whichFields)) {
1269 $pass = $passMD5 ? $passMD5 : md5($pass);
1270
1271 foreach ($whichFields as $values) {
1272 $parts = explode(':', $values);
1273 if (count($parts) > 2) {
1274 $key = $this->mapDBtoKey[$parts[0]];
1275 if ($key && isset($this->globalSiteInfo[$key]['siteInfo'])) {
1276 $error = $this->connectToDatabase($this->globalSiteInfo[$key]['siteInfo']);
1277 if (!$error) {
1278 $DB = $this->globalSiteInfo[$key]['siteInfo']['TYPO3_db'];
1279 $content .= '<h3>Updating ' . $DB . ':</h3>';
1280
1281 $query = $GLOBALS['TYPO3_DB']->UPDATEquery(
1282 'be_users',
1283 'uid=' . intval($parts[1]) . ' AND username="' . addslashes($parts[2]) . '" AND admin!=0',
1284 array('password' => $pass)
1285 ); // username/admin are added to security. But they are certainly redundant!!
1286 mysql($DB, $query);
1287
1288 $content .= 'Affected rows: ' . mysql_affected_rows() . '<br /><hr />';
1289 $updatedFlag = '1';
1290 }
1291 }
1292 }
1293 }
1294 }
1295
1296 $this->initProcess();
1297 return $content;
1298 }
1299 }
1300
1301 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_superadmin.php'])) {
1302 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_superadmin.php']);
1303 }
1304
1305 ?>