Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][HTML]bardzo proste pytanie
Forum PHP.pl > Forum > Przedszkole
gośc 01
Witam,
Ostatnio kupiłem płyte z komponentami. Jest tam bardzo dużo rzeczy min. komentarze nad którymi mam problem- nie wiem jak sprawić żeby pojawiły się w oknie przeglądarki. A to kod:

Kod
<?
//updated: 17:15 14/09/2002
///////////////////////////////////////////////////////////////////////////////
//                              talkback v1.12                               //
//                         created by James Maglo                            //
//           Download: http://php.umbagu.net/files/talkback.zip              //
//               Support: http://php.umbagu.net/support                      //
//                                         //
///////////////////////////////////////////////////////////////////////////////


$address        =   "http://php.umbagu.net/scripts/php/"; //Full URL to where the talkback.php script is installed
$file           =   "comment.dat"; //name of the file where data will be stored.  the default comment.dat value is recommended
$path           =   "/usr/home/u/m/umbagu/public_html/scripts/php/";// Finally, the full path to the script directory
$img            =   "1"; // 1 - user can post images   0  - images are disabled
$title_colour   =   "#0066AA"; //background colour of the part where user's name is displayed
$message_colour =   "#CECEFF"; //background colour of the message displayed

// CHMOD THE DIRECTORY WHICH YOU SPECIFIED IN $address TO 0777!!!
//THATS ALL YOU NEED TO EDIT, PLEASE STOP NOW.  TO USE THE SCRIPT, USE include("path/to/script/talkback.php");
$version = "1.1";
$maxlen = 30;
$route = "true";
if($img){
$imgnfo = "enabled. \\n\\n[img=http://imageaddress.com/image.jpg][/img]";
}
else{
$imgnfo = "disabled";
}

function reWriteDataInFile($fileData,$fileName =  "talkback.tb")
    {
        if(!file_exists($fileName))
        {
            @$createFile = fopen($fileName, "w") or die ("Can't create file ".$fileName."");
            fwrite ($createFile,"",0);
            @chmod($fileName, 0666);
            fclose($createFile);
        }
        @$openFile = fopen($fileName,"w+") or die ("Access is denied. Set permission to ".$fileName." by command in console \"chmod 666 ".$fileName."\"");
        if ($openFile && flock($openFile,LOCK_EX)) {
            @fwrite($openFile,$fileData);
        }
        fclose($openFile);
    }

function createFile($fileName)
    {
        if(!file_exists($fileName))
        {
            @$createFile = fopen($fileName, "w") or die ("Can't create file ".$fileName."");
            fwrite ($createFile,"",0);
            @chmod($fileName, 0666);
            fclose($createFile);
        }
    }

function convertLink($content)
    {
        global $constant;
        $content = preg_replace('/(http|ftp|news|https)(:\/\/)([^<> ])+/i', "<a href='\\' class='messagelink'>\</a>", $content);
        $content = preg_replace('/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))/i', "<a href='mailto:\\1'>\\1</a>", $content);
        return $content;
    }

function divideWord($content,$maxWordLength = "30")
    {
        return wordwrap($content, $maxWordLength, " ", 1);
    }


$back = "$HTTP_REFERER";
$time = date("d M, Y - H:i");
//############
//start of the script for adding
//############
if($action){
if($name){
if($comment){

$id =  date("dMYHis");

    if (file_exists("${file}"))
        include("${file}");
    else
        createFile("${file}");

        $comment = ereg_replace("[ ]{2,}", " ", $comment);
        $comment = convertLink($comment);
        $comment = str_replace("\"", """, $comment);
        $comment = str_replace("\n", " <br/>", $comment);
        $comment = str_replace("\$", " $", $comment);
        $comment = strip_tags($comment, '');
if($img){
        $comment = str_replace("[img=", "<img src='", $comment);
        $comment = str_replace("][/img]", "'>", $comment);
}
        $comment = trim($comment);
        $comment = stripslashes($comment);


$cnt = 0;
    $addContent = "<?php\n";

    $addContent .= "\t\$content[0]['page'] = \"".$page."\";\n";
    $addContent .= "\t\$content[0]['delete'] = \"".$id."\";\n";
    $addContent .= "\t\$content[0]['name'] = \"".$name."\";\n";
    $addContent .= "\t\$content[0]['comment'] = \"".$comment."\";\n";
    $addContent .= "\t\$content[0]['time'] = \"".$time."\";\n";



    $contentCnt = sizeof($content);
    if ($contentCnt != 0)
        $addContent .= "\n";
    for($i = 0; $i < $contentCnt; $i++)
    {
        $cnt++;
        while(list($key, $value) = each($content[$i]))
        {
            $addContent .= "\t\$content[".$cnt."]['".$key."'] = \"".$value."\";\n";
        }
        if ($i != $contentCnt-1)
            $addContent .= "\n";
    }
    $addContent .= "?>";
    reWriteDataInFile ($addContent, "$file");





}}
header ("location: $back");
exit;}
//#############
//end of script for adding
//#############
//show the entry form if nothing has been added
//#############
$page = "${HTTP_HOST}${PHP_SELF}";
    if (file_exists("${path}${file}"))
include("${path}${file}");

print<<<END
<p><b><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Talkback</font></b><br><font size="1" face="verdana">the smart way to voice your opinion</font></p>
<form action="${address}talkback.php" name="f" method="post">
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="64">
        <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">name:</font></b></div>
      </td>
      <td width="436"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000">
        <input type="text" maxlength="40" name="name" style="width: 300;font-size: 7pt; font-family: Arial; background-color: #FFFFFF; color: black; border: 1 solid #000000" size="10">
        </font></font></b></td>
    </tr>
    <tr>
      <td width="64" valign="top"> <script language="Javascript">
function help(){
alert("INFORMATION\\n\\n Images are $imgnfo\\n\\n    talkback - http://php.umbagu.net");
}
</script>
        <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">comment:</font></b></div><div align="center"><font face="verdana" size="1"> <a href="javascript:help()"><font color="blue">help</font></a></font></div>
      </td>
      <td width="436"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000">
        <textarea name="comment" style="width: 300;font-size: 7pt; font-family: Arial; background-color: #FFFFFF; color: black; border: 1 solid #000000" cols="10" rows="4"></textarea>
        </font></font></b></td>
    </tr>
    <tr>
      <td width="64">
        <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2"><font size="2"><b></b></font></font></font></font></div>
      </td>
      <td width="436"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
        <input type="submit" name="Submit" value="Submit" style="width: 300;font-size: 7pt;" ><input type="hidden" name="action" value="yeah_baby"><input type="hidden" name="page" value="$page">
        </font></b></td>
    </tr>
  </table>
</form>

END;



?>
</font></font><br>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<?
$now = "${HTTP_HOST}${PHP_SELF}";


$currentContent = $content;
    for ($i = 0; $i < sizeof($currentContent); $i++)
    {
$try = $currentContent[$i]['page'];
$message = $currentContent[$i]['comment'];
$message = str_replace("javascript:", "[talkback JS filter]", $message);
if($try == $now){
?>
  <tr>
    <td bgcolor="<?echo $title_colour;?>"><font face="Verdana, Arial, Helvetica, sans-serif"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'>
      <font size="2" color="#FFFFFF"> <b>
      <?=$currentContent[$i]['name']?>
      </b></font></font></font></font><b><font size="2" color="#FFFFFF">commented
      at </font></b></font><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">
      <?=$currentContent[$i]['time']?>
      </font></b><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'>
      </font></font></font></td>
  </tr>
  <tr>
    <td bgcolor="<?echo $message_colour;?>"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'>
       <?=$message?>
      </font></font></font></td>
  </tr><?}}?>
</table>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" color="blue" size="1">
<a href="http://php.umbagu.net">© James Maglo - umbagu </a>
</font></p>


Pytanie pierwsze
Co muszę zrobić aby ten skrypt pojawił się w oknie przęglądarki?
v1t4n
Po pierwsze nie wklepuj go w znacznikach <?php...?>. Jezeli bardzo chcesz wstawic jakies znaczniki i zeby byly one widoczne wykorzystaj te funkcje
  1. <?php
  2. function make_html($text) {
  3. $foo = array('<' => '&lt;', '>' => '&gt;');
  4. return strtr($text, $foo);
  5. }
  6. ?>


Wykorzystanie (juz dla calkiem poczatkujacych)
  1. <?php
  2. make_html('<b>tak pisze sie tekst pogrubiony</b> <i>tak pisze sie kursywa</i>');
  3. ?>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.