Advertisement
Guest User

install.php autoTvToSab

a guest
Aug 1st, 2010
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 37.81 KB | None | 0 0
  1. <?php defined('SYSPATH') or exit('Install tests must be loaded from within index.php!');
  2.  
  3. function getSabStatus($response) {
  4.     if (preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@', $response, $matches)) {
  5.         return $matches[1];
  6.     }
  7.     return null;
  8. }
  9.  
  10. function testSab($server) {
  11.     $server = preg_replace('#^http://#i', '', $server);
  12.     $fp = @fsockopen($server, 8080, $errno, $errstr, 30);
  13.  
  14.     $page = "/sabnzbd";
  15.     $out = "GET /$page HTTP/1.1\r\n";
  16.     $out .= "Host: $server\r\n";
  17.     $out .= "Connection: Close\r\n\r\n";
  18.     @fwrite($fp,$out);
  19.  
  20.     return (getSabStatus(@fgets($fp)) == 200);
  21. }
  22.  
  23. function getWarnings($server, $apiKey) {
  24.     $query = "/sabnzbd/api?mode=warnings&output=json&apikey=$apiKey";
  25.     $filename = $server.$query;
  26.     $json = json_decode(file_get_contents($filename));
  27.     if (isset($json->status))
  28.         return $json->error;
  29.     else
  30.         return $json->warnings;
  31. }
  32.  
  33. function apacheModuleLoaded($modName) {
  34.     $modules = apache_get_modules();
  35.  
  36.     return in_array($modName, $modules);
  37. }
  38.  
  39. $loadedArr['isPHP_5_2_3'] = version_compare(PHP_VERSION, '5.2.3', '>=');
  40. $loadedArr['curlLoaded'] = extension_loaded('curl');
  41. $loadedArr['mcryptLoaded'] = extension_loaded('mcrypt');
  42. $loadedArr['gdLoaded'] = function_exists('gd_info');
  43. $loadedArr['pdoLoaded'] = class_exists('PDO');
  44.  
  45. $loadedArr['splLoaded'] = function_exists('spl_autoload_register');
  46. $loadedArr['reflectionLoaded'] = class_exists('ReflectionClass');
  47. $loadedArr['filterLoaded'] = function_exists('filter_list');
  48. $loadedArr['iconvLoaded'] = extension_loaded('iconv');
  49. $loadedArr['mbstringLoadeed'] = extension_loaded('mbstring');
  50.  
  51.  
  52. $loadedArr['systemDir'] = is_dir(SYSPATH) AND is_file(SYSPATH.'classes/kohana'.EXT);
  53. $loadedArr['applicationDir'] = is_file(APPPATH.'bootstrap'.EXT);
  54. $loadedArr['cacheDir'] = is_dir(APPPATH.'cache') AND is_writable(APPPATH.'cache');
  55. $loadedArr['logsDir'] = is_dir(APPPATH.'logs') AND is_writable(APPPATH.'logs');
  56. $loadedArr['configDir'] = is_dir(APPPATH.'config') AND is_writable(APPPATH.'config');
  57. if (is_dir(realpath(APPPATH.'../images')) AND
  58.         is_writable(realpath(APPPATH.'../images')) AND
  59.         is_writable(realpath(APPPATH.'../images/__cache')) AND
  60.         is_writable(realpath(APPPATH.'../images/banner')) AND
  61.         is_writable(realpath(APPPATH.'../images/poster')) AND
  62.         is_writable(realpath(APPPATH.'../images/fanart'))) {
  63.     $loadedArr['imagesDir'] = true;
  64. } else {
  65.     $loadedArr['imagesDir'] = false;
  66. }
  67.  
  68. $loadedArr['modeRewriteLoded'] = apacheModuleLoaded('mod_rewrite');
  69.  
  70. $requestUri = preg_replace('/\/index.php/', '', $_SERVER['REQUEST_URI']);
  71. $requestUri = '/' . trim($requestUri, '/') . '/';
  72. $loadedArr['requestUri'] = ($requestUri == '/autoTvToSab/');
  73.  
  74. $loadedArr['utf8Support'] = @preg_match('/^.$/u', 'ñ');
  75. $loadedArr['unicodeSupport'] = @preg_match('/^\pL$/u', 'ñ');
  76. $loadedArr['URI_Determination'] = isset($_SERVER['REQUEST_URI']) OR isset($_SERVER['PHP_SELF']) OR isset($_SERVER['PATH_INFO']);
  77.  
  78.  
  79. $errorMsg = array();
  80. $configSaved = false;
  81. if (filter_has_var(INPUT_GET, 'save')) {
  82. //    var_dump($_GET);
  83.  
  84.     $defs = array(
  85.         'series_autocomplete'  => FILTER_SANITIZE_STRING,
  86.         'use_nzb_site'  => FILTER_SANITIZE_STRING,
  87.         'nzbs_query_string'  => FILTER_SANITIZE_STRING,
  88.         'matrix_api_key'    => FILTER_SANITIZE_STRING,
  89.         'matrix_api_user'    => FILTER_SANITIZE_STRING,
  90.         'thetvdb_api_key'   => FILTER_SANITIZE_STRING,
  91.         'sab_api_key'       => FILTER_SANITIZE_STRING,
  92.         'rss_how_old'       => array('filter'=>FILTER_SANITIZE_STRING,
  93.                                    'options'   => array('min_range' => 4, 'max_range' => 20)),
  94.         'sab_url'           => FILTER_VALIDATE_URL,
  95.         'rss_num_results'   => FILTER_VALIDATE_INT,
  96.         'db_host'           => FILTER_DEFAULT,
  97.         'db_user'           => FILTER_DEFAULT,
  98.         'db_pass'           => FILTER_DEFAULT,
  99.         'db_dbname'         => FILTER_DEFAULT,
  100.               );
  101.  
  102.     $get = filter_input_array(INPUT_GET, $defs);
  103.  
  104.     $link = @mysql_connect($get['db_host'], $get['db_user'], $get['db_pass']);
  105.     if (!$link) {
  106.         $errorMsg[] = "Can not login to the database. Check the login data to the database are correct : " . mysql_error();
  107.     }
  108.  
  109.     $db_selected = @mysql_select_db($get['db_dbname'], $link);
  110.     if (!$db_selected) {
  111.         $errorMsg[] = 'Can\'t use "'.$get['db_dbname'].'" as a database : ' . mysql_error();
  112.     }
  113.  
  114.     if (!testSab($get['sab_url'])) {
  115.         $errorMsg[] = "Incorrect URL: {$get['sab_url']}";
  116.     }
  117.  
  118.     $SabWarnings = getWarnings($get['sab_url'], $get['sab_api_key']);
  119.     if (is_string($SabWarnings)) {
  120.         $errorMsg[] = "SABnzbd error: $SabWarnings";
  121.     }
  122.  
  123.     if (!in_array(false, $loadedArr, true) && !in_array(null, $get, true) && !in_array(false, $get, true) && empty($errorMsg)) {
  124.  
  125.         $config = "<?php defined('SYSPATH') or die('No direct script access.');
  126.  
  127. return array(
  128.    'imdb' => false,
  129.    'default' => array(
  130.        'saveImagesAsNew' => false,
  131.        'cacheTimeImages' => (3600 * 3),
  132.        'TheTvDB_api_key' => '{$get['thetvdb_api_key']}',
  133.        'NzbMatrix_api_key' => '{$get['matrix_api_key']}',
  134.        'NzbMatrix_api_user' => '{$get['matrix_api_user']}',
  135.        'useNzbSite' => '{$get['use_nzb_site']}', //nzbs
  136.    ),
  137.  
  138.    'Sabnzbd' => array(
  139.        'api_key' => '{$get['sab_api_key']}',
  140.        'url' => '{$get['sab_url']}',
  141.    ),
  142.  
  143.    'rss' => array(
  144.        'numberOfResults' => {$get['rss_num_results']},
  145.        'howOld' => '{$get['rss_how_old']}' //\"-1 week\" \"-2 days\" \"-4 hours\" \"-2 seconds\" uses strtotime()
  146.    ),
  147.  
  148.    'nzbs' => array(
  149.        'queryString' => '{$get['nzbs_query_string']}'
  150.    ),
  151. );
  152.  
  153. ?>";
  154.  
  155.         file_put_contents('application/config/default.php', $config);
  156.         $get['db_pass'] = (empty($get['db_pass'])) ? "FALSE": "'{$get['db_pass']}'";
  157.         $config = "<?php defined('SYSPATH') or die('No direct access allowed.');
  158.  
  159. return array
  160. (
  161.     'default' => array
  162.     (
  163.         'type'       => 'mysql',
  164.         'connection' => array(
  165.             /**
  166.              * The following options are available for MySQL:
  167.              *
  168.              * string   hostname
  169.              * string   username
  170.              * string   password
  171.              * boolean  persistent
  172.              * string   database
  173.              *
  174.              * Ports and sockets may be appended to the hostname.
  175.              */
  176.             'hostname'   => '{$get['db_host']}',
  177.             'username'   => '{$get['db_user']}',
  178.             'password'   => {$get['db_pass']},
  179.             'persistent' => FALSE,
  180.             'database'   => '{$get['db_dbname']}',
  181.         ),
  182.         'table_prefix' => '',
  183.         'charset'      => 'utf8',
  184.         'caching'      => FALSE,
  185.         'profiling'    => TRUE,
  186.     ),
  187.     'alternate' => array(
  188.         'type'       => 'pdo',
  189.         'connection' => array(
  190.             /**
  191.              * The following options are available for PDO:
  192.              *
  193.              * string   dsn
  194.              * string   username
  195.              * string   password
  196.              * boolean  persistent
  197.              * string   identifier
  198.              */
  199.             'dsn'        => 'mysql:host=localhost;dbname=kohana',
  200.             'username'   => 'root',
  201.             'password'   => 'r00tdb',
  202.             'persistent' => FALSE,
  203.         ),
  204.         'table_prefix' => '',
  205.         'charset'      => 'utf8',
  206.         'caching'      => FALSE,
  207.         'profiling'    => TRUE,
  208.     ),
  209. );";
  210.  
  211.         file_put_contents('application/config/database.php', $config);
  212.  
  213.         $configSaved = true;
  214.     }
  215.  
  216. }
  217. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  218.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  219.  
  220. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  221.     <head>
  222.  
  223.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  224.         <title>AutoTvToSab Installation</title>
  225.  
  226.         <script type="text/javascript" src="js/jQuery.js"></script>
  227.  
  228.         <script type="text/javascript">
  229.             function isUrl(s) {
  230.                 var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
  231.                 return regexp.test(s);
  232.             }
  233.  
  234.  
  235.             var isNumber = function(num) {
  236.                 //return typeof o === 'number' && isFinite(o);
  237.                 var RE = /^-{0,1}\d*\.{0,1}\d+$/;
  238.                 return (RE.test(num));
  239.             }
  240.  
  241.             $.fn.extend({
  242.                 scrollTo : function(speed, easing) {
  243.                     return this.each(function() {
  244.                         var targetOffset = $(this).offset().top;
  245.                         $('html,body').animate({scrollTop: targetOffset}, speed, easing);
  246.                     });
  247.                 }
  248.             });
  249.  
  250.             $(document).ready(function(){
  251.                 //hide message_body after the first one
  252.                 $(".message_list .message_body:gt(3)").hide();
  253.                 $(".message_head:lt(4) cite").removeClass('down').addClass('up');
  254.  
  255.                 var collapsNum = 5;
  256.                 //hide message li after the 5th
  257.                 $(".message_list li:gt("+collapsNum+")").hide();
  258.  
  259.                 //toggle message_body
  260.                 $(".message_head").click(function(){
  261.  
  262.                     if ($(this).find('cite').hasClass('up')) $(this).find('cite').removeClass('up').addClass('down')
  263.                     else $(this).find('cite').removeClass('down').addClass('up')
  264.  
  265.                     $(this).next(".message_body").slideToggle(500)
  266.                     return false;
  267.                 });
  268.  
  269.                 <?php if (in_array(false, $loadedArr, true)) { ?>
  270.                     $(".message_list .environment").show();
  271.                     $("#environment_header").scrollTo(1000)
  272.                 <?php } ?>
  273.  
  274.                 //collapse all messages
  275.                 $(".collpase_all_message").click(function(){
  276.                     $(".message_body").slideUp(500)
  277.                     return false;
  278.                 });
  279.  
  280.                 //show all messages
  281. //                $(".show_all_message").click(function(){
  282. //                    $(this).hide()
  283. //                    $(".show_recent_only").show()
  284. //                    $(".message_list li:gt("+collapsNum+")").slideDown()
  285. //                    return false;
  286. //                });
  287. //
  288. //                //show recent messages only
  289. //                $(".show_recent_only").click(function(){
  290. //                    $(this).hide()
  291. //                    $(".show_all_message").show()
  292. //                    $(".message_list li:gt("+collapsNum+")").slideUp()
  293. //                    return false;
  294. //                });
  295.  
  296.  
  297.                 $(":input").focus(function(){
  298.                     if ($(this).hasClass("needsfilled") ) {
  299.                         $(this).val("");
  300.                         $(this).removeClass("needsfilled");
  301.                         $(this).parents('div.message_body').prev().removeClass('error');
  302.                     }
  303.                 });
  304.  
  305.  
  306.  
  307.                 var required = ["sab_api_key", "matrix_api_key", "thetvdb_api_key", "rss_num_results",
  308.                     "rss_how_old", "db_host", "db_user", /*"db_pass", */"db_dbname"];
  309.                 // If using an ID other than #email or #error then replace it here
  310.                 var url = $("#sab_url");
  311.                 var errornotice = $("#error");
  312.                 var rssNum = $("#rss_num_results");
  313.                 // The text to show up within a field when it is incorrect
  314.                 var emptyError = "Please fill out this field.";
  315.                 var urlError = "Please enter a valid url.";
  316.                 var numError = "Please enter a valid number.";
  317.  
  318.  
  319.  
  320.                 $('form').submit(function (e) {
  321.                     $('.message_list .message_head').removeClass('error');
  322.  
  323.                     for (i = 0; i < required.length; i++) {
  324.                         var input = $('#'+required[i]);
  325.                         if ((input.val() == "") || (input.val() == emptyError)) {
  326.                             input.addClass("needsfilled");
  327.                             input.parents('div.message_body').prev().addClass('error');
  328.                             input.val(emptyError);
  329.                             errornotice.fadeIn(750);
  330.                         } else {
  331.                             input.removeClass("needsfilled");
  332.                         }
  333.                     }
  334.  
  335.                     if (!isUrl(url.val())) {
  336.                         url.val(urlError);
  337.                         url.addClass("needsfilled");
  338.                         url.parents('div.message_body').prev().addClass('error');
  339.                         errornotice.fadeIn(750);
  340.                     }
  341.  
  342.                     if (!isNumber(rssNum.val())) {
  343.                         rssNum.val(numError);
  344.                         rssNum.addClass("needsfilled");
  345.                         rssNum.parents('div.message_body').prev().addClass('error');
  346.                         errornotice.fadeIn(750);
  347.                     }
  348.  
  349.                     if ($(":input").hasClass("needsfilled")) {
  350.                         return false;
  351.                     } else {
  352.                         errornotice.hide();
  353.                         return true;
  354.                     }
  355.                 });
  356.  
  357.             });
  358.  
  359.             $(document).ready(function(){
  360.                 $('#nzb_matrix').click(function () {
  361.                     $('#nzbs_wrapper').hide().find('input').removeClass('needsfilled');
  362.                     $('#nzb_matrix_wrapper').show().find('input').each(function (){
  363.                         var input = $(this);
  364.                         if (input.val() == '') {
  365.                             input.addClass('needsfilled');
  366.                         }
  367.                     });
  368.                 });
  369.                 $('#nzbs').click(function () {
  370.                     $('#nzb_matrix_wrapper').hide().find('input').removeClass('needsfilled');
  371.                     $('#nzbs_wrapper').show().find('input').each(function (){
  372.                         var input = $(this);
  373.                         if (input.val() == '') {
  374.                             input.addClass('needsfilled');
  375.                         }
  376.                     });
  377.                 });
  378.                 $('#both').click(function () {
  379.                     $('#nzb_matrix_wrapper').show().find('input').find('input').each(function (){
  380.                         var input = $(this);
  381.                         if (input.val() == '') {
  382.                             input.addClass('needsfilled');
  383.                         }
  384.                     });
  385.                     $('#nzbs_wrapper').show().find('input').find('input').each(function (){
  386.                         var input = $(this);
  387.                         if (input.val() == '') {
  388.                             input.addClass('needsfilled');
  389.                         }
  390.                     });
  391.                 });
  392.             });
  393.  
  394.         </script>
  395.  
  396.  
  397.  
  398.         <style type="text/css">
  399.             body { width: 42em; margin: 0 auto; font-family: sans-serif; background: #fff; font-size: 1em; }
  400.             h2 { letter-spacing: -0.04em; }
  401.             h2 + p { margin: 0 0 2em; color: #333; font-size: 90%; font-style: italic; }
  402.             code { font-family: monaco, monospace; }
  403.             table { border-collapse: collapse; width: 100%; }
  404.             table th,
  405.             table td { padding: 0.4em; text-align: left; vertical-align: top; }
  406.             table th { width: 12em; font-weight: normal; }
  407.             table tr:nth-child(odd) { background: #eee; }
  408.             table td.pass { color: #191; }
  409.             table td.fail { color: #911; }
  410.             #results { padding: 0.8em; color: #fff; font-size: 1.5em; }
  411.             #results.pass { background: #191; }
  412.             #results.fail { background: #911; }
  413.  
  414.             /*body {
  415.     margin: 10px auto;
  416.     width: 570px;
  417.     font: 75%/120% Arial, Helvetica, sans-serif;
  418.             }*/
  419.             p {
  420.                 padding: 0 0 1em;
  421.             }
  422.             /* message display page */
  423.             .message_list {
  424.                 list-style: none;
  425.                 margin: 0;
  426.                 padding: 0;
  427.                 width: 42em;
  428.             }
  429.             .message_list li {
  430.                 padding: 0;
  431.                 margin: 0;
  432.                 background: url(images/message-bar.gif) no-repeat;
  433.             }
  434.             .message_head {
  435.                 padding: 5px 10px;
  436.                 cursor: pointer;
  437.                 position: relative;
  438.                 background: #eee;
  439.             }
  440.             .message_head .order {
  441.                 color: #666666;
  442.                 font-size: 95%;
  443.                 position: absolute;
  444.                 right: 10px;
  445.                 top: 5px;
  446.             }
  447.             .message_head cite {
  448.                 font-size: 100%;
  449.                 font-weight: bold;
  450.                 font-style: normal;
  451.                 padding-left: 24px;
  452.             }
  453.             .message_body {
  454.                 padding: 5px 10px 15px;
  455.             }
  456.  
  457.             .message_body div {
  458.                 clear: both;
  459.             }
  460.             .collapse_buttons {
  461.                 text-align: right;
  462.                 border-top: solid 1px #e4e4e4;
  463.                 padding: 5px 0;
  464.                 width: 383px;
  465.             }
  466.             .collapse_buttons a {
  467.                 margin-left: 15px;
  468.                 float: right;
  469.             }
  470.  
  471.             .show_all_message {
  472.                 background: url(images/tall-down-arrow.gif) no-repeat right center;
  473.                 padding-right: 12px;
  474.             }
  475.             .show_recent_only {
  476.                 display: none;
  477.                 background: url(images/tall-up-arrow.gif) no-repeat right center;
  478.                 padding-right: 12px;
  479.             }
  480.             .collpase_all_message {
  481.                 background: url(images/collapse-all.gif) no-repeat right center;
  482.                 padding-right: 12px;
  483.                 color: #666666;
  484.             }
  485.  
  486.             #error {
  487.                 color: #911;
  488.                 font-size:10px;
  489.                 display:none;
  490.             }
  491.             .needsfilled, .error {
  492.                 background: #911;
  493.                 color:white;
  494.             }
  495.  
  496.  
  497.             label {
  498.                 float: left;
  499.                 width: 155px;
  500.                 margin-right: 10px;
  501.             }
  502.  
  503.             label:hover {
  504.                 background: #e4e4e4;
  505.             }
  506.  
  507.  
  508.  
  509.             .message_head cite.up {
  510.                 background: url(images/arrow-square.gif) no-repeat 0 2px;
  511.                 padding-right: 50px;
  512.             }
  513.             .message_head cite.down {
  514.                 background: url(images/arrow-square.gif) no-repeat 0 -54px;
  515.             }
  516.  
  517.             div.fail {
  518.                 background: orange;
  519.                 padding: 0.8em;
  520.                 color: #fff;
  521.                 font-size: 1.5em;
  522.             }
  523.  
  524.         </style>
  525.  
  526.     </head>
  527.     <body>
  528.         <?php if ($configSaved) { ?>
  529.         <p id="results" class="pass">✔ Your environment passed all requirements.<br />
  530.             Remove or rename the <code>install<?php echo EXT ?></code> file now.</p>
  531.         <?php if (isset($SabWarnings) && is_array($SabWarnings) && !empty($SabWarnings)) { ?>
  532.         <p class="fail">SABnzbd errors:</p>
  533.         <ul class="fail">
  534.             <li><?php echo implode('</li><li>', $SabWarnings)?></li>
  535.         </ul>
  536.        <?php } ?>
  537.         <?php } else { ?>
  538.  
  539.         <?php if (!empty($errorMsg)) { ?>
  540.         <?php foreach ($errorMsg as $msg) { ?>
  541.             <p id="results" class="fail">✘ <?php echo $msg ?></p>
  542.             <?php }
  543.         } ?>
  544.         <h2>Fields marked in red are important</h2>
  545.         <p>Follow the instructions <a href="http://sourceforge.net/apps/trac/autotvtosab/">here</a> before continuing.</p>
  546.         <p id="error">You have an error in the installation form</p>
  547.         <form action="#" method="get">
  548.         <ol class="message_list">
  549.             <li>
  550.  
  551.                 <p class="message_head"><cite class="down">Databas variables</cite> <span class="order">1</span></p>
  552.                 <div class="message_body">
  553.                     <div>
  554.                         <label for="db_host">Hostname</label>
  555.                         <input type="text" name="db_host" id="db_host" value="<?php if (isset($get['db_host'])) echo $get['db_host']; else echo 'localhost'; ?>" size="35" />
  556.                     </div>
  557.                     <div>
  558.                         <label for="db_user">Username</label>
  559.                         <input type="text" name="db_user" id="db_user" size="35" class="<?php if (!isset($get['db_user'])) echo 'needsfilled'?>" value="<?php if (isset($get['db_user'])) echo $get['db_user'] ?>" />
  560.                     </div>
  561.                     <div>
  562.                         <label for="db_pass">Password</label>
  563.                         <input type="password" name="db_pass" id="db_pass" size="35" class="<?php if (!isset($get['db_pass'])) echo 'needsfilled'?>" />
  564.                     </div>
  565.                     <div>
  566.                         <label for="db_dbname">Database name</label>
  567.                         <input type="text" name="db_dbname" id="db_dbname" size="35" class="<?php if (!isset($get['db_dbname'])) echo 'needsfilled'?>" value="<?php if (isset($get['db_dbname'])) echo $get['db_dbname'] ?>" />
  568.                     </div>
  569.                 </div>
  570.  
  571.             </li>
  572.             <li>
  573.  
  574.                 <p class="message_head"><cite class="down">Set Sabnzbd variables</cite> <span class="order">2</span></p>
  575.                 <div class="message_body">
  576.                     <div>
  577.                         <label for="sab_url">Sabnzbd url</label>
  578.                         <input type="text" name="sab_url" id="sab_url" value="<?php if (isset($get['sab_url'])) echo $get['sab_url']; else echo 'http://localhost:8080'; ?>" size="35" />
  579.                     </div>
  580.                     <div>
  581.                         <label for="sab_api_key">Sabnzbd api key</label>
  582.                         <input type="text" name="sab_api_key" id="sab_api_key" size="35" value="<?php if (isset($get['sab_api_key'])) echo $get['sab_api_key'] ?>" class="<?php if (!isset($get['sab_api_key'])) echo 'needsfilled'?>" />
  583.                     </div>
  584.                 </div>
  585.  
  586.             </li>
  587.             <li>
  588.                 <p class="message_head"><cite class="down">Set NZB site variables</cite> <span class="order">3</span></p>
  589.                 <div class="message_body">
  590.                     <div>
  591.                         <label for="matrix_api_key">Use NZB Site</label>
  592.                         Use NZB Matrix<input type="radio" name="use_nzb_site" value="nzbMatrix" id="nzb_matrix" />
  593.                         Use NZBs.org<input type="radio" name="use_nzb_site" value="nzbs" id="nzbs" />
  594.                         Use Both<input type="radio" name="use_nzb_site" value="both" id="both" />
  595.                     </div>
  596.                     <div id="nzb_matrix_wrapper">
  597.                         <div>
  598.                             <label for="matrix_api_key">NZB Matrix api key</label>
  599.                             <input type="text" name="matrix_api_key" id="matrix_api_key" size="35" value="<?php if (isset($get['matrix_api_key'])) echo $get['matrix_api_key'] ?>" class="<?php if (!isset($get['matrix_api_key'])) echo 'needsfilled'?>" />
  600.                         </div>
  601.                         <div>
  602.                             <label for="matrix_api_user">NZB Matrix username</label>
  603.                             <input type="text" name="matrix_api_user" id="matrix_api_user" size="35" value="<?php if (isset($get['matrix_api_user'])) echo $get['matrix_api_user'] ?>" class="<?php if (!isset($get['matrix_api_user'])) echo 'needsfilled'?>" />
  604.                         </div>
  605.                         <div>
  606.                             If you dont have an VIP account on Nzbmatrix.com
  607.                             <a href="http://nzbmatrix.com/account-signup.php">click here</a>
  608.                             and register for one
  609.                         </div>
  610.                     </div>
  611.                     <div id="nzbs_wrapper" style="display: none;">
  612.                         <div>
  613.                             <label for="nzbs_query_string">NZBs.org URL String</label>
  614.                             <input type="text" name="nzbs_query_string" id="nzbs_query_string" size="35" value="<?php if (isset($get['nzbs_query_string'])) echo $get['nzbs_query_string'] ?>" />
  615.                         </div>
  616.                     </div>
  617.                 </div>
  618.             </li>
  619.  
  620.             <li>
  621.                 <p class="message_head"><cite class="down">Set Thetvdb.com variables</cite> <span class="order">4</span></p>
  622.                 <div class="message_body">
  623.                     <div>
  624.                         <label for="thetvdb_api_key">Thetvdb.com api key</label>
  625.                         <input type="text" name="thetvdb_api_key" id="thetvdb_api_key" size="35" value="<?php if (isset($get['thetvdb_api_key'])) echo $get['thetvdb_api_key'] ?>" class="<?php if (!isset($get['thetvdb_api_key'])) echo 'needsfilled'?>" />
  626.                     </div>
  627.                     <div>
  628.                         If you dont have an account on Thetvdb.com
  629.                         <a href="http://thetvdb.com/?tab=register">click here</a>
  630.                         and register for one
  631.                     </div>
  632.                 </div>
  633.             </li>
  634.             <li>
  635.                 <p class="message_head"><cite class="down">RSS variables</cite> <span class="order">5</span></p>
  636.                 <div class="message_body">
  637.                     <p>Do not touch unless you know what you are doing</p>
  638.                     <div>
  639.                         <label for="rss_num_results">Rss number of results</label>
  640.                         <input type="text" name="rss_num_results" id="rss_num_results" value="<?php if (isset($get['rss_num_results'])) echo $get['rss_num_results']; else echo '10' ?>" />
  641.                     </div>
  642.                     <div>
  643.                         <label for="rss_how_old">How old the results should be</label>
  644.                         <input type="text" name="rss_how_old" id="rss_how_old" value="<?php if (isset($get['rss_how_old'])) echo $get['rss_how_old']; else echo '-1 days' ?>" />
  645.                         <em>Example: -1 week or -4 hours</em>
  646.                     </div>
  647.                 </div>
  648.             </li>
  649.             <li>
  650.                 <p id="environment_header" class="message_head"><cite class="down">Environment Tests</cite> <span class="order">6</span></p>
  651.                 <div class="message_body environment">
  652.                     <p>
  653.                         The following tests have been run to determine if AutoTvToSab will work in your environment.
  654.                     </p>
  655.  
  656.                     <?php $failed = FALSE ?>
  657.  
  658.                     <table cellspacing="0">
  659.                         <tr>
  660.                             <th>PHP Version</th>
  661.                             <?php if ($loadedArr['isPHP_5_2_3']): ?>
  662.                             <td class="pass"><?php echo PHP_VERSION ?></td>
  663.                             <?php else: $failed = TRUE ?>
  664.                             <td class="fail">AutoTvToSab requires PHP 5.2.3 or newer, this version is <?php echo PHP_VERSION ?>.</td>
  665.                             <?php endif ?>
  666.                         </tr>
  667.                         <tr>
  668.                             <th>System Directory</th>
  669.                             <?php if (is_dir(SYSPATH) AND is_file(SYSPATH.'classes/kohana'.EXT)): ?>
  670.                             <td class="pass"><?php echo SYSPATH ?></td>
  671.                             <?php else: $failed = TRUE ?>
  672.                             <td class="fail">The configured <code>system</code> directory does not exist or does not contain required files.</td>
  673.                             <?php endif ?>
  674.                         </tr>
  675.                         <tr>
  676.                             <th>Application Directory</th>
  677.                             <?php if (is_dir(APPPATH) AND is_file(APPPATH.'bootstrap'.EXT)): ?>
  678.                             <td class="pass"><?php echo APPPATH ?></td>
  679.                             <?php else: $failed = TRUE ?>
  680.                             <td class="fail">The configured <code>application</code> directory does not exist or does not contain required files.</td>
  681.                             <?php endif ?>
  682.                         </tr>
  683.                         <tr>
  684.                             <th>Cache Directory</th>
  685.                             <?php if ($loadedArr['cacheDir']): ?>
  686.                             <td class="pass"><?php echo APPPATH.'cache/' ?></td>
  687.                             <?php else: $failed = TRUE ?>
  688.                             <td class="fail">The <code><?php echo APPPATH.'cache/' ?></code> directory is not writable.</td>
  689.                             <?php endif ?>
  690.                         </tr>
  691.                         <tr>
  692.                             <th>Logs Directory</th>
  693.                             <?php if ($loadedArr['logsDir']): ?>
  694.                             <td class="pass"><?php echo APPPATH.'logs/' ?></td>
  695.                             <?php else: $failed = TRUE ?>
  696.                             <td class="fail">The <code><?php echo APPPATH.'logs/' ?></code> directory is not writable.</td>
  697.                             <?php endif ?>
  698.                         </tr>
  699.                         <tr>
  700.                             <th>Config Directory</th>
  701.                             <?php if ($loadedArr['configDir']): ?>
  702.                             <td class="pass"><?php echo APPPATH.'config/' ?></td>
  703.                             <?php else: $failed = TRUE ?>
  704.                             <td class="fail">The <code><?php echo APPPATH.'config/' ?></code> directory is not writable.</td>
  705.                             <?php endif ?>
  706.                         </tr>
  707.                         <tr>
  708.                             <th>Images Directory</th>
  709.                             <?php if ($loadedArr['imagesDir']): ?>
  710.                             <td class="pass"><?php echo APPPATH.'images/' ?></td>
  711.                             <?php else: $failed = TRUE ?>
  712.                             <td class="fail">The <code><?php echo APPPATH.'images/' ?></code> directory or it´s subdirectories is not writable.</td>
  713.                             <?php endif ?>
  714.                         </tr>
  715.                         <tr>
  716.                             <th>PCRE UTF-8</th>
  717.                             <?php if ( ! @preg_match('/^.$/u', 'ñ')): $failed = TRUE ?>
  718.                             <td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with UTF-8 support.</td>
  719.                             <?php elseif ( ! @preg_match('/^\pL$/u', 'ñ')): $failed = TRUE ?>
  720.                             <td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with Unicode property support.</td>
  721.                             <?php else: ?>
  722.                             <td class="pass">Pass</td>
  723.                             <?php endif ?>
  724.                         </tr>
  725.                         <tr>
  726.                             <th>SPL Enabled</th>
  727.                             <?php if ($loadedArr['splLoaded']): ?>
  728.                             <td class="pass">Pass</td>
  729.                             <?php else: $failed = TRUE ?>
  730.                             <td class="fail">PHP <a href="http://www.php.net/spl">SPL</a> is either not loaded or not compiled in.</td>
  731.                             <?php endif ?>
  732.                         </tr>
  733.                         <tr>
  734.                             <th>Reflection Enabled</th>
  735.                             <?php if ($loadedArr['reflectionLoaded']): ?>
  736.                             <td class="pass">Pass</td>
  737.                             <?php else: $failed = TRUE ?>
  738.                             <td class="fail">PHP <a href="http://www.php.net/reflection">reflection</a> is either not loaded or not compiled in.</td>
  739.                             <?php endif ?>
  740.                         </tr>
  741.                         <tr>
  742.                             <th>Filters Enabled</th>
  743.                             <?php if ($loadedArr['filterLoaded']): ?>
  744.                             <td class="pass">Pass</td>
  745.                             <?php else: $failed = TRUE ?>
  746.                             <td class="fail">The <a href="http://www.php.net/filter">filter</a> extension is either not loaded or not compiled in.</td>
  747.                             <?php endif ?>
  748.                         </tr>
  749.                         <tr>
  750.                             <th>Iconv Extension Loaded</th>
  751.                             <?php if ($loadedArr['iconvLoaded']): ?>
  752.                             <td class="pass">Pass</td>
  753.                             <?php else: $failed = TRUE ?>
  754.                             <td class="fail">The <a href="http://php.net/iconv">iconv</a> extension is not loaded.</td>
  755.                             <?php endif ?>
  756.                         </tr>
  757.                         <?php if ($loadedArr['mbstringLoadeed']): ?>
  758.                         <tr>
  759.                             <th>Mbstring Not Overloaded</th>
  760.                                 <?php if (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING): $failed = TRUE ?>
  761.                             <td class="fail">The <a href="http://php.net/mbstring">mbstring</a> extension is overloading PHP's native string functions.</td>
  762.                                 <?php else: ?>
  763.                             <td class="pass">Pass</td>
  764.                                 <?php endif ?>
  765.                         </tr>
  766.                         <?php endif ?>
  767.                         <tr>
  768.                             <th>URI Determination</th>
  769.                             <?php if (isset($_SERVER['REQUEST_URI']) OR isset($_SERVER['PHP_SELF']) OR isset($_SERVER['PATH_INFO'])): ?>
  770.                             <td class="pass">Pass</td>
  771.                             <?php else: $failed = TRUE ?>
  772.                             <td class="fail">Neither <code>$_SERVER['REQUEST_URI']</code>, <code>$_SERVER['PHP_SELF']</code>, or <code>$_SERVER['PATH_INFO']</code> is available.</td>
  773.                             <?php endif ?>
  774.                         </tr>
  775.                         <tr>
  776.                             <th>cURL Enabled</th>
  777.                             <?php if ($loadedArr['curlLoaded']): ?>
  778.                             <td class="pass">Pass</td>
  779.                             <?php else: ?>
  780.                             <td class="fail">AutoTvToSab requires <a href="http://php.net/curl">cURL</a> for the Remote class.</td>
  781.                             <?php endif ?>
  782.                         </tr>
  783.                         <tr>
  784.                             <th>GD Enabled</th>
  785.                             <?php if ($loadedArr['gdLoaded']): ?>
  786.                             <td class="pass">Pass</td>
  787.                             <?php else: ?>
  788.                             <td class="fail">AutoTvToSab requires <a href="http://php.net/gd">GD</a> v2 for the Image class.</td>
  789.                             <?php endif ?>
  790.                         </tr>
  791.                         <tr>
  792.                             <th>Base url</th>
  793.                             <?php if ($loadedArr['requestUri']): ?>
  794.                             <td class="pass">Pass</td>
  795.                             <?php else: ?>
  796.                             <td class="fail">AutoTvToSab requires this line <code>'base_url' => '/autoTvToSab/',</code> in application/bootstrap.php to be set to <code>'base_url' => '<?php echo $requestUri?>'</code>.</td>
  797.                             <?php endif ?>
  798.                         </tr>
  799.                         <tr>
  800.                             <th colspan="2">Optional</th>
  801.                         </tr>
  802.                         <tr>
  803.                             <th>Apache mod_rewrite</th>
  804.                             <?php if ($loadedArr['modeRewriteLoded']): ?>
  805.                             <td class="pass">Pass</td>
  806.                             <?php else: $failed = TRUE ?>
  807.                             <td class="fail">
  808.                                 AutoTvToSab requires <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> to rewrite requested URLs on the fly.
  809.                                 You can use autoTvToSab without mod_rewrite. But then you must change this line <code>'index_file' => FALSE,</code> in application/bootstrap.php to
  810.                                 <code>'index_file' => 'index.php',</code> and delete the .htaccess file.
  811.                             </td>
  812.                             <?php endif ?>
  813.                         </tr>
  814.                         <tr>
  815.                             <th>mcrypt Enabled</th>
  816.                             <?php if ($loadedArr['mcryptLoaded']): ?>
  817.                             <td class="pass">Pass</td>
  818.                             <?php else: ?>
  819.                             <td class="fail">AutoTvToSab requires <a href="http://php.net/mcrypt">mcrypt</a> for the Encrypt class.</td>
  820.                             <?php endif ?>
  821.                         </tr>
  822.                         <tr>
  823.                             <th>PDO Enabled</th>
  824.                             <?php if ($loadedArr['pdoLoaded']): ?>
  825.                             <td class="pass">Pass</td>
  826.                             <?php else: ?>
  827.                             <td class="fail">AutoTvToSab can use <a href="http://php.net/pdo">PDO</a> to support additional databases.</td>
  828.                             <?php endif ?>
  829.                         </tr>
  830.                     </table>
  831.  
  832.                     <?php if ($failed === TRUE || in_array(false, $loadedArr, true)): ?>
  833.                     <p id="results" class="fail">✘ AutoTvToSab may not work correctly with your environment.</p>
  834.                     <?php endif ?>
  835.                 </div>
  836.             </li>
  837.         </ol>
  838.             <p>
  839.                 <input type="submit" name="save" value="save" />
  840.             </p>
  841.         <p class="collapse_buttons">
  842.             <!--<a href="#" class="show_all_message">Show all message (9)</a>
  843.             <a href="#" class="show_recent_only">Show 5 only</a>-->
  844.             <a href="#" class="collpase_all_message">Collapse all</a>
  845.         </p>
  846.         </form>
  847.         <?php } ?>
  848.     </body>
  849. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement