I was looking for a way to verify the url to be from a specified url. Support for more urls will be added later.
Here is a snippet of the code used to validate the TradingView URL.
$tradingview = 'https://www.tradingview.com/x/zWY79CPs/';
// Replace these to make the string smaller.
$ar = str_replace(['https://', 'www.'], '', $tradingview);
// Explode the string into an array of strings.
$ar = explode('/', $ar);
// Is it an allowed url.
if ($ar[0] !== 'tradingview.com') {
echo 'The Link must be from TradingView';
}
// Is it a valid screenshot
if (strlen($ar[2]) !== 8) {
echo 'The code at the end of the link is usually only 8 characters.';
}
else {
echo 'All checks passed, next we add MIME types.';
}