CptChaos

Spotweb's ownsettings.php generator

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