public function voice_plusAction() { if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { error404(); } $model = new ProfileModel(); $data['uid'] = Request::getParam('user')->id; $data['pid'] = post('pid', 'int'); $data['time'] = time(); if ($data['uid'] != $data['pid']) { if (!$model->getRattingHistory($data['uid'], $data['pid'])) { if ($model->countRattingToday($data['uid']) < 5) { $result = $model->insert('rating_history', $data); $uData['rating'] = '++'; $model->update('users', $uData, "`id` = '" . $data['pid'] . "'"); if ($result) { $response['error'] = 0; $response['target_h']['#rating'] = post('rat', 'int') + 1; } else { $response['error'] = 'Error voice!'; } } else { $response['error'] = 'You can vote up to 5 times a day!'; } } else { $response['error'] = 'You have already voted for this profile today!'; } } else { $response['error'] = 'You can not vote for yourself!'; } echo json_encode($response); exit; }