Jump to content

[Guide] How to Write PHP Script


EdenEternal

Recommended Posts

Hello Ladies i want to share guide about how to write php script.it's very easy. so let's start. say for example we need top pvp kills script.

first create config.php and write there this:

 

<?php
$L2JBS_config["mysql_host"]="localhost";	// MySQL Host 	["localhost"]
$L2JBS_config["mysql_port"]="3306";		// MySQL Port			["3306"]
$L2JBS_config["mysql_db"]="l2jdb";		// MySQL Database	["l2jdb"]
$L2JBS_config["mysql_login"]="root";		// MySQL User			["root"]	
$L2JBS_config["mysql_password"]="root";	// MySQL Password			["root"]
include("_config_procs.php");
error_reporting(0);
?>

 

now create _config_procs.php

 

<?php
  $link = mysql_connect($L2JBS_config['mysql_host'].":".$L2JBS_config['mysql_port'], $L2JBS_config['mysql_login'], $L2JBS_config['mysql_password']);
  if (!$link)
die("Couldn't connect to MySQL");
  @mysql_select_db($L2JBS_config['mysql_db'], $link);
error_reporting(0);

?>

 

now create toppvp.php and write there this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("MySQL Query");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

echo "<td>"."<center>".$row['online']."</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

now we need MySQL query. so open Navicat. go to your database and then open characters table.now click File -> Query Table. Then Query Builder.now we need to select fields. we need 4 field. character name,character object id, character pvpkills , characters level and of course character online status.

So for my database(La2Base Interlude) i have this fields: obj_id,char_name,level,pvpkills,online.

 

when you select your fields, again click on Query Editor. you see your sql script

i have this

 

SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

 

now we need to specify now many player must be in top script and how to order.. so add this to your sql script

 

ORDER BY characters.pvpkills DESC LIMIT 10

 

so we have

 

SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10

 

so copy and paste in our php script this sql query

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

echo "<td>"."<center>".$row['online']."</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

now we need to discuss online and offline characters yes?

so replace this

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

if ($row['online'] == 1)

echo "<td>"."<center>Online</center>"."</td>";

else

echo "<td>"."<center>Offline</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

So it's look like this:

 

37668565.png

 

Finish. I think i deserve karma  :P

Link to comment
Share on other sites

Man i think is wrong way to learn How to Write PHP Script.

 

If someone want to write php script let go to php.net to learn the basics for php language and after let read a tutorial for sql language and finaly lets write a php script.

 

This is my opinion...

Link to comment
Share on other sites

  • 2 months later...

damn i know 000000 about this,whaen you say create config.php file,you mean how?Say i create a php file,i add the code in there?What i add to website...I dont undersatnd a thing,if anyone with video guide or else pls post..

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Hello if anyone is looking for interlude server with free bot, no P2W and uniques features I can recommend freshly opened https://l2romans.com/features/, great server for chilling and having fun with friends casually. Everyone is welcomed
    • So excited to announce 3x Telegram Premium (6 months)   Join our official TG and participate to win!   Asocks.com - trusted proxy service providing mobile and residential proxies with a single price of $3 per 1GB   A huge locations pool and high speed will help complete all tasks    
    • Well, sorry not sorry for resurrecting old topic, but I believe it's ultimately stupid to implement license checks like Vilmis did 🙂   private static String url = "jdbc:mysql://185.80.128.233/" + getData("Zm9ydW1fZGI="); private static String username = getData("bXJjb3B5cmlnaHQ="); private static String password = getData("Y29weXJpZ2h0XzEyMw=="); con = GlobalDB.getInstance().getConnection(); PreparedStatement statement; statement = con.prepareStatement("SELECT field_6 from core_pfields_content WHERE member_id = ?"); statement.setInt(1, Config.FORUM_USER_ID); ResultSet rset = statement.executeQuery();   This awesome way of coding things leaves us with base64-encoded credentials and DB exposed and accessible globally 😉 Btw he checks his licensing data from some plugin generated table his forum uses. Vilmis took action and ensured that mrcopyright user would have only needed accesses and rights for this operation. But he forgot to ensure that his INFORMATION_SCHEMA database would not be exposed and readable... That leads us to fully readable server variables like version used (10.1.26-MariaDB-0+deb9u1 - pretty ancient DB and OS, I'd assume). From here you can go south and do some kinky stuff, if you want and have knowledge for that. But who cares, right?   Ooh, table core_pfields_content field_6 is IP address which is checked by FORUM_USER_ID. Yep, you can query all IP addresses there (124 of them right now) and also do whatever you want with them! 🙂  The most fun part? Files source has been shared what, more than 2 years ago?  Vilmis still uses very same credentials and never changed it after sources exposure - who cares. Although, "sources" may be way too strong word here. If anyone still use paid Orion versions, I'd suggest packing your shit and leaving immediately, or at least fix this incompetent fool caused problems. It's obvious Vilmis don't care or maybe doesn't even know from the first place how to solve this problem (hint hint - tiny PHP Rest API microservice which would do absolutely the same but without exposing sensitive data?). By doing that, he exposes his infrastructure and YOUR data, and he does that for more than 2 years now 🙂 Developer of century!    
    • rename the l2.bin into l2.exe
  • Topics

×
×
  • Create New...