######################################################################################
##
## Program :
## Description :
## Programmer : äªÂÃѵ¹ì ÊØ¹·ÃÇÔÀÒµ
## Email : webmaster@sixhead.com
## : webmaster@todaysoftware.com
## Website : http://www.sixhead.com
## : http://www.todaysoftware.com
## Date :
## Modify log :
##
######################################################################################
#####################################################################
#### start setup ####
$tp_article_list = "_tp_article_list_v4.html";
#### end of setup ####
#####################################################################
#####################################################################
#### start program ####
require "module/_config.php";
require "module/_module.php";
ob_start();
$category_id_sql = "%";
if ($category_id) {
$category_id_sql = $category_id;
}
$keyword_sql = "%";
if ($keyword) {
$keyword_sql = "%$keyword%";
}
$trainer_id_sql = "%";
if ($trainer_id) {
$trainer_id_sql = $trainer_id;
}
# Split Page
@$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
if (!$db) { echo "Error connect to Database: " . mysql_error(); ob_end_flush(); exit; }
$cfg_list_per_page = $cfg_list_per_page_global;
$other_sql = " WHERE (($db_table_trainer_article.ARTICLE_TOPIC LIKE '$keyword_sql' OR $db_table_trainer_article.ARTICLE_DETAIL LIKE '$keyword_sql') AND $db_table_trainer_article.ARTICLE_ACTIVE = 'Y' AND $db_table_trainer_article.CATEGORY_ID LIKE '$category_id_sql' AND $db_table_trainer_article.TRAINER_ID LIKE '$trainer_id_sql')";
$link_parameter = "&category_id=$category_id&sort=$sort&keyword=$keyword&trainer_id=$trainer_id";
Split_Page($db_table_trainer_article,$other_sql,$p,$cfg_list_per_page,$link_parameter);
if ($sort == 1) { $order_by = "$db_table_trainer_article.ARTICLE_ID DESC"; }
else if ($sort == 2) { $order_by = "$db_table_trainer_article.ARTICLE_ID"; }
else if ($sort == 3) { $order_by = "$db_table_trainer_article_stats.TOTAL_VIEW DESC"; }
else if ($sort == 4) { $order_by = "$db_table_trainer_article_stats.TOTAL_REPLY DESC"; }
else if ($sort == 5) { $order_by = "$db_table_trainer_article_stats.LAST_REPLY DESC"; }
else { $order_by = "$db_table_trainer_article.ARTICLE_ID DESC"; }
$tp = new Template($tp_article_list);
$tp->Block("DATA");
$now_date = date("Y-m-d");
$sql = "SELECT $db_table_trainer_article.*,$db_table_trainer_article_stats.TOTAL_REPLY,$db_table_trainer_article_stats.TOTAL_VIEW FROM $db_table_trainer_article LEFT JOIN $db_table_trainer_article_stats ON ($db_table_trainer_article.ARTICLE_ID = $db_table_trainer_article_stats.ARTICLE_ID) $other_sql ORDER BY $order_by limit $start_loop,$cfg_list_per_page";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$article_id = $row[ARTICLE_ID];
$sql2 = "SELECT USERNAME FROM $db_table_trainer WHERE ID = '$row[TRAINER_ID]'";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2)) {
$name_show = "$row2[USERNAME]
";
}
mysql_free_result($result2);
$last_update = "";
$sql2 = "SELECT DATE_ADD FROM $db_table_comment WHERE (CATEGORY = 'article' AND CONTENT_ID = '$article_id') ORDER BY DATE_ADD DESC LIMIT 0,1";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2)) {
$last_update = Convert_YMDHMS_2_DMYHM_Name($row2[DATE_ADD]);
}
mysql_free_result($result2);
if ($bgcolor == "#F9F9F9") { $bgcolor = "#FFFFF9"; }
else { $bgcolor = "#F9F9F9"; }
$allow_view = "";
if ($row[ALLOW_VIEW] == "member") {
$allow_view = "
";
}
$icon_hot = "";
if ($row[TOTAL_VIEW] > $cfg_int_content_hot) {
$icon_hot = "
";
}
$icon_new = "";
if (DateDiff($row[DATE_ADD],$now_date) < $cfg_int_content_new) {
$icon_new = "
";
}
$article_privilege = $row["ARTICLE_PRIVILEGE"];
$article_extra = $row["ARTICLE_EXTRA"];
$icon_extra = "";
$arr_icon_extra = preg_split ("/,/",$article_privilege . $article_extra, -1, PREG_SPLIT_NO_EMPTY);
foreach ($arr_icon_extra as $strTemp) {
$icon_extra .= "
";
}
# Rating
$rating_show = "";
$sql2 = "SELECT * FROM $db_table_trainer_article_stats WHERE ARTICLE_ID = '$article_id' LIMIT 0,1";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2)) {
$total_view = $row2[TOTAL_VIEW];
$poll_Y = $row2[POLL_Y];
$poll_N = $row2[POLL_N];
}
mysql_free_result($result2);
$total_poll = $poll_Y + $poll_N;
$poll_percent_Y = 0;
$poll_percent_N = 0;
if ($poll_Y > 0) {
$poll_percent_Y = round(sprintf ("%.02f",(100 / $total_poll) * $poll_Y));
}
if ($poll_N > 0) {
$poll_percent_N = round(sprintf ("%.02f",(100 / $total_poll) * $poll_N));
}
$rating_show = <<
 |
$poll_percent_Y% |
 |
$poll_percent_N% |
SiXhEaD;
# /Rating
$data = array(
'bgcolor' => $bgcolor,
'article_id' => $article_id,
'article_topic' => $row[ARTICLE_TOPIC],
'name_show' => $name_show,
'allow_view' => $allow_view,
'total_reply' => $row[TOTAL_REPLY],
'total_view' => $row[TOTAL_VIEW],
'last_update' => $last_update,
'icon_hot' => $icon_hot,
'icon_new' => $icon_new,
'icon_extra' => $icon_extra,
'rating_show' => $rating_show,
);
$tp->Apply($data);
}
mysql_free_result($result);
if ($trainer_id) {
$sql = "SELECT * FROM $db_table_trainer WHERE ID = $trainer_id";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$fname = $row[FNAME];
$lname = $row[LNAME];
$category_name = "�������� $fname $lname";
}
mysql_free_result($result);
}
else {
$sql = "SELECT * FROM $db_table_trainer_article_category WHERE CATEGORY_ID = '$category_id'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$category_name = $row[CATEGORY_NAME];
}
mysql_free_result($result);
}
mysql_close($db);
# /Split Page
$select_sort = "
";
$select_sort = preg_replace("/&sort=$sort'/", "&sort=$sort'selected", $select_sort);
$tp->Mix();
$HTML = $tp->Data();
$HTML = preg_replace("/\\$(\w+)/e","$$1",$HTML);
echo $HTML;
exit;
ob_end_flush();
#### end of program ####
#####################################################################
#### Start sub program. Don't touch anything below ####
?>