function create() { $tab = jget('tab') ? jget('tab') : 'word'; $this->Title = "我的投票"; if (MEMBER_ID < 1) { $this->Messager("你需要先登录才能继续本操作", 'index.php?mod=login'); } if (MEMBER_ROLE_TYPE != 'admin') { load::logic('vote'); $VoteLogic = new VoteLogic(); $is_allowed = $VoteLogic->allowedCreate(MEMBER_ID); } if ($is_allowed) { $this->Messager($is_allowed); } $max_option = 50; $perpage = 10; $options = range(1, $perpage); $exp_info = $this->VoteLogic->get_publish_form_param(); extract($exp_info); $member = $this->TopicLogic->GetMember(MEMBER_ID); if ($member['medal_id']) { $medal_list = $this->TopicLogic->GetMedal($member['medal_id'], $member['uid']); } for ($i = 0; $i < $perpage; $i++) { $opts[$i]['picurl'] = 'images/none.png'; } include template('vote/vote_create'); }
function onLoadPic() { if (!$this->MemberHandler->HasPermission($this->Module, 'create')) { js_alert_output($this->MemberHandler->GetError()); } $id = jget('id', 'int'); $file_name = 'pic' . $id; if (MEMBER_ROLE_TYPE != 'admin' && !$is_allowed) { load::logic('vote'); $VoteLogic = new VoteLogic(); $is_allowed = $VoteLogic->allowedCreate(MEMBER_ID); } if ($is_allowed) { js_alert_output($is_allowed); } if ($_FILES[$file_name]['name']) { $name = time() . MEMBER_ID; $image_name = $name . "_b.jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/vote/'; $image_file = $image_path . $image_name; $image_th_file = $image_path . $name . "_th.jpg"; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $file_name, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); echo "<script language='Javascript'>"; echo "parent.document.getElementById('message').style.display='block';"; echo "parent.document.getElementById('uploading').style.display='none';"; echo "parent.document.getElementById('message').innerHTML='图片上载失败'"; echo "</script>"; exit; } image_thumb($image_file, $image_th_file, 100, 100, 1, 0, 0); if ($this->Config['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $face_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $face_url . '/' . str_replace('./', '', $image_file); } $ftp_result = ftpcmd('upload', $image_th_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_th_file); $image_th_file = $face_url . '/' . str_replace('./', '', $image_th_file); } } #插入数据库 $image_id = $this->VoteLogic->insert_vote_img(MEMBER_ID, $image_th_file, $image_file); echo "<script language='Javascript'>"; echo "parent.document.getElementById('pic_show_{$id}').src='{$image_th_file}';"; echo "parent.document.getElementById('pic_id_{$id}').value='{$image_id}';"; echo "</script>"; exit; } }
function view() { $uid = MEMBER_ID; $qid = intval(trim($this->Get['qid'])); $tag = get_safe_code($this->Get['tag']); $view = trim($this->Get['view']); $qun_info = $this->QunLogic->get_qun_info($qid); if ($qun_info['qun_theme_id']) { $this->Config['qun_theme_id'] = $qun_info['qun_theme_id']; $this->Config['theme_id'] = ''; $this->Config['theme_bg_image'] = ''; $this->Config['theme_bg_color'] = ''; $this->Config['theme_text_color'] = ''; $this->Config['theme_link_color'] = ''; $this->Config['theme_bg_image_type'] = ''; $this->Config['theme_bg_repeat'] = ''; $this->Config['theme_bg_fixed'] = ''; } if (empty($qun_info)) { $this->Messager("当前" . $this->Config[changeword][weiqun] . "不存在或者已经被删除了", 'index.php?mod=qun'); } if (!empty($tag)) { $qun_info['icon'] = $this->QunLogic->qun_avatar($qun_info['qid'], 's'); } else { $qun_info['icon'] = $this->QunLogic->qun_avatar($qun_info['qid'], 'b'); } $active = array(); $topic_list = array(); $get_topic_flg = true; $this->item_id = $qid; $params['code'] = $this->item; $cat_ary = $this->QunLogic->get_category(); $top_cat = array(); $sub_cat = array(); if ($cat_ary['second'][$qun_info['cat_id']]) { $sub_cat = array('cat_name' => $cat_ary['second'][$qun_info['cat_id']]['cat_name'], 'cat_id' => $qun_info['cat_id']); $parent_id = $cat_ary['second'][$qun_info['cat_id']]['parent_id']; $top_cat = array('cat_name' => $cat_ary['first'][$parent_id]['cat_name'], 'cat_id' => $parent_id); } else { $top_cat = array('cat_name' => $cat_ary['first'][$qun_info['cat_id']]['cat_name'], 'cat_id' => $qun_info['cat_id']); } $founder_info = $this->TopicLogic->GetMember($qun_info['founderuid']); $qun_admin_list = $this->QunLogic->get_admin_list($qid); $tag_ary = $this->QunLogic->get_qun_tag($qid); $recd_event_list = $this->QunLogic->getRecdEventList($qid); $recd_vote_list = $this->QunLogic->getRecdVoteList($qid); $followme_nums = $this->QunLogic->followme_nums($qid, MEMBER_ID); $perm = $this->QunLogic->chk_perm($qid, MEMBER_ID); $status = ''; $allow_list_manage = false; if (in_array($perm, array(1, 2, 4)) || MEMBER_ROLE_TYPE == 'admin') { $status = 'isgroupuser'; $allow_list_manage = true; } jfunc('app'); $gets = array('mod' => 'qun', 'type' => $this->Get['type'], 'qid' => $qid, 'tag' => $this->Get['tag'], 'code' => $this->Code); $page_url = 'index.php?' . url_implode($gets); $where = " type!='reply' "; if ($this->Get['type']) { if ('pic' == $this->Get['type']) { $where = " `imageid` > 0 "; } else { if ('video' == $this->Get['type']) { $where = " `videoid` > 0 "; } else { if ('music' == $this->Get['type']) { $where = " `musicid` > 0 "; } else { $this->Get['type'] = ''; } } } } if (!empty($tag)) { $sql = "SELECT * FROM " . DB::table('tag') . " WHERE name='" . addslashes($tag) . "'"; $tag_info = DB::fetch_first($sql); $tag_id = $tag_info['id']; $sql = "SELECT item_id FROM " . DB::table('topic_tag') . " WHERE tag_id='{$tag_id}' "; $query = DB::query($sql); $topic_ids = array(); while ($row = DB::fetch($query)) { $topic_ids[$row['item_id']] = $row['item_id']; } if (!empty($topic_ids)) { $where .= " AND tid IN(" . jimplode($topic_ids) . ") "; } $content = "#{$tag}#"; $view = 'tag'; } else { if ($view == "newreply") { $type_where = ' AND ' . $where; $per_page_num = $this->ShowConfig['qun']['topic_reply'] ? $this->ShowConfig['qun']['topic_reply'] : 10; $count = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic') . "\r\n\t\t\t\t\t\t\t\t\t\t\tWhere `replys` > 0 AND item='qun' AND item_id='{$qid}' {$type_where}"); if ($count > 0) { $page_arr = page($count, $per_page_num, $page_url, array('return' => 'array')); $condition = " WHERE `replys` > 0 AND item='qun' AND item_id='{$qid}' {$type_where} ORDER BY `lastupdate` DESC {$page_arr['limit']}"; $topic_list = $this->TopicLogic->Get($condition); } $get_topic_flg = false; } else { if ($view == 'recd') { Load::logic('topic_list'); $TopicListLogic = new TopicListLogic(); $p = array('where' => " tr.recd <= 2 AND tr.item='qun' AND tr.item_id='{$qid}' ", 'perpage' => $per_page_num, 'filter' => $this->Get['type']); $info = $TopicListLogic->get_recd_list($p); if (!empty($info)) { $count = $info['count']; $topic_list = $info['list']; $page_arr = $info['page']; } $get_topic_flg = false; } elseif ($view == 'event') { $param = array('qid' => $qid, 'where' => " a.item = 'qun' and a.item_id = '{$qid}' ", 'page' => true, 'perpage' => 10, 'page_url' => 'index.php?mod=qun&view=event&qid=' . $qid); load::logic('event'); $EventLogic = new EventLogic(); $return = $EventLogic->getEventInfo($param); $count = $return['count'] ? $return['count'] : 0; $event = $return['event_list']; $page_arr = $return['page']; $get_topic_flg = false; } elseif ($view == 'vote') { load::logic('vote'); $VoteLogic = new VoteLogic(); $param = array('where' => " v.item = 'qun' and v.item_id = '{$qid}' ", 'order' => " order by v.dateline ", 'page' => true, 'perpage' => 10, 'page_url' => 'index.php?mod=qun&view=vote&qid=' . $qid); $return = $VoteLogic->find($param); $count = $return['count'] ? $return['count'] : 0; if (!empty($return)) { $vote_list = $return['vote_list']; $page_arr['html'] = $return['page']['html']; $uid_ary = $return['uids']; } if (!empty($uid_ary)) { $members = $this->TopicLogic->GetMember($uid_ary); } $get_topic_flg = false; } elseif ($view == 'image') { $param = array('item' => 'qun', 'itemid' => $qid, 'page' => true, 'per_page_num' => 20, 'page_url' => 'index.php?mod=qun&view=image&qid=' . $qid); $return = jlogic('image')->get($param); $count = $return['count'] ? $return['count'] : 0; $image_list = $return['list']; $page_arr['html'] = $return['page']['html']; $get_topic_flg = false; } elseif ($view == 'attach' && $this->Config['qun_attach_enable']) { global $attach_list; $type = $this->Get['type']; load::logic('attach'); $AttachLogic = new AttachLogic(); $param = array('item' => 'qun', 'itemid' => $qid, 'page' => true, 'per_page_num' => 20, 'page_url' => 'index.php?mod=qun&view=attach&qid=' . $qid . '&type=' . $type); if ($type) { if ('hot' == $type) { $param['order'] = " order by download DESC "; } else { if ('new' == $type) { $param['order'] = " order by id DESC "; } } } $return = $AttachLogic->get($param); $count = $return['count'] ? $return['count'] : 0; $attach_list = $return['list']; $page_arr['html'] = $return['page']['html']; $get_topic_flg = false; } else { $view = 'newtopic'; } } $active[$view] = "class='current'"; } if ($get_topic_flg) { $options = array('where' => $where, 'page' => true, 'perpage' => $this->ShowConfig['qun']['topic_new'] ? $this->ShowConfig['qun']['topic_new'] : 10, 'page_url' => $page_url); $topic_info = app_get_topic_list($this->item, $qid, $options); if (!empty($topic_info)) { $topic_list = $topic_info['list']; $page_arr['html'] = $topic_info['page']['html']; } } $topic_list_count = count($topic_list); $parent_list = $this->_get_parent_topic($topic_list); $gets = array('item' => $this->item, 'item_id' => $qid); $member =& $this->my; if (!$this->Config['acceleration_mode'] && $member['medal_id']) { $medal_list = $this->TopicLogic->GetMedal($member['medal_id'], $member['uid']); } $set_qun_closed = 1; if (empty($tag)) { $new_members = $this->QunLogic->get_new_member_list($qid); $this->Title = $this->Config[changeword][weiqun] . ' - ' . $qun_info['name']; include template('qun/view'); } else { $this->Title = $this->Config[changeword][weiqun] . ' - ' . $qun_info['name'] . ' - ' . $tag; include template('qun/tag_view'); } }
function SearchTopics2($createduid = '', $containers = '', $appose = true, $content = '', $content2 = '', $topicIds = '', $item = '', $item_Ids = '', $forwards = '', $replys = '', $from = '', $type = '', $location = '', $sDateline = '', $eDateline = '', $page = 1, $pageSize, $getReply = false, $includeSelf = true, $getItem = true, $isOpen = false) { $sql = "SELECT t.*,u.uname,u.face_url,b.bname,tl.longtext,tl.id as longid,tl.dateline as ldateline,tl.views,tl.modify_times,tl.last_modify "; $sql .= ",(select (count(tt.tid)) from topic tt where tt.item='baobei' and tt.item_id=t.item_id) as baobei_replys "; $sql .= "FROM topic t "; $sql .= "left join user u on u.uid=t.uid "; $sql .= "left join topic_longtext tl on tl.id=t.longtextid "; $sql .= "left join building b on b.bid=t.container_id "; $order = " order by t.dateline desc"; $where = " where 1=1"; $sqlcount = "select count(t.tid) as rs from topic t"; if ($page > 0) { if ($pageSize == "" || $pageSize == 0) { $pageSize = $this->Config['building_topic_pagesize']; } $startrecord = $pageSize * ($page - 1); $endrecord = $pageSize * $page; $limit = ' limit ' . $startrecord . ',' . $pageSize; } if ($content != '') { $where .= " and t.content like '%{$content}%'"; } if ($content2 != '') { $where .= " and t.content like '%{$content2}%'"; } if ($topicIds != '') { if (!$getReply) { $where .= " and t.tid in({$topicIds})"; } else { $where .= " and t.tid in(select replyids from topic_more where tid in({$topicIds}))"; } } if ($item != '') { $where .= " and t.item='{$item}'"; } if ($item_Ids != '') { $where .= " and t.item_id in({$item_Ids})"; } if ($forwards > 0) { $where .= " and t.forwards>{$forwards}"; } if ($replys > 0) { $where .= " and t.replys>{$replys}"; } if ($from != '') { $where .= " and t.from='{$from}'"; } if ($type != '') { if ($type != 'reply') { $where .= " and t.type='{$type}' and t.type!='reply'"; } else { $where .= " and t.type='{$type}'"; } } else { $where .= " and t.type!='reply'"; } if ($sDateline && $sDateline != '' && $sDateline > 0) { $where .= " and t.dateline>={$sDateline}"; } if ($eDateline && $eDateline != '' && $eDateline > 0) { $where .= " and t.dateline<={$eDateline}"; } $temp = ''; if ($containers && is_array($containers) && count($containers) > 0) { foreach ($containers as $con) { $context = $con['name']; $conids = $con['ids']; if ($temp == '') { $temp = "(t.container='{$context}' and t.container_id in({$conids}))"; } else { $temp .= " or (t.container='{$context}' and t.container_id in({$conids}))"; } } } $uidcon = ''; if ($createduid != '') { $uidcon = "(t.uid in({$createduid}) and t.type!='reply')"; } if ($this->User && $this->User['uid'] > 0) { if ($includeSelf) { if ($uidcon == '') { $uidcon = "(t.uid=" . $this->User['uid'] . " and t.type!='reply')"; } else { $uidcon .= " or " . "(t.uid=" . $this->User['uid'] . " and t.type!='reply')"; } } } if ($uidcon != '' && $temp != '') { if (!$appose) { $where .= " and ({$uidcon} or(" . $temp . "))"; } else { $where .= " and {$uidcon} and (" . $temp . "))"; } } else { if ($uidcon != '' && $temp == '') { $where .= " and {$uidcon}"; } else { if ($uidcon == '' && $temp != '') { $where .= " and (" . $temp . ")"; } } } $time_s = time(); $sqlcount .= $where; $rows = array(); $total_row = $this->DatabaseHandler->FetchFirst($sqlcount); $totalRS = $total_row['rs']; //$this->Logger->Write($sqlcount); if ($totalRS > 0) { $sqlr = trim($sql . $where . $order . $limit); $query = $this->DatabaseHandler->Query($sqlr); $rows = $query->GetAll(); $topics = array(); if ($rows && is_array($rows) && count($rows) > 0) { foreach ($rows as $row) { $row['o_content'] = $row['content']; $this->_parseTag($row); $this->_parseAt($row); if ($isOpen && $isOpen == true) { $row['longtext'] = Json_Filter($row['longtext']); $row['o_content'] = Json_Filter($row['content']); $row['content'] = Json_Filter($row['content']); } $imageids = $row['imageid']; if ($imageids && $imageids != '') { $imagedRows = $this->ImageTopic->GetTopicImages($imageids); if ($imagedRows && is_array($imagedRows) && count($imagedRows) > 0) { $row['imageurls'] = $imagedRows; } $img_names = ''; foreach ($imagedRows as $img) { if ($img_names == '') { $img_names = $img['img_prefix']; } else { $img_names = $img_names . "," . $img['img_prefix']; } } $row['img_names'] = $img_names; } $row['date'] = getTime($row['dateline']); if ($row['lastupdate'] && $row['lastupdate'] > 0) { $row['update'] = date('Y-m-j H:i', $row['lastupdate']); } $from = $row['from']; if ($from == 'web') { $row['platform'] = "邻居网页版"; } else { if (strtolower($from) == 'android') { $row['platform'] = "Android客户端"; } else { if (strtolower($from) == 'iphone') { $row['platform'] = "iPhone客户端"; } else { if (strtolower($from) == 'wp') { $row['platform'] = "WindowsPhone客户端"; } else { $row['platform'] = "未知平台"; } } } } $from = "<a href=\"index.php\">" . $this->Config['sitetitle'] . "</a>"; if ($row['container'] != '') { $c = $row['container']; $c_id = $row['container_id']; $c_name = ''; switch ($c) { case "building": $crow = $this->DatabaseHandler->FetchFirst("select bname from {$c} where bid={$c_id}"); if ($crow) { $from = "<a href=\"index.php?mod=point&action=profile&bid={$c_id}\" target=\"_blank\">" . $crow['bname'] . "</a>"; } break; } } $itemlink = ''; if ($getItem && $getItem == true) { if ($row['item'] != '' && $row['item_id'] != '') { $row['hasitem'] = 1; $item_id = $row['item_id']; switch ($row['item']) { case 'event': $itemlink = "<a href=\"index.php?mod=event&action=main\">活动</a>"; if (!class_exists('EventEntity')) { include __WEB_ROOT . '/Include/Entities/event.entity.php'; } if (!class_exists('EventLogic')) { include __WEB_ROOT . '/Include/logic/event.logic.php'; } $eventLogic = new EventLogic($this->ModObj); $event_row = $eventLogic->SearchEvents('', $item_id, '', '', '', 0, 0); $event = $event_row['data'][0]; $row['item_info'] = $event; break; case 'baobei': $itemlink = "<a href=\"index.php?mod=baobei&action=main\">宝贝</a>"; if (!class_exists('BaoBeiItem')) { include __WEB_ROOT . '/Include/Entities/baobeiitem.php'; } if (!class_exists('BaobeiLogic')) { include __WEB_ROOT . '/Include/logic/baobei.logic.php'; } $baobeiLogic = new BaobeiLogic($this->ModObj); $baobe_row = $baobeiLogic->SearchBaobeis($item_id, '', 0, 0, '', '', 0, 1, 21); $baobei = $baobe_row['data'][0]; $row['item_info'] = $baobei; break; case 'vote': $itemlink = "<a href=\"index.php?mod=vote&action=main\">投票</a>"; if (!class_exists('VoteEntity')) { include __WEB_ROOT . '/Include/Entities/vote.entity.php'; } if (!class_exists('VoteEntryEntity')) { include __WEB_ROOT . '/Include/Entities/voteentry.entity.php'; } if (!class_exists('VoteLogic')) { include __WEB_ROOT . '/Include/logic/vote.logic.php'; } $voteLogic = new VoteLogic($this->ModObj); $vote_row = $vote = $voteLogic->SearchVote('', $item_id, '', '', '', 0, 0); $vote = $vote_row['data'][0]; $row['item_info'] = $vote; break; } } } if ($isOpen && $isOpen == true) { $itemlink = Json_Filter($itemlink); $from = Json_Filter($from); } if ($itemlink != '') { $row['f'] = $itemlink . ' - ' . $from; } else { $row['f'] = $from; } if ($row['roottid'] > 0) { $result = $this->SearchTopics('', '', '', '', '', '', $row['roottid']); $row['root'] = $result['data'][0]; } $topics[] = $row; } $result['data'] = $topics; } } else { $result['data'] = array(); } $time_e = time(); $result['total'] = $totalRS; return $result; }