Пример #1
0
// see if the user is autheticated (will NOT exit)
if (!$err && !authenticated()) {
    $err = 'Unauthenticated access';
}
// check to make sure required parameters have been sent
if (!$err) {
    $id = empty($_REQUEST['id']) ? '' : $_REQUEST['id'];
    if (!$id) {
        $err = 'Parameter id required';
    }
}
// check to make sure required configuration options have been set
if (!$err) {
    $dir_host = $moviemasher_client->getOption('DirHost');
    $path_media = $moviemasher_client->getOption('PathMedia');
    if (!($dir_host && $path_media)) {
        $err = 'Configuration option DirHost, PathMedia required';
    }
}
if (!$err) {
    $path_media .= authenticated_userid();
    // remove uploaded file and directory
    remove_dir_and_files($dir_host . $path_media . '/' . $id . '/');
}
if (!$err) {
    // set $err for log entry
    $err = @file_get_contents('php://input');
}
if ($err && !empty($moviemasher_client)) {
    $moviemasher_client->log($err);
}
Пример #2
0
                    $media_path = frame_file_path($media_dir, $encoder_dimensions, $encoder_fps);
                    if (!move_files_having_extension($extension, $archive_path, $media_path)) {
                        $err = 'Could not move ' . $extension . ' files from ' . $archive_path . ' to ' . $media_path;
                    }
                } else {
                    $moviemasher_client->log('Path does not exist: ' . $archive_path);
                }
                break;
        }
    }
    if (!$err) {
        // move any meta data
        $frag = 'meta/';
        $archive_path = $archive_dir . $frag;
        if (file_exists($archive_path)) {
            $media_path = $media_dir . $frag;
            if (!move_files_having_extension('txt', $archive_path, $media_path, TRUE)) {
                $err = 'Could not move txt files from ' . $archive_path . ' to ' . $media_path;
            }
        }
    }
    // remove the temporary directory we created, and any remaining files (there shouldn't be any)
    remove_dir_and_files($tmp_path);
}
if ($err) {
    header('HTTP/1.1: 400 Bad Request');
    header('Status: 400 Bad Request');
    if (!empty($moviemasher_client)) {
        $moviemasher_client->log($err);
    }
}
Пример #3
0
function remove_dir_and_files($path)
{
    $result = FALSE;
    if ($path && file_exists($path) && is_dir($path)) {
        $path = end_with_slash($path);
        if ($handle = opendir($path)) {
            $result = TRUE;
            while ($result && FALSE !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    if (is_dir($path . $file)) {
                        $result = remove_dir_and_files($path . $file);
                    } else {
                        $result = @unlink($path . $file);
                    }
                }
            }
            closedir($handle);
        }
        if ($result) {
            $result = @rmdir($path);
        }
    }
    return $result;
}