require_once('common.inc.php');
// main banners
$sql = "SELECT * FROM `main_banner` WHERE `display` = '1' ORDER BY `sorting` DESC LIMIT 10";
$rs = $db->query($sql);
$banner_list = "";
while ($row = $db->fetch_array($rs)) {
$photo = get_attachment("main_banner", $row['id'], "photo");
if (file_exists("./" . $photo["path"] . 'original/' . $photo["file_name"])) {
$banner_list .= '
';
}
}
// new books
$sql = "SELECT * FROM `node` where `status` = '1' AND `type` = 'book' ORDER BY `id` DESC, `publishing_date` DESC LIMIT 0,10";
$rs = $db->query($sql);
$f = 0;
$list = "";
while ($row = $db->fetch_array($rs)) {
$photo = get_attachment("node", $row['id'], "cover");
if (file_exists("./" . $photo["path"] . 'original/' . $photo["file_name"])) {
list($width, $height, $type, $attr) = getimagesize("./" . $photo["path"] . 'original/' . $photo["file_name"]);
if ($height <= $width) {
$imgset = 'width="119"';
} else {
$imgset = 'height="149"';
}
$img = '
';
} else {
if ($row['cover'] != 0 && $row['cover'] != '') {
$sql_cover = "SELECT * FROM `file_managed` WHERE `fid` = '" . $row['cover'] . "' AND `status` = '1' LIMIT 0,1";
$row_cover = $db->getrow($sql_cover);
if ($row_cover['filename'] != '') {
if (file_exists('./upload/products/original/' . $row_cover['filename'])) {
list($width, $height, $type, $attr) = getimagesize('./upload/products/original/' . $row_cover['filename']);
if ($height <= $width) {
$imgset = 'width="119"';
} else {
$imgset = 'height="149"';
}
$img = '
';
} else {
$img = '
';
}
} else {
$img = '
';
}
} else {
$img = '
';
}
}
if ($f == 0) {
$list .= '';
}
$padding = 'class="padding_new_arrival"';
if ($f == 4) $padding = '';
$list .= '|
| ';
$f++;
if ($f == 5) {
$list .= '
';
$f = 0;
}
}
if ($f > 0 && $f < 5) {
while ($f > 0 && $f < 5) {
$list .= ' | ';
$f++;
}
$list .= '';
$f = 0;
}
// products
$sql = "SELECT * FROM `node` where `status` = '1' AND `levelone`='2' AND `type` = 'book' ORDER BY `id` DESC, `publishing_date` DESC LIMIT 0,10";
$rs = $db->query($sql);
$f = 0;
$product_list = "";
while ($row = $db->fetch_array($rs)) {
$photo = get_attachment("node", $row['id'], "cover");
if (file_exists("./" . $photo["path"] . 'original/' . $photo["file_name"])) {
list($width, $height, $type, $attr) = getimagesize("./" . $photo["path"] . 'original/' . $photo["file_name"]);
if ($height <= $width) {
$imgset = 'width="119"';
} else {
$imgset = 'height="149"';
}
$img = '
';
} else {
if ($row['cover'] != 0 && $row['cover'] != '') {
$sql_cover = "SELECT * FROM `file_managed` WHERE `fid` = '" . $row['cover'] . "' AND `status` = '1' LIMIT 0,1";
$row_cover = $db->getrow($sql_cover);
if ($row_cover['filename'] != '') {
if (file_exists('./upload/products/original/' . $row_cover['filename'])) {
list($width, $height, $type, $attr) = getimagesize('./upload/products/original/' . $row_cover['filename']);
if ($height <= $width) {
$imgset = 'width="119"';
} else {
$imgset = 'height="149"';
}
$img = '
';
} else {
$img = '
';
}
} else {
$img = '
';
}
} else {
$img = '
';
}
}
if ($f == 0) {
$product_list .= '';
}
$padding = 'class="padding_new_arrival"';
if ($f == 4) $padding = '';
$product_list .= '|
| ';
$f++;
if ($f == 5) {
$product_list .= '
';
$f = 0;
}
}
if ($f > 0 && $f < 5) {
while ($f > 0 && $f < 5) {
$product_list .= ' | ';
$f++;
}
$product_list .= '';
$f = 0;
}
// news
$sql = "SELECT * FROM `news` where `display` = '1' ORDER BY `sorting` ASC, `date` DESC LIMIT 0,4";
$rs = $db->query($sql);
$news_list = "";
$f = 0;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
while ($row = $db->fetch_array($rs)) {
$photo = get_attachment("news", $row['id'], "photo");
$news_list .= '' . $row['date'] . ' ' . $row['name'] . '
|
';
}
$sql = "SELECT * FROM `node` where `status` = '1' AND `type` = 'book' AND `popular` <> '0' ORDER BY `popular` ASC LIMIT 0,3";
$rs = $db->query($sql);
$popular_list = "";
while ($row = $db->fetch_array($rs)) {
$photo = get_attachment("node", $row['id'], "cover");
if (file_exists("./" . $photo["path"] . 'original/' . $photo["file_name"])) {
list($width, $height, $type, $attr) = getimagesize("./" . $photo["path"] . 'original/' . $photo["file_name"]);
if ($height <= $width) {
$imgset = 'width="98"';
} else {
$imgset = 'height="102"';
}
$img = '
';
} else {
if ($row['cover'] != 0 && $row['cover'] != '') {
$sql_cover = "SELECT * FROM `file_managed` WHERE `fid` = '" . $row['cover'] . "' AND `status` = '1' LIMIT 0,1";
$row_cover = $db->getrow($sql_cover);
if ($row_cover['filename'] != '') {
if (file_exists('./upload/products/original/' . $row_cover['filename'])) {
list($width, $height, $type, $attr) = getimagesize('./upload/products/original/' . $row_cover['filename']);
if ($height <= $width) {
$imgset = 'width="98"';
} else {
$imgset = 'height="102"';
}
$img = '
';
} else {
$img = '
';
}
} else {
$img = '
';
}
} else {
$img = '
';
}
}
$popular_list .= '
' . $row['author'] . '
|
|
';
}
$sql = "SELECT * FROM `node` where `status` = '1' AND `type` = 'book' AND `popular` <> '0' ORDER BY `popular` ASC LIMIT 3,7";
$rs = $db->query($sql);
$f = 0;
while ($row = $db->fetch_array($rs)) {
$class = "popular_item";
if ($f == 6) $class = "popular_item_last";
$popular_list .= '';
$f++;
}
?>
include('inc_head.php') ?>