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

    disabilitare tag HTML in una form

    Ciao a tutti.
    Ho un sistema di gestione delle news sul sito che funziona tramite delle form: in pratica scrivo il titolo, il testo e altri dati in dei campi testo, dopodichè quanto digitato è memorizzato nel database alla pressione del tasto Submit.

    Quando poi visualizzo la pagina del risultato, compare quanto scritto, e vengono elaborati i tag html se presenti.

    Ora mi (vi) chiedo: è possibile, tramite una stringa di codice, far sì che i tag racchiusi tra < e > vengano ignorati?

  2. #2

  3. #3
    Pugia, grazie per avermi segnalato htmlentities.
    Ho fatto una breve ricerca, e ho trovato questo post:
    http://forum.html.it/forum/showthrea...t=htmlentities

    solo che, non essendo pratico di php, non saprei bene come implementarlo... questo è il mio codice:

    Codice PHP:
        // Begin output of news items 
        
    while ($r mysql_fetch_array($q[info], MYSQL_ASSOC)) {
            
    $auid $r[author];
            
    $output $set[output];
            
    $r[subject] = "<a name=\"cn_$r[id]\"></a>$r[subject]";
            
    $serv_tzone = (date("Z")/3600);
            
    // Format date to current timezone, using format setting specified 
            
    $r[date] = date("$set[dateform]"cn_zonechange("$serv_tzone""$set[timezone]""$r[date]"));
            
            
    // Print category name for current news item [v1.13]
            
    $catname cn_getinfo($r[cat],"name",$t_cats);
            
    $output str_replace("{cat}""$catname"$output);
            
            
    // Add line breaks to both content areas only [v1.13 fix]
            
    $content str_replace("\n""
    \n"
    $r[content]);
            
    $content2 str_replace("\n""
    \n"
    $r[content2]);
            
            
    // Replace image tags with proper images [v1.14]
            
    if(is_array($imgarr)) {
                foreach(
    $imgarr as $imgid => $filename) {
                    
    $content str_replace("{img:$imgid}","" cn_showImage($filename,"left") . ""$content);
                    
    $content str_replace("{img:$imgid|left}","" cn_showImage($filename,"left") . ""$content);
                    
    $content str_replace("{img:$imgid|center}","" cn_showImage($filename,"center") . ""$content);
                    
    $content str_replace("{img:$imgid|right}","" cn_showImage($filename,"right") . ""$content);
                    
    $content2 str_replace("{img:$imgid}","" cn_showImage($filename,"left") . ""$content2);
                    
    $content2 str_replace("{img:$imgid|left}","" cn_showImage($filename,"left") . ""$content2);
                    
    $content2 str_replace("{img:$imgid|center}","" cn_showImage($filename,"center") . ""$content2);
                    
    $content2 str_replace("{img:$imgid|right}","" cn_showImage($filename,"right") . ""$content2);
                }
            }
            
            
    // Highlight searched item in returned news if search is performed and searches are allowed [v1.12] 
            
    if(isset($_REQUEST['s'])) {
                
    $content cn_highlight(stripslashes($content), "$_REQUEST[s]"); // case-insensitive or partial word search 
                //$output = str_replace("$_REQUEST[s]", "<span style=\"background-color:yellow; color: black\">$s</span>", $output); // exact word search 
            
    }
        
            
    // Summarize story option [v1.12] 
            
    if($r[sumstory] == "on" && isset($_REQUEST['a'])) { 
                
    $output str_replace("{news}""$content

    $content2"$output);
            } elseif(
    $r[sumstory] == "on") {
                
    $output str_replace("{news}""$content[size="1"]<a href=\"" $_SERVER['PHP_SELF'] . "?a=$r[id]\">Leggi tutto...</a>[/size]"$output);
            } else {
                
    $output str_replace("{news}""$content"$output);
            }
            
        
            
    // Use Keywords and word filter if filter is turned "on" [v1.12] 
            
    if($set[words] == "on") {
                
    $q[words] = mysql_query("SELECT * FROM $t_words ORDER BY word ASC"$link) or E("Couldn't select keywords:
    mysql_error());
                while (
    $w mysql_fetch_array($q[words], MYSQL_ASSOC)) {
                    if(
    $w[type] == "link") {
                        
    $w[replaced] = "<a href=\"$w[replaced]\" target=\"_blank\">$w[word]</a>";
                    } elseif(
    $w[type] == "picture") {
                        
    $w[replaced] = "<img src=\"$w[replaced]\" alt=\"$w[word]\" />";
                    }
                    
    $output str_replace("$w[word]""$w[replaced]"$output);
                }
            }
        
            
    // Build user-defined source link [v1.12] 
            
    if(empty($r[source]) || empty($r[sourceurl])) {
                
    $output str_replace("{source}"""$output);
            } else {
                if(empty(
    $set[source])) {
                    
    $setsource "<a href=\"$r[sourceurl]\" target=\"_blank\">$r[source]</a>";
                    
    $output str_replace("{source}""$setsource"$output);
                } else {
                    
    $setsource str_replace("{sname}""$r[source]"$set[source]);
                    
    $setsource str_replace("{surl}""$r[sourceurl]"$setsource);
                    
    $output str_replace("{source}""$setsource"$output);
                }
            }
        
            
    // Build user-defined author link [v1.12] 
            
    if(empty($set[author])) {
                
    $setauthor "<a href=\"mailto:" cn_getinfo($r[author],"email") . "\">" cn_cn_getinfo($r[author]) . "</a>";
                
    $output str_replace("{author}""$setauthor"$output);
            } else {
                
    $setauthor str_replace("{aemail}""" cn_getinfo($r[author], "email") . ""$set[author]);
                
    $setauthor str_replace("{aname}""" cn_getinfo($r[author]) . ""$setauthor);
                
    $output str_replace("{author}""$setauthor"$output);
            }
            
            
    $output str_replace("{subject}""$r[subject]"$output);
            
    $output str_replace("{date}""$r[date]"$output);
            
            
    // Transform news output to HTML code 
            
    $output =  cn_htmltrans($output,'html');
            
            
    // View/Post Comments Link [v1.12] 
            
    if($set[comments] == "on" && !isset($_REQUEST['a'])) {
                
    $q[comsn] = mysql_query("SELECT COUNT(id) as comscount FROM $t_coms WHERE news_id = '$r[id]'"$link) or E("Couldn't count comments for current news article:
    mysql_error());
                
    $comsnum mysql_result($q[comsn],comscount);
                if(empty(
    $set[coms_text])) {
                
    $output str_replace("{comments}""<a href=\"" $_SERVER['PHP_SELF'] . "" cn_buildQueryString(array('a'=>$r[id])) . "\">[size="1"]View/Post Comments ($comsnum)[/size]</a>"$output);
                } else {
                    
    $setcoms_text str_replace("{cnum}""$comsnum"$set[coms_text]);
                    
    $output str_replace("{comments}""<a href=\"" $_SERVER['PHP_SELF'] . "" cn_buildQueryString(array('a'=>$r[id])) . "\">[size="1"]$setcoms_text[/size]</a>"$output);
                }
            } elseif(isset(
    $_REQUEST['a'])) {
                
    $output str_replace("{comments}""[size="1"][ <a href=\"" $_SERVER['PHP_SELF'] . "" cn_buildQueryString(array('a'=>'')) . "\">&lt;&lt; Return to News Page</a> ][/size]"$output);
            } else {
                
    $output str_replace("{comments}"""$output);
            }

            
    // Output formatted news 
            
    echo $output;
        
        } 
    // End While (output of news items) 
    Credo che c'entri qualcosa la stringa
    // Transform news output to HTML code
    $output = cn_htmltrans($output,'html');

    ma non so bene come fare... mi daresti ancora una mano perfavore?

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.