|
|
|
ทำระบบข่างค่ะต้องการให้มันพิมภาษาอื่นได้นอกจากภาษาไทย-อังกฤษช่วยทีนะคะ |
|
|
|
|
|
|
|
ทำระบบข่าวสารค่ะแต่อยากให้มันพิมภาษาญี่ปุ่นได้ด้วยแต่พอพิมออก มาแล้วมันได้เป็นKอกฉ็?๑4000?N?OษC?hล?aถตAณXอC?hล?mฬCsฬ๊ยฦตฤsํ๊ฤขฝSgฬ?bB?@ลตฝ รองใส่ไอ้นี่ EUC เข้าไปเหมือนเคยๆก็ไม่หายคะ ใส่UFT-8 ก็ไม่หายค่ะก็เลยไม่รู้ว่าจะต้องแก้อย่างไรรบกวนพี่ๆอีกทีนะคะเพื่อการศึกษาของเด็กไทย
หน้า newssert.php
<?php ob_start('ob_gzhandler'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta httpequiv="content-type" content="text/html;charset=TIS-620"/>
<title>เพิ่มข่าวลงฐานข้อมูล</title>
<style type="text/css">
* { font-family: 'MS Sans Serif','Microsoft Sans Serif',sans-serif; }
.tblReplies { margin:10 0;width:80%;table-layout:fixed border:solid 1px #666666;background-color:#FFFFFF;padding:5; }
.tblReplies td { border-bottom:solid 1px #FFFFFF; }
.tdRStatsBar { padding:5px; background-color:#2C4189; color:#FFFFFF; font-size:12px; text-align:right;}
.tdRStatsBar span.separator { margin:0 5;border-left:solid 2px #425FC1; }
.tdRStatsBar a { color:gold; text-decoration:none; border-bottom:dashed 1px; }
.tdRContent { background-color:#E0E6F5;font-size:16px;padding:10px; }
.tdRContent a { color:blue; text-decoration:none; border-bottom:dashed 1px; }
.tdRContent a img { border:none; }
.ulToolbar {display:block;width:602px;overflow:hidden;background-color:#CCCCCC;margin:0;padding:0;cursor:pointer;z-index:0;}
.ulToolbar li {float:left;text-align:center;list-style:none;vertical-align:middle;}
#divOverlay { position:absolute; left:0; top:0; z-index:100; background-color:#000000; display:none; opacity:0.6; cursor:not-allowed; }
#divLoading { position:absolute;left:0;top:0;z-index:102;display:none; }
#divReplies .tdRStatsBar { background-color: #677ECD; }
#divReplies .tdRStatsBar span.separator { border-left:solid 2px #2C4189; }
#divAbout { border-top: dotted 1px #CCCCCC; margin:1%; padding:10; text-align:center; color:#999999;font-size:10px; }
#divAbout a { color:gold;text-decoration:none;border-bottom:dotted 1px; }
#divAdmin { display:none;position:absolute;z-index:98;padding:2;background-color:#FFFFFF;border:solid 1px #999999; }
#divAdmin input, #divAdmin button { font-size:9px;padding:0;margin:0 1 0 0;border:solid 1px;height:16px;vertical-align:middle; }
.btnAdmin { float:right; background-color:#5670C9; width:5;height:5;cursor:pointer; }
</style>
<script type="text/javascript" src="news_supp_files/xbDesignMode.js"></script>
<script type="text/javascript">
function initEditor() { if(!document.DM) document.DM = new xbDesignMode('tRTE'); }
function askLink(){var uri=window.prompt('Enter URL for link (full url with http://)','');if(uri){document.DM.execCommand('createLink',uri);}};
function askImg(){var uri=window.prompt('Enter URL for image (full url with http://)','');if(uri){document.DM.execCommand('insertImage',uri);}};
function setFS(fs){document.DM.execCommand('fontSize',fs);};
function setFC(fc){document.DM.execCommand('foreColor',fc);};
function emo(im){document.DM.execCommand('insertImage',im.src);};
function cmd(c){document.DM.execCommand(c);};
function closeDivForm(){$('#divOverlay').hide();$('#divForm').hide();};
function formValidate(o){
o.elements['Content'].value=document.DM.getHTML();
if(o.elements['Password'].value==''){
alert('ไม่มีชื่อคนตั้งคำถาม!');
return false;
}
return true;
};
</script>
</head>
<body onload="initEditor()" topmargin="0" bgcolor="#F0F0F0">
<center>
<form id="theForm" method="post" action="newssubmit.php" enctype="multipart/form-data" onsubmit="formValidate(this)">
<table style="background-color:#F0F0F0;table-layout:fixed;width:620px;" cellspacing="3" cellpadding="3" border="1" bordercolor="#000000">
<thead>
<td align="center" style="background-color:#666666;color:#FFFFFF;">
<font size="6"><b>เพิ่มข่าวลงฐานข้อมูล</b>
</font>
</td>
</thead>
<tr>
<td>
<div style="width:100px;float:left;text-align:center;">หัวข้อ : </div>
<input type="text" name="Title" style="width:500px" size="20">
</td>
</tr>
<tr>
<td>
<div style="width:100px;float:left;text-align:center;">เนื้อหา : </div>
</td>
</tr>
<tr>
<td>
<ul class="ulToolbar">
<li><img src="news_supp_files/separator.gif"/><img src="news_supp_files/bold.gif" title="ตัวหนา" onclick="cmd('bold')"/></li>
<li><img src="news_supp_files/italic.gif" title="ตัวเอียง" onclick="cmd('italic')"/></li>
<li><img src="news_supp_files/underline.gif" title="ขีดเส้นใต้" onclick="cmd('underline')"/></li>
<li><img src="news_supp_files/strikethrough.gif" title="ขีดฆ่า" onclick="cmd('strikethrough')"/></li>
<li><img src="news_supp_files/superscript.gif" title="ตัวยก" onclick="cmd('superscript')"/></li>
<li><img src="news_supp_files/subscript.gif" title="ตัวห้อย" onclick="cmd('subscript')"/></li>
<li><img src="news_supp_files/separator.gif"/><img src="news_supp_files/fs-3.gif" title="ขนาดอักษรเล็กมาก" onclick="setFS(0)"/></li>
<li><img src="news_supp_files/fs-2.gif" title="ขนาดอักษรเล็กกว่า" onclick="setFS(1)"/></li>
<li><img src="news_supp_files/fs-1.gif" title="ขนาดอักษรเล็ก" onclick="setFS(2)"/></li>
<li><img src="news_supp_files/fs0.gif" title="ขนาดอักษรธรรมดา" onclick="setFS(3)"/></li>
<li><img src="news_supp_files/fs1.gif" title="ขนาดอักษรใหญ่" onclick="setFS(4)"/></li>
<li><img src="news_supp_files/fs2.gif" title="ขนาดอักษรใหญ่กว่า" onclick="setFS(5)"/></li>
<li><img src="news_supp_files/fs3.gif" title="ขนาดอักษรใหญ่มาก" onclick="setFS(6)"/></li>
<li><img src="news_supp_files/separator.gif"/><img src="news_supp_files/insert_picture_on.gif" title="ใส่รูป" onclick="askImg()"/></li>
<li><img src="news_supp_files/insert_hyperlink_on.gif" title="ลิ้งค์" onclick="askLink()"/></li>
<li><img src="news_supp_files/separator.gif"/><img src="news_supp_files/unlink.gif" title="ถอดลิ้งค์" onclick="cmd('unlink')"/></li>
<li><img src="news_supp_files/unformat.gif" title="ยกเลิกฟอร์แม็ต" onclick="cmd('removeformat')"/></li>
</ul>
<ul class="ulToolbar">
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" title="Black" style="background-color:#000000"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" title="DimGray" style="background-color:#696969"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" title="Gray" style="background-color:#808080"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#C0C0C0" title="Silver"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FFFFFF" title="White"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#00008B" title="DarkBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#0000CD" title="MediumBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#0000FF" title="Blue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#5F9EA0" title="CadetBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#483D8B" title="DarkSlateBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#1E90FF" title="DodgetBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#4682B4" title="SteelBlue"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#008000" title="Green"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#9ACD32" title="YellowGreen"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FFFF00" title="Yellow"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#6B8E23" title="OliveDrab"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#66CDAA" title="MediumAquamarine"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#32CD32" title="LimeGreen"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#8FBC8B" title="DarkSeaGreen"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#D2691E" title="Chocolate"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF8C00" title="DarkOrange"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FFA500" title="Orange"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FFD700" title="Gold"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#F4A460" title="SandyBrown"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF6347" title="Tomato"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#DC143C" title="Crimson"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#8B0000" title="DarkRed"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF0000" title="Red"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF1493" title="DeepPink"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF69B4" title="HotPink"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#800080" title="Purple"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#FF00FF" title="Magenta"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#BA55D3" title="MediumOrchid"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#EE82EE" title="Violet"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#D8BFD8" title="Thistle"></li>
<li><img src="news_supp_files/blank.gif" onclick="setFC(this.style.backgroundColor)" style="background-color:#DB7093" title="PaleVioletRed"></li>
</ul>
<iframe id="tRTE" style="width:600px;height:240px;border:solid 1px black;background-color:#FFFFFF;display:block;z-index:-1;" frameborder="0"></iframe>
<input type="hidden" name="Content" value="">
</td>
</tr>
<tr>
<td>
<p align="left">แทรกรูปภาพ :
<input type="file" name="Image" size="20">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">รหัสผ่าน :
<input type="password" name="Password" size="20">
</p>
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit"> <input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
<? ob_end_flush(); ?>
หน้า index.php
<?php
require_once('news.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>รายงานข่าวคราวต่างๆ</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<style type="text/css">
.dcontain {
width: 300px;
margin: 5px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
}
.dtitle { font-family: MS Sans Serif ;font-weight:bold; font-size:24px; background-color:khaki; color:#666; text-align:center;}
.dcontent { font-family: MS Sans Serif ; background-color:white; font-size:15px; padding: 10px 30px; text-align: center; }
.dimage { border: solid 1px black; }
</style>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><center>
<?
$N = getNews();
foreach($N as $n) : ?>
<div class="dcontain">
<div>
<?=$n->Title;?>
</div>
<div class="dcontent">
<? if($n->Image) : ?>
<img src="<?=$n->Image;?>" width="250" height="117"/>
<? endif; ?>
<p>
<?=$n->Content;?>
</p>
</div>
</div>
<? endforeach; ?>
<br />
<font face="MS Sans Serif" size="2"><b><font color="#000080">ข่าวที่มีทั้งหมดคือ
<?=getNewsCount();?>
ข่าว</b></font> </font>
</center></td>
</tr>
</table>
</body>
</html>
หน้า news.php
<?
require_once('news.config.php');
class News
{
var $Title;
var $Content;
var $Image;
var $Filename;
function News($title='', $content='', $image='') {
$this->Title = $title;
$this->Content = $content;
$this->Image = $image;
$this->Filename = false;
}
function load($fn) { return unserialize(file_get_contents($fn)); }
function save() {
if(!$this->Filename) { $this->Filename = date('YmdHis').'.txt'; }
$fh = @fopen(SAVEPATH.$this->Filename, 'wb');
$rslt = @fwrite($fh, serialize($this));
@fclose($fh);
return $rslt;
}
}
function _STRIPFILENAME(&$v) { $v = News::load($v); }
function &getNews($page=1) {
$offset = ($page-1)*ITEMSPERPAGE;
$files = glob(SAVEPATH.'??????????????.txt');
rsort($files);
$files = array_slice($files, $offset, ITEMSPERPAGE);
array_walk($files, '_STRIPFILENAME');
return $files;
}
function getNewsCount() { return count(glob(SAVEPATH.'??????????????.txt')); }
function getPagesCount() {return max(ceil(getNewsCount()/ITEMSPERPAGE),1); }
?>
หน้าnewssubmit.php
<?php
require_once('news.config.php');
if($_POST['Password'] != ADMINPASSWORD) { die('Permission denied: You not have admin permission to post this data.'); }
$newfn = '';
if($_FILES['Image']['error']==0) {
$pinfo = pathinfo($_FILES['Image']['name']);
$newfn = IMAGEPATH.time().'_'.mt_rand(1,999999).'.'.$pinfo['extension'];
move_uploaded_file($_FILES['Image']['tmp_name'], $newfn);
}
require_once('news.php');
$G = new News($_POST['Title'], stripslashes($_POST['Content']), $newfn);
if($G->save()) {
echo "<center><table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"87%\" id=\"AutoNumber1\" height=\"103\">
<tr>
<td width=\"100%\" height=\"103\" bgcolor=\"#CCFFCC\">
<p align=\"center\"><b><font face=\"MS Sans Serif\" size=\"2\" color=\"#800000\">
ขณะนี้ข่าวหัวข้อ "$_POST[Title]" ได้ถูกโพสลงฐานข้อมูลเป็นที่เรียบร้อยแล้ว</font></b></td>
</tr>
</table></center>";
} else {
echo "<center><table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"87%\" id=\"AutoNumber1\" height=\"103\">
<tr>
<td width=\"100%\" height=\"103\" bgcolor=\"#CCFFCC\">
<p align=\"center\"><b><font face=\"MS Sans Serif\" size=\"2\" color=\"#800000\">
ข่าวหัวข้อ "$_POST[Title]" ไม่สามารถโพสลงฐานข้อมูลได้</font></b></td>
</tr>
</table></center>";
}
?>
ขอบพระคุณคะ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-05-22 01:27:34 |
By :
oopeiw |
View :
1105 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ utf-8 ครับจะใช้ได้ทั้ง th en jp เลย
|
|
|
|
|
Date :
2009-05-22 02:05:45 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ฐานข้อมูลเป็น UTF8 อย่าง PlaKriM ว่าครับ
แล้วไฟล์ที่อ่านก็แปลงเป็น utf8 ด้วยเลยครับ รองรับทุกภาษาดี
ถ้าฐานข้อมูลเป็น tis-620 อยู่ ก็ไปเปลี่ยนเป็น UTF-8 เวลา query ก็ต้องซตเป็น utf-8 ไปเลยครับ
mysql_query("SET NAMES UTF8"); แบบนี้
ตรง Meta ก็
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
deawx
[email protected]
ปรึกษา PHP ฟรีจ้า
|
|
|
|
|
Date :
2009-05-22 03:38:53 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้แบบ UTF-8 ครับ แก้ปัญหาเรื่องภาษาได้ครับ
|
|
|
|
|
Date :
2009-05-22 06:04:02 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Strict Standards: Non-static method News::load() should not be called statically
ของผม มัน error อยู่ บรรทัดที่ 28 ครับ
<?
require_once('news.config.php');
class News
{
var $Title;
var $Content;
var $Image;
var $Filename;
function News($title='', $content='', $image='') {
$this->Title = $title;
$this->Content = $content;
$this->Image = $image;
$this->Filename = false;
}
function load($fn) { return unserialize(file_get_contents($fn)); }
function save() {
if(!$this->Filename) { $this->Filename = date('YmdHis').'.txt'; }
$fh = @fopen(SAVEPATH.$this->Filename, 'wb');
$rslt = @fwrite($fh, serialize($this));
@fclose($fh);
return $rslt;
}
}
function _STRIPFILENAME(&$v) { $v = News::load($v); }
function &getNews($page=1) {
$offset = ($page-1)*ITEMSPERPAGE;
$files = glob(SAVEPATH.'??????????????.txt');
rsort($files);
$files = array_slice($files, $offset, ITEMSPERPAGE);
array_walk($files, '_STRIPFILENAME');
return $files;
}
function getNewsCount() { return count(glob(SAVEPATH.'??????????????.txt')); }
function getPagesCount() {return max(ceil(getNewsCount()/ITEMSPERPAGE),1); }
?>
|
|
|
|
|
Date :
2011-04-21 15:39:24 |
By :
poulim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|