Skip to content

Instantly share code, notes, and snippets.

@abdumu
Last active October 31, 2019 10:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdumu/29d88fb24dd5ad170f2c625f0f8229c7 to your computer and use it in GitHub Desktop.
Save abdumu/29d88fb24dd5ad170f2c625f0f8229c7 to your computer and use it in GitHub Desktop.
vbulletin laravel valet driver
<?php
class vbulletinValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
if (file_exists($sitePath. '/includes/vb5/array.php')) {
return true;
}
return false;
}
/**
* Determine if the incoming request is for a static file.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string|false
*/
public function isStaticFile($sitePath, $siteName, $uri)
{
if (
preg_match('/^\/?images\//', $uri) ||
preg_match('/^\/?fonts\//', $uri) ||
preg_match('/^\/?css\//', $uri) ||
preg_match('/^\/?core\/clientscript\//', $uri) ||
preg_match('/\.js$/', $uri) ||
preg_match('/^\/?core\/cpstyles\//', $uri)
) {
return $sitePath . $uri;
}
return false;
}
/**
* Get the fully resolved path to the application's front controller.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri)
{
$_REQUEST['routestring'] = ltrim($uri, '/');
if ($uri == '/') {
$goto = $sitePath . '/index.php';
}
if (rtrim($uri, '/') == '/core/install') {
$goto = $sitePath . '/core/install/install.php';
}
if (rtrim($uri, '/') == '/admincp') {
$goto = '/admincp/index.php';
}
if (file_exists($sitePath . '/core' .$uri . '.php')) {
$goto = $sitePath . '/core'.$uri . '.php';
}
if (file_exists($sitePath . '/core' .$uri)) {
$goto = $sitePath.'/core'.$uri;
}
if (file_exists($sitePath . $uri)) {
$goto = $sitePath.$uri;
}
if (file_exists($sitePath . $uri . '.php')) {
$goto = $sitePath . $uri . '.php';
}
if (file_exists($sitePath . rtrim($uri, '/') . '/index.php')) {
$goto = $sitePath . rtrim($uri, '/') . '/index.php';
}
if(empty($goto))
{
$_POST = array_merge($_POST, $_REQUEST);
$_GET = array_merge($_GET, $_REQUEST);
}
return !empty($goto) ? $goto : $sitePath . '/index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment