12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace Short\Lib;
- use Dever;
- class Handle
- {
- public function get($url)
- {
- $where['key'] = md5($url);
- $info = Dever::db('short/info')->one($where);
- if ($info) {
- $id = $info['id'];
- } else {
- $where['url'] = $url;
- $id = Dever::db('short/info')->insert($where);
- }
- return Dever::idtostr($id);
- }
- public function show($str)
- {
- $id = Dever::strtoid($str);
- if ($id && $id > 0) {
- $info = Dever::db('short/info')->one($id);
- if ($info && $info['url']) {
- Dever::location($info['url']);
- }
- }
- return 'error';
- }
- }
|