This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:5.6-apache | |
RUN sed -i -e 's/deb.debian.org/archive.debian.org/g' \ | |
-e 's|security.debian.org|archive.debian.org/|g' \ | |
-e '/stretch-updates/d' /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get install --yes --force-yes cron g++ gettext libicu-dev openssl libc-client-dev libkrb5-dev libxml2-dev libfreetype6-dev libgd-dev libmcrypt-dev bzip2 libbz2-dev libtidy-dev libcurl4-openssl-dev libz-dev libmemcached-dev libxslt-dev | |
RUN a2enmod rewrite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$isAuthorized = isUserAuthorized(); //sua lógica para validar se o usuário está ou não autorizado. | |
if(!$isAuthorized) | |
die(header("Location: index.php")); //se o usuário não tiver autorização, redireciona ele pra index e encerra o script com die() | |
// aqui ele tá autorizado, então bora servir a imagem... | |
$image = $_GET["image"]; //supondo que a URL foi acessada via: showImage.php?image=foto123.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
private $x; | |
public function __construct(){ | |
$this->x = "testando"; | |
} | |
public function __toString(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$soma = 0; | |
$fornecedor = ""; | |
while($mostrar = mysql_fetch_row($result)){ | |
if($fornecedor == "") | |
$fornecedor = $mostrar[3]; | |
if($fornecedor != $mostrar[3]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET; | |
$option = $data["opc"]; | |
switch($option){ | |
case "inserir": | |
$sql = "INSERT INTO tabela (campoA, campoB, campoC, campoN) VALUES (?, ?, ?, ?)"; | |
//código para processar os dados enviados do front, e presentes na $data. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Editar Nota</title> | |
<meta http-equiv="content-Type" content="text/html" charset="UTF-8"/> | |
<link rel="shortcut icon" href="img/icon.png"/> | |
<link rel="stylesheet" type="text/css" href="css/estilo.css"/> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Parse(this DbEntityValidationException e) | |
{ | |
var builder = new StringBuilder(); | |
foreach (var eve in e.EntityValidationErrors) | |
{ | |
builder.AppendFormat("Entity type: {0} | State: {1}",eve.Entry.Entity.GetType().Name,eve.Entry.State); | |
foreach (var ve in eve.ValidationErrors) | |
builder.AppendFormat("Property name: {0} | Current value: {1} | Error message: {2}", | |
ve.PropertyName, | |
eve.Entry.CurrentValues.GetValue<Object>(ve.PropertyName), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
//seu código de verificar usuário... | |
//... | |
//... | |
//... | |
$_SESSION['email'] = $code; | |
$_SESSION['nome'] = $nome; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$texto = "sua string de 1500 caracteres"; | |
$limite = 5; //troca para 500, fiz 5 só pra teste. | |
$banner = "<img src='https://via.placeholder.com/50' alt='teste'/>"; //troca pelo seu código de banner. | |
$result = ""; | |
$splits = strlen($texto) % $limite; | |
for($i=0;$i<$splits;$i++) | |
$result .= substr($texto, $i * $limite, $limite) . $banner; | |
echo $result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseCSV(data, separator) { | |
const lines = data.split(/\r\n|\n/); | |
const header = lines[0].split(separator); | |
const result = []; | |
for(let i = 1; i < lines.length; i++){ | |
const fields = lines[i].split(separator); | |
const line = {}; | |
for(let k = 0; k < header.length; k++) | |
line[header[k]] = fields[k]; |