Skip to content

Instantly share code, notes, and snippets.

@PEMapModder
PEMapModder / mysqli.php
Created January 20, 2016 11:13
Simple MySQL client written in PHP
#!/usr/bin/env php
<?php
if(!defined("STDIN")) define("STDIN", fopen("php://stdin", "R"));
$host = "localhost";
$user = "root";
$password = "";
$schema = "";
$opts = getopt("h:u:p:s:");
@Intyre
Intyre / forum-help-README.md
Last active March 19, 2016 08:51
PocketMine Help Readme

Before reading, please consider I have poor English writing skills. Sorry. :(

What is 'Magenta'?

'Magenta' is Python script, which are made to crash PocketMine-MP servers, exactly PocketMine-Raklib.

How is it possible?

To understand this, you should know how Raklib's session system is working. Raklib creates every session per IP/Port to manage each clients, and these sessions are PHP objects.

They have many properties, such as $messageIndex, $address, $port, etc. What we need to play with is $preJoinQueue[] array. This contains MCPE DataPackets before a server-client handshake, and all stored packets will be processed after the connection process is completed. (See This)

@iksaku
iksaku / VirtualInventories.php
Created June 11, 2015 21:41
Way to open virtual custom inventories in MCPE :D (Work in progress...) Special thanks to @alejandroliu and @PEMapModder for a previous research :3
<?php
/**
* @name VirtualInventories
* @main VirtualInventories\Loader
* @version 1.0.0
* @api 1.12.0
* @description Way to open virtual custom inventories
* @author iksaku
*/
@shoghicp
shoghicp / MyPlugin.php
Created May 9, 2015 20:16
Example of new plugin format aimed for easy scripting.
<?php
/**
* This file is an example of a compressed plaintext plugin format for PocketMine
* It's aimed towards easy scripting, but not for normal plugin development.
*
* This kind of plugin won't be able to embed/load resources,
* nor have access to some features like fast permission/command integration.
*
* This first comment is used to define the properties like on plugin.yml,
<?php
namespace shoghicp\MinecraftSimulator\task;
use pocketmine\Player;
use pocketmine\scheduler\PluginTask;
use shoghicp\MinecraftSimulator\Loader;
class MarqueeTask extends PluginTask{
@matheusoliveira
matheusoliveira / random.sql
Created February 21, 2015 16:32
A very optimized way of getting random rows of a table on PostgreSQL (gets by "id" in a fast and non-biased way, if with gaps)
/* One random row from table "tbl" */
WITH RECURSIVE r AS (
SELECT NULL::int AS id, min(id) AS min_id, max(id) AS max_id, 0 AS cnt
FROM tbl
UNION ALL
SELECT tbl.id, r.min_id, r.max_id, r.cnt + 1
FROM r LEFT JOIN tbl
ON tbl.id = (SELECT floor(random() * (r.max_id - r.min_id + 1))::int)
WHERE r.id IS NULL
)
<?php
$world = $this->getServer()->getDefaultLevel();
$radius = 136;
$total = (($radius * 2) + 1) ** 2;
$count = 0;
$bList = clone \pocketmine\block\Block::$list;
$search = [];
dispatcher.registerCommand(
literal("scoreboard").then(
literal("players").then(
literal("reset").then(
argument("players", players()).then(
optional("objective", objective())
).executes(SOME_COMMAND)
)
).then(
literal("list").then(
@shoghicp
shoghicp / 3lines.php
Last active March 17, 2016 06:10
RC4 implementation in PHP, without run-time notices or errors. Outputs keystream directly. http://en.wikipedia.org/wiki/RC4
<?php
for($K='Key',$_=range($i=$j=0,$n=255);$i<=$n;$j+=$_[$i]+ord($K{$i%strlen($K)}),_($_[$j&=$n],$_[$i++]));
for($j=$i=0;++$i;$j+=$_[$i&=$n],_($_[$j&=$n],$_[$i]),printf('%x',$_[($_[$i]+$_[$j])&$n]));
function _(&$i,&$j){$i=$j+$i-($j=$i);}