The following PHP win32_query_service_status works for querying the local machine, however we are attempting to perform this query on a remote machine within the same domain. We receive no errors however nothing is returned ideas?
$name = "spooler"
$machine = "remotemachine"
$status=win32_query_service_status($name, $machine);
echo "$name service is ";
if ($status["CurrentState"]==1) {echo "Stopped";}
else
if ($status["CurrentState"]==2) {echo "Starting";}
else
if ($status["CurrentState"]==3) {echo "Stopping";}
else
if ($status["CurrentState"]==4) {echo "Running";}
Related
Currently I am working on a web application developed for ISPs. I am using Mikrotik PHP API to create firewall connections logs. I am adding all entries into the MySql database. Everything is OK when I use this script on my Windows-based XAMPP server on my laptop but when I upload this script of Ubuntu then it says
"This page isn’t working"... HTTP ERROR 500...
Other commands with $API->write(); working well but this command is not working:
$API->comm("/ip/firewall/connection/print");
I am using Ubuntu 16.4 on my server machine. Above mentioned command is working in XAMPP (Windows) but not working LAMP (Ubuntu 16.4).
Complete code is here:
<?php
include_once('key.php');
$mikrotik_ip = $ip;
$mikrotik_username = $user;
$mikrotik_password = $pass;
if ($API->connect($mikrotik_ip, $mikrotik_username,$mikrotik_password)) {
$log = $API->comm("/ip/firewall/connection/print");
$clog = count($log);
for($a=0;$a<=$clog;$a++){
$state = isset($log[$a]['tcp-state']) ? $log[$a]['tcp-state'] : '';
$src = $log[$a]['src-address'];
$src_rep = $log[$a]['reply-src-address'];
$dst = $log[$a]['dst-address'];
$dst_rep = $log[$a]['reply-dst-address'];
$prot = $log[$a]['protocol'];
mysqli_query($connect,"insert into cts(cts_id,src_address,reply_src_address,dst_address,reply_dst_address,protocol,tcp_state,date) values('','$src','$src_rep','$dst','$dst_rep','$prot','$state','".date("Y-m-d H:i:s")."')") or die(mysqli_error());
}
mysqli_close($connect);
}else{
echo 'Not Connected';
}
?>
i recently got back into php! I have been trying to get this to work but i just can't seem to get it :(
So, i am trying to check to see if a UDP port (the port i am using for my game server is running or not) it says "Online" but it stays online even when i turn the server off :( can someone explain to me what is going and correct me? thanks!
<?php
$host = '47.39.46.24';
$port = 14242;
$waitTimeoutInSeconds = 7;
if($fp = fsockopen("udp://".$host,$port,$errCode,$errStr))
{
$write = fwrite($fp,"x00");
if (!$write)
{
echo 'offline';
}
else
{
echo 'online';
}
}
else
{
echo 'offline';
}
fclose($fp);
?>
And before you say i shouldn't be giving my ip don't worry it isn't real :D
I am trying to working with geoip to display Ips and their Countries . I am trying to display this code but nothing comes up?
$country = geoip_country_name_by_name($ip);
You must have the GeoIP functions installed first. If they are installed, then it could be possible, that the IP you're providing to the function does not exist in the database.
Try this code:
<?php
$country = geoip_country_name_by_name($ip);
if ($country) {
echo 'This host is located in: ' . $country;
} else {
echo 'Cannot find the IP in the database.'
}
I'm trying to output the status of a server (online/offline) in html.
I have a PHP snippet that checks the status of the server but I need the output to be in HTML format so I can use it elsewhere on my website.
I'm running wordpress with the tablera plugin, I want to output the status (just online or offline text) in the table but it does not accept PHP, only HTML.
Edit:
This is my PHP snippet:
<?php
$array="www.php.net:80";
$fp = #fsockopen($array[0], $array[1], $errno, $errstr,1);
if(!$fp){
$status = $array[0]."==><font color=\"#FF0000\">online</font>";
}
else{
$status = $array[0]."==><font color=\"#FF0000\">offline</font>";
}
fclose($fp);
echo $status;
?>
It just needs to check if the server is online or offline, if it's online it should display 'online' if its offline, it should display 'offline'.
This script checks your server to see if the server is online or not.
<?php
if (fsockopen('www.yourwebsite.com', 80)) {
echo('Reports Online');
} else {
echo('Reports Offline');
}
?>
I am using webmatrix and trying to connect to a local database in that which is SQL database . I have IIS and SQL Server installed on the computer . The database was created in webmatrix only .
Initially the error display was not on , I managed to do that by manipulating the php.ini file . After that I tried this script which is giving the following result .
<?php
if (function_exists('mssql_connect')){
echo "Okay, fn is there<br>------------------<br>";
} else {
echo "Hmmm .. fn is not even there<br>------------------<br>";
}
if(extension_loaded("mssql")) {
echo "MSSQL is Loaded<br>";
}
else {
echo "MSSQL not loaded<br>";
}
if(extension_loaded("msql")) {
echo "MSQL is Loaded<br>";
}
else {
echo "MSQL not loaded<br>";
}
echo '<br><br>';
$ext = get_loaded_extensions();
if(in_array('mssql', $ext))
echo 'u have mssql installed<br><br>';
else
echo 'u do NOT have mssql installed<br><br>';
?>
The result is :
Hmmm .. fn is not even there
MSSQL not loaded
MSQL not loaded
u do NOT have mssql installed
This is the command I was using to connect to mssql database
<?php
$con=mssql_connect('.\SQLEXPRESS','Shops_localdbU','thePass');
if($con) {
echo "success";
}
?>
and output was:
Fatal error: Call to undefined function mssql_connect() in C:\xampp\htdocs\sample.php on line 3
May be the functions are not installed on your server. If you have access to install them, then you can do that. If not, you cannot use these functions.
If you do have permission to modify the PHP configuration, start here:
http://www.php.net/manual/en/mssql.setup.php