00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 $BACK_PATH = '';
00060 require($BACK_PATH.'init.php');
00061 require($BACK_PATH.'template.php');
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 class transferData extends t3lib_transferData {
00082
00083 var $formname = 'loadform';
00084 var $loading = 1;
00085
00086
00087 var $theRecord = Array();
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 function regItem($table, $id, $field, $content) {
00099 t3lib_div::loadTCA($table);
00100 $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
00101 switch($config['type']) {
00102 case 'input':
00103 if (isset($config['checkbox']) && $content==$config['checkbox']) {$content=''; break;}
00104 if (t3lib_div::inList($config['eval'],'date')) {$content = Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$content); }
00105 break;
00106 case 'group':
00107 break;
00108 case 'select':
00109 break;
00110 }
00111 $this->theRecord[$field]=$content;
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 class SC_show_item {
00133
00134
00135 var $table;
00136 var $uid;
00137
00138
00139 var $perms_clause;
00140 var $access;
00141 var $type;
00142 var $doc;
00143
00144
00145 var $content;
00146 var $file;
00147 var $pageinfo;
00148 var $row;
00149
00150
00151
00152
00153
00154
00155
00156
00157 function init() {
00158 global $BE_USER,$BACK_PATH,$TCA;
00159
00160
00161 $this->table = t3lib_div::_GET('table');
00162 $this->uid = t3lib_div::_GET('uid');
00163
00164
00165 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00166 $this->access = 0;
00167 $this->type = '';
00168
00169
00170 if (isset($TCA[$this->table])) {
00171 t3lib_div::loadTCA($this->table);
00172 $this->type = 'db';
00173 $this->uid = intval($this->uid);
00174
00175
00176 if ($this->uid && $BE_USER->check('tables_select',$this->table)) {
00177 if ((string)$this->table=='pages') {
00178 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->uid,$this->perms_clause);
00179 $this->access = is_array($this->pageinfo) ? 1 : 0;
00180 $this->row = $this->pageinfo;
00181 } else {
00182 $this->row = t3lib_BEfunc::getRecord($this->table,$this->uid);
00183 if ($this->row) {
00184 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->row['pid'],$this->perms_clause);
00185 $this->access = is_array($this->pageinfo) ? 1 : 0;
00186 }
00187 }
00188
00189 $treatData = t3lib_div::makeInstance('t3lib_transferData');
00190 $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
00191 $cRow = $treatData->theRecord;
00192 }
00193 } else {
00194
00195 if (substr($this->table,0,3)=='../') {
00196 $this->file = PATH_site.preg_replace('/^\.\.\
00197 } else {
00198 $this->file = $this->table;
00199 }
00200 if (@is_file($this->file) && t3lib_div::isAllowedAbsPath($this->file)) {
00201 $this->type = 'file';
00202 $this->access = 1;
00203 }
00204 }
00205
00206
00207 $this->doc = t3lib_div::makeInstance('template');
00208 $this->doc->backPath = $BACK_PATH;
00209
00210
00211 $this->content.=$this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem'));
00212 $this->content.='<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>';
00213 $this->content.=$this->doc->spacer(5);
00214 }
00215
00216
00217
00218
00219
00220
00221 function main() {
00222
00223 if ($this->access) {
00224 $returnLink = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
00225 $returnLinkTag = $returnLink ? '<a href="' . $returnLink . '" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
00226
00227
00228 $typeRendered = false;
00229 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
00230 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
00231 $typeRenderObj = t3lib_div::getUserObj($classRef);
00232 if(is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
00233 if ($typeRenderObj->isValid($this->type, $this)) {
00234 $this->content .= $typeRenderObj->render($this->type, $this);
00235 $typeRendered = true;
00236 break;
00237 }
00238 }
00239 }
00240 }
00241
00242
00243 if(!$typeRendered) {
00244
00245 switch($this->type) {
00246 case 'db':
00247 $this->renderDBInfo();
00248 break;
00249 case 'file':
00250 $this->renderFileInfo($returnLinkTag);
00251 break;
00252 }
00253 }
00254
00255
00256 if (t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))) {
00257 $this->content = $this->doc->section('',$returnLinkTag.'<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a><br /><br />').$this->content;
00258
00259 $this->content .= $this->doc->section('','<br />'.$returnLinkTag.'<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a>');
00260 }
00261 }
00262 }
00263
00264
00265
00266
00267
00268
00269 function renderDBInfo() {
00270 global $TCA;
00271
00272
00273 $code = $this->doc->getHeader($this->table,$this->row,$this->pageinfo['_thePath'],1).'<br />';
00274 $this->content.= $this->doc->section('',$code);
00275
00276
00277 $tableRows = Array();
00278 $i = 0;
00279
00280
00281 $fieldList = t3lib_div::trimExplode(',', $TCA[$this->table]['interface']['showRecordFieldList'], 1);
00282 foreach ($fieldList as $name) {
00283 $name = trim($name);
00284 if ($TCA[$this->table]['columns'][$name]) {
00285 if (!$TCA[$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name)) {
00286 $i++;
00287 $tableRows[] = '
00288 <tr>
00289 <td class="t3-col-header">' . $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($this->table, $name), 1) . '</td>
00290 <td>' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $this->row['uid'])) . '</td>
00291 </tr>';
00292 }
00293 }
00294 }
00295
00296
00297 $tableCode = '
00298 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
00299 '.implode('',$tableRows).'
00300 </table>';
00301 $this->content.=$this->doc->section('',$tableCode);
00302
00303
00304 $code = '';
00305 $code.= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path').': '.t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-48).'<br />';
00306 $code.= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table').': '.$GLOBALS['LANG']->sL($TCA[$this->table]['ctrl']['title']).' ('.$this->table.') - UID: '.$this->uid.'<br />';
00307 $this->content.= $this->doc->section('', $code);
00308
00309
00310 $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'),$this->makeRef($this->table,$this->row['uid']));
00311
00312
00313 $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesFromThisItem'),$this->makeRefFrom($this->table,$this->row['uid']));
00314 }
00315
00316
00317
00318
00319
00320
00321
00322 function renderFileInfo($returnLinkTag) {
00323
00324
00325 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00326 $imgObj->init();
00327 $imgObj->mayScaleUp = 0;
00328 $imgObj->absPrefix = PATH_site;
00329
00330
00331 $imgInfo = '';
00332 $imgInfo = $imgObj->getImageDimensions($this->file);
00333
00334
00335 $fI = t3lib_div::split_fileref($this->file);
00336 $ext = $fI['fileext'];
00337
00338 $code = '';
00339
00340
00341 $icon = t3lib_BEfunc::getFileIcon($ext);
00342 $url = 'gfx/fileicons/'.$icon;
00343 $fileName = '<img src="'.$url.'" width="18" height="16" align="top" alt="" /><strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', 1).':</strong> '.$fI['file'];
00344 if (t3lib_div::isFirstPartOfStr($this->file,PATH_site)) {
00345 $code.= '<a href="../'.substr($this->file,strlen(PATH_site)).'" target="_blank">'.$fileName.'</a>';
00346 } else {
00347 $code.= $fileName;
00348 }
00349 $code.=' <strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize').':</strong> '.t3lib_div::formatSize(@filesize($this->file)).'<br />
00350 ';
00351 if (is_array($imgInfo)) {
00352 $code.= '<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions').':</strong> '.$imgInfo[0].'x'.$imgInfo[1].' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels');
00353 }
00354 $this->content.=$this->doc->section('',$code);
00355 $this->content.=$this->doc->divider(2);
00356
00357
00358 if (is_array($imgInfo)) {
00359
00360 $imgInfo = $imgObj->imageMagickConvert($this->file,'web','346','200m','','','',1);
00361 $imgInfo[3] = '../'.substr($imgInfo[3],strlen(PATH_site));
00362 $code = '<br />
00363 <div align="center">'.$returnLinkTag.$imgObj->imgTag($imgInfo).'</a></div>';
00364 $this->content.= $this->doc->section('', $code);
00365 } else {
00366 $this->content.= $this->doc->spacer(10);
00367 $lowerFilename = strtolower($this->file);
00368
00369
00370 if (TYPO3_OS!='WIN' && !$GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
00371 if ($ext=='zip') {
00372 $code = '';
00373 $t = array();
00374 exec('unzip -l '.$this->file, $t);
00375 if (is_array($t)) {
00376 reset($t);
00377 next($t);
00378 next($t);
00379 next($t);
00380 while(list(,$val)=each($t)) {
00381 $parts = explode(' ',trim($val),7);
00382 $code.= '
00383 '.$parts[6].'<br />';
00384 }
00385 $code = '
00386 <span class="nobr">'.$code.'
00387 </span>
00388 <br /><br />';
00389 }
00390 $this->content.= $this->doc->section('', $code);
00391 } elseif($ext=='tar' || $ext=='tgz' || substr($lowerFilename,-6)=='tar.gz' || substr($lowerFilename,-5)=='tar.z') {
00392 $code = '';
00393 if ($ext=='tar') {
00394 $compr = '';
00395 } else {
00396 $compr = 'z';
00397 }
00398 $t = array();
00399 exec('tar t'.$compr.'f '.$this->file, $t);
00400 if (is_array($t)) {
00401 foreach($t as $val) {
00402 $code.='
00403 '.$val.'<br />';
00404 }
00405
00406 $code.='
00407 -------<br/>
00408 '.count($t).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.files');
00409
00410 $code = '
00411 <span class="nobr">'.$code.'
00412 </span>
00413 <br /><br />';
00414 }
00415 $this->content.= $this->doc->section('',$code);
00416 }
00417 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
00418 $this->content.= $this->doc->section('',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.cannotDisplayArchive'));
00419 }
00420
00421
00422 if ($ext=='ttf') {
00423 $thumbScript = 'thumbs.php';
00424 $check = basename($this->file).':'.filemtime($this->file).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
00425 $params = '&file='.rawurlencode($this->file);
00426 $params.= '&md5sum='.t3lib_div::shortMD5($check);
00427 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
00428 $thumb = '<br />
00429 <div align="center">'.$returnLinkTag.'<img src="'.htmlspecialchars($url).'" border="0" title="'.htmlspecialchars(trim($this->file)).'" alt="" /></a></div>';
00430 $this->content.= $this->doc->section('',$thumb);
00431 }
00432 }
00433
00434
00435
00436 $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'),$this->makeRef('_FILE',$this->file));
00437 }
00438
00439
00440
00441
00442
00443
00444 function printContent() {
00445 $this->content.= $this->doc->endPage();
00446 $this->content = $this->doc->insertStylesAndJS($this->content);
00447 echo $this->content;
00448 }
00449
00450
00451
00452
00453
00454
00455
00456
00457 function makeRef($table,$ref) {
00458
00459 if ($table==='_FILE') {
00460
00461 $fullIdent = $ref;
00462
00463 if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site)) {
00464 $fullIdent = substr($fullIdent,strlen(PATH_site));
00465 }
00466
00467
00468 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00469 '*',
00470 'sys_refindex',
00471 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
00472 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
00473 ' AND deleted=0'
00474 );
00475 } else {
00476
00477 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00478 '*',
00479 'sys_refindex',
00480 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
00481 ' AND ref_uid='.intval($ref).
00482 ' AND deleted=0'
00483 );
00484 }
00485
00486
00487 $infoData = array();
00488 if (count($rows)) {
00489 $infoData[] = '<tr class="bgColor5 tableheader">' .
00490 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.table').'</td>' .
00491 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.uid').'</td>' .
00492 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field').'</td>'.
00493 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer').'</td>'.
00494 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey').'</td>'.
00495 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting').'</td>'.
00496 '</tr>';
00497 }
00498 foreach($rows as $row) {
00499 $infoData[] = '<tr class="bgColor4"">' .
00500 '<td>'.$row['tablename'].'</td>' .
00501 '<td>'.$row['recuid'].'</td>' .
00502 '<td>'.$row['field'].'</td>'.
00503 '<td>'.$row['flexpointer'].'</td>'.
00504 '<td>'.$row['softref_key'].'</td>'.
00505 '<td>'.$row['sorting'].'</td>'.
00506 '</tr>';
00507 }
00508
00509 return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
00510 }
00511
00512
00513
00514
00515
00516
00517
00518
00519 function makeRefFrom($table,$ref) {
00520
00521 // Look up the path:
00522 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00523 '*',
00524 'sys_refindex',
00525 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
00526 ' AND recuid='.intval($ref)
00527 );
00528
00529 // Compile information for title tag:
00530 $infoData = array();
00531 if (count($rows)) {
00532 $infoData[] = '<tr class="bgColor5 tableheader">' .
00533 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field').'</td>'.
00534 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer').'</td>'.
00535 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey').'</td>'.
00536 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting').'</td>'.
00537 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refTable').'</td>' .
00538 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refUid').'</td>' .
00539 '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refString').'</td>' .
00540 '</tr>';
00541 }
00542 foreach($rows as $row) {
00543 $infoData[] = '<tr class="bgColor4"">' .
00544 '<td>'.$row['field'].'</td>'.
00545 '<td>'.$row['flexpointer'].'</td>'.
00546 '<td>'.$row['softref_key'].'</td>'.
00547 '<td>'.$row['sorting'].'</td>'.
00548 '<td>'.$row['ref_table'].'</td>' .
00549 '<td>'.$row['ref_uid'].'</td>' .
00550 '<td>'.$row['ref_string'].'</td>' .
00551 '</tr>';
00552 }
00553
00554 return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
00555 }
00556 }
00557
00558
00559 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php']) {
00560 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php']);
00561 }
00562
00563
00564
00565
00566 $SOBE = t3lib_div::makeInstance('SC_show_item');
00567 $SOBE->init();
00568 $SOBE->main();
00569 $SOBE->printContent();
00570
00571 ?>