#!/usr/bin/php
<?php 
// See: http://deanvaughan.org/wordpress/2012/07/class_dicom-php-example-send-all-dicom-files-in-a-directory/
require_once 'class_dicom.php';
# WHERE YOUR DICOM FILES ARE
$temp_dir = '../temp';
# WHERE YOU ARE SENDING THEM TO
$target_host = 'kif.sxrmedical.com';
$target_port = '105';
$target_ae = 'BK';
$my_ae = 'BK';
if (!file_exists('bk')) {
    mkdir('bk');
}
$d = new dicom_net();
if ($handle = opendir($temp_dir)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            print "Sending {$file}...\n";
            $d->file = "{$temp_dir}/{$file}";
            $ret = $d->send_dcm($target_host, $target_port, $my_ae, $target_ae);
            if ($ret) {
                print "Send Error: {$ret}\n";
                continue;
            } else {
                print "Good Send\n";
                print "Moving {$temp_dir}/{$file}\n";
                rename("{$temp_dir}/{$file}", "bk/{$file}");
            }
        }
    }
#!/usr/bin/php
<?php 
#
# Starts a DICOM store service on port 104. Any images received are stored in ./dcm_temp and then ./store_server_handler.php is ran.
#
require_once '../class_dicom.php';
print "Starting server on localhost:104\n";
$d = new dicom_net();
$d->store_server(104, './dcm_temp', './store_server_handler.php', 'store_server_config.cfg', 1);
#!/usr/bin/php
<?php 
#
# Sends a DICOM file to localhost 104... what the store_server.php example defaults too
#
require_once '../class_dicom.php';
$file = isset($argv[1]) ? $argv[1] : '';
if (!$file) {
    print "USAGE: ./send_dcm.php <FILE>\n";
    exit;
}
if (!file_exists($file)) {
    print "{$file}: does not exist\n";
    exit;
}
$d = new dicom_net();
$d->file = $file;
print "Sending file...\n";
$out = $d->send_dcm('localhost', '104', 'DEANO', 'example');
if ($out) {
    print "{$out}\n\nSomething bad happened!\n";
    exit;
}
print "Sent!\n";