Base.php 24 KB

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