Am proud of being a g33k! I do PHP Programming, *NIX, FreeBSD, MacOSX, White Water Rafting, Volleyball, PS3/PC Gaming, Travelling, and of course GADGETS!

Function checkTime()

Tuesday, August 23rd, 2011

Disebabkan ada yang bertanya pasal function checkTime() yang digunakan dalam #WaktuSolat, camni rupanya :-


function checkTime($currentTime, $startTime, $endTime){

// written 11/26/2006 by Patrick H. ([email protected])

//

// the time passed must meet all the below criteria to return 1 (true):

//

// - current hour needs to be equal or greater than start hour

// - current hour needs to be equal or less than end hour

// - current minute needs to be equal or greater than start minute (if current hour is ok)

// - current minute needs to be equal or less than end minute (if current hour is ok)

//

// if any of those checks does not pass, it will return 0 (false)

 

global $cHour;

global $cMin;

global $sHour;

global $sMin;

global $eHour;

global $eMin;

 

// break up current time

$now = explode(":",$currentTime);

$cHour = intval($now[0]); // current time - hour

$cMin = intval($now[1]); // current time - minute

 

// break up start time

$start = explode(":",$startTime);

$sHour = intval($start[0]); // start of range - hour

$sMin = intval($start[1]); // start of range - minute

 

// brek up end time

$end = explode(":",$endTime);

$eHour = intval($end[0]); // end of range - hour

$eMin = intval($end[1]); // end of range - minute

 

// this is the variable used to track the result of the checks

$pass = true;

 

if($sHour <= $eHour){

// the range is on the same day

 

// compare to the start hour

if($cHour < $sHour){

$pass = false;

}

 

// compare to the end hour

if($cHour > $eHour){

$pass = false;

}

 

// compare to the start min

if($cHour == $sHour){

if($cMin < $sMin){

$pass = false;

}

}

 

// compare to the end min

if($cHour == $eHour){

if($cMin > $eMin){

$pass = false;

}

}

 

} else {

// the range is overnight, so the logic is a little different

 

if( ($cHour < $sHour) && ($cHour > $eHour) ){

$pass = false;

}

 

// compare to the start min

if($cHour == $sHour){

if($cMin < $sMin){

$pass = false;

}

}

 

// compare to the end min

if($cHour == $eHour){

if($cMin > $eMin){

$pass = false;

}

}

 

}

 

// done with check, return the result

if($pass == false){

return 0; // failed

} else {

return 1; // passed

}

 

}

Selamat mencuba!

#TopSecretProject – Twitter Alert for Waktu Solat

Wednesday, March 2nd, 2011

Memperkenalkan the so-called #TopSecretProject lah. It’s actually a tweet alert which’ll send out tweets bila dah masuk waktu solat fardhu on daily basis. Data waktu solat fetched from JAKIM’s website http://www.e-solat.gov.my/.
It’s actually a simple PHP script connected to Twitter via OAuth, it’ll do a simple checking of current time against the data stored in MySQL database. In order to identify whether the current time is Subuh, Zuhur, etc, I did a checking based on range of time for each sets of solat fardhu using function CheckTime() written by Patrick H. ([email protected]). Function can be found at his personal blog.

The idea is to setup twitter alerts for major towns in Malaysia. For now, I’ve started creating 5 twitter accounts to cover Kuala Lumpur, Melaka, Ipoh, Pulau Pinang, & Kuantan. From time to time, I’ll be adding the other areas as well.

Below is the list of covered areas (striked-through) & to be covered.

Feedbacks are welcomed.

  1. WP Kuala Lumpur
  2. Melaka
  3. Ipoh
  4. Pulau Pinang
  5. Kuantan
  6. Kuala Terengganu
  7. Kota Kinabalu
  8. Perlis
  9. Johor Bahru
  10. Kota Bharu
  11. Alor Setar
  12. Kuching
  13. Labuan
  14. Seremban

Credits to @raficyber & @dewmandew for their help.

Uploading YouTube Videos with Zend Framework

Wednesday, August 27th, 2008

Attention all you Zend Framework junkies, Jochen Hartmann has uploaded a new video to youtube that demonstrates the basics of how to use Zend Framework with the YouTube Data API. This step-by-step demonstration walks you though everything you need to know to upload files to Youtube via Zend Framework.

PHP 4.4.9 released!

Friday, August 8th, 2008

The PHP development team would like to announce the immediate
availability of PHP 4.4.9. It continues to improve the security and the
stability of the 4.4 branch and all users are strongly encouraged to
upgrade to it as soon as possible. This release wraps up all the
outstanding patches for the PHP 4.4 series, and is therefore the
last PHP 4.4 release.

Security Enhancements and Fixes in PHP 4.4.9:

  • Updated PCRE to version 7.7.
  • Fixed overflow in memnstr().
  • Fixed crash in imageloadfont when an invalid font is given.
  • Fixed open_basedir handling issue in the curl extension.
  • Fixed mbstring.func_overload set in .htaccess becomes global.

For a full list of changes in PHP 4.4.9, see the ChangeLog.

PHP 5.3 alpha1 released!

Friday, August 1st, 2008

The PHP development team is proud to announce the first alpha release (Windows binaries will appear in the next few days) of the upcoming minor version update of PHP. The new version PHP 5.3 is expected to improve stability and performance as well as add new language syntax and extensions. Several new features have already been documented in the official documentation, others are listed on the wiki in preparation of getting documented. Please also review the NEWS file.

THIS IS A DEVELEOPMENT PREVIEW – DO NOT USE IT IN PRODUCTION!

The purpose of this alpha release is to encourage users to not only actively
participate in identifying bugs, but also in ensuring that all new features or
necessary backwards compatibility breaks are noted in the documentation. Please
report any findings to the QA mailinglist
or the bug tracker.

There have been a great number of other additions and improvements, but here is a short overview of the most important changes:

Several under the hood changes also require in depth testing with existing applications to ensure that any backwards compatibility breaks are minimized. This is especially important for users that require the undocumented Zend engine multibyte support.

The current release plan states that there will be alpha/beta/RC releases in 2-3 week intervals with an expected stable release of PHP 5.3 between mid September and mid October of 2008.

TestFest 2008 wrap-up

Wednesday, July 30th, 2008

Overall 158 tests have been submitted as part of TestFest 2008 since the launch of the TestFest submission site by 30 different people from people all over the world. Actually this is not counting the various submissions by existing core developers, who also took this opportunity to add some more tests. While the organization of the TestFest was a bit adhoc, there were numerous TestFest events in local user groups. So the number of people exposed to the PHP test framework is much greater. Hopefully this will lead to more people submitting bug reports with an accompanying phpt test file!

Our top submitter Felix has actually committed his last submissions himself since, based on the high quality of his submissions, he has been granted commit rights to the PHP repository. We have not heard back from all participants, but we encourage everybody to blog about their experience and provide us with feedback on how to improve future events.

Now better late than never, here are the 10 winners of the promised elePHPant raffle sponsored by Nexen. Note that Felix asked me not to include him in the raffle, since he is already herding quite a number of elePHPants at home.

  • Eric Stewart
  • Håvard Eide
  • Marc Veldman
  • Michelangelo van Dam
  • Rein Velt
  • Rob Young
  • Sami Greenbury
  • Sebastian Deutsch
  • Sebastian Schürmann
  • Stefan Koopmanschap

We will provide Nexen with the email addresses of the winners, so that they can arrange to get the elePHPants shipped. Also for those people wondering, you can continue to submit tests on the TestFest submission site. A bit thank you to all participants and TestFest organizers! Without the countless people that helped organize local events, implement the infrastructure and submissions reviewers, the TestFest would have obviously not worked out as well as it has. We will surely do similar events in the future based on the big success of TestFest 2008.

Manual restructure and license change

Wednesday, July 30th, 2008

A few weeks ago the manual was restructured
to improve navigation and make room for
per-extension chapters
and usage examples along with
improved documentation for
object oriented extensions.

The most noticable changes are the function reference,
predefined variables,
context options and parameters and
predefined exceptions manual pages,
for which we would really appreciate feedback on.

The upcomming PHP5.3 release introduces
several major features
such as namespaces, closures,
late static bindings, internationalization functions,
INI sections, and Phar among others.
We would really appreciate any and all help we can get improving the documentation.

In related news, the manual was relicensed recently and is now
covered by the
CreativeCommons Attribution license.

ZendCon 2008 – September 15-18 – Santa Clara, CA-US

Monday, July 21st, 2008

Join us for the largest PHP only gathering, September 15th18th. Discuss topics such as:

  • PHP in the Enterprise
  • Advanced PHP Programming Techniques
  • Scalability
  • PHP and RIAs

Our guest keynote speaker this year is Zak Greant who will be speaking on The Age of Literate Machines

For more information and to register for the biggest PHP even of the year, visit http://zendcon.com/

php|works CfP Announced!

Friday, July 11th, 2008

php|works 2008 will be held November 12-14, 2008 in Atlanta, GA. Our Call for Papers is now open, but the deadline for submissions is July 25, 2008.

This year's php|works takes place concurrently with PyWorks 2008, MTA's new fall Python conference, organized by the publishers of Python Magazine, and attendees to both conferences will be able to attend talks from either.

This gives us a great opportunity to create cross-over talks to cover topics that bridge both worlds, enriching members of either communities and facilitating the cross-pollination of ideas. If you have a topic that fits the bill, or that could be equally interesting to both PHPers and Pythonistas, don't hesitate to propose it.

For more information about our Call for Papers, visit our site at http://phpworks.mtacon.com/c/p/phpworks,cfp.

Call for PUG, for elePHPants, 2008 generation

Tuesday, May 13th, 2008

The elePHPants are now ready to make their 2008 generation.
PHP User groups, enthusiasts and companies that are interested in
groups of elePHPants, shall join this year’s herd.

ElePHPants are a great link of the community, happily promoting your favorite
language in conferences, on work station, baby cribs and other unusual places.
Production prices make it possible for groups to raise funds, entice membership
or simply bring joy and PHP around.

Pre-register your herd of elePHPants
online, for big and small,
and join the world of blue elePHPants.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Switch to our mobile site