/**
 * Check if specified variable is error object and handle it.
 *
 * Check if specified variable is error if so it takes specific action according
 * to the reply values. By default it raises the exception using
 * {@link ERROR_ACTION_RAISE} reply action constant. The reply array should has
 * action  and option keys eg. $reply = array('action' => ERROR_ACTION_WRITE,
 * 'option' => 'logfile.log'); Action key can be set with one of the following
 * constants: {@link ERROR_ACTION_ABORT}, {@link ERROR_ACTION_PRINT},
 * {@link ERROR_ACTION_LOGIN}, {@link ERROR_ACTION_EMAIL},
 * {@link ERROR_ACTION_DEBUG},{@link ERROR_ACTION_WRITE},
 * {@link ERROR_ACTION_RAISE}.
 *
 * @author Alberto Ferrer <*****@*****.**>
 * @access public
 * @param mixed $data
 * @param array $reply error mode of operation.
 * @return void
 */
function object_checkError($data, $reply = null)
{
    global $object_errorReply;
    if (object_isError($data)) {
        if (!is_array($reply)) {
            if (isset($object_errorReply)) {
                $reply = $object_errorReply;
            } else {
                $reply = array('action' => ERROR_ACTION_RAISE, 'format' => "[%d] %s", 'option' => E_USER_ERROR);
            }
        }
        $error = new Error($data->getMessage(), $data->getCode(), $reply);
    }
}
 function gc2($maxlifetime)
 {
     global $storage_path, $storage_name;
     $storage = new Dir($storage_path);
     if (is_object($storage)) {
         if ($storage->open() == true) {
             $modules = $storage->readFiles();
             if (!object_isError($modules)) {
                 $expire = time() - $maxlifetime;
                 for ($i = 0; $i < count($modules); $i++) {
                     if (!strstr($modules[$i]->getName(), 'sess_')) {
                         continue;
                     }
                     if ($modules[$i]->open() == true) {
                         $d = unserialize($modules[$i]->read());
                         $modules[$i]->close();
                         if (!isset($d['time'])) {
                             $modules[$i]->delete();
                             continue;
                         }
                         $e = time() - $d['time'];
                         if ($e < $modules[$i]->getMTime()) {
                             continue;
                         }
                         $modules[$i]->delete();
                         continue;
                     }
                     if ($expire < $modules[$i]->getMTime()) {
                         continue;
                     }
                     $result = $modules[$i]->delete();
                     if (object_isError(@$result)) {
                         break;
                     }
                 }
             }
             $storage->close();
             return object_isError(@$result) == false;
         }
     }
     return false;
 }