Hello All,
i am running a script to check if apache is running on a linux server. when i run it on command line, it works but failing on the browser.
This could be as a result of permision issues. how can i go round it
<?php
class Services {
//put your code here
public function _construc() {
}
public function mysqld() {
$command = "service mysqld status";
$res = $this->execCommand($command);
$array = explode(" ", $res);
$ret = in_array("running...", $array, TRUE) ? TRUE : FALSE;
return $ret;
}
public function startMysqld() {
$command = "service mysqld restart";
$res = $this->execCommand($command);
return $res;
}
public function httpd() {
$command = "service httpd status";
$res = $this->execCommand($command);
$array = explode(" ", $res);
$ret = in_array("running...", $array, TRUE) ? TRUE : FALSE;
return $ret;
}
public function startHttpd() {
$command = "service httpd start";
$res = $this->execCommand($command);
}
private function execCommand($command) {
$res = exec($command);
return $res;
}
}
session_start();
include_once 'DBconnect.php';
include_once 'template.php';
include_once './config/config.inc.php';
showheader("Services");
include_once 'header.php';
$ser = new Services();
$mysqld = $ser->mysqld();
$httpd = $ser->httpd();
echo "<table width='100%' align=center><tr><td class=hdr>Service</td><td class=hdr>status</td><td class=hdr>Action</td></tr>";
echo "<tr bgcolor='#FAFAFA'><td><img src='images/s_db.png'>Database</td><td>";
if ($mysqld) {
echo "Image for Running";
} else {
echo "<img src='images/s_error.png'>Error!! Service stopped";
}
echo "</td><td><img src='images/s_reload.png'>Reload</td></tr>";
echo "<tr bgcolor='#FAFAFA'><td><img src='images/s_host.png'>Webserver</td><td>";
if ($httpd) {
echo "Image for Running";
} else {
echo "<img src='images/s_error.png'>Error!! Service stopped";
}
echo "</td><td><img src='images/s_reload.png'>Reload</td></tr>";
echo "<tr bgcolor='#FAFAFA'><td><img src='images/s_cog.png'>SMS Gateway</td><td>";
echo "</td><td><img src='images/s_reload.png'>Reload</td></tr>";
echo "</table>";
showFooter();