From 6348a323ef9e9632b92137fe3a6fbe8f0a0bada2 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 1 Dec 2016 11:10:05 -0500 Subject: [PATCH] Check for image first only create if image is in array. --- models/admin/management/events.php | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/models/admin/management/events.php b/models/admin/management/events.php index cc23d00..4a2e337 100644 --- a/models/admin/management/events.php +++ b/models/admin/management/events.php @@ -152,22 +152,23 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement $results = $this->wpdb->get_results($sql, ARRAY_A); $fileUrl = 'http://is0.gaslightmedia.com/' . $this->image_owner . '/original/'; $out = '
$results: ' . print_r($results, true) . '
'; - //exit; foreach ( $results as $event ) { - $fileFullUrl = $fileUrl . $event['image']; - $fp = fopen( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 'w+' ); - $ch = curl_init( $fileUrl . $event['file1'] ); - curl_setopt($ch, CURLOPT_TIMEOUT, 50); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - $fileData = curl_exec($ch); - $httpCode = curl_getinfo($ch); - curl_close($ch); - fclose($fp); - // Set correct file permissions - $oldUmask = umask(0); - chmod( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 0660 ); - umask($oldUmask); + if ( $event['image']) { + $fileFullUrl = $fileUrl . $event['image']; + $fp = fopen( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 'w+' ); + $ch = curl_init( $fileUrl . $event['file1'] ); + curl_setopt($ch, CURLOPT_TIMEOUT, 50); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + $fileData = curl_exec($ch); + $httpCode = curl_getinfo($ch); + curl_close($ch); + fclose($fp); + // Set correct file permissions + $oldUmask = umask(0); + chmod( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 0660 ); + umask($oldUmask); + } } return $out; } -- 2.17.1