/*
日期:2009-10-01
版權:witness123.com
設計:Charles Chang
功能:以物易物交換平台
單元:首頁,顯示最新未完成交易的物件。或可以 ex_index_feature.php 做為首頁
*/
?>
include("include_ex.php");?>
include("ads_728x90.php");?>
$allLimit = 16;
if ($_GET[page] == "") {$_GET[page] = 1;}
$mm = ($_GET[page] -1) * $allLimit + 1;
//$ex_mediaurl = "http://www.witness123.com/ex_media/";
ECHO "
\r\n";
// Print Reply database
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_query("SET NAMES 'utf8'");
mysql_select_db($dbname) or die ("Unable to connect to MySQL");
$list_query = ("SELECT * FROM ex_post WHERE (ex_media != '' AND ex_close = '0') ORDER BY ex_postid DESC LIMIT ".(($_GET["page"]-1)*$allLimit).", $allLimit");
//$list_query = ("SELECT * FROM ex_post WHERE ex_media != '' ORDER BY id DESC");
$result = mysql_query($list_query) or die("No Data");
$k = 0;
while ( $row = mysql_fetch_array($result) ) {
$ex_postidxx = $row[ex_postid];
$ex_replynumxx = $row[ex_replynum];
$ex_asknumxx = $row[ex_asknum];
$ex_clicknumxx = $row[ex_clicknum];
$ex_cataloguesxx = $row[ex_catalogues];
$ex_catalogues_name = $l_add_catalogues_array[$ex_cataloguesxx];
$ex_yearxx = $row[ex_year];
$ex_year_name = "$l_add_year_array[$ex_yearxx]";
$ex_sourcexx = $row[ex_source];
$ex_source_name = $l_add_source_array[$ex_sourcexx];
$ex_namexx = $row[ex_name];
$ex_descriptionxx = $row[ex_description];
$p_catalogues_name = "";
$p_cataloguesxx = $row[p_catalogues]; //String 字串
$p_cataloguesxx_num = substr_count("$p_cataloguesxx", ","); // 字串數
$temps = split (",","$p_cataloguesxx");
for ($i = 0; $i <= $p_cataloguesxx_num; $i++) {
for ($j=1;$j <= $l_add_catalogues_num;$j++) {
if ($temps[$i] == $j) {
if ($p_catalogues_name == '') {
$p_catalogues_name = $l_add_catalogues_array[$j];
}
else {
$p_catalogues_name = "$p_catalogues_name" . ", " . "$l_add_catalogues_array[$j]";
}
} // end if
} // end for
} // End for
$p_year_name = "";
$p_yearxx = $row[p_year]; //String 字串
$p_yearxx_num = substr_count("$p_yearxx", ","); // 字串數
$temps = split (",","$p_yearxx");
for ($i=0; $i <= $p_yearxx_num; $i++) {
for ($j=0;$j <= $l_add_year_num;$j++) {
if ($temps[$i] == $j) {
if ($p_year_name == '') {
$p_year_name = "$l_add_year_array[$j]";
}
else {
$p_year_name .= ", " . "$l_add_year_array[$j]";
}
}
}
}
$p_source_name = "";
$p_sourcexx = $row[p_source]; //String 字串
$p_sourcexx_num = substr_count("$p_sourcexx", ","); // 字串數
$temps = split (",","$p_sourcexx");
for ($i=0; $i <= $p_sourcexx_num; $i++) {
for ($j=0;$j <= $l_add_source_num;$j++) {
if ($temps[$i] == $j) {
if ($p_source_name == '') {
$p_source_name = $l_add_source_array[$j];
}
else {
$p_source_name .= ", " . "$l_add_source_array[$j]";
}
}
}
}
$p_namexx = $row[p_name];
$p_descriptionxx = $row[p_description];
$m_emailxx = $row[m_email];
$m_idxx = $row[m_id];
$ex_postdatexx = $row[ex_postdate];
$ex_closexx = $row[ex_close];
$ex_closedatexx = $row[ex_closedate];
$ex_removexx = $row[ex_remove];
$ex_removedatexx = $row[ex_removedate];
$ex_winneridxx = $row[ex_winnerid];
$randomcodexx = $row[randomcode];
$balance = $k%4 ;
if ($balance == 0) {
ECHO "\r\n";
}
else {
ECHO " | \r\n";
}
$ex_mediaxx = $row[ex_media]; //字串
$ex_media_num = substr_count("$ex_mediaxx", ","); // 字串數
$temps_ex_media = split (",","$ex_mediaxx");
for ($i = 0; $i <= $ex_media_num ; $i++) {
if ($temps_ex_media[$i] != "") {
$ex_media[$i] = $temps_ex_media[$i];
$ex_last5ext[$i] = substr($ex_media[$i],-5,5); //// 取出自串的最後五碼
$ex_ext[$i] = strstr($ex_last5ext[$i],'.'); //// 取出最後五碼中包含 .及後面的字串
if (($ex_ext[$i] == '.jpg') || ($ex_ext[$i] == '.gif') || ($ex_ext[$i] == '.png')){
$mainfilename = substr($ex_media[$i],0,-4);
$smailfilename = "$mainfilename" . "s" . "$ex_ext[$i]";
$short_ex_namexx = mb_substr($ex_namexx,0,13,"Big-5");
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO "$short_ex_namexx .. | \r\n";
ECHO "$l_reply ($ex_replynumxx) | 點閱: ($ex_clicknumxx) | $l_ask ($ex_asknumxx) | \r\n";
ECHO " \r\n";
$i = $ex_media_num;
}
} // End if
} // End for
if ($balance == 3) {
ECHO " |
|
\r\n";
}
else {
ECHO "\r\n";
}
$k++;
} // End While
if ($balance == 0) {
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO " |
\r\n";
}
elseif ($balance == 1) {
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO " |
\r\n";
}
elseif ($balance == 2) {
ECHO "\r\n";
ECHO "\r\n";
ECHO "\r\n";
ECHO " | | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO "\r\n";
ECHO " | \r\n";
ECHO " \r\n";
ECHO " | \r\n";
ECHO " |
\r\n";
}
ECHO "
";
$qresult = mysql_query("SELECT * FROM ex_post WHERE (ex_media != '' AND ex_close = '0') ORDER BY ex_postid DESC");
$nrResults=mysql_num_rows($qresult);
if (($nrResults%$allLimit)<>0) {
$pmax=floor($nrResults/$allLimit)+1;
} else {
$pmax=floor($nrResults/$allLimit);
}
ECHO "