Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. function create_config($post_details)
  2. {
  3.     $fp = fopen('../includes/config.php', 'w');
  4.    
  5.     if ($fp)
  6.     {
  7.         $content = "<?php \n" .
  8.             " \n" .
  9.             "/* Database Host Name */ \n" .
  10.             "\$db_host = '" . $post_details['db_host'] . "'; \n".
  11.             " \n" .
  12.             "/* Database Username */ \n" .
  13.             "\$db_username = '" . $post_details['db_username'] . "'; \n" .
  14.             " \n" .
  15.             "/* Database Login Password */ \n" .
  16.             "\$db_password = '" . $post_details['db_password'] . "'; \n" .
  17.             " \n" .
  18.             "/* Database and Session prefixes */ \n" .
  19.             "define('DB_PREFIX', '" . $post_details['table_prefix'] . "'); ## Do not edit ! \n" .
  20.             "define('SESSION_PREFIX', 'probid_'); \n" .
  21.             " \n" .
  22.             "/* Database Name */ \n" .
  23.             "\$db_name = '" . $post_details['db_name'] . "'; \n" .
  24.             "?>";
  25.  
  26.         fputs($fp, $content);
  27.         fclose($fp);
  28.        
  29.         $output['display'] = '<b>The configuration file was created successfully.</b>';
  30.         $output['result'] = true;
  31.     }
  32.     else
  33.     {
  34.         $output['display'] = '<b>Error: Could not create the configuration file.</b><br> '.
  35.             'Please make sure the <b>includes</b> folder has writing permissions and the <b>config.php</b> file doesn\'t already exist.';
  36.         $output['result'] = false;     
  37.     }
  38.    
  39.     return $output;
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement