Debian Codegraph @

qchem/write.php

raw
1 <?php
2 //
3 // Simple PHP script to write a file
4 //
5
6 //
7 // This values must match value in dirlist.php
8 // Set parameter defining:
9 // base: base of directory path
10 //
11 $base = "data";
12
13 //
14 // Get subdirectory, filename, and contents
15 // from AJAX _POST.
16 //
17 $subdir = trim($_POST['path']);
18 $filename = trim($_POST['filename']);
19 $contents = $_POST['contents'];
20
21 //
22 // Get username and build full file path
23 //
24 $user = $_SERVER['PHP_AUTH_USER'];
25 $path = "$base/$user";
26 if (strlen($subdir) > 2)
27 $path = "$path/$subdir";
28
29 //
30 // File written to new subdirectory based on filename
31 // Build new path and full filename
32 //
33 $path = "$path/$filename";
34 $suffix = ".inp";
35 $fullname = "$path/$filename$suffix";
36 echo "File = [$filename] (Full name = $fullname)\n";
37
38 //
39 // Create new subdirectory
40 //
41 mkdir($path, 0755);
42
43 //
44 // Open file handle for new file and write contents to disk
45 //
46 $fh = fopen($fullname,'w') or die("Unable to open file $fullname");
47 fwrite($fh, $contents);
48 fclose($fh);
49
50 // Start batch job
51 system("cd $path; /usr/local/bin/subgms $filename batch 4");
52 echo "Calculation should be submitted to batch queue.\n";
53 //echo "$filename$suffix file created, but calculation NOT actually submitted. See write.php.\n";
54 ?>