1) { $prevpage = $page - 1; $prevpagestring = << EOS; $firstpagestring = << EOS; } else { $prevpagestring = << EOS; $firstpagestring = << EOS; } $pagelist = << $firstpagestring $prevpagestring EOS; if ($pagestart > 1) { $pagelist .= "1.. "; } for ($i = $pagestart; $i <= $pageend; $i++) { if ($i == $page) { $pagelist .= "$i " ; } else { $pagelist .= "$i "; } } if ($pageend < $pagelast) { $pagelist .= "..$pagelast"; } if ($page < $pagelast) { $nextpage = $page + 1; $nextpagestring = << EOS; $lastpagestring = << EOS; } else { $nextpagestring = << EOS; $lastpagestring = << EOS; } $pagelist .= << $nextpagestring $lastpagestring EOS; return $pagelist; } function mkShopListRow( &$document, $gdid, $gdseq, $gdname, $gdpriceo, $gdprice, $gdbonus, $gdabstract, $gdimage, $gdcat, $gdvisible, $gdstat, $page, $count, $totalrowcount, $limitoffset ) { global $PsycheAdmin; global $SHOP_GIMGPATH, $SHOP_GIMGURI, $SHOP_GIMGDEFAULT; global $gdvisiblearray, $gdstatarray; if ($PsycheAdmin) { $idx = $count + $limitoffset; $shopadminstring = <<
EOS; if ($idx) { $shopadminstring .= <<[¡è] EOS; } if ($idx < $totalrowcount-1) { $shopadminstring .= <<[¡é] EOS; } $shopadminstring .= "

"; if ($gdvisible == "N") { $gdvisiblestring = <<(»óǰ ¸ñ·Ï¿¡ ¾È º¸ÀÓ) EOS; } else { $gdvisiblestring = ""; } if ($gdstat == "X") { $gdstatstring = <<(ÆÇ¸Å Áß´Ü) EOS; } else { $gdstatstring = ""; } } else { $shopadminstring = ""; $gdvisiblestring = ""; $gdstatstring = ""; } if ($count) { $document['main'] .= << EOS; } if ($gdpriceo != $gdprice) { $gdpriceoc = number_format($gdpriceo) . "¿ø"; $gdoffrate = (int) (($gdpriceo - $gdprice) * 100 / $gdpriceo); $gdpriceostring = <<$gdpriceoc ¡æ EOS; $gdoffratestring = "(" . $gdoffrate . "% ÇÒÀÎ È¿°ú)"; } else { $gdpriceostring = ""; $gdoffratestring = ""; } $gdpricec = number_format($gdprice) . "¿ø"; $gdbonusc = number_format($gdbonus) . "¿ø"; if (!is_file($SHOP_GIMGPATH . "/" . $gdimage)) { $gdimage = $SHOP_GIMGDEFAULT; } $document['main'] .= <<
$shopadminstring
$gdname $gdstatstring $gdvisiblestring
$gdpriceostring $gdpricec $gdoffratestring
$gdbonusc
$gdabstract
EOS; } function mkShopList(&$document, &$script, &$init, $gdcat, $page) { global $PsycheAdmin; global $SHOP_MAXLINE, $SHOP_MAXPAGE; global $gdcatarray; if (!$gdcat) $gdcat = "0"; if (!$page) $page = 1; if ($PsycheAdmin) { $script .= << {$document['leftmenu']}
Ȩ > ¼îÇθô > {$gdcatarray[$gdcat][0]}
EOS; if ($PsycheAdmin) { if ($gdcat) { $wherecondition .= "where gd.gdcat = '$gdcat'"; } else { $wherecondition = ""; } $goodsaddstring = << EOS; } else { if ($gdcat) { $wherecondition = "where gd.gdstat = 'O' and gd.gdvisible = 'Y' and gd.gdcat = '$gdcat'"; } else { $wherecondition = "where gd.gdstat = 'O' and gd.gdvisible = 'Y'"; } $goodsaddstring = ""; } $result = mysql_query("select count(*) from goods as gd $wherecondition"); list($totalrowcount) = mysql_fetch_row($result); if ($totalrowcount) { $document['main'] .= << ÇöÀç ÃÑ {$totalrowcount}°³ÀÇ »óǰÀÌ ÁغñµÇ¾î ÀÖ½À´Ï´Ù. $goodsaddstring
 
EOS; $pagelast = ceil($totalrowcount / $SHOP_MAXLINE); $pagestart = max(1, $page - floor(($SHOP_MAXPAGE + 1) / 2)); // SHOP_MAXPAGE 9: .. 3 4 5 6 [7] 8 9 10 11 .. // SHOP_MAXPAGE 10: .. 3 4 5 6 [7] 8 9 10 11 12 .. $pageend = min($pagestart + $SHOP_MAXPAGE - 1, $pagelast); $pagelist = mkShopPageList($gdcat, $page, $pagestart, $pageend, $pagelast); $limitoffset = ($page - 1) * $SHOP_MAXLINE; $limitrowcount = $SHOP_MAXLINE; $result = mysql_query("select gd.gdid, gd.gdseq, gd.gdname, gd.gdprice1, gd.gdprice3, gd.gdbonus, gd.gdabstract, gd.gdimage1, gd.gdvisible, gd.gdstat from goods as gd $wherecondition order by gdseq limit $limitoffset, $limitrowcount"); $count = 0; while ( list($gdi, $gdsq, $gdn, $gdprc1, $gdprc3, $gdbns, $gdabs, $gdimg, $gdvis, $gdst) = mysql_fetch_row($result) ) { mkShopListRow( $document, $gdi, $gdsq, $gdn, $gdprc1, $gdprc3, $gdbns, $gdabs, $gdimg, $gdcat, $gdvis, $gdst, $page, $count++, $totalrowcount, $limitoffset ); } $document['main'] .= <<
 
$pagelist
EOS; } else { $document['main'] .= << ÇöÀç ÁغñµÈ »óǰÀÌ ¾ø½À´Ï´Ù. EOS; } $document['main'] .= << {$document['rightbanner']} EOS; $script .= << '$gdseq' $gdcatcondition order by gdseq asc limit 1"); break; } list($gdid2, $gdseq2) = mysql_fetch_row($result); if ($gdid2 && $gdseq2) { mysql_query("update goods set gdseq = '$gdseq2' where gdid = '$gdid'"); mysql_query("update goods set gdseq = '$gdseq' where gdid = '$gdid2'"); } header("Location: {$_SERVER['PHP_SELF']}?gdcat=$gdcat&page=$page"); return; } mkShopList($document, $script, $init, $gdcat, $page); require "shop_template.php"; ?>