mapi_function.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*ajax返回*/
  3. function api_ajax_return($data,$is_debug=false)
  4. {
  5. //$user_info = app_login();
  6. //$data['user_info'] = $user_info;
  7. if(!$is_debug){
  8. header("Content-Type:text/html; charset=utf-8");
  9. header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
  10. //echo(json_encode($data));
  11. $encrypt = $GLOBALS['encrypt'];
  12. if($encrypt['i_type']){
  13. ajax_return_aes($data,4);
  14. }else{
  15. echo(json_encode($data));
  16. }
  17. exit;
  18. }else{
  19. var_export($data);
  20. echo "<br />";
  21. exit;
  22. }
  23. }
  24. function filter_ma_request_mapi(&$str){
  25. $search = array("../","\n","\r","\t","\r\n","'","<",">","\"","%","\\",".","/");
  26. return str_replace($search,"",$str);
  27. }
  28. function strim_mapi($str)
  29. {
  30. return quotes_mapi(htmlspecialchars(trim($str)));
  31. }
  32. function quotes_mapi($content)
  33. {
  34. //if $content is an array
  35. if (is_array($content))
  36. {
  37. foreach ($content as $key=>$value)
  38. {
  39. //$content[$key] = mysql_real_escape_string($value);
  40. $content[$key] = addslashes($value);
  41. }
  42. } else
  43. {
  44. //if $content is not an array
  45. //$content=mysql_real_escape_string($content);
  46. $content=addslashes($content);
  47. }
  48. return $content;
  49. }
  50. ?>