Advertisement
zero50x

Определения языка для комментариев

Mar 25th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL | E_STRICT); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE);
  3. //echo "<pre>"; var_dump($_POST); echo "</pre>";
  4.  
  5.  
  6. echo "<pre>"; var_dump($_SERVER); echo "</pre>";
  7.  
  8.    
  9. if(!empty($_POST['text'])){
  10.    
  11. $text = $_POST['text'];
  12.    
  13.     // Условия для JS
  14.     if(preg_match('/=\s{0,}[a-z]{1,}\.[a-z]{1,}/ismu', $text) ||
  15.        preg_match('/[a-z]{1,}\.[a-z]{1,}\s{0,}=/ismu', $text) ||
  16.        preg_match('/(\'|\")\+[a-z0-9]{1,}\+(\'|\")/ismu', $text) ||
  17.        preg_match('/var\s{1,}[a-z0-9]{1,}\s{0,}=/ismu', $text) ||
  18.        preg_match('/[a-z]{1,}\.[a-z]{1,}\(/ismu', $text)
  19.        ){
  20.         echo "JS<br>";
  21.     }
  22.    
  23.     elseif(
  24.         preg_match('/\$[a-z]{1,}/ismu', $text) ||
  25.         preg_match('/[a-z]{1,}\.[a-z]{1,}\s{0,}=/ismu', $text) ||
  26.         preg_match('/(\'|\")\+[a-z0-9]{1,}\+(\'|\")/ismu', $text)
  27.     ){
  28.         echo "PHP<br>";
  29.     }
  30.  
  31.     elseif(
  32.         preg_match('/<[a-z]{1,}\s{1,}(id|class|href|src|rel|type)\s{0,}=/ismu', $text) ||
  33.         preg_match('/<[a-z]{1,}>[^<>]{1,}<\/[a-z]{1,}>/ismu', $text) ||
  34.         preg_match('/<\s{0,}[a-z]{1,}\s{1,}[a-z]{1,}\s{0,}=\s{0,}(\'|\")[^\"\']{1,}(\'|\")\s{0,}>/ismu', $text)
  35.     ){
  36.         echo "HTML<br>";
  37.     }
  38.  
  39.  
  40.     elseif(
  41.         preg_match('/\.[a-z0-9-_]{1,}\s{0,}{\s{0,}[a-z0-9-_]{1,}:/isu', $text) ||
  42.         preg_match('/[a-z0-9-_]{1,}\s{0,}:\s{0,}(hover|active|focus)/ismu', $text) ||
  43.         preg_match('/[a-z0-9-_]{1,}:\s{0,}[a-z0-9-_]{1,};\s{0,}\t{0,}[a-z0-9-_]{1,}:\s{0,}[a-z0-9-_]{1,};/isu', $text)
  44.     ){
  45.         echo "CSS<br>";
  46.     }
  47.  
  48.  
  49.     elseif(
  50.         preg_match('/(COUNT\(\*\)|DELETE\s{1,}FROM|INSERT INTO|SELECT\s{1,}AVG|SELECT\s{1,}MAX|SELECT\s{1,}MIN|SELECT\s{1,}DISTINCT|GROUP\s{1,}BY|ORDER\s{1,}BY)/isu', $text) ||
  51.         preg_match('/SELECT\s{0,}(\'|`|)[a-z0-9-_]{1,}(\'|`|)(,|\s{1,}FROM)/isu', $text) ||
  52.         preg_match('/[a-z0-9-_]{1,}:\s{0,}[a-z0-9-_]{1,};\s{0,}\t{0,}[a-z0-9-_]{1,}:\s{0,}[a-z0-9-_]{1,};/isu', $text)
  53.     ){
  54.         echo "SQL<br>";
  55.     }
  56.  
  57.    
  58. } // if isset POST
  59.  
  60.  
  61. /**
  62.  *
  63.  * var gulp =
  64.  * gulp.dest(
  65.  *
  66.  *
  67.  * HTML
  68.  *
  69.  * 2) <title>Тег AREA</title>
  70.  * 3) <style type="text/css">
  71. **/
  72.  
  73. ?>
  74.  
  75. <form action="" method="POST">
  76.     <textarea name="text" cols="60" rows="10" class="form-control tools_form"></textarea>
  77.     <br>
  78.     <br>
  79.     <button type="submit" name="add" class="btn btn-success">Запустить скрипт</button>
  80. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement