View Full Version : need litle help on php
do anybody have registration system that uses some serial to register?
and can anybody help me how to implement server statisticks based on cached sql data, to decrease server load by webpage? smt like every 2 min procedure will write all statistics data to some file and page takes result from there. like in RUN UO Server statistics )
btw, im using l2cp modded a bit.
and another question: how this query from asp should be writen in php
query = "SELECT TOP 100 user_data.char_name,user_data.char_id,user_data.ac count_name,TmpD.sumamount,lev,user_data.create_dat e,user_data.use_time,login,logout FROM(SELECT char_id, SUM(item_id) AS sumamount FROM user_item WHERE item_type = 1306 GROUP BY char_id) TmpD INNER JOIN user_data ON TmpD.char_id = user_data.char_id ORDER BY account_name "
the problem seems to be in tempD.sumamount, seems like php dont like that dot.
sry for my poor engl. )
tnx for any advise
vieruemil
25.06.2005, 08:14
query = "SELECT TOP 100 user_data.char_name,user_data.char_id,user_data.ac count_name,TmpD.sumamount,lev,user_data.create_dat e,user_data.use_time,login,logout FROM(SELECT char_id, SUM(item_id) AS sumamount FROM user_item WHERE item_type = 1306 GROUP BY char_id) TmpD INNER JOIN user_data ON TmpD.char_id = user_data.char_id ORDER BY account_name "
the query remains the same :)
it's SQL
Top 100[php:1:9758bd6c0c]<?
include("config.php");
mssql_connect($mssql_server,$mssql_user,$mssql_pas s);
mssql_select_db($mssql_db);
$result=mssql_query("
select
char_name, Lev, builder,
class, use_time,
PK, Duel,gender
from user_data
where char_name not in (".("'".join("','",$exclude_from_top)."'").") and account_id>0
order by Lev desc");
$online_users=array();
for($x=0;($online_users[$x]=mssql_fetch_assoc($result))&&$x<100;$x++){
$online_users[$x]['use_time_h']=round($online_users[$x]['use_time']/3600,1)."h";
**;
unset($online_users[count($online_users)-1]);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jan 01 1900 00:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META http-equiv="content-language" content="en">
<META name="author" content="">
<META HTTP-EQUIV="Reply-to" CONTENT="@.com">
<META name="generator" content="PHPEd 3.1">
<META NAME="description" CONTENT="">
<META name="keywords" content="">
<META NAME="Creation_Date" CONTENT="08/15/2000">
<META name="revisit-after" content="15 days">
<title>Online</title>
</head>
<body>
<table border="1" align=center>
<tr>
<td>##</td>
<td>Nick</td>
<td>Lvl</td>
<td>Class</td>
<td>Total in game</td>
<td>PvP/PK</td>
</tr>
<?for($x=0;$x<count($online_users);$x++){?>
<tr>
<td><?=$x+1?></td>
<td style="color:<?=$online_users[$x]["gender"]?"#FF8080":"#8080FF"?>"><?=$online_users[$x]["char_name"]?></td>
<td><?=$online_users[$x]["Lev"]?></td>
<td><?=$class_list[$online_users[$x]["class"]]?></td>
<td><?=$online_users[$x]["use_time_h"]?></td>
<td><?=$online_users[$x]["Duel"]?>/<?=$online_users[$x]["PK"]?></td>
</tr>
<?**?>
</table>
</body>
</html> [/php:1:9758bd6c0c]
Refresh in seconds
<head>
<title>FORT Admin page</title>
<meta http-equiv="REFRESH" content="90;url=home.php"></head>
For writing one file so u decrese the load from sql u can fetch data and write the new file (either log or php file).
Here is my sample of BAN log php:
[php:1:e13fd394e5]<?php
securitycheck($securitycheck);
;
if(!isset($frmAccUid)) $frmAccUid=$_POST['frmAccUid'];
$frmAccUid = intval($frmAccUid);
if($frmAccUid>0)
{
$userAccId = $frmAccUid;
$dbconnect = mssql_connect ($CONFIG['dbaddress'], $CONFIG['dbuser'], $CONFIG['dbpass']);
mssql_select_db ($CONFIG['dbdbname'], $dbconnect) or die(print("error"));
$query = "UPDATE User_Account SET block_flag=0, block_flag2=0 WHERE uid=".$userAccId;
$result = mssql_query($query);
if($result)
{
$str = "ACC UNBANNED: UID = $userAccId;";
echoLn($str);
writeLog($str);
}
else echoLn("ACC (UID = $userAccId) NOT UNBANNED!!");
}
$szArqLog = "/home/banlog.log"; <----- !!!! add ur path to file here !!!!
$hFile = fopen($szArqLog,"rb");
if(!$hFile) die("Can't open the log file");
$buffer = fread($hFile,filesize($szArqLog));
fclose($hFile);
?>
<TABLE align=center border=0>
<TR>
<TD align=center>
<FORM METHOD=POST name='frmUnban' action="home.php?page=banlog">
UNBAN ACC UID: <INPUT TYPE="text" NAME="frmAccUid"> <INPUT TYPE="submit">
</FORM>
<TEXTAREA ROWS="30" COLS="80" style="font:10pt;">
<?php echo($buffer); ?>
</TEXTAREA>
</TD>
</TR>
</TABLE>
[/php:1:e13fd394e5]
tnx for reply.
for bigboy
i got parse error on line 23..
and i have top 100 page. How exactly works that refresh? where to put it and i need it works automaticly, not only then im visiting admin page or else?
to vieruemil
i need item search by id page.. how make it on php? that sql string doesnt works for me.. got parse errors.. i make it on asp like i post.
vieruemil
26.06.2005, 08:11
BigBoy wrote an explanation for you at line 23 - "<----- !!!! add ur path to file here !!!!"
just remove it.
Th refresh code is only the meta tag
<meta http-equiv="REFRESH" content="90;url=home.php">
You put it between the
<head> </head> tags of your php file.
If you load the page in browser and let it open, after 90 sec. it goes to the url indicated in the meta-tag. So if the url is the same page, then it reloads it again, and again ... after each 90 sec.
What do you mean with search by id?
You want to indicate the ID and have as result the item name ?
Or you want to search several information about the players, who own the items you want to check?
btw the items data is stored in the user_item table (lin2world DB).
Try to execute your query in the query analyser and see the results.
SELECT TOP 100 user_data.char_name,user_data.char_id,user_data.ac count_name,TmpD.sumamount,lev,user_data.create_dat e,user_data.use_time,login,logout FROM(SELECT char_id, SUM(item_id) AS sumamount FROM user_item WHERE item_type = 1306 GROUP BY char_id) TmpD INNER JOIN user_data ON TmpD.char_id = user_data.char_id ORDER BY account_name ASC
It should work. The problem cannot be the php or asp, 'cause it's only a SQL query. The php or asp just displays what the query returns.
LoL thx vieruemil for explaining him. i tought the guy will read the code and that he got some more experience with it :/
add for items:
U need to create another database to be able to get the Item names. from user_item u can only get item id's without names and descriptions.
The easyest was would be to decrypt itemname-e.txt, open the file in word or excel, filter the non needed entryes and create brand new table under lin2world so u can fetch the item ID's for ur webpage.
vieruemil
26.06.2005, 10:30
Using excel is really a good idea, Bigoy !!!
It's really cool at editing npc's itemdata's (server-side) and easy to find errors :)
How didn't I figure up before... :?
:wink:
ok, iv got it with comment without // ) didnt notice that // is missing there.
but now i got error - undefined function securitycheck on line2 (
about autorefresh - do that script create some html or else file from wich main page should get data to decrease server load?
about item search, i just need to find users wich have item number..
this is part of my asp page:
<%
function online_offline(login,logout)
if login<>"" and logout<>"" then
if cdate(login) > cdate(logout) then
online_offline = "<image src= images/online.gif width=7 height=5>"
else
online_offline = "<image src= images/offline.gif width=7 height=5>"
end if
else
online_offline = "<image src= images/offline.gif width=7 height=5>"
end if
end function
sub ListMoneybagsTop50
dim query
dim rs
dim gender
dim no
response.write " <table width='670' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#CE923C'> " & _
" <tr align='center' valign='middle' height=25>" & _
" <td width='20'></td>" & _
" <td >Player id</td>" & _
" <td >Player Name</td>" & _
" <td >Account</td>" & _
" <td width='25'>Lev</td>" & _
" <td width='80'>last log</td>" & _
" <td width='80'>create</td>" & _
" <td width='40'>1307</td>" & _
" <td width='40'>Used Time</td></tr>"
query = "SELECT TOP 100 user_data.char_name,user_data.char_id,user_data.ac count_name,TmpD.sumamount,lev,user_data.create_dat e,user_data.use_time,login,logout FROM(SELECT char_id, SUM(enchant) AS sumamount FROM user_item WHERE enchant > 50 GROUP BY char_id) TmpD INNER JOIN user_data ON TmpD.char_id = user_data.char_id ORDER BY account_name "
set rs = Server.CreateObject("ADODB.RECORDSET")
rs.open query, lin2world_conn, 1, 1
while not rs.eof
no = no + 1
response.write "<tr align='center' valign='middle'>"
response.write "<td>" & no & "" & online_offline(rs("login"), rs("logout")) & "</td>"
response.write "<td>" & rs("char_id") & "</td>"
response.write "<td>" & rs("char_name") & "</td>"
response.write "<td>" & rs("account_name") & "</td>"
response.write "<td>" & rs("Lev") & "</td>"
response.write "<td>" & rs("login") & "</td>"
response.write "<td>" & rs("create_date") & "</td>"
response.write "<td>" & rs("sumamount") & "</td>"
dim time
time = int(rs("use_time"))
if time < 3600 then
response.write "<td>" & Int(time/60) & " min</td>"
else
response.write "<td>" & Int(time/3600) & " Hours </td>"
end if
response.write "</tr>"
rs.movenext
Wend
rs.close
set rs = nothing
response.write "</table>"
response.write " <table width='670' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#CE923C'> " & _
" <tr align='center' valign='middle' height=25>" & _
" <td width='20'></td>" & _
" <td >Player id</td>" & _
" <td >Player Name</td>" & _
" <td >Account</td>" & _
" <td width='25'>Lev</td>" & _
" <td width='80'>last log</td>" & _
" <td width='80'>create</td>" & _
" <td width='40'>1306</td>" & _
" <td width='40'>Used Time</td></tr>"
query = "SELECT TOP 100 user_data.char_name,user_data.char_id,user_data.ac count_name,TmpD.sumamount,lev,user_data.create_dat e,user_data.use_time,login,logout FROM(SELECT char_id, SUM(item_id) AS sumamount FROM user_item WHERE item_type = 1306 GROUP BY char_id) TmpD INNER JOIN user_data ON TmpD.char_id = user_data.char_id ORDER BY account_name "
set rs = Server.CreateObject("ADODB.RECORDSET")
rs.open query, lin2world_conn, 1, 1
while not rs.eof
no = no + 1
response.write "<tr align='center' valign='middle'>"
response.write "<td>" & no & "" & online_offline(rs("login"), rs("logout")) & "</td>"
response.write "<td>" & rs("char_id") & "</td>"
response.write "<td>" & rs("char_name") & "</td>"
response.write "<td>" & rs("account_name") & "</td>"
response.write "<td>" & rs("Lev") & "</td>"
response.write "<td>" & rs("login") & "</td>"
response.write "<td>" & rs("create_date") & "</td>"
response.write "<td>" & rs("sumamount") & "</td>"
dim time2
time2 = int(rs("use_time"))
if time2 < 3600 then
response.write "<td>" & Int(time2/60) & " min</td>"
else
response.write "<td>" & Int(time2/3600) & " Hours </td>"
end if
response.write "</tr>"
rs.movenext
Wend
rs.close
set rs = nothing
response.write "</table>"
maby someone can help me add search field, so i can input item id, and get results who hase that item plz? )
the code top100 is secure?
Thx a lot
vieruemil
28.06.2005, 12:29
You can find charnames using a simple sql query like that
select a.char_name, count(a.char_name) as amount from user_data a
inner join user_item b on
a.char_id=b.char_id
where b.item_type='<item id>'
group by a.char_name
order by a.char_name
asc
replace <item id> with the id you need.