CptChaos

Spotweb's ownsettings.php generator

Mar 12th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.26 KB | None | 0 0
  1. <?php
  2. $version = '0.0.1a'; // De versie dus! :)
  3.  
  4. if($_POST)
  5. {
  6.     header("Content-type: application/php");
  7.     header("Content-Disposition:attachment;filename=ownsettings.php");
  8.     echo '<?php'. PHP_EOL;
  9.     if(!empty($_POST['settings']))
  10.     {
  11.         echo '# Instellingen voor NZB- of update knop'. PHP_EOL;
  12.         foreach($_POST['settings'] as $key => $val)
  13.         {
  14.             if($val != 'true')
  15.             {
  16.                 echo '$settings[\''. $key .'\'] = \''. $val .'\';'. PHP_EOL;
  17.             }
  18.             else
  19.             {
  20.                 echo '$settings[\''. $key .'\'] = '. $val .';'. PHP_EOL;
  21.             }
  22.         }
  23.         echo PHP_EOL;
  24.     }
  25.    
  26.     if(!empty($_POST['prefs']))
  27.     {
  28.         echo '# Algemene instellen, zoals spots per pagina en type datum notatie'. PHP_EOL;
  29.         foreach($_POST['prefs'] as $key => $val)
  30.         {
  31.             echo '$settings[\'prefs\'][\''. $key .'\'] = \''. $val .'\';'. PHP_EOL;
  32.         }
  33.         echo PHP_EOL;
  34.     }
  35.    
  36.     if(!empty($_POST['nntp_nzb']))
  37.     {
  38.         echo '# Standaard NNTP (news) server'. PHP_EOL;
  39.         echo '$settings[\'nntp_nzb\'][\'host\'] = \''. $_POST['nntp_nzb']['host'] .'\';'. PHP_EOL;
  40.         echo '$settings[\'nntp_nzb\'][\'user\'] = \''. $_POST['nntp_nzb']['user'] .'\';'. PHP_EOL;
  41.         echo '$settings[\'nntp_nzb\'][\'pass\'] = \''. $_POST['nntp_nzb']['pass'] .'\';'. PHP_EOL;
  42.         echo '$settings[\'nntp_nzb\'][\'port\'] = '. $_POST['nntp_nzb']['port'] .';'. PHP_EOL;
  43.  
  44.         if($_POST['nntp_nzb']['enc'] != 'false')
  45.         {
  46.             echo '$settings[\'nntp_nzb\'][\'enc\'] = \''. $_POST['nntp_nzb']['enc'] .'\';'. PHP_EOL;
  47.         }
  48.         else
  49.         {
  50.             echo '$settings[\'nntp_nzb\'][\'enc\'] = '. $_POST['nntp_nzb']['enc'] .';'. PHP_EOL;
  51.         }
  52.  
  53.         echo PHP_EOL;
  54.     }
  55.    
  56.     if(!empty($_POST['db']))
  57.     {
  58.         echo '# De database instellingen'. PHP_EOL;
  59.         if($_POST['db']['engine'] == 'mysql')
  60.         {
  61.             foreach($_POST['db'] as $key => $val)
  62.             {
  63.                 if($key != 'path')
  64.                 {
  65.                     echo '$settings[\'db\'][\''. $key .'\'] = \''. $val .'\';'. PHP_EOL;
  66.                 }
  67.             }
  68.         }
  69.         else
  70.         {
  71.             echo '$settings[\'db\'][\'engine\'] = \''. $_POST['db']['engine'] .'\';'. PHP_EOL;
  72.             echo '$settings[\'db\'][\'path\'] = \''. $_POST['db']['path'] .'\';'. PHP_EOL;
  73.         }
  74.         echo PHP_EOL;
  75.     }
  76.    
  77.     if(!empty($_POST['nntp_hdr']))
  78.     {
  79.         echo '# Headers NNTP (news) server'. PHP_EOL;
  80.         echo '$settings[\'nntp_hdr\'][\'host\'] = \''. $_POST['nntp_hdr']['host'] .'\';'. PHP_EOL;
  81.         echo '$settings[\'nntp_hdr\'][\'user\'] = \''. $_POST['nntp_hdr']['user'] .'\';'. PHP_EOL;
  82.         echo '$settings[\'nntp_hdr\'][\'pass\'] = \''. $_POST['nntp_hdr']['pass'] .'\';'. PHP_EOL;
  83.         echo '$settings[\'nntp_hdr\'][\'port\'] = '. $_POST['nntp_hdr']['port'] .';'. PHP_EOL;
  84.  
  85.         if($_POST['nntp_hdr']['enc'] != 'false')
  86.         {
  87.             echo '$settings[\'nntp_hdr\'][\'enc\'] = \''. $_POST['nntp_hdr']['enc'] .'\';'. PHP_EOL;
  88.         }
  89.         else
  90.         {
  91.             echo '$settings[\'nntp_hdr\'][\'enc\'] = '. $_POST['nntp_hdr']['enc'] .';'. PHP_EOL;
  92.         }
  93.  
  94.         echo PHP_EOL;
  95.     }
  96.    
  97.     if(!empty($_POST['sabnzbd']))
  98.     {
  99.         echo '# Instellingen voor directe koppeling met SABnzbd\'s API.'. PHP_EOL;
  100.        
  101.         if($_POST['sabnzbd']['https'] == 'true')
  102.         {
  103.             $host = 'https';
  104.         }
  105.         else
  106.         {
  107.             $host = 'http';
  108.         }
  109.        
  110.         echo '
  111.         $settings[\'nzbhandling\'][\'action\'] = \'client-sabnzbd\';
  112.         $settings[\'nzbhandling\'][\'local_dir\'] = \'\';
  113.         $settings[\'nzbhandling\'][\'command\'] = \'\';
  114.         $settings[\'nzbhandling\'][\'sabnzbd\'] = array();
  115.         $settings[\'nzbhandling\'][\'sabnzbd\'][\'host\'] = \''. $_POST['sabnzbd']['host'].':'. $_POST['sabnzbd']['poort'] .'\';
  116.         $settings[\'nzbhandling\'][\'sabnzbd\'][\'apikey\'] = \''. $_POST['sabnzbd']['apikey'] .'\';
  117.         $settings[\'nzbhandling\'][\'sabnzbd\'][\'spotweburl\'] = \'http://server/spotweb/\';
  118.         $settings[\'nzbhandling\'][\'sabnzbd\'][\'url\'] = \''. $host .'://$SABNZBDHOST/sabnzbd/api?mode=$SABNZBDMODE&name=$NZBURL&nzbname=$SPOTTITLE&cat=$SANZBDCAT&apikey=$APIKEY&output=text';          
  119.  
  120.         echo PHP_EOL;
  121.     }
  122.     echo '?>';
  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 (versie <?php echo $version; ?>)</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.         <h1>Spotweb ownsettings.php generator versie <?php echo $version; ?></h1>
  177.         <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>
  178.         <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="generator">
  179.             <fieldset>
  180.                 <legend>Algemene SpotWeb instellingen</legend>
  181.                 <dl>
  182.                     <dt>
  183.                         <label for="Update-knop">Update-knop</label>
  184.                         Aan: <input name="settings[show_updatebutton]" value="true" type="radio" />
  185.                         Uit: <input name="settings[show_updatebutton]" value="false" type="radio" />
  186.                     </dt>                
  187.                     <dt>
  188.                         <label for="NZB-knop">NZB-knop</label>
  189.                         Aan: <input name="settings[show_nzbbutton]" value="true" type="radio" />
  190.                         Uit: <input name="settings[show_nzbbutton]" value="false" type="radio" />
  191.                     </dt>
  192.                     <dt><label for="Aantal spots per pagina">Aantal spots per pagina</label> <input type="text" name="prefs[perpage]" value="1000" /></dt>
  193.                     <dt>
  194.                         <label for="Template">Template</label>
  195.                         Standaard: <input name="settings[tpl_path]" value="./templates/" type="radio" />
  196.                         We1rdo: <input name="settings[tpl_path]" value="./templates_we1rdo/" type="radio" />
  197.                     </dt>
  198.                     <dt>
  199.                         <label for="Datum notaties">Datum notaties</label>
  200.                         Human readable: <input type="radio" name="prefs[date_formatting]" value="human" />
  201.                         Exacte datum (DD-MM-JJ): <input type="radio" name="prefs[date_formatting]" value="%a, %d-%b-%Y (%H:%M)" />
  202.                     </dt>
  203.                     <dt>
  204.                         Human readable: vandaag, gisteren, eergisteren, 3 dagen geleden enz.<br />
  205.                         Exacte datum: Dag, datum (tijd)
  206.                     </dt>                      
  207.                 </dl>
  208.             </fieldset>                
  209.             <fieldset>
  210.                 <legend>Server instellingen</legend>
  211.                 <dl>
  212.                     <dt><label for="Server">Server</label> <input type="text" name="['nntp_nzb'][host]" /></dt>
  213.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="['nntp_nzb'][user]" /></dt>
  214.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="['nntp_nzb'][pass]" /></dt>
  215.                     <dt><label for="Poort">Poort</label> <input type="text" name="['nntp_nzb'][port]" /></dt>
  216.                     <dt>
  217.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  218.                         <select name="['nntp_nzb'][enc]">
  219.                             <option value="false">Geen beveiliging</option>
  220.                             <option value="tls">TLS</option>
  221.                             <option value="SSL">SSL</option>                            
  222.                         </select>                            
  223.                     </dt>                                  
  224.                 </dl>              
  225.             </fieldset>
  226.             <fieldset>
  227.                 <legend>Database instellingen</legend>
  228.                 <dl>
  229.                     <dt>
  230.                         <label for="Type database">Type database</label>
  231.                         <select name="db[engine]" onchange="dbCheck(this.selectedIndex);">
  232.                             <option value="">Kies een optie</option>
  233.                             <option value="mysql">MySQL</option>
  234.                             <option value="sqlite3">SQLite 3</option>
  235.                         </select>                            
  236.                     </dt>
  237.                 </dl>
  238.                 <dl id="mysql" style="display: none;">
  239.                     <dt><label for="MySQL host">MySQL host</label> <input type="text" name="db[host]" /></dt>
  240.                     <dt><label for="MySQL database">MySQL database</label> <input type="text" name="db[dbname]" /></dt>
  241.                     <dt><label for="MySQL gebruiker">MySQL gebruiker</label> <input type="text" name="db[user]" /></dt>
  242.                     <dt><label for="MySQL wachtwoord">MySQL wachtwoord</label> <input type="text" name="db[pass]" /></dt>
  243.                 </dl>
  244.                 <dl id="sqlite" style="display: none;">
  245.                     <dt><label for="Pad naar SQLite 3 database">Pad naar SQLite 3 database</label> <input type="text" name="db[path]" /></dt>
  246.                 </dl>
  247.             </fieldset>
  248.             <fieldset>
  249.                 <legend>Headers server (optioneel)</legend>
  250.                 <dl>
  251.                     <dt><label for="Server">Server</label> <input type="text" name="nntp_hdr[host]" /></dt>
  252.                     <dt><label for="Genbruikersnaam">Gebruikersnaam</label> <input type="text" name="nntp_hdr[user]" /></dt>
  253.                     <dt><label for="Wachtwoord">Wachtwoord</label> <input type="text" name="nntp_hdr[pass]" /></dt>
  254.                     <dt><label for="Poort">Poort</label> <input type="text" name="nntp_hdr[port]" /></dt>
  255.                     <dt>
  256.                         <label for="Beveiligingsniveau">Beveiligingsniveau</label>
  257.                         <select name="nntp_hdr[enc]">
  258.                             <option value="">Kies eventueel iets</option>
  259.                             <option value="false">Geen beveiliging</option>
  260.                             <option value="tls">TLS</option>
  261.                             <option value="SSL">SSL</option>                            
  262.                         </select>                            
  263.                     </dt>                
  264.                 </dl>              
  265.             </fieldset>        
  266.             <fieldset>
  267.                 <legend>SABnzbd koppeling (optioneel)</legend>
  268.                 <dl>
  269.                     <dl><label for="SABnzbd hostname">SABnzbd hostname</label> <input type="text" name="sabnzbd[host]" /></dl>
  270.                     <dl><label for="SABnzbd poort">SABnzbd poort</label> <input type="text" name="sabnzbd[poort]" /></dl>
  271.                     <dl><label for="SABnzbd API-key">SABnzbd API-key</label> <input type="text" name="sabnzbd[apikey]" /></dl>
  272.                     <dl><label for="Link naar Spotweb">Link naar Spotweb</label> <input type="text" name="sabnzbd[spotweburl]" /></dl>                    
  273.                     <dl><label for="Beveiligde verbinding">Beveiligde (HTTPS) verbinding?</label><input type="checkbox" value="true" name="sabnzbd[https]" /></dl>
  274.                 </dl>
  275.             </fieldset>
  276.             <fieldset>
  277.                 <legend>Resetten of aanmaken?</legend>
  278.                 <input type="reset" value="Reset" onclick="dbCheck(0);" />
  279.                 <input type="submit" value="Aanmaken" />
  280.             </fieldset>            
  281.         </form>      
  282.     </body>
  283. </html>
  284. <?php
  285. }
  286. ?>
Advertisement
Add Comment
Please, Sign In to add comment