Version Description
- Fixed: Viewer not hidden if linked file not found
- Fixed: Divide by zero error if file size can't be determined
- Fixed: PHP error if file not found (force download link)
- Fixed: File not found falsely reported on some web servers
Download this release
Release Info
Developer | k3davis |
Plugin | Google Doc Embedder |
Version | 1.5.1 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.5.1
- functions.php +12 -8
- gviewer.php +3 -3
- pdf.php +1 -3
- readme.txt +9 -3
functions.php
CHANGED
@@ -51,8 +51,8 @@ function validUrl($url) {
|
|
51 |
$data = curl_exec($handle);
|
52 |
curl_close($handle);
|
53 |
|
54 |
-
$contentLength =
|
55 |
-
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
|
56 |
$contentLength = (int)$matches[1];
|
57 |
}
|
58 |
return $contentLength;
|
@@ -73,15 +73,19 @@ function splitFilename($filename) {
|
|
73 |
}
|
74 |
|
75 |
function formatBytes($bytes, $precision = 2) {
|
76 |
-
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
|
|
85 |
}
|
86 |
|
87 |
function sanitizeOpt($value) {
|
51 |
$data = curl_exec($handle);
|
52 |
curl_close($handle);
|
53 |
|
54 |
+
$contentLength = 0;
|
55 |
+
if (preg_match('/Content-Length: (\d+)/i', $data, $matches)) {
|
56 |
$contentLength = (int)$matches[1];
|
57 |
}
|
58 |
return $contentLength;
|
73 |
}
|
74 |
|
75 |
function formatBytes($bytes, $precision = 2) {
|
76 |
+
if ($bytes < 1) {
|
77 |
+
return "Unknown";
|
78 |
+
} else {
|
79 |
+
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
80 |
|
81 |
+
$bytes = max($bytes, 0);
|
82 |
+
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
83 |
+
$pow = min($pow, count($units) - 1);
|
84 |
|
85 |
+
$bytes /= pow(1024, $pow);
|
86 |
|
87 |
+
return round($bytes, $precision) . '' . $units[$pow];
|
88 |
+
}
|
89 |
}
|
90 |
|
91 |
function sanitizeOpt($value) {
|
gviewer.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
/*
|
4 |
Plugin Name: Google Doc Embedder
|
5 |
-
Plugin URI: http://
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
-
Version: 1.5
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2009 Kevin Davis. E-mail: kev@tnw.org
|
@@ -83,7 +83,7 @@ HERE;
|
|
83 |
$dlFile = $file;
|
84 |
$target = "_blank";
|
85 |
}
|
86 |
-
$linkcode = "<p class=\"gde-
|
87 |
|
88 |
if (get_option('gde_link_pos') == "above") {
|
89 |
$code = $linkcode . '' . $code;
|
2 |
|
3 |
/*
|
4 |
Plugin Name: Google Doc Embedder
|
5 |
+
Plugin URI: http://davismetro.com/gde/
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
+
Version: 1.5.1
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2009 Kevin Davis. E-mail: kev@tnw.org
|
83 |
$dlFile = $file;
|
84 |
$target = "_blank";
|
85 |
}
|
86 |
+
$linkcode = "<p class=\"gde-text\"><a href=\"$dlFile\" target=\"$target\" class=\"gde-link\">$txt</a></p>";
|
87 |
|
88 |
if (get_option('gde_link_pos') == "above") {
|
89 |
$code = $linkcode . '' . $code;
|
pdf.php
CHANGED
@@ -20,12 +20,10 @@ if (!$file) {
|
|
20 |
}
|
21 |
|
22 |
$file = "http://".$file;
|
23 |
-
$handle = fopen("$file", "rb");
|
24 |
|
25 |
-
if (!$handle) {
|
26 |
# file doesn't exist
|
27 |
echo "<html>Nonexistant filename, action cancelled.</html>\n";
|
28 |
-
fclose($handle);
|
29 |
exit;
|
30 |
}
|
31 |
|
20 |
}
|
21 |
|
22 |
$file = "http://".$file;
|
|
|
23 |
|
24 |
+
if (!$handle = fopen("$file", "rb")) {
|
25 |
# file doesn't exist
|
26 |
echo "<html>Nonexistant filename, action cancelled.</html>\n";
|
|
|
27 |
exit;
|
28 |
}
|
29 |
|
readme.txt
CHANGED
@@ -29,7 +29,7 @@ Go to "GDE Settings" (under "Settings" in the admin panel) to change defaults, o
|
|
29 |
== Frequently Asked Questions ==
|
30 |
|
31 |
= What file types can be embedded? =
|
32 |
-
This plug-in can embed PDF or PPT files only. The file to embed must first be available somewhere on the internet. You can upload it to your WordPress site using the standard techniques, or link to a file on another site. **You do not need to save the file in Google Documents first to embed it.**
|
33 |
|
34 |
= How do I embed a file in my page or post? =
|
35 |
Use the custom shortcode `[gview]` to embed the file, as shown:
|
@@ -44,7 +44,7 @@ Optional attributes:
|
|
44 |
* `height=` : To override the default height of the viewer, enter a new height value (number in pixels)
|
45 |
|
46 |
= Nothing is showing up! What do I do? =
|
47 |
-
View the source on the web page where you've embedded the viewer. In order to degrade gracefully in case an error occurs, error messages will be inserted as HTML comments in these pages at the spot the viewer is called
|
48 |
|
49 |
= I wish the plug-in had feature XYZ... =
|
50 |
That's not a question ;) but if you have any particular ideas on further development of this plug-in, please <a href="http://wordpress.org/tags/google-document-embedder?forum_id=10#postform">post a message</a> and I'll see what I can do.
|
@@ -56,6 +56,12 @@ That's not a question ;) but if you have any particular ideas on further develop
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
= 1.5 =
|
60 |
* Improved error checking.
|
61 |
* Improved customization options for download text.
|
@@ -63,7 +69,7 @@ That's not a question ;) but if you have any particular ideas on further develop
|
|
63 |
* Added option to reset options to defaults.
|
64 |
|
65 |
= 1.0.3 =
|
66 |
-
* Installation bug fix.
|
67 |
|
68 |
= 1.0 =
|
69 |
* Added options page.
|
29 |
== Frequently Asked Questions ==
|
30 |
|
31 |
= What file types can be embedded? =
|
32 |
+
This plug-in can embed PDF or PPT files only. The file to embed must first be available somewhere on the internet. You can upload it to your WordPress site using the standard techniques, or link to a file on another site. **You do not need to save the file in Google Documents first to embed it, and in fact you should NOT do so, unless the file is shared publicly (can be accessed without logging in).**
|
33 |
|
34 |
= How do I embed a file in my page or post? =
|
35 |
Use the custom shortcode `[gview]` to embed the file, as shown:
|
44 |
* `height=` : To override the default height of the viewer, enter a new height value (number in pixels)
|
45 |
|
46 |
= Nothing is showing up! What do I do? =
|
47 |
+
View the source on the web page where you've embedded the viewer. In order to degrade gracefully in case an error occurs, error messages will be inserted as HTML comments in these pages at the spot the viewer is called.
|
48 |
|
49 |
= I wish the plug-in had feature XYZ... =
|
50 |
That's not a question ;) but if you have any particular ideas on further development of this plug-in, please <a href="http://wordpress.org/tags/google-document-embedder?forum_id=10#postform">post a message</a> and I'll see what I can do.
|
56 |
|
57 |
== Changelog ==
|
58 |
|
59 |
+
= 1.5.1 =
|
60 |
+
* Fixed: Viewer not hidden if linked file not found
|
61 |
+
* Fixed: Divide by zero error if file size can't be determined
|
62 |
+
* Fixed: PHP error if file not found (force download link)
|
63 |
+
* Fixed: File not found falsely reported on some web servers
|
64 |
+
|
65 |
= 1.5 =
|
66 |
* Improved error checking.
|
67 |
* Improved customization options for download text.
|
69 |
* Added option to reset options to defaults.
|
70 |
|
71 |
= 1.0.3 =
|
72 |
+
* Installation bug fix. If you installed 1.0, please completely delete and reinstall plugin. Sorry :(
|
73 |
|
74 |
= 1.0 =
|
75 |
* Added options page.
|