{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
function create_guid()
{
    $charid = strtoupper(md5(uniqid(mt_rand(), true)));
    $hyphen = chr(45);
    // "-"
    $uuid = substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4);
    return $uuid;
}
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $comment = new ManagerComment();
    $kind = test_input($_GET["kind"]);
    // $helpcommentid=create_guid();
    // $helpcommentid="061C0B9A01C488EB69AE";
    // $kind = 'update';
    // $nickname = 'wmy';
    // $userid= '1D9C9163EA8B2D830267';
    // $content = '帮助他人';
    // // $helpcommentid = test_input($_GET["helpcommentid"]);
    // $hasimage = 0;
    // $hasvideo=0;
    // $state='2';
    // $helpid = 'A4098751E2D534584FA5';
    // $useful='无用';
    // $bonus=0;
    // $useraction="乐山豪奢";
    public function Insert_helps($helpid, $userid, $nickname, $helptype, $contenttype, $content, $title, $hasimage, $hasvideo, $city, $location, $locationy, $bonus, $contenttype, $tag, $createtime, $refreshtime, $state)
    {
        $datetime = date('Y-m-d H:i:s', time());
        $file = 'F:\\wampserver\\setup\\wamp\\www\\manager_comment.txt';
        $content = "\n测试事务\n";
        file_put_contents($file, $content, FILE_APPEND);
        $this->sql = "INSERT INTO helps (helpid, userid,nickname,helptype, contenttype,title,content,hasimage,hasvideo,city,location,locationx,locationy,bonus, tag,createtime, refreshtime,state)\n           VALUES ('{$helpid}','{$userid}','{$nickname}', '{$helptype}','{$contenttype}','{$content}','{$title}','{$hasimage}','{$hasvideo}','{$city}','{$location}','{$locationy}', '{$bonus}','{$contenttype}','{$tag}','{$createtime}','{$refreshtime}','{$state}')";
        if ($this->conn->query($this->sql) && $this->conn->query($this->sql2)) {
            $comm = new Comment();
            $comm->name = $username;
            $comm->date = $datetime;
            $comm->text = $content;
            $comm->kind = "OK";
            $comm->id = $eventcommentid;
            $json = json_encode($comm);
            echo "{$json}";
        } else {
            $comm = new Comment();
            $comm->name = $username;
            $comm->date = date('Y-m-d H:i:s', time());
            $comm->text = $content;
            $comm->kind = "failed";
            $comm->video = $hasvideo;
            $json = json_encode($comm);
            echo "{$json}";
        }
        $this->conn->close();
    }
}
$comment = new ManagerComment();
$comment->Query_helps();
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
function create_guid()
{
    $charid = strtoupper(md5(uniqid(mt_rand(), true)));
    $hyphen = chr(45);
    // "-"
    $uuid = substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4);
    return $uuid;
}
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $comment = new ManagerComment();
    $kind = test_input($_GET["kind"]);
    switch ($kind) {
        case "userid":
            $page = test_input($_GET["page"]);
            $userid = test_input($_GET["userid"]);
            $comment->querycommentByuserid($userid, $page);
            break;
        case "eventid":
            $eventid = test_input($_GET["eventid"]);
            // $eventid="2D9C9163EA8B2D830267";
            $page = test_input($_GET["page"]);
            $file = 'F:\\wampserver\\setup\\wamp\\www\\manager_eventcomment.txt';
            $content = "eventid:" . $eventid . "**page" . " {$page}";
            file_put_contents($file, $content, FILE_APPEND);
            $comment->querycommentByeventid($eventid, $page);