function actionDefault()
 {
     // Define the date format used for testing
     $fmt = '%A, %d %B %Y';
     // Default locale is always en
     YDDebugUtil::dump(YDLocale::get(), 'Current locale:');
     YDDebugUtil::dump(strftime($fmt), 'strftime test');
     // Set the locale to English
     YDLocale::set('eng');
     YDDebugUtil::dump(YDLocale::get(), 'Current locale:');
     YDDebugUtil::dump(strftime($fmt), 'strftime test');
     // Set the locale to Dutch
     YDLocale::set('nl');
     YDDebugUtil::dump(YDLocale::get(), 'Current locale:');
     YDDebugUtil::dump(strftime($fmt), 'strftime test');
     YDDebugUtil::dump(date("l dS of F Y h:i:s A"), 'date function');
     // Set the locale to Portugese
     YDLocale::set('ptg');
     YDDebugUtil::dump(YDLocale::get(), 'Current locale:');
     YDDebugUtil::dump(strftime($fmt), 'strftime test');
     // Set the locale to Italian
     YDLocale::set('ita');
     YDDebugUtil::dump(YDLocale::get(), 'Current locale:');
     YDDebugUtil::dump(strftime($fmt), 'strftime test');
 }
 /**
  *  This function will format a timestamp using the strftime function.
  *
  *  @param  $timestamp  The timestamp to format. It can also be a date/time form object.
  *  @param  $format     The strftime format to use. You can also use the predefined options date, time and
  *                      datetime.
  *  @param  $locale     (optional) The locale to use to format the date.
  *
  *  @returns    A formatted timestamp
  *
  *  @static
  */
 function formatDate($timestamp, $format, $locale = null)
 {
     // Check if the timestamp is an object and has the getTimeStamp function
     if (is_object($timestamp) && method_exists($timestamp, 'getTimeStamp')) {
         $timestamp = $timestamp->getTimeStamp();
     }
     // Convert to an integer
     if (is_numeric($timestamp)) {
         $timestamp = intval($timestamp);
     }
     // If text, convert to number
     if (is_string($timestamp)) {
         $timestamp = strtotime($timestamp);
     }
     // If array, is a date YDForm element value
     if (is_array($timestamp)) {
         // check if timestamp exists. otherwise create it
         $hours = isset($timestamp['hours']) ? $timestamp['hours'] : 0;
         $minutes = isset($timestamp['minutes']) ? $timestamp['minutes'] : 0;
         $seconds = isset($timestamp['seconds']) ? $timestamp['seconds'] : 0;
         $month = isset($timestamp['month']) ? $timestamp['month'] : 1;
         $day = isset($timestamp['day']) ? $timestamp['day'] : 1;
         $year = isset($timestamp['year']) ? $timestamp['year'] : 1970;
         $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
     }
     // Check the standard formats
     if (strtolower($format) == 'date') {
         $format = '%d %B %Y';
     }
     if (strtolower($format) == 'datetime') {
         $format = '%d %B %Y %H:%M';
     }
     if (strtolower($format) == 'datetimesql') {
         $format = '%Y-%m-%d %H:%M:%S';
     }
     if (strtolower($format) == 'time') {
         $format = '%H:%M';
     }
     if (strtolower($format) == 'file') {
         $format = '%d-%m-%Y %H:%M';
     }
     // Set the new locale
     if (!is_null($locale)) {
         $currentLocale = YDLocale::get();
         YDLocale::set($locale);
     }
     // Return the formatted date
     $timestamp = strftime($format, $timestamp);
     // Reset the old locale
     if (!is_null($locale)) {
         YDLocale::set($currentLocale);
     }
     // Return the timestamp
     return $timestamp;
 }
 function actionDefault()
 {
     YDDebugUtil::dump(YDDate::now(), 'YDDate::now()');
     YDDebugUtil::dump(YDDate::nowCustom("%d"), 'YDDate::nowCustom( "%d" )');
     YDDebugUtil::dump(YDDate::nowCustom("%d %B %Y"), 'YDDate::nowCustom( "%d %B %Y" )');
     // Static validation
     YDDebugUtil::dump(YDDate::get("HUM", time()), 'YDDate::get( "HUM", time() )');
     YDDebugUtil::dump(YDDate::get("EUN_DATE", time()), 'YDDate::get( "EUN_DATE", time() )');
     YDDebugUtil::dump(YDDate::get("HUM_DATE", "2004-03-12", "ISO"), 'YDDate::get( "HUM_DATE", "2004-03-12", "ISO" )');
     YDDebugUtil::dump(YDDate::now(), 'YDDate::now()');
     YDDebugUtil::dump(YDDate::now("EUN_DATE"), 'YDDate::now( "EUN_DATE" )');
     YDDebugUtil::dump(YDDate::now("ISO_TIME"), 'YDDate::now( "ISO_TIME" )');
     YDDebugUtil::dump(YDDate::now("HUM"), 'YDDate::now( "HUM" )');
     YDDebugUtil::dump(YDDate::isValid(""), 'YDDate::isValid( "" )');
     YDDebugUtil::dump(YDDate::isValid("0000-00-00 00:00:00", "ISO"), 'YDDate::isValid( "0000-00-00 00:00:00", "ISO" )');
     YDDebugUtil::dump(YDDate::isValid("0000-00-00 00:00:00", "ISO", true, false), 'YDDate::isValid( "0000-00-00 00:00:00", "ISO", true, false )');
     YDDebugUtil::dump(YDDate::isValid("2005-5-5"), 'YDDate::isValid( "2005-5-5" )');
     YDDebugUtil::dump(YDDate::isValid("2005 5 15"), 'YDDate::isValid( "2005 5 15" )');
     YDDebugUtil::dump(YDDate::isValid("20050515", "SQL"), 'YDDate::isValid( "20050515", "SQL" )');
     YDDebugUtil::dump(YDDate::isValid("15 5 2005", "EUN"), 'YDDate::isValid( "15 5 2005", "EUN" )');
     YDDebugUtil::dump(YDDate::isValid("15 May 2005", "HUM"), 'YDDate::isValid( "15 May 2005", "HUM" )');
     YDDebugUtil::dump(YDDate::isValid("5.15.2005", "USA"), 'YDDate::isValid( "5.15.2005", "USA" )');
     YDDebugUtil::dump(YDDate::isValid("5.15.2005", "EUN"), 'YDDate::isValid( "5.15.2005", "EUN" )');
     YDDebugUtil::dump(YDDate::isValid("5.15.2005", "HUM"), 'YDDate::isValid( "5.15.2005", "HUM" )');
     YDDebugUtil::dump(YDDate::isValid("5.15.2005", "ISO"), 'YDDate::isValid( "5.15.2005", "ISO" )');
     YDDebugUtil::dump(YDDate::isValid("5.15.2005", "SQL"), 'YDDate::isValid( "5.15.2005", "SQL" )');
     $date = new YDDate();
     // Setting an empty date
     $date->set("0000-00-00 00:00:00");
     YDDebugUtil::dump($date->get(), '$date->set( "0000-00-00 00:00:00" )');
     // Setting Unix epoch
     $date->set(0);
     YDDebugUtil::dump($date->get(), '$date->set( 0 )');
     // Setting in SQL format
     $date->set("20050515", "SQL");
     YDDebugUtil::dump($date->get(), '$date->set( "20050515", "SQL" )');
     // Setting in ISO format
     $date->set("2005-5-5");
     YDDebugUtil::dump($date->get(), '$date->set( "2005-5-15" )');
     $date->set("2005 5 15");
     YDDebugUtil::dump($date->get(), '$date->set( "2005 5 15" )');
     // Setting in EUN format
     $date->set("15 5 2005", "EUN");
     YDDebugUtil::dump($date->get(), '$date->set( "15 5 2005", "EUN" )');
     // Setting in HUM format
     $date->set("15 May 2005", "HUM");
     YDDebugUtil::dump($date->get(), '$date->set( "15 May 2005", "HUM" )');
     // Setting in USA format
     $date->set("5.15.2005", "USA");
     YDDebugUtil::dump($date->get(), '$date->set( "5.15.2005", "USA" )');
     // Setting a custom format
     YDDebugUtil::dump(YDDateFormat::setString("custom format", "%a %A %b %B %d %m %Y %H %M %S %T %w"), 'YDDateFormat::setString( "custom format", "%a %A %b %B %d %m %Y %H %M %S %T %w" )');
     // Returning the date with a custom format
     YDDebugUtil::dump($date->get("custom format"), '$date->get( "custom format" )');
     // Setting the date to today
     $date->set();
     YDDebugUtil::dump($date->get(), '$date->set()');
     // Getting date info
     YDDebugUtil::dump($date->get(), '$date->get()');
     YDDebugUtil::dump($date->isToday(), '$date->isToday()');
     YDDebugUtil::dump($date->isTomorrow(), '$date->isTomorrow()');
     YDDebugUtil::dump($date->isYesterday(), '$date->isYesterday()');
     YDDebugUtil::dump($date->isCurrentHour(), '$date->isCurrentHour()');
     YDDebugUtil::dump($date->isCurrentMinute(), '$date->isCurrentMinute()');
     YDDebugUtil::dump($date->isCurrentMonth(), '$date->isCurrentMonth()');
     YDDebugUtil::dump($date->isCurrentYear(), '$date->isCurrentYear()');
     YDDebugUtil::dump($date->getDayName(), '$date->getDayName()');
     YDDebugUtil::dump($date->getDayName(true), '$date->getDayName( true )');
     YDDebugUtil::dump($date->getMonthName(), '$date->getMonthName()');
     YDDebugUtil::dump($date->getMonthName(true), '$date->getMonthName( true )');
     // Getting date info with different locale
     YDDebugUtil::dump(YDLocale::set("ptb"), 'YDLocale::set( "ptb" )');
     YDDebugUtil::dump($date->getDayName(), '$date->getDayName()');
     YDDebugUtil::dump($date->getDayName(true), '$date->getDayName( true )');
     YDDebugUtil::dump($date->getMonthName(), '$date->getMonthName()');
     YDDebugUtil::dump($date->getMonthName(true), '$date->getMonthName( true )');
     // Comparing two dates
     $date2 = $date;
     $date2->addHour(10);
     $date2->addDay(35);
     YDDebugUtil::dump($date->get(), 'Date 1');
     YDDebugUtil::dump($date2->get(), 'Date 2');
     YDDebugUtil::dump($date->getDifference($date2), 'Difference between Dates 1 and 2');
     // Adding values
     YDDebugUtil::dump($date->get(), '$date->get()');
     YDDebugUtil::dump($date->addSecond(70), '$date->addSecond( 70 )');
     YDDebugUtil::dump($date->addMinute(80), '$date->addMinute( 80 )');
     YDDebugUtil::dump($date->addHour(24), '$date->addHour( 24 )');
     YDDebugUtil::dump($date->addHour(12), '$date->addHour( 12 )');
     YDDebugUtil::dump($date->addHour(-10), '$date->addHour( -10 )');
     YDDebugUtil::dump($date->addHour(-24), '$date->addHour( -24 )');
     YDDebugUtil::dump($date->addMinute(10), '$date->addMinute( 10 )');
     YDDebugUtil::dump($date->addMinute(60), '$date->addMinute( 60 )');
     YDDebugUtil::dump($date->addMinute(120), '$date->addMinute( 120 )');
     YDDebugUtil::dump($date->addMinute(-120), '$date->addMinute( -120 )');
     YDDebugUtil::dump($date->addMinute(360), '$date->addMinute( 360 )');
     YDDebugUtil::dump($date->addSecond(10), '$date->addSecond( 10 )');
     YDDebugUtil::dump($date->addSecond(60), '$date->addSecond( 60 )');
     YDDebugUtil::dump($date->addSecond(3600), '$date->addSecond( 3600 )');
     YDDebugUtil::dump($date->addSecond(), '$date->addSecond( -10 )');
     YDDebugUtil::dump($date->addDay(40), '$date->addDay( 40 )');
     YDDebugUtil::dump($date->addDay(-3), '$date->addDay( -3 )');
     YDDebugUtil::dump($date->addMonth(1), '$date->addMonth( 1 )');
     YDDebugUtil::dump($date->addMonth(12), '$date->addMonth( 12 )');
     YDDebugUtil::dump($date->addMonth(10), '$date->addMonth( 10 )');
     YDDebugUtil::dump($date->addMonth(-4), '$date->addMonth( -4 )');
     YDDebugUtil::dump($date->addMonth(-20), '$date->addMonth( -20 )');
     YDDebugUtil::dump($date->addYear(1), '$date->addYear( 1 )');
     YDDebugUtil::dump($date->addYear(12), '$date->addYear( 12 )');
     YDDebugUtil::dump($date->addYear(10), '$date->addYear( 10 )');
     YDDebugUtil::dump($date->addYear(-4), '$date->addYear( -4 )');
     YDDebugUtil::dump($date->addYear(-20), '$date->addYear( -20 )');
     // Getting an array
     YDDebugUtil::dump($date->toArray(), '$date->toArray()');
     $date->set("1981-11-20");
     YDDebugUtil::dump($date->get(), '$date->set( "1981-11-20" )');
     YDDebugUtil::dump($date->getYearsToToday(), '$date->getYearsToToday()');
     // Should return an error
     YDDebugUtil::dump($date->set("no_date"), '$date->set( "no_date" )');
 }
<?php

// initialize the Yellow Duck Framework
include_once dirname(__FILE__) . '/../../YDFramework2/YDF2_init.php';
YDInclude('YDDatabase.php');
YDInclude('YDUrl.php');
// BASIC CONFIGURATION: set YDDatabase instance connection
YDDatabase::registerInstance('default', 'mysql', 'xpto', 'root', '', 'localhost');
// BASIC CONFIGURATION: set portal language. Currently you can use 'en' and 'pt'.
YDLocale::set('en');
// set admin template path
YDConfig::set('YDCMTEMPLATES_ADMIN_PATH', dirname(__FILE__) . '/backend/templates');
YDConfig::set('YDCMTEMPLATES_ADMIN_URL', YDUrl::makeLinkAbsolute('./templates'));
 /**
  *  This function will format a timestamp using the strftime function.
  *
  *  @param  $timestamp  The timestamp to format. It can also be a date/time form object.
  *  @param  $format     The strftime format to use. You can also use the predefined options date, time and 
  *                      datetime.
  *  @param  $locale     (optional) The locale to use to format the date.
  *
  *  @returns    A formatted timestamp
  *
  *  @static
  */
 function formatDate($timestamp, $format, $locale = null)
 {
     // Check if the timestamp is an object and has the getTimeStamp function
     if (is_object($timestamp) && method_exists($timestamp, 'getTimeStamp')) {
         $timestamp = $timestamp->getTimeStamp();
     }
     // Convert to an integer
     if (is_numeric($timestamp)) {
         $timestamp = intval($timestamp);
     }
     // If text, convert to number
     if (is_string($timestamp)) {
         $timestamp = strtotime($timestamp);
     }
     // Check the standard formats
     if (strtolower($format) == 'date') {
         $format = '%d %B %Y';
     }
     if (strtolower($format) == 'datetime') {
         $format = '%d %B %Y %H:%M';
     }
     if (strtolower($format) == 'time') {
         $format = '%H:%M';
     }
     // Set the new locale
     if (!is_null($locale)) {
         $currentLocale = YDLocale::get();
         YDLocale::set($locale);
     }
     // Return the formatted date
     $timestamp = strftime($format, $timestamp);
     // Reset the old locale
     if (!is_null($locale)) {
         YDLocale::set($currentLocale);
     }
     // Return the timestamp
     return $timestamp;
 }
// Include other libraries
YDInclude(dirname(__FILE__) . '/YDWeblogAPI.php');
YDInclude(dirname(__FILE__) . '/YDWeblogRequest.php');
// Check if the weblog application is locked or not
$db = YDDatabase::getInstance('mysql', YDConfig::get('db_name', 'YDWeblog'), YDConfig::get('db_user', 'root'), YDConfig::get('db_pass', ''), YDConfig::get('db_host', 'localhost'));
$tables = $db->getRecords('show tables');
$table_field_name = 'tables_in_' . strtolower(YDConfig::get('db_name', 'YDWeblog'));
foreach ($tables as $table) {
    if (strtolower($table[$table_field_name]) == YDConfig::get('db_prefix', '') . 'locked') {
        die('Weblog application is being updated. Please come again later.');
    }
}
// Set the right locale
$language = YDConfig::get('weblog_language', 'en');
$language = empty($language) ? 'en' : $language;
YDLocale::set($language);
// The t function used for translations
function t($t)
{
    // Return empty string when param is missing
    if (empty($t)) {
        return '';
    }
    // Load the language file
    @(include_once dirname(__FILE__) . '/languages/language_' . strtolower(YDLocale::get()) . '.php');
    // Initialize the language array
    if (!isset($GLOBALS['t'])) {
        $GLOBALS['t'] = array();
    }
    // Return the right translation
    $t = strtolower($t);
<?php

// Standard include
include_once dirname(__FILE__) . '/../../YDFramework2/YDF2_init.php';
// Include server compatibility support (useful if this server don't support gettext)
YDIncludeCompatibility();
// Includes
YDInclude('YDRequest.php');
YDInclude('YDTemplate.php');
// set locale: you can use 'en', 'pt' and 'fr' and use gettext engine with 'test' filenames inside 'locale' language directory
YDLocale::set('pt', 'test', dirname(__FILE__) . '/locale/');
// Class definition
class index extends YDRequest
{
    function index()
    {
        $this->YDRequest();
        $this->tpl = new YDTemplate();
    }
    // Default action
    function actionDefault()
    {
        $this->tpl->assign('var', 'variable');
        $this->tpl->display();
    }
}
// Process the request
YDInclude('YDF2_process.php');
<?php

require_once 'includes/config.php';
// Include the Yellow Duck Framework
require_once YD_INIT_FILE;
// Include the classes needed on all pages
YDInclude('YDForm.php');
YDInclude('YDRequest.php');
YDInclude('YDTemplate.php');
require_once 'includes/page.class.php';
require_once 'includes/users.class.php';
// Define the constants we want to override for the Framework
//YDConfig::set( 'YD_DEBUG', 1 );
YDLocale::set(LOCALE);
// Show all errors including notification of unset variables
error_reporting(E_ALL);
// Include the language file
include_once dirname(__FILE__) . '/languages/language_' . strtolower(YDLocale::get()) . '.php';
//	    /**
//     * The t function used for translations
//     * @param t Code of the word to translate
//     * @return t corresponding string for the current locale
//     *
//     * For the moment the code must be in form module.word.or.more
//     * Every thing is currently in one file, could evolve if required
//     */
//    function t( $t ) {
//
//        // Return empty string when param is missing
//        if ( empty( $t ) ) {
//            return '';