Skip to content
Browse files

First commit of tvdb code

  • Loading branch information...
1 parent f229ad8 commit 59ef9d46cdcc99b9f2c06ad1621771cd03f0e23c mclaughlin.matt committed Apr 16, 2010
Showing with 11,091 additions and 0 deletions.
  1. +47 −0 NiftyLayout.css
  2. +149 −0 api/GetSeries.php
  3. +69 −0 api/Updates.php
  4. +86 −0 api/User_Favorites.php
  5. +45 −0 api/User_PreferredLanguage.php
  6. +93 −0 api/User_Rating.php
  7. +41 −0 api/include.php
  8. +14 −0 bannerdownload.php
  9. +197 −0 colorchooser.php
  10. +16 −0 config.php
  11. +16 −0 config.template.php
  12. +380 −0 default.css
  13. +42 −0 fanart_vignette.php
  14. BIN favicon.ico
  15. +82 −0 genres.php
  16. BIN icon_file.gif
  17. BIN icon_folder.gif
  18. +662 −0 include.php
  19. +1,586 −0 index.php
  20. +246 −0 langDetect.php
  21. +68 −0 makebanner.php
  22. +120 −0 mirror.php
  23. +5 −0 nbproject/private/private.properties
  24. +6 −0 nbproject/project.properties
  25. +9 −0 nbproject/project.xml
  26. 0 niftyCorners.css
  27. +11 −0 niftyLayout.js
  28. +286 −0 niftycube.js
  29. BIN popup_body.gif
  30. BIN popup_close.gif
  31. BIN popup_title.gif
  32. +213 −0 robots.txt
  33. +33 −0 rss/newtoday.php
  34. +13 −0 rss/newtoday.tmp
  35. +48 −0 rss/newtoday.xml
  36. +416 −0 schema.sql
  37. +183 −0 scrape_tvcom.php
  38. +1,063 −0 sphinxapi.php
  39. +48 −0 tab_DMCA.php
  40. +36 −0 tab_aboutus.php
  41. +15 −0 tab_addshow.php
  42. +145 −0 tab_advancedsearch.php
  43. +68 −0 tab_agreement.php
  44. +51 −0 tab_api.php
  45. +44 −0 tab_apiregister.php
  46. +15 −0 tab_artistbanners.php
  47. +75 −0 tab_artistbannersadmin.php
  48. +29 −0 tab_bannerartists.php
  49. +58 −0 tab_bannerrequests.php
  50. +58 −0 tab_bannerrequests_100.php
  51. +217 −0 tab_bannerview.php
  52. +33 −0 tab_donation.php
  53. +604 −0 tab_episode.php
  54. +57 −0 tab_forceupdates.php
  55. +67 −0 tab_listseries.php
  56. +179 −0 tab_locked.php
  57. +33 −0 tab_login.php
  58. +196 −0 tab_mainmenu.php
  59. +27 −0 tab_missingcolors.php
  60. +95 −0 tab_moveepisode.php
  61. +28 −0 tab_newshows.php
  62. +4 −0 tab_nojs.php
  63. +20 −0 tab_password.php
  64. +48 −0 tab_radsearch.php
  65. +73 −0 tab_recentbanners.php
  66. +59 −0 tab_recentbanners_admin.php
  67. +50 −0 tab_register.php
  68. +432 −0 tab_season.php
  69. +138 −0 tab_seasonall.php
  70. +759 −0 tab_series.php
  71. +20 −0 tab_todo.php
  72. +75 −0 tab_userinfo.php
  73. +127 −0 tab_userinfoadmin.php
  74. +144 −0 tab_userlist.php
  75. +312 −0 tab_xml.php
  76. +118 −0 tab_yearlist.php
  77. +1 −0 thegamesdb
  78. +134 −0 thumbnail.php
  79. +88 −0 translatedbanner.php
  80. +1 −0 trunk
  81. +65 −0 xfade2.js
View
47 NiftyLayout.css
@@ -0,0 +1,47 @@
+html,body{margin:0;padding:0}
+body{font: 85%/1.3 Verdana,Arial,sans-serif;
+ text-align: center;background: #757D88;padding-bottom:20px}
+p{margin-top:0}
+h1,h2,h3{font: normal normal 200% "Trebuchet MS",Arial,sans-serif}
+h2{font-size:160%}
+h3{font-size:120%}
+
+div#header{width:100%;overflow:hidden;background: #595D66}
+div#header h1,div#menu{width:770px;margin:0 auto;text-align:left}
+div#header h1{padding: 30px 0 10px;color: #FFF}
+
+ul#nav,ul#nav li{list-style-type:none;margin:0;padding:0}
+ul#nav{float:right;font-size: 80%}
+ul#nav li{float:left;margin-left: 3px;text-align: center}
+ul#nav a{float:left;width: 95px;padding: 5px 0;background: #369A3D;text-decoration:none;color: #FFC}
+ul#nav a:hover{background: #CDFFA1;color: #006A35}
+ul#nav li.activelink a,ul#nav li.activelink a:hover{background: #FFF;color: #003}
+
+div#container{width:770px;margin:0 auto 10px;padding:20px 0 10px;text-align:left;background:#FFF}
+div#content{float:left;display:inline;width:560px;margin:0 0 10px 10px}
+
+ul#intro,ul#intro li{list-style-type:none;margin:0;padding:0}
+ul#intro{width:100%;overflow:hidden;margin-bottom:20px}
+ul#intro li{float:left;width:180px;margin-right:10px;padding: 10px 0}
+li#mission{background: #E65714}
+li#services{background: #42B4AC}
+ul#intro li#more{margin-right:0;background: #7D63A9}
+ul#intro p,ul#intro h3{margin:0;padding: 0 10px}
+ul#intro h3{text-transform:uppercase;padding-bottom:3px;color: #FFF}
+
+div#content h2{margin: 10px 0;color: #007BC4}
+div.date{float:left;width: 4em;padding: 5px 0;background: #F1DDC4;color:#B0001E;
+ text-align:center;margin: 0 4px 4px 0;font-size: 80%;line-height:0.9}
+div.date span{display:block;font-size: 150%;font-weight:bold}
+
+div.comments div{background: #EEE;margin-bottom:10px}
+div.comments p{padding: 10px;margin:0}
+div.comments div.odd{background:#DAE6FE}
+
+div#side{float:right;display:inline;width: 180px;background:#F3CF00; margin:0 10px 10px 0}
+div#side p{margin:5px 0 10px;padding: 0 10px}
+div#side div{margin: 0 0 10px;padding: 10px 0}
+
+div#footer{clear:both;width:750px;margin:0 10px 0;padding: 10px 0;
+ background: #586695;color: #FFF;text-align:center}
+div#footer p{margin:0}
View
149 api/GetSeries.php
@@ -0,0 +1,149 @@
+<?php ## Interface that allows clients to get
+ ## seriesid using seriesname
+ ## Parameters:
+ ## $_REQUEST["seriesname"]
+ ## $_REQUEST["language"] (optional)
+ ## $_REQUEST["user"] (optional... overrides language setting)
+ ##
+ ## Returns:
+ ## XML item holding the series id that matches the seriesname
+
+ ## Include functions, db connection, etc
+ include("include.php");
+?>
+<?php
+ ## Prepare the search string
+ $seriesname = $_REQUEST["seriesname"];
+ $language = $_REQUEST["language"];
+ $user = $_REQUEST["user"];
+ if ($seriesname == "") {
+ print "<Error>seriesname is required</Error>\n";
+ exit;
+ }
+ else {
+ if (strpos($seriesname,", The")){$seriesname = "The ".substr($seriesname,0,strpos($seriesname,", The"));}
+ if (strpos($seriesname,"'")){$seriesname = str_replace("\'","",$seriesname);} ##To be removed if someone can figure out hwo to do this in sphinx
+ print "<Data>\n";
+ }
+
+
+ ## Get the languageid from the abbreviation
+ if ($language && $language != "all") {
+ $query = "SELECT id FROM languages WHERE abbreviation='$language' LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($result);
+ if ($db->id) {
+ $languageid = $db->id;
+ }
+ else {
+ $languageid = 7;
+ }
+ }
+ ## If language wasn't passed in
+ elseif ($language != "all") {
+ ## Get the user's preferred language if possible
+ if ($user) {
+ $query = "SELECT languageid FROM users WHERE uniqueid='$user' LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($result);
+ if ($db->languageid) {
+ $languageid = $db->languageid;
+ }
+ else {
+ $languageid = 7;
+ }
+ }
+ else {
+ $languageid = 7;
+ }
+ }
+
+ ## Run the query
+ include('../sphinxapi.php');
+ $cl = new SphinxClient();
+ $cl->SetServer( "localhost", 3312 );
+ $cl->SetMatchMode( SPH_MATCH_ALL );
+ $cl->SetLimits(0, 100);
+ $cl->SetSortMode ( SPH_SORT_EXTENDED, "@weight DESC, languageid ASC" );
+
+ if ($languageid) {
+ $cl->SetFilter('languageid', array( $languageid, 7 ));
+ $cl->SetSortMode ( SPH_SORT_EXTENDED, "@weight DESC, languageid DESC" );
+ }
+
+ $result = $cl->Query( "START_ " . $seriesname . " _END", 'seriesname', "seriesname");
+
+ if ( $result === false ) {
+ echo "Query failed: " . $cl->GetLastError() . ".\n";
+ }
+ else {
+ if ( !empty($result["matches"]) ) {
+ foreach ($result["matches"] AS $id => $junk) {
+
+ ## Get base information
+ $subquery = "SELECT seriesid, languageid, (SELECT abbreviation FROM languages WHERE id=translation_seriesname.languageid) AS language, translation AS SeriesName FROM translation_seriesname WHERE id=$id";
+ $subresult = mysql_query($subquery) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($subresult);
+ if (!$db->seriesid) {
+ continue;
+ }
+
+ ## Get top banner
+ $subquery = "SELECT filename FROM banners WHERE keytype='series' AND keyvalue=$db->seriesid ORDER BY (SELECT AVG(rating) FROM ratings WHERE itemtype='banner' AND itemid=banners.id) DESC,RAND() LIMIT 1";
+ $subresult = mysql_query($subquery) or die('Query failed: ' . mysql_error());
+ if ($subdb = mysql_fetch_object($subresult)) {
+ $db->banner = $subdb->filename;
+ }
+
+ ## Get additional information (overview)
+ $subquery = "SELECT translation FROM translation_seriesoverview WHERE seriesid=$db->seriesid AND (languageid=$db->languageid OR languageid=7) AND translation IS NOT NULL ORDER BY languageid DESC LIMIT 2";
+ $subresult = mysql_query($subquery) or die('Query failed: ' . mysql_error());
+ if ($subdb = mysql_fetch_object($subresult)) {
+ $db->Overview = $subdb->translation;
+ }
+
+ ## Get additional information (FirstAired, network, IMDB_id, zap2it_id)
+ $subquery = "SELECT FirstAired, Network, IMDB_ID, zap2it_id FROM tvseries WHERE id=$db->seriesid LIMIT 1";
+ $subresult = mysql_query($subquery) or die('Query failed: ' . mysql_error());
+ if ($subdb = mysql_fetch_object($subresult)) {
+ if ($subdb->FirstAired) {
+ $db->FirstAired = $subdb->FirstAired;
+ }
+ if ($subdb->network) {
+ $db->Network = $subdb->network;
+ }
+ if ($subdb->IMDB_ID) {
+ $db->IMDB_ID = $subdb->IMDB_ID;
+ }
+ if ($subdb->zap2it_id) {
+ $db->zap2it_id = $subdb->zap2it_id;
+ }
+ }
+
+ ## Remove fields
+ unset($db->languageid);
+
+ ## Duplicate series id as id for posterity
+ $db->id = $db->seriesid;
+
+ ## Start XML item
+ print "<Series>\n";
+
+ ## Loop through each field for this item
+ foreach ($db as $key => $value) {
+
+ ## Prepare the string for output
+ $value = xmlformat($value, $key);
+
+ ## Print the string
+ print "<$key>$value</$key>\n";
+
+ }
+
+ ## End XML item
+ print "</Series>\n";
+ }
+ }
+ }
+?>
+</Data>
View
69 api/Updates.php
@@ -0,0 +1,69 @@
+<?php ## Interface that returns all updates since a given time
+ ## Parameters:
+ ## $_REQUEST["time"]
+ ## $_REQUEST["type"] [series(default)|episode|all]
+ ##
+ ## Returns:
+ ## XML items for each series or episode that was updated since "time"
+
+ ## Include functions, db connection, etc
+ include("include.php");
+?>
+<?php
+ ## Prepare the search string
+ $time = $_REQUEST["time"];
+ $type = $_REQUEST["type"];
+ $actualtime = time();
+
+
+ ## If type is none, just return the time
+ if ($type == "none") {
+ print "<Items>\n";
+ print "<Time>" . time() . "</Time>\n";
+ print "</Items>\n";
+ exit;
+ }
+
+
+ ## Time is a required field
+ if ($time == "") {
+ print "<Error>Time is required</Error>\n";
+ exit;
+ }
+ ## This interface only allows lookups within the last 30 days
+ elseif ($time - $actualtime > 2592000) {
+ print "<Error>Time is greater than 30 days. Please do a full download of all series.</Error>\n";
+ exit;
+ }
+ ## Type can only be series, episode, all, or blank
+ elseif ($type != "series" && $type != "episode" && $type != "all" && $type != "") {
+ print "<Error>Unknown value for type</Error>\n";
+ exit;
+ }
+ ## No errors, so we continue
+ else {
+ print "<Items>\n";
+ print "<Time>" . time() . "</Time>\n";
+ }
+
+
+ ## Query for series (if desired)
+ if ($type == "series" || $type == "all" || $type == "") {
+ $query = "SELECT id FROM tvseries WHERE lastupdated>=$time LIMIT 1000";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while ($db = mysql_fetch_object($result)) {
+ print "<Series>$db->id</Series>\n";
+ }
+ }
+
+
+ ## Query for episodes (if desired)
+ if ($type == "episode" || $type == "all") {
+ $query = "SELECT id FROM tvepisodes WHERE lastupdated>=$time LIMIT 1000";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while ($db = mysql_fetch_object($result)) {
+ print "<Episode>$db->id</Episode>\n";
+ }
+ }
+?>
+</Items>
View
86 api/User_Favorites.php
@@ -0,0 +1,86 @@
+<?php ## Interface that allows clients to add series to their favorites
+ ## Parameters:
+ ## $_REQUEST["accountid"]
+ ## $_REQUEST["seriesid"]
+ ## $_REQUEST["type"] (add|remove|null)
+ ##
+ ## Returns:
+ ## Success
+
+ ## Include functions, db connection, etc
+ include("include.php");
+?>
+<?php
+ ## Prepare the search string
+ $accountid = $_REQUEST["accountid"];
+ $seriesid = $_REQUEST["seriesid"];
+ $type = $_REQUEST["type"];
+ if ($accountid == "") {
+ print "<Error>accountid is required</Error>\n";
+ exit;
+ }
+ elseif (($type == "add" || $type == "remove") && $seriesid == "") {
+ print "<Error>seriesid is required for adding and deleting</Error>\n";
+ exit;
+ }
+ else {
+ print "<Favorites>\n";
+ }
+
+
+ ## Run the query
+ $query = "SELECT id, favorites FROM users WHERE uniqueid='$accountid' LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($result);
+
+
+ ## If we've found a valid user
+ if ($db->id) {
+ ## Split their current favorites into an array, add new item,
+ ## and rejoin list
+ $favorites = array();
+ if ($type == "remove") {
+ $temp = explode(",", $db->favorites);
+ foreach ($temp AS $id) {
+ if ($id != $seriesid) {
+ array_push($favorites, $id);
+ }
+ }
+ $favorites = array_unique($favorites);
+ $favoriteslist = implode(",", $favorites);
+
+ ## Insert replacement value into database
+ $query = "UPDATE users SET favorites='$favoriteslist' WHERE id=$db->id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ ## Print new favorites list
+ foreach ($favorites AS $id) {
+ print "<Series>$id</Series>\n";
+ }
+ }
+ elseif ($type == "add") {
+ $favorites = explode(",", $db->favorites);
+ array_push($favorites, $seriesid);
+ $favorites = array_unique($favorites);
+ $favoriteslist = implode(",", $favorites);
+
+ ## Insert replacement value into database
+ $query = "UPDATE users SET favorites='$favoriteslist' WHERE id=$db->id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ ## Print new favorites list
+ foreach ($favorites AS $id) {
+ print "<Series>$id</Series>\n";
+ }
+ }
+ else {
+ ## Print new favorites list
+ $temp = explode(",", $db->favorites);
+ foreach ($temp AS $id) {
+ print "<Series>$id</Series>\n";
+ }
+ }
+
+ }
+?>
+</Favorites>
View
45 api/User_PreferredLanguage.php
@@ -0,0 +1,45 @@
+<?php ## Interface that returns the preferred langauge from an account identifier
+ ## Parameters:
+ ## $_REQUEST["accountid"]
+ ##
+ ## Returns:
+ ## XML item holding the preferred language for the user. Returns 7 if not available.
+
+ ## Include functions, db connection, etc
+ include("include.php");
+?>
+<?php
+ ## Prepare the search string
+ $accountid = $_REQUEST["accountid"];
+ if ($accountid == "") {
+ print "<Error>accountid is required</Error>\n";
+ exit;
+ }
+ else {
+ print "<Languages>\n";
+ }
+
+
+ ## Run the query
+ $query = "SELECT name, abbreviation, id FROM languages WHERE id=(SELECT languageid FROM users WHERE uniqueid='$accountid' LIMIT 1) OR id=7 ORDER BY id DESC LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while ($db = mysql_fetch_object($result)) {
+
+ ## Start XML item
+ print "<Language>\n";
+
+ ## Loop through each field for this item
+ foreach ($db as $key => $value) {
+ ## Prepare the string for output
+ $value = xmlformat($value, $key);
+
+ ## Print the string
+ print "<$key>$value</$key>\n";
+
+ }
+
+ ## End XML item
+ print "</Language>\n";
+ }
+?>
+</Languages>
View
93 api/User_Rating.php
@@ -0,0 +1,93 @@
+<?php ## Interface that allows clients to post-back ratings for a series/episode
+ ## Parameters:
+ ## $_REQUEST["accountid"]
+ ## $_REQUEST["itemtype"]
+ ## $_REQUEST["itemid"]
+ ## $_REQUEST["rating"] (1-10) 0=remove rating
+ ##
+ ## Returns:
+ ## Success
+
+ ## Include functions, db connection, etc
+ include("include.php");
+
+
+ ## Prepare the search string
+ $accountid = $_REQUEST["accountid"];
+ $itemtype = $_REQUEST["itemtype"];
+ $itemid = intval($_REQUEST["itemid"]);
+ $rating = intval($_REQUEST["rating"]);
+
+
+ ## Check the field values
+ if ($accountid == "") {
+ print "<Error>accountid is required</Error>\n";
+ exit;
+ }
+ elseif ($itemtype != "series" && $itemtype != "episode") {
+ print "<Error>itemtype must be series or episode</Error>\n";
+ exit;
+ }
+ elseif ($rating < 0 || $rating > 10) {
+ print "<Error>rating must be an integer between 0 and 10</Error>\n";
+ exit;
+ }
+
+
+ ## A rating of 0 means we remove it from the database
+ if ($rating == 0) {
+ $query = "DELETE FROM ratings WHERE itemtype='$itemtype' AND itemid=$itemid AND userid=(SELECT id FROM users WHERE uniqueid='$accountid' LIMIT 1)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ }
+
+
+ ## Handle adds/updates
+ else {
+ ## Run the query
+ $query = "SELECT id FROM ratings WHERE itemtype='$itemtype' AND itemid=$itemid AND userid=(SELECT id FROM users WHERE uniqueid='$accountid' LIMIT 1) LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($result);
+
+
+ ## If we've found a valid user, replace the rating
+ if ($db->id) {
+ $query = "UPDATE ratings SET rating=$rating WHERE id=$db->id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ }
+ ## Otherwise, insert a new record
+ else {
+ $query = "INSERT INTO ratings (itemtype, itemid, userid, rating) VALUES ('$itemtype', $itemid, (SELECT id FROM users WHERE uniqueid='$accountid' LIMIT 1), $rating)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ }
+ }
+
+
+ ## Recreate the XML files
+ if ($itemtype == "series") {
+ $query = "REPLACE INTO seriesupdates (seriesid) VALUES ($itemid)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ $query = "UPDATE tvseries SET lastupdated=UNIX_TIMESTAMP() WHERE id=$itemid";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $tag = "Series";
+ }
+ else {
+ $query = "REPLACE INTO seriesupdates (seriesid) VALUES ((SELECT seriesid FROM tvepisodes WHERE id=$itemid LIMIT 1))";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ $query = "UPDATE tvseries SET lastupdated=UNIX_TIMESTAMP() WHERE id=(SELECT seriesid FROM tvepisodes WHERE id=$itemid LIMIT 1)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $tag = "Episode";
+ }
+
+
+ ## Return the current rating
+ $query = "SELECT ROUND(AVG(rating),1) AS average FROM ratings WHERE itemtype='$itemtype' AND itemid=$itemid";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $db = mysql_fetch_object($result);
+?>
+<Data>
+<<?=$tag?>>
+<Rating><?=$db->average?></Rating>
+</<?=$tag?>>
+</Data>
View
41 api/include.php
@@ -0,0 +1,41 @@
+<?php
+ global $baseurl;
+ global $db_user;
+ global $db_password;
+ global $db_database;
+ global $db_server;
+ global $apache_type;
+ global $language;
+ include("../config.php");
+
+ ## Print the header
+ header("Content-Type: text/xml; charset=utf-8");
+ print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
+
+ ## Set the default language
+ if (!isset($language)) {
+ $language = 7; ## English
+ }
+
+ ## Connect to the database
+ $database = mysql_connect($db_server, $db_user, $db_password) or die('Could not connect: ' . mysql_error());
+ mysql_select_db($db_database) or die('Could not select database');
+ $result = mysql_query("SET NAMES 'utf8'") or die('Query failed: ' . mysql_error());
+
+ ## Prevent SQL injection attacks
+ $_REQUEST = array_map('mysql_real_escape_string', $_REQUEST);
+
+ ## Format the output XML properly
+ function xmlformat ($value, $key) {
+
+ ## Format value
+ #$value = utf8_encode($value);
+ #$value = str_replace('<', '&lt;', $value);
+ #$value = str_replace('<', '&gt;', $value);
+ $value = str_replace('&', '&amp;', $value); ## This Line Breaks UTF-8 Encoding
+ #$value = str_replace('&amp;#', '&#', $value); ## This Line Fixes UTF-8 Encoding added May 29, 2007
+ $value = preg_replace('/\0/', '', $value);
+ return $value;
+ }
+?>
+
View
14 bannerdownload.php
@@ -0,0 +1,14 @@
+<?php
+ $url = $_SERVER["QUERY_STRING"];
+ $url = preg_replace("/\Afilename=/", "", $_SERVER["QUERY_STRING"]);
+
+ ## Print the header info
+ header("Cache-Control: public, must-revalidate");
+ header("Pragma: hack");
+ header("Content-Type: image/jpeg");
+ header('Content-Disposition: attachment; filename="folder.jpg"');
+ header("Content-Transfer-Encoding: binary\n");
+
+ ## Output the file
+ print file_get_contents($url);
+?>
View
197 colorchooser.php
@@ -0,0 +1,197 @@
+<?php
+ ## Default functions
+ include("include.php");
+ $displaywidth = 640;
+ $displayheight = 360;
+ $colornames = array("Light Accent Color", "Dark Accent Color", "Neutral Midtone Color");
+
+
+ ## On submit
+ if ($function) {
+ $id = mysql_real_escape_string($id);
+ $colorsubmit = implode("|", array("", $color1, $color2, $color3, ""));
+ $colorsubmit = mysql_real_escape_string($colorsubmit);
+ $query = "UPDATE banners SET artistcolors='$colorsubmit' WHERE id=$id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ ##print "<script language=\"JavaScript\">\nwindow.opener.location.reload()\nwindow.close()\n</script>\n";
+ print "<script language=\"JavaScript\">\nwindow.opener.location=window.opener.location\nwindow.close()\n</script>\n";
+ exit;
+ }
+
+
+
+ ## Get this banner info from the database
+ $id = mysql_real_escape_string($id);
+ $query = "SELECT * FROM banners WHERE id=$id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $banner = mysql_fetch_object($result);
+ $colors = explode("|", $banner->artistcolors);
+
+
+ ## Override with colors in hidden inputs
+ for ($i = 1; $i <= 3; $i++) {
+ $varname = "color" . $i;
+ if ($$varname) {
+ $colors[$i] = $$varname;
+ }
+ }
+
+
+ ## Handle a new color selection
+ if ($coordinates_x) {
+
+ ## Calculate our coordinate multiplier
+ $resolution = explode("x", $banner->resolution);
+ $width = $resolution[0];
+ $height = $resolution[1];
+ $multiplier = $height / $displayheight;
+
+ ## Get the image and find the color at our pixels
+ $image = imagecreatefromjpeg("banners/$banner->filename");
+
+ ## Fix our parameter
+ $rgb = imagecolorat($image, $coordinates_x * $multiplier, $coordinates_y * $multiplier);
+
+ ## Store in the proper variable
+ $r = ($rgb >> 16) & 0xFF;
+ $g = ($rgb >> 8) & 0xFF;
+ $b = $rgb & 0xFF;
+ $colorstring = implode(",", array($r, $g, $b));
+ $colors[$targetcolor] = $colorstring;
+ }
+
+
+ ## Don't allow a targetcolor of 4
+ if ($targetcolor == 3) {
+ $targetcolor = 0;
+ }
+?>
+
+<html>
+<head>
+ <title>Color Chooser</title>
+ <link rel="stylesheet" type="text/css" href="http://thetvdb.com/default.css">
+ <style>
+ BODY {
+ background-color: #001D2D;
+ color: #FFF;
+ font: 9pt Arial, san-serif;
+ }
+ A, A:link, A:visited {
+ color: #B6D415;
+ text-decoration: none;
+ }
+ A:hover {
+ color: #DFEF86;
+ }
+ TD {
+ color: #FFF;
+ font: 10pt Arial, san-serif;
+ vertical-align: top;
+ }
+ INPUT {
+ font: 9pt Arial, san-serif;
+ border: none;
+ }
+ IMG {
+ border: 1px solid white;
+ }
+ .image {
+ cursor: crosshair;
+ }
+ .colorbox {
+ border: 3px solid white;
+ width: 180px;
+ height: 40px;
+ }
+ FORM {
+ margin: 0px;
+ padding: 0px;
+ }
+ FORM INPUT {
+ color: #001D2D;
+ background-color: #B6D415;
+ font: bold 14pt Arial, san-serif;
+ border: none;
+ text-align: center;
+ border: 1px solid white;
+ }
+ </style>
+ <script LANGUAGE="JavaScript" type="text/javascript">
+ <!--
+ function SelectColor(id) {
+ document.getElementById("colorbox1").style.border="3px solid white";
+ document.getElementById("colorbox2").style.border="3px solid white";
+ document.getElementById("colorbox3").style.border="3px solid white";
+ var objectname = eval("document.getElementById('colorbox" + id + "')");
+ objectname.style.border = '3px solid #B6D415';
+ document.colorform.targetcolor.value = id;
+ }
+
+ -->
+ </script>
+
+</head>
+<body onLoad="SelectColor(<?=$targetcolor+1?>)">
+ <form action="colorchooser.php" method="GET" name="colorform">
+ <input type="hidden" name="id" value="<?=$id?>">
+ <input type="hidden" name="targetcolor" value="1">
+
+ <div class="section">
+ <h1>Color Chooser</h1>
+
+ <table cellspacing="2" cellpadding="0" border="0" width="660">
+ <tr>
+ <td colspan="4" style="padding-bottom: 20px">
+ To use the color chooser, click the box of the color you wish to change and then click on the new color in the image. Once all 3 colors have been selected, you may save your changes.
+ </td>
+ </tr>
+ <tr>
+ <td>Light Accent Color</td>
+ <td>Dark Accent Color</td>
+ <td>Neutral Midtone Color</td>
+ </tr>
+ <tr>
+ <?php ## Loop through 3 colors
+ $completed = 1;
+ for ($i = 1; $i <= 3; $i++) {
+ print "<td>\n";
+ $rgbcolor = "";
+ $hexcolor = "";
+ $style = "";
+ if ($colors[$i]) {
+ $colorarray=split(",",$colors[$i]);
+ $rgbcolor = $$colorvar;
+ $hexcolor = rgb2hex($colorarray);
+ print "<div class=\"colorbox\" id=\"colorbox$i\" name=\"colorbox$i\" style=\"background-color:#$hexcolor\" OnClick=\"SelectColor($i)\"></div>\n";
+ }
+ else {
+ print "<div class=\"colorbox\" id=\"colorbox$i\" name=\"colorbox$i\" OnClick=\"SelectColor($i)\"></div>\n";
+ $completed = 0;
+ }
+ print "<input type=\"hidden\" name=\"color$i\" value=\"$colors[$i]\">\n";
+ print "</td>\n";
+ }
+ ?>
+ </tr>
+ <tr>
+ <td colspan="4" style="padding-top: 20px">
+ <input type="image" class="image" src="banners/<?=$banner->filename?>" name="coordinates" width="<?=$displaywidth?>" height="<?=$displayheight?>">
+ </td>
+ </tr>
+ <?php ## Only display the submit if they've selected 3 colors
+ if ($completed == 1) {
+ ?>
+ <tr>
+ <td colspan="4" style="padding-top: 10px">
+ <input type="submit" name="function" value="Accept These Colors">
+ </td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+
+ </div>
+ </form>
+</body>
View
16 config.php
@@ -0,0 +1,16 @@
+<?php
+ ## Misc Settings
+ $baseurl = "http://thetvdb.com";
+ $apache_type = "unix"; // Types are unix or windows
+
+ ## DB Settings
+ $db_user = "thetvdb"; // Database Username
+ $db_password = ""; // Database Password
+ $db_database = ""; // Database Name
+ $db_server = "localhost"; // Usually Localhost
+
+ ## Mail Settings
+ $mail_server = "mail.thetvdb.com";
+ $mail_username = "";
+ $mail_password = "";
+?>
View
16 config.template.php
@@ -0,0 +1,16 @@
+<?php
+ ## Misc Settings
+ $baseurl = "http://thetvdb.com";
+ $apache_type = "unix"; // Types are unix or windows
+
+ ## DB Settings
+ $db_user = "thetvdb"; // Database Username
+ $db_password = ""; // Database Password
+ $db_database = ""; // Database Name
+ $db_server = "localhost"; // Usually Localhost
+
+ ## Mail Settings
+ $mail_server = "mail.thetvdb.com";
+ $mail_username = "";
+ $mail_password = "";
+?>
View
380 default.css
@@ -0,0 +1,380 @@
+/**************************************************
+ General styles
+**************************************************/
+BODY {
+ margin: 0px;
+ padding: 0px;
+ background-image: url(images/bg.gif);
+ background-repeat: repeat-x;
+ background-color: #002F49;
+ font: 9pt Helvetica, Arial, san-serif;
+ color: white;
+}
+
+TABLE TD {
+ vertical-align: top;
+}
+
+FORM {
+ margin: 0px;
+ padding: 0px;
+}
+
+LI {
+ margin-bottom: 15px;
+}
+
+.section {
+ background-color: #001D2D;
+ margin: 5px 0px 5px 0px;
+ padding: 10px;
+}
+
+.section H1 {
+ margin: 0px;
+ margin-bottom: 5px;
+ color: #B6D415;
+ font: bold 12pt Helvetica, Arial, san-serif;
+}
+
+.section H2 {
+ margin: 0px;
+ color: #fff;
+ font: bold 11pt Helvetica, Arial, san-serif;
+}
+
+.titlesection {
+ background-color: #B6D415;
+ margin: 5px 0px 5px 0px;
+ padding: 10px;
+ color: #001D2D;
+}
+
+.titlesection A:link, .titlesection A:visited {
+ color: #001B2C;
+}
+
+.titlesection A:hover {
+ color: #002F49;
+}
+
+.titlesection H1 {
+ margin: 0px;
+ margin-bottom: 0px;
+ color: #001B2C;
+ font: bold 12pt Helvetica, Arial, san-serif;
+}
+
+.titlesection H2 {
+ margin: 0px;
+ margin-bottom: 0px;
+ margin-left: 20px;
+ color: #001B2C;
+ font: bold 11pt Helvetica, Arial, san-serif;
+}
+
+.titlesection H3 {
+ margin: 0px;
+ margin-bottom: 0px;
+ margin-left: 40px;
+ color: #001B2C;
+ font: bold 10pt Helvetica, Arial, san-serif;
+}
+
+.blanksection {
+ margin: 5px 0px 5px 0px;
+ padding: 0px;
+}
+
+.banner {
+ border: 1px solid black;
+ margin: 0px;
+ margin-bottom: 5px;
+}
+
+#bannerauthor {
+ color: #B6D415;
+ font: 8pt Helvetica, Arial, san-serif;
+ text-align: center;
+ margin-bottom: 5px;
+}
+
+.bannerinfo {
+ margin-bottom: 10px;
+ font: 8pt Helvetica, Arial, san-serif;
+}
+
+.seasonlink {
+
+}
+
+.languagesel_on {
+ background-color: #fdd;
+}
+.languagesel_off {
+ background-color: #fff;
+}
+
+TEXTAREA {
+ font: 9pt Helvetica, Arial, san-serif;
+}
+
+#bannerrotator
+{
+ margin: 10px 0px 5px;
+ overflow: hidden;
+ position: relative;
+ width: 758px;
+ height: 140px;
+}
+
+#bannerrotator img
+{
+ width: 758px;
+ height: 140px;
+}
+
+.subsection {
+ text-align: right;
+}
+
+#red {
+ color: red;
+}
+
+.longtext {
+ margin-left: 30px;
+ margin-right: 40px;
+}
+
+#smalltext {
+ font: 8pt Helvetica, Arial, san-serif;
+ color: #B6D415;
+}
+
+#formnote {
+ font: 8pt Helvetica, Arial, san-serif;
+ color: #B6D415;
+ white-space: normal !important;
+ margin-bottom: 5px;
+}
+
+/**************************************************
+ Searchbox styles
+**************************************************/
+#searchbox {
+ margin: 0px;
+ padding: 0px;
+ z-index: 1;
+}
+#searchbox #search {
+ position:relative;
+ top: 183px;
+ left: 590px;
+
+ width: 150px;
+ height: 16px !important;
+ border: none !important;
+ background-color: white;
+ font-size: 1em !important;
+ text-align: center;
+}
+
+#searchbox #usersearch, #yearsearch{
+ width: 150px;
+ height: 14px !important;
+ border: none !important;
+ background-color: white;
+ font-size: 1em !important;
+ text-align: center;
+}
+
+
+
+
+/**************************************************
+ Link styles
+**************************************************/
+A {
+ color: #B6D415;
+ text-decoration: none;
+}
+A:link {
+ color: #B6D415;
+}
+A:visited {
+ color: #B6D415;
+}
+A:hover {
+ color: #DFEF86;
+}
+
+
+/**************************************************
+ List table styles
+**************************************************/
+TABLE#listtable {
+ width: 100%;
+ padding: 0px;
+ background-color: #001D2D;
+}
+
+TABLE#listtable TD {
+ vertical-align: top;
+ text-align: left;
+ font: 9pt Helvetica, Arial, san-serif;
+}
+TABLE#listtable .head {
+ background-color: #B6D415;
+ font-weight: bold;
+ color: #001D2D;
+}
+TABLE#listtable .head a{
+ color: #001D2D;
+ text-decoration: none;
+}
+TABLE#listtable .head a:link {
+ color: #001D2D;
+}
+TABLE#listtable .head A:visited {
+ color: #001D2D;
+}
+TABLE#listtable .head A:hover {
+ color: #DFEF86;
+}
+
+TABLE#listtable .even {
+ background-color: #001D2D;
+}
+
+TABLE#listtable .odd {
+ background-color: #002337;
+}
+
+TABLE#listtable .special {
+ background-color: #502337;
+}
+
+
+/**************************************************
+ Infobox styles
+**************************************************/
+TABLE#infotable {
+ width: 100%;
+ padding: 0px;
+ background-color: #001D2D;
+}
+
+TABLE#infotable TD {
+ vertical-align: top;
+ text-align: left;
+ font: 9pt Helvetica, Arial, san-serif;
+ border-bottom: 1px solid #B6D415;
+}
+TABLE#infotable .head {
+ font-weight: bold;
+ color: #B6D415;
+}
+
+TABLE#infotable A {
+ color: white;
+}
+
+TABLE#infotable A:hover {
+ color: #CFE455;
+}
+
+
+/**************************************************
+ Data table styles
+**************************************************/
+TABLE#datatable TD {
+ vertical-align: top;
+ /* white-space: nowrap; */
+}
+
+TABLE#datatable INPUT {
+ width: 240px;
+}
+
+TABLE#datatable TD #formnote {
+ font: 8pt Helvetica, Arial, san-serif;
+ color: #B6D415;
+ white-space: normal !important;
+ margin-bottom: 5px;
+}
+
+/**************************************************
+ Data table list styles
+**************************************************/
+TABLE#datatablelist TD {
+ vertical-align: top;
+ /* white-space: nowrap; */
+}
+
+TABLE#datatablelist INPUT {
+ width: 95px;
+}
+
+TABLE#datatablelist TD #formnote {
+ font: 8pt Helvetica, Arial, san-serif;
+ color: #B6D415;
+ white-space: normal !important;
+ margin-bottom: 5px;
+}
+
+/**************************************************
+ Footer styles
+**************************************************/
+.footer {
+ background-color: #B6D415;
+ color: #001B2C;
+ margin: 0px 0px 0px;
+ padding: 10px;
+ font: bold 8pt Helvetica, Arial, san-serif;
+}
+
+.footer A {
+ color: #001D2D;
+ text-decoration: underline;
+}
+.footer A:hover {
+ color: #002F49;
+}
+
+
+/*Nifty Corners Cube CSS by Alessandro Fulciniti
+The following classes are added dinamically by javascript,
+and their use should be avoided in the markup */
+
+b.niftycorners,b.niftyfill{display:block}
+b.niftycorners *{display:block;height: 1px;line-height:1px;font-size: 1px;
+ overflow:hidden;border-style:solid;border-width: 0 1px}
+/*normal*/
+b.r1{margin: 0 3px;border-width: 0 2px}
+b.r2{margin: 0 2px}
+b.r3{margin: 0 1px}
+b.r4{height: 2px}
+b.rb1{margin: 0 8px;border-width:0 2px}
+b.rb2{margin: 0 6px;border-width:0 2px}
+b.rb3{margin: 0 5px}
+b.rb4{margin: 0 4px}
+b.rb5{margin: 0 3px}
+b.rb6{margin: 0 2px}
+b.rb7{margin: 0 1px;height:2px}
+b.rb8{margin: 0;height:2px}
+b.rs1{margin: 0 1px}
+/*transparent inside*/
+b.t1{border-width: 0 5px}
+b.t2{border-width: 0 3px}
+b.t3{border-width: 0 2px}
+b.t4{height: 2px}
+b.tb1{border-width: 0 10px}
+b.tb2{border-width: 0 8px}
+b.tb3{border-width: 0 6px}
+b.tb4{border-width: 0 5px}
+b.tb5{border-width: 0 4px}
+b.tb6{border-width: 0 3px}
+b.tb7{border-width: 0 2px;height:2px}
+b.tb8{border-width: 0 1px;height:2px}
+b.ts1{border-width: 0 2px}
View
42 fanart_vignette.php
@@ -0,0 +1,42 @@
+<?php
+ vignette($filename);
+
+function vignette($sourcefile) {
+
+ ## Get the image sizes and read it into an image object
+ $sourcefile_id = imagecreatefromjpeg($sourcefile);
+ $width = imageSX($sourcefile_id);
+ $height = imageSY($sourcefile_id);
+
+ ## Settings
+ $vignette_file = "images/vignette" . $height . ".png";
+ $scale = 0.75;
+
+ ## Create a new destination image object
+ $result_id = imagecreatetruecolor($width, $height);
+ $black = imagecolorallocate($result_id, 0, 0, 0);
+ imagefill($result_id, 0, 0, $black);
+
+ ## Read the vignette into an image object
+ $vignette_id = imagecreatefrompng($vignette_file);
+
+ ## Make sure they merge correctly
+ imageAlphaBlending($vignette_id, false);
+ imageSaveAlpha($vignette_id, true);
+
+ ## Create the image
+ imagecopy($sourcefile_id, $vignette_id, 0, 0, 0, 0, $width, $height);
+
+ ## Copy our source image resized into the destination object
+ imagecopyresampled($result_id, $sourcefile_id, 0, 0, 0, 0, $width * $scale, $height * $scale, $width, $height);
+
+ ## Return the JPG
+ header("Content-type: image/jpg");
+ imagejpeg ($result_id, "", 90);
+
+ ## Wrap it up
+ imagedestroy($sourcefile_id);
+ imagedestroy($vignette_id);
+ imagedestroy($result_id);
+}
+?>
View
BIN favicon.ico
Binary file not shown.
View
82 genres.php
@@ -0,0 +1,82 @@
+<?php
+ include ('include.php');
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <title>Genres Selector</title>
+ <link rel=stylesheet href="/pngHack/pngHack.css" type="text/css">
+ <link rel="stylesheet" type="text/css" href="/default.css">
+ <script type="text/javascript" src="/xfade2.js"></script>
+ <script type="text/javascript" src="/niftycube.js"></script>
+ <script type="text/javascript">
+ window.onload=function(){
+ Nifty("DIV.section","big");
+ Nifty("DIV.footer","big");
+ Nifty("DIV.titlesection","big");
+ }
+ </script>
+ <script type="text/javascript">
+ function copygenre() {
+ var genlist=""
+<?
+ $query = "SELECT count(*) AS amount FROM genres";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $max = mysql_fetch_object($result)->amount;
+ $counter=0;
+ while ($max != $counter){
+ echo " if (document.genresform.chkgenres[$counter].checked== true){genlist = genlist+\"|\"+document.genresform.chkgenres[$counter].value}\n";
+ $counter++;
+ }
+?>
+ if (genlist.length>1){genlist = genlist+"|"}
+ if (genlist.length>99){
+ alert("You have selected too many genres.")
+ }
+ else{
+ opener.document.seriesform.Genre.value = genlist;
+ opener.document.seriesform.Genrefake.value = genlist;
+ self.close();
+ }
+ return false;
+ }
+ </script>
+</head>
+<body>
+<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
+<tr><td>
+ <div class="titlesection">
+ <h1>Genres</h1>
+ <h3>Please select the genres for <?=$SeriesName?>.</h3>
+ </div>
+
+ <div class="section">
+
+ <form action="#" method="POST" name="genresform" onSubmit="return false">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" id="datatablelist">
+<?
+ $query = "SELECT * FROM genres";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $tr = 1;
+ while ($genres = mysql_fetch_object($result)) {
+ if ($tr == 1){echo " <tr>\n";}
+?>
+ <td><?=$genres->genre?>: </td>
+ <td><INPUT TYPE="checkbox" NAME="chkgenres" VALUE="<?=$genres->genre?>" <?if (strstr($Genre,"$genres->genre")){echo "checked";}?>></td>
+<?
+ if ($tr == 2){echo " </tr>\n"; $tr = 1;}else{$tr = 2;}
+ }
+?>
+ <tr>
+ <td style="text-align: right" colspan="4">
+ <input type="submit" name="function" value="Accept" class="submit" onClick="return copygenre()">
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+</td></tr>
+</table>
+</body>
+</html>
View
BIN icon_file.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN icon_folder.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
662 include.php
@@ -0,0 +1,662 @@
+<?php
+ global $baseurl;
+ global $db_user;
+ global $db_password;
+ global $db_database;
+ global $db_server;
+ global $apache_type;
+ global $userfavorites;
+ include("config.php");
+ set_time_limit(360);
+
+ $database = mysql_connect($db_server, $db_user, $db_password) or die('Could not connect: ' . mysql_error());
+ mysql_select_db($db_database) or die('Could not select database');
+ $result = mysql_query("SET NAMES 'utf8'") or die('Query failed: ' . mysql_error());
+
+
+ ## Function to create the series name for the URL. This removes all non alphanumeric characters
+ ## and converts spaces to underscores.
+ function urlseriesname($seriesid) {
+ $query = "SELECT translation FROM translation_seriesname WHERE seriesid=$seriesid AND languageid=7 LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $seriesinfo = mysql_fetch_object($result);
+
+ $urlseriesname = preg_replace("/[^0-9a-zA-Z\s]/", "", $seriesinfo->translation);
+ $urlseriesname = ucwords($urlseriesname);
+ $urlseriesname = preg_replace("/\s/", "", $urlseriesname);
+ if ($urlseriesname == '') {
+ #return "ForeignSeries";
+ return $seriesid;
+ }
+ else {
+ return $urlseriesname;
+ }
+ }
+
+ ## Function to create a seriesupdate record. This is used whenever a series or episode needs
+ ## to be updated in the XML files
+ function seriesupdate($seriesid) {
+ $query = "REPLACE INTO seriesupdates (seriesid) VALUES ($seriesid)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ $query = "UPDATE tvseries SET lastupdated=UNIX_TIMESTAMP() WHERE id=$seriesid";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ }
+
+
+ ## Function to randomly generate a pronouncable password
+ function genpassword($length) {
+ srand((double)microtime()*1000000);
+ $vowels = array("a", "e", "i", "o", "u");
+ $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
+ "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
+
+ $num_vowels = count($vowels);
+ $num_cons = count($cons);
+ for($i = 0; $i < $length; $i++){
+ $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
+ }
+ return substr($password, 0, $length);
+ }
+
+ ## Function to store a SQL call in the sqlhistory table
+ function storesql($sql, $sqlid=0) {
+ #if ($sqlid) {
+ # $sql = preg_replace("/INSERT INTO (\S+) \(/i", "INSERT INTO $1 (id, ", $sql);
+ # $sql = preg_replace("/\) VALUES \(/i", ") VALUES ($sqlid, ", $sql);
+ #}
+
+ #$sql = mysql_real_escape_string($sql);
+ #$query = "INSERT INTO history (statement) VALUES ('SQL: $sql')";
+ #$result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ #return 1;
+ }
+
+ ## Function to store a file change in the sqlhistory table
+ function storefile_add($path) {
+ $path = mysql_real_escape_string($path);
+ $query = "INSERT INTO history (statement) VALUES ('FILE: $path')";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ return 1;
+ }
+
+ ## Function to store a file change in the sqlhistory table
+ function storefile_del($path) {
+ $path = mysql_real_escape_string($path);
+ $query = "INSERT INTO history (statement) VALUES ('DELETE: $path')";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ return 1;
+ }
+ ## Function to store a file change in the sqlhistory table
+ function translatetext($english) {
+ if ($texttranslations[$english]) {
+ return $texttranslations[$english];
+ }
+ else {
+ return $english;
+ }
+ }
+
+## Function to replicate file_put_contents for php4
+if (!function_exists('file_put_contents')) {
+ function file_put_contents($filename, $data, $respect_lock = true)
+ {
+ // Open the file for writing
+ $fh = @fopen($filename, 'w');
+ if ($fh === false) {
+ return false;
+ }
+ // Check to see if we want to make sure the file is locked before we write to it
+ if ($respect_lock === true && !flock($fh, LOCK_EX)) {
+ fclose($fh);
+ return false;
+ }
+ // Convert the data to an acceptable string format
+ if (is_array($data)) {
+ $data = implode('', $data);
+ } else {
+ $data = (string) $data;
+ }
+ // Write the data to the file and close it
+ $bytes = fwrite($fh, $data);
+ // This will implicitly unlock the file if it's locked
+ fclose($fh);
+ return $bytes;
+ }
+}
+
+## Function to generate the required entries for rotating series banners
+function bannerdisplay($id) {
+ $bcount = 0;
+ $textbcount = 0;
+ $query = "SELECT * FROM banners WHERE keytype='series' AND keyvalue=$id AND subkey !='blank' and languageid=7 ORDER BY RAND()";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while ($banner = mysql_fetch_object($result)) {
+ if ($banner->subkey == 'text') { $textbcount++; }
+ else {
+ print "<img src=\"$baseurl/banners/$banner->filename\" alt='banner' title='banner' class='rotatebanner' />";
+ $bcount++;
+ }
+ }
+ if ($bcount == 0 AND $textbcount > 0) {
+ $query = "SELECT * FROM banners WHERE keytype='series' AND keyvalue=$id ORDER BY RAND()";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while ($banner = mysql_fetch_object($result)) {
+ $bcount++;
+ if ($banner->subkey == 'text') {
+ $textbcount++;
+ print "<img src=\"$baseurl/banners/$banner->filename\" alt='banner' title='banner' class='rotatebanner' />";
+ }
+ }
+ }
+ if ($bcount == 0 AND $textbcount == 0) { print "<style>#bannerrotator {display:none;}</style>"; }
+}
+
+## Function to generate a text or blank series banner from tv.com
+## Inputs: banner type, text for banner, integer language ID, tvdb ID, tv.com ID for banner retrieval
+## Outputs: image file, SQL insert statement for future display and retrieva;, IMG html code for initial display
+function generatebanner($type,$text,$languageid, $seriesid, $tvcomid) {
+ global $typecount;
+ $typecount = 0;
+ $time = time();
+ $banner = file_get_contents("http://thetvdb.com/makebanner.php?id=" . $tvcomid . "&text=" . urlencode(stripslashes($text)));
+
+ ## If banner was generated, continue
+ if ($banner != 'ERROR') {
+
+ ## Save it to disk and continue if successful
+ $filename = "$type/$seriesid.jpg";
+ if (file_put_contents("banners/$filename", $banner)) {
+
+ ## Verify once more that it doesnt exist
+ $query = "SELECT * FROM banners WHERE keytype='series' AND keyvalue=$seriesid AND subkey='$type' LIMIT 1";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+
+ ## Store the SQL record
+ if (mysql_num_rows($result) == 0) {
+ $query = "INSERT INTO banners (userid, keytype, keyvalue, subkey, dateadded, filename, languageid) VALUES (1, 'series', '$seriesid', '$type', $time, '$filename', '$languageid')";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $id = mysql_insert_id();
+ storesql($query, $id); ## Store the statement for the mirrors
+ storefile_add("banners/$filename"); ## Store the file info for the mirrors
+ }
+
+ ## Display it
+ print "<img src=\"$baseurl/banners/$filename\" class=\"banner\" border=\"0\" alt=\"text\">\n";
+ print "<div id=\"bannerauth\">Banner generated automatically</div>\n";
+ $typecount++;
+ }
+ }
+}
+
+
+## Function to generate/display a cached version of a wide banner
+## Inputs: banner filename, author, boolean delete, calling url, bannerid, display author bool
+## Outputs: resized image file, IMG html code pointing to resized
+function displaybanner ($filename, $bannerauthor, $allowdelete, $fullurl, $bannerid, $displayauthor, $link) {
+
+ ## Check if the banner is cached already. If not, create it.
+ if (!file_exists("../banners/_cache/$filename")) {
+ ## Create the cached version of the image
+ $banner = file_get_contents("http://thetvdb.com/thumbnail.php?gd=2&maxw=300&src=banners/$filename");
+ file_put_contents("banners/_cache/$filename", $banner);
+ }
+
+ ## Display the image
+ print "<a href=\"$link\"><img src=\"/banners/_cache/$filename\" class=\"banner\" border=\"0\"></a>\n";
+
+ ## Display the author
+ if ($displayauthor && $allowdelete) {
+ print "<div id=\"bannerauthor\">Banner by $bannerauthor. You can <a href=\"$fullurl&function=Delete+Banner&bannerid=$bannerid\">delete it</a>.</div>\n";
+ }
+ elseif ($displayauthor) {
+ print "<div id=\"bannerauthor\">Banner by $bannerauthor</div>\n";
+ }
+}
+
+
+## Function to generate/display a cached version of a banner
+function displaybannernew ($banner, $allowdelete, $link) {
+
+ global $loggedin, $user, $bannercount, $tab, $id, $seriesid, $seasonid;
+ switch ($tab) {
+ case "mainmenu":
+ $fullurl = "/?";
+ break;
+ case "series":
+ $fullurl = "/?tab=series&id=$id";
+ break;
+ case "season":
+ $fullurl = "/?tab=season&seriesid=$seriesid&seasonid=$seasonid";
+ break;
+ case "episode":
+ $fullurl = "/?tab=episode&seriesid=$seriesid&seasonid=$seasonid&id=$id";
+ break;
+ default:
+ $fullurl = "/?";
+ }
+
+
+ ## Check if the banner is cached already. If not, create it.
+ if (!file_exists("../banners/_cache/$banner->filename")) {
+ ## Create the cached version of the image
+ $target = file_get_contents("http://thetvdb.com/thumbnail.php?gd=2&maxw=300&src=banners/$banner->filename");
+ file_put_contents("banners/_cache/$banner->filename", $target);
+ }
+
+
+ ## Display the image
+ if ($link) {
+ print "<a href=\"$link\"><img src=\"/banners/_cache/$banner->filename\" class=\"banner\" border=\"0\" alt=\"$banner->seriesname\"></a>\n";
+ }
+ else {
+ print "<a href=\"javascript:;\" onClick=\"toggleDiv('bannerinfo$banner->id');\"><img src=\"/banners/_cache/$banner->filename\" class=\"banner\" border=\"0\"></a>\n";
+ }
+
+
+ ## Display the extra info
+ if ($bannercount == 0) {
+ $displaytype = "block";
+ }
+ else {
+ $displaytype = "none";
+ }
+
+ print "<div id=\"bannerinfo$banner->id\" style=\"display:$displaytype\"><table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" width=\"100%\" class=\"bannerinfo\">\n";
+
+ ## Skip most stuff for episode images
+ if ($tab != 'episode') {
+ print "<tr><td></td><td align=right><a href=\"banners/$banner->filename\" target=\"_blank\">View Full Size</a></td></tr>\n";
+ if ($banner->keytype == 'fanart') {
+ $banner->vignette = str_replace("original", "vignette", $banner->filename);
+ print "<tr><td></td><td align=right><a href=\"banners/$banner->vignette\" target=\"_blank\">View Full Size Vignette</a></td></tr>\n";
+ }
+ print "<tr><td>Site Rating:</td><td align=\"right\">\n";
+
+
+ ## Get the site banner rating
+ $query = "SELECT AVG(rating) AS average, count(*) AS count FROM ratings WHERE itemtype='banner' AND itemid=$banner->id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $rating = mysql_fetch_object($result);
+
+
+ ## Display the site rating
+ for ($i = 1; $i <= 10; $i++) {
+ if ($i <= $rating->average)
+ print "<img src=\"/images/star_on.gif\" width=15 height=15 border=0>";
+ else
+ print "<img src=\"/images/star_off.gif\" width=15 height=15 border=0>";
+ }
+ print "</td></tr>\n";
+
+
+ ## Get the user banner rating
+ if ($loggedin == 1) {
+ print "<tr><td>Your Rating:</td><td align=\"right\">\n";
+ ## Get user rating for this series
+ $query = "SELECT rating FROM ratings WHERE itemtype='banner' AND itemid=$banner->id AND userid=$user->id";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $rating = mysql_fetch_object($result);
+ if (!$rating->rating) {
+ $rating->rating = 0;
+ }
+
+ for ($i = 1; $i <= 10; $i++) {
+ if ($i <= $rating->rating) {
+ print "<a href=\"$fullurl&function=UserRating&type=banner&itemid=$banner->id&rating=$i\" OnMouseOver=\"UserRating2('bannerrating$banner->id', $i)\" OnMouseOut=\"UserRating2('bannerrating$banner->id', $rating->rating)\"><img src=\"/images/star_on.gif\" width=15 height=15 border=0 name=\"bannerrating$banner->id$i\"></a>";
+ }
+ else {
+ print "<a href=\"$fullurl&function=UserRating&type=banner&itemid=$banner->id&rating=$i\" OnMouseOver=\"UserRating2('bannerrating$banner->id',$i)\" OnMouseOut=\"UserRating2('bannerrating$banner->id',$rating->rating)\"><img src=\"/images/star_off.gif\" width=15 height=15 border=0 name=\"bannerrating$banner->id$i\"></a>";
+ }
+ }
+ print "</td></tr>\n";
+ }
+
+ ## Display extra info
+ print "<tr><td>Ratings:</td><td align=right>$banner->ratingcount</td></tr>\n";
+ print "<tr><td>Created:</td><td align=right>" . date("F j, Y H:i", $banner->dateadded) . "</td></tr>\n";
+ }
+ print "<tr><td>Creator:</td><td align=right><a href=?tab=artistbanners&id=$banner->userid>$banner->creator</a></td></tr>\n";
+ if ($tab != "episode") {
+ if ($banner->keytype != "season" && $banner->keytype != "seasonwide") {
+ print "<tr><td>Format:</td><td align=right>" . ucwords($banner->subkey) . "</td></tr>\n";
+ }
+ print "<tr><td>Language:</td><td align=right>$banner->language</td></tr>\n";
+ }
+
+ ## Display colors if fan art
+ if ($banner->keytype == "fanart") {
+ print "<tr><td>Auto-Colors:</td><td align=right>\n";
+ $allcolors = explode("|", $banner->colors);
+ foreach ($allcolors AS $color) {
+ if ($color) {
+ $colorarray=split(",",$color);
+ $color = rgb2hex($colorarray);
+ print "<div style=\"width:20px; height:10px; background-color:#$color; float:right; margin:1px; border: 1px solid white\"></div>\n";
+ }
+ }
+ print "</td></tr>";
+ }
+
+ ## Display artist colors if available
+ if ($banner->keytype == "fanart") {
+ if (!$banner->artistcolors) {
+ $allcolors = explode("|", $banner->colors);
+ $banner->artistcolors = implode("|", array("", $allcolors[1], $allcolors[3], $allcolors[6], ""));
+ $banner->artistcolors = "|0,29,45|0,29,45|0,29,45|";
+ $banner->artistcolors = "|255,255,255|255,255,255|255,255,255|";
+ }
+ print "<tr><td>Artist Colors:</td><td align=right>\n";
+ $allcolors = explode("|", $banner->artistcolors);
+ $allcolors = array_reverse($allcolors);
+ $colorcount = 0;
+ foreach ($allcolors AS $color) {
+ if ($color) {
+ $colorarray=split(",",$color);
+ $color = rgb2hex($colorarray);
+ print "<div style=\"width:20px; height:10px; background-color:#$color; float:right; margin:1px; border: 1px solid white\")\"></div>\n";
+ $colorcount++;
+ }
+ }
+ print "</td></tr>";
+
+
+ ## Print the color chooser
+ if ($allowdelete || $banner->artistcolors == "|255,255,255|255,255,255|255,255,255|") {
+ print "<tr><td></td><td align=right>You can <a href=\"javascript:return false\" OnClick=\"window.open('colorchooser.php?id=$banner->id','colorchooser','width=660,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')\">modify the artist colors</a>.</td></tr>\n";
+ }
+ }
+
+
+ ## Print the delete banner link
+ if ($allowdelete && $tab == "episode") {
+ print "<tr><td></td><td align=right>You can <a href=\"$fullurl&function=Delete+Episode+Banner\">delete it</a>.</td></tr>\n";
+ }
+ elseif ($allowdelete) {
+ print "<tr><td></td><td align=right>You can <a href=\"$fullurl&function=Delete+Banner&bannerid=$banner->id\">delete it</a>.</td></tr>\n";
+ }
+
+
+ ## Finish off the table for this banner
+ print "</table></div>\n";
+}
+
+
+## Function to obfuscate email so it's readable by spambots
+function cryptemail($myemail)
+{
+ $i=0; // initializing the counter to count each character
+ do{
+ $codechar = substr($myemail,$i,1); // Read each character of the string
+ $code = ord($codechar); // Convert each character to its corresponding ASCII value/number
+ if($code == "&#0") // If space/NULL is there, don't print anything ( After last character what will happen?)
+ { print ""; }
+ else { $cryptmail = $cryptmail."&#$code"; // Make a new string with cryptic ASCII codes
+ }
+ $i++;
+ } while($codechar != ""); // End of do-while loop
+return $cryptmail;
+} // end of function
+
+## Function to generate meaningful page titles
+## Inputs: Series ID, Season ID, Episode ID, Tab Name, Language ID
+function titlegenerator($titleseriesid, $titleseasonid, $titleepisodeid, $tab, $lid)
+{
+ $id = mysql_real_escape_string($titleseriesid);
+ $seriesname = "";
+ $query = "SELECT * FROM translation_seriesname WHERE seriesid=$id && (languageid=7 || languageid=$lid)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while($series = mysql_fetch_object($result)) {
+ if ($seriesname == "" || $series->languageid != 7) {
+ $seriesname = $series->translation;
+ }
+ }
+
+ if ($titleepisodeid != 'Null') {
+ $episodeid = mysql_real_escape_string($titleepisodeid);
+ $episodename = "";
+ $query = "SELECT * FROM translation_episodename WHERE episodeid=$titleepisodeid && (languageid=7 || languageid=$lid)";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ while($episode = mysql_fetch_object($result)) {
+ if ($episodename == "" || $episode->languageid != 7) {
+ $episodename = $episode->translation;
+ }
+ }
+ print "<title>$seriesname: $episodename</title>";
+ }
+ elseif ($titleseasonid != 'Null') {
+ $seasonid = mysql_real_escape_string($titleseasonid);
+ $query = "SELECT season FROM tvseasons WHERE id=$seasonid";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+ $season = mysql_fetch_object($result);
+ print "<title>$seriesname: Season $season->season Episode List</title>";
+ }
+ elseif ($tab == 'seasonall') {
+ print "<title>$seriesname: Complete Episode List</title>";
+ }
+ else {
+ print "<title>$seriesname: Series Info</title>";
+ }
+} // end of function
+
+## Function to check for special episodes
+function checkspecial($epnum, $specials, $seriesid) {
+ if ($specials) {
+ foreach ($specials as $specialepisode) {
+ foreach ($specialepisode as $specialdata) {
+ if (key($specialepisode) == $epnum) {
+ $explode = explode("'..'", $specialdata);
+ print "<tr><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">Special</a></td><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">$explode[1]</a></td><td class=\"special\">$explode[4]</td><td class=\"special\">";
+ if ($explode[5]) {
+ print "<img src=\"$baseurl/images/checkmark.png\" width=10 height=10>";
+ }
+ else {echo "&nbsp;";}
+ print "</td></tr>\n";
+ }
+ }
+ }
+ }
+}
+
+## Function to check for special episodes that air after a season
+function checkspecialafter($seasonnum, $afterspecials, $seriesid) {
+ if ($afterspecials) {
+ foreach ($afterspecials as $afterspecialepisode) {
+ foreach ($afterspecialepisode as $specialdata) {
+ if (key($afterspecialepisode) == $seasonnum) {
+ $explode = explode("'..'", $specialdata);
+ print "<tr><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">Special</a></td><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">$explode[1]</a></td><td class=\"special\">$explode[3]</td><td class=\"special\">";
+ if ($explode[4]) {
+ print "<img src=\"$baseurl/images/checkmark.png\" width=10 height=10>";
+ }
+ else {echo "&nbsp;";}
+ print "</td></tr>\n";
+ }
+ }
+ }
+ }
+}
+
+## Function to check for special episodes for all season page
+function checkspecialall($epnum, $specials, $seriesid,$seasonnumber) {
+if ($specials) {
+ foreach ($specials as $specialepisode) {
+ foreach ($specialepisode as $specialdata) {
+ if (key($specialepisode) == $epnum) {
+ $explode = explode("'..'", $specialdata);
+ if ($seasonnumber == $explode[6]) {
+ print "<tr><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">Special</a></td><td class=\"special\"><a href=\"/index.php?tab=episode&seriesid=$seriesid&seasonid=$explode[2]&id=$explode[0]$urllang\">$explode[1]</a></td><td class=\"special\">$explode[4]</td><td class=\"special\">";
+ if ($explode[5]) {
+ print "<img src=\"$baseurl/images/checkmark.png\" width=10 height=10>";
+ }
+ else {echo "&nbsp;";}
+ print "</td></tr>\n";
+ }
+ }
+ }
+ }
+}
+}
+
+## Fan art color function
+function imagecolors($filename) {
+ $colorarray = array();
+ $outpalette = array();
+ $colors = 6;
+
+ ## Process image
+ list($width, $height) = getimagesize($filename);
+ $oldimage = imagecreatefromjpeg($filename);
+
+ ## Create new image
+ $new_width = 3;
+ $new_height = 2;
+ $newimage = imagecreatetruecolor($new_width, $new_height);
+ imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
+
+ ## Process each pixel
+ for ($i = 0; $i <$new_width; $i++) {
+ for ($j = 0; $j <$new_height; $j++) {
+ $color = imagecolorat($newimage, $i, $j);
+ array_push($colorarray, $color);
+ }
+ }
+
+ ## Find the n most common colors
+ $palette = array_count_values($colorarray);
+ ksort($palette);
+ $palette = array_slice($palette, 0, $colors, true);
+ foreach ($palette AS $color => $frequency) {
+ $r = ($color >> 16) & 0xFF;
+ $g = ($color >> 8) & 0xFF;
+ $b = $color & 0xFF;
+ array_push($outpalette, "$r,$g,$b");
+ }
+
+ ## Export the formatted colors
+ return "|" . implode("|", $outpalette) . "|";
+}
+
+## Fan art vignette function (upper left)
+function vignette($sourcefile, $targetfile) {
+
+ ## Get the image sizes and read it into an image object
+ $sourcefile_id = imagecreatefromjpeg($sourcefile);
+ $width = imageSX($sourcefile_id);
+ $height = imageSY($sourcefile_id);
+
+ ## Settings
+ $vignette_file = "images/vignette" . $height . ".png";
+ $scale = 0.75;
+
+ ## Create a new destination image object
+ $result_id = imagecreatetruecolor($width, $height);
+ $black = imagecolorallocate($result_id, 0, 0, 0);
+ imagefill($result_id, 0, 0, $black);
+
+ ## Read the vignette into an image object
+ $vignette_id = imagecreatefrompng($vignette_file);
+
+ ## Make sure they merge correctly
+ imageAlphaBlending($vignette_id, false);
+ imageSaveAlpha($vignette_id, true);
+
+ ## Create the image
+ imagecopy($sourcefile_id, $vignette_id, 0, 0, 0, 0, $width, $height);
+
+ ## Copy our source image resized into the destination object
+ imagecopyresampled($result_id, $sourcefile_id, 0, 0, 0, 0, $width * $scale, $height * $scale, $width, $height);
+
+ ## Return the JPG
+ imagejpeg ($result_id, $targetfile, 90);
+
+ ## Wrap it up
+ imagedestroy($sourcefile_id);
+ imagedestroy($vignette_id);
+ imagedestroy($result_id);
+}
+
+function rgb2hex($arrColors = null) {
+ if (!is_array($arrColors)) { return "ERR: Invalid input, expecting an array of colors"; }
+ if (count($arrColors) < 3) { return "ERR: Invalid input, array too small (3)"; }
+
+ array_splice($arrColors, 3);
+
+ for ($x = 0; $x < count($arrColors); $x++) {
+ if (strlen($arrColors[$x]) < 1) {
+ return "ERR: One or more empty values found, expecting array with 3 values";
+ }
+
+ elseif (eregi("[^0-9]", $arrColors[$x])) {
+ return "ERR: One or more non-numeric values found.";
+ }
+
+ else {
+ if ((intval($arrColors[$x]) < 0) || (intval($arrColors[$x]) > 255)) {
+ return "ERR: Range mismatch in one or more values (0-255)";
+ }
+
+ else {
+ $arrColors[$x] = strtoupper(str_pad(dechex($arrColors[$x]), 2, 0, STR_PAD_LEFT));
+ }
+ }
+ }
+
+ return implode("", $arrColors);
+}
+
+
+
+
+
+
+
+
+
+## Function to check for special episodes for all season page that air after a season
+function checkspecialallafter($epnum, $specials, $seriesid,$seasonnumber, $seasonid) {
+if ($specials) {
+ ## Get the number of episodes
+ foreach ($specials as $specialepisode) {
+ foreach ($specialepisode as $specialdata) {