Hi all
Below is the entry point file i am using for embedding the gallery2 to my application
<?php
require_once(dirname(__File__) . '/../../gallery2/embed.php');
session_start();
if(isset($_SESSION['user_id']))
{
 $uid = $_SESSION['user_id'];
}
else
{
 $uid='';
}
//echo $uid;
$ret = GalleryEmbed::init(array('embedUri'=>'http://mysite.com/framework/albums/Albums.php','g2Uri'=>'http://mysite.com/gallery2/', 'loginRedirect'=>'/framework/','activeUserId' => $uid));
if($ret)
{
 echo($ret->getAsHtml());
 exit;
}
//print_r($_SESSION);
//echo $_SESSION['user_id'];
if(isset($_SESSION['user_id'])){
 //echo "calling login user id ".$_SESSION['user_id'];
 $ret = getUserLogin($_SESSION['user_id']);
 //print_r($ret);
 //die();
}
$header = '<head><link href="style.css" rel="stylesheet" type="text/css" /></head>';
//die();
$request = $_GET['view'];
if(isset($request) && strcasecmp($request,'userAlbum') == 0)
{
 getUserAlbum(null);
}
if(isset($request) && strcasecmp($request,'mostviewd') == 0)
{
 show_mostviewed_imageblock();
}
if(isset($request) && strcasecmp($request,'recentalbum') == 0)
{
 show_recent_imageblock();
}
if(isset($request) && strcasecmp($request,'randomimage') == 0)
{
 show_random_imageblock();
}
$g2data = GalleryEmbed::handleRequest();
$ret = GalleryEmbed::done();
$resp = array();
if(isset($g2data) && !($g2data['isDone']))
{
 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
 echo '<html xmlns="http://www.w3.org/1999/xhtml">';
 echo($g2data['headHtml']);
 echo($g2data['bodyHtml']);
 echo '</html>';
}
function login($user_ID)
{
 //echo "";
 $ret = GalleryEmbed::isExternalIdMapped($user_ID, 'GalleryUser');
 $ret1 = GalleryEmbed::checkActiveUser($user_ID);
 return $ret;
}
function getUserAlbum($userid='')
{
 //session_start();
 $userid = isset($userid)?$userid:$_SESSION['user_id'];
 if($userid=="")
 {
  $location = "/rang/framework/?achain=loginChain&redirect_to=/rang/framework/albums/Albums.php?view=useralbum";
  header("Location: $location");
 }
 $ret = login($userid);
 //$ret = 1;
 if (!$ret) {
  list ($ret, $user) = GalleryCoreApi::loadEntityByExternalId($userid, 'GalleryUser');
 }
 list ($ret, $albumId) =
 GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $user->getId());
 if ($ret) {
  //error condition
  echo "error in getting user album id";
 }
 $_GET['g2_itemId'] = $albumId;
}
function getUserLogin($userid)
{
 $ret = login($userid);
 //$ret = 1;
 if (!$ret) {
  list ($ret, $user) = GalleryCoreApi::loadEntityByExternalId($userid, 'GalleryUser');
 }
 list ($ret, $albumId) =
 GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $user->getId());
 if ($ret) {
  //error condition
  echo "error in getting user album id";
 }
}
function show_random_imageblock()
{
 list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomAlbum|randomAlbum|randomAlbum|randomAlbum',
                                                                 'show' => 'title|date|owner','albumFrame' =>'whiteborder','maxSize'=>'64'));
  if ($ret) {
      print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
      exit;
  }
 /* $bodyHtml contains the image block. print it somewhere on your website */
  printheaders();
  print_r($headHtml);
  print_r($bodyHtml);
  printfooters();
  die();
// exit;
}
function show_mostviewed_imageblock()
{
 list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'viewedAlbum|viewedAlbum|viewedAlbum|viewedAlbum',
                                                                 'show' => 'title|views|owner','albumFrame' =>'whiteborder','maxSize'=>'64'));
  if ($ret) {
      print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
      exit;
  }
 /* $bodyHtml contains the image block. print it somewhere on your website */
  printheaders();
  print_r($headHtml);
  print_r($bodyHtml);
  printfooters();
  die();
}
function show_recent_imageblock()
{
 list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'recentAlbum|recentAlbum|recentAlbum|recentAlbum',
                                                                 'show' => 'title|date|owner','albumFrame' =>'whiteborder','maxSize'=>'64'));
 print $headHtml;
  if ($ret) {
      print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
      exit;
  }
 /* $bodyHtml contains the image block. print it somewhere on your website */
  printheaders();
  print_r($bodyHtml);
  printfooters();
  die();
}
function printheaders()
{
 print('<link href="style.css" rel="stylesheet" type="text/css" />');
  print('<head><base target="_top"></head><style type="text/css"> .style34 {color: #677a28;font-weight: bold;font-size: 10px;}  .style5 {font-family:Verdana, Arial, Helvetica, sans-serif;font-size: 10px} body { margin-left:0px;margin-top:0px;margin-right:0px; } </style><body>');
} 
function printfooters()
{
 print('</body>');
}
?>
My problems is, when i try to upload a picture for the first time, it allows me to do so but not for the second time. Also really strange that everything starts working as soon as i type an echo in the above file
Posts: 32509
is this a duplicate topic of http://gallery.menalto.com/node/73199 ?
if so, please one of them / add a message that it's discussed in the other one.