Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make camera finder work properly for makes/models with spaces; update…

… everything else accordingly
  • Loading branch information...
commit 103a7c165ad9a17e97c7dcd96293668ae758c038 1 parent c0e5ba3
straup authored
View
7 www/.htaccess
@@ -89,9 +89,10 @@ RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/places/(\d+)(/page([0-9]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/?$ /flickr_photos_user_cameras.php?path=$2&nsid=$3&%{QUERY_STRING} [L]
-# TO DO: make this better (whitespace, etc.)
-RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_]+)(/page([0-9]+))?/?$ /flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&page=$6&%{QUERY_STRING} [L]
-RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_]+)(/([^/]+))?(/page([0-9]+))?/?$ /flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&model=$6&page=$8&%{QUERY_STRING} [L]
+RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_\s\+]+)(/page([0-9]+))?/?$ /flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&page=$6&%{QUERY_STRING} [L]
+
+RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_\s\+]+)/([0-9a-zA-z-_\s\+]+)(/page([0-9]+))?/?$ /flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&model=$5&page=$7&%{QUERY_STRING} [L]
+
# timecapsule
# TO DO: finish
View
7 www/include/lib_exif_tools.php
@@ -2,6 +2,13 @@
#################################################################
+ function exif_tools_scrub_string($str){
+
+ return sanitize(trim($str), 'str');
+ }
+
+ #################################################################
+
function exif_tools_rational2float($value){
$parts = explode('/', $value);
View
2  www/include/lib_flickr_photos_exif.php
@@ -63,7 +63,7 @@ function flickr_photos_exif_read(&$photo){
foreach ($to_simplejoin as $tag){
- if (isset($exif[$tag])){
+ if (is_array($exif[$tag])){
$exif[$tag] = implode(",", $exif[$tag]);
}
}
View
20 www/include/lib_flickr_photos_search.php
@@ -66,7 +66,9 @@ function flickr_photos_search(&$query, $more=array()){
foreach ($rsp['rows'] as $row){
$photo = flickr_photos_get_by_id($row['photo_id']);
- $photo['can_view_geo'] = ($photo['hasgeo'] && flickr_geo_permissions_can_view_photo($photo, $more['viewer_id'])) ? 1 : 0;
+ $can_view_geo = ($photo['hasgeo'] && flickr_geo_permissions_can_view_photo($photo, $more['viewer_id'])) ? 1 : 0;
+
+ $photo['can_view_geo'] = $can_view_geo;
$photos[] = $photo;
}
@@ -189,14 +191,20 @@ function flickr_photos_search_index_photo(&$photo){
$exif = $rsp['rows'];
- # TO DO: normalize (and probably sanitize)
+ if (isset($exif['Make'])){
- if (isset($exif['Model'])){
- $doc['camera_model'] = trim($exif['Model']);
+ if ($make = exif_tools_scrub_string($exif['Make'])){
+
+ $doc['camera_make'] = ucwords($make);
+ }
}
- if (isset($exif['Make'])){
- $doc['camera_make'] = trim($exif['Make']);
+ if (isset($exif['Model'])){
+
+ if ($model = exif_tools_scrub_string($exif['Model'])){
+
+ $doc['camera_model'] = $model;
+ }
}
# EXIF: what else?
View
16 www/include/lib_solr_utils.php
@@ -10,9 +10,7 @@ function solr_utils_hash2query(&$hash, $join=null){
$k = urlencode($k);
- # allow foo:[* TO *] queries
-
- $v = (preg_match("/^raw:(.*)$/", $v, $m)) ? $m[1] : urlencode($v);
+ $v = (preg_match("/^raw:(.*)$/", $v, $m)) ? $m[1] : solr_utils_escape($v);
$q[] = "{$k}:{$v}";
}
@@ -25,4 +23,16 @@ function solr_utils_hash2query(&$hash, $join=null){
}
#################################################################
+
+ # http://e-mats.org/2010/01/escaping-characters-in-a-solr-query-solr-url/
+
+ function solr_utils_escape($string){
+
+ $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
+ $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
+ $string = str_replace($match, $replace, $string);
+ return $string;
+ }
+
+ #################################################################
?>
View
1  www/templates/inc_flickr_photo_map.txt
@@ -1,6 +1,7 @@
{if $cfg.enable_feature_slippymaps}
{if $photo.hasgeo and $photo.can_view_geo}
+
<div class="photo_map">
<div class="map" data-provider="{$cfg.slippymap_provider|escape}" data-center="{$photo.latitude|escape},{$photo.longitude|escape}" data-zoom="{$photo.accuracy-2|escape}" data-interactive="false" id="map_{$photo.id|escape}">
<div class="marker" data-location="{$photo.latitude|escape},{$photo.longitude|escape}"><span class="marker_text">{$photo.latitude|string_format:"%.3f"|escape},{$photo.longitude|string_format:"%.3f"|escape}</span></div>
View
2  www/templates/page_flickr_photos_user_camera.txt
@@ -33,7 +33,7 @@ You've taken one photo with a {$camera_make|escape}{if $camera_model} {$camera_m
</div>
<div class="photo_sidebar" style="margin-top:0px;">
-{include file="inc_flickr_photo_map.txt"}
+{include file="inc_flickr_photo_map.txt" photo=$row}
</div>
<br clear="all" />
Please sign in to comment.
Something went wrong with that request. Please try again.