SettingController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class SettingController extends DooController {
  6. public $staff=array();
  7. public function beforeRun($resource, $action) {
  8. }
  9. function __construct() {
  10. if (isset ( $_COOKIE ["staff"] )) {
  11. if (! empty ( $_COOKIE ["staff"] )) {
  12. Doo::loadModel ( 'staff' );
  13. $staff = new staff ();
  14. $this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  15. return "/";
  16. }
  17. }
  18. Doo::loadCore ( 'uri/DooUriRouter' );
  19. $router = new DooUriRouter ();
  20. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  21. if ($routeRs ['1'] != "login") {
  22. header ( 'Content-Type:text/html;charset=utf-8' );
  23. @header ( "Location: /login" );
  24. }
  25. }
  26. /**
  27. * 员工信息
  28. */
  29. function settingEmployeeInfo() {
  30. $this->data ['staff'] = $this->staff;
  31. $this->data ['memu'] = "adminmyinfo";
  32. $this->data ['hrMemu'] = "settingEmployeeInfo";
  33. $this->render ( "/setting/settingEmployeeInfo", $this->data );
  34. }
  35. /**
  36. * 证件信息
  37. */
  38. function settingCredentialInfo() {
  39. $this->data ['staff'] = $this->staff;
  40. $this->data ['memu'] = "adminmyinfo";
  41. $this->data ['hrMemu'] = "settingEmployeeInfo";
  42. $this->render ( "/setting/settingCredentialInfo", $this->data );
  43. }
  44. /**
  45. * 财务信息
  46. */
  47. function settingFinanceInfo() {
  48. $this->data ['staff'] = $this->staff;
  49. $this->data ['memu'] = "adminmyinfo";
  50. $this->data ['hrMemu'] = "settingEmployeeInfo";
  51. $this->render ( "/setting/settingFinanceInfo", $this->data );
  52. }
  53. function settingPW() {
  54. $this->data ['msg'] = urldecode ( $this->params ['msg'] );
  55. $this->data ['staff'] = $this->staff;
  56. $this->data ['memu'] = "adminmyinfo";
  57. $this->data ['hrMemu'] = "settingPW";
  58. $this->render ( "/setting/settingPW", $this->data );
  59. }
  60. /*
  61. * 更新密码
  62. */
  63. function updateMyPW() {
  64. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  65. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  66. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  67. Doo::loadModel ( 'staff' );
  68. $staff = new staff ();
  69. Doo::loadModel ( 'staffDynamic' );
  70. $staffDynamic = new staffDynamic ();
  71. $staff->sid = $this->staff ['sid'];
  72. $msg = "更新成功";
  73. if ($this->staff ['passwork'] == md5 ( $oldpassword )) {
  74. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  75. $staff->passwork = md5 ( $newpassword );
  76. else
  77. $msg = "密码不一致";
  78. } else {
  79. if ($oldpassword != "")
  80. $msg = "密码错误";
  81. }
  82. $staff->update ( array (
  83. 'where' => ' sid=' . $this->staff ['sid']
  84. ) );
  85. return "/settingPW/" . $msg;
  86. }
  87. /**
  88. * 微信通知设置
  89. */
  90. function notificationConf() {
  91. Doo::loadModel ( "notificationConf" );
  92. $notificationConf = new notificationConf ();
  93. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  94. $rule = json_decode ( $detail ['conf'], true );
  95. if (! isset ( $rule ['approval'] ))
  96. $rule ['approval'] = '';
  97. if (! isset ( $rule ['print'] ))
  98. $rule ['print'] = '';
  99. if (! isset ( $rule ['receivables'] ))
  100. $rule ['receivables'] = '';
  101. $this->data ['rule'] = $rule;
  102. $this->data ['memu'] = "adminmyinfo";
  103. $this->data ['hrMemu'] = "notificationConf";
  104. $this->data ['staff'] = $this->staff;
  105. $this->render ( "/setting/invoiceNotificationConf", $this->data );
  106. }
  107. /**
  108. * 异步设置微信通知
  109. */
  110. function ajaxSetNotificationConf() {
  111. $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  112. $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  113. if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff ['sid'] )) {
  114. Doo::loadModel ( "notificationConf" );
  115. $notificationConf = new notificationConf ();
  116. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  117. if (empty ( $detail )) {
  118. $rule = array (
  119. $notificationType => $notificationValue
  120. );
  121. $rule = json_encode ( $rule );
  122. $item = array (
  123. 'sid' => $this->staff ['sid'],
  124. 'conf' => $rule
  125. );
  126. $notificationConf->addNotification ( $item );
  127. } else {
  128. $rule = json_decode ( $detail ['conf'], true );
  129. $rule [$notificationType] = $notificationValue;
  130. $rule = json_encode ( $rule );
  131. $item = array (
  132. 'nid' => $detail ['nid'],
  133. 'conf' => $rule
  134. );
  135. $notificationConf->setNotificationByCondition ( $item );
  136. }
  137. echo json_encode ( array (
  138. 'status' => 1,
  139. 'msgType' => $notificationType,
  140. 'msg' => ''
  141. ) );
  142. die ();
  143. }
  144. echo json_encode ( array (
  145. 'status' => 2,
  146. 'msgType' => $notificationType,
  147. 'msg' => 'illegal request'
  148. ) );
  149. die ();
  150. }
  151. /**
  152. * 更新员工信息
  153. */
  154. function staffUpdate() {
  155. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  156. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  157. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  158. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  159. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  160. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  161. // $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  162. // $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  163. // $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  164. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  165. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  166. $phone = is_numeric ( $this->get_args ( 'phone' ) ) ? $this->get_args ( 'phone' ) : 0;
  167. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  168. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  169. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  170. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  171. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '';
  172. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  173. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  174. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  175. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  176. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : '';
  177. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : '';
  178. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : '';
  179. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : '';
  180. $salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';
  181. $salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';
  182. $employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo';
  183. if (! empty ( $sidKey )) {
  184. Doo::loadClass ( 'XDeode' );
  185. $XDeode = new XDeode ( 5 );
  186. Doo::loadModel ( 'staff' );
  187. $staff = new staff ();
  188. Doo::loadModel ( 'L_category' );
  189. $L_category = new L_category ();
  190. Doo::loadModel ( 'tag' );
  191. Doo::loadModel ( 'holidaystaff' );
  192. Doo::loadModel ( 'staffManage' );
  193. $staffManage = new staffManage ();
  194. // 用户名检测
  195. if (! empty ( $username )) {
  196. $detail = $staff->getStaffByName ( $username );
  197. if (empty ( $detail ))
  198. die ( 'illegal request' );
  199. }
  200. $detail = $staff->getStaffBySid ( $sidKey );
  201. if (empty ( $detail ))
  202. die ( 'illegal request' );
  203. // if (!empty($username))
  204. // $staff->username = $username;
  205. if (! empty ( $hiredate ))
  206. $staff->hiredate = $hiredate;
  207. if (! empty ( $position ))
  208. $staff->position = $position;
  209. // 办事处-部门
  210. if (! empty ( $cid_did )) {
  211. $department = explode ( '_', $cid_did );
  212. $cid = $XDeode->decode ( $department [0] );
  213. // 加入默认总部分类
  214. if (! is_numeric ( $cid ))
  215. die ( 'illegal request' );
  216. $cagegory = $L_category->getCategoryById ( $cid );
  217. // 部门
  218. if (! empty ( $department [1] )) {
  219. $did = $XDeode->decode ( $department [1] );
  220. if (! is_numeric ( $did ))
  221. die ( 'illegal request' );
  222. $staff->departmentID = $did;
  223. }
  224. $staff->cid = $cagegory [0] ['cid'];
  225. $staff->category = $cagegory [0] ['title'];
  226. }
  227. if (! empty ( $telephone ))
  228. $staff->telephone = $telephone;
  229. // if (!empty($baseWage))
  230. // $staff->baseWage = $baseWage;
  231. // if (!empty($postWage))
  232. // $staff->postWage = $postWage;
  233. // if (!empty($achievementBonus))
  234. // $staff->achievementBonus = $achievementBonus;
  235. if (! empty ( $gender ))
  236. $staff->gender = $gender;
  237. if (! empty ( $qq ))
  238. $staff->qq = $qq;
  239. if (! empty ( $phone ))
  240. $staff->phone = $phone;
  241. if (! empty ( $wecat ))
  242. $staff->wecat = $wecat;
  243. if (! empty ( $email ))
  244. $staff->email = $email;
  245. if (! empty ( $birthday ))
  246. $staff->birthday = $birthday;
  247. if (! empty ( $$qualifications ))
  248. $staff->qualifications = $qualifications;
  249. if (! empty ( $marriage ))
  250. $staff->marriage = $marriage;
  251. if (! empty ( $IDcards ))
  252. $staff->IDcards = $IDcards;
  253. if (! empty ( $living ))
  254. $staff->living = $living;
  255. if (! empty ( $nativePlace ))
  256. $staff->nativePlace = $nativePlace;
  257. if (! empty ( $emergencyContacts ))
  258. $staff->emergencyContacts = $emergencyContacts;
  259. if (! empty ( $coupletNumber ))
  260. $staff->coupletNumber = $coupletNumber;
  261. if (! empty ( $bankName ))
  262. $staff->bankName = $bankName;
  263. if (! empty ( $bankNumber ))
  264. $staff->bankNumber = $bankNumber;
  265. if (! empty ( $remittanceName ))
  266. $staff->remittanceName = $remittanceName;
  267. if (! empty ( $salaryCard ))
  268. $staff->salaryCard = $salaryCard;
  269. if (! empty ( $salaryBank ))
  270. $staff->salaryBank = $salaryBank;
  271. $staff->update ( array (
  272. 'where' => 'sid=' . $detail ['sid']
  273. ) );
  274. if ($employeeInfo == 'employeeInfo') {
  275. return '/hr';
  276. } elseif ($employeeInfo == 'settingEmployeeInfo') {
  277. return '/settingEmployeeInfo';
  278. } elseif ($employeeInfo == 'settingFinanceInfo') {
  279. return '/settingFinanceInfo';
  280. }
  281. }
  282. die ( 'illegal request' );
  283. }
  284. /**
  285. * 证件文件上传
  286. */
  287. function settingCredentialInfoDo() {
  288. $IDcards = is_numeric ( $this->get_args ( 'IDcards' ) ) ? $this->get_args ( 'IDcards' ) : 0;
  289. $certificate = $this->get_args ( 'certificate' ) ? $this->get_args ( 'certificate' ) : '';
  290. $diploma = $this->get_args ( 'diploma' ) ? $this->get_args ( 'diploma' ) : '';
  291. $professionalTitle = $this->get_args ( 'professionalTitle' ) ? $this->get_args ( 'professionalTitle' ) : '';
  292. Doo::loadModel ( 'staff' );
  293. $staff = new staff ();
  294. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/";
  295. $webSite=WEB_SITE.'/upload/credentialInfo/';
  296. if (!empty($IDcards))
  297. $staff->IDcards=$IDcards;
  298. $msg = '';
  299. $file_name = 'IDcardsImgA_'. $this->staff['sid'].'.'. $this->_GetFileEXT ( $_FILES ["IDcardsImgA"] ['name'] );
  300. if (!empty($_FILES ["IDcardsImgA"] ["size"])){
  301. if (! @move_uploaded_file ( $_FILES ["IDcardsImgA"] ["tmp_name"], $save_path . $file_name ))
  302. $msg .= "文件无法保存";
  303. else{
  304. $staff->IDcardsImgA=$webSite . $file_name;
  305. }
  306. }
  307. $file_name = 'IDcardsImgB_'. $this->staff['sid'].'.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgB"] ['name'] );
  308. if (!empty($_FILES ["IDcardsImgB"] ["size"]))
  309. if (! @move_uploaded_file ( $_FILES ["IDcardsImgB"] ["tmp_name"], $save_path . $file_name )) {
  310. $msg .= "文件无法保存";
  311. }else{
  312. $staff->IDcardsImgB=$webSite . $file_name;
  313. }
  314. if (!empty($certificate)){
  315. $certificateArray=explode("-", $certificate);
  316. $staff->certificate=json_encode($certificateArray);
  317. }
  318. // $file_name = 'certificate_'. $this->staff['sid'].'.' . $this->_GetFileEXT ( $_FILES ["certificate"] ['name'] );
  319. // if (!empty($_FILES ["certificate"] ["size"]))
  320. // if (! @move_uploaded_file ( $_FILES ["certificate"] ["tmp_name"], $save_path . $file_name )) {
  321. // $msg .= "文件无法保存";
  322. // }else{
  323. // $staff->certificate=$webSite . $file_name;
  324. // }
  325. // $file_name = 'diploma_'. $this->staff['sid'].'.' . $this->_GetFileEXT ( $_FILES ["diploma"] ['name'] );
  326. // if (!empty($_FILES ["diploma"] ["size"]))
  327. // if (! @move_uploaded_file ( $_FILES ["diploma"] ["tmp_name"], $save_path . $file_name )) {
  328. // $msg .= "文件无法保存";
  329. // }else{
  330. // $staff->diploma=$webSite . $file_name;
  331. // }
  332. $staff->update(array('where'=>'sid='.$this->staff['sid']));
  333. //return '/settingCredentialInfo';
  334. }
  335. /**
  336. * 上传学位证书
  337. * @return string
  338. */
  339. function settingCredentialInfoDo3() {
  340. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  341. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  342. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  343. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  344. header ( "HTTP/1.1 500 Internal Server Error" );
  345. echo "POST exceeded maximum allowed size.";
  346. exit ( 0 );
  347. }
  348. // Settings
  349. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  350. $upload_name = "Filedata";
  351. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  352. $extension_whitelist = array (
  353. "doc",
  354. "txt",
  355. "jpg",
  356. "gif",
  357. "png"
  358. ); // Allowed file extensions
  359. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  360. // Other variables
  361. $MAX_FILENAME_LENGTH = 260;
  362. $file_name = "";
  363. $file_extension = "";
  364. $uploadErrors = array (
  365. 0 => "文件上传成功",
  366. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  367. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  368. 3 => "上传的文件仅为部分文件",
  369. 4 => "没有文件上传",
  370. 6 => "缺少临时文件夹"
  371. );
  372. $nk = time ();
  373. $file_name = 'diploma_'. $this->staff['sid'].'_'.$nk.'.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  374. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  375. echo "文件无法保存.";
  376. exit ( 0 );
  377. }
  378. echo json_encode ( array (
  379. 'filename' => $file_name,
  380. 'id' => $nk
  381. ) );
  382. exit ( 0 );
  383. }
  384. /**
  385. * 上传职称证书
  386. * @return string
  387. */
  388. function settingCredentialInfoDo4() {
  389. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  390. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  391. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  392. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  393. header ( "HTTP/1.1 500 Internal Server Error" );
  394. echo "POST exceeded maximum allowed size.";
  395. exit ( 0 );
  396. }
  397. // Settings
  398. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  399. $upload_name = "Filedata";
  400. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  401. $extension_whitelist = array (
  402. "doc",
  403. "txt",
  404. "jpg",
  405. "gif",
  406. "png"
  407. ); // Allowed file extensions
  408. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  409. // Other variables
  410. $MAX_FILENAME_LENGTH = 260;
  411. $file_name = "";
  412. $file_extension = "";
  413. $uploadErrors = array (
  414. 0 => "文件上传成功",
  415. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  416. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  417. 3 => "上传的文件仅为部分文件",
  418. 4 => "没有文件上传",
  419. 6 => "缺少临时文件夹"
  420. );
  421. $nk = time ();
  422. $file_name = 'professionalTitle_'. $this->staff['sid'].'_'.$nk.'.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  423. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  424. echo "文件无法保存.";
  425. exit ( 0 );
  426. }
  427. echo json_encode ( array (
  428. 'filename' => $file_name,
  429. 'id' => $nk
  430. ) );
  431. exit ( 0 );
  432. }
  433. /**
  434. * 上传毕业证书
  435. * @return string
  436. */
  437. function settingCredentialInfoDo2() {
  438. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  439. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  440. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  441. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  442. header ( "HTTP/1.1 500 Internal Server Error" );
  443. echo "POST exceeded maximum allowed size.";
  444. exit ( 0 );
  445. }
  446. // Settings
  447. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  448. $upload_name = "Filedata";
  449. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  450. $extension_whitelist = array (
  451. "doc",
  452. "txt",
  453. "jpg",
  454. "gif",
  455. "png"
  456. ); // Allowed file extensions
  457. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  458. // Other variables
  459. $MAX_FILENAME_LENGTH = 260;
  460. $file_name = "";
  461. $file_extension = "";
  462. $uploadErrors = array (
  463. 0 => "文件上传成功",
  464. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  465. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  466. 3 => "上传的文件仅为部分文件",
  467. 4 => "没有文件上传",
  468. 6 => "缺少临时文件夹"
  469. );
  470. $nk = time ();
  471. $file_name = 'certificate_'. $this->staff['sid'].'_'.$nk.'.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  472. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  473. echo "文件无法保存.";
  474. exit ( 0 );
  475. }
  476. echo json_encode ( array (
  477. 'filename' => $file_name,
  478. 'id' => $nk
  479. ) );
  480. exit ( 0 );
  481. }
  482. /**
  483. * 获取get或者POST值
  484. *
  485. * @param string $name 属性名称
  486. * @return fixed 值
  487. */
  488. function get_args($name) {
  489. if (isset ( $_GET [$name] )) {
  490. if (is_array ( $_GET [$name] ))
  491. return $_GET [$name];
  492. else
  493. return addslashes ( $_GET [$name] );
  494. } elseif (isset ( $_POST [$name] )) {
  495. if (is_array ( $_POST [$name] ))
  496. return $_POST [$name];
  497. else
  498. return addslashes ( $_POST [$name] );
  499. } else
  500. return false;
  501. }
  502. /**
  503. * 旧输入导入
  504. */
  505. function _GetFileEXT($filename) {
  506. $pics = explode ( '.', $filename );
  507. $num = count ( $pics );
  508. return $pics [$num - 1];
  509. }
  510. }
  511. ?>