Interesting question, I don't know. The phpinfo output doesn't show anything about suexec.
I think this is the way to solve the problem:
Execute the script that creates the test file but don't create the test file before executing the script so that the script creates the file itself (delete the file if it already exists). Then check which permissions the file has and use those permissions.

Thomas

    Interesting, PHP creates the files with permissions that prevent the further use of the files. Modify the script so that it changes permissions to 666 after writing to the file and then try to write to the file again and look how permissions change (if they change at all after writing the second time).

      i apologize for my sudden exit from this thread, but i had some issues I had to attend to, I've returned and am ready to continue anew.

      test.php
      <?PHP
      ini_set("display_startup_errors","On");
      ini_set("display_errors","On");
      
      $fp = fopen("mytestfile.txt","w");
      chmod("mytestfile.txt", 0666);
      
      if ($fp !== false) {
        fwrite($fp, "test");
        fclose($fp);
      } else {
        echo "couldn't create test file";
      }
      ?> 
      

        ok now, it's at least trying to do the script. i'm going to try a few more things here see what happens. basically combine all the different scripts into one... see what happens.

        essentially it's skipping all the php scripts that are on the page and only printing out the html to the the page, it's supposed to create two files and it's not doing that either.

          Try this one:

          <html>
          <head>
          <title>The title</title>
          </head>
          <body>
          <?PHP
          ini_set("display_startup_errors","On");
          ini_set("display_errors","On");
          
          echo "trying to create mytestfile2.txt<br>\n";
          
          $fp = fopen("mytestfile2.txt","w");
          
          if ($fp !== false) {
            fwrite($fp, "test\n");
            fclose($fp);
            chmod("mytestfile2.txt", 0666);
          } else {
            echo "couldn't create test file";
          }
          
          $fp = fopen("mytestfile2.txt","a+");
          
          if ($fp !== false) {
            echo "modifying mytestfile2.txt<br>\n";
            fwrite($fp, "test2\n");
            fclose($fp);
            chmod("mytestfile2.txt", 0666);
          } else {
            echo "couldn't create test file";
          }
          
          ?>
          </body>
          </html> 
          

          Additionally in a second step modify the script and remove the second chmod to check how the modified file looks like after the second fwrite without changing permissions. The file should contain two lines (test and test2).

          Thomas

            ok, so here's the code for my new form1.php
            <?PHP
            ini_set("display_startup_errors","On");
            ini_set("display_errors","On");
            ?>

            <?PHP
            echo "a b c d e f g h j k l m n o p q r s t u v w x y z";

            if (function_exists("file_put_contents")) {
            	echo "file_put_contents available";
            } else {
            	echo "file_put_contents missing";
            }
            $fp = fopen("mytestfile.txt","w");
            chmod("mytestfile.txt", 0666);
            
            if ($fp !== false) {
            	fwrite($fp, "test");
            	fclose($fp);
            	echo "file created";
            } else {
            	echo "couldn't create test file";
            }
            echo "a";
            $fp = fopen("form1.txt","w");
            chmod("mytestfile.txt", 0666);
            
            $filename = "form1.txt";
            echo "my filename="$filename;
            if (is_writable($filename)) {
            	echo "The file is writable";
            	file_put_contents("form1.txt", $_POST["id"] $_POST["email"], FILE_APPEND);
            } else {
            	echo "The file is not writable";
            }
            echo "hello";

            ?>

            essentially i want it to crap out to the screen a few lines, and generate two files. one should have the contents from the previous page's two text boxes the other should just read test on the inside of it, and well it's not working. shows me with a blank screen and it doesn't generate any files.

              tsinka wrote:

              Try this one:

              <html>
              <head>
              <title>The title</title>
              </head>
              <body>
              <?PHP
              ini_set("display_startup_errors","On");
              ini_set("display_errors","On");
              
              echo "trying to create mytestfile2.txt<br>\n";
              
              $fp = fopen("mytestfile2.txt","w");
              
              if ($fp !== false) {
                fwrite($fp, "test\n");
                fclose($fp);
                chmod("mytestfile2.txt", 0666);
              } else {
                echo "couldn't create test file";
              }
              
              $fp = fopen("mytestfile2.txt","a+");
              
              if ($fp !== false) {
                echo "modifying mytestfile2.txt<br>\n";
                fwrite($fp, "test2\n");
                fclose($fp);
                chmod("mytestfile2.txt", 0666);
              } else {
                echo "couldn't create test file";
              }
              
              ?>
              </body>
              </html> 
              

              Additionally in a second step modify the script and remove the second chmod to check how the modified file looks like after the second fwrite without changing permissions. The file should contain two lines (test and test2).

              Thomas

              Trying it now

                that worked fine, no issues geneated output to standard and "testtest2" to the myfile2.txt

                so, why in the world isn't it accepting things from my simple form?

                  ok basically i took your code there and added the two from the HTML form. here is the extra if statement i added after the test2 if in the above file.

                  $fp = fopen("mytestfile2.txt", "a+");

                  if ($fp !== false) {
                  echo "modyifying mytestfile2.txt<br>\n";
                  fwrite($fp, "ID='$POST["id"]' email='$POST["email"]'");
                  fclose($fp);
                  chmod("mytestfile2.txt", 0666);
                  } else {
                  echo "couldn't create test file";
                  }

                  this takes me back to a white screen again. so i'm thinking that it's probably not on this side, but rather the HTML form side, which hasn't been changed at all as of yet, here's the code for it.

                  <html>
                  <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                  </head>
                  <body>
                  <form id="form1" action="form1.php" method="post">

                  	ID:
                  	<input type="text" name="id" value="ID" />
                  	<br />
                  	Email:
                  	<input type="text" name="email" value="email" />
                  	<br />
                  	<input type="submit" value="Submit" />
                  </form>

                  </body>
                  </html>

                  http://www.mindimaging.com/form1/gentest.php is the name of the file for your script, http://www.mindimaging.com/form1/form1.php is the modified version where http://www.mindimaging.com/form1/form21.html is the original html file

                    Just to check if anything is wrong:

                    Modify the form so that it posts to e.g. test.php and create a file test.php that looks like:

                    <?PHP
                    print_r($_POST);
                    chmod("mytestfile2.txt", 0666);
                    $fp = fopen("mytestfile2.txt", "a+");
                    
                    if ($fp !== false) {
                    echo "modyifying mytestfile2.txt<br>\n";
                    fwrite($fp, "ID='".$_POST["id"]."' email='".$_POST["email"]."'\r\n");
                    fclose($fp);
                    } else {
                    echo "couldn't create test file";
                    }
                    ?>
                    

                    To test if the form submission works at all create a script that just contains

                    <?PHP
                    print_r($_POST);
                    ?>
                    

                    Make sure that the php scripts you create don't have 0777 permissions because that will cause the premature end... error, too.

                    The fwrite line in your last post contains a syntax error because of the the $_POST arrays inside the string with double quotes.

                    Thomas

                      So as a quick solution add a @chmod line in front of every line that creates or modifies a file. That's really ugly. I'd suggest to check why php creates new files with a permission of 0777. Maybe a silly umask setting. What are the permissions of the directory in which php creates the file(s) ? Delete the test file and let php create the file then check the owner and group of the file and post that info.

                      Besides that it might be neccessary to contact your hoster in order to get an idea why files are created with 777 permissions.

                      Thomas

                        it created them as 777, i'm going to ask my host why

                        Thank you very much for the help you've provided to me! really it's meant a great deal.

                          Write a Reply...