Postado Agosto 26, 2013 11 anos Olá pessoal... Estou com um probleminha aqui com meu site no gesior e preciso de alguém com conhecimento amplo no PHP pra me ajudar. Estou usando o Poll System do averatec no site, funciona tudo certinho, o problema é que ao entrar na página, todos os caracteres do layout (não da página subtopic) estão saindo com aquela interrogação. Tentei várias maneiras mas não consegui arrumar de jeito algum... O script da página que eu uso é o seguinte: <html xmlns="http://www.w3.org/1999/xhtml"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"/> <?PHP if($logged) { $link = "polls"; // your link to polls in index.php $dark = $config['site']['darkborder']; $light = $config['site']['lightborder']; $color[] = red; // for <15% $color[] = orange; // for <35% $color[] = yellow; // for <=50% $color[] = green; // for >50% $time = time(); $POLLS = $SQL->query('SELECT * FROM '.$SQL->tableName('z_polls').''); $level = 20; // need level to vote $SQL->query("SET NAMES 'utf8'"); $SQL->query('SET character_set_connection=utf8'); $SQL->query('SET character_set_client=utf8'); $SQL->query('SET character_set_results=utf8'); function color($number, $color1, $color2, $color3, $color4) { if($number < 15) return '<font color='.$color1.'><b>'.$number.'%</b></font>'; elseif($number < 35 and $number >= 15) return '<font color='.$color2.'><b>'.$number.'%</b></font>'; elseif($number <= 50 and $number >=35) return '<font color='.$color3.'><b>'.$number.'%</b></font>'; elseif($number > 50) return '<font color='.$color4.'><b>'.$number.'%</b></font>'; } /* Checking Account */ $account_players = $account_logged->getPlayers(); foreach($account_players as $player) { $player = $player->getLevel(); if($player >= $level) $allow=true; } if(empty($_REQUEST['id']) and $_REQUEST['control'] != "true") // list of polls { $active = $SQL->query('SELECT * FROM `z_polls` where `end` > '.$time.''); // active polls $closed = $SQL->query('SELECT * FROM `z_polls` where `end` < '.$time.' order by `end` desc'); // closed polls /* Active Polls */ $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Active Polls</B></TD></TR>'; if(is_int($number_of_rows / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $number_of_rows++; $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=75%><b>Tópico</b></td><td><b>End</b></td></tr>'; if(is_int($number_of_rows / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $number_of_rows++; foreach($active as $poll) { $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td><a href="?subtopic='.$link.'&id='.$poll['id'].'">'.$poll['question'].'</a></td><td>'.date("M j Y", $poll['end']).'</td></tr>'; $empty_active = true; } if(!$empty_active) { $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><center><i>Don\'t have open polls.</i></center></td></tr>'; } $main_content .= "</table><br><br>"; /* Closed Polls */ $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Closed Polls</B></TD></TR>'; if(is_int($number_of_rows / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $number_of_rows++; $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>'; if(is_int($number_of_rows / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $number_of_rows++; foreach($closed as $poll) { $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td><a href="?subtopic='.$link.'&id='.$poll['id'].'">'.$poll['question'].'</a></td><td>'.date("M j Y", $poll['end']).'</td></tr>'; $empty_closed = true; } if(!$empty_closed) { $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><center><i>Don\'t have closed polls.</i></center></td></tr>'; } $main_content .= "</table>"; $showed=true; } if(!empty($_REQUEST['id']) and $_REQUEST['control'] != "true") { foreach($POLLS as $POLL) { if($_REQUEST['id'] == $POLL['id']) { $ANSWERS = $SQL->query('SELECT * FROM '.$SQL->tableName('z_polls_answers').' where `poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).' order by `answer_id`'); $votes_all = $POLL['votes_all']; if($votes_all == 0) { $i=1; foreach($ANSWERS as $answer) { $percent[$i] = 0; $i++; } } else { $i=1; foreach($ANSWERS as $answer) { $percent[$i] = round(((100*$answer['votes'])/$votes_all),2); $i++; } } if($POLL['end'] > $time) // active poll { if($_REQUEST['vote'] == true and $allow == true) { if($account_logged->getCustomField('vote') < $_REQUEST['id'] and !empty($_POST['answer'])) { if(isset($_POST['continue'])) { $vote = addslashes(htmlspecialchars(trim($_REQUEST['id']))); $account_logged->setCustomField("vote", $vote); $UPDATE_poll = $SQL->query('UPDATE `z_polls` SET `votes_all` = `votes_all` + 1 where `id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).''); $UPDATE_answer = $SQL->query('UPDATE `z_polls_answers` SET `votes` = `votes` + 1 where `answer_id` = '.addslashes(htmlspecialchars(trim($_POST['answer']))).' and`poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).''); header("charset=ISO-8859-1", true, 'Location: index.php?subtopic='.$link.'&id='.$_REQUEST['id'].''); } } else { header("charset=ISO-8859-1", true, 'Location: index.php?subtopic='.$link.'&id='.$_REQUEST['id'].''); } } if($account_logged->getCustomField('vote') < $_REQUEST['id'] and $allow == true) { $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Vote</B></TD></TR>'; $main_content .= '<TR BGCOLOR="'.$dark.'"><td COLSPAN=2 CLASS=white><b>'.$POLL['question'].'</b></td></tr> <form action="index.php?subtopic='.$link.'&id='.$_REQUEST['id'].'&vote=true" method="POST"> '; $ANSWERS_input = $SQL->query('SELECT * FROM '.$SQL->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`'); $i=1; foreach($ANSWERS_input as $answer) { if(is_int($i / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td><input type=radio name=answer value="'.$i.'">'.$answer['answer'].'</td></tr>'; $i++; } $main_content .= '</table><input type="submit" name="continue" value="Submit" class="input2" /></form><br><br>'; } elseif($account_logged->getCustomField('vote') >= $_REQUEST['id']) { $result[] = '<br><b>You have already voted.</b><br>'; } $result[] = '<br>All players with a character of at least level '.$level.' may vote.<br>'; $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=3 CLASS=white><B>Results</B></TD></TR>'; $main_content .= '<TR BGCOLOR="'.$dark.'"><td COLSPAN=3 CLASS=white><b>'.$POLL['question'].'</b></td></tr>'; $ANSWERS_show = $SQL->query('SELECT * FROM '.$SQL->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`'); $i=1; foreach($ANSWERS_show as $answer) { if(is_int($i / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $x=0; $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=60%>'.$answer['answer'].'</td><td>'.$answer['votes'].'('.color($percent[$i], $color[0], $color[1], $color[2], $color[3]).')</td></tr>'; $i++; } $main_content .= '</table>'; foreach($result as $error) { $main_content .= $error; } $main_content .= '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>'; $main_content .= 'The poll will end at '.date("M j Y", $POLL['end']).'<br>'; $main_content .= '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>'; } else // closed poll { $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=3 CLASS=white><B>Results</B></TD></TR>'; $main_content .= '<TR BGCOLOR="'.$dark.'"><td COLSPAN=3 CLASS=white><b>'.$POLL['question'].'</b></td></tr>'; $ANSWERS_show = $SQL->query('SELECT * FROM '.$SQL->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`'); $i=1; foreach($ANSWERS_show as $answer) { if(is_int($i / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=60%>'.$answer['answer'].'</td><td width=20%><img src=bar.php?long='.(int) $percent[$i].'"></td><td>'.$answer['votes].'('.color($percent[$i], $color[0], $color[1], $color[2], $color[3]).')</td></tr>'; $i++; } $main_content .= '</table><br><br>'; $main_content .= '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>'; $main_content .= 'The poll ended at '.date("M j Y", $POLL['end']).'<br>'; $main_content .= '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>'; } $showed=true; $main_content .= '<div class=\'hr1\'></div><a href="index.php?subtopic='.$link.'"><font size="2"><b>Go to list of polls</b></font></a>'; } } } if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] != "true") { $main_content .= '<br><a href="?subtopic='.$link.'&control=true"><b>Panel Control</b></a><br><br>'; } /* Control Panel - Only Add Poll Function */ if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] == "true") { if(isset($_POST['submit'])) { $_SESSION['answers'] = $_POST['answers']; $main_content .= '<form method="post" action=""><b><font size=3>Adding Poll</font></b><br><br> <input type=text name=question value="" /> Question<br> <input type=text name=end value="" /> Time to end, in days<br>'; for( $x = 1; $x <= $_SESSION['answers']; $x++ ) { $main_content .= '<input type=text name='.$x.' value="" /> Answer no. '.$x.'<br>'; } $main_content .= '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>'; $show=true; } if(isset($_POST['finish'])) { $id = $SQL->query('SELECT MAX(id) FROM `z_polls`')->fetch(); $id_next = $id[0] + 1; for( $x = 1; $x <= $_SESSION['answers']; $x++ ) { $INSERT_answer = $SQL->query('INSERT INTO `z_polls_answers` (`poll_id`,`answer_id`,`answer`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($x).','.$SQL->quote($_POST[$x]).')'); } $end = $time+24*60*60*$_POST['end']; $INSERT_poll = $SQL->query('INSERT INTO `z_polls` (`id`,`question`,`end`,`answers`,`start`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($_POST['question']).','.$SQL->quote($end).','.$SQL->quote($_SESSION['answers']).','.$SQL->quote($time).')'); } $POLLS_check = $SQL->query('SELECT MAX(end) FROM '.$SQL->tableName('z_polls').''); foreach($POLLS_check as $checked) { if($checked[0] > $time) $check=true; else $check=false; } if(!$show) { if(!$check) { $main_content .= '<form method="post" action=""><b><font size=3>Adding Poll</font></b><br><br> <input type=text name=answers value="" /> Number of Answers<br> <input type="submit" name="submit" value="Submit" class="input2"/></form><br><br>'; } else { $main_content .= '<b><font size=3><br>Cannot be two and more active polls.<br><br></font></b>'; } } $showed=true; $main_content .= '<br><div class=\'hr1\'></div><a href="index.php?subtopic='.$link.'"><font size="2"><b>Go to list of polls</b></font></a>'; } if(!$showed) { $main_content .= 'This poll doesn\'t exist.<br>'; $main_content .= '<div class=\'hr1\'></div><a href="index.php?subtopic='.$link.'"><font size="2"><b>Go to list of polls</b></font></a>'; } } else { $main_content .= '<a href="?subtopic=accountmanagement">Faça o Login</a>'; } ?> As outras páginas funcionam normalmente, sem nenhum erro. OBS: Já estou usando a definição do charset no layout.php, tentei esse método na .php das enquetes mas não mudou nada. Alguém aí sabe como resolver? Agradeço desde já... Editado Agosto 26, 2013 11 anos por johnard (veja o histórico de edições)
Postado Agosto 26, 2013 11 anos Autor Continuou desconfigurado... Mudei tanto no layouts.php e no polls.php. Editado Agosto 26, 2013 11 anos por johnard (veja o histórico de edições)
Postado Agosto 26, 2013 11 anos abra com o bloco de notas e clica em salva como ai na codificação troque ANSI por utf-8 e salva o arquivo e coloca na pasta do site.
Postado Agosto 26, 2013 11 anos Links de referencia: 1- http://www.rafaeltheodoro.com.br/php/caracteres-especiais-com-charset-utf-8/ 2- http://blog.hospedandosites.com.br/resolva-problemas-de-acentuacao-em-seu-site/#.Uhu1A9KL0mY 3- http://www.joomlaclube.com.br/site/forum/viewtopic.php?f=15&t=12971 Veja se algum te ajuda. Atenciosamente, Stigal. Editado Agosto 26, 2013 11 anos por Stigal (veja o histórico de edições) "O fracasso é a oportunidade de se começar de novo inteligentemente" Minhas Redes Sociais: Youtube | Página & Grupo | Steam | Discord TibiaKing
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.