Guest_imported
New member
- Jan 1, 1970
- 0
Hi, I was wondering if someone could do me a real big favour and convert the following script to php. I think it's in JSP. The problem is I understand a small majority of the script and I really need it for my site. If you don't have the time to convert it all could you just convert anything which doesn't seem like basic knowledge and anything todo with cookies. Thanx
Class.forName("org.gjt.mm.mysql.Driver"
conn = DriverManager.getConnection(url, id, pass);
long lTimeNow = ( (new Date()).getTime() / 1000 );
String sXMBLVA = "";
String sXMBLVB = "";
String sXMBUser = "";
String sOnlineUser = "";
long lCurrtime1 = lTimeNow + (86400 * 365);
long lCurrtime2 = lTimeNow + 600;
long lTheTime;
String sCookiePath = "";
String sCookieDomain = "";
String sIPAddress = request.getRemoteAddr();
String sLocation = request.getRequestURI();
String sQueryString = request.getQueryString();
if ((sIPAddress.indexOf("216.239.46." == -1) &&
(sIPAddress.indexOf("64.152.75." == -1))
{
try
{
Cookie[] cookies = request.getCookies();
if ( cookies != null )
{
for (int i = 0; i < cookies.length; i++ )
{
String sCookieName = cookies.getName();
if (sCookieName.equals("xmblva")
{
sXMBLVA = cookies.getValue();
}
else if (sCookieName.equals("xbmlvb")
{
sXMBLVB = cookies.getValue();
}
else if (sCookieName.equals("xmbuser")
{
sXMBUser = cookies.getValue();
}
}
}
Cookie cCookie1 = new Cookie("xmblva", "" + lTimeNow);
Cookie cCookie2 = new Cookie("xmblvb", ""
cCookie1.setMaxAge(86400 * 365);
cCookie1.setDomain(sCookieDomain);
cCookie1.setPath(sCookiePath);
response.addCookie(cCookie1);
if (sXMBLVB.length() > 0)
lTheTime = Long.parseLong(sXMBLVA);
else
lTheTime = lTimeNow / 1000;
cCookie2.setValue("" + lTheTime);
cCookie2.setMaxAge(600);
cCookie2.setPath(sCookiePath);
cCookie2.setDomain(sCookieDomain);
response.addCookie(cCookie2);
if ( sXMBUser.length() > 0 )
{
sOnlineUser = sXMBUser;
sql = "Update xmb_members set lastvisit='" + lTimeNow + "' where username='" + sXMBUser + "'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
}
else
{
sOnlineUser = "xguest123";
}
if (sQueryString != null) sLocation += "?" + sQueryString;
sLocation = "<a href=\"" + sLocation + "\">" + sLocation + "</a>";
long lNewTime = ( (new Date()).getTime() / 1000 ) - 600;
sql = "Delete from xmb_whosonline where ";
sql += " (ip='" + sIPAddress + "' && username='" + sXMBUser + "') OR ";
sql += " ip='" + sIPAddress + "' OR username='" + sXMBUser + "' OR ";
sql += " time < " + lNewTime;
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
sql = "Insert into xmb_whosonline VALUES('" + sOnlineUser + "', '" + sIPAddress + "' , '" + lTimeNow + "', '" + sLocation + "')";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
sListUsers = "";
int iCountGuests = 0;
sql = "Select username from xmb_whosonline where location = '" + sLocation + "' order by username";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next())
{
String sUsername = rs.getString("username"
if (!sUsername.equals("xguest123")
{
if (sListUsers.length() > 0)
sListUsers += ", " + "<a class=\"link\" href=\"" + sLinkPath + "forum/member.php?action=viewpro&member=" + java.net.URLEncoder.encode(sUsername) + "\">" + java.net.URLEncoder.encode(sUsername) + "</a>";
else
sListUsers = "<a class=\"link\" href=\"" + sLinkPath + "forum/member.php?action=viewpro&member=" + java.net.URLEncoder.encode(sUsername) + "\">" + java.net.URLEncoder.encode(sUsername) + "</a>";
}
else
{
iCountGuests++;
}
}
// if no members, display "None"
if (sListUsers.length() == 0) sListUsers = "None";
// display Guests if there are any
if (iCountGuests == 1) sListUsers += " (1 Guest)";
if (iCountGuests > 1) sListUsers += " (" + iCountGuests + " Guests)";
bCookiesOn = true;
}
catch(java.lang.NoClassDefFoundError ex)
{ %>
<!--caught an error here-->
<% }
}
conn.close();
Class.forName("org.gjt.mm.mysql.Driver"
conn = DriverManager.getConnection(url, id, pass);
long lTimeNow = ( (new Date()).getTime() / 1000 );
String sXMBLVA = "";
String sXMBLVB = "";
String sXMBUser = "";
String sOnlineUser = "";
long lCurrtime1 = lTimeNow + (86400 * 365);
long lCurrtime2 = lTimeNow + 600;
long lTheTime;
String sCookiePath = "";
String sCookieDomain = "";
String sIPAddress = request.getRemoteAddr();
String sLocation = request.getRequestURI();
String sQueryString = request.getQueryString();
if ((sIPAddress.indexOf("216.239.46." == -1) &&
(sIPAddress.indexOf("64.152.75." == -1))
{
try
{
Cookie[] cookies = request.getCookies();
if ( cookies != null )
{
for (int i = 0; i < cookies.length; i++ )
{
String sCookieName = cookies.getName();
if (sCookieName.equals("xmblva")
{
sXMBLVA = cookies.getValue();
}
else if (sCookieName.equals("xbmlvb")
{
sXMBLVB = cookies.getValue();
}
else if (sCookieName.equals("xmbuser")
{
sXMBUser = cookies.getValue();
}
}
}
Cookie cCookie1 = new Cookie("xmblva", "" + lTimeNow);
Cookie cCookie2 = new Cookie("xmblvb", ""
cCookie1.setMaxAge(86400 * 365);
cCookie1.setDomain(sCookieDomain);
cCookie1.setPath(sCookiePath);
response.addCookie(cCookie1);
if (sXMBLVB.length() > 0)
lTheTime = Long.parseLong(sXMBLVA);
else
lTheTime = lTimeNow / 1000;
cCookie2.setValue("" + lTheTime);
cCookie2.setMaxAge(600);
cCookie2.setPath(sCookiePath);
cCookie2.setDomain(sCookieDomain);
response.addCookie(cCookie2);
if ( sXMBUser.length() > 0 )
{
sOnlineUser = sXMBUser;
sql = "Update xmb_members set lastvisit='" + lTimeNow + "' where username='" + sXMBUser + "'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
}
else
{
sOnlineUser = "xguest123";
}
if (sQueryString != null) sLocation += "?" + sQueryString;
sLocation = "<a href=\"" + sLocation + "\">" + sLocation + "</a>";
long lNewTime = ( (new Date()).getTime() / 1000 ) - 600;
sql = "Delete from xmb_whosonline where ";
sql += " (ip='" + sIPAddress + "' && username='" + sXMBUser + "') OR ";
sql += " ip='" + sIPAddress + "' OR username='" + sXMBUser + "' OR ";
sql += " time < " + lNewTime;
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
sql = "Insert into xmb_whosonline VALUES('" + sOnlineUser + "', '" + sIPAddress + "' , '" + lTimeNow + "', '" + sLocation + "')";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.close();
sListUsers = "";
int iCountGuests = 0;
sql = "Select username from xmb_whosonline where location = '" + sLocation + "' order by username";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next())
{
String sUsername = rs.getString("username"
if (!sUsername.equals("xguest123")
{
if (sListUsers.length() > 0)
sListUsers += ", " + "<a class=\"link\" href=\"" + sLinkPath + "forum/member.php?action=viewpro&member=" + java.net.URLEncoder.encode(sUsername) + "\">" + java.net.URLEncoder.encode(sUsername) + "</a>";
else
sListUsers = "<a class=\"link\" href=\"" + sLinkPath + "forum/member.php?action=viewpro&member=" + java.net.URLEncoder.encode(sUsername) + "\">" + java.net.URLEncoder.encode(sUsername) + "</a>";
}
else
{
iCountGuests++;
}
}
// if no members, display "None"
if (sListUsers.length() == 0) sListUsers = "None";
// display Guests if there are any
if (iCountGuests == 1) sListUsers += " (1 Guest)";
if (iCountGuests > 1) sListUsers += " (" + iCountGuests + " Guests)";
bCookiesOn = true;
}
catch(java.lang.NoClassDefFoundError ex)
{ %>
<!--caught an error here-->
<% }
}
conn.close();