Skip to content
Browse files

Adds validator post function

  • Loading branch information...
1 parent 10dd0d5 commit aea5b2837149418128f82a2461274a6959839495 Ankur committed Oct 15, 2012
Showing with 34 additions and 2 deletions.
  1. +7 −2 index.php
  2. +27 −0 validate.php
View
9 index.php
@@ -57,12 +57,18 @@
<!--[if lt IE 8 ]><body class="source ie ie7"><![endif]-->
<!--[if gte IE 8 ]><body class="source ie"><![endif]-->
<!--[if !IE]><!--><body class="source"><!--<![endif]-->
+
+<form name=validate action="/openhtml/validate.php" method=post>
+ <input type=hidden name="html_code" value= '<?php echo $html; ?>
+ <input type=hidden name="test" value="Test Value">
+</form>
+
<div id="control">
<div class="control">
<div class="buttons">
<a id="account" class="tab button group light left" href="<?php echo ROOT?>list">Page List<?php //echo $is_owner?></a>
<a id="account" class="tab button group light" href="<?php echo ROOT?>">New Page</a>
- <a id="account" class="tab button group light right gap" href="http://validator.w3.org/check?uri=<?php echo $_SERVER['HTTP_HOST'] . ROOT . $code_id?>">Validate</a>
+ <a id="account" class="tab button group light right gap" href="#" onclick="document.forms['validate'].submit(); return false;">Validate</a>
<!--<a class="tab button source group left" accesskey="1" href="#source">Code</a>
<a class="tab button preview group right gap" accesskey="2" href="#preview">Preview</a>-->
<a title="Revert" class="button light group left" id="revert" href="#"><img class="enabled" src="<?php echo ROOT?>images/revert.png" /><img class="disabled" src="<?php echo ROOT?>images/revert-disabled.png" /></a>
@@ -102,7 +108,6 @@
<a id="account" class="button group light left" href="<?php echo ROOT?>list"><?php echo $_SESSION['name']; ?></a>
<a id="logout" class="button group light right" href="<?php echo ROOT?>logout">Logout</a>
<span id="logo">openHTML</span>
-
</div>
</div>
</div>
View
27 validate.php
@@ -0,0 +1,27 @@
+<?php
+
+function validate($code, $type){
+
+ if($type == "html") $url="http://validator.w3.org/check";
+ else if ($type == "css") $url = "http://jigsaw.w3.org/css-validator/validator";
+ $handle = curl_init();
+ curl_setopt_array(
+ $handle,
+ array(
+ CURLOPT_URL => $url,
+ CURLOPT_POSTFIELDS => "fragment=".$code,//"&output=soap12",
+ CURLOPT_RETURNTRANSFER => true
+ )
+ );
+
+ $curl_response = curl_exec($handle);
+ curl_close($handle);
+
+ echo $curl_response;
+ return $curl_response;
+}
+
+validate($_POST["html_code"], "html");
+
+
+?>

0 comments on commit aea5b28

Please sign in to comment.
Something went wrong with that request. Please try again.