LoRz
MP3 Audio Player for Websites
A
tutorial for embedding mp3 audio player in websites using
Audio Player Wordpress plugin from
1pixelout.
Calculating Relative Time in PHP
class calculateTime
{
public static function createTimeString($timeStamp, $format="long", $dateFormat="n/j/Y")
{
// Take the current time and create the difference
$timeDifference = time() - $timeStamp;
// Check the length of time passed since seconds
switch($timeDifference)
{
// Date is less than an hour old
case $timeDifference <= 3600:
$minutes = floor($timeDifference / 60);
$seconds = $timeDifference - ($minutes * 60);
// Choose correct pluralizations
if($minutes == 1)
{
$minuteString = "minute";
}
else
{
$minuteString = "minutes";
}
if($seconds == 1)
{
$secondString = "second";
}
else
{
$secondString = "seconds";
}
switch($format)
{
case "short":
return $minutes . "m " . $seconds . "s ago";
break;
default:
return $minutes . " " . $minuteString . " " . $seconds . " " . $secondString . " ago";
break;
}
break;
// Date is less than a day old
case $timeDifference <= 86400:
$hours = floor($timeDifference / 60 / 60);
$minutes = floor(($timeDifference - ($hours * 60 * 60)) / 60);
// Choose correct pluralizations
if($hours == 1)
{
$hourString = "hour";
}
else
{
$hourString = "hours";
}
if($minutes == 1)
{
$minuteString = "minute";
}
else
{
$minuteString = "minutes";
}
switch($format)
{
case "short":
return $hours . "h " . $minutes . "m ago";
break;
default:
return $hours . " " . $hourString . " " . $minutes . " " . $minuteString . " ago";
break;
}
break;
// Date is less than a week old.
case $timeDifference <= 604800:
$days = floor($timeDifference / 86400);
$hours = floor(($timeDifference - ($days * 86400)) / 60 / 60);
// Choose correct pluralizations
if($days == 1)
{
$dayString = "day";
}
else
{
$dayString = "days";
}
if($hours == 1)
{
$hourString = "hour";
}
else
{
$hourString = "hours";
}
switch($format)
{
case "short":
return $days . "d " . $hours . "h ago";
break;
default:
return $days . " " . $dayString . " " . $hours . " " . $hourString . " ago";
break;
}
break;
// Older than one week. Just return the absolute date.
default:
return date($dateFormat, $timeStamp);
break;
}
}
}
?>
from
http://blog.sacklun.ch/?p=9
Get Filename in PHP
$filename = preg_replace('/(.+)\..*$/', '$1', $file);
Custom JavaScript Dialog Boxes
JavaScript dialog box library which offers four model dialog styles: alerts, warnings, prompts and success.
DemoDownload
PHP Podcast
P3 (php|architect's PHP Podcast) is a bi-weekly radio-style program full of news, punditry and plenty of rambling.
Ratproxy
Google has released its free
Ratproxy security tool to those wanting to
test the security of their Web-based apps, including for cross-site scripting
attacks.
Ratproxy is a semi-automated, largely passive web application security audit tool. It is meant to complement active crawlers and manual proxies more commonly used for this task, and is optimized specifically for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.