/
bear
/
opencorpora
Обзор
Документация
Войти
/
bear
/
opencorpora
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
ajax/own_book.php
23 строки
627 B
Dmitry Granovsky
use wrappers instead of direct reads from and (merge from branch:ensure)
27 дек 2016, 18:50
27 дек 2016, 18:50
b1f4cd2
Код
Авторство
О чём код?
<?php require_once('../lib/header_ajax.php'); try { check_permission(PERM_ADDER); $sid = POST('sid'); $status = POST('status'); if ($status == 0) { $res = sql_pe("SELECT user_id FROM sources WHERE source_id=? LIMIT 1", array($sid)); if ($res[0]['user_id'] != $_SESSION['user_id']) throw new Exception("Book is already owned"); } $user_id = $status > 0 ? $_SESSION['user_id'] : 0; sql_pe("UPDATE sources SET user_id=? WHERE source_id=? LIMIT 1", array($user_id, $sid)); } catch (Exception $e) { $result['error'] = 1; } log_timing(true); die(json_encode($result));