Jump to content
Sign in to follow this  
midnightrose2478

Fatal error: Call to undefined function apache_get_modules()

Recommended Posts

hello i am needing help fixing an script error i am trying to upload an script i am getting the error Fatal error: Call to undefined function apache_get_modules() in /home4/meadows2378/public_html/install.php on line 238 . I have tried several suggestion i saw online to no prevail and i need help.

 

here is the script

 

 

<?php

if (file_exists("install.lock")){ die("Installer is locked, please delete 'install.lock' file using ftp."); exit;}
$dbfile = 'database.sql';
// declaration of variables
$INSTALLPATH = dirname(__FILE__);
$action = isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : 'welcome');
$allowed_actions = array('user_info', 'test_mysql_connection', 'create_mysql_db', 'setup_mysql_db', 'save_owner','welcome','reqcheck','settings','sql_import','save_mysql','owner','site_config','finished');
if (!in_array($action, $allowed_actions)) { $action = 'welcome';}
define('BTIT_INSTALL', TRUE);
function test_input($input){ return $input; }
require_once 'lib/functions.php';
if ($action === 'user_info') {
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$name = test_input($_POST["name"]);
if ($name == '' || strlen ($name) <=3 ){ die(alert_gen("Name must not be empty or less then 3 chars.")); }
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed in name.";
die(alert_gen($nameErr));
}
$email = test_input($_POST["email"]);
if ($email == ''){ die(alert_gen("Email must not be empty.")); }
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format.";
die(alert_gen($emailErr));
}
$phoneNumber = $_POST['mobile'];
//if ($phoneNumber == ''){ die(alert_gen("Phone number must not be empty.")); }
if(!empty($phoneNumber)) // phone number is not empty
{
if(preg_match('/^\d{10}$/',$phoneNumber)) // phone number is valid
{
$phoneNumber = '0' . $phoneNumber;
// your other code here
}
else // phone number is not valid
{
die(alert_gen('Phone number invalid!'));
}
}
else // phone number is empty
{
die(alert_gen('You must provid a phone number !'));
}
$install_url = selfURL();
//die("$name $email $mobile");
$to = "info@boysofts.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:$email \r\n";
//$header .= "Cc:afgh@somedomain.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
if (is_localhost()) { $retval = true; }
else { $retval = @@mail ($to,$subject,$message,$header); }
if( $retval == true ) {
die("success");
}else {
die("fail");
}
}
elseif ($action === 'test_mysql_connection' || $action === 'create_mysql_db' || $action ==='setup_mysql_db') {
$host = $_POST['host'];
//$host = $_GET['host'];
if ($host == ''){ die(alert_gen("MySql database host name must not be empty.")); }
$username = $_POST['username'];
//$username = $_GET['username'];
if ($username == ''){ die(alert_gen("MySql Username must not be empty.")); }
$password = $_POST['password'];
//$password = $_GET['password'];
//die("$host $username $password");
//$link = @mysqli_connect($host, $username, $password) or die('fail');
$mysqli = @@New mysqli($host, $username, $password);
if ($mysqli->connect_error) {
die(alert_gen("Unable to Connect to '$host'."));
}
else{ if($action === 'test_mysql_connection') { die(alert_gen("Connection to '$host' is successfull.", 'success')); } }
if($action === 'create_mysql_db'){
$dbname = $_POST['databasename'];
//$dbname = $_GET['dbname'];
if ($dbname == ''){ die(alert_gen("MySql database name must not be empty.")); }
if ($dbname != ''){
// Make my_db the current database
$db_selected = $mysqli->select_db($dbname);
if (!$db_selected) {
// If we couldn't, then it either doesn't exist, or we can't see it.
$sql = "CREATE DATABASE $dbname";
if ($mysqli->query($sql)) {
die(alert_gen("Database '$dbname' created successfully.", 'success'));
} else {
//die(alert_gen('Error creating database: ' . $mysqli->error));
die(alert_gen('Error creating database: '));
}
}else{
die(alert_gen("Database '$dbname' already exists."));
}
}
}
if($action === 'setup_mysql_db'){
$dbname = $_POST['databasename'];
if ($dbname == ''){ die(alert_gen("MySql database name must not be empty.")); }
if ($dbname != ''){
// Make my_db the current database
$db_selected = $mysqli->select_db($dbname);
if (!$db_selected) {
die(alert_gen("Database '$dbname' do not exists. Please click the \"Create DB\" button to create it."));
}else{
//$sql = file_get_contents('database1.sql');
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($dbfile);
// Loop through each line
foreach ($lines as $line)
{
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
{
// Perform the query
if ($mysqli->query($templine)) {
//die(alert_gen("Database '$dbname' created successfully.", 'success'));
} else {
die(alert_gen('Error creating database: ' . $mysqli->error));
//die(alert_gen('Error creating database: '));
}
// Reset temp variable to empty
$templine = '';
}
}
//write settings file.$host = $_POST['host'];
write_settings_file($host,$username,$password,$dbname);
touch("install.lock");
die('success');
}
}
}
//if($link){ }
//
//die("$host $username $password");
}
/*
elseif ($action === 'create_mysql_db') {print_r($_POST);
$host = $_POST['host'];
$username = $_POST['username'];
$password = $_POST['password'];
$dbname = $_POST['dbname'];
die("$host $username $password $dbname");
}
*/
/*
elseif ($action === 'setup_mysql_db') {print_r($_POST);
$host = $_POST['host'];
$username = $_POST['username'];
$password = $_POST['password'];
$dbname = $_POST['dbname'];
die("$host $username $password $dbname");
}
*/
function write_settings_file($db_server,$db_user,$db_passwd,$db_name){
$fd = fopen('settings.php', 'w');
$foutput = "<?php\n\n";
$foutput.= "\$dbhost = \"".$db_server."\";\n";
$foutput.= "\$dbuser = \"".$db_user."\";\n";
$foutput.= "\$dbpass = \"".$db_passwd."\";\n";
$foutput.= "\$database = \"".$db_name."\";\n";
$foutput.= "\n?>";
fwrite($fd,$foutput);
fclose($fd);
}
function alert_gen($text, $type=false){
$greeting = 'Well done!';
if (!$type){ $type = 'danger'; $greeting = 'Warning!';}
return <<<EOD
<div class="alert alert-$type alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>$greeting</strong> $text
</div>
EOD;
}
$env_check = '';
$env_check_res = true;
$extensions = get_loaded_extensions();
$env_check = $env_check . "PHP version: " . PHP_VERSION . "<br><br>";
if(!function_exists('apache_get_modules') ){ $env_check_res = false; $env_check = $env_check . "<div class=\"alert alert-danger\" role=\"alert\"><span class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></span> Apache webserver required. Enable it and try again.</div>"; }
if(!in_array('mod_rewrite',apache_get_modules())){ $env_check_res = false; $env_check = $env_check . "<div class=\"alert alert-danger\" role=\"alert\"><span class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></span> Apache mod_rewrite required. Enable it and try again.</div>"; }
else{ $env_check = $env_check . "<div class=\"alert alert-success\" role=\"alert\"><span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span> Apache mod_rewrite enabled.</div>"; }
if(!in_array ('curl', get_loaded_extensions())){ $env_check_res = false; $env_check = $env_check . "<div class=\"alert alert-danger\" role=\"alert\"><span class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></span> Php CURL extension required. Enable it and try again.</div>"; }
else{ $env_check = $env_check . "<div class=\"alert alert-success\" role=\"alert\"><span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span> Php CURL extension enabled.</div>"; }
if($env_check_res){
$env_check = $env_check ."<div class=\"continue-button\"><a href=\"#small-dialog2\" class=\"hvr-shutter-out-horizontal play-icon popup-with-zoom-anim\">CONTINUE</a></div>";
}
else{
$env_check = $env_check ."<div class=\"continue-button\"><a href=\"install.php\" class=\"hvr-shutter-out-horizontal play-icon\">Refresh</a></div>";
}
//if (!defined("INDEX")) { die("Don't try to run this script."); }
$template = file_get_contents('template/install.html');
$template_vars = array('{{env_check}}');
$template_values = @array($env_check);
$template = str_ireplace($template_vars, $template_values, $template);
echo $template;
exit;

 

Do you guys have any suggestions on how to fix this my webhost is hostgator thanks in advance

Share this post


Link to post
Share on other sites

The script is looking for a function. That function doesn't exist. So if hostgator cannot help you now need to ask the author of the script.

Share this post


Link to post
Share on other sites

It looks like it checks to see if certain Apache modules are installed but fails to check if you're even using Apache as a web server, and that's where the function blows up. It's possible that your host is using a FastCGI or Nginx configuration instead.

To be honest, the code above is awful, it looks untested and completely unstable, for example there's stuff like '
function test_input($input){ return $input; }' which literally does nothing. Rather than fixing it, I'd look at a better alternative for what you're trying to do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing

    No registered users viewing this page.

  • Member Statistics

    • Total Members
      57,516
    • Most Online
      4,970

    Newest Member
    Codespinner
    Joined
  • Forum Statistics

    • Total Topics
      65,729
    • Total Posts
      455,373
×