SHOW:
|
|
- or go back to the newest paste.
1 | //Оприделение изображения к ссылке | |
2 | if(stripos($attach_files, 'link|') !== false){ | |
3 | $attach_arr = explode('||', $attach_files); | |
4 | $cnt_attach_link = 1; | |
5 | foreach($attach_arr as $attach_file){ | |
6 | $attach_type = explode('|', $attach_file); | |
7 | if($attach_type[0] == 'link' AND preg_match('/http:\/\/(.*?)+$/i', $attach_type[1]) AND $cnt_attach_link == 1){ | |
8 | $domain_url_name = explode('/', $attach_type[1]); | |
9 | $rdomain_url_name = str_replace('http://', '', $domain_url_name[2]); | |
10 | $rImgUrl = $attach_type[4]; | |
11 | $rImgUrl = str_replace("\\", "/", $rImgUrl); | |
12 | $img_name_arr = explode(".", $rImgUrl); | |
13 | $img_format = totranslit(end($img_name_arr)); | |
14 | $image_name = substr(md5($server_time.md5($rImgUrl)), 0, 15); | |
15 | ||
16 | //Разришенные форматы | |
17 | $allowed_files = array('jpg', 'jpeg', 'jpe', 'png'); | |
18 | ||
19 | //Загружаем картинку на сайт | |
20 | if(in_array(strtolower($img_format), $allowed_files) AND preg_match("/http:\/\/(.*?)(.jpg|.png|.jpeg|.jpe)/i", $rImgUrl)){ | |
21 | ||
22 | //Директория загрузки фото | |
23 | $upload_dir = ROOT_DIR.'/uploads/attach/'.$user_id; | |
24 | ||
25 | //Если нет папки юзера, то создаём её | |
26 | if(!is_dir($upload_dir)){ | |
27 | @mkdir($upload_dir, 0777); | |
28 | @chmod($upload_dir, 0777); | |
29 | } | |
30 | ||
31 | //Подключаем класс для фотографий | |
32 | include ENGINE_DIR.'/classes/images.php'; | |
33 | ||
34 | if(@copy($rImgUrl, $upload_dir.'/'.$image_name.'.'.$img_format)){ | |
35 | $tmb = new thumbnail($upload_dir.'/'.$image_name.'.'.$img_format); | |
36 | $tmb->size_auto('100x80'); | |
37 | $tmb->jpeg_quality(100); | |
38 | $tmb->save($upload_dir.'/'.$image_name.'.'.$img_format); | |
39 | ||
40 | $attach_files = str_replace($attach_type[4], '/uploads/attach/'.$user_id.'/'.$image_name.'.'.$img_format, $attach_files); | |
41 | } | |
42 | } | |
43 | $cnt_attach_link++; | |
44 | } | |
45 | } | |
46 | } | |
47 | ||
48 | $attach_files = str_replace('vote|', 'hack|', $attach_files); | |
49 | $attach_files = str_replace(array('|', '»', '"'), array('|', '»', '"'), $attach_files); |