function addart($catid, $title, $content) { $info = array(); $info['catid'] = $catid; $info['title'] = $title; $info['content'] = $content; $db_config = pc_base::load_config('database'); pc_base::load_sys_class('mysql', '', 0); pc_base::load_sys_class('param', '', 0); $db = pc_base::load_model('content_model'); $category = $categorys[3]; $modelid = $category['modelid']; $db->set_model($modelid); $setting = string2array($category['setting']); $workflowid = $setting['workflowid']; $info['status'] = 99; $info['keywords'] = get_keywords($info['title'], 3); $info['description'] = str_cut(str_replace(array("\r\n", "\t", '[page]', '[/page]', '“', '”', ' '), '', strip_tags($info['content'])), 200); $info['username'] = "******"; $info['inputtime'] = ''; if ($db->add_content($info)) { return true; } return false; }
public function get() { $number = isset($_GET['number']) ? intval($_GET['number']) : 3; $data = isset($_POST['data']) ? trim($_POST['data']) : exit; $result = get_keywords($data, $number); exit($result); }
function render_entities($dbc, $id) { $keywords = get_keywords($dbc, $id); foreach ($keywords as $keyword) { echo '<a href="#" >' . $keyword . '</a><br>'; echo '<p>' . get_def($dbc, $keyword) . '</p>'; //echo '<br>'; } }
function getDataAmazon() { $json = get_hukd_data(); $keywords = get_keywords($json); $json = get_amazon_competitors($json, $keywords); $json = json_decode($json); usort($json->items, 'my_sort'); $json = json_encode($json); echo $_GET['jsoncallback'] . '(' . $json . ')'; }
function render_paragraphs($dbc, $db_name, $title) { $keywords = mysql_escape_string($title); $query = "select * from resource where title = '{$keywords}'"; //echo $title; $result = mysqli_query($dbc, $query) or die('Error querying database:' . $query); while ($row = mysqli_fetch_array($result)) { $id = trim($row["id"]); $description = trim($row["description"]); echo "<div class='row'>"; echo "<div class='col-sm-8'>"; $keywords = get_keywords($dbc, $id); $predicates = get_predicates($dbc, $id); $description = preprocess_description($db_name, $description, $keywords, $predicates); echo $description; echo "</div>"; echo "<div class='col-sm-4'>"; if (count($keywords) != 0) { echo '<small>相关概念:</small>'; foreach ($keywords as $keyword) { //echo '<p>' . $keyword . ": " . $def . '</p>'; echo '<button type="button" class="btn btn-xs btn-default" data-container="body" data-toggle="popover" data-placement="bottom" data-content="' . get_def($dbc, $keyword) . '">'; echo $keyword; echo '</button> '; } echo '<small> '; render_relations($dbc, $id); echo '</small>'; } echo "</div>"; echo "</div>"; } }
$idt = array(); $cidpar = '?cidReq=' . $_course['sysCode']; while ($row = Database::fetch_array($result)) { $mdObj = new mdobject($_course, substr($row['eid'], AFTER_DOT)); $idt[$mdObj->mdo_url . $cidpar] = $row['indexabletext']; } if (count($idt) && file_exists($phpDigIncCn)) { require $phpDigIncCn; // switch to PhpDig DB foreach ($idt as $url => $text) { if (ereg('^http://([^/]+)/(.+)/([^/]+)\\?cidReq=(.+)$', $url, $regs)) { $path = $regs[2] . '/'; $file = $regs[3] . '?cidReq=' . $regs[4]; if ($site_id = remove_engine_entries('http://' . $regs[1] . '/', $path, $file)) { echo '<table>', "\n"; index_words($site_id, $path, $file, get_first_words($text, $path, $file), get_keywords($text)); echo '</table>', "\n"; } } } if (isset($db)) { //mysql_select_db($_configuration['main_database'], $db); Database::select_db($_configuration['main_database'], $db); } } else { echo 'No documents with metadata or no PhpDig in this course...<br />'; } if (false && file_exists($phpDigIncCn)) { echo '<form action="' . api_get_self() . '" method="post">', "\n", '<input type="submit" name="dmo" value="', get_lang('Import', 'noDLTT'), '">', "\n", '<input type="submit" name="dmo" value="', get_lang('Remove', 'noDLTT'), '">', "\n", '</form>', "\n"; } Display::display_footer();
/** * Adds a bookmark in the bookmarks file (table of contents) * @param type $album the album the bookmark is intended to * @param type $asset the asset the bookmark is intended to * @param type $timecode the specific time code of the bookmark * @param type $title the title of the bookmark * @param type $description the description of the bookmark * @param type $keywords the keywords of the bookmark * @param type $level the level of the bookmark * @return boolean true if the bookmark has been added to the table of contents; * false otherwise */ function toc_asset_bookmark_add($album, $asset, $timecode, $title = '', $description = '', $keywords = '', $level = '1', $type = '') { // Sanity check if (!ezmam_album_exists($album)) { return false; } if (!ezmam_asset_exists($album, $asset)) { return false; } if (!isset($timecode) || $timecode == '' || $timecode < 0) { return false; } // 1) set the repository path $toc_path = ezmam_repository_path(); if ($toc_path === false) { return false; } // set user's file path $toc_path = $toc_path . '/' . $album; // remove the previous same bookmark if it existed yet toc_asset_bookmark_delete($album, $asset, $timecode); // Get the bookmarks list $bookmarks_list = toc_album_bookmarks_list_get($album); $count = count($bookmarks_list); $index = 0; if ($count > 0) { $index = -1; $asset_ref = $bookmarks_list[0]['asset']; $timecode_ref = $bookmarks_list[0]['timecode']; // loop while the asset is older than the reference asset while ($index < $count && $asset > $asset_ref) { ++$index; $asset_ref = $bookmarks_list[$index]['asset']; $timecode_ref = $bookmarks_list[$index]['timecode']; } // if the asset already contains bookmarks, loop while // timecode is bigger than reference timecode while ($index < $count && $asset == $asset_ref && $timecode > $timecode_ref) { ++$index; $timecode_ref = $bookmarks_list[$index]['timecode']; $asset_ref = $bookmarks_list[$index]['asset']; } if ($index < 0) { // no bookmarks yet $index = 0; } if ($index > $count) { // bookmark is in last position in the table of contents --$index; } } // extract keywords from the description $keywords_array = get_keywords($description); // and save them as keywords foreach ($keywords_array as $keyword) { if (strlen($keywords) > 0) { $keywords .= ', '; } $keywords .= $keyword; } // surround every url by '*' for url recognition in EZplayer $description = surround_url($description); // add a bookmark at the specified index in the albums list array_splice($bookmarks_list, $index, 0, array(null)); $bookmarks_list[$index] = array('album' => $album, 'asset' => $asset, 'timecode' => $timecode, 'title' => $title, 'description' => $description, 'keywords' => $keywords, 'level' => $level, 'type' => $type); return assoc_array2xml_file($bookmarks_list, $toc_path . "/_bookmarks.xml", "bookmarks", "bookmark"); }
?> </title> <!-- Begin Favicon Information --> <link rel="shortcut icon" type="image/png" href="<?php bloginfo('template_directory'); ?> /icons/favicon.ico" > <!-- Begin Meta Information --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="<?php echo strip_tags(get_the_excerpt()); ?> " /> <meta name="keywords" content="<?php get_keywords(); ?> " /> <meta name="robots" content="no index, no follow" /> <meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=yes" /> <!-- Begin Style Sheets --> <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?> /style.css" type="text/css"> <link rel="stylesheet" href="<?php bloginfo('template_directory');
public function main() { global $_G; $aid = $_GET['aid'] ? $_GET['aid'] : get_goods_id($_GET['itemid']); if ($aid && $aid < 1) { msg('抱歉ID不存在'); } if ($_GET['aid']) { $aid = intval($aid); $goods = D(array('and' => "aid = " . $aid, 'limit' => 1, 'all' => true, 'key' => 'goods_' . $aid)); } else { $goods = D(array('and' => "num_iid = '{$aid}'", 'limit' => 1, 'all' => true, 'key' => 'goods_' . $aid)); } if ($goods['status'] == 0 || $goods['status'] == 2) { msg('抱歉,当前商品 ' . $goods[status_text] . ' 暂时无法查看'); } if ($_G[mobile]) { $url = URL . 'a=go_pay&num_iid=' . $goods[num_iid]; _header("Location:" . $url); } $update = array(); if ($goods['aid'] > 0) { if (!$goods[keywords]) { $keyword = get_keywords($goods['title'] . $goods['ly']); if ($keyword) { $goods[keywords] = $keyword; $update[keywords] = $keyword; } } } if ($goods['fid']) { $channel = $_G['all_channel']['k' . $goods[fid]]; } $tpl = ''; if ($channel) { $tpl = trim($channel['goods_tpl']); } $_G['channel'] = $channel; if ($goods[fid]) { $_G[fid] = $goods[fid]; } if ($_G['setting']['get_message'] && !$goods['message']) { $message = top('m_taobao', 'get_message', $goods[num_iid]); if ($message) { $goods['message'] = $message; $update['message'] = $message; } } $up = D(array('and' => ' AND aid <' . $goods['aid'], 'table' => 'goods', 'order' => 'aid DESC')); $down = D(array('and' => ' AND aid >' . $goods['aid'], 'table' => 'goods', 'order' => 'aid ASC')); $goods[up] = $up[id] ? '<a href="' . $up[id_url] . '">' . $up[title] . '</a>' : '没有了'; $goods[down] = $down[id] ? '<a href="' . $down[id_url] . '">' . $down[title] . '</a>' : '没有了'; $this->add(array('goods' => $goods, 'up' => $up, 'down' => $down)); if ($goods['aid'] > 0 && $update) { $update[views] = $goods['views'] + 1; DB::update('goods', $update, 'aid=' . $goods['aid']); } save_history(__CLASS__, $goods['aid']); $title = $goods['seo_title'] ? $goods['seo_title'] : $goods['title']; seo($title, $goods['keywords'], $goods['description']); $this->show($tpl); }
public function run($subject_id, $clean = true, $query_offset = 0, $from, $to) { $this->load->helper('sphinxapi'); $this->load->helper('mood'); // skip if matching_status is "matching" $matching_status = $this->custom_model->get_value('subject', 'matching_status', $subject_id); if ($matching_status == 'matching') { echo "subject is matching"; return false; } // flag subject as matching.. do other bot runs this queue. //$this->db->update('subject',array('matching_status'=>'matching'),array('id'=>$subject_id)); // clear all match record for this subject $config['hostname'] = "192.168.1.102"; $config['username'] = "******"; $config['password'] = "******"; $config['database'] = "thothconnect"; $config['dbdriver'] = "mysql"; $config['dbprefix'] = ""; $config['pconnect'] = FALSE; $config['db_debug'] = TRUE; $config['cache_on'] = FALSE; $config['cachedir'] = ""; $config['char_set'] = "utf8"; $config['dbcollat'] = "utf8_general_ci"; $thothconnect_db = $this->load->database($config, true); $query = $this->db->query("SELECT client_id FROM subject WHERE id = " . $subject_id); $row = $query->row(); $client_id = $row->client_id; if ($clean) { $thothconnect_db->delete('website_c' . $client_id, array('subject_id' => $subject_id)); $thothconnect_db->delete('twitter_c' . $client_id, array('subject_id' => $subject_id)); $thothconnect_db->delete('facebook_c' . $client_id, array('subject_id' => $subject_id)); } // // begin re-matching this subject // // get search string from subject_id $query = $this->custom_model->get_value('subject', 'query', $subject_id); // sphinx init $cl = new SphinxClient(); $q = $query; $sql = ""; $mode = SPH_MATCH_EXTENDED; $host = "192.168.1.102"; $port = 9312; $index = "*"; $groupby = ""; $groupsort = "@group desc"; $filter = "group_id"; $filtervals = array(); $distinct = ""; $sortby = "@id ASC"; $sortexpr = ""; $offset = $query_offset; $limit = 1000000; $ranker = SPH_RANK_PROXIMITY_BM25; $select = ""; echo 'limit=' . $limit . ' offset=' . $offset . PHP_EOL; //Extract subject keyword from search string $keywords = get_keywords($q); //////////// // do query //////////// $cl->SetServer($host, $port); $cl->SetConnectTimeout(1); $cl->SetArrayResult(true); $cl->SetWeights(array(100, 1)); $cl->SetMatchMode($mode); // if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals ); // if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort ); if ($sortby) { $cl->SetSortMode(SPH_SORT_EXTENDED, $sortby); } // if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr ); if ($distinct) { $cl->SetGroupDistinct($distinct); } if ($select) { $cl->SetSelect($select); } if ($limit) { $cl->SetLimits(0, $limit, $limit > 1000000 ? $limit : 1000000); } $cl->SetRankingMode($ranker); $res = $cl->Query($q, $index); //$res = true; //////////// // do Insert to DB //////////// // Current matching $current_matching = array(); /*$query_matchs = $this->db->get_where('matchs',array('subject_id'=>$subject_id)); if($query_matchs->num_rows() > 0) { echo PHP_EOL.'currents matching :'.$query_matchs->num_rows(); foreach($query_matchs->result() as $match) { $current_matching[] = $match->post_id; } }*/ // set matching date range from-to $from = strtotime($from); $to = strtotime($to); // Search and Update if ($res === false) { echo "Query failed: " . $cl->GetLastError() . ".\n"; } else { if ($cl->GetLastWarning()) { echo "WARNING: " . $cl->GetLastWarning() . "\n\n"; } echo "Query '{$q}' \nretrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec.\n"; if ($res['total'] == 0) { echo "no result<br/>\n"; } else { if ($res['total'] > $limit + $offset) { $this->run($subject_id, $limit + $offset); } else { echo "Updating..."; foreach ($res["matches"] as $k => $docinfo) { // echo '('.$k.')'.$docinfo["id"]." "; // Reset PHP Timeout to 1min // if found in $current_matching then skip if (in_array($docinfo["id"], $current_matching)) { continue; } else { // else insert new match set_time_limit(60); $post = new Post_model(); $post->init($docinfo["id"]); // if post_date is our of range then skip $post_date = strtotime($post->post_date); if ($post_date < $from || $post_date > $to) { continue; } $mood = get_mood($post->body, $keywords); //----------------------------------------------------- $subject = $post->get_subject($subject_id); //print_r($subject); if ($post->type == "post" || $post->type == "comment") { $postData = $post->get_post_website($post->id); if ($postData != null) { $data = array(); $data["post_id"] = $postData->post_id; $data["post_date"] = $postData->post_date; $data["title"] = $postData->title; $data["body"] = $postData->body; $data["type"] = $postData->type; $data["author_id"] = $postData->author_id; $data["author"] = $postData->author; $data["website_id"] = $postData->website_id; $data["website_name"] = $postData->website_name; $data["website_cate_id"] = $postData->website_cate_id; $data["website_cate"] = $postData->website_cate; $data["website_type_id"] = $postData->website_type_id; $data["website_type"] = $postData->website_type; $data["group_id"] = $subject->group_id; $data["group"] = $subject->group; $data["url"] = substr($postData->root_url, 0, -1) . "" . $postData->url; $data["page_id"] = $postData->page_id; $data["subject_id"] = $subject->subject_id; $data["subject_name"] = $subject->subject_name; $data["mood"] = $mood; $data["mood_by"] = 'system'; $thothconnect_db->insert("website_c" . $subject->client_id, $data); $post->insert_post_comment($postData->page_id, $subject->client_id, $thothconnect_db); } } else { if ($post->type == "tweet" || $post->type == "retweet") { $postData = $post->get_post_twitter($post->id); if ($postData != null) { $data = array(); $data["post_id"] = $postData->post_id; $data["post_date"] = $postData->post_date; $data["body"] = $postData->body; $data["type"] = $postData->type; $data["author_id"] = $postData->author_id; $data["author"] = $postData->author; $data["group_id"] = $subject->group_id; $data["group"] = $subject->group; $data["tweet_id"] = $postData->tweet_id; $data["subject_id"] = $subject->subject_id; $data["subject_name"] = $subject->subject_name; $data["mood"] = $mood; $data["mood_by"] = 'system'; $thothconnect_db->insert("twitter_c" . $subject->client_id, $data); } } else { if ($post->type == "fb_post" || $post->type == "fb_comment") { $postData = $post->get_post_facebook($post->id); if ($postData != null) { $data = array(); $data["post_id"] = $postData->post_id; $data["post_date"] = $postData->post_date; $data["body"] = $postData->body; $data["type"] = $postData->type; $data["author_id"] = $postData->author_id; $data["author"] = $postData->author; $data["group_id"] = $subject->group_id; $data["group"] = $subject->group; $data["facebook_page_id"] = $postData->facebook_page_id; $data["facebook_page_name"] = $postData->facebook_page_name; $data["subject_id"] = $subject->subject_id; $data["subject_name"] = $subject->subject_name; $data["facebook_id"] = $postData->facebook_id; $data["parent_post_id"] = $postData->parent_post_id; $data["likes"] = $postData->likes; $data["shares"] = $postData->shares; $data["mood"] = $mood; $data["mood_by"] = 'system'; $thothconnect_db->insert("facebook_c" . $subject->client_id, $data); } } } } /* $data = array( 'post_id'=> $post->id, 'subject_id' => $subject_id , 'matching_date' => null, 'sentiment' => $mood, 'by' => 'system', 'system_correct' => $mood, 'system_correct_date' => mdate('%Y-%m-%d %H:%i',time()) ); $this->db->insert('matchs',$data); */ //--------------------------------------- } } } } } // flag subject as update.. $data = array('matching_status' => 'update', 'latest_matching' => mdate('%Y-%m-%d %H:%i:%s', time()), 'from' => mdate('%Y-%m-%d %H:%i:%s', $from), 'to' => mdate('%Y-%m-%d %H:%i:%s', $to)); $this->db->update('subject', $data, array('id' => $subject_id)); }
$idt[($dotpos = strpos($ri = $row['eid'], '.', TPLEN)) !== FALSE ? ('index.php?sid=' . urlencode(substr($ri, $dotpos+1)) . $th) : 'index.php'] = $indtxt; } require($phpDigIncCn); // switch to PhpDig DB if (($site_id = remove_engine_entries('http://' . $regs[1] .'/', $path = $regs[2] . '/', $sdisub ? 'index.php?sid=' . $sdisub . '_' : ''))) { echo '<table>', "\n"; foreach ($idt as $url => $text) { set_time_limit(30); // again 30 seconds from here on... index_words($site_id, $path, $url, get_first_words($text, $path, $url), get_keywords($text)); } echo '</table>', "\n"; } // possible enhancement: UPDATE spider record for still existing pages if(isset($db)) { //mysql_select_db($_configuration['main_database'], $db); Database::select_db($_configuration['main_database'], $db); } } elseif ($smo == get_lang('Index')) { echo 'Problem! PhpDig connect.php has gone or else URL "' . htmlspecialchars($mdObj->mdo_url, ENT_QUOTES, $charset) . '" is not like "http://xxxx/yyy.../zzz/index.php"';
{ echo '<table>', "\n"; echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset), '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset), '</td><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td></tr>'; echo '</table>', "\n"; } } elseif (isset($pu['scheme']) && $pu['scheme'] == 'mailto' && isset($pu['path'])) { if ($site_id = remove_engine_entries($url = 'mailto:' . $pu['path'], '')) { echo '<table>', "\n"; index_words($site_id, '', '', get_first_words($text, $url, ''), get_keywords($text)); echo '</table>', "\n"; } else { echo '<table>', "\n"; echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset), '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset), '</td><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td></tr>'; echo '</table>', "\n"; } } } if(isset($db)) {
?> <!doctype html> <html <?php language_attributes(); ?> > <head> <meta name="baidu-site-verification" content="MvIUbl5H4b"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta charset="<?php bloginfo('charset'); ?> "> <meta name="keywords" content="<?php echo get_keywords(); ?> "> <meta name="description" content="<?php echo get_description(); ?> "> <?php if (is_single()) { ?> <meta name="robots" content="nofollow"> <?php } ?> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php
function keywords() { global $_G; if (!$_GET['title'] && !$_GET['content']) { return json(array('status' => 'error', 'data' => '', 'msg' => '数据不能为空')); } $rt = get_keywords($_GET[title]); if ($rt == '' || !$rt) { return json(array('status' => 'error', 'data' => '', 'msg' => 'false')); } json(array('status' => 'success', 'data' => $rt, 'msg' => '')); }
function search() { $question = M('question'); $keywords = get_keywords($this->get['words']); $result_qid = array(); $seachwords = M('searchwords'); foreach ($keywords as $k => $v) { $qid = $seachwords->where(array('keywords' => $v))->select(); foreach ($qid as $k2 => $v2) { array_push($result_qid, $v2['qid']); } } $result_qid = array_count_values($result_qid); arsort($result_qid); $result_qid = array_keys($result_qid); $p = $this->get['p'] ? $this->get['p'] : 1; $page_arr = array_slice($result_qid, ($p - 1) * 10, 10); $count = count($result_qid); $Page = new Page($count, 10); $show = $Page->show(); $this->assign('page', $show); $question_list = $question->where(array('id' => array('in', $page_arr)))->select(); $newkeywords = array(); foreach ($keywords as $k => $v) { $newkeywords[$v] = '<span class="yellow">' . $v . '</span>'; } unset($keywords); $this->assign('top', '对“' . getsubstr($this->get['words'], 0, 12) . '”的搜索结果,共找到' . $count . '个结果,关键词已高亮显示'); $this->assign('keywords', $newkeywords); $this->assign('question_list', $question_list); $this->assign('title', '搜索结果'); $this->display(); }
} print $return; exit; } elseif (BRequest::getVar('call', false) == 'sr') { if (preg_match('/^[0-9]{1,20}$/i', BRequest::getVar('i', false)) && preg_match('/^[a-z]{4,20}$/i', BRequest::getVar('method', false))) { $return = pms_set_rating(); } else { $return = 0; } print $return; exit; } require_once ABSPATH . 'inc' . DS . 'func_index.php'; require_once ABSPATH . 'bin' . DS . 'XPM4' . DS . 'MAIL.php'; global $cl; $keywords = get_keywords(); // START META AND TITLE INFO FOR PAGE $meta_desc = '<meta name="description" content="' . SITE_DESC . ' - '; $meta_keywords = '<meta name="keywords" content="' . SITE_KEYWORDS . ' - '; $title = '<title>'; // CONTENT ENGINE $cl = new contentLogic(); // INITIALIZE THE MAIN ENGINE $main = new main(); // END META AND TITLE INFO FOR PAGE $meta_desc .= '" />' . "\n"; $meta_keywords .= '" />' . "\n"; $meta_keywords = '<meta name="keywords" content="' . $keywords . '" />'; $title .= SITE_TITLE . '</title>'; $meta = $meta_desc . $meta_keywords . $title; $content = $main->get_content();
public function run($subject_id, $clean = true, $query_offset = 0, $from, $to) { $this->load->helper('sphinxapi'); $this->load->helper('mood'); // skip if matching_status is "matching" $matching_status = $this->custom_model->get_value('subject', 'matching_status', $subject_id); if ($matching_status == 'matching') { echo "subject is matching"; return false; } // flag subject as matching.. do other bot runs this queue. $this->db->update('subject', array('matching_status' => 'matching'), array('id' => $subject_id)); // clear all match record for this subject if ($clean) { $this->db->delete('matchs', array('subject_id' => $subject_id)); } // // begin re-matching this subject // // get search string from subject_id $query = $this->custom_model->get_value('subject', 'query', $subject_id); // sphinx init $cl = new SphinxClient(); $q = $query; $sql = ""; $mode = SPH_MATCH_EXTENDED; $host = "192.168.1.102"; $port = 9312; $index = "*"; $groupby = ""; $groupsort = "@group desc"; $filter = "group_id"; $filtervals = array(); $distinct = ""; $sortby = "@id ASC"; $sortexpr = ""; $offset = $query_offset; $limit = 1000000; $ranker = SPH_RANK_PROXIMITY_BM25; $select = ""; echo 'limit=' . $limit . ' offset=' . $offset . PHP_EOL; //Extract subject keyword from search string $keywords = get_keywords($q); //////////// // do query //////////// $cl->SetServer($host, $port); $cl->SetConnectTimeout(1); $cl->SetArrayResult(true); $cl->SetWeights(array(100, 1)); $cl->SetMatchMode($mode); // if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals ); // if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort ); if ($sortby) { $cl->SetSortMode(SPH_SORT_EXTENDED, $sortby); } // if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr ); if ($distinct) { $cl->SetGroupDistinct($distinct); } if ($select) { $cl->SetSelect($select); } if ($limit) { $cl->SetLimits(0, $limit, $limit > 1000000 ? $limit : 1000000); } $cl->SetRankingMode($ranker); $res = $cl->Query($q, $index); //////////// // do Insert to DB //////////// // Current matching $current_matching = array(); $query_matchs = $this->db->get_where('matchs', array('subject_id' => $subject_id)); if ($query_matchs->num_rows() > 0) { echo PHP_EOL . 'currents matching :' . $query_matchs->num_rows(); foreach ($query_matchs->result() as $match) { $current_matching[] = $match->post_id; } } // set matching date range from-to $from = strtotime($from); $to = strtotime($to); // Search and Update if ($res === false) { echo "Query failed: " . $cl->GetLastError() . ".\n"; } else { if ($cl->GetLastWarning()) { echo "WARNING: " . $cl->GetLastWarning() . "\n\n"; } echo "Query '{$q}' \nretrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec.\n"; if ($res['total'] == 0) { echo "no result<br/>\n"; } else { if ($res['total'] > $limit + $offset) { $this->run($subject_id, $limit + $offset); } else { echo "Updating..."; foreach ($res["matches"] as $k => $docinfo) { // echo '('.$k.')'.$docinfo["id"]." "; // Reset PHP Timeout to 1min // if found in $current_matching then skip if (in_array($docinfo["id"], $current_matching)) { continue; } else { // else insert new match set_time_limit(60); $post = new Post_model(); $post->init($docinfo["id"]); // if post_date is our of range then skip $post_date = strtotime($post->post_date); if ($post_date < $from || $post_date > $to) { continue; } $mood = get_mood($post->body, $keywords); $data = array('post_id' => $post->id, 'subject_id' => $subject_id, 'matching_date' => null, 'sentiment' => $mood, 'by' => 'system', 'system_correct' => $mood, 'system_correct_date' => mdate('%Y-%m-%d %H:%i', time())); $this->db->insert('matchs', $data); } } } } } // flag subject as update.. $data = array('matching_status' => 'update', 'latest_matching' => mdate('%Y-%m-%d %H:%i:%s', time()), 'from' => mdate('%Y-%m-%d %H:%i:%s', $from), 'to' => mdate('%Y-%m-%d %H:%i:%s', $to), 'bot_id' => 0); $this->db->update('subject', $data, array('id' => $subject_id)); }
$offset = 0; //Check for offset, see if it's a multiple of the limit //This is done to stop arbitrary offsets being entered $offset = (int) $_REQUEST['offset']; if (isset($_REQUEST['save_keywords']) && isset($_REQUEST['new_keywords']) && isset($_REQUEST['page']) || isset($_REQUEST['remove_keywords']) && isset($_REQUEST['page'])) { ask_ticket('admin_keywords'); //Set page and new_keywords var for both remove_keywords and //save_keywords actions at the same time isset($_REQUEST['page']) ? $page = $_REQUEST['page'] : ($page = $_REQUEST['page']); isset($_REQUEST['new_keywords']) ? $new_keywords = $_REQUEST['new_keywords'] : ($new_keywords = ""); $update = set_keywords($page, $new_keywords); $update ? $smarty->assign('keywords_updated', 'y') : $smarty->assign('keywords_updated', 'n'); $smarty->assign('keywords_updated_on', $_REQUEST['page']); } if (isset($_REQUEST['page']) && !$_REQUEST['remove_keywords']) { $page_keywords = get_keywords($_REQUEST['page']); $smarty->assign('edit_keywords', $page_keywords['keywords']); $smarty->assign('edit_keywords_page', $page_keywords['pageName']); $smarty->assign('edit_on', 'y'); } if (isset($_REQUEST['q']) && !$_REQUEST['remove_keywords'] && !$_REQUEST['save_keywords']) { $existing_keywords = get_all_keywords($limit, $offset, $_REQUEST['q']); $smarty->assign('search_on', 'y'); $smarty->assign('search_cant', $existing_keywords['cant']); } if (!isset($existing_keywords['cant'])) { $existing_keywords = get_all_keywords($limit, $offset); } if ($existing_keywords['cant'] > 0) { $smarty->assign('existing_keywords', $existing_keywords['pages']); $pages_cant = ceil($existing_keywords['cant'] / $limit);
<?php require 'include/config.php'; require 'include/functions/main.php'; $popKeywords = get_keywords(); $dvd_file = make_file('DVD', 1, 'salesrank'); // offset by one hour, sort by salesrank $elc_file = make_file('Electronics', 2, 'salesrank'); // offset by 2 hours // MP3ダウンロード $searchIndex = 'DVD'; $keyword = urlencode('MP3ダウンロード'); $operation = 'ItemSearch'; $service = 'AWSECommerceService'; $version = '2011-08-01'; $responseGroup = 'ItemAttributes,Images'; $browseNode = 2129039051; // mp3 download $string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, 0, $browseNode); $signature = get_signature($string_to_sign); $request = $cg['amazonUrl'] . '?' . $string_to_sign; $request .= "&Signature=" . $signature; $mp3_file = make_file('mp3', 3, "salesrank", $request); // offset by 3 hours $books_file = make_file('Books', 4, 'salesrank'); // offset by 4 hours // Videogames $searchIndex = 'DVD'; // main category $keyword = urlencode('ゲームダウンロード'); // the subcategory name
<?php require 'include/config.php'; require 'include/functions/main.php'; $popKeywords = get_keywords(100); include $cg['viewdir'] . '/keyword_v.php';
<?php /** * 获取关键字接口 */ defined('IN_gxw') or exit('No permission resources.'); define('API_URL_GET_KEYWORDS', 'http://tool.gxw.cn/api/get_keywords.php'); $number = intval($_GET['number']); $data = $_POST['data']; echo get_keywords($data, $number); function get_keywords($data, $number = 3) { $data = trim(strip_tags($data)); if (empty($data)) { return ''; } $http = pc_base::load_sys_class('http'); if (CHARSET != 'utf-8') { $data = iconv('utf-8', CHARSET, $data); } else { $data = iconv('utf-8', 'gbk', $data); } $http->post(API_URL_GET_KEYWORDS, array('siteurl' => SITE_URL, 'charset' => CHARSET, 'data' => $data, 'number' => $number)); if ($http->is_ok()) { if (CHARSET != 'utf-8') { return $http->get_data(); } else { return iconv('gbk', 'utf-8', $http->get_data()); } } return '';
function insert($arr, $update = false) { global $_G; if (!$arr || !$arr['num_iid']) { return false; } $num_iid = trim($arr['num_iid']); $res = DB::fetch_first("SELECT aid FROM " . DB::table('goods') . " WHERE num_iid='{$num_iid}'"); if ($res[aid] > 0) { if ($update) { return $this->update($arr, $res['aid']); } else { return false; } } if ($arr['images'] && is_array($arr['images'])) { $arr['images'] = array_filter($arr['images']); $arr['images'] = implode(',', $arr['images']); } elseif (!$arr['images']) { $arr['images'] = ''; } $arr['sid'] = intval($arr['sid']); $arr['fid'] = intval($arr['fid']); $arr['flag'] = intval($arr['flag']); $arr['sort'] = intval($arr['sort']); $arr['num'] = intval($arr['num']); $arr['baoyou'] = intval($arr['baoyou']); $arr['views'] = intval($arr['views']); $arr['hide'] = intval($arr['hide']); $arr['post'] = intval($arr['post']); $arr['cate'] = intval($arr['cate']); $arr['check'] = intval($arr['check']); $arr['shop_type'] = intval($arr['shop_type']); $arr['sum'] = intval($arr['sum']); $arr['bili'] = $arr['bili'] ? $arr['bili'] : ''; $arr['apply_user'] = $arr['apply_user'] ? trim($arr['apply_user']) : ''; $arr['apply_phone'] = $arr['apply_phone'] ? trim($arr['apply_phone']) : ''; $arr['apply_wangwang'] = $arr['apply_wangwang'] ? trim($arr['apply_wangwang']) : ''; $arr['keywords'] = $arr['keywords'] ? trim($arr['keywords']) : ''; $arr['description'] = $arr['description'] ? trim($arr['description']) : ''; $arr['apply_qq'] = $arr['apply_qq'] ? trim($arr['apply_qq']) : ''; if ($arr['ly']) { $arr['ly'] = trim($arr['ly']); $arr['ly'] = strip_tags($arr['ly']); } $arr['return_msg'] = $arr['return_msg'] ? trim($arr['return_msg']) : ''; $arr['num_iid'] = $arr['num_iid'] ? trim($arr['num_iid']) : ''; $arr['title'] = $arr['title'] ? trim($arr['title']) : ''; $arr['nick'] = $arr['nick'] ? trim($arr['nick']) : ''; $arr['picurl'] = $arr['picurl'] ? trim($arr['picurl']) : $arr['images'][0]; $arr['url'] = 'http://item.taobao.com/item.htm?id=' . $arr['num_iid']; $arr['price'] = $arr['price'] ? sprintf("%.1f", $arr['price']) : 0; $arr['city'] = $arr['city'] ? trim($arr['city']) : ''; $arr['state'] = $arr['state'] ? trim($arr['state']) : ''; $arr['message'] = $arr['message'] ? trim($arr['message']) : ''; $arr['username'] = $_G['username'] ? trim($_G['username']) : '外星人'; $arr['uid'] = $_G['uid'] ? intval($_G['uid']) : 0; $arr['yh_price'] = $arr['yh_price'] ? sprintf("%.1f", $arr['yh_price']) : $arr['price']; $arr['start_time'] = dmktime($arr['start_time']); $arr['end_time'] = dmktime($arr['end_time']); $arr['dateline'] = $arr['dateline'] > 0 ? $arr['dateline'] : TIMESTAMP; $arr['posttime'] = $arr['posttime'] > 0 ? $arr['posttime'] : TIMESTAMP; $arr['like'] = intval($arr[like]); $arr['open_iid'] = $arr['open_iid'] ? trim($arr['open_iid']) : ''; $arr['title'] = trim_html($arr['title'], 1); $arr['title'] = cutstr($arr['title'], 250, ''); $arr['ly'] = cutstr($arr['ly'], 250, ''); $arr['return_msg'] = cutstr($arr['return_msg'], 250, ''); unset($arr['zk']); if (!$arr['keywords'] && $_G[setting][auto_keywords] == 1) { $arr['keywords'] = get_keywords($arr['title']); } try { $id = DB::insert('goods', $arr, 1); } catch (PDOException $e) { L('商品ID重复', 'error'); return false; } if ($id > 0) { $arr['aid'] = $id; api_post(array('a' => 'insert', 'table' => 'goods', 'data' => $arr)); } return $id; }
} } } if ($th == '' && ($sclvl = strpos($indtxt, 'scorm-level-')) !== false) { $th = '&thumb=scorm-level-' . $indtxt[$sclvl + 12] . '.jpg'; } $idt[($dotpos = strpos($ri = $row['eid'], '.', TPLEN)) !== false ? 'index.php?sid=' . urlencode(substr($ri, $dotpos + 1)) . $th : 'index.php'] = $indtxt; } require $phpDigIncCn; // switch to PhpDig DB if ($site_id = remove_engine_entries('http://' . $regs[1] . '/', $path = $regs[2] . '/', $sdisub ? 'index.php?sid=' . $sdisub . '_' : '')) { echo '<table>', "\n"; foreach ($idt as $url => $text) { set_time_limit(30); // again 30 seconds from here on... index_words($site_id, $path, $url, get_first_words($text, $path, $url), get_keywords($text)); } echo '</table>', "\n"; } // possible enhancement: UPDATE spider record for still existing pages if (isset($db)) { //mysql_select_db($_configuration['main_database'], $db); Database::select_db($_configuration['main_database'], $db); } } elseif ($smo == get_lang('Index')) { echo 'Problem! PhpDig connect.php has gone or else URL "' . htmlspecialchars($mdObj->mdo_url, ENT_QUOTES, $charset) . '" is not like "http://xxxx/yyy.../zzz/index.php"'; } } // STATISTICS -----------------------------------------------------------------> echo '<h3>', get_lang('Statistics'), '</h3>', "\n"; $result = $mdStore->mds_get_many('eid', "eid LIKE '" . EID_TYPE . ".%'");
function pms_meta() { global $meta_desc, $meta_keywords, $title; require_once ABSPATH . '/inc/keywords.php'; // KEYWORD ARRAY $keywords = get_keywords(); // START META AND TITLE INFO FOR PAGE $meta_desc = '<meta name="description" content="' . SITE_DESC . ' - '; $title = '<title>'; do_action('meta'); // END META AND TITLE INFO FOR PAGE $meta_desc .= '" />' . "\n"; $meta_keywords = '<meta name="keywords" content="' . $keywords . SITE_KEYWORDS . '" />'; $title .= SITE_TITLE . '</title>'; $meta = $meta_desc . $meta_keywords . $title; return $meta; }
function post() { global $_G; $goods = get_filed(__CLASS__); $page = $_G[page] > 1 ? '&page=' . $_G[page] : ''; $field = array(); if ($_GET['onsubmit'] && check()) { //发布商品 $arr = array(); $arr = get_filed(__CLASS__, $_GET['postdb'], $_GET['aid']); $arr['images'] = $_GET['images']; $aid = ''; $url = '&fid=' . $arr['fid']; $msg = '发布'; if ($_FILES[file]) { $src = upload(); if ($src) { $arr[picurl] = $src; } } if ($_GET['aid']) { $aid = intval($_GET['aid']); $url = '&aid=' . $aid; $msg = '修改'; $id = top('goods', 'update', $arr, $aid); } else { $id = top('goods', 'insert', $arr); $url .= '&aid=' . $id; } if (CURMODULE == 'goods') { $ext = "<p><a href='" . URL . "m=goods&a=post&fid=" . $arr['fid'] . $page . "'>继续发布</a> "; $ext .= "<a href='" . URL . "m=goods&a=main" . $page . "'>返回列表页</a> "; $ext .= "<a href='" . URL . "m=goods&a=main&fid=" . $arr[fid] . $page . "'>返回栏目列表页</a>"; } elseif (CURMODULE == 'apply') { $ext .= "<a href='" . URL . "m=apply&a=main" . $page . "'>返回待审核列表</a> "; } $ext .= "</p>"; if ($id === false) { cpmsg('发布失败,不能重复发布同一商品', 'error', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . '&fid=' . $_G[fid]); } else { cpmsg($msg . '成功', 'success', 'm=' . CURMODULE . '&a=' . __FUNCTION__ . $url, '编辑此商品', $ext); } return false; } elseif ($_GET['get_submit'] && check() && $_GET['goods_id']) { //提交ID采集商品 $goods_id = get_goods_id($_GET['goods_id']); if (!$goods_id) { cpmsg('抓取失败,商品ID或链接不存在或填写错误', 'error', 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } if ($_GET['goods_aid'] > 0) { $goods = D(array('and' => " AND aid = " . intval($_GET['goods_aid']), 'limit' => 1, 'all' => true)); } $gd = top('goods', 'get_goods', $goods_id); $gd[goods_id] = $goods_id; //上线-下线时间默认为5天 $tomorrow2 = dmktime(dgmdate(TIMESTAMP + 86400, 'd') . ' 10:00'); $tomorrow5 = dmktime(dgmdate(TIMESTAMP + 86400 * 6, 'd') . ' 10:00'); $goods['start_time'] = dgmdate($tomorrow2, 'dt'); $goods['end_time'] = dgmdate($tomorrow5, 'dt'); $goods['keywords'] = get_keywords($goods['title']); if ($gd['yh_price'] != $gd['price'] && $gd['yh_price'] && $gd['price']) { $gd[zhekou_shu] = sprintf("%.1f", $gd['yh_price'] / $gd['price'] * 10); } foreach ($gd as $k => $v) { $goods[$k] = $v; } if (!$goods[yh_price]) { echo '<h1 class="admin_msg">商品优惠价格采集失败,请注意手动填写</h1>'; } } elseif ($_GET['aid']) { $aid = intval($_GET['aid']); $gd = D(array('and' => " AND aid = " . $aid, 'limit' => 1, 'all' => true)); if (!$gd[aid]) { cpmsg('抱歉,未找到任何信息', 'error'); return false; } $_GET['goods_id'] = $gd['num_iid']; foreach ($gd as $k => $v) { $goods[$k] = $v; } if ($_G['setting']['get_message'] && !$goods['message']) { $message = top('m_taobao', 'get_message', $goods[num_iid]); if ($message) { $goods['message'] = $message; } } } else { $_GET[goods_id] = ''; $goods = get_filed(__CLASS__); //上线-下线时间默认为5天 $tomorrow2 = dmktime(dgmdate(TIMESTAMP + 86400, 'd') . ' 10:00'); $tomorrow5 = dmktime(dgmdate(TIMESTAMP + 86400 * 6, 'd') . ' 10:00'); $goods['start_time'] = dgmdate($tomorrow2, 'dt'); $goods['end_time'] = dgmdate($tomorrow5, 'dt'); } if ($_G[setting][bm_status_text]) { if (!is_array($_G[setting][bm_status_text])) { $bm_status_text = array(); $tmp = explode("\r\n", $_G[setting][bm_status_text]); foreach ($tmp as $k => $v) { $v = explode("|", $v); $bm_status_text[$v[0]] = array('status' => $v[0], 'name' => $v[1], 'content' => $v[2]); } } else { $bm_status_text = $_G[setting][bm_status_text]; } } $this->add(array('goods' => $goods, 'field' => $field, 'bm_status_text' => $bm_status_text)); $tpl = ''; if (!$_GET[fid] && !$_GET['aid']) { $tpl = "goods/select_post"; } $this->show($tpl); }
function post() { global $_G; if ($_GET['onsubmit']) { $img = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']); $img['hide'] = intval($img['hide']); $img['sort'] = intval($img['sort']); $img['like'] = intval($img['like']); $img['hate'] = intval($img['hate']); if ($_FILES[file]) { $src = upload(); if ($src) { $img[picurl] = $src; } } if (!$img['keywords'] && $_G[setting][auto_keywords] == 1) { $img['keywords'] = get_keywords($img['title']); } if (preg_match("/^[0-9\\.]+\$/is", $img[description])) { $img[description] = ''; } if (!$img[description]) { $tmp = preg_replace("/###\\{(.*?)\\}###/is", '', $img[message]); $img[description] = trim(cutstr(trim_html($tmp), 250, '')); } if (!$img[picurl] && preg_match("/<img.*?src=\"http:(.*?)\"/is", $img[message], $img_arr)) { if ($img_arr[1]) { $img[picurl] = "http:" . $img_arr[1]; } } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $img, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; } else { $msg = '发布'; $img['dateline'] = TIMESTAMP; if (!$img[description]) { $img[description] = cutstr(trim_html($img[message]), 250, ''); } $r = DB::insert(__CLASS__, $img, true); } cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); return false; } elseif ($_GET['id']) { $id = intval($_GET['id']); $img = DB::fetch_first("SELECT * FROM " . DB::table("img") . " WHERE id = " . $id); $img = dstripcslashes($img); } else { $img = get_filed(__CLASS__); } $this->add(array('img' => $img)); $this->show(); }
function spider_keywords($data) { return get_keywords($data); }
function post() { global $_G; if ($_GET['onsubmit']) { //dump($_GET,1); $article = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']); $article['hide'] = intval($article['hide']); $article['sort'] = intval($article['sort']); $article['cate'] = intval($article['cate']); $article['views'] = intval($article['views']); if ($_FILES[file]) { $src = upload(); if ($src) { $article[picurl] = $src; } } if (!$article['keywords'] && $_G[setting][auto_keywords] == 1) { $article['keywords'] = get_keywords($article['title']); } if (!$article[description]) { $article[description] = cutstr(trim_html($article[message], 1), 250, ''); } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $article, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; api_post(array('a' => 'update', 'table' => 'article', 'data' => $article, 'pre_key' => 'id', 'id' => $id)); } else { $msg = '发布'; $article['dateline'] = TIMESTAMP; $r = DB::insert(__CLASS__, $article, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'article', 'data' => $article, 'id' => $r)); } } cpmsg($msg . '成功', 'success'); return false; } elseif ($_GET['id']) { $id = intval($_GET['id']); $article = DB::fetch_first("SELECT * FROM " . DB::table("article") . " WHERE id = " . $id); $article = dstripcslashes($article); } else { if (!$_GET[cate]) { $cate = $_G[__CLASS__ . '_cate']; $this->add(array('cate' => $cate)); $this->show('common_admin/select_post'); return; } else { $article = get_filed(__CLASS__); } } $this->add(array('article' => $article)); $this->show(); }