form.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. $method = $_GET['method'];
  3. $type = $_GET['type'];
  4. function getdata($action){
  5. $helper = include('../helper/Params.php');
  6. if(empty($_COOKIE['params'])){
  7. $newvalue = '';
  8. }else{
  9. $newvalue = unserialize($_COOKIE['params']);
  10. }
  11. if(empty($_COOKIE['config'])){
  12. $config = include('../config/Basics.php');
  13. $config = $config['variable'];
  14. }else{
  15. $config = unserialize($_COOKIE['config']);
  16. }
  17. $configform = '<form id="configform" method="post">';
  18. foreach ($config as $k => $v) {
  19. $configform .= "<p>{$k}<input type='text' name='{$k}' value='{$v}'></p>";
  20. }
  21. $configform .= '</form>';
  22. $form = '<fieldset style="width:15%;" class="myCode"><legend>入参配置</legend><form style="font-size: 14px;" id="ruform" method="post">';
  23. foreach ($helper['body'][$action] as $k => $v) {
  24. $value = isset($newvalue[$v['param']]) ? $newvalue[$v['param']] : $v['value'];
  25. $font = $v['require']=='true'?"<font color='red'>*</font>":"";
  26. $form .= "<p>{$font}{$v['param']} ({$v['name']})<input title='{$v['describe']}' maxlength='{$v['lengthmax']}' style='margin-top:5px' type='{$v['type']}' name='{$v['param']}' value='{$value}'></p>";
  27. }
  28. $form .= '<input type="button" onclick="rusub()" value="保存"></form></fieldset>';
  29. return json_encode([
  30. 'form' => $form ,
  31. 'configform' => $configform ,
  32. 'config' => $config ,
  33. ]);
  34. };
  35. function setdata($action){
  36. $params = $_GET['params'];
  37. $params = explode('&',$params);
  38. $config = $_GET['config'];
  39. $config = explode('&',$config);
  40. $arr=[];
  41. foreach($params as $v){
  42. $v = explode('=',$v);
  43. $arr[$v[0]] = urldecode($v[1]);
  44. }
  45. $arr2=[];
  46. foreach($config as $v){
  47. $v = explode('=',$v);
  48. $arr2[$v[0]] = urldecode($v[1]);
  49. }
  50. //var_dump($arr2);
  51. setcookie("params", serialize($arr), time()+60*5);
  52. setcookie("config", serialize($arr2), time()+60*5);
  53. return json_encode($arr);
  54. }
  55. function deletecookie($action){
  56. setcookie("params", '',time()-1);
  57. setcookie("config", '',time()- 1);
  58. }
  59. echo $type($method);
  60. ?>