OwenMelbz
Apr 27 2007, 03:39 PM
Right Im new here and stuggling with a problem im having. I've currently got a Login Script to login to a external ftp and it displays the folders contents, however i need it so it echos a specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as everything i do ends up trying to include the file from the webserver the script is hosted on and not the external ftp source. thanks Full Code Bellow CODE <html> <head> <title>Simple FTP Manager</title> <style> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; color: black; }
a { color: #666666; text-decoration: underline; }
a:hover { text-decoration: none; } </style> </head> <body> <?php /* Simple FTP Manager Programmed by Federico Ramírez ( fedekiller ) Copyright 2006 All Rights Reserved
NOTE: You must upload the file temp.txt in the same directory than this file, and CHMOD it to 777 */
$host = ''; $port = 21; $timeout = 10; $user = ''; $pass = ''; $secure = false; // If OpenSSL support is not active, this wont work, so change it to false
function clean ( ) { foreach ( $_REQUEST as $key => $val ) { $_REQUEST [ $key ] = stripslashes ( strip_tags ( htmlspecialchars ( $val, ENT_QUOTES ) ) ) ; $$key = stripslashes ( strip_tags ( htmlspecialchars ( $val, ENT_QUOTES ) ) ) ; } }
clean ( ) ;
if ( $secure ) { $con = ftp_ssl_connect ( $host, $port, $timeout ) ; } else { $con = ftp_connect ( $host, $port, $timeout ) ; }
if ( !$con ) { echo 'Could not connect to that host.'; }
if ( !file_exists ( 'temp.txt' ) || !is_writable ( 'temp.txt' ) ) // Checks if the temp file is there { die ( 'The temp file does not exists or is not writable' ) ; }
if ( @ftp_login ( $con, $user, $pass ) ) { if ( isset ( $_GET [ 'delete' ] ) ) { if ( isset ( $_GET [ 'fd' ] ) ) { ftp_delete ( $con, $_GET [ 'fd' ] .'/'.$_GET [ 'delete' ] ) ; } elseif ( isset ( $_GET [ 'subfd' ] ) ) { ftp_delete ( $con, $_GET [ 'fd' ] .'/'.$_GET [ 'subfd' ] .'/'.$_GET [ 'delete' ] ) ; } else { ftp_delete ( $con, $_GET [ 'delete' ] ) ; } } elseif ( isset ( $_GET [ 'download' ] ) ) { if ( isset ( $_GET [ 'fd' ] ) ) { ftp_get ( $con, 'temp.txt', $_GET [ 'fd' ] .'/'.$_GET [ 'download' ] , FTP_BINARY ) ; } elseif ( isset ( $_GET [ 'subfd' ] ) ) { ftp_get ( $con, 'temp.txt', $_GET [ 'fd' ] .'/'.$_GET [ 'subfd' ] .'/'.$_GET [ 'download' ] , FTP_BINARY ) ; } else { ftp_get ( $con, 'temp.txt', $_GET [ 'download' ] , FTP_BINARY ) ; } header ( 'Content-Disposition: attachment; filename=temp.txt' ) ; // To force the download readfile ( 'temp.txt' ) ; $fp = fopen ( 'temp.txt', 'w' ) ; fwrite ( $fp, '', filesize ( 'temp.txt' ) ) ; // After we write the data in the temp file we clean it fclose ( $fp ) ; } elseif ( isset ( $_GET [ 'upload' ] ) ) { if ( $_POST [ 'Submit' ] ) { $file = $_FILES [ 'file' ] [ 'tmp_name' ] ; $name = $_FILES [ 'file' ] [ 'name' ] ; $path = $_POST [ 'path' ] ; $upload = ftp_nb_put ( $con, $path.'/'.$name, $file, FTP_BINARY ) ; while ( $upload == FTP_MOREDATA ) { echo "."; $ret = ftp_nb_continue ( $con ) ; } if ( $upload != FTP_FINISHED ) { die ( 'There has been an error uploading the file' ) ; } echo 'File uploaded!'; } else { if ( isset ( $_GET [ 'subfd' ] ) ) { $path = $_GET [ 'fd' ] .'/'.$_GET [ 'subfd' ] ; } elseif ( isset ( $_GET [ 'fd' ] ) ) { $path = $_GET [ 'fd' ] ; } else { $path = '.'; } echo '<form action="?upload" method="post" enctype="multipart/form-data"> <table border="0"> <tr> <td>Upload a file </td> <td><input type="file" name="file" /></td> </tr> <tr> <td> </td> <td><input type="hidden" name="path" value="'.$path.'" /> <input type="submit" name="Submit" value="Upload!" /></td> </tr> </table> </form>'; } } else { $fd = $_GET [ 'fd' ] ; $subfd = $_GET [ 'subfd' ] ; if ( empty ( $fd ) ) { $contents = ftp_nlist ( $con, '.' ) ; echo '<h1>File List: ( '.ftp_pwd ( $con ) .' ) </h1>'; echo '<a href="?upload">Upload File</a><br />'; echo 'Go UP<br /><br />';
} elseif ( isset ( $_GET [ 'subfd' ] ) ) { $contents = ftp_nlist ( $con, $fd.'/'.$subfd ) ; echo '<h1>File List: ( '.ftp_pwd ( $con ) .$fd.'/'.$subfd.'/ ) </h1>'; echo '<a href="?upload&fd='.$_GET [ 'fd' ] .'&subfd='.$_GET [ 'subfd' ] .'">Upload File</a><br />'; echo '<a href="?upload&fd='.$_GET [ 'fd' ] .'">Go UP</a><br /><br />'; } else { $contents = ftp_nlist ( $con, $fd ) ; echo '<h1>File List: ( '.ftp_pwd ( $con ) .$fd.'/ ) </h1>'; echo '<a href="?upload&fd='.$_GET [ 'fd' ] .'">Upload File</a><br />'; echo '<a href="'.$_SERVER [ 'PHP_SELF' ] .'">Go UP</a><br /><br />'; } $files = array ( ) ; $folders = array ( ) ; foreach ( $contents as $c ) { if ( eregi ( '.', $c ) ) { $files [ ] = $c; } else { $folders [ ] = $c; } } echo '<strong>Folders:</strong><br />'; foreach ( $folders as $f ) { if ( !empty ( $fd ) ) { echo '<a href="'.$_SERVER [ 'PHP_SELF' ] .'?fd='.$fd.'&subfd='.$f.'">/'.$f.'</a><br />'; } else { echo '<a href="?fd='.$f.'">/'.$f.'</a><br />'; } } echo '<br /><strong>Files:</strong><br />'; foreach ( $files as $f ) { echo $f.' - <a href="?delete='.$f.'">Delete</a> - <a href="?download='.$f.'">Download</a><br />'; //echo '<textarea name="theText" cols="150" rows="20">'; include "server.cfg"; //echo "</textarea>"; } } echo '<div align="right">'.$host.' is powered by '.ftp_systype ( $con ) .'</div>'; } else { echo 'Sorry, username and password combination does not exists'; } ?> </body> </html>
Reply
friiks
Apr 27 2007, 10:33 PM
Um, if I'm getting right what you want to do then take a look here
Reply
OwenMelbz
Apr 27 2007, 11:51 PM
yh but wanted a bit more than that. I've actually finished the code now and is shown below CODE <? // BTW IM COMMENTING EVERYTHING FOR U echo "<title>Server Config Editor</title>"; //////////////////// // Teh Variables // //////////////////// $host = ''; // host - if u setup the database crap this will change according $port = 21; // ftp port, shudnt need to change $timeout = 10; // yh same aplies $user = ''; // setup database crap to set this to FTP username $pass = ''; // setup database so this is the FTP password $secure = false; // If OpenSSL support is not active, this wont work, so change it to false $con = ftp_connect ( $host, $port, $timeout ) ; //making the connect function smaller ////////////////////////////////////////////// if ( isset ( $_GET [ 'copy' ] ) ){ ////////////////////////////////////////////////// // PART ONE - Teh Legend Of Teh TempZ0R Filez /// ////////////////////////////////////////////////// $theText = $_POST["tehconfig"]; // name of the config edit field thing $theText = stripslashes($theText); // removes crap so form dnt *BLEEP*up $data = fopen("temp.txt", "w"); // opening the temp file fwrite($data,$theText); // putting the crap inside it fclose($data); // closing the whole thing echo "<script type=\"text/javascript\"> function delayer(){ window.location = \"?process\" } </script> <body onLoad=\"setTimeout('delayer()', 3000)\"> Processing Server Config This May Take A Few Seconds...</body>";} elseif ( isset ( $_GET [ 'process' ] ) ){ ////////////////////////////////////////// // PART TWO - TEH UPLOADING OF TEMPZOR /// ////////////////////////////////////////// function clean ( ){ //making suer no left overs foreach ( $_REQUEST as $key => $val ){ // looking around $_REQUEST [ $key ] = stripslashes ( strip_tags ( htmlspecialchars ( $val, ENT_QUOTES ) ) ) ;// converting the *BLEEP* $$key = stripslashes ( strip_tags ( htmlspecialchars ( $val, ENT_QUOTES ) ) ) ;}} // making it smaller clean ( ) ; //finish the cleaning if ( @ftp_login ( $con, $user, $pass ) ) {// if login to ftp actually works $path = "./"; //might need to play with for differnt games $upload = ftp_nb_put ( $con, "server.cfg", "temp.txt", FTP_BINARY ) ; //uploading the temp file to ftp and renaming it to server.cfg while ( $upload == FTP_MOREDATA ) {//while teh upload is going play around with the left over data echo "."; // <-- dno why $ret = ftp_nb_continue ( $con ) ;}// carry on the ftp connection if ( $upload != FTP_FINISHED ) {//onces the ftp proccess has done die ( '=/ file didnt upload- go bug Lee' ) ;} //if it failed say this echo 'Server Config Updated<p>'; }// once it worked say this else { echo 'LAWLS DIDNT LOGIN RIGHT'; }// finished part of the login if it didnt login say that echo "<a href='index.php'>BACK</a>"; }// just a link back a page else{ echo '<form method="post" action="?copy"><textarea name="tehconfig" cols="70" rows="20">'?><?php include ("ftp://$user:$pass@$host/server.cfg"); ?><? echo'</textarea> <br> <input type="submit" name="submit" value="Update Config"> </form>';} //////////////////////////////////////////////////// // Teh End - I think it will be worth a tennner xD / ////////////////////////////////////////////////////?> 
Reply
Recent Queries:--
local javascript external ftp - 206.81 hr back. (1)
Similar Topics
Keywords : edit, txt, file, ftp, webpage, file, external, ftp
- Internal File Transfer
(5)
External History And Favorites
how to put them on a flash drive (0) i installed FF3 (which works great) on my flash drive for testing perposes (web desighning). anyways
yesterday at school since i had time i went to the library to use it but i realise that my history
and bookmarks where not saved on the flash even though i imported (duh i know they're on my hard
drive). i'd like to know how can i put my history and favorites (or at least my favorites) on
my flash drive and how to make sure that the browser knows that and that's what it uses not the
one on the hard drive. thank you /laugh.gif" style="vertical-align:middle" ....
1350 Great Free Logos (jpg + Psd)
With both jpg and original psd files to edit (7) 1350 Great Free Logos (With both jpg and psd files)
http://rapidshare.com/files/126291346/1346...Great.Logos.zip This is a great collection of
logos, they are already made logos which you can use like that or just use to create other logos, do
what you want, they are free, they came from free websites that give this logos for free and lot
more, but i just took the good ones mainly. There is also a small collection of 100 logos inside
the compressed file, which you can use to insert those graphics in your logo/design/web design
projects, do what you want with them ....
Free Software For File Recovery
RECUVA (3) Hi all, I was loking for a software to recover my lost files and I found this /biggrin.gif"
style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> And the best part is ,
its free Recuva - File Recovery Recuva (pronounced "recover") is a freeware Windows utility to
restore files that have been accidentally deleted from your computer. This includes files emptied
from the Recycle bin as well as images and other files that have been deleted by user error from
digital camera memory cards or MP3 players. It will even bring back files that have been d....
Where Is The Bookmarks File Stored With Ff2?
(4) My bookmarks are critical and lengthy. I'd like to save them to a flash drive, since my laptop
is ancient and it's been acting up lately. I went into the FireFox folder, but couldn't find
the bookmarks info anywhere. there's a bookmarks.html page, but it doesn't contain the
actual bookmarks. Where does FF2 store the bookmarks? Or is there an easier way to copy and paste
the bookmarks to another file? /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
alt="huh.gif" /> 2 poor 4 a sig ....
Debug Exe Files
How to debug an exe file. (4) Think that we have written a program, and some codes are wrong. We can go back to compiler and
change the code, and compile again. But I will show you how to correct our mistakes without using
the compiler. Let's start: I have written a program in Delphi. Let's see my mistake. I
have created a form like this. After this I wrote the codes in the Compare Button click as
below. CODE 1. procedure TForm1.ComparebuttonClick(Sender: TObject); 2. var
3. a,b:integer; 4. begin 5. a := StrToInt(EditA.Text); 6. b :....
File Manager Not Working
(2) When I goto upload files using the file manager(legacy mode), the files do not upload correctly.
Every time I try to upload a file, it takes the time to upload it, but the file always comes out
being 0kb so it does not upload the file. Why is this happening?....
Flash Media Into Html/css Website
does anyone know how to import a flash into a webpage with transparenc (1) Hi I need some help , Im designing this website for school studies However, I made a flash drop down
menu, works perfectly, but you know how flash has a background when you export it in to a SWF file?
For example my flash is width= 800, and height = 200 but my div box on my html page for my
navigation is only 50 px my buttons is width of 50px and the rest of the content is the drop down
animations i want to insert it into my navigation div box but i want to set the flash background to
transparent so that when the drop down menu comes down it overlaps the text or whateva....
A Good File Explorer For Windows Xp?
what's a better alternative to explorer (6) Hi, although it has some useful features and it's (i'd hope so...) well integrated with the
shell, the file explorer that comes with windows xp is not the best we can ask for... so I've
always tried to use various other pieces of softwares randomly found on the net whenever I've
had to intensively work on my file directory... still I haven't found a very good one, all
those I tried have some kind of bug or they are not really user friendly in some occasions... would
anyone suggest a good FREEWARE file explorer? thanks /wink.gif" style="vertical-al....
Defraggler - Free Software To Defrag Your File
Try it out (12) Have you all hear a software called Defraggler? Well if not, I recommend you to download this
software. What does it do? Simple, it'll quickly defrag files you want to defrag, no need to
defrag the whole drive. Useful if you have less fragmented file and if you hate Windows's
original defragger. And it's free! OS Supported and filesystem supported? All Windows 2000
or higher (it'll be Windows 2000, 2003, XP and Vista. 64-bit support too) It support NFTS and
FAT32 Requirement? Well not much, the EXE file even smaller than 1 MB (dont judge the power ....
Qoodaa Successfully Solved Video Downloading Problems
a good large file transfer tool, (0) The rise of Video web stimulates more intuitive video feeling of large people, and makes video
downloading become a popular trend in web times. Meanwhile, more and more downloading problems arise
correspondingly, in which the first trouble is slow downloading speed and incomplete downloading. It
seems to many people that downloading video, especially downloading large video, is like a
protracted war with the internet, even the victory is difficult to predict. Many domestic video web
has succesesfully solved downloading problems that they suffered for a long time, after....
Make A Moderately-secure Password System Using Javascript
using file redirection to hide the password. (4) JavaScript is very handy at making forms, allowing for much more customization and easier ways to
send data. So making Login forms using JavaScript may seem to many to be a very feasable idea.
However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and
the whole JavaScript code is in the page, a person could just view the Page Source and find out
everything. Even if you use an external JavaScript, it would still be poor as the file name for the
external JavaScript would still be revealed. But I have an answer! There is a rela....
Php Configuration File
"config.php" (16) I did create this topic mainly because I want to know everything about that configuration file. I
will post other replies if I want to know more depending on your experience. Is this code correct
for that file: CODE <? $host="localhost"; $dbname="XXX";
$dbuser="XXX"; $dbpass="XXX";
$connection=mysql_connect($host, $dbuser, $dbpass) or
die(mysql_error()); mysql_select_db($dbname) or
die(mysql_error()); ?> Add your suggestions or i....
Question Regarding File Transfer!
FILE TRANSFER (4) Hi friends, I am looking for a secure and robust file transfer web service. I am handling a sales
force which is stationed at different locations and is frequently moving. They need to upload there
activity reports frequently to our servers. So I am looking for an easy to use secure and robust
file transfer web service which can be used by my sales force for their needs. Thanks & Warm
Regards. ....
Problem With My External Hard Disk
(7) I have a Sony VAIO 100GB External Hard drive that has recently been acting up. I got it from eBay
about 8 months ago. Yesterday I accidentally pulled the plug on it and I accidentally used windows
vista (which currently has no anti-virus program). Today when I turned on the computer it said
'Unable to write to disk, please make sure that the device is plugged in' I did the
'safely remove hardware' thing, but then the computer became really slow... So I waited and
waited... for 6 minutes, then I waited long enough and pulled the plug. I tried to restar....
Windows Ntfs Folder And File Compression. Good Or Bad?
(6) I believe everyone in this forum knows what a file system means and that every windows user knows
what FAT and NTFS means so I am not gonna start going into those. Well, the NTFS (Windows NT file
system) offers a few advantages over the good ol' FAT (File allocation table) file system one of
which is the files and folders compression. This I have done quite a number of times to save disc
space (and it really does save some disc space). i am using my computer as an example here. Consider
my 35GB partition which is carrying my Windows Vista Operating sys and has less ....
Hate Trying To Do File Sharing On Vista
(2) i've had this attempt before with no luck now i'm going to try again! now that i got my
two laptops (laptop1 - Vista, laptop2 - XP) wirelessly connected, i still can't see each
others shared files... i tried this before with my PC (XP) and laptop (Vista) now i have to make
this work because i have some files needed to be transfered between them... i have gone through
the manual process of anabling file sharing blah blah through here
http://www.microsoft.com/technet/network/e...e/vista_fp.mspx
http://www.home-network-help.com/simple-file-sharin....
Test Our New Free File Hosting! The Fastest In The World! Check It :)
(12) Another freebie guys, and it certainly rocks! /smile.gif" style="vertical-align:middle"
emoid=":)" border="0" alt="smile.gif" /> We launched the new Free File Hosting files-upload.com –
check the speed! Take out anything you like, no limitation at all. http://files-upload.com ....
Read File (.txt) On Another Website Using Jsp?
(3) in my jsp program,i need to read a file (.txt) on another website,how can i do this? thanks a lot.
shorten title ....
A Trap17 How-to Guide For Beginners
Something for those who can't get enough of the Trap17 Readme file (12) I am not entirely sure if this the right place to post about this, but here goes anyway... For
those who find themselves slightly (or considerably more than slightly) clueless about where to get
started after getting a hosting account, here is an user guide that might potentially help you
out. I wrote it out of three hours, so forgive me if it's clumsy, but I'm hoping that a few
people here may find it useful. Feedback is greatly appreciated /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm planning to build on
a FAQ....
How To Open A .daa File
(37) Hi there, How do i have to open a file with extension .daa Somebody told me to copy it on cd and to
run it from cd rom but i got the same problems. What dp i need to do to ppen the file? Thanks....
Linux Question: Amarok And File Permissions
please help, i can't get it to work with all music files (4) hey, i use to use Linux DC++ to download music from some hubs and i usually download it to
/home/downloads/ and then i move the files to my collection on another HDD a sata one, on
sda3/music/ but when i move the files using krushader root mode they become posessed by root and
amarok can't play them displaying a locker on the file's icon. I tried to " chmod 774 music
", where music is my music directory, as root in konsole but no luck. What should i do to make a
whole directory accessible from amarok as user?....
How To Put Music In The Background Of A Powerpoint Presentation
without having the viewer download the music file (9) Well, i made this power poit presentation in memory of my grandfather as many of you kno, passed
away exactly a week ago....and i am trying to get this song to play as background music..and i did,
but there is one humongus problem... in order for the people who are viewing it to hear the
background music they have to download the music file as well ad the powerpoint presentation, which
on my DSL conntection taked almost 2 minutes, and i could just imagine what it will be for a dial-up
user (my grandma who wants to see it)... Some people may say, its impossible, but i kn....
Simple C File Handling In Action
Small code snipet which covers most of basic file handling and navigat (3) Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
formalities to get the code review incorporated and update all source code files with code review
headers. Imagine if you need to open 300 files one by one and append code review headers at the
end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
utility to open all files passed on command line and open attach code review headers an....
How To: Make A Simple Php Site
Making one file show up on all pages using php (21) I have looked all over the site and could not find anything that was like this simple, or just like
this at all.. For some people i know that you are using a basic HTML site...and having a big menu
if you want to add somthing you have to go into every one of the pages and add or remove or edit
what you want to do, but with somthing verry simple all you would have to do is edit one file, and
all of the pages that have the PHP script on them would suddenly change to what that one file is.
So to start off if you are planning on using this little tirck, the page that you a....
Transfer File Of Any Size Using Winsock Control
Winsock Help (5) This tutorial shows how to transfer file of any size using winsock control. - Open VB; - Select
standard exe; - Press Ctrl + t to show the add component window; - Select winsock control and
microsoft common dialog; - Add one winsock control in the project; - Name it winsock1; - If you want
to add chat then add another winsock and name it winsock2; - Insert another winsock object if you
want to add chat also; - Add a microsoft common dialog box; - Name it cd; - We will use this
winsock1 object to transfer the file and winsock2 for chat; ------------- The basic idea : ....
Auto Webpage Resolution Format
Viewing Problem Help Needed Please (7) Hi, my website was created with Frontpage 2003. At screen resolution 1024 * 768. Now the problem
that I am finding is people with a screen resol. 800 * 600 see the table and everything in the wrong
place and its all messed up. Is there a way to make it so the site is compatiable with all screen
resolutions. Thanx in advance for your help. Edited topic title. ....
Import From Excel File Into Mysql Database
(7) Has anyone tried using the excel import function that comes with phpmyadmin
http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
to import the data to , there is a link on the bottom left corner which says "insert data from a
text file into the table" - although it says text file it still can be used to import an excel file.
When you click on this link you will be taken to a page where you will be asked for the file name
(the....
My File Manager Is Working
(2) I tried to change the html for my site in file manager but it just has the default page - the one
when you activate your site. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' />
How do i change files?....
500 Mb Free File Host!
http://www.spread-it.com/ (18) Spread-It is a great, no nonsense file host. I've been looking extensively at free file hosts
and most are up to 100 mb or something along those lines. The bigger ones for some reason are
usually Japanese, but this a totally free, no registration file host for anything up to 500 mb. The
only catch is that if it's not donwloaded once in 14 days it get's deleted. But other than
that they claim it's hosted forever. http://www.spread-it.com/ ....
Looking for edit, txt, file, ftp, webpage, file, external, ftp
|
|
Searching Video's for edit, txt, file, ftp, webpage, file, external, ftp
|
advertisement
|
|