+
+
+
+
diff --git a/imagedata.php b/includes/imagedata.php
similarity index 97%
rename from imagedata.php
rename to includes/imagedata.php
index df64684..a788853 100644
--- a/imagedata.php
+++ b/includes/imagedata.php
@@ -85,10 +85,10 @@ function senddata($data, $remote_page, $boundary)
function servername($txt)
{
if (substr(strtoupper($txt),0,4)=='WWW.')
- $txt='HTTP://'.$txt;
- if (substr(strtoupper($txt),0,7)!='HTTP://')
+ $txt='https://'.$txt;
+ if (!preg_match('~^https?://~i', $txt))
return 0;
- preg_match('~^(http://([^/ ]+))~i',$txt,$arr);
+ preg_match('~^(https?://([^/ ]+))~i',$txt,$arr);
return $arr[2];
}
@@ -206,7 +206,7 @@ function my_file_get_contents($url) {
// init ...
srand((double)microtime()*1000000);
#$remote_page = 'http://andy.snowhopers.com/ii/do_upload.php';
- $remote_page = 'http://dvdaholic.me.uk/ii/do_upload.php';
+ $remote_page = 'https://dvdaholic.me.uk/ii/do_upload.php';
$boundary = '---------------------------'.substr(md5(rand(0,32000)),0,10);
// define HTTP POST DATA
@@ -261,7 +261,7 @@ function my_file_get_contents($url) {
$totdvd = $tothddvd = $totbluray = 0;
$sql = "SELECT builtinmediatype AS bi,COUNT(*) AS count FROM $DVD_TABLE WHERE collectiontype='owned' GROUP BY builtinmediatype";
- $result = $db->sql_query($sql) or die(mysql_error());
+ $result = $db->sql_query($sql) or die($db->sql_error());
while ($mtype = $db->sql_fetchrow($result)) {
switch ($mtype['bi']) {
case MEDIA_TYPE_DVD:
@@ -311,7 +311,7 @@ function my_file_get_contents($url) {
$img_webpathb = '';
$vphp = phpversion();
- $vmysql = MySQLVersion();
+ $vmysql = mySqlVersion();
$vxml = date("Y-m-d-H:i:s", GetLastUpdateTime('LastUpdate'));
$os = php_uname('s');
@@ -328,7 +328,7 @@ function my_file_get_contents($url) {
if ( $last == '00000000' )
$ii_verbose = true;
- $result = $db->sql_query($sql) or die(mysql_error());
+ $result = $db->sql_query($sql) or die($db->sql_error());
$cnt = 0;
//$displayfreq = 100; // now a global
while ($row = $db->sql_fetchrow($result))
diff --git a/incupdate.php b/includes/incupdate.php
similarity index 87%
rename from incupdate.php
rename to includes/incupdate.php
index 74e263c..1d8e3ec 100644
--- a/incupdate.php
+++ b/includes/incupdate.php
@@ -1,16 +1,29 @@
';
+ }
exit;
}
+function safeDbDie($error_context = '') {
+global $db, $inbrowser;
+ $err = $db->sql_error();
+ error_log('phpDVDProfiler DB error' . ($error_context ? " ($error_context)" : '') . ': ' . ($err['message'] ?? 'unknown'));
+ if ($inbrowser) {
+ die('A database error occurred. Check error log for details.');
+ } else {
+ die('Database error: ' . ($err['message'] ?? 'unknown') . "\n");
+ }
+}
+
# Function to upgrade the database schema
function schema_update($schema_file) {
global $db, $lang, $inbrowser, $eoln, $table_prefix, $UpdateLast;
@@ -30,14 +43,15 @@ function schema_update($schema_file) {
$cmd .= $tmp;
if (substr($tmp, strlen($tmp)-1, 1) == ';') {
if ($dosub) $cmd = str_replace('DVDPROFILER_', $table_prefix, $cmd);
- $res = $db->sql_query($cmd) or die($db->sql_error());
+ $res = $db->sql_query($cmd);
+ if (!$res) { safeDbDie(); }
if (is_resource($res)) $db->sql_freeresult($res);
$cmd = '';
}
}
}
fclose($sfh);
- $UpdateLast = UpdateUpdateLast(); // There is no data in the db, so let everyone know
+ $UpdateLast = updateUpdateLast(); // There is no data in the db, so let everyone know
}
function interpretEscapedXml($subject) {
@@ -75,7 +89,8 @@ function UpdateRatingDescriptions() {
$now = @filemtime('localities.xod');
if ($now === false)
return;
- $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='Rating~LastLocalitiesUpdateTime'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='Rating~LastLocalitiesUpdateTime'");
+ if (!$result) { safeDbDie(); }
$lastmtime = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($lastmtime === false || $lastmtime === null || ($lastmtime['value'] < $now)) {
@@ -83,9 +98,11 @@ function UpdateRatingDescriptions() {
$RatingCallbackResult = '';
preg_replace_callback('/<([^>]*)>/U', "ProcessLocalitiesCallback", $data);
- if ($lastmtime !== false) $db->sql_query("DELETE FROM $DVD_PROPERTIES_TABLE WHERE property LIKE 'Rating%'") or die($db->sql_error());
- $db->sql_query("INSERT INTO $DVD_PROPERTIES_TABLE (property,value) VALUES $RatingCallbackResult") or die($db->sql_error());
- $db->sql_query("INSERT INTO $DVD_PROPERTIES_TABLE (property,value) VALUES ('Rating~LastLocalitiesUpdateTime',$now)") or die($db->sql_error());
+ if ($lastmtime !== false) {
+ if (!$db->sql_query("DELETE FROM $DVD_PROPERTIES_TABLE WHERE property LIKE 'Rating%'")) { safeDbDie(); }
+ }
+ if (!$db->sql_query("INSERT INTO $DVD_PROPERTIES_TABLE (property,value) VALUES $RatingCallbackResult")) { safeDbDie(); }
+ if (!$db->sql_query("INSERT INTO $DVD_PROPERTIES_TABLE (property,value) VALUES ('Rating~LastLocalitiesUpdateTime',$now)")) { safeDbDie(); }
}
return;
}
@@ -113,7 +130,7 @@ function DoSomeStats($NAME, $NeedDistinct, $WHATWHEREFROM, $WHERE, $GROUPORDER,
if ($IgnoreCount0Profiles) $WHERE .= 'AND countas!=0 ';
$sql = "INSERT INTO $DVD_STATS_TABLE SELECT $Distinct '{$NAME}Adult',$WHATWHEREFROM $WHERE $GROUPORDER";
if ($TryToChangeMemoryAndTimeLimits) set_time_limit(0);
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
$ProfileName[$numtimings] = $NAME.'Adult'; $Profile[$numtimings++] = microtime_float()-$t0; $t0 = microtime_float();
if ($noadulttitles)
@@ -122,7 +139,7 @@ function DoSomeStats($NAME, $NeedDistinct, $WHATWHEREFROM, $WHERE, $GROUPORDER,
$sql = "INSERT INTO $DVD_STATS_TABLE SELECT $Distinct '{$NAME}NoAdult',$WHATWHEREFROM $WHERE AND isadulttitle=0 $GROUPORDER";
if ($TryToChangeMemoryAndTimeLimits) set_time_limit(0);
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
$ProfileName[$numtimings] = $NAME.'NoAdult'; $Profile[$numtimings++] = microtime_float()-$t0; $t0 = microtime_float();
if ($noadulttitles) $numtimings--;
return;
@@ -157,12 +174,12 @@ function TranslateDateTime($string) {
}
class BufferedInsert {
-var $db;
-var $max_packet;
-var $table;
-var $sql;
-var $room_left;
-var $col_names;
+ public $db;
+ public $max_packet;
+ public $table;
+ public $sql;
+ public $room_left;
+ public $col_names;
function __construct(&$db, $max_packet, $table, $col_names) {
$this->db = $db;
@@ -176,7 +193,7 @@ function add_element($values) {
$retval = 0;
$templen = strlen($values);
if ($this->room_left <= $templen) {
- $this->db->sql_query($this->sql) or die($this->db->sql_error());
+ if (!$this->db->sql_query($this->sql)) { safeDbDie(); }
$this->sql = '';
$this->room_left = $this->max_packet;
$retval = 1;
@@ -194,7 +211,7 @@ function add_element($values) {
function flush() {
if ($this->sql != '') {
- $this->db->sql_query($this->sql) or die($this->db->sql_error());
+ if (!$this->db->sql_query($this->sql)) { safeDbDie(); }
return(1);
}
return(0);
@@ -334,7 +351,7 @@ function GetXMLTreeFromString($data, $inputencoding='ISO-8859-1') {
$err = xml_get_error_code($parser);
$where_exactly = xml_get_current_byte_index($parser) - 1; // It appears that the byte may be one-based, so subtract 1
preg_match('|([^<]*)|', $data, $matches);
- $title = $matches[1];
+ $title = $matches[1] ?? '';
$tag = 'Unknown';
if (preg_match('|<([^>]*)>|', strrchr(substr($data, 0, $where_exactly-1), '<'), $matches) != 0)
$tag = $matches[1];
@@ -375,8 +392,8 @@ function UpdateCommonTableFromMemory(&$common_memory, &$common_stats, $table, $h
global $db, $max_packet, $lang;
$t0 = microtime_float();
- $db->sql_query("SET autocommit=0;") or die($db->sql_error());
- $db->sql_transaction('begin') or die($db->sql_error());
+ if (!$db->sql_query("SET autocommit=0;")) { safeDbDie(); }
+ if (!$db->sql_transaction('begin')) { safeDbDie(); }
if ($common_memory != '') {
$col_names = '(caid,firstname,middlename,lastname,birthyear,fullname)';
$bi = new BufferedInsert($db, $max_packet, $table, $col_names);
@@ -425,8 +442,8 @@ function UpdateCommonTableFromMemory(&$common_memory, &$common_stats, $table, $h
unset($bi);
unset($credit);
}
- $db->sql_transaction('commit') or die($db->sql_error());
- $db->sql_query("SET autocommit=1;") or die($db->sql_error());
+ if (!$db->sql_transaction('commit')) { safeDbDie(); }
+ if (!$db->sql_query("SET autocommit=1;")) { safeDbDie(); }
$common_stats['amttime'] += microtime_float() - $t0;
}
@@ -436,7 +453,8 @@ function InitialiseCommonTable($which) {
if ($db_fast_update) {
if ($which == 'common_actor' && empty($common_actor)) {
- $res = $db->sql_query("SELECT * FROM $DVD_COMMON_ACTOR_TABLE ORDER BY caid") or die($db->sql_error());
+ $res = $db->sql_query("SELECT * FROM $DVD_COMMON_ACTOR_TABLE ORDER BY caid");
+ if (!$res) { safeDbDie(); }
$key = '';
while ($row = $db->sql_fetch_array($res)) {
$key = implode('|', array($row['firstname'], $row['middlename'], $row['lastname'], $row['birthyear']));
@@ -452,7 +470,8 @@ function InitialiseCommonTable($which) {
}
if ($which == 'common_credit' && empty($common_credit)) {
- $res = $db->sql_query("SELECT * FROM $DVD_COMMON_CREDITS_TABLE ORDER BY caid") or die($db->sql_error());
+ $res = $db->sql_query("SELECT * FROM $DVD_COMMON_CREDITS_TABLE ORDER BY caid");
+ if (!$res) { safeDbDie(); }
$key = '';
while ($row = $db->sql_fetch_array($res)) {
$key = implode('|', array($row['firstname'], $row['middlename'], $row['lastname'], $row['birthyear']));
@@ -523,7 +542,8 @@ function TrueFalse(&$str) {
function GetHashs(&$oldhashs) {
global $db, $DVD_TABLE;
- $result = $db->sql_query("SELECT id,hashprofile,hashnocolid,hashcast,hashcrew FROM $DVD_TABLE") or die($db->sql_error());
+ $result = $db->sql_query("SELECT id,hashprofile,hashnocolid,hashcast,hashcrew FROM $DVD_TABLE");
+ if (!$result) { safeDbDie(); }
while ($row = $db->sql_fetchrow($result)) {
$id = array_shift($row);
$oldhashs[$id] = $row;
@@ -535,23 +555,23 @@ function GetHashs(&$oldhashs) {
function HashData(&$data) {
$colid = '';
- $hashprofile = Hex(crc32($data));
+ $hashprofile = hex(crc32($data));
$hashnocolid = $hashcast = $hashcrew = $hashprofile;
if (($back = strpos($data, '')) !== false) {
$front = strpos($data, '') + strlen('');
$colid = substr($data, $front, $back-$front);
- $hashnocolid = Hex(crc32(substr($data, 0, $front).substr($data, $back)));
+ $hashnocolid = hex(crc32(substr($data, 0, $front).substr($data, $back)));
}
if (($back = strpos($data, '')) !== false) {
$front = strpos($data, '') + strlen('');
- $hashcast = Hex(crc32(substr($data, $front, $back-$front)));
+ $hashcast = hex(crc32(substr($data, $front, $back-$front)));
}
if (($back = strpos($data, '')) !== false) {
$front = strpos($data, '') + strlen('');
- $hashcrew = Hex(crc32(substr($data, $front, $back-$front)));
+ $hashcrew = hex(crc32(substr($data, $front, $back-$front)));
}
return(array('hashprofile' => $hashprofile, 'hashnocolid' => $hashnocolid, 'hashcast' => $hashcast, 'hashcrew' => $hashcrew, 'colid' => $colid));
@@ -573,7 +593,7 @@ function MemoryUsage($str, $addeoln = false) {
function PrepareBrowserOutput() {
global $lang;
- SendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";');
+ sendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";');
echo<<
@@ -837,7 +857,8 @@ function ProcessXMLCollection($prelim_output) {
$T0 = microtime_float();
// Get the current connection ID and stuff it into the DB so that everyone knows we're running
- $res = $db->sql_query("SELECT CONNECTION_ID() AS Id") or die($db->sql_error());
+ $res = $db->sql_query("SELECT CONNECTION_ID() AS Id");
+ if (!$res) { safeDbDie(); }
$row = $db->sql_fetchrow($res);
$MyConnectionId = $row['Id'];
$res = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='CurrentPosition'", 0, true);
@@ -845,7 +866,7 @@ function ProcessXMLCollection($prelim_output) {
$db->sql_freeresult($res);
$val = $row != null ? substr($row['value'], 0, strrpos($row['value'], '|')) : null;
unset($row);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='$val|-$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='$val|-$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
if ($inbrowser)
$tmp = "
200 - $MyConnectionId
";
@@ -898,7 +919,8 @@ function ProcessXMLCollection($prelim_output) {
@ob_flush();
// Find out how long a query we can send to the server ...
- $result = $db->sql_query("SHOW VARIABLES like 'max_allowed_packet'") or die($db->sql_error());
+ $result = $db->sql_query("SHOW VARIABLES like 'max_allowed_packet'");
+ if (!$result) { safeDbDie(); }
$row = $db->sql_fetch_array($result);
$db->sql_freeresult($result);
$max_packet = $row['Value'];
@@ -932,7 +954,7 @@ function ProcessXMLCollection($prelim_output) {
$oldhashs = array();
GetHashs($oldhashs);
- ModifyTables('DISABLE');
+ modifyTables('DISABLE');
echo $lang['IMPORTUPDATING'] . $eoln; // database name
if ($numxmlfiles != 1)
printf($lang['IMPORTXMLDIR'].$eoln, $numxmlfiles, $xmldir);
@@ -960,6 +982,10 @@ function ProcessXMLCollection($prelim_output) {
printf($lang['UPDATEFILECHANGED1'].$eoln, $currentxmlfile);
printf($lang['UPDATEFILECHANGED2'].$eoln, $UpdateLast['Filesize'], $currentxmlfilesize);
echo "$lang[UPDATEFILECHANGED3]$eoln";
+ // File changed - offset is unreliable (e.g. MediaTypes section changed length).
+ // Reset to start from the beginning for safety.
+ $UpdateLast['Offset'] = 0;
+ $UpdateLast['Filename'] = '';
}
if (!$LotsaFiles) {
if (substr($currentxmlfile, -3) == '.gz')
@@ -989,17 +1015,18 @@ function ProcessXMLCollection($prelim_output) {
$UpdateLast['Offset'] = 0;
$UpdateLast['Filename'] = '';
$data = '';
- do { // Ensure that we're at the beginning of a DVD section ... This could get messed up with MediaTypes ...
+ do { // Ensure that we're at the beginning of a DVD section
if (($temp=fgets($fh)) === false)
break 2; // escape the while (true)
- } while (strpos($temp, ' or opening tag (not e.g. inside data)
+ } while (preg_match('/]/', $temp) === 0);
}
$data = $temp;
do {
if (($temp=fgets($fh)) === false)
break 2; // escape the while (true)
$data .= $temp;
- } while (!((!(strpos($data, '') === false)) && !(strpos($temp, '') === false)));
+ } while (strpos($data, '') === false || strpos($temp, '') === false || strpos($temp, '') + strlen('');
@@ -1017,7 +1044,7 @@ function ProcessXMLCollection($prelim_output) {
}
if ($oldhashs[$id]['hashnocolid'] == $hashs['hashnocolid']) {
// Only the collection number changed. Update to new id, and walk away.
- $db->sql_query("UPDATE $DVD_TABLE SET collectionnumber='$hashs[colid]',hashprofile='$hashs[hashprofile]' WHERE id='$id'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_TABLE SET collectionnumber='$hashs[colid]',hashprofile='$hashs[hashprofile]' WHERE id='$id'")) { safeDbDie(); }
$newcollnum++;
}
else {
@@ -1058,7 +1085,7 @@ function ProcessXMLCollection($prelim_output) {
@ob_flush();
}
$WhereInFile = ftell($fh);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='$WhereInFile|$currentxmlfile!$currentxmlfilesize|$total|$added|$changed|$newcollnum|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='$WhereInFile|$currentxmlfile!$currentxmlfilesize|$total|$added|$changed|$newcollnum|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
$my_fclose($fh);
}
@@ -1084,7 +1111,7 @@ function ProcessXMLCollection($prelim_output) {
unset($common_credit);
}
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-1||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-1||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
if ($UpdateLast['Offset'] < 0) {
@@ -1116,9 +1143,9 @@ function ProcessXMLCollection($prelim_output) {
flush();
@ob_flush();
UpdateBoxSets();
- ModifyTables('ENABLE');
+ modifyTables('ENABLE');
$ppdelete = TidyPurchasePlace();
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
if ($UpdateLast['Offset'] > -3) {
@@ -1144,7 +1171,7 @@ function ProcessXMLCollection($prelim_output) {
' + ' . number_format($totaltime-$DatabaseTime, 3, $lang['MON_DECIMAL_POINT'], $lang['MON_THOUSANDS_SEP']) .
')' . $eoln;
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-3||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-3||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
if ($UpdateLast['Offset'] >= -3) {
@@ -1161,13 +1188,13 @@ function ProcessXMLCollection($prelim_output) {
}
unset($IDsChanged);
- $db->sql_query("REPLACE INTO $DVD_PROPERTIES_TABLE SET value='".time()."', property='LastUpdate'") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_PROPERTIES_TABLE SET value='".time()."', property='LastUpdate'")) { safeDbDie(); }
if (is_readable($CustomPostUpdate)) {
echo "$lang[EXECUTING] $CustomPostUpdate$eoln";
include_once($CustomPostUpdate);
}
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='0||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='0||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
if ($inbrowser)
echo "
$endbody\n";
@@ -1182,12 +1209,14 @@ function ProcessXMLCollection($prelim_output) {
function TidyPurchasePlace() {
global $db, $DVD_TABLE, $DVD_SUPPLIER_TABLE;
$ppdelete = 0;
- $suppliers = $db->sql_query("SELECT sid FROM $DVD_SUPPLIER_TABLE") or die($db->sql_error());
+ $suppliers = $db->sql_query("SELECT sid FROM $DVD_SUPPLIER_TABLE");
+ if (!$suppliers) { safeDbDie(); }
while ($supplierid = $db->sql_fetchrow($suppliers)) {
- $result = $db->sql_query("SELECT id FROM $DVD_TABLE WHERE purchaseplace='$supplierid[sid]'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT id FROM $DVD_TABLE WHERE purchaseplace='$supplierid[sid]'");
+ if (!$result) { safeDbDie(); }
if (!$db->sql_numrows($result)) {
$ppdelete++;
- $db->sql_query("DELETE FROM $DVD_SUPPLIER_TABLE where sid = '$supplierid[sid]'") or die($db->sql_error());
+ if (!$db->sql_query("DELETE FROM $DVD_SUPPLIER_TABLE where sid = '$supplierid[sid]'")) { safeDbDie(); }
}
}
return($ppdelete);
@@ -1200,31 +1229,36 @@ function DeleteFromTables($id, $castisbad = true, $crewisbad = true) {
$MadeAChange = true;
$where = '';
- if ($id != 'clean out all of the tables')
+ if ($id != 'clean out all of the tables') {
$where = "WHERE id='$id'";
- $db->sql_query("DELETE FROM $DVD_TABLE $where") or die($db->sql_error());
- if ($castisbad) $db->sql_query("DELETE FROM $DVD_ACTOR_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_EVENTS_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_LOCKS_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_DISCS_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_AUDIO_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_GENRES_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_EXCLUSIONS_TABLE $where") or die($db->sql_error());
- if ($crewisbad) $db->sql_query("DELETE FROM $DVD_CREDITS_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_BOXSET_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_STUDIO_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_LINKS_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_SUBTITLE_TABLE $where") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_TAGS_TABLE $where") or die($db->sql_error());
+ }
+ if (!$db->sql_query("DELETE FROM $DVD_TABLE $where")) { safeDbDie(); }
+ if ($castisbad) {
+ if (!$db->sql_query("DELETE FROM $DVD_ACTOR_TABLE $where")) { safeDbDie(); }
+ }
+ if (!$db->sql_query("DELETE FROM $DVD_EVENTS_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_LOCKS_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_DISCS_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_AUDIO_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_GENRES_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_EXCLUSIONS_TABLE $where")) { safeDbDie(); }
+ if ($crewisbad) {
+ if (!$db->sql_query("DELETE FROM $DVD_CREDITS_TABLE $where")) { safeDbDie(); }
+ }
+ if (!$db->sql_query("DELETE FROM $DVD_BOXSET_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_STUDIO_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_LINKS_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_SUBTITLE_TABLE $where")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_TAGS_TABLE $where")) { safeDbDie(); }
if ($where != '') {
- $db->sql_query("UPDATE $DVD_TABLE SET boxparent='' WHERE boxparent='$id'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_TABLE SET boxparent='' WHERE boxparent='$id'")) { safeDbDie(); }
}
else {
- $db->sql_query("DELETE FROM $DVD_SUPPLIER_TABLE") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_USERS_TABLE") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_COMMON_ACTOR_TABLE WHERE caid>0") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_COMMON_CREDITS_TABLE WHERE caid>0") or die($db->sql_error());
- $db->sql_query("DELETE FROM $DVD_PROPERTIES_TABLE WHERE property LIKE 'Rating%'") or die($db->sql_error());
+ if (!$db->sql_query("DELETE FROM $DVD_SUPPLIER_TABLE")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_USERS_TABLE")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_COMMON_ACTOR_TABLE WHERE caid>0")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_COMMON_CREDITS_TABLE WHERE caid>0")) { safeDbDie(); }
+ if (!$db->sql_query("DELETE FROM $DVD_PROPERTIES_TABLE WHERE property LIKE 'Rating%'")) { safeDbDie(); }
}
}
@@ -1233,7 +1267,8 @@ function GetAUserIDFor($fname, $lname, $emailaddress, $phonenumber) {
if ($users == '') {
$users = array();
- $res = $db->sql_query("SELECT * FROM $DVD_USERS_TABLE ORDER BY uid ASC") or die($db->sql_error());
+ $res = $db->sql_query("SELECT * FROM $DVD_USERS_TABLE ORDER BY uid ASC");
+ if (!$res) { safeDbDie(); }
while ($row = $db->sql_fetch_array($res)) {
$full = "$row[firstname]|$row[lastname]";
$users[$full] = $row;
@@ -1253,7 +1288,7 @@ function GetAUserIDFor($fname, $lname, $emailaddress, $phonenumber) {
$sql = "UPDATE $DVD_USERS_TABLE SET emailaddress='"
. $db->sql_escape($emailaddress) . "',phonenumber='"
. $db->sql_escape($phonenumber) . "' WHERE uid=$uid";
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
}
}
else {
@@ -1265,7 +1300,7 @@ function GetAUserIDFor($fname, $lname, $emailaddress, $phonenumber) {
."'" . $db->sql_escape($lname) ."',"
."'" . $db->sql_escape($emailaddress) ."',"
."'" . $db->sql_escape($phonenumber) . "')";
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
}
return($uid);
}
@@ -1299,7 +1334,8 @@ function GetAnIDFor($fname, $mname, $lname, $birth, $table, &$hints) {
."' AND middlename='" . $db->sql_escape($mname)
."' AND lastname='" . $db->sql_escape($lname)
."' AND birthyear='" . $db->sql_escape($birth) . "'";
- $res = $db->sql_query($sql) or die($db->sql_error());
+ $res = $db->sql_query($sql);
+ if (!$res) { safeDbDie(); }
$foundaid = false;
while ($aid = $db->sql_fetchrow($res)) {
if ($aid['firstname'] == $fname &&
@@ -1320,7 +1356,7 @@ function GetAnIDFor($fname, $mname, $lname, $birth, $table, &$hints) {
."'" . $db->sql_escape($lname) ."',"
."'" . $db->sql_escape($birth) ."',"
."'" . $db->sql_escape(preg_replace('/\s\s+/', ' ', trim("$fname $mname $lname"))) . "')";
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
$aid['caid'] = $db->sql_nextid();
}
return($aid['caid']);
@@ -1351,8 +1387,8 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
// Profile IDs may not be blank
return(1);
}
- $db->sql_query("SET autocommit=0;") or die($db->sql_error());
- $db->sql_transaction('begin') or die($db->sql_error());
+ if (!$db->sql_query("SET autocommit=0;")) { safeDbDie(); }
+ if (!$db->sql_transaction('begin')) { safeDbDie(); }
if ($delete != 1) // Don't bother if we've already nuked the entire db ...
DeleteFromTables($TheProfileID, $hashs['hashcast']!=$oldhashs['hashcast'], $hashs['hashcrew']!=$oldhashs['hashcrew']);
@@ -1459,7 +1495,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
if ($suppliername) {
$supplier = array(
'suppliername' => $suppliername,
- 'suppliertype' => (isset($dvd_info['PURCHASEINFO'][0]['PURCHASEPLACETYPE'][0]['VALUE'])) ? $dvd_info['PURCHASEINFO'][0]['PURCHASEPLACETYPE'][0]['VALUE'] : '',
+ 'suppliertype' => (isset($dvd_info['PURCHASEINFO'][0]['PURCHASEPLACETYPE'][0]['VALUE'])) ? substr($dvd_info['PURCHASEINFO'][0]['PURCHASEPLACETYPE'][0]['VALUE'], 0, 1) : '',
'supplierurl' => (isset($dvd_info['PURCHASEINFO'][0]['PURCHASEPLACEWEBSITE'][0]['VALUE'])) ? $dvd_info['PURCHASEINFO'][0]['PURCHASEPLACEWEBSITE'][0]['VALUE'] : ''
);
}
@@ -1474,12 +1510,13 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
while (!$sid) {
$xxx = "SELECT sid FROM $DVD_SUPPLIER_TABLE WHERE suppliername='" . $db->sql_escape($suppliername) . "'";
- $result = $db->sql_query($xxx) or die($db->sql_error());
+ $result = $db->sql_query($xxx);
+ if (!$result) { safeDbDie(); }
$row = $db->sql_fetchrow($result);
$sid = $row === null ? false : $row['sid'];
if (!$sid) {
$sql = "INSERT INTO $DVD_SUPPLIER_TABLE " . $db->sql_build_array('INSERT', $supplier);
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
}
}
unset ($supplier);
@@ -1499,7 +1536,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID','$n','$f')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_TAGS_TABLE (id,name,fullyqualifiedname) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_TAGS_TABLE (id,name,fullyqualifiedname) VALUES $sql")) { safeDbDie(); }
if ($auxcolltype != '')
$auxcolltype .= '/';
}
@@ -1512,7 +1549,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID','$c')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_BOXSET_TABLE (id,child) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_BOXSET_TABLE (id,child) VALUES $sql")) { safeDbDie(); }
}
$isadulttitle = 0;
@@ -1530,7 +1567,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
}
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_GENRES_TABLE (id,dborder,genre) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_GENRES_TABLE (id,dborder,genre) VALUES $sql")) { safeDbDie(); }
}
// Put any exclusions into a table.
@@ -1542,7 +1579,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$f .= ',remoteconnections'; $v .= ',' . TrueFalse($dvd_info['EXCLUSIONS'][0]['REMOTECONNECTIONS'][0]['VALUE']);
$f .= ',dpopublic'; $v .= ',' . TrueFalse($dvd_info['EXCLUSIONS'][0]['DPOPUBLIC'][0]['VALUE']);
$f .= ',dpoprivate'; $v .= ',' . TrueFalse($dvd_info['EXCLUSIONS'][0]['DPOPRIVATE'][0]['VALUE']);
- $db->sql_query("INSERT INTO $DVD_EXCLUSIONS_TABLE ($f) VALUES ($v)") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_EXCLUSIONS_TABLE ($f) VALUES ($v)")) { safeDbDie(); }
}
// Put any MyLinks entries into a table.
@@ -1566,8 +1603,11 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sortorder = 8000 + $dborder;
if ($d == '') {
$d = $u;
- if (strncasecmp($d, 'http://', 7) == 0 || strncasecmp($d, 'file://', 7) == 0)
+ if (strncasecmp($d, 'https://', 8) == 0) {
+ $d = substr($d, 8);
+ } elseif (strncasecmp($d, 'http://', 7) == 0 || strncasecmp($d, 'file://', 7) == 0) {
$d = substr($d, 7);
+ }
if (strncasecmp($d, 'www.', 4) == 0)
$d = substr($d, 4);
if (($EOHost=strpos($d, '/')) !== false)
@@ -1577,7 +1617,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID',$sortorder,0,'$u','$d','$c')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_LINKS_TABLE (id,dborder,linktype,url,description,category) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_LINKS_TABLE (id,dborder,linktype,url,description,category) VALUES $sql")) { safeDbDie(); }
}
if (isset($dvd_info['STUDIOS'][0]['STUDIO'])) {
@@ -1590,7 +1630,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID',0,$dborder,'$s')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES $sql")) { safeDbDie(); }
}
if (isset($dvd_info['MEDIACOMPANIES'][0]['MEDIACOMPANY'])) {
$dborder = 0;
@@ -1602,10 +1642,10 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID',1,$dborder,'$s')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES $sql")) { safeDbDie(); }
}
if (!empty($dvd_info['MEDIAPUBLISHER'][0]['VALUE'])) {
- $db->sql_query("INSERT INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES ('$TheProfileID',1,1,'".$dvd_info['MEDIAPUBLISHER'][0]['VALUE']."')") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_STUDIO_TABLE (id,ismediacompany,dborder,studio) VALUES ('$TheProfileID',1,1,'".$dvd_info['MEDIAPUBLISHER'][0]['VALUE']."')")) { safeDbDie(); }
}
if (isset($dvd_info['SUBTITLES'][0]['SUBTITLE'])) {
@@ -1616,7 +1656,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID','$s')";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_SUBTITLE_TABLE (id,subtitle) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_SUBTITLE_TABLE (id,subtitle) VALUES $sql")) { safeDbDie(); }
}
if (isset($dvd_info['EVENTS'][0]['EVENT'])) {
@@ -1637,7 +1677,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
}
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_EVENTS_TABLE (id,uid,eventtype,note,timestamp) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_EVENTS_TABLE (id,uid,eventtype,note,timestamp) VALUES $sql")) { safeDbDie(); }
unset($event);
}
@@ -1656,7 +1696,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= "('$TheProfileID',$dborder,'$c','$f',NULL)";
}
if ($sql != '')
- $db->sql_query("INSERT INTO $DVD_AUDIO_TABLE (id,dborder,audiocontent,audioformat,audiochannels) VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_AUDIO_TABLE (id,dborder,audiocontent,audioformat,audiochannels) VALUES $sql")) { safeDbDie(); }
}
if (isset($dvd_info['DISCS'][0]['DISC'])) {
@@ -1682,7 +1722,7 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$sql .= ')';
}
- $db->sql_query("INSERT INTO $DVD_DISCS_TABLE $fields VALUES $sql") or die($db->sql_error());
+ if (!$db->sql_query("REPLACE INTO $DVD_DISCS_TABLE $fields VALUES $sql")) { safeDbDie(); }
}
if (isset($dvd_info['LOCKS'][0])) {
@@ -1709,7 +1749,8 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$f .= ',casetype'; $v .= ',' . TrueFalse($dvd_info['LOCKS'][0]['CASETYPE'][0]['VALUE']);
$f .= ',videoformats'; $v .= ',' . TrueFalse($dvd_info['LOCKS'][0]['VIDEOFORMATS'][0]['VALUE']);
$f .= ',rating'; $v .= ',' . TrueFalse($dvd_info['LOCKS'][0]['RATING'][0]['VALUE']);
- $db->sql_query("INSERT INTO $DVD_LOCKS_TABLE ($f) VALUES ($v)") or die($db->sql_error());
+ $db->sql_query("DELETE FROM $DVD_LOCKS_TABLE WHERE id='$TheProfileID'");
+ if (!$db->sql_query("INSERT INTO $DVD_LOCKS_TABLE ($f) VALUES ($v)")) { safeDbDie(); }
}
if ($hashs['hashcast'] != $oldhashs['hashcast']) {
@@ -2015,11 +2056,12 @@ function AddADVD(&$dvd_info, $hashs, $oldhashs) {
$f .= ',hashcrew'; $v .= ",'$hashs[hashcrew]'";
$f .= ',lastedited'; $v .=',' . MakeAUnixTime(@$dvd_info['LASTEDITED'][0]['VALUE'], 0);
+ $db->sql_query("DELETE FROM $DVD_TABLE WHERE id='$TheProfileID'");
$sql = "INSERT INTO $DVD_TABLE ($f) VALUES ($v)";
- $db->sql_query($sql) or die($db->sql_error($sql));
- $db->sql_transaction('commit') or die($db->sql_error());
- $db->sql_query("SET autocommit=1;") or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie('insert profile'); }
+ if (!$db->sql_transaction('commit')) { safeDbDie(); }
+ if (!$db->sql_query("SET autocommit=1;")) { safeDbDie(); }
return(0);
}
@@ -2034,19 +2076,22 @@ function UpdateBoxSets() {
$lastbadparent = '';
// Find and remove BoxSet entries where the child id isn't in the main table
- $result = $db->sql_query("SELECT * FROM $DVD_BOXSET_TABLE ORDER BY id") or die($db->sql_error());
+ $result = $db->sql_query("SELECT * FROM $DVD_BOXSET_TABLE ORDER BY id");
+ if (!$result) { safeDbDie(); }
while ($pair = $db->sql_fetchrow($result)) {
- $result1 = $db->sql_query("SELECT COUNT(*) AS numentries FROM $DVD_TABLE WHERE id='$pair[child]'") or die($db->sql_error());
+ $result1 = $db->sql_query("SELECT COUNT(*) AS numentries FROM $DVD_TABLE WHERE id='$pair[child]'");
+ if (!$result1) { safeDbDie(); }
$answer = $db->sql_fetchrow($result1);
$db->sql_freeresult($result1);
if ($answer['numentries'] == 0) {
- $db->sql_query("DELETE FROM $DVD_BOXSET_TABLE WHERE id='$pair[id]' AND child='$pair[child]'") or die($db->sql_error());
+ if (!$db->sql_query("DELETE FROM $DVD_BOXSET_TABLE WHERE id='$pair[id]' AND child='$pair[child]'")) { safeDbDie(); }
$numbadentries++;
if ($lastbadparent != $pair['id']) {
$lastbadparent = $pair['id'];
$numbadsets++;
if ($showbadboxsetnames) {
- $result1 = $db->sql_query("SELECT title FROM $DVD_TABLE WHERE id='$lastbadparent'") or die($db->sql_error());
+ $result1 = $db->sql_query("SELECT title FROM $DVD_TABLE WHERE id='$lastbadparent'");
+ if (!$result1) { safeDbDie(); }
$answer = $db->sql_fetchrow($result1);
$db->sql_freeresult($result1);
if ($numbadsets == 1)
@@ -2062,22 +2107,25 @@ function UpdateBoxSets() {
}
// Update the main table to set the child's parentpointer
- $result = $db->sql_query("SELECT * FROM $DVD_BOXSET_TABLE") or die($db->sql_error());
+ $result = $db->sql_query("SELECT * FROM $DVD_BOXSET_TABLE");
+ if (!$result) { safeDbDie(); }
while ($pair = $db->sql_fetchrow($result)) {
- $db->sql_query("UPDATE $DVD_TABLE SET boxparent='$pair[id]' WHERE id='$pair[child]'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_TABLE SET boxparent='$pair[id]' WHERE id='$pair[child]'")) { safeDbDie(); }
}
$db->sql_freeresult($result);
// Update the main table so that the box child member reflects the number of children
- $result = $db->sql_query("SELECT DISTINCT id FROM $DVD_BOXSET_TABLE") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT id FROM $DVD_BOXSET_TABLE");
+ if (!$result) { safeDbDie(); }
while ($pair = $db->sql_fetchrow($result)) {
$parent = $pair['id'];
$numkids = 0;
- $result1 = $db->sql_query("SELECT COUNT(*) AS numkids FROM $DVD_TABLE d,$DVD_BOXSET_TABLE b WHERE d.id=b.child and b.id='$parent'") or die($db->sql_error());
+ $result1 = $db->sql_query("SELECT COUNT(*) AS numkids FROM $DVD_TABLE d,$DVD_BOXSET_TABLE b WHERE d.id=b.child and b.id='$parent'");
+ if (!$result1) { safeDbDie(); }
$answer = $db->sql_fetchrow($result1);
$db->sql_freeresult($result1);
- $db->sql_query("UPDATE $DVD_TABLE SET boxchild=$answer[numkids] WHERE id='$parent'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_TABLE SET boxchild=$answer[numkids] WHERE id='$parent'")) { safeDbDie(); }
}
$db->sql_freeresult($result);
}
@@ -2091,7 +2139,8 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
if (!$MadeAChange && !$force_cleanup)
return;
- $result = $db->sql_query("SELECT DISTINCT purchasedate FROM $DVD_TABLE ORDER BY purchasedate DESC LIMIT $Highlight_Last_X_PurchaseDates") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT purchasedate FROM $DVD_TABLE ORDER BY purchasedate DESC LIMIT $Highlight_Last_X_PurchaseDates");
+ if (!$result) { safeDbDie(); }
$thelist = '';
while ($row = $db->sql_fetchrow($result)) {
if ($thelist != '') $thelist .= ',';
@@ -2102,13 +2151,14 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
$db->sql_query("DELETE FROM $DVD_PROPERTIES_TABLE WHERE property='listofpurchasedates'");
$db->sql_query("INSERT INTO $DVD_PROPERTIES_TABLE (property,value) VALUES ('listofpurchasedates', '$thelist')");
- $db->sql_query("DELETE FROM $DVD_STATS_TABLE") or die($db->sql_error());
+ if (!$db->sql_query("DELETE FROM $DVD_STATS_TABLE")) { safeDbDie(); }
$noadulttitles = false;
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.1||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.1||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
if (TableCopyingSupported()) {
if ($TryToChangeMemoryAndTimeLimits) set_time_limit(0);
- $result = $db->sql_query("SELECT COUNT(*) AS num FROM $DVD_TABLE WHERE isadulttitle=1") or die($db->sql_error());
+ $result = $db->sql_query("SELECT COUNT(*) AS num FROM $DVD_TABLE WHERE isadulttitle=1");
+ if (!$result) { safeDbDie(); }
$answer = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$noadulttitles = $answer['num'] == 0;
@@ -2119,7 +2169,8 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
$NOTVTable = '';
$NOTVQuery = '';
$tmp = '(';
- $result = $db->sql_query("SELECT DISTINCT id FROM $DVD_GENRES_TABLE WHERE genre='Television'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT id FROM $DVD_GENRES_TABLE WHERE genre='Television'");
+ if (!$result) { safeDbDie(); }
while ($zzz = $db->sql_fetch_array($result)) {
if ($tmp != '(') $tmp .= ',';
$tmp .= "'$zzz[id]'";
@@ -2128,12 +2179,13 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
if ($tmp != '(') {
$NOTVQuery = " AND d.id NOT IN $tmp)";
}
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.2||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.2||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
$t0 = microtime_float(); $numtimings = 0;
// Create tables including and excluding Adult titles
- $result = $db->sql_query("SELECT DISTINCT auxcolltype FROM $DVD_TABLE") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT auxcolltype FROM $DVD_TABLE");
+ if (!$result) { safeDbDie(); }
$masterauxcolltype = '';
while ($row = $db->sql_fetchrow($result)) {
$masterauxcolltype .= $row['auxcolltype'];
@@ -2143,34 +2195,37 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
sort($temparray);
$masterauxcolltype = implode('/', $temparray);
unset($temparray);
- $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeNoAdult'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeNoAdult'");
+ if (!$result) { safeDbDie(); }
$answer = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($answer === false) {
- $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."', property='masterauxcolltypeNoAdult'";
+ $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."', property='masterauxcolltypeNoAdult'";
}
else {
- $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."' WHERE property='masterauxcolltypeNoAdult'";
+ $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."' WHERE property='masterauxcolltypeNoAdult'";
}
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
unset($answer);
$ProfileName[$numtimings] = 'AuxilliaryCollectionsAdult'; $Profile[$numtimings++] = microtime_float()-$t0; $t0 = microtime_float();
if ($noadulttitles) {
- $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeAdult'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeAdult'");
+ if (!$result) { safeDbDie(); }
$answer = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($answer === false) {
- $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."', property='masterauxcolltypeAdult'";
+ $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."', property='masterauxcolltypeAdult'";
}
else {
- $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."' WHERE property='masterauxcolltypeAdult'";
+ $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."' WHERE property='masterauxcolltypeAdult'";
}
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
unset($answer);
}
else {
- $result = $db->sql_query("SELECT DISTINCT auxcolltype FROM $DVD_TABLE WHERE isadulttitle=0") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT auxcolltype FROM $DVD_TABLE WHERE isadulttitle=0");
+ if (!$result) { safeDbDie(); }
$masterauxcolltype = '';
while ($row = $db->sql_fetchrow($result)) {
$masterauxcolltype .= $row['auxcolltype'];
@@ -2180,19 +2235,20 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
sort($temparray);
$masterauxcolltype = implode('/', $temparray);
unset($temparray);
- $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeAdult'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='masterauxcolltypeAdult'");
+ if (!$result) { safeDbDie(); }
$answer = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($answer === false) {
- $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."', property='masterauxcolltypeAdult'";
+ $sql = "INSERT INTO $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."', property='masterauxcolltypeAdult'";
}
else {
- $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".addslashes($masterauxcolltype)."' WHERE property='masterauxcolltypeAdult'";
+ $sql = "UPDATE $DVD_PROPERTIES_TABLE SET value='".$db->sql_escape($masterauxcolltype)."' WHERE property='masterauxcolltypeAdult'";
}
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
unset($answer);
}
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.3||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.3||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
$ProfileName[$numtimings] = 'AuxilliaryCollectionsNoAdult'; $Profile[$numtimings++] = microtime_float()-$t0; $t0 = microtime_float();
if ($noadulttitles) $numtimings--;
@@ -2205,7 +2261,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
'',
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
}
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.4||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.4||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// Number of profiles per Audio Format
DoSomeStats('AudioFormat', false,
@@ -2213,7 +2269,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE d.id=a.id AND collectiontype='owned' $audiospecialcondition ",
"GROUP BY audioformat ORDER BY total DESC",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.5||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.5||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX profiles with longest running time
DoSomeStats('LongTime', true,
@@ -2221,7 +2277,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE collectiontype='owned' $runtimespecialcondition ",
"ORDER BY runningtime DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.6||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.6||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX profiles with shortest running time
DoSomeStats('ShortTime', true,
@@ -2229,7 +2285,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE collectiontype='owned' $shortestspecialcondition ",
"ORDER BY runningtime ASC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.7||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.7||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX profiles with longest running time NO TV
DoSomeStats('LongTimeNOTV', true,
@@ -2237,7 +2293,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE collectiontype='owned' $runtimespecialcondition$NOTVQuery ",
"ORDER BY runningtime DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.8||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.8||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX profiles with shortest running time NO TV
DoSomeStats('ShortTimeNOTV', true,
@@ -2245,7 +2301,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE collectiontype='owned' $shortestspecialcondition$NOTVQuery ",
"ORDER BY runningtime ASC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.9||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.9||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
if ($usetemptable) {
$sql = "CREATE TEMPORARY TABLE TEMP_ACTORS ("
@@ -2259,12 +2315,12 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
."countas smallint, "
."KEY(id), KEY(caid)"
.");";
- $db->sql_query($sql) or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
// this needs to be looked at
$sql = "INSERT IGNORE INTO TEMP_ACTORS SELECT a.id,caid,if(originaltitle != '', originaltitle, title),voice,uncredited,boxparent,isadulttitle,countas FROM $DVD_ACTOR_TABLE a,$DVD_TABLE d "
."WHERE a.id=d.id AND caid>0 AND collectiontype='owned'";
- $db->sql_query($sql) or die($db->sql_error());
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.10||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query($sql)) { safeDbDie(); }
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.10||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
$ProfileName[$numtimings] = 'Actors Setup'; $Profile[$numtimings++] = microtime_float()-$t0; $t0 = microtime_float();
// $MaxX most collected Actors
@@ -2273,7 +2329,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE 1 ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.11||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.11||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors excluding voice-only parts
DoSomeStats('ActorsNV', false,
@@ -2281,7 +2337,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE voice=0 ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.12||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.12||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/*********************************
// $MaxX most collected Actors counting BoxSets as 1
@@ -2305,7 +2361,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE 1$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.13||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.13||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors excluding voice-only parts
DoSomeStats('ActorsNVNOTV', false,
@@ -2313,7 +2369,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE voice=0$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.14||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.14||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/*********************************
// $MaxX most collected Actors counting BoxSets as 1 NO TV
@@ -2337,7 +2393,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE 1 ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.15||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.15||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors OriginalTitle NO TV
DoSomeStats('ActorsORNOTV', false,
@@ -2345,7 +2401,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE 1$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.16||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.16||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
else {
@@ -2355,7 +2411,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned' ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.17||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.17||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors excluding voice-only parts
DoSomeStats('ActorsNV', false,
@@ -2363,7 +2419,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned' AND voice=0 ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.18||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.18||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/************************************
// $MaxX most collected Actors counting BoxSets as 1
@@ -2387,7 +2443,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned'$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.19||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.19||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors excluding voice-only parts NO TV
DoSomeStats('ActorsNVNOTV', false,
@@ -2395,7 +2451,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned' AND voice=0$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.20||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.20||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/************************************
// $MaxX most collected Actors counting BoxSets as 1 NO TV
@@ -2419,7 +2475,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned' ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.21||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.21||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
// $MaxX most collected Actors OriginalTitle NO TV
DoSomeStats('ActorsORNOTV', false,
@@ -2427,7 +2483,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND caid>0 AND collectiontype='owned'$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.22||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.22||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
}
@@ -2437,7 +2493,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND collectiontype='owned' AND credittype='direction' ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.23||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.23||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/*************************************
// $MaxX most collected Directors counting BoxSets as 1
@@ -2454,7 +2510,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND collectiontype='owned' AND credittype='writing' ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.24||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.24||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/****************************************
// $MaxX most collected Writers counting BoxSets as 1
@@ -2471,7 +2527,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND collectiontype='owned' AND credittype='direction'$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.25||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.25||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/*************************************
// $MaxX most collected Directors counting BoxSets as 1 NO TV
@@ -2488,7 +2544,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
"WHERE a.id=d.id AND collectiontype='owned' AND credittype='writing'$NOTVQuery ",
"GROUP BY caid ORDER BY times DESC LIMIT $MaxX",
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.26||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.26||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
/****************************************
// $MaxX most collected Writers counting BoxSets as 1 NO TV
@@ -2505,7 +2561,8 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
// same currency. If they are not, then these results are incorrect. A more correct way to do this is once for
// each of the currencies paid ... a fair bit of work i'm not interested in doing at the moment
if ($TryToChangeMemoryAndTimeLimits) set_time_limit(0);
- $result = $db->sql_query("SELECT DISTINCT purchasepricecurrencyid AS ppci FROM $DVD_TABLE WHERE collectiontype='owned'") or die($db->sql_error());
+ $result = $db->sql_query("SELECT DISTINCT purchasepricecurrencyid AS ppci FROM $DVD_TABLE WHERE collectiontype='owned'");
+ if (!$result) { safeDbDie(); }
while ($ppcis = $db->sql_fetchrow($result)) {
DoSomeStats("$ppcis[ppci]PricePaid", false,
"title,purchasepricecurrencyid,id,paid*1000 FROM $DVD_TABLE ",
@@ -2514,7 +2571,7 @@ function UpdateStats($TryToChangeMemoryAndTimeLimits) {
$noadulttitles, $ProfileName, $Profile, $numtimings, $t0);
}
$db->sql_freeresult($result);
- $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.27||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'") or die($db->sql_error());
+ if (!$db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='-2.27||0|0|0|0|$MyConnectionId' WHERE property='CurrentPosition'")) { safeDbDie(); }
if ($ProfileStatistics) {
if ($inbrowser) echo "
";
// ***************** General Statistics
- echo <<
$lang[GENSTATS]
\n";
+ echo "
\n";
+ } else {
+ echo <<
$lang[GENSTATS]
EOT;
+ }
// Total number of profiles
$sql = "SELECT COUNT(*) AS total FROM $DVD_TABLE WHERE collectiontype='owned' $noadult";
@@ -166,7 +201,11 @@ function FiddleMonth(str) {
}
$db->sql_freeresult($result);
}
- echo "