Beispiel #1
0
function clearPageCache()
{
    require_once dirname(__FILE__) . '/../../embed.php';
    GalleryEmbed::init();
    $ret1 = GalleryCoreApi::removeAllMapEntries('GalleryCacheMap');
    $ret2 = GalleryEmbed::done();
    if ($ret1 || $ret2) {
        $status[] = array('error', 'Error deleting page cache!');
    } else {
        $status[] = array('info', 'Successfully deleted page cache');
    }
    return $status;
}
Beispiel #2
0
 /**
  * Initialize the embedded Gallery2 instance.  Call this before any other Gallery2 calls.
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return false;
     }
     // Gallery2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
     // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
     // and Gallery.class) and munge them so that we can rename the Gallery class to be
     // G2_Gallery.   Is this retarded?  Why yes it is.
     //
     // Store the munged files in a directory that's the md5 hash of the embed path so that
     // multiple import sources don't interfere with each other.
     $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
     if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
         @dir::unlink($mod_path);
         mkdir($mod_path);
         $base_dir = dirname($embed_path);
         file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
         file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
         file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$base_dir}');", "\$gallery =& new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
         file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
     }
     require "{$mod_path}/embed.php";
     if (!class_exists("GalleryEmbed")) {
         return false;
     }
     $ret = GalleryEmbed::init();
     if ($ret) {
         return false;
     }
     $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
     $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
     $admin_id = current(array_flip($admins));
     $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
     $GLOBALS["gallery"]->setActiveUser($admin);
     return true;
 }
Beispiel #3
0
 /**
  * Initialize the embedded Gallery 2 instance.  Call this before any other Gallery 2 calls.
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return false;
     }
     // Gallery 2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
     // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
     // and Gallery.class) and munge them so that we can rename the Gallery class to be
     // G2_Gallery.   Is this retarded?  Why yes it is.
     //
     // Store the munged files in a directory that's the md5 hash of the embed path so that
     // multiple import sources don't interfere with each other.
     $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
     if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
         @dir::unlink($mod_path);
         mkdir($mod_path);
         $config_dir = dirname($embed_path);
         if (filesize($embed_path) > 200) {
             // Regular install
             $base_dir = $config_dir;
         } else {
             // Multisite install.  Line 2 of embed.php will be something like:
             //   require('/usr/home/bharat/public_html/gallery2/embed.php');
             $lines = file($embed_path);
             preg_match("#require\\('(.*)/embed.php'\\);#", $lines[2], $matches);
             $base_dir = $matches[1];
         }
         file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
         file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
         file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();", "\$GLOBALS['gallery'] =& new Gallery();", "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$config_dir}');", "\$gallery =& new G2_Gallery();", "\$GLOBALS['gallery'] =& new G2_Gallery();", "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
         file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
     }
     require "{$mod_path}/embed.php";
     if (!class_exists("GalleryEmbed")) {
         return false;
     }
     $ret = GalleryEmbed::init();
     if ($ret) {
         return false;
     }
     $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
     $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
     $admin_id = current(array_flip($admins));
     $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
     $GLOBALS["gallery"]->setActiveUser($admin);
     // Make sure we have an embed location so that embedded url generation comes out ok.  Without
     // this, the Gallery2 ModRewrite code won't try to do url generation.
     $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation"));
     if (empty($g2_embed_location)) {
         $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation"));
         g2(GalleryCoreApi::setPluginParameter("module", "rewrite", "modrewrite.embeddedLocation", $g2_embed_location));
         g2($gallery->getStorage()->checkPoint());
     }
     self::$g2_base_url = $g2_embed_location;
     return true;
 }
Beispiel #4
0
    echo g2ic_make_html_display_options();
    echo g2ic_make_html_controls();
    print_r($g2ic_page_navigation);
    echo g2ic_make_html_image_navigation();
    print_r($g2ic_page_navigation);
}
echo g2ic_make_html_about($g2ic_version_text);
echo '                    </div>' . "\n";
echo '                </td>' . "\n";
echo '            </tr>' . "\n";
echo '        </table>' . "\n";
echo '    </form>' . "\n";
echo '</body>' . "\n\n";
echo '</html>';
$_SESSION['g2ic_last_album_visited'] = $g2ic_options['current_album'];
GalleryEmbed::done();
// ====( Functions - Alphabetical by Function Name)
/**
 * Get all of the Gallery2 items
 *
 * @return array $album_info Album Title and URL for the current album
 * @return array $gallery_items Sorted array of IDs and Titles for all Gallery2 Data Items in the current album
 */
function g2ic_get_gallery_items()
{
    global $gallery, $g2ic_options;
    $gallery_items = array();
    $item_mod_times = array();
    $item_orig_times = array();
    $item_create_times = array();
    $item_titles = array();
Beispiel #5
0
 /**
  * Initialize the embedded Gallery 2 instance.  Call this before any other Gallery 2 calls.
  *
  * Return values:
  *  "ok"      - the Gallery 2 install is fine
  *  "missing" - the embed path does not exist
  *  "invalid" - the install path is not a valid Gallery 2 code base
  *  "broken"  - the embed path is correct, but the Gallery 2 install is broken
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return "missing";
     }
     try {
         // Gallery 2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
         // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
         // and Gallery.class) and munge them so that we can rename the Gallery class to be
         // G2_Gallery.   Is this retarded?  Why yes it is.
         //
         // Store the munged files in a directory that's the md5 hash of the embed path so that
         // multiple import sources don't interfere with each other.
         $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
         if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
             @dir::unlink($mod_path);
             mkdir($mod_path);
             $config_dir = dirname($embed_path);
             if (filesize($embed_path) > 200) {
                 // Regular install
                 $base_dir = $config_dir;
             } else {
                 // Multisite install.  Line 2 of embed.php will be something like:
                 //   require('/usr/home/bharat/public_html/gallery2/embed.php');
                 $lines = file($embed_path);
                 preg_match("#require\\('(.*)/embed.php'\\);#", $lines[2], $matches);
                 $base_dir = $matches[1];
             }
             file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
             file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
             file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();", "\$GLOBALS['gallery'] =& new Gallery();", "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$config_dir}');", "\$gallery =& new G2_Gallery();", "\$GLOBALS['gallery'] =& new G2_Gallery();", "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
             file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
         } else {
             // Ok, this is a good one.  If you're running a bytecode accelerator and you move your
             // Gallery install, these files sometimes get cached with the wrong path and then fail to
             // load properly.
             // Documented in https://sourceforge.net/apps/trac/gallery/ticket/1253
             touch("{$mod_path}/embed.php");
             touch("{$mod_path}/main.php");
             touch("{$mod_path}/bootstrap.inc");
             touch("{$mod_path}/Gallery.class.inc");
         }
         require "{$mod_path}/embed.php";
         if (!class_exists("GalleryEmbed")) {
             return "invalid";
         }
         $ret = GalleryEmbed::init();
         if ($ret) {
             Kohana_Log::add("error", "Gallery 2 call failed with: " . $ret->getAsText());
             return "broken";
         }
         $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
         $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
         $admin_id = current(array_flip($admins));
         $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
         $GLOBALS["gallery"]->setActiveUser($admin);
         // Make sure we have an embed location so that embedded url generation comes out ok.  Without
         // this, the Gallery2 ModRewrite code won't try to do url generation.
         $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation"));
         if (empty($g2_embed_location)) {
             $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation"));
             g2(GalleryCoreApi::setPluginParameter("module", "rewrite", "modrewrite.embeddedLocation", $g2_embed_location));
             g2($gallery->getStorage()->checkPoint());
         }
         if ($g2_embed_location) {
             self::$g2_base_url = $g2_embed_location;
         } else {
             self::$g2_base_url = $GLOBALS["gallery"]->getUrlGenerator()->generateUrl(array(), array("forceSessionId" => false, "htmlEntities" => false, "urlEncode" => false, "useAuthToken" => false));
         }
     } catch (ErrorException $e) {
         Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
         return "broken";
     }
     return "ok";
 }
Beispiel #6
0
         echo '</td></tr>';
         echo '</table>';
     }
 } else {
     if ($type == "gallery") {
         $alluserslink = "";
         if ($_POST['addselect']) {
             foreach ($_POST['addselect'] as $user) {
                 $alluserslink .= $user . ":";
             }
         }
         echo "<h2>Gallery:</h2><br />";
         echo '<a href="get_csv.php?id=' . $id . '&type=gallery&addselect=' . $alluserslink . '">Download CSV</a><br /><br />';
         require_once $CFG->dirroot . "/gallery2/bootstrap.inc";
         require_once $CFG->dirroot . "/gallery2/embed.php";
         $embed = new GalleryEmbed();
         $embed->init();
         $g_api = new GalleryCoreApi();
         list($ret, $usersdata) = $g_api->fetchUsernames();
         if ($_POST['addselect']) {
             foreach ($_POST['addselect'] as $user) {
                 list($ret, $items) = $g_api->fetchAllItemIdsByOwnerId($user);
                 //---------------------????????? ? ????????????---------------------//
                 list($ret, $usr) = $g_api->fetchUserByUserName($usersdata[$user]);
                 $summary = "";
                 $summary_s = "";
                 foreach ($items as $item) {
                     $r_tb = mysql_query("SELECT * FROM " . $storeConfig['tablePrefix'] . "Item WHERE " . $storeConfig['columnPrefix'] . "id = '" . $item . "'");
                     $row_tb = mysql_fetch_array($r_tb);
                     if ($row_tb[$storeConfig['columnPrefix'] . 'summary'] != $usr->userName) {
                         $summarysize = strlen(trim($row_tb[$storeConfig['columnPrefix'] . 'summary']));
Beispiel #7
0
            //vd( $gallery->getActiveUserId() );
            if ($g2User = GalleryEmbed::createUser($gBitUser->mUserId, array('username' => $gBitUser->mInfo['login'], 'email' => $gBitUser->mInfo['email'], 'fullname' => $gBitUser->mInfo['real_name'], 'creationtimestamp' => $gBitUser->mInfo['registration_date']))) {
                if ($gBitUser->isAdmin()) {
                    list($ret, $adminGroupId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
                    if ($ret->isError()) {
                        return array($ret->wrap(__FILE__, __LINE__), false);
                    }
                    GalleryEmbed::addUserToGroup($activeUserId, 2);
                }
                //'language' => $gBitUser->mInfo['language'],
                //'password' => string,
                //'hashedpassword' => string,
                //'hashmethod' => string,
            } else {
                fatalError(tra($status->getAsHtml()));
                exit;
            }
        }
    }
    GalleryCapabilities::set('showSidebar', TRUE);
    $g2data = GalleryEmbed::handleRequest();
    //After enabling sidebar, no need to smarty menu and it is not working as of 2005 06 17
    //$gBitSmarty->assign_by_ref( 'menuLinks', $g2data['layoutData']['itemLinks'] );
    if ($g2data['isDone']) {
        exit;
        // G2 has already sent output (redirect or binary data)
    }
    $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
    $gBitSmarty->assign_by_ref('g2data', $g2data);
    $gBitSystem->display('bitpackage:gallery2/bitweaver_embed.tpl', NULL, array('display_mode' => 'display'));
}
Beispiel #8
0
        global $gallery;
        $gallery->initEmptySession();
    }
    $remember = array();
    foreach ($_REQUEST['target'] as $key => $ignored) {
        /* Make sure the dir is legit */
        if (!array_key_exists($key, $caches)) {
            $status[] = array('error', "Ignoring illegal cache: {$key}");
            continue;
        }
        $func = $caches[$key][1];
        $args = $caches[$key][2];
        $status = array_merge($status, call_user_func_array($func, $args));
        $remember[] = $key;
    }
    $ret = GalleryEmbed::done();
    if ($ret) {
        $status[] = array('error', 'Error completing transaction!');
    }
    $_COOKIE['g2cache'] = join(',', $remember);
}
?>
<html>
  <head>
    <title>Gallery Support | Cache Maintenance</title>
    <link rel="stylesheet" type="text/css" href="<?php 
print $baseUrl;
?>
support.css"/>
  </head>
  <body>
Beispiel #9
0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 */
/**
 * Access point for external application in which Gallery is embedded.
 * See modules/core/classes/GalleryEmbed.class  and
 * http://codex.gallery2.org/index.php/Gallery2:Embedding  for more details.
 *
 * @package Gallery
 * @author Alan Harder <*****@*****.**>
 * @version $Revision: 17657 $
 */
/* 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';
GalleryEmbed::getEmbedPathByHttpRequest();
 function gimage_thumb($photo_path, $params)
 {
     global $serendipity;
     $path_parts = pathinfo($photo_path);
     //The pathinfo funtion returns 'filename' from PHP 5.2 upwards, but until that has wide support, the below returns it too...
     if (strlen($path_parts["extension"]) > 0) {
         $path_parts['filename'] = substr($path_parts["basename"], 0, strlen($path_parts["basename"]) - (strlen($path_parts["extension"]) + 1));
     } else {
         $path_parts['filename'] = $path_parts["basename"];
     }
     $album = $path_parts['dirname'];
     $photo = $path_parts['filename'];
     $extension = $path_parts['extension'];
     $gallery_base = $this->get_config('gallery_base');
     $album_base = $this->get_config('album_base');
     $album_abs = $this->get_config('album_abs');
     $photo_ext = $extension ? "{$extension}" : "jpg";
     if ($this->get_config('gversion') == 2) {
         $album_base = $this->get_config('album_base') . "/albums";
     }
     // get popup max image size, default if not good.
     $popup_max = $this->get_config('popup_max');
     if ($popup_max < 100) {
         $popup_max = 640;
     }
     $paramlist = explode(";", $params);
     //split up the parameters
     $param_array = array();
     foreach ($paramlist as $parameter) {
         $temp = explode("=", $parameter);
         $param_array[trim(strtolower($temp[0]))] = trim($temp[1]);
     }
     if ($this->get_config('gversion') == 2) {
         $image = $album_abs . '/albums/' . $album . '/' . $photo . '.' . $photo_ext;
         $image_path = $serendipity['baseURL'] . ($serendipity['rewrite'] == "none" ? $serendipity['indexFile'] . "?/" : "/") . "plugin/g2wrapper?";
         $image_path .= "album=" . $album;
         $image_path .= "&amp;image=" . $photo;
         $image_path .= "&amp;ext=" . $photo_ext;
         //handle the parameters
         // size = thumb sized or full image?
         switch (strtolower($param_array['size'])) {
             case 'sized':
                 $image_path .= "&amp;size=sized";
                 break;
             case 'full':
                 $image_path .= "&amp;size=full";
                 break;
             case 'thumb':
             default:
                 $image_path .= "&amp;size=thumb";
                 break;
         }
     }
     //handle the parameters
     // size = thumb sized or full image?
     switch (strtolower($param_array['size'])) {
         case 'sized':
             $image_size = ".sized.";
             break;
         case 'full':
             $image_size = ".";
             break;
         case 'thumb':
         default:
             $image_size = ".thumb.";
             break;
     }
     // link = image, page, album, none?
     if ($this->get_config('gversion') == 2) {
         switch (strtolower($param_array['link'])) {
             case 'image':
                 $image_link = $serendipity['baseURL'] . ($serendipity['rewrite'] == "none" ? $serendipity['indexFile'] . "?/" : "/") . "plugin/g2wrapper?";
                 $image_link .= "album=" . $album;
                 $image_link .= "&amp;image=" . $photo;
                 $image_link .= "&amp;ext=" . $photo_ext;
                 $image_link .= "&amp;size=";
                 break;
             case 'image_sized':
                 $image_link = $serendipity['baseURL'] . ($serendipity['rewrite'] == "none" ? $serendipity['indexFile'] . "?/" : "/") . "plugin/g2wrapper?";
                 $image_link .= "album=" . $album;
                 $image_link .= "&amp;image=" . $photo;
                 $image_link .= "&amp;ext=" . $photo_ext;
                 $image_link .= "&amp;size=sized";
                 break;
             case 'album':
                 include_once $this->get_config('gallery_abs') . "/embed.php";
                 if (!class_exists('GalleryEmbed')) {
                     break;
                 }
                 $ret = GalleryEmbed::init(array('fullInit' => true, 'activeUserId' => ''));
                 if (is_object($ret) && $ret->isError()) {
                     echo $ret->getAsHtml();
                     exit;
                 }
                 $ret_aid = GalleryCoreApi::fetchItemIdByPath($album);
                 $album_id = is_array($ret_aid) && intval($ret_aid[1]) >= 1 ? intval($ret_aid[1]) : 0;
                 $image_link = $gallery_base . '/main.php?g2_view=core.ShowItem&amp;g2_itemId=' . $album_id;
                 break;
             case 'page':
             default:
                 include_once $this->get_config('gallery_abs') . "/embed.php";
                 if (!class_exists('GalleryEmbed')) {
                     break;
                 }
                 $ret = GalleryEmbed::init(array('fullInit' => true, 'activeUserId' => ''));
                 if (is_object($ret) && $ret->isError()) {
                     echo $ret->getAsHtml();
                     exit;
                 }
                 $ret_iid = GalleryCoreApi::fetchItemIdByPath($album . "/" . $photo . "." . $photo_ext);
                 $fullsize_id = is_array($ret_iid) && intval($ret_iid[1]) >= 1 ? intval($ret_iid[1]) : 0;
                 $image_link = $gallery_base . '/main.php?g2_view=core.ShowItem&amp;g2_itemId=' . $fullsize_id;
                 break;
         }
     } else {
         switch (strtolower($param_array['link'])) {
             case 'image':
                 $image_link = $album_base . '/' . $album . '/' . $photo . '.' . $photo_ext;
                 break;
             case 'image_sized':
                 $image_link = $album_base . '/' . $album . '/' . $photo . '.sized.' . $photo_ext;
                 break;
             case 'album':
                 $image_link = $gallery_base . '/view_album.php?set_albumName=' . $album;
                 break;
             case 'page':
             default:
                 $image_link = $gallery_base . '/view_photo.php?set_albumName=' . $album . '&amp;id=' . $photo;
                 break;
         }
     }
     if ($this->get_config('gversion') != 2) {
         // get thumbnail image attributes
         list($width, $height, $type, $attr) = getimagesize($album_base . '/' . $album . '/' . $photo . $image_size . $photo_ext);
     } else {
         $thissize = getimagesize($album_abs . '/albums/' . $album . '/' . $photo . "." . $photo_ext);
         if (strtolower($param_array['size']) == 'sized') {
             $newsize = $this->g2_imagesize($thissize[0], $thissize[1], $this->get_config('popup_max'));
             $width = $newsize[0];
             $height = $newsize[1];
             $attr = 'width="' . $width . '" height="' . $height . '"';
         } elseif (strtolower($param_array['size']) == 'thumb') {
             $newsize = $this->g2_imagesize($thissize[0], $thissize[1], $this->get_config('thumb_max'));
             $width = $newsize[0];
             $height = $newsize[1];
             $attr = 'width="' . $width . '" height="' . $height . '"';
         } else {
             list($width, $height, $type, $attr) = getimagesize($album_abs . "/albums/" . $album . "/" . $photo . "." . $photo_ext);
         }
     }
     // target=default|new|popup only allow popup for link=image and link-image_sized
     switch (strtolower($param_array['target'])) {
         case 'popup':
             if ($this->get_config('gversion') != 2) {
                 if (strtolower($param_array['link']) == 'image' || strtolower($param_array['link']) == 'image_sized') {
                     // get target image attributes
                     list($pwidth, $pheight, $ptype, $pattr) = getimagesize($image_link);
                     //work out popup image window size
                     if ($pwidth >= $pheight && $pwidth > $popup_max) {
                         $pwidth = $popup_max;
                         $pheight = round($popup_max * $height / $width);
                         //from thumbnail
                     } elseif ($pheight >= $pwidth && $pheight > $popup_max) {
                         $pheight = $popup_max;
                         $pwidth = round($popup_max * $width / $height);
                         //from thumbnail
                     }
                     //standard spacing for windows and title bars
                     $pwidth += 30;
                     $pheight += 50;
                     $link_target = '<a href="javascript:;" ';
                     $link_target .= ' onclick="w = window.open(';
                     $link_target .= "'" . $image_link . "', 'GImage Popup','width={$pwidth},height={$pheight},menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');";
                     $link_target .= 'w.resizeTo(' . $pwidth . ',' . $pheight . ')">';
                 } else {
                     $link_target = '<a href="' . $image_link . '">';
                 }
             } else {
                 $link_target = '<a href="' . $image_link . '">';
             }
             break;
         case 'new':
             $link_target = '<a href="' . $image_link . '" target="_blank">';
             break;
         case 'none':
             $link_target = '';
             break;
         case 'default':
         default:
             $link_target = '<a href="' . $image_link . '">';
             break;
     }
     // align = left, center, right? default center
     switch (strtolower($param_array['align'])) {
         case 'left':
             $div_align = 'left';
             $img_align = 'align=left';
             $img_pre = '';
             $img_post = '';
             break;
         case 'right':
             $div_align = 'right';
             $img_align = 'align=right';
             $img_pre = '';
             $img_post = '';
             break;
         case 'center':
             $div_align = 'center';
             $img_align = '';
             $img_pre = '<center>';
             $img_post = '</center>';
             break;
         case 'none':
         default:
             $div_align = 'center';
             $img_align = '';
             $img_pre = '';
             $img_post = '';
             break;
     }
     // caption = image alt text or caption
     if ($param_array['caption'] == "") {
         $param_array['caption'] = "[PHOTO]";
     }
     $param_array['caption'] = str_replace("\"", "", $param_array['caption']);
     $param_array['caption'] = str_replace("'", "", $param_array['caption']);
     $param_array['caption'] = str_replace("&quot;", "", $param_array['caption']);
     // style = link, image or fancy (s9y stylesheet image amanager style)?
     switch (strtolower($param_array['style'])) {
         case 'image':
             if ($this->get_config('gversion') == 2) {
                 $output = $img_pre . '<img ' . $img_align . ' src="' . $image_path . '" alt="' . $param_array['caption'] . '" />' . $img_post;
             } else {
                 $output = $img_pre . '<img ' . $img_align . ' src="' . $album_base . '/' . $album . '/' . $photo . $image_size . $photo_ext . '" alt="' . $param_array['caption'] . '" />' . $img_post;
             }
             break;
         case 'fancy':
             $output = '<div class="serendipity_imageComment_' . $div_align . '" style="width: ' . $width . 'px">';
             $output .= '<div class="serendipity_imageComment_img">';
             if ($this->get_config('gversion') == 2) {
                 $output .= $link_target . '<img src="' . $image_path . '" border="0" hspace="5" ' . $attr . ' /></a>';
             } else {
                 $output .= $link_target . '<img src="' . $album_base . '/' . $album . '/' . $photo . $image_size . $photo_ext . '" border="0" hspace="5" ' . $attr . ' /></a>';
             }
             $output .= '</div><div class="serendipity_imageComment_txt">' . $param_array['caption'] . '</div></div>';
             break;
         case 'link':
         default:
             if ($this->get_config('gversion') == 2) {
                 $output = $img_pre . $link_target . '<img ' . $img_align . ' src="' . $image_path . '" alt="' . $param_array['caption'] . '" /></a>' . $img_post;
             } else {
                 $output = $img_pre . $link_target . '<img ' . $img_align . ' src="' . $album_base . '/' . $album . '/' . $photo . $image_size . $photo_ext . '" alt="' . $param_array['caption'] . '" /></a>' . $img_post;
             }
             break;
     }
     return $output;
 }
Beispiel #11
0
      <h2>
        <a href="<?php 
generateUrl('index.php?import');
?>
">Import Database</a>
      </h2>
      <p class="description">
        Restore your Gallery database from an export that was made from the site administration
        maintenance screen or from the Database Backup step of the Gallery upgrader.
      </p>
      <hr class="faint" />

      <h2>
	<?php 
require_once '../../embed.php';
$ret = GalleryEmbed::init(array('fullInit' => false, 'noDatabase' => true));
/* Ignore error */
$url = GalleryUrlGenerator::appendParamsToUrl('../../' . GALLERY_MAIN_PHP, array('view' => 'core.UserAdmin', 'subView' => 'core.UserRecoverPasswordAdmin'));
?>
	<a href="<?php 
print $url;
?>
">Reset User Password</a>
      </h2>
      <p class="description">
	Set new password for any user.  Can be used to regain access to an administrator
	account when the "forgot password" feature cannot be used due to invalid/missing
	email address or other email problems.
      </p>
    </div>
  </body>
Beispiel #12
0
/**
 * Initialize the emedded functions of Gallery2
 *
 * Exit on Fatal Error
 *
 * @param array $option The GalleryEmbed options array
 * @param boolean $embedded_mode Whether to perform embedded GalleryEmbed init, or standalone init.
 */
function g2ic_init($option, $embedded_mode)
{
    // Initialise GalleryAPI
    if ($embedded_mode) {
        $error = GalleryEmbed::init(array('g2Uri' => $option['g2Uri'], 'embedUri' => $option['embedUri'], 'fullInit' => true));
    } else {
        $error = GalleryEmbed::init(array('g2Uri' => $option['g2Uri'], 'embedUri' => $option['g2Uri'], 'fullInit' => true));
    }
    if ($error) {
        print g2ic_make_html_header();
        print T_('<h3>Fatal Gallery2 error:</h3><br />Here\'s the error from G2:') . ' ' . $error->getAsHtml() . "\n";
        print "</body>\n\n";
        print "</html>";
        die;
    }
    return;
}
Beispiel #13
0
 /**
  * Builds the generic initialization of the Gallery2 integration
  * @return status object
  */
 private function initGalleryApi()
 {
     global $logger;
     //$logger->debug(get_class($this) . "::initGalleryApi()");
     $emAppUserId = 'embed';
     $ret = GalleryEmbed::init(array('activeUserId' => $emAppUserId, 'fullInit' => true));
     if ($ret) {
         print "An error occurred when initing<br>";
         print $ret->getAsHtml();
         exit;
     }
     $this->init = true;
 }
 function loadG2()
 {
     global $serendipity;
     if ($this->isG2Loaded === false) {
         require_once $this->get_config('g2dir') . 'embed.php';
         $ret = GalleryEmbed::init(array('g2Uri' => $this->get_config('g2uri'), 'embedUri' => $this->get_config('embedUri'), 'gallerySessionId' => $_COOKIE['PHPSESSID']));
         GalleryCapabilities::set('login', true);
         // handle the G2 request
         $this->g2moddata = GalleryEmbed::handleRequest();
         // show error message if isDone is not defined
         if (!isset($this->g2moddata['isDone'])) {
             print 'isDone is not defined, something very bad must have happened.';
             exit;
         }
         // die if it was a binary data (image) request
         if ($this->g2moddata['isDone']) {
             exit;
             /* uploads module does this too */
         }
         $this->isG2Loaded = true;
     }
 }