File indexing completed on 2024-12-22 05:33:07
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 header("HTTP/1.1 503 Service Unavailable"); 0024 exit(1); 0025 0026 function getimg($url) 0027 { 0028 #$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; 0029 $headers[] = 'Connection: Keep-Alive'; 0030 $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 0031 $user_agent = 'php'; 0032 $process = curl_init($url); 0033 curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 0034 curl_setopt($process, CURLOPT_HEADER, 0); 0035 curl_setopt($process, CURLOPT_USERAGENT, $user_agent); 0036 curl_setopt($process, CURLOPT_TIMEOUT, 30); 0037 curl_setopt($process, CURLOPT_USERPWD, "ubuntu:ubuntu."); 0038 curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 0039 curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); 0040 $return = curl_exec($process); 0041 curl_close($process); 0042 return $return; 0043 } 0044 0045 $imgurl = $_GET['path']; 0046 $imagename = basename($imgurl); 0047 0048 if (!$imgurl || !$imagename) { 0049 print "Error"; 0050 return; 0051 } 0052 0053 0054 if (file_exists('./img/' . $imagename)) { 0055 print "<img src='/cache/800x600-2/img/" . $imagename . "'>"; 0056 return; 0057 } 0058 $image = getimg($imgurl); 0059 file_put_contents('img/' . $imagename, $image); 0060 0061 if (file_exists('./img/' . $imagename)) { 0062 print "<img src='/cache/800x600-2/img/" . $imagename . "'>"; 0063 } else { 0064 print "Error"; 0065 }