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
00059 $BACK_PATH = '';
00060 require($BACK_PATH.'init.php');
00061 require($BACK_PATH.'template.php');
00062 require_once(PATH_t3lib.'class.t3lib_page.php');
00063 require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php');
00064 require_once(PATH_t3lib.'class.t3lib_transferdata.php');
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00084 class transferData extends t3lib_transferData {
00085
00086 var $formname = 'loadform';
00087 var $loading = 1;
00088
00089
00090 var $theRecord = Array();
00091
00101 function regItem($table, $id, $field, $content) {
00102 t3lib_div::loadTCA($table);
00103 $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
00104 switch($config['type']) {
00105 case 'input':
00106 if (isset($config['checkbox']) && $content==$config['checkbox']) {$content=''; break;}
00107 if (t3lib_div::inList($config['eval'],'date')) {$content = Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$content); }
00108 break;
00109 case 'group':
00110 break;
00111 case 'select':
00112 break;
00113 }
00114 $this->theRecord[$field]=$content;
00115 }
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00135 class SC_show_item {
00136
00137
00138 var $table;
00139 var $uid;
00140
00141
00142 var $perms_clause;
00143 var $access;
00144 var $type;
00145 var $doc;
00146
00147
00148 var $content;
00149 var $file;
00150 var $pageinfo;
00151 var $row;
00152
00153
00160 function init() {
00161 global $BE_USER,$LANG,$BACK_PATH,$TCA;
00162
00163
00164 $this->table = t3lib_div::_GET('table');
00165 $this->uid = t3lib_div::_GET('uid');
00166
00167
00168 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00169 $this->access = 0;
00170 $this->type = '';
00171
00172
00173 if (isset($TCA[$this->table])) {
00174 t3lib_div::loadTCA($this->table);
00175 $this->type = 'db';
00176 $this->uid = intval($this->uid);
00177
00178
00179 if ($this->uid && $BE_USER->check('tables_select',$this->table)) {
00180 if ((string)$this->table=='pages') {
00181 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->uid,$this->perms_clause);
00182 $this->access = is_array($this->pageinfo) ? 1 : 0;
00183 $this->row = $this->pageinfo;
00184 } else {
00185 $this->row = t3lib_BEfunc::getRecord($this->table,$this->uid);
00186 if ($this->row) {
00187 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->row['pid'],$this->perms_clause);
00188 $this->access = is_array($this->pageinfo) ? 1 : 0;
00189 }
00190 }
00191
00192 $treatData = t3lib_div::makeInstance('t3lib_transferData');
00193 $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
00194 $cRow = $treatData->theRecord;
00195 }
00196 } else {
00197
00198 if (substr($this->table,0,3)=='../') {
00199 $this->file = PATH_site.ereg_replace('^\.\./','',$this->table);
00200 } else {
00201 $this->file = $this->table;
00202 }
00203 if (@is_file($this->file) && t3lib_div::isAllowedAbsPath($this->file)) {
00204 $this->type = 'file';
00205 $this->access = 1;
00206 }
00207 }
00208
00209
00210 $this->doc = t3lib_div::makeInstance('smallDoc');
00211 $this->doc->backPath = $BACK_PATH;
00212 $this->doc->docType = 'xhtml_trans';
00213
00214
00215 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.viewItem'));
00216 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.viewItem'));
00217 $this->content.=$this->doc->spacer(5);
00218 }
00219
00225 function main() {
00226 global $LANG;
00227
00228 if ($this->access) {
00229 $returnLinkTag = t3lib_div::_GP('returnUrl') ? '<a href="'.t3lib_div::_GP('returnUrl').'" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
00230
00231
00232 $typeRendered = false;
00233 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
00234 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
00235 $typeRenderObj = t3lib_div::getUserObj($classRef);
00236 if(is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
00237 if ($typeRenderObj->isValid($this->type, $this)) {
00238 $this->content .= $typeRenderObj->render($this->type, $this);
00239 $typeRendered = true;
00240 break;
00241 }
00242 }
00243 }
00244 }
00245
00246
00247 if(!$typeRendered) {
00248
00249 switch($this->type) {
00250 case 'db':
00251 $this->renderDBInfo();
00252 break;
00253 case 'file':
00254 $this->renderFileInfo($returnLinkTag);
00255 break;
00256 }
00257 }
00258
00259
00260 if (t3lib_div::_GP('returnUrl')) {
00261 $this->content = $this->doc->section('',$returnLinkTag.'<strong>'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a><br /><br />').$this->content;
00262
00263 $this->content .= $this->doc->section('','<br />'.$returnLinkTag.'<strong>'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a>');
00264 }
00265 }
00266 }
00267
00273 function renderDBInfo() {
00274 global $LANG,$TCA;
00275
00276
00277 $code = $this->doc->getHeader($this->table,$this->row,$this->pageinfo['_thePath'],1).'<br />';
00278 $this->content.= $this->doc->section('',$code);
00279
00280
00281 $tableRows = Array();
00282 $i = 0;
00283
00284
00285 $fieldList = t3lib_div::trimExplode(',',$TCA[$this->table]['interface']['showRecordFieldList'],1);
00286 foreach($fieldList as $name) {
00287 $name = trim($name);
00288 if ($TCA[$this->table]['columns'][$name]) {
00289 if (!$TCA[$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$this->table.':'.$name)) {
00290 $i++;
00291 $tableRows[] = '
00292 <tr>
00293 <td class="bgColor5">'.$LANG->sL(t3lib_BEfunc::getItemLabel($this->table,$name),1).'</td>
00294 <td class="bgColor4">'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table,$name,$this->row[$name])).'</td>
00295 </tr>';
00296 }
00297 }
00298 }
00299
00300
00301 $tableCode = '
00302 <table border="0" cellpadding="1" cellspacing="1" id="typo3-showitem">
00303 '.implode('',$tableRows).'
00304 </table>';
00305 $this->content.=$this->doc->section('',$tableCode);
00306 $this->content.=$this->doc->divider(2);
00307
00308
00309 $code = '';
00310 $code.= $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path').': '.t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-48).'<br />';
00311 $code.= $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.table').': '.$LANG->sL($TCA[$this->table]['ctrl']['title']).' ('.$this->table.') - UID: '.$this->uid.'<br />';
00312 $this->content.= $this->doc->section('', $code);
00313
00314
00315 $this->content.= $this->doc->section('References to this item:',$this->makeRef($this->table,$this->row['uid']));
00316
00317
00318 $this->content.= $this->doc->section('References from this item:',$this->makeRefFrom($this->table,$this->row['uid']));
00319 }
00320
00327 function renderFileInfo($returnLinkTag) {
00328 global $LANG;
00329
00330
00331 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
00332 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00333 $imgObj->init();
00334 $imgObj->mayScaleUp = 0;
00335 $imgObj->absPrefix = PATH_site;
00336
00337
00338 $imgInfo = '';
00339 $imgInfo = $imgObj->getImageDimensions($this->file);
00340
00341
00342 $fI = t3lib_div::split_fileref($this->file);
00343 $ext = $fI['fileext'];
00344
00345 $code = '';
00346
00347
00348 $icon = t3lib_BEfunc::getFileIcon($ext);
00349 $url = 'gfx/fileicons/'.$icon;
00350 $fileName = '<img src="'.$url.'" width="18" height="16" align="top" alt="" /><b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.file',1).':</b> '.$fI['file'];
00351 if (t3lib_div::isFirstPartOfStr($this->file,PATH_site)) {
00352 $code.= '<a href="../'.substr($this->file,strlen(PATH_site)).'" target="_blank">'.$fileName.'</a>';
00353 } else {
00354 $code.= $fileName;
00355 }
00356 $code.=' <b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.filesize').':</b> '.t3lib_div::formatSize(@filesize($this->file)).'<br />
00357 ';
00358 if (is_array($imgInfo)) {
00359 $code.= '<b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.dimensions').':</b> '.$imgInfo[0].'x'.$imgInfo[1].' pixels';
00360 }
00361 $this->content.=$this->doc->section('',$code);
00362 $this->content.=$this->doc->divider(2);
00363
00364
00365 if (is_array($imgInfo)) {
00366
00367 $imgInfo = $imgObj->imageMagickConvert($this->file,'web','346','200m','','','',1);
00368 $imgInfo[3] = '../'.substr($imgInfo[3],strlen(PATH_site));
00369 $code = '<br />
00370 <div align="center">'.$returnLinkTag.$imgObj->imgTag($imgInfo).'</a></div>';
00371 $this->content.= $this->doc->section('', $code);
00372 } else {
00373 $this->content.= $this->doc->spacer(10);
00374 $lowerFilename = strtolower($this->file);
00375
00376
00377 if (TYPO3_OS!='WIN' && !$GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
00378 if ($ext=='zip') {
00379 $code = '';
00380 $t = array();
00381 exec('unzip -l '.$this->file, $t);
00382 if (is_array($t)) {
00383 reset($t);
00384 next($t);
00385 next($t);
00386 next($t);
00387 while(list(,$val)=each($t)) {
00388 $parts = explode(' ',trim($val),7);
00389 $code.= '
00390 '.$parts[6].'<br />';
00391 }
00392 $code = '
00393 <span class="nobr">'.$code.'
00394 </span>
00395 <br /><br />';
00396 }
00397 $this->content.= $this->doc->section('', $code);
00398 } elseif($ext=='tar' || $ext=='tgz' || substr($lowerFilename,-6)=='tar.gz' || substr($lowerFilename,-5)=='tar.z') {
00399 $code = '';
00400 if ($ext=='tar') {
00401 $compr = '';
00402 } else {
00403 $compr = 'z';
00404 }
00405 $t = array();
00406 exec('tar t'.$compr.'f '.$this->file, $t);
00407 if (is_array($t)) {
00408 foreach($t as $val) {
00409 $code.='
00410 '.$val.'<br />';
00411 }
00412
00413 $code.='
00414 -------<br/>
00415 '.count($t).' files';
00416
00417 $code = '
00418 <span class="nobr">'.$code.'
00419 </span>
00420 <br /><br />';
00421 }
00422 $this->content.= $this->doc->section('',$code);
00423 }
00424 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
00425 $this->content.= $this->doc->section('','Sorry, TYPO3_CONF_VARS[BE][disable_exec_function] was set, so cannot display content of archive file.');
00426 }
00427
00428
00429 if ($ext=='ttf') {
00430 $thumbScript = 'thumbs.php';
00431 $params = '&file='.rawurlencode($this->file);
00432 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
00433 $thumb = '<br />
00434 <div align="center">'.$returnLinkTag.'<img src="'.htmlspecialchars($url).'" border="0" title="'.htmlspecialchars(trim($this->file)).'" alt="" /></a></div>';
00435 $this->content.= $this->doc->section('',$thumb);
00436 }
00437 }
00438
00439
00440
00441 $this->content.= $this->doc->section('References to this item:',$this->makeRef('_FILE',$this->file));
00442 }
00443
00449 function printContent() {
00450 $this->content.= $this->doc->endPage();
00451 $this->content = $this->doc->insertStylesAndJS($this->content);
00452 echo $this->content;
00453 }
00454
00462 function makeRef($table,$ref) {
00463
00464 if ($table==='_FILE') {
00465
00466 $fullIdent = $ref;
00467
00468 if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site)) {
00469 $fullIdent = substr($fullIdent,strlen(PATH_site));
00470 }
00471
00472
00473 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00474 '*',
00475 'sys_refindex',
00476 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
00477 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
00478 ' AND deleted=0'
00479 );
00480 } else {
00481
00482 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00483 '*',
00484 'sys_refindex',
00485 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
00486 ' AND ref_uid='.intval($ref).
00487 ' AND deleted=0'
00488 );
00489 }
00490
00491
00492 $infoData = array();
00493 if (count($rows)) {
00494 $infoData[] = '<tr class="bgColor5 tableheader">' .
00495 '<td>Table:</td>' .
00496 '<td>Uid:</td>' .
00497 '<td>Field:</td>'.
00498 '<td>Flexpointer:</td>'.
00499 '<td>Softref Key:</td>'.
00500 '<td>Sorting:</td>'.
00501 '</tr>';
00502 }
00503 foreach($rows as $row) {
00504 $infoData[] = '<tr class="bgColor4"">' .
00505 '<td>'.$row['tablename'].'</td>' .
00506 '<td>'.$row['recuid'].'</td>' .
00507 '<td>'.$row['field'].'</td>'.
00508 '<td>'.$row['flexpointer'].'</td>'.
00509 '<td>'.$row['softref_key'].'</td>'.
00510 '<td>'.$row['sorting'].'</td>'.
00511 '</tr>';
00512 }
00513
00514 return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
00515 }
00516
00524 function makeRefFrom($table,$ref) {
00525
00526 // Look up the path:
00527 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00528 '*',
00529 'sys_refindex',
00530 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
00531 ' AND recuid='.intval($ref)
00532 );
00533
00534 // Compile information for title tag:
00535 $infoData = array();
00536 if (count($rows)) {
00537 $infoData[] = '<tr class="bgColor5 tableheader">' .
00538 '<td>Field:</td>'.
00539 '<td>Flexpointer:</td>'.
00540 '<td>Softref Key:</td>'.
00541 '<td>Sorting:</td>'.
00542 '<td>Ref Table:</td>' .
00543 '<td>Ref Uid:</td>' .
00544 '<td>Ref String:</td>' .
00545 '</tr>';
00546 }
00547 foreach($rows as $row) {
00548 $infoData[] = '<tr class="bgColor4"">' .
00549 '<td>'.$row['field'].'</td>'.
00550 '<td>'.$row['flexpointer'].'</td>'.
00551 '<td>'.$row['softref_key'].'</td>'.
00552 '<td>'.$row['sorting'].'</td>'.
00553 '<td>'.$row['ref_table'].'</td>' .
00554 '<td>'.$row['ref_uid'].'</td>' .
00555 '<td>'.$row['ref_string'].'</td>' .
00556 '</tr>';
00557 }
00558
00559 return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
00560 }
00561 }
00562
00563
00564 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php']) {
00565 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php']);
00566 }
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580 $SOBE = t3lib_div::makeInstance('SC_show_item');
00581 $SOBE->init();
00582 $SOBE->main();
00583 $SOBE->printContent();
00584 ?>