'pending' "; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_row($rv); return $row[0]; } elseif ($date != "") { return $date; } else { #$sql = "select date_format(max(publication_date), '%Y%m%d') from article_header"; $sql = "select if(max(publication_date) < curdate(),". "date_format(max(publication_date),'%Y%m%d'),". "date_format(curdate(),'%Y%m%d')) from article_header_".$sys_table.$sys_year_str." ". "where category <> '000IN' and category <> '000PN' and status<>'pending' "; //echo $sql; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_row($rv); return $row[0]; } } function get_lang($lang) { if ($lang == "") { return 'B'; } else { return $lang; } } function test_connection($dbh,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select 1 from article_header_".$sys_table.$sys_year_str." limit 1"; //echo $sql; $sth = mysql_query($sql,$dbh); $row = mysql_fetch_row($sth); if ($row[0] == 1) { return true; } else { return false; } } function get_wdate($l_date, $s_lang) { $ch_day_of_week = array ("Monday" => "星期一", "Tuesday" => "星期二", "Wednesday" => "星期三", "Thursday" => "星期四", "Friday" => "星期五", "Saturday" => "星期六", "Sunday" => "星期日"); $year = (int)substr($l_date,0,4); $month = (int)substr($l_date,4,2); $day = (int)substr($l_date,6,2); $timestamp = mktime(0,0,0,$month,$day,$year); $day_of_week = date("l",$timestamp); if ($s_lang == "B") { return $year."年".$month."月".$day."日 $ch_day_of_week[$day_of_week]"; //return "$year 年 $month 月 $day 日 $ch_day_of_week[$day_of_week]"; } else if ($s_lang == "E") { return "$year.$month.$day $day_of_week"; } } // getSystemVariable.phtml----------------1 // getCatInfo.phtml----------------2 function getCatListFile($cat){ global $catList_type_1_category; global $catList_type_2_category; global $catList_type_3_category; global $catList_type_1_catFile; global $catList_type_2_catFile; global $catList_type_3_catFile; global $catList_type_4_catFile; global $catList_type_default; if (in_array($cat, $catList_type_1_category)){ return $catList_type_1_catFile; } elseif (in_array($cat, $catList_type_2_category)){ return $catList_type_2_catFile; } elseif (in_array($cat, $catList_type_3_category)){ return $catList_type_3_catFile; } elseif (strstr(Strtolower($cat), 'zt')){ return $catList_type_4_catFile; } elseif ($cat == "" || empty($cat)) { return $catList_type_4_catFile; } else { return $catList_type_default; } } function get_cat_maxCount($d_date,$s_lang,$cat,$dbh,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if($d_date){ $pub_str = " and publication_date = '$d_date' "; } else { $pub_str = ""; } if ($cat == '005WW') { if ($sys_year == '2003' || $sys_year == '2002' || $sys_year == '2001') { $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." ". "where language_type = '$s_lang' and category = '$cat' ". " and headline like '%文匯社評%' and status<>'pending' and (isnull(parent_news_id) or parent_news_id = '') $pub_str". "order by priority_list "; } elseif ($sys_year == '2000') { $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." ". "where language_type = '$s_lang' and category = '$cat' ". " and headline like '%社論%' and status<>'pending' and (isnull(parent_news_id) or parent_news_id = '') $pub_str". "order by priority_list "; } else { $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." ". "where language_type = '$s_lang' and category = '$cat' ". " and (news_id like '%0001' or news_id like '%0002') and status<>'pending' and (isnull(parent_news_id) or parent_news_id = '') $pub_str". "order by priority_list "; } } elseif ($cat == '057PL') { $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." ". "where language_type = '$s_lang' and category = '$cat' ". " and status<>'pending' and (isnull(parent_news_id) or parent_news_id = '') $pub_str". "order by priority_list "; } else { $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." ". "where language_type = '$s_lang' and category = '$cat' ". " and status<>'pending' and (isnull(parent_news_id) or parent_news_id = '') $pub_str". "order by priority_list "; } //echo $sql; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } function getCatDescription($cat,$dbh) { $sql = "select description from category where cat_id = '$cat'"; $sth = mysql_query($sql,$dbh); $row = mysql_fetch_row($sth); return $row[0]; } function getYearSp($cat,$dbh) { $sql = "select begin_dt from sideLinks where cat_id = '$cat'"; $sth = mysql_query($sql,$dbh); $row = mysql_fetch_row($sth); return $row[0]; } function &get_cat_headlines($sys_table,$sys_year,$d_date,$s_lang,$num_of_record,$cat,$dbh,$idx=0, $show_suffix=0, $headlen=0, $isShowText=0, $textlen=0, $sorting=0) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if($d_date){ $pub_str = " and publication_date = '$d_date' "; } else { $pub_str = ""; } $headline_str = "headline"; if ($headlen > 0 ){ $headline_str = "concat(left(headline,$headlen),if(char_length(headline)>$headlen,'...','')) as headline"; } $text_str = "news_text"; if ($textlen > 0 ){ $text_str = "left(news_text,$textlen) as text"; } $limit_str = ""; if ($num_of_record > 0){ if ($idx <= 0){ $limit_str = "limit $num_of_record "; } else { $limit_str = "limit $idx, $num_of_record "; } } if ($sorting){ $sort_str = $sorting; } else { $sort_str = "priority_list, news_id"; } if ($isShowText == 1){ //echo "shit"; //$sql = "select ah.news_id as news_id, $headline_str, layout, $text_str, is_proprietary, is_renew, is_have_child from article_header as ah, article_text as at ". // "where publication_date = '$d_date' and parent_news_id = '' ". // "and language_type = '$s_lang' and category = '$cat' and status<>'pending' and priority_list>0 ". //"order by priority_list "; //$sql1 = "select ah.news_id as news_id, $headline_str, layout, $text_str, is_proprietary, is_renew, is_have_child from article_header as ah, article_text as at ". //"where publication_date = '$d_date' and parent_news_id = '' ". //"and language_type = '$s_lang' and category = '$cat' and status<>'pending' ". //"and priority_list=0 "; } else { if ($cat == '005WW') { if ($sys_year == '2003' || $sys_year == '2002' || $sys_year == '2001') { $sql = "select news_id, category, headline_prefix, headline_suffix, $headline_str, layout, date_format(creation_date,'%d %H:%i') as cre_dt, is_proprietary, is_renew, is_have_child, date_format(creation_date,'%Y-%m-%d') as creation_date from article_header_".$sys_table.$sys_year_str." ". "where (parent_news_id is null or parent_news_id = '') ". " and headline like '%文匯社評%' and language_type = '$s_lang' and category = '$cat' and status<>'pending' $pub_str ". "order by $sort_str $limit_str "; } elseif ($sys_year == '2000') { $sql = "select news_id, category, headline_prefix, headline_suffix, $headline_str, layout, date_format(creation_date,'%d %H:%i') as cre_dt, is_proprietary, is_renew, is_have_child, date_format(creation_date,'%Y-%m-%d') as creation_date from article_header_".$sys_table.$sys_year_str." ". "where (parent_news_id is null or parent_news_id = '') ". " and headline like '%社論%' and language_type = '$s_lang' and category = '$cat' and status<>'pending' $pub_str ". "order by $sort_str $limit_str "; } else { $sql = "select news_id, category, headline_prefix, headline_suffix, $headline_str, layout, date_format(creation_date,'%d %H:%i') as cre_dt, is_proprietary, is_renew, is_have_child, date_format(creation_date,'%Y-%m-%d') as creation_date from article_header_".$sys_table.$sys_year_str." ". "where (parent_news_id is null or parent_news_id = '') ". " and (news_id like '%0001' or news_id like '%0002' or creation_date >= '2008-12-05') and language_type = '$s_lang' and category = '$cat' and status<>'pending' $pub_str ". "order by $sort_str $limit_str "; } } elseif ($cat == '057PL') { $sql = "select news_id, category, headline_prefix, headline_suffix, $headline_str, layout, date_format(creation_date,'%d %H:%i') as cre_dt, is_proprietary, is_renew, is_have_child, date_format(creation_date,'%Y-%m-%d') as creation_date from article_header_".$sys_table.$sys_year_str." ". "where (parent_news_id is null or parent_news_id = '') ". " and language_type = '$s_lang' and category = '$cat' and status<>'pending' $pub_str ". "order by $sort_str $limit_str "; } else { $sql = "select news_id, category, headline_prefix, headline_suffix, $headline_str, layout, date_format(creation_date,'%d %H:%i') as cre_dt, is_proprietary, is_renew, is_have_child, date_format(creation_date,'%Y-%m-%d') as creation_date from article_header_".$sys_table.$sys_year_str." ". "where (parent_news_id is null or parent_news_id = '') ". "and language_type = '$s_lang' and category = '$cat' and status<>'pending' $pub_str ". "order by $sort_str $limit_str "; } } $rt = array(); //echo $sql; $sth = mysql_query($sql,$dbh); while ($row = mysql_fetch_array($sth)) { if($show_suffix){ $suffix = ""; if ($sys_table == 'paper') { $sql = "select count(1) from article_image where news_id='".$row["news_id"]."'"; //echo $sql; $rv1 = mysql_query($sql, $dbh); $results = mysql_fetch_row($rv1); if ($results[0]>0){ $row["headline"] .= " (圖)"; } } } array_push($rt,$row); } return $rt; } // getCatInfo.phtml----------------2 // getNewsinfo.phtml----------------3 function &get_part_news($sys_table,$sys_year,$d_date,$s_lang,$cat,$len,$dbh, $is_show_all=0) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } /* $sql = "select min(priority_list) from article_header ". "where category = '$cat' and publication_date = '$d_date' ". "and language_type = '$s_lang' and priority_list>0 group by category"; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_row($rv); */ ### to remove warning from being displayed ### if (empty($row[0])) { $row[0] = 0; } if ($is_show_all==0){ $pub_str = " publication_date = '$d_date' "; } else { $pub_str = " publication_date <= '$d_date' "; } $sql = "select news_id from article_header_".$sys_table.$sys_year_str." ". "where category = '$cat' and $pub_str ". "and language_type = '$s_lang' and status<>'pending' order by publication_date DESC, priority_list, news_id limit 1"; //echo $sql; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_row($rv); $sql = "select h.news_id, headline, category, image_filename, ". "concat(left(news_text,$len),'......') as atext from article_text_".$sys_table.$sys_year_str." t ,article_header_".$sys_table.$sys_year_str." h ". "left join article_image i on h.news_id = i.news_id ". "where h.news_id = t.news_id and h.news_id = '$row[0]' and h.status<>'pending' order by news_id"; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_assoc($rv); return $row; } function get_hot_headlines($dbh, $cat, $s_lang, $priority_list, $limit, $sys_table, $sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if ($is_show_all==0){ $pub_str = " publication_date = '$d_date' "; } else { $pub_str = " publication_date <= '$d_date' "; } $sql = "select news_id, headline ". "from article_header_".$sys_table.$sys_year_str." ". "where category = '$cat' and priority_list = $priority_list ". "and language_type = '$s_lang' ". "and status <> 'pending' ". "order by priority_list, creation_date DESC LIMIT $limit"; //echo $sql; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_assoc($rv); return $row; } // getNewsinfo.phtml----------------3 // getImageInfo.phtml----------------4 function get_today_img_path($today,$img_base) { $year = substr($today,0,4); $month = substr($today,4,2); $day = substr($today,6,2); return "$img_base/$year/$month/$day"; } function get_today_img_path_id($newsid,$img_base) { $year = substr($newsid,2,2); $month = substr($newsid,4,2); $day = substr($newsid,6,2); return "$img_base/20$year/$month/$day"; } function get_today_img_path_sp($today,$img_base) { $year = substr($today,0,4); $month = substr($today,5,2); $day = substr($today,8,2); return "$img_base/$year/$month/$day"; } function get_news_imgs_sp($s_news_id, $dbh) { $sql = "select image_filename from article_image ". "where news_id = '$s_news_id' order by priority_list limit 1"; //echo $sql; $rv = mysql_query($sql, $dbh); $row = mysql_fetch_row($rv); return $row[0]; } // getImageInfo.phtml----------------4 // getSideLinkInfo.phtml----------------5 function &get_sideLink_headlines($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx=0) { $sql = "select catType from sideLinks where cat_id = '$cat_id' ". "and language_type = '$s_lang' ". "and begin_dt <= '$d_date' and end_dt >= '$d_date'"; //print "sql = $sql
\n"; $sth = mysql_query($sql,$dbh); $row = mysql_fetch_row($sth); $rt = array(); switch ($row[0]) { case "normCat": $rt['maxCount'] = get_normCat_maxCount($sys_table,$sys_year,$d_date,$s_lang,$cat_id,$dbh); $rt['data'] = get_normCat_headlines($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx); break; case "linked": $rt['maxCount'] = get_LinkedCat_maxCount($d_date,$s_lang,$cat_id,$dbh); $rt['data'] = get_LinkedCat_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx); break; } return $rt; } function get_normCat_maxCount($sys_table,$sys_year,$d_date,$s_lang,$cat_id,$dbh) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if ($cat_id == '005WW') { if ($sys_year == '2003' || $sys_year == '2002' || $sys_year == '2001') { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and headline like '%文匯社評%' and publication_date <= '$d_date' and category = '$cat_id' ". "order by publication_date desc, priority_list "; } elseif ($sys_year == '2000') { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and headline like '%社論%' and publication_date <= '$d_date' and category = '$cat_id' ". "order by publication_date desc, priority_list "; } else { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and (news_id like '%0001' or news_id like '%0002') and publication_date <= '$d_date' and category = '$cat_id' ". "order by publication_date desc, priority_list "; } } elseif ($cat_id == '057PL') { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and publication_date <= '$d_date' and category = '$cat_id' ". "order by publication_date desc, priority_list "; } else { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and category = '$cat_id' ". "order by publication_date desc, priority_list "; } $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } function get_normCat_headlines($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if ($cat_id == '005WW') { if ($sys_year == '2003' || $sys_year == '2002' || $sys_year == '2001') { $sql = "select news_id, concat(headline,' (',publication_date,')') as headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and headline like '%文匯社評%' and publication_date <= '$d_date' ". "and category = '$cat_id' ". "order by publication_date desc, priority_list "; } elseif ($sys_year == '2000') { $sql = "select news_id, concat(headline,' (',publication_date,')') as headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and headline like '%社論%' and publication_date <= '$d_date' ". "and category = '$cat_id' ". "order by publication_date desc, priority_list "; } else { $sql = "select news_id, concat(headline,' (',publication_date,')') as headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and (news_id like '%0001' or news_id like '%0002') and publication_date <= '$d_date' ". "and category = '$cat_id' ". "order by publication_date desc, priority_list "; } } elseif ($cat_id == '057PL') { $sql = "select news_id, concat(headline,' (',publication_date,')') as headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and publication_date <= '$d_date' ". "and category = '$cat_id' ". "order by publication_date desc, priority_list "; } else { $sql = "select news_id, concat(headline,' (',publication_date,')') as headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". " and publication_date <= '$d_date' ". "and category = '$cat_id' ". "order by publication_date desc, priority_list "; } if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = $sql
\n"; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_LinkedCat_maxCount($d_date,$s_lang,$cat_id,$dbh) { $sql = "select count(1) ". "from article_related_keyword ". "where keyword = '$cat_id' ". "order by rwid desc "; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } function get_LinkedCat_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx=0) { $sql = "select news_id, headline, category ". "from article_related_keyword ". "where keyword = '$cat_id' ". "order by priority_list, RIGHT(news_id,10) desc "; if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = asdf $sql
\n"; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_normReport_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select news_id, concat(headline,' (',publication_date,')') as headline, category ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' ". "and is_proprietary = 1 ". "order by publication_date desc, priority_list "; if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = $sql
\n"; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_normReport_maxCount($d_date,$s_lang,$cat_id,$dbh,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and is_proprietary = 1 ". "order by publication_date desc, priority_list "; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } // getSideLinkInfo.phtml----------------5 // getTopHeadlines.php----------------6 function get_Top_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select news_id, concat(headline,' (',publication_date,')') as headline, category ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and news_id like '%0001' ". "and category = '001YO' ". "order by publication_date desc "; if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = $sql
\n"; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_Top_maxCount($d_date,$s_lang,$cat_id,$dbh,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and is_proprietary = 1 and category = '001YO' ". "order by publication_date desc, priority_list "; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } // getTopHeadlines.php----------------6 // getInstantInfo.phtml----------------7 function &get_instant_cat_headlines($sys_table,$sys_year,$d_date,$s_lang,$num_of_record,$cat,$dbh,$idx=0,$instantCat, $is_show_others=0) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } // count number of record; $sql = "select h.news_id, h.headline, layout, date_format(h.creation_date,'%d日 %H:%i') as cre_dt ". "from article_header_".$sys_table.$sys_year_str." h, instant_new_category inc ". "where h.publication_date = '$d_date' and h.news_id=inc.news_id and inc.instant_cat_id='$instantCat' ". "and h.language_type = '$s_lang' and h.category = '$cat' and h.status<>'pending' ". "order by h.creation_date DESC "; $sth = mysql_query($sql,$dbh); $num_row = mysql_affected_rows($dbh); $rt = array(); if ($num_row<$num_of_record){ if ($is_show_others){ $sql = "select h.news_id, h.headline, layout, date_format(h.creation_date,'%d日 %H:%i') as cre_dt ". "from article_header_".$sys_table.$sys_year_str." h, instant_new_category inc ". "where h.publication_date < '$d_date' and h.news_id=inc.news_id ". "and inc.instant_cat_id='$instantCat' ". "and h.language_type = '$s_lang' and h.category = '$cat' ". "and h.status<>'pending' ". "order by h.creation_date DESC ". "limit $num_of_record "; $rv2 = mysql_query($sql, $dbh); } } else { $is_show_others = 0; } $loop_count=0; $news_count=0; while (1) { if ($row = mysql_fetch_assoc($sth)){ $loop_count++; } elseif ($is_show_others) { if ($row = mysql_fetch_assoc($rv2)) { $loop_count++; } else { break; } } else { break; } if ( $news_count > $num_of_record && $num_of_record>0) { break; } if($loop_count > $idx){ $sql = "select count(1) from article_image where news_id='".$row["news_id"]."'"; $rv1 = mysql_query($sql, $dbh); $results = mysql_fetch_row($rv1); $suffix = ""; if ($results[0]>0){ $row["headline"] .= " (圖)"; } array_push($rt,$row); $news_count++; } } return $rt; } function get_instant_cat_maxCount($d_date,$s_lang,$cat,$dbh, $instantCat,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select count(1) from article_header_".$sys_table.$sys_year_str." h, instant_new_category inc ". "where h.publication_date <= '$d_date' and h.news_id=inc.news_id and inc.instant_cat_id='$instantCat' ". "and h.language_type = '$s_lang' and h.category = '$cat' and h.status<>'pending' order by h.creation_date DESC "; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } // getInstantInfo.phtml----------------7 // getSideLinkInfo.phtml----------------8 function &get_sideLink_headlines_sp($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx=0) { if ($cat_id == "" || empty($cat_id)) { $sql = "select catType from sideLinks where cat_id like '%$cat_id' ". "and language_type = '$s_lang' "; // $sql = "select catType from sideLinks where cat_id like '%$cat_id' ". // "and language_type = '$s_lang' ". // "and begin_dt <= '$d_date' and end_dt >= '$d_date'"; } else { $sql = "select catType from sideLinks where cat_id = '$cat_id' ". "and language_type = '$s_lang' "; // $sql = "select catType from sideLinks where cat_id = '$cat_id' ". // "and language_type = '$s_lang' ". // "and begin_dt <= '$d_date' and end_dt >= '$d_date'"; } // print "sql = $sql
\n"; $sth = mysql_query($sql,$dbh); $row = mysql_fetch_row($sth); $rt = array(); switch ($row[0]) { case "normCat": $rt['maxCount'] = get_normCat_maxCount_sp($sys_table,$sys_year,$d_date,$s_lang,$cat_id,$dbh); $rt['data'] = get_normCat_headlines_sp($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx); break; case "linked": $rt['maxCount'] = get_LinkedCat_maxCount($d_date,$s_lang,$cat_id,$dbh); $rt['data'] = get_LinkedCat_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx); break; } return $rt; } function get_normCat_maxCount_sp($sys_table,$sys_year,$d_date,$s_lang,$cat_id,$dbh) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if ($cat_id == "" || empty($cat_id)) { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and (category like '%zt' or category like '%ZT')". " and priority_list = 1 ". "order by publication_date desc, priority_list "; } else { $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and category = '$cat_id' and priority_list = 1 ". "order by publication_date desc, priority_list "; } $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } function get_normCat_headlines_sp($sys_table,$sys_year,$d_date,$s_lang,$offset,$cat_id,$dbh,$idx) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } if ($cat_id == "" || empty($cat_id)) { $sql = "select news_id, headline, publication_date, category ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and priority_list = 1 ". "and (category like '%zt' or category like '%ZT') ". "order by publication_date desc, category "; } else { $sql = "select news_id, headline, publication_date, category ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and priority_list = 1 ". "and category = '$cat_id' ". "order by publication_date desc, category "; } if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = $sql
\n"; //echo $sql; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_normCat_headlines_sp_in($sys_table,$sys_year,$d_date,$s_lang,$cat_id,$dbh) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select news_id, headline ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date = '$d_date' ". "and category = '$cat_id' ". "order by priority_list "; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function &get_sidelink_by_category_top ($category, $priority_list, $d_date, $s_lang, $dbh, $limit = 0) { if ( $limit > 0 ){ $limit_str = "limit $limit"; } else { $limit_str = ""; } $sql = "select s.cat_id, c.description from ". "sideLinks s, category c ". "where s.language_type = '$s_lang' and s.begin_dt <= '$d_date' and ". "s.end_dt >= '$d_date' and category = '$category' and ". "c.cat_id = s.cat_id and s.priority_list = $priority_list ". "order by REPLACE(s.cat_id,'zt','')+0 desc $limit_str;"; //echo $sql; $rv = mysql_query($sql, $dbh); $temp_array = array(); while($row = mysql_fetch_array($rv)) { array_push($temp_array, $row); } return $temp_array; } function &get_side_links_info ($d_date,$s_lang,$loc,$dbh) { $sql = "select s.cat_id,c.description,s.banner_img,s.url, c.headline_suffix, c.headline_prefix ". "from category c, sideLinks s where s.cat_id = c.cat_id ". "and s.language_type = '$s_lang' and s.begin_dt <= '$d_date' ". "and s.end_dt >= '$d_date' and catLoc='$loc' and s.priority_list>0 ". "order by s.priority_list"; $sql1 = "select s.cat_id,s.url,c.description, c.headline_suffix, c.headline_prefix, s.banner_img ". "from category c, sideLinks s where s.cat_id = c.cat_id ". "and s.language_type = '$s_lang' and s.begin_dt <= '$d_date' ". "and s.end_dt >= '$d_date' and catLoc='$loc' and s.priority_list=0 "; $sth = mysql_query($sql, $dbh); $sth1 = mysql_query($sql1, $dbh); $rt = array(); while (1) { if ($row = mysql_fetch_assoc($sth)){ } elseif ($row = mysql_fetch_assoc($sth1)) { } else { break; } array_push($rt,$row); } return $rt; } // getSideLinkInfo.phtml----------------8 // getPoliticalStar.php----------------9 function get_Star_headlines($d_date,$s_lang,$offset,$cat_id,$dbh,$idx,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select news_id, concat(headline,' (',publication_date,')') as headline, category ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and (headline like '%政壇新星%' or news_id = 'CH0701200001' or news_id = 'CH0701200002' or news_id = 'CH0701200003' or news_id = 'CH0701200004' or news_id = 'CH0701200005' or news_id = 'CH0701200006' or news_id = 'CH0701200007' or news_id = 'CH0701200008' or news_id = 'CH0701200009' or news_id = 'CH0701200010' or news_id = 'CH0701200011' or news_id = 'CH0701200012' or news_id = 'CH0701290013' or news_id = 'CH0701290014' or news_id = 'CH0701290015' or news_id = 'CH0701290016' or news_id = 'CH0701290017' or news_id = 'CH0701290018' or news_id = 'CH0701290019' or news_id = 'CH0701290020' or news_id = 'CH0701290021' or news_id = 'CH0701290022' or news_id = 'CH0701290023' or news_id = 'CH0701290024' or news_id = 'CH0701290025' or news_id = 'CH0701290026') ". "order by publication_date desc "; if (!empty($offset)) { $sql .= "limit $idx,$offset"; } //print "sql = $sql
\n"; $rt = array(); $sth = mysql_unbuffered_query($sql,$dbh); while ($row = mysql_fetch_assoc($sth)) { array_push($rt,$row); } return $rt; } function get_Star_maxCount($d_date,$s_lang,$cat_id,$dbh,$sys_table,$sys_year) { if ($sys_year != '') { $sys_year_str = "_".$sys_year; } else { $sys_year_str =""; } $sql = "select count(*) ". "from article_header_".$sys_table.$sys_year_str." where language_type = '$s_lang' ". "and publication_date <= '$d_date' and (headline like '%政壇新星%' or news_id = 'CH0701200001' or news_id = 'CH0701200002' or news_id = 'CH0701200003' or news_id = 'CH0701200004' or news_id = 'CH0701200005' or news_id = 'CH0701200006' or news_id = 'CH0701200007' or news_id = 'CH0701200008' or news_id = 'CH0701200009' or news_id = 'CH0701200010' or news_id = 'CH0701200011' or news_id = 'CH0701200012' or news_id = 'CH0701290013' or news_id = 'CH0701290014' or news_id = 'CH0701290015' or news_id = 'CH0701290016' or news_id = 'CH0701290017' or news_id = 'CH0701290018' or news_id = 'CH0701290019' or news_id = 'CH0701290020' or news_id = 'CH0701290021' or news_id = 'CH0701290022' or news_id = 'CH0701290023' or news_id = 'CH0701290024' or news_id = 'CH0701290025' or news_id = 'CH0701290026') ". "order by publication_date desc, priority_list "; $sth = mysql_unbuffered_query($sql,$dbh); $rt = mysql_fetch_row($sth); return $rt[0]; } // getPoliticalStar.php----------------9 function get_click_rate_num($dbh) { $date_today = substr(date("Ymd"),2,6); $sql = "select headline, news_id, category from hit_rate WHERE news_id like '%".$date_today."%' ORDER BY publication_date DESC, hits DESC limit 50;"; $rv = mysql_query($sql, $dbh); $num_rows = mysql_num_rows($rv); if ($num_rows<10) { $sql = "select headline, news_id, category from hit_rate ORDER BY publication_date DESC, hits DESC limit 50;"; $rv = mysql_query($sql, $dbh); } $temp_array = array(); while($row = mysql_fetch_array($rv)) { array_push($temp_array, $row); } return $temp_array; } function get_click_rate_week($dbh) { $sql = "select headline, news_id, category from hit_rate WHERE publication_date > subdate(now(), interval 7 day) ORDER BY hits DESC limit 50;"; $rv = mysql_query($sql, $dbh); $temp_array = array(); while($row = mysql_fetch_array($rv)) { array_push($temp_array, $row); } return $temp_array; } function get_click_rate_month($dbh) { $sql = "select headline, news_id, category from hit_rate WHERE publication_date > subdate(now(), interval 30 day) ORDER BY hits DESC limit 50;"; $rv = mysql_query($sql, $dbh); $temp_array = array(); while($row = mysql_fetch_array($rv)) { array_push($temp_array, $row); } return $temp_array; } function get_sp_types($dbh){ $sql="select * from sp_cats where hide=0 order by priority desc "; $query = mysql_query($sql, $dbh); $rt = array (); $i = 0; while ( $row = &mysql_fetch_array ( $query ) ) { $rt [$i] = $row; $i ++; } return $rt; } function get_sp_typeForId($dbh,$id){ if(is_numeric($id)&&$id>0){ $sql="select * from sp_cats where hide=0 and id=$id"; $query = mysql_query($sql, $dbh); $row = &mysql_fetch_assoc ( $query ); return $row; } } function getSpForType($id,$dbh,$d_date='',$limit=''){ $limitWhere = ""; $timeLimit = ""; $rt = array (); if($id!=0){ if(is_numeric($limit)&&$limit>0){ $limitWhere=" limit $limit"; } if(!empty($d_date)&&strlen($d_date)<12){ $timeLimit=" and s.begin_dt <= '$d_date' "." and s.end_dt >= '$d_date'"; } $sql="select c.description,s.cat_id,s.thumbs_img,s.begin_dt,s.end_dt,s.url,s.priority_list,s.sp_cat_id from category c, sideLinks s where s.cat_id = c.cat_id and s.sp_cat_id='$id' " . $timeLimit." ORDER BY s.priority_list asc". $limitWhere; $query = mysql_query($sql, $dbh); $i = 0; while ( $row = &mysql_fetch_array ( $query ) ) { $rt [$i] = $row; $i ++; } } return $rt; } ?>