Version Description
Download this release
Release Info
Developer | qqworld |
Plugin | QQWorld Auto Save Images |
Version | 1.7.12.4 |
Comparing to | |
See all releases |
Code changes from version 1.7.12.3 to 1.7.12.4
- qqworld-auto-save-images.php +41 -4
qqworld-auto-save-images.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: QQWorld Auto Save Images
|
4 |
Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
|
5 |
Description: Automatically keep the all remote picture to the local, and automatically set featured image.
|
6 |
-
Version: 1.7.12.
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
Text Domain: qqworld_auto_save_images
|
@@ -593,7 +593,7 @@ class QQWorld_auto_save_images {
|
|
593 |
<?php submit_button(); ?>
|
594 |
</div>
|
595 |
</form>
|
596 |
-
<form action="options.php" method="post" id="form">
|
597 |
<?php settings_fields('qqworld_auto_save_images_watermark'); ?>
|
598 |
<div class="tab-content hidden">
|
599 |
<div class="readme"><p><strong><?php _e("Just for preview, The complete feature will on the Pro version. Don't worry, other features will be free forever.", 'qqworld_auto_save_images') ?></strong></p></div>
|
@@ -989,7 +989,7 @@ class QQWorld_auto_save_images {
|
|
989 |
if ($width<$this->minimum_picture_size['width'] || $height<$this->minimum_picture_size['height']) $allow = false;
|
990 |
// check if remote image
|
991 |
if ($allow) {
|
992 |
-
$pos=strpos($image_url,get_bloginfo('url'));
|
993 |
if($pos===false){
|
994 |
$this->has_remote_image = 1;
|
995 |
if ($action=="save" && $res=$this->save_images($image_url,$post_id)) {
|
@@ -1154,7 +1154,29 @@ class QQWorld_auto_save_images {
|
|
1154 |
return array($file, $width, $height);
|
1155 |
}
|
1156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
public function download_image($image_url) {
|
|
|
1158 |
if (function_exists('curl_init')) {
|
1159 |
$ch = curl_init();
|
1160 |
$timeout = 5;
|
@@ -1162,7 +1184,22 @@ class QQWorld_auto_save_images {
|
|
1162 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
1163 |
$file = curl_exec($ch);
|
1164 |
curl_close($ch);
|
1165 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1166 |
$file = @file_get_contents($image_url);
|
1167 |
}
|
1168 |
return $file;
|
3 |
Plugin Name: QQWorld Auto Save Images
|
4 |
Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
|
5 |
Description: Automatically keep the all remote picture to the local, and automatically set featured image.
|
6 |
+
Version: 1.7.12.4
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
Text Domain: qqworld_auto_save_images
|
593 |
<?php submit_button(); ?>
|
594 |
</div>
|
595 |
</form>
|
596 |
+
<form action="options.php" method="post" id="watermark-form">
|
597 |
<?php settings_fields('qqworld_auto_save_images_watermark'); ?>
|
598 |
<div class="tab-content hidden">
|
599 |
<div class="readme"><p><strong><?php _e("Just for preview, The complete feature will on the Pro version. Don't worry, other features will be free forever.", 'qqworld_auto_save_images') ?></strong></p></div>
|
989 |
if ($width<$this->minimum_picture_size['width'] || $height<$this->minimum_picture_size['height']) $allow = false;
|
990 |
// check if remote image
|
991 |
if ($allow) {
|
992 |
+
$pos = strpos($image_url, get_bloginfo('url'));
|
993 |
if($pos===false){
|
994 |
$this->has_remote_image = 1;
|
995 |
if ($action=="save" && $res=$this->save_images($image_url,$post_id)) {
|
1154 |
return array($file, $width, $height);
|
1155 |
}
|
1156 |
|
1157 |
+
function fsockopen_image_header($image_url, $mode='Content-Type') { // 'Content-Length' | 'Content-Type' | 'Date' | 'Last-Modified'
|
1158 |
+
$url = parse_url($image_url);
|
1159 |
+
$fp = fsockopen($url['host'], 80, $errno, $errstr, 30);
|
1160 |
+
if ($fp) {
|
1161 |
+
//������������ΪHEAD
|
1162 |
+
$out = "HEAD {$url['path']} HTTP/1.1\r\n";
|
1163 |
+
$out .= "Host: {$url['host']}\r\n";
|
1164 |
+
$out .= "Connection: Close\r\n\r\n";
|
1165 |
+
fwrite($fp, $out);
|
1166 |
+
while (!feof($fp)) {
|
1167 |
+
$header = fgets($fp);
|
1168 |
+
if (stripos($header, $mode) !== false) {
|
1169 |
+
$value = trim(substr($header, strpos($header, ':') + 1));
|
1170 |
+
return $value;
|
1171 |
+
}
|
1172 |
+
}
|
1173 |
+
fclose($fp);
|
1174 |
+
}
|
1175 |
+
return null;
|
1176 |
+
}
|
1177 |
+
|
1178 |
public function download_image($image_url) {
|
1179 |
+
// curl
|
1180 |
if (function_exists('curl_init')) {
|
1181 |
$ch = curl_init();
|
1182 |
$timeout = 5;
|
1184 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
1185 |
$file = curl_exec($ch);
|
1186 |
curl_close($ch);
|
1187 |
+
}
|
1188 |
+
// GD
|
1189 |
+
if (!$file && function_exists('fsockopen')) {
|
1190 |
+
$type = $this->fsockopen_image_header($image_url);
|
1191 |
+
if ($type && in_array($type, array('image/jpeg', 'image/gif', 'image/png'))) {
|
1192 |
+
$type = substr($type, 6);
|
1193 |
+
$img = call_user_func("imagecreatefrom{$type}", $image_url);
|
1194 |
+
ob_start();
|
1195 |
+
call_user_func("image{$type}", $img);
|
1196 |
+
$file = ob_get_contents();
|
1197 |
+
ob_end_clean();
|
1198 |
+
imagedestroy($img);
|
1199 |
+
} else $file = '';
|
1200 |
+
}
|
1201 |
+
// file_get_contents
|
1202 |
+
if (!$file && function_exists('file_get_contents')) {
|
1203 |
$file = @file_get_contents($image_url);
|
1204 |
}
|
1205 |
return $file;
|