Малко помощ ако може ...

Paina

Registered
Значи искам да добавя поле за html код към картинка и поле за bbcode към картинка.За html успях да го направя , но за bbcode ми дава следната грешка
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in E:\xampp\xampp\htdocs\test\index.php on line 275 като сложа
$file
.
Ще ви помоля ако може да помогнете ... :cry:


Значи ето какво съм направил

Код:
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<meta http-equiv="content-language" content="en-us">
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<title>Upload</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<SCRIPT TYPE="text/javascript">

</SCRIPT>
<script language="JavaScript" type="text/javascript">
<!-- ;
var newwindow;
var wheight = 450, wwidth = 450;
function popimg(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+450;
pheight=iheight+450;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+100;
pheight=iheight+100;
newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + ' border=0>');
newwindow.document.writeln('<br>HTML Код:<input type="text" size="75" class="field" value="<img src=http://bgsite.serveblog.net/test/' + url + '>"></input>');
newwindow.document.writeln('<br>phpBB/IPB:<input type="text" size="75" class="field" value="[img]http://bgsite.serveblog.net/test/' + url + '[/img]"></input><br>');
newwindow.document.writeln('<a title="Кликни за да затвориш прозореца!" href="javascript:window.close();">Затвори прозореца</а><br><br><\/center><br> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}



function tidy5() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

</script>

<body bgcolor="#ECF5FF" text="#3399FF" leftmargin="20" topmargin="10" marginwidth="10" marginheight="10">
<div align="center">
 <center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#CCCCCC" width="995" id="AutoNumber1" bgcolor="#FFFFFF">
        <tr>
          <td width="100%">
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5">
            <tr>
              <td width="21%" valign="top" bgcolor="#3399FF">
              <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber6">
		<tr>
                  <td width="100%" valign="top" bgcolor="#3399FF" align="center"><center>
                  <font face="Verdana" size="2" color="#FFFFFF">Меню</font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/index.php"><center>Начало</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/irc/index.html" onClick="form(this, 'join')" target="_new"><center>IRC Чат</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/Signatures" ><center>Подписи</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/wallpapers><center>Тапети</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/games.php"  onClick="form(this, 'join')" ><center>Игри</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                <tr>
                  <td width="97%" valign="top" bgcolor="#FFFFFF"><font face="Verdana" size="1">
                  <a href="/vbox.php"><center>Свали клипче от vBox7</a></font></td>
                  <td width="3%" valign="top"></td>
                </tr>
                </tr>
                </table>
              </td>
             </table>
            </div>

           </center>


<?php

//Chmod it (777)
$upload_dir = "images/"; 

$size_bytes = 2048000; 
$extlimit = "yes"; 
$limitedext = array(".gif" , ".jpg" , ".png" , ".jpeg" , ".bmp");


if (!is_dir("$upload_dir")) {
die ("<Center><h1>Грешка: Директорията <b>($upload_dir)</b> не съществува!</h1></center>");
}

if (!is_writeable("$upload_dir")){
die ("<center><h1>Грешка: Качването е забранено!</h1></center>");
}


if(isset($_POST['uploadform'])){

$file_tmp = $_FILES['filetoupload']['tmp_name'];
$file_name = $_FILES['filetoupload']['name'];

$file_size = $_FILES['filetoupload']['size'];


if (!is_uploaded_file($file_tmp)){
echo "<center><h1>Грешка: Моля изберете файл!.</h1> <br>»<a href=\"$_SERVER[PHP_SELF]\">Върни се обратно</a></center>";
exit();
}



if ($file_size > $size_bytes){
echo "<center><h1>Грешка: Файлът е твърде голям. Големината му трябва да е <b>". $size_bytes / 1024 ."</b> KB.</h1> <br>»<a href=\"$_SERVER[PHP_SELF]\">Върни се обратно</a></center>";
exit();
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array(strtolower($ext),$limitedext))) {
echo("<centeR><h1>Грешка: Грeшно разширение на файлът. </h1></center>");
exit();
}



if(file_exists($upload_dir.$file_name)){
echo "<centeR><h1>Грешка! Файлът <b>$file_name</b> Вече съществува. </h1><br>»<a href=\"$_SERVER[PHP_SELF]\">Върни се обратно</a></center>";
exit();
}


$file_name = str_replace(' ', '_', $file_name);

if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {

echo "<centeR><h1>Файлът (<a href=\"$upload_dir$file_name\">$file_name</a>) е успешно качен!</h1><br>»<a href=\"$_SERVER[PHP_SELF]\">Върни се обратно</a></centeR";
exit();
}else{

echo "<center><h1>Грешка:Файлът неможе да се премести.</h1> <br>»<a href=\"$_SERVER[PHP_SELF]\">Върни се обратно</a></center>";
exit();
}


}else{



for($i=0;$i<count($limitedext);$i++){
if (($i<>count($limitedext)-1))$commas=", ";else $commas="";
list($key,$value)=each($limitedext);
$all_ext .= $value.$commas;
}


echo "<center><br><h3>»Избери файл за качване:</h3>"
."» Резрешени разширения: $all_ext</b> <br>"
."» Максимална големина на файл = ". $size_bytes / 1024 ."KB"
."<form method=\"post\" enctype=\"multipart/form-data\" action=\"$PHP_SELF\">"
."<input type=\"file\" name=\"filetoupload\"><br>"
."<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$size_bytes\"><br>"
."<input type=\"Submit\" name=\"uploadform\" value=\"Качи\">"
."</form></center>";
}


function del(){
global $upload_dir, $file;
@unlink($upload_dir."/$file");
echo"<h3><font color=red>The File ($file) was deleted! <br> Please wait...</font></h3>";
echo "<meta http-equiv=Refresh content=1;url=index.php>";
}
if ( $action == del ){
del();
}





$cols = 2;

$i =1;

echo "<table width=100% border ='1' bordercolor='#3399FF' cellpadding='10' cellspacing='6'>
<tr>";

echo "<br><hr><center><b>Галерия</b></center><br>";
$opendir =opendir($upload_dir);

while ($file = readdir($opendir)) {

if($file != '..' && $file !='.' && $file !=''){

if (!is_dir($file)){


$imgsize = getimagesize ($upload_dir."".$file);


$file_size = filesize($upload_dir."".$file);

if ($file_size >= 1048576){
$show_filesize = number_format(($file_size / 1048576),2) . " MB";
}elseif ($file_size >= 1024){
$show_filesize = number_format(($file_size / 1024),2) . " KB";
}elseif ($file_size >= 0){
$show_filesize = $file_size . " bytes";
}else{
$show_filesize = "0 bytes";
}


$last_modified = date ("F d Y H:i:s", filemtime($upload_dir."".$file));


if ($imgsize[0] > 100){
$base_img = "<img src=\"$upload_dir$file\" border=\"0\" width=\"100\">";
}else{
$base_img = "<img src=\"$upload_dir$file\" border=\"0\">";
}

$ip = $_SERVER['REMOTE_ADDR'];

if ($ip == "91.139.155.16") {
$all_stuff = "Файлово име:<b> $file</b> <hr size=1>
<div style=\"width: 120px; height: 120px; z-index: 1; float: left; border: 1px dotted #C0C0C0\">
<a href=\"javascript:popimg('$upload_dir$file','$file', $imgsize[0], $imgsize[1],'white')\">
$base_img</a>
</div>
<p align=left>
Размер: $show_filesize<br>
Options: [<a title=\"Delete File\" href=\"javascript:;\" onClick=\"cf=confirm('Are you sure you want to delete?');if (cf)window.location='index.php?action=del&file=$file'; return false;\">Del</a>]<br>
Широчина : $imgsize[0] px
<br>Височина : $imgsize[1] px
<br>Дата на добавяне: $last_modified
<br><br>HTML Код:<input type=\"text\" size=60 value=\"<img src=http://bgsite.serveblog.net/test/images/$file>\"></input>
<br>BBCode: <input type=\"text\" size=60 value=[img]http://bgsite.serveblog.net/test/images/$file[/img]></input>

"; }

else { $all_stuff = "Файлово име:<b> $file</b> <hr size=1>
<div style=\"width: 120px; height: 120px; z-index: 1; float: left; border: 1px dotted #C0C0C0\">
<a href=\"javascript:popimg('$upload_dir$file','$file', $imgsize[0], $imgsize[1],'white')\">
$base_img</a>
</div>
<p align=left>
Размер: $show_filesize<br>
Options: [<a href=\"javascript:alert('Нямате достъп до тази опция!')\">Del</a>]<br>
Широчина : $imgsize[0] px
<br>Височина : $imgsize[1] px
<br>Дата на добавяне: $last_modified
<br><br>HTML Код:<input type=\"text\" size=60 value=\"<img src=http://bgsite.serveblog.net/images/test/$file>\"></input>
<br>BBCode: <input type=\"text\" size=60 value=[img]http://bgsite.serveblog.net/test/images/$file[/img]></input>

"; }



if (is_int($i / $cols)){
echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td></tr><tr>";
}else{

echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>";
}

$i++;
}
}
}
closedir($opendir);
clearstatcache();
echo "</tr>
</table>";

//print copyright ;)
echo "<p align=\"right\"><br></p>
</body>
</html>";
 

Back
Горе