Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 863b117

Browse files
committed
Began adding tar.gz capabilities
1 parent 9956b93 commit 863b117

File tree

4 files changed

+2492
-1
lines changed

4 files changed

+2492
-1
lines changed

classes/class.import.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @author Jared Howland <[email protected]@gmail.com>
66
* @version 2013-02-23
77
*/
8+
9+
require_once 'lib/Archive_Tar/Archive/Tar.php';
810

911
class import {
1012
/**
@@ -18,7 +20,10 @@ class import {
1820
public function upload( $resource_id, $frequency, $num_records, $file ) {
1921
$filename = $resource_id . '.xml';
2022
$tmp_name = $file['marc_records']['tmp_name'];
21-
if (move_uploaded_file($tmp_name, config::UPLOAD_DIRECTORY . '/' . $filename)) {
23+
if(move_uploaded_file($tmp_name, config::UPLOAD_DIRECTORY . '/' . $filename)) {
24+
$tar = new Archive_Tar(config::UPLOAD_DIRECTORY . '/' . $filename . '.tar.gz', 'gz');
25+
$files = array($filename);
26+
$compressed_tar = $tar->create($files) or die('Could not create archive. Please go back and try again.');
2227
$today = date('Y-m-d');
2328
switch ($frequency) {
2429
case 'Once':

download.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Compress and download all files
4+
*
5+
* @author Jared Howland <[email protected]>
6+
* @version 2013-03-04
7+
* @since 2013-03-04
8+
*
9+
*/
10+
require_once 'config.php';
11+
require_once 'lib/Archive_Tar/Archive/Tar.php';
12+
13+
$database = new db;
14+
$db = $database->connect();
15+
$sql = 'SELECT id, load_records, file_exists FROM records WHERE load_records = "Y" AND file_exists = "Y"';
16+
$query = $db->prepare($sql);
17+
$query->execute();
18+
$marc_record_loads = $query->fetchAll(PDO::FETCH_ASSOC);
19+
$db = null;
20+
21+
$tar = new Archive_Tar(config::UPLOAD_DIRECTORY . '/ALL.tar.gz', 'gz');
22+
$files = array();
23+
foreach($marc_record_loads as $resource) {
24+
$resource_id = $resource['id'];
25+
$filename = $resource_id . '.xml';
26+
$files[] = $filename;
27+
}
28+
29+
// $files = array($filename);
30+
$compressed_tar = $tar->create($files) or die('Could not create archive. Please go back and try again.');
31+
32+
?>

0 commit comments

Comments
 (0)