Example #1
0
define("PWD", "123456");
$client = new SoapClient("http://ideone.com/api/1/service.wsdl", array('proxy_host' => "172.16.1.11", 'proxy_port' => 3128));
// --------------------------------------------------------------
// IF PROFILES ARE ENABLED IN CONFIG FILE
// --------------------------------------------------------------
if (ENABLE_USER_PROFILES == 1) {
    require_once ROOT_PATH . 'user/modules/accordion/banner.html.php';
    ?>

	 <form action='' method='post'>
	<fieldset>
		<legend>Write your code</legend>
		Select Your Language: <select name="PL">
		<option value="">--- PROGRAMMING LANGUAGE ---</option>
			<?php 
    $result = $client->getLanguages($user = "******", $pass = "******");
    foreach ($result["languages"] as $k => $v) {
        echo "<option value='" . $k . "'>" . $v . "</option>";
    }
    ?>
		</select><br/>
		<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>
Example #2
0
 /**
  * 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);
 }