Difference between revisions of "C.php"

From Organic Design wiki
(write article to source.c)
m
Line 6: Line 6:
  
 
// Write the source to tmp file source.c
 
// Write the source to tmp file source.c
if ($handle = fopen("$htdocs/source.c, 'w+')) {
+
if ($handle = fopen("$htdocs/source.c", 'w+')) {
 
     fwrite($handle, $article);
 
     fwrite($handle, $article);
 
     fclose($handle);
 
     fclose($handle);

Revision as of 05:43, 23 June 2006

<?

  1. C compiler for XmlWiki Environment

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

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

   fwrite($handle, $article);
   fclose($handle);
   }

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