<?php header("Content-Type:text/html; charset=UTF-8");
error_reporting(E_ALL & ~E_NOTICE);
$d = $_SERVER['QUERY_STRING'];
ini_set('memory_limit', -1);
set_time_limit(10 * 3600);

require './ImageTo.php';

$strErro = '';
$generator = null;
$css = '';
$html = '';

if (isset($_FILES['image'])) {
    if (UPLOAD_ERR_OK === $_FILES['image']['error']) {
        $fileContents = file_get_contents($_FILES['image']['tmp_name']);
        if (false !== $fileContents) {
            $image = imagecreatefromstring($fileContents);
            if (false !== $image) {
                $inicio = microtime(true);
                $generator = new ImageToHtml($image);
                $css = $generator->generateCSS();
                $html = $generator->generateHTML();
                $fim = microtime(true);
            } else {
                $strErro = '无效的图片';
            }
        } else {
            $strErro = '不能打开此图片';
        }
    } else {
        $strErro = '上传错误.';
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<title>图片转换HTML工具 - 站长社站长工具</title>
<meta name="keywords" content="图片转换HTML工具,站长工具" />
<meta name="description" content="图片转换HTML工具,图片防下载,图片防盗链" />
<link type="text/css" href="css/bootstrap.min.css" rel="stylesheet" />
<link type="text/css" href="css/main.css" rel="stylesheet" />
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<?php include('topnav.php');?>

<div class="container" style="margin-top: 68px;">
<?php include("main_header.php");?>
	<div class="row" style="margin-top: 28px;">
		<div class="col-md-9">
			<div class="panel panel-tianyu">
				<header class="panel-heading">
					<span class="glyphicon glyphicon-link"></span><strong>图片转换HTML工具</strong>
				</header>
				<div class="panel-body">
				 <?php if (!empty($strErro)):  ?>
                 <h3><?php echo htmlspecialchars($strErro) ?></h3>
                 <?php endif  ?>
				<form method="POST" action="" enctype="multipart/form-data">
								<label>选择图片: <input type="file" name="image" required ></label>
								<input type="submit" value="转换">
                    </form>
					<div class="col-md-12" id="linkshow">
						 <h3>css代码</h3>
						 <div id="linklist">
							
							<textarea id="content" name="content" style="width: 650px; border: 1px solid #c5e2f2;
                    height: 300px; overflow: visible;" cols="20" rows="20"><?php if ($generator):  ?><?php echo $css  ?><?php endif ?></textarea>
						</div>
					</div>
			
                 
					<div class="col-md-12" id="linkshow">
						 <h3>html代码</h3>
						 <div id="linklist">
							<textarea id="content" name="content" style="width: 650px; border: 1px solid #c5e2f2;
                    height: 300px; overflow: visible;" cols="20" rows="20"><?php if ($generator):  ?><?php echo $html ?><?php endif ?></textarea>
						</div>
					</div>
				
					
				
			</div>
			</div>
		</div>
		<div class="col-md-3">
			<div class="panel panel-tianyu">
				<header class="panel-heading">
					<span class="glyphicon glyphicon-wrench"></span>工具介绍
				</header>
				<div class="panel-body">
						<p>通过本工具可以将图片转换成HTML，防止图片下载,防止图片盗链！把生成的css和DIV代码结合成HTML，由于此项目在线预览浪费资源特关闭预览，效果可以看下面的演示</p>
				</div>
			</div>
		</div>
		<div class="col-md-3">
			<div class="panel panel-tianyu">
				<header class="panel-heading">
					<span class="glyphicon glyphicon-save"></span>效果演示
				</header>
				<div class="panel-body">
						<a href="http://tool.zzs1.com/code/logo.html" class="btn btn-tianyu" target="_blank"><span class="glyphicon glyphicon-save">站长社LOGO演示</a>
				</div>
			</div>
		</div>
	</div>
</div>
<?php include('footer.php');?>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=1361866808579755" charset="utf-8"></script>
</body>
</html>