Skip to content

Instantly share code, notes, and snippets.

@Amazingred
Forked from TomiToivio/svg.php
Created November 6, 2012 09:59
Show Gist options
  • Select an option

  • Save Amazingred/4023805 to your computer and use it in GitHub Desktop.

Select an option

Save Amazingred/4023805 to your computer and use it in GitHub Desktop.
svg.php
<?php
$plotxml = file_get_contents("plot.xml");
$plotxml=preg_replace("/<Arc>/","<ellipse",$plotxml);
$plotxml=preg_replace("/<\/Arc>/","/>",$plotxml);
$plotxml=preg_replace("/<ArcExtend>/","rx=\"",$plotxml);
$plotxml=preg_replace("/<\/ArcExtend>/","\"",$plotxml);
$plotxml=preg_replace("/<XCenter>/","cx=\"",$plotxml);
$plotxml=preg_replace("/<\/XCenter>/","\"",$plotxml);
$plotxml=preg_replace("/<YCenter>/","cy=\"",$plotxml);
$plotxml=preg_replace("/<\/YCenter>/","\"",$plotxml);
$plotxml=preg_replace("/<Radius>/","ry=\"",$plotxml);
$plotxml=preg_replace("/<\/Radius>/","\"",$plotxml);
$plotxml=preg_replace("/<ArcStart>/","rotate=\"",$plotxml);
$plotxml=preg_replace("/<\/ArcStart>/","\"",$plotxml);
$plotxml=preg_replace("/<Line>/","<line",$plotxml);
$plotxml=preg_replace("/<\/Line>/","/>",$plotxml);
$plotxml=preg_replace("/<YStart>/","y1=\"",$plotxml);
$plotxml=preg_replace("/<\/YStart>/","\"",$plotxml);
$plotxml=preg_replace("/<YEnd>/","y2=\"",$plotxml);
$plotxml=preg_replace("/<\/YEnd>/","\"",$plotxml);
$plotxml=preg_replace("/<XStart>/","x1=\"",$plotxml);
$plotxml=preg_replace("/<\/XStart>/","\"",$plotxml);
$plotxml=preg_replace("/<XEnd>/","x2=\"",$plotxml);
$plotxml=preg_replace("/<\/XEnd>/","\"",$plotxml);
$plotxml=preg_replace("/<Color>/","style=\"stroke: ",$plotxml);
$plotxml=preg_replace("/<\/Color>/",";\"",$plotxml);
$plotxml=preg_replace("/<ppcPlot xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"/","",$plotxml);
$plotxml=preg_replace("/xsi:noNamespaceSchemaLocation=\"http:\/\/www.hackthissite.org\/missions\/prog\/4\/plotMe.xsd\">/"," ",$plotxml);
$plotxml=preg_replace("/<\/ppcPlot>/","</svg>",$plotxml);
$plotxml=preg_replace("/<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>/","<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">",$plotxml);
echo $plotxml;
file_put_contents("solution.svg", $plotxml);
shell_exec("chromium-browser solution.svg");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment