/** * 获取学校验证码 * @method GET_codeAction * @param integer $id [description] * @author NewFuture */ public function GET_codeAction($id = 0) { if ($code = School::code($id)) { $code['img'] = 'data:image/png;base64,' . base64_encode($code['img']); $this->response(1, $code); } elseif ($code === false) { $this->response(0, '无需验证码'); } else { Log::write('验证码获取失败' . $id, 'ERROR'); $this->response(-3, $id . '验证码获取失败'); } }
/** * 验证码 * @method codeAction * @param integer $sch_id [学校id] * @return [image] [description] * @author NewFuture */ public function codeAction($sch_id = 0) { $code = School::code($sch_id); $this->_response->setHeader('Content-type', 'image/jpeg'); echo $code; }