示例#1
0
文件: embed.php 项目: noikiy/owaspbwa
 */
/* Define G2_EMBED = 1 to remember to generate correct URLs and return the HTML, etc. */
require_once dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class';
GalleryDataCache::put('G2_EMBED', 1, true);
require dirname(__FILE__) . '/main.php';
require dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class';
/*
 * Simplify finding the path to embed.php by sending it as a HTTP header
 * Idea:
 *   In your integration setup you need to find out
 *     - the filesystem path for embed.php
 *     - the g2Uri and the embedUri.
 * You can get the embed.php path with your g2Uri by fetching 
 * http://example.com/gallery2/embed.php?getEmbedPath=1 via fsockopen.
 */
$getEmbedPath = GalleryUtilities::getRequestVariablesNoPrefix('getEmbedPath');
if (!empty($getEmbedPath)) {
    if (!headers_sent()) {
        /*
         * Don't use GalleryUtilities::getRemoteHostAddress() 
         * since it checks headers that can be forged easily too
         */
        $remotehost = GalleryUtilities::getServerVar('REMOTE_ADDR');
        $remotehost = !empty($remotehost) ? gethostbyname($remotehost) : '';
        $localhost = GalleryUtilities::getServerVar('HTTP_HOST');
        $localhost = !empty($localhost) ? gethostbyname($localhost) : '127.0.0.1';
        if (!empty($remotehost) && $remotehost == $localhost) {
            if (defined('GALLERY_CONFIG_DIR')) {
                /* GALLERY_CONFIG_DIR is multisite-aware */
                header('X-G2-EMBED-PATH: ' . GALLERY_CONFIG_DIR . '/embed.php');
            } else {