assets.php.bak 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * 客户端热更新相关
  4. * Date: 2017/9/13 0013
  5. * Time: 12:00
  6. */
  7. $subversion = trim($_POST['subversion']);//热更新名称
  8. $actList = $_POST['act']; //act名称
  9. $device = $_POST['device'] == 1 ? 'android' : 'ios'; //设备名称
  10. $stagefile = $_FILES['stagefile']; //上传文件名称名称
  11. //加了_old表示之前的
  12. $act_old = $_POST['act_old'];
  13. $size_old = $_POST['size_old'];
  14. $name_old = $_POST['name_old'];
  15. $code_old = $_POST['code_old'];
  16. $silent_old = $_POST['silent_old'];
  17. $luaFile = '';//生成的lua文件
  18. $time = time();
  19. $hotuploadPath = './public/assets/'.$device.'/';
  20. deldir($hotuploadPath);
  21. foreach ($stagefile['name'] as $k => $fileName){
  22. if (!$fileName) {
  23. continue;
  24. }
  25. $uploadName = $fileName;
  26. $filePath = $hotuploadPath.$uploadName;
  27. $tmpName = $stagefile['tmp_name'][$k];
  28. move_uploaded_file($tmpName, $filePath);
  29. $zip = new ZipArchive();
  30. if ($zip->open($filePath) === true) {
  31. //解压文件到获得的路径a文件夹下
  32. $zip->extractTo($hotuploadPath);
  33. //关闭
  34. $zip->close();
  35. }
  36. }
  37. die(json_encode(['code'=>1,'msg'=>'ok']));
  38. function getTitle($version){
  39. $arr = explode('.', $version);
  40. array_pop($arr);
  41. $new = implode('.', $arr);
  42. return $new;
  43. }
  44. function deldir($path){
  45. //如果是目录则继续
  46. if(is_dir($path)){
  47. $p = scandir($path);
  48. foreach($p as $val){
  49. if($val !="." && $val !=".."){
  50. if(is_dir($path.$val)){
  51. deldir($path.$val.'/');
  52. @rmdir($path.$val.'/');
  53. }else{
  54. unlink($path.$val);
  55. }
  56. }
  57. }
  58. }
  59. }