if ($meta->name == 'EXIF.ExifVersion') {
            $metaalreadyset = true;
            break;
        }
    }
    if ($metaalreadyset === true) {
        $time = '[' . date('c') . ']';
        echo "{$time} 0: metadata already set for '{$target_file}'\n";
        exit(0);
    }
    // download file from irods to tmp
    $localfile = '/tmp/' . basename($target_file);
    if (file_exists($localfile)) {
        unlink($localfile);
    }
    $irodsfile->open("r");
    $str = '';
    while (($buffer = $irodsfile->read(1024 * 1024)) != NULL && connection_status() == 0) {
        $str = $str . $buffer;
    }
    $irodsfile->close();
    file_put_contents($localfile, $str);
    extactExif($localfile, $irodsfile);
    if (file_exists($localfile)) {
        unlink($localfile);
    }
    $time = '[' . date('c') . ']';
    echo "{$time} 0: '{$target_file}' processed!\n";
    exit(0);
} catch (Exception $e) {
    if (file_exists($localfile)) {
Beispiel #2
0
<?php

require_once "/Path/to/Prods/src/Prods.inc.php";
// make an iRODS account object for connection, assuming:
// username: demouser, password: demopass, server: srbbrick15.sdsc.edu, port: 1247
$account = new RODSAccount("srbbrick15.sdsc.edu", 1247, "demouser", "demopass");
//create an file object for read, assuming the path is "/tempZone/home/demouser/test_read.txt"
$myfile = new ProdsFile($account, "/tempZone/home/demouser/test_read.txt");
//read and print out the file
$myfile->open("r");
echo "the file reads: <pre>";
while ($str = $myfile->read(4096)) {
    echo $str;
}
echo "</pre>";
//close the file pointer
$myfile->close();
//create an file object for write, assuming the path is "/tempZone/home/demouser/test_write.txt"
$myfile = new ProdsFile($account, "/tempZone/home/demouser/test_write.txt");
//write hello world to the file, onto "demoResc" as resource. Note that resource name is
//required here by method open(), because iRODS needs to know which resource to write to.
$myfile->open("w+", "demoResc");
$bytes = $myfile->write("Hello world!\n");
//print the number of bytes writen
echo "{$bytes} bytes written <br/>\n";
$myfile->close();
 $childfiles = $dir->getChildFiles();
 echo "Child files: <br/>\n";
 foreach ($childfiles as $childfile) {
     echo $childfile . " <br/>\n";
     /*
     $childfile->open("r");
     echo "desc=".$childfile->getL1desc()."<br/>\n";
     echo "<pre>".$childfile->read($childfile->stats->size)."</pre><br/>\n";
     $cur_offset=$childfile->seek(3);
     echo "offsetted '$cur_offset' bytes <br/> \n";
     echo "<pre>".$childfile->read($childfile->stats->size)."</pre><br/>\n";
     */
     //$childfile->close();
 }
 $myfile = new ProdsFile($account, "/tempZone/home/rods/test1");
 $myfile->open("w+", "demoResc");
 $bytes = $myfile->write("Hello world from Sifang!\n");
 echo "{$bytes} bytes written <br/>\n";
 $myfile->close();
 $myfile->open("r", "demoResc", true);
 $str = $myfile->read(200);
 echo "the file reads: <pre>{$str}</pre>";
 $myfile->close();
 $file_src = new ProdsFile($account, "/tempZone/home/rods/test.php");
 $file_dest = new ProdsFile($account, "/tempZone/home/rods/test.sifang.txt");
 //$file_src->cpMeta($file_dest);
 foreach ($file_dest->getMeta() as $meta) {
     echo "{$file_dest->path_str}: {$meta->name}; {$meta->value}; {$meta->units} <br/> \n";
 }
 $meta = array(new RODSMeta("test1", "1"));
 $files = ProdsPath::queryMeta($account, $meta);
Beispiel #4
0
<?php

/**
 * Developer: Daniel Speichert
 * Date: 14.12.12
 * Time: 13:40
 */
require_once "../src/Prods.inc.php";
require_once "../src/ProdsStreamer.class.php";
error_reporting(-1);
try {
    // make an iRODS account object for connection, assuming:
    // username: demouser, password: demopass, server: srbbrick15.sdsc.edu, port: 1247
    // $host, $port, $user, $pass, $zone = "", $default_resc = "", $ticket = ''
    //$account = new RODSAccount('localhost', 1247, 'rods', 'rods');
    $account = new RODSAccount('localhost', 1247, 'a', 'a', '', '', 'RpO7kyGvh40egRz');
    $myfile = new ProdsFile($account, "/tempZone/home/rods/phrases.html");
    //header('Content-Type: image/png');
    //read and print out the file
    $myfile->open("r");
    //while($str=$myfile->read(4096))
    //$str=file_get_contents("rods://*****:*****@localhost:1247/tempZone/home/rods/testphoto.png");
    $str = file_get_contents("rods+ticket://a#RpO7kyGvh40egRz:a@localhost:1247/tempZone/home/rods/phrases.html");
    echo $str;
    //close the file pointer
    $myfile->close();
} catch (RODSException $e) {
    echo "--- test failed! --- <br/>\n";
    echo $e;
    echo $e->showStackTrace();
}
Beispiel #5
0
            } else {
                $response = array('success' => false, 'errmsg' => 'Unknow errors', 'errcode' => $srcfile['error']);
            }
            $error = true;
            break;
        }
        $tempuploadfilepath = tempnam(dirname($srcfile['tmp_name']), 'RODS_Web_Upload');
        move_uploaded_file($srcfile['tmp_name'], $tempuploadfilepath);
        //copy($srcfile['tmp_name'], $srcfile['name']);
        $destfile = new ProdsFile($collection->account, $collection->path_str . "/" . $filename);
        /*
        $response=array('success'=> false,'log'=> ''.$collection->account); 
        echo json_encode($response);
        exit(0); 
        */
        $destfile->open('w', $resource);
        $destfile->write(file_get_contents($tempuploadfilepath));
        $destfile->close();
        if (AUTO_EXTRACT_EXIF === true) {
            extactExif($tempuploadfilepath, $destfile);
        }
        $numfiles++;
        unlink($tempuploadfilepath);
    }
    if ($error === false) {
        $response = array('success' => true, 'msg' => "Uploaded file successfully.");
    }
    echo json_encode($response);
} catch (Exception $e) {
    $response = array('success' => false, 'errmsg' => $e->getMessage(), 'errcode' => $e->getCode());
    echo json_encode($response);
Beispiel #6
0
    $response = array('success' => false, 'log' => 'Resource name not specified');
    echo json_encode($response);
    exit(0);
}
try {
    $parent = ProdsDir::fromURI($ruri, false);
    if (empty($parent->account->pass)) {
        $acct = $_SESSION['acct_manager']->findAcct($parent->account);
        if (empty($acct)) {
            $response = array('success' => false, 'log' => 'Authentication Required');
            echo json_encode($response);
            exit(0);
        }
        $parent->account = $acct;
    }
    if (empty($parent->account->zone)) {
        $parent->account->getUserInfo();
    }
    $file = new ProdsFile($parent->account, $parent->path_str . '/' . $name);
    if ($file->exists()) {
        $response = array('success' => false, 'log' => 'Path ' . $parent->path_str . '/' . $name . ' already exists!');
    } else {
        $file->open('w', $resc);
        $file->close();
        $response = array('success' => true, 'log' => "new file '{$name}' created!");
    }
    echo json_encode($response);
} catch (Exception $e) {
    $response = array('success' => false, 'log' => $e->getMessage());
    echo json_encode($response);
}