public function upload() { //上传文件 $this->files = $this->upload->save(); //设置错误 if ($this->upload->error()) { $this->error($this->upload->error(), $this->upload->msg()); } if (is_array($this->files)) { //保存文件 $ip = ip::current(); $userid = $this->_user['id']; $description = (array) $this->description; foreach ($this->files as $key => $file) { if (!$this->isExist($this->_key, $file['id'])) { $image = $this->info($file['path']); $file['id'] = $file['id']; $file['parentid'] = $file['id']; $file['globalid'] = $this->globalid; $file['folderid'] = $this->folderid; $file['field'] = $this->field; $file['type'] = 'image'; $file['width'] = $image['width']; $file['height'] = $image['height']; $file['description'] = empty($description[$key]) ? $file['description'] : $description[$key]; $file['userid'] = $userid; $file['createip'] = $ip; $file['createtime'] = TIME; $this->insert($file); } } return $this->files; } return array(); }
/** * 刷新用户状态,包括登录时间以及登录次数等 * */ public function refresh($id = '') { $id = empty($id) ? $this->id : $id; if (empty($id)) { return false; } $result = $this->update(array('id' => (int) $id, 'logintime' => TIME, 'loginnum' => array('loginnum', '+', 1), 'loginip' => ip::current())); return $result; }
public function upload() { //上传文件 $this->files = $this->upload->save(); //设置错误 if ($this->upload->error()) { $this->error($this->upload->error(), $this->upload->msg()); } if (is_array($this->files)) { //保存文件 $ip = ip::current(); $userid = $this->_user['id']; $description = (array) $this->description; foreach ($this->files as $key => $file) { $file['id'] = $file['id']; $file['parentid'] = $file['id']; $file['globalid'] = $this->globalid; $file['groupid'] = $this->folderid; $file['field'] = $this->field; $file['type'] = file::type($file['path']); $file['description'] = empty($description[$key]) ? $file['description'] : $description[$key]; $file['userid'] = $userid; $file['status'] = (int) $this->status; $file['createip'] = $ip; $file['createtime'] = TIME; if ($file['type'] == 'image' || preg_match('/^(jpeg|jpeg|png|gif|bmp|ico|tif|tiff|psd|xbm|xcf)$/', $file['ext'])) { $info = image::info($file['path']); $file['width'] = (int) $info['width']; $file['height'] = (int) $info['height']; } $this->insert($file); } return $this->files; } return array(); }