UserController.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <?php
  2. ini_set('display_errors', 1);
  3. Doo::loadClass('auth');
  4. Doo::loadClass('attfile');
  5. Doo::loadClass('profile');
  6. Doo::loadClass('project');
  7. Doo::loadClass('contractact');
  8. Doo::loadClass('actmeasure');
  9. Doo::loadClass('numofperact');
  10. Doo::loadClass('user');
  11. Doo::loadClass('PasswordHash');
  12. Doo::loadClass('sms');
  13. Doo::loadModelAt('aconfig', 'admin');
  14. Doo::loadClass('measureauditact');
  15. Doo::loadClass('sign');
  16. Doo::loadClass('phpqrcode');
  17. Doo::loadClass('Hashids/Hashids');
  18. /* * proDetail
  19. * MainController
  20. * Feel free to delete the methods and replace them with your own code.
  21. *
  22. * @author darkredz
  23. */
  24. class UserController extends DooController
  25. {
  26. private $data, $sign, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $numofperact, $user, $ph, $sms, $aconfig, $__hashids;
  27. public function beforeRun($resource, $action)
  28. {
  29. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  30. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  31. // if (!$falg)
  32. // return Doo::acl()->defaultFailedRoute;
  33. if ($this->auth->getUid()) {
  34. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  35. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  36. if (!$falg)
  37. return Doo::acl()->defaultFailedRoute;
  38. } else {
  39. return Doo::acl()->defaultFailedRoute;
  40. }
  41. }
  42. public function __construct()
  43. {
  44. $this->data['numofchecking'] = null;
  45. $this->auth = new Auth();
  46. $this->attfile = new attFile();
  47. $this->profile = new Profile();
  48. $this->project = new Project();
  49. $this->contractact = new Contractact();
  50. $this->actmeasure = new actMeasure();
  51. $this->numofperact = new NumofperAct();
  52. $this->user = new User();
  53. $this->ph = new PasswordHash(8, FALSE);
  54. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);
  55. $this->aconfig = new AConfig();
  56. $this->measureauditact = new MeasureauditAct();
  57. $this->sign = new signn();
  58. $this->__hashids = new Hashids\Hashids('jlzfuserid', 8);
  59. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  60. $this->data['currChannle'] = '';
  61. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  62. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  63. if (isset($mpidArray[0]['pid'])) {
  64. foreach ($mpidArray as $key => $value) {
  65. // 审批操作按照时间排序多标段
  66. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  67. }
  68. }
  69. if (!isset($this->data['numofchecking']) || $this->data['numofchecking'] == 0) {
  70. $this->data['numofchecking'] = null;
  71. }
  72. $this->data['signSwitch'] = $this->aconfig->getOne(array('select' => 'signswitch', 'asArray' => TRUE))['signswitch'];
  73. //获取需要您签署的数目
  74. if($this->data['signSwitch'] > 0)
  75. $this->data['needSignNum'] = $this->sign->getNeedSignNumbyUid($this->auth->getUid()) != 0 ? $this->sign->getNeedSignNumbyUid($this->auth->getUid()) : '';
  76. //获取桌面版本
  77. $this->data['version'] = '';
  78. $this->getsoftware();
  79. }
  80. function getsoftware(){
  81. $StrJson = ($this->aconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
  82. $upgradeinfo = json_decode($StrJson, true);
  83. if ($upgradeinfo) {
  84. $this->data['version'] = $upgradeinfo['version'];
  85. $this->data['download'] = $upgradeinfo['download'];
  86. }
  87. }
  88. /**
  89. *
  90. * @return type
  91. */
  92. public function index()
  93. {
  94. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  95. $this->data['uprofile']['email'] = $this->auth->getUemail();
  96. if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone'])) {
  97. $this->profile->upProfile($this->auth->getUid(), $_POST);
  98. return DOO::conf()->APP_URL . 'user/profile';
  99. }
  100. $this->render('edit-profile', $this->data, TRUE);
  101. }
  102. public function avatar()
  103. {
  104. // TODO:加入目录可否写入判断
  105. if (count($_FILES) == 3) {
  106. $result = array();
  107. $result['success'] = false;
  108. $successNum = 0;
  109. $avatarNumber = 1;
  110. $i = 0;
  111. $msg = '';
  112. $dir = 'global/avatar';
  113. while (list($key, $val) = each($_FILES)) {
  114. if ($_FILES[$key]['error'] > 0) {
  115. $msg .= $_FILES[$key]['error'];
  116. } else {
  117. $fileName = date("YmdHis") . '_' . floor(microtime() * 1000) . '_' . self::createRandomCode(8);
  118. if ($key == '__source') {
  119. $initParams = $_POST["__initParams"];
  120. $virtualPath = "$dir/php_source_$fileName.jpg";
  121. $result['sourceUrl'] = '/' . $virtualPath . $initParams;
  122. move_uploaded_file($_FILES[$key]["tmp_name"], Doo::conf()->SITE_PATH . $virtualPath);
  123. $successNum++;
  124. } else if (strpos($key, '__avatar') === 0) {
  125. $virtualPath = "$dir/php_avatar" . $avatarNumber . "_$fileName.jpg";
  126. $result['avatarUrls'][$i] = $virtualPath;
  127. if ($i == 2) {
  128. $this->profile->setAvatar($this->auth->getUid(), $result['avatarUrls'][$i]);
  129. }
  130. move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
  131. $successNum++;
  132. $i++;
  133. }
  134. }
  135. }
  136. $result['msg'] = $msg;
  137. if ($successNum > 0) {
  138. $result['success'] = true;
  139. }
  140. print json_encode($result);
  141. die;
  142. }
  143. $this->render('edit-profile-avtra', $this->data, TRUE);
  144. }
  145. /* * ************************************************************
  146. * 生成指定长度的随机码。
  147. * @param int $length 随机码的长度。
  148. * @access public
  149. * ************************************************************ */
  150. function createRandomCode($length)
  151. {
  152. $randomCode = "";
  153. $randomChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  154. for ($i = 0; $i < $length; $i++) {
  155. $randomCode .= $randomChars{mt_rand(0, 35)};
  156. }
  157. return $randomCode;
  158. }
  159. public function proSection()
  160. {
  161. /**
  162. * 计量期数
  163. * 完成进度
  164. *
  165. */
  166. $this->getFav();
  167. $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
  168. $htmlstr = NULL;
  169. foreach ($contractArray as $k => $v) {
  170. $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
  171. $bdhtmlstr = NULL;
  172. $biaoduantotalmoney = 0;
  173. $currTotal = 0;
  174. $progress = $otherprogress = '0%';
  175. $currTotal = $this->numofperact->getCountTotalSTID($v['stid']);
  176. //
  177. foreach ($retval as $key => $value) {
  178. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  179. $numCount = $this->numofperact->getCountTotalnum($value['pmid']);
  180. $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
  181. $snTotal = $this->numofperact->getStopNow($value['pmid']); //截止目前
  182. $currcomTotal = $this->numofperact->getCurrTotal($value['pmid']); //截止目前
  183. if ($numCount > 0) {
  184. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  185. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  186. $nlessTotalProgress = number_format($totalplus['totalplus'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  187. $snTotalProgress = round(($snTotal['sntotal'] / $totalplus['totalplus']) * 100) . '%';
  188. $currTotalProgress = round(($currcomTotal['currtotal'] / $totalplus['totalplus']) * 100) . '%';
  189. $lessTotalProgress = round((($totalplus['totalplus'] - $currcomTotal['currtotal'] - $snTotal['sntotal']) / $totalplus['totalplus']) * 100) . '%';
  190. }
  191. $biaoduantotalmoney += $value['contracttotal'];
  192. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  193. $bdhtmlstr .= '
  194. <thead>
  195. <tr><th class="taC" width="225">标段名</th><th class="taC" width="140">计量期数</th><th width="115" class="taC">总价</th><th class="taC" width="">截止本期累计完成/本期完成/未完成</th></tr></thead>
  196. <tbody>
  197. <tr>
  198. <td><a href="/project/1/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
  199. <td class="">共 ' . $numCount . ' 期(本期 <span class="colOrange">审批中</span>)</td>
  200. <td class="taR">¥' . $totalmoney . '</td>
  201. <td>
  202. <div class="progress">
  203. <div class="bar bar-success" style="width: ' . $snTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止本期累计完成:¥' . $nTotalProgress . '">' . $snTotalProgress . '</div>
  204. <div class="bar" style="width:' . $currTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $currTotalProgress . '</div>
  205. <div class="bar bar-gary" style="width:' . $lessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $lessTotalProgress . '</div>
  206. </div>
  207. </td>
  208. </tr>';
  209. }
  210. if ($biaoduantotalmoney > 0 && ($currTotal['totalplus'] > 0)) {
  211. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  212. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  213. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%';
  214. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  215. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  216. }
  217. $htmlstr .= '<div class="project">
  218. <div class="proSection">
  219. <table class="table">
  220. <thead>
  221. <tr>
  222. <td width="150"><span aria-hidden="true" data-icon="u"></span> ' . $v['stname'] . '(' . $v['stkey'] . ') <a href="#secoption" data-toggle="modal" title="编辑/查看KEY"><span data-icon="S" aria-hidden="true" value="' . $v['stid'] . '" class="closePanel"></span></a></td>
  223. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  224. <td width="60">完成进度:</td><td><div class="progress">
  225. <div class="bar bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  226. <div class="bar bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  227. </div></td>
  228. </tr>
  229. </thead>
  230. </table>
  231. <table class="table table-striped table-hover">
  232. ' . $bdhtmlstr . '
  233. </tbody>
  234. </table>
  235. </div>
  236. </div>';
  237. }
  238. $this->data['htmlstr'] = $htmlstr;
  239. if (isset($_POST['secname']) && $_POST['secname']) {
  240. $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
  241. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  242. }
  243. $this->data['pid'] = $this->params['pid'];
  244. $this->render('w-project-section', $this->data, TRUE);
  245. }
  246. /**
  247. *
  248. * @return type
  249. */
  250. public function sms()
  251. {
  252. if (isset($_POST['mobile']) && isset($_POST['verifycode'])) {
  253. $vmArray = $this->auth->getVerifyMobile();
  254. if (isset($vmArray) && $vmArray) {
  255. if (md5($_POST['mobile'] . $_POST['verifycode']) == md5($vmArray['mobile'] . $vmArray['code'])) {
  256. $this->profile->updateMobile($this->auth->getUid(), $vmArray['mobile']);
  257. die(json_encode(array('status'=> true)));
  258. }
  259. }
  260. }
  261. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  262. $this->data['smsNoticeSwitch'] = $this->aconfig->getOne(array('select' => 'smsswitch', 'asArray' => TRUE))['smsswitch'];
  263. $this->render('edit-profile-sms', $this->data, TRUE);
  264. }
  265. /**
  266. *
  267. * @return type
  268. */
  269. public function smsEdit()
  270. {
  271. if (isset($_POST['mobile']) && isset($_POST['verifycode'])) {
  272. $vmArray = $this->auth->getVerifyMobile();
  273. if (isset($vmArray) && $vmArray) {
  274. if (md5($_POST['mobile'] . $_POST['verifycode']) == md5($vmArray['mobile'] . $vmArray['code'])) {
  275. $this->profile->updateMobile($this->auth->getUid(), $vmArray['mobile']);
  276. return Doo::conf()->APP_URL . 'user/profile/sms/edit';
  277. }
  278. }
  279. }
  280. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  281. $this->render('edit-profile-sms-edit', $this->data, TRUE);
  282. }
  283. /**
  284. *
  285. * @return type
  286. */
  287. public function checkMobile()
  288. {
  289. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  290. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  291. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  292. // return DOO::conf()->APP_URL . 'user/profile';
  293. // }
  294. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  295. }
  296. /**
  297. *
  298. * @return type
  299. */
  300. public function mobileVerify()
  301. {
  302. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  303. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  304. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  305. // return DOO::conf()->APP_URL . 'user/profile';
  306. // }
  307. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  308. }
  309. /**
  310. *
  311. * @return type
  312. */
  313. public function smsSend()
  314. {
  315. $randNum = rand(1000, 9999);
  316. $this->auth->setVerifyMobile(array('mobile' => $_POST['mobile'], 'code' => $randNum));
  317. $res = $this->sms->sendSms($_POST['mobile'], Doo::conf()->SMS_TIPS['AUDIT_NOTICE'] . $randNum . Doo::conf()->SMS_TIPS['END_MSG']);
  318. die(json_encode(array('verify' => $res)));
  319. }
  320. Function fNumber($number)
  321. {
  322. if ($number == '')
  323. Return "-";
  324. $nlen = strlen($number);
  325. while ($nlen > 3) {
  326. $fNumber = "," . substr($number, $nlen - 3, 3);
  327. $number = substr($number, 0, -3);
  328. $nlen = strlen($number);
  329. }
  330. if ($nlen <= 3) {
  331. $fNumber = $number . $fNumber;
  332. }
  333. Return $fNumber;
  334. }
  335. private function getFav()
  336. {
  337. $proArray = $this->project->getAll();
  338. $this->data['othrPro'] = [];
  339. foreach ($proArray as $key => $value) {
  340. if ($value['pid'] == $this->params['pid']) {
  341. $this->data['currProName'] = $value['pname'];
  342. $this->data['currProID'] = $value['pid'];
  343. } else {
  344. $this->data['othrPro'][] = $proArray[$key];
  345. }
  346. }
  347. }
  348. public function proSectionMeasure()
  349. {
  350. //此处未做更改,JSON文件已经固定名称
  351. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  352. if (isset($jsonpath['dirname'])) {
  353. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  354. if ($handle = opendir($extPathdir)) {
  355. while (false !== ($file = readdir($handle))) {
  356. $filename = NULL;
  357. $filename = pathinfo($file);
  358. if ($filename['extension'] == 'json')
  359. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  360. }
  361. closedir($handle);
  362. }
  363. $this->data['proArray'] = $proArray['Bills'];
  364. } else {
  365. $this->data['proArray'] = [];
  366. }
  367. $this->data['mpid'] = $this->params['mpid'];
  368. $this->data['pid'] = $this->params['pid'];
  369. $this->render('w-project-section-measure', $this->data, TRUE);
  370. }
  371. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  372. {
  373. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  374. if (!$count) {
  375. return $string;
  376. }
  377. if ($len == 0) {
  378. $end = $count; //传入0则替换到最后
  379. } else {
  380. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  381. }
  382. $i = 0;
  383. $returnString = '';
  384. while ($i < $count) { //循环该字符串
  385. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  386. if ($start <= $i && $i < $end) {
  387. $returnString .= $repalce;
  388. } else {
  389. $returnString .= $tmpString;
  390. }
  391. $i++;
  392. }
  393. return $returnString;
  394. }
  395. function unicode_encode($name)
  396. {//to Unicode
  397. $name = iconv('UTF-8', 'UCS-2', $name);
  398. $len = strlen($name);
  399. $str = '';
  400. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  401. $c = $name[$i];
  402. $c2 = $name[$i + 1];
  403. if (ord($c) > 0) {// 两个字节的字
  404. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  405. } else {
  406. $str .= $c2;
  407. }
  408. }
  409. $str = strtoupper($str);
  410. return $str;
  411. }
  412. function unicode_decode($name)
  413. {//Unicode to
  414. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  415. preg_match_all($pattern, $name, $matches);
  416. if (!empty($matches)) {
  417. $name = '';
  418. for ($j = 0; $j < count($matches[0]); $j++) {
  419. $str = $matches[0][$j];
  420. if (strpos($str, '\\u') === 0) {
  421. $code = base_convert(substr($str, 2, 2), 16, 10);
  422. $code2 = base_convert(substr($str, 4), 16, 10);
  423. $c = chr($code) . chr($code2);
  424. $c = iconv('UCS-2', 'UTF-8', $c);
  425. $name .= $c;
  426. } else {
  427. $name .= $str;
  428. }
  429. }
  430. }
  431. return $name;
  432. }
  433. public function proDetail()
  434. {
  435. // 面包屑导航项目
  436. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  437. $allproArray = $this->project->getAll();
  438. foreach ($allproArray as $kk => $vv) {
  439. if ($vv['pid'] == $this->params['pid']) {
  440. $this->data['currproArray'] = $vv;
  441. } else {
  442. $this->data['allproArray'][] = $vv;
  443. }
  444. }
  445. // 面包屑导航合同
  446. $conArray = $this->contractact->getAll();
  447. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  448. if (isset($measureArray['stid'])) {
  449. foreach ($conArray as $kkk => $vvv) {
  450. if ($vvv['stid'] == $measureArray['stid']) {
  451. $this->data['currconArray'] = $vvv;
  452. } else {
  453. $this->data['allconArray'][] = $vvv;
  454. }
  455. }
  456. } else {
  457. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  458. }
  459. // 面包屑导航标段
  460. $this->data['curractmeasureArray'] = NULL;
  461. $this->data['allactmeasureArray'] = [];
  462. $actmeasureArray = $this->actmeasure->getAll();
  463. foreach ($actmeasureArray as $kkkk => $vvvv) {
  464. if ($vvvv['stid'] == $measureArray['stid']) {
  465. if (($vvvv['pmid'] == $this->params['pmid'])) {
  466. $this->data['curractmeasureArray'] = $vvvv;
  467. } else {
  468. $this->data['allactmeasureArray'][] = $vvvv;
  469. }
  470. }
  471. }
  472. // 图标
  473. $this->data['MeasureArray'] = $this->numofperact->getRowByPmid($this->params['pmid']);
  474. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  475. foreach ($this->data['MeasureArray'] as $key => $value) {
  476. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  477. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  478. } else {
  479. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  480. }
  481. }
  482. $this->data['pmid'] = $this->params['pmid'];
  483. $this->data['pid'] = $this->params['pid'];
  484. $this->render('w-project-section-detail', $this->data, TRUE);
  485. }
  486. public function welcome()
  487. {
  488. // if (!$this->auth->isLoggedIn())
  489. // return Doo::conf()->APP_URL;
  490. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  491. return Doo::conf()->APP_URL . 'project/list';
  492. if (isset($_POST['welform'])) {
  493. $profileUserArray = $_POST;
  494. $profileUserArray['userid'] = $this->auth->getUid();
  495. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  496. return Doo::conf()->APP_URL . 'project/list';
  497. }
  498. $this->render('welcome', $this->data);
  499. }
  500. public function prolist()
  501. {
  502. // if (!$this->auth->isLoggedIn())
  503. // return Doo::conf()->APP_URL;
  504. // $proArray = new stdClass();
  505. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  506. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  507. // if ($handle = opendir($extPathdir)) {
  508. // while (false !== ($file = readdir($handle))) {
  509. // $filename = pathinfo($file);
  510. // if ($filename['extension'] == 'json')
  511. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  512. // }
  513. // closedir($handle);
  514. // }
  515. // $this->data['proArray'] = null;
  516. $this->render('s-project', $this->data);
  517. }
  518. // ajax提取密码名称
  519. public function getAjaxSection()
  520. {
  521. if (!$this->isAjax())
  522. return;
  523. echo json_encode($_POST);
  524. }
  525. public function repasswd()
  526. {
  527. if (isset($_POST['oldpasswd']) && isset($_POST['newpasswd']) && isset($_POST['renewpasswd']) && ($_POST['newpasswd'] == $_POST['renewpasswd'])) {
  528. $userArray = $this->user->getRowUser($this->auth->getUid());
  529. if ($this->ph->CheckPassword($_POST['oldpasswd'], $userArray['upass'])) {
  530. if ($this->user->updatePassWd($this->auth->getUid(), $_POST['newpasswd']))
  531. return Doo::conf()->APP_URL . 'signout';
  532. }
  533. }
  534. $this->render('edit-profile-pw', $this->data, TRUE);
  535. }
  536. public function appdownload(){
  537. $token = $this->auth->getWebToken($this->auth->getUid());
  538. if($token == ''){
  539. exit('token不存在或已过期,请重新登录 '.DOO::conf()->APP_URL);
  540. }
  541. //加密uid
  542. $uid = $this->__hashids->encode($this->auth->getUid());
  543. $content = Doo::conf()->APP_URL.'api/app/scan/validate?user='.$uid.'&token='.$token;
  544. $qrcodeurl = 'global/qrcode/';
  545. $filepath = $qrcodeurl.'qrcode_'.$uid.'.png';
  546. $this->codemake($content,$filepath);
  547. $this->data['qrcode'] = $filepath;
  548. $this->render('edit-app', $this->data, TRUE);
  549. }
  550. function codemake($content,$filepath){
  551. $value = $content;//二维码内容
  552. $errorCorrectionLevel = 'H';//容错级别
  553. $matrixPointSize = 3;//生成图片大小
  554. //生成二维码图片
  555. QRcode::png($value, $filepath, $errorCorrectionLevel, $matrixPointSize,0);
  556. // $logo = 'jb51.png';//准备好的logo图片
  557. // $QR = 'qrcode.png';//已经生成的原始二维码图
  558. //
  559. // if ($logo !== FALSE) {
  560. // $QR = imagecreatefromstring(file_get_contents($QR));
  561. // $logo = imagecreatefromstring(file_get_contents($logo));
  562. // $QR_width = imagesx($QR);//二维码图片宽度
  563. // $QR_height = imagesy($QR);//二维码图片高度
  564. // $logo_width = imagesx($logo);//logo图片宽度
  565. // $logo_height = imagesy($logo);//logo图片高度
  566. // $logo_qr_width = $QR_width / 5;
  567. // $scale = $logo_width/$logo_qr_width;
  568. // $logo_qr_height = $logo_height/$scale;
  569. // $from_width = ($QR_width - $logo_qr_width) / 2;
  570. // //重新组合图片并调整大小
  571. // imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
  572. // $logo_qr_height, $logo_width, $logo_height);
  573. // }
  574. //输出图片
  575. // Header("Content-type: image/png");
  576. // ImagePng($QR);
  577. }
  578. }
  579. ?>