PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/helpers/validations.php

https://github.com/MilkZoft/zan
PHP | 223 lines | 208 code | 15 blank | 0 comment | 17 complexity | bac4cfdc7da1889746d0873b62e9aa34 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. if (!defined("ACCESS")) {
  3. die("Error: You don't have permission to access here...");
  4. }
  5. if (!function_exists("is")) {
  6. function is($var = null, $value = null)
  7. {
  8. return (isset($var) and $var === $value) ? true : false;
  9. }
  10. }
  11. if (!function_exists("isName")) {
  12. function isName($name)
  13. {
  14. if (strlen($name) < 7) {
  15. return false;
  16. }
  17. $parts = explode(" ", $name);
  18. $count = count($parts);
  19. if ($count > 1) {
  20. for ($i = 0; $i <= $count; $i++) {
  21. if (isset($parts[$i]) and strlen($parts[$i]) > 25) {
  22. return false;
  23. }
  24. }
  25. } else {
  26. return false;
  27. }
  28. return true;
  29. }
  30. }
  31. if (!function_exists("isEmail")) {
  32. function isEmail($email)
  33. {
  34. return (filter_var($email, FILTER_VALIDATE_EMAIL)) ? true : false;
  35. }
  36. }
  37. if (!function_exists("isImage")) {
  38. function isImage($image)
  39. {
  40. return (getimagesize($image)) ? true : false;
  41. }
  42. }
  43. if (!function_exists("isInjection")) {
  44. function isInjection($text, $count = 1)
  45. {
  46. if (is_string($text)) {
  47. $text = html_entity_decode($text);
  48. if (substr_count($text, "scriptalert") >= $count) {
  49. return true;
  50. } elseif (substr_count($text, ";/alert") >= $count) {
  51. return true;
  52. } elseif (substr_count($text, "<script") >= $count) {
  53. return true;
  54. } elseif (substr_count($text, "<iframe") >= $count) {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. }
  61. if (!function_exists("isIP")) {
  62. function isIP($IP)
  63. {
  64. return filter_var($IP, FILTER_VALIDATE_IP) ? true : false;
  65. }
  66. }
  67. if (!function_exists("isSPAM")) {
  68. function isSPAM($string, $max = 1)
  69. {
  70. $words = array(
  71. "??", "comment", "interesting", "blends", "studies", "have", "has", "suis", "`", "aphthous",
  72. ".edu", ".com", ".net", ".org", ".html", "www", ".co.uk", ".jp", ".ch", ".info", ".mobi", ".us", ".ca", ".ws", ".ag", ".pl", "?????", "href",
  73. ".com.co", ".net.co", ".com.ag", ".net.ag", ".it", ".fr", ".tv", ".am", ".asia", ".at", ".be", ".cc", ".de", ".es", ".com.es", ".eu",
  74. ".fm", ".in", ".tk", ".com.mx", ".nl", ".nu", ".tw", ".vg", "sex", "porn", "fuck", "buy", "free", "dating", "viagra", "money", "dollars",
  75. "payment", "website", "games", "toys", "poker", "cheap", "[url]", "[/url]", "[url="
  76. );
  77. $count = 0;
  78. $string = strtolower($string);
  79. foreach ($words as $word) {
  80. $count += substr_count($string, $word);
  81. }
  82. return ($count >= $max) ? true : false;
  83. }
  84. }
  85. if (!function_exists("isVulgar")) {
  86. function isVulgar($string, $max = 1)
  87. {
  88. $words = array(
  89. "puto", "puta", "perra", "tonto", "tonta", "pene", "pito", "chinga tu madre", "hijo de puta", "verga", "pendejo", "baboso",
  90. "estupido", "idiota", "joto", "gay", "maricon", "marica", "chingar", "jodete", "pinche", "panocha", "vagina", "zorra", "fuck",
  91. "chingada", "cojer", "imbecil", "pendeja", "piruja", "puerca", "polla", "capullo", "gilipollas", "cabron", "cagada", "cago",
  92. "cagar", "mierda", "marrano", "porno", "conche", "tu puta madre", "putas", "putos", "pendejas", "pendejos", "pendejadas",
  93. "mamadas", "lesbianas", "coño", "huevon", "sudaca", "fucker", "ramera", "fuck", "bitch", "malparido", "hijuputa", "gonorrea",
  94. "marica e' polvado", "boludo", "chimba", "chunchurria", "gorsovia", "condon", "gorzobia", "bastardo", "fueputa", "zunga",
  95. "flaite", "reculiao", "reculiado", "culiado", "culiao", "puñetero", "ñero", "gil", "mujerzuelo", "mujerzuela", "puberto",
  96. "emopuberto", "putete", "pendejete", "pajero", "putito", "putita", "mamar en reversa", "clitoris", "penudo", "hijueputa",
  97. "galondra", "piroba", "guaricha", "catre", "catre hijueputa", "putazo", "trollazo", "putaso", "putisimo", "putillo", "pete",
  98. "puñete", "puñeñe", "penitente", "vergacion", "vergatario", "nawara", "porqueria", "pajuo", "becerro", "mieldero", "tarado",
  99. "mierdero", "aweboniao", "aweboniado", "aweboniar", "a webo", "orto", "horto", "coger", "imvecil", "inbecil", "imbesil",
  100. "imvesil", "mames", "guaton", "callampa", "callapa", "cayapa", "ermio", "vergon", "vergudo", "verguita", "xuxa", "andate",
  101. "kaga", "kagar", "kagon", "vaca", "kear", "vacan", "bakan", "bakano", "vacano", "bagina", "pichicho", "calzon", "tanga",
  102. "cagado", "cagadisimo", "caguengue", "cojido", "cojida", "orgasmo", "anal", "catimba", "guevo", "lamepene", "pucha",
  103. "coño he tu madre", "cojio", "culero", "culito", "malpario", "verguero", "vergero", "nojoa", "nojodas", "jolines", "pichi",
  104. "pinshe", "inche", "reputisima", "infeliz", "concha rota", "chupame el piko", "chupame el pico", "huevon","camboyana",
  105. "pelao", "pelado", "chuchalaloma", "conchetumare", "chuchetumare", "guaite", "ñoño", "ñoña", "charquican", "piko", "menem",
  106. "huevón", "huevona", "huevada", "gei", "gey", "marikon", "marika", "marikona", "culia", "maraca", "ahuevonado", "sexo",
  107. "agilado", "maraka kulia", "razorra", "cokitos", "chupala", "locote", "pichanga", "cabro", "hoe", "whore", "asshole", "asswipe",
  108. "kulia", "geicha", "cacha", "culiando", "conxhetumare", "conxetumare", "qliao", "qlia", "flaitongo", "ctm", "reconxetumare",
  109. "webn", "yanaruntu", "siquisapa", "mariposon", "maripozon", "jijuna", "ñuñusapa", "pajarincama", "parido", "pirobo", "locota",
  110. "baboso", "fuck", "bitch", "ass", "jackass", "jackas", "dumbas", "dumbass", "motherfucker", "motherfocker", "shit", "damn",
  111. "rape", "bitchass", "bullshit", "douche", "douchebag", " dipshit", "lesbians", "homo", "ass rape", "filho", "xereca", "escroto",
  112. "piranha", "jetea", "jetear", "getea", "getear", "que pedo", "morrillo", "morro", "carajo", "carajito", "merguevo", "merhuevo",
  113. "rosquete", "chimbombo", "brichi", "cojonudo", "cojudo", "friega", "pta madre", "follar", "follado", "follas", "pedo",
  114. "pishes", "shishotas", "chiches", "chichotas", "senos", "bubis", "puerco", "mamon", "mamón"
  115. );
  116. $count = 0;
  117. $string = strtolower($string);
  118. if (is_array($words)) {
  119. foreach ($words as $word) {
  120. $count += substr_count($string, $word);
  121. }
  122. }
  123. return ($count >= $max) ? true : false;
  124. }
  125. }
  126. if (!function_exists("isNumber")) {
  127. function isNumber($number)
  128. {
  129. $number = (int) $number;
  130. if ($number > 0) {
  131. return true;
  132. }
  133. return false;
  134. }
  135. }
  136. if (!function_exists("isMethod")) {
  137. function isMethod($method, $Controller)
  138. {
  139. try {
  140. $Reflection = new ReflectionMethod($Controller, $method);
  141. return true;
  142. } catch (Exception $e) {
  143. return false;
  144. }
  145. }
  146. }
  147. if (!function_exists("isController")) {
  148. function isController($controller, $application = null, $principal = false)
  149. {
  150. if ($application === true) {
  151. if (file_exists($controller)) {
  152. return true;
  153. }
  154. } else {
  155. if ($principal) {
  156. if ($controller === $application) {
  157. $file = "www/applications/$application/controllers/$controller.php";
  158. if (file_exists($file)) {
  159. return true;
  160. }
  161. } else {
  162. return false;
  163. }
  164. }
  165. return file_exists("www/applications/$application/controllers/$controller.php") ? true : false;
  166. }
  167. }
  168. }
  169. if (!function_exists("isLeapYear")) {
  170. function isLeapYear($year)
  171. {
  172. return ((((int) $year % 4 === 0) and ((int) $year % 100 !== 0 ) or ((int) $year % 400 === 0)));
  173. }
  174. }
  175. if (!function_exists("isDay")) {
  176. function isDay($day)
  177. {
  178. return (strlen($day) === 2 and $day > 0 and $day <= 31) ? true : false;
  179. }
  180. }
  181. if (!function_exists("isMonth")) {
  182. function isMonth($month)
  183. {
  184. return (strlen($month) === 2 and $month > 0 and $month <= 12) ? true : false;
  185. }
  186. }
  187. if (!function_exists("isYear")) {
  188. function isYear($year)
  189. {
  190. return (strlen($year) === 4 and $year >= 1950 and $year <= date("Y")) ? true : false;
  191. }
  192. }