1
0

added redirect for sized+thumbs and hotfix for buggy dat files

This commit is contained in:
Thomas E. Horner 2012-12-29 10:34:51 +01:00
parent eff3c7835b
commit bd9a5e38bf
2 changed files with 20 additions and 7 deletions

View File

@ -51,7 +51,7 @@ class G1_Controller extends Controller {
$pos = strrpos($path, '/');
if($pos!==false) {
// Get ItemX into g1_item
$g1_item = substr($path,$pos+1);
$g1_item = substr($path,$pos+1,strlen($path));
// Get FolderX into g1_item
$g1_album = substr($path,0,$pos);
}
@ -69,7 +69,12 @@ class G1_Controller extends Controller {
$g1_item = substr($g1_item, 0, $pos);
}
$mapping = ORM::factory('g1_map')->where('album', '=', $g1_album)->where('item', '=', $g1_item)->where('resource_type', '=', $album ? 'album':'item')->find();
if(($pos=strrpos($g1_item, '.sized'))!==false||($pos=strrpos($g1_item, '.thumb'))!==false) {
$mapping = ORM::factory('g1_map')->where('album', '=', $g1_album)->where('item', '=', substr($g1_item,0, $pos))->where('resource_type', '=', $album ? 'album':'item')->find();
}
else {
$mapping = ORM::factory('g1_map')->where('album', '=', $g1_album)->where('item', '=', $g1_item)->where('resource_type', '=', $album ? 'album':'item')->find();
}
if(!$mapping->loaded()) {
throw new Kohana_404_Exception();
}
@ -80,7 +85,15 @@ class G1_Controller extends Controller {
access::required('view', $item);
if($binary) {
url::redirect($item->file_url(true), '301');
if(strrpos($g1_item, '.sized')!==false) {
url::redirect($item->resize_url(true), '301');
}
else if(strrpos($g1_item, '.thumb')!==false) {
url::redirect($item->thumb_url(true), '301');
}
else {
url::redirect($item->file_url(true), '301');
}
}
else {
$url = $item->abs_url();

View File

@ -74,16 +74,16 @@ class Gallery1DataParser {
* We renamed User.php to Gallery_User.php in v1.2, so port forward
* any saved user objects.
*/
if (!strcmp(substr($tmp, 0, 10), 'O:4:"user"')) {
$tmp = str_replace('O:4:"user"', 'O:12:"gallery_user"', $tmp);
if (stripos($tmp, 'O:4:"user"')!==false) {
$tmp = str_ireplace('O:4:"user"', 'O:12:"gallery_user"', $tmp);
}
/*
* Gallery3 already contains a class named Image so
* we need to rename the G1 Image class to G1Img here
*/
if (strpos($tmp, 'O:5:"Image"')!==false) {
$tmp = str_replace('O:5:"Image"', 'O:5:"G1Img"', $tmp);
if (stripos($tmp, 'O:5:"image"')!==false) {
$tmp = str_ireplace('O:5:"image"', 'O:5:"G1Img"', $tmp);
}
$object = unserialize($tmp);