From: Chuck Scott Date: Wed, 8 Jun 2016 14:51:04 +0000 (-0400) Subject: Fixed bad lat/lon lists and images & files with bad characters. X-Git-Tag: v2.1^2~11 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=6587456ed0f7fb14eb07f6f1abe955776a4a8367;p=WP-Plugins%2Fglm-member-db.git Fixed bad lat/lon lists and images & files with bad characters. --- diff --git a/classes/glmMemberImportFromConnections.php b/classes/glmMemberImportFromConnections.php index 0708fa87..e7c9dd54 100644 --- a/classes/glmMemberImportFromConnections.php +++ b/classes/glmMemberImportFromConnections.php @@ -548,6 +548,7 @@ class GlmMemberImportFromConnections // Get the desired file name and add a timestamp to it to ensure that it's unique $fInfo = pathinfo($image); + $fInfo['filename'] = preg_replace('/([^a-zA-Z0-9-_\.]+)/','_', $fInfo['filename']); $newFilename = $fInfo['filename'].'_'.time().'.'.$fInfo['extension']; // Try to store the image using that file name in the 'original' directory diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index 072aeb40..866b3c1c 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -2437,6 +2437,10 @@ abstract class GlmDataAbstract // Get the desired file name and add a timestamp to it to ensure that it's unique $fInfo = pathinfo($_FILES[$as.'_new']['name']); + + // Strip all but permitted characters from the file name. + $fInfo['filename'] = preg_replace('/([^a-zA-Z0-9-_\.]+)/','_', $fInfo['filename']); + $newFilename = $prefix.strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']); // Get image temp file name - Not currently using, but should be using to check for resizing sanity @@ -2648,6 +2652,11 @@ abstract class GlmDataAbstract // Get the desired file name and add a timestamp to it to ensure that it's unique $fInfo = pathinfo($_FILES[$as.'_new']['name']); + + // Replace all but the permitted characters. + $fInfo['filename'] = preg_replace('/([^a-zA-Z0-9-_\.]+)/','_', $fInfo['filename']); + + $newFilename = $prefix.strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']); // Try to store the file using that file name diff --git a/models/admin/ajax/imageUpload.php b/models/admin/ajax/imageUpload.php index 35c6e251..e0d36f91 100644 --- a/models/admin/ajax/imageUpload.php +++ b/models/admin/ajax/imageUpload.php @@ -172,7 +172,7 @@ class GlmMembersAdmin_ajax_imageUpload extends GlmDataImages public function storeImage ($file, $refType = false, $refTable = false, $refDest = false, $caption = '') { - // If $file is just a URL to an image, the simulate the file array from a form submission + // If $file is just a URL to an image, then simulate the file array from a form submission if (!is_array($file)) { $file = array( 'tmp_name' => $file, @@ -183,6 +183,9 @@ class GlmMembersAdmin_ajax_imageUpload extends GlmDataImages // Get the desired file name and add a timestamp to it to ensure that it's unique $fInfo = pathinfo($file['name']); + // Strip all characters from the file name other than the permitted characters. + $fInfo['filename'] = preg_replace('/([^a-zA-Z0-9-_\.]+)/','_', $fInfo['filename']); + // Build new file name if ($refType != false) { $newFilename = $refTable.'_'.$refDest.'-'.strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']); diff --git a/views/admin/dashboardWidget/index.html b/views/admin/dashboardWidget/index.html index f888b5c9..dea2e322 100644 --- a/views/admin/dashboardWidget/index.html +++ b/views/admin/dashboardWidget/index.html @@ -1,129 +1,128 @@ - {if apply_filters('glm_members_permit_admin_widget_members', true)} {if $membersList} - - - - + }); + + }); + + + + + {/if} +
Number of {$terms.term_member_plur_cap} Listed: List Members{$numbMembers}
- - {$terms.term_member_cap} Search: - -
{/if} -{if apply_filters('glm_members_permit_admin_widget_warnings', true)} - {if !$haveMemberTypes} +{if apply_filters('glm_members_permit_admin_widget_warnings', true)} + {if !$haveMemberTypes || !$haveCategories || !$haveAmenities || !$haveCities || !$haveRegions || $numbMembers == 0} +

Pending {$terms.term_member_cap} Information

+ + {if !$haveMemberTypes} - {/if} - {if !$haveCategories} + {/if} + {if !$haveCategories} - {/if} - {if !$haveAmenities} + {/if} + {if !$haveAmenities} - {/if} - {if !$haveCities} + {/if} + {if !$haveCities} - {/if} - {if !$haveRegions} + {/if} + {if !$haveRegions} - {/if} - {if $numbMembers == 0} + {/if} + {if $numbMembers == 0} - {/if} + {/if} +
No {$terms.term_member_cap} Types Add
No {$terms.term_member_cap} Categories Add
No Amenities Add
No Cities Add
No Regions Add
No {$terms.term_member_plur_cap} Add a {$terms.term_member_cap}
+ {/if} {if $haveBadLatLon} - - -

Records with Bad Map Locations

- - - - {assign var="i" value="0"} - {foreach $badLatLonList as $p} - {if $i++ is odd by 1} - - {else} - - {/if} - - - {/foreach} - -
- {$p.member}: {$p.reference_name} -
- - +

Records with Bad Map Locations

+ + + + {foreach $badLatLonList as $p} + + + + {/foreach} + +
+ {$p.member}: {$p.reference_name} +
{/if} {/if} - {if apply_filters('glm_members_permit_admin_widget_pending_info', true)} {if $membersPending} -

Pending {$terms.term_member_cap} Information

- +
- {assign var="i" value="0"} {foreach $pendingList as $p} - {if $i++ is odd by 1} - {else} - - {/if} - + - {assign var="i" value="0"} {foreach $badLatLonList as $p} - {if $i++ is odd by 1} - {else} - - {/if} - - {/foreach}
{$p.member}: diff --git a/views/admin/members/index.html b/views/admin/members/index.html index 0b8609d8..cb3cf304 100644 --- a/views/admin/members/index.html +++ b/views/admin/members/index.html @@ -66,29 +66,18 @@
{$terms.term_member_cap} NameCreatedReference Name
{$p.member} - {$p.modify_time.datetime} - {$p.reference_name} - {$p.created.date} -