log_('LIMIT REACHED[BYTES]:' . $limit['uploaded_bytes'] . ' FROM ' . $day_limit_bytes); exit(0); } else { log_('LIMIT [BYTES]:' . $limit['uploaded_bytes'] . ' FROM ' . $day_limit_bytes); } if ($limit['uploaded_count'] > $day_limit_count) { log_('LIMIT REACHED[COUNT]:' . $limit['uploaded_count'] . ' FROM ' . $day_limit_count); exit(0); } else { log_('LIMIT [COUNT]:' . $limit['uploaded_count'] . ' FROM ' . $day_limit_count); } $real_path = ImgStore::getFileLocalPath($image['image_id'], $image['size_id']); log_($real_path . ' ' . floor($image['bytes'] / 1024 / 1024 * 1000) / 1000 . 'Mb'); $target_path = str_replace(ImgStore::$server_urls[ImgStore::SERVER_ORIG], '', ImgStore::getUrl($image['image_id'], $image['size_id'], 0)); log_('saving to ' . $target_path); $result = Amazon::store($real_path, $target_path); if ($result) { $limit['uploaded_count']++; $limit['uploaded_bytes'] += $image['bytes']; log_('Stored at amazon at ' . ImgStore::$server_urls[ImgStore::SERVER_AMAZONS3] . $target_path); Database::query('UPDATE `images` SET `server_id`=' . ImgStore::SERVER_AMAZONS3 . ', `amazon_stored_time`=' . time() . ' WHERE `id`=' . $image['id']); } else { log_('Cant store file to amazon'); Database::query('UPDATE `images` SET `amazon_stored_time`=' . time() . ' WHERE `id`=' . $image['id']); } Database::query('REPLACE INTO `amazon_limit` SET `day`=' . $day . ', `uploaded_bytes`=' . $limit['uploaded_bytes'] . ',`uploaded_count`=' . $limit['uploaded_count']); } log_('+'); }