Discuz Thai

 ลืมรหัสผ่าน
 สมัครสมาชิก

ข้อตกลงการใช้งานกระดานข่าวดิสคัสไทย DiscuzThai Agreement (English Version) ประกาศดิสคัสไทย - ทำเนียบดิสคัสภาษาไทย

Discuz! X3.5 Thai R20231001 Rev.8 (NEW) [วิดีโอช่วยสอน] อัปเกรด Discuz! X3.4 เป็น X3.5 Discord ของ Discuz! Thai Community อย่างเป็นทางการ

Discuz! X3.4 Thai R20220811 (REV.75) สิ้นสุดการสนับสนุน Discuz! X3.4 ภาษาไทยตั้งแต่วันนี้เป็นต้นไป (ขอแนะนำให้อัปเกรดเป็น X3.5 แทน)

ค้นหา
แท็กยอดนิยม: ดิสคัสภาษาไทย Discuz Thai
เจ้าของ: raffer7

[X2.5] อยากแก้ไข rsspost นะครับมันขึ้นแบบนี้มาด้วย \'text\'

[คัดลอกลิงก์]
 เจ้าของ| raffer7 โพสต์ 2012-6-13 14:47:48
ถอดแล้วครับแก้ไขเรียบร้อยแล้วครับขอบคุณมาก ^^
pimsaree โพสต์ 2012-6-21 01:47:37
banrong โพสต์ 2012-6-30 10:09:49
แก้ยังงัย จ๊ะ บอก รายละเอียด ได้ เปล่า ครับ
aniroon โพสต์ 2012-6-30 15:18:25
ขอวิธีการทำหน่อยครับ ท่านๆอื่นจะได้รู้กันด้วย
honshop โพสต์ 2012-6-30 17:36:59
ใช้ครับ อยากรู้
 เจ้าของ| raffer7 โพสต์ 2012-7-1 13:04:16
ครับแต่ผมแก้แล้วมีปัญหาตามมานะครับ
แต่ก็แก้ปัญหาขั้นต้นของผมได้
เริ่มเลยแล้วกันผมใช้ตัวนี้นะครับ

http://forum.discuzthai.com/forum.php?mod=viewthread&tid=28710&extra=&highlight=rss&page=1[/url]

แล้วเอา Code นี้ไปแทนที่ cron_rsspost.php อย่าลืม Backup ก่อนนะครับ

<?php

/**
*      [RSS POST] By MooPing
*/

if(!defined('IN_DISCUZ')) {
    exit('Access Denied');
}

include("rsspost_config.inc.php");

$rss_post_dir = DISCUZ_ROOT . './data/rss_post';
if(!is_dir($rss_post_dir)) mkdir($rss_post_dir,0777);
if(!is_dir($rss_post_dir.'/mark')) mkdir($rss_post_dir.'/mark',0777);
//if(!is_dir($rss_post_dir.'/images')) mkdir($rss_post_dir.'/images',0777);

$credit_links = file_get_contents('http://wiki.moohin.com/rsspost_credit.txt');

if(!$credit_links){
$credit_links="\nขอบคุณ Plugin ดีๆจาก MooHin Community - ชุมชนออนไลน์ของคนชอบเที่ยว\n";
$credit_links.="สถานที่ท่องเที่ยวแนะนำ - ปางอุ๋ง, เกาะล้าน, เกาะสีชัง";
}
if (!isset($rsspost['data'])) {
return;
}



foreach ($rsspost['data'] as $dd) {
    $count=0;
    if (isset($dd['rss'])&&isset($dd['fid'])) {
    $dom = new DOMDocument();
        if ($dom->load($dd['rss'])) {
            $datas = $dom->getElementsByTagName("item");
            foreach($datas as $data) {
                $attach_img=array();
                if (isset($dd['limit'])&&$count>=$dd['limit']) {break;}
                $title =  trim($data->getElementsByTagName("title")->item(0)->nodeValue);
                $link =  trim($data->getElementsByTagName("link")->item(0)->nodeValue);
                if (isset($dd['keywords'])&&count($dd['keywords'])>0) {
                    $skip=1;
                    foreach ($dd['keywords'] as $k) {
                    if (preg_match("/{$k}/i",$title)) {
                        $skip=0;
                    }
                    }
                    if ($skip==1) {continue;}
                }
                if (!isset($dd['content_var'])||$dd['content_var']=='') {$dd['content_var']='description';}
                if (preg_match("/^(.+).+)$/",$dd['content_var'],$match)) {
                $description =  trim($data->getElementsByTagNameNS('*',$match[2])->item(0)->nodeValue);               
                if ($description=='') {return;}
                } else {
                $description =  trim($data->getElementsByTagName($dd['content_var'])->item(0)->nodeValue);
                }
                if (isset($dd['convert_bbcode'])&&$dd['convert_bbcode']=='1') {               
                $description = BBCODE($description);               
                // cache image
                $arr=preg_match_all("|(\[img\]([^>]+)\[\/img\])|U",$description,$match,PREG_SET_ORDER);
                if (count($match)>0)  {
                    $markfile=DISCUZ_ROOT . './data/rss_post/mark/'.parse_url($link,PHP_URL_HOST).'.txt';
                    if(!file_exists($markfile)||strpos(file_get_contents($markfile) ,$link) === false){            

                    foreach ($match as $img) {
                        $imgpath=DISCUZ_ROOT . './data/attachment/forum';
                        if(!is_dir($imgpath.'/'.date('Ym'))) make_dir($imgpath.'/'.date('Ym'));
                        if(!is_dir($imgpath.'/'.date('Ym').'/'.date('d'))) make_dir($imgpath.'/'.date('Ym').'/'.date('d'));
                        $imagedata = file_get_contents($img[2]);
                        $ext = addslashes(strtolower(substr(strrchr($img[2], '.'), 1, 10)));   
                        $filename = strtolower(substr(strrchr($img[2], '/'), 1));
                        $attachment=date('Ym').'/'.date('d').'/'.date('His').strtolower(random(16)).'.'.$ext;
                        $imagefile = $imgpath.'/'.$attachment;
                        $imageurl = $_G['siteurl'] .(substr($_G['siteurl'],-1)=='/'?'':'/').$imagefile;                        
                        $f = fopen($imagefile,'w');
                        fwrite($f,$imagedata);
                        fclose($f);                        
                        list($width, $height, $type, $attr) = getimagesize($imagefile);
                        // insert new image
                        
                        $arr = array(
                            'tid'=>0,
                            'pid'=>0,
                            'uid'=>0,
                            'tableid'=>0,
                            'downloads'=>0,
                        );
                        DB::insert('forum_attachment',$arr);
                        $aid = DB::insert_id();                    
                        
                        // edit content
                        $description=str_replace("{$img[1]}","[attach]{$aid}[/attach]",$description);
                        // queue order
                        $attach_img[] = array(
                            'aid'=>$aid,
                            'filename'=>$filename,
                            'filesize'=>filesize($imagefile),
                            'attachment'=>$attachment,
                            'width'=>$width
                        );
                    }
                    }
                    
                }
                }
                $description = addslashes($description);
               
                if (!isset($dd['image_var'])||$dd['image_var']=='') {$image='';} else {
                if ($domDocument->getElementsByTagName($dd['image_var'])->length!=0)
                {
                    $image=trim($data->getElementsByTagName($dd['image_var'])->item(0)->getAttribute('url'));
                } else {$image='';}
                }
                $time = strtotime(trim($data->getElementsByTagName("pubDate")->item(0)->nodeValue));
                $title = str_replace(array('\\','\''),array('\\\\','\\\''),$title);
                $markfile=DISCUZ_ROOT . './data/rss_post/mark/'.parse_url($link,PHP_URL_HOST).'.txt';
                if(!file_exists($markfile)||strpos(file_get_contents($markfile) ,$link) === false){            
                $f = fopen($markfile,'a');
                fwrite($f,$link."\n");
                fclose($f);               
                if ($dd['module']==''||!isset($dd['module'])) {
                    $content = $description;
                    $content.= '
                    
ขอบคุณข่าวจาก: [url=http://'.parse_url($link,PHP_URL_HOST).']'.parse_url($link,PHP_URL_HOST).'';
                } elseif ($dd['module']=='thairath') {            
                    $image=trim($data->getElementsByTagName('enclosure')->item(0)->getAttribute('url'));
                    $image = str_replace('120.jpg','630.jpg',$image);
                    $content = file_get_contents($link);
                    $content = explode('<div id="details" class="page">',$content);
                    $content = $content[1];
                    $content = explode('</p></p>',$content);
                    $content = $content[0];
                    $content = str_replace(array('\\','\'','<br />','</p>'),array('\\\\','\\\'',"\r\n","\r\n"),$content);
                    $content = strip_tags($content);
                    $content.='
                    
ขอบคุณข่าวจาก: ไทยรัฐออนไลน์';
                }
                                
               
                // save image
                if ($image!='') {            
                        $imgpath=DISCUZ_ROOT . './data/attachment/forum';
                        if(!is_dir($imgpath.'/'.date('Ym'))) make_dir($imgpath.'/'.date('Ym'));
                        if(!is_dir($imgpath.'/'.date('Ym').'/'.date('d'))) make_dir($imgpath.'/'.date('Ym').'/'.date('d'));
                        $imagedata = file_get_contents($image);
                        $ext = addslashes(strtolower(substr(strrchr($image, '.'), 1, 10)));   
                        $filename = strtolower(substr(strrchr($img[2], '/'), 1));
                        $attachment=date('Ym').'/'.date('d').'/'.date('His').strtolower(random(16)).'.'.$ext;
                        $imagefile = $imgpath.'/'.$attachment;
                        $imageurl = $_G['siteurl'] .(substr($_G['siteurl'],-1)=='/'?'':'/').$imagefile;
                        $f = fopen($imagefile,'w');
                        fwrite($f,$imagedata);
                        fclose($f);               
                        list($width, $height, $type, $attr) = getimagesize($imagefile);                        
                        // insert new image
                        $arr = array(
                            'tid'=>0,
                            'pid'=>0,
                            'uid'=>0,
                            'tableid'=>0,
                            'downloads'=>0,
                        );
                        DB::insert('forum_attachment',$arr);
                        $aid = DB::insert_id();                    
                        // edit content
                        $content = '[attach]'.$aid.'[/attach]'.$content;                        
                        // queue order                        
                        $attach_img[] = array(
                            'aid'=>$aid,
                            'filename'=>$filename,
                            'filesize'=>filesize($imagefile),
                            'attachment'=>$attachment,
                            'width'=>$width
                        );

                }
               
                $content .= $credit_links;
                $count++;
                $poster = DB::result_first("SELECT username FROM ".DB::table('common_member')." WHERE uid='{$rsspost['poster_uid']}'");
                $arr = array(
                    'fid'=>$dd['fid'],
                    'author'=>$poster,
                    'authorid'=>$rsspost['poster_uid'],
                    'subject'=>$title,
                    'dateline'=>$time,
                    'lastpost'=>$time,
                    'lastposter'=>$poster,
                    'status'=>32,
                    'stamp'=>-1,
                    'icon'=>-1,
                );
                DB::insert('forum_thread',$arr);
                $tid = DB::insert_id();
               
                $pid = insertpost(array(
                    'fid'=>$dd['fid'],
                    'tid'=>$tid,
                    'first'=>1,
                    'author'=>$poster,
                    'authorid'=>$rsspost['poster_uid'],
                    'subject'=>$title,
                    'dateline'=>$time,
                    'message'=>$content,
                    'useip'=>'127.0.0.1',
                    'invisible'=>0,
                    'anonymous'=>0,
                    'usesig'=>1,
                    'htmlon'=>1,
                    'bbcodeoff'=>0,
                    'smileyoff'=>0,
                    'parseurloff'=>0,
                    'attachment'=>'0',
                    'tags'=>'',
                ));
                DB::query("UPDATE ".DB::table('forum_forum')." SET threads=threads+1,posts=posts+1,todayposts=todayposts+1,lastpost='".strval($tid) .' '.$title .' '.$time .' '.$poster."' WHERE fid='{$dd['fid']}'", 'UNBUFFERED');
                DB::query("UPDATE ".DB::table('common_member_count')." SET posts=posts+1,threads=threads+1 WHERE uid='{$rsspost['poster_uid']}'", 'UNBUFFERED');   
                $first_img=0;
                // insert image
                foreach ($attach_img as $ai) {
                    
                    $tableid=$tid%10;
                    DB::query("UPDATE ".DB::table('forum_attachment')." SET tid='{$tid}',pid='{$pid}',uid={$rsspost['poster_uid']},tableid='{$tableid}' WHERE aid='{$ai['aid']}'", 'UNBUFFERED');   
                    $arr = array(
                        'aid'=>$ai['aid'],
                        'tid'=>$tid,
                        'pid'=>$pid,
                        'uid'=>$rsspost['poster_uid'],
                        'dateline'=>$_G['timestamp'],
                        'filename'=>$ai['filename'],
                        'filesize'=>$ai['filesize'],
                        'attachment'=>$ai['attachment'],
                        'remote'=>0,
                        'description'=>'',
                        'readperm'=>0,
                        'price'=>0,
                        'isimage'=>1,
                        'width'=>$ai['width'],
                        'thumb'=>0,
                        'picid'=>0
                    );
                    DB::insert('forum_attachment_'.$tableid,$arr);
                    DB::query("UPDATE ".DB::table('forum_post')." SET attachment=attachment+1 WHERE pid='{$pid}'", 'UNBUFFERED');
                    DB::query("UPDATE ".DB::table('forum_thread')." SET attachment=attachment+1 WHERE tid='{$tid}'", 'UNBUFFERED');   
                    if ($first_img==0) {
                    DB::insert('forum_threadimage', array(
                            'tid' => $tid,
                            'attachment' => $ai['attachment'],
                            'remote' => 0
                    ));
                    $first_img=1;
                    }

                }
                }
            }
        } else {
        }
    }
}

function BBCODE($input)
{
$bbcode = array(
"/\<([bius])\>/is" => "[$1]",
"/\<center\>/is" => "
",
"/\<\/center\>/is" => "
",
"/\<strong\>/is" => "",
"/\<\/strong\>/is" => "",
"/\<em\>/is" => "",
"/\<\/em\>/is" => "",
"/\<code\>/is" => "
",
"/\<\/code\>/is" => "
คัดลอกไปที่คลิปบอร์ด
",
"/\<small\>/is" => "[small]",
"/\<\/small\>/is" => "[/small]",
"/\<script[^>]*\>.*\<\/script\>/is" => "",
"/\<font[^>]*\>/is" => "",
"/\<h([0-9]+)[^>]*\>/" => "[h$1]",
"/\<\/h([0-9]+)[^>]*\>/" => "[/h$1]",
"/\<\/font\>/is" => "",
"/\<span[^>]*\>/is" => "",
"/\<\/span\>/is" => "",
"/\<table[^>]*\>/is" => "
",
"/\<\/table\>/is" => "
",
"/\<\/tr\>/is" => "[/tr]",
"/\<\/td\>/is" => "[/td]",
"/\<tr[^>]*\>/is" => "[tr]",
"/\<td[^>]*\>/is" => "[td]",
"/\<div[^>]*\>/is" => "
",
"/\<\/div\>/is" => "
",
"/\<p[^>]*\>/is" => "
",
"/\<\/p\>/is" => "
",
"/\<img[^>]*src=[\"\']([^\s'\"<>]+)[\"\'][^>]*\>/is" => "
",
"/\<a[^>]*href=[\"\']([^\s'\"<>]+)[\"\'][^>]*\>/is" => "",
"/\<\/a\>/is" => "",
"/\<ol[^>]*\>/is" => "
",
"/\<ul[^>]*\>/is" => "
",
"/\<li[^>]*\>/is" => "
",
"/\<\/li\>/is" => "",
"/\<\/ul\>/is" => "
",
"/\<\/ol\>/is" => "
",
"/\<br[^>]*\>/is" => "\n",
"/\<blockquote[^>]*\>/is" => "
",
"/\<\/blockquote\>/is" => "
",
"/\<\/blockquote\>/is" => "[/quote]",
"/\<object[^>]*\>/is" => "",
"/\<\/object\>/is" => "",
"/\<param[^>]*\>/is" => "",
"/\<\/param\>/is" => "",
"/\<embed[^>]*src=[\"\'](http\:\/\/www\.youtube\.com\/watch\?v\=\/[^\s'\"<>]+)[\"\'][^>]*\>/is" => "http://$1",
"/\<embed[^>]*src=[\"\']http\:\/\/www\.youtube\.com\/v\/([^\s'\"<>]+)[\"\'][^>]*\>/is" => "http://www.youtube.com/watch?v=$1"
);

$text = preg_replace(array_keys($bbcode), array_values($bbcode), $input);

$strfind = array(' ', '<', '>', '&');
$strreplace = array(' ', '<', '>', '&');
$text = str_replace($strfind, $strreplace, $text);

return  htmlspecialchars_decode($text);
}


function make_dir($dir, $index = true) {
        $res = true;
        if(!is_dir($dir)) {
            $res = @mkdir($dir, 0777);
            $index && @touch($dir.'/index.html');
        }
        return $res;
}
?>

และผมแก้ไขบรรทัดที่ 115 เป็น
$title = str_replace(array('\\','\''),array('\\"','"'),$title); ครับ
บรรทัดอาจคาดเคลื่อนนะครับลองดูราวๆนี้ถ้าผิดพลาดประการใดก็ขออภัยครับ มือใหม่ +.+
banrong โพสต์ 2012-7-1 16:25:37
ปัญหาอะไรตามมาบ้างครับ
banrong โพสต์ 2012-7-1 16:41:00
อยากสอบถามเพิ่มเติม  ท่าน  raffer7   ครับ   



code  เว็บ ท่าน เขียน ยัง งัย ให้ โชว์ แบบ นี้ ครับ

 เจ้าของ| raffer7 โพสต์ 2012-7-1 20:40:01
ตั้ง Module เป็นกระทู้ล่าสุดครับ

code ดังนี้ผมเขียนฝังไปเลยขี้เกียจไปเพิ่มแก้เอานะครับผม

<div class="module cl xld">
[loop]
<div style="float:left;width:230px;height:100px;margin-top:5px;">
<div style="float:left;width:100px;"><a href="{url}"  target="_blank"><img src="{pic}" width="{picwidth}" height="{picheight}"  style="border:1px solid #ccc;" /></a></div>
<div style="float:left;padding:3px 10px 0 10px;width:110px;word-wrap: break-word;"><a href="{url}"  target="_blank">{summary}</a></div>
</div>

[/loop]
</div>


ส่วนผลที่ตามมาคือ ผมแทนที่จาก ' เป็น " ทำให้เวลาเอาคำนั้นๆไปแสดงที่ attr มันมีปัญหาครับผม
honshop โพสต์ 2012-7-2 18:58:46
ทาน raffer7 ครับ ท่านดึงข่าวจากเว็บไหนครับ แล้วรูปภาพขึ้นไหม อยากเห็นไฟร์ comfig ครับ ขอบคุณมาก...
ขออภัย! คุณไม่ได้รับสิทธิ์ในการดำเนินการในส่วนนี้ กรุณาเลือกอย่างใดอย่างหนึ่ง ลงชื่อเข้าใช้ | สมัครสมาชิก

รายละเอียดเครดิต

รายชื่อผู้กระทำผิด|Archiver|ดิสคัส ไทย Follow us: Become a fan on facebook. Follow us on Twitter.

GMT+7, 2024-5-3 09:45

Powered by Discuz! X3.4, Rev.66

Copyright © 2001-2021 Tencent Cloud. Licensed

ตอบกระทู้ ขึ้นไปด้านบน ไปที่หน้ารายการกระทู้