function writeArray($parts, $response, $csrfToken = null) { $config = Config::get(); $hashes = new Hashes(); # Unless we're in debug mode, serve minified versions of things like semantic. # Don't bother minifying styles.css and client.js, because their size is tiny # compared to these libraries. $assetMap = $config['debug'] ? [] : ['lib/semantic.css' => 'lib/semantic.min.css', 'lib/semantic.js' => 'lib/semantic.min.js', 'lib/jquery.js' => 'lib/jquery.min.js', 'lib/jquery.inputmask.bundle.js' => 'lib/jquery.inputmask.bundle.min.js']; foreach ($parts as $part) { if (is_string($part)) { $response->append($part); } else { if (isset($part['asset'])) { $part = $part['asset']; $fileName = isget($assetMap[$part], $part); $response->append(preg_replace_callback('/^(.*)\\.(.*)$/', function ($parts) use($fileName, $config, $hashes) { return htmlspecialchars($config['asset-prefix'] . $parts[1] . '.hash-' . $hashes->get($fileName) . '.' . $parts[2], ENT_QUOTES | ENT_HTML5); }, $fileName)); } else { if (isset($part['csrf'])) { $response->append(htmlspecialchars($csrfToken, ENT_QUOTES | ENT_HTML5)); } else { if (isset($part['header'])) { $response->header($part['header'], $part['value']); } else { throw new Exception("Invalid HTML component!"); } } } } } }
function find_helper_files($file) { $files = array(); // Skip helper files if ($this->is_helper_file($file)) { return $files; } foreach (explode(' ', 'metalink torrent mirrors') as $helper) { if (is_file($file . '.' . $helper)) { $files[] = $file . '.' . $helper; } } $hashes = new Hashes(); $hashes->find_files($file); $files = array_merge($files, $hashes->files); $files = array_merge($files, $hashes->find_signatures($file)); return $files; }
/** * Checks if the given hash was calculated using the given options. * * @return bool Two Base64 characters. * @access public * @version 1.0 * @since 1.0 */ public function generateSalt() { return Hashes::createBase64Salt(2); }