แจก PHP Article Rewriter แบบง่ายคับ

เริ่มโดย แบบนี้ไม่ต้องสืบ, 17 สิงหาคม 2007, 16:52:42

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

แบบนี้ไม่ต้องสืบ

แจก PHP Article Rewriter แบบง่ายคับ พอดีไปเจอมาคับหวังว่าจะมีประโยชน์  ;D ;D ;D

<?php

//Article Rewriter
//v1.0
//Copyright [email protected]
//Rewrite an article by translating it from english to french, and than back to english
//Translation done trough google translate

/*
by [email protected]
-----------------------------
Rewrite an article by translating it from english to french, and than back to english
Translation done trough google translate
-----------------------------------------
Upload the rewrite.php file to your website, and that's all. Have Fun:)
Please note that because rewriting it is done trough Google Translate, if you abuse and make hundred of rewritings/day, you might get a temporary ban from Google.
*/


$text=$_POST["text"];
if(
$text!="")
{

$url "http://translate.google.com/translate_t";
$useragent="YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)";

$ch curl_init();
curl_setopt($chCURLOPT_USERAGENT$useragent);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_POST4);

$text=urlencode($text);

$postdata="hl=en&ie=UTF8&langpair=en|fr&text=".$text;
curl_setopt($chCURLOPT_POSTFIELDS,$postdata);
$resultcurl_exec ($ch);
curl_close ($ch);

$dela=strpos($result,"<div id=result_box dir=ltr>");
$panala=strpos($result,"</",$dela);
$text=substr($result,$dela+27,$panala-$dela-27);

$text=str_replace("&#38;#39;","'",$text);
$text=str_replace("&amp;","&",$text);

$ch curl_init();
curl_setopt($chCURLOPT_USERAGENT$useragent);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_POST4);

$text=urlencode(utf8_encode($text));

$postdata="hl=en&ie=UTF8&langpair=fr|en&text=".$text;
curl_setopt($chCURLOPT_POSTFIELDS,$postdata);
$resultcurl_exec ($ch);
curl_close ($ch);


$dela=strpos($result,"<div id=result_box dir=ltr>");
$panala=strpos($result,"</",$dela);
$text=substr($result,$dela+27,$panala-$dela-27);

echo 
$text;

}
else
{
echo 
'
<center>
<form method="post" action="rewrite.php">
  
  <p><strong>Article Rewriter     </strong></p>
  <p>
    <textarea name="text" cols="70" rows="20"></textarea>
    </p>
  <p>
   
    <input type="submit" name="Submit" value="ReWrite" />
    
  </p>
</form>
</center>'
;
}
?>



อัพโหลดเป็น rewrite.php แล้วก็ใช้ซะ

aomnaruk

ขอบคุณครับ

ปล.เท่าที่ดู code รู้สึกจะแปลกลับไปกลับมาใช่ใหมครับ

แบบนี้ไม่ต้องสืบ

อ้างถึงจาก: aomnaruk ใน 17 สิงหาคม 2007, 16:55:16
ขอบคุณครับ

ปล.เท่าที่ดู code รู้สึกจะแปลกลับไปกลับมาใช่ใหมครับ

Translating it from english to french, and than back to english

ถูกแล้วคับ

MonkyDLuffy

เอากูเกิล มาหลอกกูเกิล อิอิ ขอบคุณครับ เด๊วลองดู :)

เรารักนายนะน้องฟี่

ขอบคุณครับ แต่มันยัง มีบัค นิดหน่อย

A wall of the narrow gallery was furnished with the white industrial shelf filled with boxes d&#39; an ordered manner marked containing photographs, manuscripts, letters, stores and objects gathered by lace and Labowitz. Well qu&#39; one n&#39; did not allow visitors d&#39; to explore the boxes, the 12 younger artists were given the white cotton gloves and guests to choose 10 articles each one. They were recorded in video discussing their results, and resulting DVDs played on monitors intermingled among the boxes.

ตรงคำแปลกๆ

KapookOmsin

แจ่มครับ หุๆ   :'( :'(

ความคิดกระฉูด  :) :)

Gemini

คนเขียนก็เข้าใจคิดดีนะครับ แต่ว่าแปลกลับไปกลับมามันจะยังอ่านได้ใจความมั้ย หรือว่าได้สักกี่ %

???

ton01


nume

 ;D อ่านแล้วฮาดีเหมือนเอาคำพ้องความหมายมาใส่แทน แปลกๆครับ แต่ก็ง่ายดี
[direct=http://daekyoamerica.com/888paydaylaon/][/direct]
[direct=http://bestbuymastercreditcard.com/]best buy credit card[/direct] [direct=http://moon3dbook.com/]:P[/direct]
สมัครHostgatorไม่เป็นpmมาครับ

tee04

เอาไปใช้กับ hypervre ได้ไหมคะ  ถ้าใช้ได้ ต้องเอาไปแปะไว้ที่ส่วนไหนของ hypervre คะ
ขอบคูณคะ :-*

nume

คือมันเป็นคิปครับ ต้องทำเป็นบทความให้เสร็จก่อนแล้วค่อยแอดแบบทำมือ
[direct=http://daekyoamerica.com/888paydaylaon/][/direct]
[direct=http://bestbuymastercreditcard.com/]best buy credit card[/direct] [direct=http://moon3dbook.com/]:P[/direct]
สมัครHostgatorไม่เป็นpmมาครับ

tee04

โอ้ ขอบคุณม๊ากมากเลยค่ะ :-*

joe

เห็นแต่ก่อนมีคนพูดถึงเหมือนกัน แต่ไม่เคยใช้
วันนี้ได้ของมา ต้องขอลองหน่อยแล้ว

ขอบคุณมากครับ  :)

ล่า

ใช้ไดนะอันนี้

เอามาใส่โน่นนิดนี่หน่อยก็อ่านรู้เรื่องแล้ว

แต่ขึ้นอยู่กับต้นฉบับด้วยนะครับ

แต่เท่าที่ลองมาสองสามอัน ก็แก้แค่ไม่กี่จุด ก็พอไหว

iPhoenix

ตัวนี้ curl_init มันมีหน้าที่อะไรครับ ผมติดตัวนี้อะรันไม่ได้ครับ

invisibleman


e-business

คูปอง Facebook (มูลค่า $50) เพียงใบละ 259-299 บาท

ColdMoney

[direct=https://www.jumnong.com]รับจำนอง[/direct] [direct=https://burapasup.com]รับซื้อบ้าน[/direct] [direct=https://kadsan.com]สินค้าราคาถูก[/direct] [direct=https://checkcheap.com]เปรียบเทียบราคา[/direct]

ball6847

#18
ขอขุดทีนึงนะคับ พอดีเจอกระทู้นี้แล้ว คิดว่าเจ้าของสคริปทืเค้าไอเดียดีมั่กๆ แต่ว่าสคริปท์มี บั้ก อยู่บางที่

เท่าที่ดูผมคิดว่าสำหรับ คนที่เก่ง PHP อยู่แล้วเอาไปแก้บั้ก หรือ เอาไปโม ต่อได้สบายๆ เลย

แต่ทำมัยไม่เห็นมีใครแก้บั้กให้เลยอ่ะ ปล่อยให้ใช้กันซะอย่างงั้น ผมก็เลยคิดว่าจะเขียนใหม่โดยใช้ไอเดียเดียวกันนี้นะคับ ให้เอาไปใช้กัน

***ออกตัวก่อนว่าผมไม่ใช่โปรแกรมเมอร์ ไม่เคยเรียนเขียน PHP มาจากไหน (เรียนมัธยมยังไม่จบเลย -*-) ดังนั้นพื้นฐานผมไม่ปึ้ก ทุกอย่างเกิดจากการลองผิดลองถูกเอาเอง ดังนั้นถ้าอันไหนที่ผมเขียนไม่ถูกหลัก หรือโค้ดดูรกๆ มั่วๆ ต้องขออภัยมา ณ ที่นี้คับ

*** ก๊อป Code ใส่ notepad แล้วเซฟเป็น rewrite.php นะคับ ไม่งั้นทำงานไม่ได้

*** ผมไม่ได้ใช้ curl เหมือนต้นฉบับนะคับ เพราะปกติผมเขียนผมจะใช้ HTTP_Request ของ PEAR Package อ่ะคับ ผมเลยเขียนอันนี้ด้วย HTTP_Request ทำให้เครื่องที่ไม่มี PEAR จะใช้ไม่ได้นะคับ (นอกจากจะไปหามาลงเอง แต่ปกติแล้วมีเกือบหมดนะ) ถ้าใช้กันไม่ได้เยอะเด๋วผมจะแก้เป็นใช้ curl อีกที (หรือใครจะแก้ให้ก็ขอบคุงมากๆเลยคับ) ถ้าไม่มีทั้งสองอย่างเลย ก็อย่าไปใช้มันเลยคับ  :P

*** ใครเจอบั้กช่วยบอกกันด้วยนะคับ แก้ได้จะแก้ให้ แก้ไม่ได้ก็แล้วแต่เวรแต่กรรมคับ หรือใครเจอ Error ยังงัยก็ลองมาโพสท์ดูคับ

*** ผมเปลี่ยนจาก english <-> french เป็น english <-> italian นะคับ เพราะภาษาฝรั่งเศสมีอักขระแปลกๆ เยอะคับ เท่าที่ลองเลือกมามีภาษา อิตาลีนี่เรียบๆ ที่สุด ผมลองใช้ดูแล้ว ก็พออ่านได้อ่ะนะคับ (แต่จะมีบางคำที่ google มันแปลกลับให้ไม่ได้นะคับ)

เอาไปลองดูคับ



<?php

require_once('HTTP/Request.php');

$action $_GET['act'];

if(!
$action){
print <<<FORM
<center>
<form method="post" action="?act=trans">
  
  <p><strong>Article Rewriter     </strong></p>
  <p>
    <textarea name="text" cols="70" rows="20"></textarea>
    </p>
  <p>
   
    <input type="submit" name="Submit" value="ReWrite" />
    
  </p>
</form>
</center>
FORM;
}

if(
$action == 'trans'){

$text $_POST['text'];
$text str_replace("\'","'",$text);
$text str_replace('\"','||--||',$text);
$text str_replace("\n",'<br />',$text);

$result translate($text,'en|it'); //  if you want French pair with English
$result translate($result,'it|en'); // Just edit 'en|it' and 'it|en' to 'en|fr' and 'fr|en'

$result str_replace('||--||','"',$result);


print 
$result;

print <<< BACK
<br /><br /><br /><br />
<a href="rewrite.php">Click here to translate another article</a>. 
BACK;
}

function 
translate($text,$langpair){
$url 'http://translate.google.com/translate_t';
$r = new HTTP_Request($url);
$r->setMethod(HTTP_REQUEST_METHOD_POST);
$r->addPostData('hl','en');
$r->addPostData('ie','UTF8');
$r->addPostData('text',$text);
$r->addPostData('langpair',$langpair);
$r->sendRequest();
$result $r->getResponseBody();
$split substr($result,strpos($result,'<div id=result_box'));
$split substr($split,0,strpos($split,'</div>')+6);
$result htmlspecialchars_decode(strip_tags($split),ENT_QUOTES);
return $result;
}

?>




ย้ำอีกทีนะคับ ผมไม่ได้ร่ำเรียนมา ถ้าผิดผมต้องขอโทดจิงๆ คับ (กลัวคนเก่งๆหาว่าอ่อนแล้วยังจะทำอ่ะ) ทั้งหมดทำไปเพื่อให้ได้ใช้ประโยชน์กันทั่วๆ น่ะคับ

ต้องขอขอบคุณ จขกท และ คนที่เขียนต้นฉบับ มา ณ ที่นี้ด้วยนะคับ

-------------
*หากต้องการเปลี่ยนคู่ภาษาเป็น eng-french เหมือนต้นฉบับให้เปลี่ยนตาม comment ใน code นะคับ เพราะบางทีอิตาลีก็ไม่ได้เรื่อง บางที ฝรั่งเศสก็ไม่ได้เรื่อง ต้องลองๆกันดูเอานะคับ
We use Ubuntu.

[direct=http://ng-seo.sourcelab.xyz/]AngularJS SEO Experimental[/direct]

sisi