config.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*
  3. This FTP addon works with EHCP (www.ehcp.net)
  4. It allows OGP - the open game panel - to manage custom FTP user accounts
  5. by own3mall
  6. */
  7. @include_once "/var/www/new/ehcp/config.php";
  8. /**********************************
  9. * DB Creds *
  10. * ********************************/
  11. // Database credentials change if needed
  12. $server = 'localhost';
  13. $login = 'ehcp';
  14. // Script should detect password automatically from EHCP config file above... but if not, please change the value down here.
  15. if(!isset($dbpass) || empty($dbpass)){
  16. $dbpass = 'changeme';
  17. }
  18. $dbName = 'ehcp';
  19. $debug=false;
  20. /**********************************
  21. * END DB Creds *
  22. * ********************************/
  23. // Log File
  24. $logFile = 'ehcp_ftp_log.txt';
  25. function addToLog($errors) {
  26. global $logFile, $debug;
  27. if (!file_exists($logFile)) {
  28. $createLog = fopen($logFile, 'a+');
  29. if (!$createLog) {
  30. trigger_error("Unable to create EHCP FTP Integration log file! Please create a file named \"ehcp_ftp_log.txt\" in the ogp_agent install directory under the EHCP folder with permissions of 777", E_USER_NOTICE);
  31. }
  32. fclose($createLog);
  33. }
  34. if (!is_writable($logFile)) {
  35. $chPerm = chmod($logFile, 777);
  36. if (!$chPerm) {
  37. trigger_error("The $logFile file is not writable. CHMOD failed. Please manually set the chmod to 777!", E_USER_NOTICE);
  38. }
  39. }
  40. $logContents = file_get_contents($logFile);
  41. foreach ($errors as $err) {
  42. $logContents.= $err . "\n";
  43. if($debug){
  44. trigger_error($err, E_USER_NOTICE);
  45. echo $err . "\n";
  46. }
  47. }
  48. $updateLog = file_put_contents($logFile, $logContents);
  49. if (!$updateLog) {
  50. trigger_error("Unable to write errors to the log file of $logFile", E_USER_NOTICE);
  51. }
  52. }
  53. // Create the database connection
  54. if(function_exists("mysql_connect")){
  55. $connection = mysql_connect($server, $login, $dbpass);
  56. if ($connection) {
  57. mysql_select_db($dbName, $connection);
  58. }
  59. }else{
  60. $connection = mysqli_connect($server, $login, $dbpass, $dbName);
  61. }
  62. if(!$connection){
  63. $errToLog[] = 'Unable to connect to the EHCP MySQL database using provided credentials! Please update your config.php settings!';
  64. addToLog($errToLog);
  65. die('Unable to connect to the EHCP MySQL database using provided credentials! Please update your config.php settings!');
  66. }
  67. ?>