Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-09-2022, 08:46 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 770
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
__________________
DMCASUITE
BETA Testers Needed.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2022, 10:01 PM   #2
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
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);

?>
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2022, 10:31 PM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 770
Quote:
Originally Posted by ZTT View Post
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

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.
__________________
DMCASUITE
BETA Testers Needed.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2022, 12:30 AM   #4
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Quote:
Originally Posted by Publisher Bucks View Post
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
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.
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
create, directory, template, putting, server, created, issues, .php, code, php, folder, add, file, domain, setup, admin, system



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.