} if (isset($save_tvlinks) && $save_tvlinks && isset($_POST['tvlinks'])) { if (!defined("DEMO") || !DEMO) { $tvlinks = $_POST['tvlinks']; $tv_errors = array(); if (!isset($tvlinks['username']) || !$tvlinks['username']) { $tv_errors[1] = "Please enter your TV-links username"; } if (!isset($tvlinks['password']) || !$tvlinks['password']) { $tv_errors[1] = "Please enter your TV-links password"; } if (!count($tv_errors)) { require_once "../includes/tvlinks.class.php"; require_once "../includes/curl.php"; $curl_test = new Curl(); $tvlinks_test = new TVlinks($curl_test); if ($tvlinks_test->login($tvlinks['username'], $tvlinks['password'])) { $settings->addSetting("tvlinks", json_encode($tvlinks)); $tv_success = true; } else { $tv_errors[1] = "Can't login with these details"; } } } } else { $tvlinks = $settings->getSetting("tvlinks", true); if (defined("DEMO") && DEMO && $tvlinks && !empty($tvlinks)) { foreach ($tvlinks as $key => $val) { $tvlinks[$key] = "HIDDEN IN DEMO"; } }
} if (!$id) { $return = array("status" => 99); print json_encode($return); exit; } require_once "../../vars.php"; require_once "../../includes/curl.php"; require_once "../../includes/show.class.php"; require_once "../../includes/settings.class.php"; require_once "../../includes/tvlinks.class.php"; $settings = new Settings(); $shows = new Show(); $curl = new Curl(); $curl->setCookieFile($basepath . "/cachefiles/tvlinkscookie.txt"); $tv = new TVlinks($curl); sleep(2); $return = array(); if (isset($id) && $id && is_numeric($id)) { $show = $shows->getEpisodeById($id, "en"); if (count($show)) { $sr = $settings->getSetting("tvlinks"); if ($tv->login($sr->username, $sr->password)) { $url = $baseurl . $show['url']; $link = $tv->submit($show['showtitle'], $show['season'], $show['episode'], $url); if ($link) { $shows->addSubmit($id, 7, $link); $return['status'] = 1; $return['link'] = $link; } else { $return['status'] = 2;