All pastes #340013 Raw Edit

Untitled

public php v1 · immutable
·published 2007-02-04 14:12 UTC
rendered paste body
<?phpsession_start();$_SESSION = array();function info($dir){	$open = opendir($dir);	while ($read = readdir($open))		if (is_file($dir . $read))		{			$size += filesize($dir . $read);			$files++;		}	return array($files, $size);}function read($dir, $sub){	$skip = array('.', '..');	$open = opendir($dir);	while ($read = readdir($open))	{		if (is_dir($dir . $read) and !in_array($read, $skip))		{			if (!$sub)			{				$_SESSION['artists']++;				echo "<tr>\n" . '<th colspan="4">' . $read . "</th>\n</tr>\n";				read($dir . '/' . $read . '/', TRUE);			}			else			{				list ($year, $album) = explode(') ', substr($read, 1));				list ($files, $size) = info($dir . $read . '/');				$_SESSION['size']  += $size;				$_SESSION['files'] += $files;				$_SESSION['albums']++;				echo				"<tr>\n" .				'<td>' . $album . "</td>\n" . '<td>' . $year  . "</td>\n" .				'<td>' . $files . "</td>\n" .				'<td>' . round($size / 1048576)  . " MB</td>\n" .				"</tr>\n";			}		}	}}?><style><!--table { border-collapse: collapse }th { text-align: left }th, td { font-family: Verdana, Sans; font-size: 0.8em; padding: 0.5em; border-bottom: 1px solid #aaa }--></style><table><?php read('S:/Audio/', FALSE); ?><tr><th colspan="4">Statistics</th></tr><tr><td>Generated</td><td colspan="3"><?=date('jS F Y')?></td></tr><tr><td>Artists</td><td colspan="3"><?=$_SESSION['artists']?></td></tr><tr><td>Albums</td><td colspan="3"><?=$_SESSION['albums']?></td></tr><tr><td>Files</td><td colspan="3"><?=$_SESSION['files']?></td></tr><tr><td>Size</td><td colspan="3"><?=round($_SESSION['size'] / 1073741824)?> GB</td></tr></table>