Genesis Posted January 5, 2010 Report Share Posted January 5, 2010 Sveiki, gribējās zināt no pieredzējušākiem lietotājiem par to no kuras php versijas dabojas zipa funkcijas. Nu ir tā ka uzliku lapu uz servera kurai ir php 5.04 un principā nestrādā - izsaucu funkciju un viss apstājas... pat erorus neuzmet. Tāpēc kur ir vaina - kodā vai arī php versijā (ieks php info rādija ka zips ir un ir enablots). if (isset($_POST['dw'])) { $gallery=$_POST['id']; $results = mysql_fetch_assoc(mysql_query("SELECT * FROM gallerys WHERE path='{$gallery}'")); $gallery_name=$results['gallery_name']; $result = mysql_query("SELECT * FROM pictures WHERE galleryID='{$gallery}'"); $masivs=array(); while($row=mysql_fetch_assoc($result)) { $masivs[] = 'Gallerys/'.$gallery.'/'.$row['picture_name']; } $url=curPageURL(); $gallery_name = zip_filename($gallery_name); if (create_zip($masivs, 'Gallerys/'.$gallery.'/'.$gallery_name.'.zip', true)) { $file='Gallerys/'.$gallery.'/'.$gallery_name.'.zip'; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); $url=curPageURL(); redirect_to($url); } else { redirect_to("index.php"); } } function create_zip($files,$destination,$overwrite) { if(file_exists($destination) && !$overwrite) { return false; } $valid_files = array(); if(is_array($files)) { foreach($files as $file) { if(file_exists($file)) { $valid_files[] = $file; } } } if(count($valid_files)) { $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } foreach($valid_files as $file) { $zip->addFile($file,basename($file)); } $zip->close(); return file_exists($destination); } else { return false; } } Quote Link to comment Share on other sites More sharing options...
gurkjis Posted January 5, 2010 Report Share Posted January 5, 2010 php zip installation zip extensions ir pieejams jau kopš PHP 4, bet tev laikam nav ieslēgts/iekompilēts tas. paskaties, ko atgriež var_dump(function_exists('zip_open')); ja false, tad jāskatās,kā ieslēgt zip ext. Quote Link to comment Share on other sites More sharing options...
Genesis Posted January 5, 2010 Author Report Share Posted January 5, 2010 atgrieza bool(false) :) Quote Link to comment Share on other sites More sharing options...
briedis Posted January 5, 2010 Report Share Posted January 5, 2010 atgrieza bool(false) :) Ja tas ir tavs serveris, meklē php.ini failu un atkomentē attiecīgo extensionu. Ja tas ir hostinga firmas - sūti ziņu admiņiem, lai pieslēdz atteicīgo exteniosnu.. Quote Link to comment Share on other sites More sharing options...
Genesis Posted January 5, 2010 Author Report Share Posted January 5, 2010 nav mans serveris, tapec jau padevu zinu.. :) Quote Link to comment Share on other sites More sharing options...
gurkjis Posted January 5, 2010 Report Share Posted January 5, 2010 Gadījumā, ja admini negrib slēgt klāt extensionu, tad var izlīdzēties ar php zip bibliotēku, kas ir vienkārši lietojama. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.