PHP微信柏拉图性格标签生成器源码


演示参考:http://www.erdangjiade.com/php/1176.html


效果图片:
前台页面:
  1. <!DOCTYPE html>
  2. <html><head>
  3. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;">
  7. <meta name="format-detection" content="telephone=no">
  8. <title>我的性格标签</title>
  9. <link rel="stylesheet" type="text/css" href="assets/4css.css">
  10. <script type="text/javascript" src="assets/jquery-1.js"></script>
  11. <script type="text/javascript" src="assets/hs_mobiscroll_date.js"></script>
  12. <script type="text/javascript" src="assets/hs_mobiscroll.js"></script>
  13. </head>
  14. <body onload="init()">
  15. <div class="background">
  16.     <div class="name">
  17.         <span class="title">姓名:</span>
  18.         <span class="write-name">
  19.             <input placeholder="请输入姓名(最多4个汉字)" class="user-name" maxlength="4" onblur="checkName()" type="text">
  20.         </span>
  21.     </div>
  22.     <div class="birthday">
  23.         <span class="title">生日:</span>
  24.         <span class="chose-birthday">
  25.             <input readonly="readonly" placeholder="请选择出生日期(阳历生日)" class="user-birthday" id="user_birthday" type="text">
  26.         </span>
  27.     </div>
  28. </div>
  29. <div style="width: 1152px; height: 167.767px; position: absolute; z-index: 10; top: 77%; left: 10%;" class="button" onclick="makePicture()"></div>

  30. <div class="transparent-float"></div>
  31. <div class="float">
  32.     <div style="width: 1353.6px; height: 1748.4px; position: relative; margin-top: 2%; margin-left: 3%;" class="picture-box">
  33.         <span class="close" onclick="closeFloat()"></span>
  34.         <span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 1; bottom: 2%; left: 2%;" class="picture">
  35.             <img class="mypicture" src="">
  36.         </span>
  37.         <span style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 2; top: 2%; left: 2%;" class="scan"></span>
  38.     </div>
  39.     <div style="width: 1353.6px; height: 205.512px; position: relative; margin-top: 5%; left: 3%;" class="text"></div>
  40. </div>

  41. <script type="text/javascript">
  42. $(function () {
  43.     var currYear = new Date().getFullYear();    

  44.     var opt={};
  45.     opt.date = {preset : 'date'};
  46.     opt.default = {
  47.         theme: 'android-ics light', 
  48.         display: 'bottom', 
  49.         mode: 'scroller',
  50.         dateFormat: 'yyyy-mm-dd',
  51.         lang: 'zh',
  52.         showNow: false,
  53.         startYear: currYear - 100,
  54.         endYear: currYear
  55.     };

  56.     $("#user_birthday").mobiscroll($.extend(opt['date'], opt['default']));
  57. });
  58. </script>
  59. <script type="text/javascript" src="assets/4js.js"></script>
  60. </body></html>
复制代码
数据处理:
  1. <?php
  2. if($_SERVER['REQUEST_METHOD'] == 'POST'){
  3.     $weixin = '二当家的素材网';
  4.     extract($_POST);

  5.     $month = intval(substr($birthday,5,2));
  6.     $day = intval(substr($birthday,8,2));
  7.     
  8.     if (empty($name) || $month < 1 || $month > 12 || $day < 1 || $day > 31){
  9.         echo '-1';
  10.         exit();
  11.     }
  12.     
  13.     $signs = array(
  14.         array('20'=>2),
  15.         array('19'=>3),
  16.         array('21'=>4),
  17.         array('20'=>5),
  18.         array('21'=>6),
  19.         array('22'=>7),
  20.         array('23'=>8),
  21.         array('23'=>9),
  22.         array('23'=>10),
  23.         array('24'=>11),
  24.         array('22'=>12),
  25.         array('22'=>1)
  26.     );
  27.     list($start, $num) = each($signs[$month-1]);
  28.     if ($day < $start){
  29.         list($start, $num) = each($signs[($month-2 < 0) ? 11 : $month-2]);
  30.     }

  31.     $basePath = dirname(__FILE__).'/';
  32.     $font1 = $basePath.'assets/font1.ttf';
  33.     $font2 = $basePath.'assets/font2.ttf';
  34.     $font3 = $basePath.'assets/font3.ttf';
  35.     $source = $basePath.'assets/'.$num.'.jpg';
  36.     $water = $basePath.'assets/footer.jpg';
  37.     $savepath = 'images/'.date('Ym');
  38.     $savename = md5($month.$day.$name).'.jpg';
  39.     $savefile = $savepath .'/'. $savename;
  40.     
  41.     if(!is_dir($basePath.$savepath)){
  42.         mkdir($basePath.$savepath,0777,true);
  43.     }
  44.     
  45.     if(file_exists($savefile)){
  46.         echo $savefile;
  47.         exit();
  48.     }
  49.     
  50.     if (!file_exists($source) || !file_exists($water)) {
  51.         echo '-1';
  52.         exit();
  53.     }

  54.     $source = imagecreatefromjpeg($source);
  55.     if (!$source) {
  56.         echo '-1';
  57.         exit();
  58.     }
  59.     $water = imagecreatefromjpeg($water);
  60.     if (!$water) {
  61.         echo '-1';
  62.         exit();
  63.     }
  64.     switch ($num) {
  65.         case 9:
  66.             $x=45;
  67.             $y=238;
  68.         break;
  69.         default:
  70.             $x=120;
  71.             $y=185;
  72.     }
  73.     imagefttext($source, 18, 0, $x, $y, imagecolorallocate($source, 175,152,85), $font1, $month.'月'.$day.'日');
  74.     $length = mb_strlen($name,'utf-8');
  75.     $margin = 120;
  76.     $left = 20;
  77.     if($length <= 4){
  78.         $margin = 140;
  79.         $left = 40;
  80.     }
  81.     for($i = 0; $i < $length; $i++){
  82.         imagefttext($source, 60, 0, $margin * $i + $left, 335, imagecolorallocate($source, 255,255,255), $font2, mb_substr($name,$i,1,'utf-8'));
  83.     }
  84.     imagecopymerge($source, $water, 40, 590, 0, 0, 110, 110, 100);
  85.     imagefttext($source, 17, 0, 175, 630, imagecolorallocate($source, 180,180,180), $font3, '长安识别二维码,生成您的性格签名');
  86.     imagefttext($source, 17, 0, 175, 670, imagecolorallocate($source, 180,180,180), $font3, '或关注“'.$weixin.'”公众号生成');
  87.     imagejpeg($source, $basePath.$savefile);
  88.     imagedestroy($source);
  89.     imagedestroy($water);
  90.     echo $savefile;
  91. }else{
  92.     echo '-1';
  93. }
复制代码
演示参考:http://www.erdangjiade.com/php/1176.html

转载于:https://www.cnblogs.com/66daima/p/7507681.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互操作控件微信小程序源码(含截图)交互
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值