rejetto forum

How to display current user in your hfs server using php?

0 Members and 1 Guest are viewing this topic.

Offline squall8985

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
I already try to display in my webpage whether my hfs server is on or off and it works!  ;D
Anyone who is interested for the coding cam PM me.

Just wondering whether is it possible to display current user viewing my hfs and currently downloading in my hfs server.
And if it is possible how can i do it.
Thanx..
« Last Edit: March 04, 2007, 07:09:50 PM by squall8985 »


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
I don't think its possible..

Would be nice tho if it could be implemented in HFS :)


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
i guess that is possible to do

inside the template of the hfs we add a external file using this iframe:

Code: [Select]
<iframe name="HFS_Check" frameborder="0" width="150" height="300" marginheight="0" src="http://ledufe.no-ip.info/check.php" scrolling="AUTO"></iframe>
and inside the loggedin section we add the call to the check.php again but here it pass the username and its ip as a parameter

Code: [Select]
<script type="text/javascript" src="http://ledufe.no-ip.info/check.php?userip=%ip%&username=%user%"></script>
note the call of the php file just to show inside it the ajax part of the page that will auto update it self with the user names and maybe their ip adress :-)

inside the file check.php we have 3 sections:
the part of the code that will read the parameter and put it inside a raw text file or mysql database
the part that will read the data source(the raw text or the mysqldb)
the part that will auto update itself with ajax or actionscript/flash

also there is a hard way, that i guess it would be using the parse of the php to GET/READ the username of the user logged...
these are just ideas..i will test it and post here my progress

<<LeDuFe>>


Offline squall8985

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Thinking of the same thing..but dunno how to implement it..
If u've the solution do let me know..thanks..
in mean while i'll try to figure it out..


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
well this sollution does not "display current user in your hfs server using php" but it show to us that this might work
i could manage to get some info from a page generated by hfs using a hidden form and store this info into a mysql database,
this must be no big deal to some users, but it was a pain in @#$ to make this work, and it is still not working as much as i want, it must become a better component to any apache server with mysql, it will be good even when hfs support php...

well i passed some values into a form to a php page, that show the info, and post it into the db, and also created a page to show the info stored, but to make it be more usefull i puted it into a iframe on the hfs, and i was thinking that this could be the start of the admi page of the hfs.... lol, it give me more ideas....

i made some progress here, not much beauty, but at least is functional...
http://ledufe.no-ip.info/hfs/
this is my apache server page on port 80 (also i have instaled and configured my mysql to store the data)
wich will fowarded you to my hfs server on port 2222

inside my hfs (last version with default template and a small hidden form to pass some info that i want from the user inside my hfs, like ip, and username...)

hit the button  "Send DATA TO PHP"
you will be fowarded to a php page that recieved the data from the html form of the hfs and the data that will be stored will be showed and will give you two choices, to see the status or to get back to hfs
you will see on the iframe on the botton of the hfs that your info has been stored inside a mysql db beeing showed by a php page that auto refresh it self every 30 seconds(all this is external, and also im much new bee in php to make this beauty ) i wish that when the hfs support php and mysql i would be much more good than this, but this at least works...

i will comment the code to post it here later....

[attachment deleted by admin]
« Last Edit: March 11, 2007, 01:40:34 AM by ledufe »
<<LeDuFe>>


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
how many time can we count until we could considerer the user inactive or supose that he is offline(since the hfs does not support the logou yet)???

and about the code above

i was thinking

if we are going to show only the current logged users or "every" users online(if the user is not logged we shall call it a guest)

and to show it we could use ajax inside the php to auto update/increment the code without the refresh function

<<LeDuFe>>


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
by the way, here is the code that i used to make this work

this is the first section of my hfs template, with 2 easy changes
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <style type="text/css">
  %style%
  </style>
  <title>HFS %folder%</title>
  <link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
%login-link%
%loggedin%
%upload-link%
<div id=folderlabel>folder</div>
<div id=folder>%folder%</div>
<div id=body>
%folder-comment%
%up%
%files%
</div>
<div id=footer>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Build-time: %build-time%
</div>
<div>
<form action="http://ledufe.no-ip.info/hfs/hfs-stats.php" method="post">
<input type=hidden name=hfsuserip value="%ip%">
<input type=hidden name=hfsusername value="%user%">
<input type=hidden name=hfsurl value="http://%host%%encoded-folder%">
<input type=hidden name=hfstime value="%timestamp%">
<input name=senddata type=submit value="Send Data to php">
</form>
<div>
<iframe name="HFS-PHP-Status-TRACKER" frameborder="1" width="auto" height="auto" marginheight="1" src="http://ledufe.no-ip.info/hfs/hfs-stats3.php" scrolling="auto"></iframe>
</body>
</html>

right after the footer part of the section, i added a hidden form wich will pass the info to the php+mysql, please note that in the form i call the file hfs-stats.php as action, here bellow is the content of the file:

Code: [Select]
<?php
echo "User IP: " $_POST["hfsuserip"];
echo 
"<br>User Logged: " $_POST["hfsusername"];
echo 
"<br>URL: " $_POST["hfsurl"];
echo 
"<br>Time: " $_POST["hfstime"];
echo 
"<br>Data Provided by LeDuFe HFS-Server.";
$username "SQLUSERNAME";
$password "SQLPASSWORD";
$hostname "localhost";
$f_ip $_POST["hfsuserip"];
$f_username $_POST["hfsusername"];
$f_url $_POST["hfsurl"];
$f_time $_POST["hfstime"];
$dbh mysql_connect($hostname$username$password
or die("Unable to connect to mysql");
print 
"<br>connected to mysql server<br>";
$selected mysql_select_db("hfs",$dbh
or die("Could not select HFS-DB");
if (
mysql_query("insert into hfs_track (hfs_userip, hfs_username, hfs_url, hfs_time) VALUES ('$f_ip', '$f_username', '$f_url', '$f_time')")) {
  print 
"successfully inserted record<br><a href='hfs-stats2.php'>Show Results</a><br><a href='#'' onclick='history.go(-1);return false;'>Back to HFS</a>";
}
else {
  print "Failed to insert record";
}
mysql_close($dbh);
?>

and created a iframe with the results the file hfs-stats2.php here the content of the file:

Code: [Select]
<html>
<meta http-equiv="refresh" content="30">
<head>
<title>HFS PHP+MYSQL STATS                -    BY LeDuFe :-P</title>
  </head>
<body>

<?php
$username 
"SQLUSERNAME";
$password "SQLPASSWORD";
$hostname "localhost";
$dbh mysql_connect($hostname$username$password
or die("Unable to connect to mysql");
print 
"<br>HFS-Server PHP+MySQL Statistics - Auto-Refresh every 30 seconds<br>";
echo 
date("d/m/Y h:i:sa"time());
print 
"<br><br>";
$selected mysql_select_db("hfs",$dbh
or die("Could not select HFS-DB");
$query  "SELECT hfs_userip, hfs_username, hfs_url, hfs_time FROM hfs_track WHERE hfs_time<'hfs_time' ORDER BY hfs_username, hfs_userip, hfs_time";
$result mysql_query($query);
echo 
"<table>";
echo 
"<th>User IP Adress";
echo 
"<th>Logged Username";
echo 
"<th>URL";
echo 
"<th>Time";
while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
{
    echo  
 
"<tr><td align=left>".
 
"IP :{$row['hfs_userip']}".
 
"<td align=left>".
 
"USER NAME : {$row['hfs_username']}.
 
"<td align=left>".
 
"URL : {$row['hfs_url']}.
 
"<td align=left>".
 
"TIME : {$row['hfs_time']}";
}
echo 
"</table>";
mysql_close($dbh);
?>



</body>
</html>

and of course there is a database to store this info for future use os just to store the stats and access, but the possibilities are huge
<<LeDuFe>>


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
well, no one comment? ???

im trying to create a monitored template, a mod that could be made inside any template, to track some info, i already can do the online check, but i can go more deeper into the hfs, i can track wich user is at wich folder, and also, what was the most accessed folder, and also, i found a way to auto-generate the thumnail with the php+the library GD, and if some of you like the flash player , maybe we can achieve something new in this level too, since the php can generate the xml playlist, we can use it to generate a playlist with mp3 from diferent folders(just using the php to check the desired mp3 files and adding it to a php page, and after the selection be complete(while the user is browsing the folders inside the hfs) the xml generated would be puted inside a special folder(that is on the hfs-folder-tree) and then readed and played by the flash player(or any other player) mixed-ideas....

if somebody want to help us here, i may not be a "template releaser", and got not much time to spend with only hte hfs, but im learning php, and using what i learn with the hfs, and i found tha we can do almost anything we want as if the hfs supported the php itself, until this day come, i am training it with apache+php.
<<LeDuFe>>


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
Sounds very promising and it could solve a lot of problems!!

But the one thing that bothers me.. is that you need a remote web server to host the php files. And i dont think a lot of ppl have access to a web server (or want to host a php server along with HFS).

Anyway..
Somewhere around december last year, i started to learn html- and javascripting. I havent started learning PHP, but the way you say it makes it sound really easy and all the things you can do with it makes me want to learn how PHP works.

But in the mean time, do you mind showing me how the auto generated playlist would work and how it's done?

Thnx



Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
...But the one thing that bothers me.. is that you need a remote web server to host the php files.
And i dont think a lot of ppl have access to a web server (or want to host a php server along with HFS).
well, this is only a experiment, it is not a rule to the folloing templates of me or anybody, i just shocked with the power of the combinationof the hfs and php+mysql, note that i do not want to run many servers too, but since hfs not support any SSI besides what is on the template, and as the future versions (in a not so far futere i hope) will support php, im just learning the language, and applying it with hfs, and to be more lazy than ever  ;D im using some other servers to test it, i used the easyphp and the xampp  to run php+apache+mysql+phpmyadmin and more itens with my hfs,

Anyway..
Somewhere around december last year, i started to learn html- and javascripting. I havent started learning PHP, but the way you say it makes it sound really easy and all the things you can do with it makes me want to learn how PHP works.
it is a little easy, and it is free, so lets try it  ;) and i will be more than glad to exchange ideas with you or anyone else that plays with php and web stuffs

But in the mean time, do you mind showing me how the auto generated playlist would work
i will post here the info and some screens
and how it's done?
well thats another history, im already trying to do this and it is not as fuctional as i want, so let me improve it more to post here some code in the next post
wich remind me something, hey moderator, please put this message and the last one about php+hfs online check into a new area, like php+hfs or put some php into a stick post to make it more easy to find and to avoid the same question about HFS and PHP suport  ;)
Thnx
<<LeDuFe>>


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
your is a cool solution, ledufe.
the only other solution i may think of is a program that reads from the GUI, inside the connections panel, and then make it available through the net, but it may be very tricky.

the hard point in this, is that HFS won't let you know via web what other people is transfering, but only your own transfers (privacy).


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
your is a cool solution, ledufe.
thanks!
Quote from: rejetto
the only other solution i may think of is a program that reads from the GUI, inside the connections panel, and then make it available through the net, but it may be very tricky.
i dont know if this is possible, and even if it is, well, my knowledge in programing things is not capable to do this ...
Quote from: rejetto
the hard point in this, is that HFS won't let you know via web what other people is transfering, but only your own transfers (privacy).
if....

if we give the user a option to read or not his clicks, and form itens of upload,
but if i build a java-script to send at every click with the info, user logged, time, his actual browsing folder, the link he clicked(file or folder, or link) the the php catchs this info, ...
it could be saved in session of the server, or inside a database...
and finally in a php iframe we show thos the users the ifo about who is logged and what are they doing...
i will try this, i was travelling at work, but now im home again....

<<LeDuFe>>