コード例 #1
0
ファイル: content_index.php プロジェクト: jjmhtp/CROTOS
     }
     $commons_artist = esc_dblq(htmlentities(preg_replace("/<\\/?img[^>]*\\>/i", "", preg_replace("/<\\/?ul[^>]*\\>/i", "", preg_replace("/<\\/?li[^>]*\\>/i", "", preg_replace("/<\\/?table[^>]*\\>/i", "", preg_replace("/<\\/?div[^>]*\\>/i", "", $commons_artist)))))));
     $commons_credit = esc_dblq(htmlentities(preg_replace("/<ul[^>]+\\>/i", "", preg_replace("/<li[^>]+\\>/i", "", preg_replace("/<p[^>]+\\>/i", "", preg_replace("/<dd[^>]+\\>/i", "", preg_replace("/<dl[^>]+\\>/i", "", preg_replace("/<img[^>]+\\>/i", "", preg_replace("/<\\/?td[^>]*\\>/i", "", preg_replace("/<\\/?tr[^>]*\\>/i", "", preg_replace("/<\\/?table[^>]*\\>/i", "", preg_replace("/<\\/?li[^>]*\\>/i", "", preg_replace("/<\\/?ul[^>]*\\>/i", "", preg_replace("/<\\/?hr[^>]*\\>/i", "", preg_replace("/<\\/?p[^>]*\\>/i", "", preg_replace("/<\\/?div[^>]*\\>/i", "", $commons_credit))))))))))))))));
     $credits = $commons_artist;
     if ($credits != "" && $license != "") {
         $credits .= "&nbsp;&nbsp;|&nbsp;&nbsp;";
     }
     $credits .= $license;
     if ($credits != "" && $commons_credit != "") {
         $credits .= "&nbsp;&nbsp;|&nbsp;&nbsp;";
     }
     $credits .= $commons_credit;
     if ($num_rows > 1) {
         $content .= "<a href=\"" . $commons_link . "\" data-file=\"" . esc_dblq($large) . "\" data-commons=\"" . $commons_link . "\" class=\"yox\" id=\"link{$cpt}\" onclick=\"return wait();\"><img src=\"" . esc_dblq($thumb_h) . "\" alt=\"" . esc_dblq($titre) . "\" data-img=\"" . esc_dblq($thumb_h) . "\" data-credit=\"" . $credits . "\" data-notice=\"" . esc_dblq(htmlentities($yox_cartel)) . "\"/></a>";
     } else {
         $content .= "<a href=\"" . $commons_link . "\" data-commons=\"" . $commons_link . "\" class=\"linksolo\" id=\"link{$cpt}\" onclick=\"return wait();\"><img src=\"" . esc_dblq($large) . "\" alt=\"" . esc_dblq($titre) . "\" data-img=\"" . esc_dblq($thumb_h) . "\" data-credit=\"" . $credits . "\" data-notice=\"" . esc_dblq(htmlentities($yox_cartel)) . "\"/></a>";
     }
 } else {
     if ($disp == 0) {
         $content .= "<img src=\"img/no_image2.png\" alt=\"\" width=\"200\" height=\"240\">";
     } else {
         $content .= "<img src=\"img/no_image_day.png\" alt=\"\" width=\"200\" height=\"240\" class=\"no_img\">";
     }
 }
 $content .= "\n\t\t</div></div>";
 $content .= $cartel;
 $content .= "\n\t</div>";
 if ($num_rows > 1) {
     $content .= "\n\t<script>document.getElementById('notice{$cpt}').style.display = 'none';</script>\n";
 }
 echo $content;
コード例 #2
0
ファイル: compilation.php プロジェクト: jjmhtp/CROTOS
                 $tab_prop[$key] = $value["mainsnak"]["datavalue"]["value"];
             } else {
                 break;
             }
         }
         if ($key != "P18") {
             $tab_prop[$key] = esc_dblq($tab_prop[$key]);
         }
     }
 }
 $new_img = 0;
 $p18 = 0;
 $hd = 0;
 if ($tab_prop["P18"] != "") {
     $img_exists = false;
     $sql = "SELECT id FROM commons_img WHERE P18=\"" . esc_dblq($tab_prop["P18"]) . "\"";
     $rep = mysqli_query($link, $sql);
     if (mysqli_num_rows($rep) != 0) {
         $img_exists = true;
     }
     $p18 = id_commons($tab_prop["P18"]);
     if ($p18 != 0) {
         $sql = "SELECT width,height FROM commons_img WHERE id=" . $p18;
         $rep = mysqli_query($link, $sql);
         if (mysqli_num_rows($rep) != 0) {
             $row = mysqli_fetch_assoc($rep);
             if ($row['width'] >= 2000 || $row['height'] >= 2000) {
                 $hd = 1;
             }
         }
     }
コード例 #3
0
ファイル: functions.php プロジェクト: jjmhtp/CROTOS
function id_commons($p18_str)
{
    global $link;
    $p18 = 0;
    $commons_artist = "";
    $commons_credit = "";
    $commons_license = "";
    $thumb = "";
    $thumb_h = "";
    $large = "";
    $w_thumb_h = 0;
    $sql = "SELECT id FROM commons_img WHERE P18=\"" . esc_dblq($p18_str) . "\"";
    $rep = mysqli_query($link, $sql);
    if (mysqli_num_rows($rep) == 0) {
        $img = str_replace(" ", "_", $p18_str);
        $urlapi = "https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&format=xml&iiprop=extmetadata&iilimit=10&titles=File:" . urlencode($img);
        $xml = simplexml_load_file_from_url($urlapi);
        if ($xml) {
            $commons_artist = $xml->xpath('//Artist/@value')[0];
            $commons_credit = $xml->xpath('//Credit/@value')[0];
            $commons_license = $xml->xpath('//License/@value')[0];
            $digest = md5($img);
            $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . urlencode($img);
            $urlimg = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
            if (substr($img, -3) == "svg") {
                $thumb = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/200px-" . urlencode($img) . ".png";
                $size = getimagesize($thumb);
                $width_tmp = $size[0];
                $height_tmp = $size[1];
                if ($width_tmp / $height_tmp > 200 / 350) {
                    $w_thumb = 200;
                } else {
                    $w_thumb = floor(350 * $width_tmp / $height_tmp);
                }
                $thumb = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/" . $w_thumb . "px-" . urlencode($img) . ".png";
                if ($width_tmp / $height_tmp > 1400 / 900) {
                    $width = 1400;
                } else {
                    $width = floor(900 * $width_tmp / $height_tmp);
                }
                $height = floor($height_tmp * $width / $width_tmp);
                $large = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/" . $width . "px-" . urlencode($img) . ".png";
            } else {
                $urlapimagnus = "https://tools.wmflabs.org/magnus-toolserver/commonsapi.php?image=" . urlencode($img);
                $xml = simplexml_load_file_from_url($urlapimagnus);
                if ($xml) {
                    $width = intval($xml->xpath('//file/width/text()')[0]);
                    $height = intval($xml->xpath('//file/height/text()')[0]);
                } else {
                    $size = getjpegsize($urlimg);
                    if (!isset($size[1])) {
                        $size = getimagesize($urlimg);
                    }
                    $width = $size[0];
                    $height = $size[1];
                }
                if (!(is_null($width) || $width == 0)) {
                    // thumb vertical
                    if ($width / $height > 200 / 350) {
                        if ($width > 200) {
                            $w_thumb = 200;
                        } else {
                            $w_thumb = $width;
                        }
                    } else {
                        if ($height > 350) {
                            $w_thumb = floor(350 * $width / $height);
                        } else {
                            $w_thumb = $width;
                        }
                    }
                    if ($w_thumb == $width) {
                        $thumb = $urlimg;
                    } else {
                        $thumb = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/" . $w_thumb . "px-" . urlencode($img);
                    }
                    // thumb horizontal
                    if ($width / $height > 320 / 240) {
                        if ($width > 320) {
                            $w_thumb_h = 320;
                        } else {
                            $w_thumb_h = $width;
                        }
                    } else {
                        if ($height > 240) {
                            $w_thumb_h = floor(240 * $width / $height);
                        } else {
                            $w_thumb_h = $width;
                        }
                    }
                    if ($w_thumb_h == $width) {
                        $thumb_h = $urlimg;
                    } else {
                        $thumb_h = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/" . $w_thumb_h . "px-" . urlencode($img);
                    }
                    // large
                    if ($width / $height > 1400 / 900) {
                        if ($width > 1400) {
                            $w_large = 1400;
                        } else {
                            $w_large = $width;
                        }
                    } else {
                        if ($height > 900) {
                            $w_large = floor(900 * $width / $height);
                        } else {
                            $w_large = $width;
                        }
                    }
                    if ($w_large == $width) {
                        $large = $urlimg;
                    } else {
                        $large = "http://upload.wikimedia.org/wikipedia/commons/thumb/" . $folder . "/" . $w_large . "px-" . urlencode($img);
                    }
                } else {
                    $width = 0;
                }
                unset($size);
            }
            if ($width != 0) {
                $commons_artist = esc_dblq($commons_artist);
                $commons_credit = esc_dblq($commons_credit);
                $commons_license = esc_dblq($commons_license);
                $thumb = esc_dblq($thumb);
                $thumb_h = esc_dblq($thumb_h);
                $large = esc_dblq($large);
                $sql = "INSERT INTO commons_img (P18,commons_artist,commons_credit,commons_license,thumb,thumb_h,width_h,large,width,height) VALUES (\"" . esc_dblq($p18_str) . "\",\"" . $commons_artist . "\",\"" . $commons_credit . "\",\"" . $commons_license . "\",\"" . $thumb . "\",\"" . $thumb_h . "\",{$w_thumb_h},\"" . $large . "\",{$width},{$height})";
                $rep = mysqli_query($link, $sql);
                $sql = "SELECT id FROM commons_img WHERE P18=\"" . esc_dblq($p18_str) . "\"";
                $rep = mysqli_query($link, $sql);
                $row = mysqli_fetch_assoc($rep);
                $p18 = $row['id'];
            }
        }
    } else {
        $row = mysqli_fetch_assoc($rep);
        $p18 = $row['id'];
    }
    return $p18;
}