/** * Get paste data. * * @access public * @throws Exception * @return stdClass */ public function get() { $data = $this->_store->read($this->getId()); if ($data === false) { throw new Exception(PrivateBin::GENERIC_ERROR, 64); } // check if paste has expired and delete it if neccessary. if (property_exists($data->meta, 'expire_date')) { if ($data->meta->expire_date < time()) { $this->delete(); throw new Exception(PrivateBin::GENERIC_ERROR, 63); } // We kindly provide the remaining time before expiration (in seconds) $data->meta->remaining_time = $data->meta->expire_date - time(); } // set formatter for for the view. if (!property_exists($data->meta, 'formatter')) { // support < 0.21 syntax highlighting if (property_exists($data->meta, 'syntaxcoloring') && $data->meta->syntaxcoloring === true) { $data->meta->formatter = 'syntaxhighlighting'; } else { $data->meta->formatter = $this->_conf->getKey('defaultformatter'); } } // support old paste format with server wide salt if (!property_exists($data->meta, 'salt')) { $data->meta->salt = ServerSalt::get(); } $data->comments = array_values($this->getComments()); $data->comment_count = count($data->comments); $data->comment_offset = 0; $data->{'@context'} = 'js/paste.jsonld'; $this->_data = $data; return $this->_data; }
/** * get a HMAC of the current visitors IP address * * @access public * @static * @param string $algo * @return string */ public static function getHash($algo = 'sha512') { return hash_hmac($algo, $_SERVER[self::$_ipKey], ServerSalt::get()); }