CptChaos

Spotweb's ownsettings.php generator

Mar 12th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.25 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(!empty($_POST['sabnzbd']['user']) && !empty($_POST['sabnzbd']['pass']))
  100.         {
  101.             echo '$settings[\'sabnzbd\'][\'host\'] = \''. $_POST['sabnzbd']['user']  .':'. $_POST['sabnzbd']['pass'] .'@'. $_POST['sabnzbd']['host'] .':'. $_POST['sabnzbd']['poort'] .'\';'. PHP_EOL;
  102.         }
  103.         else
  104.         {
  105.             echo '$settings[\'sabnzbd\'][\'host\'] = \''. $_POST['sabnzbd']['host'] .':'. $_POST['sabnzbd']['poort'] .'\';'. PHP_EOL;              
  106.         }
  107.  
  108.         echo '$settings[\'sabnzbd\'][\'apikey\'] = \''. $_POST['sabnzbd']['apikey'] .'\';'. PHP_EOL;
  109.         echo '$settings[\'sabnzbd\'][\'spotweburl\'] = \''. $_POST['sabnzbd']['spotweburl'] .'\';'. PHP_EOL;
  110.         if($_POST['sabnzbd']['https'] == 'true')
  111.         {
  112.             $host = 'https';
  113.         }
  114.         else
  115.         {
  116.             $host = 'http';
  117.         }
  118.         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;
  119.  
  120.         echo PHP_EOL;
  121.     }
  122.     echo '?>'. PHP_EOL;
  123.     echo '
  124. #=========================================================================#
  125. #Plaats bovenstaande in een bestand genaamd ownsettings.php.              #
  126. #Als deze bijvoorbeeld in de map staat waar settings.php te vinden is,    #
  127. #is er niets aan de hand en worden de instellingen automatisch toegepast. #
  128. #=========================================================================#
  129. ';
  130. }
  131. else
  132. {
  133. ?>
  134. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  135. <html xmlns="http://www.w3.org/1999/xhtml">
  136.     <head>
  137.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  138.         <title>Spotweb ownsettings.php generator</title>
  139.         <script type="text/javascript">
  140.             function dbCheck(val)
  141.             {
  142.                 if(val == 0)
  143.                 {
  144.                     document.getElementById('mysql').style.display = 'none';
  145.                     document.getElementById('sqlite').style.display = 'none';  
  146.                    
  147.                     document.generator.db[host].value = '';
  148.                     document.generator.db[dbname].value = '';
  149.                     document.generator.db[user].value = '';
  150.                     document.generator.db[pass].value = ''                                 
  151.                     document.generator.db[path].value = '';                
  152.                 }
  153.                
  154.                 if(val == 1)
  155.                 {
  156.                     document.getElementById('mysql').style.display = 'block';
  157.                     document.getElementById('sqlite').style.display = 'none';
  158.                    
  159.                     document.generator.db[path].value = '';
  160.                 }
  161.                
  162.                 if(val == 2)
  163.                 {
  164.                     document.getElementById('mysql').style.display = 'none';
  165.                     document.getElementById('sqlite').style.display = 'block';     
  166.                    
  167.                     document.generator.db[host].value   = '';
  168.                     document.generator.db[dbname].value = '';
  169.                     document.generator.db[user].value   = '';
  170.                     document.generator.db[pass].value   = '';
  171.                 }
  172.             }
  173.         </script>
  174.         <style type="text/css">
  175.             body, html, form, dl, dt, legend, label, input, select, option
  176.             {
  177.                 font-family: Verdana, Tahoma, Geneva, sans-serif;
  178.                 font-size: 10pt;
  179.             }
  180.         </style>
  181.     </head>
  182.     <body>
  183.         <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>
  184.         <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="generator">
  185.             <fieldset>
  186.                 <legend>Algemene SpotWeb instellingen</legend>
  187.                 <dl>
  188.                     <dt>
  189.                         <label for="Update-knop">Update-knop</label>
  190.                         Aan: <input name="settings[show_updatebutton]" value="true" type="radio" />
  191.                         Uit: <input name="settings[show_updatebutton]" value="false" type="radio" />
  192.                     </dt>                
  193.                     <dt>
  194.                         <label for="NZB-knop">NZB-knop</label>
  195.                         Aan: <input name="settings[show_nzbbutton]" value="true" type="radio" />
  196.                         Uit: <input name="settings[show_nzbbutton]" value="false" type="radio" />
  197.                     </dt>
  198.                     <dt><label for="Aantal spots per pagina">Aantal spots per pagina</label> <input type="text" name="prefs[perpage]" value="1000" /></dt>
  199.                     <dt>
  200.                         <label for="Template">Template</label>
  201.                         Standaard: <input name="settings[tpl_path]" value="./templates/" type="radio" />
  202.                         We1rdo: <input name="settings[tpl_path]" value="./templates_we1rdo/" type="radio" />
  203.                     </dt>
  204.                 </dl>
  205.             </fieldset>                
  206.             <fieldset>
  207.                 <legend>Server instellingen</legend>
  208.                 <dl>
  209.                     <dt><label for="Server">Server</label> <input type="text" name="['nntp_nzb'][host]" /></dt>
  210.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="['nntp_nzb'][user]" /></dt>
  211.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="['nntp_nzb'][pass]" /></dt>
  212.                     <dt><label for="Poort">Poort</label> <input type="text" name="['nntp_nzb'][port]" /></dt>
  213.                     <dt>
  214.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  215.                         <select name="['nntp_nzb'][enc]">
  216.                             <option value="false">Geen beveiliging</option>
  217.                             <option value="tls">TLS</option>
  218.                             <option value="SSL">SSL</option>                            
  219.                         </select>                            
  220.                     </dt>                                  
  221.                 </dl>              
  222.             </fieldset>
  223.             <fieldset>
  224.                 <legend>Database instellingen</legend>
  225.                 <dl>
  226.                     <dt>
  227.                         <label for="Type database">Type database</label>
  228.                         <select name="db[engine]" onchange="dbCheck(this.selectedIndex);">
  229.                             <option value="">Kies een optie</option>
  230.                             <option value="mysql">MySQL</option>
  231.                             <option value="sqlite3">SQLite 3</option>
  232.                         </select>                            
  233.                     </dt>
  234.                 </dl>
  235.                 <dl id="mysql" style="display: none;">
  236.                     <dt><label for="MySQL host">MySQL host</label> <input type="text" name="db[host]" /></dt>
  237.                     <dt><label for="MySQL database">MySQL database</label> <input type="text" name="db[dbname]" /></dt>
  238.                     <dt><label for="MySQL gebruiker">MySQL gebruiker</label> <input type="text" name="db[user]" /></dt>
  239.                     <dt><label for="MySQL wachtwoord">MySQL wachtwoord</label> <input type="text" name="db[pass]" /></dt>
  240.                 </dl>
  241.                 <dl id="sqlite" style="display: none;">
  242.                     <dt><label for="Pad naar SQLite 3 database">Pad naar SQLite 3 database</label> <input type="text" name="db[path]" /></dt>
  243.                 </dl>
  244.             </fieldset>
  245.             <fieldset>
  246.                 <legend>Headers server (optioneel)</legend>
  247.                 <dl>
  248.                     <dt><label for="Server">Server</label> <input type="text" name="nntp_hdr[host]" /></dt>
  249.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="nntp_hdr[user]" /></dt>
  250.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="nntp_hdr[pass]" /></dt>
  251.                     <dt><label for="Poort">Poort</label> <input type="text" name="nntp_hdr[port]" /></dt>
  252.                     <dt>
  253.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  254.                         <select name="nntp_hdr[enc]">
  255.                             <option value="">Kies eventueel iets</option>
  256.                             <option value="false">Geen beveiliging</option>
  257.                             <option value="tls">TLS</option>
  258.                             <option value="SSL">SSL</option>                            
  259.                         </select>                            
  260.                     </dt>                
  261.                 </dl>              
  262.             </fieldset>        
  263.             <fieldset>
  264.                 <legend>SABnzbd koppeling (optioneel)</legend>
  265.                 <dl>
  266.                     <dl><label for="SABnzbd hostname">SABnzbd hostname</label> <input type="text" name="sabnzbd[host]" /></dl>
  267.                     <dl><label for="SABnzbd poort">SABnzbd poort</label> <input type="text" name="sabnzbd[poort]" /></dl>
  268.                     <dl><label for="SABnzbd API-key">SABnzbd API-key</label> <input type="text" name="sabnzbd[apikey]" /></dl>
  269.                     <dl><label for="Link naar Spotweb">Link naar Spotweb</label> <input type="text" name="sabnzbd[spotweburl]" /></dl>                    
  270.                     <dl><label for="SABnzbd gebruikersnaam">SABnzbd gebruikersnaam</label> <input type="text" name="sabnzbd[user]" /></dl>
  271.                     <dl><label for="SABnzbd wachtwoord">SABnzbd wachtwoord</label> <input type="text" name="sabnzbd[pass]" /></dl>
  272.                     <dl><label for="Beveiligde verbinding">Beveiligde (HTTPS) verbinding?</label><input type="checkbox" value="true" name="sabnzbd[https]" /></dl>
  273.                 </dl>
  274.             </fieldset>
  275.             <fieldset>
  276.                 <legend>Resetten of aanmaken?</legend>
  277.                 <input type="reset" value="Reset" onclick="dbCheck(0);" />
  278.                 <input type="submit" value="Aanmaken" />
  279.             </fieldset>            
  280.         </form>      
  281.     </body>
  282. </html>
  283. <?php
  284. }
  285. ?>
Advertisement
Add Comment
Please, Sign In to add comment