Module: EasyInstaller::ModuleValidateHelper

Defined in:
lib/easy_installer/modules/php/validate_helper.rb

Instance Method Summary collapse

Instance Method Details

#mysql?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/easy_installer/modules/php/validate_helper.rb', line 19

def mysql?
  mysql_host      = $user_input['mysql_host'].value
  mysql_username  = $user_input['mysql_username'].value
  mysql_password  = $user_input['mysql_password'].value
  mysql_database  = $user_input['mysql_database'].value
  template = ERB.new <<-EOF
  <?
  $link = mysql_connect('<%= mysql_host %>', '<%= mysql_username %>', '<%= mysql_password %>')
    or die('Could not connect: ' . mysql_error());
  echo 'Connected successfully';
  mysql_select_db('<%= mysql_database %>') or die('Could not select database');
  print("OK");
  ?>
  EOF
  file = File.new("mysql.php", "w")
file.write(template.result binding)
file.close
  begin
  move_file(file.path, $user_input['path'].value+'/'+"mysql.php",777)
  ValidatorSupportMethods.assert_http_body($user_input['http_address'].value+"/mysql.php","OK","no_mysql")
    File.delete(file.path)
    true
  rescue
    File.delete(file.path)
    true
  end
end

#php?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/easy_installer/modules/php/validate_helper.rb', line 4

def php?
file = File.new("phptest.php", "w")
file.write("<? echo 'OK' ?>")
file.close
begin
    move_file(file.path, $user_input['path'].value+'/'+"phptest.php",777)
		ValidatorSupportMethods.assert_http_body($user_input['http_address'].value+"/phptest.php","OK","no_php")
    File.delete(file.path)
    true
	rescue
    File.delete(file.path)
    false
  end
end