Imagem em base64 com php, css e html

No site: “http://www.motobit.com/util/base64-decoder-encoder.asp” você pode codificar a imagem em base64, e aplicando ao código citado abaixo, você verá que pode ser gerada a imagem a partir do código.

Alguns tipos de conversões se encontram no site: http://php.net/manual/en/function.base64-encode.php

 

A chamada para o funcionamento abaixo deve ser o “http://caminho/nomedoarquivo.php?img=pngFolder”

 

IMAGENS

$pngFolder = <<< EOFILE
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAA3NCSVQICAjb4U/gAAABhlBMVEX//v7//v3///7//fr//fj+/v3//fb+/fT+/Pf//PX+/Pb+/PP+/PL+/PH+/PD+++/+++7++u/9+vL9+vH79+r79+n79uj89tj89Nf889D88sj78sz78sr58N3u7u7u7ev777j67bL67Kv46sHt6uP26cns6d356aP56aD56Jv45pT45pP45ZD45I324av344r344T14J734oT34YD13pD24Hv03af13pP233X025303JL23nX23nHz2pX23Gvn2a7122fz2I3122T12mLz14Xv1JPy1YD12Vz02Fvy1H7v04T011Py03j011b01k7v0n/x0nHz1Ejv0Hnuz3Xx0Gvz00buzofz00Pxz2juz3Hy0TrmznzmzoHy0Djqy2vtymnxzS3xzi/kyG3jyG7wyyXkwJjpwHLiw2Liw2HhwmDdvlXevVPduVThsX7btDrbsj/gq3DbsDzbrT7brDvaqzjapjrbpTraojnboTrbmzrbmjrbl0Tbljrakz3ajzzZjTfZijLZiTJdVmhqAAAAgnRSTlP///////////////////////////////////////8A////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9XzUpQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAB90RVh0U29mdHdhcmUATWFjcm9tZWRpYSBGaXJld29ya3MgOLVo0ngAAACqSURBVBiVY5BDAwxECGRlpgNBtpoKCMjLM8jnsYKASFJycnJ0tD1QRT6HromhHj8YMOcABYqEzc3d4uO9vIKCIkULgQIlYq5haao8YMBUDBQoZWIBAnFtAwsHD4kyoEA5l5SCkqa+qZ27X7hkBVCgUkhRXcvI2sk3MC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b5PzK5439Sdg9eAwACCEyANMBwaFwTGIMMAOEQIBuGA6Mb/qMbABBAEAOQnIyMo1M74Tgiqf2/b3gVhgEAAQQmQuKa/8ekdYMxyLCgmEYMHJXc9t87FNMAgACCGgBxIkgzyDaQU5FxQGQN2AUBUXX/vULKwdgjsOQ/SC9AAKEEYlB03f+oFJABdSjYP6L6P0guIqkVjt0DisEGAAQQigEgG0AhHxBVi4L9wqvBBiEHtqs/xACAAAIbEBBd/x+Eg2ObwH4FORmGfYCaQRikCUS7B5YBNReBMUgvQABBDADaAtIIwsEx9f/Dk9pQsH9kHTh8XANKMAIRIIDAhF9ELTiQQH4FaQAZCAsskPNhyRpkK7oBAAEEMSC8GsVGkEaYIlBghcU3gbGzL6YBAAEEJnzCgP6EYs/gcjCGKQI5G4Z9QiswDAAIIAZKszNAgAEAHgFgGSNMTwgAAAAASUVORK5CYII=
EOFILE;


$pngWrench = <<< EOFILE
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAA3NCSVQICAjb4U/gAAABO1BMVEXu7u7n5+fk5OTi4uLg4ODd3d3X19fV1dXU1NTS0tLPz8+7z+/MzMy6zu65ze65zu7Kysq3zO62zO3IyMjHx8e1yOiyyO2yyOzFxcXExMSyxue0xuexxefDw8OtxeuwxOXCwsLBwcGuxOWsw+q/v7+qweqqwuqrwuq+vr6nv+qmv+m7u7ukvumkvemivOi5ubm4uLicuOebuOeat+e0tLSYtuabtuaatuaXteaZteaatN6Xs+aVs+WTsuaTsuWRsOSrq6uLreKoqKinp6elpaWLqNijo6OFpt2CpNyAo92BotyAo9+dnZ18oNqbm5t4nt57nth7ntp4nt15ndp3nd6ZmZmYmJhym956mtJzm96WlpaVlZVwmNyTk5Nvl9lultuSkpKNjY2Li4uKioqIiIiHh4eGhoZQgtVKfNFdha6iAAAAaXRSTlMA//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////914ivwAAAACXBIWXMAAAsSAAALEgHS3X78AAAAH3RFW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qre9ptZiAscTI38ng7YTQ8g6Budlg75pktkxPV9idctss
1mGYOKciupsxatQB8pJkmkUTpgCvHZ0jDtg+t4/60vAf3tVGBf8WYAC3Rq8Ub3mHyQAAAABJRU5E
rkJggg==
SAN;

 

 

//affichage des images
if (isset($_GET[‘img’]))
{
switch ($_GET[‘img’])
{
case ‘pngFolder’ :
header(“Content-type: image/png”);
echo base64_decode($pngFolder);
exit();

case ‘pngFolderGo’ :
header(“Content-type: image/png”);
echo base64_decode($pngFolderGo);
exit();

case ‘gifLogo’ :
header(“Content-type: image/gif”);
echo base64_decode($gifLogo);
exit();

case ‘pngPlugin’ :
header(“Content-type: image/png”);
echo base64_decode($pngPlugin);
exit();

case ‘pngWrench’ :
header(“Content-type: image/png”);
echo base64_decode($pngWrench);
exit();

case ‘favicon’ :
header(“Content-type: image/x-icon”);
echo base64_decode($favicon);
exit();
}
}

 

 

EXEMPLO 2

$file = “icon.gif”;
if($fp = fopen($file,”rb”, 0))
{
$picture = fread($fp,filesize($file));
fclose($fp);
// base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics
$base64 = chunk_split(base64_encode($picture));
$tag = ‘<a href=”http://www.britblog.com/”><img ‘ . “n” .
‘src=”data:image/gif;base64,’ . $base64 .
‘” alt=”British Blog Directory” width=”80″ height=”15″ />’;
echo $tag;
}

 

Exemplo 3

Em css pode ser feito desta maneira:

.img_teste{

   content: url(“data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAI0lEQVQIW2P4//8/w8yZM//DMIjPAGPAMIiPWxCIMQQxzAQAoFpF7lGFr24AAAAASUVORK5CYII=”);
}

Comparativos Framework PHP

PHP Framework PHP4 PHP5 MVC Múltiplos da DB ORM Objetos DB Modelos Caching Validação Ajax Auth Módulo Módulos EDP
Akelos Visite Akelos url baixar Akelos falar no fórum Akelos Suporte PHP4 Akelos Suporte PHP5 Akelos Suporte MVC Akelos Suporte DB Múltiplas Akelos Suporte ORM Suporte Akelos Objects DB Modelos de Apoio Akelos Akelos Suporte Caching Akelos Validação de Apoio Akelos suporte a Ajax Suporte Akelos módulo Auth Suporte Módulos Akelos
ash.MVC Visite url baixar ash.MVC ash.MVC Suporte PHP5 ash.MVC Suporte MVC Suporte ash.MVC Objects DB Modelos de Apoio ash.MVC ash.MVC Validação de Apoio Suporte ash.MVC módulo Auth Suporte Módulos ash.MVC
CakePHP Visite CakePHP url baixar CakePHP falar no fórum CakePHP Suporte PHP4 CakePHP Suporte PHP5 CakePHP Suporte MVC CakePHP DB Suporte Múltiplas CakePHP Suporte ORM Suporte CakePHP Objects DB CakePHP Caching Suporte CakePHP Validação de Apoio CakePHP suporte a Ajax Suporte CakePHP Auth Módulo Suporte Módulos CakePHP
CodeIgniter Visite url CodeIgniter baixar CodeIgniter falar no fórum Suporte CodeIgniter PHP4 CodeIgniter Suporte PHP5 CodeIgniter Suporte MVC CodeIgniter DB Suporte Múltiplas Suporte CodeIgniter Objects DB Modelos de Apoio CodeIgniter CodeIgniter Caching Suporte CodeIgniter Validação de Apoio
DIY Visite DIY url baixar DIY Suporte PHP5 DIY Suporte MVC DIY Suporte ORM DIY Suporte Objects DB Modelos de Apoio DIY DIY Caching Suporte DIY suporte a Ajax
Componentes eZ Visite url baixar eZ Components Componentes eZ Suporte PHP5 Componentes eZ Suporte DB Múltiplas Componentes eZ Support Objects DB Componentes eZ Suporte Templates Componentes eZ Suporte Caching Componentes eZ Validação de Apoio
Fusebox Visite Fusebox url baixar Suporte Fusebox PHP4 Fusebox Suporte PHP5 Fusebox Suporte MVC Fusebox DB Suporte Múltiplas Fusebox Caching Suporte Fusebox suporte a Ajax Suporte Módulos Fusebox
PHP em TRAX Visite PHP em TRAX url baixar PHP em TRAX Suporte PHP5 PHP em TRAX Suporte MVC PHP em TRAX DB Suporte Múltiplas PHP em TRAX Suporte ORM PHP em objetos de Apoio TRAX DB PHP em TRAX Validação de Apoio PHP em TRAX suporte a Ajax PHP em Módulos de Apoio TRAX
PHPDevShell Visite url PHPDevShell baixar PHPDevShell Suporte PHP5 Modelos de Apoio PHPDevShell PHPDevShell suporte a Ajax PHPDevShell módulo Auth Suporte Suporte Módulos PHPDevShell
PhpOpenbiz Visite PhpOpenbiz url baixar PhpOpenbiz Suporte PHP5 PhpOpenbiz Suporte MVC PhpOpenbiz DB Suporte Múltiplas PhpOpenbiz Suporte ORM PhpOpenbiz Support Objects DB Modelos de Apoio PhpOpenbiz PhpOpenbiz Validação de Apoio PhpOpenbiz suporte a Ajax Suporte PhpOpenbiz módulo Auth
Prado Visite Prado url baixar falar Prado no fórum Prado Suporte PHP5 Prado Suporte MVC Prado DB Suporte Múltiplas Prado Suporte ORM Prado Support Objects DB Modelos de Apoio Prado Prado Caching Suporte Prado Validação de Apoio Prado suporte a Ajax Prado Suporte Auth Módulo Suporte Módulos Prado Prado Suporte EDP
QPHP Visite url baixar QPHP Suporte QPHP PHP4 QPHP Suporte PHP5 QPHP Suporte MVC QPHP DB Suporte Múltiplas Suporte QPHP Objects DB Modelos de Apoio QPHP QPHP Validação de Apoio QPHP suporte a Ajax Suporte QPHP módulo Auth Suporte Módulos QPHP QPHP Suporte EDP
Gaivota Visite Seagull url baixar Suporte Seagull PHP4 Seagull Suporte PHP5 Seagull Suporte MVC Seagull DB Suporte Múltiplas Seagull Suporte ORM Suporte Seagull Objects DB Modelos de Apoio Seagull Seagull Caching Suporte Seagull Validação de Apoio Seagull suporte a Ajax Suporte Seagull módulo Auth Suporte Módulos Seagull
Symfony Visite url baixar Symfony Symfony falar no fórum Suporte Symfony PHP5 Symfony Suporte MVC DB Symfony Suporte Múltiplas ORM Suporte symfony Symfony Objects DB Suporte Suporte Symfony Caching Validação de Apoio symfony Symfony suporte a Ajax Symfony Módulo Auth Suporte Suporte Módulos symfony
Wact Visite Wact url baixar Wact falar no fórum Wact Suporte PHP4 Wact Suporte PHP5 Wact Suporte MVC Wact DB Suporte Múltiplas Wact Support Objects DB Wact Modelos de Apoio Wact Validação de Apoio Wact Módulos de Apoio
WASP Visite url baixar WASP Suporte WASP PHP5 WASP Suporte MVC WASP Objects DB Suporte Modelos de Apoio WASP Validação de Apoio WASP WASP suporte a Ajax WASP módulo Auth Suporte Suporte Módulos WASP
Yii Visite Yii url baixar Yii falar no fórum Yii Suporte PHP5 Yii Suporte MVC Yii DB Suporte Múltiplas Yii Suporte ORM Yii Support Objects DB Modelos de Apoio Yii Yii Caching Suporte Yii Validação de Apoio Yii suporte a Ajax Suporte Yii módulo Auth Suporte Módulos Yii Yii Suporte EDP
Zend Visite Zend url baixar Zend falar no fórum Suporte Zend PHP5 Suporte Zend MVC Zend DB Suporte Múltiplas Zend Suporte ORM Objetos Zend Suporte DB Modelos de Apoio Zend Zend Cache de Apoio Zend Validação de Apoio Zend suporte a Ajax Suporte Zend Auth Módulo Suporte Módulos Zend
Zoop Visite url Zoop baixar Suporte Zoop PHP4 Zoop Suporte PHP5 Zoop Suporte MVC Zoop DB Suporte Múltiplas Suporte Zoop Objects DB Modelos de Apoio Zoop Zoop Caching Suporte Zoop Validação de Apoio Zoop suporte a Ajax Suporte Zoop módulo Auth
  • MVC: Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup.
  • Multiple DB’s: Indicates whether the framework supports multiple databases without having to change anything.
  • ORM: Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord.
  • DB Objects: Indicates whether the framework includes other database objects, like a TableGateWay.
  • Templates: Indicates whether the framework has an inbuilt template engine.
  • Caching: Indicates whether the framework includes a caching object or some way other way of caching.
  • Validation: Indicates whether the framework has an inbuilt validation or filtering component.
  • Ajax: Indicates whether the framework comes with inbuilt support for Ajax.
  • Auth Module: Indicates whether the framework has an inbuilt module for handling user authentication.
  • Modules: Indicates whether the framework has other modules, like an RSS feed parser, PDF module or anything else (useful).
  • EDP: Event Driven Programming.New!

Conteúdo por: http://www.phpframeworks.com/

Máscara em PHP

function mask($val, $mask)
{
$maskared = ”;
$k = 0;
for($i = 0; $i<=strlen($mask)-1; $i++)
{
if($mask[$i] == ‘#’)
{
if(isset($val[$k]))
$maskared .= $val[$k++];
}
else
{
if(isset($mask[$i]))
$maskared .= $mask[$i];
}
}
return $maskared;
}

$cnpj = “11222333000199”;
$cpf = “00100200300”;
$cep = “08665110”;
$data = “10102010”;

echo mask($cnpj,’##.###.###/####-##’).'<br>’;
echo mask($cpf,’###.###.###-##’).'<br>’;
echo mask($cep,’#####-###’).'<br>’;
echo mask($data,’##/##/####’).'<br>’;

 

 

Saídas:
11.222.333/0001-99
001.002.003-00
08665-110
10/10/2010

 

<?
$data = "10102010";
echo mask($data,'##/##/####');
echo mask($data,'[##][##][####]');
echo mask($data,'(##)(##)(####)');
?>

Conteúdo pertencente à: http://clares.wordpress.com/2010/11/12/php-mascara-cnpj-cpf-data-e-qualquer-outra-coisa/

Exportação Excel no php

Baixo um exemplo de como criar.

header(‘Content-type: application/vnd.ms-excel; charset=iso-8859-1’);
header(“Content-Disposition: attachment; filename=list.xls”);
header(“Pragma: no-cache”);
header(“Expires: 0”);

Conteúdo:
$contents = “testdata1 \t testdata2 \t testdata3 \t \n”;
echo $contents;

Ou pode ser criado como uma tabela em html que fará o mesmo efeito, e também poderá ser formatada!

 

Para IE8, o cabeçalho deve ser assim:

header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Content-Type: application/force-download”);
header(“Content-Type: application/octet-stream”);
header(“Content-Type: application/download”);;
header(“Content-Disposition: attachment;filename=list.xls”);
header(“Content-Transfer-Encoding: binary “);

Formatar campos na geração de arquivo excel

É possível forçar a formatação de campos em arquivos excel gerados pelo sistema, para isto basta gerar as informações com formato de tabela html e no td informar o class da formatação específica.
A definição do style deverá estar no início dos dados, antes da tabela, e seguir um dos formatos específicos:

>> Data no formato dd/mm/yy
.DATA1 {
mso-number-format:”dd\/mm\/yy\;\@”;
}

>> Data “Simples”
.DATA2 {
mso-number-format:”Short Date”;
}

>> Moeda Nacional
.MOEDARS {
mso-number-format:”_\(\[$R$ -416\]* \#\,\#\#0\.00_\)\;_\(\[$R$ -416\]* \\\(\#\,\#\#0\.00\\\)\;_\(\[$R$ -416\]* \0022-\0022??_\)\;_\(\@_\)”;
}

>> Moeda Estrangeira (US$)
.MOEDAUS {
mso-number-format:”_\(\[$$ -416\]* \#\,\#\#0\.00_\)\;_\(\[$$ -416\]* \\\(\#\,\#\#0\.00\\\)\;_\(\[$$ -416\]* \0022-\0022??_\)\;_\(\@_\)”;
}

>> Percentual
.PORCENTAGEM {
mso-number-format:Percent;
}

>> Forçar formatação como texto
.TEXTO {
mso-number-format:”\@”;
}

Exemplo completo:

<style>.TEXTO { mso-number-format:\@;}</style>
<table>
<tr>
<td>000123456</td>
</tr>
</table>


Criado por: Cássio Lisboa

Convertendo numero para moeda em php

Esta forma abaixo foi criada para adicionar dentro do excel e o formato de moeda ficar efetivo através da exportação.

 

function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf(‘%.2f’, $number);
}
while (true) {
$replaced = preg_replace(‘/(-?\d+)(\d\d\d)/’, ‘$1.$2’, $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}

echo $formato_en = money_format(‘%.2n’, ‘2225778.10’) . “<br>”;
echo $formato_en = number_format($formato_en,2,’,’,’.’);

 

Formatações numericas em PHP

Mais que duas casas decimais

function numberFormat  ($number  , $decimals = 2 , $dec_point = ‘.’ , $sep = ‘,’, $group=3   ){
$num = sprintf(“%0.{$decimals}f”,$number);
$num = explode(‘.’,$num);
while (strlen($num[0]) % $group) $num[0]= ‘ ‘.$num[0];
$num[0] = str_split($num[0],$group);
$num[0] = join($sep[0],$num[0]);
$num[0] = trim($num[0]);
$num = join($dec_point[0],$num);

return $num;
}

$valor_test = ‘445400525’;
echo numberformat($valor_test,0,”,’.’,6);

#retorno: 445.400525

 

 

Regra Geral

number_format($variavel_com_numero, int casa decimais, separador decimal , separador de milhares);

ex:

PHP
$num= 100000.50; // repare que o padrão é no formato americano
echo ‘R$’ . number_format($num, 2); //retorna R$100,000.50// nosso formato
echo ‘R$’ . number_format($num, 2, ‘,’, ‘.’); // retorna R$100.000,50

//formato americano
echo ‘R$’ . number_format($num, 2, ‘.’, ‘,’); // retorna R$100,000.50

Referência: http://forum.imasters.com.br/topic/118370-formatacao-de-moeda-r-no-php/

 

 

Este site abaixo é uma referência para diversas formatações numéricas.

Acesse: http://www.clubedainformatica.com.br/site/2009/08/13/formatacao-de-numeros-em-php/

 

Link amigável dinâmico com imagens

Criando link de imagens passando o id do registro e configurando URL amigável.
Primeiro resgatamos valores do banco de dados e inserimos algumas condições opcionais.

Controler-1

$logo = $this->Operadora->all(array( ‘conditions’=>array( ‘
cancelado_id IS NULL’,
‘status_id’=>2,
),
‘fields’=>array(
‘nome’,
‘logo’,
‘id’
),
‘groupBy’=>’id’,
‘limit’=>’9’,
‘recursion’=>-1
));

//Preparamos a variável para poder ser usada na view obtendo os valores desejados.

$this->set(‘logo’,$logo);

View-1

//Exibimos as imagens e configuramos o link amigável, para que o id possa ser passado para a pagina direcionada.

foreach($logo as $a):
echo ‘<div>’; $slug = Inflector::slug(utf8_encode($a[‘nome’]));
echo $html->imagelink(‘../files/operadora/’.$a[“logo”],’/operadora/detalhe/’.$a[“id”].’/’.$slug,array(‘alt’=>$a[‘nome’]));
echo ‘</div>’;
endforeach;

Configuração da página a ser direcionada.

Controller-2

//Selecionamos os dados e passamos o id e slug como o nome no caso para a função que irá obter os dados desejados da página qual foi direcionada a navegação.

public function detalhe($id = null, $slug = null){

$this->set(‘opera’,$this->Operadora->combo(array(),’Operadora’));
$this->set(‘abrang’,$this->Abrangencia->combo(array(),’Abrangência’));
$this->set(‘acomod’,$this->Acomodacao->combo(array(),’Acomodação’));

if(is_numeric($id)):
$all = $this->Operadora->first(array(
‘conditions’=>array(
‘cancelado_id IS NULL’,
‘status_id’=>2,
‘id’=> $id
),
‘groupBy’=>’id’,
‘recursion’=>-1
));
$this->set(‘all’,$all);
else: $this->redirect(‘/’);
endif;
}

View-2

//Exibindo informações desejadas

echo $html->image(‘../files/operadora/’.$all[“logo”]);