Exemple #1
0
if (isset($_POST['num'])) {
    $maps = $mapLoad->getMapFeedCapture($_SESSION['user_id'], $_POST['num']);
} else {
    $maps = $mapLoad->getMapFeedCapture($_SESSION['user_id']);
}
$map_list[] = null;
// 결과 담을 변수
foreach ($maps as $map) {
    $user_info = $auth->user_info($map['user_id']);
    // 각 맵의 사용자 정보 가져옴
    $tag = $hash_tag->get_tag_id_by_map($map['map_id']);
    // 태그 정보
    foreach ($tag as $tag_id) {
        $tag_name .= "#" . $hash_tag->get_tag_name($tag_id) . " ";
        // 태그 네임 저장
    }
    if ($Img_ctl->is_map_liker($map['map_id'], $_SESSION['user_id'])) {
        $is_like = 'true';
    } else {
        $is_like = 'false';
    }
    array_push($map_list, $map + array('is_like' => $is_like, 'nickname' => $user_info['nickname'], 'tag_name' => $tag_name));
    // tag 이름 가져옴
    $tag_name = null;
}
$mapArray[] = null;
for ($i = 0; $i < count($maps); $i++) {
    $mapArray['mapInfo' . $i] = $map_list[$i + 1];
    // 각 맵정보를 배열에 담음
}
echo urldecode(json_encode($mapArray));
Exemple #2
0
<?php

include '../Class/Img_ctl.php';
session_start();
if ($_SESSION['is_login'] === true) {
    $img_ctl = new Img_ctl();
    // 좋아요가 안되있을 경우
    if ($img_ctl->is_map_liker($_POST['map_id'], $_SESSION['user_id']) === false) {
        $liker = $img_ctl->map_like($_POST['map_id'], $_SESSION['user_id']);
        if (is_int($liker)) {
            $result = array('result' => 'true', 'liker' => $liker, 'is_like' => 'true');
        } else {
            $result = array('result' => 'false', 'msg' => '좋아요 실패');
        }
        // 좋아요가 되어있을 경우
    } else {
        $liker = $img_ctl->map_dislike($_POST['map_id'], $_SESSION['user_id']);
        if (is_int($liker)) {
            $result = array('result' => 'true', 'liker' => $liker, 'is_like' => 'false');
        } else {
            $result = array('result' => 'false', 'msg' => '좋아요 취소 실패');
        }
    }
} else {
    $result = array('result' => 'false', 'msg' => '로그인이 필요합니다.');
}
echo urldecode(json_encode($result));