0?"LIMIT 0,$limit":''; $sql = "select SQL_CALC_FOUND_ROWS * from view_products pd where pd.NumIMG > 0 AND Bestbuy = 'Y' ORDER BY RAND() $limit"; $return = db_get_array($sql); foreach($return as $k => $v) { $v['last'] = ($k+1)%4==0? 'no-boder':''; $v['ProductNameG']=url_google($v['ProductName_'.$_SESSION['lang']]); $v['Price']=$v['Price']==0?($_SESSION['lang'] == "VN"?"Please call!":"Please call!"):addSignIntoNumber($v['Price'])." VNĐ"; $v['PriceOld']=$v['PriceOld']==0?'':'

'.addSignIntoNumber($v['PriceOld']).' VNĐ

'; $v['ProductImage'] = get_img_first($v['ProductID']); if(($v['ProductImage']=='')||(($v['ProductImage']!='')&&!file_exists($v['UserName'].'/images/news_img/'.$v['ProductImage']))) { $v['ProductImage']='no_img.png'; } $v['ProductName'] = $v['ProductName_'.$_SESSION['lang']]; parse_block($v,"main.$block.list_product"); $i++; } parse_block($v,"main.$block"); } function encode_base64($sData){ $sBase64 = base64_encode($sData); return strtr($sBase64, '+/', '-_'); } function decode_base64($sData){ $sBase64 = strtr($sData, '-_', '+/'); return base64_decode($sBase64); } function encrypt($sData, $sKey='greenint'){ $sResult = ''; for($i=0;$i0 ? "LIMIT 0,$limit":''; $sql = "select * from view_shoptieubieu ORDER BY Typical ASC, NumSP DESC $limit"; $rs = db_get_array($sql); $sum = count($rs) -1; foreach($rs as $k => $v){ $v['endshop'] = $k === $sum ? 'endshop' : ''; parse_block($v,'main.'.$block); } } function get_img_first($Parent){ $sql = "select * from `".$GLOBALS['table_prefix']."store` where `Parent` = '$Parent' ORDER BY StoreID ASC LIMIT 0,1"; $result = db_get_row($sql); return $result['StoreParth']; } function get_all_img_store($Parent){ $sql = "select * from `".$GLOBALS['table_prefix']."store` where `Parent` = '$Parent' ORDER BY StoreID ASC"; //echo $sql ; $result = db_get_array($sql); return $result; } function get_sub_name_buy_url($url) { $url = explode('cmmart.vn/',$url); if(count($url)>0) { $url1 = explode('/',$url[1]); return $url1[0]; } } function url_google_trim($str) { $str = url_google($str); $str = str_replace("-", "", strtolower($str)); return strtolower($str); } function search_city_bds($parse_name = 'search_city_bds',$check='0') { $sql = "SELECT * from `".$GLOBALS['table_prefix']."citycode`"; $sql.= " ORDER BY CityID "; $return = db_get_array($sql); foreach($return as $k => $v){ if($k==0) $cityID = $v['CityID']; if($v['CityID']==$_GET[$name] || $v['CityID']==$check){ $v['active'] = 'selected="selected" style="color:#5A0000; font-weight:bold"'; } else $v['active'] = ''; parse_block($v,'main.'.$parse_name); } return $cityID ; } function new_pass(){ $char = strtoupper(substr(str_shuffle('abcdefghjkmnpqrstuvwxyz'), 0, 4)); $str = rand(1, 7) . rand(1, 7) . $char; return $str; } function get_city_cb($block = 'get_cbCity',$check=0) { $sql = "SELECT * from `".$GLOBALS['table_prefix']."citycode`"; $sql.= " ORDER BY `Order` DESC, CityName ASC"; $return = db_get_array($sql); foreach($return as $k => $v){ if($v['CityID']==$check){ $v['active'] = 'selected="selected" '; $v['active'] .= ($v['CityID']==$check)?' style="color:#5A0000; font-weight:bold"':''; } else $v['active'] = ''; parse_block($v,'main.'.$block); } } function show_category_son_by_parent($block,$id,$selected) { $result = db_get_array("Select c.CategoryID, c.Parent, c.CategoryName_".$_SESSION['lang']." as CategoryName From ".$GLOBALS['table_prefix']."category c Where c.Active_".$_SESSION['lang']." ='Y' AND c.Parent = $id ORDER BY c.`Order` DESC;"); foreach($result as $k => $v) { $v['Total'] = get_total_product_by_cate($v['CategoryID']); $v['CategoryNameG']= url_google($v['CategoryName']); $v['active'] = $v['CategoryID'] == $selected ? 'class="active"':''; parse_block($v,"main.$block.list"); } if(count($result)>0){ parse_block($v,"main.$block"); } } function get_total_product_by_cate($id) { $arr=getListSonCate($id); if(count($arr)>0) $sql_u=" AND (p.CategoryID='$id' OR p.CategoryID=".implode(" OR p.CategoryID=",$arr).")"; else $sql_u="AND p.CategoryID='$id' "; $result = db_get_row("SELECT COUNT(p.ProductID) as Total FROM `products` p WHERE Active_".$_SESSION['lang']." = 'Y' $sql_u"); return $result['Total']; } function getCateRoot_str($CategoryID,$last=true) { $str = ""; $return = db_get_row("Select CategoryID, Parent, CategoryName_".$_SESSION['lang']." as CategoryName From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND CategoryID=$CategoryID"); if(count($return)>0){ $css = $last?'-end':''; $str = '
  • '.$return["CategoryName"].'
  • '; if($return["Parent"]>0) $str =getCateRoot_str($return["Parent"],false).$str; } return $str; } function getCateRoot_str2($CategoryID,$last=true) { $str = ""; $return = db_get_row("Select CategoryID, Parent, CategoryName_".$_SESSION['lang']." as CategoryName From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND CategoryID=$CategoryID"); if(count($return)>0){ $css = $last?'-end':''; $str = ''.$return["CategoryName"].''; if($return["Parent"]>0) $str =getCateRoot_str($return["Parent"],false).' » '.$str; } return $str; } function getCateRoot_id($CategoryID) { $return = db_get_row("Select * From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND CategoryID=$CategoryID"); if(count($return)>0){ if($return["Parent"]>0) $CategoryID = getCateRoot_id($return["Parent"]); } return $CategoryID; } function show_products_by_id_limit($block,$id,$limit=0) { $arr=getListSonCate($id); $limit = $limit >0 ? "LIMIT 0,$limit":''; if(count($arr)>0) $sql_u=" AND (pd.CategoryID='$id' OR pd.CategoryID=".implode(" OR pd.CategoryID=",$arr).")"; else $sql_u="AND pd.CategoryID='$id' "; $sql = "select SQL_CALC_FOUND_ROWS * from view_products pd where pd.NumIMG > 0 $sql_u ORDER BY pd.`Order` desc, pd.`ProductID` desc $limit"; $return = db_get_array($sql); foreach($return as $k => $v) { $v['clear_div'] = ($k+1)%4==0? (($k+1)
    ':''):''; $v['last'] = ($k+1)%4==0? '':''; $v['ProductNameG']=url_google($v['ProductName_'.$_SESSION['lang']]); $v['Price']=$v['Price']==0?($_SESSION['lang'] == "VN"?"Please call!":"Please call!"):addSignIntoNumber($v['Price'])." VNĐ"; $v['PriceOld']=$v['PriceOld']==0?'':'

    '.addSignIntoNumber($v['PriceOld']).' VNĐ

    '; $v['ProductImage'] = get_img_first($v['ProductID']); if(($v['ProductImage']=='')||(($v['ProductImage']!='')&&!file_exists($v['UserName'].'/images/news_img/'.$v['ProductImage']))) { $v['ProductImage']='no_img.png'; } $v['ProductName'] = rutgonchuoi(strip_tags( $v['ProductName_'.$_SESSION['lang']]),15); parse_block($v,"main.$block"); $i++; } return count($return); } function show_block_category_left($PageID,$block) { $sql = "select * from newsgroup ng JOIN `".$GLOBALS['table_prefix']."newsgroup_lang` ngl ON ng.NewsGroupID = ngl.NewsGroupID where ng.`PageID`='$PageID' AND ngl.Lang='".$_SESSION['lang']."' ORDER BY `Order` DESC"; $result=db_get_array($sql); foreach($result as $i => $row) { show_list_news($row['NewsGroupID'],"$block",6); parse_block($row,"main.$block"); } } function show_list_newsgroup_by_PageID($block,$PageID, $limit = 0) { $limit = $limit>0?"LIMIT 0,$limit":''; $sql = "select * from newsgroup ng JOIN `".$GLOBALS['table_prefix']."newsgroup_lang` ngl ON ng.NewsGroupID = ngl.NewsGroupID where ng.`PageID`='$PageID' AND ngl.Lang='".$_SESSION['lang']."' ORDER BY `Order` DESC $limit"; $result=db_get_array($sql); foreach($result as $i => $row) { parse_block($row,"main.$block.list_group"); } if(count($result)>0) parse_block(array(),"main.$block"); } function show_block_category_trangchu($block='') { //Area = 9 -> Banner trang chủ (sen kẻ với block category) (735... $sql = "select * from `".$GLOBALS['table_prefix']."banner` where UserID = 0 AND Status = 1 AND Area = 9 ORDER BY `BannerID` DESC"; $banner=db_get_array($sql); $sql = "select *,CategoryName_".$_SESSION['lang']." as CategoryName, Active_".$_SESSION['lang']." as Active from `".$GLOBALS['table_prefix']."category` where Active_".$_SESSION['lang']." = 'Y' AND BlockHomePage = 'Y' ORDER BY `Order` DESC"; $result=db_get_array($sql); $j = 0; foreach($result as $i => $row) {//show san pham $numsp = show_products_by_id_limit("$block.product",$row['CategoryID'],10); if($numsp>0){ $sql2 = "select *,CategoryName_".$_SESSION['lang']." as CategoryName, Active_".$_SESSION['lang']." as Active from `".$GLOBALS['table_prefix']."category` where Active_".$_SESSION['lang']." = 'Y' AND Parent = '".$row['CategoryID']."' ORDER BY `Order` DESC LIMIT 0,4"; $result2=db_get_array($sql2); foreach($result2 as $i2 => $row2) { $row2['CategoryNameG']= url_google($row2['CategoryName']); parse_block($row2,"main.$block.sub_cate"); } //show banner $banner_item = $banner[$j]; $banner_item['class'] = ($k+1)%2==0?'fr':'fl'; $banner_item['LinkType2'] = $banner_item['LinkType']==2?'target="_blank"':''; $banner_item['Link_a'] = $banner_item['LinkType']==0?'':''; $banner_item['Link_a_end'] = $banner_item['LinkType']==0?'':''; if(($banner_item['FileName']=='')||(($banner_item['FileName']!='')&&!file_exists('images/banner/'.$banner_item['FileName']))) {} else{ if(strtolower(fileExtension($banner_item['FileName'])) == "flv" || fileExtension(strtolower($banner_item['FileName'])) == "swf") parse_block($banner_item,"main.$block.banner.flash_type"); else{ parse_block($banner_item,"main.$block.banner.image_type"); } parse_block($banner_item,"main.$block.banner"); } if(($row['Image2']=='')||(($row['Image2']!='')&&!file_exists('images/news_img/'.$row['Image2']))) { $row['Image2']='cate.jpg'; } //echo $row['url_cate']; $row['CategoryNameG']= url_google($row['CategoryName']); $row['Link_a'] = $row['url_cate']==''?'':''; $row['Link_a_end'] = $row['url_cate']==''?'':''; parse_block($row,"main.$block"); $j++; } } for($a=$j;$a'; $banner_item['Link_a_end'] = $banner_item['LinkType']==0?'':''; if(($banner_item['FileName']=='')||(($banner_item['FileName']!='')&&!file_exists('images/banner/'.$banner_item['FileName']))) {} else{ if(strtolower(fileExtension($banner_item['FileName'])) == "flv" || fileExtension(strtolower($banner_item['FileName'])) == "swf") parse_block($banner_item,"main.banner_block_2.flash_type"); else{ parse_block($banner_item,"main.banner_block_2.image_type"); } parse_block($banner_item,"main.banner_block_2"); } } } function show_block_newsgroup_trangchu($block='show_link_seo',$PageID) { $sql = "select * from newsgroup ng JOIN `".$GLOBALS['table_prefix']."newsgroup_lang` ngl ON ng.NewsGroupID = ngl.NewsGroupID where ng.`PageID`='3' AND ngl.Lang='".$_SESSION['lang']."' ORDER BY `Order` DESC"; $result=db_get_array($sql); //echo count($result); foreach($result as $i => $row) { $sql2 = "select * from newsgroup ng JOIN `".$GLOBALS['table_prefix']."newsgroup_lang` ngl ON ng.NewsGroupID = ngl.NewsGroupID where ng.`Parent`='".$row['NewsGroupID']."' AND ngl.Lang='".$_SESSION['lang']."' ORDER BY `Order` DESC"; $result2=db_get_array($sql2); foreach($result2 as $i => $row2) { $row2['page'] = in_array($row2['PageID'],array(1,2))?ROOT_BASE.$row2['Description'].'_'.$row2['NewsGroupID'].'.html' : ROOT_BASE.$row2['Description'].'.html'; parse_block($row2,"main.$block.list_group"); } // $row['end'] = ($i+1)%4==0?'col1-no-margin':''; parse_block($row,"main.$block"); } } function show_list_news($id=1,$nameblock='content',$page_size_front=0) { $id=intval($id); $arr=getListSonGroup($id); if(count($arr)>0) $sql_u="AND (n.NewsGroupID=$id OR n.NewsGroupID=".implode(" OR n.NewsGroupID=",$arr).")"; else $sql_u=" AND n.NewsGroupID=$id "; global $record_total; $LIMIT = $page_size_front==0 ? '' : " LIMIT 0, ".$page_size_front ; $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*, n.Date as Date2, ngl.Description as page, n.NewsGroupID "; $sql.= " FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID JOIN newsgroup_lang ngl ON n.NewsGroupID = ngl.NewsGroupID"; $sql.= " WHERE nl.Lang='".$_SESSION['lang']."' AND ngl.Lang='".$_SESSION['lang']."' "; $sql.= " $sql_u "; $sql.= " AND nl.Status=1"; $sql.= " ORDER BY n.`NewsID` DESC "; $sql.= $LIMIT; //echo $sql; $return = db_get_array($sql); foreach($return as $i => $row) { if(($row['Image']=='')||(($row['Image']!='')&&!file_exists('images/news_img/'.$row['Image']))) { $row['Image']='no_img.png'; } $row['Title_G']= url_google($row['Title']); $row['Summary'] = rutgonchuoi(strip_tags($row['Content']),70); //$row["Title2"] = rutgonchuoi($row["Title"],35,'...'); $row["Date3"] = export_date5($row["Date2"]); /*if($i == 0){ $row['Title_G']= url_google($row['Title']); parse_block($row,'main.'.$nameblock.'.list_news_1'); } else*/ parse_block($row,'main.'.$nameblock.'.list_news'); } } function show_item_lichhathanh($id=0,$nameblock='list_F_lichphathanh') { //db_query("update news_lang set Status = 0 where DateStart < DATE_FORMAT(NOW(),'%Y-%m-%d') AND DateStart != '000-00-00'"); //$sql = "Select ng.`NewsGroupID`,ngl.`GroupName` from `newsgroup` ng,`newsgroup_lang` ngl where ng.`NewsGroupID`= ngl.`NewsGroupID` AND `PageID` = 15 ORDER BY `Order` DESC, NewsGroupID DESC"; // $group = db_get_array($sql); //foreach($group as $i => $newsgroup) //{ //$sql_u =" AND ng.NewsGroupID = ".$newsgroup['NewsGroupID']; $sql = "Select SQL_CALC_FOUND_ROWS n.NewsID, nl.Title, nl.Content, DATE_FORMAT(nl.DateStart,'%d-%m-%Y') as DateStart2 From news n, news_lang nl, newsgroup ng, newsgroup_lang ngl Where ng.`PageID` = 15 AND n.NewsID = nl.NewsID AND ng.NewsGroupID = n.NewsGroupID AND ngl.NewsGroupID = n.NewsGroupID AND ngl.Lang='".$_SESSION['lang']."' AND nl.Status =1 AND nl.Lang='".$_SESSION['lang']."' ORDER BY DateStart DESC, ng.`Order` DESC, n.NewsID DESC "; $return = db_get_array($sql); foreach($return as $i => $row) { parse_block($row,'main.'.$nameblock.'.item'); } parse_block($newsgroup,'main.'.$nameblock); //} } function show_cb_lichphathanh($block,$ID=0) { $return = db_get_array("SELECT * FROM `".$GLOBALS['table_prefix']."newsgroup` ng JOIN newsgroup_lang ngl ON ng.NewsGroupID = ngl.NewsGroupID WHERE ng.PageID = $ID ORDER BY ng.`Order` DESC, ng.NewsGroupID DESC"); // echo "SELECT * FROM `".$GLOBALS['table_prefix']."newsgroup` ng JOIN newsgroup_lang ngl ON ng.NewsGroupID = ngl.NewsGroupID WHERE ng.PageID = $ID ORDER BY ng.`Order` DESC"; $IDF = 0; foreach($return as $k => $v) { if($k==0) $IDF = $v['NewsGroupID']; parse_block($v,'main.'.$block); } return $IDF; } function get_page_template($page){ $page = str_replace('ct-','',$page); $sql = "SELECT pt.* FROM `".$GLOBALS['table_prefix']."newsgroup` ng JOIN newsgroup_lang ngl ON ng.NewsGroupID = ngl.NewsGroupID left JOIN page_template pt ON ng.PageID = pt.ID WHERE ngl.Description = '$page' LIMIT 0 ,1"; //echo $sql; $return = db_get_row($sql); return $return['Page']; } function rutgonchuoi($chuoi,$gioidan=30,$more='...') { $chuoi = trim($chuoi); $chuoi = str_replace(' ',' ',$chuoi); $chuoi = str_replace(' ',' ',$chuoi); //$mang = explode(' ',$chuoi); $html =''; if(@strpos($chuoi," ",$gioidan)>0){ $html = substr($chuoi,0,strpos($chuoi," ",$gioidan)); $html .= $more; } else{ $html = $chuoi; } return $html; } function show_list_video($page_size_front=4,$block='video_list') { $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM `".$GLOBALS['table_prefix']."video` order by VideoID desc limit 0,".$page_size_front; $return = db_get_array($sql); foreach($return as $i => $row) { if(($row['Image']=='')||(($row['Image']!='')&&!file_exists('video/'.$row['Image']))) { $row['Image']='no_img.png'; } $row['clear_div'] = $i>0 ? 'margin-top:2px;' :''; //print_r($row); parse_block($row,"main.$block"); } } function getDuAn($DuAnID) { $DuAnID=intval($DuAnID); $sql = "select d.* from `".$GLOBALS['table_prefix']."duan` d where Active = 'Y' AND DuAnID = '$DuAnID' limit 1;"; $return = db_get_row($sql); $return['DuAnName_G']=url_google($return['DuAnName']); return $return; } function export_date5($time) { $date = getdate($time); $ngay = $date['mday']; $thang = $date['mon']; $nam = $date['year']; $gio = $date['hours']; $phut = $date['minutes']; if(intval($gio)>11) $ap = "PM"; else $ap = "AM"; $gio = ($gio>12)?($gio-12):$gio; $gio = ($gio<10)?'0'.$gio:$gio; $phut = ($phut<10)?'0'.$phut:$phut; $ngay = ($ngay<10)?'0'.$ngay:$ngay; $thang = ($thang<10)?'0'.$thang:$thang; //$ngaythang = "$ngay-$thang-$nam - $gio:$phut $ap"; $ngaythang = "$ngay-$thang-$nam $gio:$phut $ap"; return $ngaythang; } function get_image_duan($DuAnID){ $sql = "SELECT PicPath FROM pic_duan WHERE DuAnID = '".$DuAnID."' ORDER BY PicID DESC LIMIT 6 "; $return = db_get_array($sql); $count = 0; foreach($return as $k => $v) { if(($v['PicPath']=='')||(($v['PicPath']!='')&&!file_exists('images/news_img/'.$v['PicPath']))) {} else{ return $v['PicPath']; $count++; } } return 'no_img.png'; } function get_list_image_duan($DuAnID){ $sql = "SELECT PicPath FROM pic_duan WHERE DuAnID = '".$DuAnID."' ORDER BY PicID DESC"; $return = db_get_array($sql); $count = 0; $PicPath = array(); foreach($return as $k => $v) { if(($v['PicPath']=='')||(($v['PicPath']!='')&&!file_exists('images/news_img/'.$v['PicPath']))) { $v['PicPath'] = 'no_img.png'; } else{ $v['display'] = ' style="display:'.($count == 0?'block':'none').'" '; parse_block($v,'main.content.list_pic'); $count++; } } if($count == 0){ $v['display'] = ''; $v['PicPath'] = 'no_img.png'; parse_block($v,'main.content.list_pic'); } return $count; } function fileExtension($file) { $fileExp = explode('.', $file); // make array off the periods $filetype = $fileExp[count($fileExp) -1]; // file extension will be last index in array, -1 for 0-based indexes return $filetype; } function fileExtension2($file) { $fileExp = explode('.', $file); // make array off the periods $filetype = $fileExp[count($fileExp) -1]; // file extension will be last index in array, -1 for 0-based indexes return $filetype; } function ins_ykiem() { if($_SESSION['ykien'] != ""){ return; } else{ if(intval($_REQUEST['id']) >0){ $_SESSION['ykien'] = time(); $sql = "SELECT SQL_CALC_FOUND_ROWS *"; $sql.= " FROM `".$GLOBALS['table_prefix']."question` "; $sql.= " WHERE Status ='Y' "; $sql.= " ORDER BY `qid` DESC LIMIT 1"; $question = db_get_row($sql); $qid = $question["qid"]; $sql = "UPDATE answer SET acount = acount +1 Where aid = '".$_REQUEST['id']."'"; $result = $GLOBALS["DB"]->query($sql); } } } function show_banner_left_right($block,$Area,$limit=0) { $limit = $limit>0? "LIMIT 0,$limit" : ''; $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = $Area AND Status = 1 ORDER BY BannerID Desc $limit"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['clear_div'] = ($k+1)%4==0? (($k+1)
    ':''):''; $v['class'] = ($k+1)%2==0?'fr':'fl'; $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; $v['Summary'] = ($v['Summary']!='
    ' && $v['Summary']!='')?$v['Summary']:$v['BannerName']; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,"main.$block.flash_type"); else{ parse_block($v,"main.$block.image_type"); } parse_block($v,"main.$block"); } } } function show_banner_center_home() { $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 8 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_1.flash_type'); else{ parse_block($v,'main.show_banner_center_1.image_type'); } parse_block($v,'main.show_banner_center_1'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 9 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_2.flash_type'); else{ parse_block($v,'main.show_banner_center_2.image_type'); } parse_block($v,'main.show_banner_center_2'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 10 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_3.flash_type'); else{ parse_block($v,'main.show_banner_center_3.image_type'); } parse_block($v,'main.show_banner_center_3'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 14 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_4.flash_type'); else{ parse_block($v,'main.show_banner_center_4.image_type'); } parse_block($v,'main.show_banner_center_4'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 15 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_5.flash_type'); else{ parse_block($v,'main.show_banner_center_5.image_type'); } parse_block($v,'main.show_banner_center_5'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 16 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_6.flash_type'); else{ parse_block($v,'main.show_banner_center_6.image_type'); } parse_block($v,'main.show_banner_center_6'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 17 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_7.flash_type'); else{ parse_block($v,'main.show_banner_center_7.image_type'); } parse_block($v,'main.show_banner_center_7'); } } $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 18 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_8.flash_type'); else{ parse_block($v,'main.show_banner_center_8.image_type'); } parse_block($v,'main.show_banner_center_8'); } } } function show_banner_center_list_news_page_str() { $str = ''; $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 11 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf"){ $str .='
    '; //parse_block($v,'main.show_banner_center_list_news_page_1.flash_type'); } else{ $str .='
    '.$v['Link_a'].' '.$v['BannerName'].' '.$v['Link_a_end'].'
    '; } } } return $str; } function show_banner_center_list_news_page() { $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 12 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_list_news_page_2.flash_type'); else{ parse_block($v,'main.show_banner_center_list_news_page_2.image_type'); } parse_block($v,'main.show_banner_center_list_news_page_2'); } } } function show_banner_center_list_detail_page() { $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE Area = 13 AND Status = 1 ORDER BY BannerID Desc"; $arr=db_get_array($sql); if(count($arr)>0){ foreach($arr as $k => $v) { $v['LinkType2'] = $v['LinkType']==2?'target="_blank"':''; $v['Link_a'] = $v['LinkType']==0?'':''; $v['Link_a_end'] = $v['LinkType']==0?'':''; if(strtolower(fileExtension($v['FileName'])) == "flv" || fileExtension(strtolower($v['FileName'])) == "swf") parse_block($v,'main.show_banner_center_list_detail_page.flash_type'); else{ parse_block($v,'main.show_banner_center_list_detail_page.image_type'); } parse_block($v,'main.show_banner_center_list_detail_page'); } } } function show_lienketweb($id) { $sql = "SELECT n.*,nl.* from `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID WHERE nl.Lang='".$_SESSION['lang']."' and (n.`NewsGroupID` = $id) ORDER BY n.`Date` desc; "; //echo $sql; $return = db_get_array($sql); //echo $sql; foreach($return as $k => $v){ $v['Summary'] = strip_tags($v['Summary']); parse_block($v,'main.is_links_web.links_web'); } $v['select_str'] = $_SESSION['lang'] == 'VN' ? 'LIÊN KẾT WEBSITE' : 'LINK'; if(count($return )>0) parse_block($v,'main.is_links_web'); } function show_ketqua() { $sql = "SELECT SQL_CALC_FOUND_ROWS *"; $sql.= " FROM `".$GLOBALS['table_prefix']."question` "; $sql.= " WHERE Status ='Y' "; $sql.= " ORDER BY `qid` DESC LIMIT 1"; $question = db_get_row($sql); return $question; $qid = $question["qid"]; $question = $question["qtitle"]; $answer = db_get_array("Select SQL_CALC_FOUND_ROWS * From answer Where qid = $qid"); foreach($answer as $k => $v){ parse_block($v,'main.show_question.show_answer'); } parse_block($question,'main.show_question'); } function count_ketqua($id) { $sql = "SELECT SQL_CALC_FOUND_ROWS SUM(acount) as SUM"; $sql.= " FROM `".$GLOBALS['table_prefix']."answer` "; $sql.= " WHERE qid =$id "; $SUM = db_get_row($sql); return $SUM ; } function show_list_5_new($page) { /*global $record_total; $start = intval($_REQUEST["p"]); if($start<=0)$start = 1; $page_size_front = 5; */ /*$start = ($start -1)*$page_size_front; */ $id=getPageID($page); $sql = "Select SQL_CALC_FOUND_ROWS * From news n JOIN news_lang nl ON n.NewsID = nl.NewsID Where n.Status =1 AND NewsGroupID = $id ORDER BY n.NewsID DESC LIMIT ".$start.", ".$page_size_front; //echo $sql; $return = db_get_array($sql ); /*$record_total = record_total(); page_invalid($record_total,$page_size_front);*/ foreach($return as $k => $v) { if(($v['Image']=='')||(($v['Image']!='')&&!file_exists('images/news_img/'.$v['Image']))) { $v['Image']='no_img.png'; } $row['TitleG']= url_google($row['Title']); $row["Date3"] = export_date5($row["Date2"]); parse_block($v,'main.list_news'); } } function show_hotline($id) { $sql = "Select SQL_CALC_FOUND_ROWS * From news n JOIN news_lang nl ON n.NewsID = nl.NewsID Where nl.Status =1 AND n.NewsGroupID = '".$id."' ORDER BY n.NewsID DESC"; //echo $sql ; $return = db_get_array($sql ); foreach($return as $k => $v) { parse_block($v,'main.hotline'); } } function show_help_list($limit = 0) { $limit = $limit == 0 ? '' : 'LIMIT 0,'.$limit; $sql = "Select SQL_CALC_FOUND_ROWS * From helpgroup hp JOIN helponline_lang hpl ON hp.HelpID = hpl.HelpID Where hpl.Active = 'Y' AND hpl.Lang='".$_SESSION['lang']."' ".$limit; //echo $sql ; $return = db_get_array($sql ); foreach($return as $k => $v) { $v['check'] = Get_status($v['YahooID'])?'Online':'Offline'; parse_block($v,'main.help_list'); } } function Get_status($yahooid){ /*$status = file_get_contents("http://opi.yahoo.com/online?u=$yahooid&m=a&t=1"); if ($status === '01') return true; else*/ return false; } function show_ketqua2() { $sql = "SELECT SQL_CALC_FOUND_ROWS *"; $sql.= " FROM `".$GLOBALS['table_prefix']."question` "; $sql.= " WHERE Status ='Y' "; $sql.= " ORDER BY `qid` DESC LIMIT 1"; $question = db_get_row($sql); $qid = $question["qid"]; $question = $question["qtitle"]; $answer = db_get_array("Select SQL_CALC_FOUND_ROWS * From answer Where qid = $qid"); return $answer; } function show_question() { $sql = "SELECT SQL_CALC_FOUND_ROWS *"; $sql.= " FROM `".$GLOBALS['table_prefix']."question` "; $sql.= " WHERE Status ='Y' "; $sql.= " ORDER BY `qid` DESC LIMIT 1"; $question = db_get_row($sql); $qid = $question["qid"]; $answer = db_get_array("Select SQL_CALC_FOUND_ROWS * From answer Where qid = $qid"); foreach($answer as $k => $v){ $v['no'] = $k; parse_block($v,'main.show_question.show_answer'); } $question['tt'] =$v['aid']; $question['count'] =$k; parse_block($question,'main.show_question'); } function show_banner_company() { $return = db_get_array("Select SQL_CALC_FOUND_ROWS * From productcompany Where Active ='Y' "); foreach($return as $k => $v) { if(($v['Image']=='')||(($v['Image']!='')&&!file_exists('images/news_img/'.$v['Image']))) { } else{ parse_block($v,'main.banner_company'); } } } function list_product_noibat() { $return = db_get_array("Select SQL_CALC_FOUND_ROWS * From products Where Active_".$_SESSION['lang']." ='Y' AND `Bestbuy` ='Y' ORDER BY `Order` desc, `ProductID` desc"); foreach($return as $k => $v) { if(($v['ProductImage_'.$_SESSION['lang']]=='')||(($v['ProductImage_'.$_SESSION['lang']]!='')&&!file_exists('images/news_img/'.$v['ProductImage_'.$_SESSION['lang']]))) { } else{ $v['ProductNameG']=url_google($v['ProductName_'.$_SESSION['lang']]); $v['ProductImage'] = $v['ProductImage_'.$_SESSION['lang']]; $v['ProductName'] = $v['ProductName_'.$_SESSION['lang']]; parse_block($v,'main.list_product_noibat'); } } } function show_list_news_2($id=1,$nameblock='content',$page_size_front=0,$cut=400) { $id=intval($id); global $record_total; //$start = intval($GLOBALS["start"]); $LIMIT = $page_size_front==0 ? '' : " LIMIT 0, ".$page_size_front ; $sql = "Select SQL_CALC_FOUND_ROWS n.NewsID, nl.Title,nl.Summary, nl.Image, nl.Content,nl.Tooltip , n.Read, n.Date as Date2, ngl.* From news n, news_lang nl, newsgroup ng, newsgroup_lang ngl Where n.NewsID = nl.NewsID AND ng.NewsGroupID = n.NewsGroupID AND ngl.NewsGroupID = n.NewsGroupID AND ngl.Lang='".$_SESSION['lang']."' AND nl.Status =1 AND ng.PageID = $id AND nl.Lang='".$_SESSION['lang']."' ORDER BY n.`Order` DESC, n.NewsID DESC "; $sql.= $LIMIT; $return = db_get_array($sql); foreach($return as $i => $row) { parse_block($row,'main.'.$nameblock); } } function show_list_news_4($id=1,$nameblock='content',$page_size_front=0,$cut=400) { $id=intval($id); global $record_total; //$start = intval($GLOBALS["start"]); $LIMIT = $page_size_front==0 ? '' : " LIMIT 0, ".$page_size_front ; //if($page_size_front==0) //$page_size_front = $GLOBALS['page_size_front']; $arr=getListSonGroup($id); if(count($arr)>0) $sql_u=" OR n.NewsGroupID=".implode(" OR n.NewsGroupID=",$arr); else $sql_u=""; $sql = "Select SQL_CALC_FOUND_ROWS n.NewsID, nl.Title, nl.Image, nl.Content,nl.Tooltip , n.Read, n.Date as Date2, ngl.* From news n, news_lang nl, newsgroup ng, newsgroup_lang ngl Where n.NewsID = nl.NewsID AND ng.NewsGroupID = n.NewsGroupID AND ngl.NewsGroupID = n.NewsGroupID AND ngl.Lang='".$_SESSION['lang']."' AND nl.Status =1 AND ng.PageID = $id AND nl.Lang='".$_SESSION['lang']."' ORDER BY n.`Order` DESC, n.NewsID DESC "; $sql.= $LIMIT; //if($id == 5)echo $sql; $return = db_get_array($sql); $record_total = record_total(); /*page_invalid($record_total,$page_size_front); parse_variable('print_page',print_page($page_size_front,'start','page_links'));*/ if(count($return)>0){ for($i= count($return)-1; $i>=0; $i--) { $row = $return[$i]; if(($row['Image']=='')||(($row['Image']!='')&&!file_exists('images/news_img/'.$row['Image']))) { $row['Image']='no_img.png'; } $row['Title_G']= url_google($row['Title']); $row["Content2"] =rutgonchuoi(trim(strip_tags($row["Content"])),$cut,'...'); // $row['GIA'] = $_SESSION['lang'] == 'VN' ? 'Giá' : 'Price'; $row["Date3"] = export_date5($row["Date2"]); $row["page"] = $row["Description"]; parse_block($row,'main.'.$nameblock.'.list_news'); } } if(count($return)>0){ $row['GroupName'] = getCategoryNewName($row['NewsGroupID']); $row["page"] = $row["Description"]; parse_block($row,'main.'.$nameblock); } } function show_list_news_3($id=1,$page_size_front=6) { $id=intval($id); $LIMIT = $page_size_front==0 ? '' : " LIMIT 0, ".$page_size_front ; //$sql = "Select SQL_CALC_FOUND_ROWS *, n.Read, n.Date as Date2 From news n JOIN news_lang nl ON n.NewsID = nl.NewsID Where n.Status =1 AND nl.Lang='".$_SESSION['lang']."' AND NewsGroupID = $id ORDER BY n.NewsID DESC "; $sql = "Select SQL_CALC_FOUND_ROWS n.NewsID, nl.Title, nl.Image, nl.Content , n.Read, n.Date as Date2, ngl.* From news n, news_lang nl, newsgroup ng, newsgroup_lang ngl Where n.NewsID = nl.NewsID AND ng.NewsGroupID = n.NewsGroupID AND ngl.NewsGroupID = n.NewsGroupID AND ngl.Lang='".$_SESSION['lang']."' AND nl.Status =1 AND ng.PageID = $id AND nl.Lang='".$_SESSION['lang']."' ORDER BY n.`Order` DESC, n.NewsID DESC "; $sql.= $LIMIT; //echo $sql; $return = db_get_array($sql); $record_total = record_total(); $i = 1; foreach($return as $k => $row) { if(($row['Image']=='')||(($row['Image']!='')&&!file_exists('images/news_img/'.$row['Image']))) { $row['Image']='no_img.png'; } $row['Title_G']= url_google($row['Title']); $row["Content2"] = rutgonchuoi(trim(strip_tags($row["Content"])),300,'...'); $row["Date3"] = export_date5($row["Date2"]); if(($v['Image']=='')||(($v['Image']!='')&&!file_exists('images/news_img/'.$v['Image']))) { $v['Image']='no_img.png'; } $column_type = ($k+1)%2 == 0? '_left':'_right'; $block = $k>1? 'list2':'list1'; parse_block($row,'main.block_baiviet.list_baiviet'.$column_type.'.'.$block); } if(count($return)>0){ $row['GroupName'] = getCategoryNewName($row['NewsGroupID']); parse_block($row,'main.block_baiviet.list_baiviet_left'); parse_block($row,'main.block_baiviet.list_baiviet_right'); parse_block($row,'main.block_baiviet'); } } function show_products_promo() { $sql = "Select SQL_CALC_FOUND_ROWS * From products Where Promo='Y' AND Active ='Y' ".$sql_u." ORDER BY RAND() LIMIT 0,5"; //echo $sql; $return = db_get_array($sql ); foreach($return as $k => $v) { if(($v['ProductImage']=='')||(($v['ProductImage']!='')&&!file_exists('images/news_img/'.$v['ProductImage']))) { $v['ProductImage']='no_img.png'; } $v['Price']=$v['Price']==0?"Call":addSignIntoNumber($v['Price']); $v['PriceNew']=$v['PriceNew']==0?"Call":addSignIntoNumber($v['PriceNew']); parse_block($v,'main.product_left_promo'); } } function show_news_other($NewsGroupID,$id,$Order=0,$nameblock='other',$page_size_front=10,$page_n='',$UserID=0) { $sql_u = " AND (NewsGroupID = '$NewsGroupID' OR NewsGroupID IN( SELECT NewsGroupID FROM newsgroup WHERE Parent = '$NewsGroupID')) " ; $sql_u .= $UserID>0?" AND n.UserID = $UserID":''; $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*, n.Date as Date2 FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID WHERE nl.Lang='".$_SESSION['lang']."' AND n.NewsID != '$id' AND n.`Order` >= '$Order' $sql_u ORDER BY n.`Order` DESC, n.NewsID Desc LIMIT 0, ".ceil($page_size_front/2); //echo $sql; $return1 = db_get_array($sql ); if((count($return1)<$page_size_front)){ $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*, n.Date as Date2 FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID WHERE nl.Lang='".$_SESSION['lang']."' AND n.NewsID != '$id' AND n.`Order` < '$Order' $sql_u ORDER BY n.`Order` DESC, n.NewsID Desc LIMIT 0,".($page_size_front-count($return1)); $return2 = db_get_array($sql ); } //$count_1 = 6-count($return1); if(count($return2)<$page_size_front-count($return1)){ $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*, n.Date as Date2 FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID WHERE nl.Lang='".$_SESSION['lang']."' AND n.NewsID != '$id' AND n.`Order` >= '$Order' $sql_u ORDER BY n.`Order` DESC, n.NewsID ASC LIMIT 0,".($page_size_front-count($return2)); $return1 = db_get_array($sql ); } $j=1; for($tu = count($return1)-1; $tu>=0;$tu--){ $return1[$tu]['TitleG']=url_google($return1[$tu]['Title']); $return1[$tu]["odd"] = $j%2==0?'odd':''; $return1[$tu]["Date3"] = export_date5($return1[$tu]["Date2"]); $img = $return1[$tu]["Image"]; if(($img=='')||(($img!='')&&!file_exists('images/news_img/'.$img))) { $img='no_img.png'; } $return1[$tu]['last'] = $j%3==0? 'last':''; $return1[$tu]["Image"] = $img; $return1[$tu]["page"] = $GLOBALS['page']; parse_block($return1[$tu],'main.'.$nameblock.'.news'); $j++; } if(count($return2)>0) foreach($return2 as $k => $v){ $v['TitleG']=url_google($v['Title']); $v["odd"] = $j%2==0?'odd':''; $v["Date3"] = export_date5($v["Date2"]); $img = $v["Image"]; if(($img=='')||(($img!='')&&!file_exists('images/news_img/'.$img))) { $img='no_img.png'; } $v["Image"] = $img; //$v['clear_div'] = ($k+1)%3==0? ($i
    ':''):''; $v['last'] = $j%3==0? 'last':''; $v["page"] = $GLOBALS['page']; parse_block($v,'main.'.$nameblock.'.news'); $j++; } //echo $j; if($j>1) parse_block($v,'main.'.$nameblock); return $j; } function show_news_other_banner($nameblock,$page_size_front=10,$id) { $sql_u = " AND Area = 3 AND Status = 1" ; //$sql = "SELECT SQL_CALC_FOUND_ROWS nl.*, n.Date as Date2 FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID WHERE nl.Lang='".$_SESSION['lang']."' AND n.NewsID > '$id' $sql_u ORDER BY n.NewsID Desc LIMIT 0, ".ceil($page_size_front/2); $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE BannerID > $id $sql_u ORDER by BannerID ASC LIMIT 0, ".ceil($page_size_front/2); //echo $sql; $return1 = db_get_array($sql ); if((count($return1)<$page_size_front)){ $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE BannerID < '$id' $sql_u ORDER BY BannerID Desc LIMIT 0,".($page_size_front-count($return1)); $return2 = db_get_array($sql ); } //$count_1 = 6-count($return1); if(count($return2)<$page_size_front-count($return1)){ $sql = "SELECT * FROM `".$GLOBALS['table_prefix']."banner` WHERE BannerID > $id $sql_u ORDER BY BannerID ASC LIMIT 0,".($page_size_front-count($return2)); $return1 = db_get_array($sql ); } $j=1; for($tu = count($return1)-1; $tu>=0;$tu--){ $return1[$tu]['TitleG']=url_google($return1[$tu]['BannerName']); parse_block($return1[$tu],'main.'.$nameblock.'.news'); $j++; } if(count($return2)>0) foreach($return2 as $k => $v){ $v['TitleG']=url_google($v['BannerName']); parse_block($v,'main.'.$nameblock.'.news'); $j++; } //echo $j; if($j>1) parse_block($v,'main.'.$nameblock); return $j; } function module_dang_nhap($error, $form) { if($error != "" && $form == 'do_login'){ $be2['msg_err'] = $error; $be2['UserName'] = $_REQUEST['UserName']; $be2['Pass'] = $_REQUEST['Pass']; } if(is_not_login()){ parse_block($be2,'main.module_dang_nhap.not_login'); } else{ $u = db_get_row("select * from user u where u.UserID = '".$_SESSION["user"]['UserID']."'"); $_SESSION["user"] = $u; $u['UserAmount'] = addSignIntoNumber($u['UserAmount']); parse_block($u,'main.module_dang_nhap.is_login'); } parse_block(array(),'main.module_dang_nhap'); } function show_product($id) { $sql="select * from ".$GLOBALS['table_prefix']."products where ProductID='".intval($id)."' limit 0,1"; return db_get_row($sql); } function show_price_search($title_pr,$value_pr) { for($k = 0; $k< count($title_pr);$k++) { $be['title'] = $title_pr[$k]; $be['value'] = $k+1; if($_REQUEST["pr"] == ($k+1)){ $be['active'] = ' selected="selected"'; } else $be['active'] = ""; parse_block($be,'main.show_price_search'); } } function show_cate_menu() { $return = db_get_array("Select * From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND (Parent=0 OR ISNULL(Parent)) "); foreach($return as $k => $v) { if($_REQUEST["id"] == $v['CategoryID']) $v['active'] = ' class="selected"'; else $v['active'] = ""; //echo "Select * From ".$GLOBALS['table_prefix']."category Where Active ='Y' AND Parent=".$v['CategoryID']." "; $return2 = db_get_array("Select * From ".$GLOBALS['table_prefix']."category Where Parent=".$v['CategoryID']." "); if(count($return2)>0) { foreach($return2 as $k2 => $v2) { if($_REQUEST["id"] == $v2['CategoryID']) $v2['active'] = ' class="selected"'; else $v2['active'] = ""; $v2['CategoryNameG']=url_google($v2['CategoryName'.$_SESSION['lang']]); parse_block($v2,'main.show_sub_category.show_sub_category2.data'); } parse_block($v2,'main.show_sub_category.show_sub_category2'); } $v['CategoryNameG']=url_google($v['CategoryName'].$_SESSION['lang']); parse_block($v,'main.show_sub_category'); } } function get_power_shop_array($ShopID=0) { $result = db_get_array("Select ProductPowerID From ".$GLOBALS['table_prefix']."user_shop_power where ShopID = $ShopID ORDER BY ProductPowerID ASC"); $arr = array(); foreach($result as $k => $v) { $arr[] = $v['ProductPowerID']; } return $arr; } function show_productpower($block,$ShopID=0) { $return = db_get_array("Select * From ".$GLOBALS['table_prefix']."productpower"); $array_active = array(); if($ShopID>0) $array_active = get_power_shop_array($ShopID); foreach($return as $k => $v) { if(in_array($v['ProductPowerID'],$array_active)) $v['active'] = ' selected="selected"'; else $v['active'] = ""; $v['PowerTitle_G']= url_google($v['PowerTitle']); parse_block($v,"main.$block"); } } function show_company_search() { $return = db_get_array("Select * From ".$GLOBALS['table_prefix']."productcompany Where Active ='Y'"); foreach($return as $k => $v) { if($_REQUEST["cp"] == $v['productCompanyID']) $v['active'] = ' selected="selected"'; else $v['active'] = ""; parse_block($v,'main.show_company_search'); } } function show_category_search() { $return = db_get_array("Select * From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND Parent = 0 ORDER BY `Order` DESC"); foreach($return as $k => $v) { $result2 = db_get_array("Select * From ".$GLOBALS['table_prefix']."category Where Active_".$_SESSION['lang']." ='Y' AND Parent = ".$v['CategoryID']." ORDER BY `Order` DESC"); foreach($result2 as $k2 => $v2) { $v2['CategoryName']= $v2['CategoryName_'.$_SESSION['lang']]; $v2['CategoryNameG']= url_google($v2['CategoryName']); parse_block($v2,'main.show_category_nav.is_sup.list_sup'); } if(count($result2)>0) parse_block($v,'main.show_category_nav.is_sup'); if($_REQUEST["cid_s"] == $v['CategoryID']) $v['active'] = ' selected="selected" '; else $v['active'] = ""; $v['CategoryName']= $v['CategoryName_'.$_SESSION['lang']]; $v['CategoryNameG']= url_google($v['CategoryName']); parse_block($v,'main.show_category_search'); parse_block($v,'main.show_category_nav'); } } function show_company_product() { $return = db_get_array("Select * From ".$GLOBALS['table_prefix']."productcompany Where Active ='Y'"); foreach($return as $k => $v) { parse_block($v,'main.show_company_product'); } } function getListSonCate($id) { $sql = "SELECT CategoryID,Parent from `".$GLOBALS['table_prefix']."category` where Active_".$_SESSION['lang']." = 'Y'"; if(($id!=0)&&($id!='')) $sql.= " AND Parent='".$id."' "; else $sql.= " AND (Parent='".$id."' OR ISNULL(Parent)) "; $return = db_get_array($sql); if(count($return)>0) { foreach($return as $k => $v) { $arr[]=$v['CategoryID']; $arr2= getListSonCate($v['CategoryID']); if(count($arr2)>0) { $arr=array_merge($arr,$arr2); } } } return $arr; } function getListSonGroup($id) { $sql = "SELECT * from `".$GLOBALS['table_prefix']."newsgroup` "; if(($id!=0)&&($id!='')) $sql.= " WHERE Parent='".$id."' "; else $sql.= " WHERE (Parent='".$id."' OR ISNULL(Parent)) "; $return = db_get_array($sql); if(count($return)>0) { foreach($return as $k => $v) { $arr[]=$v['NewsGroupID']; $arr2= getListSonGroup($v['NewsGroupID']); if(count($arr2)>0) { $arr=array_merge($arr,$arr2); } } } return $arr; } function getCategoryName($id) { $sql = "SELECT CategoryName_".$_SESSION['lang']." as CategoryName from `".$GLOBALS['table_prefix']."category` c WHERE c.CategoryID='$id'"; $arr=db_get_row($sql); return $arr['CategoryName']; } function getCate_by_ProductID($id) { $sql = "SELECT c.CategoryID from `".$GLOBALS['table_prefix']."products` p join category c on p.CategoryID = c.CategoryID and c.Lang = '".$_SESSION['lang']."' WHERE p.ProductID='$id'"; //$sql; $arr=db_get_row($sql); return $arr['CategoryID']; } function getCompanyName($id) { $sql = "SELECT CompanyName from `".$GLOBALS['table_prefix']."productcompany` WHERE productCompanyID ='$id'"; $arr=db_get_row($sql); return $arr['CompanyName']; } function getPowerName($id) { $sql = "SELECT PowerTitle_".$_SESSION['lang']." from `".$GLOBALS['table_prefix']."productpower` WHERE ProductPowerID ='$id'"; $arr=db_get_row($sql); return $arr['PowerTitle_'.$_SESSION['lang']]; } //------------------------------------------------------------- function is_admin() { return ((!is_not_login())&&($_SESSION["user"]['Admin']==1)); } function is_uploader() { return ((!is_not_login())&&($_SESSION["user"]['Admin']==2)); } function is_moderater() { return (is_admin()|| is_uploader()); } function is_not_login() { if((count($_SESSION["user"])==0||!isset($_SESSION["user"])||$_SESSION["user"]=="")) return true; else return false; } function check_exists_session() { $sql="SELECT * "; $sql.=" FROM ".$GLOBALS['table_prefix']."statistics_sessions"; $sql.=" WHERE SessionPage = '".session_id()."'"; $sql.=" AND IP = '".get_ip()."'"; $sql.=" AND TimeLogin + Expiry > '".convert_datetime(get_current_time())."'"; $result = $GLOBALS["DB"]->query($sql) or die("getProduct: ".$GLOBALS["DB"]->error()); if($GLOBALS["DB"]->num_rows($result)>0) return true; else return false; } function insert_session() { $sql = "INSERT INTO ".$GLOBALS['table_prefix']."statistics_sessions SET"; $sql .= " OS = '".get_os()."',"; $sql .= " ClientType = 'G',"; $sql .= " UserID = '".$_SESSION["user"]['UserID']."',"; $sql .= " Browser = '".get_browser_name()."',"; $sql .= " UserAgent = '".$_SERVER['HTTP_USER_AGENT']."',"; $sql .= " ClientLanguage = '".$_SERVER['HTTP_ACCEPT_LANGUAGE']."',"; $sql .= " IP ='".get_ip()."',"; $sql .= " SessionPage = '".session_id()."',"; $sql .= " Referrer = '".$_SERVER['HTTP_REFERER']."',"; $sql .= " ReferrerHost = '".$_SERVER['SERVER_NAME']."/".$_SERVER['QUERY_STRING']."',"; $sql .= " TimeLogin = '".convert_datetime(get_current_time())."',"; $sql .= " DateCreate = NOW(),"; $sql .= " Expiry = '".$GLOBALS['expiry_session_timeout']."'"; $result = $GLOBALS["DB"]->query($sql) or die("getProduct: ".$GLOBALS["DB"]->error()); } function write_log($task,$note) { $data['UserID']=$_SESSION["user"]['UserID']; $data['Task']=$task; $data['Notes']=urlencode($note); $data['DateCreate']=get_current_time(); $data['URLMod']=urlencode($_SERVER['QUERY_STRING']); //print_r($data); db_insert_by_array('log_mod',$data); } //------------------------------------------------------------------------------- function getPageID($Description) { $sql = "select * from `".$GLOBALS['table_prefix']."newsgroup_lang` where `Description`='$Description' AND Lang='".$_SESSION['lang']."' limit 1;"; $r=db_get_row($sql); return intval($r['NewsGroupID']); } function getNews($NewsID) { $NewsID=intval($NewsID); $sql = "select nl.*, n.NewsGroupID, n.Date as Date2 from `".$GLOBALS['table_prefix']."news_lang` nl, `".$GLOBALS['table_prefix']."news` n where n.`NewsID` = nl.`NewsID` AND nl.`NewsID`=$NewsID AND nl.Lang='".$_SESSION['lang']."' limit 1;"; $return = db_get_row($sql); if(($return['Image']=='')||(($return['Image']!='')&&!file_exists('images/news_img/'.$return['Image']))) { $return['Image']='no_img.png'; } return $return; } function getCompany($productCompanyID) { $productCompanyID=intval($productCompanyID); $sql = "select * from `".$GLOBALS['table_prefix']."productcompany` where `productCompanyID`='$productCompanyID' limit 1;"; $return = db_get_row($sql); return $return; } function getGroupNews($NewsID) { $NewsID=intval($NewsID); $sql = "select * from `".$GLOBALS['table_prefix']."news` where `NewsID`=$NewsID limit 1;"; $r= db_get_row($sql); return intval($r['NewsGroupID']); } function getDateNews($NewsID) { $NewsID=intval($NewsID); $sql = "select * from `".$GLOBALS['table_prefix']."news` where `NewsID`=$NewsID limit 1;"; $r= db_get_row($sql); return ($r['Date']); } function getUserIDNews($NewsID) { $NewsID=intval($NewsID); $sql = "select * from `".$GLOBALS['table_prefix']."news` where `NewsID`=$NewsID limit 1;"; $r= db_get_row($sql); return intval($r['UserID']); } function getLaterNews($NewsGroupID) { $arr=getListSonGroup($NewsGroupID); if(count($arr)>0) $sql_u="(NewsGroupID=$NewsGroupID OR n.NewsGroupID=".implode(" OR n.NewsGroupID=",$arr).")"; else $sql_u=" NewsGroupID=$NewsGroupID "; //echo $sql_u; $sql = "select nl.* "; $sql.= " FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID "; $sql.= " WHERE $sql_u AND nl.Lang='".$_SESSION['lang']."' Order By `NewsID` DESC limit 1;"; //echo $sql; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); return $row['NewsID']; } function getFirstNews($NewsGroupID) { $sql = "select nl.* "; $sql.= " FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID "; $sql.= " WHERE `NewsGroupID`=$NewsGroupID AND nl.Lang='".$_SESSION['lang']."' Order By `Order` , `NewsID` limit 1;"; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); return $row['NewsID']; } function innit_page() { $sql = "SELECT gl.* "; $sql.= " FROM `".$GLOBALS['table_prefix']."newsgroup` g inner join `".$GLOBALS['table_prefix']."newsgroup_lang` gl on g.NewsGroupID = gl.NewsGroupID WHERE gl.Lang='".$_SESSION['lang']."' AND gl.Description!=''"; return db_get_hash_single_array($sql,'Description','GroupName'); } function getCategoryNewName($NewsGroupID) { $sql = "SELECT gl.* "; $sql.= " FROM `".$GLOBALS['table_prefix']."newsgroup` g inner join `".$GLOBALS['table_prefix']."newsgroup_lang` gl on g.NewsGroupID = gl.NewsGroupID WHERE gl.Lang='".$_SESSION['lang']."' AND g.NewsGroupID='$NewsGroupID'"; $da= db_get_row($sql); return $da['GroupName']; } function getIDRecordLess($newsID,$num_record) { $id=ceil($id); $sql = "SELECT NewsGroupID"; $sql.= " FROM `".$GLOBALS['table_prefix']."news`"; $sql.= " WHERE NewsID='$newsID' "; $sql.= " LIMIT 0, 1" ; //echo $sql; $result = $GLOBALS["DB"]->query($sql) or die("admin_loadProduct: ".$GLOBALS["DB"]->error()); while($row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH)) { $Parent=$row['NewsGroupID']; } $Parent=ceil($Parent); $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*"; $sql.= " FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID "; $sql.= " WHERE nl.Lang='".$_SESSION['lang']."' "; $sql.= " AND n.NewsID >'$newsID' "; $sql.= " AND n.NewsGroupID ='$Parent' "; $sql.= " ORDER BY n.NewsID "; $sql.= " LIMIT 0, $num_record" ; //echo $sql; $result = $GLOBALS["DB"]->query($sql) or die("admin_loadProduct: ".$GLOBALS["DB"]->error()); if($GLOBALS["DB"]->num_rows($result)) { while($row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH)) { $NewsID=$row['NewsID']; } return $NewsID; } else return $newsID; } // applied only number has 9 digits. Example: 123456789 -> 123.456.789 function show_box_link_law() { $sql = "SELECT SQL_CALC_FOUND_ROWS nl.*"; $sql.= " FROM `".$GLOBALS['table_prefix']."news` n inner join `".$GLOBALS['table_prefix']."news_lang` nl on nl.NewsID = n.NewsID "; $sql.= " WHERE nl.Lang='".$_SESSION['lang']."' "; $sql.= " AND n.NewsGroupID=63"; $sql.= " ORDER BY n.`Order` DESC "; //$sql.= " LIMIT 0, 5" ; $result = $GLOBALS["DB"]->query($sql) or die("admin_loadProduct: ".$GLOBALS["DB"]->error()); while($row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH)) { parse_block($row,'main.show_box_link_law.news'); } parse_block($be,'main.show_box_link_law'); } function show_customer($id) { $arr=getListSonCate($id); global $record_total; $start = intval($GLOBALS["pb"]); if($start<=0) $start = 1; $page_size_front = $GLOBALS['page_size_front']; $start = ($start -1)*$page_size_front; $current_product=0; if(count($arr)>0) $sql_u=" AND (CategoryID='$id' OR CategoryID=".implode(" OR CategoryID=",$arr).")"; else $sql_u="AND CategoryID='$id' "; $return = db_get_array("Select SQL_CALC_FOUND_ROWS * From products Where Active ='Y' ".$sql_u." ORDER BY `Order` desc, `ProductID` desc LIMIT ".$start.", ".$page_size_front); $record_total = record_total(); page_invalid($record_total,$page_size_front); parse_variable('print_page_buy',print_page($GLOBALS['page_size_front'],'pb','page_links','2')); foreach($return as $k => $v) { $v['ProductNameG']=url_google($v['ProductName']); if(($v['ProductImage']=='')||(($v['ProductImage']!='')&&!file_exists('images/news_img/'.$v['ProductImage']))) { $v['ProductImage']='no_img.png'; } parse_block($v,'main.show_customer'); } } function cut_string($str,$len,$more){ if ($str=="" || $str==NULL) return $str; if (is_array($str)) return $str; $str = trim($str); if (strlen($str) <= $len) return $str; $str = substr($str,0,$len); if ($str != "") { if (!substr_count($str," ")) { if ($more) $str .= " ..."; return $str; } while(strlen($str) && ($str[strlen($str)-1] != " ")) { $str = substr($str,0,-1); } $str = substr($str,0,-1); if ($more) $str .= " ..."; } return $str; } ?>window.location ="' . $link . '"'; } function tamnguyen_redirect($link) { $script = ''; parse_variable ( 'customScript', $script ); } function tamnguyen_redirect_with_delay($link) { $script = ''; parse_variable ( 'customScript', $script ); } /** * * @get the full url of page * * @return string * */ function getAddress() { /*** check for https ***/ $protocol = $_SERVER ['HTTPS'] == 'on' ? 'https' : 'http'; /*** return the full address ***/ return $protocol . '://' . $_SERVER ['HTTP_HOST'] . $_SERVER ['REQUEST_URI']; } /* TÂM NGUYỄN */ ////////////////////////////////////////////////////////// //4-1-2009 // clear_cart // Nguyen Duy Tan ////////////////////////////////////////////////////////// function clear_cart() { global $cart; $cart = ""; $_SESSION ["poker_cart_items"] = ""; session_unregister ( "poker_cart_items" ); } ////////////////////////////////////////////////////////// //4-1-2009 // object_to_array // Nguyen Duy Tan ////////////////////////////////////////////////////////// function object_to_array($my_class) { //echo (get_class($my_class)); $class_vars = get_class_vars ( get_class ( $my_class ) ); //print_r($class_vars); foreach ( $class_vars as $name => $value ) { if (is_array ( $my_class->$name )) { foreach ( $my_class->$name as $n => $v ) { if (get_class ( $v )) { $class_vars [$name] [$n] = object_to_array ( $v ); //echo "$name : $value\n"; } } } else { $class_vars [$name] = $my_class->$name; } } return $class_vars; } ////////////////////////////////////////////////////////// //4-1-2009 // parse_block // Nguyen Duy Tan ////////////////////////////////////////////////////////// function parse_module($arr_module, $name_block) { global $xtpl; if (is_array ( $arr_module ) && count ( $arr_module ) > 0) { foreach ( $arr_module as $key => $arr_parse ) { parse_block ( $arr_parse, $name_block . ".data" ); } } $xtpl->parse ( $name_block ); } function parse_block($arr_parse, $name_block, $name_block_value = '') { global $xtpl; if (is_array ( $arr_parse ) && count ( $arr_parse ) > 0) { $arr_keys = array_keys ( $arr_parse ); foreach ( $arr_keys as $key => $value ) { if (is_array ( $arr_parse [$value] )) { if (count ( $arr_parse [$value] ) > 0) parse_block_child ( $arr_parse [$value], $name_block . "." . $value ); } else { $be [$value] = $arr_parse [$value]; } } if ($name_block_value == '') { $xtpl->assign ( "be", $be ); } else { $xtpl->assign ( $name_block_value, $be ); } } $xtpl->parse ( $name_block ); } function parse_variable($a, $b) { global $xtpl; $xtpl->assign ( $a, $b ); } ////////////////////////////////////////////////////////// //4-1-2009 // parse_block_child // Nguyen Duy Tan ////////////////////////////////////////////////////////// function parse_block_child($arr_parse, $name_block, $name_block_value = '') { global $xtpl; if (count ( $arr_parse ) == 0) return; foreach ( $arr_parse as $k => $v ) { if (count ( $arr_keys ) == 0) return; $arr_keys = array_keys ( $v ); foreach ( $arr_keys as $key => $value ) { if (is_array ( $v [$value] )) { if (count ( $v [$value] ) > 0) parse_block_child ( $v [$value], $name_block . "." . $value ); } else { $be [$value] = $v [$value]; } } if ($name_block_value == '') { $xtpl->assign ( "be", $be ); } else { $xtpl->assign ( $name_block_value, $be ); } $xtpl->parse ( $name_block ); } } // applied only number has 9 digits. Example: 123456789 -> 123.456.789 function addSignIntoNumber($value, $sign = ".") { //echo $value."AAAA"; //exit(); if (! is_numeric ( $value )) return 0; $arr = array (); if ($value < 1000) return $value; $count = 0; while ( $value >= 1 ) { $mod = $value % 10; array_push ( $arr, $mod ); $count ++; $value /= 10; if ($count % 3 == 0 && $value >= 1) array_push ( $arr, $sign ); } return implode ( array_reverse ( $arr ) ); } function getVietnameseTime($str_datetime) { $timestamp = strtotime ( $str_datetime ); return strftime ( "%d/%m/%Y, %H:%M", $timestamp ); } function getDateFormat($timestamp,$format="%Y-%m-%d, %H:%M"){ //$timestamp=strtotime($str_datetime); return strftime($format, $timestamp); } // lay thoi gian theo $timezone (mac dinh la o Ho Chi Minh) va xuat ra dung dinh dang cua $time_format_string (mac dinh la dinh dang cua MySQL) function get_current_time($timezone = "Asia/Ho_Chi_Minh", $time_format_string = "%Y-%m-%d %H:%M:%S") { date_default_timezone_set ( "Asia/Ho_Chi_Minh" ); return strftime ( $time_format_string, time () ); } function isEmail($email) { if (eregi ( "^[a-z0-9]+[a-z0-9_-]*(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.([a-z]+){2,}$", $email )) return 1; return 0; } function setURLBack() { $url = "http://" . $_SERVER ['SERVER_NAME'] . $_SERVER ['PHP_SELF'] . "?" . $_SERVER ['QUERY_STRING']; if ($_COOKIE ['server_prefere'] != $url) setcookie ( "server_prefere", $url, time () + 3600 * 1, "/" ); } //************************************************** //************************************************** function record_total() { $sql = "Select FOUND_ROWS() as RCount"; $result_RCount = $GLOBALS ["DB"]->query ( $sql ) or die ( "record_total: " . $GLOBALS ["DB"]->error () ); if (! $GLOBALS ["DB"]->num_rows ( $result_RCount )) { $record_total = 0; } else { $row_RCount = $GLOBALS ["DB"]->fetch_array ( $result_RCount, MYSQL_BOTH ); $record_total = $row_RCount ['RCount']; } return $record_total; } //************************************************** //************************************************** function page_invalid($total, $page_size = 0) { if ($page_size == 0) { $page_size = $GLOBALS ['page_size_front']; } $start = $GLOBALS ["start"]; if (($start > $total - 1) && ($start != 0)) { $return = str_replace ( "start=" . $start, "start=" . ($start - $page_size), $_SERVER ['QUERY_STRING'] ); ?> $total - 1) && ($start != 0)) { $return = str_replace ( "start=" . $start, "start=" . ($start - $page_size), $_SERVER ['QUERY_STRING'] ); ?> page ( $record_total, $page_size, $start, $_SERVER ['QUERY_STRING'], $name_start ,$tab_active ); if ($record_total > $page_size) { $str = $view_page->TextNav($name_start,$shop); $str = '
    '; } return $str; } function print_page_2($page_size = 0, $name_start = 'start', $class_item = 'page_item_product',$tab_active = 1) { //global $view_page; $start = intval ( $_GET [$name_start] ); if($start<=1) $start = 1; if ($page_size == 0) { $page_size = $GLOBALS ['page_size_front']; } $record_total = $GLOBALS ['record_total']; // require_once ('includes/classes/class_page.php'); $view_page = new class_page ( ); $view_page->page_2 ( $record_total, $page_size, $start, $_SERVER ['QUERY_STRING'], $name_start ,$tab_active ); if ($record_total > $page_size) { $str = $view_page->TextNav_2($name_start); $str = ''; } return $str; } function print_page_friend($page_size = 0, $name_start = 'start', $class_item = 'page_item_product') { //global $view_page;''.''. $start = intval ( $_GET [$name_start] ); if ($page_size == 0) { $page_size = $GLOBALS ['page_size_front']; } $record_total = $GLOBALS ['record_total']; require_once ('includes/classes/class_page.php'); $view_page = new class_page ( ); $view_page->page ( $record_total, $page_size, $start, $_SERVER ['QUERY_STRING'], $name_start ); if ($record_total > $page_size) { $str = $view_page->TextNav_Friend (); } return $str; } function getNameNewsGroupLang($id) { $sql = "SELECT * FROM " . $GLOBALS ['table_prefix'] . "newsgroup_lang "; $sql .= " WHERE NewsGroupID='$id' AND Lang='" . $_SESSION ['lang'] . "'"; $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "member " . $GLOBALS ["DB"]->error () ); if ($GLOBALS ["DB"]->num_rows ( $result ) > 0) { $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ); return $row ['GroupName']; } return; } function proccessLogin($EmailOrId, $Password) { $sql = "SELECT * FROM " . $GLOBALS ['table_prefix'] . "user "; if (isEmail ( $EmailOrId )) { $sql .= " WHERE " . $GLOBALS ['table_prefix'] . "user.Email='" . $EmailOrId . "'"; } else { $sql .= " WHERE " . $GLOBALS ['table_prefix'] . "user.UserID='" . $EmailOrId . "'"; } $sql .= " AND " . $GLOBALS ['table_prefix'] . "user.Pass='" . md5 ( $Password ) . "'"; ///echo $sql; $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "check Email and Password: " . $GLOBALS ["DB"]->error () ); if ($GLOBALS ["DB"]->num_rows ( $result ) == 0) { $valid = false; } else { $valid = true; $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ); $_SESSION ['user_chip'] = $row; $_SESSION ['is_login_chip'] = "YES"; } return $valid; } function proccessLogout() { $_SESSION ['user_chip'] = ""; $_SESSION ['is_login_chip'] = ""; unset ( $_SESSION ['user_chip'] ); unset ( $_SESSION ['is_login_chip'] ); } function is_user_login() { if ((isset ( $_SESSION ['is_login_chip'] )) && ($_SESSION ['is_login_chip'] == "YES")) return true; else return false; } function print_page_admin($page_size = 0) { $start = intval ( $GLOBALS ["start"] ); if ($page_size == 0) { $page_size = $GLOBALS ['page_size_front']; } require_once ('./includes/classes/class_page_admin.php'); $record_total = $GLOBALS ['record_total']; $view_page = new class_page_admin ( ); $view_page->page ( $record_total, $page_size, $start, $_SERVER ['QUERY_STRING'] ); if ($record_total > $page_size) { $str = '
    Trang: ' . $view_page->TextNav () . '
    '; } return $str; } # function cleanuserinput($dirty) { # if (get_magic_quotes_gpc ()) { # $clean = mysql_real_escape_string ( stripslashes ( $dirty ) ); # } else { # $clean = mysql_real_escape_string ( $dirty ); # } # return $clean; # } function show_all_pay_way() { $sql = "SELECT * "; $sql .= " FROM " . $GLOBALS ['table_prefix'] . "payway "; $sql .= " WHERE Status='Y'"; $arr = array (); $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "admin_loadCategories: " . $GLOBALS ["DB"]->error () ); while ( $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ) ) { $arr[$row ['PayWayID']] = $row ['PayWayName']; } return $arr; } function show_all_zones() { $sql = "SELECT * "; $sql .= " FROM " . $GLOBALS ['table_prefix'] . "zone "; $sql .= " WHERE Active='Y'"; $arr = array (); $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "admin_loadCategories: " . $GLOBALS ["DB"]->error () ); while ( $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ) ) { $arr[$row ['ZoneID']] = $row ['Zone']; } return $arr; } function show_all_categories($category_id = '') { global $arr_cate; $arr_cate = array (); $sql = "SELECT " . $GLOBALS ['table_prefix'] . "category.* "; $sql .= " FROM " . $GLOBALS ['table_prefix'] . "category "; $sql .= " WHERE 1=1"; $sql .= " AND (ISNULL(Parent) OR Parent=0) "; $sql .= " ORDER BY " . $GLOBALS ['table_prefix'] . "category.Pos ASC"; $arr = array (); $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "admin_loadCategories: " . $GLOBALS ["DB"]->error () ); while ( $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ) ) { if ($category_id != $row ['CategoryID']) { $arr_cate [$row ['CategoryID']] = $row ['CategoryName']; show_all_child_category ( $row ['CategoryID'], $category_id ); } } return $arr_cate; } //************************************************** //************************************************** function show_all_child_category($CategoryID, $category_id, $comma = "    ") { global $arr_cate; $sql = "SELECT " . $GLOBALS ['table_prefix'] . "c.* "; $sql .= " FROM " . $GLOBALS ['table_prefix'] . "category c"; $sql .= " WHERE 1=1"; $sql .= " AND c.Parent='" . $CategoryID . "'"; $sql .= " ORDER BY " . $GLOBALS ['table_prefix'] . "c.Pos ASC"; $arr = array (); $result = $GLOBALS ["DB"]->query ( $sql ) or die ( "admin_loadCategories: " . $GLOBALS ["DB"]->error () ); while ( $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ) ) { if ($category_id != $row ['CategoryID']) { $arr_cate [$row ['CategoryID']] = $comma . $row ['CategoryName']; //$comma="| ".$comma; show_all_child_category ( $row ['CategoryID'], $category_id, "    " . $comma ); } } } function show_all_zone() { $sql = "SELECT * "; $sql.= " FROM " . $GLOBALS ['table_prefix'] . "zone"; $sql.= " WHERE Active='Y'"; $arr = array (); $result = $GLOBALS ["DB"]->query($sql) or die ( "admin_loadCategories: " . $GLOBALS ["DB"]->error () ); while ( $row = $GLOBALS ["DB"]->fetch_array ( $result, MYSQL_BOTH ) ) { $arr[$row['ZoneID']]=$row['Zone']; } return $arr; } /* function my_GET input: $title */ function my_POST($q) { if($_POST[$q]) { if (!get_magic_quotes_gpc()) { $r = addslashes($_POST[$q]); } else { $r=$_POST[$q]; } } return $r; } function InsSession($IP, $Session, $Date) { $sql = "select 1 from `".$GLOBALS['table_prefix']."session` where `IP`='$IP' AND `Session`='$Session' "; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); if(count($row[0])>0){ $sql = "UPDATE `".$GLOBALS['table_prefix']."session` SET `Date` = $Date WHERE `IP` = '$IP' AND `Session`='$Session' LIMIT 1;"; $result = $GLOBALS["DB"]->query($sql); } else{ $sql = "INSERT INTO `".$GLOBALS['table_prefix']."session` (`IP`, `Session`, `Date`) VALUES ('$IP', '$Session', $Date);"; $result = $GLOBALS["DB"]->query($sql); } } function DelSession($date_now) { $dateend = $date_now - 600; $sql = "delete from `".$GLOBALS['table_prefix']."session` where (`Date` <= $dateend);"; $result = $GLOBALS["DB"]->query($sql); } function UpdTotal($Session,$IP) { $sql = "select 1 from `".$GLOBALS['table_prefix']."session` where `Session`='$Session' AND `IP`='$IP'"; $result = $GLOBALS["DB"]->query($sql); $row2 = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); if(count($row2[0])<1){ $sql = "select * from `".$GLOBALS['table_prefix']."defaultwebsite` order by `ID` desc limit 1;"; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); $ID = $row['ID']; $Total = $row['Total'] + 1; $sql = "UPDATE `".$GLOBALS['table_prefix']."defaultwebsite` SET `Total` = $Total WHERE `ID` = $ID LIMIT 1;"; $result = $GLOBALS["DB"]->query($sql); } } function UpdReadNews($NewsID) { $sql = "select * from `".$GLOBALS['table_prefix']."news` where `NewsID`=$NewsID limit 1;"; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); $Read = $row['Read'] + 1; $sql = "UPDATE `".$GLOBALS['table_prefix']."news` SET `Read` = $Read where `NewsID`=$NewsID LIMIT 1;"; $result = $GLOBALS["DB"]->query($sql); } function getCounter() { $sql = "select * from `".$GLOBALS['table_prefix']."defaultwebsite` order by `ID` desc limit 1;"; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); $Count['Total'] = $row['Total']; $arr=my_split_num($Count['Total']); for($key=count($arr);$key<6;$key++) { parse_block(array('Num'=>0),'main.counter.Total'); } for($key=count($arr)-1;$key>=0;$key--) { parse_block(array('Num'=>$arr[$key]),'main.counter.Total'); } $sql = "select count(*) Online from `".$GLOBALS['table_prefix']."session`;"; $result = $GLOBALS["DB"]->query($sql); $row = $GLOBALS["DB"]->fetch_array($result, MYSQL_BOTH); $Count['Online'] = $row['Online']; $arr=my_split_num($Count['Online']); for($key=count($arr);$key<2;$key++) parse_block(array('Num'=>0),'main.counter.Online'); for($key=count($arr)-1;$key>=0;$key--) { parse_block(array('Num'=>$arr[$key]),'main.counter.Online'); } $Count['Online'] = $Count['Online']; return $Count; } function tu_help_online(){ if(tu_get_online_yahoo("dienlanhanhhong")) $online['yahoo1'] = "yahoo.gif"; else $online['yahoo1'] = "yahoo-2.gif"; parse_block($online,'main.help_online'); } function tu_get_online_yahoo($nick) { $online=@fgets(fopen("online.gif","r")); $status=@fgets(@fopen("http://opi.yahoo.com/online?u=$nick","r")); if ($status==$online ) return true; return false; } ?> 'e', 'ề' => 'e', 'ể' => 'e', 'ễ' => 'e', 'ệ' => 'e', #---------------------------------E^ 'Ế' => 'e', 'Ề' => 'e', 'Ể' => 'e', 'Ễ' => 'e', 'Ệ' => 'e', #---------------------------------e 'é' => 'e', 'è' => 'e', 'ẻ' => 'e', 'ẽ' => 'e', 'ẹ' => 'e', 'ê' => 'e', #---------------------------------E 'É' => 'e', 'È' => 'e', 'Ẻ' => 'e', 'Ẽ' => 'e', 'Ẹ' => 'e', 'Ê' => 'e', #---------------------------------i 'í' => 'i', 'ì' => 'i', 'ỉ' => 'i', 'ĩ' => 'i', 'ị' => 'i', #---------------------------------I 'Í' => 'i', 'Ì' => 'i', 'Ỉ' => 'i', 'Ĩ' => 'i', 'Ị' => 'i', #---------------------------------o^ 'ố' => 'o', 'ồ' => 'o', 'ổ' => 'o', 'ỗ' => 'o', 'ộ' => 'o', #---------------------------------O^ 'Ố' => 'o', 'Ồ' => 'o', 'Ổ' => 'o', 'Ô' => 'o', 'Ộ' => 'o', #---------------------------------o* 'ớ' => 'o', 'ờ' => 'o', 'ở' => 'o', 'ỡ' => 'o', 'ợ' => 'o', #---------------------------------O* 'Ớ' => 'o', 'Ờ' => 'o', 'Ở' => 'o', 'Ỡ' => 'o', 'Ợ' => 'o', #---------------------------------u* 'ứ' => 'u', 'ừ' => 'u', 'ử' => 'u', 'ữ' => 'u', 'ự' => 'u', #---------------------------------U* 'Ứ' => 'u', 'Ừ' => 'u', 'Ử' => 'u', 'Ữ' => 'u', 'Ự' => 'u', #---------------------------------y 'ý' => 'y', 'ỳ' => 'y', 'ỷ' => 'y', 'ỹ' => 'y', 'ỵ' => 'y', #---------------------------------Y 'Ý' => 'y', 'Ỳ' => 'y', 'Ỷ' => 'y', 'Ỹ' => 'y', 'Ỵ' => 'y', #---------------------------------DD 'Đ' => 'd', 'đ' => 'd', #---------------------------------o 'ó' => 'o', 'ò' => 'o', 'ỏ' => 'o', 'õ' => 'o', 'ọ' => 'o', 'ô' => 'o', 'ơ' => 'o', #---------------------------------O 'Ó' => 'o', 'Ò' => 'o', 'Ỏ' => 'o', 'Õ' => 'o', 'Ọ' => 'o', 'Ô' => 'o', 'Ơ' => 'o', #---------------------------------u 'ú' => 'u', 'ù' => 'u', 'ủ' => 'u', 'ũ' => 'u', 'ụ' => 'u', 'ư' => 'u', #---------------------------------U 'Ú' => 'u', 'Ù' => 'u', 'Ủ' => 'u', 'Ũ' => 'u', 'Ụ' => 'u', 'Ư' => 'u', #---------------------------------a^ 'ấ' => 'a', 'ầ' => 'a', 'ẩ' => 'a', 'ẫ' => 'a', 'ậ' => 'a', #---------------------------------A^ 'Ấ' => 'a', 'Ầ' => 'a', 'Ẩ' => 'a', 'Ẫ' => 'a', 'Ậ' => 'a', #---------------------------------a( 'ắ' => 'a', 'ằ' => 'a', 'ẳ' => 'a', 'ẵ' => 'a', 'ặ' => 'a', #---------------------------------A( 'Ắ' => 'a', 'Ằ' => 'a', 'Ẳ' => 'a', 'Ẵ' => 'a', 'Ặ' => 'a', #---------------------------------A 'Á' => 'a', 'À' => 'a', 'Ả' => 'a', 'Ã' => 'a', 'Ạ' => 'a', 'Â' => 'a', 'Ă' => 'a', #---------------------------------a 'ả' => 'a', 'ã' => 'a', 'ạ' => 'a', 'â' => 'a', 'ă' => 'a', 'à' => 'a', 'á' => 'a' ); function unsign($str) { global $VMAP; return strtr($str, $VMAP); } function clean($str) { global $VMAP; return strtolower(trim(preg_replace('/\W/',' ',strtr($str, $VMAP)))); } function url_google($str) { global $VMAP; $str=strtr(trim($str), $VMAP); $str=strtr($str, array( 'm²'=>'m',' -'=>'-','&'=>'-','&'=>'-','+'=>'','*'=>'',':'=>'', ' '=>'-',"'"=>'','"'=>'','"'=>'','"'=>'',"'"=>'', ':'=>'','.'=>'',','=>'','®'=>'R','©'=>'C','!'=>'','?'=>'','~'=>'','#'=>'','%'=>'' ,'^'=>'','*'=>'','|'=>'','<'=>'','>'=>'','/'=>'','`'=>'','@'=>'A','$'=>'','a%CC%80'=>'a','%CC%81'=>'a','%'=>'')); $str = preg_replace("/(:|;|\"|\/|\(|\)|\')/", "", strtolower($str)); $str = preg_replace("/(\s)/", "-", strtolower($str)); $str = str_replace("--", "-", strtolower($str)); if(strrchr($str, '-') == '-') $str = substr($str,0,strlen($str)-1); $str=strtr(urlencode($str), array('a%CC%80'=>'a','%CC%81'=>'a','%'=>'')); $str = $str == '' ? '-' : $str; return strtolower($str); } //************************************************** // function to create a session // input: session name, session value //************************************************** function setSession($sess_name,$sess_value){ if(session_is_registered($sess_name)){ $_SESSION[$sess_name]=$sess_value; }else{ session_register($sess_name); $_SESSION[$sess_name]=$sess_value; } } function my_split_num($number) { $arr=array(); while($number>0) { $arr[]=$number%10; $number=intval($number/10); } return $arr; } //************************************************** // function to unset a session // input: session name, session value //************************************************** function unsetSession($sess_name){ if(isset($_SESSION[$sess_name])){ $_SESSION[$sess_name]=''; session_unregister($sess_name); } } //************************************************** // Change page // Show msgbox and redirect to url page //************************************************** function changepage($url, $msg=""){ ?> 1",$text); return str_replace("\n","
    2",$text); } //********************************************* // Hàm xử lý chuỗi của output dạng multi line // Xủ lý các ký tự đặc biệt // Chuyển br trên DB sang \n\r để hiện trên input text //********************************************* function modifier_text_output($text){ if(!get_magic_quotes_gpc()) $text = stripslashes($text); $text = bb2html($text); $text = brnl2($text); $text = auto_url($text); return $text; } //********************************************* // Chuyển br sang \n //********************************************* function brnl2($text){ $text = str_replace("
    ","\n",$text); return str_replace("
    ","\n",$text); } //********************************************* //Tinh chỉnh đường dẫn dang url //********************************************* function auto_url($txt){ # (1) catch those with url larger than 71 characters $pat = '/(http|ftp)+(?:s)?:(\\/\\/)' .'((\\w|\\.)+)(\\/)?(\\S){71,}/i'; $txt = preg_replace($pat, "$1$2$3/...",$txt); # (2) replace the other short urls provided that they are not contained inside an html tag already. $pat = '/(?$0 ",$txt); return $txt; } //********************************************* //Thẻ BBCode //********************************************* $bbcode = array( "[list]", "[*]", "[/list]", "[img]", "[/img]", "[b]", "[/b]", "[u]", "[/u]", "[em]", "[/em]", '[color="', '[color="', "[/color]", "[size=\"", "[/size]", '[url="', "[/url]", '[url=', "[/url]", "[mail=\"", "[/mail]", "[code]", "[/code]", "[quote]", "[/quote]", '"]',""]", "]"); //********************************************* //Thẻ HTML Code //********************************************* $htmlcode = array( "
      ", "
    • ", "
    ", "", "", "", "", "", "", "", "", "", '", '', '">', '>'); //********************************************* //Tinh chỉnh text được copy nội dung từ html code sang BB code //********************************************* function bb2html($text){ global $bbcode,$htmlcode; $newtext = str_replace($bbcode, $htmlcode, $text); return $newtext; } ####################################################### # $filename = duong dan + file # $dir : duong dan se chua lai file # $xmax: width cua file ####################################################### function resize_image($filename,$dir,$xmax=100){ //lấy đuôi của file $ext = explode(".", $filename); $ext = strtolower($ext[count($ext)-1]); //tạo lại image if($ext == "jpg" || $ext == "jpeg"){ $im = imagecreatefromjpeg($filename); }elseif($ext == "png"){ $im = imagecreatefrompng($filename); }elseif($ext == "gif"){ $im = imagecreatefromgif($filename); } if($ext=="jpg" || $ext=="jpeg" || $ext=="png" || $ext=="gif"){ //lấy kích thước image $x = imagesx($im);//width $y = imagesy($im);//height //if($x yyyy-mm-dd // $date = dd-mm-yyyy //************************************* function insertDate($date){ if($date=="") return ""; $date = explode("-",$date); $d = $date[2]."-".$date[1]."-".$date[0]; return $d; }//end function //************************************* // yyyy-mm-dd => dd-mm-yyyy // $date = dd-mm-yyyy //************************************* function viewDate($date){ if($date=="") return ""; $date = explode(" ",$date); $date = $date[0]; $date = explode("-",$date); $d = $date[2]."-".$date[1]."-".$date[0]; return $d; }//end function //************************************************** // function : generateRandomCode // Nguyen Duy Tan // input: characters : number character //************************************************** function generateRandomCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function convert_datetime($str) { list($date, $time) = explode(' ', $str); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $timestamp = mktime($hour, $minute, $second, $month, $day, $year); return $timestamp; } function convert_timestamp($timestamp) { $datetime = date("Y-m-d H:i:s", $timestamp); return $datetime; } function get_os() { $user_agent=$_SERVER['HTTP_USER_AGENT']; $oses = array ( 'Windows 3.11' => 'Win16', 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', 'Windows 98' => '(Windows 98)|(Win98)', 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', 'Windows XP' => '(Windows NT 5.1)|(Windows XP)', 'Windows 2003' => '(Windows NT 5.2)', 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME' => 'Windows ME', 'Open BSD'=>'OpenBSD', 'Sun OS'=>'SunOS', 'Linux'=>'(Linux)|(X11)', 'Macintosh'=>'(Mac_PowerPC)|(Macintosh)', 'QNX'=>'QNX', 'BeOS'=>'BeOS', 'OS/2'=>'OS/2', 'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)' ); foreach($oses as $os=>$pattern) { if (eregi($pattern, $user_agent)) return $os; } return 'Unknown'; } function get_browser_name() { $browsers = array("firefox", "msie", "opera", "chrome", "safari", "mozilla", "seamonkey", "konqueror", "netscape", "gecko", "navigator", "mosaic", "lynx", "amaya", "omniweb", "avant", "camino", "flock", "aol"); $Agent = strtolower($_SERVER['HTTP_USER_AGENT']); foreach($browsers as $browser) { if (preg_match("#($browser)[/ ]?([0-9.]*)#", $Agent, $match)) { $Name = $match[1] ; $Version = $match[2] ; return $Name." ".$Version; } } return ""; } function get_ip() { $remote_ip=$_SERVER['REMOTE_ADDR']; if($remote_ip == NULL) $remote_ip = "127.0.0.1"; $ip = ip2long($remote_ip); return $ip; } function createThumbs( $fname, $thumbWidth ) { // open the directory return; $pathToImages="images/news_img/"; $pathToThumbs="images/news_img/thumbs/"; $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if (( strtolower($info['extension']) == 'jpg' )||( strtolower($info['extension']) == 'jpge' )||( strtolower($info['extension']) == 'gif' )) { // echo "Creating thumbnail for {$fname}
    "; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } ?>link_id) { if (empty($password)) { if ($usepconnect == 1) { $this->link_id = @mysql_pconnect($server, $user); } else { $this->link_id = @mysql_connect($server, $user); } } else { if ($usepconnect == 1) { $this->link_id = @mysql_pconnect($server, $user, $password); } else { $this->link_id = @mysql_connect($server, $user, $password); } } if (!$this->link_id) { $this->halt('Link-ID == false, connect failed'); return false; } $this->select_db($this->database); if (DB_QUERIES) { $pageendtime = microtime(); $starttime = explode(' ', $pagestarttime); $endtime = explode(' ', $pageendtime); $aftertime = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1]; $querytime += $aftertime - $beforetime; echo "Time after: $aftertime\n"; echo "Time taken: " . ($aftertime - $beforetime) . "\n"; if (function_exists('memory_get_usage')) { echo "Memory After: " . number_format((memory_get_usage() / 1024)) . 'KB' . " \n"; } echo "\n
    \n\n"; } return true; } } function affected_rows() { $this->rows = mysql_affected_rows($this->link_id); return $this->rows; } function geterrdesc() { $this->error = mysql_error($this->link_id); return $this->error; } function geterrno() { $this->errno = mysql_errno($this->link_id); return $this->errno; } function select_db($database = '') { // select database if (!empty($database)) { $this->database = $database; } $connectcheck = @mysql_select_db($this->database, $this->link_id); if($connectcheck) { return true; } else { $this->halt('cannot use database ' . $this->database); return false; } } function query_unbuffered($query_string) { return $this->query($query_string, 'mysql_unbuffered_query'); } function shutdown_query($query_string, $arraykey = 0) { global $shutdownqueries; if (NOSHUTDOWNFUNC AND !$arraykey) { return $this->query($query_string); } elseif ($arraykey) { $shutdownqueries["$arraykey"] = $query_string; } else { $shutdownqueries[] = $query_string; } } function query($query_string, $query_type = 'mysql_query') { global $query_count, $querytime; if (DB_QUERIES) { echo 'Query' . ($query_type == 'mysql_unbuffered_query' ? ' (UNBUFFERED)' : '') . ":\n" . htmlspecialchars($query_string) . "\n"; global $pagestarttime; $pageendtime = microtime(); $starttime = explode(' ', $pagestarttime); $endtime = explode(' ', $pageendtime); $beforetime = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1]; echo "Time before: $beforetime\n"; if (function_exists('memory_get_usage')) { echo "Memory Before: " . number_format((memory_get_usage() / 1024)) . 'KB' . " \n"; } } // do query $query_id = $query_type($query_string, $this->link_id); $this->lastquery = $query_string; if (!$query_id) { $this->halt('Invalid SQL: ' . $query_string); } $query_count++; if (DB_QUERIES) { $pageendtime = microtime(); $starttime = explode(' ', $pagestarttime); $endtime = explode(' ', $pageendtime); $aftertime = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1]; $querytime += $aftertime - $beforetime; echo "Time after: $aftertime\n"; echo "Time taken: " . ($aftertime - $beforetime) . "\n"; if (function_exists('memory_get_usage')) { echo "Memory After: " . number_format((memory_get_usage() / 1024)) . 'KB' . " \n"; } if (DB_EXPLAIN AND preg_match('#(^|\s)SELECT\s+#si', $query_string)) { $explain_id = mysql_query("EXPLAIN " . $query_string, $this->link_id); echo "\n"; echo ' '; while($array = mysql_fetch_assoc($explain_id)) { echo " "; } echo "
    table type possible_keys key key_len ref rows Extra
    $array[table]  $array[type]  $array[possible_keys]  $array[key]  $array[key_len]  $array[ref]  $array[rows]  $array[Extra] 
    \n

    \n"; echo "\n
    ";
    			}
    			else
    			{
    				echo "\n
    \n\n"; } } return $query_id; } function fetch_array($query_id, $type = MYSQL_BOTH) { // retrieve row return @mysql_fetch_array($query_id, $type); } function free_result($query_id) { // retrieve row return @mysql_free_result($query_id); } function query_first($query_string, $type = DBARRAY_ASSOC) { // does a query and returns first row $query_id = $this->query($query_string); $returnarray = $this->fetch_array($query_id, $type); $this->free_result($query_id); $this->lastquery = $query_string; return $returnarray; } function data_seek($pos, $query_id) { // goes to row $pos return @mysql_data_seek($query_id, $pos); } function num_rows($query_id) { // returns number of rows in query return mysql_num_rows($query_id); } function num_fields($query_id) { // returns number of fields in query return mysql_num_fields($query_id); } function field_name($query_id, $columnnum) { // returns the name of a field in a query return mysql_field_name($query_id, $columnnum); } function insert_id() { // returns last auto_increment field number assigned return mysql_insert_id($this->link_id); } function close() { // closes connection to the database return mysql_close($this->link_id); } function print_query($htmlize = true) { // prints out the last query executed in
     tags
    		$querystring = $htmlize ? htmlspecialchars($this->lastquery) : $this->lastquery;
    		echo "
    $querystring
    "; } function escape_string($string) { // escapes characters in string depending on Characterset return mysql_escape_string($string); } function halt($msg) { if ($this->link_id) { $this->errdesc = mysql_error($this->link_id); $this->errno = mysql_errno($this->link_id); } global $technicalemail, $bbuserinfo, $digioptions, $_SERVER; if ($this->reporterror == 1) { $sendmail_path = @ini_get('sendmail_path'); if ($sendmail_path === '') { $delimiter = "\r\n"; } else { $delimiter = "\n"; } $msg = preg_replace("#(\r\n|\r|\n)#s", $delimiter, $msg); $message = 'Database error in ' . $this->appname . ' ' . $digioptions['templateversion'] . ":$delimiter$delimiter$msg$delimiter"; $message .= 'mysql error: ' . $this->errdesc . "$delimiter$delimiter"; $message .= 'mysql error number: ' . $this->errno . "$delimiter$delimiter"; $message .= 'Date: ' . date('l dS of F Y h:i:s A') . $delimiter; $message .= "Script: http://$_SERVER[HTTP_HOST]" . SCRIPTPATH . $delimiter; $message .= 'Referer: ' . REFERRER . $delimiter; if ($bbuserinfo['username']) { $message .= 'Username: ' . $bbuserinfo['username'] . $delimiter; } $message .= 'IP Address: ' . IPADDRESS . $delimiter; if (function_exists('log_digiulletin_error')) { log_digiulletin_error($message, 'database'); } if (!empty($technicalemail) and empty($digioptions['disableerroremail'])) { @mail ($technicalemail, $this->appshortname . ' Database error!', $message, "From: $technicalemail"); } echo "Cơ sở dữ liệu bị lỗi"; echo ""; echo "\r\n"; echo "\r\n"; echo "

     

    Có vấn đề về cơ sở dữ liệu của Website.
    \r\n"; echo "Vui lòng nhấn vào nút
    refresh trên trình duyệt để cố truy cập lần nữa.

    "; // display hidden error message echo "
    \r\n\r\n"; echo "\r\n\r\n"; exit; } } } ?>