function mime_mail()
 {
     $this->html_images = array();
     $this->headers = array();
     $this->is_built = false;
     $this->image_types = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'swf' => 'application/x-shockwave-flash');
     $locale =& locale::instance();
     $this->build_params['html_encoding'] = '8bit';
     $this->build_params['text_encoding'] = '8bit';
     $this->build_params['html_charset'] = $locale->get_charset();
     $this->build_params['text_charset'] = $locale->get_charset();
     $this->build_params['head_charset'] = $locale->get_charset();
     $this->build_params['text_wrap'] = 998;
     if (!empty($_SERVER['HTTP_HOST'])) {
         $helo = $_SERVER['HTTP_HOST'];
     } elseif (!empty($_SERVER['SERVER_NAME'])) {
         $helo = $_SERVER['SERVER_NAME'];
     } else {
         $helo = 'localhost';
     }
     $this->smtp_params['host'] = 'localhost';
     $this->smtp_params['port'] = 25;
     $this->smtp_params['helo'] = $helo;
     $this->smtp_params['auth'] = false;
     $this->smtp_params['user'] = '';
     $this->smtp_params['pass'] = '';
     $this->headers['MIME-Version'] = '1.0';
 }
	function get_cart_summ()
	{
		$cart =& cart :: instance();
		$locale = locale :: instance();
		
		return number_format($cart->get_total_summ(), $locale->fract_digits, $locale->decimal_symbol, $locale->thousand_separator);
	}
  function run(&$filter_chain, &$request, &$response) 
  {
    debug :: add_timing_point('locale filter started');
    
    if(!$node = map_request_to_node($request))
    {
    	define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
    	define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
    	
    	$locale =& locale :: instance();    	
    	$locale->setlocale();
    	
      $filter_chain->next();
      return;
    }
          
    if($object_locale_id = site_object :: get_locale_by_id($node['object_id']))
    	define('CONTENT_LOCALE_ID', $object_locale_id);
    else
      define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
    
    $user = user :: instance();
    if($user_locale_id = $user->get_locale_id())
    	define('MANAGEMENT_LOCALE_ID', $user_locale_id);
    else
      define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
              
    debug :: add_timing_point('locale filter finished');

  	$locale =& locale :: instance();    	
  	$locale->setlocale();
    
    $filter_chain->next();
  }   
	function _set_period_filter()
	{
		$locale =& locale :: instance();
		$start_date = new date();
		$start_date->set_hour(0);
		$start_date->set_minute(0);
		$start_date->set_second(0);

		if (isset($_REQUEST['stats_start_date']))
		{
			$start_date->set_by_string($_REQUEST['stats_start_date'], $locale->get_short_date_time_format());
		}
		
		$finish_date = new date();

		if (isset($_REQUEST['stats_finish_date']))
		{
			$finish_date->set_by_string($_REQUEST['stats_finish_date'], $locale->get_short_date_time_format());
		}

		$finish_date->set_hour(23);
		$finish_date->set_minute(59);
		$finish_date->set_second(59);
		
		$this->stats_report->set_period_filter($start_date, $finish_date);
	}
 function setUp()
 {
     $this->report = new Mockstats_referers_report($this);
     $this->ds = new stats_referers_except_groups_list_datasource_test_version($this);
     $this->ds->setReturnReference('_create_referers_report', $this->report);
     $this->ds->stats_referers_list_datasource();
     $this->locale =& locale::instance();
 }
 function check($value)
 {
     $locale =& locale::instance();
     $date =& new date();
     $date->set_by_string($value, $locale->get_short_date_format());
     if (!$date->is_valid()) {
         $this->error('INVALID_DATE');
     }
 }
 function locale_format($number, $locale_string = null)
 {
     $locale = locale::instance($locale_string);
     $neg = $number < 0;
     $num = $neg ? -$number : $number;
     $num_text =& number_format($num, $locale->get_currency_fract_digits(), $locale->get_currency_decimal_symbol(), $locale->get_currency_thousand_separator());
     $text =& utf8_str_replace(array('%c', '%p', '%q'), array($locale->get_currency_symbol(), $neg ? $locale->get_currency_negative_symbol() : $locale->get_currency_positive_symbol(), $num_text), $neg ? $locale->get_currency_negative_format() : $locale->get_currency_positive_format());
     return $text;
 }
 function format()
 {
     if ($this->format_string) {
         $format_string = $this->format_string;
     } else {
         $locale =& locale::instance($this->locale_type);
         $format_string = $locale->get_short_date_format();
     }
     echo $this->date->format($format_string);
 }
 function _set_period_filter(&$request)
 {
     $locale =& locale::instance();
     $start_date = new date();
     $start_date->set_hour(0);
     $start_date->set_minute(0);
     $start_date->set_second(0);
     if ($stats_start_date = $request->get_attribute('stats_start_date')) {
         $start_date->set_by_string($stats_start_date, $locale->get_short_date_time_format());
     }
     $finish_date = new date();
     if ($stats_finish_date = $request->get_attribute('stats_finish_date')) {
         $finish_date->set_by_string($stats_finish_date, $locale->get_short_date_time_format());
     }
     $finish_date->set_hour(23);
     $finish_date->set_minute(59);
     $finish_date->set_second(59);
     $this->stats_report->set_period_filter($start_date, $finish_date);
 }
 function _get_mail_body($template_path)
 {
     $template = new template($template_path);
     $locale =& locale::instance();
     $date = new date();
     $template->set('date', $date->format($locale->get_short_date_format()));
     $cart =& cart::instance();
     $list =& $template->find_child('cart_items');
     $list->register_dataset($cart->get_items_array_dataset());
     $template->set('name', $this->dataspace->get('name'));
     $template->set('notes', $this->dataspace->get('notes'));
     $template->set('phone', $this->dataspace->get('phone'));
     $template->set('address', $this->dataspace->get('address'));
     $template->set('email', $this->dataspace->get('email'));
     ob_start();
     $template->display();
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
 function format($value)
 {
     $locale =& locale::instance();
     if (!isset($this->attributes['fract_digits']) || !$this->attributes['fract_digits']) {
         $fract_digits = $locale->fract_digits;
     } else {
         $fract_digits = (int) $this->attributes['fract_digits'];
     }
     if (!isset($this->attributes['decimal_symbol']) || !$this->attributes['decimal_symbol']) {
         $decimal_symbol = $locale->decimal_symbol;
     } else {
         $decimal_symbol = $this->attributes['dec_point'];
     }
     if (!isset($this->attributes['thousand_separator']) || !$this->attributes['thousand_separator']) {
         $thousand_separator = $locale->thousand_separator;
     } else {
         $thousand_separator = $this->attributes['thousand_separator'];
     }
     return number_format($value, $fract_digits, $decimal_symbol, $thousand_separator);
 }
 function get_current_locale_code()
 {
     $locale =& locale::instance();
     return $locale->locale_code();
 }
 function get_available_locales_data()
 {
     if (isset($GLOBALS['AVAILABLE_LOCALES']) && is_array($GLOBALS['AVAILABLE_LOCALES'])) {
         $available_locales = $GLOBALS['AVAILABLE_LOCALES'];
     } else {
         return array();
     }
     $locales_data = array();
     foreach ($available_locales as $locale_id) {
         $locale_data =& locale::instance($locale_id);
         $locales_data[$locale_id] = $locale_data->get_language_name() ? $locale_data->get_language_name() : $locale_id;
     }
     return $locales_data;
 }
	function get_value()
	{		
		$form =& $this->find_parent_by_class('form_component');
		
		$value = parent :: get_value();

		if(empty($value))
			$value = $this->get_attribute('default_value');		
		
		if($form->is_first_time())
		{				
			$locale =& locale :: instance();
			$date =& new date($value);
			
			$value = $date->format($locale->get_short_date_format());
		}
			
		return $value;
	}
require_once LIMB_DIR . 'core/lib/date/date.class.php';
require_once LIMB_DIR . 'core/lib/util/mime_type.class.php';
require_once LIMB_DIR . 'core/model/chat/chat_user.class.php';
require_once LIMB_DIR . 'core/model/chat/chat_system.class.php';
require_once LIMB_DIR . 'core/model/chat/smiles.class.php';
start_user_session();
$smiles =& new smiles();
$chat_user_data = chat_user::get_chat_user_data();
chat_system::update_user_time($chat_user_data['id']);
$last_message_ids = session::get("last_message_ids");
if (!($last_message_id = $last_message_ids[$chat_user_data['chat_room_id']])) {
    $last_message_id = 0;
}
$messages = chat_system::get_messages_for_user($chat_user_data['id'], $chat_user_data['chat_room_id'], $last_message_id);
$date =& new date();
$locale =& locale::instance($this->locale_type);
$format_string = $locale->get_short_date_time_format();
echo "<html>\r\n\t\t\t<script>";
foreach ($messages as $message) {
    $message_text = $smiles->decode_smiles($message['message']);
    $message_text = str_replace("\r", "", $message_text);
    $message_text = str_replace("\n", "<br>", $message_text);
    $message_color = $message['color'];
    $sender_name = $message['nickname'];
    $date->set_by_stamp($message['time']);
    $message_date = $date->format($format_string);
    switch (true) {
        case $message['sender_id'] == -1:
            list($message_type, $string) = explode(':', $message['message'], 2);
            if ($message_type == 'system_message') {
                echo "top.add_system_message('{$message_date}', {$message['id']}, '{$string}');\n";
 /**
  *  date pretty printing, similar to strftime()
  *
  *  Formats the date in the given format, much like
  *  strftime().  Most strftime() attributes are supported.
  *  %a    abbreviated weekday name (Sun, Mon, Tue) 
  *  %A    full weekday name (Sunday, Monday, Tuesday) 
  *  %b    abbreviated month name (Jan, Feb, Mar) 
  *  %B    full month name (January, February, March) 
  *  %C    century number (the year divided by 100 and truncated to an integer, range 00 to 99) 
  *  %d    day of month (range 00 to 31) 
  *  %D    same as "%m/%d/%y" 
  *  %e    day of month, single digit (range 0 to 31) 
  *  %E    number of days since unspecified epoch
  *  %H    hour as decimal number (00 to 23) 
  *  %I    hour as decimal number on 12-hour clock (01 to 12) 
  *  %j    day of year (range 001 to 366) 
  *  %m    month as decimal number (range 01 to 12) 
  *  %M    minute as a decimal number (00 to 59) 
  *  %n    newline character (\n) 
  *  %O    dst-corrected timezone offset expressed as "+/-HH:MM" 
  *  %o    raw timezone offset expressed as "+/-HH:MM" 
  *  %p    either 'am' or 'pm' depending on the time 
  *  %P    either 'AM' or 'PM' depending on the time 
  *  %r    time in am/pm notation, same as "%I:%M:%S %p" 
  *  %R    time in 24-hour notation, same as "%H:%M" 
  *  %S    seconds as a decimal number (00 to 59) 
  *  %t    tab character (\t) 
  *  %T    current time, same as "%H:%M:%S" 
  *  %w    weekday as decimal (0 = Sunday) 
  *  %U    week number of current year, first sunday as first week 
  *  %y    year as decimal (range 00 to 99) 
  *  %Y    year as decimal including century (range 0000 to 9999) 
  *  %%    literal '%' 
  */
 function format($format = DATE_SHORT_FORMAT_ISO)
 {
     $output = '';
     $locale = locale::instance();
     for ($strpos = 0; $strpos < strlen($format); $strpos++) {
         $char = substr($format, $strpos, 1);
         if ($char == '%') {
             $nextchar = substr($format, $strpos + 1, 1);
             switch ($nextchar) {
                 case 'a':
                     $output .= $locale->get_day_name($this->get_day_of_week(), true);
                     break;
                 case 'A':
                     $output .= $locale->get_day_name($this->get_day_of_week());
                     break;
                 case 'b':
                     $output .= $locale->get_month_name($this->month - 1, true);
                     break;
                 case 'B':
                     $output .= $locale->get_month_name($this->month - 1);
                     break;
                 case 'p':
                     $output .= $locale->get_meridiem_name($this->hour);
                     break;
                 case 'P':
                     $output .= $locale->get_meridiem_name($this->hour, true);
                     break;
                 case 'C':
                     $output .= sprintf("%02d", intval($this->year / 100));
                     break;
                 case 'd':
                     $output .= sprintf("%02d", $this->day);
                     break;
                 case 'D':
                     $output .= sprintf("%02d/%02d/%02d", $this->month, $this->day, $this->year);
                     break;
                 case 'e':
                     $output .= $this->day;
                     break;
                 case 'E':
                     $output .= $this->date_to_days();
                     break;
                 case 'H':
                     $output .= sprintf("%02d", $this->hour);
                     break;
                 case 'I':
                     $hour = $this->hour + 1 > 12 ? $this->hour - 12 : $this->hour;
                     $output .= sprintf("%02d", $hour == 0 ? 12 : $hour);
                     break;
                 case 'j':
                     $output .= $this->get_day_of_year();
                     break;
                 case 'm':
                     $output .= sprintf("%02d", $this->month);
                     break;
                 case 'M':
                     $output .= sprintf("%02d", $this->minute);
                     break;
                 case 'n':
                     $output .= "\n";
                     break;
                 case 'O':
                     $offms = $this->tz->get_offset($this);
                     $direction = $offms >= 0 ? '+' : '-';
                     $offmins = abs($offms) / 1000 / 60;
                     $hours = $offmins / 60;
                     $minutes = $offmins % 60;
                     $output .= sprintf("%s%02d:%02d", $direction, $hours, $minutes);
                     break;
                 case 'o':
                     $offms = $this->tz->get_raw_offset($this);
                     $direction = $offms >= 0 ? '+' : '-';
                     $offmins = abs($offms) / 1000 / 60;
                     $hours = $offmins / 60;
                     $minutes = $offmins % 60;
                     $output .= sprintf("%s%02d:%02d", $direction, $hours, $minutes);
                     break;
                 case 'r':
                     $hour = $this->hour + 1 > 12 ? $this->hour - 12 : $this->hour;
                     $output .= sprintf("%02d:%02d:%02d %s", $hour == 0 ? 12 : $hour, $this->minute, $this->second, $this->hour >= 12 ? "PM" : "AM");
                     break;
                 case 'R':
                     $output .= sprintf("%02d:%02d", $this->hour, $this->minute);
                     break;
                 case 'S':
                     $output .= sprintf("%02d", $this->second);
                     break;
                 case 't':
                     $output .= "\t";
                     break;
                 case 'T':
                     $output .= sprintf("%02d:%02d:%02d", $this->hour, $this->minute, $this->second);
                     break;
                 case 'w':
                     $output .= $this->get_day_of_week();
                     break;
                 case 'U':
                     $output .= $this->get_week_of_year();
                     break;
                 case 'y':
                     $output .= substr($this->year, 2, 2);
                     break;
                 case 'Y':
                     $output .= $this->year;
                     break;
                 case 'Z':
                     $output .= $this->tz->is_in_daylight_time($this) ? $this->tz->get_DST_short_name() : $this->tz->get_short_name();
                     break;
                 case '%':
                     $output .= '%';
                     break;
                 default:
                     $output .= $char . $nextchar;
             }
             $strpos++;
         } else {
             $output .= $char;
         }
     }
     return $output;
 }
  function _process_datetime_value($value)
  {
    $locale =& locale :: instance($this->_locale_id);
    $date =& new date($value, DATE_FORMAT_ISO);

    if(!$date->is_valid())
    {
      $date->set_by_string($value, $locale->get_short_date_time_format());
      $value = $date->format(DATE_FORMAT_ISO);
    }

    return "'" . $value . "'";
  }