forked from chadopp/mythepisode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.php
69 lines (61 loc) · 2.47 KB
/
handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* handler file
*
* @url $URL$
* @date $Date$
* @version $Revision$
* @author $Author$
* @license GPL
*
/**/
// Update include path to include modules/tv classes/includes
ini_set('include_path', ini_get('include_path').':modules/tv');
// Setup some paths
$rootDir = getcwd();
$scriptDir = "$rootDir/modules/episode/utils";
$dataDir = "$rootDir/data";
$epDir = "$dataDir/episode";
$showDir = "$epDir/shows";
$imageDir = "$epDir/images";
$cacheDir = "$epDir/cache";
$wishDir = "$epDir/tvwish";
$configFile = "$epDir/config.ini";
$showsOverride = "$epDir/override.txt";
// Create the episode dir if it doesn't exist
if (!is_dir($epDir) && !mkdir($epDir, 0775)) {
custom_error('Error creating '.$epDir.': Please check permissions on the data directory.');
exit;
}
// Copy configuration file to data/episode if it doesn't exist
if (!file_exists($configFile))
copy("$scriptDir/config.template", "$configFile");
$config = parse_ini_file($configFile, 1);
$defaultView = (empty($config['defaultView'])) ? 'recorded' : $config['defaultView'];
$defaultSite = (empty($config['defaultSite'])) ? 'TVRage.com' : $config['defaultSite'];
$matchPercent = (empty($config['matchPercent'])) ? '85' : $config['matchPercent'];
$maxFileAge = (empty($config['maxFileAge'])) ? '7' : $config['maxFileAge'];
$tvwishHide = (empty($config['tvwishHide'])) ? '0' : $config['tvwishHide'];
$thumbnailSize = (empty($config['thumbnailSize'])) ? '250' : $config['thumbnailSize'];
$countryList = (empty($config['countryList'])) ? 'US' : $config['countryList'];
$mythtvVersion = (empty($config['mythtvVersion'])) ? '.24+' : $config['mythtvVersion'];
// Load classes and includes
require_once 'classes/Common.php';
// Load a custom page
switch ($Path[1]) {
case 'show';
require_once 'modules/episode/show.php';
exit;
case 'episodes';
require_once 'modules/episode/episodes.php';
exit;
case 'tvwish_list';
require_once 'modules/episode/tvwish_list.php';
exit;
case 'previous_recordings';
require_once 'modules/episode/previous_recordings.php';
exit;
default;
require_once 'modules/episode/show.php';
exit;
}