Skip to content

Commit

Permalink
Adds validator post function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankur committed Oct 15, 2012
1 parent 10dd0d5 commit aea5b28
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.php
Expand Up @@ -57,12 +57,18 @@
<!--[if lt IE 8 ]><body class="source ie ie7"><![endif]--> <!--[if lt IE 8 ]><body class="source ie ie7"><![endif]-->
<!--[if gte IE 8 ]><body class="source ie"><![endif]--> <!--[if gte IE 8 ]><body class="source ie"><![endif]-->
<!--[if !IE]><!--><body class="source"><!--<![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 id="control">
<div class="control"> <div class="control">
<div class="buttons"> <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 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" 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 source group left" accesskey="1" href="#source">Code</a>
<a class="tab button preview group right gap" accesskey="2" href="#preview">Preview</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> <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>
Expand Down Expand Up @@ -102,7 +108,6 @@
<a id="account" class="button group light left" href="<?php echo ROOT?>list"><?php echo $_SESSION['name']; ?></a> <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> <a id="logout" class="button group light right" href="<?php echo ROOT?>logout">Logout</a>
<span id="logo">openHTML</span> <span id="logo">openHTML</span>

</div> </div>
</div> </div>
</div> </div>
Expand Down
27 changes: 27 additions & 0 deletions 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.