Jump to content

BlackKite

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by BlackKite

  1. Hm, well now i have another error that i dont understand. Actually... i do but i dont know how to fix it ebcause all this code is starting to confuse me. :-\ Im pretty sure its refering to the temp file becuase I have yet to see it in my file directory, but im not sure becuase if it is creating it then unlink is deleteing it.. right? ??? [b]Error:[/b] [quote]Warning: ftp_fput() [function.ftp-fput]: Rename/move failure: No such file or directory in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52[/quote] [u][b]Line 52:[/b][/u] [code=php:0]ftp_fput($connection, $tempfile, $bandle, FTP_ASCII);[/code] [u][b]My Code:[/b][/u] [code=php:0]<?php         //Check for file existence; $ourFile = $_POST['title']; $filename = "/home/jaboo12/public_html/$ourFile"; if (file_exists("$filename")) {   echo "The file $filename already exists. Please hit the back button and choose a new one";   exit(); } else {   echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>"; }         //If it doesn't exist, login to FTP and chmod; ########################### # ftp settings            # $ftpServer='ftp.neohound.com'; //ftp server, without ftp:// $ftpPort=21;                //the ftp port (don't change if you don't know what it is) $ftpUser='XXXXXX';        //ftp username $ftpPass='XXXXXX';        //ftp password # end ftp settings        # ########################### ########################### # file settings          # $tempfile = '/home/jaboo12/public_html/temp.php'; $ftpdir = 'public_html'; $nav = 'public_html/index.php'; $file = '/home/jaboo12/public_html/$ourFile'; # end file settings      # ########################### //connect to server $connection = ftp_connect($ftpServer, $ftpPort); ftp_login($connection, $ftpUser, $ftpPass); //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $ftpdir); //make temporary file $handle = fopen("$tempfile", 'w'); fclose($handle); //upload file using ftp $bandle = fopen("$file", 'w'); ftp_fput($connection, $tempfile, $bandle, FTP_ASCII); fclose($bandle); //delete temporary file unlink($tempfile); $ourFileName = $_POST['name']; $ourLinkName = $_POST['link'];         //Post content feild to the file created; $myFile = "/home/jaboo12/public_html/$ourFile"; $fh = fopen("$myFile", 'w') or die("can't open file"); $content = $_POST['content']; $help = stripslashes ($content); $newcontent = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>'); fwrite ($fh, $newcontent); fclose($fh); //reset directory permissions ftp_chmod($connection, 0750, $ftpdir);         //Post navigation link on index; //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $nav); $newLink = "<br> » <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a> <!-- game -->"; $data = file_get_contents('/home/jaboo12/public_html/index.php'); $data = str_replace ('<!-- game -->', $newLink, $data); $fp = fopen ("/home/jaboo12/public_html/index.php", 'w'); fwrite ($fp, $data); fclose ($fp); //reset directory permissions ftp_chmod($connection, 0644, $nav); //close connection ftp_close($connection);  ?>[/code]
  2. 0.0 Ooh crap, lol, i forgot i had them in there. Removed/changed. Thanks lol, that could of been bad. And thanks for the help, i'll go see if it works.
  3. I have this script I wrote up as a php backend. But its throwing some errors i dont quite understand. Hope someone can help me fix this. Please [u][b]Error:[/b][/u] [quote] Originally Posted by Warning: ftp_fput() expects parameter 2 to be string, resource given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52[/quote] [u][b]Line 52:[/b][/u] [code] ftp_fput($connection, $bandle, $file, FTP_ASCII);[/code] [u][b]Whole Code:[/b][/u] [code=php:0]<?php         //Check for file existence; $ourFile = $_POST['title']; $filename = "/home/jaboo12/public_html/$ourFile"; if (file_exists("$filename")) {   echo "The file $filename already exists. Please hit the back button and choose a new one";   exit(); } else {   echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>"; }         //If it doesn't exist, login to FTP and chmod; ########################### # ftp settings            # $ftpServer='ftp.neohound.com'; //ftp server, without ftp:// $ftpPort=21;                //the ftp port (don't change if you don't know what it is) $ftpUser='XXXXXX';        //ftp username $ftpPass='XXXXXX';        //ftp password # end ftp settings        # ########################### ########################### # file settings          # $tempfile = '/home/jaboo12/public_html/temp.php'; $ftpdir = 'public_html'; $nav = 'public_html/index.php'; $file = '/home/jaboo12/public_html/$ourFile'; # end file settings      # ########################### //connect to server $connection = ftp_connect($ftpServer, $ftpPort); ftp_login($connection, $ftpUser, $ftpPass); //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $ftpdir); //make temporary file $handle = fopen("$tempfile", 'w'); fclose($handle); //upload file using ftp $bandle = fopen("$tempfile", 'r'); ftp_fput($connection, $bandle, $file, FTP_ASCII); fclose($bandle); //delete temporary file unlink($tempfile); $ourFileName = $_POST['name']; $ourLinkName = $_POST['link'];         //Post content feild to the file created; $myFile = "/home/jaboo12/public_html/$ourFile"; $fh = fopen("$myFile", 'w') or die("can't open file"); $content = $_POST['content']; $help = stripslashes ($content); $newcontent = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>'); fwrite ($fh, $newcontent); fclose($fh); //reset directory permissions ftp_chmod($connection, 0750, $ftpdir);         //Post navigation link on index; //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $nav); $newLink = "<br> » <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a> <!-- game -->"; $data = file_get_contents('/home/jaboo12/public_html/index.php'); $data = str_replace ('<!-- game -->', $newLink, $data); $fp = fopen ("/home/jaboo12/public_html/index.php", 'w'); fwrite ($fp, $data); fclose ($fp); //reset directory permissions ftp_chmod($connection, 0644, $nav); //close connection ftp_close($connection);  ?>[/code]
  4. Lol thats gay. Guess i'll be visiting the support system again. I dont even know what im asking them though. Anyone know exactly why this problem would be happening?
  5. For some reason the script I wrote up is causing the files it creates to not be editable in Cpanel. Cpanel gives the following error... [QUOTE]a fatal error or timeout occurred while processing this directive[/QUOTE] I really dont know if this is the script itself, the host i just moved to, or the current version of cpanel, but sice my other files i have that werent uploaded with the script work. So my guess is either the host or the script because i didnt have this problem before. [code]        //Check for file existence; $ourFile = $_POST['title']; $filename = "/home/USER/public_html/$ourFile"; if (file_exists("$filename")) {   echo "The file $filename already exists. Please hit the back button and choose a new one";   exit(); } else {   echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>"; }         //If it doesn't exist, login to FTP and chmod; ########################### # ftp settings            # $ftpServer='ftp.SITE.com'; //ftp server, without ftp:// $ftpPort=21;                //the ftp port (don't change if you don't know what it is) $ftpUser='USER';        //ftp username $ftpPass='PASS';        //ftp password # end ftp settings        # ########################### ########################### # file settings          # $dir='public_html'; $nav='public_html/index.php'; # end file settings      # ########################### //connect to server $connection = ftp_connect($ftpServer, $ftpPort); ftp_login($connection, $ftpUser, $ftpPass); //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $dir);         //Create file $ourFileHandle = fopen("/home/USER/public_html/$ourFile", 'w') or die("can't open file"); fclose($ourFileHandle); $ourFileName = $_POST['name']; $ourLinkName = $_POST['link'];         //Post content feild to the file created; $myFile = "/home/USER/public_html/$ourFile"; $fh = fopen("$myFile", 'w') or die("can't open file"); $stringData = $_POST['content']; $help = stripslashes ($stringData); $newStringData = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>'); fwrite ($fh, $newStringData); fclose($fh); //reset directory permissions ftp_chmod($connection, 0750, $dir);         //Post navigation link on index; //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $nav); $SData = "<br> » <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a> <!-- game -->"; $data = file_get_contents('/home/USER/public_html/index.php'); $data = str_replace ('<!-- game -->', $SData, $data); $fp = fopen ("/home/USER/public_html/index.php", 'w'); fwrite ($fp, $data); fclose ($fp); //reset directory permissions ftp_chmod($connection, 0644, $nav); //close connection ftp_close($connection);[/code] Thanks, -BlackKite
  6. Well I can... but that defeats the purpose. I want the script to change it to 777 and then change it back to 750 once complete becuase having yuor public_html at 777 always isn't safe. Why is it failing, is there an error in the script... something im missing or didnt set right?
  7. Ick... thats not working. Seems like I dont have the permission to set permissions via chmod()? I understand though, that theres a way to do it via an ftp connection? I've tried this but I can't quite get it to work. Im putting the following code in...[code]<?php $file = 'public_html/'; $ftp_user_name = "XXXXXXX"; $ftp_user_pass = "XXXXXXXX"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to chmod $file to 777 if (ftp_chmod($conn_id, 0777, $file) !== false) { echo "$file chmoded successfully to 777\n"; } else { echo "could not chmod $file\n"; } // close the connection ftp_close($conn_id); ?> [/code] But apparently this is wrong because I get the following error...[code]Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 22 Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 25 Fatal error: Call to undefined function: ftp_chmod() in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 28[/code]
  8. Aah, would make sense. Ok, I'll give it a try. Thanks ;)
  9. Is there a way to set it tp 777 and then drop it back to 755 using php? And yes I could have it so it creates files in a higher folder, but what if someone wants to put something in their main public_html folder.
  10. Hm... wow do I feel like a noob now. Aah well, here it goes. Im designing a open source control panel in php that allows you to create files and them have them listed on your site automatically without the hassle of going through cpanel (or whatever panel). It gives admin permission to add users so that they can have others add files also. But I'm having a problem that keeps appearing. Depending on if phpsuexec is installed or not directories have to be set to 777 or 755. I pretty sure its really unsafe to set files and folders to 777 , especially your public_html folder. Yet, in order to create a file in public_html I need to set it to 777 or i get a permissions error. Is there any way around this?
  11. Wow, im stupid. How did i not think of trying that?!? It worked, lol. Thanks alot! :)
  12. Hello! Ok this is sort of hard to explain but i'll do my best. I've got a php site backend script im developing. A part of the script is a page uploader in which you give the file a title, the page a name, type in the content of the page, and then select from a drop down option list where on the sites navigation column you want the link to be displayed. The problem is that I cant get navigation part to work correctly. I have it setup so that the script opens the index file, searches for a hidden html tag and then replaces the hidden tag with the link and a new hidden tag. In my eyes it looks like the hidden tag isn't being found and the scrip is just passing over that part becuase its not found. Here are the parts of code that are connected to my problem. Any help at all would be appreciated greatly. Thanks! Forms Drop List: [code]Navigation Spot:<br> <select name="navi"> <option value="nav1">1</option> <option value="nav2">2</option> <option value="nav3">3</option> </select>[/code] Php script that processes the this part of the form: [code]        //Post navigation link on index; $nav = $_POST['navi']; $SData = "<a href=\"index.php?id=$ourFileName\">$ourLinkName</a><br> <!-- $nav -->"; $data = file_get_contents("$dir/index.php"); $data = str_replace ('<!-- $nav -->', $SData, $data); $fp = fopen ("$dir/index.php", 'w'); fwrite ($fp, $data); fclose ($fp); [/code] Hidden tags on index.php page: [code]<!-- nav1 --> <br> <!-- nav2 --> <br> <!-- nav3 -->[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.