Base.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <?php
  2. namespace Passport\Lib;
  3. use Dever;
  4. use Upload\Src\Lib\Img;
  5. use Dever\Routing\Uri;
  6. use Dever\Session\Oper as Save;
  7. use Dever\String\Encrypt;
  8. class Base
  9. {
  10. const NAME = 'passportv10';
  11. const CODE = 'code';
  12. const MCODE = 'mcode';
  13. protected $save = false;
  14. protected $save_type = 'session';
  15. public function __construct()
  16. {
  17. //$this->save = new Save(false, 'cookie');
  18. $save_type = $this->save_type = Dever::config('base', 'project')->mobileCode['save'];
  19. if ($this->save_type == 'db') {
  20. $save_type = 'session';
  21. }
  22. $this->save = new Save(false, $save_type);
  23. }
  24. # 返回加密的用户信息
  25. public function getSign($uid, $vid = false, $mobile = false)
  26. {
  27. if ($vid) {
  28. $data['vid'] = $vid;
  29. }
  30. if ($mobile) {
  31. $data['mobile'] = $mobile;
  32. }
  33. $data['uid'] = $uid;
  34. $data['signature'] = Dever::login($uid);
  35. return $data;
  36. }
  37. # 注册用户
  38. public function reg($type, $system_source, $data)
  39. {
  40. $user = $this->getUserExtInfo($data);
  41. $user['source_type'] = $type;
  42. $user['system_source'] = $system_source;
  43. $user['system_id'] = isset($data['system']) ? $data['system'] : 1;
  44. if (isset($data['username'])) {
  45. $user['temp'] = 2;
  46. $user['username'] = $data['username'];
  47. } else {
  48. $user['temp'] = 1;
  49. $user['username'] = '临时用户';
  50. }
  51. if (isset($data['mobile'])) {
  52. $user['bind'] = 1;
  53. $user['mobile'] = $data['mobile'];
  54. } else {
  55. $user['bind'] = 2;
  56. $user['mobile'] = '';
  57. }
  58. $uid = Dever::db('passport/user')->insert($user);
  59. $this->invite($uid);
  60. $this->createUsername($uid, $user['username'], true);
  61. return $uid;
  62. }
  63. # 更新用户
  64. public function updateUser($uid, $data)
  65. {
  66. $user = $this->getUserExtInfo($data);
  67. $user['username'] = $this->createUsername($uid, $data['username']);
  68. if (isset($user) && $user) {
  69. $user['where_id'] = $uid;
  70. Dever::db('passport/user')->update($user);
  71. }
  72. return $uid;
  73. }
  74. private function getUserExtInfo($data)
  75. {
  76. $user = array();
  77. if (isset($data['sex'])) {
  78. $user['sex'] = $data['sex'];
  79. }
  80. if (isset($data['avatar']) && $data['avatar']) {
  81. //$update['avatar'] = $this->saveAvatar($pic);
  82. $user['avatar'] = $data['avatar'];
  83. } else {
  84. # 获取默认头像
  85. $where = array();
  86. if (isset($user['sex']) && $user['sex']) {
  87. $where['sex'] = $user['sex'] . ',4';
  88. }
  89. $avatar = Dever::db('passport/avatar')->rand($where);
  90. if ($avatar) {
  91. $user['avatar_id'] = $avatar['id'];
  92. }
  93. }
  94. if (isset($data['city'])) {
  95. $user['city'] = $data['city'];
  96. }
  97. if (isset($data['province'])) {
  98. $user['province'] = $data['province'];
  99. }
  100. if (isset($data['country'])) {
  101. $user['country'] = $data['country'];
  102. }
  103. if (isset($user['country']) && isset($user['province']) && isset($user['city'])) {
  104. $user['set_area'] = $user['country'] .','. $user['province'] .','. $user['city'];
  105. }
  106. return $user;
  107. }
  108. public function wechat($data, $user = array(), $account, $system, $source_type, $system_source, $source = false, $invite = false, $uid = false)
  109. {
  110. if ($uid <= 0) {
  111. $uid = false;
  112. }
  113. if (!$data['openid']) {
  114. Dever::alert('错误的openid');
  115. }
  116. if (!isset($user['username'])) {
  117. Dever::alert('用户名错误');
  118. }
  119. if (isset($user['sex'])) {
  120. if ($user['sex'] != 1 && $user['sex'] != 2) {
  121. $user['sex'] = 3;
  122. }
  123. }
  124. if (isset($user['country']) && $user['country'] && isset($user['province']) && $user['province'] && isset($user['city']) && $user['city']) {
  125. $user['area'] = $user['country'] .','. $user['province'] .','. $user['city'];
  126. }
  127. $info = Dever::db('passport/wechat')->one(array('openid' => $data['openid']));
  128. if (!$info) {
  129. if (isset($data['unionid']) && $data['unionid']) {
  130. $info = Dever::db('passport/wechat')->one(array('unionid' => $data['unionid']));
  131. if ($info) {
  132. $uid = $info['uid'];
  133. }
  134. $wechat['unionid'] = $data['unionid'];
  135. }
  136. if (!$uid) {
  137. $user['source_type'] = 'service';//即将废弃
  138. $user['system_source'] = 6;
  139. if ($system) {
  140. $user['system_id'] = $system;
  141. }
  142. if ($source_type) {
  143. $user['source_type'] = $source_type;
  144. }
  145. if ($system_source) {
  146. $user['system_source'] = $system_source;
  147. }
  148. $uid = Dever::db('passport/user')->insert($user);
  149. } else {
  150. $user['where_id'] = $uid;
  151. Dever::db('passport/user')->update($user);
  152. }
  153. $wechat['access_token'] = $data['access_token'];
  154. $wechat['openid'] = $data['openid'];
  155. $wechat['expires_in'] = $data['expires_in'];
  156. $wechat['refresh_token'] = $data['refresh_token'];
  157. if ($account) {
  158. $wechat['account_id'] = $account;
  159. }
  160. if ($system) {
  161. $wechat['system_id'] = $system;
  162. }
  163. $wechat['uid'] = $uid;
  164. # 此处整个废弃
  165. if ($source_type) {
  166. # 默认为公众号
  167. $wechat['type'] = 2;//即将废弃,统一
  168. $wechat['system_source'] = 6;
  169. if ($source_type == 'applet') {
  170. $wechat['type'] = 1;//即将废弃,统一
  171. $wechat['system_source'] = 5;
  172. } elseif ($source_type == 'ios') {
  173. $wechat['type'] = 3;//即将废弃,统一
  174. $wechat['system_source'] = 3;
  175. } elseif ($source_type == 'android') {
  176. $wechat['type'] = 4;//即将废弃,统一
  177. $wechat['system_source'] = 2;
  178. }
  179. }
  180. if ($system_source) {
  181. $wechat['system_source'] = $system_source;
  182. }
  183. $id = Dever::db('passport/wechat')->insert($wechat);
  184. if (Dever::project('source') && isset($source) && $source && $source > 0) {
  185. Dever::load('source/lib/core')->saveUser($id, $uid, $source, 'oauth', $account);
  186. }
  187. } else {
  188. $uid = $info['uid'];
  189. if (isset($data['unionid']) && $data['unionid']) {
  190. $wechat['unionid'] = $data['unionid'];
  191. # 判断用户是否存在,是否需要合并
  192. //$wechat['uid'] = $this->combine($uid, $data['unionid']);
  193. }
  194. $wechat['access_token'] = $data['access_token'];
  195. $wechat['openid'] = $data['openid'];
  196. $wechat['expires_in'] = $data['expires_in'];
  197. $wechat['refresh_token'] = $data['refresh_token'];
  198. $wechat['where_id'] = $info['id'];
  199. if ($account) {
  200. $wechat['account_id'] = $account;
  201. }
  202. if ($system) {
  203. $wechat['system_id'] = $system;
  204. }
  205. $id = $info['id'];
  206. //Dever::db('passport/wechat')->update($wechat);
  207. $user['where_id'] = $uid;
  208. //Dever::load('passport/user-update', $user);
  209. }
  210. $this->createUsername($uid, $user['username']);
  211. $user = Dever::load('passport/user-one', $uid);
  212. $this->save($user);
  213. $user['uid'] = $user['id'];
  214. $user['signature'] = Dever::login($user['id']);
  215. return $user;
  216. }
  217. /**
  218. * 更新用户信息 绑定用户手机号
  219. *
  220. * @return mixed
  221. */
  222. public function bind_mobile()
  223. {
  224. $uid = $this->check();
  225. //$code = Dever::input('mcode');
  226. $mobile = Dever::load('passport/reg')->checkMobileExists();
  227. //$mobile = Dever::input('mobile');
  228. if ($mobile && $uid) {
  229. $info = Dever::load('passport/user-one', array('mobile' => $mobile));
  230. if ($info && $info['bind'] == 1) {
  231. Dever::alert('该手机号已绑定');
  232. }
  233. $uid = $this->combine($uid, $mobile, 'mobile');
  234. $info = Dever::load('passport/user-one', $uid);
  235. $result['mobile'] = $mobile;
  236. if ($info) {
  237. $update['set_mobile'] = $mobile;
  238. $update['set_bind'] = 1;
  239. $update['where_id'] = $uid;
  240. Dever::load('passport/user-update', $update);
  241. $state = Dever::config('base', 'project')->regSendSms;
  242. if ($state) {
  243. Dever::setInput('skin', $state);
  244. $this->send($mobile, $uid);
  245. }
  246. } else {
  247. Dever::alert('无效的用户id,请重新登录');
  248. }
  249. }
  250. if (!$info['mobile']) {
  251. Dever::score($uid, 'bind_mobile', '绑定手机号');
  252. }
  253. $result['uid'] = $uid;
  254. $result['signature'] = Dever::login($uid);
  255. return $result;
  256. }
  257. public function createUsername($uid, $username, $update = false)
  258. {
  259. if (!$username || $username == '临时用户') {
  260. $username = $uid + 100000;
  261. $username = 'JM' . $username;
  262. if ($update) {
  263. Dever::db('passport/user')->update(array('where_id' => $uid, 'username' => $username));
  264. }
  265. }
  266. return $username;
  267. }
  268. # 合并用户
  269. public function combine($uid, $unionid, $col = 'unionid')
  270. {
  271. $cur = $uid;
  272. if ($col == 'mobile' || $col == 'id') {
  273. $user_wechat = Dever::load('passport/user-all', array($col => $unionid));
  274. } else {
  275. $user_wechat = Dever::load('passport/wechat-getByUnionid', array($col => $unionid));
  276. }
  277. if ($user_wechat) {
  278. # 合并去
  279. $drop = array();
  280. $total = count($user_wechat);
  281. if ($total <= 1) {
  282. return $cur;
  283. }
  284. $new = false;
  285. foreach ($user_wechat as $k => $v) {
  286. if (!isset($v['uid'])) {
  287. $v['uid'] = $v['id'];
  288. $user = $v;
  289. } else {
  290. $user = Dever::db('passport/user')->one($v['uid']);
  291. $user['uid'] = $user['id'];
  292. }
  293. if (!$new) {
  294. if ($user['bind'] == 1 && !strstr($user['username'], '****')) {
  295. $new = $user;
  296. } elseif ($user['temp'] == 2 && $user['system_source'] == 5) {
  297. $new = $user;
  298. } elseif ($user['temp'] == 2 && $user['source_type'] == 'applet') {
  299. $new = $user;
  300. } elseif ($user['avatar']) {
  301. $new = $user;
  302. } elseif ($user['mobile']) {
  303. $new = $user;
  304. } else {
  305. $drop[$user['uid']] = $user;
  306. }
  307. } else {
  308. $drop[$user['uid']] = $user;
  309. }
  310. }
  311. $cur = $new;
  312. if (Dever::input('test') == 1) {
  313. print_r($user_wechat);
  314. print_r($cur);
  315. print_r($drop);die;
  316. }
  317. # 异步处理
  318. $this->updateCombine($cur, $drop);
  319. $cur = $new['uid'];
  320. }
  321. return $cur;
  322. }
  323. private function updateCombine($new, $drop)
  324. {
  325. # 队列
  326. //Dever::queue();
  327. if (isset($drop[$new['uid']])) {
  328. unset($drop[$new['uid']]);
  329. }
  330. $drops = array();
  331. if ($drop) {
  332. foreach ($drop as $k => $v) {
  333. $drops[] = $k;
  334. $update = array();
  335. if (!$new['username'] && $v['username']) {
  336. $update['username'] = $v['username'];
  337. } elseif (strstr($new['username'], '****') && $v['username']) {
  338. $update['username'] = $v['username'];
  339. }
  340. if (!$new['avatar'] && $v['avatar']) {
  341. $update['avatar'] = $v['avatar'];
  342. }
  343. if (!$new['mobile'] && $v['mobile']) {
  344. $update['mobile'] = $v['mobile'];
  345. }
  346. if (!$new['area'] && $v['area']) {
  347. $update['area'] = $v['area'];
  348. }
  349. if (isset($update) && $update) {
  350. $update['where_id'] = $new['uid'];
  351. Dever::load('passport/user-update', $update);
  352. }
  353. }
  354. if ($drops) {
  355. asort($drops);
  356. $drop_uid = implode(',', $drops);
  357. //Dever::load('passport/lib/base.handleCombine?new_uid=' . $new['uid'] . '&old_uid=' . $drop_uid);
  358. Dever::daemon('lib/base.handleCombine?new_uid=' . $new['uid'] . '&old_uid=' . $drop_uid, 'passport');
  359. }
  360. }
  361. }
  362. public function handleCombine()
  363. {
  364. $combine = array();
  365. $combine['status'] = 1;
  366. $combine['new_uid'] = Dever::input('new_uid');
  367. $combine['old_uid'] = Dever::input('old_uid');
  368. $info = Dever::db('passport/combine')->one($combine);
  369. if (!$info) {
  370. Dever::db('passport/combine')->insert($combine);
  371. }
  372. Dever::load('passport/user-updates', array('set_state' => 2, 'where_id' => $combine['old_uid']));
  373. Dever::load('passport/wechat-updates', array('set_uid' => $combine['new_uid'], 'where_uid' => $combine['old_uid']));
  374. }
  375. /**
  376. * 检测用户有效性
  377. *
  378. * @return mixed
  379. */
  380. public function check($state = true)
  381. {
  382. $signature = Dever::input('signature');
  383. $user = Dever::checkLogin($signature, $state);
  384. if ($state && !isset($user['uid'])) {
  385. Dever::alert('user error');
  386. }
  387. if (isset($user['uid']) && $user['uid']) {
  388. return $user['uid'];
  389. }
  390. return -1;
  391. }
  392. public function getToken($request = array())
  393. {
  394. return http_build_query(Dever::token($request));
  395. }
  396. public function getUrl($method, $request = array())
  397. {
  398. return Dever::proxy($method, $this->getToken($request));
  399. }
  400. protected function info()
  401. {
  402. $data = $this->save->get(self::NAME);
  403. return $data;
  404. }
  405. public function code($code = false, $image = true)
  406. {
  407. if ($code) {
  408. $save = $this->save->get(self::CODE);
  409. $state = $code == $save;
  410. if ($state) {
  411. //$this->save->un(self::CODE);
  412. }
  413. return $state;
  414. }
  415. if ($image) {
  416. $code = new Code();
  417. $code->create();
  418. $code = $code->code;
  419. } else {
  420. $code = Dever::code();
  421. }
  422. $this->save->add(self::CODE, $code, 86400);
  423. return $code;
  424. }
  425. protected function mcode($mobile, $code = false)
  426. {
  427. $day = date('Ymd', time());
  428. # 检测当前手机号最新一次发送时间,不允许一分钟之内发送
  429. $param['option_day'] = $day;
  430. $param['option_mobile'] = $mobile;
  431. if ($code) {
  432. if ($this->save_type == 'db') {
  433. $check = Dever::db('passport/code')->getNew($param);
  434. if ($check) {
  435. return $mobile . '_' . $code == $check['mobile'] . '_' . $check['code'];
  436. }
  437. return false;
  438. } else {
  439. $save = $this->save->get(self::MCODE);
  440. return $mobile . '_' . $code == $save;
  441. }
  442. }
  443. # 检测当前手机号今天已经发送多少验证码了
  444. $info = Dever::load('passport/code-total', $param);
  445. if ($info >= 1) {
  446. $check = Dever::db('passport/code')->getNew($param);
  447. if ($check) {
  448. if (time() - $check['cdate'] < Dever::config('base', 'project')->mobileCode['time']) {
  449. Dever::alert('请不要在一分钟之内申请多次验证码,请您稍后再试');
  450. }
  451. }
  452. }
  453. $total = Dever::config('base', 'project')->mobileCode['total'];
  454. if ($info >= $total) {
  455. Dever::alert('很抱歉,您已经申请获取验证码超过' . $total . '次,今天您已经无法获取验证码了,请您明天再来');
  456. }
  457. $code = new Code();
  458. $code->createM();
  459. # 记录当前的验证码
  460. $insert['add_mobile'] = $mobile;
  461. $insert['add_day'] = $day;
  462. $insert['add_code'] = $code->mcode;
  463. $id = Dever::load('passport/code-insert', $insert);
  464. # 启动发送
  465. $this->send($mobile, $insert['add_code'], $id);
  466. if ($this->save_type != 'db') {
  467. $this->save->add(self::MCODE, $mobile . '_' . $code->mcode, Dever::config('base', 'project')->mobileCode['timeout']);
  468. }
  469. return $code->mcode;
  470. }
  471. public function send($mobile, $code, $id = false)
  472. {
  473. if (Dever::project('sms')) {
  474. $send['skin'] = 'code';
  475. $send['mobile'] = $mobile;
  476. $send['param'] = array
  477. (
  478. 'code' => $code
  479. );
  480. $send['param'] = Dever::json_encode($send['param']);
  481. return Dever::load('sms/api.send', $send);
  482. }
  483. $url = Dever::config('base', 'project')->mobileCode['url'];
  484. if (!$url) {
  485. return;
  486. }
  487. $content = Dever::config('base', 'project')->mobileCode['body'];
  488. $content = $this->replace($content, $mobile, $code);
  489. parse_str($content, $param);
  490. $type = Dever::config('base', 'project')->mobileCode['method'];
  491. $json = Dever::config('base', 'project')->mobileCode['json'];
  492. $header = Dever::config('base', 'project')->mobileCode['header'];
  493. return Dever::curl($url, $param, $type, $json, $header);
  494. }
  495. private function replace($content, $mobile = '', $code = '')
  496. {
  497. $skin = Dever::config('base', 'project')->mobileCode['skin'];
  498. $skin_key = Dever::input('skin', 'code');
  499. if (isset($skin[$skin_key])) {
  500. $skin = $skin[$skin_key];
  501. } else {
  502. $skin = array_shift($skin);
  503. }
  504. $config = array('{code}', '{mobile}', '{sign}', '{skin}', '{param}');
  505. $replace = array($code, $mobile, Dever::config('base', 'project')->mobileCode['sign'], $skin);
  506. return str_replace($config, $replace, $content);
  507. }
  508. protected function refer($state = false)
  509. {
  510. $refer = Dever::input('refer');
  511. $project = 'main';
  512. if ($refer) {
  513. if (!strstr($refer, 'http://')) {
  514. $refer = Encrypt::decode($refer);
  515. }
  516. /*
  517. $url = parse_url(Encrypt::decode($refer));
  518. $url['path'] = preg_replace('/^\//', '', $url['path']);
  519. if (!isset($url['query'])) {
  520. $url['query'] = '';
  521. }
  522. if (Uri::$type == '?') {
  523. $refer = Dever::url(str_replace($url['path'] . Uri::$type, '', $url['query']), $project);
  524. } else {
  525. $refer = Dever::url($url['path'] . '?' . $url['query'], $project);
  526. }
  527. */
  528. } else {
  529. $refer = Dever::url('home', $project);
  530. }
  531. $param = Dever::input('param');
  532. if ($param) {
  533. $refer .= '&' . $param;
  534. }
  535. if ($state) {
  536. return $refer;
  537. }
  538. Dever::out($refer);
  539. }
  540. protected function save($user)
  541. {
  542. if (is_numeric($user)) {
  543. $user = Dever::load('passport/user-one', $user);
  544. }
  545. if ($user && is_array($user)) {
  546. if (Dever::mobile()) {
  547. $time = 30;
  548. } else {
  549. $time = 7;
  550. }
  551. $this->save->add(self::NAME, $user, 3600 * 24 * $time);
  552. $user['signature'] = Dever::login($user['id']);
  553. $this->invite($user['id']);
  554. if (Dever::config('base', 'project')->regAction) {
  555. Dever::load(Dever::config('base', 'project')->regAction, $user);
  556. }
  557. return $user;
  558. }
  559. }
  560. protected function invite($uid)
  561. {
  562. $invite = Dever::input('invite');
  563. if (Dever::project('invite') && $invite) {
  564. Dever::load('invite/api')->setRelation($uid, false, $invite);
  565. }
  566. }
  567. public function createRefer()
  568. {
  569. return 'refer=' . Encrypt::encode(Dever::url(false, 'main'));
  570. }
  571. protected function saveSex($sex)
  572. {
  573. if ($sex || $sex == 0) {
  574. $config_sex = Dever::config('base', 'project')->sex;
  575. if (isset($config_sex[$sex])) {
  576. $sex = $config_sex[$sex];
  577. } else {
  578. if ($sex == '男') {
  579. $sex = 1;
  580. } elseif ($sex == '女') {
  581. $sex = 2;
  582. } elseif ($sex == '未知') {
  583. $sex = 3;
  584. }
  585. }
  586. }
  587. return $sex;
  588. }
  589. protected function saveAvatar($value)
  590. {
  591. if (!$value) {
  592. return '';
  593. }
  594. $value = Dever::pic($value);
  595. $base = Dever::data();
  596. $date = explode('-', date("Y-m-d"));
  597. if (is_array($value)) {
  598. $user = $value[1];
  599. $value = $value[0];
  600. if (is_array($value)) {
  601. $name = md5($value['tmp_name'] . rand(0, 100) . microtime());
  602. $path = 'avatar/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
  603. $ext = '.jpg';
  604. $temp = Dever::path($base, $path . $name . $ext);
  605. move_uploaded_file($value['tmp_name'], $temp);
  606. $value = $temp;
  607. }
  608. }
  609. //$result = Dever::$global['host']['img'] . 'chead.jpg';
  610. if ($value) {
  611. # 裁图
  612. $handle = new Img();
  613. $size = '200_200_2';
  614. $user = isset($user) && $user ? $user : $this->init();
  615. if ($user && isset($user['id']) && $user['id']) {
  616. $name = md5($user['id']);
  617. } else {
  618. $name = md5($value . rand(0, 100) . microtime());
  619. }
  620. $path = 'avatar/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
  621. $ext = '.jpg';
  622. $file = Dever::path($base, $path . $name . $ext);
  623. $temp = $file . '.temp.jpg';
  624. //$value = Dever::curl($value);
  625. //file_put_contents($temp, file_get_contents($value));
  626. $file = $handle->thumb($value, $size, true, $file);
  627. if ($file) {
  628. $result = str_replace('/upload/', '/', Dever::config('host')->uploadRes . $path . $name . $ext);
  629. } else {
  630. $result = $value;
  631. }
  632. }
  633. return $result;
  634. }
  635. }