Koozali.org: home of the SME Server

fyi php scripts to show samba files open from web browser

Offline purvis

  • ****
  • 567
  • +0/-0
fyi php scripts to show samba files open from web browser
« on: April 20, 2011, 04:12:20 AM »
i have server php script files i put in a directory called serverstatus inside the Primary ibay
that will give me the files opened and how they are opened
this is very useful for many purposes and i used these two scripts to work out my oplocks problems with
programs that that do not make use of opportunistic file locking (oplocks).

like i said, the php files are placed in a directory i created  called /home/e-smith/files/ibays/Primary/html/serverstatus
one script refreshes the web browser every 3 seconds and the other does not
you will need both files

many top sme people users and developers have worried that this could be a security issue on your server from harmful eyes.
i would say create your own crazy named directory under Primary other than serverstatus
i do not have any links to my serverstatus directory from webpages and i always keep  default html web pages inside the Primary directory
so a web user cannot view my directory structure under Primary

some people might put these two files directly inside the Primary directory and not create a subdirectory under Primary at all.

basically these two scripts send the results of the smbstatus program with specific command tail arguments to a webpage.



filesopenloop.php
Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->
<html>
<head>
<meta http-equiv="refresh" content="3">
<title>Server open locked files report</title>
</head>
<body>
<tt>
<b>
<div>
<font size="2">
To stop this webpage from automatic refreshing <a href="filesopen.php">click here</a>.
<?php
print "<pre>";
echo  
'<font size="2">';
print 
"Server open locked files report ";system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"URL name : ";
print  (
$_SERVER['SERVER_NAME']);
system("smbstatus -b | col -b",$return);
echo  
'<font size="1">';
print 
"\n";
system("smbstatus -L | col -b",$return);
echo  
'<font size="2">';
print 
"---end of report---\n";
print 
"</pre>";
?>

</div>
</body>
</html>

and

filesopen.php
Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->
<html>
<head>
<title>Server open locked files report</title>
</head>
<body>
<tt>
<b>
<div>
<font size="2">
To have web page auto refresh every 3 seconds <a href="filesopenloop.php">click here</a>.
<?php
print "<pre>";
echo  
'<font size="2">';
print 
"Server open locked files report ";system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"URL name : ";
print  (
$_SERVER['SERVER_NAME']);
system("smbstatus -b | col -b",$return);
print 
"\n";
system("smbstatus -L | col -b",$return);
print 
"---end of report---\n";
print 
"</pre>";
?>

</div>
</body>
</html>



« Last Edit: April 20, 2011, 04:15:21 AM by purvis »