|
 |
|
ถามเรื่องการแปลง preg_replace กับ urlencode ครับ เราสามาถเลือกช่วงระหว่าง ข้อความนี้ ถึงข้อความนี้ได้ไหม |
|
 |
|
|
 |
 |
|
อันนี้คือข้อความ
Code (PHP)
[ฝรั่ง]-[HD2DVD] XXXX [2010] [DVD XXXX]-[XXXX] XXXXXXX
[ur l=http://www.xxxx.xxxx/xxxx/MovieDVD/xxxx/Death 1 1 44.iso]
[im g]http://www.image.com/downloadbutt_n.gif[/img][/url]
[im g]http://www.image.com/imgupload/images/viu1281627109a.jpg[/img]
[im g]http://www.image.com/imgupload/images/cqs1281627119c.jpg[/img]
[im g]http://www.image.com/imgupload/images/rgh1281627120g.jpg[/img]
[im g]http://www.image.com/imgupload/images/arx1281627120c.jpg[/img]
[im g]http://www.image.com/imgupload/images/jdv1281627121n.jpg[/img]
อันนี้คือฟังชั่นที่ผมใช้งาน
Code (PHP)
function getvip($posting) {
$posting=str_replace("</div>","",$posting);
$posting=str_replace("[","[",$posting);
$posting=str_replace("]","]",$posting);
$posting=str_replace(" "," ",$posting);
$posting=eregi_replace("http://www.xxxx.xxxx","http://111.222.333.444",$posting);
$nostr="image.com/imgupload";
if(strstr($posting,$nostr))
{
//$posting=eregi_replace("\[IMG\]([^\[]+)\[/IMG\]","",$posting);
$posting=eregi_replace("\[URL=http://www.image.com/","[IMG]http://www.image.com/",$posting);
$posting=eregi_replace("thumbs","images",$posting);
$posting=eregi_replace("\]\[img\]","[/del][img]",$posting);
$posting=eregi_replace("\[IMG\]http://www.image.com/imgupload/viewer.php","[del]",$posting);
$posting=eregi_replace("\[del\]([^\[]+)\[/del\]","",$posting);
$posting=str_replace("[url=http://111","[download][url=http://111",$posting);
$posting=str_replace("gif[/img] [/url]","gif[/img][/url][/download]",$posting);
$posting=str_replace("gif[/img][/url]","gif[/img][/url][/download]",$posting);
$posting=eregi_replace("\[/url\]","",$posting);
$posting=eregi_replace("\[/img\]\[/download\]","[/img][/url][/download]",$posting);
$posting=eregi_replace("\[/img\] \[/download\]","[/img][/url][/download]",$posting);
}else{
$posting=str_replace("[url=http://111","[download][url=http://111",$posting);
$posting=str_replace("gif[/img][/url]","gif[/img][/url][/download]",$posting);
$posting=str_replace("gif[/img] [/url]","gif[/img][/url][/download]",$posting);
}
$posting=eregi_replace("<div","",$posting);
$posting=str_replace('class=\"code\">',"",$posting);
$posting=str_replace('class="code">',"",$posting);
$posting=eregi_replace(",1\[/del\]","]",$posting);
$posting=eregi_replace(",2\[/del\]","]",$posting);
$posting=eregi_replace(",3\[/del\]","]",$posting);
$posting=eregi_replace(",4\[/del\]","]",$posting);
$posting=eregi_replace(",5\[/del\]","]",$posting);
$posting=eregi_replace("\[/del\]","]",$posting);
$posting=eregi_replace("\[del\]","",$posting);
$posting=eregi_replace(",1\]\[img\]","][img]",$posting);
$posting=eregi_replace(",2\]\[img\]","][img]",$posting);
$posting=eregi_replace(",3\]\[img\]","][img]",$posting);
$posting=eregi_replace(",4\]\[img\]","][img]",$posting);
return $posting;
}
อันนี้พอใช้งานฟังชั่น
Code (PHP)
[ฝรั่ง]-[HD2DVD] XXXX [2010] [DVD XXXX]-[XXXX] XXXXXXX
[download][ur l=http://111.222.333.444/xxxx/MovieDVD/xxxx/Death 1 1 44.iso]
[im g]http://www.image.com/button/downloadbutt_n.gif[/img][/url][/download]
[im g]http://www.image.com/imgupload/images/viu1281627109a.jpg[/img]
[im g]http://www.image.com/imgupload/images/cqs1281627119c.jpg[/img]
[im g]http://www.image.com/imgupload/images/rgh1281627120g.jpg[/img]
[im g]http://www.image.com/imgupload/images/arx1281627120c.jpg[/img]
[im g]http://www.image.com/imgupload/images/jdv1281627121n.jpg[/img]
คือผม ไม่รู้จะทำอย่างไร กับ ลิงค์ใน [download] อะครับ มันมีช่องว่าง พอเอาไปโพสต์แล้ว มัน จะไม่เป็นลิงคืให้ครับ
ผมลองใช้ urlencode ก็แล้ว แต่ไม่ได้ ครับ
ผมลอง เพิ่ม แบบนี้ เข้าไปใน ฟังชั่น บรรทัดสุดท้าย
$posting = urlencode($posting);
มันมั่ว หมดเลย พี่พอแนะนำได้ไหมครับ
ขอบพระคุณครับ
ปล. [img] [url] ต้องเว้นว่างเพราะ ไม่งั้นจะ อ่านไม่ออก
Tag : PHP

|
ประวัติการแก้ไข 2011-05-23 09:39:36 2011-05-23 09:40:53 2011-05-23 09:42:01 2011-05-23 09:42:44 2011-05-23 10:07:18
|
 |
 |
 |
 |
Date :
2011-05-23 09:38:18 |
By :
rokaisakkon |
View :
1114 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอคำตอบอยู่ครับ ๆ
|
 |
 |
 |
 |
Date :
2011-05-23 17:00:45 |
By :
rokaisakkon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไปเจอของต่างประเทศมาครับ
Code (PHP)
$result = preg_replace('#href="([^"*])"#is', urlencode($1), $result)
หรือ
Code (PHP)
function my_urlencode($a){
return urlencode($a[1]);
}
$result = preg_replace_callback('#href="([^"]*)"#is', 'my_urlencode', $result);
|
 |
 |
 |
 |
Date :
2011-05-23 17:37:11 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|