| home -> documentation -> language reference ->TRANSFORM tag |
Description
The TRANSFORM tag allows you to apply different string transformations to a certain block of code.
Syntax
<#TRANSFORM TRANSFORMATION="trans">
.
.
<#/TRANSFORM>
|
| Transformation |
Specify in this property the string transformation to apply. The valid transformations work as follows
|
Valid transformations
| uppercase |
Transforms all the bounded block code to upper case.
|
| lowercase |
Transforms all the bounded block code to lower case.
|
| crypt |
Encrypt the bounded block using the 128 bits site key.
|
| decrypt |
Decrypt the bounded block using the 128 bits site key.
|
| html |
Converts all the bounded block of code to HTML visible characters using hex codes.
|
|
Note: The code is first interpreted and then the result is transformed.
|
Applications
Use the TRANSFORM tag to apply different transformations to certain blocks of code:
- Formatting text for its presentation.
- Insert DBSP/HTML source code into your DBSP® pages.
- Encrypt/decrypt sensible information in your database (Like credit card information, documents or user passwords).
Operative examples
Example 1. All the possible tansformations using TRANSFORM.
See all the possible transformations in one page.
Source code
File: examples/TRANSFORM.dbsp
<HTML> <body> <h1>Transform text</h1> <hr> <#SETCOOKIE NAME="ORIGINALTEXT" value="DBSP (Data Base Scripting Pages) is a new server-side scripting technology designed specifically for the exploitation of databases across the Internet. DBSP enhances and simplifies the database connection process keeping the database connections active and incorporating proven algorithms and technology in order to increase the performance, stability and availability of your data-aware web sites."/> <br><H3>Original text</H3> <#ORIGINALTEXT/> <br><h3>Upper case:</h3> <#TRANSFORM TRANSFORMATION="UPPERCASE"><#ORIGINALTEXT/><#/TRANSFORM> <br><h3>Lower case:</h3> <#TRANSFORM transformation='LOWERCASE'><#ORIGINALTEXT/><#/TRANSFORM> <!-- Look the variation of the SETCOOKIE. It has an opening and closing tag !--> <!-- In order to perform a correct decryption, don't add additional characters!!! Thats why the transform is in the same line and contiguous, for not adding any space or the return char. !--> <br><h3>Crypting:</h3> <#SETCOOKIE NAME="ORIGINALTEXT"><#TRANSFORM TRANSFORMATION="CRYPT"><#ORIGINALTEXT/><#/TRANSFORM><#/SETCOOKIE> <#ORIGINALTEXT/> <br><h3>Decrypting:</h3> <#SETCOOKIE NAME="ORIGINALTEXT"><#TRANSFORM TRANSFORMATION="DECRYPT"><#ORIGINALTEXT/><#/TRANSFORM><#/SETCOOKIE> <#ORIGINALTEXT/> <br><h3>HTML encoding</h3> <table border="1" cellpadding="10"> <tr> <td> <#TRANSFORM TRANSFORMATION="HTML"> <#INCLUDE DOC="nocache.dbsp"/> <#/TRANSFORM> </td> </tr> </table> <p>You could have the same effect using the INCLUDE tag and ASHTML property:</p> <table border="1" cellpadding="10"> <tr> <td> <#INCLUDE DOC="nocache.dbsp" ASHTML/> </td> </tr> </table> </body> </HTML>
|
Test example
Example 2. Storing sensible information in your database.
Sensible information could be stolen if your database gets compromised. See how DBSP® could help you to secure your information.
Source code
File: examples/CryptDataset.dbsp
<html> <body> <h1>Storing sensible information in your database</h1> <p>This example shows how you can save/crypted and retrieve/decrypted information on your database.</p> <p>This table has two fields: username and password. The password is crypted before it is stored in the database.</p> <table border="1" cellpadding="3" cellspacing="0"> <tr> <th colspan="2">Physical table</th> <th> </th> </tr> <tr> <th>Username</th> <th>Password</th> <th>Uncrypted Password</th> </tr> <#DATASET ALIAS="OPEX" QUERYID="5"> <tr> <td><#USERNAME/></td> <td><#USERPASSWORD/></td> <td><#TRANSFORM TRANSFORMATION="DECRYPT"><#USERPASSWORD/><#/TRANSFORM></td> </tr> <#/DATASET> </table> <form name="form1" method="post" action="CryptDatasetA.dbsp"> <p>Add a username and password combination to the table:</p> Username: <input type="text" name="CTRLUSERNAME" maxsize="16"> Password: <input type="text" name="CTRLPASSWORD" maxsize="16"> <button type="submit">Add</button> </form> </body> </html>
|
SQL sentence: 5
|
SELECT * FROM USERPASSWORDS
|
File: examples/CryptDatasetA.dbsp
<!-- Crypt the password !--> <!-- executed in one sigle line and contiguous for avoid introducing undesired characters like enter or spaces !--> <#SETCOOKIE NAME="CTRLPASSWORD"><#TRANSFORM TRANSFORMATION="CRYPT"><#CTRLPASSWORD/><#/TRANSFORM><#/SETCOOKIE> <!-- Insert the value in the table !--> <#QRYEXEC ALIAS="OPEX" QUERYID="6"/> <#KILLCOOKIE NAME="CTRLPASSWORD"/> <#REDIRECT DOC="CryptDataset.dbsp"/>
|
SQL sentence: 6
|
INSERT INTO USERPASSWORDS
VALUES
( :CTRLUSERNAME , :CTRLPASSWORD )
|
Test example
|