Vod.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. class Vod extends Validate
  5. {
  6. protected $rule = [
  7. 'vod_name' => 'require',
  8. 'type_id' => 'require',
  9. ];
  10. protected $message = [
  11. 'vod_name.require' => 'validate/require_name',
  12. 'type_id.require' => 'validate/require_type',
  13. ];
  14. protected $scene = [
  15. 'add' => ['vod_name','type_id'],
  16. 'edit' => ['vod_name','type_id'],
  17. ];
  18. // xss过滤、长度裁剪
  19. public static function formatDataBeforeDb($data)
  20. {
  21. $filter_fields = [
  22. 'vod_name' => 255,
  23. 'vod_sub' => 255,
  24. 'vod_en' => 255,
  25. 'vod_color' => 6,
  26. 'vod_tag' => 100,
  27. 'vod_class' => 255,
  28. 'vod_pic' => 1024,
  29. 'vod_pic_thumb' => 1024,
  30. 'vod_pic_slide' => 1024,
  31. 'vod_pic_screenshot' => 65535,
  32. 'vod_actor' => 255,
  33. 'vod_director' => 255,
  34. 'vod_writer' => 100,
  35. 'vod_behind' => 100,
  36. 'vod_blurb' => 255,
  37. 'vod_remarks' => 100,
  38. 'vod_pubdate' => 100,
  39. 'vod_serial' => 20,
  40. 'vod_tv' => 30,
  41. 'vod_weekday' => 30,
  42. 'vod_area' => 20,
  43. 'vod_lang' => 10,
  44. 'vod_year' => 10,
  45. 'vod_version' => 30,
  46. 'vod_state' => 30,
  47. 'vod_author' => 60,
  48. 'vod_jumpurl' => 150,
  49. 'vod_tpl' => 30,
  50. 'vod_tpl_play' => 30,
  51. 'vod_tpl_down' => 30,
  52. 'vod_duration' => 10,
  53. 'vod_reurl' => 255,
  54. 'vod_rel_vod' => 255,
  55. 'vod_rel_art' => 255,
  56. 'vod_pwd' => 10,
  57. 'vod_pwd_url' => 255,
  58. 'vod_pwd_play' => 10,
  59. 'vod_pwd_play_url' => 255,
  60. 'vod_pwd_down' => 10,
  61. 'vod_pwd_down_url' => 255,
  62. 'vod_play_from' => 255,
  63. 'vod_play_server' => 255,
  64. 'vod_play_note' => 255,
  65. 'vod_down_from' => 255,
  66. 'vod_down_server' => 255,
  67. 'vod_down_note' => 255,
  68. ];
  69. foreach ($filter_fields as $field => $length) {
  70. if (!isset($data[$field])) {
  71. continue;
  72. }
  73. $data[$field] = mac_filter_xss($data[$field]);
  74. $data[$field] = mb_substr($data[$field], 0, $length);
  75. }
  76. return $data;
  77. }
  78. }