CptChaos

Spotweb's ownsettings.php generator

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