Zachary Kotlarek 13 лет назад
Родитель
Сommit
151e4a8a5b
6 измененных файлов с 97 добавлено и 1 удалено
  1. 2 1
      web/includes/display.php
  2. 1 0
      web/includes/main.php
  3. 24 0
      web/includes/season.php
  4. 39 0
      web/includes/series.php
  5. 23 0
      web/includes/tvdb.php
  6. 8 0
      web/index.php

+ 2 - 1
web/includes/display.php

@@ -22,6 +22,7 @@ function printShow($show) {
 	# Header
 	echo '<h1>' . htmlspecialchars($show) . '</h1>';
 	echo '<form action="' . $SERVER['PHP_SELF'] . '" method="post">';
+	echo '<input type="hidden" name="show" value="' . htmlspecialchars($show) . '"/>';
 
 	# Exists and content flags
 	echo '<h2>Series Parameters</h2>';
@@ -68,7 +69,7 @@ function printShow($show) {
 	echo '</p>';
 
 	# Footer
-	echo '<p><input type="submit" name="submit" value="Save"/></p>';
+	echo '<p><input type="submit" name="Save" value="Save"/></p>';
 	echo '</form>';
 }
 

+ 1 - 0
web/includes/main.php

@@ -7,6 +7,7 @@ require_once 'webloc.php';
 require_once 'season.php';
 require_once 'series.php';
 
+require_once 'tvdb.php';
 require_once 'display.php';
 
 ?>

+ 24 - 0
web/includes/season.php

@@ -77,4 +77,28 @@ function findSeasons($path) {
 	return $retval;
 }
 
+# Save the search status for all seasons in a series
+function saveSeasons($data) {
+}
+
+# Add a folder for the provided show and season
+function addSeason($show, $season) {
+	global $TV_DIR;
+
+	# Ensure the show exists
+	$show_path = $TV_DIR . '/' . $show;
+	if (!is_dir($show_path)) {
+		die('Invalid show: ' . htmlspecialchars($show) . "\n");
+	}
+
+	# Ensure the season does not exist
+	$season_path = $show_path . '/Season ' . intval($season);
+	if (file_exists($season_path)) {
+		die('Invalid season: ' . htmlspecialchars($season) . "\n");
+	}
+
+	# Create the directory
+	mkdir($season_path);
+}
+
 ?>

+ 39 - 0
web/includes/series.php

@@ -64,4 +64,43 @@ function readFlags($path) {
 	return $flags;
 }
 
+# Parse and save all of the serires-level exists and content files
+function saveFlags($show, $data) {
+	global $TV_PATH;
+	global $EXISTS_FILES;
+	global $CONTENT_FILES;
+
+	$series_path = $TV_PATH . '/' . $show;
+
+	# Exists files
+	foreach ($EXISTS_FILES as $file) {
+		$path = $series_path . '/' . $file;
+		if ($data[ $file ]) {
+			if (!file_exists($path)) {
+				touch($path);
+			}
+		} else {
+			if (file_exists($path)) {
+				unlink($path);
+			}
+		}
+	}
+
+	# Content files
+	foreach ($CONTENT_FILES as $file) {
+		$path = $series_path . '/' . $file;
+		if ($data[ $file ]) {
+			file_put_contents($path, $data[ $file ]);
+		} else {
+			if (file_exists($path)) {
+				unlink($path);
+			}
+		}
+	}
+}
+
+# Add a series as identified by TVDB ID
+function addSeries($id) {
+}
+
 ?>

+ 23 - 0
web/includes/tvdb.php

@@ -0,0 +1,23 @@
+<?
+
+require 'config.php';
+
+# Get the title of a TVDB entity
+function getTVDBTitle($id) {
+	$retval = false;
+	return $retval;
+}
+
+# Get the seasons of a TVDB entity
+function getTVDBSeasons($id) {
+	$retval = false;
+	return $retval;
+}
+
+# Search TVDB for the named show and return all likely results
+function findTVDBShow($show) {
+	$retval = false;
+	return $retval;
+}
+
+?>

+ 8 - 0
web/index.php

@@ -14,6 +14,14 @@ if (isset($_REQUEST['show'])) {
 	$show = basename($show);
 }
 
+# Did the user request an update?
+if ($show !== false && isset($_POST['Save'])) {
+	echo '<h4 style="color: red;">Saving not yet implemented</h4>';
+
+	#saveFlags($show, $_POST);
+	saveSeasons($show, $_POST);
+}
+
 #=========================================================================================
 
 # Generic XHTML 1.1 header