rendered paste body<?php $name = "Shuttle-X Captures"; // Who are the stats for? $software = "3"; // Which upload software do you use? 1 for screengrab, 2 for GrabUp, 3 for jing. For others: remove this line. $theme = "2"; // Which theme to use? 1 for original white, 2 for my dark version. $background = "none"; // Website background to use, if you dont want one, skip this step, the script will then use theme background color. $grabspath = "images"; // Where are the grabs located? date_default_timezone_set('America/Vancouver'); if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if (preg_match("/\.png/i", $file) == true || preg_match("/\.jpg/i", $file) == true || preg_match("/\.bmp/i", $file) == true || preg_match("/\.jpeg/i", $file) == true) { $mtime = filemtime("./{$file}"); $allgrabs["".date('Y', $mtime).""]["".date('n', $mtime).""][] = $file; $bydaylist[date("n", $mtime)][date("d", $mtime)][] = $file; $filelist[] = $file; } } closedir($handle); } $monthindex = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb"><head> <?php if ($background !== "none") { $mark = chr(34); echo "<body style={$mark}background-image: url('{$background}'){$mark}>"; } ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Language" content="en-gb" /> <meta http-equiv="imagetoolbar" content="no" /> <title>image uploads of <?php echo "{$name}"; ?></title> <?php if ($theme == "1") { $body_fg = "#000000"; $body_bg = "#FFFFFF"; $h2_fg = "#333333"; $link_color = "#0066aa"; $divider_color = "#999999"; } if ($theme == "2") { $body_fg = "#FFFFFF"; $body_bg = "#000000"; $h2_fg = "#0033cc"; $link_color = "#0066ff"; $divider_color = "#999999"; } ?> <style type="text/css"><!-- body { font-family: Verdana, Arial, HVerdana, helvetica, sans-serif; font-size: 12px; color: <?php echo "{$body_fg}"; ?>; background-color: <?php echo "{$body_bg}"; ?>; padding: 10px; } form { display: inline; } img { border: 0px; } h2 { font-family: "Trebuchet MS", Helvetica, sans-serif; font-size: 1.70em; font-weight: 700; color: <?php echo "{$h2_fg}"; ?>; margin: 10px 0; } a:link, a:visited { text-decoration: none; color: <?php echo "{$link_color}"; ?>; } a:active, a:hover { text-decoration: underline; } .copyright { text-align: center; font-size: 12px; } .content { width: 800px; margin-left: auto; margin-right: auto; } .divider { border: 0; border-top: 1px dotted <?php echo "{$divider_color}"; ?>; margin-bottom: 5px; padding-bottom: 5px; height: 1px; } --></style></head><body> <table class="content"> <tr> <td class="cnt"> <?php if ($software == NULL) { echo "<h2>Screenshot statistics for {$name}</h2>"; } ?> <?php ksort($allgrabs); for ($y = 2000; $y <= 2012; $y++) { for ($m = 1; $m <= 12; $m++) { if (is_array($allgrabs[$y][$m]) == true) { $totalcount = (count($allgrabs[$y][$m])+$totalcount); } } } echo "Total number of Grabs: {$totalcount}<br /><ul>"; for ($y = 2000; $y <= 2012; $y++) { for ($m = 1; $m <= 12; $m++) { if (is_array($allgrabs[$y][$m]) == true) { $totalcount = count($allgrabs[$y][$m]); $avgeachday = ceil(count($allgrabs[$y][$m]) / count($bydaylist[$m])); foreach ($bydaylist[$m] as $day => $files) { if (count($day) > $max[$m]) { $maxno[$m] = $day; $max[$m] = date("F d, Y", mktime(0, 0, 0, $m, $day, date("y"))); } } echo "<li>Grabs in {$monthindex[$m]} {$y}: {$totalcount} -- average of {$avgeachday} grabs a day -- most active day is {$max[$m]} with {$maxno[$m]} grabs.</li>"; } } } echo "</ul>"; ?> <?php function timediff($dif) { $time = time(); $seconds = $time - $dif; $days = intval(intval($seconds) / 86400); if($days > 0) { $dhours = ($days*24*3600); $seconds = $seconds-$dhours; $ret .= "$days days, "; } $hours = intval(intval($seconds) / 3600); if($hours > 0) { $ret .= "$hours hours, "; } $minutes = bcmod((intval($seconds) / 60),60); if($hours > 0 || $minutes > 0) { $ret .= "$minutes minutes and "; } $seconds = bcmod(intval($seconds),60); $ret .= "$seconds seconds"; return "$ret"; } ?> <br /> <div class="divider"> </div> <?php /* Resize functions taken from my image hosting script */ function get_image_info($filename) { $base_info = getimagesize($filename); return array( "width" => $base_info['0'], "height" => $base_info['1'], "type" => $base_info['2'], "html" => $base_info['3'], "bits" => filesize($filename), "mime" => $base_info['mime'], "mtime" => filemtime($filename), "comment" => NULL, ); } function scale_maxwidth($file_info, $width) { if ($file_info['width'] > $width) { if ($file_info['width'] > $file_info['height']) { $image_width = $width; $image_height = round(($file_info['height'] * $width) / $file_info['width']); } elseif ($file_info['width'] < $file_info['height']) { $image_width = round(($file_info['width'] * $width) / $file_info['height']); $image_height = $width; } elseif ($file_info['height'] == $file_info['width']) { $image_height = $image_height = $width; } return array("w" => $image_width, "h" => $image_height); } } $randgrab = (mt_rand(1, count($filelist)) - 1); $randgrab = $filelist[$randgrab]; $fileinfo = get_image_info("./{$randgrab}"); $randgrab_date = date ("l, F d, Y H:i O ", filemtime($randgrab)); $since = filemtime($randgrab); $since = timediff($since); $base_info = getimagesize($randgrab); $size0 = filesize($randgrab); $size0 = $size0 / '1024'; if ($size0 >= '1024') { $size0 = $size0 / '1024'; } $size0 = round($size0, '2'); $size1 = $base_info['0']; $size2 = $base_info['1']; $randgrab_noext = preg_replace('/\.[^.]*$/', '', $randgrab); echo "<h2>Random Grab (<a href=\"{$randgrab}\">{$randgrab_noext}</a>)</h2>"; echo "<center>Uploaded: {$randgrab_date}</center>"; echo "<center>({$since} ago.)</center>"; echo "<center>Size: {$size0}KB - {$size1}x{$size2}</center>"; if ($fileinfo['width'] > 795) { $filedems = scale_maxwidth($fileinfo, 795); echo "<center><a href=\"./{$randgrab}\"><img src=\"./{$randgrab}\" alt=\"{$randgrab}\" style=\"width:{$filedems['w']}px;height:{$filedems['h']}px;\" /></a>"; echo "<br /><br /><i>The above image has been resized to better fit the screen. Click it to view the true size.</i></center><br />"; } else { echo "<center><a href=\"./{$randgrab}\"><img src=\"./{$randgrab}\" alt=\"{$randgrab}\" /></a></center><br />"; } ?> <?php ksort($allgrabs); for ($y = 2000; $y <= 2012; $y++) { for ($m = 1; $m <= 12; $m++) { if (is_array($allgrabs[$y][$m]) == true) { echo "<a name='{$y}_{$monthindex[$m]}_grabs'></a>"; echo "<h2>Grabups in {$monthindex[$m]} {$y}</h2>"; echo "<ul style='list-style-type: decimal-leading-zero;'>"; $files2show = array(); foreach ($allgrabs[$y][$m] as $file) { $datemt = filemtime("./{$file}"); $files2show[$datemt] = array("name" => $file, "mt" => $datemt); } ksort($files2show); foreach ($files2show as $file) { if (preg_match("/\.png/i", $file['name']) == true) { $filetype = 'PNG'; } if (preg_match("/\.jpg/i", $file['name']) == true) { $filetype = 'JPEG'; } if (preg_match("/\.jpeg/i", $file['name']) == true) { $filetype = 'JPEG'; } if (preg_match("/\.bmp/i", $file['name']) == true) { $filetype = 'BMP'; } $filedate = date ("l, F d, Y H:i O ", filemtime($file['name'])); $file_noext = preg_replace('/\.[^.]*$/', '', $file['name']); echo "<li>{$filetype} <a href='{$file['name']}'>{$file_noext}</a> - {$filedate}"; } unset($files2show); echo "</ul>"; } } } ?> <div class="divider"> </div> <div class="copyright"> </div> </td> </tr> </table></body></html>