<?php
include_once("config.inc.php");
if(is_file("tree.txt")) unlink("tree.txt");
define("CREATE", false);
define("ADD", ($_GET["perm"]=="add"?true:false));
define("REMOVE", ($_GET["perm"]=="del"?true:false));
define("REMOVETREE", ($_GET["perm"]=="rem"?true:false));
define("CREATEROOT", ($_GET["perm"]=="root"?true:false));
define("MOVEUP", ($_GET["perm"]=="up"?true:false));
define("MOVEDOWN", ($_GET["perm"]=="down"?true:false));
define("MOVELEFT", ($_GET["perm"]=="left"?true:false));
define("MOVERIGHT", ($_GET["perm"]=="right"?true:false));
if(array_key_exists("HTTP_REFERER", $_SERVER)) {
$header = $_SERVER["HTTP_REFERER"];
} else {
$header = "index.php";
if($_GET["node"]) {
$header .= "?node=".((int)$_GET["node"]);
}
}
Db_ClosureTable::debug();
$db = new Db_ClosureTable(new Db($conn), "tp_posts", "posts", "post_id");
if(CREATE) {
$db->createClosureTable();
}
if(ADD) {
$loremGenerator = '';
for($i=0;$i<2;$i++){
$loremGenerator .= $lorem[rand(0,count($lorem)-1)];
}
$sql = 'INSERT INTO mydb.posts (user_id,post,content,ts) VALUES('.($_GET["u"]?$_GET["u"]:1).',\'bene '.rand(0,1000).'\',\''.$loremGenerator.'\',NOW());';
$db->insert($sql, ($_GET["a"]?$_GET["a"]:1));
}
elseif(CREATEROOT) {
$loremGenerator = '';
for($i=0;$i<2;$i++){
$loremGenerator .= $lorem[rand(0,count($lorem)-1)];
}
$sql = 'INSERT INTO mydb.posts (user_id,post,content,ts) VALUES('.($_GET["u"]?$_GET["u"]:1).',\'bene '.rand(0,1000).'\',\''.$loremGenerator.'\',NOW());';
$db->insert($sql, ($_GET["a"]?$_GET["a"]:1));
}elseif(MOVEUP){
$db->moveUp(($_GET["a"]?$_GET["a"]:1), ($_GET["p"]?$_GET["p"]:1) );
}elseif(MOVEDOWN){
$db->moveDown(($_GET["a"]?$_GET["a"]:1), ($_GET["p"]?$_GET["p"]:1) );
}elseif(MOVELEFT){
$db->moveLeft(($_GET["a"]?$_GET["a"]:1), ($_GET["p"]?$_GET["p"]:1));
}elseif(MOVERIGHT){
$db->moveRight(($_GET["a"]?$_GET["a"]:1), ($_GET["p"]?$_GET["p"]:1));
}
if(REMOVE) {
$db->delete($_GET["a"], ($_GET["p"]?$_GET["p"]:1));
}
elseif(REMOVETREE) {
$db->deleteSubtree($_GET["a"], ($_GET["p"]?$_GET["p"]:1));
}
$db->close();
header("Location:". $header);
|