Skip to content

Instantly share code, notes, and snippets.

@nazt
Created April 26, 2010 17:59
Show Gist options
  • Save nazt/379658 to your computer and use it in GitHub Desktop.
Save nazt/379658 to your computer and use it in GitHub Desktop.
<?php
header('Content-type: text/html; charset=windows-874');
require 'simple_html_dom.php';
$file = $_FILES['userfile'];
$allowedExtensions = array("txt", "htm", "html");
function isAllowedExtension($fileName) {
global $allowedExtensions;
return in_array(end(explode(".", $fileName)), $allowedExtensions);
}
if($file['error'] == UPLOAD_ERR_OK) {
if(isAllowedExtension($file['name'])) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-874">
<title>http://www.together.in.th</title>
<meta name="author" content="NAzT">
<!-- Date: 2010-03-10 -->
</head>
<body>
<?php
$html = file_get_html($file["tmp_name"]);
// find all td tags with attribite align=center
foreach($html->find('table [width="70%"]') as $e)
{
$main_table=$e->outertext;
echo $main_table."\n\n";
}
?>
</body>
</html>
<?
} else {
echo "Invalid file type";
}
} else die("Cannot upload");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment