Visit Our UNIX and Linux User Community


PHP - add rm %dir to php code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP - add rm %dir to php code
# 1  
Old 04-01-2016
PHP - add rm %dir to php code

Hello everyone,

I'm trying to modify a php file to perform 2 actions in an if statement.

PHP Code:
// If the delete button is pressed
                
if(isset($_GET['delete']) && isset($_GET['username_box']))
                {
                        if(!
mysql_query("DELETE FROM users WHERE User='".$_GET['username_box']."'",$link))
                        {
                                echo (
"<br>Error: Not a valid DELETE query.<br>");
                                echo (
"<br>MySql error : ".mysql_error());
                        }else
                        {
                                
$table_users  "SELECT * FROM users ORDER BY User ASC";
                                
$query_users  mysql_query($table_users);
                                
$length_users mysql_numrows($query_users);

                                
send_delete_notification($_GET['username_box']);

                        }
                        
// same effect when the 'new user' button is pressed
                        
$new=1;
                } 
The code is taken from Machiel's FreeBSD page (Dutch & English), and the file is the index.php. That piece of code is executed when the "Remove" button is pressed in the web interface. What I need to do is add some php code to also remove the corresponding home directory of the user. I tried with the "exec" function in php but failed miserably. The user home dirs are located under "/home/ftpusers/<ftp_login_account>".

I would appreciate a few pointers here or a piece of code maybe.

Thanks!
# 2  
Old 04-02-2016
Look system cmd, but http-server has not usually enough privileges to do ex. rm some user directory.

Need sudo or some other method to get enough privileges.
# 3  
Old 04-03-2016
Make use of ftp_rmdir

For more details : PHP: ftp_rmdir - Manual

Previous Thread | Next Thread
Test Your Knowledge in Computers #831
Difficulty: Easy
Asynchronous JavaScript and JSON (or AJAJ) refers to the same dynamic web page methodology as AJAX, but instead of JSON, XML is the data format.
True or False?

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test Server - Forum Code Changes for PHP 5.3.10 to PHP 7

Here is some docs of my ongoing work to port this forum PHP code which is running on 5.3.10, to PHP 7. Motivation: Unfortunately, every thing that has a beginning must have an end. PHP 5.6 active support ended January 19, 2017. It will receive security support until December 31, 2018. #1 ... (7 Replies)
Discussion started by: Neo
7 Replies

2. Shell Programming and Scripting

Php code help.

Hello again, I'm trying to block ips using a php script (no .htaccess). <? if ($_SERVER == "109.101.51.119") die(); ?> How can I make this to block the entire block -> 109.101.*.* Found something while searching the web but the codes are too complex. I just wanna make it simple. ... (9 Replies)
Discussion started by: galford
9 Replies

3. Red Hat

Update php 4.3 RPM to php 5.3.3 php

Dear All, My redhat version is: # cat /etc/redhat-release Red Hat Enterprise Linux AS release 4 (Nahant Update 4) # # uname -a Linux cotapplication3.cot.com 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux # I want to update my php from: # php... (1 Reply)
Discussion started by: monojcool
1 Replies

4. Shell Programming and Scripting

Help with PHP Code

<?php chdir('/var/www/cacti/'); # Cacti's directory include('./include/global.php'); duplicate_tree(ID_FROM, ID_TO); # ID of tree function duplicate_tree($tree_id_from, $tree_id_to) { $tree_items = db_fetch_assoc("SELECT * FROM graph_tree_items WHERE graph_tree_id = " .... (0 Replies)
Discussion started by: SkySmart
0 Replies

5. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies

Featured Tech Videos