-
Notifications
You must be signed in to change notification settings - Fork 4
/
checkruntimes.php
42 lines (39 loc) · 1.53 KB
/
checkruntimes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
error_reporting(E_ALL);
defined('IN_SCRIPT') || define('IN_SCRIPT', 1);
if (!isset($_SERVER['QUERY_STRING']))
$_SERVER['QUERY_STRING'] = '(Null)';
include_once('global.php');
SendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";');
if (!isset($runtimeslack))
$runtimeslack = 2;
if ($inbrowser)
echo "<pre>";
$sql = "SELECT id,title,runningtime,boxchild FROM $DVD_TABLE WHERE collectiontype='owned' AND boxchild <> 0 ORDER BY sorttitle ASC";
$result = $db->sql_query($sql) or die($db->sql_error());
while ($dvd = $db->sql_fetchrow($result)) {
$strout = "Parent: ($dvd[boxchild] children) $dvd[title]\t\t$dvd[runningtime] minutes\n";
$sql = "SELECT title,runningtime FROM $DVD_TABLE WHERE boxparent='$dvd[id]' ORDER BY sorttitle ASC";
$result1 = $db->sql_query($sql) or die($db->sql_error());
$count = $db->sql_numrows($result1);
if ($count != $dvd['boxchild']) {
echo "$strout*** Problem: Parent says $dvd[boxchild] children, but $count are found!!!\n";
}
$childtot = 0;
while ($child = $db->sql_fetchrow($result1)) {
$strout .= "\t$child[title]\t\t$child[runningtime] minutes\n";
$childtot += $child['runningtime'];
}
$db->sql_freeresult($result1);
$less = 'less';
$diff = $dvd['runningtime'] - $childtot;
if ($diff < 0) {
$diff *= -1;
$less = 'more'; // I just like writing this :)
}
if ($diff > $runtimeslack) {
echo "$strout*** Problem:\tSum of children is $childtot minutes ($diff minutes $less than the parent profile)\n\n";
}
}
$db->sql_freeresult($result);
echo "Done\n";