Project Babel
Made by V2EX | software for internet');
}
/* S Node class */
class Node {
public $db;
public $nod_id;
public $nod_pid;
public $nod_uid;
public $nod_sid;
public $nod_level;
public $nod_name;
public $nod_title;
public $nod_title_en_us;
public $nod_title_de_de;
public $nod_title_zh_cn;
public $nod_title_i18n;
public $nod_description;
public $nod_header;
public $nod_footer;
public $nod_topics;
public $nod_favs;
public $nod_created;
public $nod_lastupdated;
public $usr_id;
public $usr_nick;
public function __construct($node_id, $db) {
$this->db =& $db;
$sql = "SELECT nod_id, nod_pid, nod_uid, nod_sid, nod_level, nod_name, nod_title, nod_title_en_us, nod_title_de_de, nod_title_zh_cn, nod_description, nod_header, nod_footer, nod_topics, nod_favs, nod_created, nod_lastupdated, usr_id, usr_nick FROM babel_node, babel_user WHERE nod_uid = usr_id AND nod_id = {$node_id}";
$rs = mysql_query($sql, $this->db);
$O = mysql_fetch_object($rs);
mysql_free_result($rs);
$this->nod_id = $O->nod_id;
$this->nod_pid = $O->nod_pid;
$this->nod_uid = $O->nod_uid;
$this->nod_sid = $O->nod_sid;
$this->nod_level = $O->nod_level;
$this->nod_name = $O->nod_name;
$this->nod_title = $O->nod_title;
$this->nod_title_en_us = $O->nod_title_en_us;
$this->nod_title_de_de = $O->nod_title_de_de;
$this->nod_title_zh_cn = $O->nod_title_zh_cn;
$this->nod_title_i18n = $O->nod_title;
switch (BABEL_LANG) {
default:
case 'en_us':
if ($this->nod_title_en_us != '') {
$this->nod_title_i18n = $this->nod_title_en_us;
}
break;
case 'zh_cn':
if ($this->nod_title_zh_cn != '') {
$this->nod_title_i18n = $this->nod_title_zh_cn;
}
break;
case 'de_de':
if ($this->nod_title_de_de != '') {
$this->nod_title_i18n = $this->nod_title_de_de;
}
break;
}
$this->nod_description = $O->nod_description;
$this->nod_header = $O->nod_header;
$this->nod_footer = $O->nod_footer;
$this->nod_topics = $O->nod_topics;
$this->nod_favs = $O->nod_favs;
$this->nod_created = $O->nod_created;
$this->nod_lastupdated = $O->nod_lastupdated;
$this->usr_id = $O->usr_id;
$this->usr_nick = $O->usr_nick;
$O = null;
}
public function __destruct() {
}
public function vxGetNodeInfo($node_id) {
$sql = "SELECT nod_id, nod_name, nod_title, nod_title_en_us, nod_title_de_de, nod_title_zh_cn FROM babel_node WHERE nod_id = {$node_id}";
$rs = mysql_query($sql, $this->db);
$Node = mysql_fetch_object($rs);
mysql_free_result($rs);
$Node->nod_title_i18n = $Node->nod_title;
switch (BABEL_LANG) {
default:
case 'en_us':
if ($Node->nod_title_en_us != '') {
$Node->nod_title_i18n = $Node->nod_title_en_us;
}
break;
case 'zh_cn':
if ($Node->nod_title_zh_cn != '') {
$Node->nod_title_i18n = $Node->nod_title_zh_cn;
}
break;
case 'de_de':
if ($Node->nod_title_de_de != '') {
$Node->nod_title_i18n = $Node->nod_title_de_de;
}
break;
}
return $Node;
}
public function vxUpdateTopics($board_id = '') {
if ($board_id == '') {
$board_id = $this->nod_id;
}
$_t = time();
$sql = "SELECT COUNT(tpc_id) FROM babel_topic WHERE tpc_pid = {$board_id}";
$rs = mysql_query($sql, $this->db);
$nod_topics = mysql_result($rs, 0, 0);
mysql_free_result($rs);
$sql = "UPDATE babel_node SET nod_topics = {$nod_topics}, nod_lastupdated = {$_t} WHERE nod_id = {$board_id} LIMIT 1";
mysql_query($sql, $this->db);
if (mysql_affected_rows($this->db) == 1) {
return true;
} else {
return false;
}
}
public function vxUpdateFavs($board_id = '') {
if ($board_id == '') {
$board_id = $this->nod_id;
}
$sql = "SELECT COUNT(fav_id) FROM babel_favorite WHERE fav_res = '{$board_id}' AND fav_type = 1";
$rs = mysql_query($sql, $this->db);
$nod_favs = mysql_result($rs, 0, 0);
mysql_free_result($rs);
$sql = "UPDATE babel_node SET nod_favs = {$nod_favs} WHERE nod_id = {$board_id} LIMIT 1";
mysql_query($sql, $this->db);
if (mysql_affected_rows($this->db) == 1) {
return true;
} else {
return false;
}
}
public function vxGetNodeChildren($section_id = '') {
if ($section_id == '') {
$section_id = $this->nod_id;
}
$sql = "SELECT nod_id, nod_name, nod_title FROM babel_node WHERE nod_pid = {$section_id} ORDER BY nod_topics DESC";
$rs = mysql_query($sql, $this->db);
if (mysql_num_rows($rs) > 0) {
return $rs;
} else {
return false;
}
}
public function vxDrawChannels($board_id = '', $exclude = 0) {
echo ('');
if ($board_id == '') {
$board_id = $this->nod_id;
}
$sql = "SELECT chl_id, chl_title, chl_url FROM babel_channel WHERE chl_pid = {$board_id} ORDER BY chl_title";
$rs = mysql_query($sql, $this->db);
$count = mysql_num_rows($rs);
if ($count > 0) {
switch (BABEL_LANG) {
case 'en_us':
default:
echo($exclude != 0 ? ' ... ' . $count . ' more channels
':' ... ' . $count . ' related channels');
break;
case 'zh_cn':
echo($exclude != 0 ? ',' . $count . ' 个其他相关频道
':',' . $count . ' 个相关频道');
break;
}
_v_hr();
echo('
';
$o .= $this->nod_header . ' 行情图表 |
| 新闻资讯 |
';
$o .= _vo_hr();
$o .= '';
$o .= '
分时行情 | 5 分钟 K 线 | 日 K 线 | 周 K 线 | 月 K 线 | RSI | MACD | KDJ | MIKE . ')