Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Problem, uppladdningsfunktion

Postades av 2005-10-13 21:44:47 - Marcus Wennerberg, i forum php, Tråden har 1 Kommentarer och lästs av 918 personer

Hej!
Hittade följande kod på nätet. Nu är det så att jag vill att alla uppladdade filer ska hamna i en egen mapp. Vad ska jag ändra på?


<HTML>
<TITLE>File Manager</TITLE>
<?PHP
global $HTTP_GET_VARS;

if(isset($HTTP_GET_VARS['dir']))
$DIRPATH = $HTTP_GET_VARS['dir'];

if(isset($HTTP_GET_VARS['what']))
$WHAT = $HTTP_GET_VARS['what'];

if(isset($HTTP_GET_VARS['save']))
$SAVEIT = $HTTP_GET_VARS['save'];

if(isset($HTTP_GET_VARS['tothis']))
$TOTHIS = $HTTP_GET_VARS['tothis'];

if(isset($HTTP_GET_VARS['dowhat']))
$DOWHAT = $HTTP_GET_VARS['dowhat'];

if(isset($HTTP_GET_VARS['downloads']))
$DOWNLOADS = $HTTP_GET_VARS['downloads'];

if(isset($HTTP_GET_VARS['images']))
$IMAGES = $HTTP_GET_VARS['images'];

if (!$DIRPATH)
$DIRPATH = "./";

if (!$WHAT)
filemanager ($DIRPATH, $SAVEIT, $TOTHIS, $DOWHAT, $DOWNLOADS, $IMAGES);

if ($WHAT == 1)
createhtml ($DIRPATH, $DOWHAT, $SAVEIT);

if ($WHAT == 2)
uploadfile ($DIRPATH, $SAVEIT);

function filemanager ($DIRPATH, $SAVEIT, $TOTHIS, $DOWHAT, $DOWNLOADS, $IMAGES)
{
if ($DIRPATH)
{
if ($DOWHAT == 1)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$thedir = "$DIRPATH$TOTHIS";

if (unlink ($thedir))
echo "File: $thedir was deleted successfully<br>";
else
echo "File: $thedir could not be deleted. BOooooo.<br>";
}

if ($DOWHAT == 2)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$thedir = "$DIRPATH$TOTHIS";

$file = fopen ($thedir, "rb");
while (!feof ($file))
$filestring = $filestring . fgets ($file, filesize ($thedir) + 1);

echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?what=0&dowhat=4&tothis=$TOTHIS&downloads=$DOWNLOADS&images=$IMAGES&dir=$DIRPATH\">";
echo "<center><textarea name = \"txtNEWS\" rows = \"20\" cols = \"60\" wrap = \"virtual\">$filestring</textarea><br>";
echo "<input type = \"submit\" name = \"cmdSUBMIT\" value = \"Save\"><br>";
echo "</FORM>";
fclose ($file);
}

if ($DOWHAT == 3)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$thedir = "$DIRPATH$TOTHIS";

$RENAMETO = stripslashes ($_POST["txtRENAME"]);

if (rename ("$DIRPATH$TOTHIS", "$DIRPATH$RENAMETO"))
echo "File: $DIRPATH/$TOTHIS was renamed to $DIRPATH/$RENAMETO<br>";
else
echo "File: $DIRPATH/$TOTHIS could not be renamed. BOoooo<br>";
}

if ($DOWHAT == 4)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$thedir = "$DIRPATH$TOTHIS";

$string = stripslashes($_POST["txtNEWS"]);

$file = fopen ("$DIRPATH$TOTHIS", "wb");
fwrite ($file, $string);
fclose ($file);

echo "File successfully saved.<br>";
}

if (!$DOWHAT)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$dir = opendir ("$DIRPATH");

while ($file = readdir ($dir))
{
$string = $file;
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?dir=$DIRPATH&what=0&dowhat=3&tothis=$file\">";
if (filetype ("$DIRPATH/$string") == 'dir')
{
echo "Directory: $string<br>";
switch ($string)
{
case ".":
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;View";
echo "<br>";
echo "<br>";
break;
case "..":
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;View";
echo "<br>";
echo "<br>";
break;
default:
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;View";
echo "&nbsp;&nbsp;Delete";
echo "&nbsp;&nbsp;Rename: <input type = \"text\" name = \"txtRENAME\" value = \"$string\">";
echo "<input type = \"submit\" name = \"cmdSUBMIT\" value = \"Rename\"><br><br>";
break;
}
}
}

closedir ($dir);

$dir = opendir ("$DIRPATH");

while ($file = readdir ($dir))
{
$string = $file;
if (!(filetype ("$DIRPATH/$string") == 'dir'))
{
echo "File: $string<br>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete";
echo "&nbsp;&nbsp;Edit";
echo "&nbsp;&nbsp;Rename: <input type = \"text\" name = \"txtRENAME\" value = \"$string\">";
echo "<input type = \"submit\" name = \"cmdSUBMIT\" value = \"Rename\"><br><br>";
}
echo "</FORM>";
}

closedir ($dir);
}
}
}

function createhtml($DIRPATH, $DOWHAT, $SAVEIT)
{
if (!$DOWHAT)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?dir=$DIRPATH&what=1&dowhat=6\">";
echo "Title of your page: <INPUT TYPE = \"text\" NAME = \"txtTITLE\"><br>";
echo "How do you want your page justified?";
echo "<select name = \"lstBANDS\">";
echo "<option>Left Justified</option>";
echo "<option>Centered</option>";
echo "<option>Right Justified</option>";
echo "</select><br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}

if ($DOWHAT == 1)
addimage ($DIRPATH);

if ($DOWHAT == 2)
addlink ($DIRPATH);

if ($DOWHAT == 3)
adddownload ($DIRPATH);

if ($DOWHAT == 4)
uploadimage ($DIRPATH);

if ($DOWHAT == 5)
addurl ($DIRPATH);

if ($DOWHAT == 6)
{
if ($TITLE = $_POST["txtTITLE"])
{
$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, "<HTML>\n");
fwrite ($file, "<TITLE>$TITLE</TITLE>\n");
fwrite ($file, "<body bgcolor = \"#0D3142\" text = \"#FFFFFF\" link = \"#97CBFF\" vlink = \"#C0C0C0\" alink = \"#FFFFFF\">\n");
fwrite ($file, "<center><font size = \"20\">$TITLE</font></center><br><br>\n");

if ($bah = $_POST["lstBANDS"])
{
if ($bah == "Left Justified")
fwrite ($file, "<p align = \"left\">\n");

if ($bah == "Centered")
fwrite ($file, "<center>\n");

if ($bah == "Right Justified")
fwrite ($file, "<p align = \"right\">\n");
}
fclose ($file);
}

mainthingy ($DIRPATH);
}

if ($DOWHAT == 7)
addtext ($DIRPATH);

if ($DOWHAT == 8)
adddownload2 ($DIRPATH);

if ($DOWHAT == 9)
addtext2 ($DIRPATH);

if ($DOWHAT == 10)
{
$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);
fwrite ($file, "&nbsp;");
fclose ($file);

mainthingy ($DIRPATH);
}

if ($DOWHAT == 11)
{
$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);
fwrite ($file, "<br>");
fclose ($file);

mainthingy ($DIRPATH);
}

if ($DOWHAT == 12)
{
}

if ($SAVEIT == 1)
SAVEFILE ($DIRPATH);

if ($SAVEIT == 2)
SAVEFILE2 ($DIRPATH);
}

function mainthingy ($DIRPATH)
{
$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&save=1&dowhat=12\">";
echo "<center>";
echo "Add Text&nbsp;&nbsp;&nbsp;";
echo "Add Image&nbsp;&nbsp;&nbsp;";
echo "Add Link&nbsp;&nbsp;&nbsp;";
echo "Add Download&nbsp;&nbsp;&nbsp;";
echo "Add a space&nbsp;&nbsp;&nbsp;";
echo "Add another line";
echo "<br>";
echo "HTML:<br><textarea name = \"txtNEWS\" rows = \"20\" cols = \"60\" wrap = \"virtual\">";
echo $string;
echo "</textarea>";
echo "<br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\"></center>";
echo "</FORM>";
}

function addimage ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "Click here to upload .gif/.jpg/.jpeg images to your webspace.<br>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=4\">";
echo "<INPUT TYPE = \"file\" VALUE = \"Browse\" NAME = \"cmdBROWSEIMAGES\"><br>";
echo "Go on to the next line: <input type = \"checkbox\" checked = \"checked\" name = \"chkNEXTLINE\"><br>";
echo "Use this image as a link: <input type = \"checkbox\" name = \"chkLINK\"><br>";
echo "If use this image as a link is checked in, what web site do you want the image to go to? (DO NOT ADD http://): http://<INPUT TYPE = \"text\" NAME = \"txtURL\"><br>";
echo "Is this link pointing to another page on this site? <input type = \"checkbox\" name = \"chkDB\"><br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\"><br>";
echo "</FORM>";
}

function uploadimage ($DIRPATH)
{
if(isset($HTTP_GET_VARS['who']))
$DIRPATH = $HTTP_GET_VARS['who'];

echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$urlman = $_POST["txtURL"];

$path = $DIRPATH . $_FILES ['cmdBROWSEIMAGES']['name'];
$date = getdate();

if (move_uploaded_file ($_FILES['cmdBROWSEIMAGES']['tmp_name'], $path))
{
echo "File was successfully transferred on ";
echo $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"];
echo "<br>This image was saved under your directory/images<br>";

$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);

if ($_POST["chkNEXTLINE"])
{
$stringmoo = "<br><img src = \"./images/" . $_FILES['cmdBROWSEIMAGES']['name'] . "\">\n";

if ($_POST["chkLINK"])
{
if ($_POST["chkDB"])
{
$stringmoo = "<br>\n";
}
else
{
$stringmoo = "<br>\n";
}
}
}
else
{
$stringmoo = "<img src = \"./images/" . $_FILES['cmdBROWSEIMAGES']['name'] . "\">\n";

if ($_POST["chkLINK"])
{
if ($_POST["chkDB"])
{
$stringmoo = "\n";
}
else
{
$stringmoo = "\n";
}
}
}

fwrite ($file, $stringmoo);

fclose ($file);

echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=6\">";
echo "<INPUT TYPE = \"submit\" VALUE = \"Back to your HTML page\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}
else
{
echo "File couldn't be transferred.<br><u>This is being logged as an attack on the server.</u><br>Contact Someone13 if this is in error, or else your IP will be traced.<br>Depending on what happened you may be reported to your ISP.<br>";

$file = fopen ("./holyshit.txt", "a");
fwrite ($file, "On " . $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"] . ":" . "\n");
fwrite ($file, "-------------------------------------\n");
fwrite ($file, "Transferred failed.\nThis may be a hacking attempt.\n");
fwrite ($file, $_FILES . "\n\n");
fclose ($file);
print_r ($_FILES);
}
}

function addlink ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=5\">";
echo "Web site (Without the http://): http://<INPUT TYPE = \"text\" NAME = \"txtURL\"><br>";
echo "What the link says: <INPUT TYPE = \"text\" NAME = \"txtSAYS\"><br>";
echo "Go on to the next line: <input type = \"checkbox\" checked = \"checked\"name = \"chkNEXTLINE\"><br>";
echo "Is this link pointing to another page on this site?: <input type = \"checkbox\" name = \"chkDB\"><br>";
echo "Thats all you have to type. You really dont even the http:// part<br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}

function addurl ($DIRPATH)
{
$urlman = stripslashes ($_POST["txtURL"]);
$urlsays = stripslashes ($_POST["txtSAYS"]);

echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

if ($urlsays == "")
$urlsays = $urlman;

$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);

if ($_POST["chkNEXTLINE"])
{
$stringmoo = "<br>$urlsays\n";

if ($_POST["chkDB"])
{
$stringmoo = "<br>$urlsays\n";
}
}
else
{
$stringmoo = "$urlsays\n";

if ($_POST["chkDB"])
{
$stringmoo = "$urlsays\n";
}
}

fwrite ($file, $stringmoo);

fclose ($file);

echo "Link added.";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=6\">";
echo "<INPUT TYPE = \"submit\" VALUE = \"Back to your HTML page\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}

function adddownload ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "Click here to upload .exe/.zip/.mp3 files that can be downloaded.";
echo "<FORM ACTION = \"./filemanager.php?dowhat=8&what=1&who=$DIRPATH\" METHOD = \"POST\" ENCTYPE = \"multipart/form-data\">";
echo "<INPUT TYPE = \"file\" VALUE = \"Browse\" NAME = \"cmdBROWSEDOWNLOADS\"><br>";
echo "Go on to the next line: <input type = \"checkbox\" checked = \"checked\"name = \"chkNEXTLINE\"><br>";
echo "File Name/Name of song: <input type = \"text\" name = \"txtFILENAME\"><br>";
echo "Description of the file:<br>";
echo "<textarea name = \"txtNEWS\" rows = \"20\" cols = \"60\" wrap = \"virtual\">Description of file goes here</textarea><br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\"><br>";
echo "</FORM>";
}

function adddownload2 ($DIRPATH)
{
error_reporting (0);

echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
$filename = stripslashes ($_POST["txtFILENAME"]);
$description = stripslashes ($_POST["txtNEWS"]);

$path = $DIRPATH . $_FILES ["cmdBROWSEDOWNLOADS"]["name"];
$date = getdate();

if (move_uploaded_file ($_FILES["cmdBROWSEDOWNLOADS"]["tmp_name"], $path))
{
if ($file2 = fopen ("../downloads/" . $_FILES["cmdBROWSEDOWNLOADS"]["name"] . ".php", "rb"))
{
while (!feof ($file2))
$descriptions = $descriptions . fgets ($file, filesize ("../downloads/" . $_FILES["cmdBROWSEDOWNLOADS"]["name"] . ".php") + 1);
}
fclose ($file2);

$file = fopen ("../downloads/$DIRPATH/" . $_FILES["cmdBROWSEDOWNLOADS"]["name"] . ".php", "wb");
fwrite ($file, "<?PHP\n");
fwrite ($file, " \$filename=\"" . $filename . "\";\n");
fwrite ($file, " \$description=\"" . $description . $descriptions . "\";\n");
fwrite ($file, "?>");
fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);

if ($_POST["chkNEXTLINE"])
fwrite ($file, "<br>$filename\n");
else
fwrite ($file, "$filename\n");

fclose ($file);

echo "File was successfully transferred on ";
echo $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"];
echo "<br>This file was saved under your directory under downloads.<br>";

echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=6\">";
echo "<INPUT TYPE = \"submit\" VALUE = \"Back to your HTML page\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}
else
{
echo "File couldn't be transferred.<br><u>This is being logged as an attack on the server.</u><br>Contact Someone13 if this is in error, or else your IP will be traced.<br>Depending on what happened you may be reported to your ISP.<br>";

$file = fopen ("./holyshit.txt", "a");
fwrite ($file, "On " . $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"] . ":" . "\n");
fwrite ($file, "-------------------------------------\n");
fwrite ($file, "Transferred failed.\nThis may be a hacking attempt.\n");
fwrite ($file, $_FILES . "\n\n");
fclose ($file);
print_r ($_FILES);
}
}

function addtext ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=9\">";
echo "Go on to the next line: <input type = \"checkbox\" checked = \"checked\"name = \"chkNEXTLINE\"><br>";
echo "Text:<br><textarea name = \"txtNEWS\" rows = \"20\" cols = \"60\" wrap = \"virtual\">";
echo "</textarea>";
echo "<br>";
echo "<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\"></center>";
echo "</FORM>";
}

function addtext2 ($DIRPATH)
{
$string2 = stripslashes ($_POST["txtNEWS"]);

echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

if ($string2 == "")
echo "You must enter something before going on.<br>";
else
{
$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("$DIRPATH" . "temp.txt", "wb");
fwrite ($file, $string);

if ($_POST["chkNEXTLINE"])
fwrite ($file, "<br>$string2\n");
else
fwrite ($file, "$string2\n");

fclose ($file);

echo "Text added.";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&dowhat=6\">";
echo "<INPUT TYPE = \"submit\" VALUE = \"Back to your HTML page\" NAME = \"cmdSUBMIT\">";
echo "</FORM>";
}
}

function SAVEFILE ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?who=$DIRPATH&what=1&save=2&dowhat=12\">";
echo "Save file as: <input type = \"text\" name = \"txtNAME\">&nbsp;";
echo "<INPUT TYPE = \"submit\" VALUE = \"Save\" NAME = \"cmdSUBMIT\"><br>";
echo "DO NOT ADD A FILE EXTENSION SUCH AS .HTML, .HTM, OR ANYTHING ELSE.<br>";
echo "Preview File";
echo "</FORM>";
}

function SAVEFILE2 ($DIRPATH)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
if ($_POST["txtNAME"])
{
$file = fopen ("$DIRPATH" . "temp.txt", "rb");

while (!feof($file))
$string = $string . fgets ($file, filesize ("$DIRPATH" . "temp.txt") + 1);

fclose ($file);

$file = fopen ("../$DIRPATH/" . $_POST["txtNAME"] . ".htm", "wb");
fwrite ($file, $string);
fwrite ($file, "<p align = \"left\">Back\n");
fwrite ($file, "</HTML>");
fclose ($file);

echo "File was successfully saved under $DIRPATH" . $_POST["txtNAME"] . ".htm<br>";
echo "<br>Have fun clicking the back button until you get back to the main menu!";
}
else
echo "You must enter a filename.<br><br>Use the browser's back button to go back.";
}

function uploadfile($DIRPATH, $SAVEIT)
{
if (!$SAVEIT)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";
echo "Click here to upload a file to: $DIRPATH";
echo "<FORM METHOD = \"POST\" enctype = \"multipart/form-data\" ACTION = \"./filemanager.php?what=2&save=1&dir=$DIRPATH\">";
echo "<INPUT TYPE = \"file\" VALUE = \"Browse\" NAME = \"cmdBROWSEHTMS\">&nbsp;<INPUT TYPE = \"submit\" VALUE = \"Submit\" NAME = \"cmdSUBMIT\"><br>";
echo "</FORM>";
}

if ($SAVEIT == 1)
{
echo "<center>Create a HTML file online&nbsp;&nbsp;Upload a file&nbsp;&nbsp;View your webspace</center>";

$path = $DIRPATH . $_FILES ['cmdBROWSEHTMS']['name'];
$date = getdate();

if (move_uploaded_file ($_FILES['cmdBROWSEHTMS']['tmp_name'], $path))
{
echo "File was successfully transferred on ";
echo $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"];
echo "<br>This file was saved under $DIRPATH.<br>";
}
else
{
echo "File couldn't be transferred.<br><u>This is being logged as an attack on the server.</u><br>Contact Someone13 if this is in error, or else your IP will be traced.<br>Depending on what happened you may be reported to your ISP.<br>";

$file = fopen ("./errors.txt", "a");
fwrite ($file, "On " . $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"] . " at " . $date["hours"] . ":" . $date["minutes"] . ":" . $date["seconds"] . ":" . "\n");
fwrite ($file, "-------------------------------------\n");
fwrite ($file, "Transferred failed.\nThis may be a hacking attempt.\n");
fwrite ($file, $_FILES . "\n\n");
fclose ($file);
print_r ($_FILES);
}
}
}
?>
</HTML>


hehe, blev en del ;)


Svara

Sv: Problem, uppladdningsfunktion

Postades av 2005-10-14 08:29:13 - Johan Jonsson

Med reservation för att det är morgon:

Raden: $path = $DIRPATH . $_FILES ['cmdBROWSEHTMS']['name'];
Lägg till ditt katalognamn emellan $DIRPATH och $FILES


Svara

Nyligen

  • 21:41 Automotive Services UK
  • 20:44 Erfarenhet av CBD-olja mot sömnpro
  • 12:13 Sex Dolls for Sale
  • 19:42 Online Casinos for Haitian Players
  • 19:38 Rekommendera något intressant
  • 19:13 Международная перевозка грузов
  • 00:01 DL Van Tuning | Exclusive Body Kit
  • 12:08 Indian casino

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 570 888
27 965
271 776
3 068
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies