Jump to content

permissions question


knight47

Recommended Posts

ok I have a php file that simply creates a html file, but whats different is that this php file is in the public_html folder, (usually, when I have a script that generates a file that is inside a folder, I set the folder to 777, and the file to 755). I currently have the settings for the file at 777 (it is password protected), but when I try to generate a file, it says:

 

Warning: fopen(testsdf.htm) [function.fopen]: failed to open stream: Permission denied in /home/sbai/public_html/test.php on line 113

 

What permission should it be at??

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/
Share on other sites

I think the password protection is the problem...take that off and try again?

well, it's password protected by another php file.

 

this is how I have it set up:

 

login.html - you login with a username and pass

then login.php - if the login info is correct, it "echos" another form, this new form is linked to another php file, which generates the html file.

 

so in total there are 3, including 1 html file with just a login form.

 

hope that made sense. if you need me to i can post the code

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/#findComment-181767
Share on other sites

here is the code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Please Login...</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style></head>

<body>
<div align="center">
  <p class="style1">Please Login...</p>
  <form id="form1" name="form1" method="post" action="login.php">
    <label><span class="style1">Username:<br />
      <input name="name" type="text" id="name" />
      <br />
      Password:<br /> 
      <input name="pass" type="text" id="pass" />
    </span></label>
    <span class="style1"><br />
    </span><br />
    <label>
    <input type="submit" name="Submit" value="Create" />
    </label>
    <br />
  </form>
  </div>
</body>

</html>

 

login.php:

 <?php

  if ($_POST['Submit'] && $_POST['name'] == "username" && $_POST['pass'] == "password")
  
{
  echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<title>Create a Video page</title>
<style type=\"text/css\">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
-->
</style>
</head>

<body>
<form action=\"gen.php\" method=\"post\" name=\"form1\" class=\"style1\" id=\"form1\">
  <label>
  <div align=\"center\">
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p>Page Link:<br />
      <input name=\"link\" type=\"text\" class=\"style1\" id=\"link\" />
    </p>
  </div>
  <p align=\"center\">
    <label>Page Title:<br /> 
    <input name=\"title\" type=\"text\" class=\"style1\" id=\"title\" />
    </label>
  </p>
  <p align=\"center\">
    <label>
    YouTube or Google Code:<br />
    <input name=\"code\" type=\"text\" class=\"style1\" id=\"code\" />
    </label>
  </p>
  <p align=\"center\">
    <label>Description:<br />
    <textarea name=\"desc\" cols=\"49\" rows=\"5\" class=\"style1\" id=\"desc\"></textarea>
    </label>

    <label></label>
  </p>
  <p align=\"center\">
    <label>
    <input name=\"create\" type=\"submit\" class=\"style1\" id=\"Create!\" value=\"Submit\" />
    </label>
  </p>
</form>
</body>
</html>";
}
else { echo "Sorry, wrong password."; }
  ?>

 

and gen.php

<?php

// variable swap
$link = $_POST['link'];
$title = $_POST['title'];
$code = stripslashes($_POST['code']); // needs to be cleaned out!
$desc = $_POST['desc'];



$site_code = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html xmlns=\"undefined\">
<head>
<link rel=\"shortcut icon\" href=\"http://www.sbai.xenweb.net/index_files/images/favicon.ico\" />

<title>$title </title>
<meta name=\"description\" content=\"\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"index_files/style.css\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><style type=\"text/css\">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.style3 {
font-size: 24px;
font-weight: bold;
}
-->
</style></head>

<body bgcolor=\"#FFFFFF\">
<div id=\"fw-window\">
  <div style=\"background-color: rgb(69, 127, 201);\" id=\"fw-window-col\">
    <div style=\"display: none;\" id=\"fw-search\">
      <table>
        <tbody>
          <tr>
            
          </tr>
          <tr> </tr>
        </tbody>
      </table>
    </div>
    <div style=\"display: none;\" id=\"fw-thumbs\"> </div>
  </div>
</div>
</div>
<div class=\"fw-container\"><div class=\"fw-head\">
<div class=\"fw-home-link\"> <a href=\"#\">Home</a> </div>
  </div>
  <div class=\"fw-nav-menu\">
    <ul>
       <li><a class=\"section\" href=\"index.htm\">Home</a></li>
      <li><a class=\"section\" href=\"pictures.htm\">Pictures</a></li>
      <li><a class=\"section\" href=\"videos.htm\">Videos</a></li> 
        <li><a class=\"section\" href=\"downloads.htm\">Downloads</a></li>	
      <li><a class=\"section\" href=\"experiments.htm\">Experiments</a></li>
      <li><a class=\"section\" href=\"/forum\">Forum</a></li>
   <li><a class=\"section\" href=\"http://www.knight47.com/store\">Store</a></li>
    </ul>
    <hr>
  </div>
  <div class=\"fw-with-mini fw-content\">
    <div class=\"fw-paragraph\">
      <h2 align=\"center\">$title </h2>
      <div class=\"fw-text\">

        <div align=\"center\">
          <table width=\"40%\" border=\"0\" cellspacing=\"5\" cellpadding=\"5\">
            <tr>
              <td> $code </td>
            </tr>
          </table>
          <p>$desc </p>
          <p> <script src=\"http://www.knight47.com/index_files/comments.js\"></script></p>
          <p><br>
            <!-- ParagraphBodyEnd -->
          </p>
        </div>
      </div>
    </div>
  </div>
  <div class=\"fw-footer\">
    <hr>
    <p align=\"center\">knight47 ©</p>
  </div>
  <div class=\"fw-tracker\">
    <div align=\"center\">site created by riad sbai <a href=\"#\" onClick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.sbai.xenweb.net');\"></a></div>
  </div>
</div>
<script src=\"http://www.knight47.com/index_files/urchin.js\" type=\"text/javascript\">
</script>
<script type=\"text/javascript\">
_uacct = \"UA-492454-1\";
urchinTracker();
</script>
</body>
</html>";

$file = $link . ".htm";

if ($_POST['create'] && !file_exists($file))
{
    $create = fopen($file, 'w') or die("Hm... There seems to be a problem, I hope you didn't break anything!");
    fwrite($create, $site_code);
    fclose($create);
}
else { echo "oops, i think you have already created a file that already exists, OR your not supposed to be here! GET OUT!!!...";
echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.knight47.com/create/' . $file . '>';
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/#findComment-181781
Share on other sites

it's at the very end:

 

$file = $link . ".htm";

if ($_POST['create'] && !file_exists($file))
{
    $create = fopen($file, 'w') or die("Hm... There seems to be a problem, I hope you didn't break anything!");
    fwrite($create, $site_code);
    fclose($create);
}
else { echo "oops, i think you have already created a file that already exists";	

echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.knight47.com/create/' . $file . '>';
} 

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/#findComment-182018
Share on other sites

Instead of having to scape all those quotes and other stuff try this method:

<?php
  if ($_POST['Submit'] && $_POST['name'] == "username" && $_POST['pass'] == "password") {
?>
<html>
<body>
 This is a bit easier to read
</body>
</html>
<?php
  } else {echo "Sorry, wrong password.";}
?>

Not helping with your problem much but it might help you read and write code easier :D

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/#findComment-182031
Share on other sites

Instead of having to scape all those quotes and other stuff try this method:

<?php
  if ($_POST['Submit'] && $_POST['name'] == "username" && $_POST['pass'] == "password") {
?>
<html>
<body>
  This is a bit easier to read
</body>
</html>
<?php
  } else {echo "Sorry, wrong password.";}
?>

Not helping with your problem much but it might help you read and write code easier :D

Didn't know you could do that! Thanks!!

 

jesirose, I will look into that. thanks

Link to comment
https://forums.phpfreaks.com/topic/37985-permissions-question/#findComment-182033
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.