
17-09-2008, 17:04
|
|
|
|
חבר מתאריך: 04.09.08
הודעות: 50
|
|
אפשר:
קוד PHP:
<?php header("Content-type: image/gif"); //================================================== ==================== class Diploma { var $course; var $student; var $settings; //================================================== ==================== function Diploma($student,$course){ $this->settings = array('baseURL' => 'Diploma.gif', 'font' => 5, 'fontcr' => 189, 'fontcg' => 216, 'fontcb' => 232, 'useICONV' => false, 'studentY' => 155, 'studentX' => 330, 'courseX' => 165, 'courseY' => 250 ); //++++++++ $this->course = $this->validCourse(trim($course)); $this->student = $this->validStudent(trim($student)); } //================================================== ==================== function validCourse($course){ if(strlen($course) < 1 || strlen($course) > 9) return false; return $course; } //================================================== ==================== function validStudent($student){ if(strlen($student) < 2 || strlen($student) > 28) return false; return $student; } //================================================== ==================== function ErrorOutput($errorstr){ $image = imagecreate(400, 50); $bg = imagecolorallocate($image, 250, 250, 250); $textcolor = imagecolorallocate($image, $this->settings['fontcr'], $this->settings['fontcg'], $this->settings['fontcb']); imagestring($image, $this->settings['font'], 5, 5, 'Error creating Diploma: '.$errorstr, $textcolor); imagegif($image); imagedestroy($image); die(); } //================================================== ==================== function output(){ if($this->course === false) $this->ErrorOutput('Bad Course'); if($this->student === false) $this->ErrorOutput('Bad Student'); //++++++++ $image = @imagecreatefromgif($this->settings['baseURL']); if(!$image || $image === false) $this->ErrorOutput('Loading Base Failure'); //++++++++ if($this->settings['useICONV'] && ereg("[א-ת]",$this->student)) $student = iconv("Windows-1255", "Latin2", $this->student); else $student = $this->student; //++++++++ $textcolor = imagecolorallocate($image, $this->settings['fontcr'], $this->settings['fontcg'], $this->settings['fontcb']); imagestring($image, $this->settings['font'], ($this->settings['studentX']-(strlen($student)*$this->settings['font'])-70), $this->settings['studentY'], $student, $textcolor); imagestring($image, $this->settings['font'], ($this->settings['courseX']-(strlen($this->course)*$this->settings['font'])-10), $this->settings['courseY'], $this->course, $textcolor); imagegif($image); imagedestroy($image); } } //================================================== ==================== if(!isset($_GET['student'])) $student = ''; else $student = trim($_GET['student']); if(!isset($_GET['course'])) $course = ''; else $course = trim($_GET['course']); $diploma = new Diploma($student,$course); $diploma->output(); ?>
וזה לא בהעלאת קבצים כפי שאתה רואה, תמונת GIF שהעלתי בFTP לשרת בגודל 400*500.
הטקסט פשוט נכתב בלבן [כשמסמנים את התמונה ב IE רואים את זה], ולא בצבע שבחרתי.
|