$id)); include $this->template('detail_more'); } public function doMobileDetail() { global $_W, $_GPC; $id = intval($_GPC['id']); $album = pdo_fetch("SELECT * FROM " . tablename('album') . " WHERE id = :id", array(':id' => $id)); if (empty($album)) { message('相册不存在或是已经被删除!'); } $title = $album['title']; $_W['styles'] = $this->module['config']['album']; $pindex = max(1, intval($_GPC['page'])); $psize = 10; $sql = 'SELECT * FROM ' . tablename('album_photo') . ' WHERE `albumid` = :albumid ORDER BY `displayorder` DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize; $result['list'] = pdo_fetchall($sql, array(':albumid' => $album['id'])); $url = "app/index.php?c=entry&m=we7_album&do=detail&id={$album['id']}&i={$_W['uniacid']}"; $imageurl = "/app/index.php?c=entry&m=we7_album&do=image&id={$album['id']}&i={$_W['uniacid']}&attach="; //360全景 if ($album['type'] == 1 && $_GPC['gettype'] == 'xml') { $result['list'] = pdo_fetchall("SELECT * FROM " . tablename('album_photo') . " WHERE albumid = :albumid ORDER BY displayorder ASC", array(':albumid' => $album['id'])); header("Content-type: text/xml"); $xml = ' '; return $xml; } include $this->template('detail'); } public function doWebList() { global $_W, $_GPC; load()->func('file'); $foo = !empty($_GPC['foo']) ? $_GPC['foo'] : 'display'; $category = pdo_fetchall("SELECT * FROM " . tablename('album_category') . " WHERE weid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC", array(), 'id'); if (!empty($category)) { $children = ''; foreach ($category as $cid => $cate) { if (!empty($cate['parentid'])) { $children[$cate['parentid']][$cate['id']] = array($cate['id'], $cate['name']); } } } load()->func('tpl'); if ($foo == 'create') { $id = intval($_GPC['id']); if (!empty($id)) { $sql = 'SELECT * FROM ' . tablename('album') . ' WHERE `id` = :id AND `weid` = :weid'; $params = array(':id' => $id, ':weid' => $_W['uniacid']); $item = pdo_fetch($sql, $params); if (empty($item)) { message('抱歉,相册不存在或是已经删除!', '', 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['title'])) { message('请输入相册名称!'); } $data = array( 'weid' => $_W['uniacid'], 'title' => $_GPC['title'], 'content' => $_GPC['content'], 'displayorder' => intval($_GPC['displayorder']), 'isview' => intval($_GPC['isview']), 'type' => intval($_GPC['type']), 'thumb' => $_GPC['thumb'], 'pcate' => intval($_GPC['pcate']), 'ccate' => intval($_GPC['ccate']) ); if (empty($id)) { $data['createtime'] = TIMESTAMP; pdo_insert('album', $data); } else { pdo_update('album', $data, array('id' => $id)); } message('相册更新成功!', $this->createWebUrl('list', array('foo' => 'display')), 'success'); } include $this->template('album'); } elseif ($foo == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 12; $condition = ''; if (!empty($_GPC['keyword'])) { $condition .= " AND title LIKE '%{$_GPC['keyword']}%'"; } if (!empty($_GPC['cate_2'])) { $cid = intval($_GPC['cate_2']); $condition .= " AND ccate = '{$cid}'"; } elseif (!empty($_GPC['cate_1'])) { $cid = intval($_GPC['cate_1']); $condition .= " AND pcate = '{$cid}'"; } if (istrlen($_GPC['isview']) > 0) { $condition .= " AND isview = '" . intval($_GPC['isview']) . "'"; } $list = pdo_fetchall("SELECT * FROM " . tablename('album') . " WHERE weid = '{$_W['uniacid']}' $condition ORDER BY displayorder DESC, id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('album') . " WHERE weid = '{$_W['uniacid']}' $condition"); $pager = pagination($total, $pindex, $psize); if (!empty($list)) { foreach ($list as &$row) { $row['total'] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('album_photo') . " WHERE albumid = :albumid", array(':albumid' => $row['id'])); } } include $this->template('album'); } elseif ($foo == 'photo') { $id = intval($_GPC['albumid']); $sql = 'SELECT * FROM ' . tablename('album') . ' WHERE `id` = :id AND `weid` = :weid'; $params = array(':id' => $id, ':weid' => $_W['uniacid']); $album = pdo_fetch($sql, $params); if (empty($album)) { message('相册不存在或是已经被删除!'); } if (checksubmit('submit')) { if (!empty($_GPC['attachment-new'])) { foreach ($_GPC['attachment-new'] as $index => $row) { if (empty($row)) { continue; } $data = array( 'weid' => $_W['uniacid'], 'albumid' => intval($_GPC['albumid']), 'title' => $_GPC['title-new'][$index], 'description' => $_GPC['description-new'][$index], 'attachment' => $_GPC['attachment-new'][$index], 'displayorder' => $_GPC['displayorder-new'][$index], ); pdo_insert('album_photo', $data); } } if (!empty($_GPC['attachment'])) { foreach ($_GPC['attachment'] as $index => $row) { if (empty($row)) { continue; } $data = array( 'weid' => $_W['uniacid'], 'albumid' => intval($_GPC['albumid']), 'title' => $_GPC['title'][$index], 'description' => $_GPC['description'][$index], 'attachment' => $_GPC['attachment'][$index], 'displayorder' => $_GPC['displayorder'][$index], ); pdo_update('album_photo', $data, array('id' => $index)); } } message('相册更新成功!', $this->createWebUrl('list', array('foo' => 'photo', 'albumid' => $album['id']))); } if (checksubmit('delete')) { pdo_delete('album_photo', array('albumid' => $id)); message('全部照片已成功删除', referer(), 'success'); } $sql = 'SELECT * FROM ' . tablename('album_photo') . ' WHERE `albumid` = :albumid ORDER BY `displayorder`'; $params = array(':albumid' => $album['id']); if (empty($album['type'])) { $sql .= ' DESC'; } else { $sql .= ' ASC'; } $photos = pdo_fetchall($sql, $params); include $this->template('album'); } elseif ($foo == 'delete') { $type = $_GPC['type']; $id = intval($_GPC['id']); if ($type == 'photo') { if (!empty($id)) { $sql = 'SELECT `id`, `attachment` FROM ' . tablename('album_photo') . ' WHERE `id` = :id AND `weid` = :weid'; $params = array(':id' => $id, ':weid' => $_W['uniacid']); $item = pdo_fetch($sql, $params); if (empty($item)) { message('图片不存在或是已经被删除!'); } pdo_delete('album_photo', array('id' => $item['id'])); } else { $item['attachment'] = $_GPC['attachment']; } file_delete($item['attachment']); } elseif ($type == 'album') { $sql = 'SELECT * FROM ' . tablename('album') . ' WHERE `id` = :id AND `weid` = :weid'; $params = array(':id' => $id, ':weid' => $_W['uniacid']); $album = pdo_fetch($sql, $params); if (empty($album)) { message('相册不存在或是已经被删除!'); } $photos = pdo_fetchall("SELECT id, attachment FROM " . tablename('album_photo') . " WHERE albumid = :albumid", array(':albumid' => $id)); if (!empty($photos)) { foreach ($photos as $row) { file_delete($row['attachment']); } } pdo_delete('album', array('id' => $id)); pdo_delete('album_photo', array('albumid' => $id)); } message('删除成功!', referer(), 'success'); } elseif ($foo == 'cover') { $id = intval($_GPC['albumid']); $attachment = $_GPC['thumb']; if (empty($attachment)) { message('抱歉,参数错误,请重试!', '', 'error'); } $sql = 'SELECT * FROM ' . tablename('album') . ' WHERE `id` = :id AND `weid` = :weid'; $params = array(':id' => $id, ':weid' => $_W['uniacid']); $item = pdo_fetch($sql, $params); if (empty($item)) { message('抱歉,相册不存在或是已经删除!', '', 'error'); } pdo_update('album', array('thumb' => $attachment), array('id' => $id)); message('设置封面成功!', '', 'success'); } } public function doWebQuery() { global $_W, $_GPC; $kwd = $_GPC['keyword']; $sql = 'SELECT * FROM ' . tablename('album') . ' WHERE `weid`=:weid AND `title` LIKE :title'; $params = array(); $params[':weid'] = $_W['uniacid']; $params[':title'] = "%{$kwd}%"; $ds = pdo_fetchall($sql, $params); foreach ($ds as &$row) { $r = array(); $r['id'] = $row['id']; $r['title'] = $row['title']; $r['content'] = cutstr($row['content'], 30, '...'); $r['thumb'] = toimage( $row['thumb'] ); $row['entry'] = $r; } include $this->template('query'); } public function doWebDelete() { global $_W, $_GPC; $id = intval($_GPC['id']); pdo_delete('album_reply', array('id' => $id)); message('删除成功!', referer(), 'success'); } public function doMobileList() { global $_W, $_GPC; $_W['styles'] = $this->module['config']['album']; $_W['styles']['listtype'] = max(1, $_W['styles']['listtype']); $pindex = max(1, intval($_GPC['page'])); $psize = 10; $pcate = intval($_GPC['pcate']); $ccate = intval($_GPC['ccate']); $where = ' WHERE weid = :weid'; $params = array(':weid' => $_W['uniacid']); if (empty($pcate) && empty($ccate)) { $sql = 'SELECT * FROM ' . tablename('album_category') . $where . ' AND `enabled` = :enabled AND `parentid` = 0 ORDER BY `displayorder` DESC'; $params[':enabled'] = 1; $categories = pdo_fetchall($sql, $params, 'id'); if (!empty($categories)) { foreach ($categories as $key => $category) { if (empty($category['parentid'])) { $categories[$key]['url'] = $this->createMobileUrl('list', array('pcate' => $category['id'])); } else { $categories[$key]['url'] = $this->createMobileUrl('list', array('pcate' => $category['parentid'], 'ccate' => $category['id'])); } $child_sql = 'SELECT * FROM ' . tablename('album_category') . $where . ' AND `enabled` = :enabled AND `parentid` = :parentid ORDER BY `displayorder` DESC'; $child_params = array( ':weid' => $_W['uniacid'], ':enabled' => 1, ':parentid' => $category['id'] ); $child_categories = pdo_fetchall($child_sql, $child_params, 'id'); foreach ($child_categories as $child_key => $value) { $child_categories[$child_key]['url'] = $this->createMobileUrl('list', array('pcate' => $value['parentid'], 'ccate' => $value['id'])); } $categories[$key]['children'] = $child_categories; } } $show_category = true; } else { $condition = ""; if (!empty($pcate) && !empty($ccate)) { $condition .= " and pcate={$pcate} and ccate={$ccate} "; } else if (!empty($pcate)) { $condition .= " and pcate={$pcate}"; } else if (!empty($ccate)) { $condition .= " and ccate={$ccate} "; } $where .= ' AND `isview` = :isview '; $sql = 'SELECT COUNT(*) FROM ' . tablename('album') . $where . $condition; $params[':isview'] = 1; $total = pdo_fetchcolumn($sql, $params); if ($total > 0) { $sql = 'SELECT * FROM ' . tablename('album') . $where . $condition . ' ORDER BY `displayorder` DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize; $list = pdo_fetchall($sql, $params); $pager = pagination($total, $pindex, $psize); } $sql = 'SELECT `name` FROM ' . tablename('album_category') . ' WHERE `id` = :id'; $params = array(':id' => $pcate); $pc = pdo_fetchcolumn($sql, $params); $params[':id'] = $ccate; $cc = pdo_fetchcolumn($sql, $params); $show_category = false; } include $this->template('list'); } public function doMobileListMore() { global $_GPC, $_W; $pindex = max(1, intval($_GPC['page'])); $psize = 10; $category = pdo_fetchall("SELECT * FROM " . tablename('album_category') . " WHERE weid = '{$_W['uniacid']}' and parentid=0 and enabled=1 ORDER BY displayorder DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); if (!empty($category)) { $children = ''; foreach ($category as &$cate) { if (empty($cate['parentid'])) { $cate['url'] = $this->createMobileUrl('list', array('pcate' => $cate['id'])); } else { $cate['url'] = $this->createMobileUrl('list', array('pcate' => $cate['parentid'], 'ccate' => $cate['id'])); } $children = pdo_fetchall("SELECT * FROM " . tablename('album_category') . " WHERE parentid={$cate['id']} and enabled=1 ORDER BY displayorder desc"); foreach ($children as &$c) { $c['url'] = $this->createMobileUrl('list', array('pcate' => $c['parentid'], 'ccate' => $c['id'])); } unset($c); $cate['children'] = $children; } unset($cate); } include $this->template('list_more'); } public function getAlbumTiles() { global $_W; $urls = array(); $albums = pdo_fetchall("SELECT id, title FROM " . tablename('album') . " WHERE isview = '1' AND weid = '{$_W['uniacid']}'"); if (!empty($albums)) { foreach ($albums as $row) { $urls[] = array('title' => $row['title'], 'url' => $this->createMobileUrl('detail', array('id' => $row['id']))); } } $category = pdo_fetchall("SELECT id, name,parentid FROM " . tablename('album_category') . " WHERE weid = '{$_W['uniacid']}'"); if (!empty($category)) { foreach ($category as $row) { if (empty($row['parentid'])) { $urls[] = array('title' => "分类: " . $row['name'], 'url' => $this->createMobileUrl('list', array('pcate' => $row['id']))); } else { $urls[] = array('title' => "分类: " . $row['name'], 'url' => $this->createMobileUrl('list', array('pcate' => $row['parentid'], 'ccate' => $row['id']))); } } } return $urls; } public function doWebCategory() { global $_GPC, $_W; load()->func('tpl'); $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { if (!empty($_GPC['displayorder'])) { foreach ($_GPC['displayorder'] as $id => $displayorder) { pdo_update('album_category', array('displayorder' => $displayorder), array('id' => $id)); } message('分类排序更新成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } $children = array(); $category = pdo_fetchall("SELECT * FROM " . tablename('album_category') . " WHERE weid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC"); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][] = $row; unset($category[$index]); } } include $this->template('category'); } elseif ($operation == 'post') { $parentid = intval($_GPC['parentid']); $id = intval($_GPC['id']); if (!empty($id)) { $category = pdo_fetch("SELECT * FROM " . tablename('album_category') . " WHERE id = '$id'"); if (empty($category['parentid'])) { $url = "../app/index.php?c=entry&m=we7_album&do=list&pcate={$category['id']}&i={$_W['uniacid']}"; } else { $url = "../app/index.php?c=entry&m=we7_album&do=list&pcate={$category['parentid']}&ccate={$category['id']}&i={$_W['uniacid']}"; } } else { $category = array( 'displayorder' => 0, ); } if (!empty($parentid)) { $parent = pdo_fetch("SELECT id, name FROM " . tablename('album_category') . " WHERE id = '$parentid'"); if (empty($parent)) { message('抱歉,上级分类不存在或是已经被删除!', $this->createWebUrl('post'), 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['catename'])) { message('抱歉,请输入分类名称!'); } $data = array( 'weid' => $_W['uniacid'], 'name' => $_GPC['catename'], 'enabled' => intval($_GPC['enabled']), 'displayorder' => intval($_GPC['displayorder']), 'description' => $_GPC['description'], 'parentid' => intval($parentid), 'thumb' => $_GPC['thumb'] ); if (!empty($id)) { unset($data['parentid']); pdo_update('album_category', $data, array('id' => $id)); } else { pdo_insert('album_category', $data); $id = pdo_insertid(); } message('更新分类成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } include $this->template('category'); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $category = pdo_fetch("SELECT id, parentid FROM " . tablename('album_category') . " WHERE id = '$id'"); if (empty($category)) { message('抱歉,分类不存在或是已经被删除!', $this->createWebUrl('category', array('op' => 'display')), 'error'); } pdo_delete('album_category', array('id' => $id, 'parentid' => $id), 'OR'); message('分类删除成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } } public function doMobileImage() { global $_GPC, $_W; load()->func('communication'); $image = trim($_GPC['attach']); if(empty($image)) { exit(); } $content = ihttp_request($image, '', ''); header('Content-Type:image/jpg'); echo $content['content']; exit(); } }