<?php
/*显示名片图片
*http://39wifi.com
*/
include "img.php";
require_once('inc/configue.php');
if (empty($_GET['act'])){exit;}
$fil=$_GET['act'];
if (strlen($fil)==11){$n="tel";}else{$n="uid";}
$m=$db->pe_select('mp_39',array($n=>$fil));
if ($m==null){exit;}
$json=json_decode(base64_decode($m['text']),true);//stripslashes清除转义的‘\’,json_decode可选参数true定义强制转换成数组
$f1="fonts/".rand(1,12);
if(file_exists($f1.".TTF")) {
 $f=$f1.".TTF";  
 }else{$f=$f1.".ttf"; }
 $a=empty($_GET['mod'])?0:1;
$img=new Image($json[$a]['Background']);
      foreach($json[$a]['Texts'] as $w){
             $color = str_replace('#','',$w['RGBColor']);
$rgb = array(hexdec(substr($color,0,2)),
hexdec(substr($color,2,2)),
hexdec(substr($color,4,2)),1);
          
           $img->fontMark($f,$w['Text'],$w['FontSize']-2,$rgb,array($w['Left'],($w['Top']+$w['FontSize'])),$angle=0);
      }
      if(count($json[$a]['Images'])){
          if(!empty($json[$a]['Images'][1])){
              $img->imageMark($json[$a]['Images'][1]['ImageUrl'],array($json[$a]['Images'][1]['Left'],$json[$a]['Images'][1]['Top']),array($json[$a]['Images'][1]['Width'],$json[$a]['Images'][1]['Height']));
          }
          $img->imageMark($json[$a]['Images'][0]['ImageUrl'],array($json[$a]['Images'][0]['Left'],$json[$a]['Images'][0]['Top']),array($json[$a]['Images'][0]['Width']-5,$json[$a]['Images'][0]['Height']-5)); 
       }
       $img->show();
?>