2018-09-18 22:16:29 +00:00
|
|
|
<?php
|
2018-10-04 20:30:55 +00:00
|
|
|
require_once '../misuzu.php';
|
2018-09-18 22:16:29 +00:00
|
|
|
|
|
|
|
if (empty($_SERVER['HTTP_REFERER']) || !is_local_url($_SERVER['HTTP_REFERER'])) {
|
|
|
|
header('Location: /');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-02 22:34:05 +00:00
|
|
|
if (!user_session_active()) {
|
2018-09-18 22:16:29 +00:00
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$subjectId = (int)($_GET['u'] ?? 0);
|
|
|
|
|
|
|
|
switch ($_GET['m'] ?? null) {
|
|
|
|
case 'add':
|
|
|
|
switch ($_GET['t'] ?? null) {
|
|
|
|
case 'follow':
|
|
|
|
default:
|
|
|
|
$type = MSZ_USER_RELATION_FOLLOW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-10-02 22:34:05 +00:00
|
|
|
if (user_relation_add(user_session_current('user_id', 0), $subjectId, $type) !== MSZ_USER_RELATION_E_OK) {
|
2018-09-18 22:16:29 +00:00
|
|
|
echo render_error(500);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'remove':
|
2018-10-02 22:34:05 +00:00
|
|
|
if (!user_relation_remove(user_session_current('user_id', 0), $subjectId)) {
|
2018-09-18 22:16:29 +00:00
|
|
|
echo render_error(500);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Location: ' . $_SERVER['HTTP_REFERER']);
|