1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| public function Chemical(){ $id = rand(1,10186); $results = Db::name("vcode")->where("id",$id)->find(); $url = "https://www.chemicalbook.com/CAS/GIF/".$results["cas"].".gif"; ob_end_clean(); Header("HTTP/1.1 303 See Other"); Header("Location: $url"); session('Checknum', $results["anwser"]); }
public function History(){ $id = rand(1,30000); $results1 = Db::table("event")->where("id",$id)->find(); $type = $results1['y']; $year = $results1['d']; $riqi = $results1['i']; $info = $results1['p']; if($type != "0"){ $id = rand(1,30000); $results1 = Db::table("event")->where("id",$id)->find(); $type = $results1['y']; $year = $results1['d']; $riqi = $results1['i']; $info = $results1['p']; } switch ($type) { case '0': $t="大事件发生"; break; case '1': $t="人物出生"; break; case '2': $t="人物逝世"; break;
default: break; } $year = str_replace("前", "-", $year); $year = str_replace("年", "", $year); $month = explode("月",$riqi); $m = sprintf("%02d", $month[0]); $d = sprintf("%02d", str_replace("日","",$month[1])); $ttt=$t.":\n".$info; $width = (strlen($info)>=189) ? 500 : 250 ; $im = imagecreatetruecolor(500, $width); $backgroundColor = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $backgroundColor); $box = new Box($im); $box->setFontFace(ROOT_PATH.'/SourceHanSansCN-Regular.otf'); $box->setFontColor(new Color(0, 0, 0)); $box->setTextShadow(new Color(0, 0, 0, 50), 0, 0); $box->setFontSize(28); $box->setLineHeight(1.5); $box->setBox(20, 20, 460, 460); $box->setTextAlign('left', 'top'); $box->draw($ttt ); session('Checknum', $year.$m.$d); header("Content-type: image/png;"); header("cache-control:no-cache,must-revalidate"); imagepng($im); imagedestroy($im); }
public function Matrix(){ $image = imagecreatefrompng(ROOT_PATH."/bg.png"); $black = imagecolorallocate($image, 0, 0, 0); $id = rand(1,22523); $size = 22; $font = ROOT_PATH.'/SourceHanSansCN-Regular.otf'; $text="1"; $results1 = Db::table("m")->where("id",$id)->find(); $m1 = $results1['m1']; $m2 = $results1['m2']; $anwser = $results1['anwser']; $m1_ex = explode(";",$m1); $m2_ex = explode(";",$m2); $row = ""; foreach ($m1_ex as $key => $value) { foreach (explode(" ",$value) as $key1 => $value1) { $row = $row.$value1." "; } imagettftext($image, $size, 0, 45, 130+$key*40, $black, $font, $row); $row = ""; } foreach ($m2_ex as $key => $value) { foreach (explode(" ",$value) as $key1 => $value1) { $row = $row.$value1." "; } imagettftext($image, $size, 0, 307, 130+$key*40, $black, $font, $row); $row = ""; } ob_end_clean(); header("cache-control:no-cache,must-revalidate"); session('Checknum', $anwser); header('content-type: image/png'); imagepng($image); imagedestroy($image); }
|