| 4 |   | In early versions of BOINC, scientists submitted jobs to | 
                      
                        | 5 |   | a BOINC server by logging in to the server and running programs or scripts. | 
                      
                        | 6 |   | More recently, BOINC has been used to build systems, | 
                      
                        | 7 |   | collectively called '''remote job submission''' systems, | 
                      
                        | 8 |   | in which scientists can submit jobs without logging in to the BOINC server. | 
                      
                      
                        |   | 4 | "Remote job submissions" means that jobs are submitted | 
                      
                        |   | 5 | by scripts or programs running on hosts other than the BOINC server. | 
                      
            
                      
                        | 10 |   | In all these systems, job submitters are identified using accounts on the BOINC project | 
                      
                        | 11 |   | (the same kind of accounts as volunteers; job submitters can also act as resource providers). | 
                      
                        | 12 |   | Access control is provided by BOINC's [MultiUser multi-user project features]: | 
                      
                        | 13 |   | users can submit jobs only if they have been given access by project administrators, | 
                      
                        | 14 |   | and admins can restrict the apps for which each user is allowed to submit jobs. | 
                      
                        | 15 |   | Users have '''quotas''' how resources are allocated to their jobs. | 
                      
                        | 16 |   |  | 
                      
                        | 17 |   | The structure and details of remote job submission systems | 
                      
                        | 18 |   | vary widely. | 
                      
                        | 19 |   | BOINC doesn't include a pre-packaged remote job submission system, | 
                      
                      
                        |   | 7 | BOINC doesn't include a generic remote job submission system, | 
                      
            
                      
                        | 23 |   | == Example: single-server portal == | 
                      
                        | 24 |   |  | 
                      
                        | 25 |   | Users submit jobs using forms on the project web site: | 
                      
                        | 26 |   |  | 
                      
                        | 27 |   | [[Image(submit2.png)]] | 
                      
                        | 28 |   |  | 
                      
                        | 29 |   | These forms are application-specific; you must develop them yourself. | 
                      
                        | 30 |   | Two examples are included in the BOINC distribution: | 
                      
                        | 31 |   |  * '''html/user/tree_threader.php''' | 
                      
                        | 32 |   |  * '''html/user/lammps.php''' | 
                      
                        | 33 |   |  | 
                      
                        | 34 |   | TODO: the above are full of application-specific complexity; | 
                      
                        | 35 |   | provide a minimal/generic example. | 
                      
                        | 36 |   |  | 
                      
                        | 37 |   | The job-submission scripts use [RemoteOverview#LocalPHPinterfaces local PHP interfaces] to | 
                      
                        | 38 |   | authenticate users and to create jobs and batches. | 
                      
                        | 39 |   |  | 
                      
                        | 40 |   | Input files can be handled in any of several ways: | 
                      
                        | 41 |   |  | 
                      
                        | 42 |   |  * Uploading them (from the submitter's computer) as part of the submission form. | 
                      
                        | 43 |   |    The submission script would then [JobStage stage them]. | 
                      
                        | 44 |   |  * Using the [RemoteInputFiles#Per-userfilesandbox user file sandbox] mechanism. | 
                      
                        | 45 |   |  * Serving them from a remote server. | 
                      
                        | 46 |   |  | 
                      
                        | 47 |   | == Example: multi-server portal == | 
                      
                      
                        |   | 11 | == Example: Science portal == | 
                      
            
                  
                          | 73 |   | === Job submission control panel === | 
                  
                          | 74 |   |  | 
                  
                          | 75 |   | The web page '''submit.php''' allows users to view submitted jobs | 
                  
                          | 76 |   | and retrieve their output files. | 
                  
                          | 77 |   | This link should be shown only to authorized users. | 
                  
                          | 78 |   | You can do this, e.g., by putting the following on your home page (index.php): | 
                  
                          | 79 |   | {{{ | 
                  
                          | 80 |   | $user = get_logged_in_user(false); | 
                  
                          | 81 |   | if ($user && BoincUserSubmit::lookup_userid($user->id); | 
                  
                          | 82 |   |     echo ' | 
                  
                          | 83 |   |         <li><a href=submit.php>Job submission</a> | 
                  
                          | 84 |   |         <li><a href=sandbox.php>File sandbox</a> | 
                  
                          | 85 |   |     '; | 
                  
                          | 86 |   | } | 
                  
                          | 87 |   | }}} | 
                  
                          | 88 |   | (include the "File sandbox" link if you use this feature - see below). | 
                  
                          | 89 |   |  | 
                  
                          | 90 |   | === Local PHP interfaces === | 
                  
                          | 91 |   |  | 
                  
                          | 92 |   | Job-submission scripts to be run on the BOINC server | 
                  
                          | 93 |   | are best implemented in PHP. | 
                  
                          | 94 |   | BOINC provides a large set of PHP APIs for accessing the BOINC database, | 
                  
                          | 95 |   | staging files, and so on. | 
                  
                          | 96 |   |  | 
                  
                          | 97 |   | For example, you can authorize a job submission request with code like | 
                  
                          | 98 |   | {{{ | 
                  
                          | 99 |   | $user = get_logged_in_user(); | 
                  
                          | 100 |   | $user_submit = BoincUserSubmit::lookup_userid($user->id); | 
                  
                          | 101 |   | if (!$user_submit) error_page("no submit access"); | 
                  
                          | 102 |   | $app = BoincApp::lookup("name='lammps'"); | 
                  
                          | 103 |   | if (!$app) error_page("no lammps app"); | 
                  
                          | 104 |   | if (!$user_submit->submit_all) { | 
                  
                          | 105 |   |     $usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id"); | 
                  
                          | 106 |   |     if (!$usa) { | 
                  
                          | 107 |   |         error_page("no submit access"); | 
                  
                          | 108 |   |     } | 
                  
                          | 109 |   | } | 
                  
                          | 110 |   | }}} | 
                  
                          | 111 |   |  | 
                  
                          | 112 |   | You can create a batch as follows: | 
                  
                          | 113 |   | {{{ | 
                  
                          | 114 |   | $batch_id = BoincBatch::insert( | 
                  
                          | 115 |   |     "(user_id, create_time, njobs, name, app_id, state) | 
                  
                          | 116 |   |     values ($user->id, $now, $njobs, '$batch_name', $app->id, ".BATCH_STATE_IN_PROGRESS.")" | 
                  
                          | 117 |   | ); | 
                  
                          | 118 |   | }}} | 
                  
                          | 119 |   |  | 
                  
                          | 120 |   | '''TODO: document these interfaces, or provide simpler examples.''' | 
                  
                          | 121 |   |  |