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
|