PHP based html generator for csv files, specially for
d2j Movie Databases.
The output format and rows can be easily configured with a config file and a cascading style sheet.
The rows are also real-time customizable with CGI parameters.
back to top
Copy the main and the css file to your webserver and the function, the config and the input file anywhere
into your filesystem where the webserver user has readaccess. Link the css file in your html file and make sure
the correct paths are set in the two include commands in the main file. Set the options in the config file, at least
the path to the input file.
back to top
Open the main file with a webbrowser. Allowed CGI parameters are:
view = short | long
show = all | german
letter = <letter> (_ = all, ` = #)
back to top
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
back to top
<?php
// Movie Weblist - php based html generator for csv files, specially for d2j movie databases
// last changed: 23.10.2004
// Copyright (C) 2003/2004 Soenke Gluch
// http://www.mellowmood.no-ip.com
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once "../data/moviezConf.php";
if (isset($_POST['submit'])) {
$search = true;
$searchC = 0;
if (isset($_POST['german'])) {
$show = "german";
} else {
$show = "all";
}
if (isset($_POST['long'])) {
$view = "long";
} else {
$view = "short";
}
if (!isset($_POST['name']) and !isset($_POST['aka']) and !isset($_POST['info'])) {
$_POST['name'] = 1;
}
} else {
$search = false;
}
require_once "../inc/moviezFunc.php";
init_vars($y, $ger, $view, $show, $standard_view, $standard_show, $lang_param, $skip_lines, $
letter, $search);
$all = $letter == "_";
$triggerS = false;
print
"<div id=\"header\">
<form action=\"$prefix/private,$view,$show.html\" method=\"post\" id=\"search\">
<fieldset id=\"searchSet\">
<input type=\"checkbox\" name=\"name\" value=\"1\"";
if ($search) {
if (isset($_POST['name'])) {
print " checked=\"checked\"";
}
} elseif ($defaultName) {
print " checked=\"checked\"";
}
print
" class=\"searchNAbstand\" />Name
<input type=\"checkbox\" name=\"aka\" value=\"1\"";
if ($search) {
if (isset($_POST['aka'])) {
print " checked=\"checked\"";
}
} elseif ($defaultAka) {
print " checked=\"checked\"";
}
print
" class=\"searchAbstand\" />Aka
<input type=\"checkbox\" name=\"info\" value=\"1\"";
if ($search) {
if (isset($_POST['info'])) {
print " checked=\"checked\"";
}
} elseif ($defaultInfo) {
print " checked=\"checked\"";
}
print
" class=\"searchAbstand\" />Info
<input type=\"text\" id=\"pattern\" name=\"pattern\" value=\"";
if ($search) {
print $_POST['pattern'];
}
print
"\" size=\"20\" />
<input type=\"submit\" name=\"submit\" value=\"Search\" id=\"submit\" />
<input type=\"checkbox\" name=\"german\" value=\"1\"";
if ($search) {
if (isset($_POST['german'])) {
print " checked=\"checked\"";
}
} elseif ($show == "german") {
print " checked=\"checked\"";
}
print
" class=\"searchAbstand\" />only German
<input type=\"checkbox\" name=\"long\" value=\"1\"";
if ($search) {
if (isset($_POST['long'])) {
print " checked=\"checked\"";
}
} elseif ($view == "long") {
print " checked=\"checked\"";
}
print
" class=\"searchAbstand\" />long list
</fieldset>
</form>
<table id=\"pages\"><tr>
<td class=\"pages\">";
if (!$search and (ord($letter) > 96)) {
print
"<a href=\"$prefix/private," . chr(ord($letter)-1) . ",$view,$show.html\" class=\"pag
es\" id=\"fwArrow\">
<span class=\"pages\">$fwLeft</span>
</a>
";
} else {
print "<div class=\"pages\" id=\"fwArrow\">$fwLeft</div>\n";
}
print "</td>
";
for ($i = 95; $i < 123; $i++) {
print "<td class=\"pages\">";
if (chr($i) == $letter) {
print "<div class=\"pagesActive\">" . str_replace(chr(95), "all", str_replace(chr(96), "0
-9", chr($i))) . "</div>";
} else {
print
"<a href=\"$prefix/private," . chr($i) . ",$view,$show.html\" class=\"pages\">"
. str_replace(chr(95), "all", str_replace(chr(96), "0-9", chr($i))) .
"</a>
";
}
print "</td>\n";
}
print
"<td class=\"pages\">";
if (!$search and !$all and (ord($letter) < 122)) {
print
"<a href=\"$prefix/private," . chr(ord($letter)+1) . ",$view,$show.html\" class=\"pag
es\">
<span class=\"pages\">$fwRight</span>
</a>
";
} else {
print "<div class=\"pages\">$fwRight</div>";
}
print "</td>
</tr></table>
</div>
";
$fp = fopen($datei,"r");
$regexp = "/" . str_replace("_", ".", str_replace(chr(96), "[0-9]", $letter)) . "/i";
$trigger = false;
while($zeile = fgetcsv($fp,500,",")) { //iterate for every line
if ($y > 0) { //skip first lines with "d2j.databaseXX"
if (!$search and !$trigger) {
if (preg_match($regexp, substr($zeile[1], 0, 1))) {
$trigger = true;
print "<table id=\"moviez\">\n";
showHeads($view, $show, $select);
}
}
if ($trigger) {
if (!$all) {
if (!preg_match($regexp, substr($zeile[1], 0, 1))) {
break;
}
}
if ($show == "all") {
print "<tr class=\"" . einfaerben($y) . "\">"; //colorize line
select_rows($zeile, $view, $show, $positions, $y, $select);
print "</tr>\n";
} else {
if (preg_match("/" . $lang_string . "/i", $zeile[$positions['region']]) or
preg_match("/" . $lang_string . "/i", $zeile[$positions['comment3']])) {
print "<tr class=\"" . einfaerben($ger-1) . "\">"; //colorize line
select_rows($zeile, $view, $show, $positions, $y, $select);
print "</tr>\n";
}
}
}
if ($search) {
if ($_POST['pattern'] == "") {
break;
}
if ((isset($_POST['name']) and preg_match("/" . $_POST['pattern'] . "/i", $zeile[$posit
ions['name']])) or
(isset($_POST['aka']) and preg_match("/" . $_POST['pattern'] . "/i", $zeile[$position
s['aka']])) or
(isset($_POST['info']) and (preg_match("/" . $_POST['pattern'] . "/i", $zeile[$positi
ons['comment3']]) or
preg_match("/" . $_POST['pattern'] . "/i", $zeile[$positions['actors']]) or
preg_match("/" . $_POST['pattern'] . "/i", $zeile[$positions['director']])))) {
if (($show == "german") and !preg_match("/" . $lang_string . "/i", $zeile[$positions[
'region']]) and
!preg_match("/" . $lang_string . "/i", $zeile[$positions['comment3']])) {
$y++;
continue;
}
if (!$triggerS) {
print "<table id=\"moviez\">\n";
showHeads($view, $show, $select);
$triggerS = true;
}
print "<tr class=\"" . einfaerben($searchC + 1) . "\">"; //colorize line
select_rows($zeile, $view, $show, $positions, $y, $select);
print "</tr>\n";
$searchC++;
}
}
if (!$search and preg_match("/" . $lang_string . "/i", $zeile[$positions['region']]) or
preg_match("/" . $lang_string . "/i", $zeile[$positions['comment3']])) {
$ger++;
}
}
$y++; //increment counter
}
fclose($fp);
$y--; //counter has been incremented after last iteration
if ($trigger or $triggerS) {
if ($all and !$search) {
print
"<tr><td colspan=\"9\" class=\"dummy\">---</td></tr>
<tr><td colspan=\"9\" class=\"total\">Total: $y<span class=\"total_small\"> [$lang
_total: $ger]</span></td></tr>
";
}
print "</table>\n";
if ($search) {
if ($searchC > 1) {
print "<div id=\"searchResults\">$searchC search results</div>";
} else {
print "<div id=\"searchResults\">$searchC search result</div>";
}
}
print "<div id=\"topLink\"><a href=\"#top\" class=\"top\">back to top</a></div>";
} else {
print "<div id=\"noMoviez\">No items in this selection.</div>";
}
?>
<?PHP
// This file is part of Movie Weblist
// Copyright (C) 2003/2004 Soenke Gluch
// Movie Weblist is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// Movie Weblist is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Movie Weblist; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$fwLeft = "<<<"; //left arrow
$fwRight = ">>>"; //right arrow
$defaultName = true; //search name by default
$defaultAka = true; //search aka by default
$defaultInfo = false; //search info by default
$datei = "../data/moviez.d2j"; //d2j file
$lang_string = "GER"; //for $lang_total counter and $lang_param parameter
$lang_total = "Deutsch"; //string in totals
$lang_param = "german"; //parameter for language
$standard_show = "all"; //default for $show
$standard_view = "short"; //default for $view
$skip_lines = 5; //skip first lines (set to 5 for d2j files)
$select = array(
"Number" => false,
"Name" => true,
"Aka" => true,
"switchAka" => false,
"Year" => true,
"Genre" => true,
"Special" => true,
"Region" => true,
"Format" => true,
"Cds" => true,
);
function genre_benennen($z) { //genre definitions
/*switch($z) {
case "Action": $z = "Action"; break;
case "Actionkom�die": $z = "Actionkom�die"; break;
case "Abenteuer": $z = "Abenteuer"; break;
case "Amateur": $z = "Amateur"; break;
case "Zeichentrick": $z = "Zeichentrick"; break;
case "Anime": $z = "Anime"; break;
case "Kom�die": $z = "Kom�die"; break;
case "Krimi": $z = "Krimi"; break;
case "Dokumentation": $z = "Dokumentation"; break;
case "Drama": $z = "Drama"; break;
case "Familie": $z = "Familie"; break;
case "Fantasy": $z = "Fantasy"; break;
case "Horror": $z = "Horror"; break;
case "Horrorkom�die": $z = "Horrorkom�die"; break;
case "Horror/Sci-Fi": $z = "Horror/Sci-Fi"; break;
case "Musical": $z = "Musical"; break;
case "Mystery": $z = "Mystery"; break;
case "Romanze": $z = "Romanze"; break;
case "Science Fiction": $z = "Science Fiction"; break;
case "Kurzfilm": $z = "Kurzfilm"; break;
case "Sport": $z = "Sport"; break;
case "Thriller": $z = "Thriller"; break;
case "Kriegsfilm": $z = "Kriegsfilm"; break;
case "Western": $z = "Western"; break;
case "XXX": $z = "XXX"; break;
}*/
return $z;
}
function format_benennen($z) { //format definitions
switch($z) {
case "1": $z = "DVD"; break;
case "2": $z = "DVDr"; break;
case "3": $z = "LD"; break;
case "4": $z = "SVCD"; break;
case "5" : $z = "VCD"; break;
case "6": $z = "VHS"; break;
case "7": $z = "VHSc"; break;
case "8": $z = "Beta"; break;
case "9": $z = "V2000"; break;
case "10": $z = "TV"; break;
case "11": $z = "DivX"; break;
case "12": $z = "XviD"; break;
case "13": $z = "Other"; break;
}
return $z;
}
$positions = array( //positions of properties in array if changed in future
"format" => 0,
"name" => 1,
"aka" => 2,
"year" => 3,
"region" => 4,
"distributor" => 5,
"genre" => 6,
"rating" => 7,
"country" => 8,
"director" => 9,
"actors" => 10,
"comment1" => 11,
"comment2" => 12,
"comment3" => 13,
"comment4" => 14,
"comment5" => 15
);
?>
<?PHP
// This file is part of Movie Weblist
// Copyright (C) 2003/2004 Soenke Gluch
// Movie Weblist is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// Movie Weblist is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Movie Weblist; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function init_vars(&$y, &$ger, &$view, &$show, $standard_view, $standard_show, $lang_param, $
skip_lines, &$letter, $search) {
$y = $skip_lines * -1;
$ger = "0";
if (!$search) {
if (isset($_GET["view"])) {
$view = $_GET["view"];
if (($view != "short") and ($view != "long")) {
$view = $standard_view;
}
} else {
$view = $standard_view;
}
if (isset($_GET["show"])) {
$show = $_GET["show"];
if (($show != $lang_param) and ($show != "all")) {
$show = $standard_show;
}
} else {
$show = $standard_show;
}
}
if (isset($_GET["letter"])) {
$letter = $_GET["letter"];
if ((strlen($letter) != 1) || (!preg_match("/[a-z" . chr(96) . "_]+/i", $letter))) {
$letter = "a";
}
} else {
$letter = "a";
}
}
function einfaerben($y) { //colorize lines differently
if ($y % 2) {
return "e"; //color for even lines
}
return "o"; //color for odd lines
}
function kuerzen($z, $laenge) { //shorten to specific length
if (strlen($z) > $laenge) {
return substr($z, 0, $laenge) . "...";
}
return $z;
}
function name2aka($aka, $name) { //if no aka, name as aka
if ($aka == "#") {
return $name;
}
return $aka;
}
function format_year($z) { //if year = 0, output "-"
if($z == "0") {
return "-";
}
return $z;
}
function define_special($special, $director, $actors) {
if($special == "#") {
if($director != "#") {
return $director;
}
else {
if($actors != "#") {
return $actors;
}
}
}
return $special;
}
function normal_ausgeben($z) {
print "<td>$z</td>";
}
function fett_ausgeben($z) {
print "<td class=\"f\">$z</td>";
}
function zeichen_codieren($z) {
$zeichen = array(
array("&","&"),
array("<","<"),
array(">",">"),
array('"',"""),
array("#","-"),
array("_",",")
);
for ($i=0;$i<sizeof($zeichen);$i++) {
$z = str_replace($zeichen[$i][0],$zeichen[$i][1],$z);
}
return $z;
}
function showHeads($view, $show, $select) {
print "<tr>";
if ($select['Number']) {
print "<th>#</th>";
}
if ($select['Name']) {
print "<th>Title</th>";
}
if ($select['Aka'] and ($view == "long")) {
print "<th>Aka</th>"; }
if ($select['Year']) {
print "<th>Year</th>";
}
if ($select['Genre']) {
print "<th>Genre</th>";
}
if ($select['Special']) {
print "<th>Info</th>";
}
if ($select['Region'] and (($view == "long") or ($show == "all"))) {
print "<th>Language</th>";
}
if ($select['Format'] and ($view == "long")) {
print "<th>Format</th>";
}
if ($select['Cds'] and ($view == "long")) {
print "<th>CDs</th>";
}
print "</tr>\n";
}
function select_rows($zeile, $view, $show, $positions, $y, $select) {
if ($select['Number']) {
normal_ausgeben(str_pad($y, 4, "0", STR_PAD_LEFT));
}
if ($select['Name']) {
fett_ausgeben(zeichen_codieren(kuerzen($zeile[$positions['name']], 48)));
}
if ($select['Aka'] and ($view == "long")) {
if ($select['switchAka']) {
normal_ausgeben(zeichen_codieren(kuerzen(name2aka($zeile[$positions['aka']], $zeile[$po
sitions['name']]), 40)));
} else {
normal_ausgeben(zeichen_codieren(kuerzen($zeile[$positions['aka']], 40)));
}
}
if ($select['Year']) {
normal_ausgeben(format_year($zeile[$positions['year']]));
}
if ($select['Genre']) {
normal_ausgeben(genre_benennen($zeile[$positions['genre']]));
}
if ($select['Special']) {
normal_ausgeben(zeichen_codieren(kuerzen(define_special(
$zeile[$positions['comment3']], $zeile[$positions['director']], $zeile[$positions['acto
rs']]), 18)));
}
if ($select['Region'] and (($view == "long") or ($show == "all"))) {
normal_ausgeben($zeile[$positions['region']]);
}
if ($select['Format'] and ($view == "long")) {
normal_ausgeben(format_benennen($zeile[$positions['format']]));
}
if ($select['Cds'] and ($view == "long")) {
normal_ausgeben(substr($zeile[$positions['comment2']], 0, 1));
}
}
?>
/*
This file is part of Movie Weblist
Copyright (C) 2003/2004 Soenke Gluch
Movie Weblist is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Movie Weblist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Movie Weblist; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
table#moviez {
border-collapse:collapse;
font-size:7.5pt;
margin-top:10pt;
}
table#moviez td {
text-align:left;
white-space:nowrap;
border:1pt solid #6B8E23;
padding-left:2pt;
padding-right:2pt;
}
table#moviez th {
color:#000000;
text-align:left;
white-space:nowrap;
border:1pt solid #6B8E23;
padding-left:2pt;
padding-right:2pt;
padding-top:1pt;
padding-bottom:4pt;
text-decoration:underline;
}
td.f {
font-weight: bold;
border:1pt solid #6B8E23;
}
td.dummy {
color:#000000;
font-size:6pt;
}
td.total {
font-size:10pt;
font-weight: bold;
}
.total_small {
font-weight: normal;
}
tr.o{ /* color of odd lines */
color:#2F4F4F;
}
tr.e{ /* color of even lines */
color:#006400;
}
a.pages {
display:block;
padding-left:6px;
padding-right:6px;
padding-top:6px;
padding-bottom:6px;
font-size:8pt;
}
a.pages:link {
font-weight:700;
color:#000000;
text-decoration:none;
}
a.pages:visited {
font-weight:700;
color:#000000;
text-decoration:none;
}
a.pages:hover {
font-weight:700;
color:#A52A2A;
text-decoration:none;
}
a.pages:active {
font-weight:700;
color:#A52A2A;
padding-top:7px;
padding-bottom:5px;
padding-left:7px;
padding-right:5px;
text-decoration:none;
}
a.pages:focus {
font-weight:700;
color:#2F4F4F;
text-decoration:none;
}
td.pages {
margin:0px;
padding:0px;
border-width:0pt;
}
table#pages {
margin:0px;
padding:0px;
border:0pt solid #000000;
}
div#header {
margin-bottom:0pt;
}
div.pagesActive {
margin-left:6px;
margin-right:6px;
margin-top:6px;
margin-bottom:6px;
color:#DC143C;
font-weight:700;
font-size:8pt;
}
span.pages {
font-size:9pt;
}
div.pages {
margin-left:6px;
margin-right:6px;
margin-top:6px;
margin-bottom:6px;
font-weight:700;
font-size:9pt;
color:#696969;
}
div#topLink {
margin-top:10pt;
margin-bottom:0pt;
margin-left:0pt;
}
table#moviez {
margin-left:0pt;
margin-right:0pt;
margin-top:12pt;
margin-bottom:0pt;
}
fieldset#searchSet {
padding-top:2pt;
padding-bottom:2pt;
padding-left:2pt;
padding-right:2pt;
margin:0pt;
width:510pt;
}
form#search {
margin:0px;
padding:0px;
}
input#pattern {
height:15pt;
font-weight:700;
vertical-align:middle;
padding:0pt;
background-color:#FFFAF0;
color:#666666;
margin-left:4pt;
}
input#submit {
margin:0pt;
margin-left:4pt;
padding:0pt;
height:15pt;
text-align:center;
font-size:8pt;
background-color:#A0522D;
border-color:#8B4513;
width:90pt;
vertical-align:middle;
color:#FFFFF0;
font-weight:700;
}
input.searchAbstand {
margin-left:4pt;
margin-right:0pt;
vertical-align:middle;
}
input.searchNAbstand {
vertical-align:middle;
}
#fwArrow {
padding-left:0px;
margin-left:0px;
}
div#noMoviez {
margin-top:20pt;
}
div#searchResults {
margin-top:10pt;
font-weight:700;
}