Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [REGEX] Verificare la provenienza dell'url

    Salve, ho questa funzione e vorrei sapere come poterla modificare in modo che riconosca se l'immagine proviene da www.miosito.it oppure da un altro.

    Potete anche indicarmi se la soluzione da me apportata è corretta?

    Se l'immagine provenisse da un altro sito allora deve eseguire un codice diverso
    Codice PHP:
    function catch_first_image($text) {
            
    $first_img '';
            
    $text str_replace("\\","",$text);
            
    $output preg_match_all('/<img.+src=\"([^\\'"]+)\".*>/i', $text$matches);
            if(isset(
    $matches[1][0]) && strstr($matches[0][1], 'www.miosito.it')) {
                //... eseguo del codice
                
    $first_img = 'url-immagine';
            } else {
                
    $first_img = isset($matches[1][0]) ? $matches[1][0] : "";
            }
            if(!empty(
    $first_img)){ //Defines a default image
                return IMAGES_URL.'articles/news/'.basename(
    $first_img);
            } else {
                return false;
            }
        } 
    1000 Grazie
    La rovina del mondo sara' l'indifferenza. Ma chi se ne frega!!

  2. #2
    Utente di HTML.it L'avatar di tapu
    Registrato dal
    May 2008
    Messaggi
    885
    guarda su php manual la variabile $_SERVER[];

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.