function dodefault() { $len = strlen('plugin-momo-momo-default-'); $title = substr($_SERVER['QUERY_STRING'], $len); $title = urldecode($title); $title = trim($title); $title2 = $title; $title = urldecode($title); if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') { $title = string::hiconv($title, $to = 'gbk', $from = 'utf-8'); } $doc = $_ENV['momo']->get_doc_by_title($title); if ($doc) { $doc['image'] = util::getfirstimg($doc['content']); $momourl = trim($this->plugin[momo][vars][momourl]); if ($momourl) { $doc['url'] = $momourl . "index.php?doc-view-" . $doc['did'] . $this->setting['seo_suffix']; } else { $doc['url'] = $this->setting['site_url'] . "/" . $this->setting['seo_prefix'] . "doc-view-" . $doc['did'] . $this->setting['seo_suffix']; } $doc_exists = 1; } else { $url = 'http://www.hudong.com/validateDocSummary.do?doc_title=' . $title2; $data = util::hfopen($url); $doc_exists = 1; if ($data && stripos($data, '<flag>true</flag>') && preg_match_all("/<\\!\\[CDATA\\[(.*)\\]\\]>/", $data, $matches)) { $summary = $matches[1][1]; $image = $matches[1][2]; if ($summary == 'null') { $summary = ''; } if ($image == 'null') { $image = ''; } if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') { $summary = string::hiconv($summary, $to = 'gbk', $from = 'utf-8'); } $doc = array('image' => $image, 'url' => 'http://www.hudong.com/wiki/' . $title, 'summary' => $summary); } else { $doc_exists = 0; } } $this->view->assign("doc_exists", $doc_exists); $this->view->assign("doc", $doc); $this->view->assign("encode", WIKI_CHARSET); $this->view->assign("title", $title); $this->view->display('file://plugins/momo/view/momo'); }
function edit_feed($doc) { $isimg = util::getfirstimg($doc[content]); if (false !== strpos($isimg, "http://")) { $img = empty($isimg) ? "" : $isimg; } else { $img = empty($isimg) ? "" : WIKI_URL . "/" . $isimg; } $feed = unserialize($this->base->setting[feed]); $uid = $this->base->user[uid]; if (@in_array("edit", $feed)) { $feed = array(); $feed["icon"] = "post"; $feed["type"] = "edit"; $feed["title_data"] = array("title" => "<a href=\\\"" . WIKI_URL . "/{$this->base->setting[seo_prefix]}doc-view-{$doc['did']}{$this->base->setting[seo_suffix]}\\\">{$doc['title']}</a>", "author" => "<a href=\\\"space.php?uid={$uid}\\\">{$this->base->user['username']}</a>", "app" => $this->base->setting["site_name"]); $feed["body_data"] = array("subject" => "<a href=\\\"" . WIKI_URL . "/{$this->base->setting[seo_prefix]}doc-view-{$doc['did']}{$this->base->setting[seo_suffix]}\\\">{$doc['title']}</a>", "message" => $doc["summary"]); $feed["images"][] = array("url" => "{$img}", "link" => WIKI_URL . "/{$this->base->setting[seo_prefix]}doc-view-{$doc['did']}{$this->base->setting[seo_suffix]}"); $this->postfeed($feed); } }
function doupdateimg() { if (!empty($this->post['did']) && is_array($this->post['did'])) { foreach ($this->post['did'] as $did) { $doc = $this->db->fetch_by_field('doc', 'did', $did); if (is_array($doc)) { $img = $_ENV['doc']->setfocusimg(util::getfirstimg($doc['content'])); if ($img != '') { $doc = $this->db->update_field('focus', 'image', $img, "did={$did}"); } } } } $this->cache->removecache('data_' . $GLOBALS['theme'] . '_index'); if (isset($this->get[2])) { $searchdata = $this->get[2]; $searchdata = str_replace(',', '-', $searchdata); $this->header(urldecode($searchdata)); } else { $this->header("admin_focus-focuslist"); } }
function set_focus_doc($dids, $doctype) { $doclist = $this->get_doc_by_ids($dids); foreach ($doclist as $key => $doc) { $title = string::haddslashes($doc['rawtitle'], 1); $tag = string::haddslashes($this->jointags($doc['tag']), 1); if ($doctype == 2) { $summary = trim(string::convercharacter(string::substring(strip_tags($doc['content']), 0, 30))); } elseif ($doctype == 3) { $summary = trim(string::convercharacter(string::substring(strip_tags($doc['content']), 0, 80))); } else { $summary = trim(string::convercharacter(string::substring(strip_tags($doc['content']), 0, 100))); } $summary = string::haddslashes($summary, 1); $image = $this->setfocusimg(util::getfirstimg($doc['content'])); $this->db->query("REPLACE INTO " . DB_TABLEPRE . "focus (did,title,tag,summary,image,time,type)VALUES (" . $doc['did'] . ",'{$title}','{$tag}','{$summary}','{$image}','" . $this->base->time . "','{$doctype}')"); } return true; }
function dosummary() { $count = count($this->get); @($title = $this->get[2]); for ($i = 3; $i < $count; $i++) { $title .= '-' . $this->get[$i]; } $title = trim($title); $title2 = $title; $title = urldecode($title); if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') { $title = string::hiconv($title, $to = 'gbk', $from = 'utf-8'); } $doc = $this->db->fetch_by_field('doc', 'title', addslashes($title)); if ((bool) $doc) { $doc['image'] = util::getfirstimg($doc['content']); $doc['url'] = WIKI_URL . "/" . $this->setting['seo_prefix'] . "doc-view-" . $doc['did'] . $this->setting['seo_suffix']; $doc_exists = 1; } else { $url = 'http://www.hudong.com/validateDocSummary.do?doc_title=' . $title2; $data = util::hfopen($url); $doc_exists = 1; if ($data && stripos($data, '<flag>true</flag>') && preg_match_all("/<\\!\\[CDATA\\[(.*)\\]\\]>/", $data, $matches)) { $summary = $matches[1][1]; $image = $matches[1][2]; if ($summary == 'null') { $summary = ''; } if ($image == 'null') { $image = ''; } $doc = array('image' => $image, 'url' => 'http://www.hudong.com/wiki/' . $title2, 'summary' => $summary); } else { $doc_exists = 0; } } $this->view->assign("doc_exists", $doc_exists); $this->view->assign("doc", $doc); $this->view->assign("encode", WIKI_CHARSET); $this->view->assign("title", $title); //$this->view->display('hdmomo'); $_ENV['block']->view('hdmomo'); }
function getfirstimg(&$content) { $doc_firstimg = util::getfirstimg($content); if (!empty($doc_firstimg)) { if (stripos($doc_firstimg, "http") !== false) { $doc_firstimg = '<img src="' . $doc_firstimg . '" class="firstimg" alt="" />'; } else { $doc_firstimg = '<img src="' . WIKI_URL . '/' . $doc_firstimg . '" class="firstimg" alt="" />'; } } return $doc_firstimg; }