<?php

// deal request for trying to join an activity (ok)
session_start();
$activityid = intval($_POST["activityid"]);
$audienceid = isset($_SESSION["userid"]) ? $_SESSION["userid"] : null;
$response = array();
$response["result"] = false;
if ($activityid > 0 && $audienceid != null) {
    include_once "../model/connect.php";
    include_once "../model/activitymodel.php";
    include_once "../model/audiencemodel.php";
    $conn = getConnection();
    if (getActivityState($conn, $activityid) == 1 && contains($conn, $activityid, $audienceid) == false) {
        $response["result"] = joinActivity($conn, $activityid, $audienceid);
    }
    mysql_close($conn);
}
header("Content-Type:application/json;charset=utf-8");
echo json_encode($response);
Example #2
0
}
$type = $_GET['type'];
if ($type == "list") {
    $page = $_GET['page'];
    getPageN($page, $db);
}
if ($type == "hot") {
    getHot($db);
}
if ($type == "detail") {
    $id = $_GET['id'];
    getActivity($id, $db);
}
if ($type == "join") {
    $id = $_GET['id'];
    joinActivity($id, $db);
}
if ($type == "getjoin") {
    $id = $_GET['id'];
    getJoin($id, $db);
}
function getJoin($acid, $db)
{
    $searchsql = "Select * from user where userid in (Select userid from ActivityParticipation where activityid='{$acid}' order by createTime desc)";
    $result = $db->query($searchsql);
    $joinlist = '[';
    $count = 0;
    while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
        $nickname = $row['nickname'];
        $userid = $row['userid'];
        $joinnode = array("userid" => $userid, "nickname" => $nickname);
<?php

// deal request for creating a new activity (ok)
session_start();
$theme = $_POST["theme"];
$introduction = $_POST["introduction"];
$userid = isset($_SESSION["userid"]) ? $_SESSION["userid"] : null;
$response = array();
$response["result"] = false;
if ($userid != null) {
    include_once "../model/connect.php";
    include_once "../model/activitymodel.php";
    include_once "../model/audiencemodel.php";
    include_once "../model/filter.php";
    $conn = getConnection();
    $theme = themeFilter($theme);
    $introduction = introductionFilter($introduction);
    $activityid = createActivity($conn, $userid, $theme, $introduction);
    if ($activityid != null) {
        joinActivity($conn, $activityid, $userid);
        $response["result"] = true;
        $response["activityid"] = $activityid;
    }
    mysql_close($conn);
}
header("Content-Type:application/json;charset=utf-8");
echo json_encode($response);