<?php
namespace imcat;
(!defined('RUN_INIT')) && die('No Init');

glbHtml::head('html');
// 邮箱,短信发送接口

$ucfg = read('user','sy'); 
//die("success");

$mod = req('mod');
$tel = req('tel');
$code = req('code');

// 发短信-验证码
if($mod=='sms-vcode' && $ucfg['regnow']=='sms-vcode' && $code && $tel){
    safComm::urlFrom();
    safComm::urlStamp('check',480); // 8min(5min)
    $vcres = safComm::formCVimg('vsms4', $code, 'check', 480);
    if($vcres) die("var ajres='验证码错误！';"); // $vcres
    // check 发送频率
    $sms = new extSms();
    $tpl = $ucfg['utpls'][$mod];
    $code = basKeyid::kidRand('0',6);
    if(method_exists($sms->smsdo, 'sendTid')){
        $re = $sms->sendTid($tel, '', array('code'=>$code), array('pid'=>"$mod:$code"));
    }else{
        $re = $sms->sendTpl($tel, $tpl, array('code'=>$code), array('pid'=>"$mod:$code"));
    }
    if($re[0]==1) die("var ajres='success';");
    else die("var ajres='{$re[1]}';");
//}elseif($mod=='mail-act'){
    //
}else{
    die("var ajres='Unknow Error!';");
    //die("var _repeat_res = '$msg';");
}

