[geeklog-hg] geeklog: Better checking to see if OAuth Profile Image resized c...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat Dec 28 10:47:13 EST 2013
changeset 9354:df039288703d
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/df039288703d
user: Tom <websitemaster at cogeco.net>
date: Sat Dec 28 10:45:39 2013 -0500
description:
Better checking to see if OAuth Profile Image resized correctly and passes file size requirements. If not now image is deleted.
diffstat:
system/classes/oauthhelper.class.php | 40 ++++++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 8 deletions(-)
diffs (82 lines):
diff -r 0e9d81e16ab5 -r df039288703d system/classes/oauthhelper.class.php
--- a/system/classes/oauthhelper.class.php Thu Dec 26 15:46:40 2013 -0500
+++ b/system/classes/oauthhelper.class.php Sat Dec 28 10:45:39 2013 -0500
@@ -376,6 +376,8 @@
protected function _DBupdate_users($uid, $users) {
global $_TABLES, $_CONF;
+
+ $photo = '';
$sql = "UPDATE {$_TABLES['users']} SET remoteusername = '".DB_escapeString($users['remoteusername'])."', remoteservice = '".DB_escapeString($users['remoteservice'])."', status = 3 ";
if (!empty($users['remotephoto'])) {
@@ -389,10 +391,20 @@
}
rename($save_img, $image);
- $this->_handleImageResize($_CONF['path_images'] . 'userphotos/' . $uid . $ext);
+ $photo = $uid . $ext;
+ $img_path = $this->_handleImageResize($_CONF['path_images'] . 'userphotos/' . $photo);
- $imgname = $uid . $ext;
- $sql .= ", photo = '".DB_escapeString($imgname)."'";
+ // If nothing returned then image resize did not go right
+ if (!empty($img_path)) {
+ if (!file_exists($img_path)) {
+ $photo = '';
+ }
+ } else {
+ USER_deletePhoto($photo, false);
+ $photo = '';
+ }
+
+ $sql .= ", photo = '".DB_escapeString($photo)."'"; // update photo even if blank just incase OAuth profile picture has been removed
}
}
$sql .= " WHERE uid = ".(int) $uid;
@@ -400,6 +412,7 @@
}
protected function _saveUserPhoto($from, $to) {
+ // Use Pear HTTP Request 2 since first Facebook url to profile picture redirects to a new location
$ret = '';
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2($from, HTTP_Request2::METHOD_GET);
@@ -480,7 +493,7 @@
) );
// Set new path and image name
if (!$upload->setPath ($_CONF['path_images'] . 'userphotos')) {
- exit; // don't return
+ return;
}
// Current path of image to resize
@@ -508,13 +521,24 @@
// do the upload
if (!empty($filename)) {
$upload->setFileNames($filename);
- $upload->setPerms('0644');
- $upload->setMaxDimensions($_CONF['max_photo_width'], $_CONF['max_photo_height']);
- $upload->setMaxFileSize($_CONF['max_photo_size']);
+ $upload->setPerms ('0644');
+ if (($_CONF['max_photo_width'] > 0) &&
+ ($_CONF['max_photo_height'] > 0)) {
+ $upload->setMaxDimensions ($_CONF['max_photo_width'],
+ $_CONF['max_photo_height']);
+ } else {
+ $upload->setMaxDimensions ($_CONF['max_image_width'],
+ $_CONF['max_image_height']);
+ }
+ if ($_CONF['max_photo_size'] > 0) {
+ $upload->setMaxFileSize($_CONF['max_photo_size']);
+ } else {
+ $upload->setMaxFileSize($_CONF['max_image_size']);
+ }
$upload->uploadFiles();
if ($upload->areErrors()) {
- exit; // don't return
+ return;
}
}
More information about the geeklog-cvs
mailing list