Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.51 KB | None | 0 0
  1. <?php
  2.  
  3. define('SALT','hfdlshvavh;elvha;ohva');
  4.  
  5.  
  6. function multiExplode($delimiters,$string) {
  7. return explode($delimiters[0],strtr($string,array_combine(array_slice($delimiters,1),array_fill(0,count($delimiters)-1,array_shift($delimiters)))));
  8. }
  9.  
  10.  
  11. function trim_all( $str , $what = NULL , $with = ' ' )
  12. {
  13. if( $what === NULL )
  14. {
  15. // Character Decimal Use
  16. // "\0" 0 Null Character
  17. // "\t" 9 Tab
  18. // "\n" 10 New line
  19. // "\x0B" 11 Vertical Tab
  20. // "\r" 13 New Line in Mac
  21. // " " 32 Space
  22.  
  23. $what = "\\x00-\\x20"; //all white-spaces and control chars
  24. }
  25.  
  26. return trim( preg_replace( "/[".$what."]+/" , $with , $str ) , $what );
  27. }
  28.  
  29.  
  30.  
  31. //WEBCACHE
  32.  
  33. function getcache($url) {
  34. if(!file_exists(storage_path().'/webcache/'."w".sha1($url).".html")) {
  35. return false;
  36. }else{
  37. return file_get_contents(storage_path().'/webcache/'."w".sha1($url).".html");
  38. }
  39. }
  40.  
  41. function webcache($url,$withpost=true) {
  42.  
  43. //search log
  44. $logfile = storage_path().'/webcache.log';
  45. if(file_exists($logfile)) $logf = file_get_contents($logfile); else $logf = '';
  46. $logf = $logf.Request::getClientIp()." - ".date("Y-m-d H:i:s")." - ".$url.' - hash: '.sha1($url)."\n";
  47. if(trim($url)!='') file_put_contents($logfile,$logf);
  48. //end search log
  49.  
  50.  
  51. if(!file_exists(storage_path().'/webcache/'."w".sha1($url).".html")) {
  52. try {
  53. if($withpost) $fgc = file_get_contents_post($url); else $fgc = file_get_contents_ref($url);
  54.  
  55. //retry once
  56. if(strlen(trim($fgc))<2){
  57. sleep(3);
  58. if($withpost) $fgc = file_get_contents_post($url); else $fgc = file_get_contents_ref($url);
  59. }
  60.  
  61. //retry twice
  62. if(strlen(trim($fgc))<2){
  63. sleep(2);
  64. if($withpost) $fgc = file_get_contents_post($url); else $fgc = file_get_contents_ref($url);
  65. }
  66.  
  67. file_put_contents(storage_path().'/webcache/'."w".sha1($url).".html",websig($url).$fgc);
  68. } catch (Exception $e) {
  69. return false;
  70. //return file_get_contents_proxy($url);
  71. }
  72. }else{
  73. $fgc = file_get_contents(storage_path().'/webcache/'."w".sha1($url).".html");
  74. }
  75. return $fgc;
  76. }
  77. function websig($url){
  78. return "";
  79. //return "<!-- url: $url -->".PHP_EOL;
  80. }
  81.  
  82.  
  83. function webcacheproxy($url){
  84. if(!file_exists(storage_path().'/webcache/'."w".sha1($url).".html")) {
  85. try {
  86. $fgc = file_get_contents_proxy($url);
  87. file_put_contents(storage_path().'/webcache/'."w".sha1($url).".html",websig($url).$fgc);
  88. } catch (Exception $e) {
  89. return false;
  90. }
  91. }else{
  92. $fgc = file_get_contents(storage_path().'/webcache/'."w".sha1($url).".html");
  93. }
  94. return $fgc;
  95. }
  96.  
  97.  
  98.  
  99.  
  100.  
  101. function file_get_contents_post($url){
  102.  
  103. $referer = "https://www.tmdn.org/";
  104.  
  105. $ch = curl_init();
  106.  
  107. /*
  108. curl_setopt($ch, CURLOPT_HEADER, 0); // return headers 0 no 1 yes
  109. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return page 1:yes
  110. curl_setopt($ch, CURLOPT_TIMEOUT, 200); // http request timeout 20 seconds
  111. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects, need this if the url changes
  112. curl_setopt($ch, CURLOPT_MAXREDIRS, 2); //if http server gives redirection responce
  113. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  114. //curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); // cookies storage / here the changes have been made
  115. //curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
  116. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // false for https
  117. curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // the page encoding
  118. curl_setopt($ch, CURLOPT_REFERER, $referer);
  119. curl_setopt($ch, CURLOPT_URL,$url);
  120. //curl_setopt($ch, CURLOPT_PROXY, $proxy);
  121. //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  122. $curl_scraped_page = curl_exec($ch);
  123. curl_close($ch);
  124. */
  125.  
  126. $postfields = "TSd805d5_id=3&TSd805d5_75=e4c8b93ca2f9ce16fca253c6ada053bd:rqqp:Rh4Awz7S:721943986&TSd805d5_md=1&TSd805d5_rf=https%3a%2f%2fwww.tmdn.org%2f&TSd805d5_ct=0&TSd805d5_pd=0";
  127. //$postfields = 'TS82d731_id=3&TS82d731_75=bedfe8ebd5e7283d8a7ee318a46c721f%3Ajklj%3A28PM92r2%3A1988019743&TS82d731_md=1&TS82d731_rf=0&TS82d731_ct=0&TS82d731_pd=0';
  128. //$postfields = 'TS01a8cc48_id=3&TS01a8cc48_cr=02b2ebe5a9863e8a3913b79553418c16:abda:PQ0Z4Bm6:483549760&TS01a8cc48_76=0&TS01a8cc48_md=1&TS01a8cc48_rf=0&TS01a8cc48_ct=0&TS01a8cc48_pd=0';
  129. $postfields = 'TS01a8cc48_id=3&TS01a8cc48_cr=02518683b2023b8b9fd84e1aa71beebd:sqpo:kbZ809WJ:842733783&TS01a8cc48_76=0&TS01a8cc48_md=1&TS01a8cc48_rf=0&TS01a8cc48_ct=0&TS01a8cc48_pd=0';
  130.  
  131.  
  132. curl_setopt($ch, CURLOPT_HEADER, 0); // return headers 0 no 1 yes
  133. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return page 1:yes
  134. curl_setopt($ch, CURLOPT_TIMEOUT, 200); // http request timeout 20 seconds
  135. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects, need this if the url changes
  136. curl_setopt($ch, CURLOPT_MAXREDIRS, 5); //if http server gives redirection responce
  137. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  138. //curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); // cookies storage / here the changes have been made
  139. //curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
  140. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // false for https
  141. curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // the page encoding
  142. curl_setopt($ch, CURLOPT_REFERER, $referer);
  143. curl_setopt($ch, CURLOPT_URL,$url);
  144. //curl_setopt($ch, CURLOPT_PROXY, $proxy);
  145. //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  146. curl_setopt($ch, CURLOPT_POST, 1);
  147. curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
  148. $curl_scraped_page = curl_exec($ch);
  149. curl_close($ch);
  150. return $curl_scraped_page;
  151.  
  152. }
  153.  
  154.  
  155. function file_get_contents_ref($url){
  156.  
  157. $referer = "https://www.tmdn.org/";
  158.  
  159. $ch = curl_init();
  160.  
  161.  
  162. curl_setopt($ch, CURLOPT_HEADER, 0); // return headers 0 no 1 yes
  163. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return page 1:yes
  164. curl_setopt($ch, CURLOPT_TIMEOUT, 200); // http request timeout 20 seconds
  165. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects, need this if the url changes
  166. curl_setopt($ch, CURLOPT_MAXREDIRS, 5); //if http server gives redirection responce
  167. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  168. //curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); // cookies storage / here the changes have been made
  169. //curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
  170. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // false for https
  171. curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // the page encoding
  172. curl_setopt($ch, CURLOPT_REFERER, $referer);
  173. curl_setopt($ch, CURLOPT_URL,$url);
  174. //curl_setopt($ch, CURLOPT_PROXY, $proxy);
  175. //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  176. $curl_scraped_page = curl_exec($ch);
  177.  
  178. curl_close($ch);
  179. return $curl_scraped_page;
  180.  
  181. }
  182.  
  183. function file_get_contents_proxy($url){
  184.  
  185. //$url = 'http://dynupdate.no-ip.com/ip.php';
  186.  
  187. $proxy = '127.0.0.1:8888';
  188. //$proxyauth = 'user:password';
  189. $proxy = '72.159.148.20:10000';
  190. $proxy = '37.59.101.237:3128';
  191. $referer = "https://www.tmdn.org/";
  192.  
  193. $ch = curl_init();
  194.  
  195. curl_setopt($ch, CURLOPT_HEADER, 0); // return headers 0 no 1 yes
  196. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return page 1:yes
  197. curl_setopt($ch, CURLOPT_TIMEOUT, 200); // http request timeout 20 seconds
  198. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects, need this if the url changes
  199. curl_setopt($ch, CURLOPT_MAXREDIRS, 5); //if http server gives redirection responce
  200. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  201. //curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); // cookies storage / here the changes have been made
  202. //curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
  203. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // false for https
  204. curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // the page encoding
  205. curl_setopt($ch, CURLOPT_REFERER, $referer);
  206. curl_setopt($ch, CURLOPT_URL,$url);
  207. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  208. //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  209. $curl_scraped_page = curl_exec($ch);
  210. curl_close($ch);
  211.  
  212. return $curl_scraped_page;
  213.  
  214. }
  215.  
  216.  
  217.  
  218.  
  219. function checkauth($inputEmail,$inputPassword){
  220.  
  221.  
  222. $authok = false;
  223. $f=file(storage_path().'/auth.txt');
  224. foreach($f as $a){
  225. $e = explode(' ',$a);
  226. if(trim($e[0])==trim($inputEmail) && hash_equals(trim($e[1]),sha1(SALT.$inputPassword))) $authok = true;
  227. }
  228.  
  229. return $authok;
  230. }
  231.  
  232.  
  233.  
  234. function checkhash($inputEmail,$hsh){
  235.  
  236.  
  237. $authok = false;
  238. $f=file(storage_path().'/auth.txt');
  239. foreach($f as $a){
  240. $e = explode(' ',$a);
  241. if(trim($e[0])==trim($inputEmail) && hash_equals(trim($e[1]),$hsh)) $authok = true;
  242. }
  243.  
  244. return $authok;
  245. }
  246.  
  247.  
  248.  
  249. function autho(){
  250.  
  251. $login = Request::cookie('login');
  252. $pass = Request::cookie('pass');
  253.  
  254. if(checkhash($login,$pass)){
  255. Session::put('login', $login);
  256. return true;
  257.  
  258. }else{
  259.  
  260. Session::flush();
  261. Cookie::queue('login', null, -1);
  262. Cookie::queue('pass', null, -1);
  263. return false;
  264.  
  265. }
  266.  
  267.  
  268. }
  269.  
  270. function setif($arr,$name){
  271. if(isset($arr[$name])) return $arr[$name]; else return '';
  272. }
  273.  
  274.  
  275.  
  276. if (!function_exists('hash_equals')) {
  277.  
  278. /**
  279. * Timing attack safe string comparison
  280. *
  281. * Compares two strings using the same time whether they're equal or not.
  282. * This function should be used to mitigate timing attacks; for instance, when testing crypt() password hashes.
  283. *
  284. * @param string $known_string The string of known length to compare against
  285. * @param string $user_string The user-supplied string
  286. * @return boolean Returns TRUE when the two strings are equal, FALSE otherwise.
  287. */
  288. function hash_equals($known_string, $user_string)
  289. {
  290. if (func_num_args() !== 2) {
  291. // handle wrong parameter count as the native implentation
  292. trigger_error('hash_equals() expects exactly 2 parameters, ' . func_num_args() . ' given', E_USER_WARNING);
  293. return null;
  294. }
  295. if (is_string($known_string) !== true) {
  296. trigger_error('hash_equals(): Expected known_string to be a string, ' . gettype($known_string) . ' given', E_USER_WARNING);
  297. return false;
  298. }
  299. $known_string_len = strlen($known_string);
  300. $user_string_type_error = 'hash_equals(): Expected user_string to be a string, ' . gettype($user_string) . ' given'; // prepare wrong type error message now to reduce the impact of string concatenation and the gettype call
  301. if (is_string($user_string) !== true) {
  302. trigger_error($user_string_type_error, E_USER_WARNING);
  303. // prevention of timing attacks might be still possible if we handle $user_string as a string of diffent length (the trigger_error() call increases the execution time a bit)
  304. $user_string_len = strlen($user_string);
  305. $user_string_len = $known_string_len + 1;
  306. } else {
  307. $user_string_len = $known_string_len + 1;
  308. $user_string_len = strlen($user_string);
  309. }
  310. if ($known_string_len !== $user_string_len) {
  311. $res = $known_string ^ $known_string; // use $known_string instead of $user_string to handle strings of diffrent length.
  312. $ret = 1; // set $ret to 1 to make sure false is returned
  313. } else {
  314. $res = $known_string ^ $user_string;
  315. $ret = 0;
  316. }
  317. for ($i = strlen($res) - 1; $i >= 0; $i--) {
  318. $ret |= ord($res[$i]);
  319. }
  320. return $ret === 0;
  321. }
  322.  
  323. }
  324.  
  325.  
  326.  
  327. /*
  328. * PHP function to resize an image maintaining aspect ratio
  329. * http://salman-w.blogspot.com/2008/10/resize-images-using-phpgd-library.html
  330. *
  331. * Creates a resized (e.g. thumbnail, small, medium, large)
  332. * version of an image file and saves it as another file
  333. */
  334.  
  335. define('THUMBNAIL_IMAGE_MAX_WIDTH', 100);
  336. define('THUMBNAIL_IMAGE_MAX_HEIGHT', 100);
  337.  
  338. function generate_image_thumbnail($source_image_path, $thumbnail_image_path)
  339. {
  340. list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
  341. switch ($source_image_type) {
  342. case IMAGETYPE_GIF:
  343. $source_gd_image = imagecreatefromgif($source_image_path);
  344. break;
  345. case IMAGETYPE_JPEG:
  346. $source_gd_image = imagecreatefromjpeg($source_image_path);
  347. break;
  348. case IMAGETYPE_PNG:
  349. $source_gd_image = imagecreatefrompng($source_image_path);
  350. break;
  351. }
  352. if ($source_gd_image === false) {
  353. return false;
  354. }
  355. $source_aspect_ratio = $source_image_width / $source_image_height;
  356. $thumbnail_aspect_ratio = THUMBNAIL_IMAGE_MAX_WIDTH / THUMBNAIL_IMAGE_MAX_HEIGHT;
  357. if ($source_image_width <= THUMBNAIL_IMAGE_MAX_WIDTH && $source_image_height <= THUMBNAIL_IMAGE_MAX_HEIGHT) {
  358. $thumbnail_image_width = $source_image_width;
  359. $thumbnail_image_height = $source_image_height;
  360. } elseif ($thumbnail_aspect_ratio > $source_aspect_ratio) {
  361. $thumbnail_image_width = (int) (THUMBNAIL_IMAGE_MAX_HEIGHT * $source_aspect_ratio);
  362. $thumbnail_image_height = THUMBNAIL_IMAGE_MAX_HEIGHT;
  363. } else {
  364. $thumbnail_image_width = THUMBNAIL_IMAGE_MAX_WIDTH;
  365. $thumbnail_image_height = (int) (THUMBNAIL_IMAGE_MAX_WIDTH / $source_aspect_ratio);
  366. }
  367. $thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height);
  368. imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, 0, 0, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height);
  369. imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90);
  370. imagedestroy($source_gd_image);
  371. imagedestroy($thumbnail_gd_image);
  372. return true;
  373. }
  374.  
  375.  
  376.  
  377. define('DOC_IMAGE_MAX_WIDTH', 280);
  378. define('DOC_IMAGE_MAX_HEIGHT', 100);
  379.  
  380. function generate_image_doc($source_image_path, $thumbnail_image_path)
  381. {
  382. list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
  383. switch ($source_image_type) {
  384. case IMAGETYPE_GIF:
  385. $source_gd_image = imagecreatefromgif($source_image_path);
  386. break;
  387. case IMAGETYPE_JPEG:
  388. $source_gd_image = imagecreatefromjpeg($source_image_path);
  389. break;
  390. case IMAGETYPE_PNG:
  391. $source_gd_image = imagecreatefrompng($source_image_path);
  392. break;
  393. }
  394. if ($source_gd_image === false) {
  395. return false;
  396. }
  397. $source_aspect_ratio = $source_image_width / $source_image_height;
  398. $thumbnail_aspect_ratio = DOC_IMAGE_MAX_WIDTH / DOC_IMAGE_MAX_HEIGHT;
  399. if ($source_image_width <= DOC_IMAGE_MAX_WIDTH && $source_image_height <= DOC_IMAGE_MAX_HEIGHT) {
  400. $thumbnail_image_width = $source_image_width;
  401. $thumbnail_image_height = $source_image_height;
  402. } elseif ($thumbnail_aspect_ratio > $source_aspect_ratio) {
  403. $thumbnail_image_width = (int) (DOC_IMAGE_MAX_HEIGHT * $source_aspect_ratio);
  404. $thumbnail_image_height = DOC_IMAGE_MAX_HEIGHT;
  405. } else {
  406. $thumbnail_image_width = DOC_IMAGE_MAX_WIDTH;
  407. $thumbnail_image_height = (int) (DOC_IMAGE_MAX_WIDTH / $source_aspect_ratio);
  408. }
  409. $thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height);
  410. imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, 0, 0, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height);
  411. imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90);
  412. imagedestroy($source_gd_image);
  413. imagedestroy($thumbnail_gd_image);
  414. return true;
  415. }
  416.  
  417.  
  418.  
  419. function prepara_texto($texto)
  420. {
  421. #$texto = html_entity_decode($texto);
  422. return $texto;
  423.  
  424.  
  425. //setlocale(LC_CTYPE, 'cs_CZ');
  426. $texto = str_replace('&amp;','and',$texto);
  427. //$texto = fixchars($texto);
  428. try {
  429. $r = html_entity_decode(iconv('UTF-8', 'windows-1252',$texto));
  430. } catch (Exception $e) {
  431. $r = html_entity_decode($texto);
  432. }
  433.  
  434. //return html_entity_decode(iconv('UTF-8', 'windows-1252',$texto));
  435.  
  436. //$r = html_entity_decode(iconv("utf-8", "cp1252//TRANSLIT", $texto));
  437. //$r = html_entity_decode(iconv('UTF-8', 'CP1252//TRANSLIT', $texto));
  438. //$r = clean($r);
  439. return $r;
  440. }
  441.  
  442.  
  443.  
  444.  
  445. function fixchars($string, $alphanumonly=true) {
  446.  
  447. $normalizeChars = array(
  448. 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A',
  449. 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I',
  450. 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U',
  451. 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a',
  452. 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
  453. 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u',
  454. 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ƒ'=>'f', 'Ą'=>'A', 'Ć'=>'C', 'Ę'=>'E',
  455. 'Ł'=>'L', 'Ń'=>'N', 'Ó'=>'O', 'Ś'=>'S', 'Ż'=>'Z', 'Ź'=>'Z', 'ą'=>'a', 'ć'=>'c', 'ę'=>'e', 'ł'=>'l',
  456. 'ń'=>'n', 'ó'=>'o', 'ś'=>'s', 'ż'=>'z', 'ź'=>'z', 'Č'=>'C', 'Á'=>'A', 'Í'=>'I', 'Ý'=>'Y', 'Ř'=>'R',
  457. 'Ĺ'=>'L', 'Ž'=>'Z', 'Ň'=>'N', 'Ú'=>'U', 'Ě'=>'E', 'Ž'=>'Z', 'Š'=>'S', 'č'=>'c', 'á'=>'a', 'í'=>'i',
  458. 'ý'=>'y', 'ř'=>'r', 'ĺ'=>'l', 'ž'=>'z', 'ň'=>'n', 'ú'=>'u', 'ě'=>'e', 'ž'=>'z', 'š'=>'s'
  459. );
  460.  
  461. $sText = strtr($string,$normalizeChars);
  462. //$sText = str_replace('<','char123456789',$sText);
  463. //$sText = str_replace('>','char987654321',$sText);
  464.  
  465. if($alphanumonly) $sText = preg_replace('|[^0-9A-Za-z \-\.\;\&\#\_\/+]|', '', $sText);
  466.  
  467. //$sText = str_replace('char123456789','<',$sText);
  468. //$sText = str_replace('char987654321','>',$sText);
  469.  
  470. return $sText;
  471. }
  472.  
  473. function clean($var) {
  474. $regEx="/[^a-zA-Z0-9.,]/";
  475. $var = preg_replace($regEx, "", $var);
  476. return str_replace(array("&", "'"),
  477. array("&amp;", "&apos;"), $var);
  478. }
  479.  
  480.  
  481. function prepara_texto_json($texto)
  482. {
  483. $texto = str_replace('&amp;','and',$texto);
  484. return html_entity_decode($texto);
  485. }
  486.  
  487.  
  488. function chmod_r($path) {
  489. $dir = new DirectoryIterator($path);
  490. foreach ($dir as $item) {
  491. chmod($item->getPathname(), 0777);
  492. if ($item->isDir() && !$item->isDot()) {
  493. chmod_r($item->getPathname());
  494. }
  495. }
  496. }
  497.  
  498.  
  499. function capitaliser($str){
  500. //return ucfirst(strtolower($str));
  501. return ucwords(strtolower($str));
  502. }
  503.  
  504.  
  505. function unicode2html($string){
  506. $string = html_entity_decode($string);
  507. $f = file_get_contents(storage_path().'/unics-decimal_html_entity-mini.json');
  508. $normalizeChars = json_decode($f,true);
  509. $s = strtr($string,$normalizeChars);
  510. $s = fixchars($s);
  511. return $s;
  512.  
  513. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement