Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

marcelocardosof

Os acentos não estão saindo no meu sistema de galeria de fotos

Recommended Posts

Olá galera, eu tenho um sistem de galeria de fotos feitos em php e o flash lê.. beleza.. na parte de flash tá tudo ok. Mas na parte de PHP, quando eu insiro uma legenda com algum tipo de acento (ã, é, ó, ã, etc..) dá erro!

 

diz:

 

"XML error: Invalid character at line 16"

 

e as vezes dá esse:

 

"XML error: not well-formed (invalid token) at line 9"

 

Daí na linha 16 e na linha 9 estão os caracteres com acentos.. já tentei uft-8, e todos os outros formatos.. mas nao manjo mt de php..

 

 

Preciso entregar o site (que ja está pronto) até quarta e preciso resolver este problema!! Eu pago pra quem conseguir resolver este pequeno probleminha!!

 

Grato pela atenção de todos e espero algum tipo de ajuda

 

Quem estiver disposto a resolver este problema e ganhar uns trocados por isso, me contate pelo marcelocardosof@hotmail.com que mando o login/senha e os arquivos para vocês olharem!!

 

Grato.!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você usou o cdata?

<no_qualquer><![CDATA[AQUI VAI O TEXTO COM ACENTOU OU SEJA LÁ O QUE FOR]]></no_qualquer>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Este é um arquivo .xml que vai em cada pasta de cada galeria:

 

<pictures>

<image location="Imagem_13_-_Quarto_do_casal_._Praia_Brava.jpg" desc="" />

<image location="Imagem_12_-_Cozinha_._Ingleses.jpg" desc="" />

<image location="Imagem_10-_Nutriway_-_Rua_Osmar_Cunha_-_Centro.jpg" desc="" />

<image location="Imagem_11_-_EAD_-_UFSC.JPG" desc="" />

<image location="Imagem_08-_Quarto_do_Casal_._Barreiros_-_Em_fase_de_projeto.jpg" desc="" />

 

<image location="Imagem_03_-_M.A.M_-_Pinheira_-_em_fase_de_acabamentos.JPG" desc="ghjgh" />

<image location="Imagem_04_-_Condomínio_em_Canasvieiras.jpg" desc="jghjg" />

<image location="Imagem_01_-_Jardim_Mediterraneo_-_Canasvieiras.jpg" desc="hjhgj" />

<image location="Imagem_02_-_Jardim_Mediterraneo_-_Canasvieiras.jpg" desc="ghjghjgjf" />

 

<image location="grazi2.jpg" desc="Residncia Unifamiliar . Altos de So Jos . So Jos " />

<image location="grazi1.jpg" desc="Residencial Flor de Ltus . Dubai Empreendimentos Imobilirios . So Jos " />

<image location="grazi3.jpg" desc="" />

<image location="grazi4.jpg" desc="" />

<image location="grazi5.jpg" desc="" />

</pictures>

 

 

Só tem isso dentro do xml.. Não entendo absolutamente NADA de xml.. é tudo japones para mim :upset:

Compartilhar este post


Link para o post
Compartilhar em outros sites

você vai me paga como e qnto? kkkkkkk

 

<?xml version="1.0" encoding="UTF-8"?>
<pictures>
<image location="Imagem_13_-_Quarto_do_casal_._Praia_Brava.jpg" desc="" />
<image location="Imagem_12_-_Cozinha_._Ingleses.jpg" desc="" />
<image location="Imagem_10-_Nutriway_-_Rua_Osmar_Cunha_-_Centro.jpg" desc="" />
<image location="Imagem_11_-_EAD_-_UFSC.JPG" desc="" />
<image location="Imagem_08-_Quarto_do_Casal_._Barreiros_-_Em_fase_de_projeto.jpg" desc="" />

<image location="Imagem_03_-_M.A.M_-_Pinheira_-_em_fase_de_acabamentos.JPG" desc="ghjgh" />
<image location="Imagem_04_-_Condomínio_em_Canasvieiras.jpg" desc="jghjg" />
<image location="Imagem_01_-_Jardim_Mediterraneo_-_Canasvieiras.jpg" desc="hjhgj" />
<image location="Imagem_02_-_Jardim_Mediterraneo_-_Canasvieiras.jpg" desc="ghjghjgjf" />

<image location="grazi2.jpg" desc="Residncia Unifamiliar . Altos de So Jos . So Jos " />
<image location="grazi1.jpg" desc="Residencial Flor de Ltus . Dubai Empreendimentos Imobilirios . So Jos " />
<image location="grazi3.jpg" desc="" />
<image location="grazi4.jpg" desc="" />
<image location="grazi5.jpg" desc="" />
</pictures>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpe Giovani.

 

Não deu certo:

 

fui testar seu código acrescentando um "falcão":

 

<?xml version="1.0" encoding="UTF-8"?>

<pictures>

 

<image location="grazi3.jpg" desc="fghfghfghfgh falcão" />

<image location="grazi4.jpg" desc="" />

<image location="grazi5.jpg" desc="" />

</pictures>

 

e o erro que deu:

 

"XML error: not well-formed (invalid token) at line 4"

 

Linha 4: "falcão"

 

Não sei o que pode ser.. acho que a pessoa teria que ver todos os meus arquivos PHP para tentar resolver este problema :cry: :cry:

 

www.5mcardoso.com.br/admin.rar

 

Coloquei o .rar com todos os arquivos, é só descompactar no servidor e acessar www.site.com.br/admin

 

login: admin

senha: admin

 

acredito que seja algo nos PHP que tem, quando lê o xml..

 

 

Pra vcs se depararem com o erro, criem uma galeria, adicionem uma foto com legenda sem acento, depois adicionem uma foto com legenda com acento.. dps vão em "Editar Fotos", vai dar o erro.. daí se editar o xml e tirar o acento.. não dá erro.. :(

Compartilhar este post


Link para o post
Compartilhar em outros sites

NA hr de grava o XML você tem que manda como UTF-8

 

esse XML e gravado direto em arquivo, ou vem do banco de dados?

 

você usa que codigo pra gera esse XML.

 

pode tenta outras ISO -- <?xml version="1.0" encoding="iso-8859-1"?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

NA hr de grava o XML você tem que manda como UTF-8

 

esse XML e gravado direto em arquivo, ou vem do banco de dados?

 

você usa que codigo pra gera esse XML.

 

pode tenta outras ISO -- <?xml version="1.0" encoding="iso-8859-1"?>

 

Fiz oq você disse e deu erro denovo :/

Grava direto no arquivo .xml

 

olha amigo.. olhei uns arquivo e vi que quando uplodeia a foto ele usa esses codigos:

 

//------------- writing new xml ----------------//

 

//path to xml

$filename = realpath("../$folder/pics.xml");

 

// make sure xml exists and is writable

if (is_writable($filename)) {

//open the file for reading and writing

if (!$handle = fopen($filename, 'r+b')) {

error("Cannot open file");

exit;

}

 

//read file

$contents = fread($handle, filesize($filename));

 

//rewind file pointer to start and truncate file to zero

rewind($handle);

ftruncate($handle, 0);

 

if ($attach == "start"){

//attach pictures at beginning of gallery

$contents = str_replace("<pictures>","",$contents);

$contents = "<pictures>\n" . $pics_xml_add . $contents;

} else {

//attach pictures at end of gally

$contents = str_replace("</pictures>","",$contents);

$contents .= $pics_xml_add . "</pictures>";

}

 

// writing new xml

if (fwrite($handle, $contents) === FALSE) {

error("Cannot write to file");

exit;

}

 

fclose($handle);

 

} else {

error("pics.xml does not seem to be writable. Check that you have changed its CHMOD settings to 777.");

}

 

//---------------- done writing new xml --------------//

 

 

?>

<html>

<head>

<title><?php echo $name; ?> - Upload</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

<!--

p {

line-height: 1.5em;

}

</style>

<link href="style.css" rel="stylesheet" type="text/css">

</head>

 

<body>

<p align="center"><a href="page_upload_pics.php?name=<?php echo $name; ?>&folder=<?php echo $folder; ?>">Enviar mais Fotos</a></p>

<p align="center">ou</p>

<p align="center"><a href="javascript:window.close();">Fechar esta janela</a></p>

</body>

 

Mas acredito que o problema é na hora de LER, e nao de GRAVAR.. porque mesmo quando eu edito o .xml com acentos (como se estivesse gravando certo), na hora de LER dá erro.. entao o erro é na LEITURA e nao na GRAVAÇÃO.. e nao consigo achar o erro..

 

Ajuda.. :(

Compartilhar este post


Link para o post
Compartilhar em outros sites

que tenso isso ai em prq num uso SimpleXMLElement, era mais pratico.

 

você pode tenta assim deixa o XML pra UTF-8

 

da um encode nessa variavel $pics_xml_add

 

//la onde grava o XML
utf8_encode ( $pics_xml_add )

//o XMl
<?xml version="1.0" encoding="UTF-8"?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

que tenso isso ai em prq num uso SimpleXMLElement, era mais pratico.

 

você pode tenta assim deixa o XML pra UTF-8

 

da um encode nessa variavel $pics_xml_add

 

//la onde grava o XML
utf8_encode ( $pics_xml_add )

//o XMl
<?xml version="1.0" encoding="UTF-8"?>

 

adicionei oq você falou, dai fui fazer upload de uma foto com legenda com acento e apareceu essa msg:

 

"Parse error: syntax error, unexpected T_REQUIRE in /home/mcardoso/public_html/graziela/admin/upload_pics.php on line 4"

 

conteudo do upload_pics.php:

 

<?php

########################################################

# Script Info

# ===========

# File: ImageEditor.php

# Created: 05/06/03

# Modified: 16/05/04

# Author: Ash Young (ash@evoluted.net)

# Website: http://evoluted.net/php/image-editor.htm

# Requirements: PHP with the GD Library

#

# Description

# ===========

# This class allows you to edit an image easily and

# quickly via php.

#

# If you have any functions that you like to see

# implemented in this script then please just send

# an email to ash@evoluted.net

#

# Limitations

# ===========

# - GIF Editing: this script will only edit gif files

# your GD library allows this.

#

# Image Editing Functions

# =======================

# resize(int width, int height)

# resizes the image to proportions specified.

#

# crop(int x, int y, int width, int height)

# crops the image starting at (x, y) into a rectangle

# width wide and height high.

#

# addText(String str, int x, int y, Array color)

# adds the string str to the image at position (x, y)

# using the colour given in the Array color which

# represents colour in RGB mode.

#

# addLine(int x1, int y1, int x2, int y2, Array color)

# adds the line starting at (x1,y1) ending at (x2,y2)

# using the colour given in the Array color which

# represents colour in RGB mode.

#

# setSize(int size)

# sets the size of the font to be used with addText()

#

# setFont(String font)

# sets the font for use with the addText function. This

# should be an absolute path to a true type font

#

# shadowText(String str, int x, int y, Array color1, Array color2, int shadowoffset)

# creates show text, using the font specified by set font.

# adds the string str to the image at position (x, y)

# using the colour given in the Array color which

# represents colour in RGB mode.

#

# Useage

# ======

# First you are required to include this file into your

# php script and then to create a new instance of the

# class, giving it the path and the filename of the

# image that you wish to edit. Like so:

#

# include("ImageEditor.php");

# $imageEditor = new ImageEditor("filename.jpg", "directoryfileisin/");

#

# After you have done this you will be able to edit the

# image easily and quickly. You do this by calling a

# function to act upon the image. See below for function

# definitions and descriptions see above. An example

# would be:

#

# $imageEditor->resize(400, 300);

#

# This would resize our imported image to 400 pixels by

# 300 pixels. To then export the edited image there are

# two choices, out put to file and to display as an image.

# If you are displaying as an image however it is assumed

# that this file will be viewed as an image rather than

# as a webpage. The first line below saves to file, the

# second displays the image.

#

# $imageEditor->outputFile("filenametosaveto.jpg", "directorytosavein/");

#

# $imageEditor->outputImage();

########################################################

 

class ImageEditor {

var $x;

var $y;

var $type;

var $img;

var $font;

var $error;

var $size;

 

########################################################

# CONSTRUCTOR

########################################################

function ImageEditor($filename, $path, $col=NULL)

{

$this->font = false;

$this->error = false;

$this->size = 25;

if(is_numeric($filename) && is_numeric($path))

## IF NO IMAGE SPECIFIED CREATE BLANK IMAGE

{

$this->x = $filename;

$this->y = $path;

$this->type = "jpg";

$this->img = imagecreatetruecolor($this->x, $this->y);

if(is_array($col))

## SET BACKGROUND COLOUR OF IMAGE

{

$colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);

ImageFill($this->img, 0, 0, $colour);

}

}

else

## IMAGE SPECIFIED SO LOAD THIS IMAGE

{

## FIRST SEE IF WE CAN FIND IMAGE

 

if(file_exists($path . $filename))

{

$file = $path . $filename;

}

else if (file_exists($path . "/" . $filename))

{

$file = $path . "/" . $filename;

}

else

{

$this->errorImage("File Could Not Be Loaded");

}

 

if(!($this->error))

{

## LOAD OUR IMAGE WITH CORRECT FUNCTION

$this->type = strtolower(end(explode('.', $filename)));

if ($this->type == 'jpg' || $this->type == 'jpeg')

{

$this->img = @imagecreatefromjpeg($file);

}

else if ($this->type == 'png')

{

$this->img = @imagecreatefrompng($file);

}

else if ($this->type == 'gif')

{

$this->img = @imagecreatefrompng($file);

}

## SET OUR IMAGE VARIABLES

$this->x = imagesx($this->img);

$this->y = imagesy($this->img);

}

}

}

 

########################################################

# RESIZE IMAGE GIVEN X AND Y

########################################################

function resize($width, $height)

{

if(!$this->error)

{

$tmpimage = imagecreatetruecolor($width, $height);

imagecopyresampled($tmpimage, $this->img, 0, 0, 0, 0,

$width, $height, $this->x, $this->y);

imagedestroy($this->img);

$this->img = $tmpimage;

$this->y = $height;

$this->x = $width;

}

}

 

########################################################

# CROPS THE IMAGE, GIVE A START CO-ORDINATE AND

# LENGTH AND HEIGHT ATTRIBUTES

########################################################

function crop($x, $y, $width, $height)

{

if(!$this->error)

{

$tmpimage = imagecreatetruecolor($width, $height);

imagecopyresampled($tmpimage, $this->img, 0, 0, $x, $y,

$width, $height, $width, $height);

imagedestroy($this->img);

$this->img = $tmpimage;

$this->y = $height;

$this->x = $width;

}

}

 

########################################################

# ADDS TEXT TO AN IMAGE, TAKES THE STRING, A STARTING

# POINT, PLUS A COLOR DEFINITION AS AN ARRAY IN RGB MODE

########################################################

function addText($str, $x, $y, $col)

{

if(!$this->error)

{

if($this->font) {

$colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);

if(!imagettftext($this->img, $this->size, 0, $x, $y, $colour, $this->font, $str)) {

$this->font = false;

$this->errorImage("Error Drawing Text");

}

}

else {

$colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);

Imagestring($this->img, 5, $x, $y, $str, $colour);

}

}

}

 

function shadowText($str, $x, $y, $col1, $col2, $offset=2) {

$this->addText($str, $x, $y, $col1);

$this->addText($str, $x-$offset, $y-$offset, $col2);

 

}

 

########################################################

# ADDS A LINE TO AN IMAGE, TAKES A STARTING AND AN END

# POINT, PLUS A COLOR DEFINITION AS AN ARRAY IN RGB MODE

########################################################

function addLine($x1, $y1, $x2, $y2, $col)

{

if(!$this->error)

{

$colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);

ImageLine($this->img, $x1, $y1, $x2, $y2, $colour);

}

}

 

########################################################

# RETURN OUR EDITED FILE AS AN IMAGE

########################################################

function outputImage()

{

if ($this->type == 'jpg' || $this->type == 'jpeg')

{

header("Content-type: image/jpeg");

imagejpeg($this->img);

}

else if ($this->type == 'png')

{

header("Content-type: image/png");

imagepng($this->img);

}

else if ($this->type == 'gif')

{

header("Content-type: image/png");

imagegif($this->img);

}

}

 

########################################################

# CREATE OUR EDITED FILE ON THE SERVER

########################################################

function outputFile($filename, $path)

{

if ($this->type == 'jpg' || $this->type == 'jpeg')

{

imagejpeg($this->img, ($path . $filename));

}

else if ($this->type == 'png')

{

imagepng($this->img, ($path . $filename));

}

else if ($this->type == 'gif')

{

imagegif($this->img, ($path . $filename));

}

}

 

 

########################################################

# SET OUTPUT TYPE IN ORDER TO SAVE IN DIFFERENT

# TYPE THAN WE LOADED

########################################################

function setImageType($type)

{

$this->type = $type;

}

 

########################################################

# ADDS TEXT TO AN IMAGE, TAKES THE STRING, A STARTING

# POINT, PLUS A COLOR DEFINITION AS AN ARRAY IN RGB MODE

########################################################

function setFont($font) {

$this->font = $font;

}

 

########################################################

# SETS THE FONT SIZE

########################################################

function setSize($size) {

$this->size = $size;

}

 

########################################################

# GET VARIABLE FUNCTIONS

########################################################

function getWidth() {return $this->x;}

function getHeight() {return $this->y;}

function getImageType() {return $this->type;}

 

########################################################

# CREATES AN ERROR IMAGE SO A PROPER OBJECT IS RETURNED

########################################################

function errorImage($str)

{

$this->error = false;

$this->x = 235;

$this->y = 50;

$this->type = "jpg";

$this->img = imagecreatetruecolor($this->x, $this->y);

$this->addText("AN ERROR OCCURED:", 10, 5, array(250,70,0));

$this->addText($str, 10, 30, array(255,255,255));

$this->error = true;

}

}

?>

 

 

To desesperado ¬¬

Compartilhar este post


Link para o post
Compartilhar em outros sites

falta o CDATA

 

Coloquei e nao deu certo, acredito que o arquivo que lê as legendas e as fotos na hora da listagem é onde tem o código errado.. page_pictures.php:

 

 

<?php

utf8_encode ($p)

require dirname(__FILE__).'/includes/functions.php';

 

$folder = $_GET["folder"];

$name = $_GET["name"];

 

//this var is used in header.php

//used in the javascript for dragging the <li> tags

$list = "pic";

 

require dirname(__FILE__).'/includes/header.php';

 

// get menu.xml file

$p =& new xmlParser();

$p->parse('../' . $folder . '/pics.xml');

$pictures = isset($p->output[0]['child']) ? $p->output[0]['child'] : array();

?>

<h1>Galeria de Fotos de <?php echo $name; ?></h1>

<hr />

<br>

<form name="form_save" action="save_pictures.php" method="post" onsubmit="return save_pics('pic_list');">

<input type="hidden" name="folder" value="<?php echo $folder; ?>">

<input type="hidden" name="gallery" value="<?php echo $name; ?>">

<input type="hidden" name="pic_names" value="">

<input type="hidden" name="pic_descs" value="">

<input type="hidden" name="pic_deletes" value="">

<p><input type="submit" value="Salvar Mudanças/Deletar Selecionados"/></p>

<ul id="pic_list" class="sortable boxy">

<?php print_pictures($pictures, $folder); ?>

</ul>

<p><input type="submit" value="Salvar Mudanças/Deletar Selecionados"/></p>

</form>

<script language="JavaScript" type="text/javascript"><!--

<?php print_pic_vars($pictures); ?>

//-->

</script>

<?php

 

require dirname(__FILE__).'/includes/footer.php';

 

function print_pictures($pics, $folder){

$pics_html = "";

$count = 0;

 

$template = '<li id="pic_%NUM%">

<div class="handle2"></div>

<table class="text">

<tr>

<td valign="middle" class="pic_box"><img src="../%FOLDER%/thumbs/%NAME%" border="0"></td>

<td class="pic_content" valign="top">

<span class="pic_name">%NAME%</span><input type="checkbox" name="delete_%NUM%">delete<br>

<textarea name="desc_%NUM%" class="pic_desc" onBlur="this.className=\'pic_desc\'" onFocus="this.className=\'pic_desc_on\'">%DESC%</textarea>

</td>

</tr>

</table>

</li>';

//array of vars used in template

$pic_vars = array("%NUM%", "%NAME%", "%FOLDER%", "%DESC%");

 

foreach ($pics as $pic){

//array of replacement values for template

$pic_values = array($count+1, $pics[$count]['attrs']['LOCATION'], $folder , $pics[$count]['attrs']['DESC']);

$pics_html .= str_replace($pic_vars, $pic_values, $template);

 

++$count;

}

echo $pics_html;

}

 

function print_pic_vars($pics){

$count = 1;

foreach ($pics as $pic){

echo("var pic_$count = \"" . $pic['attrs']['LOCATION'] . "\";\r\n");

//var folder_3 = "balh";

++$count;

}

}

?>

 

Em negrito eu adicionei o encode na variável que eu ACHO que é a que contém o xml com os acentos.. em sublinhado é o arquivo xml..

 

Obrigado até agora pelas ajudas amigos.. vcs sao demais.. mas ainda espero resultado :(

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.