当前位置: 首页>>代码示例>>PHP>>正文


PHP SoapClient::createSubmission方法代码示例

本文整理汇总了PHP中SoapClient::createSubmission方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapClient::createSubmission方法的具体用法?PHP SoapClient::createSubmission怎么用?PHP SoapClient::createSubmission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoapClient的用法示例。


在下文中一共展示了SoapClient::createSubmission方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SoapClient

 function judge_ideone($sub)
 {
     global $CFG;
     // creating soap client
     $client = new SoapClient("http://ideone.com/api/1/service.wsdl");
     $user = $CFG->assignment_oj_ideone_username;
     $pass = $CFG->assignment_oj_ideone_password;
     if ($source = $this->get_submission_file_content($sub->userid)) {
         $cases = $this->get_tests();
         $status_ideone = array(11 => 'ce', 12 => 're', 13 => 'tle', 15 => 'ok', 17 => 'mle', 19 => 'rf', 20 => 'ie');
         $result->grade = -1;
         try {
             // Begin soap
             // Submit all cases first to save time.
             $links = array();
             foreach ($cases as $case) {
                 $webid = $client->createSubmission($user, $pass, $source, $this->ideone_langs[$this->onlinejudge->language], $case->input, true, true);
                 if ($webid['error'] == 'OK') {
                     $links[] = $webid['link'];
                 } else {
                     $result->status = 'ie';
                     $result->info = $webid['error'];
                     return $result;
                 }
             }
             // Get ideone results
             $delay = $CFG->assignment_oj_ideone_delay;
             $i = 0;
             $results = array();
             foreach ($cases as $case) {
                 while (1) {
                     if ($delay > 0) {
                         sleep($delay);
                         $delay = ceil($delay / 2);
                     }
                     $status = $client->getSubmissionStatus($user, $pass, $links[$i]);
                     if ($status['status'] == 0) {
                         $delay = 0;
                         break;
                     }
                 }
                 $details = $client->getSubmissionDetails($user, $pass, $links[$i], false, true, true, true, true, false);
                 $result->status = $status_ideone[$details['result']];
                 // If got ce or compileonly, don't need to test other case
                 if ($result->status == 'ce' || $this->onlinejudge->compileonly) {
                     if ($result->status != 'ce' && $result->status != 'ie') {
                         $result->status = 'compileok';
                     }
                     $result->info = $details['cmpinfo'] . '<br />' . get_string('ideonelogo', 'assignment_onlinejudge');
                     $result->grade = $this->grade_marker('ce', $this->assignment->grade);
                     return $result;
                 }
                 // Check for wa, pe, tle, mle or accept
                 if ($result->status == 'ok') {
                     if ($details['time'] > $this->onlinejudge->cpulimit) {
                         $result->status = 'tle';
                     } else {
                         if ($details['memory'] * 1024 > $this->onlinejudge->memlimit) {
                             $result->status = 'mle';
                         } else {
                             $result->output = $details['output'];
                             $result->status = $this->diff($case->output, $result->output);
                         }
                     }
                 }
                 $results[] = $result;
                 unset($result);
                 $i++;
             }
         } catch (SoapFault $ex) {
             $result->status = 'ie';
             $result->info = 'faultcode=' . $ex->faultcode . '|faultstring=' . $ex->faultstring;
             return $result;
         }
         $result = $this->merge_results($results, $cases);
         $result->info .= '<br />' . get_string('ideonelogo', 'assignment_onlinejudge');
         return $result;
     } else {
         return false;
     }
 }
开发者ID:hit-moodle,项目名称:onlinejudge,代码行数:81,代码来源:assignment.class.php

示例2: judge

 /**
  * Judge the current task
  *
  * @return updated task
  */
 function judge()
 {
     $task =& $this->task;
     // create client.
     $client = new SoapClient("http://ideone.com/api/1/service.wsdl");
     $user = $task->var1;
     $pass = $task->var2;
     $language = $this->language;
     $input = $task->input;
     // Get source code
     $fs = get_file_storage();
     $files = $fs->get_area_files(get_context_instance(CONTEXT_SYSTEM)->id, 'local_onlinejudge', 'tasks', $task->id, 'sortorder, timemodified', false);
     $source = '';
     foreach ($files as $file) {
         $source = $file->get_content();
         break;
     }
     $status_ideone = array(0 => ONLINEJUDGE_STATUS_PENDING, 11 => ONLINEJUDGE_STATUS_COMPILATION_ERROR, 12 => ONLINEJUDGE_STATUS_RUNTIME_ERROR, 13 => ONLINEJUDGE_STATUS_TIME_LIMIT_EXCEED, 15 => ONLINEJUDGE_STATUS_COMPILATION_OK, 17 => ONLINEJUDGE_STATUS_MEMORY_LIMIT_EXCEED, 19 => ONLINEJUDGE_STATUS_RESTRICTED_FUNCTIONS, 20 => ONLINEJUDGE_STATUS_INTERNAL_ERROR);
     // Begin soap
     /**
      * function createSubmission create a paste.
      * @param user is the user name.
      * @param pass is the user's password.
      * @param source is the source code of the paste.
      * @param language is language identifier. these identifiers can be
      *     retrieved by using the getLanguages methods.
      * @param input is the data that will be given to the program on the stdin
      * @param run is the determines whether the source code should be executed.
      * @param private is the determines whether the paste should be private.
      *     Private pastes do not appear on the recent pastes page on ideone.com.
      *     Notice: you can only set submission's visibility to public or private through
      *     the API (you cannot set the user's visibility).
      * @return array(
      *         error => string
      *         link  => string
      *     )
      */
     $webid = $client->createSubmission($user, $pass, $source, $language, $input, true, true);
     $delay = get_config('local_onlinejudge', 'ideonedelay');
     sleep($delay);
     // ideone reject bulk access
     if ($webid['error'] == 'OK') {
         $link = $webid['link'];
     } else {
         throw new onlinejudge_exception('ideoneerror', $webid['error']);
     }
     // Get ideone results
     while (1) {
         $status = $client->getSubmissionStatus($user, $pass, $link);
         sleep($delay);
         // ideone reject bulk access. Always add delay between accesses
         if ($status['status'] == 0) {
             break;
         }
     }
     $details = $client->getSubmissionDetails($user, $pass, $link, false, false, true, true, true);
     $task->stdout = $details['output'];
     $task->stderr = $details['stderr'];
     $task->compileroutput = $details['cmpinfo'];
     $task->memusage = $details['memory'] * 1024;
     $task->cpuusage = $details['time'];
     $task->infoteacher = get_string('ideoneresultlink', 'local_onlinejudge', $link);
     $task->infostudent = get_string('ideonelogo', 'local_onlinejudge');
     $task->status = $status_ideone[$details['result']];
     if ($task->compileonly) {
         if ($task->status != ONLINEJUDGE_STATUS_COMPILATION_ERROR && $task->status != ONLINEJUDGE_STATUS_INTERNAL_ERROR) {
             $task->status = ONLINEJUDGE_STATUS_COMPILATION_OK;
         }
     } else {
         if ($task->status == ONLINEJUDGE_STATUS_COMPILATION_OK) {
             if ($task->cpuusage > $task->cpulimit) {
                 $task->status = ONLINEJUDGE_STATUS_TIME_LIMIT_EXCEED;
             } else {
                 if ($task->memusage > $task->memlimit) {
                     $task->status = ONLINEJUDGE_STATUS_MEMORY_LIMIT_EXCEED;
                 } else {
                     $task->status = $this->diff();
                 }
             }
         }
     }
     return $task;
 }
开发者ID:boychunli,项目名称:moodle-local_onlinejudge,代码行数:88,代码来源:lib.php

示例3: array

$subStatus = array(0 => 'Success', 1 => 'Compiled', 3 => 'Running', 11 => 'Compilation Error', 12 => 'Runtime Error', 13 => 'Timelimit exceeded', 15 => 'Success', 17 => 'memory limit exceeded', 19 => 'illegal system call', 20 => 'internal error');
$error = array('status' => 'error', 'output' => 'Something went wrong :(');
//echo json_encode( array( 'hi', 1 ) ); exit;
//print_r( $_POST ); exit;
$result_sql = mysql_query("SELECT * FROM `questions_input` WHERE `qusID` = '{$questionID}'") or die("Invaild Question");
$result_array = mysql_fetch_array($result_sql);
$required_output = $result_array['output'];
if (!empty($required_output) && $valid_question) {
    //isset( $_POST['process'] ) && $_POST['process'] == 1 ) {
    $lang = isset($_POST['lang']) ? intval($_POST['lang']) : 11;
    $input = trim($result_array['input']);
    $mark = $result_array['mark'];
    $code = trim($_POST['source']);
    $client = new SoapClient("http://ideone.com/api/1/service.wsdl");
    //create new submission
    $result = $client->createSubmission($user, $pass, $code, $lang, $input, $run, $private);
    //if submission is OK, get the status
    if ($result['error'] == 'OK') {
        $status = $client->getSubmissionStatus($user, $pass, $result['link']);
        if ($status['error'] == 'OK') {
            //check if the status is 0, otherwise getSubmissionStatus again
            while ($status['status'] != 0) {
                sleep(3);
                //sleep 3 seconds
                $status = $client->getSubmissionStatus($user, $pass, $result['link']);
            }
            //finally get the submission results
            $details = $client->getSubmissionDetails($user, $pass, $result['link'], true, true, true, true, true);
            if ($details['error'] == 'OK') {
                //print_r( $details );
                if ($details['status'] < 0) {
开发者ID:stenalpjolly,项目名称:CodeIt,代码行数:31,代码来源:process.php

示例4: stripslashes

		<textarea id="code" style="height: 350px; width: 100%;" name="code">
		<?php 
    echo stripslashes($_POST["code"]);
    ?>
		</textarea>
	</fieldset>
	<input type="submit" value="Execute" class="amit_button"/>
	</form>
</body>
</html>
<?php 
    $code = stripslashes($_POST["code"]);
    $lang = $_POST["PL"];
    //explore($client->getLanguages($user="arsenalnerk",$pass="123456"));
    if ($code) {
        $result = $client->createSubmission($user = USER, $pass = PWD, $sourceCode = $code, $language = $lang, $input = "", $run = 1, $private = 0);
        //explore($result);
        $stat = $client->getSubmissionStatus($user = USER, $pass = PWD, $link = $result["link"]);
        //explore($stat);
        $output = $client->getSubmissionDetails($user = USER, $pass = PWD, $link = $result["link"], $withSource = 1, $withInput = 0, $withOutput = 1, $withStderr = 1, $withCmpinfo = 1);
        echo $output["output"];
        explore($output);
        //echo $output["output"];
    }
    ?>
 
    </div>
  </div>
</div>
<?php 
} else {
开发者ID:amitjoy,项目名称:other-php,代码行数:31,代码来源:compiler.html.php

示例5: isset

    $link = isset($_POST['link']) ? trim($_POST['link']) : '';
    $run = true;
    $private = true;
    if (strlen($input) > 1) {
        if ($input[strlen($input) - 1] != "\n") {
            $input .= "\n";
        }
    }
    if ($action == 'submit') {
        if (empty($_POST['source'])) {
            throw new Exception("Source is empty");
        }
        if (empty($_POST['language'])) {
            throw new Exception("Language is empty");
        }
        $result = $client->createSubmission($api_user, $api_pass, $source, $language, $input, $run, $private);
        if ($result['error'] == 'OK') {
            $link = $result['link'];
            $status = check($link);
        } else {
            throw new Exception("createSubmission: " . $result['error']);
        }
    } else {
        $status = check($link);
    }
    //var_dump($params);
    $response['status'] = 'OK';
    $response['message'] = $status;
    $response['message']['link'] = $link;
    $response['message']['date'] = date("Y-m-d\\TH:i:s\\Z");
} catch (Exception $e) {
开发者ID:mehulsbhatt,项目名称:code,代码行数:31,代码来源:ideone.php

示例6: onCommandIdeone

 /**
  * Executes a source code sequence in a specified language and returns
  * the result.
  *
  * @param string $language Programming language the source code is in
  * @param string $code     Source code to execute
  *
  * @return void
  */
 public function onCommandIdeone($language, $code)
 {
     $source = $this->event->getSource();
     $nick = $this->event->getNick();
     // Get authentication credentials
     $user = $this->getConfig('ideone.user', 'test');
     $pass = $this->getConfig('ideone.pass', 'test');
     // Normalize the command parameters
     $language = strtolower($language);
     // Massage PHP code to allow for convenient shorthand
     if ($language == 'php') {
         if (!preg_match('/^<\\?(?:php)?/', $code)) {
             $code = '<?php ' . $code;
         }
         switch (substr($code, -1)) {
             case '}':
             case ';':
                 break;
             default:
                 $code .= ';';
                 break;
         }
     }
     // Identify the language to use
     $client = new SoapClient('http://ideone.com/api/1/service.wsdl');
     $response = $client->getLanguages($user, $pass);
     if ($this->isError($response)) {
         return;
     }
     $languageLength = strlen($language);
     foreach ($response['languages'] as $languageId => $languageName) {
         if (strncasecmp($language, $languageName, $languageLength) == 0) {
             break;
         }
     }
     // Send the paste data
     $response = $client->createSubmission($user, $pass, $code, $languageId, null, true, false);
     if ($this->isError($response)) {
         return;
     }
     $link = $response['link'];
     // Wait until the paste data is processed or the service fails
     $attempts = $this->getConfig('ideone.attempts', 10);
     foreach (range(1, $attempts) as $attempt) {
         $response = $client->getSubmissionStatus($user, $pass, $link);
         if ($this->isError($response)) {
             return;
         }
         if ($response['status'] == 0) {
             $result = $response['result'];
             break;
         } else {
             $result = null;
             sleep(1);
         }
     }
     if ($result == null) {
         $this->doNotice($nick, 'ideone error: Timed out');
         return;
     }
     if ($result != 15) {
         $this->doNotice($nick, 'ideone error: Status code ' . $result);
         return;
     }
     // Get details for the created paste
     $response = $client->getSubmissionDetails($user, $pass, $link, false, false, true, true, false);
     if ($this->isError($response)) {
         return;
     }
     // Replace the output if it exceeds a specified maximum length
     $outputLimit = $this->getConfig('ideone.output_limit', 100);
     var_dump($response);
     if ($outputLimit && strlen($response['output']) > $outputLimit) {
         $response['output'] = 'Output is too long to post';
     }
     // Format the message
     $msg = $this->getConfig('ideone.format', '%nick%: [ %link% ] %output%');
     $response['nick'] = $nick;
     $response['link'] = 'http://ideone.com/' . $link;
     foreach ($response as $key => $value) {
         $msg = str_replace('%' . $key . '%', $value, $msg);
     }
     $this->doPrivmsg($source, $msg);
 }
开发者ID:rdohms,项目名称:phergie,代码行数:93,代码来源:Ideone.php


注:本文中的SoapClient::createSubmission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。