예제 #1
0
function update_other_cat($uid){

	$db = & $this->d3dConf->db;

	require_once dirname( dirname(__FILE__) ).'/include/magpierss/rss_fetch.inc';

// get categories of this user

	// only other blogs
	$query = "SELECT u.uid, cat.cid, cat.cname, cat.corder, cat.blogtype, cat.blogurl, cat.rss, cat.openarea 
			FROM ".$db->prefix('users')." u 
			LEFT JOIN ".$db->prefix($this->mydirname.'_category')." cat ON u.uid=cat.uid 
			WHERE u.uid='".$uid."' AND cat.blogtype>'0'";

	$result = $db->query($query);
	
	while ( $line = $db->fetchArray($result) ) {
		//$uid    = intval($line['uid']);
		$cid = intval($line['cid']);

		# 鐃緒申
		$query = "DELETE FROM ".$db->prefix($this->mydirname.'_newentry')." WHERE uid='".$uid
			."' AND cid='".$cid."'";
		$result2 = $db->queryF($query);
		

		$rss_url=$line['rss'];
		$rss = d3d_mgp_fetch_rss($rss_url);
		//var_dump($rss);	// test
		$yd_data="";
		if(empty($rss)){break;}
		foreach ($rss->items as $item) {
	    		$yd_data['title'] = $item['title'];
		  	if(mb_internal_encoding()!="UTF-8"){
				$yd_data['title']=mb_convert_encoding($yd_data['title'], mb_internal_encoding(), "UTF-8");
			}
	    		$yd_data['link'] = $item['link'];
	    		$yd_data['blogtype'] = $line['blogtype'];
			//var_dump($cid); var_dump($yd_data['title'] ); echo"<br />";

			# 鐃緒申鐃緒申se鐃緒申髭鐃緒申鐃緒申
			if(!empty($item['dc']['date'])){
				$tstamp=strtotime($item['dc']['date']);
			}elseif(!empty($item['pubdate'])){
				$tstamp=strtotime($item['pubdate']);
			}elseif(!empty($item['published'])){
				$tstamp=strtotime($item['published']);
			}elseif(!empty($item['issued'])){
				$tstamp=strtotime($item['issued']);
			}elseif(!empty($item['modified'])){
				$tstamp=strtotime($item['modified']);
			}else{
				$tstamp=$item['date_timestamp'];
			}
			$yd_data['ctime'] = date("Y-m-d H:i:s", $tstamp);
	
			if(!empty($item['summary'])){
	    			$yd_data['diary'] = $item['summary'];
			}elseif(!empty($item['description'])){
				$yd_data['diary'] = $item['description'];
			}elseif(!empty($item['content'])){
				$yd_data['diary'] = $item['content'];
			}else{
				$yd_data['diary']="";
			}
			if(mb_internal_encoding()!="UTF-8"){
				$yd_data['diary']=mb_convert_encoding($yd_data['diary'], mb_internal_encoding(), "UTF-8");
			}
	        	if (!get_magic_quotes_gpc()) {
				$yd_data['title']=addslashes($yd_data['title']);
				$yd_data['diary']=addslashes($yd_data['diary']);
			}
	
			# entry
			$query = "INSERT INTO ".$db->prefix($this->mydirname.'_newentry')." (uid, cid, title, url, 
						create_time, blogtype, diary) 
						VALUES (
						'".$uid."',
						'".$cid."',
						'".$yd_data['title']."',
						'".$yd_data['link']."',
						'".$yd_data['ctime']."',
						'".$yd_data['blogtype']."',
						'".$yd_data['diary']."'
						)";
			$result2 = $db->queryF($query);
	
			# 鐃初�鐃緒申肇蝪�
			break;
		}
	}
	return true;
}
예제 #2
0
파일: other.php 프로젝트: naao/d3diary
        }
    }
}
// get categories of this user
if ($req_cid > 0) {
    $whr_cat = " AND cid=" . intval($req_cid);
} else {
    $whr_cat = "";
}
$sql = "SELECT *\n\t\t\t  FROM " . $xoopsDB->prefix($mydirname . '_category') . "\n\t          WHERE uid='" . intval($d3dConf->dcfg->uid) . "'" . $whr_cat . " AND blogtype>0 ORDER BY corder";
$result = $xoopsDB->query($sql);
$other_cids = array();
$i = 0;
while ($dbdat = $xoopsDB->fetchArray($result)) {
    // ここに各カテゴリの外部設定を渡して取り込む//
    $rss = d3d_mgp_fetch_rss($dbdat['rss']);
    $j = 0;
    $yd_data = array();
    foreach ($rss->items as $item) {
        $yd_data['title'] = $item['title'];
        if (mb_internal_encoding() != "UTF-8") {
            $yd_data['title'] = mb_convert_encoding($yd_data['title'], mb_internal_encoding(), "UTF-8");
        }
        $yd_data['link'] = $item['link'];
        # 普通はelse文の部分だけでいいはずなんだが・・・
        if (!empty($item['dc']['date'])) {
            $tstamp = yr_strtotime($item['dc']['date']);
        } elseif (!empty($item['pubdate'])) {
            $tstamp = yr_strtotime($item['pubdate']);
        } elseif (!empty($item['published'])) {
            $tstamp = yr_strtotime($item['published']);