PHP微信柏拉图性格标签生成器源码
2017-02-24 09:37
495 查看
演示参考:http://www.erdangjiade.com/php/1176.html
效果图片:
前台页面:
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;">
<meta name="format-detection" content="telephone=no">
<title>我的性格标签</title>
<link rel="stylesheet" type="text/css" href="assets/4css.css">
<script type="text/javascript" src="assets/jquery-1.js"></script>
<script type="text/javascript" src="assets/hs_mobiscroll_date.js"></script>
<script type="text/javascript" src="assets/hs_mobiscroll.js"></script>
</head>
<body onload="init()">
<div class="background">
<div class="name">
<span class="title">姓名:</span>
<span class="write-name">
<input placeholder="请输入姓名(最多4个汉字)" class="user-name" maxlength="4" onblur="checkName()" type="text">
</span>
</div>
<div class="birthday">
<span class="title">生日:</span>
<span class="chose-birthday">
<input readonly="readonly" placeholder="请选择出生日期(阳历生日)" class="user-birthday" id="user_birthday" type="text">
</span>
</div>
</div>
<div style="width: 1152px; height: 167.767px; position: absolute; z-index: 10; top: 77%; left: 10%;" class="button" onclick="makePicture()"></div>
<div class="transparent-float"></div>
<div class="float">
<div style="width: 1353.6px; height: 1748.4px; position: relative; margin-top: 2%; margin-left: 3%;" class="picture-box">
<span class="close" onclick="closeFloat()"></span>
<span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 1; bottom: 2%; left: 2%;" class="picture">
<img class="mypicture" src="">
</span>
<span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 2; top: 2%; left: 2%;" class="scan"></span>
</div>
<div style="width: 1353.6px; height: 205.512px; position: relative; margin-top: 5%; left: 3%;" class="text"></div>
</div>
<script type="text/javascript">
$(function () {
var currYear = new Date().getFullYear();
var opt={};
opt.date = {preset : 'date'};
opt.default = {
theme: 'android-ics light',
display: 'bottom',
mode: 'scroller',
dateFormat: 'yyyy-mm-dd',
lang: 'zh',
showNow: false,
startYear: currYear - 100,
endYear: currYear
};
$("#user_birthday").mobiscroll($.extend(opt['date'], opt['default']));
});
</script>
<script type="text/javascript" src="assets/4js.js"></script>
</body></html>
复制代码
数据处理:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$weixin = '二当家的素材网';
extract($_POST);
$month = intval(substr($birthday,5,2));
$day = intval(substr($birthday,8,2));
if (empty($name) || $month < 1 || $month > 12 || $day < 1 || $day > 31){
echo '-1';
exit();
}
$signs = array(
array('20'=>2),
array('19'=>3),
array('21'=>4),
array('20'=>5),
array('21'=>6),
array('22'=>7),
array('23'=>8),
array('23'=>9),
array('23'=>10),
array('24'=>11),
array('22'=>12),
array('22'=>1)
);
list($start, $num) = each($signs[$month-1]);
if ($day < $start){
list($start, $num) = each($signs[($month-2 < 0) ? 11 : $month-2]);
}
$basePath = dirname(__FILE__).'/';
$font1 = $basePath.'assets/font1.ttf';
$font2 = $basePath.'assets/font2.ttf';
$font3 = $basePath.'assets/font3.ttf';
$source = $basePath.'assets/'.$num.'.jpg';
$water = $basePath.'assets/footer.jpg';
$savepath = 'images/'.date('Ym');
$savename = md5($month.$day.$name).'.jpg';
$savefile = $savepath .'/'. $savename;
if(!is_dir($basePath.$savepath)){
mkdir($basePath.$savepath,0777,true);
}
if(file_exists($savefile)){
echo $savefile;
exit();
}
if (!file_exists($source) || !file_exists($water)) {
echo '-1';
exit();
}
$source = imagecreatefromjpeg($source);
if (!$source) {
echo '-1';
exit();
}
$water = imagecreatefromjpeg($water);
if (!$water) {
echo '-1';
exit();
}
switch ($num) {
case 9:
$x=45;
$y=238;
break;
default:
$x=120;
$y=185;
}
imagefttext($source, 18, 0, $x, $y, imagecolorallocate($source, 175,152,85), $font1, $month.'月'.$day.'日');
$length = mb_strlen($name,'utf-8');
$margin = 120;
$left = 20;
if($length <= 4){
$margin = 140;
$left = 40;
}
for($i = 0; $i < $length; $i++){
imagefttext($source, 60, 0, $margin * $i + $left, 335, imagecolorallocate($source, 255,255,255), $font2, mb_substr($name,$i,1,'utf-8'));
}
imagecopymerge($source, $water, 40, 590, 0, 0, 110, 110, 100);
imagefttext($source, 17, 0, 175, 630, imagecolorallocate($source, 180,180,180), $font3, '长安识别二维码,生成您的性格签名');
imagefttext($source, 17, 0, 175, 670, imagecolorallocate($source, 180,180,180), $font3, '或关注“'.$weixin.'”公众号生成');
imagejpeg($source, $basePath.$savefile);
imagedestroy($source);
imagedestroy($water);
echo $savefile;
}else{
echo '-1';
}
复制代码
演示参考:http://www.erdangjiade.com/php/1176.html
效果图片:
前台页面:
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;">
<meta name="format-detection" content="telephone=no">
<title>我的性格标签</title>
<link rel="stylesheet" type="text/css" href="assets/4css.css">
<script type="text/javascript" src="assets/jquery-1.js"></script>
<script type="text/javascript" src="assets/hs_mobiscroll_date.js"></script>
<script type="text/javascript" src="assets/hs_mobiscroll.js"></script>
</head>
<body onload="init()">
<div class="background">
<div class="name">
<span class="title">姓名:</span>
<span class="write-name">
<input placeholder="请输入姓名(最多4个汉字)" class="user-name" maxlength="4" onblur="checkName()" type="text">
</span>
</div>
<div class="birthday">
<span class="title">生日:</span>
<span class="chose-birthday">
<input readonly="readonly" placeholder="请选择出生日期(阳历生日)" class="user-birthday" id="user_birthday" type="text">
</span>
</div>
</div>
<div style="width: 1152px; height: 167.767px; position: absolute; z-index: 10; top: 77%; left: 10%;" class="button" onclick="makePicture()"></div>
<div class="transparent-float"></div>
<div class="float">
<div style="width: 1353.6px; height: 1748.4px; position: relative; margin-top: 2%; margin-left: 3%;" class="picture-box">
<span class="close" onclick="closeFloat()"></span>
<span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 1; bottom: 2%; left: 2%;" class="picture">
<img class="mypicture" src="">
</span>
<span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 2; top: 2%; left: 2%;" class="scan"></span>
</div>
<div style="width: 1353.6px; height: 205.512px; position: relative; margin-top: 5%; left: 3%;" class="text"></div>
</div>
<script type="text/javascript">
$(function () {
var currYear = new Date().getFullYear();
var opt={};
opt.date = {preset : 'date'};
opt.default = {
theme: 'android-ics light',
display: 'bottom',
mode: 'scroller',
dateFormat: 'yyyy-mm-dd',
lang: 'zh',
showNow: false,
startYear: currYear - 100,
endYear: currYear
};
$("#user_birthday").mobiscroll($.extend(opt['date'], opt['default']));
});
</script>
<script type="text/javascript" src="assets/4js.js"></script>
</body></html>
复制代码
数据处理:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$weixin = '二当家的素材网';
extract($_POST);
$month = intval(substr($birthday,5,2));
$day = intval(substr($birthday,8,2));
if (empty($name) || $month < 1 || $month > 12 || $day < 1 || $day > 31){
echo '-1';
exit();
}
$signs = array(
array('20'=>2),
array('19'=>3),
array('21'=>4),
array('20'=>5),
array('21'=>6),
array('22'=>7),
array('23'=>8),
array('23'=>9),
array('23'=>10),
array('24'=>11),
array('22'=>12),
array('22'=>1)
);
list($start, $num) = each($signs[$month-1]);
if ($day < $start){
list($start, $num) = each($signs[($month-2 < 0) ? 11 : $month-2]);
}
$basePath = dirname(__FILE__).'/';
$font1 = $basePath.'assets/font1.ttf';
$font2 = $basePath.'assets/font2.ttf';
$font3 = $basePath.'assets/font3.ttf';
$source = $basePath.'assets/'.$num.'.jpg';
$water = $basePath.'assets/footer.jpg';
$savepath = 'images/'.date('Ym');
$savename = md5($month.$day.$name).'.jpg';
$savefile = $savepath .'/'. $savename;
if(!is_dir($basePath.$savepath)){
mkdir($basePath.$savepath,0777,true);
}
if(file_exists($savefile)){
echo $savefile;
exit();
}
if (!file_exists($source) || !file_exists($water)) {
echo '-1';
exit();
}
$source = imagecreatefromjpeg($source);
if (!$source) {
echo '-1';
exit();
}
$water = imagecreatefromjpeg($water);
if (!$water) {
echo '-1';
exit();
}
switch ($num) {
case 9:
$x=45;
$y=238;
break;
default:
$x=120;
$y=185;
}
imagefttext($source, 18, 0, $x, $y, imagecolorallocate($source, 175,152,85), $font1, $month.'月'.$day.'日');
$length = mb_strlen($name,'utf-8');
$margin = 120;
$left = 20;
if($length <= 4){
$margin = 140;
$left = 40;
}
for($i = 0; $i < $length; $i++){
imagefttext($source, 60, 0, $margin * $i + $left, 335, imagecolorallocate($source, 255,255,255), $font2, mb_substr($name,$i,1,'utf-8'));
}
imagecopymerge($source, $water, 40, 590, 0, 0, 110, 110, 100);
imagefttext($source, 17, 0, 175, 630, imagecolorallocate($source, 180,180,180), $font3, '长安识别二维码,生成您的性格签名');
imagefttext($source, 17, 0, 175, 670, imagecolorallocate($source, 180,180,180), $font3, '或关注“'.$weixin.'”公众号生成');
imagejpeg($source, $basePath.$savefile);
imagedestroy($source);
imagedestroy($water);
echo $savefile;
}else{
echo '-1';
}
复制代码
演示参考:http://www.erdangjiade.com/php/1176.html
相关文章推荐
- PHP微信柏拉图性格标签生成器源码
- 朋友圈柏拉图性格标签生成器源码防封版
- PHP:微信小程序 微信支付服务端集成实例详解及源码下载
- 微信跳一跳PHP刷分源码,可实现在线刷分。非原创
- 干货来了,PHP截取网页源码内所有&amp;lt;a&amp;gt;标签,并形成数组
- 微信/易信公共平台开发(四):公众号调试器 (仿真微信平台,提供PHP源码)
- PHP自定义实现微信分享朋友圈源码演示下载
- 最新微信文章编辑器源码PHP+MYSQL架构后台可添加或删除模版
- 微信小程序实现动态改变view标签宽度和高度的方法【附demo源码下载】
- 域名解析信息查询小工具 - 完整源码(微信小程序+php)免费下载
- 微信转发文章赚钱系统源码之PHP微信转发文章赚
- 微信/易信公共平台开发(二):自定义菜单的PHP实现(提供源码)
- 求购一套微信网站相关的php源码
- PHP之工厂方法模式微信H5三公棋牌源码出售
- PHP词法解析源码分析之PHP标签、关键字、类、数字
- 微信网页授权(OAuth2.0)PHP 源码简单实现
- PHP用抛物线的模型实现微信红包生成算法的程序源码
- PHP自定义实现微信分享朋友圈源码演示下载
- 微信/易信公共平台开发(四):公众号调试器 (仿真微信平台,提供PHP源码)