Login redirection problems after server change
cowmoo
Joined: 2007-07-18
Posts: 20 |
Posted: Thu, 2007-11-15 01:09 |
Hey again, The script redirects here after login (split over 3 lines for readability): I want it to redirect here: the code for my script (main_wrapper.php): <?php $db = mysql_connect("www.example.com:4406","dbuser","dbpass") or die("Unable to connect to Server."); mysql_select_db("database",$db) or die( "Unable to select database."); $sql = "SELECT blah FROM blah WHERE blah"; $res = mysql_query($sql, $db) or die(mysql_error); $row = mysql_fetch_assoc($res); if($row) { $data = runGallery($row['blah'], $row['blah'], $row['blah']); $data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery'; if (isset($data['bodyHtml'])) { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html> <head> <title>{$data['title']}</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"> {$data['javascript']} {$data['css']} </head> <body> {$data['bodyHtml']} </body> </html>"; } } else { print "You must have an account with XXXXX to use this feature"; } function runGallery($firstName, $lastName, $contactEmail) { require_once('./embed.php'); $data = array(); // if anonymous user, set g2 activeUser to '' $uid = $_GET['u']; $upass = $_GET['p']; // initiate G2 $ret = GalleryEmbed::init(array('g2Uri' => 'www.example.com/', 'embedUri' => '/main.php', 'activeUserId' => $uid)); if ($ret && $ret->getErrorCode() & ERROR_MISSING_OBJECT) { /* The user does not exist in G2 yet. Create in now on-the-fly */ $ret = GalleryEmbed::createUser($uid, array('username' => $uid, 'email' => $contactEmail, 'fullname' => $firstName." ".$lastName, 'hashedpassword' => $upass, 'hashmethod' => 'md5')); if ($ret) { /* An error during user creation. Not good, print an error or do whatever is appropriate * in your emApp when an error occurs */ print "An error occurred during the on-the-fly user creation <br>"; /* add mails in to inform me when errors occour */ print $ret->getAsHtml(); exit; } } elseif ($ret) { /* The error we got wasn't due to a missing user, it was a real error */ if ($ret) { print "An error occurred while checking if a user already exists<br>"; print $ret->getAsHtml(); } print "An error occurred while trying to initialize G2<br>"; print $ret->getAsHtml(); exit; } /* locking the user to disallow changing of details through gallery */ list ($ret, $user) = GalleryCoreApi::loadEntityByExternalId($uid, 'GalleryUser'); if($ret) { print "An error occurred while loading the user object<br>"; print $ret->getAsHtml(); } else { list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($user->getId()); if($ret) { print "An error occurred while loading the user object<br>"; print $ret->getAsHtml(); } else { $user->setLocked(true); $user->save(); } } GalleryCoreApi::releaseLocks($lockId); if ($ret) { $data['bodyHtml'] = $ret->getAsHtml(); return $data; } // BEGIN ALBUM REDIRECT STUFF // Before initializing the user session, let's get the user's default album: // First return array with all Gallery user data in Guser list ($ret, $user) = GalleryCoreApi::fetchUserByUsername('admin'); if ($ret && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) { $data[error] = "An error occurred <br>"; $data[error] .= $ret->getAsHtml(); return $data; } // Now return the user's default albumID list ($ret, $userAlbumID) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $user->getId()); if ($ret) { $data[error] = "An error occurred <br>"; $data[error] .= $ret->getAsHtml(); return $data; } //Now set the default userAlbumID $gallery->setConfig('defaultAlbumId', intval($userAlbumID)); $gallery->setConfig('breadcrumbRootId', intval($userAlbumID)); // END ALBUM REDIRECT STUFF // user interface: you could disable sidebar in G2 and get it as separate HTML to put it into a block // GalleryCapabilities::set('showSidebarBlocks', false); GalleryEmbed::checkActiveUser($uid); // handle the G2 request $g2moddata = GalleryEmbed::handleRequest(); // show error message if isDone is not defined if (!isset($g2moddata['isDone'])) { $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.'; return $data; } // exit if it was an immediate view / request (G2 already outputted some data) if ($g2moddata['isDone']) { exit; } // put the body html from G2 into the xaraya template $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : ''; // get the page title, javascript and css links from the <head> html from G2 $title = ''; $javascript = array(); $css = array(); if (isset($g2moddata['headHtml'])) { list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']); $data['headHtml'] = $g2moddata['headHtml']; } /* Add G2 javascript */ $data['javascript'] = ''; if (!empty($javascript)) { foreach ($javascript as $script) { $data['javascript'] .= "\n".$script; } } /* Add G2 css */ $data['css'] = ''; if (!empty($css)) { foreach ($css as $style) { $data['css'] .= "\n".$style; } } // sidebar block if (isset($g2moddata['sidebarBlocksHtml']) && !empty($g2moddata['sidebarBlocksHtml'])) { $data['sidebarHtml'] = $g2moddata['sidebarBlocksHtml']; } return $data; } ?>
* the URL to your Gallery (seeing the problem is very helpful). Anyone know what might be going on here? Thanks in advance, |
|
Posts: 20
Anyone got any ideas? I honestly can't work out why this is happening. I've never seen a redirect to that page before, and can't see where it's happening.
Posts: 20
Sorry bout the pics everyone, but can't give access to my gallery, it's the best I can do atm, ask if you would like to see any of the source.
I have still got nowhere with this, currently my script logs user in, but redirects to the following page:
[img]http://images.frozenbear.com:9090/i/picfu0/2007/11/19/17/1/5/a/15a3621c4006998ea1443495d33514350_main.jpg[/img]
As you can see, there are a few problems there.
Aswell as the problems shown in the pic, there is also some extra whitespace around the entire site, and the url still points to the wrapper file instead of main.php.
I would like my script to create / login user then pass info to gallery, then load gallery as normal (not embedding etc).
Also with the problems in that pic, gallery seems to think that the users album is the root album for some reason (might be wrong here).
If you click on the 'Your album' link, it will take you to the root album, seen here:
[img]http://images.frozenbear.com:9090/i/picfu0/2007/11/19/17/e/f/e/efe1277b176d89bb037b99a5baf6e6900_main.jpg[/img]
Everything on this page appears properly, however the link should've taken them to their own album, not the root album.
just for reference, here is where I want the user to be taken straight from login:
[img]http://images.frozenbear.com:9090/i/picfu0/2007/11/19/17/0/3/3/033b9f282b061030ba2293e797c4016a0_main.jpg[/img]
Any help would be greatly appreciated, I just need to know where this is happening.
Thanks
cOwMoO