コード例 #1
0
<?php

// add a minion relationship between two creatures
class ajaxRequest
{
    function addMinion()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $boss = (string) htmlspecialchars($_POST['boss']);
        $minion = (string) htmlspecialchars($_POST['minion']);
        $return = array();
        $return['boss'] = $boss;
        $return['minion'] = $minion;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_minions(boss_id, minion_id) \n\t\t\t\t\t\t\t\t\t\t\tVALUES ((SELECT id FROM mm_creatures WHERE name = ?), \n\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT id FROM mm_creatures WHERE name = ?))");
            $stmt->bind_param("ss", $boss, $minion);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addMinion();
コード例 #2
0
<?php

// add a type to the database
class ajaxRequest
{
    function addType()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $nameInput = (string) htmlspecialchars($_POST['typeName']);
        $return = array();
        $return['name'] = $nameInput;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_types(category) \n\t\t\t\t\t\t\t\t\t\t\t\t  VALUES (?)");
            $stmt->bind_param("s", $nameInput);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addType();
コード例 #3
0
<?php

// remove all creature-sense relationships for a given creature
class ajaxRequest
{
    function remCSenses()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature_name = (string) htmlspecialchars($_POST['rem_senses']);
        $return = array();
        $return['name'] = $creature_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_c_senses WHERE creature_id = \n\t\t\t\t\t\t\t\t\t\t(SELECT id FROM mm_creatures WHERE name= ?)");
            $stmt->bind_param("s", $creature_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->remCSenses();
コード例 #4
0
// add a relationship between a creature and a skill with a bonus value,
// update bonus value if relationship already exists
class ajaxRequest
{
    function addCreatureSkill()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature = (string) htmlspecialchars($_POST['cs_creature']);
        $skill = (string) htmlspecialchars($_POST['cs_skill']);
        $bonus = (string) htmlspecialchars($_POST['cs_bonus']);
        $return = array();
        $return['creature'] = $creature;
        $return['skill'] = $skill;
        $return['bonus'] = $bonus;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_c_skills (creature_id, skill_id, bonus)\n\t\t\t\t\t\t\t\t\t\t  VALUES\n\t\t\t\t\t\t\t\t\t\t\t((SELECT id FROM mm_creatures WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t (SELECT id FROM mm_skills WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t  ?)\n\t\t\t\t\t\t\t\t\t\t\t  ON DUPLICATE KEY UPDATE bonus = ?");
            $stmt->bind_param("ssdd", $creature, $skill, $bonus, $bonus);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addCreatureSkill();
コード例 #5
0
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['environ'][] = $rowName;
            }
        }
        $stmt->close();
        $stmt = $mysqli->prepare("SELECT CM.name FROM mm_creatures CB\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN mm_minions M ON CB.id = M.boss_id\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN mm_creatures CM ON M.minion_id = CM.id\n\t\t\t\t\t\t\t\t\t\t  WHERE CB.name = ?");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->bind_result($rowName);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['minion'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
            }
        }
        $stmt->close();
        $stmt = $mysqli->prepare("\tSELECT CB.name\n\t\t\t\t\t\t\t\t\t\tFROM mm_creatures CB\n\t\t\t\t\t\t\t\t\t\tINNER JOIN mm_minions M ON CB.id = M.boss_id\n\t\t\t\t\t\t\t\t\t\tWHERE M.minion_id = (SELECT id FROM mm_creatures WHERE name = ?)");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->bind_result($rowName);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['bosses'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
            }
        }
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->requestLists();
コード例 #6
0
<?php

//Add a new relationship between creature and attribute with a given value
class ajaxRequest
{
    function addCreatureAttr()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature = (string) htmlspecialchars($_POST['ca_creature']);
        $attr = (string) htmlspecialchars($_POST['ca_attr']);
        $value = (string) htmlspecialchars($_POST['ca_value']);
        $return = array();
        $return['creature'] = $creature;
        $return['attr'] = $attr;
        $return['value'] = $value;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_c_attr (creature_id, attribute, stat)\n\t\t\t\t\t\t\t\t\t\t  VALUES\n\t\t\t\t\t\t\t\t\t\t\t((SELECT id FROM mm_creatures WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t (SELECT id FROM mm_attributes WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t  ?)\n\t\t\t\t\t\t\t\t\t\t\t  ON DUPLICATE KEY UPDATE stat = ?");
            $stmt->bind_param("ssdd", $creature, $attr, $value, $value);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addCreatureAttr();
コード例 #7
0
<?php

//remove all environment-creature relationships for a given creature
class ajaxRequest
{
    function remCEnvirs()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature_name = (string) htmlspecialchars($_POST['rem_envirs']);
        $return = array();
        $return['name'] = $creature_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_c_environ WHERE creature_id = \n\t\t\t\t\t\t\t\t\t\t(SELECT id FROM mm_creatures WHERE name= ?)");
            $stmt->bind_param("s", $creature_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->remCEnvirs();
コード例 #8
0
<?php

// remove a sense from the database
class ajaxRequest
{
    function delSense()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $name = (string) htmlspecialchars($_POST['del_sense']);
        $return = array();
        $return['name'] = $name;
        $stmt = $mysqli->prepare("DELETE FROM mm_senses WHERE name = ?");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delSense();
コード例 #9
0
// add a relationship between a sense and a creature, with a range
// update range if relationship already exists.
class ajaxRequest
{
    function addCreatureSense()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature = (string) htmlspecialchars($_POST['csen_creature']);
        $sense = (string) htmlspecialchars($_POST['csen_name']);
        $range = (string) htmlspecialchars($_POST['csen_range']);
        $return = array();
        $return['creature'] = $creature;
        $return['sense'] = $sense;
        $return['range'] = $range;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_c_senses (creature_id, sense_id, distance)\n\t\t\t\t\t\t\t\t\t\t  VALUES\n\t\t\t\t\t\t\t\t\t\t\t((SELECT id FROM mm_creatures WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t (SELECT id FROM mm_senses WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t  ?)\n\t\t\t\t\t\t\t\t\t\t\t  ON DUPLICATE KEY UPDATE distance = ?");
            $stmt->bind_param("ssdd", $creature, $sense, $range, $range);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addCreatureSense();
コード例 #10
0
<?php

// add an environment to the database
class ajaxRequest
{
    function addEnviron()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $nameInput = (string) htmlspecialchars($_POST['environName']);
        $return = array();
        $return['name'] = $nameInput;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_environments(name) \n\t\t\t\t\t\t\t\t\t\t\t\t  VALUES (?)");
            $stmt->bind_param("s", $nameInput);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addEnviron();
コード例 #11
0
class ajaxRequest
{
    function getSense()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $sense = (string) htmlspecialchars($_POST['sense']);
        $return = array();
        $return['sense'] = $sense;
        $return['range'] = array();
        $return['name'] = array();
        $stmt = $mysqli->prepare("SELECT C.name, CS.distance FROM mm_creatures C\n\t\t\t\t\t\t\t\t\t  INNER JOIN mm_c_senses CS ON C.id = CS.creature_id\n\t\t\t\t\t\t\t\t\t  INNER JOIN mm_senses S ON CS.sense_id = S.id\n\t\t\t\t\t\t\t\t\t  WHERE S.name = ?\n\t\t\t\t\t\t\t\t\t  ORDER BY CS.distance, C.name");
        $stmt->bind_param("s", $sense);
        $stmt->execute();
        $stmt->bind_result($rowName, $rowRange);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['name'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
                $return['range'][] = $rowRange;
            }
        }
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->getSense();
コード例 #12
0
<?php

//Add a new attribute to the database
class ajaxRequest
{
    function addAttribute()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $nameInput = (string) htmlspecialchars($_POST['attrName']);
        $return = array();
        $return['name'] = $nameInput;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_attributes(name) \n\t\t\t\t\t\t\t\t\t\t\t\t  VALUES (?)");
            $stmt->bind_param("s", $nameInput);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addAttribute();
コード例 #13
0
<?php

// add a skill and its associated attribute to the database
class ajaxRequest
{
    function addSkill()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $nameInput = (string) htmlspecialchars($_POST['skillName']);
        $attrInput = (string) htmlspecialchars($_POST['skillAttr']);
        $return = array();
        $return['attr'] = $attrInput;
        $return['name'] = $nameInput;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_skills(name, attribute) \n\t\t\t\t\t\t\t\t\t\t\t\t  VALUES (?, (SELECT id FROM mm_attributes WHERE name = ?))\n\t\t\t\t\t\t\t\t\t\t\t\t  ON DUPLICATE KEY UPDATE attribute = (SELECT id FROM mm_attributes WHERE name = ?)");
            $stmt->bind_param("sss", $nameInput, $attrInput, $attrInput);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addSkill();
コード例 #14
0
<?php

// add a sense to the database
class ajaxRequest
{
    function addSense()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $nameInput = (string) htmlspecialchars($_POST['senseName']);
        $return = array();
        $return['name'] = $nameInput;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_senses(name) \n\t\t\t\t\t\t\t\t\t\t\t\t  VALUES (?)");
            $stmt->bind_param("s", $nameInput);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addSense();
コード例 #15
0
<?php

// remove all attribute-creature relationships for a given creature
class ajaxRequest
{
    function remCAttrs()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature_name = (string) htmlspecialchars($_POST['rem_attrs']);
        $return = array();
        $return['name'] = $creature_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_c_attr WHERE creature_id = \n\t\t\t\t\t\t\t\t\t\t(SELECT id FROM mm_creatures WHERE name= ?)");
            $stmt->bind_param("s", $creature_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->remCAttrs();
コード例 #16
0
<?php

// remove a type from the table
class ajaxRequest
{
    function delType()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $name = (string) htmlspecialchars($_POST['del_type']);
        $return = array();
        $return['name'] = $name;
        $stmt = $mysqli->prepare("DELETE FROM mm_types WHERE category = ?");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delType();
コード例 #17
0
<?php

// add a relationship between a creature and an environment
class ajaxRequest
{
    function addCreatureEnviron()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature = (string) htmlspecialchars($_POST['ce_creature']);
        $environ = (string) htmlspecialchars($_POST['ce_name']);
        $return = array();
        $return['creature'] = $creature;
        $return['environ'] = $environ;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("INSERT INTO mm_c_environ (creature_id, envir_id)\n\t\t\t\t\t\t\t\t\t\t  VALUES\n\t\t\t\t\t\t\t\t\t\t\t((SELECT id FROM mm_creatures WHERE name= ?),\n\t\t\t\t\t\t\t\t\t\t\t (SELECT id FROM mm_environments WHERE name= ?))");
            $stmt->bind_param("ss", $creature, $environ);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->addCreatureEnviron();
コード例 #18
0
<?php

// remove a skill from the database
class ajaxRequest
{
    function delSkill()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $name = (string) htmlspecialchars($_POST['del_skill']);
        $return = array();
        $return['name'] = $name;
        $stmt = $mysqli->prepare("DELETE FROM mm_skills WHERE name = ?");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delSkill();
コード例 #19
0
<?php

// remove a creature from the database
class ajaxRequest
{
    function delCreature()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature_name = (string) htmlspecialchars($_POST['del_creature']);
        $return = array();
        $return['name'] = $creature_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_creatures WHERE name = ? LIMIT 1");
            $stmt->bind_param("s", $creature_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delCreature();
コード例 #20
0
ファイル: getCR.php プロジェクト: NathanMize/Monster-Database
class ajaxRequest
{
    function getCR()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $minCR = (string) htmlspecialchars($_POST['getCRmin']);
        $maxCR = (string) htmlspecialchars($_POST['getCRmax']);
        $return = array();
        $return['cr'] = array();
        $return['name'] = array();
        $stmt = $mysqli->prepare("SELECT C.name, C.cr FROM mm_creatures C WHERE C.cr >= ? AND C.cr <= ? ORDER BY C.cr, C.name");
        $stmt->bind_param("dd", $minCR, $maxCR);
        $stmt->execute();
        $stmt->bind_result($rowName, $rowCR);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['name'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
                $return['cr'][] = $rowCR;
            }
        }
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->getCR();
コード例 #21
0
    function getAttr()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $attr = (string) htmlspecialchars($_POST['getAttr']);
        $stat = (string) htmlspecialchars($_POST['getStat']);
        $return = array();
        $return['attr'] = $attr;
        $return['value'] = $stat;
        $return['stat'] = array();
        $return['name'] = array();
        $stmt = $mysqli->prepare("SELECT C.name, CA.stat FROM mm_creatures C\n\t\t\t\t\t\t\t\t\t  INNER JOIN mm_c_attr CA ON C.id = CA.creature_id\n\t\t\t\t\t\t\t\t\t  INNER JOIN mm_attributes A ON CA.attribute = A.id\n\t\t\t\t\t\t\t\t\t  WHERE A.name = ? AND CA.stat >= ?\n\t\t\t\t\t\t\t\t\t  ORDER BY CA.stat");
        $stmt->bind_param("sd", $attr, $stat);
        $stmt->execute();
        $stmt->bind_result($rowName, $rowStat);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['name'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
                $return['stat'][] = $rowStat;
            }
        }
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->getAttr();
コード例 #22
0
<?php

// remove an attribute from the table
class ajaxRequest
{
    function delAttr()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $attr_name = (string) htmlspecialchars($_POST['del_attr']);
        $return = array();
        $return['name'] = $attr_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_attributes WHERE name = ? LIMIT 1");
            $stmt->bind_param("s", $attr_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delAttr();
コード例 #23
0
<?php

// remove all minion relationships for a given creature
class ajaxRequest
{
    function remCMinions()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creature_name = (string) htmlspecialchars($_POST['rem_minions']);
        $return = array();
        $return['name'] = $creature_name;
        if (count($_POST) > 0) {
            $stmt = $mysqli->prepare("DELETE FROM mm_minions WHERE boss_id = \n\t\t\t\t\t\t\t\t\t\t(SELECT id FROM mm_creatures WHERE name= ?)");
            $stmt->bind_param("s", $creature_name);
            $stmt->execute();
            $stmt->close();
        }
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->remCMinions();
コード例 #24
0
<?php

// remove an environment from the database
class ajaxRequest
{
    function delEnviron()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $name = (string) htmlspecialchars($_POST['del_envir']);
        $return = array();
        $return['name'] = $name;
        $stmt = $mysqli->prepare("DELETE FROM mm_environments WHERE name = ?");
        $stmt->bind_param("s", $name);
        $stmt->execute();
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->delEnviron();
コード例 #25
0
<?php

class ajaxRequest
{
    function getType()
    {
        require 'Mize_connect.php';
        $mysqli = Mize_server();
        if ($mysqli->connect_errno) {
            echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            exit;
        }
        $creatureType = (string) htmlspecialchars($_POST['creatureType']);
        $return = array();
        $return['creatureType'] = $creatureType;
        $return['name'] = array();
        $stmt = $mysqli->prepare("SELECT C.name FROM mm_creatures C\n\t\t\t\t\t\t\t\t\t  INNER JOIN mm_types T ON C.type_id = T.id\n\t\t\t\t\t\t\t\t\t  WHERE T.category = ?");
        $stmt->bind_param("s", $creatureType);
        $stmt->execute();
        $stmt->bind_result($rowName);
        while ($stmt->fetch()) {
            if (strlen($rowName) > 0) {
                $return['name'][] = "<a href='MonsterDisplay.html?name=" . $rowName . "'>" . $rowName . "</a>";
            }
        }
        $stmt->close();
        return json_encode($return);
    }
}
$ajaxRequest = new ajaxRequest();
echo $ajaxRequest->getType();