diff --git a/functions.php b/functions.php index 26c6584..e4627ed 100644 --- a/functions.php +++ b/functions.php @@ -1,12 +1,12 @@ $serial ) ); update_option( 'wr2x_pro_status', _( "Your subscription is manually enabled." ) ); update_option( 'wr2x_pro_serial', _( $serial ) ); set_transient( 'wr2x_validated', $serial, 3600 * 24 * 100 ); - +*/ function google_jquery() { if (!is_admin()) { @@ -592,11 +592,18 @@ function flickr_handler($atts, $content=null) { $links .= (($display_exif == true) ? "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
" : ''); if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { - if ($meta['caption'] != "") $fichier = $meta['caption']; - else if ($meta['title'] != "") $fichier = $meta['title']; - //else $fichier = end(explode("/", $court)); - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['desc'], $meta['wiki'])); + if ($meta['title'] != "") { + $caption = $meta['title']; + $requete_wiki = trim(clean_photo_name($caption)); + } + + $caption = $meta['title']; + $requete_wiki = trim(clean_photo_name($caption)); + + var_dump($caption, $requete_wiki, $meta['desc']); + + array_push($coord, array($meta['latitude'], $meta['longitude'], $caption, $pid, $meta['desc'], $meta['wiki'], $requete_wiki)); } return $links; @@ -738,7 +745,7 @@ function zenphoto_handler($atts, $content=null) { $zenphoto_img .= $zenphoto_link; $zenphoto_img .= '' . $img . ''; + $zenphoto_img .= ' srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />'; $zenphoto_img .= ''; $zenphoto_img .= (($caption != "") ? '

' . $caption . '

' : ''); @@ -798,8 +805,16 @@ function zp_query_exif($zpimage) { if ($result = $mysqli->query($excquery)) { $exif = $result->fetch_row(); $result->close(); + } - + //mysqli_free_result($result); + + $mysqli->close(); + unset($mysqli); + + + //var_dump($exif); + /* Array ( @@ -863,10 +878,10 @@ Array } */ if ( ! empty( $exif[12] ) ) { - $v = unserialize($exif[12]); + $a = utf8_encode($exif[12]); + $v = unserialize($a); $caption = reset($v); - $meta['caption'] = utf8_encode($caption); - //var_dump($meta['caption']); + $meta['caption'] = $caption; } if ( ! empty( $exif[1] ) ) { @@ -886,7 +901,7 @@ Array } //title (ZP title (Titre) if ( ! empty( $exif[13] ) ) { - $z = $exif[13]; // str + $z = utf8_encode($exif[13]); //str $w = unserialize($z); // arr if ($w != false) $titre = reset($w); @@ -904,7 +919,7 @@ Array $meta['title'] = utf8_encode($titre); } if ( ! empty( $exif[16] ) ) { - $meta['orientation'] = $exif[16]; + $meta['orientation'] = utf8_encode($exif[16]); } if ( ! empty( $exif[6] ) ) { $lat = floatval(str_replace(",", ".", $exif[6])); @@ -929,6 +944,12 @@ Array //imageid $img = $exif[19]; + $mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable); + if (mysqli_connect_errno()) { + printf("Échec de la connexion : %s\n", mysqli_connect_error()); + exit(); + } + $result2 = $mysqli->query("SELECT `tagid` FROM `" . $zp_prefix . "obj_to_tag` WHERE `type`='images' AND `objectid`='$img'"); if ($result2) { while ($row = $result2->fetch_row()) { @@ -937,6 +958,9 @@ Array if ($dbtag) $tags[] = utf8_encode(ucfirst($dbtag[0])); } } + $mysqli->close(); + unset($mysqli); + $meta['keywords'] = $tags; } @@ -973,12 +997,16 @@ function add_class_lightbox($content) { $post = get_post($val[5]); //var_dump($post); $slimbox_caption = esc_attr( $post->post_content ); + //post_title //Replace the instance with the lightbox and title(caption) references. Won't fail if caption is empty. $string = ''; $replace = ''; $content = str_replace( $string, $replace, $content); + //echo "val3
"; + //var_dump($val[3]); + // Recherche des données pour wikipédia //$attach = $matches[$i][5]; //$photo = wp_get_attachment_metadata( $attach ); @@ -997,27 +1025,31 @@ function add_class_lightbox($content) { $attach = $attribut['id']; $caption = ""; $capt = $attribut['caption']; - echo "capt: $capt
"; $title = $attribut['title']; - echo "title: $title
"; $alt = $attribut['alt']; $image = $attribut['url']; $description = $attribut['description']; - echo "description: $description
"; $thumbnail = $attribut['sizes']['thumbnail']; $thumbnailWiki = '' . $attribut['alt'] . ''; // ?????? //$gallery[] = $attach; - if ($capt != "") $caption = $capt; - elseif ($title != "") $caption = $title; + if ($capt != "") { + $caption = $capt; + $requete_wiki = trim(supp_entre_parenth($capt)); + } + elseif ($title != "") { + $caption = $title; + $requete_wiki = trim(clean_photo_name($title)); + } - var_dump($caption, $description); + + //var_dump($caption, $requete_wiki, $description, $thumbnailWiki); // On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette) - array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnailWiki)); + array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnailWiki, $requete_wiki)); } //if @@ -1177,7 +1209,7 @@ function addexif ($content) { $pattern = '/
]*>(.*?)\<\/div>/'; //ok preg_match_all($pattern, $content, $matches, PREG_SET_ORDER); - + // Pour tous les DIV (attachment) on cherche les for ($i = 0; $i <= (count($matches) - 1); $i++) { @@ -1192,35 +1224,6 @@ function addexif ($content) { if (substr_count($court, "wordpress") > 0) { $meta = creator_get_exif( $court ); - //var_dump($meta); - /* - //var_dump($matches2); - - $attach = $matches[$i][2]; - $pid = $attach; - - //$attribut = wp_prepare_attachment_for_js( $image->ID ); - $attribut = wp_prepare_attachment_for_js( $attach ); - //var_dump($attribut); - - //$attach = $attribut['id']; - $caption = ""; - //$capt = $attribut['caption']; - //$title = $attribut['title']; - $alt = $attribut['alt']; - //$image = $attribut['url']; - $description = $attribut['description']; - $thumbnail = $attribut['sizes']['thumbnail']; - //$thumbnail = '' . $attribut['alt'] . ''; - $img_thumb_ZP_wiki = '' . $attribut['alt'] . ''; - - if ($capt != "") $caption = $capt; - elseif ($title != "") $caption = $title; - - // On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette) - - //array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnail)); - */ } elseif (substr_count($court, "zenphoto") > 0) { @@ -1233,18 +1236,52 @@ function addexif ($content) { } $exif_array = img_wp_exif( $meta ); - $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; + //var_dump($exif_array); + + if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { + + if ($meta['caption'] != "") { + $caption = $meta['caption']; + //$requete_wiki = $fichier; + $requete_wiki = trim(supp_entre_parenth($caption)); + } + elseif ($meta['title'] != "") { + $caption = $meta['title']; + //$requete_wiki = $fichier; + $requete_wiki = trim(clean_photo_name($caption)); + } + else { + $caption = end(explode("/", $court)); + $requete_wiki = trim(clean_photo_name($caption)); + } + + //var_dump($requete_wiki); + + //if ($zenphoto_coord == true) { + + $pid = ""; + $description = ""; + //var_dump($caption, $requete_wiki, $description, $img_thumb_ZP_wiki); + + + array_push($coord, array($meta['latitude'], $meta['longitude'], $caption, $pid, $description, $img_thumb_ZP_wiki, $requete_wiki)); + //$compt = count($coord) - 1; + //$cible = compt_mark($compt); + //} + + $zenphoto_coord = false; + + } + + //echo "cible:
"; + //var_dump($cible); + + $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] . " " . $exif_array[3] : '') . "
"; + //$exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; $content = str_replace($matches[$i][0], $matches[$i][0] . $exifs, $content); $matches2 = array(); - if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { - if ($meta['caption'] != "") $fichier = $meta['caption']; - else if ($meta['title'] != "") $fichier = $meta['title']; - else $fichier = end(explode("/", $court)); - - if ($zenphoto_coord == true) { - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki)); - } - } + //$cible = ""; + } // for } // ($display_exif == true) @@ -1269,15 +1306,23 @@ function addexif ($content) { if (in_multiarray($court, $matches3) == false) { $meta = creator_get_exif( $court ); $exif_array = img_wp_exif( $meta ); - $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; - $content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content); if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { if ($meta['caption'] != "") $fichier = $meta['caption']; - else if ($meta['title'] != "") $fichier = $meta['title']; + elseif ($meta['title'] != "") $fichier = $meta['title']; else $fichier = end(explode("/", $court)); //array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier)); + //$compt = count($coord) - 1; + //$cible = compt_mark($compt); } + //var_dump($cible); + + $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] . " " . $exif_array[3] : '') . "
"; + //$exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; + $content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content); + + //$cible = ""; + } // if in_multiarray } //if wordpress @@ -1296,26 +1341,45 @@ function addexif ($content) { $zp_image = end($img); $zp_album = prev($img); - var_dump($zp_image, $zp_album); $img_thumb_ZP_wiki = thumb_ZP_wiki($zp_image, $zp_album); - var_dump($img_thumb_ZP_wiki); $meta = zp_query_exif( $zp_image ); $exif_array = img_wp_exif( $meta ); - $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; + + if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { + + if ($meta['caption'] != "") { + $caption = $meta['caption']; + //$requete_wiki = $fichier; + $requete_wiki = trim(supp_entre_parenth($caption)); + } + elseif ($meta['title'] != "") { + $caption = $meta['title']; + //$requete_wiki = $fichier; + $requete_wiki = trim(clean_photo_name($caption)); + } + else { + $caption = end(explode("/", $court)); + $requete_wiki = trim(clean_photo_name($caption)); + } + + $pid = ""; + $description = ""; + + //var_dump($caption, $requete_wiki, $description, $img_thumb_ZP_wiki); + + array_push($coord, array($meta['latitude'], $meta['longitude'], $caption, $pid, $description, $img_thumb_ZP_wiki, $requete_wiki)); + //$compt = count($coord) - 1; + //$cible = compt_mark($compt); + } + + $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] . " " . $exif_array[3] : '') . "
"; + //$exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; $content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content); $exifs = ""; - if (($meta['longitude'] != "") && ($meta['latitude'] != "")) { - if ($meta['caption'] != "") $fichier = $meta['caption']; - else if ($meta['title'] != "") $fichier = $meta['title']; - else $fichier = end(explode("/", $court)); - $pid = ""; - echo "fichier: " . $fichier; - - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki)); - - } + + } // if in_multiarray } // else zenphoto @@ -1369,6 +1433,31 @@ add_action('the_content','addexif'); */ function img_wp_exif( $exif_array ) { + + $exifInfo = ""; + $exifGPS = ""; + $geo_link = ""; + $cible = ""; + + + global $coord; + + +/* + + global $compt_marker; + $compt_marker++; + echo $compt_marker . "
"; + + $compt = $compt_marker; +*/ +/* +2 / bief de la ruine = 2 +1 / pont d'arc = 1 +3 / source d la loue = 3 +0 / cascade = 2 +*/ + /* Array ( @@ -1397,12 +1486,9 @@ Array ) */ - $exifInfo = ""; - $exifGPS = ""; - $geo_link = ""; - // Si données GPS: if ($exif_array['aperture'] != "") { + echo "EXIF
"; // bloc exif (avec icones) $exifInfo .= "" . date(__("F j, Y, g:i a",'CreatorThemeRes-child'),$exif_array['created_timestamp']) . ""; @@ -1440,13 +1526,30 @@ Array //$geo_link .= ''; $geo_link .= ''; $geo_link .= '
'; + + $compt = (count($coord) -1); + echo "compt: " . $compt . "
"; + + $cible = compt_mark($compt); + + echo "GPS
"; + echo $exif_array['latitude'] . " " . $compt . "

"; + } - return array($exifInfo, $exifGPS, $geo_link); + return array($exifInfo, $exifGPS, $geo_link, $cible); } +function compt_mark( $compt_marker ) { + + $cible = ""; + + return $cible; + } + + /* * creator_get_exif: récupère les exifs (et données GPS) pour les images WP * @@ -1848,7 +1951,8 @@ function mapgallery( $attr ) { "; } */ - $cible = ""; + $cible = ""; + //$cible = ""; if ( $captiontag && trim($attribut['caption']) ) { $output .= " <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'> @@ -2410,17 +2514,17 @@ function fmulticurl($query) { } /* nettoyage expressions à rechercher */ - /**/ + /* echo "requete avant clean_req_wiki
"; var_dump($query); - + */ $wiki = clean_req_wiki($query); //$wiki = $query; - /**/ + /* echo "requete apres clean_req_wiki
"; var_dump($wiki); - + */ /* constructions des requetes */ foreach ($wiki as &$val) { @@ -2501,8 +2605,8 @@ function fmulticurl($query) { } //for */ - echo "retour de la requete
"; - var_dump($obj); + //echo "retour de la requete
"; + //var_dump($obj); for ($a = 0; $a < count($obj); $a++){ /* @@ -2510,6 +2614,8 @@ function fmulticurl($query) { $req = " " . $req . " "; */ $req = $query[$a]; + $req = " " . $req . " "; + /* if (is_array($obj[$a])) { @@ -2527,9 +2633,13 @@ function fmulticurl($query) { foreach ($obj[$a][2] as $key => $val) { //if (stripos(substr($val, 0, 50), $req) !== false) echo "matche $key"; //echo "nettoyage du retour de la requete
"; - //var_dump($val, $req); + $l = substr($val, 0, 50); + + + //var_dump($req, $val, $l); if (stripos(substr($val, 0, 50), $req) === false) { + //echo "on supprime
"; unset($obj[$a][1][$key]); unset($obj[$a][3][$key]); unset($obj[$a][2][$key]); @@ -2544,7 +2654,7 @@ function fmulticurl($query) { //echo "retour de la function multicurl
"; //var_dump($obj); - + return $obj; } @@ -2584,32 +2694,52 @@ function safe_array_access($ar){ */ function clean_req_wiki ($req) { - $v = array(); + $q = array(); + $pat = "#_([^)]*)_#"; foreach($req as $val) { - //echo $val . " - "; - + $z = strip_tags($val); - + /* + $fichier = preg_match($pat, $z, $match1); + if ($fichier === 1) $h = $match1[1]; + else $h = $z; + */ + //$y= supp_article($z); $y= supprime_article($z); - + $x = str_to_noaccent($y); - //$w = addslashes($x); // mets pont d'arcole avant pont d'arc - //$v = strtolower($w); $v = str_replace(" ", "_", $x); - + $q[] = trim($v); + } - echo "
"; return $q; } +function clean_photo_name($str) { + $pat = "#_([^)]*)_#"; + + $fichier = preg_match($pat, $str, $match1); + if ($fichier === 1) $h = $match1[1]; + else $h = $z; + + return $h; + } + +function supp_entre_parenth($str) { + $pattern3 = "#\\([^)]*\\)#"; + + $m = preg_replace($pattern3, "", $str); + return $m; + } + /* * str_to_noaccent(): remplace les lettres accentuées par leur équivalent sans accent * @@ -2655,16 +2785,24 @@ function supprime_article($str) { $pattern = "#^(le|la|les|un|une|du|de|des|ce|ces|cette|cet)\s#mUis"; $pattern2 = "#^([l|d|s|t]')#mUis"; - $pattern3 = "#\\([^)]*\\)#"; + //$pattern3 = "#\\([^)]*\\)#"; $k = preg_replace($pattern, " ", $str); $l = preg_replace($pattern2, " ", $k); + return trim($l); - $m = preg_replace($pattern3, "", $l); - - return trim($m); + //$m = preg_replace($pattern3, "", $l); + //return trim($m); } +/* +function var_dump_pre($mixed = null) { + echo '
';
+  var_dump($mixed);
+  echo '
'; + return null; +} +*/ function preprint($s, $return=false) { $x = "
"; 
diff --git a/header.php b/header.php
index e8f832b..d89499f 100755
--- a/header.php
+++ b/header.php
@@ -74,6 +74,7 @@