getHome($where); if ($data) { foreach ($data as $k => $v) { $data[$k] = $this->getPic($v); $data[$k]['link'] = Dever::url('main/xnr-detail?id=' . $v['id']); $data[$k]['info'] = Dever::cut($v['info'], 50); } } return $data; } public function getDataByCreater($creater_id) { $where = array(); //$where['creater_id'] = $creater_id; //$data = Dever::db('content/xuniren')->getDataByCreater($where); $where['cid'] = $creater_id; $data = Dever::db('content/creater_xuniren')->getAll($where); $result = array(); if ($data) { foreach ($data as $k => $v) { $info = Dever::db('content/xuniren')->one($v['xid']); if ($info) { $info = $this->getPic($info); $info['sname'] = $info['name']; $info['link'] = Dever::url('main/xnr-detail?id=' . $info['id']); $info['info'] = '简介 ' . $info['info']; $result[] = $info; } } } return $result; } private function getPic($data) { $data['pic'] = str_replace('http://8.131.66.239/', 'http://www.virtualbeings.cn/', $data['pic']); if (strstr($data['pic'], ',')) { $data['pic_list'] = explode(',', $data['pic']); $data['pic'] = $data['pic_list'][0]; } else { $data['pic_list'][] = $data['pic']; } return $data; } public function getInfo($id) { $data = Dever::db('content/xuniren')->one(array('id' => $id)); if ($data) { $data = $this->getPic($data); $data['news'] = Dever::array_decode($data['news']); /* if ($data['bdate']) { $data['age'] = $this->birthday($data['bdate']); if ($data['age'] <= 0) { $data['age'] = '不详'; } } else { $data['age'] = '不详'; } */ if (!$data['age']) { $data['age'] = '不详'; } if ($data['sex'] == 1) { $data['sex'] = '男'; } elseif ($data['sex'] == 2) { $data['sex'] = '女'; } else { $data['sex'] = '不详'; } //$data['sname'] = $data['name'] . ' / ' . $data['ename']; $data['sname'] = $data['name']; //$data['pdate'] = date('Y/m/d', $data['pdate']); $data['pdate'] = $data['pdate_string']; $data['creater_name'] = ''; $creater_name = array(); $where['xid'] = $data['id']; $info = Dever::db('content/creater_xuniren')->getAll($where); if ($info) { foreach ($info as $k => $v) { $creater = Dever::db('content/creater')->one(array('id' => $v['cid'])); if ($creater) { $url = Dever::url('main/zwz-detail?id=' . $creater['id']); $creater_name[] = '' . $creater['name'] . ''; } } } if ($data['zwz']) { $temp = explode(',', $data['zwz']); $creater_name = array_merge($creater_name, $temp); } if ($creater_name) { $data['creater_name'] = implode(' & ', $creater_name); } } return $data; } public function birthday($age) { $temp = explode("-",date("Y-m-d",$age)); $y1 = $temp[0]; $m1 = $temp[1]; $d1 = $temp[2]; $temp = explode("-",date("Y-m-d")); $y2 = $temp[0]; $m2 = $temp[1]; $d2 = $temp[2]; $age = $y2 - $y1; if((int)($m2.$d2) < (int)($m1.$d1)) $age -= 1; return $age; } }