Advertisement
Russell

Shomoy

Jan 3rd, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.80 KB | None | 0 0
  1. <?php
  2. header('Content-type: text/html; charset=UTF-8');
  3. date_default_timezone_set('Asia/Dhaka');
  4.  
  5. // SELECT TIME ZONE
  6. $sign = "+"; // Whichever direction from GMT to your timezone.
  7. $h = "6"; // Hour for time zone goes here e.g. +8 or -4, just remove the + or -
  8. $dst = "false"; // Just insert "true" if your location uses daylight savings time or "false" if it does not
  9.  
  10. // DETECT AND ADJUST FOR DAYLIGHT SAVINGS TIME
  11. if ($dst) {
  12.     $daylight_saving = date('I');
  13.     if ($daylight_saving){
  14.         if ($sign == "-"){ $h=$h-1;  }
  15.         else { $h=$h+1; }
  16.     }
  17. }
  18.  
  19. // FIND DIFFERENCE FROM GMT
  20. $hm = $h * 60;
  21. $ms = $hm * 60;
  22.  
  23. // SET CURRENT TIME
  24. if ($sign == "-"){ $timestamp = time()-($ms); }
  25. else { $timestamp = time()+($ms); }
  26.  
  27. // SAMPLE OUTPUT
  28. $gmdate = gmdate("g", $timestamp);
  29.  
  30. //echo "$gmdate";
  31. switch ($gmdate)
  32. {
  33. case 1:
  34.   //echo "Number 1";
  35.   $ghanta = "ডিংডং";
  36.  break;
  37.  
  38. case 2:
  39.   //echo "Number 2";
  40.   $ghanta = "ডিংডং ডিংডং";
  41.  break;
  42.  
  43. case 3:
  44.   //echo "Number 3";
  45.   $ghanta = "ডিংডং ডিংডং ডিংডং";
  46. break;
  47.  
  48. case 4:
  49.   //echo "Number 4";
  50.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং";
  51. break;
  52.  
  53. case 5:
  54.   //echo "Number 5";
  55.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  56.  break;
  57.  
  58. case 6:
  59.   //echo "Number 6";
  60.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  61. break;
  62.  
  63. case 7:
  64.   //echo "Number 7";
  65.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ";
  66. break;
  67.  
  68. case 8:
  69.   //echo "Number 8";
  70.  
  71.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  72. break;
  73.  
  74. case 9:
  75.   //echo "Number 9";
  76.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  77. break;
  78.  
  79. case 10:
  80.   //echo "Number 10";
  81.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  82. break;
  83.  
  84. case 11:
  85.   //echo "Number 11 ";
  86.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  87.  break;
  88.  
  89. case 12:
  90.   //echo "Number 12";
  91.   $ghanta = "ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং ডিংডং";
  92. break;
  93.  
  94. default:
  95.   echo "ঘড়ি নস্ট! মেরামতের জন্য কারিগরকে ডাকা হচ্ছে!";
  96. }
  97.  
  98. $shomoy = ' (' . date("g A") . ' BDST)';
  99.  
  100. // Twitter magic starts here :)
  101.  
  102. // Set username and password
  103. $username = 'shomoy';
  104. $password = 'password_here';
  105.  
  106. // The Twitter API address
  107. $url = 'http://twitter.com/statuses/update.xml';
  108. // Alternative JSON version
  109. // $url = 'http://twitter.com/statuses/update.json';
  110. // Set up and execute the curl process
  111. $curl_handle = curl_init();
  112. curl_setopt($curl_handle, CURLOPT_URL, "$url");
  113. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
  114. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
  115. curl_setopt($curl_handle, CURLOPT_POST, 1);
  116. curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$ghanta $shomoy");
  117. curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
  118. $buffer = curl_exec($curl_handle);
  119. curl_close($curl_handle);
  120. // check for success or failure
  121. if (empty($buffer)) {
  122.     echo 'message';
  123. } else {
  124.     echo 'The time is ' . date("g A") . ' BDST';
  125. }
  126.  
  127. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement