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; }
/** * 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; }
/** * 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; }
/** * 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"; }
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'])); $descriptionsize = strlen(trim($row_tb[$storeConfig['columnPrefix'] . 'description']));
<?php require_once '../kernel/setup_inc.php'; if (!file_exists('embed.php')) { $lines = file("README."); foreach ($lines as $lineno => $line) { echo htmlspecialchars($line) . "<br />\n"; } } else { require_once 'embed.php'; $activeUserId = $gBitUser->isRegistered() ? $gBitUser->mUserId : NULL; $status = GalleryEmbed::init(array('embedUri' => 'index.php', 'relativeG2Path' => '', 'loginRedirect' => '/users/login.php', 'activeUserId' => $activeUserId)); $gallerySessionId = GalleryEmbed::getSessionId(); //print " $status = GalleryEmbed::init( array( 'embedUri' => 'index.php', 'relativeG2Path' => '', 'loginRedirect' => '/users/login.php', 'activeUserId' => $activeUserId ))"; if ($status->isError()) { if ($status->getErrorCode() & ERROR_MISSING_OBJECT) { //vd( $gBitUser->mUserId ); //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 {
$count++; } else { $status[] = array('error', "Error removing {$path}{$filename}"); } } } closedir($fd); } $status[] = array('info', "Removed {$count} install/upgrade log files"); return $status; } $status = array(); $caches = getCaches(); if (isset($_REQUEST['clear']) && isset($_REQUEST['target'])) { require_once dirname(__FILE__) . '/../../embed.php'; $ret = GalleryEmbed::init(array('fullInit' => false)); if ($ret) { /* Try to swallow the error, but define a session to make ::done() pass. */ 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));
<? $modid = 8; $intro_id = 64; include("AMP/BaseDB.php"); require_once('gallery2/embed.php'); // initiate G2 GalleryEmbed::init(array('embedUri' => 'gallery2.php', 'embedPath' => '/', 'relativeG2Path' => 'gallery2')); // user interface: you could disable sidebar in G2 and get it as separate HTML to put it into a block GalleryCapabilities::set('showSidebarBlocks', false); // handle the G2 request $g2moddata = GalleryEmbed::handleRequest(); $dbcon=&_Registry::getDbcon(); $dbcon->SetFetchMode("ADODB_FETCH_ASSOC"); include("AMP/BaseTemplate.php"); print $g2moddata['headHtml']; print $g2moddata['bodyHtml']; #print_r ($g2moddata['sidebarBlocksHtml']); include("AMP/BaseFooter.php"); ?>
/** * <b>****************************************** Global ***********************************************</b><br /> * Include Gloabl File.<br /> * */ require "_global.php"; switch ($_GET['tempid']) { case "gallery": define("MOS_GALLERY2_PARAMS_RELATIVEG2PATH", "gallery2"); define("MOS_GALLERY2_PARAMS_EMBEDURI", "database.php?mandant=" . $mandant['mandant_id'] . "&tempid=gallery" . $url_und_sid); define("MOS_GALLERY2_PARAMS_LOGINREDIRECT", "database.php?mandant=2&tempid=gallery" . $url_und_sid); define("MOS_GALLERY2_PARAMS_DISPLAYSIDEBAR", 1); define("MOS_GALLERY2_PARAMS_DISPLAYLOGIN", 1); define("MOS_GALLERY2_PARAMS_EMBEDPATH", ""); require_once MOS_GALLERY2_PARAMS_PATH . 'embed.php'; $ret = GalleryEmbed::init(array('embedUri' => MOS_GALLERY2_PARAMS_EMBEDURI, 'embedPath' => MOS_GALLERY2_PARAMS_EMBEDPATH, 'relativeG2Path' => MOS_GALLERY2_PARAMS_RELATIVEG2PATH, 'loginRedirect' => MOS_GALLERY2_PARAMS_LOGINREDIRECT, 'activeUserId' => '0')); if (MOS_GALLERY2_PARAMS_DISPLAYSIDEBAR == 0) { GalleryCapabilities::set('showSidebar', false); } else { GalleryCapabilities::set('showSidebar', true); } if (MOS_GALLERY2_PARAMS_DISPLAYLOGIN == 0) { GalleryCapabilities::set('login', false); } else { GalleryCapabilities::set('login', true); } // handle the G2 request $g2moddata = GalleryEmbed::handleRequest(); // show error message if isDone is not defined if (!isset($g2moddata['isDone'])) { echo 'isDone is not defined, something very bad must have happened.';
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 .= "&image=" . $photo; $image_path .= "&ext=" . $photo_ext; //handle the parameters // size = thumb sized or full image? switch (strtolower($param_array['size'])) { case 'sized': $image_path .= "&size=sized"; break; case 'full': $image_path .= "&size=full"; break; case 'thumb': default: $image_path .= "&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 .= "&image=" . $photo; $image_link .= "&ext=" . $photo_ext; $image_link .= "&size="; break; case 'image_sized': $image_link = $serendipity['baseURL'] . ($serendipity['rewrite'] == "none" ? $serendipity['indexFile'] . "?/" : "/") . "plugin/g2wrapper?"; $image_link .= "album=" . $album; $image_link .= "&image=" . $photo; $image_link .= "&ext=" . $photo_ext; $image_link .= "&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&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&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 . '&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(""", "", $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; }
<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>
/** * 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; }
/** * 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; } }