Esempio n. 1
0
 protected function get_upload_data($key)
 {
     $md5 = substr($key, 0, 32);
     $id = substr($key, 32);
     if (!isset(self::$upload_cache[$id])) {
         self::$upload_cache[$id] = $this->db->get_full_row('art_upload', $id);
     }
     $data = self::$upload_cache[$id];
     if (empty($data) || $data['md5'] != $md5) {
         throw new ErrorApi('Неверный ключ загрузки', ErrorApi::INCORRECT_INPUT);
     }
     $exist = $this->db->get_field('art', 'id', 'md5 = ?', $md5);
     if ($exist) {
         throw new ErrorApi($exist, ErrorUpload::ALREADY_EXISTS);
     }
     unset($data['id'], $data['date'], $data['name']);
     if (function_exists('puzzle_fill_cvec_from_file') && function_exists('puzzle_compress_cvec')) {
         $imagelink = $this->get_images_path() . 'art' . SL . $md5 . '_largethumb.jpg';
         $vector = puzzle_fill_cvec_from_file($imagelink);
         $vector = base64_encode(puzzle_compress_cvec($vector));
         $data['vector'] = $vector;
     }
     return $data;
 }