Difference between revisions of "C.php"

From Organic Design wiki
(wrong dir!)
(code needs trailing newline)
Line 8: Line 8:
 
// Write the source to tmp file source.c
 
// Write the source to tmp file source.c
 
if ($handle = fopen($htdocs.'wiki/source.c', 'w+')) {
 
if ($handle = fopen($htdocs.'wiki/source.c', 'w+')) {
     fwrite($handle, $article);
+
     fwrite($handle, "$article\n");
 
     fclose($handle);
 
     fclose($handle);
 
     }
 
     }

Revision as of 07:10, 23 June 2006

<?

  1. C compiler for XmlWiki Environment

xwSetProperty($properties,'language','TEXT'); $server = $_SERVER['HTTP_HOST']; $htdocs = $_SERVER['DOCUMENT_ROOT']; if ( !ereg( "\\/$", $htdocs ) ) $htdocs .= '/';

// Write the source to tmp file source.c if ($handle = fopen($htdocs.'wiki/source.c', 'w+')) {

   fwrite($handle, "$article\n");
   fclose($handle);
   }

// Compile and output $gcc = $htdocs.'wiki/gcc'; $article = "Compiling using $gcc:\n"; $article .= shell_exec("$gcc 2>&1"); ?>