1. Elementos de preparación
1) Reemplace el archivo Font JS
Código JS:
función com_stewartspeak_replacation () {/* generador de encabezado dinámico por Stewart Rosenberger http://www.stewartspeak.com/headings/ Este script busca a través de una página web para elementos específicos o generales y los reemplaza con imágenes generadas dinámicamente, en conjunto con un servidor script.*/replacesElector ("H1", "Dynatext/Heading.php", true); // Los dos primeros parámetros deben modificarse var testUrl = "Dynatext/Loading.gif"; // Modificar a la vía de imagen correspondiente var dontPrintimages = false; var printercsss = "reemplazo-print.css"; var hideflicker = false; var hideflickercss = "reemplazo-screen.css"; var hideflickerTimeOut = 100; // Se pueden hacer modificaciones responsables aquí/* --------------------------------------------------------------------------------------------------------------------------------------------------------------- Javascript. Y tome un refresco o algo.*/ Var elementos; var imageLoaded = false; var documentloaded = false; function reemplaateselector (selector, url, wordwrap) {if (typeof elementos == "indefinido") elementos = new array (); elementos [elementos.length] = {selector: selector, url: url, wordwrap: wordwrap};} if (hideflicker) {document.write ('<link id = "hide-flicker" rel = "stylesheet" medios = "pantalla" href = "' + hideflickercss + '" />'); Window.flickerCheck = function () {if (! imageLoaded) setstylesheetState ('hide-flicker', falso); }; setTimeOut ('Window.flickerCheck ();', hideflickerTimeOut)} if (DonotPrIntimages) document.write ('<link id = "print-text" rel = "stylesheet" medios = "print" href = "' + printercss + '" />'); var test = new image (); test.onload = function () {imageLoaded = true; if (documentloaded) reemplazo (); }; test.src = testurl + "? date =" + (new Date ()). GetTime (); addLoadHandler (function () {documentloaded = true; if (imageLoaded) reemplazo ();}); función documentload () {documentloaded = true; if (imageLoaded) reemplazo ();} function reemplazo () {for (var i = 0; i <items.length; i ++) {var elements = getElementsByselector (elementos [i] .selector); if (elements.length> 0) for (var j = 0; j <elements.length; j ++) {if (! Elements [j]) continúa; var text = ExtractText (Elementos [j]); while (Elements [j] .haschildnodes ()) elementos [j] .removechild (elementos [j] .firstchild); var tokens = elementos [i] .wordwrap? text.split (''): [text]; for (var k = 0; k <tokens.length; k ++) {var url = items [i] .Url+"? Text ="+Escape (tokens [k]+'' ')+"& selector ="+Escape (items [i] .selector); var image = document.createElement ("img"); image.classname = "reemplazo"; image.alt = tokens [k]; image.src = url; elementos [j] .appendChild (imagen); } if (dontprintimages) {var span = document.createElement ("span"); span.style.display = 'ninguno'; span.classname = "print-text"; span.appendChild (document.createTextNode (text)); elementos [j] .appendChild (span); }}} if (hideflicker) setstylesheetState ('hide-flicker', false);} function addLoadHandler (handler) {if (window.adDeventListener) {window.adDeventListener ("Load", Handler, false); } else if (window.attachevent) {window.attachevent ("onload", manejador); } else if (window.onload) {var OldHandler = Window.Onload; window.onload = function piggyback () {OldHandler (); entrenador de animales(); }; } else {window.onload = handler; }} function setstylesHeetState (id, habilitado) {var hoja = document.getElementById (id); if (sheet) shead.disable = (! Enabled);} función ExtractText (elemento) {if (typeof element == "string") Elemento de retorno; else if (typeof element == "indefinido") elemento return; else if (element.inntext) return element.innertext; var text = ""; var niños = elemento.childnodes; para (var i = 0; i <kids.length; i ++) {if (niños [i] .nodeType == 1) text+= extractText (niños [i]); else if (niños [i] .nodeType == 3) texto += niños [i] .nodeValue; } Texto de retorno;} /* Encuentra elementos en la página que coinciden con una regla selectora CSS dada. Algunas reglas complicadas no son compatibles. Basado en la excelente función "GetElementsByselector" de Simon Willison. Código original (con comentarios y descripción): http://simon.incutio.com/archive/2003/03/25/getelementsbyselector*/function getelementsbyselector (selector) {var tokens = selector.split (''); var currentContext = new Array (documento); for (var i = 0; i <tokens.length; i ++) {token = tokens [i] .replace (/^/s+/, ''). Reemplazar (// s+$/, ''); if (token.indexof ('#')> -1) {var bits = token.split ('#'); var tagName = bits [0]; var id = bits [1]; var elemento = document.getElementById (id); if (tagName && element.nodename.tolowercase ()! = tagName) return new Array (); currentContext = new Array (elemento); continuar; } if (token.indexof ('.')> -1) {var bits = token.split ('.'); var tagName = bits [0]; var className = bits [1]; if (! tagName) tagName = '*'; var encontrado = nueva matriz; 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 ('*'); Elements elements = currentContext [h] .getElementsBytagName (tagName); para (var j = 0; j <elements.length; j ++) encontrado [FoundCount ++] = Elements [j]; } currentContext = new Array; var currentContextIndex = 0; for (var k = 0; k <foed.length; k ++) {if (encontrado [k] .classname && found [k] .classname.match (new regexp ('// b'+classname+'// b'))) CurrentContext [CurrentContextIndex ++] = Found [k]; } continuar; } if (token.match (/^(/w*)/[(/w+) ([= ~/|/^/$/*]?) =? "? ([^/]"]*) "?/] $/)) {var tagName = REGEXP. $ 1; var attName = REGEXP. $ 2; var AttrOperator = REGEXP. $ 3; REGEXP. if (! TagName) TagName = '*'; CurrentContext [h] .getElementsByTagName (TagName); (E.GetAttribute (AttrName) == ATtrValue); (E.GetTribute (AttrName). (E.GetAttribute (AttrName). (E.GetTribute (AttrName). CurrentContext [CurrentContextIndex ++] = FOUNTADO [K]; FOUNTADO [FOUNDECO ++] = Elementos [j];2) Genere el archivo php de la imagen
<? Php/* Generador de encabezado dinámico por Stewart Rosenberger http://www.stewartspeak.com/headings/ Este script genera imágenes PNG de texto, escritas en la fuente/tamaño que especifica. Estas imágenes de PNG se transmiten al navegador. Opcionalmente, se pueden almacenar en caché para su uso posterior. Si se encuentra una imagen en caché, no se generará una nueva imagen y la copia existente se enviará al navegador. La documentación adicional sobre las capacidades de manejo de imágenes de PHP se puede encontrar en http://www.php.net/image/ */$ font_file = 'trebuc.ttf'; // La correspondiente xiuga $ font_size = 23; // Las modificaciones correspondientes se pueden hacer $ font_color = '#0000000000'; $ background_color = ' ; $ transparent_background = true; $ cache_images = true; $ cache_folder = 'cache';/* --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- ; $ send_buffer_size = 4096; // Verifique si GD Supportif (! Function_Exists ('imageCreate')) fatal_error ('Error: el servidor no admite la generación de imágenes PHP'); // Limpiar textif (vacía ($ _ get ['text'])) fatal_error ('Error: sin texto especificado.'); $ text = $ _get ['text']; if (get_magic_quotes_gpc ()) $ text = stripsLashes ($ text); $ text = javascript_to_html ($ text); // Busque una copia en caché, envíe si existe $ hash = md5 (BaseName ($ Font_file). $ Font_Size. $ Font_color. $ Background_color. $ Transparent_Background. $ Text); $ Cache_Filename = $ Cache_Folder. '/'. $ hash. $ extensión; if ($ cache_images && ($ file = @fopen ($ cache_filename, 'rb'))) {Header ('Content-type:'. $ mime_type); while (! feof ($ file)) print (($ buffer = fread ($ archivo, $ send_buffer_size))); fcLose ($ archivo); salir;} // verificar la disponibilidad de fuentes $ font_found = is_readable ($ font_file); if (! $ font_found) {fatal_error ('Error: al servidor le falta el font especificado.');} // crea imagen $ en segundo plano = hex_to_rgb ($ en segundo plano_color); $ font_rgb = = hex_to_rgb ($ font_color); $ dip = get_dip ($ font_file, $ font_size); $ box = @imagettfbbox ($ font_size, 0, $ font_file, $ text); $ image = @imageCreate (abs ($ box [2]-$ box [0]), aus ($ 5]-$ dip); l. ImageColorallocate ($ Image, $ Font_rgb ['Red'], $ Font_RGB ['Green'], $ Font_rgb ['Blue']); Imagettftext ($ image, $ font_size, 0,-$ box [0], ABS ($ box [5]-$ box [3])-$ box [1], $ font_color, $ font_file, $ text); // establecer transparentif ($ transparent_background) imageColortransparent ($ image, $ background_color); Header ('Content-type:'. $ mime_type); imagepng ($ image); // Guardar copia de la imagen para cacheif ($ cache_images) {@iMagePng ($ image, $ cache_filename);} iMageGeStroy ($ image); salida ; /* Intente determinar la "inmersión" (píxeles caídas por debajo de la línea de base) de esta fuente para este tamaño.*/function get_dip ($ font, $ size) {$ test_chars = 'abcdefghijklmnopqrstuvwxyz'. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. '1234567890'. '! @#$%^&* ()/' "/// ;. Browser como código 500 en su lugar. */function fatal_error ($ mensaje) {// Enviar una imagen if (function_exists ('imageCreate')) {$ width = imageFontWidth (5) * strlen ($ mensaje) + 10; ImageColorAllOd ($ Image, 255,255,255); encabezado de código ("HTTP/1.0 500 Error de servidor interno"); if (substr ($ hex, 0,1) == '#') $ hex = substr ($ hex, 1); substr ($ hex, 2,1); $ rgb ['blue'] = hexDec (substr ($ hex, 4,2)); preg_match_all ('/%u ([0-9a-f] {4})/i', $ text, $ coincidentes); '&#'. HEXDEC ($ coincidencias [1] [$ i]).3) Fuentes requeridas
Aquí coloca el yo requerido en el mismo directorio que los archivos JS y PHP (también puede modificarlo, pero el archivo correspondiente también debe modificarse)
4) Biblioteca GD2 de PHP
2. Código HTML implementado
<? Php // Cargue la biblioteca Utils PopUp // require_once 'include/popup_utils.inc.php';?> <! Doctype html público "-// w3c // dtd xhtml 1.1 // en "" http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd "> <html> <fead> <title> optimización de motores de búsqueda profesional con php: tabla de contenido <//title> <script type =" text/javaScript "lenguaje =" javaScript "src =" dinatex/reemplazo </head> <body onload = "window.resizeto (800,600);" onresize = 'setTimeOut ("Window.resizeto (800,600);", 100)'> <h1> Optimización de motores de búsqueda profesional con PHP: Tabla de contenido </h1> <? Php // Display Navegación emergente solo cuando el visitante proviene de un SERP // Display_Navigation (); // display_popup_navigation (); ?> <ol> <li>You: Programmer and Search Engine Marketer</li> <li>A Primer in Basic SEO</li> <li>Provocative SE-Friendly URLs</li> <li>Content Relocation and HTTP Status Codes</li> <li>Duplicate Content</li> <li>SE-Friendly HTML and JavaScript</li> <li>Web Syndication and Social Bookmarking </li> <li> Black Hat Seo </li> <li> Sitemaps </li> <li> Link Bait </li> <li> IP Clowing, Geo-Targeting y IP Delivery </li> <li> Lenguaje extranjero SEO </li> <li> Cabando con problemas técnicos </li> <li> Sitio clínico: ¿por lo que tiene un sitio web? Weblog? </li> <li> Introducción a la expresión regular </li> </ol> </body> </html>3. Comparación antes y después de su uso
Antes de usar
Después de usar