コード例 #1
0
function b_mysearch_last_search_show()
{
    include_once XOOPS_ROOT_PATH . '/modules/mysearch/include/functions.php';
    $mysearch_handler =& xoops_getmodulehandler('searches', 'mysearch');
    $visiblekeywords = 0;
    $block = array();
    $visiblekeywords = mysearch_getmoduleoption('showindex');
    if ($visiblekeywords > 0) {
        $block['visiblekeywords'] = $visiblekeywords;
        $totalcount = $mysearch_handler->getCount();
        $start = 0;
        $critere = new Criteria('mysearchid', 0, '<>');
        $critere->setSort('datesearch');
        $critere->setLimit($visiblekeywords);
        $critere->setStart($start);
        $critere->setOrder('DESC');
        $tmpmysearch = new searches();
        $elements = $mysearch_handler->getObjects($critere);
        foreach ($elements as $oneelement) {
            $search = array();
            $search['keyword'] = $oneelement->getVar('keyword');
            $search['date'] = formatTimestamp(strtotime($oneelement->getVar('datesearch')));
            $search['uid'] = $oneelement->getVar('keyword');
            $search['uname'] = $tmpmysearch->uname($oneelement->getVar('uid'));
            $search['link'] = "<a href='" . XOOPS_URL . '/search.php?query=' . $oneelement->getVar('keyword') . "&action=results' target='_blank'>";
            $block['searches'][] = $search;
            unset($search);
        }
    }
    return $block;
}
コード例 #2
0
function b_mysearch_big_user_show()
{
    include_once XOOPS_ROOT_PATH . "/modules/mysearch/include/functions.php";
    $mysearch_handler =& xoops_getmodulehandler('searches', 'mysearch');
    $block = array();
    $visiblekeywords = mysearch_getmoduleoption('showindex');
    if ($visiblekeywords > 0) {
        $tmpmysearch = new searches();
        $keywords_count = mysearch_getmoduleoption('admincount');
        // Total keywords count
        $block['total_keywords'] = $mysearch_handler->getCount();
        // Biggest users
        $elements = $mysearch_handler->getBiggestContributors(0, $keywords_count);
        foreach ($elements as $oneuser => $onecount) {
            $block['biggesusers'][] = array('uid' => $oneuser, 'uname' => $tmpmysearch->uname($oneuser), 'count' => $onecount);
        }
    }
    return $block;
}
コード例 #3
0
ファイル: searches.php プロジェクト: trabisdementia/xuups
 /**
  * End hack by Smart
  */
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->db->prefix('mysearch_searches');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         if ($criteria->getSort() != '') {
             $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
         }
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $searches = new searches();
         $searches->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $searches;
         } else {
             $ret[$myrow['mysearchid']] =& $searches;
         }
         unset($searches);
     }
     return $ret;
 }
コード例 #4
0
ファイル: index.php プロジェクト: trabisdementia/xuups
 echo '<br />';
 echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>";
 echo "<tr><th align='center'>" . _AM_MYSEARCH_HITS . "</th><th align='center'>" . _AM_MYSEARCH_KEYWORD . "</th><th align='center'>" . _AM_MYSEARCH_ACTION . "</th></tr>";
 $class = '';
 foreach ($elements as $onekeyword_id => $onekeyword_datas) {
     $onekeyword = $onekeyword_datas['keyword'];
     $onekeywordcount = $onekeyword_datas['count'];
     $class = $class == 'even' ? 'odd' : 'even';
     $link1 = "<a href='" . XOOPS_URL . '/search.php?query=' . $onekeyword . "&action=results' target='_blank'>" . $onekeyword . "</a>";
     $action_del = "<a " . mysearch_JavascriptLinkConfirm(_AM_MYSEARCH_AREYOUSURE) . " href='index.php?op=removekeyword&id=" . $onekeyword_id . "' title='" . _AM_MYSEARCH_DELETE . "'><img src='../images/delete.png' border='0' alt='" . _AM_MYSEARCH_DELETE . "' /></a>";
     $action_black = "<a " . mysearch_JavascriptLinkConfirm(_AM_MYSEARCH_AREYOUSURE) . " href='index.php?op=addblacklist&id=" . $onekeyword_id . "' title='" . _AM_MYSEARCH_BLACKLIST . "'><img src='../images/list.png' border='0' alt='" . _AM_MYSEARCH_BLACKLIST . "' /></a>";
     echo "<tr class='" . $class . "'><td align='center'>" . $onekeywordcount . "</td><td align='center'>" . $link1 . "</td><td align='center'>" . $action_del . '&nbsp;' . $action_black . "</td></tr>";
 }
 echo "</table><div align='right'>" . $pagenav->renderNav() . '</div></div><br />';
 // Biggest users of the search ************************************************************************************************************************
 $tmpmysearch = new searches();
 $start = 0;
 if (isset($_GET['start3'])) {
     $start = intval($_GET['start3']);
 } elseif (isset($_SESSION['start3'])) {
     $start = intval($_SESSION['start3']);
 }
 $_SESSION['start3'] = $start;
 $pagenav = new XoopsPageNav($mysearch_handler->getBiggestContributorsCount(), $keywords_count, $start, 'start3', 'op=stats');
 $elements = $mysearch_handler->getBiggestContributors($start, $keywords_count);
 mysearch_collapsableBar('bigcontribut', 'bigcontributicon');
 echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='bigcontributicon' name='bigcontributicon' src=" . XOOPS_URL . "/modules/mysearch/images/close12.gif alt='' /></a>&nbsp;" . _AM_MYSEARCH_BIGGEST_USERS . "</h4>";
 echo "<div id='bigcontribut'>";
 echo '<br />';
 echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>";
 echo "<tr><th align='center'>" . _AM_MYSEARCH_USER . "</th><th align='center'>" . _AM_MYSEARCH_HITS . "</th></tr>";
コード例 #5
0
 public function base()
 {
     $results = array();
     $query = isset($_GET['q']) ? $_GET['q'] : false;
     $search = $query;
     if ($query !== false) {
         $stemmer = new PorterStemmer();
         $index = new indexes($this->getDb());
         $file = new files($this->getDb());
         $scores = array();
         $terms = explode(' ', $query);
         $db_searches = new searches($this->getDb());
         foreach ($terms as $term) {
             if ($term != '') {
                 $old = $db_searches->select('*', 'WHERE term="' . $term . '"');
                 if (isset($old[0]['id'])) {
                     $db_searches->update(array('count' => ++$old[0]['count'], 'date' => time()), 'WHERE term="' . $term . '"');
                 } else {
                     $db_searches->insert(array('term' => $term, 'count' => 1, 'date' => time()));
                 }
             }
         }
         $term_weight = 0.05;
         $wpm_weight = 5;
         //7
         $count_weight = 150;
         //135
         $count = 0;
         foreach ($terms as $term) {
             $term = 'indx-' . $stemmer->Stem($term);
             $data = $index->select('*', 'WHERE stem="' . $term . '" ORDER BY wpm DESC, count DESC LIMIT 0, 100');
             foreach ($data as $file_data) {
                 $file_id = $file_data['file'];
                 $wpm = $file_data['wpm'];
                 $index_count = $file_data['count'];
                 $weight = $wpm * $wpm_weight * (1 - $term_weight * $count) + $index_count * $count_weight * (1 - $term_weight * $count);
                 if (isset($scores[$file_id])) {
                     $scores[$file_id] += $weight;
                 } else {
                     $scores[$file_id] = $weight;
                 }
             }
             $count++;
         }
         arsort($scores);
         foreach ($scores as $key => $score) {
             $results[$key] = array();
             $results[$key]['score'] = $score;
         }
         $ids = array_keys($scores);
         $files = array();
         if (count($ids) > 0) {
             $files = $file->select('*', 'WHERE id IN (' . implode(', ', $ids) . ')');
         }
         foreach ($files as $selected) {
             $results[$selected['id']]['id'] = $selected['id'];
             $results[$selected['id']]['name'] = $selected['name'];
             $results[$selected['id']]['link'] = $selected['link'];
         }
         $this->set('results', $results);
     } else {
         $this->set('results', $results);
     }
     $this->set('search', $search);
     $searches = new searches($this->getDb());
     $this->set('popular', $searches->select('*', 'ORDER BY count DESC LIMIT 0, 10'));
 }