function table_var_dump($variable) { $returnstring = ''; switch (gettype($variable)) { case 'array': $returnstring .= '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">'; foreach ($variable as $key => $value) { $returnstring .= '<TR><TD VALIGN="TOP"><B>' . str_replace("", ' ', $key) . '</B></TD>'; $returnstring .= '<TD VALIGN="TOP">' . gettype($value); if (is_array($value)) { $returnstring .= ' (' . count($value) . ')'; } elseif (is_string($value)) { $returnstring .= ' (' . strlen($value) . ')'; } $returnstring .= '</TD><TD>' . table_var_dump($value) . '</TD></TR>'; } $returnstring .= '</TABLE>'; break; case 'boolean': $returnstring .= $variable ? 'TRUE' : 'FALSE'; break; case 'integer': case 'double': case 'float': $returnstring .= $variable; break; case 'object': case 'null': $returnstring .= string_var_dump($variable); break; case 'string': $variable = str_replace("", ' ', $variable); $varlen = strlen($variable); for ($i = 0; $i < $varlen; $i++) { if (ereg('[' . chr(0xa) . chr(0xd) . ' -;0-9A-Za-z]', $variable[$i])) { $returnstring .= $variable[$i]; } else { $returnstring .= '&#' . str_pad(ord($variable[$i]), 3, '0', STR_PAD_LEFT) . ';'; } } $returnstring = nl2br($returnstring); break; default: $returnstring .= nl2br(htmlspecialchars(str_replace("", ' ', $variable))); break; } return $returnstring; }
function table_var_dump($variable) { global $filename; $returnstring = ''; if (is_array($variable)) { $returnstring .= '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">'; foreach ($variable as $key => $value) { $returnstring .= '<TR><TD VALIGN="TOP"><B>' . str_replace(chr(0), ' ', $key) . '</B></TD>'; $returnstring .= '<TD VALIGN="TOP">' . gettype($value); if (is_array($value)) { $returnstring .= ' (' . count($value) . ')'; } else { if (is_string($value)) { $returnstring .= ' (' . strlen($value) . ')'; } } if ($key == 'data' && isset($variable['image_mime']) && isset($variable['dataoffset'])) { $returnstring .= '</TD><TD><IMG SRC="getid3.thumbnail.php?filename=' . rawurlencode($filename) . '&frameoffset=' . $variable['dataoffset'] . '"></TD>'; } else { $returnstring .= '</TD><TD>' . table_var_dump($value) . '</TD>'; } } $returnstring .= '</TABLE>'; } else { if (gettype($variable) == 'boolean') { if ($variable) { $returnstring .= 'TRUE</TR>'; } else { $returnstring .= 'FALSE</TR>'; } } else { include_once GETID3_INCLUDEPATH . 'getid3.getimagesize.php'; $imagechunkcheck = GetDataImageSize(substr($variable, 0, FREAD_BUFFER_SIZE)); if ($imagechunkcheck[2] >= 1 && $imagechunkcheck[2] <= 3) { $imagetypes = array(1 => 'image/gif', 2 => 'image/jpeg', 3 => 'image/png'); $returnstring .= '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">'; $returnstring .= '<TR><TD><B>type</B></TD><TD>' . $imagetypes["{$imagechunkcheck[2]}"] . '</TD></TR>'; $returnstring .= '<TR><TD><B>width</B></TD><TD>' . number_format($imagechunkcheck[0]) . ' px</TD></TR>'; $returnstring .= '<TR><TD><B>height</B></TD><TD>' . number_format($imagechunkcheck[1]) . ' px</TD></TR>'; $returnstring .= '<TR><TD><B>size</B></TD><TD>' . number_format(strlen($variable)) . ' bytes</TD></TR></TABLE></TR>'; } else { $returnstring .= htmlspecialchars(str_replace(chr(0), ' ', $variable)) . '</TR>'; } } } return $returnstring; }
function table_var_dump($variable) { $returnstring = ''; switch (gettype($variable)) { case 'array': $returnstring .= '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">'; foreach ($variable as $key => $value) { $returnstring .= '<TR><TD VALIGN="TOP"><B>' . str_replace(chr(0), ' ', $key) . '</B></TD>'; $returnstring .= '<TD VALIGN="TOP">' . gettype($value); if (is_array($value)) { $returnstring .= ' (' . count($value) . ')'; } elseif (is_string($value)) { $returnstring .= ' (' . strlen($value) . ')'; } if ($key == 'data' && isset($variable['image_mime']) && isset($variable['dataoffset'])) { require_once GETID3_INCLUDEPATH . 'getid3.getimagesize.php'; $imageinfo = array(); $imagechunkcheck = GetDataImageSize($value, $imageinfo); $DumpedImageSRC = (!empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '.getid3') . '.' . $variable['dataoffset'] . '.' . ImageTypesLookup($imagechunkcheck[2]); if ($tempimagefile = fopen($DumpedImageSRC, 'wb')) { fwrite($tempimagefile, $value); fclose($tempimagefile); } $returnstring .= '</TD><TD><IMG SRC="' . $DumpedImageSRC . '" WIDTH="' . $imagechunkcheck[0] . '" HEIGHT="' . $imagechunkcheck[1] . '"></TD></TR>'; } else { $returnstring .= '</TD><TD>' . table_var_dump($value) . '</TD></TR>'; } } $returnstring .= '</TABLE>'; break; case 'boolean': $returnstring .= $variable ? 'TRUE' : 'FALSE'; break; case 'integer': case 'double': case 'float': $returnstring .= $variable; break; case 'object': case 'null': $returnstring .= string_var_dump($variable); break; case 'string': $variable = str_replace(chr(0), ' ', $variable); $varlen = strlen($variable); for ($i = 0; $i < $varlen; $i++) { if (ereg('[' . chr(0xa) . chr(0xd) . ' -;0-9A-Za-z]', $variable[$i])) { $returnstring .= $variable[$i]; } else { $returnstring .= '&#' . str_pad(ord($variable[$i]), 3, '0', STR_PAD_LEFT) . ';'; } } $returnstring = nl2br($returnstring); break; default: require_once GETID3_INCLUDEPATH . 'getid3.getimagesize.php'; $imageinfo = array(); $imagechunkcheck = GetDataImageSize(substr($variable, 0, FREAD_BUFFER_SIZE), $imageinfo); if ($imagechunkcheck[2] >= 1 && $imagechunkcheck[2] <= 3) { $returnstring .= '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">'; $returnstring .= '<TR><TD><B>type</B></TD><TD>' . ImageTypesLookup($imagechunkcheck[2]) . '</TD></TR>'; $returnstring .= '<TR><TD><B>width</B></TD><TD>' . number_format($imagechunkcheck[0]) . ' px</TD></TR>'; $returnstring .= '<TR><TD><B>height</B></TD><TD>' . number_format($imagechunkcheck[1]) . ' px</TD></TR>'; $returnstring .= '<TR><TD><B>size</B></TD><TD>' . number_format(strlen($variable)) . ' bytes</TD></TR></TABLE>'; } else { $returnstring .= nl2br(htmlspecialchars(str_replace(chr(0), ' ', $variable))); } break; } return $returnstring; }
function table_var_dump($variable, $wrap_in_td = false) { $returnstring = ''; switch (gettype($variable)) { case 'array': $returnstring .= $wrap_in_td ? '<td>' : ''; $returnstring .= '<table class="dump" cellspacing="0" cellpadding="2">'; foreach ($variable as $key => $value) { $returnstring .= '<tr><td valign="top"><b>' . str_replace("", ' ', $key) . '</b></td>'; $returnstring .= '<td valign="top">' . gettype($value); if (is_array($value)) { $returnstring .= ' (' . count($value) . ')'; } elseif (is_string($value)) { $returnstring .= ' (' . strlen($value) . ')'; } if ($key == 'data' && isset($variable['image_mime']) && isset($variable['dataoffset'])) { $imageinfo = array(); $imagechunkcheck = getid3_lib::GetDataImageSize($value, $imageinfo); $DumpedImageSRC = (!empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '.getid3') . '.' . $variable['dataoffset'] . '.' . getid3_lib::ImageTypesLookup($imagechunkcheck[2]); if ($tempimagefile = @fopen($DumpedImageSRC, 'wb')) { fwrite($tempimagefile, $value); fclose($tempimagefile); } $returnstring .= '</td><td><img src="' . $_SERVER['PHP_SELF'] . '?showfile=' . urlencode($DumpedImageSRC) . '&md5=' . md5_file($DumpedImageSRC) . '" width="' . $imagechunkcheck[0] . '" height="' . $imagechunkcheck[1] . '"></td></tr>'; } else { $returnstring .= '</td>' . table_var_dump($value, true) . '</tr>'; } } $returnstring .= '</table>'; $returnstring .= $wrap_in_td ? '</td>' : ''; break; case 'boolean': $returnstring .= ($wrap_in_td ? '<td class="dump_boolean">' : '') . ($variable ? 'TRUE' : 'FALSE') . ($wrap_in_td ? '</td>' : ''); break; case 'integer': $returnstring .= ($wrap_in_td ? '<td class="dump_integer">' : '') . $variable . ($wrap_in_td ? '</td>' : ''); break; case 'double': case 'float': $returnstring .= ($wrap_in_td ? '<td class="dump_double">' : '') . $variable . ($wrap_in_td ? '</td>' : ''); break; case 'object': case 'null': $returnstring .= ($wrap_in_td ? '<td>' : '') . string_var_dump($variable) . ($wrap_in_td ? '</td>' : ''); break; case 'string': $variable = str_replace("", ' ', $variable); $varlen = strlen($variable); for ($i = 0; $i < $varlen; $i++) { if (ereg('[' . "\n\r" . ' -;0-9A-Za-z]', $variable[$i])) { $returnstring .= $variable[$i]; } else { $returnstring .= '&#' . str_pad(ord($variable[$i]), 3, '0', STR_PAD_LEFT) . ';'; } } $returnstring = ($wrap_in_td ? '<td class="dump_string">' : '') . nl2br($returnstring) . ($wrap_in_td ? '</td>' : ''); break; default: $imageinfo = array(); $imagechunkcheck = getid3_lib::GetDataImageSize($variable, $imageinfo); if ($imagechunkcheck[2] >= 1 && $imagechunkcheck[2] <= 3) { $returnstring .= $wrap_in_td ? '<td>' : ''; $returnstring .= '<table class="dump" cellspacing="0" cellpadding="2">'; $returnstring .= '<tr><td><b>type</b></td><td>' . getid3_lib::ImageTypesLookup($imagechunkcheck[2]) . '</td></tr>'; $returnstring .= '<tr><td><b>width</b></td><td>' . number_format($imagechunkcheck[0]) . ' px</td></tr>'; $returnstring .= '<tr><td><b>height</b></td><td>' . number_format($imagechunkcheck[1]) . ' px</td></tr>'; $returnstring .= '<tr><td><b>size</b></td><td>' . number_format(strlen($variable)) . ' bytes</td></tr></table>'; $returnstring .= $wrap_in_td ? '</td>' : ''; } else { $returnstring .= ($wrap_in_td ? '<td>' : '') . nl2br(htmlspecialchars(str_replace("", ' ', $variable))) . ($wrap_in_td ? '</td>' : ''); } break; } return $returnstring; }
function table_var_dump($variable, $wrap_in_td = false, $encoding = 'ISO-8859-1') { $returnstring = ''; switch (gettype($variable)) { case 'array': $returnstring .= $wrap_in_td ? '<td>' : ''; $returnstring .= '<table class="dump" cellspacing="0" cellpadding="2">'; foreach ($variable as $key => $value) { $returnstring .= '<tr><td valign="top"><b>' . str_replace("", ' ', $key) . '</b></td>' . "\n"; $returnstring .= '<td valign="top">' . gettype($value); if (is_array($value)) { $returnstring .= ' (' . count($value) . ')'; } elseif (is_string($value)) { $returnstring .= ' (' . strlen($value) . ')'; } //if (($key == 'data') && isset($variable['image_mime']) && isset($variable['dataoffset'])) { if ($key == 'data' && isset($variable['image_mime'])) { $imageinfo = array(); $imagechunkcheck = getid3_lib::GetDataImageSize($value, $imageinfo); $returnstring .= '</td>' . "\n" . '<td><img src="data:' . $variable['image_mime'] . ';base64,' . base64_encode($value) . '" width="' . $imagechunkcheck[0] . '" height="' . $imagechunkcheck[1] . '"></td></tr>' . "\n"; } else { $returnstring .= '</td>' . "\n" . table_var_dump($value, true, $encoding) . '</tr>' . "\n"; } } $returnstring .= '</table>' . "\n"; $returnstring .= $wrap_in_td ? '</td>' . "\n" : ''; break; case 'boolean': $returnstring .= ($wrap_in_td ? '<td class="dump_boolean">' : '') . ($variable ? 'TRUE' : 'FALSE') . ($wrap_in_td ? '</td>' . "\n" : ''); break; case 'integer': $returnstring .= ($wrap_in_td ? '<td class="dump_integer">' : '') . $variable . ($wrap_in_td ? '</td>' . "\n" : ''); break; case 'double': case 'float': $returnstring .= ($wrap_in_td ? '<td class="dump_double">' : '') . $variable . ($wrap_in_td ? '</td>' . "\n" : ''); break; case 'object': case 'null': $returnstring .= ($wrap_in_td ? '<td>' : '') . string_var_dump($variable) . ($wrap_in_td ? '</td>' . "\n" : ''); break; case 'string': //$variable = str_replace("\x00", ' ', $variable); //$varlen = strlen($variable); //for ($i = 0; $i < $varlen; $i++) { // $returnstring .= htmlentities($variable{$i}, ENT_QUOTES, $encoding); //} $returnstring = htmlentities($variable, ENT_QUOTES, $encoding); $returnstring = ($wrap_in_td ? '<td class="dump_string">' : '') . nl2br($returnstring) . ($wrap_in_td ? '</td>' . "\n" : ''); break; default: $imageinfo = array(); $imagechunkcheck = getid3_lib::GetDataImageSize($variable, $imageinfo); if ($imagechunkcheck[2] >= 1 && $imagechunkcheck[2] <= 3) { $returnstring .= $wrap_in_td ? '<td>' : ''; $returnstring .= '<table class="dump" cellspacing="0" cellpadding="2">'; $returnstring .= '<tr><td><b>type</b></td><td>' . getid3_lib::ImageTypesLookup($imagechunkcheck[2]) . '</td></tr>' . "\n"; $returnstring .= '<tr><td><b>width</b></td><td>' . number_format($imagechunkcheck[0]) . ' px</td></tr>' . "\n"; $returnstring .= '<tr><td><b>height</b></td><td>' . number_format($imagechunkcheck[1]) . ' px</td></tr>' . "\n"; $returnstring .= '<tr><td><b>size</b></td><td>' . number_format(strlen($variable)) . ' bytes</td></tr></table>' . "\n"; $returnstring .= $wrap_in_td ? '</td>' . "\n" : ''; } else { $returnstring .= ($wrap_in_td ? '<td>' : '') . nl2br(htmlspecialchars(str_replace("", ' ', $variable))) . ($wrap_in_td ? '</td>' . "\n" : ''); } break; } return $returnstring; }
echo 'Browse: <A HREF="' . $PHP_SELF . '?listdirectory=' . urlencode($listdirectory) . '">' . $listdirectory . '</A><BR>'; echo 'Parse this file as: '; $allowedFormats = array('zip', 'ogg', 'riff', 'mpeg', 'midi', 'image', 'mp3'); foreach ($allowedFormats as $possibleFormat) { if (isset($assumeFormat) && $assumeFormat == $possibleFormat) { echo '<B>' . $possibleFormat . '</B> | '; } else { echo '<A HREF="' . $PHP_SELF . '?filename=' . urlencode($filename) . '&assumeFormat=' . $possibleFormat . '">' . $possibleFormat . '</A> | '; } } if (isset($assumeFormat)) { echo '<A HREF="' . $PHP_SELF . '?filename=' . urlencode($filename) . '">default</A><BR>'; } else { echo '<B>default</B><BR>'; } echo table_var_dump($MP3fileInfo); $endtime = getmicrotime(); echo 'File parsed in ' . number_format($endtime - $starttime, 3) . ' seconds.<BR>'; } else { if (!isset($listdirectory)) { $listdirectory = '.'; } // if (!is_dir($listdirectory) && is_dir(str_replace(chr(92).chr(39), chr(39), $listdirectory))) { if (!is_dir($listdirectory)) { // Directory names with single quotes or double quotes in them will likely come out addslashes()'d // so this will replace \' with ' (can't use stripslashes(), that would get rid of all slashes!) $listdirectory = str_replace(chr(92) . chr(92), chr(92), $listdirectory); // \\ -> \ $listdirectory = str_replace(chr(92) . chr(39), chr(39), $listdirectory); // \' -> ' $listdirectory = str_replace(chr(92) . chr(34), chr(34), $listdirectory);
} echo 'Parse this file as: '; $allowedFormats = array('zip', 'ogg', 'riff', 'mpeg', 'midi', 'aac', 'mp3'); foreach ($allowedFormats as $possibleFormat) { if (isset($_REQUEST['assumeFormat']) && $_REQUEST['assumeFormat'] == $possibleFormat) { echo '<B>' . $possibleFormat . '</B> | '; } else { echo '<A HREF="' . $_SERVER['PHP_SELF'] . '?filename=' . urlencode($_REQUEST['filename']) . '&assumeFormat=' . $possibleFormat . '">' . $possibleFormat . '</A> | '; } } if (isset($_REQUEST['assumeFormat'])) { echo '<A HREF="' . $_SERVER['PHP_SELF'] . '?filename=' . urlencode($_REQUEST['filename']) . '">default</A><BR>'; } else { echo '<B>default</B><BR>'; } echo table_var_dump($ThisFileInfo); $endtime = getmicrotime(); echo 'File parsed in ' . number_format($endtime - $starttime, 3) . ' seconds.<BR>'; } else { $listdirectory = isset($_REQUEST['listdirectory']) ? SafeStripSlashes($_REQUEST['listdirectory']) : '.'; $listdirectory = realpath($listdirectory); // get rid of /../../ references $currentfulldir = $listdirectory . '/'; if (substr(php_uname(), 0, 7) == 'Windows') { // this mostly just gives a consistant look to Windows and *nix filesystems // (windows uses \ as directory seperator, *nix uses /) $currentfulldir = str_replace('\\', '/', $listdirectory . '/'); } if ($handle = @opendir($listdirectory)) { echo str_repeat(' ', 300); // IE buffers the first 300 or so chars, making this progressive display useless - fill the buffer with spaces