Archive to duplicate does not exist. End of duplicate."); // ----- Nothing to duplicate, so duplicate is a success. $v_result = 1; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result=$this->privOpenFd('wb')) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Open the temporary file in write mode //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { $this->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = filesize($p_archive_filename); while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); $v_buffer = fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close $this->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorLog() // Description : // Parameters : // -------------------------------------------------------------------------------- function privErrorLog($p_error_code=0, $p_error_string='') { if (PCLZIP_ERROR_EXTERNAL == 1) { PclError($p_error_code, $p_error_string); } else { $this->error_code = $p_error_code; $this->error_string = $p_error_string; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorReset() // Description : // Parameters : // -------------------------------------------------------------------------------- function privErrorReset() { if (PCLZIP_ERROR_EXTERNAL == 1) { PclErrorReset(); } else { $this->error_code = 0; $this->error_string = ''; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDecrypt() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); $v_result=1; // ----- To Be Modified ;-) $v_pwd = "test"; $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, $p_crc, $v_pwd); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDisableMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privDisableMagicQuotes() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', ""); $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look if already done if ($this->magic_quotes_status != -1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Get and memorize the magic_quote value $this->magic_quotes_status = @get_magic_quotes_runtime(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'"); // ----- Disable magic_quotes if ($this->magic_quotes_status == 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes"); @set_magic_quotes_runtime(0); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privSwapBackMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privSwapBackMagicQuotes() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', ""); $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look if something to do if ($this->magic_quotes_status != -1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Swap back magic_quotes if ($this->magic_quotes_status == 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes"); @set_magic_quotes_runtime($this->magic_quotes_status); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- } // End of class // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathReduction() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function PclZipUtilPathReduction($p_dir) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'"); $v_result = ""; // ----- Look for not empty path if ($p_dir != "") { // ----- Explode path by directory names $v_list = explode("/", $p_dir); // ----- Study directories from last to first $v_skip = 0; for ($i=sizeof($v_list)-1; $i>=0; $i--) { // ----- Look for current path if ($v_list[$i] == ".") { // ----- Ignore this directory // Should be the first $i=0, but no check is done } else if ($v_list[$i] == "..") { $v_skip++; } else if ($v_list[$i] == "") { // ----- First '/' i.e. root slash if ($i == 0) { $v_result = "/".$v_result; if ($v_skip > 0) { // ----- It is an invalid path, so the path is not modified // TBC $v_result = $p_dir; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged"); $v_skip = 0; } } // ----- Last '/' i.e. indicates a directory else if ($i == (sizeof($v_list)-1)) { $v_result = $v_list[$i]; } // ----- Double '/' inside the path else { // ----- Ignore only the double '//' in path, // but not the first and last '/' } } else { // ----- Look for item to skip if ($v_skip > 0) { $v_skip--; } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } } // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { $v_result = '../'.$v_result; $v_skip--; } } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathInclusion() // Description : // This function indicates if the path $p_path is under the $p_dir tree. Or, // said in an other way, if the file or sub-dir $p_path is inside the dir // $p_dir. // The function indicates also if the path is exactly the same as the dir. // This function supports path with duplicated '/' like '//', but does not // support '.' or '..' statements. // Parameters : // Return Values : // 0 if $p_path is not inside directory $p_dir // 1 if $p_path is inside directory $p_dir // 2 if $p_path is exactly the same as $p_dir // -------------------------------------------------------------------------------- function PclZipUtilPathInclusion($p_dir, $p_path) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); $v_result = 1; // ----- Look for path beginning by ./ if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'"); } if ( ($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'"); } // ----- Explode dir and path by directory separator $v_list_dir = explode("/", $p_dir); $v_list_dir_size = sizeof($v_list_dir); $v_list_path = explode("/", $p_path); $v_list_path_size = sizeof($v_list_path); // ----- Study directories paths $i = 0; $j = 0; while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); // ----- Look for empty dir (path reduction) if ($v_list_dir[$i] == '') { $i++; continue; } if ($v_list_path[$j] == '') { $j++; continue; } // ----- Compare the items if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); $v_result = 0; } // ----- Next items $i++; $j++; } // ----- Look if everything seems to be the same if ($v_result) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); // ----- Skip all the empty items while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { // ----- There are exactly the same $v_result = 2; } else if ($i < $v_list_dir_size) { // ----- The path is shorter than the dir $v_result = 0; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilCopyBlock() // Description : // Parameters : // $p_mode : read/write compression mode // 0 : src & dest normal // 1 : src gzip, dest normal // 2 : src normal, dest gzip // 3 : src & dest gzip // Return Values : // -------------------------------------------------------------------------------- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); $v_result = 1; if ($p_mode==0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); } else if ($p_mode==1) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @gzread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==2) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==3) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @gzread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilRename() // Description : // This function tries to do a simple rename() function. If it fails, it // tries to copy the $p_src file in a new $p_dest file and then unlink the // first one. // Parameters : // $p_src : Old filename // $p_dest : New filename // Return Values : // 1 on success, 0 on failure. // -------------------------------------------------------------------------------- function PclZipUtilRename($p_src, $p_dest) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); $v_result = 1; // ----- Try to rename the files if (!@rename($p_src, $p_dest)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); // ----- Try to copy & unlink the src if (!@copy($p_src, $p_dest)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); $v_result = 0; } else if (!@unlink($p_src)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); $v_result = 0; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilOptionText() // Description : // Translate option value in text. Mainly for debug purpose. // Parameters : // $p_option : the option value. // Return Values : // The option text value. // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); if (( ($v_prefix == 'PCLZIP_OPT') || ($v_prefix == 'PCLZIP_CB_') || ($v_prefix == 'PCLZIP_ATT')) && ($v_list[$v_key] == $p_option)) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key); return $v_key; } } $v_result = 'Unknown'; //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilTranslateWinPath() // Description : // Translate windows path by replacing '\' by '/' and optionally removing // drive letter. // Parameters : // $p_path : path to translate. // $p_remove_disk_letter : true | false // Return Values : // The path translated. // -------------------------------------------------------------------------------- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) { if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } // -------------------------------------------------------------------------------- ?> nali o psichica nadis emerge: la Ida, la Pingala e la Sushumna." onmouseout="this.style.backgroundColor='#fff'">Muladhara es la base de que los tres canales principales psíquica o nadis emerge: la Ida, Pingala y Suchumná.

sushumna


CHAKRA PRIMERO


Swadhisthanasecondo reiki chakra (sánscrito) llamado como 'su casa' es el chakra de la segunda mayor de acuerdo a la tradición hindú.

Descripción Swadhisthana se encuentra dos dedos por encima de la Muladhara.

Cuenta con seis pétalos que se corresponden con "el afecto, todo el sentimiento de destrucción, el engaño, el desprecio y la sospecha. Su punto correspondiente en la parte frontal del cuerpo (es decir, su Kshetram) es el hueso púbico.

Swadhisthana se asocia con el inconsciente, y con la emoción.

Está estrechamente relacionado con Muladhara en Swadhisthana, y los diversos samskaras (karmas posibles), permanecer en estado latente, y Muladhara debe encontrar su expresión a través de ellos.

Swadhisthana contiene el deseo inconsciente, el deseo sexual en particular, y se dice que elevar el Kundalini Shakti (energía de la conciencia) es extremadamente difícil para esta razón, muchos santos han tenido que afrontar las tentaciones asociados con este ce la digestione." onmouseout="this.style.backgroundColor='#fff'">E 'asociada con el poder de fuego, y la digestión. Manipura irradia y distribuye el prana para el resto del cuerpo. En este sentido, es más o menos similar a la idea de Dan Tian de Qi Gong.

Estas glándulas de cre il bilanciamento delle forze," onmouseout="this.style.backgroundColor='#fff'">Para algunos, se refiere a la Sephira de Netzach y Hod, Netzach es que la calidad de la energía para superar diversos obstáculos, y Hod es la tendencia a romper el control de la energía en diversas formas, como lo es para apoyar la balanza de fuerzas, como las fuerzas de anabolismo y catabolismo en el cuerpo humano.


cuerpo humano





Anahata chakra es un símbolo de la conciencia de amor, solidaridad, generosidad y dedicación. El nivel psíquico: el centro del poder impulsa al ser humano para amar, ser compasivo, generoso, dedicado y para aceptar las cosas que suceden de una manera divina.

Anahata (Sánscrito: Anahata) es el chakra de la primaria cuarto de acuerdo con la tradición hindú y del yoga tántrico (Shakta).

En sánscrito la palabra Anahata - significa ileso, no golpear y correr. * @author Pierre-Alain Joye * @author Firman Wandayandi * @copyright 1997-2006 Baba Buehler, Pierre-Alain Joye * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version CVS: $Id: Date.php,v 1.41 2006/11/22 00:28:03 firman Exp $ * @link http://pear.php.net/package/Date */ // }}} // {{{ Includes /** * Load Date_TimeZone. */ require_once 'Date/TimeZone.php'; /** * Load Date_Calc. */ require_once 'Date/Calc.php'; /** * Load Date_Span. */ require_once 'Date/Span.php'; // }}} // {{{ Constants // {{{ Output formats Pass this to getDate(). /** * "YYYY-MM-DD HH:MM:SS" */ define('DATE_FORMAT_ISO', 1); /** * "YYYYMMSSTHHMMSS(Z|(+/-)HHMM)?" */ define('DATE_FORMAT_ISO_BASIC', 2); /** * "YYYY-MM-SSTHH:MM:SS(Z|(+/-)HH:MM)?" */ define('DATE_FORMAT_ISO_EXTENDED', 3); /** * "YYYY-MM-SSTHH:MM:SS(.S*)?(Z|(+/-)HH:MM)?" */ define('DATE_FORMAT_ISO_EXTENDED_MICROTIME', 6); /** * "YYYYMMDDHHMMSS" */ define('DATE_FORMAT_TIMESTAMP', 4); /** * long int, seconds since the unix epoch */ define('DATE_FORMAT_UNIXTIME', 5); // }}} // }}} // {{{ Class: Date /** * Generic date handling class for PEAR * * Generic date handling class for PEAR. Attempts to be time zone aware * through the Date::TimeZone class. Supports several operations from * Date::Calc on Date objects. * * @author Baba Buehler * @author Pierre-Alain Joye * @author Firman Wandayandi * @copyright 1997-2006 Baba Buehler, Pierre-Alain Joye * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version Release: 1.4.7 * @link http://pear.php.net/package/Date */ class Date { // {{{ Properties /** * the year * @var int */ var $year; /** * the month * @var int */ var $month; /** * the day * @var int */ var $day; /** * the hour * @var int */ var $hour; /** * the minute * @var int */ var $minute; /** * the second * @var int */ var $second; /** * the parts of a second * @var float */ var $partsecond; /** * timezone for this date * @var object Date_TimeZone */ var $tz; /** * define the default weekday abbreviation length * used by ::format() * @var int */ var $getWeekdayAbbrnameLength = 3; // }}} // {{{ Constructor /** * Constructor * * Creates a new Date Object initialized to the current date/time in the * system-default timezone by default. A date optionally * passed in may be in the ISO 8601, TIMESTAMP or UNIXTIME format, * or another Date object. If no date is passed, the current date/time * is used. * * @access public * @see setDate() * @param mixed $date optional - date/time to initialize * @return object Date the new Date object */ function Date($date = null) { $this->tz = Date_TimeZone::getDefault(); if (is_null($date)) { $this->setDate(date("Y-m-d H:i:s")); } elseif (is_a($date, 'Date')) { $this->copy($date); } else { $this->setDate($date); } } // }}} // {{{ setDate() /** * Set the fields of a Date object based on the input date and format * * Set the fields of a Date object based on the input date and format, * which is specified by the DATE_FORMAT_* constants. * * @access public * @param string $date input date * @param int $format Optional format constant (DATE_FORMAT_*) of the input date. * This parameter isn't really needed anymore, but you could * use it to force DATE_FORMAT_UNIXTIME. */ function setDate($date, $format = DATE_FORMAT_ISO) { if ( preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)?$/i', $date, $regs) && $format != DATE_FORMAT_UNIXTIME) { // DATE_FORMAT_ISO, ISO_BASIC, ISO_EXTENDED, and TIMESTAMP // These formats are extremely close to each other. This regex // is very loose and accepts almost any butchered format you could // throw at it. e.g. 2003-10-07 19:45:15 and 2003-10071945:15 // are the same thing in the eyes of this regex, even though the // latter is not a valid ISO 8601 date. $this->year = $regs[1]; $this->month = $regs[2]; $this->day = $regs[3]; $this->hour = isset($regs[5])?$regs[5]:0; $this->minute = isset($regs[6])?$regs[6]:0; $this->second = isset($regs[7])?$regs[7]:0; $this->partsecond = isset($regs[8])?(float)$regs[8]:(float)0; // if an offset is defined, convert time to UTC // Date currently can't set a timezone only by offset, // so it has to store it as UTC if (isset($regs[9])) { $this->toUTCbyOffset($regs[9]); } } elseif (is_numeric($date)) { // UNIXTIME $this->setDate(date("Y-m-d H:i:s", $date)); } else { // unknown format $this->year = 0; $this->month = 1; $this->day = 1; $this->hour = 0; $this->minute = 0; $this->second = 0; $this->partsecond = (float)0; } } // }}} // {{{ getDate() /** * Get a string (or other) representation of this date * * Get a string (or other) representation of this date in the * format specified by the DATE_FORMAT_* constants. * * @access public * @param int $format format constant (DATE_FORMAT_*) of the output date * @return string the date in the requested format */ function getDate($format = DATE_FORMAT_ISO) { switch ($format) { case DATE_FORMAT_ISO: return $this->format("%Y-%m-%d %T"); break; case DATE_FORMAT_ISO_BASIC: $format = "%Y%m%dT%H%M%S"; if ($this->tz->getID() == 'UTC') { $format .= "Z"; } return $this->format($format); break; case DATE_FORMAT_ISO_EXTENDED: $format = "%Y-%m-%dT%H:%M:%S"; if ($this->tz->getID() == 'UTC') { $format .= "Z"; } return $this->format($format); break; case DATE_FORMAT_ISO_EXTENDED_MICROTIME: $format = "%Y-%m-%dT%H:%M:%s"; if ($this->tz->getID() == 'UTC') { $format .= "Z"; } return $this->format($format); break; case DATE_FORMAT_TIMESTAMP: return $this->format("%Y%m%d%H%M%S"); break; case DATE_FORMAT_UNIXTIME: return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year); break; } } // }}} // {{{ copy() /** * Copy values from another Date object * * Makes this Date a copy of another Date object. * * @access public * @param object Date $date Date to copy from */ function copy($date) { $this->year = $date->year; $this->month = $date->month; $this->day = $date->day; $this->hour = $date->hour; $this->minute = $date->minute; $this->second = $date->second; $this->tz = $date->tz; } // }}} // {{{ format() /** * Date pretty printing, similar to strftime() * * Formats the date in the given format, much like * strftime(). Most strftime() options are supported.

* * formatting options:

* * %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 (integer, Date_Calc::dateToDays())
* %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 including the decimal representation smaller than one second
* %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 '%'
*
* * @access public * @param string format the format string for returned date/time * @return string date/time in given format */ function format($format) { $output = ""; 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 .= Date_Calc::getWeekdayAbbrname($this->day,$this->month,$this->year, $this->getWeekdayAbbrnameLength); break; case "A": $output .= Date_Calc::getWeekdayFullname($this->day,$this->month,$this->year); break; case "b": $output .= Date_Calc::getMonthAbbrname($this->month); break; case "B": $output .= Date_Calc::getMonthFullname($this->month); 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 * 1; // get rid of leading zero break; case "E": $output .= Date_Calc::dateToDays($this->day,$this->month,$this->year); break; case "H": $output .= sprintf("%02d", $this->hour); break; case 'h': $output .= sprintf("%d", $this->hour); break; case "I": $hour = ($this->hour + 1) > 12 ? $this->hour - 12 : $this->hour; $output .= sprintf("%02d", $hour==0 ? 12 : $hour); break; case "i": $hour = ($this->hour + 1) > 12 ? $this->hour - 12 : $this->hour; $output .= sprintf("%d", $hour==0 ? 12 : $hour); break; case "j": $output .= Date_Calc::julianDate($this->day,$this->month,$this->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->getOffset($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->getRawOffset($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 "p": $output .= $this->hour >= 12 ? "pm" : "am"; break; case "P": $output .= $this->hour >= 12 ? "PM" : "AM"; 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 .= str_replace(',', '.', sprintf("%09f", (float)((float)$this->second + $this->partsecond))); 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 .= Date_Calc::dayOfWeek($this->day,$this->month,$this->year); break; case "U": $output .= Date_Calc::weekOfYear($this->day,$this->month,$this->year); break; case "y": $output .= substr($this->year,2,2); break; case "Y": $output .= $this->year; break; case "Z": $output .= $this->tz->inDaylightTime($this) ? $this->tz->getDSTShortName() : $this->tz->getShortName(); break; case "%": $output .= "%"; break; default: $output .= $char.$nextchar; } $strpos++; } else { $output .= $char; } } return $output; } // }}} // {{{ getTime() /** * Get this date/time in Unix time() format * * Get a representation of this date in Unix time() format. This may only be * valid for dates from 1970 to ~2038. * * @access public * @return int number of seconds since the unix epoch */ function getTime() { return $this->getDate(DATE_FORMAT_UNIXTIME); } // }}} // {{{ setTZ() /** * Sets the time zone of this Date * * Sets the time zone of this date with the given * Date_TimeZone object. Does not alter the date/time, * only assigns a new time zone. For conversion, use * convertTZ(). * * @access public * @param object Date_TimeZone $tz the Date_TimeZone object to use, if called * with a paramater that is not a Date_TimeZone object, will fall through to * setTZbyID(). */ function setTZ($tz) { if(is_a($tz, 'Date_Timezone')) { $this->tz = $tz; } else { $this->setTZbyID($tz); } } // }}} // {{{ setTZbyID() /** * Sets the time zone of this date with the given time zone id * * Sets the time zone of this date with the given * time zone id, or to the system default if the * given id is invalid. Does not alter the date/time, * only assigns a new time zone. For conversion, use * convertTZ(). * * @access public * @param string id a time zone id */ function setTZbyID($id) { if (Date_TimeZone::isValidID($id)) { $this->tz = new Date_TimeZone($id); } else { $this->tz = Date_TimeZone::getDefault(); } } // }}} // {{{ inDaylightTime() /** * Tests if this date/time is in DST * * Returns true if daylight savings time is in effect for * this date in this date's time zone. See Date_TimeZone::inDaylightTime() * for compatability information. * * @access public * @return boolean true if DST is in effect for this date */ function inDaylightTime() { return $this->tz->inDaylightTime($this); } // }}} // {{{ toUTC() /** * Converts this date to UTC and sets this date's timezone to UTC * * Converts this date to UTC and sets this date's timezone to UTC * * @access public */ function toUTC() { if ($this->tz->getOffset($this) > 0) { $this->subtractSeconds(intval($this->tz->getOffset($this) / 1000)); } else { $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000)); } $this->tz = new Date_TimeZone('UTC'); } // }}} // {{{ convertTZ() /** * Converts this date to a new time zone * * Converts this date to a new time zone. * WARNING: This may not work correctly if your system does not allow * putenv() or if localtime() does not work in your environment. See * Date::TimeZone::inDaylightTime() for more information. * * @access public * @param object Date_TimeZone $tz the Date::TimeZone object for the conversion time zone */ function convertTZ($tz) { // convert to UTC if ($this->tz->getOffset($this) > 0) { $this->subtractSeconds(intval(abs($this->tz->getOffset($this)) / 1000)); } else { $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000)); } // convert UTC to new timezone if ($tz->getOffset($this) > 0) { $this->addSeconds(intval(abs($tz->getOffset($this)) / 1000)); } else { $this->subtractSeconds(intval(abs($tz->getOffset($this)) / 1000)); } $this->tz = $tz; } // }}} // {{{ convertTZbyID() /** * Converts this date to a new time zone, given a valid time zone ID * * Converts this date to a new time zone, given a valid time zone ID * WARNING: This may not work correctly if your system does not allow * putenv() or if localtime() does not work in your environment. See * Date::TimeZone::inDaylightTime() for more information. * * @access public * @param string id a time zone id */ function convertTZbyID($id) { if (Date_TimeZone::isValidID($id)) { $tz = new Date_TimeZone($id); } else { $tz = Date_TimeZone::getDefault(); } $this->convertTZ($tz); } // }}} // {{{ toUTCbyOffset() function toUTCbyOffset($offset) { if ($offset == "Z" || $offset == "+00:00" || $offset == "+0000") { $this->toUTC(); return true; } if (preg_match('/([\+\-])(\d{2}):?(\d{2})/', $offset, $regs)) { // convert offset to seconds $hours = (int) isset($regs[2])?$regs[2]:0; $mins = (int) isset($regs[3])?$regs[3]:0; $offset = ($hours * 3600) + ($mins * 60); if (isset($regs[