$file = ROOT . DS . 'data' . DS . 'arts.json'; $arts = array('count' => 0, 'arts' => array()); if (file_exists($file)) { $str = file_get_contents($file); $rows = json_decode($str); if ($rows->count > 0) { $arts['count'] = $rows->count; $arts['arts'] = array_reverse($rows->arts); } } echo json_encode($arts); break; case 'prices': $data = file_get_contents('php://input'); $data = json_decode($data, true); $prices = $dg->prices($data); echo json_encode($prices); exit; break; case 'svg': $data = $_POST; $svg = $dg->getSVG($data); echo json_encode($svg); exit; break; case 'addCart': header('Content-Type: text/html; charset=UTF-8'); $data = file_get_contents('php://input'); $data = json_decode($data, true); $content = $dg->addCart($data); echo json_encode($content);