Exemplo n.º 1
0
 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');
 }
Exemplo n.º 2
0
 function dostand()
 {
     $stand = $this->cache->getcache('stand', $this->cache_time);
     if (!(bool) $stand) {
         $stand = array();
         $doc_num = $_ENV['statistics']->count_num('doc');
         $edition_num = $_ENV['statistics']->count_num('edition');
         $user_day_num = ($this->time - $_ENV['statistics']->first_register_time()) / (24 * 3600);
         $doc_num = $doc_num > 1 ? $doc_num : 1;
         $user_day_num = $user_day_num > 1 ? $user_day_num : 1;
         $doc_day_num = ($this->time - $_ENV['statistics']->first_create_time()) / (24 * 3600);
         $stand['register'] = $_ENV['statistics']->count_num('user');
         $stand['register'] = $stand['register'] > 1 ? $stand['register'] : 1;
         $stand['edit_user'] = $_ENV['statistics']->count_num("user", "creates<>0 or edits<>0");
         $stand['manage_user'] = $_ENV['statistics']->count_num("user", "groupid=3 or groupid=4");
         $stand['unedit_user'] = $stand['register'] - $stand['edit_user'];
         $stand['new_user'] = $_ENV['statistics']->new_user();
         $stand['edit_user_percent'] = round($stand['edit_user'] * 100 / $stand['register'], 2) . "%";
         $stand['star_today'] = $_ENV['statistics']->star_today();
         $stand['average_edition'] = round($edition_num / $stand['register'], 2);
         $stand['category_num'] = $_ENV['statistics']->count_num('category');
         $stand['average_day_doc'] = round($doc_num / $user_day_num, 2);
         $stand['hot_category'] = $_ENV['statistics']->hot_category();
         $stand['create_doc_num'] = $doc_num;
         $stand['average_day_user'] = round($stand['register'] / $user_day_num, 2);
         $stand['doc_comment_num'] = $_ENV['statistics']->count_num('comment');
         $stand['edition_num'] = $edition_num;
         $stand['day_recent_doc'] = $_ENV['statistics']->count_num("doc", "time >= " . ($this->time - 3600 * 24));
         $stand['average_doc_edition'] = $doc_num ? round($edition_num / $doc_num, 2) : $doc_num;
         $stand['day_recent_user'] = $_ENV['statistics']->count_num("user", "regtime >= " . ($this->time - 3600 * 24));
         $stand['activity_index'] = ($stand['unedit_user'] ? round($stand['edit_user'] * 100 / $stand['register'], 2) : $stand['unedit_user']) . "%";
         $stand['last_cache_time'] = $this->date($this->time);
         $stand['cache_time'] = $this->date($this->time + $this->cache_time);
         $this->cache->writecache('stand', $stand);
     }
     //统计信息
     if ($this->setting['wk_count']) {
         $wk_count = unserialize($this->setting['wk_count']);
         $count = @util::hfopen('http://kaiyuan.hudong.com/count2/count.php?m=count&a=getcount&key=' . $wk_count['key'], 0);
         if ($count) {
             $count = explode('|', $count);
             $this->view->assign('count', $count);
         }
     }
     $this->view->assign('stand', $stand);
     $this->view->display('admin_stand');
 }
Exemplo n.º 3
0
 function doinstall()
 {
     $appid = $this->get[2];
     if (is_numeric($appid)) {
         $pluginurl = $this->setting['app_url'] . '/hdapp.php?action=download&type=plugin&install=1&id=' . $appid . '&url=' . urlencode(WIKI_URL);
         $zipcontent = @util::hfopen($pluginurl);
         if (empty($zipcontent)) {
             $this->message($this->view->lang['msgConnectFailed']);
         }
         $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
         file::writetofile($tmpname, $zipcontent);
         if (function_exists('gzopen')) {
             require HDWIKI_ROOT . "/lib/zip.class.php";
             $zip = new zip();
             if (!$zip->chk_zip) {
                 $this->message($this->view->lang['pluginInstallNoZlib'], '');
             }
             $ziplist = @$zip->get_List($tmpname);
             if (!(bool) $ziplist) {
                 unlink($tmpname);
                 $this->message($this->view->lang['pluginAddr'] . $pluginurl . $this->view->lang['pluginAddrFail']);
             }
             $lastpos = strpos($ziplist[0]['filename'], '/');
             $identifier = substr($ziplist[0]['filename'], 0, $lastpos);
             @$zip->Extract($tmpname, HDWIKI_ROOT . '/plugins');
         } else {
             $this->message($this->view->lang['pluginInstallNoZlib']);
         }
         unlink($tmpname);
     } else {
         $identifier = $this->get[2];
     }
     $plugin = $this->db->fetch_by_field('plugin', 'identifier', $identifier);
     if ($plugin) {
         $this->message($this->view->lang['pluginAddrName'] . $identifier . $this->view->lang['pluginHasInstall'], 'index.php?admin_plugin-list');
     }
     $this->loadplugin($identifier);
     $plugin = $_ENV["{$identifier}"]->install();
     $_ENV['plugin']->add_plugin($plugin);
     $this->cache->removecache('plugin');
     $this->message($this->view->lang['pluginInstallSuccess'], 'index.php?admin_plugin-list');
 }
Exemplo n.º 4
0
 function hfopen($url, $limit = 0, $post = '', $timeout = 27)
 {
     if ($this->api_error == 'timeout') {
         return '';
     }
     $t = time();
     $data = util::hfopen($url, $limit, $post, $cookie, FALSE, '', $timeout);
     $t = time() - $t;
     $data = trim($data);
     $this->setLog('time:' . $url, 'time:' . $t);
     if ($t >= $timeout) {
         $this->api_error = 'timeout';
         $this->cache->writecache('hdapi_timeout', array('timeout'));
         $data = '';
         $this->setLog('error:' . $url, 'timeout:' . $t);
     } elseif (!empty($data) && substr($data, 0, 5) != '<?xml' && substr($data, 0, 1) != '{') {
         $this->setLog('error:' . $url, $data . $post);
         $data = '';
     } else {
         $this->setLog($url, $data . $post);
         $this->cache->writecache('hdapi_timeout', array('ok'));
     }
     return $data;
 }
Exemplo n.º 5
0
 function clode_register()
 {
     $privateip = util::is_private_ip();
     if (!$privateip) {
         $jsondata = $this->get_jason_data(array());
         // 发送数据
         $timeout = isset($this->setting['cloud_search_timeout']) ? $this->setting['cloud_search_timeout'] : 5;
         $flag = util::hfopen(CLOUD_REGISTER_URL, '', $jsondata, '', '', '', $timeout);
     }
     if (empty($flag) || $privateip) {
         // 关闭云搜索
         $this->db->query("REPLACE INTO `" . DB_TABLEPRE . "setting` (`variable`, `value`) values ('cloud_search', '0')");
     }
     return $flag;
 }
Exemplo n.º 6
0
 function _get_key($domain)
 {
     $key = '';
     if ($domain) {
         $key = @util::hfopen('http://kaiyuan.hudong.com/count2/count.php?m=count&a=getkey&domain=' . $domain, 0);
     }
     return $key;
 }
Exemplo n.º 7
0
 function dologin()
 {
     @header('Content-type: text/html; charset=' . WIKI_CHARSET);
     $json = '';
     $arr = array();
     if (!isset($this->post['action'])) {
         exit('error');
     }
     $arr['type'] = $this->post['action'];
     $arr['email'] = $this->post['email'];
     $arr['password'] = strtoupper(md5($this->post['pwd']));
     $arr['sitedomain'] = $this->post['sitedomain'];
     $arr['wikiurl'] = str_replace('plugin-hdapi-admin_hdapi.html', '', $this->post['wikiurl']);
     if ('register' == $this->post['action']) {
         $arr['user_nick'] = $this->form('usernick');
         $arr['username'] = $this->form('name');
         $arr['siteremark'] = $this->form('sitename');
         $arr['userqq'] = $this->post['qq'];
         $arr['usermsn'] = $this->post['msn'];
         $arr['userphone'] = $this->post['tel'];
     }
     $json = $this->tojson($arr);
     $url = 'http://api.hudong.com/siteouteractive.do?json=' . $json;
     $data = util::hfopen($url);
     $json = base64_encode($data);
     $obj = $this->unjson($data);
     if ($obj->success == true) {
         //登录或注册成功,更新插件变量信息
         //并将usernick提交给安装统计
         //将信息传给统计列表程序
         $url2 = 'http://kaiyuan.hudong.com/count2/in.php?action=update&sitedomain=' . $arr['sitedomain'] . '&json=' . $json;
         $data = util::hfopen($url2);
         $pluginid = $this->get_pluginid();
         $a = array('sitenick' => $obj->site_nick, 'usernick' => $obj->site_nick, 'sitekey' => $obj->key);
         $_ENV['plugin']->update_pluginvar($a, $pluginid);
         //清理缓存
         $this->cache->removecache('plugin');
         echo 'OK';
     } else {
         //登录失败
         echo $obj->error_code;
     }
 }
Exemplo n.º 8
0
 function get_available_packages($get_first = false)
 {
     $packages = @util::hfopen($this->get_api_url('getlist'));
     $packages = @unserialize($packages);
     if ($get_first) {
         if (count($packages) > 0) {
             $first = each($packages);
             $first['value']['release_code'] = $first['key'];
             return $first['value'];
         } else {
             return array();
         }
     } else {
         return is_array($packages) ? $packages : false;
     }
 }
Exemplo n.º 9
0
 function get($name, $expires = 0)
 {
     $file = $this->dir . $name . '.php';
     if (!file_exists($file)) {
         $data = util::hfopen($this->url_cache . rawurlencode($name) . '.php');
         if ($data) {
             file::forcemkdir($this->dir);
             $flag = file::writetofile($this->dir . $name . '.php', $data);
         } else {
             return '';
         }
     }
     if (file_exists($file)) {
         $data = file::readfromfile($file);
         $data = str_replace($this->phpexit, '', $data);
         return unserialize(base64_decode($data));
     } else {
         return '';
     }
 }
Exemplo n.º 10
0
             runquery($sql);
         }
     }
     copydir(HDWIKI_ROOT . '/install/testdata/201007', HDWIKI_ROOT . '/uploads/201007');
     copydir(HDWIKI_ROOT . '/install/testdata/201008', HDWIKI_ROOT . '/uploads/201008');
 }
 @touch(HDWIKI_ROOT . '/data/install.lock');
 $info['type'] = 1;
 $info['sitedomain'] = $_SERVER['SERVER_NAME'];
 $info['siteaddress'] = $site_url;
 $info['version'] = HDWIKI_VERSION . HDWIKI_RELEASE . $lang['commonCharset'];
 $info = base64_encode(serialize($info));
 //install count
 require_once HDWIKI_ROOT . '/config.php';
 require_once HDWIKI_ROOT . '/lib/util.class.php';
 @util::hfopen('http://kaiyuan.hudong.com/count2/in.php?action=install', 0, 'info=' . urlencode($info));
 $str = "<div id=\"wrapper1\"><span style=\"color:red\">{$lang['stepSetupSuccessTip']}</span><a href='../index.php'>{$lang['stepSetupGoTOIndex']}</a></div>";
 $str .= '<iframe id="count" name="count" src="http://kaiyuan.hudong.com/count2/interface.php?info=' . $info . '" scrolling="no" width="455" style="height:370px" frameborder="0"></iframe>';
 break;
 /*
 case 8:
 	require_once HDWIKI_ROOT.'/config.php';
 	require_once HDWIKI_ROOT.'/lib/hddb.class.php';
 	require_once HDWIKI_ROOT.'/lib/util.class.php';
 	require_once HDWIKI_ROOT.'/lib/string.class.php';
 	
 	$db = new hddb(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_CHARSET);
 	//install 
 	$setting=$db->result_first('select `value` from '.DB_TABLEPRE.'setting WHERE `variable` = \'site_appkey\'');
 	if ($setting){
 		echo "<span style='font-size:20px;'>百科联盟开通成功.</span><a href='../'>进入首页</a>";
Exemplo n.º 11
0
 function dodiary()
 {
     $adminmaindiary = $this->cache->getcache('adminmaindiary', 3600 * 25);
     //if (!empty($adminmaindiary)) return '';
     $this->load('statistics');
     $this->setting['app_url'] = 'http://localhost';
     $url = $this->setting['app_url'] . base64_decode('L2NvdW50Mi9kaWFyeS5waHA=');
     $post = array();
     $post['domain'] = WIKI_URL;
     $post['lasttime'] = $this->time;
     $post['sitename'] = $this->setting['site_name'];
     $postquery = $_ENV['statistics']->http_array($post);
     $this->cache->writecache('adminmaindiary', date('d'));
     die(util::hfopen($url, 0, $postquery));
 }
Exemplo n.º 12
0
 function setfocusimg($img)
 {
     if ('' == $img) {
         return '';
     }
     if (substr($img, 0, strlen(WIKI_URL)) == WIKI_URL) {
         $img = substr($img, strlen(WIKI_URL) + 1);
     }
     if ("http://" == substr($img, 0, 7) && substr($img, 0, strlen(WIKI_URL)) != WIKI_URL) {
         $tmpname = 'uploads/' . date("Ym") . "/" . util::random() . '.' . file::extname($img);
         if ($pic_content = @util::hfopen($img)) {
             file::forcemkdir(dirname($tmpname));
             if (file::writetofile($tmpname, $pic_content)) {
                 $img = $tmpname;
             }
         }
     }
     $compress = util::image_compress($img, 's_f_', 100, 75);
     if (!$compress['result']) {
         return '';
     }
     util::image_compress($img, 'f_', 152, 114);
     @unlink($tmpname);
     return $compress['tempurl'];
 }
Exemplo n.º 13
0
 function doinstall()
 {
     if (isset($this->get[2]) && is_numeric($this->get[2])) {
         $style_download_url = $this->setting['app_url'] . "/hdapp.php?action=download&type=template&install=1&id=" . $this->get[2] . "&url=" . WIKI_URL;
         $zipcontent = @util::hfopen($style_download_url);
         $tmpdir = HDWIKI_ROOT . '/data/tmp/';
         file::forcemkdir($tmpdir);
         $tmpname = $tmpdir . util::random(6) . '.zip';
         file::writetofile($tmpname, $zipcontent);
         require HDWIKI_ROOT . "/lib/zip.class.php";
         require HDWIKI_ROOT . "/lib/xmlparser.class.php";
         $zip = new zip();
         if (!$zip->chk_zip) {
             $this->message($this->view->lang['styleInstallNoZlib'], '');
         }
         $ziplist = @$zip->get_List($tmpname);
         if (!(bool) $ziplist) {
             @unlink($tmpname);
             $this->message($this->view->lang['styleZipFail'], 'BACK');
         }
         $theme_name = $_ENV['theme']->get_theme_name($ziplist);
         @$zip->Extract($tmpname, $tmpdir);
         @unlink($tmpname);
         //move file
         $syle_path = $tmpdir . 'hdwiki';
         if (is_dir(HDWIKI_ROOT . '/style/' . $theme_name)) {
             @file::removedir($syle_path);
             $this->message($this->view->lang['stylePathRepeat'], 'BACK');
         }
         @file::copydir($syle_path, HDWIKI_ROOT);
         @file::removedir($syle_path);
         //save db
         $style_xml = HDWIKI_ROOT . '/style/' . $theme_name . '/desc.xml';
         if (!is_file($style_xml)) {
             $this->message($this->view->lang['styleXmlNotExist'], 'BACK');
         }
         $xmlnav = $_ENV['theme']->read_xml($theme_name);
         $style['name'] = $xmlnav['name'];
         $style['copyright'] = $xmlnav['copyright'];
         $style['path'] = $theme_name;
         $stylecon = $_ENV['theme']->add_check_style($style['path']);
         if ($stylecon == null) {
             $_ENV['theme']->add_style($style);
             $this->cache->removecache('style');
             $this->message($this->view->lang['styleInstallSuccess'], 'BACK');
         } else {
             $this->message($this->view->lang['styleDbPathRepeat'], 'index.php?admin_theme');
         }
     } else {
         $this->message($this->view->lang['commonParametersInvalidTip'], 'index.php?admin_theme');
     }
 }
Exemplo n.º 14
0
 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');
 }
Exemplo n.º 15
0
 function share_plugin($plugin)
 {
     $identifier = $plugin['identifier'];
     $descxml = "<?xml version=\"1.0\" encoding=\"" . WIKI_CHARSET . "\"?>\n" . "<theme>\n" . "<author><![CDATA[" . $plugin['author'] . "]]></author>\n" . "<authorurl><![CDATA[" . $plugin['authorurl'] . "]]></authorurl>\n" . "<name><![CDATA[" . $plugin['name'] . "]]></name>\n" . "<tag><![CDATA[" . $plugin['tag'] . "]]></tag>\n" . "<desc><![CDATA[" . $plugin['description'] . "]]></desc>\n" . "<weburl><![CDATA[" . $plugin['weburl'] . "]]></weburl>\n" . "<version><![CDATA[" . $plugin['version'] . "]]></version>\n" . "<hdversion><![CDATA[" . $plugin['hdversion'] . "]]></hdversion>\n" . "<copyright><![CDATA[" . $plugin['copyright'] . "]]></copyright>\n" . "<charset><![CDATA[" . WIKI_CHARSET . "]]></charset>\n" . "</theme>";
     file::writetofile(HDWIKI_ROOT . '/plugins/' . $identifier . '/desc.xml', $descxml);
     require_once HDWIKI_ROOT . '/lib/zip.class.php';
     $zip = new zip();
     $filedir = array('plugins/' . $identifier);
     $zipdir = array($identifier);
     $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
     @$zip->zip_dir($filedir, $tmpname, $zipdir);
     $zip_content = file::readfromfile($tmpname);
     $upload_url = $this->base->setting['app_url'] . '/hdapp.php?action=upload&type=plugin';
     $data = 'data=' . base64_encode($zip_content);
     if ('1' == @util::hfopen($upload_url, 0, $data)) {
         unlink($tmpname);
         return true;
     }
     return false;
 }