示例#1
0
	function getRSSItems( &$items )
	{
		// check module_read permission
		$module_handler =& xoops_gethandler( 'module' ) ;
		$module =& $module_handler->getByDirname( $this->mydirname ) ;
		$gperm_handler =& xoops_gethandler( 'groupperm' ) ;
		$can_read = $gperm_handler->checkRight( 'module_read' , $module->getVar('mid') , XOOPS_GROUP_ANONYMOUS ) ;
		if( ! $can_read ) return ;

		// check config (feed_as_backend)
		$config_handler =& xoops_gethandler( 'config' ) ;
		$mod_config =& $config_handler->getConfigsByCat( 0 , $module->getVar( 'mid' ) ) ;
		if( empty( $mod_config['feed_as_backend'] ) ) {
			return ;
		}

		$myts =& MyTextSanitizer::getInstance();
		$articles = Bulletin::getAllPublished( $this->mydirname , 10 , 0 , 0 , 1 , true, true, true) ;//ver3.0 changed
		foreach( $articles as $article ) {
			$hometext = $article->getVar('hometext','n') ;
			if( function_exists( 'easiestml' ) ) {
				$hometext = easiestml( $hometext ) ;
			}
			$items[] = array(
				'pubdate' => $article->getVar('published') ,
				'title' => htmlspecialchars(bulletin_utf8_encode($article->getVar('title', 'n')), ENT_QUOTES),
				'category' => htmlspecialchars(bulletin_utf8_encode($article->newstopic->topic_title), ENT_QUOTES),
				'link' => XOOPS_URL.'/modules/'.$this->mydirname.'/index.php?page=article&storyid='.$article->getVar('storyid') ,
				'guid' => XOOPS_URL.'/modules/'.$this->mydirname.'/index.php?page=article&storyid='.$article->getVar('storyid') ,
				'description' => bulletin_utf8_encode(htmlspecialchars(strip_tags($myts->xoopsCodeDecode($hometext)), ENT_QUOTES)),
			) ;
		}
	}
 function fetchSummary($external_link_id)
 {
     $db =& Database::getInstance();
     $myts =& MyTextsanitizer::getInstance();
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($this->mydirname);
     $storyid = intval($external_link_id);
     $mydirname = $this->mydirname;
     if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
         die('Invalid mydirname');
     }
     $mytrustdirpath = dirname(dirname(__FILE__));
     require_once dirname(dirname(__FILE__)) . '/class/bulletin.php';
     if (Bulletin::isPublishedExists($mydirname, $storyid)) {
         $article = new Bulletin($mydirname, $storyid);
         $subject4assign = $article->getVar('title');
         $summary = $article->getVar('hometext');
         if (function_exists('easiestml')) {
             $summary = easiestml($summary);
         }
         $summary4assign = htmlspecialchars(xoops_substr($this->unhtmlspecialchars(strip_tags($summary)), 0, 255), ENT_QUOTES);
     } else {
         $subject4assign = '';
         $summary4assign = '';
     }
     return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $subject4assign, 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/index.php?page=article&storyid=' . $storyid, 'summary' => $summary4assign);
 }
示例#3
0
文件: search.php 项目: nouphet/rata
 function gnavi_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     // not implemented for uid specifications
     //if( ! empty( $userid ) ) {
     //	return array() ;
     //}
     $db =& Database::getInstance();
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "t.description" : "'' AS description";
     $sql = "SELECT l.lid,l.cid,l.title,l.caption,l.caption1,l.caption2,l.poster_name,l.submitter,l.date,{$select4con} FROM " . $db->prefix($mydirname . "_photos") . " l LEFT JOIN " . $db->prefix($mydirname . "_text") . " t ON t.lid=l.lid LEFT JOIN " . $db->prefix("users") . " u ON u.uid=l.submitter WHERE status>0";
     if ($userid > 0) {
         $sql .= " AND l.submitter=" . $userid . " ";
     }
     $whr = "";
     if (is_array($keywords) && count($keywords) > 0) {
         $whr = "AND (";
         switch (strtolower($andor)) {
             case "and":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keyword}%' AND ";
                 }
                 $whr = substr($whr, 0, -5);
                 break;
             case "or":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keyword}%' OR ";
                 }
                 $whr = substr($whr, 0, -4);
                 break;
             default:
                 $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keywords[0]}%'";
                 break;
         }
         $whr .= ")";
     }
     $sql = "{$sql} {$whr} ORDER BY l.date DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while ($myrow = $db->fetchArray($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myrow['description']);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array("image" => "images/pict.gif", "link" => "index.php?lid=" . $myrow["lid"], "title" => $myrow["title"], "time" => $myrow["date"], "uid" => $myrow["submitter"], "context" => $context);
     }
     return $ret;
 }
示例#4
0
 function d3pipes_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     // not implemented for uid specifications
     if (!empty($userid)) {
         return array();
     }
     $db =& Database::getInstance();
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "`data` AS text" : "'' AS text";
     if (is_array($keywords) && count($keywords) > 0) {
         switch (strtolower($andor)) {
             case "and":
                 $whr = "";
                 foreach ($keywords as $keyword) {
                     $whr .= "`data` LIKE '%{$keyword}%' AND ";
                 }
                 $whr .= "1";
                 break;
             case "or":
                 $whr = "";
                 foreach ($keywords as $keyword) {
                     $whr .= "`data` LIKE '%{$keyword}%' OR ";
                 }
                 $whr .= "0";
                 break;
             default:
                 $whr = "`data` LIKE '%{$keywords[0]}%'";
                 break;
         }
     } else {
         $whr = 1;
     }
     $sql = "SELECT `clipping_id`,`headline`,`pubtime`,{$select4con} FROM " . $db->prefix($mydirname . "_clippings") . " WHERE ({$whr}) AND can_search ORDER BY `pubtime` DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($clipping_id, $title, $mtime, $serialized_data) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $data = d3pipes_common_unserialize($serialized_data);
             $text = @$data['description'];
             $full_context = strip_tags($text);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array("image" => "", "link" => "index.php?page=clipping&clipping_id=" . intval($clipping_id), "title" => $title, "time" => $mtime, "uid" => "0", "context" => $context);
     }
     return $ret;
 }
 function myalbum_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB;
     include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/read_configs.php";
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "t.description" : "'' AS description";
     $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,{$select4con} FROM {$table_photos} l LEFT JOIN {$table_text} t ON t.lid=l.lid LEFT JOIN " . $xoopsDB->prefix("users") . " u ON l.submitter=u.uid WHERE status>0";
     if ($userid > 0) {
         $sql .= " AND l.submitter=" . $userid . " ";
     }
     $whr = "";
     if (is_array($keywords) && count($keywords) > 0) {
         $whr = "AND (";
         switch (strtolower($andor)) {
             case "and":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' AND ";
                 }
                 $whr = substr($whr, 0, -5);
                 break;
             case "or":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' OR ";
                 }
                 $whr = substr($whr, 0, -4);
                 break;
             default:
                 $whr .= "CONCAT(l.title,'  ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keywords[0]}%'";
                 break;
         }
         $whr .= ")";
     }
     $sql = "{$sql} {$whr} ORDER BY l.date DESC";
     $result = $xoopsDB->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     include_once XOOPS_ROOT_PATH . "/modules/{$mydirname}/class/myalbum.textsanitizer.php";
     $myts =& MyAlbumTextSanitizer::getInstance();
     while ($myrow = $xoopsDB->fetchArray($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myts->displayTarea($myrow['description'], 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array("image" => "images/pict.gif", "link" => "photo.php?lid=" . $myrow["lid"], "title" => $myrow["title"], "time" => $myrow["date"], "uid" => $myrow["submitter"], "context" => $context);
     }
     return $ret;
 }
示例#6
0
 function wraps_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     // not implemented for uid specifications
     if (!empty($userid)) {
         return array();
     }
     // check if .htaccess exists (mod_rewrite on/off)
     $rewrite_mode = file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/.htaccess');
     $db =& Database::getInstance();
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "`body` AS text" : "'' AS text";
     if (is_array($keywords) && count($keywords) > 0) {
         switch (strtolower($andor)) {
             case "and":
                 $whr = "";
                 foreach ($keywords as $keyword) {
                     $whr .= "`body` LIKE '%{$keyword}%' AND ";
                 }
                 $whr .= "1";
                 break;
             case "or":
                 $whr = "";
                 foreach ($keywords as $keyword) {
                     $whr .= "`body` LIKE '%{$keyword}%' OR ";
                 }
                 $whr .= "0";
                 break;
             default:
                 $whr = "`body` LIKE '%{$keywords[0]}%'";
                 break;
         }
     } else {
         $whr = 1;
     }
     $sql = "SELECT `filename`,`title`,`mtime`,{$select4con} FROM " . $db->prefix($mydirname . "_indexes") . " WHERE ({$whr}) ORDER BY 1";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($filename, $title, $mtime, $text) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($text);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array("image" => "", "link" => $rewrite_mode ? $filename : 'index.php/' . $filename, "title" => $title, "time" => $mtime, "uid" => "0", "context" => $context);
     }
     return $ret;
 }
 function getResultArray(&$row)
 {
     // 追加で取得して貰ったフィールド qid を使ってリンク URL を作成します
     $row['link'] = "index.php?action=detail&qid=" . $row['qid'];
     // get context for module "search"
     if (function_exists('search_make_context') && !empty($_GET['showcontext'])) {
         $text = $row['body'] . '  ' . $row['for_search'];
         if (function_exists('easiestml')) {
             $text = easiestml($text);
         }
         $row['context'] = search_make_context(htmlspecialchars($text, ENT_QUOTES), $this->filter_->querys_);
     }
     return $row;
 }
示例#8
0
 function eguide_search_base($myprefix, $queryarray, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB;
     $sql = "SELECT eid,uid,title,edate,cdate, summary FROM " . $xoopsDB->prefix($myprefix) . " WHERE status=0";
     //$sql .= " AND expire>".time();
     if ($userid != 0) {
         $sql .= " AND uid=" . $userid . " ";
     }
     // because count() returns 1 even if a supplied variable
     // is not an array, we must check if $querryarray is really an array
     if (is_array($queryarray) && ($count = count($queryarray))) {
         $sql .= " AND ((summary LIKE '%{$queryarray['0']}%' OR body LIKE '%{$queryarray['0']}%' OR title LIKE '%{$queryarray['0']}%')";
         for ($i = 1; $i < $count; $i++) {
             $sql .= " {$andor} ";
             $sql .= "(summary LIKE '%{$queryarray[$i]}%' OR body LIKE '%{$queryarray[$i]}%' OR title LIKE '%{$queryarray[$i]}%')";
         }
         $sql .= ") ";
     }
     $sql .= " ORDER BY edate DESC";
     $result = $xoopsDB->query($sql, $limit, $offset);
     $ret = array();
     // XOOPS Search module
     $showcontext = function_exists('search_make_context') && (empty($_GET['showcontext']) ? 0 : 1);
     if ($showcontext) {
         include_once XOOPS_ROOT_PATH . "/class/module.textsanitizer.php";
         $myts =& MyTextSanitizer::getInstance();
     }
     $i = 0;
     while ($myrow = $xoopsDB->fetchArray($result)) {
         //$ret[$i]['image'] = "images/forum.gif";
         $ret[$i]['link'] = "event.php?eid=" . $myrow['eid'] . "";
         $ret[$i]['title'] = formatTimestamp($myrow['edate'], 's') . ' ' . $myrow['title'];
         $ret[$i]['time'] = $myrow['cdate'];
         $ret[$i]['uid'] = $myrow['uid'];
         $ret[$i]['description'] = $myrow['summary'];
         $i++;
         // get context for module "search"
         if ($showcontext) {
             $full_context = strip_tags($myts->displayTarea($myrow['summary'], 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $ret[$i]['context'] = search_make_context($full_context, $queryarray);
         }
     }
     return $ret;
 }
示例#9
0
 function d3forum_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     $myts =& MyTextsanitizer::getInstance();
     $db =& Database::getInstance();
     $andor = strtoupper($andor);
     $userid = intval($userid);
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "p.post_text" : "'' AS post_text";
     require_once dirname(__FILE__) . '/include/common_functions.php';
     $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")";
     $whr_uid = $userid > 0 ? "p.uid={$userid}" : "1";
     $whr_query = $andor == 'OR' ? '0' : '1';
     if (is_array($keywords)) {
         foreach ($keywords as $word) {
             // I know this is not a right escaping, but I can't believe $keywords :-)
             $word4sql = addslashes(stripslashes($word));
             $whr_query .= $andor == 'EXACT' ? ' AND' : ' ' . $andor;
             $whr_query .= " (p.subject LIKE '%{$word4sql}%' OR p.post_text LIKE '%{$word4sql}%')";
         }
     }
     $sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,{$select4con} FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON t.topic_id=p.topic_id WHERE ({$whr_forum}) AND ({$whr_uid}) AND ({$whr_query}) AND ! topic_invisible ORDER BY p.post_time DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($post_id, $topic_id, $post_time, $uid, $subject, $html, $smiley, $xcode, $br, $text) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             if (function_exists('easiestml')) {
                 $text = easiestml($text);
             }
             $full_context = strip_tags($myts->displayTarea($text, $html, $smiley, $xcode, 1, $br));
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array('link' => "index.php?post_id={$post_id}", 'title' => $subject, 'time' => $post_time, 'uid' => $uid, "context" => $context);
     }
     return $ret;
 }
 function tinyd_search_base($mydirname, $mydirnumber, $keywords, $andor, $limit, $offset, $userid)
 {
     // get my config
     $module_handler =& xoops_gethandler('module');
     $config_handler =& xoops_gethandler('config');
     $module =& $module_handler->getByDirname($mydirname);
     $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     $myts =& TinyDTextSanitizer::getInstance();
     $db =& Database::getInstance();
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "text" : "'' AS text";
     $sql = "SELECT storyid,title,link,UNIX_TIMESTAMP(last_modified),{$select4con} FROM " . $db->prefix("tinycontent{$mydirnumber}") . " WHERE visible AND ! (nohtml & 8) ";
     if (!empty($userid)) {
         $sql .= " AND 0 ";
     }
     $whr = "";
     if (is_array($keywords) && count($keywords) > 0) {
         $whr = "AND (";
         switch (strtolower($andor)) {
             case "and":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' AND ";
                 }
                 $whr = substr($whr, 0, -5);
                 break;
             case "or":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' OR ";
                 }
                 $whr = substr($whr, 0, -4);
                 break;
             default:
                 $whr .= "CONCAT(title,' ',text) LIKE '%{$keywords[0]}%'";
                 break;
         }
         $whr .= ")";
     }
     $sql = "{$sql} {$whr} ORDER BY storyid ASC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($id, $title, $link, $timestamp, $text) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myts->displayTarea($text, 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         if (!empty($config['tc_force_mod_rewrite'])) {
             if (!empty($config['tc_modulesless_dir'])) {
                 $href = '../../' . $config['tc_modulesless_dir'] . '/' . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             } else {
                 $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             }
         } else {
             if ($link == TC_WRAPTYPE_USEREWRITE) {
                 $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             } else {
                 if ($link == TC_WRAPTYPE_CONTENTBASE) {
                     $href = "content/index.php?id={$id}";
                 } else {
                     $href = "index.php?id={$id}";
                 }
             }
         }
         $ret[] = array("image" => "images/content.gif", "link" => $href, "title" => $title, "time" => $timestamp, "uid" => "0", "context" => $context);
     }
     return $ret;
 }
示例#11
0
function pico_admin_easiestml( $s )
{
	if( function_exists( 'easiestml' ) ) {
		return easiestml( $s ) ;
	} else {
		return $s ;
	}
}
示例#12
0
 function get($keywords, $andor, $limit, $offset, $userid)
 {
     // for XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $where_readable = $this->func->get_readable_where('p.');
     $where = "p.editedtime != 0";
     if ($where_readable) {
         $where = "{$where} AND ({$where_readable})";
     }
     $sql = "SELECT p.pgid,p.name,p.editedtime,p.title,p.uid FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_pginfo") . " p INNER JOIN " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " t ON t.pgid=p.pgid WHERE ({$where}) ";
     if ($userid != 0) {
         $sql .= "AND (p.uid=" . $userid . ") ";
     }
     if (is_array($keywords) && $keywords) {
         $keywords = array_map('stripslashes', $keywords);
         // 英数字は半角,カタカナは全角,ひらがなはカタカナに
         $sql .= "AND (";
         $i = 0;
         foreach ($keywords as $keyword) {
             if ($i++ !== 0) {
                 $sql .= " {$andor} ";
             }
             if ($this->cont['LANG'] === 'ja' && function_exists("mb_convert_kana")) {
                 // 英数字は半角,カタカナは全角,ひらがなはカタカナに
                 $word = addslashes(mb_convert_kana($keyword, 'aKCV'));
             } else {
                 $word = addslashes($keyword);
             }
             $sql .= "(p.name_ci LIKE '%{$word}%' OR t.plain LIKE '%{$word}%')";
         }
         $sql .= ") ";
     }
     $sql .= "ORDER BY p.editedtime DESC";
     //exit($sql);
     $result = $this->xpwiki->db->query($sql, $limit, $offset);
     $ret = array();
     if (!$keywords) {
         $keywords = array();
     }
     $sword = rawurlencode(join(' ', $keywords));
     $context = '';
     $make_context_func = function_exists('xoops_make_context') ? 'xoops_make_context' : (function_exists('search_make_context') ? 'search_make_context' : '');
     while ($myrow = $this->xpwiki->db->fetchArray($result)) {
         // get context for module "search"
         if ($make_context_func && $showcontext) {
             $pobj =& XpWiki::getSingleton($this->root->mydirname);
             $pobj->init($myrow['name']);
             $GLOBALS['Xpwiki_' . $this->root->mydirname]['cache'] = null;
             $pobj->root->rtf['use_cache_always'] = TRUE;
             $pobj->execute();
             $text = $pobj->body;
             $text = preg_replace('/<!--description ignore-->.+?<!--\\/description ignore-->|<(script|style).+?<\\/\\1>/is', '', $text);
             // 付箋
             if (empty($GLOBALS['Xpwiki_' . $this->root->mydirname]['cache']['fusen']['loaded'])) {
                 if ($fusen = $this->func->get_plugin_instance('fusen')) {
                     if ($fusen_data = $fusen->plugin_fusen_data($myrow['name'])) {
                         if ($fusen_tag = $fusen->plugin_fusen_gethtml($fusen_data, '')) {
                             $text .= '<fieldset><legend> fusen.dat </legend>' . $fusen_tag . '</fieldset>';
                         }
                     }
                 }
             }
             $full_context = strip_tags($text);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = $make_context_func($full_context, $keywords);
         }
         $title = $myrow['title'] ? ' [' . $myrow['title'] . ']' : '';
         $link = $this->func->get_page_uri($myrow['name']);
         $ret[] = array('link' => $link . (strpos($link, '?') === false ? '?' : '&amp;') . 'word=' . $sword, 'title' => htmlspecialchars($myrow['name'] . $title, ENT_QUOTES, _CHARSET), 'image' => 'skin/loader.php?src=xoops_search.png', 'time' => $myrow['editedtime'] + $this->cont['LOCALZONE'], 'uid' => $myrow['uid'], 'page' => $myrow['name'], 'context' => $context);
     }
     // for xoops search module
     $GLOBALS['md_search_flg_zenhan_support'] = true;
     return $ret;
 }
示例#13
0
文件: rss.php 项目: nunoluciano/uxcl
			$width = ($dimention[0] > 144) ? 144 : $dimention[0];
		}
		if (empty($dimention[1])) {
			$height = 31;
		} else {
			$height = ($dimention[1] > 400) ? 400 : $dimention[1];
		}
		$tpl->assign('image_width', $width);
		$tpl->assign('image_height', $height);
		$count = $articles;
		foreach ($articles as $article) {
			$content4html = $article->getVar('hometext') . $article->getDividedBodytext() ;
			$hometext = $article->getVar('hometext','n') ;
			if( function_exists( 'easiestml' ) ) {
				$content4html = easiestml( $content4html ) ;
				$hometext = easiestml( $hometext ) ;
			}
			$tpl->append('items', array(
				'title' => htmlspecialchars(bulletin_utf8_encode($article->getVar('title', 'n')), ENT_QUOTES),
				'category' => htmlspecialchars(bulletin_utf8_encode($article->newstopic->topic_title), ENT_QUOTES),
				'link' => $mydirurl.'/index.php?page=article&amp;storyid='.$article->getVar('storyid'),
				'guid' => $mydirurl.'/index.php?page=article&amp;storyid='.$article->getVar('storyid'),
//				'pubdate' => formatTimestamp($article->getVar('published'), 'rss'),
				'pubdate' => date( 'r' , $article->getVar('published') ) , // GIJ
				'description' => bulletin_utf8_encode(htmlspecialchars(strip_tags($myts->xoopsCodeDecode($hometext)), ENT_QUOTES)),
				'content' => bulletin_utf8_encode($content4html),
			) ) ;
		}
	}
}
示例#14
0
 function pico_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $uid)
 {
     // get this module's config
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     $config_handler =& xoops_gethandler('config');
     $configs = $config_handler->getConfigList($module->mid());
     // check xmobile or not
     $is_xmobile = false;
     if (function_exists('debug_backtrace') && ($backtrace = debug_backtrace())) {
         if (strstr($backtrace[2]['file'], '/xmobile/actions/')) {
             $is_xmobile = true;
         }
     }
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     // where by uid
     if (!empty($uid)) {
         if (empty($configs['search_by_uid'])) {
             return array();
         }
         $whr_uid = 'o.poster_uid=' . intval($uid);
     } else {
         $whr_uid = '1';
     }
     // where by keywords
     if (is_array($keywords) && count($keywords) > 0) {
         switch (strtolower($andor)) {
             case "and":
                 $whr_kw = "";
                 foreach ($keywords as $keyword) {
                     $whr_kw .= "(`for_search` LIKE '%{$keyword}%') AND ";
                 }
                 $whr_kw .= "1";
                 break;
             case "or":
                 $whr_kw = "";
                 foreach ($keywords as $keyword) {
                     $whr_kw .= "(`for_search` LIKE '%{$keyword}%') OR ";
                 }
                 $whr_kw .= "0";
                 break;
             default:
                 $whr_kw = "(`for_search` LIKE '%{$keywords['0']}%')";
                 break;
         }
     } else {
         $whr_kw = 1;
     }
     $content_handler =& new PicoContentHandler($mydirname);
     $contents4assign = $content_handler->getContents4assign("({$whr_kw}) AND ({$whr_uid})", 'created_time DESC', $offset, $limit, false);
     $ret = array();
     foreach ($contents4assign as $content) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext && $content['can_readfull']) {
             $full_context = strip_tags(@$content['body_cached']);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         } else {
             $context = '';
         }
         $ret[] = array('image' => '', 'link' => $is_xmobile ? 'index.php?cat_id=' . $content['cat_id'] . '&content_id=' . $content['content_id'] : pico_common_make_content_link4html($configs, $content), 'title' => $content['subject'], 'time' => $content['created_time'], 'uid' => empty($configs['search_by_uid']) ? 0 : $content['poster_uid'], 'context' => $context);
     }
     return $ret;
 }
示例#15
0
function trans($string, $lang = null)
{
    $myts =& MyTextSanitizer::getInstance();
    if (function_exists('easiestml')) {
        global $easiestml_lang;
        $easiestml_lang = isset($_GET['lang']) ? $_GET['lang'] : $easiestml_lang;
        // this is required when linked with a Drupal install
        $original_easiestml_lang = $easiestml_lang;
        $easiestml_lang = $lang ? $lang : $easiestml_lang;
        $string = easiestml($string);
        $easiestml_lang = $original_easiestml_lang;
    } elseif (function_exists('xlanguage_ml')) {
        $string = xlanguage_ml($string);
    } elseif (method_exists($myts, 'formatForML')) {
        $string = $myts->formatForML($string);
    }
    return $string;
}
示例#16
0
文件: search.php 项目: nouphet/rata
 function d3forum_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     $myts =& MyTextsanitizer::getInstance();
     $db =& Database::getInstance();
     $andor = strtoupper($andor);
     $userid = intval($userid);
     // naao from
     require_once dirname(__FILE__) . '/include/main_functions.php';
     // get all forums
     $sql = "SELECT forum_id, forum_external_link_format FROM " . $db->prefix($mydirname . "_forums");
     $frs = $db->query($sql);
     $d3com = array();
     while ($forum_row = $db->fetchArray($frs)) {
         // d3comment object
         $temp_forum_id = intval($forum_row['forum_id']);
         if (!empty($forum_row['forum_external_link_format'])) {
             $d3com[$temp_forum_id] =& d3forum_main_get_comment_object($mydirname, $forum_row['forum_external_link_format']);
         } else {
             $d3com[$temp_forum_id] = false;
         }
     }
     // naao to
     $charset = strtoupper(_CHARSET);
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "p.post_text" : "'' AS post_text";
     require_once dirname(__FILE__) . '/include/common_functions.php';
     $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")";
     $whr_uid = $userid > 0 ? "p.uid={$userid}" : "1";
     $whr_query = $andor == 'OR' ? '0' : '1';
     if (is_array($keywords)) {
         // I know this is not a right escaping, but I can't believe $keywords :-)
         $keywords = array_map('stripslashes', $keywords);
         foreach ($keywords as $word) {
             $word4sql = addslashes($word);
             $word_or = array('p.subject LIKE \'%' . $word4sql . '%\' OR p.post_text LIKE \'%' . $word4sql . '%\'');
             if (($charset === 'UTF-8' || $charset === 'EUC-JP') && function_exists('mb_convert_kana')) {
                 foreach (array('a', 'A', 'k', 'KV', 'h', 'HV', 'c', 'C') as $_op) {
                     $_word = mb_convert_kana($word, $_op, $charset);
                     if ($_word !== $word) {
                         $word4sql = addslashes($_word);
                         $word_or[] = 'p.subject LIKE \'%' . $word4sql . '%\' OR p.post_text LIKE \'%' . $word4sql . '%\'';
                     }
                 }
             }
             $word4sql = join(' OR ', $word_or);
             $whr_query .= $andor == 'EXACT' ? ' AND' : ' ' . $andor;
             $whr_query .= ' (' . $word4sql . ')';
         }
     }
     //$sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,$select4con FROM ".$db->prefix($mydirname."_posts")." p LEFT JOIN ".$db->prefix($mydirname."_topics")." t ON t.topic_id=p.topic_id WHERE ($whr_forum) AND ($whr_uid) AND ($whr_query) AND ! topic_invisible ORDER BY p.post_time DESC" ;
     //naao
     $sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,{$select4con},t.topic_external_link_id,f.forum_id FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON t.topic_id=p.topic_id  LEFT JOIN " . $db->prefix($mydirname . "_forums") . " f ON t.forum_id = f.forum_id WHERE ({$whr_forum}) AND ({$whr_uid}) AND ({$whr_query}) AND ! topic_invisible ORDER BY p.post_time DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     // nao-pon
     $make_context_func = function_exists('xoops_make_context') ? 'xoops_make_context' : (function_exists('search_make_context') ? 'search_make_context' : '');
     while (list($post_id, $topic_id, $post_time, $uid, $subject, $html, $smiley, $xcode, $br, $text, $external_link_id, $forum_id) = $db->fetchRow($result)) {
         // naao from
         $can_display = true;
         //default
         if (is_object($d3com[intval($forum_id)])) {
             $d3com_obj = $d3com[intval($forum_id)];
             if (($external_link_id = $d3com_obj->validate_id($external_link_id)) === false) {
                 $can_display = false;
             }
         }
         if ($can_display == true) {
             // naao to
             // get context for module "search"
             // nao-pon
             //if( function_exists('search_make_context') && $showcontext ) {
             if ($make_context_func && $showcontext) {
                 if (function_exists('easiestml')) {
                     $text = easiestml($text);
                 }
                 $full_context = strip_tags($myts->displayTarea($text, $html, $smiley, $xcode, 1, $br));
                 // nao-pon
                 //$context = search_make_context( $full_context , $keywords ) ;
                 $context = $make_context_func($full_context, $keywords);
             }
             $ret[] = array('link' => "index.php?post_id={$post_id}", 'title' => htmlspecialchars($subject, ENT_QUOTES), 'time' => $post_time, 'uid' => $uid, 'context' => $context);
         }
         // naao
     }
     // for xoops search module
     $GLOBALS['md_search_flg_zenhan_support'] = true;
     return $ret;
 }
示例#17
0
	function d3downloads_global_search_base( $mydirname, $keywords, $andor, $limit, $offset, $userid )
	{
		require_once dirname( __FILE__ ).'/class/d3downloads.textsanitizer.php' ;
		include_once dirname( __FILE__ ).'/class/mydownload.php' ;
		include_once dirname( __FILE__ ).'/class/user_access.php' ;

		$myts =& d3downloadsTextSanitizer::getInstance() ;
		$db =& Database::getInstance() ;

		$showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ;
		$mydownload = new MyDownload( $mydirname ) ;
		$user_access = new user_access( $mydirname ) ;
		$whr = "cid IN ( ".implode( ",", $user_access->can_read() )." )" ;
		
		if( $showcontext == 1 ){
			$sql = "SELECT lid, cid, title, description, submitter, date FROM ".$db->prefix( $mydirname."_downloads" )."" ;
		} else {
			$sql = "SELECT lid, cid, title, submitter, date, title FROM ".$db->prefix( $mydirname."_downloads" )."" ;
		}
		$sql .= " WHERE ".$mydownload->whr_append( 'Single' )." AND ( $whr )" ;
		if ( $userid != 0 ) $sql .= " AND submitter=".$userid." ";

		// because count() returns 1 even if a supplied variable
		// is not an array, we must check if $querryarray is really an array
		if ( is_array( $keywords ) && $count = count( $keywords ) ) {
			$sql .= " AND ( ( title LIKE '%$keywords[0]%' OR description LIKE '%$keywords[0]%' )" ;
			for( $i=1; $i<$count; $i++ ){
				$sql .= " $andor " ;
				$sql .= "( title LIKE '%$keywords[$i]%' OR description LIKE '%$keywords[$i]%' )" ;
			}
			$sql .= ") " ;
		}
		$sql .= "ORDER BY date DESC" ;
		$result = $db->query( $sql, $limit, $offset ) ;
		$ret = array();
		while( $myrow = $db->fetchArray( $result ) )
		{
			$lid = intval( $myrow['lid'] ) ;
			$cid = intval( $myrow['cid'] ) ;
			$title = $myts->makeTboxData4Show( $myrow['title'] ) ;
			$date = intval( $myrow['date'] ) ;
			$submitter = intval( $myrow['submitter'] ) ;
			$context = '' ;
			// get context for module "search"
			if( function_exists( 'search_make_context' ) && $showcontext ) {
				$body = $myts->displayTarea( $myrow['description'], 0, 1, 1, 1, 1 ) ;
				if ( strstr ( $body , '[pagebreak]' ) ){
					$str = explode( '[pagebreak]', $body , 2 ) ;
					$body = $str[0] ;
				}
				$full_context = strip_tags( $body ) ;
				if( function_exists( 'easiestml' ) ) $full_context = easiestml( $full_context ) ;
				$context = search_make_context( $full_context , $keywords ) ;
			}
			$ret[] = array(
				'link' => "index.php?page=singlefile&amp;cid=$cid&amp;lid=$lid" ,
				'title' => $title ,
				'time' => $date ,
				'uid' => $submitter ,
				'context' => $context ,
			) ;
		}
		return $ret ;
	}
示例#18
0
function msg_list()
{
    global $msg_status, $xoopsDB, $xoopsUser, $xoopsModuleConfig, $xoopsModule, $myts;
    $labels = array('mtime' => _AM_FORM_MTIME, 'status' => _AM_MSG_STATUS, 'fidref' => _AM_FORM_TITLE, 'cfrom' => _AM_MSG_FROM, 'uname' => _AM_MSG_CHARGE, 'comms' => _AM_MSG_COMMS, 'ope' => _AM_OPERATION);
    $orders = array('mtime' => 'DESC', 'fidref' => 'ASC', 'uname' => 'ASC', 'status' => 'ASC', 'uid' => 'ASC', 'orders' => array('mtime'));
    $listctrl = new ListCtrl('msgadm', $orders);
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    $search = isset($_GET['q']) ? $myts->stripSlashesGPC($_GET['q']) : '';
    $max = $xoopsModuleConfig['max_lists'];
    $users = $xoopsDB->prefix('users');
    $comms = $xoopsDB->prefix('xoopscomments');
    $mid = $xoopsModule->getVar('mid');
    $sql0 = "FROM " . CCMES . " m LEFT JOIN " . FORMS . " ON fidref=formid \nLEFT JOIN {$users} u ON touid=u.uid LEFT JOIN {$users} f ON m.uid=f.uid";
    $sql1 = "LEFT JOIN {$comms} ON com_modid={$mid} AND com_itemid=msgid";
    $sql2 = "WHERE " . $listctrl->sqlcondition();
    $formid = isset($_REQUEST['formid']) ? intval($_REQUEST['formid']) : 0;
    if ($formid) {
        $sql2 .= " AND fidref={$formid}";
    }
    if ($search) {
        $sql2 .= " AND CONCAT(body,' ',m.email) like " . $xoopsDB->quoteString("%{$search}%");
    }
    $res = $xoopsDB->query("SELECT count(msgid) {$sql0} {$sql2}");
    list($total) = $xoopsDB->fetchRow($res);
    $args = preg_replace('/\\b&?start=\\d+/', '', $_SERVER['QUERY_STRING']);
    $nav = new XoopsPageNav($total, $max, $start, "start", $args);
    $res = $xoopsDB->query("SELECT m.*,title,u.uname, f.uname cfrom, count(com_id) comms {$sql0} {$sql1} {$sql2} GROUP BY msgid" . $listctrl->sqlorder(), $max, $start);
    echo "<style>td.num { text-align: right; }</style>\n";
    echo "<h2>" . _AM_MSG_ADMIN . "</h2>\n";
    echo "<table class='ccinfo' width='100%'>\n<tr><td width='30%'>" . _AM_MSG_COUNT . " {$total}</td>\n";
    echo "<td align='center'>" . $nav->renderNav() . "</td>\n";
    echo "<td align='right' width='30%' nowrap='nowrap'>\n  <form method='get'>" . _SEARCH . "\n    <input name='q' value=\"" . htmlspecialchars($search, ENT_QUOTES) . '" size="8" /> &nbsp; ' . _CC_STATUS . " " . $listctrl->renderStat() . "\n      <noscript> <input type='submit' type='submit' value='" . _AM_SUBMIT_VIEW . "'></noscript>\n  </form>\n</td></tr>\n";
    echo "</table>\n";
    if ($res && $xoopsDB->getRowsNum($res)) {
        $sorts = array('mtime', 'status', 'fidref', 'touid', 'comms');
        echo "<form method='post' name='msglist'>\n";
        echo "<table class='outer' border='0' cellspacing='1'>\n";
        echo "<tr><th><input type='checkbox' id='checkall' name='checkall' onClick='xoopsCheckAll(\"msglist\", \"checkall\");'/>";
        $args = preg_replace('/\\b&?\\w{3,}=(asc|desc)/', '', $args);
        foreach ($listctrl->getLabels($labels) as $lab) {
            if (isset($lab['value'])) {
                $extra = empty($lab['extra']) ? '' : $lab['extra'];
                $sargs = ($args ? "{$args}&" : '') . $lab['name'] . "=" . $lab['next'];
                $anc = " <a href='?{$sargs}' title='" . _CC_SORT_ORDER . "'{$extra}><img src='../images/" . $lab['value'] . ".gif'></a>";
            } else {
                $anc = '';
            }
            echo "<th>" . $lab['text'] . "{$anc}</th>\n";
        }
        echo "</tr>\n";
        $n = 0;
        $dirname = basename(dirname(dirname(__FILE__)));
        $mbase = XOOPS_URL . "/modules/{$dirname}";
        $strcut = XOOPS_USE_MULTIBYTES && function_exists('mb_strcut') ? 'mb_strcut' : 'substr';
        if (!function_exists('easiestml')) {
            /* XXX: support multi lang site */
            function easiestml($text)
            {
                return $text;
            }
        } else {
            $GLOBALS['easiestml_lang'] = substr($GLOBALS['xoopsConfig']['language'], 0, 2);
        }
        while ($data = $xoopsDB->fetchArray($res)) {
            $id = $data['msgid'];
            $title = easiestml(htmlspecialchars($data['title'], ENT_QUOTES));
            $stat = $data['status'];
            $url = "{$mbase}/message.php?id={$id}";
            $msg = $url . ($data['touid'] < 0 ? "&amp;uid=" . $xoopsUser->getVar('uid') : "");
            $bg = $n++ % 2 ? 'even' : 'odd';
            $date = myTimestamp($data['mtime'], "m", _AM_TIME_UNIT);
            $priuname = empty($data['uname']) ? _AM_FORM_PRIM_NONE : htmlspecialchars($data['uname'], ENT_QUOTES);
            $from = empty($data['uid']) ? $data['email'] : htmlspecialchars($data['cfrom'], ENT_QUOTES);
            $box = "<input type='checkbox' name='ids[]' value='{$id}'/>";
            $ope = "<a href='{$msg}'>" . _AM_DETAIL . "</a>";
            $ope .= " | <a href='?msgid={$id}'>" . _EDIT . "</a>";
            $vals = unserialize_text($data['body']);
            $fval = preg_replace('/[\\n\\r].*$/', '...', array_shift($vals));
            $slen = 30;
            if (strlen($fval) > $slen) {
                $fval = preg_replace('/\\.\\.\\.$/', '', $fval);
                $fval = $strcut($fval, 0, $slen) . "...";
            }
            $fval = htmlspecialchars($fval, ENT_QUOTES);
            $readit = $data['mtime'] < $data['atime'] ? _CC_MARK_READIT : '';
            echo "<tr class='{$bg} stat{$stat}'><td align='center'>{$box}</td><td>{$date}</td><td>" . $msg_status[$stat] . $readit . "</td><td>{$title}: {$fval}</td><td>{$from}</td><td>{$priuname}</td><td class='num'>" . $data['comms'] . "</td><td>{$ope}</td></tr>\n";
        }
        echo "</table>\n";
        echo "<div>" . _AM_MSG_CHANGESTATUS . " <select name='op'><option></option>\n";
        foreach ($msg_status as $k => $v) {
            echo "<option value='{$k}'>{$v}</option>\n";
        }
        echo "</select>\n";
        echo "<input type='submit' value='" . _AM_SUBMIT . "'/>";
        echo "</div>\n";
        echo "</form>\n";
    } else {
        echo _AM_NODATA;
    }
}
 function get_xoops_search_result($keywords, $andor, $limit, $offset, $uid)
 {
     // 時差計算
     $tzoffset = ($this->user_TZ - $this->server_TZ) * 3600;
     // カテゴリー関連のWHERE条件取得
     $whr_categories = $this->get_where_about_categories();
     // CLASS関連のWHERE条件取得
     $whr_class = $this->get_where_about_class();
     // 文字列指定
     if (!empty($keywords)) {
         switch (strtolower($andor)) {
             case 'and':
                 $whr_text = '';
                 foreach ($keywords as $keyword) {
                     $whr_text .= "CONCAT(summary,' ',description) LIKE '%{$keyword}%' AND ";
                 }
                 $whr_text = substr($whr_text, 0, -5);
                 break;
             case 'or':
                 $whr_text = '';
                 foreach ($keywords as $keyword) {
                     $whr_text .= "CONCAT(summary,' ',description) LIKE '%{$keyword}%' OR ";
                 }
                 $whr_text = substr($whr_text, 0, -4);
                 break;
             default:
                 $whr_text = "CONCAT(summary,'  ',description) LIKE '%{$keywords[0]}%'";
                 break;
         }
     } else {
         $whr_text = '1';
     }
     // ユーザID指定
     if ($uid > 0) {
         $whr_uid = "uid={$uid}";
     } else {
         $whr_uid = '1';
     }
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "description" : "'' AS description";
     // SQL文生成
     $sql = "SELECT id,uid,summary,UNIX_TIMESTAMP(dtstamp) AS udtstamp, start, end, allday, start_date, end_date, {$select4con} FROM {$this->table} WHERE admission>0 AND (rrule_pid=0 OR rrule_pid=id) AND ({$whr_categories}) AND ({$whr_class}) AND ({$whr_text}) AND ({$whr_uid}) ORDER BY dtstamp DESC LIMIT {$offset},{$limit}";
     // クエリ
     $rs = mysql_query($sql, $this->conn);
     $ret = array();
     $context = '';
     $myts =& MyTextSanitizer::getInstance();
     while ($event = mysql_fetch_object($rs)) {
         if (isset($event->start_date)) {
             $start_str = $event->start_date;
         } else {
             if ($event->allday) {
                 $start_str = $this->get_long_ymdn($event->start);
             } else {
                 $start_str = $this->get_long_ymdn($event->start + $tzoffset);
             }
         }
         if (isset($event->end_date)) {
             $end_str = $event->end_date;
         } else {
             if ($event->allday) {
                 $end_str = $this->get_long_ymdn($event->end - 300);
             } else {
                 $end_str = $this->get_long_ymdn($event->end + $tzoffset);
             }
         }
         $date_desc = $start_str == $end_str ? $start_str : "{$start_str} - {$end_str}";
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myts->displayTarea($event->description, 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array('image' => "images/pical.gif", 'link' => "index.php?action=View&amp;event_id={$event->id}", 'title' => "[{$date_desc}] {$event->summary}", 'time' => $event->udtstamp, 'uid' => $uid, "context" => $context);
     }
     return $ret;
 }
 function sendMail()
 {
     $mail_body = $this->makeMailBody();
     $cc_mail_body = $this->makeCCMailBody();
     $subject = $this->makeMailSubject();
     $cc_subject = $this->makeCCMailSubject();
     // easiestml
     if (function_exists('easiestml')) {
         $mail_body = easiestml($mail_body);
         $cc_mail_body = easiestml($cc_mail_body);
         $subject = easiestml($subject);
         $cc_subject = easiestml($cc_subject);
     }
     // send main mail (server to admin/poster)
     if (!empty($this->toEmails)) {
         // initialize
         $toMailer =& getMailer();
         $toMailer->useMail();
         $toMailer->setFromEmail($this->fromEmail);
         $toMailer->setFromName($this->fromName);
         // "from" overridden by form data
         if (!empty($this->from_field_name) && $this->isValidEmail($this->form_processor->fields[$this->from_field_name]['value'])) {
             $toMailer->setFromEmail($this->form_processor->fields[$this->from_field_name]['value']);
             if (!empty($this->fromname_field_name) && !empty($this->form_processor->fields[$this->fromname_field_name]['value'])) {
                 // remove cr, lf, null
                 $toMailer->setFromName(str_replace(array("\n", "\r", ""), '', $this->form_processor->fields[$this->fromname_field_name]['value']));
             }
         }
         // "Reply-To" header
         if (!empty($this->replyto_field_name) && $this->isValidEmail($this->form_processor->fields[$this->replyto_field_name]['value'])) {
             $toMailer->addHeaders('Reply-To: ' . $this->form_processor->fields[$this->replyto_field_name]['value']);
         }
         $toMailer->setToEmails(array_unique($this->toEmails));
         $toMailer->setSubject($subject);
         $toMailer->setBody($mail_body);
         $toMailer->send();
     }
     // send confirming mail (server to visitor)
     if (!empty($this->cc_field_name) && !empty($this->form_processor->fields[$this->cc_field_name]['value'])) {
         // initialize
         $ccMailer =& getMailer();
         $ccMailer->useMail();
         $ccMailer->setFromEmail($this->fromEmail);
         $ccMailer->setFromName($this->fromName);
         $ccMailer->setToEmails($this->form_processor->fields[$this->cc_field_name]['value']);
         $ccMailer->setSubject($cc_subject);
         $ccMailer->setBody($cc_mail_body);
         $ccMailer->send();
     }
 }
示例#21
0
文件: search.php 项目: nouphet/rata
 function xpress_global_search_base($mydirname, $queryarray, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB, $myts;
     require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/general_functions.php';
     $myts =& MyTextSanitizer::getInstance();
     $xp_prefix = preg_replace('/wordpress/', 'wp', $mydirname);
     if ($userid) {
         $wp_uid = xoops_uid_to_wp_uid(intval($userid), $mydirname);
     }
     $prefix = XOOPS_DB_PREFIX . '_' . $xp_prefix;
     $posts_tables = get_table_list($prefix, 'posts');
     $i = 0;
     $ret = array();
     foreach ($posts_tables as $views_table) {
         $mid_prefix = get_multi_mid_prefix($prefix, 'posts', $views_table);
         $option_table = $prefix . $mid_prefix . 'options';
         $time_difference = get_blog_option($option_table, 'gmt_offset');
         $blog_url = get_blog_option($option_table, 'siteurl');
         $pattern = '/.*' . $mydirname . '/';
         $mid_url = preg_replace($pattern, '', $blog_url);
         $mid_url = preg_replace('/\\//', '', $mid_url);
         if (!empty($mid_url)) {
             $mid_url = $mid_url . '/';
         }
         $blog_name = get_blog_option($option_table, 'blogname');
         if (empty($mid_url)) {
             $blog_name = '';
         } else {
             $blog_name = $blog_name . ':: ';
         }
         $now = date('Y-m-d H:i:s', time() + $time_difference * 3600);
         $where = "(post_status = 'publish') AND (post_date <= '" . $now . "') AND (post_type <> 'revision') AND (post_type <> 'nav_menu_item') ";
         if (is_array($queryarray) && ($count = count($queryarray))) {
             $str_query = array();
             for ($j = 0; $j < $count; $j++) {
                 $str_query[] = "(post_title LIKE '%" . $queryarray[$j] . "%' OR post_content LIKE '%" . $queryarray[$j] . "%')";
             }
             $where .= " AND " . implode(" {$andor} ", $str_query);
         }
         if ($userid) {
             if ($wp_uid) {
                 $where .= " AND (post_author=" . $wp_uid . ")";
             } else {
                 $where .= " AND 0 ";
             }
         }
         $request = "SELECT * FROM " . $views_table . " WHERE " . $where;
         $request .= " ORDER BY post_date DESC";
         $result = $xoopsDB->query($request, $limit, $offset);
         while ($myrow = $xoopsDB->fetchArray($result)) {
             if ($myrow['post_type'] !== 'revision' && $myrow['post_type'] !== 'nav_menu_item') {
                 switch ($myrow['post_type']) {
                     case 'page':
                         $ret[$i]['link'] = $mid_url . '?page_id=' . $myrow['ID'];
                         break;
                     case 'post':
                     case '':
                         $ret[$i]['link'] = $mid_url . '?p=' . $myrow['ID'];
                         break;
                     default:
                         $ret[$i]['link'] = $mid_url . '?' . $myrow['post_type'] . '=' . $myrow['post_name'];
                 }
             }
             $ret[$i]['title'] = $blog_name . $myts->htmlSpecialChars($myrow['post_title']);
             $date_str = $myrow['post_date'];
             $yyyy = substr($date_str, 0, 4);
             $mm = substr($date_str, 5, 2);
             $dd = substr($date_str, 8, 2);
             $hh = substr($date_str, 11, 2);
             $nn = substr($date_str, 14, 2);
             $ss = substr($date_str, 17, 2);
             $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
             $ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'], $mydirname);
             $context = '';
             $text = $myrow['post_content'];
             // get context for module "search"
             $showcontext = empty($_GET['showcontext']) ? 0 : 1;
             if (function_exists('search_make_context') && $showcontext) {
                 if (function_exists('easiestml')) {
                     $text = easiestml($text);
                 }
                 $full_context = strip_tags($text);
                 $context = search_make_context($full_context, $queryarray);
             }
             $ret[$i]['context'] = $context;
             $i++;
         }
     }
     return $ret;
 }