| | |
| | | const REQUEST_ERROR_URL = 1; |
| | | const REQUEST_ERROR_TOKEN = 2; |
| | | |
| | | const DEBUG_LINE_LENGTH = 4096; |
| | | |
| | | /** |
| | | * Singleton instace of rcube |
| | | * |
| | |
| | | if (empty($_SESSION['secure_token']) && $generate) { |
| | | // generate x characters long token |
| | | $length = $len > 1 ? $len : 16; |
| | | $token = openssl_random_pseudo_bytes($length / 2); |
| | | $token = bin2hex($token); |
| | | $token = rcube_utils::random_bytes($length); |
| | | |
| | | $plugin = $this->plugins->exec_hook('secure_token', |
| | | array('value' => $token, 'length' => $length)); |
| | |
| | | |
| | | |
| | | /** |
| | | * Write debug info to the log |
| | | * |
| | | * @param string Engine type - file name (memcache, apc) |
| | | * @param string Data string to log |
| | | * @param bool Operation result |
| | | */ |
| | | public static function debug($engine, $data, $result = null) |
| | | { |
| | | static $debug_counter; |
| | | |
| | | $line = '[' . (++$debug_counter[$engine]) . '] ' . $data; |
| | | |
| | | if (($len = strlen($line)) > self::DEBUG_LINE_LENGTH) { |
| | | $diff = $len - self::DEBUG_LINE_LENGTH; |
| | | $line = substr($line, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]"; |
| | | } |
| | | |
| | | if ($result !== null) { |
| | | $line .= ' [' . ($result ? 'TRUE' : 'FALSE') . ']'; |
| | | } |
| | | |
| | | self::write_log($engine, $line); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns current time (with microseconds). |
| | | * |
| | | * @return float Current time in seconds since the Unix |