| 1 | = Web-based job submission = |
| 2 | |
| 3 | This involves developing web pages, run on your BOINC server, |
| 4 | for submitting jobs. |
| 5 | These pages are application-specific, |
| 6 | since the way that users specify parameters and input files depends on the application. |
| 7 | |
| 8 | These scripts are best implemented in PHP. |
| 9 | BOINC provides a large set of PHP APIs for accessing the BOINC database, |
| 10 | staging files, and so on. |
| 11 | |
| 12 | These scripts will typically use BOINC PHP code for various purposes: |
| 13 | |
| 14 | * '''inc/util.inc''': utility functions |
| 15 | * '''inc/boinc_db.inc''': access to BOINC database |
| 16 | * '''inc/submit_db.inc''': access to job-submissions parts of BOINC database |
| 17 | * '''inc/submit_util.inc''': job submission utility functions |
| 18 | |
| 19 | == Authorizing requests == |
| 20 | |
| 21 | Job-submissions scripts must check that the user is allowed to submit jobs. |
| 22 | You can do this as follows: |
| 23 | {{{ |
| 24 | $user = get_logged_in_user(); |
| 25 | $user_submit = BoincUserSubmit::lookup_userid($user->id); |
| 26 | if (!$user_submit) error_page("no submit access"); |
| 27 | $app = BoincApp::lookup("name='lammps'"); |
| 28 | if (!$app) error_page("no lammps app"); |
| 29 | if (!$user_submit->submit_all) { |
| 30 | $usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id"); |
| 31 | if (!$usa) { |
| 32 | error_page("no submit access"); |
| 33 | } |
| 34 | } |
| 35 | }}} |
| 36 | |
| 37 | == Creating batches and jobs == |
| 38 | |
| 39 | You can create a batch as follows: |
| 40 | {{{ |
| 41 | $batch_id = BoincBatch::insert( |
| 42 | "(user_id, create_time, njobs, name, app_id, state) |
| 43 | values ($user->id, $now, $njobs, '$batch_name', $app->id, ".BATCH_STATE_IN_PROGRESS.")" |
| 44 | ); |
| 45 | }}} |
| 46 | |
| 47 | Create jobs using the [JobSubmission#creatework-tool create_work script]. |