Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <div>
  2. ...Some code here...
  3. </div>
  4.  
  5. <?php
  6. /**
  7. * Ok, glad you are here
  8. * first we get a config instance, and set the settings
  9. * $config = HTMLPurifier_Config::createDefault();
  10. * $config->set('Core.Encoding', $this->config->get('purifier.encoding'));
  11. * $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath'));
  12. * if ( ! $this->config->get('purifier.finalize')) {
  13. * $config->autoFinalize = false;
  14. * }
  15. * $config->loadArray($this->getConfig());
  16. *
  17. * You must NOT delete the default settings
  18. * anything in settings should be compacted with params that needed to instance HTMLPurifier_Config.
  19. *
  20. * @link http://htmlpurifier.org/live/configdoc/plain.html
  21. */
  22.  
  23. return [
  24. 'encoding' => 'UTF-8',
  25. 'finalize' => true,
  26. 'cachePath' => storage_path('app/purifier'),
  27. 'cacheFileMode' => 0755,
  28. 'settings' => [
  29. 'default' => [
  30. 'HTML.Doctype' => 'HTML 4.01 Transitional',
  31. 'HTML.Allowed' => 'blockquote,h1,h2,h3,h4,h5,h6,pre,code,div[class],b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
  32. 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
  33. 'AutoFormat.AutoParagraph' => false,
  34. 'AutoFormat.RemoveEmpty' => true,
  35. ],
  36. 'test' => [
  37. 'Attr.EnableID' => true
  38. ],
  39. "youtube" => [
  40. "HTML.SafeIframe" => 'true',
  41. "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
  42. ],
  43. ],
  44.  
  45. ];
  46.  
  47. public function store(Request $request)
  48. {
  49. //Validate the data
  50. $this->validate($request, array(
  51. 'title' => 'required|max:255',
  52. 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug',
  53. 'category_id' =>'required|integer',
  54. 'body' => 'required'
  55. ));
  56. //Store in the database
  57. $post = new Post;
  58.  
  59. $post->title = $request->title;
  60. $post->slug = $request->slug;
  61. $post->category_id = $request->category_id;
  62. $post->body = Purifier::clean($request->body, "youtube");
  63.  
  64. $post->save();
  65.  
  66. $post->tags()->sync($request->tags, false);
  67.  
  68. Session::flash('success', 'AWESOMESAUCE! Your post was saved successfully!');
  69.  
  70. //redirect to another page
  71. return redirect()->route('posts.show', $post->id);
  72.  
  73. }
  74.  
  75. <?php
  76. $str = "This is some <b>bold</b> text.";
  77. echo htmlspecialchars($str);
  78. ?>
  79.  
  80. This is some <b>bold</b> text.
  81.  
  82. pre[class],code
  83.  
  84. $post->body = clean($request->body, "youtube");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement