PHP Classes

File: class.data_uri.example.php

Recommend this page to a friend!
  Classes of Uku-Kaarel Jo~esaar   Data URI   class.data_uri.example.php   Download  
File: class.data_uri.example.php
Role: Example script
Content type: text/plain
Description: Example usage of class
Class: Data URI
Generate data URL to embed binaries in links
Author: By
Last change: reviewed beacause main class is changed
Date: 13 years ago
Size: 1,589 bytes
 

 

Contents

Class file image Download
<?php

// Example
$pathToScriptDir = pathinfo( __FILE__,PATHINFO_DIRNAME ).DIRECTORY_SEPARATOR;

require
$pathToScriptDir.'class.data_uri.php';
$du = new data_uri;
/* Apache mime magic file */
$du->set_magic_file('/Applications/MAMP/conf/apache/magic');
$uridata1 = $du->fromFile($pathToScriptDir.'elephpant.jpg');
 
 
$urihtml =
 
"\xEF\xBB\xBF" . //UTF-8
 
'<'.'?xml version="1.0" encoding="UTF-8" ?'.'>
 <html>
 <head>
 <title>elephpant.jpg</title>
 <meta name="skip" value="other stuff" />
 <meta charset="UTF-8" />
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 </head>
 <body>
 <center><p>infinityJH.gif(4kb)</p></center>
 <img src="'
.$uridata1.'" height="117" width="133" alt="elephpant.jpg" />
 <p>ÜÕÖÄ £é</p>
</body>
</html>'
;
 
 
 
 
$du->set_encoding('raw'); // to raworlencode octets %00
//$du->set_charset('ascii');
$uridata3 = $du->fromData($urihtml ,'text/html' ,'auto' ); //auto detects as utf-8
//$uridata3 = $du->fromData($urihtml ,'unknown/html' ,'auto' ); //skip



?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>class.data_uri.php</title>
<style>
body {
    background:url('<?=$uridata1?>') repeat-y;
}
</style>

 <script>
window.open('<?=$uridata3?>','infinity','height=200,width=200');
</script>
 </head>
 <body>
 
 
<center><h1>class.data_uri.php</h1></center>


<img src="<?=$uridata1?>" height="117" width="133" alt="An elephant"
    style="margin-left:266px;border:3px solid blue;" />
 
 <pre><?php print_r($du->get_execution_data()); ?></pre>
 
</body>
</html>