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