GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Create new folder & add file template in php? (https://gfy.com/showthread.php?t=1352973)

Publisher Bucks 03-09-2022 08:46 PM

Create new folder & add file template in php?
 
I'm currently trying to get a part of an admin system setup whereby I can create a new sub directory on a domain, I have that part working however, I'm having issues putting a .php template into the directory once it has been created.

Here is the code I'm using to create the directory itself on the server:

Quote:

<?php
function createDirectory() {
$add = $_POST["add"];
mkdir("/blah/blah/domain.com/toplevel".$add);
echo "<script type = 'text/javascript'>alert('Done!');</script>";
}
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<title>
Create directory
</title>
</head>

<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action = "" method = "post">

<table>
<tr>
<td style = " border-style: none;"></td>
<td bgcolor = "blue" style = "font-weight: bold">
Directory Name
</td>

<td bgcolor = "red">
<input type = "text" style = "width: 220px;"
class = "form-control" name = "add" id = "add" />
</td>

<td bgcolor = "blue" colspan = "2">
<input type = "submit" name = "submit"
value = "Create directory" />
</td>
</tr>
</table>
</form>
<?php
}
else {
createDirectory();
}
?>
</body>
</html>
Like i say, the directory creation is working perfectly, but when it comes to adding the following code to upload an index.php file into the 'new' directory, nothing is happening:

Quote:

$my_file = 'index.php';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
The index.php file is basically a templated layout that will read the directory name, in addition to some random array stuff to generate a bunch of text while also pulling a list of data from my database to display on the index page of the new directory.

Could someone with a little more knowledge take a moment to point me in the right direction on how I get the new page creation to work please?

Im not getting any error logs when the button on the submit form is clicked :helpme

ZTT 03-09-2022 10:01 PM

You're not writing anything so obviously nothing will be written.

If all you're doing is copying an existing template to a new directory then:

<?php

$mytemplate="mytemplate.txt";

$newfolder="new";

mkdir($newfolder);

copy($mytemplate,$newfolder."/".$mytemplate);

?>

Publisher Bucks 03-09-2022 10:31 PM

Quote:

Originally Posted by ZTT (Post 22976131)
You're not writing anything so obviously nothing will be written.

If all you're doing is copying an existing template to a new directory then:

<?php

$mytemplate="mytemplate.txt";

$newfolder="new";

mkdir($newfolder);

copy($mytemplate,$newfolder."/".$mytemplate);

?>

Yes, but I can't use that as part of an admin backend without editing it every single time.

I need a html form to be able to name the new directory which also needs to upload that file based on an existing template, Im not having 8 or so people who use this system be able to log into the server to do that manually each time, it defeats the purpose of having a backend system to do it :2 cents:

It also means I need to make sure the people using the php you suggested, are competant when it comes to logging onto the server and arent going to fuck anything thats already in place, up.

ZTT 03-10-2022 12:30 AM

Quote:

Originally Posted by Publisher Bucks (Post 22976143)
Yes, but I can't use that as part of an admin backend without editing it every single time.

Editing what? The subject says you want to create a folder and put a template into the new folder. Do you even know what a template is?

Quote:

Im not having 8 or so people who use this system be able to log into the server to do that manually each time, it defeats the purpose of having a backend system to do it :2 cents:
How am I supposed to know what you are doing or what you will or will not allow other people to do? In your post you said:

Quote:

I'm currently trying to get a part of an admin system setup whereby I can create a new sub directory on a domain, I have that part working however, I'm having issues putting a .php template into the directory once it has been created.

Here is the code I'm using to create the directory itself on the server:
Nowhere does it say Fiverr monkeys are uploading files that "change every time". In fact it pretty much says the opposite of that.

Quote:

I need a html form to be able to name the new directory which also needs to upload that file based on an existing template,
A file based on a template is not a template, and if all you want to do is upload a file that's already generated, based on whatever, then use a upload script.

1. mkdir "dir"

2. Upload to "dir"

Quote:

It also means I need to make sure the people using the php you suggested, are competant when it comes to logging onto the server and arent going to fuck anything thats already in place, up.
If you were competent enough to explain what you want, you might get the answers you want.


All times are GMT -7. The time now is 11:22 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc