/** * 输出验证码图像资源 * 将验证码存入库 */ public function set_verify_code() { $verify_id = $this->input['type']; $session_id = $this->input['session_id']; if (!$verify_id) { $sql = "SELECT id FROM " . DB_PREFIX . "verify WHERE is_default = 1"; $tmp = $this->db->query_first($sql); if ($tmp['id']) { $verify_id = $tmp['id']; } else { $this->errorOutput('缺少验证码id'); } } //取参数 $sql = "SELECT v.*,f.name AS fontface,p.name AS bg_pic,p.type AS pic_type FROM " . DB_PREFIX . "verify v \r\n\t\t \tLEFT JOIN " . DB_PREFIX . "font f ON v.fontface_id=f.id \r\n\t\t \tLEFT JOIN " . DB_PREFIX . "bgpicture p ON v.bgpicture_id=p.id \r\n\t\t \tWHERE v.id = " . $verify_id; $parameter = $this->db->query_first($sql); require_once 'lib/captche.class.php'; $captche = new Captche($parameter); //向浏览器输出图像 $captche->showImage(); $code = $captche->getCheckCode(); //验证码入库 if ($session_id) { $sql = "INSERT INTO " . DB_PREFIX . "verify_code SET \r\n\t\t\t\t\t\t\t\t\t\tsession_id='" . $session_id . "',\r\n\t\t\t\t\t\t\t\t\t\tcode='" . $code . "',\r\n\t\t\t\t\t\t\t\t\t\tis_dipartite='" . $parameter['is_dipartite'] . "',\r\n\t\t\t\t\t\t\t\t\t\tcreate_time='" . TIMENOW . "'"; $this->db->query($sql); } $this->addItem('success'); $this->output(); }
/** * 预览 * Enter description here ... */ public function preview() { $parameter = $this->input['parameter']; $parameter = json_decode($parameter, 1); require_once CUR_CONF_PATH . 'lib/captche.class.php'; $captche = new Captche($parameter); //向浏览器输出图像 $captche->showImage(); }