Files
librenms-librenms/app/Helpers/Common.php
Tony Murray df850a3ed9 Attempt to make proxy sub-dir -> app no subdir work (#9317)
Set APP_URL and APP_URL_SUFFIX in .env
2018-10-17 17:07:26 +01:00

55 lines
1.5 KiB
PHP

<?php
/**
* Helpers.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if (!function_exists('str_start')) {
/**
* Begin a string with a single instance of a given value.
*
* @param string $value
* @param string $prefix
* @return string
*/
function str_start($value, $prefix)
{
$quoted = preg_quote($prefix, '/');
return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
}
}
if (!function_exists('str_finish')) {
/**
* Cap a string with a single instance of a given value.
*
* @param string $value
* @param string $cap
* @return string
*/
function finish($value, $cap)
{
$quoted = preg_quote($cap, '/');
return preg_replace('/(?:' . $quoted . ')+$/u', '', $value) . $cap;
}
}