CptChaos

Spotweb's ownsettings.php generator

Mar 12th, 2011
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.79 KB | None | 0 0
  1. <?php
  2. if($_POST)
  3. {
  4.     header("Content-type: application/php");
  5.     header("Content-Disposition:attachment;filename=ownsettings.php");
  6.     echo '<?php'. PHP_EOL;
  7.     if(!empty($_POST['settings']))
  8.     {
  9.         echo '# Instellingen voor NZB- of update knop'. PHP_EOL;
  10.         foreach($_POST['settings'] as $key => $val)
  11.         {
  12.             if($val != 'true')
  13.             {
  14.                 echo '$settings[\''. $key .'\'] = \''. $val .'\';'. PHP_EOL;
  15.             }
  16.             else
  17.             {
  18.                 echo '$settings[\''. $key .'\'] = '. $val .';'. PHP_EOL;
  19.             }
  20.         }
  21.         echo PHP_EOL;
  22.     }
  23.    
  24.     if(!empty($_POST['prefs']))
  25.     {
  26.         echo '# Deze instelling zet het aantal spots per pagina'. PHP_EOL;
  27.         foreach($_POST['prefs'] as $key => $val)
  28.         {
  29.             echo '$prefs[\''. $key .'\'] = '. $val .';'. PHP_EOL;
  30.         }
  31.         echo PHP_EOL;
  32.     }
  33.    
  34.     if(!empty($_POST['nntp_nzb']))
  35.     {
  36.         echo '# Standaard NNTP (news) server'. PHP_EOL;
  37.         echo '$settings[\'nntp_nzb\'][\'host\'] = \''. $_POST['nntp_nzb']['host'] .'\';'. PHP_EOL;
  38.         echo '$settings[\'nntp_nzb\'][\'user\'] = \''. $_POST['nntp_nzb']['user'] .'\';'. PHP_EOL;
  39.         echo '$settings[\'nntp_nzb\'][\'pass\'] = \''. $_POST['nntp_nzb']['pass'] .'\';'. PHP_EOL;
  40.         echo '$settings[\'nntp_nzb\'][\'port\'] = '. $_POST['nntp_nzb']['port'] .';'. PHP_EOL;
  41.  
  42.         if($_POST['nntp_nzb']['enc'] != 'false')
  43.         {
  44.             echo '$settings[\'nntp_nzb\'][\'enc\'] = \''. $_POST['nntp_nzb']['enc'] .'\';'. PHP_EOL;
  45.         }
  46.         else
  47.         {
  48.             echo '$settings[\'nntp_nzb\'][\'enc\'] = '. $_POST['nntp_nzb']['enc'] .';'. PHP_EOL;
  49.         }
  50.  
  51.         echo PHP_EOL;
  52.     }
  53.    
  54.     if(!empty($_POST['db']))
  55.     {
  56.         echo '# De database instellingen'. PHP_EOL;
  57.         if($_POST['db']['engine'] == 'mysql')
  58.         {
  59.             foreach($_POST['db'] as $key => $val)
  60.             {
  61.                 if($key != 'path')
  62.                 {
  63.                     echo '$settings[\'db\'][\''. $key .'\'] = \''. $val .'\';'. PHP_EOL;
  64.                 }
  65.             }
  66.         }
  67.         else
  68.         {
  69.             echo '$settings[\'db\'][\'engine\'] = \''. $_POST['db']['engine'] .'\';'. PHP_EOL;
  70.             echo '$settings[\'db\'][\'path\'] = \''. $_POST['db']['path'] .'\';'. PHP_EOL;
  71.         }
  72.         echo PHP_EOL;
  73.     }
  74.    
  75.     if(!empty($_POST['nntp_hdr']))
  76.     {
  77.         echo '# Headers NNTP (news) server'. PHP_EOL;
  78.         echo '$settings[\'nntp_hdr\'][\'host\'] = \''. $_POST['nntp_hdr']['host'] .'\';'. PHP_EOL;
  79.         echo '$settings[\'nntp_hdr\'][\'user\'] = \''. $_POST['nntp_hdr']['user'] .'\';'. PHP_EOL;
  80.         echo '$settings[\'nntp_hdr\'][\'pass\'] = \''. $_POST['nntp_hdr']['pass'] .'\';'. PHP_EOL;
  81.         echo '$settings[\'nntp_hdr\'][\'port\'] = '. $_POST['nntp_hdr']['port'] .';'. PHP_EOL;
  82.  
  83.         if($_POST['nntp_hdr']['enc'] != 'false')
  84.         {
  85.             echo '$settings[\'nntp_hdr\'][\'enc\'] = \''. $_POST['nntp_hdr']['enc'] .'\';'. PHP_EOL;
  86.         }
  87.         else
  88.         {
  89.             echo '$settings[\'nntp_hdr\'][\'enc\'] = '. $_POST['nntp_hdr']['enc'] .';'. PHP_EOL;
  90.         }
  91.  
  92.         echo PHP_EOL;
  93.     }
  94.    
  95.     if(!empty($_POST['sabnzbd']))
  96.     {
  97.         echo '# Instellingen voor directe koppeling met SABnzbd\'s API.'. PHP_EOL;
  98.        
  99.         if($_POST['sabnzbd']['https'] == 'true')
  100.         {
  101.             $host = 'https';
  102.         }
  103.         else
  104.         {
  105.             $host = 'http';
  106.         }
  107.        
  108.         echo '$settings[\'nzbhandling\'] =
  109.             array(\'action\'        => \'client-sabnzbd\',
  110.                   \'local_dir\' => \'\',
  111.                   \'command\'       => \'\',                                               
  112.                   \'sabnzbd\'       => array(\'host\'           => \''. $_POST['sabnzbd']['host'].':'. $_POST['sabnzbd']['poort'] .'\',        
  113.                                          \'apikey\'     => \''. $_POST['sabnzbd']['apikey'] .'\',                      
  114.                                          \'spotweburl\' => \''. $_POST['sabnzbd']['spotweburl'] .'\',  
  115.                                          \'url\'            => \''. $host .'://$SABNZBDHOST/sabnzbd/api?mode=$SABNZBDMODE&amp;name=$NZBURL&nzbname=$SPOTTITLE&amp;cat=$SANZBDCAT&amp;apikey=$APIKEY&amp;output=text\'
  116.                                          )
  117.             );';
  118.  
  119.         echo PHP_EOL;
  120.     }
  121.     echo '?>'. PHP_EOL;
  122.     echo '
  123. #=========================================================================#
  124. #Plaats bovenstaande in een bestand genaamd ownsettings.php.              #
  125. #Als deze bijvoorbeeld in de map staat waar settings.php te vinden is,    #
  126. #is er niets aan de hand en worden de instellingen automatisch toegepast. #
  127. #=========================================================================#
  128. ';
  129. }
  130. else
  131. {
  132. ?>
  133. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  134. <html xmlns="http://www.w3.org/1999/xhtml">
  135.     <head>
  136.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  137.         <title>Spotweb ownsettings.php generator</title>
  138.         <script type="text/javascript">
  139.             function dbCheck(val)
  140.             {
  141.                 if(val == 0)
  142.                 {
  143.                     document.getElementById('mysql').style.display = 'none';
  144.                     document.getElementById('sqlite').style.display = 'none';  
  145.                    
  146.                     document.generator.db[host].value = '';
  147.                     document.generator.db[dbname].value = '';
  148.                     document.generator.db[user].value = '';
  149.                     document.generator.db[pass].value = ''                                 
  150.                     document.generator.db[path].value = '';                
  151.                 }
  152.                
  153.                 if(val == 1)
  154.                 {
  155.                     document.getElementById('mysql').style.display = 'block';
  156.                     document.getElementById('sqlite').style.display = 'none';
  157.                    
  158.                     document.generator.db[path].value = '';
  159.                 }
  160.                
  161.                 if(val == 2)
  162.                 {
  163.                     document.getElementById('mysql').style.display = 'none';
  164.                     document.getElementById('sqlite').style.display = 'block';     
  165.                    
  166.                     document.generator.db[host].value   = '';
  167.                     document.generator.db[dbname].value = '';
  168.                     document.generator.db[user].value   = '';
  169.                     document.generator.db[pass].value   = '';
  170.                 }
  171.             }
  172.         </script>
  173.         <style type="text/css">
  174.             body, html, form, dl, dt, legend, label, input, select, option
  175.             {
  176.                 font-family: Verdana, Tahoma, Geneva, sans-serif;
  177.                 font-size: 10pt;
  178.             }
  179.         </style>
  180.     </head>
  181.     <body>
  182.         <strong>De gegevens die je hieronder invult, zullen niet worden opgeslagen of worden doorgegeven aan derden, ze zullen uitsluitend gebruikt worden om een ownsettings.php te genereren voor spotWEB.</strong>
  183.         <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="generator">
  184.             <fieldset>
  185.                 <legend>Algemene SpotWeb instellingen</legend>
  186.                 <dl>
  187.                     <dt>
  188.                         <label for="Update-knop">Update-knop</label>
  189.                         Aan: <input name="settings[show_updatebutton]" value="true" type="radio" />
  190.                         Uit: <input name="settings[show_updatebutton]" value="false" type="radio" />
  191.                     </dt>                
  192.                     <dt>
  193.                         <label for="NZB-knop">NZB-knop</label>
  194.                         Aan: <input name="settings[show_nzbbutton]" value="true" type="radio" />
  195.                         Uit: <input name="settings[show_nzbbutton]" value="false" type="radio" />
  196.                     </dt>
  197.                     <dt><label for="Aantal spots per pagina">Aantal spots per pagina</label> <input type="text" name="prefs[perpage]" value="1000" /></dt>
  198.                     <dt>
  199.                         <label for="Template">Template</label>
  200.                         Standaard: <input name="settings[tpl_path]" value="./templates/" type="radio" />
  201.                         We1rdo: <input name="settings[tpl_path]" value="./templates_we1rdo/" type="radio" />
  202.                     </dt>
  203.                 </dl>
  204.             </fieldset>                
  205.             <fieldset>
  206.                 <legend>Server instellingen</legend>
  207.                 <dl>
  208.                     <dt><label for="Server">Server</label> <input type="text" name="['nntp_nzb'][host]" /></dt>
  209.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="['nntp_nzb'][user]" /></dt>
  210.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="['nntp_nzb'][pass]" /></dt>
  211.                     <dt><label for="Poort">Poort</label> <input type="text" name="['nntp_nzb'][port]" /></dt>
  212.                     <dt>
  213.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  214.                         <select name="['nntp_nzb'][enc]">
  215.                             <option value="false">Geen beveiliging</option>
  216.                             <option value="tls">TLS</option>
  217.                             <option value="SSL">SSL</option>                            
  218.                         </select>                            
  219.                     </dt>                                  
  220.                 </dl>              
  221.             </fieldset>
  222.             <fieldset>
  223.                 <legend>Database instellingen</legend>
  224.                 <dl>
  225.                     <dt>
  226.                         <label for="Type database">Type database</label>
  227.                         <select name="db[engine]" onchange="dbCheck(this.selectedIndex);">
  228.                             <option value="">Kies een optie</option>
  229.                             <option value="mysql">MySQL</option>
  230.                             <option value="sqlite3">SQLite 3</option>
  231.                         </select>                            
  232.                     </dt>
  233.                 </dl>
  234.                 <dl id="mysql" style="display: none;">
  235.                     <dt><label for="MySQL host">MySQL host</label> <input type="text" name="db[host]" /></dt>
  236.                     <dt><label for="MySQL database">MySQL database</label> <input type="text" name="db[dbname]" /></dt>
  237.                     <dt><label for="MySQL gebruiker">MySQL gebruiker</label> <input type="text" name="db[user]" /></dt>
  238.                     <dt><label for="MySQL wachtwoord">MySQL wachtwoord</label> <input type="text" name="db[pass]" /></dt>
  239.                 </dl>
  240.                 <dl id="sqlite" style="display: none;">
  241.                     <dt><label for="Pad naar SQLite 3 database">Pad naar SQLite 3 database</label> <input type="text" name="db[path]" /></dt>
  242.                 </dl>
  243.             </fieldset>
  244.             <fieldset>
  245.                 <legend>Headers server (optioneel)</legend>
  246.                 <dl>
  247.                     <dt><label for="Server">Server</label> <input type="text" name="nntp_hdr[host]" /></dt>
  248.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="nntp_hdr[user]" /></dt>
  249.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="nntp_hdr[pass]" /></dt>
  250.                     <dt><label for="Poort">Poort</label> <input type="text" name="nntp_hdr[port]" /></dt>
  251.                     <dt>
  252.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  253.                         <select name="nntp_hdr[enc]">
  254.                             <option value="">Kies eventueel iets</option>
  255.                             <option value="false">Geen beveiliging</option>
  256.                             <option value="tls">TLS</option>
  257.                             <option value="SSL">SSL</option>                            
  258.                         </select>                            
  259.                     </dt>                
  260.                 </dl>              
  261.             </fieldset>        
  262.             <fieldset>
  263.                 <legend>SABnzbd koppeling (optioneel)</legend>
  264.                 <dl>
  265.                     <dl><label for="SABnzbd hostname">SABnzbd hostname</label> <input type="text" name="sabnzbd[host]" /></dl>
  266.                     <dl><label for="SABnzbd poort">SABnzbd poort</label> <input type="text" name="sabnzbd[poort]" /></dl>
  267.                     <dl><label for="SABnzbd API-key">SABnzbd API-key</label> <input type="text" name="sabnzbd[apikey]" /></dl>
  268.                     <dl><label for="Link naar Spotweb">Link naar Spotweb</label> <input type="text" name="sabnzbd[spotweburl]" /></dl>                    
  269.                     <dl><label for="Beveiligde verbinding">Beveiligde (HTTPS) verbinding?</label><input type="checkbox" value="true" name="sabnzbd[https]" /></dl>
  270.                 </dl>
  271.             </fieldset>
  272.             <fieldset>
  273.                 <legend>Resetten of aanmaken?</legend>
  274.                 <input type="reset" value="Reset" onclick="dbCheck(0);" />
  275.                 <input type="submit" value="Aanmaken" />
  276.             </fieldset>            
  277.         </form>      
  278.     </body>
  279. </html>
  280. <?php
  281. }
  282. ?>
Advertisement
Add Comment
Please, Sign In to add comment