The 1.8.5 preview does now support canonical URLs

Hi,

The 1.8.5 preview does now support canonical URLs.

This means that there is an additional attribute in the header that tells search engines that e.g.

http://www.tinywebgallery.com/demo/index.php?twg_album=01_Administration&twg_show=Administration+Help+Screen.gif

and

http://www.tinywebgallery.com/demo/index.php?twg_album=01_Administration&twg_show=Administration+Help+Screen.gif&twg_rot=90&twg_zs=1301827018

are the same page!

This is important to avoid duplicate content on your site. I have this now running at the demo and will check in the webmaster tools of google how this works :).

More info about this: http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066

Have fun using TWG,

Michael

TWG 1.8.5 preview is in the forum!

Hi,

I have already started with TWG 1.8.5 and one of the main features is that folder.txt and foldername.txt can be edited in the front end.
I have implemented this already and the reason why this is available is that new translations are needed as well.
Additionally some small fixes are included.
So if you can help with the translation or want to use this new feature you can already use 1.8.5. But be aware that in the final a lot of more stuff will come.

For details and the download please go here:

http://www.tinywebgallery.com/forum/viewtopic.php?f=14&t=2944&start=0

Have fun using TWG,

Michael

Website was refactored

Hi,

The website was refactored. It still looks the same but I removed most of the duplicate content.

I had english content under the /de part as well.

So if you have any bookmarks this are not working anymore please update them.

Best,

Michael

TWG 1.8.4.1 is online

Hi,

Some minor bugfixes which makes TWG 1.8.4.1 even nicer ;).

New: The default for $direct_folderpng was chaged to true. This gives better performance because no php calls are needed. Special characters in the path are not supported. If you have this set this to false again.
New: $direct_folderpng is now used for private.png as well. It has the same performance impact and restrictions as folder.png.
Fix: I updated the flash thumbnailer. There where some undefined strings in the url which where not right. It should not change anything but the requests are now correct.
Fix: I added the new zip class I made to TWG itself. I also updated TFU 2.13 to the latest version where this zip class was included first.
Fix: removed the duplicate zip class from the admin/upload folder. One was from TFU, one from TWG. I only use the one from TFU here.
Fix: Some smilies where not displayed properly because I was sorting the file names but not the display names.

The official version is still 1.8.4. the .1 is the internal build. Always look in version.txt to see the latest changes.

I’m now working on TWG 1.8.5.

have fun using TWG,

Michael

Fix for optimized php zip class that now works on windows and mac

Hi,

I was using the php zip class of Rochak Chauhan for a while but because of the high memory usage I switched to an optimized version of this class from ironhawk.

Unfortunately both implementations where creating zip files that where not working properly on mac. I compared the implementations against some other classes and found out that a section what printed twice which causes mac to fail.
the other zip implementation also where using proper time stamps and I merged this two implementation and added some stuff I needed. So the code below has the following differences to the original implementations:

  • The created zip files where not working on Mac. Now they do. A couple of elements where added twice!
  • It also does not require php 5 anymore. It works also fine on php 4.
  • Compression can be turned off to get more speed if this is important for you.
  • I also added the patch from Peter Listiak <mlady@users.sourceforge.net> for last modified date and time of the compressed file.

The code I used is based on an older class then the one currently published on phpclasses.org. The newer one do also contain directory functions. You would have to merge this if you need them.

You can download the example below here:  zip_class.zip


<?php
/**
* Original source was created by Rochak Chauhan, www.rochakchauhan.com.
* But it used a lot of memory so it was modified.
* The original code kept the continuesly growing .zip stream in memory and in addition
* adding a new file to the stream required filesize*4 bytes.

* Now the growing .zip stream is not kept in memory, it is written to the file continuesly.
* Adding a new file to the .zip requires filesize*2 bytes of memory.
* Plus some more memory required to store the .zip entries -
* this is written only at the end of the process.
*
* 20.2.2011: Fixed by Michael Dempfle (www.tinywebgallery.com).
*            - The created zip files do now work on Mac.
*            - It also does not require php 5 anymore. It works also fine on php 4.
*            - Compression can be turned off to get more speed if this is important for you.
*            - I also added the patch from Peter Listiak <mlady@users.sourceforge.net>
*              for last modified date and time of the compressed file.
*
* This code based on an older class then the one currently published on phpclasses.org.
* The newer one do also contain
* directory functions. You would have to merge this if you need them.
*
* @author ironhawk, Rochak Chauhan  www.rochakchauhan.com
* @package zip
*/
class ZipFile {

var $centralDirectory = array(); // central directory
var $endOfCentralDirectory = "x50x4bx05x06x00x00x00x00"; //end of Central directory record
var $oldOffset = 0;

var $fileHandle;
var $compressedDataLength = 0;

function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0; }
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
}

/**
* Creates a new ZipFile object
*
* @param resource $_fileHandle file resource opened using fopen() with "w+" mode
* @return ZipFile
*/
function ZipFile($_fileHandle)
{
$this->fileHandle = $_fileHandle;
}

/**
* Adds a new file to the .zip in the specified .zip folder - previously created using addDirectory()!
*
* @param string $directoryName full path of the previously created .zip folder the file is inserted into
* @param string $filePath full file path on the disk
* @return void
*/
function addFile($filePath, $directoryName, $doCompress = true)   {

// reading content into memory
$data = file_get_contents($filePath);

// adding the time
$time = 0;
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = 'x' . $dtime[6] . $dtime[7] . 'x' . $dtime[4] . $dtime[5] . 'x' . $dtime[2] . $dtime[3] . 'x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');

// create some descriptors
$directoryName = str_replace("", "/", $directoryName);
$feedArrayRow = "x50x4bx03x04";
$feedArrayRow .= "x14x00";
$feedArrayRow .= "x00x00";
$feedArrayRow .= "x08x00";
$feedArrayRow .= $hexdtime;
$uncompressedLength = strlen($data);

// compression of the data
$compression = crc32($data);
// at this point filesize*2 memory is required for a moment but it will be released immediatelly
// once the compression itself done
// compression does not work with mac - I use the compression only to download multiple file so I skip it!
if ($doCompress) {
$data = gzcompress($data);
}
// manipulations
$data = substr($data, 2, strlen($data) - 6);

// writing some info
$compressedLength = strlen($data);
// Compression does not work with mac
if ($doCompress) {
$feedArrayRow .= pack("V",$compression);
$feedArrayRow .= pack("V",$compressedLength);
$feedArrayRow .= pack("V",$uncompressedLength);
}
$feedArrayRow .= pack("v", strlen($directoryName) );
$feedArrayRow .= pack("v", 0 );
$feedArrayRow .= $directoryName;
fwrite($this->fileHandle, $feedArrayRow);
$this->compressedDataLength += strlen($feedArrayRow);

// writing out the compressed content
fwrite($this->fileHandle, $data);
$this->compressedDataLength += $compressedLength;

// some more info...
// The part below cause the mac to fail!
//   $feedArrayRow = pack("V",$compression);
//   $feedArrayRow .= pack("V",$compressedLength);
//   $feedArrayRow .= pack("V",$uncompressedLength);
//fwrite($this->fileHandle, $feedArrayRow);
//$this->compressedDataLength += strlen($feedArrayRow);
$newOffset = $this->compressedDataLength;

// adding entry
$addCentralRecord = "x50x4bx01x02";
$addCentralRecord .="x00x00";
$addCentralRecord .="x14x00";
$addCentralRecord .="x00x00";
$addCentralRecord .="x08x00";
$addCentralRecord .= $hexdtime;
$addCentralRecord .= pack("V",$compression);
$addCentralRecord .= pack("V",$compressedLength);
$addCentralRecord .= pack("V",$uncompressedLength);
$addCentralRecord .= pack("v", strlen($directoryName) );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("V", 32 );
$addCentralRecord .= pack("V", $this->oldOffset );
$this->oldOffset = $newOffset;
$addCentralRecord .= $directoryName;
$this->centralDirectory[] = $addCentralRecord;

}

/**
* Close the .zip - we do not add more stuff
*
* @param boolean $closeFileHandle if true the file resource will be closed too
*/
function close($closeFileHandle = true) {

$controlDirectory = implode("", $this->centralDirectory);

fwrite($this->fileHandle, $controlDirectory);
fwrite($this->fileHandle, $this->endOfCentralDirectory);
fwrite($this->fileHandle, pack("v", sizeof($this->centralDirectory)));
fwrite($this->fileHandle, pack("v", sizeof($this->centralDirectory)));
fwrite($this->fileHandle, pack("V", strlen($controlDirectory)));
fwrite($this->fileHandle, pack("V", $this->compressedDataLength));
fwrite($this->fileHandle, "x00x00");

if($closeFileHandle)
fclose($this->fileHandle);
}
}
?>

The usage is really simple:


<?php
/**
*  Example how to create the zip.
*
*  Thanks to Rochak Chauhan for the initial implementation and
*  Attila Wind for the memory optimization.
*  I only fixed and extended the class. So the main credits goes to the guys above.
*
*  The TWG Flash Uploader is using this class as well.
*
* 20.2.2011: Fixed by Michael Dempfle (www.tinywebgallery.com).
*            - The created zip files where not working on Mac. Now they do. A couple of elements where added twice!
*            - It also does not require php 5 anymore. It works also fine on php 4.
*            - Compression can be turned off to get more speed if this is important for you.
*            - I also added the patch from Peter Listiak <mlady@users.sourceforge.net>
*              for last modified date and time of the compressed file.
*
*/

include("zip.class.php");
$fileonserver = "filename.txt";
$filename = "example.zip";
$fd = fopen ($filename, "wb");
$createZip = new ZipFile($fd);
$createZip -> addFile($fileonserver, $fileonserver, true);
$createZip -> close();

?>

This new zip class is also included in TFU 2.13.

Hope this helps someone ;).

Have fun using TFU,

Michael