Skip to content

Instantly share code, notes, and snippets.

@H7-25
Created July 7, 2019 23:13
Show Gist options
  • Save H7-25/ae162631e3a2411a171e8290cb09d3fd to your computer and use it in GitHub Desktop.
Save H7-25/ae162631e3a2411a171e8290cb09d3fd to your computer and use it in GitHub Desktop.
<?php
$style = "include/style.php";
$js = "include/js.php";
$dom = new DOMDocument;
$dom->loadHTMLFile('/home/kiwi/public_html/index.html');
$head = $dom->getElementsByTagName('head')->item(0);
$css = $head->getElementsByTagName("link")->item(1);
$fh = fopen($style, 'w');
$data = "<link href=".$css->getAttribute("href")." rel=stylesheet>";
fwrite($fh, $data);
fclose($fh);
$body = $dom->getElementsByTagName('body')->item(0);
$scripts = $body->getElementsByTagName("script");
$fh = fopen($js, 'w');
$data = "";
foreach($scripts as $s) {
$data .="<script type=text/javascript src=".$s->getAttribute("src")."></script>";
}
fwrite($fh, $data);
fclose($fh);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment