Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Оприделение изображения к ссылке
- if(stripos($attach_files, 'link|') !== false){
- $attach_arr = explode('||', $attach_files);
- $cnt_attach_link = 1;
- foreach($attach_arr as $attach_file){
- $attach_type = explode('|', $attach_file);
- if($attach_type[0] == 'link' AND preg_match('/http:\/\/(.*?)+$/i', $attach_type[1]) AND $cnt_attach_link == 1){
- $domain_url_name = explode('/', $attach_type[1]);
- $rdomain_url_name = str_replace('http://', '', $domain_url_name[2]);
- $rImgUrl = $attach_type[4];
- $rImgUrl = str_replace("\\", "/", $rImgUrl);
- $img_name_arr = explode(".", $rImgUrl);
- $img_format = totranslit(end($img_name_arr));
- $image_name = substr(md5($server_time.md5($rImgUrl)), 0, 15);
- //Разришенные форматы
- $allowed_files = array('jpg', 'jpeg', 'jpe', 'png');
- //Загружаем картинку на сайт
- if(in_array(strtolower($img_format), $allowed_files) AND preg_match("/http:\/\/(.*?)(.jpg|.png|.jpeg|.jpe)/i", $rImgUrl)){
- //Директория загрузки фото
- $upload_dir = ROOT_DIR.'/uploads/attach/'.$user_id;
- //Если нет папки юзера, то создаём её
- if(!is_dir($upload_dir)){
- @mkdir($upload_dir, 0777);
- @chmod($upload_dir, 0777);
- }
- //Подключаем класс для фотографий
- include ENGINE_DIR.'/classes/images.php';
- if(@copy($rImgUrl, $upload_dir.'/'.$image_name.'.'.$img_format)){
- $tmb = new thumbnail($upload_dir.'/'.$image_name.'.'.$img_format);
- $tmb->size_auto('100x80');
- $tmb->jpeg_quality(100);
- $tmb->save($upload_dir.'/'.$image_name.'.'.$img_format);
- $attach_files = str_replace($attach_type[4], '/uploads/attach/'.$user_id.'/'.$image_name.'.'.$img_format, $attach_files);
- }
- }
- $cnt_attach_link++;
- }
- }
- }
- $attach_files = str_replace('vote|', 'hack|', $attach_files);
- $attach_files = str_replace(array('|', '»', '"'), array('|', '»', '"'), $attach_files);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement