Beispiel #1
0
 public function show($cond)
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "recommend WHERE 1 " . $cond;
     $q = $this->db->query($sql);
     $info = array();
     $id_array = array();
     while ($row = $this->db->fetch_array($q)) {
         $id_array[$row['source']][] = $row['cid'];
         $info[] = $row;
     }
     //	hg_pre($id_array);
     $user = array();
     if (!empty($id_array['user'])) {
         include_once ROOT_PATH . 'lib/class/member.class.php';
         $obj_member = new member();
         $data = $obj_member->getMemberById(implode(',', $id_array['user']));
         $user = $data[0];
         //	hg_pre($user);
     }
     $action = array();
     if (!empty($id_array['action'])) {
         include_once ROOT_PATH . 'lib/class/activity.class.php';
         $obj_activity = new activityCLass();
         $data = $obj_activity->show(implode(',', $id_array['action']));
         $action = $data['data'];
         $team_id = $space = '';
         foreach ($action as $k => $v) {
             $team_id .= $space . $v['team_id'];
             $space = ',';
         }
         if ($team_id) {
             include_once ROOT_PATH . 'lib/class/team.class.php';
             $obj_team = new team();
             $team_tmp = $obj_team->get_team_by_id($team_id);
             $team_tmp = $team_tmp[0];
             foreach ($action as $k => $v) {
                 $action[$k]['team_name'] = $team_tmp[$v['team_id']]['team_name'];
             }
         }
     }
     $team = array();
     if (!empty($id_array['team'])) {
         include_once ROOT_PATH . 'lib/class/team.class.php';
         $obj_team = new team();
         $data = $obj_team->get_team_by_id(implode(',', $id_array['team']));
         $team = $data[0];
     }
     $topic = array();
     if (!empty($id_array['topic'])) {
         include_once ROOT_PATH . 'lib/class/team.class.php';
         $obj_team = new team();
         $data = $obj_team->get_topic_by_id(implode(',', $id_array['topic']));
         $topic = $data[0];
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "column WHERE 1";
     $q = $this->db->query($sql);
     $column = array();
     while ($row = $this->db->fetch_array($q)) {
         $column[$row['id']] = $row['name'];
     }
     $ret = array();
     foreach ($info as $k => $v) {
         $tmp = ${$v}['source'];
         $ret[$k] = array('id' => $v['id'], 'cid' => $v['cid'], 'title' => $v['title'], 'source' => $v['source'], 'column_id' => $column[$v['column_id']], 'pubtime' => $v['pubtime'], 'data' => $tmp[$v['cid']]);
     }
     return $ret;
 }
Beispiel #2
0
 public function getOftenById($member_id, $source = "", $con = "")
 {
     if (empty($member_id)) {
         return false;
     }
     $cond = '';
     if ($source) {
         $cond = " AND source='" . $source . "' ";
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "visit WHERE 1 " . $cond . " AND user_id=" . $member_id . " ORDER BY num DESC" . $con;
     $q = $this->db->query($sql);
     $member_id = $action_id = $team_id = $topic_id = '';
     $member_space = $action_space = $team_space = $topic_space = '';
     $info = array();
     while ($row = $this->db->fetch_array($q)) {
         switch ($row['source']) {
             case 'user':
                 $member_id .= $member_space . $row['cid'];
                 $member_space = ",";
                 break;
             case 'action':
                 $action_id .= $action_space . $row['cid'];
                 $action_space = ",";
                 break;
             case 'team':
                 $team_id .= $team_space . $row['cid'];
                 $team_space = ",";
                 break;
             case 'topic':
                 $topic_id .= $topic_space . $row['cid'];
                 $topic_space = ",";
                 break;
             default:
                 break;
         }
         $info[] = array('id' => $row['id'], 'source' => $row['source'], 'cid' => $row['cid'], 'visit_time' => $row['visit_time']);
     }
     $member_info = $action_info = $team_info = $topic_info = array();
     if (!empty($member_id)) {
         include_once ROOT_PATH . 'lib/class/member.class.php';
         $obj_member = new member();
         $data = $obj_member->getMemberById($member_id);
         $member_info = $data[0];
     }
     if (!empty($action_id)) {
         include_once ROOT_PATH . 'lib/class/activity.class.php';
         $obj_activity = new activityCLass();
         $data = $obj_activity->show($action_id);
         $action_info = $data['data'];
     }
     if (!empty($team_id)) {
         include_once ROOT_PATH . 'lib/class/team.class.php';
         $obj_team = new team();
         $data = $obj_team->get_team_by_id($team_id);
         $team_info = $data[0];
     }
     if (!empty($topic_id)) {
         include_once ROOT_PATH . 'lib/class/team.class.php';
         $obj_team = new team();
         $data = $obj_team->get_topic_by_id($topic_id);
         $topic_info = $data[0];
     }
     //
     foreach ($info as $k => $v) {
         switch ($v['source']) {
             case 'user':
                 if (empty($member_info[$v['cid']])) {
                     unset($info[$k]);
                 } else {
                     $info[$k]['data'] = $member_info[$v['cid']];
                 }
                 break;
             case 'action':
                 if (empty($action_info[$v['cid']])) {
                     unset($info[$k]);
                 } else {
                     $info[$k]['data'] = $action_info[$v['cid']];
                 }
                 break;
             case 'team':
                 if (empty($team_info[$v['cid']])) {
                     unset($info[$k]);
                 } else {
                     $info[$k]['data'] = $team_info[$v['cid']];
                 }
                 break;
             case 'topic':
                 if (empty($topic_info[$v['cid']])) {
                     unset($info[$k]);
                 } else {
                     $info[$k]['data'] = $topic_info[$v['cid']];
                 }
                 break;
             default:
                 break;
         }
     }
     return $info;
 }
Beispiel #3
0
 public function show()
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "search_queue WHERE 1";
     //新插入
     $q = $this->db->query($sql);
     $id_array = array();
     while ($row = $this->db->fetch_array($q)) {
         if ($row['state'] == 0) {
             $id_array[$row['source']]['create'][$row['id']] = $row['cid'];
         }
         if ($row['state'] == 1) {
             $id_array[$row['source']]['update'][$row['id']] = $row['cid'];
         }
         if ($row['state'] == 2) {
             $id_array[$row['source']]['delete'][$row['id']] = $row['cid'];
         }
     }
     if (!empty($id_array)) {
         $this->xs_index(array(), 'search_config_team', 'clean');
         if (!empty($id_array['user'])) {
             include_once ROOT_PATH . 'lib/class/member.class.php';
             $obj_member = new member();
             if ($id_array['user']['create']) {
                 $user = array();
                 $tmp = $id_array['user']['create'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $user = $obj_member->getMemberInfoById($ids);
                 //hg_pre($user);
                 if (!empty($user)) {
                     foreach ($user as $k => $v) {
                         $data = array('id' => $tmp[$v['id']], 'title' => $v['nick_name'], 'content' => $v['talk']['content'], 'source' => 'user', 'user_id' => $v['id'], 'user_name' => $v['nick_name'], 'address' => '', 'province' => $v['home_prov'], 'city' => $v['home_city'], 'area' => $v['home_dist'], 'sex' => $v['sex'] ? $v['sex'] == 1 ? '男' : '女' : '保密', 'bloodtype' => $v['bloodtype_name'], 'constellation' => $v['constellation_name'], 'talk' => $v['talk']['content'], 'img' => !empty($v['indexpic']) ? serialize($v['indexpic']) : '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['ip']);
                         //	hg_pre($data);
                         file_put_contents('../cache/user.php', var_export($v, 1));
                         $reback = $this->xs_index($data, 'search_config_team', 'add');
                         $this->update_state($ids, 'user', -1);
                     }
                 }
             }
             if ($id_array['user']['update']) {
                 $user = array();
                 $tmp = $id_array['user']['update'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $user = $obj_member->getMemberInfoById($ids);
                 //hg_pre($user);
                 if (!empty($user)) {
                     foreach ($user as $k => $v) {
                         $data = array('id' => $tmp[$v['id']], 'title' => $v['nick_name'], 'content' => $v['talk']['content'], 'source' => 'user', 'user_id' => $v['id'], 'user_name' => $v['nick_name'], 'address' => '', 'province' => $v['home_prov'], 'city' => $v['home_city'], 'area' => $v['home_dist'], 'sex' => $v['sex'] ? $v['sex'] == 1 ? '男' : '女' : '保密', 'bloodtype' => $v['bloodtype_name'], 'constellation' => $v['constellation_name'], 'talk' => $v['talk']['content'], 'img' => !empty($v['indexpic']) ? serialize($v['indexpic']) : '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['ip']);
                         //	hg_pre($data);
                         $reback = $this->xs_index($data, 'search_config_team', 'update');
                         $this->update_state($ids, 'user', -1);
                     }
                 }
             }
             if ($id_array['user']['delete']) {
                 $data = array();
                 foreach ($id_array['user']['delete'] as $k => $v) {
                     $data[] = $k;
                 }
                 if ($data) {
                     $reback = $this->xs_index($data, 'search_config_team', 'del');
                     $this->update_state(implode(',', $id_array['user']['delete']), 'user', -1);
                 }
             }
         }
         if (!empty($id_array['team'])) {
             include_once ROOT_PATH . 'lib/class/team.class.php';
             $obj_team = new team();
             if ($id_array['team']['create']) {
                 $team = array();
                 $tmp = $id_array['team']['create'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_team->get_team_by_id($ids);
                 $team = $data[0];
                 if (!empty($team)) {
                     foreach ($team as $k => $v) {
                         $data = array('id' => $tmp[$v['team_id']], 'title' => $v['team_name'], 'content' => $v['introduction'], 'source' => 'team', 'team_id' => $v['team_id'], 'team_name' => $v['team_name'], 'img' => !empty($v['team_logo']) ? serialize($v['team_logo']) : '', 'introduction' => $v['introduction'], 'user_id' => $v['creater_id'], 'user_name' => $v['creater_name'], 'team_type' => $v['team_type'], 'category' => $v['team_category'], 'attention_num' => $v['attention_num'], 'topic_num' => $v['topic_num'], 'action_num' => $v['action_num'], 'apply_num' => $v['apply_num'], 'visit_num' => $v['visit_num'], 'notice' => $v['notice'], 'type_name' => $v['type_name'], 'category_name' => $v['category_name'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['team_logo']['ip']);
                         //	hg_pre($data);
                         file_put_contents('../cache/team.php', var_export($v, 1));
                         $reback = $this->xs_index($data, 'search_config_team', 'add');
                         $this->update_state($ids, 'team', -1);
                     }
                 }
             }
             if ($id_array['team']['update']) {
                 $team = array();
                 $tmp = $id_array['team']['update'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_team->get_team_by_id($ids);
                 $team = $data[0];
                 if (!empty($team)) {
                     foreach ($team as $k => $v) {
                         $data = array('id' => $tmp[$v['team_id']], 'title' => $v['team_name'], 'content' => $v['introduction'], 'source' => 'team', 'team_id' => $v['team_id'], 'team_name' => $v['team_name'], 'img' => !empty($v['team_logo']) ? serialize($v['team_logo']) : '', 'introduction' => $v['introduction'], 'user_id' => $v['creater_id'], 'user_name' => $v['creater_name'], 'team_type' => $v['team_type'], 'category' => $v['team_category'], 'attention_num' => $v['attention_num'], 'topic_num' => $v['topic_num'], 'action_num' => $v['action_num'], 'apply_num' => $v['apply_num'], 'visit_num' => $v['visit_num'], 'notice' => $v['notice'], 'type_name' => $v['type_name'], 'category_name' => $v['category_name'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['team_logo']['ip']);
                         //	hg_pre($data);
                         $reback = $this->xs_index($data, 'search_config_team', 'update');
                         $this->update_state($ids, 'team', -1);
                     }
                 }
             }
             if ($id_array['team']['delete']) {
                 $data = array();
                 foreach ($id_array['team']['delete'] as $k => $v) {
                     $data[] = $k;
                 }
                 if ($data) {
                     $reback = $this->xs_index($data, 'search_config_team', 'del');
                     $this->update_state(implode(',', $id_array['team']['delete']), 'team', -1);
                 }
             }
         }
         if (!empty($id_array['action'])) {
             include_once ROOT_PATH . 'lib/class/activity.class.php';
             $obj_activity = new activityCLass();
             include_once ROOT_PATH . 'lib/class/team.class.php';
             $obj_team = new team();
             if ($id_array['action']['create']) {
                 $tmp = $id_array['action']['create'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_activity->show($ids);
                 $action = $data['data'];
                 $team_id = $space = '';
                 foreach ($action as $k => $v) {
                     $team_id .= $space . $v['team_id'];
                     $space = ',';
                 }
                 if ($team_id) {
                     $team_tmp = $obj_team->get_team_by_id($team_id);
                     $team_tmp = $team_tmp[0];
                     foreach ($action as $k => $v) {
                         $action[$k]['team_name'] = $team_tmp[$v['team_id']]['team_name'];
                     }
                 }
                 if (!empty($action)) {
                     foreach ($action as $k => $v) {
                         $data = array('id' => $tmp[$v['action_id']], 'title' => $v['action_name'], 'content' => $v['summary'], 'source' => 'action', 'action_id' => $v['action_id'], 'action_name' => $v['action_name'], 'user_id' => $v['user_id'], 'user_name' => $v['user_name'], 'img' => !empty($v['action_img']) ? serialize($v['action_img']) : '', 'category' => $team_tmp[$v['team_id']]['team_category'], 'team_id' => $v['team_id'], 'team_name' => $v['team_name'], 'slogan' => $v['slogan'], 'register_time' => $v['register_time'], 'start_time' => $v['start_time'], 'end_time' => $v['end_time'], 'address' => $v['address'], 'province' => $v['province'], 'city' => $v['city'], 'area' => $v['area'], 'yet_join' => $v['yet_join'], 'apply_num' => $v['apply_num'], 'collect_num' => $v['collect_num'], 'thread_num' => $v['thread_num'], 'reply_num' => $v['reply_num'], 'scan_num' => $v['scan_num'], 'share_num' => $v['share_num'], 'praise_num' => $v['praise_num'], 'isopen' => $v['isopen'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['from_ip']);
                         //	hg_pre($data);
                         file_put_contents('../cache/action.php', var_export($v, 1));
                         $reback = $this->xs_index($data, 'search_config_team', 'add');
                         $this->update_state($ids, 'action', -1);
                     }
                 }
             }
             if ($id_array['action']['update']) {
                 $tmp = $id_array['action']['update'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_activity->show($ids);
                 $action = $data['data'];
                 $team_id = $space = '';
                 foreach ($action as $k => $v) {
                     $team_id .= $space . $v['team_id'];
                     $space = ',';
                 }
                 if ($team_id) {
                     $team_tmp = $obj_team->get_team_by_id($team_id);
                     $team_tmp = $team_tmp[0];
                     foreach ($action as $k => $v) {
                         $action[$k]['team_name'] = $team_tmp[$v['team_id']]['team_name'];
                     }
                 }
                 if (!empty($action)) {
                     foreach ($action as $k => $v) {
                         $data = array('id' => $tmp[$v['action_id']], 'title' => $v['action_name'], 'content' => $v['summary'], 'source' => 'action', 'action_id' => $v['action_id'], 'action_name' => $v['action_name'], 'user_id' => $v['user_id'], 'user_name' => $v['user_name'], 'img' => !empty($v['action_img']) ? serialize($v['action_img']) : '', 'category' => $team_tmp[$v['team_id']]['team_category'], 'team_id' => $v['team_id'], 'team_name' => $v['team_name'], 'slogan' => $v['slogan'], 'register_time' => $v['register_time'], 'start_time' => $v['start_time'], 'end_time' => $v['end_time'], 'address' => $v['address'], 'province' => $v['province'], 'city' => $v['city'], 'area' => $v['area'], 'yet_join' => $v['yet_join'], 'apply_num' => $v['apply_num'], 'collect_num' => $v['collect_num'], 'thread_num' => $v['thread_num'], 'reply_num' => $v['reply_num'], 'scan_num' => $v['scan_num'], 'share_num' => $v['share_num'], 'praise_num' => $v['praise_num'], 'isopen' => $v['isopen'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['from_ip']);
                         //	hg_pre($data);
                         $reback = $this->xs_index($data, 'search_config_team', 'update');
                         $this->update_state($ids, 'action', -1);
                     }
                 }
             }
             if ($id_array['action']['delete']) {
                 $data = array();
                 foreach ($id_array['action']['delete'] as $k => $v) {
                     $data[] = $k;
                 }
                 if ($data) {
                     $reback = $this->xs_index($data, 'search_config_team', 'del');
                     $this->update_state(implode(',', $id_array['action']['delete']), 'action', -1);
                 }
             }
         }
         if (!empty($id_array['topic'])) {
             include_once ROOT_PATH . 'lib/class/team.class.php';
             $obj_team = new team();
             if ($id_array['topic']['create']) {
                 $topic = array();
                 $tmp = $id_array['topic']['create'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_team->get_topic_by_id($ids);
                 $topic = $data[0];
                 if (!empty($topic)) {
                     $team_id = $space = "";
                     foreach ($topic as $k => $v) {
                         $team_id .= $space . $v['source_id'];
                         $space = ',';
                     }
                     $team_tmp = $obj_team->get_team_by_id($team_id);
                     $team_tmp = $team_tmp[0];
                     foreach ($topic as $k => $v) {
                         $data = array('id' => $tmp[$v['topic_id']], 'title' => $v['subject'], 'content' => $v['content'], 'source' => 'topic', 'topic_id' => $v['topic_id'], 'team_id' => $v['source_id'], 'team_name' => $v['source_name'], 'category' => $team_tmp[$v['source_id']]['team_category'], 'user_id' => $v['creater_id'], 'user_name' => $v['creater_name'], 'topic_type' => $v['topic_type'], 'material_num' => $v['material_num'], 'img' => !empty($v['data']) ? serialize($v['data']) : '', 'views' => $v['views'], 'replies' => $v['replies'], 'favor_num' => $v['favor_num'], 'is_essence' => $v['is_essence'], 'is_sticky' => $v['is_sticky'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['from_ip']);
                         //	hg_pre($data);
                         file_put_contents('../cache/topic.php', var_export($v, 1));
                         $reback = $this->xs_index($data, 'search_config_team', 'add');
                         $this->update_state($ids, 'topic', -1);
                     }
                 }
             }
             if ($id_array['topic']['update']) {
                 $topic = array();
                 $tmp = $id_array['topic']['update'];
                 $ids = implode(',', $tmp);
                 $tmp = array_flip($tmp);
                 $data = $obj_team->get_topic_by_id($ids);
                 $topic = $data[0];
                 if (!empty($topic)) {
                     $team_id = $space = "";
                     foreach ($topic as $k => $v) {
                         $team_id .= $space . $v['source_id'];
                         $space = ',';
                     }
                     $team_tmp = $obj_team->get_team_by_id($team_id);
                     $team_tmp = $team_tmp[0];
                     foreach ($topic as $k => $v) {
                         $data = array('id' => $tmp[$v['topic_id']], 'title' => $v['subject'], 'content' => $v['content'], 'source' => 'topic', 'topic_id' => $v['topic_id'], 'team_id' => $v['source_id'], 'team_name' => $v['source_name'], 'category' => $team_tmp[$v['source_id']]['team_category'], 'user_id' => $v['creater_id'], 'user_name' => $v['creater_name'], 'topic_type' => $v['topic_type'], 'material_num' => $v['material_num'], 'img' => !empty($v['data']) ? serialize($v['data']) : '', 'views' => $v['views'], 'replies' => $v['replies'], 'favor_num' => $v['favor_num'], 'is_essence' => $v['is_essence'], 'is_sticky' => $v['is_sticky'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $v['from_ip']);
                         //	hg_pre($data);
                         $reback = $this->xs_index($data, 'search_config_team', 'update');
                         $this->update_state($ids, 'topic', -1);
                     }
                 }
             }
             if ($id_array['topic']['delete']) {
                 $data = array();
                 foreach ($id_array['topic']['delete'] as $k => $v) {
                     $data[] = $k;
                 }
                 if ($data) {
                     //	$reback = $this->xs_index($data, 'search_config_team','del');
                     $this->update_state(implode(',', $id_array['topic']['delete']), 'topic', -1);
                 }
             }
         }
     }
 }