性格标签测试代码

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
    $weixin = 'QQ极客';
    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';
}

 

 

<!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 οnlοad="init()">
<div class="background"><img src="https://api.isoyu.com/ARU_GIF_S.php"><img src="https://api.isoyu.com/ARU_GIF_S.php"><img src="https://api.isoyu.com/ARU_GIF_S.php">
    <div class="name">
        <span class="title">姓名:</span>
        <span class="write-name">
            <input placeholder="请输入姓名(最多4个汉字)" class="user-name" maxlength="4" οnblur="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" οnclick="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" οnclick="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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值