formatize.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. setlocale(LC_MONETARY, 'hu_HU');
  3. class formatize {
  4. static function currency($number=0,$currency='HUF',$separator=false) {
  5. if ($currency=='HUF') {
  6. if ($separator==false) {
  7. return number_format($number,0,'',' ');
  8. }
  9. else {
  10. return number_format($number,0,'','.');
  11. }
  12. }
  13. else {
  14. return number_format($number,2,'.',' ');
  15. }
  16. }
  17. static function currency_in_million($number=0,$currency='HUF') {
  18. if ($currency=='HUF' && $number>1000000) {
  19. return round($number/1000000,2)." M";
  20. }
  21. else {
  22. return number_format($number,2,'.',' ');
  23. }
  24. }
  25. static function getUserFavoritePropertiesCount() {
  26. if ($_COOKIE['fp_fav_props']!=='') {
  27. $data = unserialize($_COOKIE['fp_fav_props']);
  28. return sizeof($data);
  29. }
  30. else {
  31. return 0;
  32. }
  33. }
  34. static function getUserFavoriteAgentsCount() {
  35. if ($_COOKIE['fp_fav_agents']!=='') {
  36. $data = unserialize($_COOKIE['fp_fav_agents']);
  37. return sizeof($data);
  38. }
  39. else {
  40. return 0;
  41. }
  42. }
  43. static function getUserFavoriteOfficesCount() {
  44. if ($_COOKIE['fp_fav_offices']!=='') {
  45. $data = unserialize($_COOKIE['fp_fav_offices']);
  46. return sizeof($data);
  47. }
  48. else {
  49. return 0;
  50. }
  51. }
  52. static function propertySlideURL($filename) {
  53. if ($filename!='') {
  54. $maindir = substr($filename,1,3);
  55. $subdir = substr($filename,1,5);
  56. $url = 'https://prod.rockhome.hu:8445/pictures/ingatlan/'.$maindir.'/'.$subdir.'/'.$filename;
  57. return $url;
  58. }
  59. else {
  60. return false;
  61. }
  62. }
  63. static function is_url_exist($url){
  64. return true;
  65. $ch = curl_init($url);
  66. curl_setopt($ch, CURLOPT_NOBODY, true);
  67. curl_exec($ch);
  68. $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  69. if ($code==200) {
  70. $status = true;
  71. }
  72. else {
  73. $status = false;
  74. }
  75. curl_close($ch);
  76. return $status;
  77. }
  78. }