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

原文链接: https://yq.aliyun.com/articles/561456

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


效果图片: PHP微信柏拉图性格标签生成器源码_第1张图片
前台页面:
  1.  http-equiv="content-type" content="text/html; charset=UTF-8">
  2.  charset="utf-8">
  3.  http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  4.  name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;">
  5.  name="format-detection" content="telephone=no">
  6. </span><span class="pln">我的性格标签</span><span class="tag">
  7.  rel="stylesheet" type="text/css" href="assets/4css.css">
  8.  type="text/javascript" src="assets/jquery-1.js">
  9.  type="text/javascript" src="assets/hs_mobiscroll_date.js">
  10.  type="text/javascript" src="assets/hs_mobiscroll.js">
  11.  onload="init()">
  12.  class="background">
  13.      class="name">
  14.          class="title">姓名:
  15.          class="write-name">
  16.              placeholder="请输入姓名(最多4个汉字)" class="user-name" maxlength="4" onblur="checkName()" type="text">
  17.         
  18.     
  •      class="birthday">
  •          class="title">生日:
  •          class="chose-birthday">
  •              readonly="readonly" placeholder="请选择出生日期(阳历生日)" class="user-birthday" id="user_birthday" type="text">
  •         
  •     
  •  style="width: 1152px; height: 167.767px; position: absolute; z-index: 10; top: 77%; left: 10%;" class="button" onclick="makePicture()">

  •  class="transparent-float">
  •  class="float">
  •      style="width: 1353.6px; height: 1748.4px; position: relative; margin-top: 2%; margin-left: 3%;" class="picture-box">
  •          class="close" onclick="closeFloat()">
  •          style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 1; bottom: 2%; left: 2%;" class="picture">
  •              class="mypicture" src="">
  •         
  •          style="width: 1299.46px; height: 1537.69px; position: absolute; z-index: 2; top: 2%; left: 2%;" class="scan">
  •     
  •      style="width: 1353.6px; height: 205.512px; position: relative; margin-top: 5%; left: 3%;" class="text">

  •  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']));
  • });
  •  type="text/javascript" src="assets/4js.js">
  • 复制代码
    数据处理:
    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

    你可能感兴趣的:(PHP微信柏拉图性格标签生成器源码)