Un parell de funcions que us poden ser útils
Porto uns quants dies que crec que estic deixant de ser humà m’acaba de trucar la Daphne i semblava un mussol. No era capaç de lligar una frase amb cara i ulls. Què té a veure això amb el codi que posa més avall? doncs que estic programant una especie de webspider o robot o diga-li com vulguis per un tema de Downcenter, per tal de nutrir d’informació la BBDD del proper software que surt l’1 de desembre.
Com que no puc explicar més detalls del que estic programant em limitaré a enganxar un parell de funcions que poden ser útils a més d’un que estigui programant en PHP. Segur que sabeu que quan accediu a un formulari HTML i aquest llença una petició la URL que s’envia, com es pot comprobar a la barra de direccions del navegador, agafa una forma rara. O sigui, els espais passen a ser símbols “+” i els caràcters ASCII extesos, per sobre el codi 127, es codifiquen en codis hexadecimals.
Doncs bé aquestes funcions el que fan és precisament això, els passes una cadena, per exemple, una URL en forma de 8 bits normal i corrent i te la converteix en el format que comentava anteriorment. L’altre funció el que fa és alrevés, passa de format codificat a normal. Espero que us sigui tan útil com ho ha estat per mi.
function cadenaNormal2Hex ($cadena) { // Canviem simbols Hex del mig de la cadena $llarg = strlen($cadena); for ($i=0;$i<$llarg;$i++) { $numascii=ord($cadena[$i]); if ( $numascii>127 ) { // És text pla (???) $car=strtoupper(dechex(ord($cadena[$i]))); $cadena = substr_replace ($cadena,"%".$car,$i,1); }//if }//for // Canvia el + per l'espai while ($pos = strpos($cadena," ")) { $cadena = substr_replace ( $cadena, "+", $pos,1); } //while return $cadena; } // function
function cadenaHex2Normal ($cadena) { // Canvia el + per l'espai while ($pos = strpos($cadena,"+")) { $cadena = substr_replace ( $cadena, " ", $pos,1); } //while // Canviem simbols Hex del mig de la cadena while ( $pos = strpos($cadena,"%") ) { $codi=substr($cadena,$pos+1,2); $car=chr(hexdec($codi)); $cadena = substr_replace ($cadena,$car,$pos,3); }//while return $cadena; } // function
XML & DocBook: Structured Technical Documentation Authoring
XML is short for Extended Markup Language and is a subset of SGML, the Standard Generalized Markup Language. XML is an HTML-like formatting language. Whereas most HTML-related formats developed in the past adopted the “be conservative in what you send and liberal in what you receive” attitude, XML takes the opposite approach–documents should be 100% compatible. This compatibility is known as “well-formedness” of an XML document. To this end, even when the goal is clear, a document is rejected if it does not follow XML specifications to the fullest extent. In terms of practicality, this approach guarantees interoperability in the long run. Unlike HTML, which is the standard groupname for a lot of sub-protocols that are slightly different and not fully interoperable with one another, the strictness of XML ensures compatibility. XML also improves security dramatically, because there is only one way to interpret expressions, a way on which everybody agrees.
DocBook is an XML Document Type Definition or DTD. It is a subset of XML particularly suited for but not limited to the creation of books and papers about computer hardware and software. DocBook is well-known in the Linux community and is used by many publishing companies and open-source development projects. Most tools are developed for the DocBook DTD and are included in most Linux distributions. This allows for sending raw data that can be processed at the receiver’s end–wherever applications able to interpret XML directly are available.
The important thing to keep in mind is XML and DocBook let authors focus on content. In that sense, the presence of the word “markup” in the definition of XML is misleading. With XML, authors specify what type of data they are including, such as text explanations, command names, tables or images. How the content is formatted, laid out and displayed should not be their concern. From a single source, the receiver might generate PDF, PS, plain text, HTML and many other representations of the content.
Another advantage is DocBook XML files are written in plain text. Although many editors are available, such as oXygen and XMLmind, advanced DocBook users easily can write the source texts using vim, Emacs or any other text editor.
Publicat al Linux Journal: XML & DocBook: Structured Technical Documentation Authoring
Understanding and Attacking DNS
The Domain Name System (DNS) is a distributed resource used by most every network application. DNS data is generally trusted implicitly; false data therefore can jeopardize the integrity of network traffic and allow attackers to play manin- the-middle with all traffic. DNS security depends on the client, server, and their respective trust relationship. Securing the trust relationship and building a reliable server can create a reliable and secure DNS structure for the system administrator behind your corporate and private communication requirements. Security of a DNS server varies according to its active role and name resolution requirements. Server responsibilities can be classified as one of three types. Depending on the need of the server, one specific role should be chosen; in particular situations, multiple roles can be supported simultaneously on one physical server. In this shared configuration, authoritative and resolver servers are generally together. Running an individual server for each DNS role is ideal, specifically in a large production environment. After understanding the individual roles and mechanics between each server and experiencing problems individually, an administrator can securely and reliably maintain multiple DNS roles on a single system. DNS security is custom for each type of server, each type of communication, and each common software distribution, all of which will be explained in this article via an in-depth walkthrough.
OpenSSH for Windows
OpenSSH for Windows is a free package that installs a minimal
OpenSSH server and client utilities in the Cygwin package without
needing the full Cygwin installation. This is similar to the package
formerly available from NetworkSimplicity.
The OpenSSH for Windows package provides full SSH/SCP/SFTP support.
SSH terminal support provides a familiar Windows Command prompt, while
retaining Unix/Cygwin-style paths for SCP and SFTP.
Sancho: mldonkey GUI
Sancho is a gui that connects to a p2p core application. Power users
that use p2p applications usually choose one that has core/gui
separation. sancho provides an easy to use, powerful, and configurable
gui, currently supporting the gui protocol of the popular mldonkey
core.
The sancho project is written for fun, but also to test some new
and exciting technologies. It is written in Java using the SWT widget
toolkit and can be compiled on multiple platforms with the gcj compiler
to native machine code (java=slow and bulky? not anymore! no external
java runtime required!). Windows, Linux, OSX and other popular
operating systems are supported.
La llegenda dels teclats QWERTY
Imagino que tots estareu al corrent de la famosa llegenda del perquè els teclats QWERTY estan organitzats d’aquesta manera i no d’una altre. De fet, un gran motiu és que sinó no es podrien dir QWERTY, no em feu cas aquesta parida és meva, tot i que certa. Per si algú no esta al corrent he trobat una web on ens expliquen tota la història sobre la organització de les tecles als teclats: THE FABLE OF THE KEYS. ( local)
Per si algú és un mandrós i no vol llegir-se tot el rollazo en anglès però encara no sap el perquè, us en faig cinc centims. Resulta que quan es van inventar les màquines d’escriure els mecanismes no eren el bons que d’ells es podien esperar i llavors si escribies massa ràpid les “lletres” no tenien temps de tornar al seu lloc. Per tant, es van haver de buscar la forma més “lenta” (òptima) possible perquè els carros de lletres que picaben la tinta i imprimien el paper tinguessin temps de tornar al seu lloc quan algú escribia.