- 积分
- 16992
- UID
- 4
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
发表于 2006-10-1 10:05:56
|
显示全部楼层
SETI3E
- <?php
- function http_get($url)
- {
- $result = shell_exec("wget -q -O - $url");
- return $result;
- }
- if(!$_GET[userid]){
- $userid="";
- }
- $file = "http://setiathome.berkeley.edu/userw.php?id=";
- $file .= $userid;
- $map_array = array(
- "BOLD" => "B",
- "EMPHASIS" => "I",
- "LITERAL" => "TT"
- );
- function startElement($parser, $name, $attrs)
- {
- global $map_array;
- if (isset($map_array[$name])) {
- echo "<$map_array[$name]>";
- }
- }
- function endElement($parser, $name)
- {
- global $map_array;
- if (isset($map_array[$name])) {
- echo "</$map_array[$name]>";
- }
- }
- function characterData($parser, $data)
- {
- global $outdata;
- $outdata[]=$data;
- }
- $xml_parser = xml_parser_create();
- // use case-folding so we are sure to find the tag in $map_array
- xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
- xml_set_element_handler($xml_parser, "startElement", "endElement");
- xml_set_character_data_handler($xml_parser, "characterData");
- if (!($fp = fopen($file, "r"))) {
- die("could not open XML input");
- }
- while ($data = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $data, feof($fp))) {
- die(sprintf("XML error: %s at line %d, ",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
- }
- xml_parser_free($xml_parser);
- /* 发送文件头以使浏览器知道文件类型*/
- header("Content-type: image/jpeg");
- /* 以给定长和宽创建空白新图片 */
- $im = imagecreatetruecolor(380,100);
- /* 从原始大图获取资料 */
- //$origImg = ImageCreateFromJPEG("seti.jpg");
- //ImageCopyResized($im,$origImg,0,0,0,0,380,100,ImageSX($origImg),ImageSY($origImg));
- imagefilledrectangle($im, 0, 0, 380, 150, $background_color);
- $secondImg = ImageCreateFromJPEG("seti3e.jpg");
- ImageCopyResized($im,$secondImg,270,0,0,0,ImageSX($secondImg),ImageSY($secondImg),ImageSX($secondImg),ImageSY($secondImg));
- $origImg = ImageCreateFromJPEG("seti3e.jpg");
- ImageCopyResized($im,$origImg,0,0,0,0,380,100,ImageSX($origImg),ImageSY($origImg));
- $background_color = imagecolorallocate($im, 0, 0, 0);
- $black = ImageColorAllocate($im, 255,255,255);
- $text_color = imagecolorallocate($im, 0, 0, 0);
- //$text_color = imagecolorallocate($im, 0, 0, 0);
- //$text_color = imagecolorallocate($im, 0, 0, 255);
- // imagestring($im, 20, 85,5, "SETI@Home", $text_color);
- imagestring($im, 20, 9,5, ereg_replace('for ','',$outdata[2]), $text_color);
- for($i=4;$i<count($outdata);$i++){
- imagestring($im, 20, 9,20+(15*($i-4)), $outdata[$i], $text_color);
- }
- //imagestring($im, 20, 0,130, $outdata[3], $text_color);
- //imageline($im, 55, 20, 250, 20, $black);
- //imagefilledrectangle($im, 0, 0, 380, 150, $background_color);
- imagejpeg($im);
- imagedestroy($im);
- ?>
复制代码 |
|