diff --git a/.gitignore b/.gitignore index 79656ba..3aa8df3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ sonar-project.properties localsiteconfig.php* *.xml *.xml.gz +README.md diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..d5e2981 --- /dev/null +++ b/.htaccess @@ -0,0 +1,45 @@ +RewriteEngine On + +# Pages +RewriteRule ^popup\.php$ pages/popup.php [L,QSA] +RewriteRule ^gallery\.php$ pages/gallery.php [L,QSA] +RewriteRule ^ws\.php$ pages/ws.php [L,QSA] +RewriteRule ^rss\.php$ pages/rss.php [L,QSA] +RewriteRule ^smallshow\.php$ pages/smallshow.php [L,QSA] +RewriteRule ^BorrowADVD\.php$ pages/BorrowADVD.php [L,QSA] +RewriteRule ^Chooser\.php$ pages/Chooser.php [L,QSA] +RewriteRule ^Picker\.php$ pages/Picker.php [L,QSA] +RewriteRule ^userpref\.php$ pages/userpref.php [L,QSA] +RewriteRule ^summary\.php$ pages/summary.php [L,QSA] +RewriteRule ^handleloans\.php$ pages/handleloans.php [L,QSA] +RewriteRule ^MakeAnImage\.php$ pages/MakeAnImage.php [L,QSA] +RewriteRule ^getimages\.php$ pages/getimages.php [L,QSA] +RewriteRule ^no_coo\.php$ pages/no_coo.php [L,QSA] +RewriteRule ^wrong_srp\.php$ pages/wrong_srp.php [L,QSA] +RewriteRule ^showcolors\.php$ pages/showcolors.php [L,QSA] + +# Admin tools +RewriteRule ^ForceDatabaseUpgrade\.php$ admin/ForceDatabaseUpgrade.php [L,QSA] +RewriteRule ^checkruntimes\.php$ admin/checkruntimes.php [L,QSA] +RewriteRule ^checktables\.php$ admin/checktables.php [L,QSA] +RewriteRule ^check_credits\.php$ admin/check_credits.php [L,QSA] +RewriteRule ^CleanCommon\.php$ admin/CleanCommon.php [L,QSA] +RewriteRule ^ConvertUTF8FilenamesToCP1252\.php$ admin/ConvertUTF8FilenamesToCP1252.php [L,QSA] + +# Graphs +RewriteRule ^gr_by(.+)\.php$ graphs/gr_by$1.php [L,QSA] + +# JS/CSS generators +RewriteRule ^format\.css\.php$ js/format.css.php [L,QSA] +RewriteRule ^momItems\.js\.php$ js/momItems.js.php [L,QSA] +RewriteRule ^SmartUpdater\.js\.php$ js/SmartUpdater.js.php [L,QSA] + +# Static JS/CSS files +RewriteRule ^main\.js$ js/main.js [L] +RewriteRule ^mom\.js$ js/mom.js [L] +RewriteRule ^navframe\.js$ js/navframe.js [L] +RewriteRule ^top\.js$ js/top.js [L] +RewriteRule ^JavascriptOnerr\.js$ js/JavascriptOnerr.js [L] +RewriteRule ^wz_tooltip\.js$ js/wz_tooltip.js [L] +RewriteRule ^custom\.css$ js/custom.css [L] +RewriteRule ^smallshow\.css$ js/smallshow.css [L] diff --git a/CHANGES b/CHANGES index 5a89eb5..47be916 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,35 @@ +Version 20260211 (fork by jakub961241) +Changes since version 20260208: +- feature: web-based XML upload — new `import/` directory with upload form on the update page, allowing collection.xml upload from the browser instead of requiring FTP access +- feature: TMDB Cover Fetcher (`fetch_covers.php`) — browse collection, search TMDB for movie posters, download covers with thumbnails; includes auto-fetch for all missing covers +- feature: `config/localsiteconfig.php.example` — example configuration file with all important settings and comments, ready to copy and customize +- feature: TMDB API key now configurable in `install.php` (Step 1) and `localsiteconfig.php` instead of being hardcoded +- feature: installer (`install.php`) — web-based setup wizard that creates `localsiteconfig.php`, checks directory permissions, and initializes the database schema +- feature: Bootstrap 5.3.3 dark theme applied across the entire application (index, admin, statistics, graphs, includes) +- feature: complete translations for all 10 language files (en, cs, de, dk, fi, fr, nl, no, ru, sv) — 900+ new translated strings covering upload UI, cover fetcher, preferences, chooser, statistics, graphs, link categories, color formats, and crew roles +- feature: sidebar sort header with column labels +- feature: `Titles Per Page` pagination preference with translations in all languages +- refactor: folder reorganization — PHP files moved from root into `core/`, `pages/`, `includes/`, `admin/`, `graphs/` subdirectories with `bootstrap.php` autoloader and `.htaccess` rewrites for backward compatibility +- fix: `statistics.php` — `round(0, INF)` TypeError when `log10()` returns `-INF` in `MakeAPercentage()` +- fix: `ws.php` — DISTINCT + ORDER BY errors with unqualified `timestamp` column in 4 queries (Last/Best/Worst/Me Watched) +- fix: `ws.php` — null array access in `get_watchers()` and `me_watched` when no rows returned +- fix: `popup.php` — `only_full_group_by` SQL mode error in actor/credit filmography queries (ORDER BY without GROUP BY) +- fix: `functions.php` — `mb_convert_encoding()` deprecation with null input +- fix: `incupdate.php` — duplicate key handling on insert +- fix: DVD detail rendering issues with cover display +- fix: favicon path corrected +- removed: `db/consistancy.sql` — unused diagnostic SQL script + +Version 20260208 (fork by jakub961241) +Changes since version 20250511: +- feature: added complete Czech translation (`lang_cs.php`) with 900+ translated strings including UI labels, genre names, country names, audio languages, crew roles and statistics +- feature: registered Czech locale in `locale.php` and added language selector in `index.php` +- fix: full PHP 8.3+ compatibility — changed default `$dbtype` from `mysql` to `mysqli` in `globalinits.php` +- fix: replaced direct `mysql_fetch_array()` in `getimages.php` and `mysql_error()` in `imagedata.php` with database abstraction layer methods +- fix: replaced deprecated `var` property declarations with `public` in `mysqli.php`, `mysql.php` and `incupdate.php` +- fix: replaced deprecated `@list()` with explicit array access using null coalescing (`??`) in `functions.php` +- fix: added deprecation notice to `mysql.php` recommending `mysqli` + Version 20250511 (phpdvdprofiler.20250511.zip) Changes since version v_20230807 (phpdvdprofiler.20230807.zip) - security: removed XSS using the search function (CVE-2025-46729) diff --git a/MakeHTMLFromSkin.php b/MakeHTMLFromSkin.php deleted file mode 100644 index 6429f0f..0000000 --- a/MakeHTMLFromSkin.php +++ /dev/null @@ -1,33 +0,0 @@ -newskin.html -// -// eg: php MakeHTMLFromSkin.php sv 'phpDVDProfiler Skin.html' >skin.html -// to create the skin with Swedish strings -// -// This code puts the language strings into a skin by replacing the $lang[] elements -// for the purpose of creating an HTML file for import into DVDProfiler - -include_once('lang_'.$_SERVER['argv'][1].'.php'); - -function Replace2Lang($matches) { -global $lang; - $matches[1] = str_replace("'", '', $matches[1]); - $matches[1] = str_replace('"', '', $matches[1]); - $matches[2] = str_replace("'", '', $matches[2]); - $matches[2] = str_replace('"', '', $matches[2]); - return($lang[$matches[1]][$matches[2]]); -} -function ReplaceLang($matches) { -global $lang; - $matches[1] = str_replace("'", '', $matches[1]); - $matches[1] = str_replace('"', '', $matches[1]); - return($lang[$matches[1]]); -} - - $j = file_get_contents($_SERVER['argv'][2]); - - $j = preg_replace_callback('/\\$lang\\[(.*)\\]\\[(.*)\\]/U', "Replace2Lang", $j); - $j = preg_replace_callback('/\\$lang\\[(.*)\\]/U', "ReplaceLang", $j); - - echo $j; diff --git a/README.md b/README.md index e56b0b9..c66bcf2 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,50 @@ # phpDVDProfiler -The phpDVDProfiler project allows you to display on the web your DVD collection maintained with Invelos's DVDProfiler software. +The phpDVDProfiler project allows you to display on the web your DVD collection maintained with [Invelos's DVD Profiler](http://www.intl.dvdprofiler.com/) software. Alas, the project seems to have been dead for some time and has stopped working with newer versions of PHP. So for my own needs, I've decided to make it work again with PHP 7.2, and publish it too so that others can benefit if they need it. I have no intention on making more work than basic maintenance to support newer versions of PHP. +## What's New in This Fork + +This fork extends the original project with PHP 8.3+ compatibility and several new features: + +- **Modern UI** — Bootstrap 5.3.3 dark theme applied across the entire application +- **Web-based installer** (`install.php`) — 3-step setup wizard that checks requirements, creates configuration, and initializes the database +- **TMDB Cover Fetcher** — search and download movie posters from The Movie Database; includes one-click auto-fetch for all missing covers +- **Web-based XML upload** — upload your `collection.xml` directly from the browser instead of requiring FTP access +- **Full internationalization** — complete translations for 10 languages (English, Czech, German, Danish, Finnish, French, Dutch, Norwegian, Russian, Swedish) with 900+ translated strings +- **Titles Per Page** — configurable pagination for large collections +- **Example configuration** — `config/localsiteconfig.php.example` with all settings documented and ready to customize +- **PHP 8.3+ fixes** — resolved deprecation warnings, SQL compatibility issues, null handling errors, and an XSS vulnerability (CVE-2025-46729) +- **Code reorganization** — PHP files moved into `core/`, `pages/`, `includes/`, `admin/`, `graphs/` subdirectories with backward-compatible URL rewrites + ## Getting Started -See the file phpdvdprofiler-install.txt for instructions on installing the application. +### Quick Start + +1. Extract the files to your web server directory +2. Open `install.php` in your browser and follow the wizard +3. Upload your `collection.xml` via the update page +4. Run the import from `index.php?action=update` + +### Manual Installation + +See the file `docs/phpdvdprofiler-install.txt` for detailed instructions. Copy `config/localsiteconfig.php.example` to `config/localsiteconfig.php` and edit your settings there. + +## Requirements + +- PHP 7.2+ (tested with PHP 8.3) +- MySQL 5.7+ or MariaDB 10.x+ +- Apache with `mod_rewrite` +- PHP extensions: `mysqli`, `mbstring`, `xml`, `intl`, `gd` (optional, for thumbnails) ## Authors -* **FredLooks and contributors** - *Initial work* - [FredLooks](http://www.invelos.com/UserProfile.aspx?Alias=FredLooks) -* **Thomas Fintzel** - *Gallery code for the covers* -* **Julien Mudry** - *Compatibility with PHP 7.2* -* **Gavin-John Noonan** - *Suport of 4K UHD media types and numerous fixes* - [Gavin-John Noonan](https://github.com/gjnoonan) +- **FredLooks** and contributors — Initial work — [FredLooks](https://github.com/FredLooks) +- **Thomas Fintzel** — Gallery code for the covers +- **Julien Mudry** — Compatibility with PHP 7.2 +- **Gavin-John Noonan** — Support of 4K UHD media types and numerous fixes — [Gavin-John Noonan](https://github.com/gavinjohn) +- **jakub961241** — PHP 8.3 compatibility, Bootstrap theme, installer, TMDB cover fetcher, Czech translation, full i18n ## License diff --git a/TODO b/TODO deleted file mode 100644 index e0ead12..0000000 --- a/TODO +++ /dev/null @@ -1,11 +0,0 @@ - - boxset association doesn't occur when searching. This is - because I can't get the records to order properly. - - collection=loaned ignores boxchildren. This is related to - the above problem with displaying boxsets when searches happen. - - need a TitlesPerPage userpref - - pagination needs pages, not just previous/next - - - boxset spacing is whack - - this doesn't account for people who don't have gd as part of php ... - - - update can break with media-type issue if offset is borked diff --git a/TestFonts.php b/TestFonts.php deleted file mode 100644 index 1ed190f..0000000 --- a/TestFonts.php +++ /dev/null @@ -1,270 +0,0 @@ - -1, 1 => 3, 2 => 123, 3 => 3, 4 => 123, 5 => -11, 6 => -1, 7 => -11); -$cour = array(0 => 0, 1 => 2, 2 => 174, 3 => 2, 4 => 174, 5 => -9, 6 => 0, 7 => -9); -$comic = array(0 => 0, 1 => 4, 2 => 128, 3 => 4, 4 => 128, 5 => -12, 6 => 0, 7 => -12); -$times = array(0 => -1, 1 => 3, 2 => 111, 3 => 3, 4 => 111, 5 => -10, 6 => -1, 7 => -10); - -function DisplayError($heading) { -global $eoln, $g_errno, $g_errstr, $g_errfile, $g_errline; - - if ($eoln !== "\n") { - $bold = ''; $unbold = ''; - $space = '          '; - } - else { - $bold = $unbold = '****'; - $space = "\t"; - } - if ($heading != '') - echo "$bold$heading$unbold$eoln"; - echo "$space Error Number: [$g_errno]$eoln"; - echo "$space Error String: $g_errstr$eoln"; - if ($heading != '') - echo "$space Error Location: Line $g_errline of $g_errfile$eoln"; -} - -function myErrorHandler($errno, $errstr, $errfile, $errline) { -global $IAmReady, $g_errno, $g_errstr, $g_errfile, $g_errline, $ItWorked; - - $ItWorked = false; - $g_errno = $errno; - $g_errstr = $errstr; - $g_errfile = $errfile; - $g_errline = $errline; - if (!$IAmReady) { - DisplayError("Error Handler: Unexpected error"); - } - - /* Don't execute PHP internal error handler */ - return(true); -} - -function DisplayResult($result) { -global $eoln; - if ($eoln !== "\n") echo "
";
-    $one = str_pad("($result[6],$result[7])", 16);
-    echo "$one\t\t($result[4],$result[5])\n";
-    $one = str_pad("($result[0],$result[1])", 16);
-    echo "$one\t\t($result[2],$result[3])\n";
-    if ($eoln !== "\n") echo "
"; -//print_r($result); -} - -function DisplayFilesInDir($dir, $extfil='', $typefil='') { -global $eoln; - - if (!is_dir($dir)) { - echo "$dir is not a valid path to a directory.$eoln"; - return; - } - if (($dh=opendir($dir)) === false) { - echo "Unable to open directory $dir$eoln"; - return; - } - $count = 0; - if ($eoln !== "\n") echo "
";
-    while (($file=readdir($dh)) !== false) {
-        if ($file == '.' || $file == '..')
-            continue;       // ignore sub-directory linkages
-        //echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
-        if ($extfil != '' && pathinfo($file, PATHINFO_EXTENSION) != $extfil)
-            continue;
-        $ActualFile = $dir.$file;
-        if (filetype($dir.$file) == 'link')
-            $ActualFile = readlink($dir.$file);
-        if ($typefil != '' && filetype($ActualFile) == $typefil) {
-            $count++;
-            if ($ActualFile != $dir.$file)
-                echo "\t$dir$file => $ActualFile ($typefil)\n";
-            else
-                echo "\t$dir$file ($typefil)\n";
-        }
-        if ($typefil == '') {
-            $count++;
-            echo "\t$dir$file\n";
-        }
-    }
-    closedir($dh);
-    if ($eoln !== "\n") echo "
"; - return($count); -} - -function TestAFont($fontname, $MyResult='') { -global $eoln, $IAmReady, $g_errno, $g_errstr, $g_errfile, $g_errline, $ItWorked; -global $$MyResult; - - $ItWorked = true; - $IAmReady = true; - $result = ImageTTFBBox(10, 0, $fontname, 'This is just some text'); - $IAmReady = false; - if ($ItWorked) { - echo "The ImageTTFBBox() call with font \"$fontname\" succeeded.$eoln"; - echo "Font \"$fontname\" gives a bounding box of:$eoln"; - DisplayResult($result); - if ($result[6] != $result[0] || $result[4] != $result[2] || $result[7] != $result[5] || $result[1] != $result[3]) { - echo "****The result isn't a rectangle!?!?!$eoln"; - } - echo "which means a height of ", $result[3] - $result[5], " and a width of ", $result[4] - $result[6], $eoln; - if (isset($$MyResult)) { - if ($result != $$MyResult) { - echo "This is different than my result of:$eoln"; - DisplayResult($$MyResult); - } - } - else { - echo "I have no external data on font \"$fontname\"$eoln"; - } - return(true); - } - else { - echo "The ImageTTFBBox() call with font \"$fontname\" FAILED.$eoln"; - echo "The Error Handler reported:$eoln"; - DisplayError(''); - return(false); - } -} - -function TestConfiguration(&$fontnames) { -global $eoln; - - $FontsTested = array(); - foreach($fontnames as $key => $fontname) { - echo "$eoln$key: Testing font \"$fontname\":"; - if (in_array($fontname, $FontsTested)) { - echo " Already tested$eoln"; - } - else { - echo "$eoln"; - $success = TestAFont($fontname, basename($fontname, '.ttf')); - if ($success) - $FontsTested[] = $fontname; - if ($fontname != basename($fontname)) { - echo "Testing font \"$fontname\" without the path...$eoln"; - $success = TestAFont(basename($fontname), basename($fontname, '.ttf')); - if ($success) - $FontsTested[] = basename($fontname); - } - } - } - return($FontsTested); -} - - set_error_handler('myErrorHandler'); - echo "This code is running on PHP " . PHP_VERSION . " (" . PHP_OS . ")$eoln"; - echo "in directory ", getcwd(), " [", realpath(getcwd()),"]$eoln"; - if (!function_exists('ImageTTFBBox')) { - echo "The function ImageTTFBBox() does not exist.$eoln"; - echo "None of the image code will work.$eoln"; - echo "Likely this instance of php was not compiled with the GD option.$eoln"; - echo "Aborting.$eoln"; - exit; - } - - $GDFPOGood = true; - $GDFONTPATH = @getenv('GDFONTPATH'); - if ($GDFONTPATH !== false) { - echo "Environment variable GDFONTPATH is \"$GDFONTPATH\"$eoln"; - echo "TrueType fonts available in that directory are:$eoln"; - $num = DisplayFilesInDir($GDFONTPATH, 'ttf'); - echo "for a total of $num fonts$eoln"; - } - else { - echo "Environment variable GDFONTPATH is not set.$eoln"; - $GDFONTPATH = ''; - } - if (isset($GDFontPathOverride)) { - echo "phpdvdprofiler variable \$GDFontPathOverride is set to \"$GDFontPathOverride\"$eoln"; - echo "TrueType fonts available in that directory are:$eoln"; - $num = DisplayFilesInDir($GDFontPathOverride, 'ttf'); - echo "for a total of $num fonts$eoln"; - if ($num == 0) { - echo "It look like this is a bad setting for \$GDFontPathOverride; it should likely be$eoln"; - echo "removed, or possibly changed. More information later...$eoln"; - $GDFPOGood = false; - } - } - - $TryJpGraph = false; - if ($usejpgraph) { - echo "It says here that jpgraph is to be used"; - if (!isset($jpgraphlocation)) { - echo " but \$jpgraphlocation isn't set$eoln"; - } - else { - echo " and it's located at \"$jpgraphlocation\"$eoln"; - if (!is_dir($jpgraphlocation)) { - echo "Sadly, that is not a directory, so no help there (and likely your graphs are broken, also)$eoln"; - } - else { - echo "The directories in that location are:$eoln"; - DisplayFilesInDir($jpgraphlocation, '', 'dir'); - if (!is_dir($jpgraphlocation.'fonts')) { - echo "Sadly, there is no {$jpgraphlocation}fonts directory, so likely no fonts.$eoln"; - } - else { - echo "The directories in {$jpgraphlocation}fonts are:$eoln"; - DisplayFilesInDir($jpgraphlocation.'fonts/', '', 'dir'); - if (!is_dir($jpgraphlocation.'fonts/truetype')) { - echo "Sadly, there is no {$jpgraphlocation}fonts/truetype directory, so likely no fonts.$eoln"; - } - else { - echo "TrueType fonts available in {$jpgraphlocation}fonts/truetype are:$eoln"; - $num = DisplayFilesInDir($jpgraphlocation.'fonts/truetype/', 'ttf'); - echo "for a total of $num fonts$eoln"; - $TryJpGraph = true; - } - } - } - } - } - - if (isset($profiles)) { - foreach ($profiles as $key => $profile) { - if (isset($profile['font'])) - $fontnames[$key] = $profile['font']; - else - $fontnames[$key] = 'arial.ttf'; - } - } - - echo "{$eoln}/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\/\\$eoln"; - echo "Testing ImageTTFBBox() calls with the current configuration$eoln"; - $FontsSucceeded = TestConfiguration($fontnames); - $numsystem = count($FontsSucceeded); - if ($TryJpGraph) { - echo "{$eoln}/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\/\\$eoln"; - echo "Testing ImageTTFBBox() calls using {$jpgraphlocation}fonts/truetype in the fontpath$eoln"; - $gdfp = @putenv("GDFONTPATH={$jpgraphlocation}fonts/truetype"); - if ($gdfp === false) - echo "The putenv() call to set the path indicates that it FAILED$eoln"; - $FontsSucceeded = TestConfiguration($fontnames); - $numjpgraph = count($FontsSucceeded); - if ($numsystem != $numjpgraph) - echo "Current configuration: $numsystem fonts available{$eoln}JpGraph configuration: $numjpgraph fonts available$eoln"; - if ($numjpgraph > $numsystem) - echo "{$eoln}Consider setting \$GDFontPathOverride = '{$jpgraphlocation}fonts/truetype'; in your $localsiteconfig$eoln"; - } - if (isset($GDFontPathOverride) && $GDFPOGood) { - echo "{$eoln}/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\/\\$eoln"; - echo "Testing ImageTTFBBox() calls using $GDFontPathOverride in the fontpath$eoln"; - $gdfp = @putenv("GDFONTPATH=$GDFontPathOverride"); - if ($gdfp === false) - echo "The putenv() call to set the path indicates that it FAILED$eoln"; - $FontsSucceeded = TestConfiguration($fontnames); - $numgdfpo = count($FontsSucceeded); - if ($numsystem != $numgdfpo) - echo "Current configuration: $numsystem fonts available{$eoln}\$GDFontPathOverride configuration: $gdfpo fonts available$eoln"; - if ($numgdfpo > $numsystem) - echo "{$eoln}Consider setting \$GDFontPathOverride = '{$jpgraphlocation}fonts/truetype'; in your $localsiteconfig$eoln"; - } - exit; diff --git a/CleanCommon.php b/admin/CleanCommon.php similarity index 82% rename from CleanCommon.php rename to admin/CleanCommon.php index beb7a49..f4495f0 100644 --- a/CleanCommon.php +++ b/admin/CleanCommon.php @@ -1,9 +1,10 @@ sql_query($sql) or die($db->sql_error()); @@ -26,6 +27,6 @@ function CheckCommonTable($t1, $t2) { } echo "Checking Cast\n"; - CheckCommonTable($DVD_ACTOR_TABLE, $DVD_COMMON_ACTOR_TABLE); + checkCommonTable($DVD_ACTOR_TABLE, $DVD_COMMON_ACTOR_TABLE); echo "Checking Crew\n"; - CheckCommonTable($DVD_CREDITS_TABLE, $DVD_COMMON_CREDITS_TABLE); + checkCommonTable($DVD_CREDITS_TABLE, $DVD_COMMON_CREDITS_TABLE); diff --git a/ConvertUTF8FilenamesToCP1252.php b/admin/ConvertUTF8FilenamesToCP1252.php similarity index 77% rename from ConvertUTF8FilenamesToCP1252.php rename to admin/ConvertUTF8FilenamesToCP1252.php index 75b828d..8b5399b 100644 --- a/ConvertUTF8FilenamesToCP1252.php +++ b/admin/ConvertUTF8FilenamesToCP1252.php @@ -2,12 +2,13 @@ error_reporting(-1); $goterror = false; -function myErrorHandler($errno, $errstr, $errfile, $errline) { +function myErrorHandler($errno) { global $goterror; - if ($errno != E_NOTICE) - return(false); + if ($errno != E_NOTICE) { + return false; + } $goterror = true; - return(true); + return true; } // set to the user defined error handler @@ -19,20 +20,21 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) { echo "Unable to open directory '$dir' to read. Exiting.\n"; exit; } - echo "
Processing '$dir'\n";;
+    echo "
Processing '$dir'\n";
     while (($old=readdir($handle)) !== false) {
-        if (is_dir($old))
+        if (is_dir($old)) {
             continue;
+        }
         echo "Processing '$dir$old' ... ";
         $goterror = false;
         $new = iconv('UTF-8', 'CP1252', $old);
         if ($goterror) {
             echo "non-UTF-8 characters in string: ignoring this file";
         }
-        else if ($new == '') {
+        elseif ($new == '') {
             echo "new filename is empty: ignoring this file";
         }
-        else if ($new != $old) {
+        elseif ($new != $old) {
             echo "Converting '$old' to '$new'";
             rename($dir.$old, $dir.$new);
         }
diff --git a/ForceDatabaseUpgrade.php b/admin/ForceDatabaseUpgrade.php
similarity index 87%
rename from ForceDatabaseUpgrade.php
rename to admin/ForceDatabaseUpgrade.php
index 3c8295b..d7535d4 100644
--- a/ForceDatabaseUpgrade.php
+++ b/admin/ForceDatabaseUpgrade.php
@@ -1,7 +1,8 @@
 sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='0.0' WHERE property='db_schema_version'");
 
diff --git a/admin/check_credits.php b/admin/check_credits.php
new file mode 100644
index 0000000..21e7c2d
--- /dev/null
+++ b/admin/check_credits.php
@@ -0,0 +1,63 @@
+%s%s%s";
+        if ($is_first) {
+            echo "
\n"; + } else { + echo "
$check_description


\n"; + } + } else { + $fmt = "%s || %s || %s\n"; + if ($is_first) { + echo "$check_description\n"; + } else { + echo "\n\n$check_description\n"; + } + } + + // Execute query + $res = $db->sql_query($sql) or die($db->sql_error()); + + // Loop through results and display + while ($row = $db->sql_fetchrow($res)) { + if ($row['description'] != '') { + $row['title'] = "$row[title] ($row[description])"; + } + printf($fmt, $row['title'], $row['fullname'], $row['role']); + } + + // Free result + $db->sql_freeresult($res); +} + + $check1 = "Checking for truncated 'uncredited' indicators [searching roles for '(u']"; + $check2 = "Checking for truncated 'voice' indicators [searching roles for '(v']"; + + $sql1 = "SELECT title,description,fullname,role FROM $DVD_TABLE d, $DVD_COMMON_ACTOR_TABLE ca, $DVD_ACTOR_TABLE a WHERE a.id=d.id AND ca.caid=a.caid AND role LIKE '%(u%' ORDER BY sorttitle"; + displayCreditsCheck($db, $check1, $sql1, $inbrowser, true); + + $sql2 = "SELECT title,description,fullname,role FROM $DVD_TABLE d, $DVD_COMMON_ACTOR_TABLE ca, $DVD_ACTOR_TABLE a WHERE a.id=d.id AND ca.caid=a.caid AND role LIKE '%(v%' ORDER BY sorttitle"; + displayCreditsCheck($db, $check2, $sql2, $inbrowser, false); + + echo "\n"; + + if ($inbrowser) { + echo "
$check_description

\n"; + } diff --git a/checkruntimes.php b/admin/checkruntimes.php similarity index 86% rename from checkruntimes.php rename to admin/checkruntimes.php index 122a98a..0706c87 100644 --- a/checkruntimes.php +++ b/admin/checkruntimes.php @@ -2,15 +2,19 @@ error_reporting(E_ALL); defined('IN_SCRIPT') || define('IN_SCRIPT', 1); -if (!isset($_SERVER['QUERY_STRING'])) +if (!isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = '(Null)'; -include_once('global.php'); -SendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";'); +} +require_once __DIR__ . '/../bootstrap.php'; +include_once 'global.php'; +sendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";'); - if (!isset($runtimeslack)) + if (!isset($runtimeslack)) { $runtimeslack = 2; - if ($inbrowser) + } + if ($inbrowser) { echo "
";
+    }
     $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());
 
diff --git a/admin/checktables.php b/admin/checktables.php
new file mode 100644
index 0000000..a48311f
--- /dev/null
+++ b/admin/checktables.php
@@ -0,0 +1,67 @@
+sql_query($sql);
+    $firstrow = true;
+    while ($row = $db->sql_fetchrow($result)) {
+        if ($firstrow) {
+            $firstrow = false;
+            echo "\n";
+            foreach ($row as $key => $value) {
+                echo "";
+            }
+            echo "\n";
+        }
+        echo "";
+        foreach ($row as $key => $value) {
+            echo "\n";
+        }
+        echo "\n";
+    }
+    echo "
" . htmlspecialchars($key) . "
" . htmlspecialchars($value ?? '') . "
\n"; + $db->sql_freeresult($result); + unset($row); +} + + $allowed_table_vars = array( + 'DVD_TABLE', 'DVD_COMMON_ACTOR_TABLE', 'DVD_ACTOR_TABLE', 'DVD_EVENTS_TABLE', + 'DVD_DISCS_TABLE', 'DVD_LOCKS_TABLE', 'DVD_AUDIO_TABLE', 'DVD_COMMON_CREDITS_TABLE', + 'DVD_CREDITS_TABLE', 'DVD_BOXSET_TABLE', 'DVD_GENRES_TABLE', 'DVD_STUDIO_TABLE', + 'DVD_SUBTITLE_TABLE', 'DVD_TAGS_TABLE', 'DVD_STATS_TABLE', 'DVD_SUPPLIER_TABLE', + 'DVD_PROPERTIES_TABLE', 'DVD_EXCLUSIONS_TABLE', 'DVD_LINKS_TABLE', 'DVD_USERS_TABLE', + ); + $allowed_tables = array(); + foreach ($allowed_table_vars as $var) { + if (isset($GLOBALS[$var])) { + $allowed_tables[] = $GLOBALS[$var]; + } + } + + $table = @$_GET['table']; + if (is_string($table) && isset($table[0]) && $table[0] == '$') { + $var_name = substr($table, 1); + if (in_array($var_name, $allowed_table_vars, true) && isset($GLOBALS[$var_name])) { + $table = $GLOBALS[$var_name]; + } else { + $table = ''; + } + } + if ($table == '' || !in_array($table, $allowed_tables, true)) { + $table = $DVD_STATS_TABLE; + } + + $request = "SELECT * FROM ".$db->sql_escape($table); + echo "Dump of table " . htmlspecialchars($table) . "\n"; + displayAResultSet($db, $request); + echo "\n"; diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..9ab3471 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,14 @@ +%s%s%s"; - echo "
\n"; - } - else { - $fmt = "%s || %s || %s\n"; - echo "$check1\n"; - } - - $sql = "SELECT title,description,fullname,role FROM $DVD_TABLE d, $DVD_COMMON_ACTOR_TABLE ca, $DVD_ACTOR_TABLE a WHERE a.id=d.id AND ca.caid=a.caid AND role LIKE '%(u%' ORDER BY sorttitle"; - $res = $db->sql_query($sql) or die($db->sql_error()); - - while ($row = $db->sql_fetchrow($res)) { - if ($row['description'] != '') $row['title'] = "$row[title] ($row[description])"; - printf($fmt, $row['title'], $row['fullname'], $row['role']); - } - $db->sql_freeresult($res); - if ($inbrowser) { - echo "
$check1


\n"; - } - else { - echo "\n\n$check2\n"; - } - - $sql = "SELECT title,description,fullname,role FROM $DVD_TABLE d, $DVD_COMMON_ACTOR_TABLE ca, $DVD_ACTOR_TABLE a WHERE a.id=d.id AND ca.caid=a.caid AND role LIKE '%(v%' ORDER BY sorttitle"; - $res = $db->sql_query($sql) or die($db->sql_error()); - - while ($row = $db->sql_fetchrow($res)) { - if ($row['description'] != '') $row['title'] = "$row[title] ($row[description])"; - printf($fmt, $row['title'], $row['fullname'], $row['role']); - } - $db->sql_freeresult($res); - echo "\n"; - - if ($inbrowser) { - echo "
$check2

\n"; - } diff --git a/checktables.php b/checktables.php deleted file mode 100644 index 0531869..0000000 --- a/checktables.php +++ /dev/null @@ -1,39 +0,0 @@ -sql_query($sql); - $firstrow = true; - while ($row = $db->sql_fetchrow($result)) { - if ($firstrow) { - $firstrow = false; - echo "\n"; - foreach ($row as $key => $value) { - echo ""; - } - echo "\n"; - } - echo ""; - foreach ($row as $key => $value) { - echo "\n"; - } - echo "\n"; - } - echo "
$key
$value
\n"; - $db->sql_freeresult($result); - unset($row); -} - - $table = @$_GET['table']; - if ($table[0] == '$') - $table = $GLOBALS[substr($table, 1)]; - if ($table == '') - $table = $DVD_STATS_TABLE; - - $request = "SELECT * FROM ".$db->sql_escape($table); - echo "Dump of table $table\n"; - DisplayAResultSet($db, $request); - echo "\n"; diff --git a/emailmessageconfig.php b/config/emailmessageconfig.php similarity index 98% rename from emailmessageconfig.php rename to config/emailmessageconfig.php index 0ecb4db..f02f706 100644 --- a/emailmessageconfig.php +++ b/config/emailmessageconfig.php @@ -3,8 +3,6 @@ // This file needs to define $LOAN_REMINDER_FROM as the address that you want the email // to come from. Replies will also go to this address. -//$LOAN_REMINDER_FROM = "fred@bws.com"; - // This file also needs to define the messages that will be sent to the borrowers. If you want // only one message sent until the DVD is returned, then define only $message[1]. If you want // a series of different messages sent until the return, then define more messages as diff --git a/globalinits.php b/config/globalinits.php similarity index 86% rename from globalinits.php rename to config/globalinits.php index fe9219a..b044db1 100644 --- a/globalinits.php +++ b/config/globalinits.php @@ -10,12 +10,18 @@ // in siteconfig.php rather than setting them appropriately. This is to prevent having // to have butt-loads of "if (isset($var))""-type code ... +// Define constants for commonly used color and icon literals +define('COLOR_LIGHT_GREEN', '#BDD9A7'); +define('COLOR_DARK_BLUE', '#0000A0'); +define('ICON_ULTRAHD', 'gfx/iconultrahd.png'); +define('ICON_ULTRAHD_JPG', 'gfx/ultrahd.jpg'); + $ClassColor[0] = 'blue'; // #0000FF URL link to main page color $ClassColor[1] = '#ADA9A9'; // -$ClassColor[2] = '#BDD9A7'; // +$ClassColor[2] = COLOR_LIGHT_GREEN; // $ClassColor[3] = '#D9E1FF'; // $ClassColor[4] = '#ADC0D3'; // -$ClassColor[5] = '#0000A0'; // +$ClassColor[5] = COLOR_DARK_BLUE; // $ClassColor[6] = '#CCFFCC'; // $ClassColor[7] = '#CCFFDD'; // $ClassColor[8] = '#99CC99'; // @@ -30,17 +36,17 @@ $ClassColor[17] = 'white'; // #FFFFFF class=f1 text color $ClassColor[18] = 'black'; // #000000 class=l,o,d,a,u,v,x,y,z1,f2,f2np,f7 text color $ClassColor[19] = 'white'; // #FFFFFF class=nav text color -$ClassColor[20] = '#BDD9A7'; // class=a,f6,f8,bgl bgcolor -$ClassColor[21] = '#BDD9A7'; // class=z2,f3,f3np,f5 bgcolor +$ClassColor[20] = COLOR_LIGHT_GREEN; // class=a,f6,f8,bgl bgcolor +$ClassColor[21] = COLOR_LIGHT_GREEN; // class=z2,f3,f3np,f5 bgcolor $ClassColor[22] = 'black'; // #000000 class=z2 text color -$ClassColor[23] = '#0000A0'; // class=f3,f3np text color -$ClassColor[24] = '#0000A0'; // class=f5,f6 text color +$ClassColor[23] = COLOR_DARK_BLUE; // class=f3,f3np text color +$ClassColor[24] = COLOR_DARK_BLUE; // class=f5,f6 text color $ClassColor[25] = 'white'; // #FFFFFF mom_linkBGColor $ClassColor[26] = '#CCCCCC'; // mom_linkOverBGColor $ClassColor[27] = 'black'; // #000000 mom_menuBGColor ... was #CCCCCC $ClassColor[28] = 'black'; // #000000 mom_hdrFontColor -$ClassColor[29] = '#BDD9A7'; // mom_hdrBGColor -$ClassColor[30] = '#0000A0'; // mom_barBGColor +$ClassColor[29] = COLOR_LIGHT_GREEN; // mom_hdrBGColor +$ClassColor[30] = COLOR_DARK_BLUE; // mom_barBGColor $ClassColor[31] = 'white'; // #FFFFFF mom_barFontColor $ClassColor[32] = 'black'; // #000000 class=s text color $ClassColor[33] = 'black'; // #000000 class=s1 text color @@ -67,9 +73,9 @@ MEDIA_TYPE_HDDVD_DVD => array('FormatIcon' => 'gfx/iconhddvdpng.png', 'Icon' => 'gfx/hddvd.jpg', 'Banner' => 'gfx/Banner_HDDVD_DVD.png'), MEDIA_TYPE_BLURAY => array('FormatIcon' => 'gfx/iconbluraypng.png', 'Icon' => 'gfx/bluray.jpg', 'Banner' => 'gfx/Banner_BluRay.png'), MEDIA_TYPE_BLURAY_DVD => array('FormatIcon' => 'gfx/iconbluraypng.png', 'Icon' => 'gfx/bluray.jpg', 'Banner' => 'gfx/Banner_BluRayDVD.png'), - MEDIA_TYPE_ULTRAHD => array('FormatIcon' => 'gfx/iconultrahd.png', 'Icon' => 'gfx/ultrahd.jpg', 'Banner' => 'gfx/Banner_UltraHD.png'), - MEDIA_TYPE_ULTRAHD_BLURAY => array('FormatIcon' => 'gfx/iconultrahd.png', 'Icon' => 'gfx/ultrahd.jpg', 'Banner' => 'gfx/Banner_UltraHDBD.png'), - MEDIA_TYPE_ULTRAHD_BLURAY_DVD => array('FormatIcon' => 'gfx/iconultrahd.png', 'Icon' => 'gfx/ultrahd.jpg', 'Banner' => 'gfx/Banner_UltraHDBDDVD.png'), + MEDIA_TYPE_ULTRAHD => array('FormatIcon' => ICON_ULTRAHD, 'Icon' => ICON_ULTRAHD_JPG, 'Banner' => 'gfx/Banner_UltraHD.png'), + MEDIA_TYPE_ULTRAHD_BLURAY => array('FormatIcon' => ICON_ULTRAHD, 'Icon' => ICON_ULTRAHD_JPG, 'Banner' => 'gfx/Banner_UltraHDBD.png'), + MEDIA_TYPE_ULTRAHD_BLURAY_DVD => array('FormatIcon' => ICON_ULTRAHD, 'Icon' => ICON_ULTRAHD_JPG, 'Banner' => 'gfx/Banner_UltraHDBDDVD.png'), ); @@ -123,18 +129,16 @@ $GDFontPathOverride = ''; $IMDBNumFromSlot = false; $IframeHeight = 0; -$ImageUserURL = 'http://dvdaholic.me.uk/ii/index.php'; +$ImageUserURL = 'https://dvdaholic.me.uk/ii/index.php'; $NoBackImageNotFound = false; $MaxX = 20; $CollectionsNotInOwned = array(); $PrivateNotes = false; $ProfileStatistics = false; $ReportOnMemory = false; -//$pscommand = 'ps -p %%pid%% -o%mem= -orss='; $pscommand = ''; $SeparateReviews = true; $SecondarySortFollowPrimary = true; -//$StatisticsOnFrameInit = false; $ShowSQLInPicker = false; $SubmitOldStyle = false; $InitialRightFrame = ''; @@ -180,10 +184,10 @@ $db_fast_update = false; $dbhost = 'localhost'; $dbname = 'phpdvdprofiler'; -$dbpasswd = 'admin'; +$dbpass = ''; $dbport = ''; -$dbtype = 'mysql'; -$dbuser = 'admin'; +$dbtype = 'mysqli'; +$dbuser = ''; $debugon = true; $debugimageuploads = false; $debugskin = false; @@ -237,8 +241,9 @@ $jpgraphlocation = '../jpgraph/'; $language_override = ''; $lettermeaning = 0; -if (($localsiteconfig=@getenv('localsiteconfig')) == '') +if (($localsiteconfig=@getenv('localsiteconfig')) == '') { $localsiteconfig = 'localsiteconfig.php'; +} $local_lan = array(); $locale = 'en'; $localemin ='0.05'; @@ -273,8 +278,8 @@ $thumbwidth = 180; $titledesc = 1; $titleorig = 0; -$update_login = 'admin'; -$update_pass = 'admin'; +$update_login = ''; +$update_pass = ''; $usejpgraph = false; $usetemptable = false; $watched = 'Watched'; diff --git a/sample_multisite.php b/config/sample_multisite.php similarity index 97% rename from sample_multisite.php rename to config/sample_multisite.php index 7d29007..2e1ca11 100644 --- a/sample_multisite.php +++ b/config/sample_multisite.php @@ -2,8 +2,9 @@ if (php_sapi_name() == 'cli') { return; } - if (!isset($_SERVER['REQUEST_URI'])) + if (!isset($_SERVER['REQUEST_URI'])) { return; + } if (substr($_SERVER['REQUEST_URI'], 0, strlen('/phpdvdprofiler.test/')) == '/phpdvdprofiler.test/') { $localsiteconfig = 'test_localsiteconfig.php'; } @@ -54,7 +55,7 @@ // $dbname - each site needs its own database or alternatively, you could set // $table_prefix - to use different tables in a single database // $dbuser - for security, each database should use a different access username/password -// $dbpasswd - although technically, they could all use the same one. these are real MySQL +// $dbpass - although technically, they could all use the same one. these are real MySQL // users, and so may be restricted by your hosting provider. // $images - could be all set to the same directory, although then differences between // cover images will be removed (for people who have dpecial covers). diff --git a/siteconfig.php b/config/siteconfig.php similarity index 98% rename from siteconfig.php rename to config/siteconfig.php index 1025376..656d1a2 100644 --- a/siteconfig.php +++ b/config/siteconfig.php @@ -20,8 +20,8 @@ // This may require the database administrator to GRANT CREATE TEMPORARY TABLES on db.* to dbuser $dbtype = 'mysqli'; $dbhost = 'localhost'; -$dbuser = 'admin'; -$dbpasswd = 'admin'; +$dbuser = ''; // Configure in localsiteconfig.php +$dbpass = ''; // Configure in localsiteconfig.php $dbname = 'phpdvdprofiler'; $dbport = ''; // leave blank if on default port $table_prefix = 'DVDPROFILER_'; @@ -125,7 +125,6 @@ // serves the same purpose in the profiles-by-purchaseplace graph. // genremax controls how many segments are in the genre pie chart. -//$usejpgraph = true; $usejpgraph = false; $jpgraphlocation = '../jpgraph/'; $localemin ='0.05'; @@ -177,17 +176,12 @@ //$localespecialcondition = "AND purchaseplace <> ''"; $localespecialcondition = ''; -//$runtimespecialcondition = "AND boxparent = ''"; // ignore child profiles -//$runtimespecialcondition = "AND boxchild = 0"; // ignore parent profiles $runtimespecialcondition = ''; -//$shortestspecialcondition = "AND runningtime <> 0"; $shortestspecialcondition = ''; -//$productionyearspecialcondition = "AND productionyear <> '0'"; $productionyearspecialcondition = "AND productionyear <> '0'"; -//$currencyspecialcondition = "AND purchaseplace <> ''"; $currencyspecialcondition = ''; // $currencypriority is for controlling the cost-by-month graph. $onlycurrencypriority says don't // show currencies I don't list here. Otherwise, the graphs cycle through all of the available currencies @@ -198,8 +192,8 @@ // Force form based login on Apache servers instead of Basic HTTP authentification when updating $force_formlogin = 1; // Login name and password for maintenance -$update_login = 'admin'; -$update_pass = 'admin'; +$update_login = ''; // Configure in localsiteconfig.php +$update_pass = ''; // Configure in localsiteconfig.php // Variables for gallery.php integration // $rows is the maximum number of rows of images per page; default = 20 @@ -509,9 +503,7 @@ // in which the reviews are to be displayed/sorted. The full DVDProfiler graph would correspond to // $reviewgraph='FVAE'. DVDProfiler has two additional settings: Default, which is equivalent // to $reviewgraph='FV' and one called Simple, which is the same as $reviewgraph='F'. -//$reviewgraph = 'FVAE'; $reviewgraph = 'FV'; -//$reviewsort = 'VFA'; $reviewsort = 'FV'; // $SeparateReviews controls whether reviews are shown as an image representing the score, or // as a graph, the way that DVDProfiler does it in the windows application diff --git a/consistancy.sql b/consistancy.sql deleted file mode 100644 index ce4d879..0000000 --- a/consistancy.sql +++ /dev/null @@ -1,9 +0,0 @@ -#length of UPC fields. Disc ID's are 18 -prompt "length of UPC fields. Disc ID's are 18 "; -select length(upc), count(*) from DVDPROFILER_dvd group by length(upc); -select formataspectratio, count(*) from DVDPROFILER_dvd group by formataspectratio; -select title,formatletterbox,format16x9 from DVDPROFILER_dvd where formatletterbox = 0 and format16x9 = 1; -select title,formataspectratio from DVDPROFILER_dvd where formatletterbox = 0 and formataspectratio != '1.33' and formataspectratio != ''; -prompt "look for credited as "; -select substr(title,1,40),fullname,role from DVDPROFILER_dvd x,DVDPROFILER_dvd_actor a, DVDPROFILER_dvd_common_actor ca where x.id=a.id and ca.caid=a.caid and role like '%(as %' order by sorttitle; -prompt "mysql> "; diff --git a/functions.php b/core/functions.php similarity index 79% rename from functions.php rename to core/functions.php index a63782a..869ffb6 100644 --- a/functions.php +++ b/core/functions.php @@ -3,56 +3,66 @@ error_reporting(E_ALL); require_once 'php-8.1-strftime.php'; use function PHP81_BC\strftime; -include_once('version.php'); +include_once 'version.php'; if (!defined('IN_SCRIPT')) { die('This script should not be manually executed ... Possible Hacking attempt'); } +define('GFX_UNKNOWN', 'gfx/unknown.jpg'); + function strftimeReplacement(string $format, ?int $timestamp = null) { - global $lang; - return mb_convert_encoding(strftime($format, $timestamp, $lang['__strftime_locale']), 'WINDOWS-1252', 'UTF-8'); + global $lang, $ajax; + $result = strftime($format, $timestamp, $lang['__strftime_locale']); + if ($ajax) { + return $result; // already UTF-8, page is UTF-8 + } + // Convert non-ASCII UTF-8 characters to HTML numeric entities + // (works with any page charset, including windows-1252 and Czech chars) + return preg_replace_callback('/[\x{0080}-\x{FFFF}]/u', function($m) { + return '&#' . mb_ord($m[0], 'UTF-8') . ';'; + }, $result); } -function UpdateUpdateLast($str='0||0|0|0|0|0') { - @list( - $x['Offset'], - $x['Filename'], - $x['Total'], - $x['Added'], - $x['Changed'], - $x['NewCollNum'], - $x['ConnectionId'] - ) = explode('|', $str); +function updateUpdateLast($str='0||0|0|0|0|0') { + $parts = explode('|', $str); + $x['Offset'] = $parts[0] ?? '0'; + $x['Filename'] = $parts[1] ?? ''; + $x['Total'] = $parts[2] ?? '0'; + $x['Added'] = $parts[3] ?? '0'; + $x['Changed'] = $parts[4] ?? '0'; + $x['NewCollNum'] = $parts[5] ?? '0'; + $x['ConnectionId'] = $parts[6] ?? '-1'; if (isset($x['Filename']) && $x['Filename'] != '') { - @list( - $x['Filename'], - $x['Filesize'] - ) = explode('!', $x['Filename']); + $fparts = explode('!', $x['Filename']); + $x['Filename'] = $fparts[0] ?? ''; + $x['Filesize'] = $fparts[1] ?? ''; } - if (!isset($x['ConnectionId'])) + if (!isset($x['ConnectionId'])) { $x['ConnectionId'] = '-1'; - return($x); + } + return $x; } -function MySQLVersion() { -global $db, $dbtype, $MyMySQLVersion; +function mySqlVersion() { +global $db, $dbtype, $myMySqlVersion; - if (!isset($MyMySQLVersion)) { - if ($dbtype != 'mysql' && $dbtype != 'mysqli') - return(false); // This fails if it isn't mysql + if (!isset($myMySqlVersion)) { + if ($dbtype != 'mysql' && $dbtype != 'mysqli') { + return false; + } $sql = "SELECT VERSION() AS ver"; $result = $db->sql_query($sql) or die($db->sql_error()); $answer = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $MyMySQLVersion = $answer['ver']; + $myMySqlVersion = $answer['ver']; unset($answer); } - return($MyMySQLVersion); + return $myMySqlVersion; } -function DebugLog($str) { +function debugLog($str) { global $DebugFilename; if (($handle=@fopen($DebugFilename, 'a')) !== false) { @@ -61,17 +71,18 @@ function DebugLog($str) { } } -function SendNoCacheHeaders($endheader='') { +function sendNoCacheHeaders($endheader='') { header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); - if ($endheader != '') + if ($endheader != '') { header($endheader); + } } -function DiscourageAbuse($RefuseBots) { +function discourageAbuse($refuseBots) { // This routine rely on the (current) fact that the img= parameter should only be called from // within phpdvdprofiler, and indeed, only from index.php // it is explicitly checking that the referring URL was from phpdvdprofiler @@ -80,32 +91,35 @@ function DiscourageAbuse($RefuseBots) { // anonymously grab web content ... global $PHP_SELF; - if (!$RefuseBots) + if (!$refuseBots) { return; + } $str = '~://[^/]*'.$PHP_SELF.'~i'; $referer = ''; - if (isset($_SERVER['HTTP_REFERER'])) + if (isset($_SERVER['HTTP_REFERER'])) { $referer = @$_SERVER['HTTP_REFERER']; - if (($num=preg_match($str, $referer)) != 1) { -// DebugLog("$_SERVER[REMOTE_ADDR]: $_SERVER[REQUEST_URI] FROM >$referer<"); + } + if (preg_match($str, $referer) != 1) { +// debugLog("$_SERVER[REMOTE_ADDR]: $_SERVER[REQUEST_URI] FROM >$referer<"); //maybe send a "get knotted" image back to the bot/scammer exit; } } -function Hex($int) { - return(sprintf("%08x", $int)); +function hex($int) { + return sprintf("%08x", $int); } -function CustomTranslation($ind, $str) { +function customTranslation($ind, $str) { global $lang; - if (isset($lang[$ind])) + if (isset($lang[$ind])) { $str = $lang[$ind]; - return($str); + } + return $str; } -function CountryToLang($country, &$langname, &$localenum) { +function countryToLang($country, &$langname, &$localenum) { global $lang, $CountryToLocality; $langname = $country; @@ -114,76 +128,85 @@ function CountryToLang($country, &$langname, &$localenum) { $localenum = $CountryToLocality[$country]; $langname = $lang['LOCALE'.$localenum]; } - return; } -function GenreTranslation($gen) { +function genreTranslation($gen) { global $genre_translation; - if (isset($genre_translation[$gen])) + if (isset($genre_translation[$gen])) { $gen = $genre_translation[$gen]; - return($gen); + } + return $gen; } -function HideName($str) { +function hideName($str) { global $HideNames, $IsPrivate; - if (!$HideNames || $IsPrivate) - return($str); - return(substr($str, 0, 1).'.'); + if (!$HideNames || $IsPrivate) { + return $str; + } + return substr($str, 0, 1).'.'; } -function PhyspathToWebpath($string) { +function physpathToWebpath($string) { global $img_physpath, $img_webpath; - return(str_replace($img_physpath, $img_webpath, $string)); + return str_replace($img_physpath, $img_webpath, $string); } -function WebpathToPhyspath($string) { +function webpathToPhyspath($string) { global $img_physpath, $img_webpath; - return(str_replace($img_webpath, $img_physpath, $string)); + return str_replace($img_webpath, $img_physpath, $string); } -function FormatIcon(&$dvd) { +function formatIcon(&$dvd) { global $AddFormatIcons, $MediaTypes; $formaticon = ''; if ($AddFormatIcons != 2) { - if ($dvd['custommediatype'] != '' && @$MediaTypes[$dvd['custommediatype']]['FormatIcon'] != '') + if ($dvd['custommediatype'] != '' && @$MediaTypes[$dvd['custommediatype']]['FormatIcon'] != '') { $formaticon .= ''; + } switch ($dvd['builtinmediatype']) { case MEDIA_TYPE_DVD: - if ($AddFormatIcons == 0 || $formaticon != '') // force the DVD icon if there is already a custom icon - if ($MediaTypes[MEDIA_TYPE_DVD]['FormatIcon'] != '') - $formaticon .= ''; + if (($AddFormatIcons == 0 || $formaticon != '') && $MediaTypes[MEDIA_TYPE_DVD]['FormatIcon'] != '') { + $formaticon .= ''; + } break; case MEDIA_TYPE_HDDVD: case MEDIA_TYPE_BLURAY: case MEDIA_TYPE_ULTRAHD: - if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') + if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') { $formaticon .= ''; + } break; case MEDIA_TYPE_HDDVD_DVD: case MEDIA_TYPE_BLURAY_DVD: - if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') + if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') { $formaticon .= ''; - if ($MediaTypes[MEDIA_TYPE_DVD]['FormatIcon'] != '') + } + if ($MediaTypes[MEDIA_TYPE_DVD]['FormatIcon'] != '') { $formaticon .= ''; + } break; // Just display the 4k and BR icons for now to avoid clutter. case MEDIA_TYPE_ULTRAHD_BLURAY: case MEDIA_TYPE_ULTRAHD_BLURAY_DVD: - if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') + if ($MediaTypes[$dvd['builtinmediatype']]['FormatIcon'] != '') { $formaticon .= ''; - if ($MediaTypes[MEDIA_TYPE_BLURAY]['FormatIcon'] != '') + } + if ($MediaTypes[MEDIA_TYPE_BLURAY]['FormatIcon'] != '') { $formaticon .= ''; + } + break; + default: break; - break; } - if ($formaticon != '') + if ($formaticon != '') { $formaticon .= ' '; + } } - return($formaticon); + return $formaticon; } -function FormatTheTitle(&$dvd) { +function formatTheTitle(&$dvd) { global $titleorig, $titledesc; if ($dvd['originaltitle'] != '') { @@ -198,6 +221,8 @@ function FormatTheTitle(&$dvd) { case 2: $dvd['title'] .= " ($dvd[originaltitle])"; break; + default: + break; } } if ($dvd['description'] != '') { @@ -211,17 +236,21 @@ function FormatTheTitle(&$dvd) { case 3: $dvd['title'] .= " - $dvd[description]"; break; + default: + break; } } } -function CheckOutOfDateSchema(&$action) { +function checkOutOfDateSchema(&$action) { global $lang, $WeCannotContinue, $db_Errors, $inbrowser, $DontNeedDatabase, $dbname, $dbhost, $dbuser, $db_schema_version, $code_schema_version; - if (!$WeCannotContinue) + if (!$WeCannotContinue) { return; - if (in_array($action, $DontNeedDatabase)) + } + if (in_array($action, $DontNeedDatabase)) { return; + } if ($db_Errors['code'] != 0) { switch ($db_Errors['code']) { case 1044: @@ -255,27 +284,40 @@ function CheckOutOfDateSchema(&$action) { echo html_entity_decode($output_string); } $action = 'update'; - if ($db_Errors['code'] != 0) + if ($db_Errors['code'] != 0) { exit; - return; + } } -function ModifyTables($onoff) { +function modifyTables($onoff) { global $TryToFiddleIndices, $db; - if (!$TryToFiddleIndices) + if (!$TryToFiddleIndices) { return; + } $result = $db->sql_query("SHOW TABLES") or die($db->sql_error()); while ($table = $db->sql_fetchrow($result)) { $db->sql_query("ALTER TABLE ".array_shift($table)." $onoff KEYS") or die($db->sql_error()); } $db->sql_freeresult($result); - return; } -function resize_jpg(&$idstring, $side, $RequestedWidth, $qual, $RequestedHeight=0, $bgcolor='', $center=true) { +function resizeJpg(&$idstring, $side, $requestedWidth, $qual, $requestedHeight=0, $bgcolor='', $center=true) { global $img_physpath, $imagecachedir, $thumbnails, $AddHDLogos, $DVD_TABLE, $db, $MediaTypes; global $DontBreakOnBadPNGGDRoutines; + if (!extension_loaded('gd')) { + // GD not available, return original image or unknown + $id = is_array($idstring) ? $idstring['id'] : $idstring; + $filename = "$thumbnails/$id$side.jpg"; + if (file_exists($img_physpath.$filename)) { + return $img_physpath.$filename; + } + $filename = "$id$side.jpg"; + if (file_exists($img_physpath.$filename)) { + return $img_physpath.$filename; + } + return GFX_UNKNOWN; + } // we wish to put high-def banners at the top, if necessary. // allow plain string id (causing possible SQL lookup) or array with pre-looked-up banner data // possible array is passed by reference, so don't muck with the variable (hence the $idstring) @@ -285,19 +327,20 @@ function resize_jpg(&$idstring, $side, $RequestedWidth, $qual, $RequestedHeight= $dvd = $idstring; $id = $dvd['id']; } - if ($bgcolor != '' && $bgcolor[0] == '#') + if ($bgcolor != '' && $bgcolor[0] == '#') { $bgcolor = substr($bgcolor, 1); - $RequestedHeight = round($RequestedHeight); + } + $requestedHeight = round($requestedHeight); $filename = "$thumbnails/$id$side.jpg"; if (!isset($imagecachedir) || !is_dir($imagecachedir) || !is_writeable($imagecachedir)) { if (!file_exists($img_physpath.$filename)) { $filename = "$id$side.jpg"; if (!file_exists($img_physpath.$filename)) { - return('gfx/unknown.jpg'); + return GFX_UNKNOWN; } } - return($img_physpath.$filename); + return $img_physpath.$filename; } # Now work out what file to use. Try thumb, then full, then unknown. @@ -306,7 +349,7 @@ function resize_jpg(&$idstring, $side, $RequestedWidth, $qual, $RequestedHeight= # Ok, check the main image $filename = "$id$side.jpg"; if (!is_readable($img_physpath.$filename)) { - return('gfx/unknown.jpg'); + return GFX_UNKNOWN; } $usethumb = false; } @@ -316,17 +359,18 @@ function resize_jpg(&$idstring, $side, $RequestedWidth, $qual, $RequestedHeight= list($OriginalImageWidth, $OriginalImageHeight) = getimagesize($img_physpath.$filename); if ($usethumb) { $fullfilename = "$id$side.jpg"; - if ($RequestedWidth > $OriginalImageWidth && is_readable($img_physpath.$fullfilename)) { + if ($requestedWidth > $OriginalImageWidth && is_readable($img_physpath.$fullfilename)) { $filename = $fullfilename; list($OriginalImageWidth, $OriginalImageHeight) = getimagesize($img_physpath.$filename); } } - if ($RequestedWidth == 0) - $RequestedWidth = $OriginalImageWidth; + if ($requestedWidth == 0) { + $requestedWidth = $OriginalImageWidth; + } # Ok now we know the name of the source file we're using. - $newfilename = "$imagecachedir$id$side-$RequestedWidth-$qual-$RequestedHeight-$bgcolor-$center-imagecache.jpg"; + $newfilename = "$imagecachedir$id$side-$requestedWidth-$qual-$requestedHeight-$bgcolor-$center-imagecache.jpg"; if (!is_readable($newfilename) || filemtime($img_physpath.$filename) > filemtime($newfilename)) { # @@ -340,95 +384,96 @@ function resize_jpg(&$idstring, $side, $RequestedWidth, $qual, $RequestedHeight= $db->sql_freeresult($result); } $z = ($side=='f')? $dvd['mediabannerfront']: $dvd['mediabannerback']; - if ($z < 0) - $z = $dvd['custommediatype']; // positive values are the builtins and -1 means the string custommediatype + if ($z < 0) { + $z = $dvd['custommediatype']; + } // positive values are the builtins and -1 means the string custommediatype $hdbanner = @$MediaTypes[$z]['Banner']; // if it doesn't exist, it'll get set with an empty string } if ($hdbanner != '') { list($OriginalBannerWidth, $OriginalBannerHeight) = getimagesize($hdbanner); - $BannerHeightForActualImageWidth = round(($OriginalImageWidth * $OriginalBannerHeight) / $OriginalBannerWidth); - $BannerHeightPercent = $BannerHeightForActualImageWidth / $OriginalImageHeight; - $BannerHeight = round(($RequestedWidth * $OriginalBannerHeight) / $OriginalBannerWidth); + $bannerHeightForActualImageWidth = round(($OriginalImageWidth * $OriginalBannerHeight) / $OriginalBannerWidth); + $bannerHeightPercent = $bannerHeightForActualImageWidth / $OriginalImageHeight; + $bannerHeight = round(($requestedWidth * $OriginalBannerHeight) / $OriginalBannerWidth); } else { - $BannerHeight = 0; - $BannerHeightForActualImageWidth = 0; - $BannerHeightPercent = 0; + $bannerHeight = 0; + $bannerHeightForActualImageWidth = 0; + $bannerHeightPercent = 0; } - $ThumbImageWidth = $ImageWidth = $RequestedWidth; - if ($RequestedHeight == 0) { - $ImageWidth = $RequestedWidth; - $ImageHeight = round(($ImageWidth * $OriginalImageHeight) / $OriginalImageWidth); - $ThumbImageWidth = $RequestedWidth; - $ThumbImageHeight = $ImageHeight + $BannerHeight; + $imageWidth = $requestedWidth; + $thumbImageWidth = $requestedWidth; + if ($requestedHeight == 0) { + $imageHeight = round(($imageWidth * $OriginalImageHeight) / $OriginalImageWidth); + $thumbImageHeight = $imageHeight + $bannerHeight; } else { - $ThumbHtoWRatio = $RequestedHeight / $RequestedWidth; - $ThumbImageWidth = $RequestedWidth; - $ThumbImageHeight = $RequestedHeight; - $WhichIsTooLarge = ($OriginalImageHeight + $BannerHeightForActualImageWidth) / $OriginalImageWidth; - if ($WhichIsTooLarge > $ThumbHtoWRatio) { + $thumbHtoWRatio = $requestedHeight / $requestedWidth; + $thumbImageHeight = $requestedHeight; + $whichIsTooLarge = ($OriginalImageHeight + $bannerHeightForActualImageWidth) / $OriginalImageWidth; + if ($whichIsTooLarge > $thumbHtoWRatio) { // height must be scaled - $ImageHeight = round($ThumbImageHeight / (1 + $BannerHeightPercent)); - $ImageWidth = round(($ImageHeight * $OriginalImageWidth) / $OriginalImageHeight); - $BannerHeight = $ThumbImageHeight - $ImageHeight; // handle rounding/truncation artifacts + $imageHeight = round($thumbImageHeight / (1 + $bannerHeightPercent)); + $imageWidth = round(($imageHeight * $OriginalImageWidth) / $OriginalImageHeight); + $bannerHeight = $thumbImageHeight - $imageHeight; // handle rounding/truncation artifacts } else { // width must be scaled same as just correct ratio - $ImageWidth = $RequestedWidth; - $ImageHeight = round(($ImageWidth * $OriginalImageHeight) / $OriginalImageWidth); + $imageWidth = $requestedWidth; + $imageHeight = round(($imageWidth * $OriginalImageHeight) / $OriginalImageWidth); } } - $im2 = ImageCreateTrueColor($ThumbImageWidth, $ThumbImageHeight); + $im2 = ImageCreateTrueColor($thumbImageWidth, $thumbImageHeight); // figure out the offsets within the thumbnail of the images $offx = $offy = 0; - if ($ImageWidth != $ThumbImageWidth || ($ImageHeight + $BannerHeight) != $ThumbImageHeight) { + if ($imageWidth != $thumbImageWidth || ($imageHeight + $bannerHeight) != $thumbImageHeight) { if ($bgcolor != '') { $col = ImageColorAllocate($im2, hexdec('0x'.$bgcolor[0].$bgcolor[1]), hexdec('0x'.$bgcolor[2].$bgcolor[3]), hexdec('0x'.$bgcolor[4].$bgcolor[5])); ImageFill($im2, 0, 0, $col); } if ($center) { - $offx = round(($ThumbImageWidth - $ImageWidth) / 2); - $offy = round(($ThumbImageHeight - $ImageHeight - $BannerHeight) / 2); + $offx = round(($thumbImageWidth - $imageWidth) / 2); + $offy = round(($thumbImageHeight - $imageHeight - $bannerHeight) / 2); } } # Copy banner into place if ($hdbanner != '') { if ($DontBreakOnBadPNGGDRoutines) { -////////////////DebugLog("PNG:$me_updating: $dvd[title] -- $newfilename:$z"); +////////////////debugLog("PNG:$me_updating: $dvd[title] -- $newfilename:$z"); // if (is_readable($newfilename)) { -// DebugLog("$img_physpath$filename=".date("F d Y H:i:s.", filemtime($img_physpath.$filename))); -// DebugLog("$newfilename=".date("F d Y H:i:s.", filemtime($newfilename))); +// debugLog("$img_physpath$filename=".date("F d Y H:i:s.", filemtime($img_physpath.$filename))); +// debugLog("$newfilename=".date("F d Y H:i:s.", filemtime($newfilename))); // } - return('gfx/unknown.jpg'); + return GFX_UNKNOWN; } $banner = ImageCreateFromPNG($hdbanner); - ImageCopyResampled ($im2, $banner, $offx, $offy, 0, 0, $ImageWidth, $BannerHeight, $OriginalBannerWidth, $OriginalBannerHeight); + ImageCopyResampled ($im2, $banner, $offx, $offy, 0, 0, $imageWidth, $bannerHeight, $OriginalBannerWidth, $OriginalBannerHeight); ImageDestroy($banner); - $offy += $BannerHeight; + $offy += $bannerHeight; } # Copy thumbnail into place $image = ImageCreateFromJpeg($img_physpath.$filename); - if ($OriginalImageWidth == $ImageWidth) + if ($OriginalImageWidth == $imageWidth) { ImageCopy($im2, $image, $offx, $offy, 0, 0, $OriginalImageWidth, $OriginalImageHeight); - else - ImageCopyResampled ($im2, $image, $offx, $offy, 0, 0, $ImageWidth, $ImageHeight, $OriginalImageWidth, $OriginalImageHeight); + } else { + ImageCopyResampled ($im2, $image, $offx, $offy, 0, 0, $imageWidth, $imageHeight, $OriginalImageWidth, $OriginalImageHeight); + } ImageDestroy($image); - if (file_exists($newfilename)) - unlink($newfilename); // get rid of any old file + if (file_exists($newfilename)) { + unlink($newfilename); + } // get rid of any old file ImageJPEG($im2, $newfilename, $qual); ImageDestroy($im2); touch($newfilename); } - return($newfilename); + return $newfilename; } if (!function_exists('stripos')) { function stripos($haystack,$needle,$offset = 0) { - return(strpos(strtolower($haystack),strtolower($needle),$offset)); + return strpos(strtolower($haystack),strtolower($needle),$offset); } } @@ -458,6 +503,8 @@ function ReplaceSlashes($text, $searchfor='src') { // Converts Windows-1252 characters as decimal entities into their HTML equivalents function fix1252($s) { +global $ajax; +if ($ajax) return $s; // data is already UTF-8, no byte-level conversion needed $replacement = array( "\x80" => '€', "\x81" => ' ', "\x82" => '‚', "\x83" => 'ƒ', "\x84" => '„', "\x85" => '…', "\x86" => '†', "\x87" => '‡', @@ -531,7 +578,13 @@ function fix88595($s) { } function my_mktime() { - @list($hours, $minutes, $seconds, $mon, $mday, $year) = func_get_args(); + $args = func_get_args(); + $hours = $args[0] ?? null; + $minutes = $args[1] ?? null; + $seconds = $args[2] ?? null; + $mon = $args[3] ?? null; + $mday = $args[4] ?? null; + $year = $args[5] ?? null; $temp = @getdate(); if (!is_numeric($hours)) { $hours = $temp['hours']; } if (!is_numeric($minutes)) { $minutes = $temp['minutes']; } @@ -554,7 +607,11 @@ function DecToIPv4($number) { } function IPv4ToDec($addr) { - @list($a, $b, $c, $d) = explode('.', $addr); + $parts = explode('.', $addr); + $a = $parts[0] ?? 0; + $b = $parts[1] ?? 0; + $c = $parts[2] ?? 0; + $d = $parts[3] ?? 0; return(((((($a<<8) + $b)<<8) + $c)<<8) + $d); } @@ -635,7 +692,7 @@ function TableCopyingSupported() { if ($dbtype != 'mysql' && $dbtype != 'mysqli') return(true); // This assumes that databases other than mysql will like the syntax - $ver = MySQLVersion(); + $ver = mySqlVersion(); list($major, $minor, $patch) = explode('.', $ver); $patch = (int)$patch; if ($major>4 || ($major==4 && ($minor>0 || ($minor==0 && $patch>=14)))) @@ -724,7 +781,7 @@ function AcquireAThumbnail($filename) { global $getimages, $img_physpath, $createthumbs, $thumbnails; if (!file_exists($img_physpath.$thumbnails.'/'.$filename) && $getimages == 2) { // if $getimages == 2, try to grab an image from the Invelos server - if ($thumb=@file_get_contents('http://www.invelos.com/mpimages/'.$filename[0].$filename[1].'/'.$filename)) { + if ($thumb=@file_get_contents('https://www.invelos.com/mpimages/'.$filename[0].$filename[1].'/'.$filename)) { if ($handle = fopen($img_physpath.$thumbnails.'/'.$filename, 'wb')) { fwrite($handle, $thumb); fclose($handle); @@ -749,6 +806,7 @@ function AcquireAThumbnail($filename) { function real_find_a_file($id, $isfront, $checkthumb=true) { global $img_physpath, $thumbnails; + $id = rtrim($id, "\x00"); $name = $id . (($isfront)? 'f': 'b') . '.jpg'; $dir = $img_physpath; if ($checkthumb) @@ -760,10 +818,10 @@ function real_find_a_file($id, $isfront, $checkthumb=true) { if (!file_exists($dir.$name) && $checkthumb) { AcquireAThumbnail($name); } - if (is_readable($dir.$name)) - return($name); -//DebugLog('$dir='.$dir.', $name='.$name); - return(''); + if (is_readable($dir.$name)) { + return $name; + } + return ''; } function find_a_file($id, $isfront, $checkthumb=true) { @@ -809,7 +867,7 @@ function DebugSQL($db, $string) { return; $num_queries = $db->sql_num_queries(); $thequeries = $db->sql_ret_queries(); - DebugLog("$string: $num_queries$thequeries\n"); + debugLog("$string: $num_queries$thequeries\n"); } function GetLastUpdateTime($which) { @@ -977,7 +1035,7 @@ function GimmeAThumb($id, $side='f', $addbanner='') { $banner = @$MediaTypes[$addbanner]['Banner']; // if the type doesn't exist, $banner will be set to empty string if ($banner != '' && is_readable($banner)) { if ($DontBreakOnBadPNGGDRoutines) { -////////////////DebugLog("PNG2:GimmeAThumb -- $filename"); +////////////////debugLog("PNG2:GimmeAThumb -- $filename"); $filename = 'gfx/unknown.jpg'; } else { @@ -995,14 +1053,14 @@ function GimmeAThumb($id, $side='f', $addbanner='') { ImageCopy($newbitmap, $imim, 0, $newbannerheight, 0, 0, $imagewidth, $imageheight); ImageDestroy($imim); - SendNoCacheHeaders('Content-Type: image/jpeg'); + sendNoCacheHeaders('Content-Type: image/jpeg'); ImageJPEG($newbitmap, '', 100); // manual says to use NULL, but only '' seems to work ImageDestroy($newbitmap); return; } } } - SendNoCacheHeaders('Content-Type: image/jpeg'); + sendNoCacheHeaders('Content-Type: image/jpeg'); readfile($filename); return; } @@ -1072,3 +1130,69 @@ function GetRatingLogo($locale, $ratingsystem, $rating) { } return NULL; } + +function tmdbLookupImdbId($title, $year = '', $originalTitle = '') { + global $tmdb_api_key; + $apiKey = (isset($tmdb_api_key) && $tmdb_api_key !== '') ? $tmdb_api_key : '134b15beef358903890a761f41dd98d8'; + $ctx = stream_context_create(['http' => ['timeout' => 5]]); + + $url = "https://api.themoviedb.org/3/search/movie?api_key=$apiKey" + . "&query=" . urlencode($title) + . "&include_adult=false"; + if ($year && $year != '0') $url .= "&year=$year"; + + $response = @file_get_contents($url, false, $ctx); + if ($response === false) return null; + + $data = @json_decode($response, true); + $tmdbId = null; + + if (!empty($data['results'])) { + $tmdbId = $data['results'][0]['id']; + } + + if ($tmdbId === null && $originalTitle !== '' && $originalTitle !== $title) { + $url2 = "https://api.themoviedb.org/3/search/movie?api_key=$apiKey" + . "&query=" . urlencode($originalTitle) + . "&include_adult=false"; + if ($year && $year != '0') $url2 .= "&year=$year"; + + $response2 = @file_get_contents($url2, false, $ctx); + if ($response2 !== false) { + $data2 = @json_decode($response2, true); + if (!empty($data2['results'])) { + $tmdbId = $data2['results'][0]['id']; + } + } + } + + if ($tmdbId === null) return ''; + + $detailUrl = "https://api.themoviedb.org/3/movie/$tmdbId?api_key=$apiKey"; + $detailResponse = @file_get_contents($detailUrl, false, $ctx); + if ($detailResponse === false) return null; + + $detail = @json_decode($detailResponse, true); + if (!empty($detail['imdb_id'])) { + return $detail['imdb_id']; + } + + return ''; +} + +function stripQuotes($str) { + return str_replace(['"', "'"], '', $str); +} + +function replace2Lang($matches) { +global $lang; + $matches[1] = stripQuotes($matches[1]); + $matches[2] = stripQuotes($matches[2]); + return $lang[$matches[1]][$matches[2]]; +} + +function replaceLang($matches) { +global $lang; + $matches[1] = stripQuotes($matches[1]); + return $lang[$matches[1]]; +} diff --git a/global.php b/core/global.php similarity index 95% rename from global.php rename to core/global.php index d83114f..22adf2a 100644 --- a/global.php +++ b/core/global.php @@ -1,11 +1,12 @@ 'asc', @@ -226,7 +238,12 @@ $tmp = rawurldecode($_COOKIE['skinfile']); if ($tmp != 'internal') { list($skinloc, $skinfile) = explode('/', $tmp); - $skinloc = "skins/$skinloc"; + if (strpos($skinloc, '..') !== false || strpos($skinfile, '..') !== false) { + $skinfile = 'internal'; + $skinloc = ''; + } else { + $skinloc = "skins/$skinloc"; + } } else { $skinfile = 'internal'; @@ -686,7 +703,7 @@ $DeleteTemporaryFile = false; // Flag to see if we need to delete a file created from a zip ... if (!isset($PHP_SELF)) { if (isset($_SERVER['PHP_SELF'])) - $PHP_SELF = $_SERVER['PHP_SELF']; + $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'); else $PHP_SELF = 'index.php'; } @@ -696,7 +713,7 @@ $db_schema_version = 'Unknown'; -$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, $debugSQL, true); +$db = new sql_db($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, $debugSQL, true); $db_Errors = $db->GetErrorState(); $collectiontypelist = array(); @@ -725,13 +742,13 @@ $masterauxcolltype = explode('/', substr($item['value'], 1)); break; case 'CurrentPosition': - $UpdateLast = UpdateUpdateLast($item['value']); + $UpdateLast = updateUpdateLast($item['value']); break; } } $db->sql_freeresult($result); if (!isset($UpdateLast)) { - $UpdateLast = UpdateUpdateLast(); + $UpdateLast = updateUpdateLast(); $result = $db->sql_query("SELECT CONNECTION_ID() AS Id") or die($db->sql_error()); $item = $db->sql_fetchrow($result); $db->sql_query("INSERT IGNORE INTO $DVD_PROPERTIES_TABLE (property,value) VALUES ('CurrentPosition','0||0|0|0|0|".$db->sql_escape($item['Id'])."')") or die($db->sql_error()); diff --git a/locale.php b/core/locale.php similarity index 71% rename from locale.php rename to core/locale.php index 2e8141b..8f7d114 100644 --- a/locale.php +++ b/core/locale.php @@ -23,92 +23,100 @@ ($tmp == 'nl') || ($tmp == 'sv') || ($tmp == 'fi') || - ($tmp == 'ru')) { + ($tmp == 'ru') || + ($tmp == 'cs')) { $locale = $tmp; } } -$localeset = 'C'; -$ISO88595 = false; -switch ($locale) { -case 'de': - $localeset = array( +// Locale mapping: maps locale codes to their locale variant arrays +$localeMap = array( + 'de' => array( 'de_DE', 'de_DE.ISO8859-1', 'de_DE.iso88591', 'german', 'deu_DE', 'ger_DE', - ); - break; -//case 'dk': // There doesn't seem to be a locale defined for Danish -case 'en': - $localeset = array( + ), + 'en' => array( 'en_US', 'en_US.ISO8859-1', 'en_US.iso88591', 'english', 'eng_US', - ); - break; -case 'fi': - $localeset = array( + ), + 'fi' => array( 'fi_FI', 'fi_FI.ISO8859-1', 'fi_FI.iso88591', 'finnish', 'fin_FI', - ); - break; -case 'fr': - $localeset = array( + ), + 'fr' => array( 'fr_FR', 'fr_FR.ISO8859-1', 'fr_FR.iso88591', 'french', 'fra_FR', - ); - break; -case 'no': - $localeset = array( + ), + 'no' => array( 'no_NO', 'no_NO.ISO8859-1', 'no_NO.iso88591', 'norwegian', 'nor_NO', - ); - break; -case 'nl': - $localeset = array( + ), + 'nl' => array( 'nl_NL', 'nl_NL.ISO8859-1', 'nl_NL.iso88591', 'dutch', 'nla_NL', 'dut_NL', - ); - break; -case 'ru': - $ISO88595 = true; - $localeset = array( + ), + 'ru' => array( 'ru_RU', 'ru_RU.ISO8859-5', 'ru_RU.iso88595', 'Russian_Russia.28595', 'russian', 'rus_RU', - ); - break; -case 'sv': - $localeset = array( + ), + 'sv' => array( 'sv_SE', 'sv_SE.ISO8859-1', 'sv_SE.iso88591', 'swedish', 'sve_SE', 'swe_SE', - ); - break; + ), + 'cs' => array( + 'cs_CZ', + 'cs_CZ.UTF-8', + 'cs_CZ.ISO8859-2', + 'cs_CZ.iso88592', + 'czech', + 'ces_CZ', + 'cze_CZ', + ), + // Note: 'dk' (Danish) doesn't have a locale defined +); + +// Default locale fallback +$localeset = 'C'; +$ISO88595 = false; + +// Lookup locale settings +if (isset($localeMap[$locale])) { + $localeset = $localeMap[$locale]; + // Special handling for Russian locale + if ($locale === 'ru') { + $ISO88595 = true; + } +} else { + // Fall back to English if locale not found + $localeset = isset($localeMap['en']) ? $localeMap['en'] : 'C'; } // This requires that the system have the appropriate locale installed // PHP pre-4.3.0 will throw a warning with the muliple strings in the array, hence the @ @@ -120,16 +128,16 @@ $language_override = substr($language_override, 0, $x); } } - if (is_readable($language_override . "_$locale")) { + if (is_readable(BASE_PATH . $language_override . "_$locale")) { include_once($language_override . "_$locale"); } - else if (is_readable($language_override . "_$locale.php")) { + else if (is_readable(BASE_PATH . $language_override . "_$locale.php")) { include_once($language_override . "_$locale.php"); } - else if (is_readable($language_override)) { + else if (is_readable(BASE_PATH . $language_override)) { include_once($language_override); } - else if (is_readable($language_override . ".php")) { + else if (is_readable(BASE_PATH . $language_override . ".php")) { include_once($language_override . ".php"); } } diff --git a/monetary.php b/core/monetary.php similarity index 100% rename from monetary.php rename to core/monetary.php diff --git a/php-8.1-strftime.php b/core/php-8.1-strftime.php similarity index 100% rename from php-8.1-strftime.php rename to core/php-8.1-strftime.php diff --git a/version.php b/core/version.php similarity index 100% rename from version.php rename to core/version.php diff --git a/mysqli.php b/db/mysqli.php similarity index 82% rename from mysqli.php rename to db/mysqli.php index 7c13654..5db64d9 100644 --- a/mysqli.php +++ b/db/mysqli.php @@ -14,12 +14,13 @@ #[AllowDynamicProperties] class sql_db { - var $db_connect_id; - var $query_result; - var $return_on_error = false; - var $transaction = false; - var $sql_report = ''; - var $sql_time = 0; + public $db_connect_id; + public $query_result; + public $return_on_error = false; + public $transaction = false; + public $sql_report = ''; + public $sql_time = 0; + public $convertToUtf8 = false; // // Constructor @@ -54,7 +55,7 @@ function __construct($sqlserver, $sqluser, $sqlpassword, $database, $port = fals if ($this->db_connect_id && $this->dbname != '') { - $this->db_connect_id->set_charset("latin1"); + $this->db_connect_id->set_charset("utf8"); if (@mysqli_select_db($this->db_connect_id, $this->dbname)) { return $this->db_connect_id; @@ -155,7 +156,7 @@ function sql_query($query = '', $expire_time = 0, $quiet = false) if ($this->DebugSQL) $this->sql_list .= "\n\t$query"; - if (!empty($_GET['explain'])) + if (!empty($_GET['explain']) && !empty($GLOBALS['IsPrivate'])) { global $starttime; @@ -171,7 +172,7 @@ function sql_query($query = '', $expire_time = 0, $quiet = false) } } - if (!empty($_GET['explain'])) + if (!empty($_GET['explain']) && !empty($GLOBALS['IsPrivate'])) { $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1] - $starttime; @@ -180,12 +181,12 @@ function sql_query($query = '', $expire_time = 0, $quiet = false) if ($this->query_result) { - $this->sql_report .= "Time before: $curtime\nTime after: $endtime\nElapsed time: " . ($endtime - $curtime) . "\n
"; + $this->sql_report .= "Time before: " . htmlspecialchars($curtime, ENT_COMPAT, 'ISO-8859-1') . "\nTime after: " . htmlspecialchars($endtime, ENT_COMPAT, 'ISO-8859-1') . "\nElapsed time: " . htmlspecialchars($endtime - $curtime, ENT_COMPAT, 'ISO-8859-1') . "\n
"; } else { $error = $this->sql_error(); - $this->sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message'], ENT_COMPAT, 'ISO-8859-1') . '

';
+                        $this->sql_report .= 'FAILED - MySQL Error ' . htmlspecialchars($error['code'], ENT_COMPAT, 'ISO-8859-1') . ': ' . htmlspecialchars($error['message'], ENT_COMPAT, 'ISO-8859-1') . '

';
                     }
 
                     $this->sql_time += $endtime - $curtime;
@@ -201,9 +202,9 @@ function sql_query($query = '', $expire_time = 0, $quiet = false)
                                 {
                                     $html_table = TRUE;
                                     $this->sql_report .= "\n";
-                                    $this->sql_report .= "\n\n\n\n";
+                                    $this->sql_report .= "\n\n\n\n";
                                 }
-                                $this->sql_report .= "\n\n\n\n";
+                                $this->sql_report .= "\n\n\n\n";
                             }
                         }
 
@@ -350,7 +351,16 @@ function sql_fetchrow($query_id = 0)
         }
         */
 
-        return ($query_id) ? @mysqli_fetch_assoc($query_id) : false;
+        $row = ($query_id) ? @mysqli_fetch_assoc($query_id) : false;
+        if ($row && $this->convertToUtf8) {
+            foreach ($row as $k => $v) {
+                if (is_string($v)) {
+                    $c = @iconv('CP1250', 'UTF-8//IGNORE', $v);
+                    if ($c !== false) $row[$k] = $c;
+                }
+            }
+        }
+        return $row;
     }
 
     function sql_fetchrowset($query_id = 0)
@@ -422,7 +432,16 @@ function sql_rowseek($rownum, $query_id = 0)
 
     function sql_fetch_array($res)
     {
-        return ($res) ? @mysqli_fetch_array($res) : false;
+        $row = ($res) ? @mysqli_fetch_array($res) : false;
+        if ($row && $this->convertToUtf8) {
+            foreach ($row as $k => $v) {
+                if (is_string($v)) {
+                    $c = @iconv('CP1250', 'UTF-8//IGNORE', $v);
+                    if ($c !== false) $row[$k] = $c;
+                }
+            }
+        }
+        return $row;
     }
 
     function sql_nextid()
@@ -446,7 +465,8 @@ function sql_freeresult($query_id = false)
 
     function sql_escape($msg)
     {
-        return mysqli_real_escape_string($this->db_connect_id, stripslashes($msg));
+        // stripslashes removed - magic_quotes_gpc was removed in PHP 5.4
+        return mysqli_real_escape_string($this->db_connect_id, $msg);
     }
 
     function sql_error($sql = '')
@@ -470,10 +490,16 @@ function sql_error($sql = '')
             if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) $the_query = $_SERVER['QUERY_STRING'];
             if (empty($the_query) && isset($_ENV['QUERY_STRING'])) $the_query = $_ENV['QUERY_STRING'];
 
-            $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
+            $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : ($_ENV['PHP_SELF'] ?? '');
             $this_page .= '&' . $the_query;
 
-            $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysqli_error($this->db_connect_id) . '

CALLING PAGE

' . $this_page . (($sql != '') ? '

SQL

' . $sql : '') . '
'; + // Escape all user-controllable and internal data to prevent XSS + $esc_layer = htmlspecialchars(SQL_LAYER, ENT_QUOTES, 'ISO-8859-1'); + $esc_error = htmlspecialchars(@mysqli_error($this->db_connect_id), ENT_QUOTES, 'ISO-8859-1'); + $esc_page = htmlspecialchars($this_page, ENT_QUOTES, 'ISO-8859-1'); + $esc_sql = ($sql != '') ? '

SQL

' . htmlspecialchars($sql, ENT_QUOTES, 'ISO-8859-1') : ''; + + $message = 'SQL ERROR [ ' . $esc_layer . ' ]

' . $esc_error . '

CALLING PAGE

' . $esc_page . $esc_sql . '
'; trigger_error($message, E_USER_ERROR); } return $result; diff --git a/db/schema.sql b/db/schema.sql new file mode 100644 index 0000000..83645f7 --- /dev/null +++ b/db/schema.sql @@ -0,0 +1,61 @@ +-- -------------------------------------------------------- +-- Hostitel: 127.0.0.1 +-- Verze serveru: 8.0.43 - MySQL Community Server - GPL +-- OS serveru: Win64 +-- HeidiSQL Verze: 12.8.0.6908 +-- -------------------------------------------------------- + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +-- Export dat nebyl vybrán. + +/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */; +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */; diff --git a/Colours.txt b/docs/Colours.txt similarity index 100% rename from Colours.txt rename to docs/Colours.txt diff --git a/docs/TODO b/docs/TODO new file mode 100644 index 0000000..769068d --- /dev/null +++ b/docs/TODO @@ -0,0 +1,12 @@ + - boxset association doesn't occur when searching. This is + because I can't get the records to order properly. + [Known limitation: search results span across boxset parents, + SQL ordering can't guarantee parents before children.] + + FIXED: + - collection=loaned now includes boxchildren via subquery + - TitlesPerPage userpref added (cookie: titlesperpage) + - pagination now shows numbered pages (AJAX sidebar) + - boxset spacing improved (CSS: toggle button, left border for children) + - GD library check added (resize_jpg, fetch_covers, ws.php) + - update offset bug: reset offset on file size change, stricter tag matching diff --git a/gallery-license.txt b/docs/gallery-license.txt similarity index 100% rename from gallery-license.txt rename to docs/gallery-license.txt diff --git a/phpdvdprofiler-install.txt b/docs/phpdvdprofiler-install.txt similarity index 98% rename from phpdvdprofiler-install.txt rename to docs/phpdvdprofiler-install.txt index 8a58140..f282db5 100644 --- a/phpdvdprofiler-install.txt +++ b/docs/phpdvdprofiler-install.txt @@ -71,7 +71,7 @@ unzip -a phpDVDprofiler-v20050102.zip -------------------------------------------------------------------------------- -Edit siteconfig.php and configure $dbuser, $dbpasswd, $update_login, $update_pass. +Edit siteconfig.php and configure $dbuser, $dbpass, $update_login, $update_pass. I set my $dbuser to 'guest'. The $update vars are the login name and password that you need to type in on the web page form when you try to update your collection. Set these to whatever you'd like. diff --git a/phpdvdprofiler-skins.txt b/docs/phpdvdprofiler-skins.txt similarity index 100% rename from phpdvdprofiler-skins.txt rename to docs/phpdvdprofiler-skins.txt diff --git a/phpdvdprofiler_on_windoze.txt b/docs/phpdvdprofiler_on_windoze.txt similarity index 99% rename from phpdvdprofiler_on_windoze.txt rename to docs/phpdvdprofiler_on_windoze.txt index 43973d6..e4b6134 100644 --- a/phpdvdprofiler_on_windoze.txt +++ b/docs/phpdvdprofiler_on_windoze.txt @@ -121,4 +121,4 @@ These instructions don't require creating a new mysql or setting the mysql root password. Well thats bad if your collection is available externally. So, if your collection is going to be viewable externally, please create yourself a new mysql or set the root password. Then update the siteconfig.php with the -new user/password ($dbuser/$dbpasswd). +new user/password ($dbuser/$dbpass). diff --git a/gr_bycurrency.php b/graphs/gr_bycurrency.php similarity index 84% rename from gr_bycurrency.php rename to graphs/gr_bycurrency.php index 0d5ce7f..610410e 100644 --- a/gr_bycurrency.php +++ b/graphs/gr_bycurrency.php @@ -1,19 +1,9 @@ sql_query("SELECT date_format(from_unixtime(purchasedate), '%Y/%m') AS month, " ."COUNT(title) AS count, SUM(paid) AS price " diff --git a/gr_bygenre.php b/graphs/gr_bygenre.php similarity index 73% rename from gr_bygenre.php rename to graphs/gr_bygenre.php index 7b7a896..f88c3be 100644 --- a/gr_bygenre.php +++ b/graphs/gr_bygenre.php @@ -1,18 +1,8 @@ sql_query($sql) or die($db->sql_error()); diff --git a/gr_byorigin.php b/graphs/gr_byorigin.php similarity index 77% rename from gr_byorigin.php rename to graphs/gr_byorigin.php index a30937d..f36a8e4 100644 --- a/gr_byorigin.php +++ b/graphs/gr_byorigin.php @@ -1,31 +1,15 @@ sql_query($sql) or die($db->sql_error()); @@ -36,7 +20,7 @@ function cmp($a, $b) { while ($row = $db->sql_fetch_array($result)) { $origin = ''; if ($row['countryoforigin'] != '') { - CountryToLang($row['countryoforigin'], $origin, $countryloc); + countryToLang($row['countryoforigin'], $origin, $countryloc); if (!isset($origins[$origin])) $origins[$origin] = 0; $origins[$origin] += $row['count']; @@ -44,7 +28,7 @@ function cmp($a, $b) { $maxcount = $origins[$origin]; } if ($row['countryoforigin2'] != '') { - CountryToLang($row['countryoforigin2'], $origin, $countryloc); + countryToLang($row['countryoforigin2'], $origin, $countryloc); if (!isset($origins[$origin])) $origins[$origin] = 0; $origins[$origin] += $row['count']; @@ -52,7 +36,7 @@ function cmp($a, $b) { $maxcount = $origins[$origin]; } if ($row['countryoforigin3'] != '') { - CountryToLang($row['countryoforigin3'], $origin, $countryloc); + countryToLang($row['countryoforigin3'], $origin, $countryloc); if (!isset($origins[$origin])) $origins[$origin] = 0; $origins[$origin] += $row['count']; diff --git a/gr_byplace.php b/graphs/gr_byplace.php similarity index 76% rename from gr_byplace.php rename to graphs/gr_byplace.php index 3c54072..2973552 100644 --- a/gr_byplace.php +++ b/graphs/gr_byplace.php @@ -1,23 +1,7 @@ sql_query("SELECT productionyear,COUNT(title) AS count " ."FROM $DVD_TABLE WHERE collectiontype='owned' " diff --git a/graphs/graph_init.php b/graphs/graph_init.php new file mode 100644 index 0000000..9d53d93 --- /dev/null +++ b/graphs/graph_init.php @@ -0,0 +1,18 @@ + + Require all denied + diff --git a/includes/MakeHTMLFromSkin.php b/includes/MakeHTMLFromSkin.php new file mode 100644 index 0000000..080708a --- /dev/null +++ b/includes/MakeHTMLFromSkin.php @@ -0,0 +1,19 @@ +newskin.html +// +// eg: php MakeHTMLFromSkin.php sv 'phpDVDProfiler Skin.html' >skin.html +// to create the skin with Swedish strings +// +// This code puts the language strings into a skin by replacing the $lang[] elements +// for the purpose of creating an HTML file for import into DVDProfiler + +require_once(__DIR__ . '/../bootstrap.php'); +include_once('lang_'.$_SERVER['argv'][1].'.php'); + + $j = file_get_contents($_SERVER['argv'][2]); + + $j = preg_replace_callback('/\\$lang\\[(.*)\\]\\[(.*)\\]/U', "replace2Lang", $j); + $j = preg_replace_callback('/\\$lang\\[(.*)\\]/U', "replaceLang", $j); + + echo $j; diff --git a/includes/fetch_covers.php b/includes/fetch_covers.php new file mode 100644 index 0000000..a00740d --- /dev/null +++ b/includes/fetch_covers.php @@ -0,0 +1,310 @@ +convertToUtf8 = true; + + if ($_GET['tmdb_action'] === 'search') { + $query = $_GET['query'] ?? ''; + $year = $_GET['year'] ?? ''; + $url = "https://api.themoviedb.org/3/search/movie?api_key=$TMDB_API_KEY" + . "&query=" . urlencode($query) + . "&language=cs-CZ&include_adult=false"; + if ($year !== '' && ctype_digit($year)) $url .= "&year=" . urlencode($year); + $ctx = stream_context_create(['http' => ['timeout' => 10]]); + $response = @file_get_contents($url, false, $ctx); + echo ($response !== false) ? $response : json_encode(['error' => 'TMDB API request failed']); + exit; + } + + if ($_GET['tmdb_action'] === 'download') { + $mediaid = $_GET['mediaid'] ?? ''; + $poster_path = $_GET['poster_path'] ?? ''; + $size = $_GET['size'] ?? 'original'; + if (!$mediaid || !$poster_path) { echo json_encode(['error' => 'Missing parameters']); exit; } + + // Validate $size against allowed TMDB image sizes + $allowedSizes = ['w92','w154','w185','w342','w500','w780','original']; + if (!in_array($size, $allowedSizes, true)) { echo json_encode(['error' => 'Invalid size']); exit; } + + // Validate $poster_path: must be /alphanumeric+dots+hyphens (e.g. /abc123.jpg) + if (!preg_match('#^/[a-zA-Z0-9._-]+$#', $poster_path)) { echo json_encode(['error' => 'Invalid poster path']); exit; } + + // Look up the media ID in the database to avoid constructing paths from user input + $row = $db->sql_fetchrow($db->sql_query( + "SELECT id FROM {$table_prefix}dvd WHERE id='" . $db->sql_escape($mediaid) . "' LIMIT 1" + )); + if (!$row) { echo json_encode(['error' => 'Invalid media ID']); exit; } + $cleanId = rtrim($row['id'], "\x00"); + + $filename = $img_physpath . $cleanId . 'f.jpg'; + $thumbname = $img_physpath . $thumbnails . '/' . $cleanId . 'f.jpg'; + + $ctx = stream_context_create(['http' => ['timeout' => 30]]); + $imgData = @file_get_contents($TMDB_IMG_BASE . $size . $poster_path, false, $ctx); + if ($imgData === false) { echo json_encode(['error' => 'Failed to download image']); exit; } + if (file_put_contents($filename, $imgData) === false) { echo json_encode(['error' => "Failed to save"]); exit; } + + if (extension_loaded('gd')) { + $src = @imagecreatefromstring($imgData); + if ($src) { + $w = imagesx($src); $h = imagesy($src); + $nw = 150; $nh = (int)($h * $nw / $w); + $thumb = imagecreatetruecolor($nw, $nh); + imagecopyresampled($thumb, $src, 0, 0, 0, 0, $nw, $nh, $w, $h); + imagejpeg($thumb, $thumbname, 80); + imagedestroy($thumb); imagedestroy($src); + } + } + echo json_encode(['success' => true, 'filename' => $filename, 'size' => strlen($imgData)]); + exit; + } +} + +// Page content +$db->convertToUtf8 = true; +$result = $db->sql_query("SELECT id, title, originaltitle, productionyear FROM {$table_prefix}dvd ORDER BY title ASC"); +$dvds = []; +while ($row = $db->sql_fetchrow($result)) { + $cleanId = rtrim($row['id'], "\x00"); + $dvds[] = [ + 'cleanId' => $cleanId, + 'title' => $row['title'], + 'originaltitle' => $row['originaltitle'], + 'year' => $row['productionyear'], + 'hasCover' => file_exists($img_physpath . $cleanId . 'f.jpg'), + ]; +} +$db->sql_freeresult($result); +$total = count($dvds); +$withCover = count(array_filter($dvds, fn($d) => $d['hasCover'])); +$missing = $total - $withCover; + +// --- Output --- +if ($cf_standalone) { + header('Content-Type: text/html; charset=UTF-8'); +} +?> + + + + + + +<?= $lang['CF']['TITLE'] ?> + + + + +
+ + + +
+
+
+
+ + + +
+
+ + 0): ?> +
+ +
+ +
+ +
+ + +
" . implode("", array_keys($row)) . "
" . implode("", array_map(function($v) { return htmlspecialchars($v, ENT_COMPAT, 'ISO-8859-1'); }, array_keys($row))) . "
" . implode(" ", array_values($row)) . " 
" . implode(" ", array_map(function($v) { return htmlspecialchars($v ?? '', ENT_COMPAT, 'ISO-8859-1'); }, array_values($row))) . " 
+ + + + + + + + + + + + + + + + + + + + +
+ OK' : 'X' ?> + + +
+ + + + + + + + + + + + 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 "

$lang[IMPORTCLICK]
$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 "
";
diff --git a/processskin.php b/includes/processskin.php
similarity index 97%
rename from processskin.php
rename to includes/processskin.php
index 20ecfd5..6a87886 100644
--- a/processskin.php
+++ b/includes/processskin.php
@@ -77,10 +77,11 @@ function header_vars($param) {
     $result = $db->sql_query("SELECT value FROM $DVD_PROPERTIES_TABLE WHERE property='Rating~$locale~$dvd[ratingsystem]~$dvd[rating]'") or die($db->sql_error());
     $row = $db->sql_fetchrow($result);
     $db->sql_freeresult($result);
-    $RatingDescription = $row['value'];
+    $RatingDescription = $row ? $row['value'] : '';
     unset($row);
     $locale = locality(array());
-    list($vmaj, $vmin, $vpatch, $vbuild) = explode('.', $VersionNum);
+    $vparts = explode('.', $VersionNum);
+    $vmaj = $vparts[0] ?? '0'; $vmin = $vparts[1] ?? '0'; $vpatch = $vparts[2] ?? '0'; $vbuild = $vparts[3] ?? '0';
 
     $retval = '';
     if ($comments && ($includecrew || $includecast)) $retval .= "\r\n";     // These two comments should always be emitted, but aren't
@@ -182,7 +183,7 @@ function header_vars($param) {
     $retval .= "\tvar DP_Title = \"$dvd[title]\";\r\n";
     $retval .= "\tvar DP_RatingSystem = \"$dvd[ratingsystem]\";\r\n";
     $retval .= "\tvar DP_Rating = \"$dvd[rating]\";\r\n";
-    $retval .= "\tvar DP_RatingAge = $dvd[ratingage];\r\n";
+    $retval .= "\tvar DP_RatingAge = " . (int)$dvd['ratingage'] . ";\r\n";
     $retval .= "\tvar DP_RatingDescription = \"$RatingDescription\";\r\n";
     $retval .= "\tvar DP_RatingDetails = \"$dvd[ratingdetails]\";\r\n";
     $retval .= "\tvar DP_OriginalTitle = \"$dvd[originaltitle]\";\r\n";
@@ -194,11 +195,11 @@ function header_vars($param) {
     $retval .= "\tvar DP_MediaTypeHDDVD = " . JSTrueFalse($h) . ";\r\n";
     $retval .= "\tvar DP_MediaTypeBluRay = " . JSTrueFalse($b) . ";\r\n";
     if ($dvd['custommediatype'] != '')$retval .= "\tvar DP_CustomMediaType = \"$dvd[custommediatype]\";\r\n";
-    $retval .= "\tvar DP_ProductionYear = $dvd[productionyear];\r\n";
+    $retval .= "\tvar DP_ProductionYear = " . (int)$dvd['productionyear'] . ";\r\n";
     $retval .= "\tvar DP_CountryOfOrigin = \"$dvd[countryoforigin]\";\r\n";
     $retval .= "\tvar DP_CountryOfOrigin2 = \"$dvd[countryoforigin2]\";\r\n";
     $retval .= "\tvar DP_CountryOfOrigin3 = \"$dvd[countryoforigin3]\";\r\n";
-    $retval .= "\tvar DP_RunTime = $dvd[runningtime];\r\n";
+    $retval .= "\tvar DP_RunTime = " . (int)$dvd['runningtime'] . ";\r\n";
     $retval .= "\tvar DP_CaseType = \"$dvd[casetype]\";\r\n";
     $retval .= "\tvar DP_CaseSlipCover = " . JSTrueFalse($dvd['caseslipcover']) . ";\r\n";
     $retval .= "\tvar DP_CaseType_Translated = \"" . $lang[strtoupper(str_replace(' ', '', $dvd['casetype']))] . "\";\r\n";
@@ -214,7 +215,7 @@ function header_vars($param) {
     $retval .= "\tvar DP_VideoFormatPanScan = " . JSTrueFalse($dvd['formatpanandscan']) . ";\r\n";
     $retval .= "\tvar DP_VideoFormatFullFrame = " . JSTrueFalse($dvd['formatfullframe']) . ";\r\n";
     $retval .= "\tvar DP_VideoFormatAnamorphic = " . JSTrueFalse($dvd['format16x9']) . ";\r\n";
-    $retval .= "\tvar DP_AspectRatio = $dvd[formataspectratio];\r\n";
+    $retval .= "\tvar DP_AspectRatio = " . (float)$dvd['formataspectratio'] . ";\r\n";
     if ($comments) $retval .= "\r\n";
     if ($comments) $retval .= "// Features\r\n";
     $retval .= "\tvar DP_FeatureSceneAccess = " . JSTrueFalse($dvd['featuresceneaccess']) . ";\r\n";
@@ -254,7 +255,7 @@ function header_vars($param) {
     $retval .= "\tvar DP_CollectionTypeCustom = " . JSTrueFalse($iscust) . ";\r\n";
     if ($iscust) $retval .= "\tvar DP_CustomCollectionTypeName = \"" . addslashes($dvd['realcollectiontype']) . "\";\r\n";
     $retval .= "\tvar DP_CollectionNumber = \"$dvd[collectionnumber]\";\r\n";
-    $retval .= "\tvar DP_CountAs = $dvd[countas];\r\n";
+    $retval .= "\tvar DP_CountAs = " . (int)$dvd['countas'] . ";\r\n";
     $retval .= "\tvar DP_SortTitle = \"$dvd[sorttitle]\";\r\n";
     $retval .= "\tvar DP_WishPriority = \"" . $lang_en_WISHNAME[$dvd['wishpriority']] . "\";\r\n";
     $retval .= "\tvar DP_WishPriority_Translated = \"" . $lang["WISHNAME$dvd[wishpriority]"] . "\";\r\n";
@@ -267,10 +268,10 @@ function header_vars($param) {
     $retval .= "\tvar DP_LoanDue = new Date(" . JSDate($dvd['loandue'], '1899,11,30') . ");\r\n";
     if ($comments) $retval .= "\r\n";
     if ($comments) $retval .= "// Review\r\n";
-    $retval .= "\tvar DP_ReviewFilm = $dvd[reviewfilm];\r\n";
-    $retval .= "\tvar DP_ReviewVideo = $dvd[reviewvideo];\r\n";
-    $retval .= "\tvar DP_ReviewAudio = $dvd[reviewaudio];\r\n";
-    $retval .= "\tvar DP_ReviewExtras = $dvd[reviewextras];\r\n";
+    $retval .= "\tvar DP_ReviewFilm = " . (int)$dvd['reviewfilm'] . ";\r\n";
+    $retval .= "\tvar DP_ReviewVideo = " . (int)$dvd['reviewvideo'] . ";\r\n";
+    $retval .= "\tvar DP_ReviewAudio = " . (int)$dvd['reviewaudio'] . ";\r\n";
+    $retval .= "\tvar DP_ReviewExtras = " . (int)$dvd['reviewextras'] . ";\r\n";
     if ($comments) $retval .= "\r\n";
     if ($comments) $retval .= "// Locks\r\n";
     $retval .= "\tvar DP_LockEntire = " . JSTrueFalse($locks['entire']) . ";\r\n";
@@ -311,11 +312,11 @@ function header_vars($param) {
     $retval .= "\tDP_Genres[3] = \"" . (isset($dvd['genres'][3])?$dvd['genres'][3]:'') . "\";\r\n";
     $retval .= "\tDP_Genres[4] = \"" . (isset($dvd['genres'][4])?$dvd['genres'][4]:'') . "\";\r\n";
     $retval .= "\tvar DP_Genres_Translated = new Array(5);\r\n";
-    $retval .= "\tDP_Genres_Translated[0] = \"" . (isset($dvd['genres'][0])?GenreTranslation($dvd['genres'][0]):'') . "\";\r\n";
-    $retval .= "\tDP_Genres_Translated[1] = \"" . (isset($dvd['genres'][1])?GenreTranslation($dvd['genres'][1]):'') . "\";\r\n";
-    $retval .= "\tDP_Genres_Translated[2] = \"" . (isset($dvd['genres'][2])?GenreTranslation($dvd['genres'][2]):'') . "\";\r\n";
-    $retval .= "\tDP_Genres_Translated[3] = \"" . (isset($dvd['genres'][3])?GenreTranslation($dvd['genres'][3]):'') . "\";\r\n";
-    $retval .= "\tDP_Genres_Translated[4] = \"" . (isset($dvd['genres'][4])?GenreTranslation($dvd['genres'][4]):'') . "\";\r\n";
+    $retval .= "\tDP_Genres_Translated[0] = \"" . (isset($dvd['genres'][0])?genreTranslation($dvd['genres'][0]):'') . "\";\r\n";
+    $retval .= "\tDP_Genres_Translated[1] = \"" . (isset($dvd['genres'][1])?genreTranslation($dvd['genres'][1]):'') . "\";\r\n";
+    $retval .= "\tDP_Genres_Translated[2] = \"" . (isset($dvd['genres'][2])?genreTranslation($dvd['genres'][2]):'') . "\";\r\n";
+    $retval .= "\tDP_Genres_Translated[3] = \"" . (isset($dvd['genres'][3])?genreTranslation($dvd['genres'][3]):'') . "\";\r\n";
+    $retval .= "\tDP_Genres_Translated[4] = \"" . (isset($dvd['genres'][4])?genreTranslation($dvd['genres'][4]):'') . "\";\r\n";
     if ($comments) $retval .= "\r\n";
     if ($comments) $retval .= "// Studios\r\n";
     $retval .= "\tvar DP_Studios = new Array(3);\r\n";
@@ -551,7 +552,7 @@ function last_watched_by($param) {
         if ($row['timestamp'] != $ts)
             break;
         if ($ret != '') $ret .= $divider;
-        $row['lastname'] = HideName($row['lastname']);
+        $row['lastname'] = hideName($row['lastname']);
         $ret .= preg_replace('/\s\s+/', ' ', trim("$row[firstname] $row[lastname]"));
     }
     $db->sql_freeresult($res);
@@ -1129,7 +1130,7 @@ function events($param) {
 
     $ret = '';
     foreach ($dvd['events'] as $k => $e) {
-        $e['lastname'] = HideName($e['lastname']);
+        $e['lastname'] = hideName($e['lastname']);
         if ($ret != '') $ret .= $divider;
         $line = '';
         if ($showfullname) {
@@ -1330,28 +1331,13 @@ function ProcessDP($matches) {
     return($matches[1].$result);
 }
 
-function Replace2Lang($matches) {
-global $lang;
-    $matches[1] = str_replace("'", '', $matches[1]);
-    $matches[1] = str_replace('"', '', $matches[1]);
-    $matches[2] = str_replace("'", '', $matches[2]);
-    $matches[2] = str_replace('"', '', $matches[2]);
-    return($lang[$matches[1]][$matches[2]]);
-}
-function ReplaceLang($matches) {
-global $lang;
-    $matches[1] = str_replace("'", '', $matches[1]);
-    $matches[1] = str_replace('"', '', $matches[1]);
-    return($lang[$matches[1]]);
-}
-
 if (is_readable("$skinloc/$skinfile")) {
     $skin = file_get_contents("$skinloc/$skinfile");
     $j = preg_replace_callback('/(.*)("]*(("[^"]*")[^>"]*)*)(>)(.*)/Ui', "ProcessDP", $skin);
     unset($skin);
 
-    $j = preg_replace_callback('/\\$lang\\[(.*)\\]\\[(.*)\\]/U', "Replace2Lang", $j);
-    $j = preg_replace_callback('/\\$lang\\[(.*)\\]/U', "ReplaceLang", $j);
+    $j = preg_replace_callback('/\\$lang\\[(.*)\\]\\[(.*)\\]/U', "replace2Lang", $j);
+    $j = preg_replace_callback('/\\$lang\\[(.*)\\]/U', "replaceLang", $j);
 
     $j = preg_replace('|\\.\\.[\\\\/]\\.\\.[\\\\/]skins[\\\\/]temp[\\\\/]|i', $skinloc.'/', $j);
     $j = str_replace('$DPIMAGES.', $skinloc.'/', $j);
diff --git a/statistics.php b/includes/statistics.php
similarity index 96%
rename from statistics.php
rename to includes/statistics.php
index 14e91f0..1265e1c 100644
--- a/statistics.php
+++ b/includes/statistics.php
@@ -1,16 +1,18 @@
 0)? $decimals: -1*floor($j);
-    $frac = round($frac, $round);
+    if (!is_finite($j)) return(round($frac, $decimals));
+    $round = ($j>0)? $decimals: (int)(-1*floor($j));
+    $frac = round($frac, (int)$round);
     return($frac);
 }
 
-    SendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";');
+    if (!$ajax) sendNoCacheHeaders('Content-Type: text/html; charset="windows-1252";');
 
     if (!DisplayIfIsPrivateOrAlways($handleadult)) {
         $noadult = "AND isadulttitle=0";
@@ -88,27 +90,60 @@ function FiddleMonth(str) {
     }
 
 // ***************** Page Heading
+    if (!$ajax) {
     echo<<
 
 
 
 $lang[STATISTICS]
-$hdr
+
 
 
-
$lang[STATISTICS]
-
EOT; + } + // Scripts needed in both modes (re-executed by runInlineScripts in AJAX) + echo $hdr; + if ($ajax) { + // Fix GetWidth for AJAX: use #main-content width + echo "\n"; + // Override document.write for AJAX mode (called after page load, would clear page) + echo <<<'JSFIX' + +JSFIX; + + echo "
\n"; + echo "

$lang[STATISTICS]

\n"; + } else { + echo "
$lang[STATISTICS]

\n"; + } $t0 = microtime_float(); $numtimings = 0; $centertable = "" ."
%d (%s%%)
"; // ***************** 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 "

\n"; + if ($ajax) { + echo "
\n"; // close table, col, row, stats-section + } else { + echo "
\n"; + } if ($usejpgraph) { if (DisplayIfIsPrivateOrAlways($displaymonth)) { @@ -461,7 +500,7 @@ function SwitchCurrency(obj) { printf("%s" ."$centertable" ."$centertable\n", - GenreTranslation($key), + genreTranslation($key), $genre[$key]['primetotal'], $genre[$key]['primefrac'], $genre[$key]['alltotal'], $genre[$key]['allfrac']); } @@ -1211,4 +1250,8 @@ function SwitchCurrency(obj) { unset($ProfileName); unset($Profile); echo ''; - echo "$endbody\n"; + if ($ajax) { + echo "\n"; // close stats-container + } else { + echo "$endbody\n"; + } diff --git a/index.php b/index.php index b844747..403f29d 100644 --- a/index.php +++ b/index.php @@ -1,18 +1,24 @@ convertToUtf8 = true; +} +define('HTML_CHARSET', $ajax ? 'UTF-8' : 'ISO-8859-1'); +checkOutOfDateSchema($action); -$iconPath = dirname($_SERVER['SCRIPT_NAME']) . '/gfx'; +$iconPath = 'gfx'; if (!isset($collection)) $collection = $DefaultCollection; @@ -46,6 +52,7 @@ function UpdateDataRow(&$dvd) { if ($action == 'GimmeAFrontThumb') { if (!isset($mediaid)) $mediaid = ''; + if (strlen($mediaid) > 0 && strlen($mediaid) < 20) $mediaid = str_pad($mediaid, 20, "\x00"); if (!isset($bannertype)) $bannertype = ''; if (!isset($side)) $side = 'f'; if ($side != 'b') $side = 'f'; @@ -55,6 +62,11 @@ function UpdateDataRow(&$dvd) { } if ($action == 'phpinfo') { + if (!$IsPrivate) { + header("HTTP/1.0 403 Forbidden"); + echo "Access denied."; + exit; + } phpinfo(); DebugSQL($db, "$action"); exit; @@ -75,7 +87,7 @@ function UpdateDataRow(&$dvd) { $db->sql_freeresult($res); $db->sql_query("UPDATE $DVD_PROPERTIES_TABLE SET value='0||0|0|0|0|$row[Id]' WHERE property='CurrentPosition'") or die($db->sql_error()); unset($row); - ModifyTables('ENABLE'); + modifyTables('ENABLE'); DebugSQL($db, "$action"); $action = 'UpdateStatus'; // while this looks hackish, it prevents having to duplicate code } @@ -101,7 +113,7 @@ function UpdateDataRow(&$dvd) { } $db->sql_freeresult($result); } - SendNoCacheHeaders(); + sendNoCacheHeaders(); echo "$QueryNumber-UpdateStatus:Status=$UpdateStatus:$found\n\n"; DebugSQL($db, "$action"); exit; @@ -109,13 +121,14 @@ function UpdateDataRow(&$dvd) { if ($action == 'info') { $thedatetime = date('Y-m-d-H:i:s', GetLastUpdateTime('LastUpdate')); - SendNoCacheHeaders(); - echo "phpDVDProfiler:Version=$VersionNum|XML:Version=$thedatetime|MySQL:Version=".MySQLVersion()."|PHP:Version=".phpversion()."\n\n"; + sendNoCacheHeaders(); + echo "phpDVDProfiler:Version=$VersionNum|XML:Version=$thedatetime|MySQL:Version=".mySqlVersion()."|PHP:Version=".phpversion()."\n\n"; DebugSQL($db, "$action"); exit; } if ($action == 'notes') { + if (strlen($mediaid) > 0 && strlen($mediaid) < 20) $mediaid = str_pad($mediaid, 20, "\x00"); $result = $db->sql_query("SELECT notes FROM $DVD_TABLE WHERE id='".$db->sql_escape($mediaid)."'") or die($db->sql_error()); $data = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -126,14 +139,15 @@ function UpdateDataRow(&$dvd) { } if ($action == 'image') { - DiscourageAbuse($RefuseBots); + discourageAbuse($RefuseBots); + if (strlen($mediaid) > 0 && strlen($mediaid) < 20) $mediaid = str_pad($mediaid, 20, "\x00"); $TheTitle = $lang['DVDCOVER']; $res = $db->sql_query("SELECT title, originaltitle, description, custommediatype FROM $DVD_TABLE WHERE id='".$db->sql_escape($mediaid)."'") or die($db->sql_error()); $dat = $db->sql_fetchrow($res); $db->sql_freeresult($res); - if ($dat['title'] != '') { - FormatTheTitle($dat); - $TheTitle = fix1252(htmlspecialchars($dat['title'], ENT_COMPAT, 'ISO-8859-1')); + if ($dat && $dat['title'] != '') { + formatTheTitle($dat); + $TheTitle = fix1252(htmlspecialchars($dat['title'], ENT_COMPAT, HTML_CHARSET)); } if (!isset($mtype)) @@ -145,7 +159,7 @@ function UpdateDataRow(&$dvd) { else $ban = @$MediaTypes[$dat['custommediatype']]['Banner']; if ($ban != '') { - $imagedata = getimagesize(WebpathToPhyspath($img)); + $imagedata = getimagesize(webpathToPhyspath($img)); $width = $imagedata[0]; $hdlogo = "\"$TheTitle\"
"; } @@ -184,11 +198,60 @@ function UpdateDataRow(&$dvd) { } if ($action == 'upload' || $action == 'uploadxml') { - if (is_readable('upload.php')) { + if (is_readable(BASE_PATH . 'upload.php')) { include_once('upload.php'); } } +// Upload max size for display +$GLOBALS['_upload_max'] = ini_get('upload_max_filesize'); + +// Handle XML collection upload +if ($action == 'upload_collection' && $_SERVER['REQUEST_METHOD'] == 'POST') { + $upload_msg = ''; + $upload_ok = false; + + // Authentication check applies to both delete and upload + $badlogin = !isset($_POST['auth_login']) || + ($_POST['auth_login'] != $update_login) || ($_POST['auth_pass'] != $update_pass); + + if ($badlogin) { + $upload_msg = $lang['BADLOGIN']; + } elseif (isset($_POST['delete_import']) && $_POST['delete_import']) { + // Delete an uploaded file from import/ + $delFile = BASE_PATH . 'import/' . basename($_POST['delete_import']); + if (is_file($delFile) && pathinfo($delFile, PATHINFO_EXTENSION) === 'xml') { + @unlink($delFile); + $upload_msg = $lang['UPLOAD']['XMLDELETED']; + $upload_ok = true; + } + } else { + if (!isset($_FILES['xmlfile']) || $_FILES['xmlfile']['error'] == UPLOAD_ERR_NO_FILE) { + $upload_msg = $lang['UPLOAD']['XMLNOFILE']; + } elseif ($_FILES['xmlfile']['error'] !== UPLOAD_ERR_OK) { + $errors = [1=>$lang['UPLOAD']['XMLTOOLARGE_SRV'],2=>$lang['UPLOAD']['XMLTOOLARGE_FRM'],3=>$lang['UPLOAD']['XMLPARTIAL'],6=>$lang['UPLOAD']['XMLNOTMPDIR'],7=>$lang['UPLOAD']['XMLWRITEFAIL']]; + $upload_msg = $errors[$_FILES['xmlfile']['error']] ?? 'Upload error '.$_FILES['xmlfile']['error']; + } else { + $ext = strtolower(pathinfo($_FILES['xmlfile']['name'], PATHINFO_EXTENSION)); + if ($ext !== 'xml') { + $upload_msg = $lang['UPLOAD']['XMLONLYXML']; + } else { + $importDir = BASE_PATH . 'import'; + if (!is_dir($importDir)) @mkdir($importDir, 0775, true); + $targetFile = $importDir . '/' . basename($_FILES['xmlfile']['name']); + if (move_uploaded_file($_FILES['xmlfile']['tmp_name'], $targetFile)) { + $upload_ok = true; + $upload_msg = sprintf($lang['UPLOAD']['XMLUPLOADED'], basename($targetFile), number_format(filesize($targetFile)/1024, 0)); + } else { + $upload_msg = $lang['UPLOAD']['XMLFAILED']; + } + } + } + } + header('Location: index.php?action=update&upload_msg=' . urlencode($upload_msg) . '&upload_ok=' . ($upload_ok?1:0)); + exit; +} + if ($action == 'smallupdate') { $LeaveMissing = true; $action = 'update'; @@ -205,7 +268,7 @@ function UpdateDataRow(&$dvd) { $forumuser = ''; if ($action == 'CompleteUpdate') { $delete = 1; - $UpdateLast = UpdateUpdateLast(); + $UpdateLast = updateUpdateLast(); } $remove_missing = true; // default to not doing partial updates // This allows this to be used from the command-line if desired @@ -246,53 +309,105 @@ function UpdateDataRow(&$dvd) { $OnloadStyle = 'UpdateLoaded();'; $JavascriptOnerr = ''."\n"; $Javascript = ''."\n"; - $SubmitButton = ''; + $SubmitButton = ''; if ($UpdateDebug) - $SubmitButton = ''.$SubmitButton; + $SubmitButton = ''.$SubmitButton; $Action = 'phpaction'; - $OutputAreas = '
'."\n" + $OutputAreas = '
'."\n" .'
'."\n" - .'
'."\n"; + .'
'."\n"; if ($SubmitOldStyle) { $OnloadStyle = 'document.LoginForm.auth_login.focus();'; $JavascriptOnerr = ''; $Javascript = ''; - $SubmitButton = ''; + $SubmitButton = ''; $Action = 'action'; $OutputAreas = ''; } - @header('Content-Type: text/html; charset="windows-1252";'); - echo << - - - -$lang[IMPORTTITLE] - - - - -$JavascriptOnerr$Javascript - -
+ // Build import file status + $importDir = BASE_PATH . 'import'; + $importFiles = (is_dir($importDir)) ? glob("$importDir/*.xml") : []; + $importStatus = ''; + if (!empty($importFiles)) { + foreach ($importFiles as $ifile) { + $fname = basename($ifile); + $fsize = number_format(filesize($ifile) / 1024, 0); + $ftime = date('d.m.Y H:i', filemtime($ifile)); + $importStatus .= '
' + . '✔ ' . htmlspecialchars($fname) . " ({$fsize} KB, {$ftime})" + . '' + . '' + . '' + . '' + . '
'; + } + } + $uploadMsg = ''; + if (isset($_GET['upload_msg']) && $_GET['upload_msg'] !== '') { + $cls = (isset($_GET['upload_ok']) && $_GET['upload_ok']) ? 'success' : 'danger'; + $uploadMsg = '
' . htmlspecialchars($_GET['upload_msg']) . '
'; + } + + // Store update form to render inside main shell + $update_head_scripts = $JavascriptOnerr . $Javascript; + $update_onload = $OnloadStyle; + $update_content = << +

$lang[IMPORTTITLE]

+ +
+
+
{$lang['UPLOAD']['XMLTITLE']}
+$uploadMsg +$importStatus +
+ +
+
+
+
+
+ + +
+Max: {$GLOBALS['_upload_max']} — {$lang['UPLOAD']['XMLHINT']} +
+
+
+ +
-$lang[LOGIN] -$lang[PASSWORD] -$lang[COMPLETE]
-$lang[REMOVE]
+
+ + +
+
+ + +
+
+ + +
+
+ + +
-$SubmitButton +
$SubmitButton
-$OutputAreas$endbody -EOT; + +$OutputAreas +UPDATEFORM; + $action = 'main'; // Let it flow to main shell } else { header("HTTP/1.0 401 Bad Username/Password", true, 401); $str = ''; - $str .= 'Bad Username/Password.'; + $str .= $lang['BADLOGIN']; echo "$str$eoln"; + exit; } - exit; } else { $authorized = true; @@ -308,9 +423,21 @@ function UpdateDataRow(&$dvd) { else $db_fast_update = false; } + // If action was changed to 'main' (update form stored for main shell), skip processing + if ($action == 'main') goto update_form_skip; + if ($LeaveMissing) $remove_missing = false; + // Use import/ directory if it has XML files + $importDir = BASE_PATH . 'import'; + if (is_dir($importDir)) { + $importXmlFiles = glob("$importDir/*.xml"); + if (!empty($importXmlFiles)) { + $xmldir = $importDir; + } + } + include_once('incupdate.php'); HandleOutOfDateSchema($outputtext); if ($action == 'UpdateStats') { @@ -320,6 +447,7 @@ function UpdateDataRow(&$dvd) { DebugSQL($db, "$action"); exit; } +update_form_skip: function CleanTheHTMLIn(&$str) { global $playsounds; @@ -504,7 +632,13 @@ function ProjectAColumn($colname, &$dvd, $align) { break; } if ($colvalue == '0') $colvalue = ''; - if ($colname != 'none') $colvalue = "$colvalue"; + if ($colname != 'none') { + global $ajax; + if ($ajax) + $colvalue = "$colvalue"; + else + $colvalue = "$colvalue"; + } return($colvalue); } @@ -685,7 +819,7 @@ function DisplayDecoration($str, &$dvd) { if (!isset($searchtext)) $searchtext = ''; $searchtext = rawurldecode($searchtext); $searchurl = rawurlencode($searchtext); -$searchdisp = htmlentities($searchtext, ENT_COMPAT, 'ISO-8859-1'); +$searchdisp = htmlentities($searchtext, ENT_COMPAT, HTML_CHARSET); if ($action == 'nav') { if (!isset($searchby)) $searchby = ''; @@ -710,7 +844,7 @@ function DisplayDecoration($str, &$dvd) { $thetitle = " ($lang[SEARCHED] $lang[RATINGS] $lang[FOR] \"".$lang['LOCALE'.$tmploc] . ": $tmpsys: $tmprat\")"; break; case 'genre': - $thetitle = " ($lang[SEARCHED] $lang[GENRES] $lang[FOR] \"" . GenreTranslation($searchtext) . '")'; + $thetitle = " ($lang[SEARCHED] $lang[GENRES] $lang[FOR] \"" . genreTranslation($searchtext) . '")'; break; case 'purchase': $result = $db->sql_query("SELECT suppliername from $DVD_SUPPLIER_TABLE WHERE sid=".$db->sql_escape($searchtext)) or die($db->sql_error()); @@ -726,7 +860,7 @@ function DisplayDecoration($str, &$dvd) { $thetitle = " ($lang[SEARCHED] $lang[LOCALE] $lang[FOR] \"".$lang['LOCALE'.$searchtext].'")'; break; case 'coo': - CountryToLang($searchtext, $countryname, $localenum); + countryToLang($searchtext, $countryname, $localenum); $thetitle = " ($lang[SEARCHED] $lang[COUNTRYOFORIGIN] $lang[FOR] \"$countryname\")"; break; case 'tag': @@ -771,7 +905,7 @@ function DisplayDecoration($str, &$dvd) { $result = $db->sql_query("SELECT collectiontype, SUM(countas) AS itemcount FROM $DVD_TABLE WHERE 1 $noadult GROUP BY collectiontype") or die($db->sql_error()); while ($items = $db->sql_fetchrow($result)) { $numincollection[$items['collectiontype']] = $items['itemcount']; - $colltype = CustomTranslation(strtoupper(str_replace(' ', '', $items['collectiontype'])), $items['collectiontype']); + $colltype = customTranslation(strtoupper(str_replace(' ', '', $items['collectiontype'])), $items['collectiontype']); $infoline .= "$items[itemcount] $colltype, "; $numincollection['all'] += $items['itemcount']; } @@ -922,7 +1056,7 @@ function DisplayDecoration($str, &$dvd) { $sql = "SELECT DISTINCT(genre) FROM $DVD_GENRES_TABLE ORDER BY genre"; $result = $db->sql_query($sql) or die($db->sql_error()); while ($row = $db->sql_fetchrow($result)) { - $displaygenre = GenreTranslation($row['genre']); + $displaygenre = genreTranslation($row['genre']); if ($searchtext == $displaygenre) echo "\n"; else @@ -963,7 +1097,7 @@ function DisplayDecoration($str, &$dvd) { unset($coo); sort($remembercoo); foreach ($remembercoo as $coo) { - CountryToLang($coo, $countryname, $localenum); + countryToLang($coo, $countryname, $localenum); if ($searchtext == $countryname) echo "\n"; else @@ -1234,7 +1368,7 @@ function DisplayDecoration($str, &$dvd) { $where .= " AND auxcolltype=''"; break; case 'loaned': - $where = "loaninfo!=''"; + $where = "(loaninfo!='' OR (boxparent!='' AND boxparent IN (SELECT id FROM $DVD_TABLE lp WHERE lp.loaninfo!='')))"; break; case 'all': $where = "1"; @@ -1244,11 +1378,11 @@ function DisplayDecoration($str, &$dvd) { break; default: if (is_numeric($collection)) { - $where = "auxcolltype LIKE '%/".addslashes($masterauxcolltype[$collection])."/%'"; + $where = "auxcolltype LIKE '%/".$db->sql_escape($masterauxcolltype[$collection])."/%'"; } else if (substr($collection, 0, strlen('FJW-')) == 'FJW-') { $collsel = $collectiontypelist[(int)(substr($collection, strlen('FJW-')))]; - $where = "realcollectiontype='" . addslashes($collsel) . "'"; + $where = "realcollectiontype='" . $db->sql_escape($collsel) . "'"; if ($removetabbed) $where .= " AND auxcolltype=''"; } @@ -1265,8 +1399,8 @@ function DisplayDecoration($str, &$dvd) { $where .= " AND boxparent='%%BOXPARENT%%'"; $Extra = 'dvd WHERE'; -if (isset($letter) && $lettermeaning == 1) { - if ($letter == "0") +if (isset($letter) && ($lettermeaning == 1 || $ajax)) { + if ($letter == "0" || $letter == "0-9") $where .= " AND dvd.sorttitle < 'A'"; else $where .= " AND dvd.sorttitle LIKE '$letter%'"; @@ -1289,7 +1423,7 @@ function DisplayDecoration($str, &$dvd) { $Extra = "dvd WHERE IF (LOCATE('.',id) = '0',0,SUBSTRING(id,locate('.',id)+1,LENGTH(id)-LOCATE('.',id)))+0 = '$srchtext' AND"; break; case 'coo': - CountryToLang($searchtext, $countryname, $localenum); + countryToLang($searchtext, $countryname, $localenum); $countryname = $db->sql_escape($countryname); $Extra = "dvd WHERE (countryoforigin = '$countryname' OR countryoforigin2 = '$countryname' OR countryoforigin3 = '$countryname') AND"; break; @@ -1448,37 +1582,248 @@ function DisplayDecoration($str, &$dvd) { } } - if ($allowwidths) { - if (isset($_COOKIE['widthgt800'])) $widthgt800 = $_COOKIE['widthgt800']; + // Build collection options for navbar + $noadult = ''; + if (!DisplayIfIsPrivateOrAlways($handleadult)) + $noadult .= ' AND isadulttitle=0'; + $numincollection_nav = array('owned'=>0,'ordered'=>0,'wishlist'=>0,'loaned'=>0,'all'=>0); + $result = $db->sql_query("SELECT collectiontype, SUM(countas) AS itemcount FROM $DVD_TABLE WHERE 1 $noadult GROUP BY collectiontype") or die($db->sql_error()); + while ($items = $db->sql_fetchrow($result)) { + $numincollection_nav[$items['collectiontype']] = $items['itemcount']; + $numincollection_nav['all'] += $items['itemcount']; + } + if (DisplayIfIsPrivateOrAlways($displayloaned)) { + $db->sql_freeresult($result); + $result = $db->sql_query("SELECT SUM(countas) AS itemcount FROM $DVD_TABLE WHERE loaninfo != '' $noadult") or die($db->sql_error()); + $items = $db->sql_fetchrow($result); + if ($items['itemcount'] != 0) + $numincollection_nav['loaned'] = $items['itemcount']; + } + $db->sql_freeresult($result); + + // Build collection "; + if (!$hideowned && $numincollection_nav['owned'] != 0) + $collectionOptions .= ""; + if (!$hideordered && $numincollection_nav['ordered'] != 0) + $collectionOptions .= ""; + if (!$hidewishlist && $numincollection_nav['wishlist'] != 0) + $collectionOptions .= ""; + if (!$hideloaned && $numincollection_nav['loaned'] != 0) + if (DisplayIfIsPrivateOrAlways($displayloaned)) + $collectionOptions .= ""; - header('Content-Type: text/html; charset="windows-1252";'); - $rssfeed = ''; - if (is_readable('rss.php')) $rssfeed = ' '; - if ($mobileshow) { - if ($lastmedia == 'Chooser' || $lastmedia == 'Statistics' || $lastmedia == 'WatchedStatistics' || substr($lastmedia, 0, 7) == 'Gallery') - $mobilepage = $PHP_SELF; + $coltnum_m = (substr($collection, 0, strlen('FJW-'))=='FJW-')?(int)substr($collection, strlen('FJW-')): -1; + foreach ($collectiontypelist as $num => $ctype) { + $thissel = ($coltnum_m==$num)? ' selected': ''; + $collectionOptions .= ""; + } + foreach ($masterauxcolltype as $num => $auxcoltype) { + if ($auxcoltype != '') { + $thissel = (is_numeric($collection) && $collection==$num)? ' selected': ''; + $collectionOptions .= ""; + } + } + + // Build A-Z letter links + $letterLinks = ''; + $letters = array('0-9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); + foreach ($letters as $lt) { + $letterLinks .= "$lt "; + } + + // Build language menu items + $langMenuItems = ''; + if ($allowlocale) { + $langMenuItems .= "
  • English
  • "; + $langMenuItems .= "
  • Français
  • "; + $langMenuItems .= "
  • Deutsch
  • "; + $langMenuItems .= "
  • Norsk
  • "; + $langMenuItems .= "
  • Svenska
  • "; + $langMenuItems .= "
  • Dansk
  • "; + $langMenuItems .= "
  • Suomi
  • "; + $langMenuItems .= "
  • Nederlands
  • "; + $langMenuItems .= "
  • Русский
  • "; + $langMenuItems .= "
  • Čeština
  • "; + } + + // Build tools menu items + $toolsMenuItems = "
  • $lang[STATISTICS]
  • "; + if (is_readable(BASE_PATH . 'pages/ws.php') && DisplayIfIsPrivateOrAlways($handlewatched)) { + $toolsMenuItems .= "
  • $lang[WATCHED]
  • "; + } + if (is_readable(BASE_PATH . 'pages/gallery.php')) { + $toolsMenuItems .= "
  • $lang[FRONTGALLERY]
  • "; + if ($BackGallery) { + $toolsMenuItems .= "
  • $lang[BACKGALLERY]
  • "; + } } + if ($AllowChooser) + $toolsMenuItems .= "
  • $lang[CHOOSERSHORT]
  • "; + if (is_readable(BASE_PATH . 'includes/fetch_covers.php')) + $toolsMenuItems .= "

  • TMDB Cover Fetcher
  • "; + $toolsMenuItems .= "

  • "; + $toolsMenuItems .= "
  • {$lang['PREFS']['USERPREFS']}
  • "; + if ($allowupdate) + $toolsMenuItems .= "
  • $lang[UPDATE]
  • "; + + // DVD count info + $infoline_nav = "$numincollection_nav[all] $lang[TOTAL]"; + + header('Content-Type: text/html; charset=UTF-8;'); + $jsCacheBust = time(); + $rssfeed = ''; + if (is_readable(BASE_PATH . 'pages/rss.php')) $rssfeed = ''; + echo << - + + - - $CurrentSiteTitle - $rssfeed - - - - + + +$CurrentSiteTitle +$rssfeed + + + + + + + + +EOT; + if (!empty($update_head_scripts)) echo $update_head_scripts; + if (!empty($update_content)) $lastmedia = ''; // Don't auto-load DVD content over update form + $bodyOnload = !empty($update_onload) ? " onLoad=\"$update_onload\"" : ''; + echo << - - - - - - - + + + + + + +
    +$letterLinks +
    + + +
    $infoline_nav
    + + +
    +
    + +
    + +
    + +
    +EOT; + if (!empty($update_content)) { + echo $update_content; + } else { + echo "
    $lang[LOADING]
    \n"; + } + echo << +
    +
    + + +
    +
    +
    $lang[TITLES]
    + +
    + +
    + + + + + + + EOT; @@ -1547,8 +1892,8 @@ function DisplayDecoration($str, &$dvd) { // Cookies are used to remember the current sort type and order when when the collection is changed // If cookies are disabled, then the only effect is that changing the collection reverts to the // default sort type and order. - setcookie('cookiesort', $sort); - setcookie('cookieorder', $order); + setcookie('cookiesort', $sort, ['path' => '/', 'httponly' => true, 'samesite' => 'Lax']); + setcookie('cookieorder', $order, ['path' => '/', 'httponly' => true, 'samesite' => 'Lax']); // removed DISTINCT to repair broken order by // added back to support searches finding single entries per profile @@ -1576,6 +1921,20 @@ function DisplayDecoration($str, &$dvd) { } + $numcols = 1; // 1 for image, one for title + $page = 1; + if ($TitlesPerPage != 0) + $page = ceil($startrow / $TitlesPerPage)+1; + if (($lettermeaning == 1 || $TitlesPerPage != 0) && isset ($letter)) { + if ($letter != '0-9') + $let = "&letter=$letter#$letter"; + else + $let = "&letter=$letter#0-9"; + } + else + $let = ''; + + if (!$ajax) { header('Content-Type: text/html; charset="windows-1252";'); echo << @@ -1609,18 +1968,6 @@ function dh(theitems, obj) { } EOT; - $numcols = 1; // 1 for image, one for title - $page = 1; - if ($TitlesPerPage != 0) - $page = ceil($startrow / $TitlesPerPage)+1; - if (($lettermeaning == 1 || $TitlesPerPage != 0) && isset ($letter)) { - if ($letter != '0-9') - $let = "&letter=$letter#$letter"; - else - $let = "&letter=$letter#0-9"; - } - else - $let = ''; echo << @@ -1644,6 +1991,7 @@ function dh(theitems, obj) { momItems[num++]=["Suomi", "javascript:top.setcookie('locale','fi',10*365);top.ChangeLang();", "_top", 1, "no"] momItems[num++]=["Nederlands", "javascript:top.setcookie('locale','nl',10*365);top.ChangeLang();", "_top", 1] momItems[num++]=["Русский", "javascript:top.setcookie('locale','ru',10*365);top.ChangeLang();", "_top"] + momItems[num++]=["Čeština", "javascript:top.setcookie('locale','cs',10*365);top.ChangeLang();", "_top", 1] EOT; echo << + +EOT; + } // end if (!$ajax) - legacy frame mode + + if ($ajax) { + // Compute sort header variables for AJAX sidebar + SetColumnTitles($secondcol, $secondcoltitle, $secondcolhover); + SetColumnTitles($thirdcol, $thirdcoltitle, $thirdcolhover); + $sortimg_title = ($sort=='sorttitle') ? "▲ " . $lang['TITLE'] : $lang['TITLE']; + $sortimg_year = ($sort==$secondcol) ? "▲ $secondcoltitle" : $secondcoltitle; + $sortimg_num = ($sort==$thirdcol) ? "▲ $thirdcoltitle" : $thirdcoltitle; + if ($sort=='sorttitle' && $order=='desc') $sortimg_title = "▼ " . $lang['TITLE']; + if ($sort==$secondcol && $order=='desc') $sortimg_year = "▼ $secondcoltitle"; + if ($sort==$thirdcol && $order=='desc') $sortimg_num = "▼ $thirdcoltitle"; + $sorthdr_title = ($sort=='sorttitle') ? (($order=='asc')?'desc':'asc') : $defaultorder['sorttitle']; + $sorthdr_year = ($sort==$secondcol) ? (($order=='asc')?'desc':'asc') : $defaultorder[$secondcol]; + $sorthdr_num = ($sort==$thirdcol) ? (($order=='asc')?'desc':'asc') : $defaultorder[$thirdcol]; + + echo '' . "\n"; + echo ' +
    +
    +
    +EOT; + // Label/value pairs + if ($dvd['originaltitle'] != '') + echo "
    $plwrapf$origtitle:$plwrapb
    $dvd[originaltitle]
    \n"; + if ($dvd['countryoforigin'] != '') + echo "
    $plwrapf$lang[COUNTRYOFORIGIN]:$plwrapb
    $dvd[countryoforigin]
    \n"; + if ($dvd['productionyear'] == '0') $dvd['productionyear'] = ' '; + echo "
    $plwrapf$lang[PRODUCTIONYEAR]:$plwrapb
    $dvd[productionyear]$locks[productionyear]
    \n"; + echo "
    $plwrapf$dirname:$plwrapb
    $dvd[p_directors]
    \n"; + echo "
    $plwrapf$lang[RATING]:$plwrapb
    $ratinglogo$locks[rating]
    \n"; + echo "
    \n"; + echo "
    $plwrapf$lang[REGIONCODE]:$plwrapb
    $regions$locks[regions]
    \n"; + echo "
    $plwrapf$lang[RUNNINGTIME]:$plwrapb
    $runtime$locks[runningtime]
    \n"; + echo "
    $plwrapf$lang[CASETYPE]:$plwrapb
    $dvd[p_casetype]$locks[casetype]
    \n"; + echo "
    $plwrapf$lang[FORMAT]:$plwrapb
    $dvd[format]$locks[videoformats]
    \n"; + echo "
    $plwrapf$lang[MEDIA]:$plwrapb
    $dvd[media]
    \n"; + echo "
    $plwrapf$lang[RELEASED]:$plwrapb
    $dvd[p_released]$locks[releasedate]
    \n"; + echo "
    $plwrapf$lang[COLLECTIONTYPE]:$plwrapb
    $ctype $cnum
    \n"; + echo "
    $plwrapf$locname:$plwrapb
    $locval
    \n"; + echo "
    \n"; + + // Purchase info + $giftfiddle1 = $lang['PURCHASEDATE']; + $giftfiddle2 = $lang['PURCHASEPRICE']; + $giftfiddle3 = $dvd['purchaseprice']; + if ($dvd['gift']) { + $giftfiddle1 = $lang['RECEIVED']; + $giftfiddle2 = $lang['GIFTFROM']; + $giftfiddle3 = ''; + if ($dvd['giftuid'] != 0) { + $userres = $db->sql_query("SELECT firstname,lastname FROM $DVD_USERS_TABLE WHERE uid=$dvd[giftuid]") or die($db->sql_error()); + $r2 = $db->sql_fetchrow($userres); + $db->sql_freeresult($userres); + $giftfiddle3 = $r2['firstname'] . ' ' . hideName($r2['lastname']); + } + } + echo "
    $plwrapf$giftfiddle1:$plwrapb
    $dvd[p_purchasedate]
    \n"; + echo "
    $plwrapf$giftfiddle2:$plwrapb
    $plwrapf$giftfiddle3$plwrapb
    \n"; + + if (DisplayIfIsPrivateOrAlways($displaySRP)) + echo "
    $plwrapf$lang[SRP]:$plwrapb
    $dvd[srp] $dvd[srpcurrencyid]$locks[srp]
    \n"; + if (DisplayIfIsPrivateOrAlways($displayplace)) + echo "
    $plwrapf$lang[PURCHASEPLACE]:$plwrapb
    $purchaseplace
    \n"; + + // Reviews + if ($SeparateReviews) { + if ($dvd['p_reviewfilm'] != '' && strpos($reviewgraph, 'F') !== false) + echo "
    $lang[REVIEWFILM]:
    $dvd[p_reviewfilm]
    \n"; + if ($dvd['p_reviewvideo'] != '' && strpos($reviewgraph, 'V') !== false) + echo "
    $lang[REVIEWVIDEO]:
    $dvd[p_reviewvideo]
    \n"; + if ($dvd['p_reviewaudio'] != '' && strpos($reviewgraph, 'A') !== false) + echo "
    $lang[REVIEWAUDIO]:
    $dvd[p_reviewaudio]
    \n"; + if ($dvd['p_reviewextras'] != '' && strpos($reviewgraph, 'E') !== false) + echo "
    $lang[REVIEWEXTRA]:
    $dvd[p_reviewextras]
    \n"; + } else { + if ($dvd['reviewfilm'] != 0 || $dvd['reviewvideo'] != 0 || $dvd['reviewaudio'] != 0 || $dvd['reviewextras'] != 0 || $displayreviewsEQ0) + echo "
    $lang[REVIEWS]:
    ' . DrawAReviewGraph($dvd, $reviewgraph, 240, 20, '') . "
    \n"; + } + echo "
    \n"; + + // Overview (collapsible) + echo "
    $lang[OVERVIEW]$locks[overview]
    \n"; + echo "
    $dvd[p_overview]
    \n"; + + // Notes (collapsible) + if ($dvd['notes'] != '') { + if ($UseIframeForNotes) { + $ifh = ($IframeHeight != 0) ? "height=\"{$IframeHeight}px\"" : ''; + $notesContent = ""; + } else { + $notesContent = $dvd['notes']; + } + echo "
    $lang[NOTES]
    \n"; + echo "
    $notesContent
    \n"; + } + + // EPG (collapsible) + if ($dvd['epg'] != '') { + if ($UseIframeForEPGs) { + $ifh = ($IframeHeight != 0) ? "height=\"{$IframeHeight}px\"" : ''; + $epgContent = ""; + } else { + $epgContent = $dvd['epg']; + } + echo "
    $lang[EPG]
    \n"; + echo "
    $epgContent
    \n"; + } + + echo "
    \n"; + + // Right column: Covers + Links + echo "
    \n"; + echo "
    $lang[COVERS]$locks[covers]
    $dvd[thumbs]
    \n"; + echo "
    $lang[MISCLINKS]
    $dvd[links]
    \n"; + echo "
    \n"; + echo "
    \n"; + + // Genres + Studios side by side + echo "
    $lang[GENRES]$locks[genres]
    $dvd[p_genres]
    \n"; + echo "
    $lang[STUDIOS]$locks[studios]
    $dvd[p_studios]
    \n"; + + // Audio + Subtitles side by side + echo "
    $lang[AUDIOFORMAT]$locks[audio]
    $dvd[p_audio]
    \n"; + echo "
    $lang[SUBTITLES]$locks[subtitles]
    $dvd[p_subtitles]
    \n"; + + // Tags + if (DisplayIfIsPrivateOrAlways($displaytags) && ($dvd['p_tags'] != '')) + echo "
    $lang[TAGS]
    $dvd[p_tags]
    \n"; + + // Discs + if ($dvd['p_discs'] != '') { + echo "
    $lang[DISCS]$locks[discinfo]
    "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + if ($IsPrivate) + echo ""; + echo "$dvd[p_discs]
    $lang[DISCNO]$lang[DESCRIPTION]$lang[SIDEA]$lang[SIDEB]$lang[DS]$lang[DL] A$lang[DL] B$lang[LOCATION]$lang[SLOT]
    \n"; + } + + // Events + if ($dvd['p_events'] != '') { + echo "
    $lang[EVENTS]
    "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "$dvd[p_events]
    $lang[USERNAME]$lang[PHONE]$lang[EMAIL]$lang[EVENT]$lang[TIMESTAMP]$lang[EVENTNOTE]
    \n"; + } + + // Extras + echo "
    $lang[EXTRAS]$locks[features]
    $dvd[p_extras]
    \n"; + + // Easter Eggs + if (strlen($dvd['eastereggs']) > 0) { + $dvd['eastereggs'] = nl2br($dvd['eastereggs']); + echo "
    $lang[EASTEREGGS]$locks[eastereggs]
    $dvd[eastereggs]
    \n"; + } + + // Credits (collapsible) + if (strlen($dvd['p_credits']) > 0) { + echo "
    $lang[CREDITHEAD]$locks[crew]
    \n"; + echo "
    $dvd[p_credits]
    \n"; + } + + // Cast (collapsible) + echo "
    $lang[CAST]$locks[cast]
    \n"; + echo "
    $dvd[p_actors]
    \n"; + + echo "
    \n"; + echo "\n"; + // ===== END BOOTSTRAP DVD DETAIL ===== + } else { + // ===== LEGACY TABLE-BASED DVD DETAIL ===== + echo << $r$dvd[title]$locks[title]$J @@ -3069,7 +3761,7 @@ function SwitchOutRows(theitems, obj) { $userres = $db->sql_query("SELECT firstname,lastname FROM $DVD_USERS_TABLE WHERE uid=$dvd[giftuid]") or die($db->sql_error()); $r = $db->sql_fetchrow($userres); $db->sql_freeresult($userres); - $giftfiddle3 = $r['firstname'] . ' ' . HideName($r['lastname']); + $giftfiddle3 = $r['firstname'] . ' ' . hideName($r['lastname']); } } echo << -$endbody - EOT; + } // end legacy table-based detail (else branch of $ajax) + if (!$ajax) { + echo "$endbody\n\n"; + } } else { + if (!$ajax) { header('Content-Type: text/html; charset="windows-1252";'); echo << @@ -3502,16 +4197,21 @@ function SwitchOutRows(theitems, obj) { + +EOT; + } // end if (!$ajax) for empty list header + echo << $lang[EMPTYLIST]
    0 $lang[ITEMS] $lang[NOMEDIA] -$endbody - EOT; + if (!$ajax) { + echo "$endbody\n\n"; + } } DebugSQL($db, "$action: $mediaid"); exit; diff --git a/install.php b/install.php new file mode 100644 index 0000000..f68f10c --- /dev/null +++ b/install.php @@ -0,0 +1,422 @@ + 'DVD cover images', + 'images/thumbnails' => 'Cover thumbnails (writable)', + 'imagecache' => 'Resized image cache (writable)', + 'headshots/cast' => 'Actor headshot images', + 'headshots/crew' => 'Crew headshot images', + 'skins' => 'Custom skin templates', + 'import' => 'XML collection upload (writable)', +]; + +$writableDirs = ['images', 'images/thumbnails', 'imagecache', 'import']; + +// PHP extensions +$requiredExt = [ + 'mysqli' => 'MySQL database connection', + 'xml' => 'XML parsing for collection import', + 'mbstring' => 'Multi-byte string handling', +]; +$optionalExt = [ + 'gd' => 'Image resizing and thumbnails', + 'intl' => 'Internationalization support', + 'curl' => 'Remote image fetching', +]; + +// ---- Helper functions ---- + +function renderHeader($pageTitle, $step) { + echo ' + + + + +' . htmlspecialchars($pageTitle) . ' + + + + +
    +
    +

    phpDVDProfiler Installer

    +

    Step ' . ($step + 1) . ' of 4

    '; +} + +function renderFooter() { + echo '
    + +'; +} + +function checkIcon($ok, $warn = false) { + if ($ok) return ''; + if ($warn) return ''; + return ''; +} + +// ---- STEP 0: System Check ---- +if ($step === 0) { + renderHeader($pageTitle, $step); + + $allOk = true; + echo '
    '; + echo '
    System Requirements
    '; + echo ''; + + // PHP version + $phpOk = version_compare(PHP_VERSION, '8.0', '>='); + if (!$phpOk) $allOk = false; + echo ''; + + // Required extensions + foreach ($requiredExt as $ext => $desc) { + $loaded = extension_loaded($ext); + if (!$loaded) $allOk = false; + echo '"; + } + + // Optional extensions + foreach ($optionalExt as $ext => $desc) { + $loaded = extension_loaded($ext); + echo '"; + } + + // Schema file + $schemaOk = is_readable($schemaFile); + if (!$schemaOk) $allOk = false; + echo ''; + + // Config writable + $configDir = dirname($configTarget); + $configWritable = is_writable($configDir); + if (!$configWritable) $allOk = false; + echo ''; + + echo '
    ' . checkIcon($phpOk) . ' PHP Version' . PHP_VERSION . ($phpOk ? '' : ' (8.0+ required)') . '
    ' . checkIcon($loaded) . " $ext$desc
    ' . checkIcon($loaded, true) . " $ext (optional)$desc
    ' . checkIcon($schemaOk) . ' db/schema.sqlDatabase schema file
    ' . checkIcon($configWritable) . ' config/ writableFor generating localsiteconfig.php
    '; + + // Directories + echo '
    '; + echo '
    Directories
    '; + echo ''; + foreach ($requiredDirs as $dir => $desc) { + $path = __DIR__ . '/' . $dir; + $exists = is_dir($path); + $writable = $exists && is_writable($path); + $needsWrite = in_array($dir, $writableDirs); + $ok = $exists && (!$needsWrite || $writable); + echo ''; + } + echo '
    ' . checkIcon($ok, !$exists) . " $dir$desc" . + ($exists && $needsWrite && !$writable ? ' (not writable)' : '') . + (!$exists ? ' (will be created)' : '') . + '
    '; + + // Existing config check + if (file_exists($configTarget)) { + echo '
    Note: config/localsiteconfig.php already exists. It will be overwritten if you continue.
    '; + } + + if ($allOk) { + echo '
    + +
    +
    '; + } else { + echo '
    Please fix the issues above before continuing.
    '; + echo '
    + +
    +
    '; + } + renderFooter(); + exit; +} + +// ---- STEP 1: Database Configuration Form ---- +if ($step === 1) { + // Restore previous values from session + $defaults = [ + 'dbhost' => $_SESSION['inst_dbhost'] ?? 'localhost', + 'dbport' => $_SESSION['inst_dbport'] ?? '', + 'dbname' => $_SESSION['inst_dbname'] ?? 'phpdvdprofiler', + 'dbuser' => $_SESSION['inst_dbuser'] ?? 'root', + 'dbpass' => $_SESSION['inst_dbpass'] ?? '', + 'table_prefix' => $_SESSION['inst_table_prefix'] ?? 'DVDPROFILER_', + 'update_login' => $_SESSION['inst_update_login'] ?? 'admin', + 'update_pass' => $_SESSION['inst_update_pass'] ?? '', + 'sitetitle' => $_SESSION['inst_sitetitle'] ?? 'My DVD Collection', + 'tmdb_api_key' => $_SESSION['inst_tmdb_api_key'] ?? '', + ]; + + renderHeader($pageTitle, $step); + $err = $_SESSION['inst_error'] ?? ''; + unset($_SESSION['inst_error']); + if ($err) echo '
    ' . htmlspecialchars($err) . '
    '; + + echo '
    + +
    +
    Database Connection
    +
    +
    +
    +
    +
    + Will be created if it doesn\'t exist.
    +
    +
    +
    +
    +
    +
    + +
    +
    Site Settings
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + ← Back + +
    +
    '; + renderFooter(); + exit; +} + +// ---- STEP 2: Execute Installation ---- +if ($step === 2) { + $dbhost = trim($_POST['dbhost'] ?? 'localhost'); + $dbport = trim($_POST['dbport'] ?? ''); + $dbname = trim($_POST['dbname'] ?? 'phpdvdprofiler'); + $dbuser = trim($_POST['dbuser'] ?? 'root'); + $dbpass = $_POST['dbpass'] ?? ''; + $table_prefix = trim($_POST['table_prefix'] ?? 'DVDPROFILER_'); + $update_login = trim($_POST['update_login'] ?? 'admin'); + $update_pass = $_POST['update_pass'] ?? ''; + $sitetitle = trim($_POST['sitetitle'] ?? 'My DVD Collection'); + $tmdb_api_key = trim($_POST['tmdb_api_key'] ?? ''); + + // Save to session for back navigation + foreach (['dbhost','dbport','dbname','dbuser','dbpass','table_prefix','update_login','update_pass','sitetitle','tmdb_api_key'] as $k) { + $_SESSION['inst_' . $k] = $$k; + } + + // Validate + if ($dbname === '' || $dbuser === '' || $update_login === '' || $update_pass === '') { + $_SESSION['inst_error'] = 'All fields are required (database name, user, admin login & password).'; + header('Location: install.php?step=1'); + exit; + } + + // Validate table_prefix: only alphanumeric and underscore allowed (prevents SQL injection via schema replacement) + if (!preg_match('/^[a-zA-Z0-9_]+$/', $table_prefix)) { + $_SESSION['inst_error'] = 'Table prefix may only contain letters, numbers, and underscores.'; + header('Location: install.php?step=1'); + exit; + } + + // Connect to MySQL server (without database) + $port = $dbport !== '' ? (int)$dbport : 3306; + $conn = @new mysqli($dbhost, $dbuser, $dbpass, '', $port); + if ($conn->connect_error) { + $_SESSION['inst_error'] = 'Database connection failed: ' . $conn->connect_error; + header('Location: install.php?step=1'); + exit; + } + + $log = []; + + // Create database if not exists + $dbnameSafe = $conn->real_escape_string($dbname); + if ($conn->query("CREATE DATABASE IF NOT EXISTS `$dbnameSafe` CHARACTER SET latin1")) { + $log[] = ['ok', "Database $dbname ready."]; + } else { + $log[] = ['fail', "Could not create database: " . $conn->error]; + } + + // Select database + if (!$conn->select_db($dbname)) { + $_SESSION['inst_error'] = "Cannot select database '$dbname': " . $conn->error; + $conn->close(); + header('Location: install.php?step=1'); + exit; + } + $conn->set_charset('utf8'); + + // Load and execute schema + $schema = file_get_contents($schemaFile); + if ($schema === false) { + $_SESSION['inst_error'] = 'Cannot read db/schema.sql'; + $conn->close(); + header('Location: install.php?step=1'); + exit; + } + + // Replace table prefix if different + if ($table_prefix !== 'DVDPROFILER_') { + $schema = str_replace('DVDPROFILER_', $table_prefix, $schema); + } + + // Parse and execute SQL statements (# is comment) + $statements = []; + $current = ''; + foreach (explode("\n", $schema) as $line) { + $trimmed = trim($line); + if ($trimmed === '' || $trimmed[0] === '#') continue; + $current .= $line . "\n"; + if (substr(rtrim($line), -1) === ';') { + $statements[] = trim($current); + $current = ''; + } + } + + $tablesCreated = 0; + $errors = 0; + foreach ($statements as $sql) { + if ($conn->query($sql)) { + if (stripos($sql, 'CREATE TABLE') !== false) $tablesCreated++; + } else { + $errors++; + $short = substr($sql, 0, 80); + $log[] = ['fail', "SQL Error: " . $conn->error . " ($short...)"]; + } + } + $log[] = ['ok', "$tablesCreated tables created, $errors errors."]; + + $conn->close(); + + // Create directories + foreach ($requiredDirs as $dir => $desc) { + $path = __DIR__ . '/' . $dir; + if (!is_dir($path)) { + if (@mkdir($path, 0775, true)) { + $log[] = ['ok', "Created directory $dir/"]; + } else { + $log[] = ['warn', "Could not create $dir/ - create it manually."]; + } + } + } + + // Generate localsiteconfig.php (use var_export for safe PHP string literals) + $configContent = "config/localsiteconfig.php"]; + } else { + $log[] = ['fail', "Could not write config/localsiteconfig.php - create it manually."]; + } + + // Save log to session for display + $_SESSION['inst_log'] = $log; + $_SESSION['inst_done'] = true; + + header('Location: install.php?step=3'); + exit; +} + +// ---- STEP 3: Results ---- +if ($step === 3) { + $log = $_SESSION['inst_log'] ?? []; + renderHeader($pageTitle, $step); + + echo '
    '; + echo '
    Installation Results
    '; + + $hasErrors = false; + foreach ($log as $entry) { + [$type, $msg] = $entry; + if ($type === 'ok') { + echo '
    ' . $msg . '
    '; + } elseif ($type === 'warn') { + echo '
    ' . $msg . '
    '; + } else { + echo '
    ' . $msg . '
    '; + $hasErrors = true; + } + } + echo '
    '; + + if (!$hasErrors) { + echo '
    '; + echo '
    Installation Complete!
    '; + echo '

    Next steps:

    '; + echo '
      '; + echo '
    1. Export your DVD collection as XML from DVD Profiler
    2. '; + echo '
    3. Upload the XML file and cover images to the server
    4. '; + echo '
    5. Run the collection import
    6. '; + echo '
    7. Delete this file (install.php) for security!
    8. '; + echo '
    '; + echo '
    '; + + echo '
    '; + echo 'Go to phpDVDProfiler →'; + echo 'Import Collection'; + echo '
    '; + } else { + echo '
    '; + echo '← Back to Settings'; + echo 'Start Over'; + echo '
    '; + } + + // Clean up session + unset($_SESSION['inst_log']); + + renderFooter(); + exit; +} diff --git a/JavascriptOnerr.js b/js/JavascriptOnerr.js similarity index 100% rename from JavascriptOnerr.js rename to js/JavascriptOnerr.js diff --git a/SmartUpdater.js.php b/js/SmartUpdater.js.php similarity index 99% rename from SmartUpdater.js.php rename to js/SmartUpdater.js.php index 09e22c3..264e7bb 100644 --- a/SmartUpdater.js.php +++ b/js/SmartUpdater.js.php @@ -1,15 +1,16 @@ /i; +var patt = /]*id="LoginForm"[\s\S]*?<\/form>/i; var rt = '"; CalledFrom='PostAnUpdateTop'; diff --git a/js/custom.css b/js/custom.css new file mode 100644 index 0000000..c1f4f77 --- /dev/null +++ b/js/custom.css @@ -0,0 +1,970 @@ +/* phpDVDProfiler Bootstrap custom styles */ + +/* ===== Layout ===== */ +html, body { + height: 100%; +} + +#dvd-sidebar { + height: calc(100vh - 56px); + overflow-y: auto; + border-right: 1px solid #dee2e6; + padding: 0; + background-color: #f8f9fa; +} + +#main-content { + height: calc(100vh - 56px); + overflow-y: auto; + padding: 15px; +} + +/* ===== Navbar ===== */ +.navbar { + padding: 0.25rem 0.5rem; +} + +.navbar .form-select, +.navbar .form-control { + font-size: 0.85rem; + padding: 0.2rem 0.5rem; +} + +.navbar .btn { + font-size: 0.85rem; + padding: 0.2rem 0.5rem; +} + +/* A-Z letter navigation */ +#letter-nav { + padding: 2px 0; + text-align: center; + background-color: var(--phpdvd-header-bg, #0000A0); +} + +#letter-nav a { + color: #fff; + text-decoration: none; + padding: 1px 3px; + font-size: 0.85rem; + font-weight: bold; +} + +#letter-nav a:hover { + color: #ff0; + text-decoration: underline; +} + +#letter-nav a.active { + color: #ff0; + background-color: rgba(255,255,255,0.2); + border-radius: 3px; +} + +/* Info line (DVD counts) */ +#info-line { + font-size: 0.75rem; + padding: 2px 8px; + background-color: #f0f0f0; + border-bottom: 1px solid #dee2e6; + color: #333; +} + +/* ===== Sidebar DVD list ===== */ +#sidebar-header { + position: sticky; + top: 0; + z-index: 10; + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + font-weight: bold; + font-size: 0.8rem; + padding: 4px 8px; +} + +#sidebar-header a { + color: #fff; + text-decoration: none; +} + +#sidebar-header a:hover { + color: #ff0; +} + +#sidebar-list { + font-size: 0.85rem; +} + +/* DVD list rows */ +.dvd-row { + padding: 3px 8px; + border-bottom: 1px solid #e9ecef; + cursor: pointer; + display: flex; + align-items: center; + gap: 4px; +} + +.dvd-row:hover { + background-color: #e2e6ea; +} + +.dvd-row.active { + background-color: #d0e0f0; + font-weight: bold; +} + +.dvd-row-even { + background-color: #fff; +} + +.dvd-row-odd { + background-color: #f5f7fa; +} + +.dvd-row a { + color: #000; + text-decoration: none; + flex-grow: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.dvd-row a:hover { + color: #0000A0; +} + +.dvd-row .col2, .dvd-row .col3 { + font-size: 0.75rem; + color: #666; + white-space: nowrap; + flex-shrink: 0; +} + +/* Section divider in DVD list */ +.dvd-divider { + padding: 3px 12px; + font-weight: bold; + font-size: 0.8rem; + background-color: #BDD9A7; + color: #000; + border-bottom: 1px solid #aaa; +} + +/* Box set toggle */ +.boxset-toggle { + cursor: pointer; + width: 16px; + height: 16px; + flex-shrink: 0; + display: inline-flex; + align-items: center; + justify-content: center; + font-weight: bold; + font-size: 0.9rem; + color: #666; + border-radius: 3px; + background: #e9ecef; + line-height: 1; +} + +.boxset-toggle:hover { + background: #ced4da; + color: #000; +} + +/* Box set children container */ +.dvd-row[style*="padding-left"] { + border-left: 2px solid #BDD9A7; + font-size: 0.82rem; +} + +/* Pagination in sidebar */ +.sidebar-pagination { + padding: 6px 8px; + background-color: var(--phpdvd-header-bg, #0000A0); + text-align: center; + position: sticky; + bottom: 0; +} + +.sidebar-pagination a { + color: #fff; + padding: 0 6px; + font-size: 0.8rem; + text-decoration: none; +} + +.sidebar-pagination a:hover { + color: #ff0; +} + +.sidebar-pagination .page-current { + color: #ff0; + font-weight: bold; + padding: 0 4px; + font-size: 0.8rem; +} + +.sidebar-pagination .item-count { + color: #ccc; + font-size: 0.75rem; +} + +/* ===== Main content area - DVD detail ===== */ +/* Preserve old class styling for backward compat */ +.detail-title { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + padding: 10px 15px; + font-size: 1.4rem; + border-radius: 4px 4px 0 0; +} + +.detail-title a { + color: #fff; +} + +.detail-body { + background-color: #BDD9A7; + padding: 10px; + border-radius: 0 0 4px 4px; +} + +/* Data rows - label/value pairs */ +.detail-table { + width: 100%; + border-collapse: collapse; +} + +.detail-table td { + padding: 3px 5px; + vertical-align: top; + font-size: 0.9rem; +} + +.detail-table .label-cell { + font-weight: bold; + background-color: #BDD9A7; + color: #0000A0; + white-space: nowrap; + width: 160px; +} + +.detail-table .value-cell { + background-color: #D9E1FF; + color: #000; +} + +.detail-table .separator { + height: 2px; + background-color: #ADA9A9; + padding: 0; +} + +/* Section headers (Audio, Extras, Cast) */ +.detail-section-header { + background-color: #BDD9A7; + color: #0000A0; + font-weight: bold; + font-size: 1rem; + padding: 5px 8px; + margin-top: 10px; + cursor: pointer; + border-radius: 3px; +} + +.detail-section-header:hover { + background-color: #a8cc96; +} + +/* Cover image */ +.cover-image { + max-width: 100%; + height: auto; + border: 2px solid #ADA9A9; + border-radius: 3px; +} + +/* Quick nav links (Audio, Extras, Cast) */ +.quick-nav { + font-size: 0.75rem; + text-align: right; + padding: 4px; +} + +.quick-nav a { + color: #fff; + margin-left: 5px; +} + +/* ===== Backward compat: map old classes to new look ===== */ +/* These keep existing PHP-generated HTML working */ +.f1 { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + font-size: 1.2rem; + text-align: center; + padding: 8px; +} + +.f2 { + background-color: #D9E1FF; + color: #000; + padding: 3px 5px; + font-size: 0.9rem; + vertical-align: top; +} + +.f2np { + background-color: #D9E1FF; + color: #000; + font-size: 0.9rem; +} + +.f3 { + background-color: #BDD9A7; + color: #0000A0; + font-weight: bold; + padding: 3px 5px; + font-size: 0.9rem; + vertical-align: top; +} + +.f3np { + background-color: #BDD9A7; + color: #0000A0; + font-weight: bold; + font-size: 0.9rem; +} + +.f4 { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + font-weight: bold; + padding: 3px 5px; + font-size: 0.9rem; +} + +.f6 { + background-color: #BDD9A7; + color: #0000A0; + font-weight: bold; + font-size: 1rem; + padding: 3px 5px; +} + +.bgl { background-color: #BDD9A7; } +.bgd { background-color: #ADA9A9; } + +.t { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + font-weight: bold; + padding: 3px; + font-size: 0.85rem; +} + +.l, .o { + font-size: 0.85rem; + padding: 2px 3px; + vertical-align: top; +} + +.l { background-color: #D9E1FF; } +.o { background-color: #ADC0D3; } + +.a { + background-color: #BDD9A7; + font-weight: bold; + padding-left: 12px; + font-size: 0.85rem; +} + +.s { font-size: 0.7rem; } +.s1 { font-size: 0.85rem; } + +.line { background-color: #ADA9A9; height: 1px; } +.line2 { background-color: #ADA9A9; height: 2px; } + +.nav2 { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #BDD9A7; + font-weight: bold; + text-align: center; + padding: 2px; + font-size: 0.85rem; +} + +.Divider, .GroupDivider { + font-weight: bold; + padding: 2px 8px; + border-radius: 2px; + margin: 2px 0; +} + +.Divider { + background-image: linear-gradient(to bottom, #4a6fa5, #2a4a80); + color: #fff; +} + +.GroupDivider { + background-image: linear-gradient(to bottom, #6a8fb5, #4a6f95); + color: #fff; +} + +/* ===== Loading spinner ===== */ +.loading-spinner { + text-align: center; + padding: 40px; + color: #666; +} + +.loading-spinner::after { + content: ''; + display: block; + width: 32px; + height: 32px; + margin: 10px auto; + border: 3px solid #ddd; + border-top-color: #0000A0; + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { transform: rotate(360deg); } +} + +/* ===== Mobile responsive ===== */ +@media (max-width: 767.98px) { + #dvd-sidebar { + height: auto; + max-height: 50vh; + border-right: none; + border-bottom: 1px solid #dee2e6; + } + + #main-content { + height: auto; + min-height: 50vh; + } + + .detail-title { + font-size: 1.1rem; + } + + .cover-image { + max-width: 200px; + } + + /* Hide sidebar on mobile, use offcanvas */ + #dvd-sidebar.mobile-hidden { + display: none; + } +} + +@media (min-width: 768px) { + /* On desktop, sidebar toggle button hidden */ + #sidebar-toggle-btn { + display: none !important; + } +} + +/* ===== Offcanvas sidebar for mobile ===== */ +.offcanvas-body #sidebar-list-mobile { + font-size: 0.85rem; +} + +/* ===== Gallery cards ===== */ +.gallery-card { + transition: transform 0.2s; +} + +.gallery-card:hover { + transform: scale(1.03); +} + +.gallery-card img { + border-radius: 3px; +} + +/* ===== Statistics ===== */ +.stats-section { + margin-bottom: 20px; +} + +.stats-section h5 { + background-color: var(--phpdvd-header-bg, #0000A0); + color: #fff; + padding: 8px 12px; + border-radius: 4px; +} + +/* ===== Standalone label/value (DVD detail Bootstrap grid) ===== */ +.label-cell { + font-weight: bold; + background-color: #BDD9A7; + color: #0000A0; + font-size: 0.9rem; + padding: 3px 8px; + border-radius: 2px; +} + +.value-cell { + background-color: #D9E1FF; + color: #000; + font-size: 0.9rem; + padding: 3px 8px; + border-radius: 2px; +} + +/* ===== Statistics container ===== */ +.stats-container { + padding: 10px; +} + +.stats-container .table { + font-size: 0.9rem; +} + +/* ===== Gallery container (AJAX mode) ===== */ +.gallery-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 5px; +} + +/* ===== Dark theme: Base overrides for Bootstrap 5.3.3 dark mode ===== */ +[data-bs-theme="dark"] body { + background-color: #212529 !important; + color: #dee2e6 !important; + --phpdvd-header-bg: #2a5a9a; +} + +[data-bs-theme="dark"] a { color: #6ea8fe; } +[data-bs-theme="dark"] a:hover { color: #9ec5fe; } +[data-bs-theme="dark"] a.n { color: #6ea8fe; } +[data-bs-theme="dark"] a.n:hover { color: #9ec5fe; } +[data-bs-theme="dark"] a.n1 { color: #6ea8fe; } +[data-bs-theme="dark"] a.n1:hover { color: #9ec5fe; } + +/* Old classes with configurable colors - dark overrides */ +[data-bs-theme="dark"] .f1 { + background-color: #2a5a9a; + color: #e0e0e0; + border-radius: 4px; + margin-bottom: 8px; +} + +[data-bs-theme="dark"] .f2, +[data-bs-theme="dark"] .f2np { + background-color: #2b3035; + color: #dee2e6; + border-bottom: 1px solid #3a3f44; + padding: 4px 8px; +} + +[data-bs-theme="dark"] .f3, +[data-bs-theme="dark"] .f3np { + background-color: #1a3340; + color: #82c8c8; + border-bottom: 1px solid #3a3f44; + padding: 4px 8px; +} + +[data-bs-theme="dark"] .f4 { + background-color: #2a5a9a; + color: #e0e0e0; +} + +[data-bs-theme="dark"] .f6 { + background-color: #1a3340; + color: #82c8c8; +} + +[data-bs-theme="dark"] .bgl { + background-color: transparent; + border-collapse: collapse; +} + +[data-bs-theme="dark"] .bgd { + background-color: #3a3f44; +} + +[data-bs-theme="dark"] .t { + background-color: #2a5a9a; + color: #e0e0e0; +} + +[data-bs-theme="dark"] .l { background-color: #2b3035; color: #dee2e6; } +[data-bs-theme="dark"] .o { background-color: #343a40; color: #dee2e6; } + +[data-bs-theme="dark"] .a { + background-color: #1a3340; + color: #82c8c8; +} + +[data-bs-theme="dark"] .u { background-color: #2b3035; color: #dee2e6; } +[data-bs-theme="dark"] .v { background-color: #343a40; color: #dee2e6; } +[data-bs-theme="dark"] .x { background-color: #2b3035; color: #dee2e6; } +[data-bs-theme="dark"] .y { background-color: #343a40; color: #dee2e6; } +[data-bs-theme="dark"] .z1 { background-color: #2b3035; color: #dee2e6; } +[data-bs-theme="dark"] .z2 { background-color: #1a3340; color: #82c8c8; } +[data-bs-theme="dark"] .f5, [data-bs-theme="dark"] .f5b { background-color: #1a3340; color: #adb5bd; } +[data-bs-theme="dark"] .f7 { background-color: #2b3035; color: #dee2e6; } +[data-bs-theme="dark"] .f8 { background-color: #1a3340; } +[data-bs-theme="dark"] .f9 { background-color: #2b3035; } +[data-bs-theme="dark"] .hdlogo, [data-bs-theme="dark"] .fthumb { background-color: #212529; } +[data-bs-theme="dark"] .nav { background-color: #2a5a9a; color: #adb5bd; } +[data-bs-theme="dark"] .s { color: #8b929a; } +[data-bs-theme="dark"] .s1 { color: #adb5bd; } +[data-bs-theme="dark"] .input { color: #dee2e6; } +[data-bs-theme="dark"] img.b { border-color: #3a3f44; } +[data-bs-theme="dark"] .URLref { color: #6ea8fe; } + +[data-bs-theme="dark"] .line, +[data-bs-theme="dark"] .line2 { + background-color: #3a3f44; +} + +[data-bs-theme="dark"] .nav2 { + background-color: #2a5a9a; + color: #82c8c8; +} + +[data-bs-theme="dark"] .label-cell { + background-color: #1a3340; + color: #82c8c8; +} + +[data-bs-theme="dark"] .value-cell { + background-color: #2b3035; + color: #dee2e6; +} + +/* Auto-style tables inside #main-content like Bootstrap tables */ +[data-bs-theme="dark"] #main-content table { + width: 100%; + border-collapse: collapse; + color: #dee2e6; + font-size: 0.9rem; +} + +[data-bs-theme="dark"] #main-content table td, +[data-bs-theme="dark"] #main-content table th { + padding: 4px 8px; + border-bottom: 1px solid #3a3f44; + vertical-align: middle; +} + +[data-bs-theme="dark"] #main-content table th { + background-color: #2a5a9a; + color: #e0e0e0; + font-weight: 600; +} + +[data-bs-theme="dark"] #main-content table tr:hover td { + background-color: rgba(255,255,255,0.05); +} + +/* Fix
    tags inside AJAX content */ +#main-content center { + display: block; + text-align: center; + max-width: 90%; + margin: 0 auto 12px; +} + +/* Make old-style table forms look better in dark theme */ +[data-bs-theme="dark"] #main-content input[type="radio"] { + accent-color: #0d6efd; + margin: 0 4px; +} + +[data-bs-theme="dark"] #main-content form { + margin: 0; +} + +[data-bs-theme="dark"] .f1sm { + background-color: #2a5a9a; + color: #e0e0e0; + font-size: 0.85rem; + padding: 4px 8px; +} + +/* Old table links inherit dark theme colors */ +[data-bs-theme="dark"] #main-content table a { + color: #6ea8fe; +} + +[data-bs-theme="dark"] #main-content table a:hover { + color: #9ec5fe; +} + +/* Stats-specific: decade/year selector tables */ +[data-bs-theme="dark"] #main-content table[border] { + border: 1px solid #3a3f44 !important; + border-radius: 4px; + overflow: hidden; + margin-bottom: 8px; +} + +[data-bs-theme="dark"] #main-content table[border] td { + border: 1px solid #3a3f44; + padding: 4px; +} + +[data-bs-theme="dark"] #main-content table[border] a { + cursor: pointer; + color: #6ea8fe; +} + +/* JPGraph images center nicely */ +[data-bs-theme="dark"] #main-content center img[name="jpgraph"], +[data-bs-theme="dark"] #main-content img[name="jpgraph"] { + max-width: 100%; + height: auto; + border-radius: 4px; + margin: 8px 0; +} + +/* Gallery in dark mode */ +[data-bs-theme="dark"] .gallery { + color: #dee2e6; +} + +[data-bs-theme="dark"] .gallery img { + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0,0,0,0.4); +} + +/* ws.php watched statistics in dark mode */ +[data-bs-theme="dark"] #main-content center > table { + border-radius: 4px; + overflow: hidden; +} + +/* ===== Dark theme: Sidebar & Layout ===== */ +[data-bs-theme="dark"] #dvd-sidebar { + background-color: #1a1d21; + border-right-color: #3a3f44; +} + +[data-bs-theme="dark"] #info-line { + background-color: #2b3035; + border-bottom-color: #3a3f44; + color: #adb5bd; +} + +[data-bs-theme="dark"] .dvd-row { + border-bottom-color: #3a3f44; +} + +[data-bs-theme="dark"] .dvd-row:hover { + background-color: #2c3034; +} + +[data-bs-theme="dark"] .dvd-row.active { + background-color: #2a5080; +} + +[data-bs-theme="dark"] .dvd-row-even { + background-color: #212529; +} + +[data-bs-theme="dark"] .dvd-row-odd { + background-color: #1a1d21; +} + +[data-bs-theme="dark"] .dvd-row a { + color: #dee2e6; +} + +[data-bs-theme="dark"] .dvd-row a:hover { + color: #6ea8fe; +} + +[data-bs-theme="dark"] .dvd-row .col2, +[data-bs-theme="dark"] .dvd-row .col3 { + color: #8b929a; +} + +[data-bs-theme="dark"] .boxset-toggle { + background: #3a3f44; + color: #adb5bd; +} + +[data-bs-theme="dark"] .boxset-toggle:hover { + background: #4a5056; + color: #fff; +} + +[data-bs-theme="dark"] .dvd-row[style*="padding-left"] { + border-left-color: #1a3340; +} + +[data-bs-theme="dark"] .dvd-divider { + background-color: #1a3340; + color: #82c8c8; + border-bottom-color: #3a3f44; +} + +/* Dark theme: Detail view */ +[data-bs-theme="dark"] .detail-body { + background-color: #1a1d21; +} + +[data-bs-theme="dark"] .detail-table .label-cell { + background-color: #1a3340; + color: #82c8c8; +} + +[data-bs-theme="dark"] .detail-table .value-cell { + background-color: #2b3035; + color: #dee2e6; +} + +[data-bs-theme="dark"] .detail-table .separator { + background-color: #3a3f44; +} + +[data-bs-theme="dark"] .detail-section-header { + background-color: #1a3340; + color: #82c8c8; +} + +[data-bs-theme="dark"] .detail-section-header:hover { + background-color: #24404f; +} + +[data-bs-theme="dark"] .cover-image { + border-color: #3a3f44; +} + +[data-bs-theme="dark"] .detail-body hr { + border-color: #3a3f44; + opacity: 0.5; +} + +/* Dark theme: Divider classes */ +[data-bs-theme="dark"] .Divider { + background-image: linear-gradient(to bottom, #2a5a9a, #1a4a7a); +} + +[data-bs-theme="dark"] .GroupDivider { + background-image: linear-gradient(to bottom, #3a6aaa, #2a5080); +} + +/* Dark theme: loading spinner */ +[data-bs-theme="dark"] .loading-spinner { + color: #adb5bd; +} + +[data-bs-theme="dark"] .loading-spinner::after { + border-color: #3a3f44; + border-top-color: #6ea8fe; +} + +/* ===== Popup (actor/crew/studio filmography) ===== */ +.popup-header { + background-color: #f0f0f0; + border-radius: 4px 4px 0 0; +} + +.popup-header img { + border-radius: 4px; +} + +.popup-entry { + transition: background-color 0.15s; +} + +.popup-entry:hover { + background-color: rgba(0,0,0,0.03); +} + +.popup-entry img { + border-radius: 3px; + border: 1px solid #dee2e6; +} + +.popup-entry-title a { + color: #0000A0; + text-decoration: none; +} + +.popup-entry-title a:hover { + text-decoration: underline; +} + +.popup-entry-table { + font-size: 0.85rem; + border-collapse: collapse; +} + +.popup-entry-table td { + padding: 1px 4px; + vertical-align: top; +} + +/* Popup divider classes (from OutputRoles) */ +.DividerPopup { + background-image: linear-gradient(to bottom, #4a6fa5, #2a4a80); + color: #fff; + font-weight: bold; + padding: 2px 8px; + border-radius: 2px; +} + +.GroupDividerPopup { + background-image: linear-gradient(to bottom, #6a8fb5, #4a6f95); + color: #fff; + font-weight: bold; + padding: 2px 8px; + border-radius: 2px; +} + +/* Dark theme: Popup */ +[data-bs-theme="dark"] .popup-header { + background-color: #2b3035; + border-color: #3a3f44; +} + +[data-bs-theme="dark"] .popup-entry:hover { + background-color: rgba(255,255,255,0.05); +} + +[data-bs-theme="dark"] .popup-entry img { + border-color: #3a3f44; +} + +[data-bs-theme="dark"] .popup-entry-title a { + color: #6ea8fe; +} + +[data-bs-theme="dark"] .popup-entry-table td { + border-bottom: none; +} + +[data-bs-theme="dark"] .DividerPopup { + background-image: linear-gradient(to bottom, #2a5a9a, #1a4a7a); +} + +[data-bs-theme="dark"] .GroupDividerPopup { + background-image: linear-gradient(to bottom, #3a6aaa, #2a5080); +} + +/* ===== Print styles ===== */ +@media print { + .navbar, #dvd-sidebar, .sidebar-pagination, #letter-nav, #info-line { + display: none !important; + } + + #main-content { + height: auto !important; + overflow: visible !important; + } +} diff --git a/format.css.php b/js/format.css.php similarity index 98% rename from format.css.php rename to js/format.css.php index 893312c..8f6a6d4 100644 --- a/format.css.php +++ b/js/format.css.php @@ -1,15 +1,16 @@ Loading...
    '; + + var url = baseUrl + '?action=menu&ajax=1' + + '&collection=' + encodeURIComponent(currentCollection) + + '&sort=' + encodeURIComponent(currentSort) + + '&order=' + encodeURIComponent(currentOrder) + + '&searchby=' + encodeURIComponent(currentSearchBy) + + '&searchtext=' + encodeURIComponent(currentSearchText); + + if (startrow !== undefined) url += '&startrow=' + startrow; + if (letter !== undefined) url += '&letter=' + encodeURIComponent(letter); + + fetchHtml(url).then(function(html) { + sidebar.innerHTML = html; + attachSidebarClicks(); + }).catch(function(err) { + sidebar.innerHTML = '
    Error loading list: ' + err.message + '
    '; + }); + } + + function attachSidebarClicks() { + var links = document.querySelectorAll('#sidebar-content a[data-mediaid]'); + links.forEach(function(link) { + link.addEventListener('click', function(e) { + e.preventDefault(); + var mediaid = this.getAttribute('data-mediaid'); + loadContent(mediaid); + + // Update active state + document.querySelectorAll('#sidebar-content .dvd-row').forEach(function(row) { + row.classList.remove('active'); + }); + this.closest('.dvd-row').classList.add('active'); + + // On mobile, close offcanvas + var offcanvas = bootstrap.Offcanvas.getInstance(document.getElementById('sidebarOffcanvas')); + if (offcanvas) offcanvas.hide(); + }); + }); + + // Box set toggle buttons + var toggles = document.querySelectorAll('#sidebar-content .boxset-toggle'); + toggles.forEach(function(btn) { + btn.addEventListener('click', function(e) { + e.stopPropagation(); + var target = this.getAttribute('data-target'); + var el = document.getElementById(target); + if (el) { + if (el.style.display === 'none') { + el.style.display = ''; + this.textContent = '−'; + } else { + el.style.display = 'none'; + this.textContent = '+'; + } + } + }); + }); + + // Sidebar pagination links + var pagLinks = document.querySelectorAll('#sidebar-content a[data-startrow]'); + pagLinks.forEach(function(link) { + link.addEventListener('click', function(e) { + e.preventDefault(); + loadSidebar(this.getAttribute('data-startrow')); + }); + }); + + // Sort header clicks + var sortLinks = document.querySelectorAll('#sidebar-content a[data-sort]'); + sortLinks.forEach(function(link) { + link.addEventListener('click', function(e) { + e.preventDefault(); + currentSort = this.getAttribute('data-sort'); + currentOrder = this.getAttribute('data-order') || 'asc'; + loadSidebar(); + }); + }); + } + + // ===== Main content ===== + function loadContent(mediaid) { + var main = document.getElementById('main-content'); + if (!main) return; + + currentMediaId = mediaid; + main.innerHTML = '
    Loading...
    '; + + var url; + if (mediaid === 'Statistics' || mediaid === 'WatchedStatistics') { + url = baseUrl + '?action=show&mediaid=' + encodeURIComponent(mediaid) + '&ajax=1'; + } else if (mediaid === 'Chooser') { + url = 'Chooser.php?ajax=1'; + } else if (mediaid.indexOf('Gallery') === 0) { + url = baseUrl + '?action=show&mediaid=' + encodeURIComponent(mediaid) + '&ajax=1' + + '&ct=' + encodeURIComponent(currentCollection) + + '&sort=' + encodeURIComponent(currentSort) + + '&order=' + encodeURIComponent(currentOrder) + + '&searchby=' + encodeURIComponent(currentSearchBy) + + '&searchtext=' + encodeURIComponent(currentSearchText); + } else { + url = baseUrl + '?action=show&mediaid=' + encodeURIComponent(mediaid) + '&ajax=1'; + } + + fetchHtml(url).then(function(html) { + main.innerHTML = html; + runInlineScripts(main); + }).catch(function(err) { + main.innerHTML = '
    Error loading content: ' + err.message + '
    '; + }); + } + + function runInlineScripts(container) { + var scripts = container.querySelectorAll('script'); + scripts.forEach(function(oldScript) { + var newScript = document.createElement('script'); + if (oldScript.src) { + newScript.src = oldScript.src; + } else { + newScript.textContent = oldScript.textContent; + } + oldScript.parentNode.replaceChild(newScript, oldScript); + }); + } + + // ===== Search ===== + function setupSearch() { + var form = document.getElementById('search-form'); + if (!form) return; + + form.addEventListener('submit', function(e) { + e.preventDefault(); + var searchby = form.querySelector('[name=searchby]').value; + var searchtext = ''; + + // Get the right input value based on search type + var textbox = document.getElementById('search-textbox'); + var combo = document.getElementById('search-combo-' + searchby); + + if (combo && combo.style.display !== 'none') { + searchtext = combo.value; + } else if (textbox) { + searchtext = textbox.value; + } + + currentSearchBy = searchby; + currentSearchText = searchtext; + loadSidebar(); + }); + + // Search type change - show/hide combo boxes + var searchSelect = form.querySelector('[name=searchby]'); + if (searchSelect) { + searchSelect.addEventListener('change', function() { + switchSearchField(this.value); + }); + } + + // Clear button + var clearBtn = document.getElementById('search-clear'); + if (clearBtn) { + clearBtn.addEventListener('click', function() { + currentSearchBy = ''; + currentSearchText = ''; + var textbox = document.getElementById('search-textbox'); + if (textbox) textbox.value = ''; + // Hide all combos + document.querySelectorAll('.search-combo').forEach(function(c) { + c.style.display = 'none'; + }); + var textbox = document.getElementById('search-textbox'); + if (textbox) textbox.style.display = ''; + loadSidebar(); + }); + } + } + + function switchSearchField(searchby) { + var textbox = document.getElementById('search-textbox'); + var combos = ['genre', 'rating', 'coo', 'locale', 'purchase', 'mediatype', 'tag', 'lock', 'medialanguages', 'mediasubtitles']; + + // Hide all combos first + combos.forEach(function(name) { + var el = document.getElementById('search-combo-' + name); + if (el) el.style.display = 'none'; + }); + + // Show textbox by default + if (textbox) textbox.style.display = ''; + + // If this search type has a combo, show it and hide textbox + var combo = document.getElementById('search-combo-' + searchby); + if (combo) { + combo.style.display = ''; + if (textbox) textbox.style.display = 'none'; + } + } + + // ===== Collection change ===== + function setupCollectionChange() { + var select = document.getElementById('collection-select'); + if (!select) return; + + select.addEventListener('change', function() { + currentCollection = this.value; + currentSearchBy = ''; + currentSearchText = ''; + loadSidebar(); + }); + } + + // ===== Letter navigation ===== + var currentLetter = ''; + + function setupLetterNav() { + document.querySelectorAll('#letter-nav a').forEach(function(link) { + link.addEventListener('click', function(e) { + e.preventDefault(); + var letter = this.getAttribute('data-letter'); + // Toggle: click same letter again to clear filter + if (currentLetter === letter) { + currentLetter = ''; + } else { + currentLetter = letter; + } + // Update active highlight + document.querySelectorAll('#letter-nav a').forEach(function(a) { + a.classList.remove('active'); + }); + if (currentLetter) { + this.classList.add('active'); + } + loadSidebar(0, currentLetter || undefined); + }); + }); + } + + // ===== Sort headers ===== + function setupSortHeaders() { + // Handled via attachSidebarClicks since sort headers are inside sidebar content + } + + // ===== Cookie helpers ===== + function setCookie(name, value, days) { + var expires = ''; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = '; expires=' + date.toUTCString(); + } + document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/'; + } + + // ===== Tools menu handlers ===== + window.loadStatistics = function() { + loadContent('Statistics'); + }; + + window.loadGallery = function() { + loadContent('Gallery'); + }; + + window.loadBackGallery = function() { + loadContent('GalleryB'); + }; + + window.loadChooser = function() { + loadContent('Chooser'); + }; + + window.loadWatched = function() { + loadContent('WatchedStatistics'); + }; + + // ===== Popup (actor/crew/studio filmography) ===== + window.loadPopup = function(acttype, fullname, sortby) { + var main = document.getElementById('main-content'); + if (!main) return; + main.innerHTML = '
    Loading...
    '; + var url = 'popup.php?acttype=' + encodeURIComponent(acttype) + + '&fullname=' + encodeURIComponent(fullname) + + (sortby ? '&sortby=' + encodeURIComponent(sortby) : '') + + '&ajax=1'; + fetchHtml(url).then(function(html) { + main.innerHTML = html; + runInlineScripts(main); + }).catch(function(err) { + main.innerHTML = '
    Error: ' + err.message + '
    '; + }); + }; + + // ===== Language change ===== + window.changeLanguage = function(locale) { + setCookie('locale', locale, 3650); + window.location.reload(); + }; + + // ===== Expose for PHP-generated onclick handlers ===== + window.loadDvdContent = loadContent; + window.loadDvdSidebar = loadSidebar; + + // ===== SwitchOutRows (backward compat for cast/crew dividers) ===== + window.SwitchOutRows = function(theitems, obj) { + var item = document.getElementById(theitems); + if (item) { + if (item.style.display === 'none') { + item.style.display = ''; + obj.src = 'gfx/minus.gif'; + } else { + item.style.display = 'none'; + obj.src = 'gfx/plus.gif'; + } + } + }; + + // ===== Box set toggle (backward compat) ===== + window.dh = function(theitems, obj) { + var item = document.getElementById(theitems); + if (item) { + if (item.style.display === 'none') { + item.style.display = ''; + obj.src = 'gfx/minus.gif'; + } else { + item.style.display = 'none'; + obj.src = 'gfx/plus.gif'; + } + } + }; + + // ===== Image modal ===== + function setupImageModal() { + document.addEventListener('click', function(e) { + var link = e.target.closest('a[href*="?img="], a[href*="&img="]'); + if (!link) return; + e.preventDefault(); + var href = link.getAttribute('href'); + // Extract img parameter + var match = href.match(/[?&]img=([^&]*)/); + if (!match) return; + var imgSrc = decodeURIComponent(match[1]); + // Get title from the img inside the link, or from the link title + var title = link.getAttribute('title') || ''; + if (!title) { + var img = link.querySelector('img'); + if (img) title = img.getAttribute('title') || img.getAttribute('alt') || ''; + } + var modalImg = document.getElementById('imageModalImg'); + var modalTitle = document.getElementById('imageModalTitle'); + if (modalImg && modalTitle) { + modalImg.src = imgSrc; + modalImg.alt = title; + modalTitle.textContent = title; + var modal = new bootstrap.Modal(document.getElementById('imageModal')); + modal.show(); + } + }); + } + + // ===== Start ===== + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', function() { init(); setupImageModal(); }); + } else { + init(); + setupImageModal(); + } + +})(); diff --git a/mom.js b/js/mom.js similarity index 100% rename from mom.js rename to js/mom.js diff --git a/momItems.js.php b/js/momItems.js.php similarity index 85% rename from momItems.js.php rename to js/momItems.js.php index 3532575..74f0f1a 100644 --- a/momItems.js.php +++ b/js/momItems.js.php @@ -1,25 +1,26 @@ -/* Vision Slidemen 1.0 */ +/* Vision Slidemen� 1.0 */ /* Copyright (C) 2002 Matthias Mohr */ /* E-mail: webmaster@mamo-net.de */ /* Homepage: http://www.mamo-net.de */ /* ------------------------------------------- */ -/* Sie drfen dieses Script frei benutzen wenn */ +/* Sie d�rfen dieses Script frei benutzen wenn */ /* dieser Corpright Hinweis bestehen bleibt. */ + +EOT; + if (!$ajax) { + echo<< + +
    +EOT; + } + echo<<{$lang['PREFS']['USERPREFS']} +
    +
    + + +EOT; + + if ($allowactorsort) { + renderPreferenceDropdown( + 'actorsort', + $actorsort, + $siteactorsort, + array( + '0' => $lang['PREFS']['ACTORSORT'][0], + '1' => $lang['PREFS']['ACTORSORT'][1], + '2' => $lang['PREFS']['ACTORSORT'][2], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['ACTORSORT'][$siteactorsort] . ']', + ), + $lang['PREFS']['ACTORSORT']['NAME'], + $lang['PREFS']['ACTORSORT'], + $ddstyle + ); + } + + /* Column options shared by secondcol and thirdcol */ + $columnOptionValues = array('released','productionyear','purchasedate','collectionnumber','runningtime','rating','genres','reviews','director'); + + if ($allowsecondcol) { + $opts = array(); + foreach ($columnOptionValues as $v) { + $opts[$v] = $lang['PREFS']['COLUMNS'][$v]; + } + $opts['sitedefault'] = $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['COLUMNS'][$sitesecondcol] . ']'; + $opts['none'] = $lang['PREFS']['COLUMNS']['none']; + + renderPreferenceDropdown( + 'secondcol', + $secondcol, + $sitesecondcol, + $opts, + $lang['PREFS']['COLUMNS']['SECONDNAME'], + $lang['PREFS']['COLUMNS'], + $ddstyle + ); + } + + if ($allowthirdcol) { + $opts = array(); + foreach ($columnOptionValues as $v) { + $opts[$v] = $lang['PREFS']['COLUMNS'][$v]; + } + $opts['sitedefault'] = $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['COLUMNS'][$sitethirdcol] . ']'; + $opts['none'] = $lang['PREFS']['COLUMNS']['none']; + + renderPreferenceDropdown( + 'thirdcol', + $thirdcol, + $sitethirdcol, + $opts, + $lang['PREFS']['COLUMNS']['THIRDNAME'], + $lang['PREFS']['COLUMNS'], + $ddstyle + ); + } + + if ($allowdefaultsorttype) { + $z = $$sitedefaultsorttype; + $displaysitedefaultsorttype = $lang['PREFS']['DEFAULTSORTTYPE'][$sitedefaultsorttype].$lang['PREFS']['COLUMNS'][$z]; + + /* For the "current value" display when cookie is set, we need + custom logic because the display combines two lang lookups. + We handle this by overriding $a after renderPreferenceDropdown + would compute it -- but actually the simplest approach that + keeps identical output is to handle the current-value text + inline, since renderPreferenceDropdown uses $langSection[$currentValue]. */ + + // Build a synthetic langSection that maps the value to its composite display string + $dstLangSection = array( + 'firstcol' => $lang['PREFS']['DEFAULTSORTTYPE']['firstcol'].$lang['PREFS']['COLUMNS'][$firstcol], + 'secondcol' => $lang['PREFS']['DEFAULTSORTTYPE']['secondcol'].$lang['PREFS']['COLUMNS'][$secondcol], + 'thirdcol' => $lang['PREFS']['DEFAULTSORTTYPE']['thirdcol'].$lang['PREFS']['COLUMNS'][$thirdcol], + ); + + // Current value display: when cookie is set, original code did: + // $z = $$defaultsorttype; $a = DEFAULTSORTTYPE[$defaultsorttype].COLUMNS[$z] + // That equals dstLangSection[$defaultsorttype]. + // For sitedefault display, original used $displaysitedefaultsorttype. + // We need a custom siteDefault display. In our helper, siteDefault display + // looks up $langSection[$siteDefault], so we put the right value into a + // synthetic section. + $dstLangSection[$sitedefaultsorttype] = $displaysitedefaultsorttype; + + renderPreferenceDropdown( + 'defaultsorttype', + $defaultsorttype, + $sitedefaultsorttype, + array( + 'firstcol' => $lang['PREFS']['DEFAULTSORTTYPE']['firstcol'].$lang['PREFS']['COLUMNS'][$firstcol], + 'secondcol' => $lang['PREFS']['DEFAULTSORTTYPE']['secondcol'].$lang['PREFS']['COLUMNS'][$secondcol], + 'thirdcol' => $lang['PREFS']['DEFAULTSORTTYPE']['thirdcol'].$lang['PREFS']['COLUMNS'][$thirdcol], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $displaysitedefaultsorttype . ']', + ), + $lang['PREFS']['DEFAULTSORTTYPE']['NAME'], + $dstLangSection, + $ddstyle + ); + } + + if ($allowtitledesc) { + renderPreferenceDropdown( + 'titledesc', + $titledesc, + $sitetitledesc, + array( + '0' => $lang['PREFS']['TITLEDESC'][0], + '1' => $lang['PREFS']['TITLEDESC'][1], + '2' => $lang['PREFS']['TITLEDESC'][2], + '3' => $lang['PREFS']['TITLEDESC'][3], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['TITLEDESC'][$sitetitledesc] . ']', + ), + $lang['PREFS']['TITLEDESC']['NAME'], + $lang['PREFS']['TITLEDESC'], + $ddstyle + ); + } + + if ($allowlocale) { + renderPreferenceDropdown( + 'locale', + $locale, + $sitelocale, + array( + 'en' => $lang['PREFS']['LOCALE']['en'], + 'de' => $lang['PREFS']['LOCALE']['de'], + 'no' => $lang['PREFS']['LOCALE']['no'], + 'fr' => $lang['PREFS']['LOCALE']['fr'], + 'nl' => $lang['PREFS']['LOCALE']['nl'], + 'sv' => $lang['PREFS']['LOCALE']['sv'], + 'dk' => $lang['PREFS']['LOCALE']['dk'], + 'fi' => $lang['PREFS']['LOCALE']['fi'], + 'ru' => $lang['PREFS']['LOCALE']['ru'], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['LOCALE'][$sitelocale] . ']', + ), + $lang['PREFS']['LOCALE']['NAME'], + $lang['PREFS']['LOCALE'], + $ddstyle + ); + } + + if ($allowstickyboxsets) { + renderPreferenceDropdown( + 'stickyboxsets', + $stickyboxsets, + $sitestickyboxsets, + array( + '1' => $lang['PREFS']['STICKYBOXSETS'][1], + '0' => $lang['PREFS']['STICKYBOXSETS'][0], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['STICKYBOXSETS'][$sitestickyboxsets] . ']', + ), + $lang['PREFS']['STICKYBOXSETS']['NAME'], + $lang['PREFS']['STICKYBOXSETS'], + $ddstyle + ); + } + + if ($allowpopupimages) { + renderPreferenceDropdown( + 'popupimages', + $popupimages, + $sitepopupimages, + array( + '1' => $lang['PREFS']['POPUPIMAGES'][1], + '0' => $lang['PREFS']['POPUPIMAGES'][0], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['POPUPIMAGES'][$sitepopupimages] . ']', + ), + $lang['PREFS']['POPUPIMAGES']['NAME'], + $lang['PREFS']['POPUPIMAGES'], + $ddstyle + ); + } + + if ($allowtitlesperpage) { + $siteTitlesPerPage = isset($siteTitlesPerPage) ? (int)$siteTitlesPerPage : 0; + + // Build a langSection that maps integer keys to their display labels, + // matching the original fallback logic for current-value display. + $tppLangSection = array(); + foreach (array(0, 25, 50, 100, 200) as $v) { + $tppLangSection[$v] = isset($lang['PREFS']['TITLESPERPAGE'][$v]) ? $lang['PREFS']['TITLESPERPAGE'][$v] : "$v per page"; + } + // For current value display when cookie is set, original used $TitlesPerPage + $tppLangSection[(int)$TitlesPerPage] = isset($lang['PREFS']['TITLESPERPAGE'][(int)$TitlesPerPage]) + ? $lang['PREFS']['TITLESPERPAGE'][(int)$TitlesPerPage] + : "$TitlesPerPage per page"; + // For site default display + $sitedefval = isset($lang['PREFS']['TITLESPERPAGE'][$siteTitlesPerPage]) ? $lang['PREFS']['TITLESPERPAGE'][$siteTitlesPerPage] : "$siteTitlesPerPage"; + $tppLangSection[$siteTitlesPerPage] = $sitedefval; + + renderPreferenceDropdown( + 'titlesperpage', + (int)$TitlesPerPage, + $siteTitlesPerPage, + array( + '0' => $lang['PREFS']['TITLESPERPAGE'][0], + '25' => $lang['PREFS']['TITLESPERPAGE'][25], + '50' => $lang['PREFS']['TITLESPERPAGE'][50], + '100' => $lang['PREFS']['TITLESPERPAGE'][100], + '200' => $lang['PREFS']['TITLESPERPAGE'][200], + 'sitedefault' => $lang['PREFS']['SITEDEFAULT'] . ' [' . $lang['PREFS']['TITLESPERPAGE'][$siteTitlesPerPage] . ']', + ), + $lang['PREFS']['TITLESPERPAGE']['NAME'], + $tppLangSection, + $ddstyle + ); + } + + if ($allowskins) { + $n1 = $n2 = ''; + if ($skinfile == 'internal') + $n1 = 'selected'; + $ss = $siteskinfile; + if ($siteskinfile == 'internal') + $ss = $lang['PREFS']['SKINS']['INTERNAL']; + $ss = preg_replace('/\.htm[l]$/i', '', $ss); + if (isset($_COOKIE['skinfile'])) { + if ($skinfile == 'internal') + $a = $lang['PREFS']['SKINS']['INTERNAL']; + else + $a = preg_replace('/\.htm[l]$/i', '', $skinfile); + } + else { + $a = $lang['PREFS']['SITEDEFAULT']."
    [$ss]"; + $n2 = 'selected'; + } + echo << +EOT; + unset($TheSkins); + } + + if ($allowwidths) { + echo<< +EOT; + } + + unset($mapping); + echo '
    {$lang['PREFS']['PREFERENCE']}{$lang['PREFS']['CURRENTVAL']}{$lang['PREFS']['SELECTIONS']}
    {$lang['PREFS']['SKINS']['NAME']}$a +
    +
    {$lang['PREFS']['WIDTHS']['NAME']}
    '; + if (!$ajax) { + echo '\n"; + echo "
    \n"; // close container + echo renderPrefPageFooter(); + } diff --git a/wrong_srp.php b/pages/wrong_srp.php similarity index 98% rename from wrong_srp.php rename to pages/wrong_srp.php index 543ab54..b29a1e6 100644 --- a/wrong_srp.php +++ b/pages/wrong_srp.php @@ -1,4 +1,5 @@ '; + echo "
    "; + goto ws_content_start; +} header('Content-Type: text/html; charset="windows-1252";'); echo<< @@ -361,13 +368,13 @@ // I've created a landing page on bws.com for the about. it links back to the pages on dvdaholic. $vver = preg_replace('/\./', '_', $ws_version); -$vlink = "http://www.bws.com/phpdvdprofiler/ws_version_$vver.html"; +$vlink = "https://www.bws.com/phpdvdprofiler/ws_version_$vver.html"; #$vlink = "http://www.dvdaholic.me.uk/phpdvdprofiler/ws_version_$vver.html"; #$vlink = "http://didi/dvd/ws_version_$vver.html"; echo<< EOT; +ws_content_start: watched(); echo<<sql_fetch_array($sql); -$cnt = $row['count']; -$rt = $row['runningtime']; +if ($row) { + $cnt = $row['count']; + $rt = $row['runningtime']; +} $avg = 0; if ($cnt <> 0) $avg = intval($rt / $cnt); @@ -482,9 +492,11 @@
    {$lang['WS']['HEADING']}
    - - EOT; +if (empty($ajax)) { + echo ''; + echo ''; +} $db->sql_freeresult($sql); @@ -496,7 +508,7 @@ function get_watchers() { global $uclass, $ws_watcher, $usejpgraph, $dolast, $domost, $dobest, $doworst, $ignore_list, $WS_SELF, $ws_wb, $ColScheme; $uline = 0; - $cmd = "SELECT u.uid,firstname,lastname FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e, $DVD_USERS_TABLE u WHERE e.id=d.id AND e.uid=u.uid AND $ws_wb"; + $cmd = "SELECT ANY_VALUE(u.uid) AS uid,firstname,lastname FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e, $DVD_USERS_TABLE u WHERE e.id=d.id AND e.uid=u.uid AND $ws_wb"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; @@ -539,8 +551,8 @@ function get_watchers() { $rt = 0; $cnt = 0; $row = $db->sql_fetch_array($sql1); - $tcnt = $row['count']; - $trt = $row['runningtime']; + $tcnt = $row ? $row['count'] : 0; + $trt = $row ? $row['runningtime'] : 0; $tavg = 0; if ($tcnt <> 0) $tavg = intval($trt / $tcnt); @@ -598,7 +610,7 @@ function get_watchers() { $mouse .= "')\""; } $mouse .= ">"; - $mouse .= $firstname . " ". HideName($lastname) . ""; + $mouse .= $firstname . " ". hideName($lastname) . ""; echo<< @@ -777,7 +789,7 @@ function get_months($uid, $firstname, $lastname) { for ($mth=$maxmonths;$mth>0;$mth--) { $yearmonth = sprintf('%04d-%02d', $year, $mth); - $cmd = "SELECT SUM(runningtime) AS runningtime, SUM(1) AS count, e.id FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e "; + $cmd = "SELECT SUM(runningtime) AS runningtime, SUM(1) AS count FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e "; $cmd .= "WHERE e.id=d.id AND e.uid=$uid AND SUBSTRING(timestamp,1,7)='$yearmonth' AND $ws_wb"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) { $cmd .= " AND isadulttitle=0"; @@ -969,11 +981,9 @@ function mouseover($id, $title, $doimage, $topline) { global $db, $DVD_TABLE, $DVD_EVENTS_TABLE, $DVD_USERS_TABLE, $lang, $watched, $handleadult, $IsPrivate, $ws_wb, $ColScheme, $getimages, $img_webpath; $mouseline = 1; - $cmd = "SELECT DISTINCT * FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e WHERE e.id=d.id AND e.id='$id' AND $ws_wb"; + $cmd = "SELECT DISTINCT e.uid FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e WHERE e.id=d.id AND e.id='$id' AND $ws_wb"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; - - $cmd .= " GROUP BY e.uid"; $sql6 = $db->sql_query($cmd) or die($db->sql_error()); $unique = $db->sql_numrows($sql6); $db->sql_freeresult($sql6); @@ -990,7 +1000,7 @@ function mouseover($id, $title, $doimage, $topline) { if ($getimages == 3) $thumbname = "$img_webpath[$id]f.jpg"; else - $thumbname = PhyspathToWebpath(resize_jpg($id, "f", 60, 100)); + $thumbname = physpathToWebpath(resizeJpg($id, "f", 60, 100)); $mouse = ""; + $mouse .= "$firstname " . hideName($lastname) . ""; list($tdate, $ttime) = explode(' ',$timestamp); list($tyear, $tmonth, $tday) = explode('-', $tdate); list($thour, $tmin, $tsec) = explode(':',$ttime); @@ -1207,12 +1217,12 @@ function watched() { EOT; if ($dolast) { echo ""; - $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, timestamp, reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb"; + $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, $DVD_EVENTS_TABLE.timestamp, reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; - $cmd .= " ORDER BY timestamp DESC LIMIT $maxthumbs"; + $cmd .= " ORDER BY $DVD_EVENTS_TABLE.timestamp DESC LIMIT $maxthumbs"; $sql8 = $db->sql_query($cmd) or die($db->sql_error()); while ($row = $db->sql_fetch_array($sql8)) { @@ -1248,11 +1258,11 @@ function watched() { if ($domost) { echo ""; - $cmd = "SELECT $DVD_EVENTS_TABLE.id, SUM(1) AS count, title, reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id = $DVD_TABLE.id WHERE $ws_wb"; + $cmd = "SELECT $DVD_EVENTS_TABLE.id, SUM(1) AS count, ANY_VALUE(title) AS title, ANY_VALUE(reviewfilm) AS reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id = $DVD_TABLE.id WHERE $ws_wb"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; - $cmd .= " GROUP BY $DVD_EVENTS_TABLE.id ORDER BY count DESC, sorttitle LIMIT $maxthumbs"; + $cmd .= " GROUP BY $DVD_EVENTS_TABLE.id ORDER BY count DESC, ANY_VALUE(sorttitle) LIMIT $maxthumbs"; $sql9 = $db->sql_query($cmd) or die($db->sql_error()); while ($row = $db->sql_fetch_array($sql9)) { $id = $row['id']; @@ -1287,11 +1297,11 @@ function watched() { if ($dobest) { echo ""; - $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb AND reviewfilm > '0'"; + $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, reviewfilm, $DVD_EVENTS_TABLE.timestamp FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb AND reviewfilm > '0'"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; - $cmd .= " ORDER BY reviewfilm DESC, timestamp DESC LIMIT $maxthumbs"; + $cmd .= " ORDER BY reviewfilm DESC, $DVD_EVENTS_TABLE.timestamp DESC LIMIT $maxthumbs"; $sql10 = $db->sql_query($cmd) or die($db->sql_error()); while ($row = $db->sql_fetch_array($sql10)) { $id = $row['id']; @@ -1324,11 +1334,11 @@ function watched() { EOT; if ($doworst) { echo ""; - $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, reviewfilm FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb AND reviewfilm > '0'"; + $cmd = "SELECT DISTINCT $DVD_EVENTS_TABLE.id, title, reviewfilm, $DVD_EVENTS_TABLE.timestamp FROM $DVD_EVENTS_TABLE LEFT JOIN $DVD_TABLE ON $DVD_EVENTS_TABLE.id=$DVD_TABLE.id WHERE $ws_wb AND reviewfilm > '0'"; if (($handleadult == 2) || (($handleadult == 1) && !$IsPrivate)) $cmd .= " AND isadulttitle=0"; - $cmd .= " ORDER BY reviewfilm, timestamp DESC LIMIT $maxthumbs"; + $cmd .= " ORDER BY reviewfilm, $DVD_EVENTS_TABLE.timestamp DESC LIMIT $maxthumbs"; $sql11 = $db->sql_query($cmd) or die($db->sql_error()); while ($row = $db->sql_fetch_array($sql11)) { $id = $row['id']; @@ -1397,6 +1407,11 @@ function my_watched($me) { # $me_botalign = "l", $me_datefmt = $lang[SHORTDATEFORMAT], $me_type = 'watched', $me_filter = '', $me_space = 0. # + if (!extension_loaded('gd')) { + echo '

    GD library is not available. Image generation requires the PHP GD extension.

    '; + return; + } + if (!isset($profiles)) $profiles = array(); if (!isset($me_first)) $me_first = ""; if (!isset($me_last)) $me_last = ""; @@ -1537,7 +1552,7 @@ function my_watched($me) { echo "I'm sorry, but profile ($me) doesn't exist"; foreach ($profiles as $key => $val) if (isset($val['last'])) - $profiles[$key]['last'] = HideName($profiles[$key]['last']); + $profiles[$key]['last'] = hideName($profiles[$key]['last']); echo "
    \$me="; print_r($me);echo "\n\$profiles="; print_r($profiles);
             exit;
         }
    @@ -1553,7 +1568,7 @@ function my_watched($me) {
         if ( $me_type == 'watched' ) {
     
     #   Check the namelist first
    -        $cmd = "SELECT DISTINCT e.id,title,mediabannerfront,custommediatype,originaltitle,timestamp FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e, $DVD_USERS_TABLE u WHERE e.id=d.id AND e.uid=u.uid AND $ws_wb";
    +        $cmd = "SELECT DISTINCT e.id,title,mediabannerfront,custommediatype,originaltitle,e.timestamp FROM $DVD_TABLE d, $DVD_EVENTS_TABLE e, $DVD_USERS_TABLE u WHERE e.id=d.id AND e.uid=u.uid AND $ws_wb";
             $cmd .= " $me_filter AND firstname='$me_first' AND lastname='$me_last'";
         }
     
    @@ -1581,7 +1596,11 @@ function my_watched($me) {
             $cmd .= " ORDER BY timestamp DESC, title LIMIT $me_start,$mt";
         }
     */
    -    $cmd .= " ORDER BY timestamp DESC, sorttitle DESC";
    +    if ($me_type == 'watched') {
    +        $cmd .= " ORDER BY e.timestamp DESC, sorttitle DESC";
    +    } else {
    +        $cmd .= " ORDER BY timestamp DESC, sorttitle DESC";
    +    }
         if (!$CullDupsFromWatched && $me_excludetag == '' && $me_includetag == '' && !is_array($me_includetags)) {
             $cmd .= " LIMIT $me_start,$mt";
         }
    @@ -1591,7 +1610,7 @@ function my_watched($me) {
     #   data, rather than the timestamp on the xml.
         $sql8 = $db->sql_query($cmd) or die($db->sql_error());
         $row = $db->sql_fetch_array($sql8);
    -    $timestamp = $row['timestamp'];
    +    $timestamp = $row ? $row['timestamp'] : null;
         if ( !$timestamp )
             return;
     
    @@ -1776,7 +1795,7 @@ function my_watched($me) {
     
     #       New code for caching of the thumbnails
             $me_updating = $me;
    -        $filename = resize_jpg($row, 'f', $me_width, $me_quality, $me_height, $me_bgcol);
    +        $filename = resizeJpg($row, 'f', $me_width, $me_quality, $me_height, $me_bgcol);
     #       Wow was that it! Much smaller than before
     
             $imagedata = getimagesize($filename);
    @@ -1830,7 +1849,7 @@ function my_watched($me) {
             @unlink($filename);
         }
         else {
    -        SendNoCacheHeaders('Content-Type: image/jpeg');
    +        sendNoCacheHeaders('Content-Type: image/jpeg');
         }
         ImageJPEG($im2, $filename, $me_quality);
         ImageDestroy($im2); // fjw added plug memory leak
    diff --git a/schema.sql b/schema.sql
    deleted file mode 100644
    index edceb83..0000000
    --- a/schema.sql
    +++ /dev/null
    @@ -1,398 +0,0 @@
    -#	$Id$
    -# DB installation schema for phpdvdprofiler
    -# replace DVDPROFILER_ with your $tableprefix
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd;
    -CREATE TABLE DVDPROFILER_dvd (
    -  id char(20) NOT NULL,
    -  upc varchar(30) default NULL,
    -  builtinmediatype tinyint unsigned default NULL,
    -  custommediatype varchar(40) default NULL,
    -  mediabannerfront tinyint default NULL,
    -  mediabannerback tinyint default NULL,
    -  title varchar(250) default NULL,
    -  sorttitle varchar(250) default NULL,
    -  originaltitle varchar(250) default NULL,
    -  description varchar(255) default NULL,
    -  countryoforigin varchar(255) default NULL,
    -  countryoforigin2 varchar(255) default NULL,
    -  countryoforigin3 varchar(255) default NULL,
    -  region varchar(10) default NULL,
    -  collectiontype varchar(60) default NULL,
    -  realcollectiontype varchar(60) default NULL,
    -  auxcolltype varchar(250) default NULL,
    -  collectionnumber int unsigned default NULL,
    -  rating varchar(40) default NULL,
    -  ratingsystem varchar(80) default NULL,
    -  ratingage varchar(20) default NULL,
    -  ratingvariant varchar(20) default NULL,
    -  ratingdetails varchar(255) default NULL,
    -  productionyear varchar(4) default NULL,
    -  released bigint default NULL,
    -  runningtime smallint unsigned default NULL,
    -  casetype varchar(20) default NULL,
    -  caseslipcover tinyint unsigned default NULL,
    -  primegenre varchar(80) default NULL,
    -  primedirector varchar(200) default NULL,
    -  isadulttitle tinyint unsigned default NULL,
    -  formataspectratio varchar(10) default NULL,
    -  formatcolorcolor tinyint unsigned default NULL,
    -  formatcolorbw tinyint unsigned default NULL,
    -  formatcolorcolorized tinyint unsigned default NULL,
    -  formatcolormixed tinyint unsigned default NULL,
    -  formatvideostandard varchar(10) default NULL,
    -  formatletterbox tinyint unsigned default NULL,
    -  formatpanandscan tinyint unsigned default NULL,
    -  formatfullframe tinyint unsigned default NULL,
    -  format16x9 tinyint unsigned default NULL,
    -  formatdualsided tinyint unsigned default NULL,
    -  formatduallayered tinyint unsigned default NULL,
    -  dim2d tinyint unsigned default NULL,
    -  dim3danaglyph tinyint unsigned default NULL,
    -  dim3dbluray tinyint unsigned default NULL,
    -  drhdr10 tinyint unsigned default NULL,
    -  drdolbyvision tinyint unsigned default NULL,
    -  featuresceneaccess tinyint unsigned default NULL,
    -  featureplayall tinyint unsigned default NULL,
    -  featuretrailer tinyint unsigned default NULL,
    -  featurebonustrailers tinyint unsigned default NULL,
    -  featuremakingof tinyint unsigned default NULL,
    -  featurecommentary tinyint unsigned default NULL,
    -  featuredeletedscenes tinyint unsigned default NULL,
    -  featureinterviews tinyint unsigned default NULL,
    -  featureouttakes tinyint unsigned default NULL,
    -  featurestoryboardcomparisons tinyint unsigned default NULL,
    -  featurephotogallery tinyint unsigned default NULL,
    -  featureproductionnotes tinyint unsigned default NULL,
    -  featuredvdromcontent tinyint unsigned default NULL,
    -  featuregame tinyint unsigned default NULL,
    -  featuremultiangle tinyint unsigned default NULL,
    -  featuremusicvideos tinyint unsigned default NULL,
    -  featurethxcertified tinyint unsigned default NULL,
    -  featureclosedcaptioned tinyint unsigned default NULL,
    -  featuredigitalcopy tinyint unsigned default NULL,
    -  featurepip tinyint unsigned default NULL,
    -  featurebdlive tinyint unsigned default NULL,
    -  featuredbox tinyint unsigned default NULL,
    -  featurecinechat tinyint unsigned default NULL,
    -  featuremovieiq tinyint unsigned default NULL,
    -  featureother varchar(255) default NULL,
    -  reviewfilm smallint unsigned default NULL,
    -  reviewvideo smallint unsigned default NULL,
    -  reviewaudio smallint unsigned default NULL,
    -  reviewextras smallint unsigned default NULL,
    -  srp varchar(10) default NULL,
    -  srpcurrencyid varchar(10) default NULL,
    -  srpcurrencyname varchar(100) default NULL,
    -  srpdec decimal(10,3) default NULL,
    -  gift tinyint unsigned default NULL,
    -  giftuid smallint unsigned default 0,
    -  purchaseprice varchar(10) default NULL,
    -  purchasepricecurrencyid varchar(10) default NULL,
    -  purchasepricecurrencyname varchar(100) default NULL,
    -  paid decimal(10,3) default NULL,
    -  purchasedate bigint default NULL,
    -  purchaseplace int default NULL,
    -  loaninfo varchar(250) default NULL,
    -  loandue bigint default NULL,
    -  overview mediumtext default NULL,
    -  eastereggs mediumtext default NULL,
    -  lastedited bigint default NULL,
    -  countas smallint signed default NULL,
    -  hashprofile varchar(10) default NULL,
    -  hashnocolid varchar(10) default NULL,
    -  hashcast varchar(10) default NULL,
    -  hashcrew varchar(10) default NULL,
    -  notes mediumtext default NULL,
    -  wishpriority tinyint unsigned default NULL,
    -  boxparent varchar(20) default NULL,
    -  boxchild tinyint unsigned default NULL,
    -  PRIMARY KEY (id),
    -  KEY sorttitle (sorttitle),
    -  KEY collectiontype (collectiontype)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_common_actor`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_common_actor;
    -CREATE TABLE DVDPROFILER_dvd_common_actor (
    -  caid int NOT NULL AUTO_INCREMENT,
    -  firstname varchar(50) default NULL,
    -  middlename varchar(50) default NULL,
    -  lastname varchar(50) default NULL,
    -  birthyear varchar(10) default NULL,
    -  fullname varchar(200) default NULL,
    -  PRIMARY KEY (caid),
    -  KEY fullname (fullname)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -INSERT INTO DVDPROFILER_dvd_common_actor VALUES (-1, '__DiViDeR__', '__Episode__', '__DiViDeR__', '0', '__DiViDeR__');
    -INSERT INTO DVDPROFILER_dvd_common_actor VALUES (-2, '__DiViDeR__', '__Group__',   '__DiViDeR__', '0', '__DiViDeR__');
    -INSERT INTO DVDPROFILER_dvd_common_actor VALUES (-3, '__DiViDeR__', '__EndDiv__',  '__DiViDeR__', '0', '__DiViDeR__');
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_actor`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_actor;
    -CREATE TABLE DVDPROFILER_dvd_actor (
    -  id char(20) NOT NULL,
    -  lineno smallint NOT NULL,
    -  caid int default NULL,
    -  creditedas varchar(250) default NULL,
    -  role varchar(250) default NULL,
    -  voice tinyint unsigned default NULL,
    -  uncredited tinyint unsigned default NULL,
    -  PRIMARY KEY (id,lineno),
    -  KEY caid (caid)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_users`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_users;
    -CREATE TABLE DVDPROFILER_dvd_users (
    -  uid smallint unsigned NOT NULL,
    -  firstname varchar(30) default NULL,
    -  lastname varchar(30) default NULL,
    -  phonenumber varchar(30) default NULL,
    -  emailaddress varchar(30) default NULL,
    -  PRIMARY KEY (uid)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_events`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_events;
    -CREATE TABLE DVDPROFILER_dvd_events (
    -  id char(20) NOT NULL,
    -  uid smallint unsigned default NULL,
    -  eventtype varchar(30) default NULL,
    -  note varchar(250) default NULL,
    -  timestamp DATETIME default NULL,
    -  KEY id (id),
    -  KEY uid (uid)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_discs`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_discs;
    -CREATE TABLE DVDPROFILER_dvd_discs (
    -  id char(20) NOT NULL,
    -  discno smallint default NULL,
    -  discdescsidea varchar(250) default NULL,
    -  discdescsideb varchar(250) default NULL,
    -  discidsidea varchar(16) default NULL,
    -  discidsideb varchar(16) default NULL,
    -  labelsidea varchar(50) default NULL,
    -  labelsideb varchar(50) default NULL,
    -  duallayeredsidea tinyint unsigned default NULL,
    -  duallayeredsideb tinyint unsigned default NULL,
    -  dualsided tinyint unsigned default NULL,
    -  location varchar(250) default NULL,
    -  slot varchar(250) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_audio`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_audio;
    -CREATE TABLE DVDPROFILER_dvd_audio (
    -  id char(20) NOT NULL,
    -  dborder smallint default NULL,
    -  audiocontent varchar(250) default NULL,
    -  audioformat varchar(250) default NULL,
    -  audiochannels varchar(250) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_common_credits`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_common_credits;
    -CREATE TABLE DVDPROFILER_dvd_common_credits (
    -  caid int NOT NULL AUTO_INCREMENT,
    -  firstname varchar(50) default NULL,
    -  middlename varchar(50) default NULL,
    -  lastname varchar(50) default NULL,
    -  birthyear varchar(10) default NULL,
    -  fullname varchar(200) default NULL,
    -  PRIMARY KEY (caid),
    -  KEY fullname (fullname)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -INSERT INTO DVDPROFILER_dvd_common_credits VALUES (-1, '__DiViDeR__', '__Episode__', '__DiViDeR__', '0', '__DiViDeR__');
    -INSERT INTO DVDPROFILER_dvd_common_credits VALUES (-2, '__DiViDeR__', '__Group__',   '__DiViDeR__', '0', '__DiViDeR__');
    -INSERT INTO DVDPROFILER_dvd_common_credits VALUES (-3, '__DiViDeR__', '__EndDiv__',  '__DiViDeR__', '0', '__DiViDeR__');
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_credits`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_credits;
    -CREATE TABLE DVDPROFILER_dvd_credits (
    -  id char(20) NOT NULL,
    -  lineno smallint NOT NULL,
    -  caid int default NULL,
    -  creditedas varchar(250) default NULL,
    -  credittype varchar(250) default NULL,
    -  creditsubtype varchar(250) default NULL,
    -  customrole varchar(250) default NULL,
    -  PRIMARY KEY (id,lineno),
    -  KEY caid (caid)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_genres`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_genres;
    -CREATE TABLE DVDPROFILER_dvd_genres (
    -  id char(20) NOT NULL,
    -  dborder smallint default NULL,
    -  genre varchar(250) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_boxset`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_boxset;
    -CREATE TABLE DVDPROFILER_dvd_boxset (
    -  id char(20) NOT NULL,
    -  child varchar(20) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_studio`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_studio;
    -CREATE TABLE DVDPROFILER_dvd_studio (
    -  id char(20) NOT NULL,
    -  ismediacompany tinyint unsigned default NULL,
    -  dborder smallint default NULL,
    -  studio varchar(250) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_subtitle`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_subtitle;
    -CREATE TABLE DVDPROFILER_dvd_subtitle (
    -  id char(20) NOT NULL,
    -  subtitle varchar(80) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_tags`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_tags;
    -CREATE TABLE DVDPROFILER_dvd_tags (
    -  id char(20) NOT NULL,
    -  name varchar(250) default NULL,
    -  fullyqualifiedname varchar(250) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_stats`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_stats;
    -CREATE TABLE DVDPROFILER_dvd_stats (
    -  stattype varchar(20) NOT NULL,
    -  namestring1 varchar(250) default NULL,
    -  namestring2 varchar(250) default NULL,
    -  id char(20) default NULL,
    -  counts int unsigned default NULL,
    -  KEY stattype (stattype)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_locks`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_locks;
    -CREATE TABLE DVDPROFILER_dvd_locks (
    -  id char(20) UNIQUE NOT NULL,
    -  entire BOOL default NULL,
    -  covers BOOL default NULL,
    -  title BOOL default NULL,
    -  mediatype BOOL default NULL,
    -  overview BOOL default NULL,
    -  regions BOOL default NULL,
    -  genres BOOL default NULL,
    -  srp BOOL default NULL,
    -  studios BOOL default NULL,
    -  discinfo BOOL default NULL,
    -  cast BOOL default NULL,
    -  crew BOOL default NULL,
    -  features BOOL default NULL,
    -  audio BOOL default NULL,
    -  subtitles BOOL default NULL,
    -  eastereggs BOOL default NULL,
    -  runningtime BOOL default NULL,
    -  releasedate BOOL default NULL,
    -  productionyear BOOL default NULL,
    -  casetype BOOL default NULL,
    -  videoformats BOOL default NULL,
    -  rating BOOL default NULL,
    -  PRIMARY KEY (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_supplier`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_supplier;
    -CREATE TABLE DVDPROFILER_dvd_supplier (
    -  sid int NOT NULL AUTO_INCREMENT,
    -  suppliername varchar(250) UNIQUE,
    -  supplierurl varchar(250) default NULL,
    -  suppliertype char(1) default NULL,
    -  PRIMARY KEY (sid)
    -#  KEY suppliername (suppliername)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_properties`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_properties;
    -CREATE TABLE DVDPROFILER_dvd_properties (
    -  property varchar(100) NOT NULL,
    -  value varchar(250) default NULL,
    -  PRIMARY KEY (property)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_exclusions`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_exclusions;
    -CREATE TABLE DVDPROFILER_dvd_exclusions (
    -  id char(20) UNIQUE NOT NULL,
    -  moviepick BOOL default NULL,
    -  mobile BOOL default NULL,
    -  iphone BOOL default NULL,
    -  remoteconnections BOOL default NULL,
    -  dpopublic BOOL default NULL,
    -  dpoprivate BOOL default NULL,
    -  PRIMARY KEY (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -# --------------------------------------------------------
    -#
    -# Table Structure for Table `dvd_links`
    -#
    -DROP TABLE IF EXISTS DVDPROFILER_dvd_links;
    -CREATE TABLE DVDPROFILER_dvd_links (
    -  id char(20) NOT NULL,
    -  dborder smallint default NULL,
    -  linktype tinyint unsigned default NULL,
    -  url varchar(250) default NULL,
    -  description varchar(80) default NULL,
    -  category varchar(80) default NULL,
    -  KEY id (id)
    -) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    -#
    -INSERT INTO DVDPROFILER_dvd_properties VALUES ("db_schema_version", "2.10");
    -# --------------------------------------------------------
    diff --git a/skins/phpDVDProfiler_Skin/phpDVDProfiler Skin.html b/skins/phpDVDProfiler_Skin/phpDVDProfiler Skin.html
    index 52da843..04e36b6 100644
    --- a/skins/phpDVDProfiler_Skin/phpDVDProfiler Skin.html	
    +++ b/skins/phpDVDProfiler_Skin/phpDVDProfiler Skin.html	
    @@ -480,7 +480,7 @@
     	tmp = id.split('.');
     	if (tmp.length == 1)
     		tmp[1] = '0';
    -	document.write('  ');
     	for (var i in regions) {
    @@ -805,7 +805,7 @@
     
     
     
    - • ','Contributors','toolbar=no,width=702,height=499,resizable=yes,scrollbars=yes,status=yes'); return false;">$lang[CONTRIBUTORS]
    + • ','Contributors','toolbar=no,width=702,height=499,resizable=yes,scrollbars=yes,status=yes'); return false;">$lang[CONTRIBUTORS]
    - - -
    {$lang['PREFS']['USERPREFS']}
    -
    $lang[IMPORTCLICK]
    -
    - - -EOT; - - if ($allowactorsort) { - $n1 = $n2 = $n3 = $n4 = $n5 = ''; - if (isset($_COOKIE['actorsort'])) { - $a = $lang['PREFS']['ACTORSORT'][$actorsort]; - if ($_COOKIE['actorsort'] == '0') - $n1 = 'selected'; - else if ($_COOKIE['actorsort'] == '1') - $n2 = 'selected'; - else if ($_COOKIE['actorsort'] == '2') - $n3 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['ACTORSORT'][$siteactorsort]."]"; - $n4 = 'selected'; - } - echo<< -EOT; - } - - if ($allowsecondcol) { - $n1 = $n2 = $n3 = $n4 = $n5 = $n6 = $n7 = $n8 = $n9 = $n10 = $n11 = ''; - if (isset($_COOKIE['secondcol'])) { - $a = $lang['PREFS']['COLUMNS'][$secondcol]; - if ($_COOKIE['secondcol'] == 'released') - $n1 = 'selected'; - else if ($_COOKIE['secondcol'] == 'productionyear') - $n2 = 'selected'; - else if ($_COOKIE['secondcol'] == 'purchasedate') - $n3 = 'selected'; - else if ($_COOKIE['secondcol'] == 'collectionnumber') - $n4 = 'selected'; - else if ($_COOKIE['secondcol'] == 'runningtime') - $n5 = 'selected'; - else if ($_COOKIE['secondcol'] == 'rating') - $n6 = 'selected'; - else if ($_COOKIE['secondcol'] == 'genres') - $n7 = 'selected'; - else if ($_COOKIE['secondcol'] == 'reviews') - $n10 = 'selected'; - else if ($_COOKIE['secondcol'] == 'director') - $n11 = 'selected'; - else if ($_COOKIE['secondcol'] == 'none') - $n9 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['COLUMNS'][$sitesecondcol]."]"; - $n8 = 'selected'; - } - echo<< -EOT; - } - - if ($allowthirdcol) { - $n1 = $n2 = $n3 = $n4 = $n5 = $n6 = $n7 = $n8 = $n9 = $n10 = $n11 = ''; - if (isset($_COOKIE['thirdcol'])) { - $a = $lang['PREFS']['COLUMNS'][$thirdcol]; - if ($_COOKIE['thirdcol'] == 'released') - $n1 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'productionyear') - $n2 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'purchasedate') - $n3 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'collectionnumber') - $n4 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'runningtime') - $n5 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'rating') - $n6 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'genres') - $n7 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'reviews') - $n10 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'director') - $n11 = 'selected'; - else if ($_COOKIE['thirdcol'] == 'none') - $n9 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['COLUMNS'][$sitethirdcol]."]"; - $n8 = 'selected'; - } - echo<< -EOT; - } - - if ($allowdefaultsorttype) { - $n1 = $n2 = $n3 = $n4 = $n5 = ''; - $z = $$sitedefaultsorttype; - $displaysitedefaultsorttype = $lang['PREFS']['DEFAULTSORTTYPE'][$sitedefaultsorttype].$lang['PREFS']['COLUMNS'][$z]; - if (isset($_COOKIE['defaultsorttype'])) { - $z = $$defaultsorttype; - $a = $lang['PREFS']['DEFAULTSORTTYPE'][$defaultsorttype].$lang['PREFS']['COLUMNS'][$z]; - if ($_COOKIE['defaultsorttype'] == 'firstcol') - $n1 = 'selected'; - else if ($_COOKIE['defaultsorttype'] == 'secondcol') - $n2 = 'selected'; - else if ($_COOKIE['defaultsorttype'] == 'thirdcol') - $n3 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [$displaysitedefaultsorttype]"; - $n4 = 'selected'; - } - echo<< -EOT; - } - - if ($allowtitledesc) { - $n1 = $n2 = $n3 = $n4 = $n5 = ''; - if (isset($_COOKIE['titledesc'])) { - $a = $lang['PREFS']['TITLEDESC'][$titledesc]; - if ($_COOKIE['titledesc'] == '0') - $n1 = 'selected'; - else if ($_COOKIE['titledesc'] == '1') - $n2 = 'selected'; - else if ($_COOKIE['titledesc'] == '2') - $n3 = 'selected'; - else if ($_COOKIE['titledesc'] == '3') - $n4 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['TITLEDESC'][$sitetitledesc]."]"; - $n5 = 'selected'; - } - echo<< -EOT; - } - - if ($allowlocale) { - $n1 = $n2 = $n3 = $n4 = $n5 = $n6 = $n7 = $n8 = $n9 = $n10 = ''; - if (isset($_COOKIE['locale'])) { - $a = $lang['PREFS']['LOCALE'][$locale]; - if ($_COOKIE['locale'] == 'en') - $n1 = 'selected'; - else if ($_COOKIE['locale'] == 'de') - $n2 = 'selected'; - else if ($_COOKIE['locale'] == 'no') - $n3 = 'selected'; - else if ($_COOKIE['locale'] == 'fr') - $n4 = 'selected'; - else if ($_COOKIE['locale'] == 'nl') - $n5 = 'selected'; - else if ($_COOKIE['locale'] == 'sv') - $n6 = 'selected'; - else if ($_COOKIE['locale'] == 'dk') - $n7 = 'selected'; - else if ($_COOKIE['locale'] == 'fi') - $n8 = 'selected'; - else if ($_COOKIE['locale'] == 'ru') - $n9 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['LOCALE'][$sitelocale]."]"; - $n10 = 'selected'; - } - echo<< -EOT; - } - - if ($allowstickyboxsets) { - $n1 = $n2 = $n3 = $n4 = $n5 = ''; - if (isset($_COOKIE['stickyboxsets'])) { - $a = $lang['PREFS']['STICKYBOXSETS'][$stickyboxsets]; - if ($_COOKIE['stickyboxsets'] == '1') - $n1 = 'selected'; - else if ($_COOKIE['stickyboxsets'] == '0') - $n2 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['STICKYBOXSETS'][$sitestickyboxsets]."]"; - $n3 = 'selected'; - } - echo<< -EOT; - } - - if ($allowpopupimages) { - $n1 = $n2 = $n3 = $n4 = $n5 = ''; - if (isset($_COOKIE['popupimages'])) { - $a = $lang['PREFS']['POPUPIMAGES'][$popupimages]; - if ($_COOKIE['popupimages'] == '1') - $n1 = 'selected'; - else if ($_COOKIE['popupimages'] == '0') - $n2 = 'selected'; - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [".$lang['PREFS']['POPUPIMAGES'][$sitepopupimages]."]"; - $n3 = 'selected'; - } - echo<< -EOT; - } - - if ($allowskins) { - $n1 = $n2 = ''; - if ($skinfile == 'internal') - $n1 = 'selected'; - $ss = $siteskinfile; - if ($siteskinfile == 'internal') - $ss = $lang['PREFS']['SKINS']['INTERNAL']; - $ss = preg_replace('/\.htm[l]$/i', '', $ss); - if (isset($_COOKIE['skinfile'])) { - if ($skinfile == 'internal') - $a = $lang['PREFS']['SKINS']['INTERNAL']; - else - $a = preg_replace('/\.htm[l]$/i', '', $skinfile); - } - else { - $a = $lang['PREFS']['SITEDEFAULT']."
    [$ss]"; - $n2 = 'selected'; - } - echo << -EOT; - unset($TheSkins); - } - - if ($allowwidths) { - echo<< -EOT; - } - - unset($mapping); - echo '
    {$lang['PREFS']['PREFERENCE']}{$lang['PREFS']['CURRENTVAL']}{$lang['PREFS']['SELECTIONS']}
    {$lang['PREFS']['ACTORSORT']['NAME']}$a -
    {$lang['PREFS']['COLUMNS']['SECONDNAME']}$a -
    {$lang['PREFS']['COLUMNS']['THIRDNAME']}$a -
    {$lang['PREFS']['DEFAULTSORTTYPE']['NAME']}$a -
    {$lang['PREFS']['TITLEDESC']['NAME']}$a -
    {$lang['PREFS']['LOCALE']['NAME']}$a -
    {$lang['PREFS']['STICKYBOXSETS']['NAME']}$a -
    {$lang['PREFS']['POPUPIMAGES']['NAME']}$a -
    {$lang['PREFS']['SKINS']['NAME']}$a -
    -
    {$lang['PREFS']['WIDTHS']['NAME']}

    '; - echo '
    ', $lang['IMPORTCLICK'], "
    \n"; - echo "$endbody\n";