CptChaos

Spotweb's ownsettings.php generator

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