1. 준비 요소
1) 글꼴 JS 파일을 교체하십시오
JS 코드 :
함수 com_stewartspeak_replacement () {/* dynamic heading generator by Stewart Rosenberger http://www.stewartspeak.com/headings/이 스크립트는 웹 페이지를 통해 특정 또는 일반 요소에 대해 검색하고 서버-면에서 동적으로 생성 된 이미지로 대체합니다. 스크립트.*/ReplacesElector ( "h1", "dynatext/heading.php", true); // 처음 두 매개 변수는 var testurl = "dynatext/loading.gif"; // 해당 이미지 경로로 수정해야합니다. var onotprintimages = false; var printercs = "Replacement-print.css"; var hideflicker = false; var hideflickercss = "Replacement-screen.css"; var hideflickertimeout = 100; // 책임 수정은 여기에서 만들 수 있습니다/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- further customize this script's abilities, make sure you're familiar with 자바 스크립트. 그리고 소다 또는 무언가를 잡습니다.*/ var 항목; var imageloaded = false; var documentloaded = false; 함수 replacesElector (selector, url, wordwrap) {if (typeof items == "undefined") 항목 = new Array (); 항목 [items.length] = {selector : selector, url : url, url, wordwrap : wordwrap};} if (hideflicker) {document.write ( '<link id = "hide-flicker"rel = "stylesheet"media = "screen"href = "' + hideflickercss + '" />'); window.flickercheck = function () {if (! imageloaded) setStylesheetstate ( 'hide-flicker', false); }; settimeout ( 'wind var test = new image (); test.onload = function () {imageLoaded = true; if (DocumentRoaded) 대체 (); }; test.src = testurl + "? date =" + (new date ()). gettime (); addloadhandler (function () {DocumentLoaded = true; if (imageLoaded) replacement ();}); 함수 documentload () {documentloaded = true; if (imageOloaded) replacement ();} 함수 대체 () {for (var i = 0; i <initem.length; i ++) {var elements = getElementsByselector (items [i] .Selector); (var j = 0; j <elements.lenges.length; j ++) {if (! elements [j]) 계속; var text = ExtractText (elements [j]); while (elements [j] .haschildnodes ()) 요소 [j] .removechild (elements [j] .firstchild); var 토큰 = 항목 [i] .wordwrap? text.split ( '') : [text]; for (var k = 0; k <tokens.length; k ++) {var url = 항목 [i] .url+"? text ="+Escape (Tokens [k]+'')+"& selector ="+Escape (Item [i] .selector); var image = document.createelement ( "IMG"); image.classname = "교체"; image.alt = 토큰 [k]; image.src = url; 요소 [j]. AppendChild (이미지); } if (donotPrintimages) {var span = document.createElement ( "span"); span.style.display = 'none'; span.classname = "print-text"; span.appendChild (document.createtextNode (텍스트)); 요소 [j]. AppendChild (span); }}} if (hideflicker) setStylesheetstate ( 'hide-flicker', false);} 함수 addloadhandler (handler) {if (wind } else if (window.attachevent) {wind } else if (window.onload) {var oldhandler = window.onload; Window.onload = function piggyback () {OldHandler (); 매니저(); }; } else {window.onload = handler; }} 함수 setStylesHeetState (id, enabled) {var sheet = document.getElementById (id); if (sheet) sheet.disabled = (! enabled);} function extrectText (element) {if (typeof element == "String") 리턴 요소; else if (typeof element == "undefined") 리턴 요소; else if (element.innertext) retoynnerText; var text = ""; var kids = element.childnodes; for (var i = 0; i <kids.length; i ++) {if (kids [i] .nodeType == 1) text+= extrestText (kids [i]); else if (kids [i] .nodeType == 3) text += kids [i] .nodevalue; } return text;} /* 주어진 CSS 선택기 규칙과 일치하는 페이지에서 요소를 찾습니다. 일부 복잡한 규칙은 호환되지 않습니다. Simon Willison의 훌륭한 "GetElementsByselector"기능을 기반으로합니다. 원본 코드 (주석 및 설명 포함) : http://simon.incutio.com/archive/2003/03/25/getelementsbyselector*/function getElementsByselector (선택기) {var tokens = selector.split ( ''); var currentContext = 새 배열 (문서); for (var i = 0; i <tokens.length; i ++) {token = tokens [i] .replace (/^/s+/, ''). 교체 (// s+$/, ''); if (token.indexof ( '#')> -1) {var bits = token.split ( '#'); var tagname = 비트 [0]; var id = 비트 [1]; var 요소 = document.getElementById (id); if (tagname && element.nodename.tolowercase ()! = tagname) return new array (); currentContext = 새 배열 (요소); 계속하다; } if (token.indexof ( '.')> -1) {var bits = token.split ( '.'); var tagname = 비트 [0]; var className = 비트 [1]; if (! tagname) tagname = '*'; var found = 새로운 배열; var foundCount = 0; for (var h = 0; h <currentContext.length; h ++) {var elements; if (tagname == '*') elements = currentContext [h] .all? currentContext [h] .all : currentContext [h] .getElementsByTagName ( '*'); else elements = currentContext [h] .getElementsByTagName (tagname); for (var j = 0; j <elements.lenges.length; j ++) found [foundCount ++] = 요소 [j]; } currentContext = 새 배열; var currentContextIndex = 0; for (var k = 0; k <found.length; k ++) {if (found [k] .classname && found [k] .classname.match (new regexp ( '// b'+classname+'// b'))) currentContext [currentContextIndex ++] = 발견 된 [k]; } 계속하다; } if (token.match (/^(/w*)/[(/w+) ([/w+) ([= ~/|/^/$/*] =? "?"? "?"? "? if (! tagname) var var var h <currentcontext.lengess (tagname = h] CurrentContext (getElementsByTagName) (var j = 0; j ++) [j] (AtttRValue); (Attattribe) (attrname) (attrname). CurrentContext [k]} founds = 0; FoundCount ++] = Elements [J];} furrentContext;2) 그림의 PHP 파일을 생성하십시오
<? php/* Stewart Rosenberger의 동적 제목 생성기 http://www.stewartspeak.com/headings/이 스크립트는 지정한 글꼴/크기로 작성된 텍스트의 PNG 이미지를 생성합니다. 이 PNG 이미지는 브라우저로 다시 전달됩니다. 선택적으로 나중에 사용하기 위해 캐시 할 수 있습니다. 캐시 된 이미지가 발견되면 새 이미지가 생성되지 않으며 기존 사본이 브라우저로 전송됩니다. PHP의 이미지 처리 기능에 대한 추가 문서는 http://www.php.net/image/ */$ font_file = 'trebuc.ttf'; // 해당 xiuga $ font_size = 23에서 찾을 수 있습니다. ; $ transparent_background = true; $ cache_images = true; $ cache_folder = 'cache';/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; $ send_buffer_size = 4096; // gd supportif (! function_exists ( 'imageCreate'))) fatal_error ( '오류 : 서버가 PHP 이미지 생성을 지원하지 않음') // textif 정리 (empty ($ _ get [ 'text'])) fatal_error ( '오류 : 텍스트가 지정되지 않음'); $ text = $ _get [ 'text']; if (get_magic_quotes_gpc ()) $ text = stripSlashes ($ text); $ text = javaScript_to_html ($ text); // 캐시 된 사본을 찾으십시오. $ hash = md5 (basename ($ font_file). $ font_size. $ font_color. $ backgring_color. $ transparent_background. $ text); $ cache_filename = $ cache_folder. '/'. $ 해시. $ extension; if ($ cache_images && ($ file = @fopen ($ cache_filename, 'rb'))) {header ( 'content-type :'. $ mime_type); while (! feof ($ file)) print (($ buffer = fread ($ file, $ send_buffer_size))); fclose ($ 파일); 종료;} // 글꼴 가용성 확인 $ font_found = is_readable ($ font_file); if (! $ font_found) {fatal_error ( 'error : 서버에 지정된 글꼴이 없음);} // 이미지 생성 $ background_rgb = hex_to_rgb ($ background_rgb); $ font_rgb =. hex_to_rgb ($ font_color); $ dip = get_dip ($ font_file, $ font_size); $ box = @imagettfbbox ($ font_size, 0, $ font_file, $ text); $ image = @imagecreate ($ box [2]-$ box [0]), ($ box |); {fatal_error ( '오류 : 서버 가이 제목 이미지를 만들 수 없습니다. imageColorAllocate ($ im imageTtfText ($ im // transparentif를 설정합니다 ($ transparent_background) imageColortransparent ($ image, $ background_color); 헤더 ( 'content-type :'. $ mime_type); imagepng ($ image); // cacheif ($ cache_images)에 대한 이미지 사본을 저장 {@imagepng ($ image, $ cache_filename);} imageStroy ($ image); 출구 ; /*이 크기에 대해이 글꼴의 "DIP"(기준선 아래로 떨어진 픽셀)을 결정하십시오.*/function get_dip ($ font, $ size) {$ test_chars = 'abcdefghijklmnopqrstuvwxyz'. 'abcdefghijklmnopqrstuvwxyz'. '1234567890'. '! @#$%^&* ()/'///;. 대신 500 코드로서의 브라우저. * // fatal_error ($ message) {// if (function_exists ( 'imageCreate')) {$ width = imageFontWidth ($ message) + 10; image inmate, 255,255,255) 코드 헤더 (http/1.0 500 내부 서버 오류”; if ($ hex, 0,1) == '#') $ hex = SORMAND ( 'ffff') {$ hex = substr ($ hex, 0,1). SARDTR ($ hex, 2,1); if (strlen ($ hex)! = 6) avalid color ". $ hex. '"); $ rgb [ 'blue'] = hexdec ($ hex, 4,2); preg_match_all ( '/%u ([0-9a-f] {4})/i', $ text, $ matches (! empty ($ matches)); '&#'. hexdec ($ matches [1] [$ i]). ';', $ text);3) 필수 글꼴
여기에서 필요한 자체를 JS 및 PHP 파일과 동일한 디렉토리에 넣습니다 (또한 수정할 수도 있지만 해당 파일도 수정해야합니다).
4) PHP의 GD2 라이브러리
2. HTML 코드를 구현했습니다
<? php // 팝업 Utils 라이브러리로드 // require_once '포함/popup_utils.inc.php';?> <! doctype html public "-// w3c // dtd xhtml 1.1 // <head> <title> PHP를 사용한 전문 검색 엔진 최적화 : 목차 </title> <script type = "text/javaScript"language = "javaScript"src = "dynatext/eplacement.js"> </script> </head> <body onload = "window.resizeto (800,600);" onresize = 'settimeout ( "wind // display_popup_navigation (); ?> <ol> <li> You : 프로그래머 및 검색 엔진 마케팅 담당자 </li> <li> 기본 SEO의 프라이머 </li> <li> 도발적인 SE- 친화적 인 URLS </li> <li> 컨텐츠 재배치 및 HTTP 상태 코드 </li> <li> Duplication Content </li> <li> se-friendly html and javascript </li> <li> Black Hat Seo </li> <li> sitemaps </li> <li> 링크 미끼 </li> <li> IP Cloaking, Geo-Targeting 및 IP Delivery </li> <li> 외국어 SEO </li> <li> 기술적 문제에 대처하는 </li> <li> 사이트 클리닉 : 웹 사이트를 가졌습니까? <li> 정규 표현 소개 </li> </ol> </body> </html>
3. 사용 전후의 비교
사용하기 전에
사용 후