Closed Thread Icon

Preserved Topic: PHP Chmod (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21187" title="Pages that link to Preserved Topic: PHP Chmod (Page 1 of 1)" rel="nofollow" >Preserved Topic: PHP Chmod <span class="small">(Page 1 of 1)</span>\

 
AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-17-2002 01:16

Hey guys, I must say I'm thirsty... but who cares?

I have a page trying to chmod a file from 0200, to 0600 then back after I'm done...
the problem is, I'm getting this error...

'chmod failed: Operation not permitted in /home/removed/public_html/chats/count.php on line 18'

Line 18 reads: chmod($fp, 0600);

The host says that it's enabled, so am I doing something wrong?


thanks!

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-17-2002 05:43

Try hardcoding the file name once and see what happens. This works for me:
$mymod=chmod("$server_path/$dest/$id.$ext", 0644);
echo "Results: " . $mymod;


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-17-2002 06:06

Do you have the whole code.

Quick guess, usually $fp in the manual is a file pointer, not a filename or directory. It's usually used like this

$filename = "/whaterver/file.txt";
$fp = $fopen($filename, "r");

I'm guessing trying to chmod a file pointer instead of a filename you might get an error. So it should be

chmod($filename, 0777)
instead of
chmod($fp, 0777)




.:[ Never resist a perfect moment ]:.

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-17-2002 09:31

Why am I up? I'm stupid!

I tried both your suggestions
It didn't work, so is it a host issue?

How could I check to see if they have it enabled, or?

Pat, I forgot to mention I had already tried the full path, sorry and thanks for your suggestion

Bit, I have an evil tendency to use $fp for file paths... Is there a big difference in using $fp vs $filepath?
I'm new, so I may ask stupid things... I just want to learn...

Thanks

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-17-2002 20:14

Nah there's no technical difference it's just one of those things that has kinda become a defacto standard, if for no other reason but because that's how it's done in the manual. In the manual they use $fp to refer to "File Pointer" as opposed to file path and then use $filename to refrence the string that indicates the path to the file.

This is really a small issue and I only even say this because if someone else had to adjust your code, these are the little things that sometimes can make figuring out other peoples code difficult. I'm not really one to talk though I use really wierd variable names sometimes and rarely comment my stuff





.:[ Never resist a perfect moment ]:.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-17-2002 20:21

Nah there's no technical difference it's just one of those things that has kinda become a defacto standard, if for no other reason but because that's how it's done in the manual. In the manual they use $fp to refer to "File Pointer" as opposed to file path and then use $filename to refrence the string that indicates the path to the file.

This is really a small issue and I only even say this because if someone else had to adjust your code, these are the little things that sometimes can make figuring out other peoples code difficult. I'm not really one to talk though I use really wierd variable names sometimes and rarely comment my stuff





.:[ Never resist a perfect moment ]:.

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 09-17-2002 20:52

Post the whole script. Dat might help.

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-18-2002 07:19

Thanks Bit

Drac, before I wrote the script I was verifying the ability to chmod, so all it is thus far is.

$filepath = "/home/removed/public_html/chats/public/chatters.txt";
chmod($filepath, 0600);


(Changed $fp due to Bits post )

BTW, How is your Dad doing? I hope he's getting better.

thanks

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 09-18-2002 07:36

My Dad's good.

That's the whole script!

hmmm.... How odd. What permissions have you set on the script itself?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-18-2002 07:50

Ok, the next question is "who owns the file"? If it's owned by ROOT, I can almost see an issue with a script trying to chmod the file. Almost. Not likely, but.......

Make sure the file is owned by the same user account that the script runs under.

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-18-2002 09:32

Great to hear Drac

The script has been set to many things, including 666, 644(currently) and 777
I made it, and uploaded her a few days ago.
Upon doing that and having the error, I contacted the host to double
check to see if it was permitted... They said yes... sooo...

I asked them to correct me, and write something in PHP that'll change
the permissions on their server, and let me see it so I can see my wrong... lol

Thus far, no response so we'll see eh?

Any suggestions? thanks you two

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-18-2002 19:13

Alright lets test some stuff out. Try this

code:
<?
$filename = "test.php";

// this is all just for testing.
// Get the file's owner
echo "File Info: for file - ".$filename."<br>";
$owner = posix_getpwuid(fileowner($filename));
echo "file owner: ".$owner['name']."<br>";

// Get the file's group name
$group = posix_getgrgid(filegroup($filename));
echo "file group: ".$group['name']."<br>";

// Get the current permisssions
echo get_perms($filename);
echo "<br>";
echo "<p>Directory info cwd - ".getcwd()."<br>";
echo "Dirname - ".$dir."<br>";
// For giggles let's get the firectory info too.
$dir = dirname($filename);
$owner = posix_getpwuid(fileowner($dir));
echo "dir owner: ".$owner['name']."<br>";
$group = posix_getgrgid(filegroup($dir));
echo "dir group: ".$group['name']."<br>";
echo get_perms($dir);
echo "<br>";

// Utility function to get Unix Style permissions
function get_perms($file) {
$p_bin = substr(decbin(fileperms($file)), -9) ;
$p_arr = explode(".", substr(chunk_split($p_bin, 1, "."), 0, 17)) ;
$perms = ""; $i = 0;
foreach ($p_arr as $this) {
$p_char = ( $i%3==0 ? "r" : ( $i%3==1 ? "w" : "x" ) );
$perms .= ( $this=="1" ? $p_char : "-" ) . ( $i%3==2 ? " " : "" );
$i++;
}
return $perms;
}

?>



just dump that into a php file on your server, change the path to point to your file and then you can post the results. If you change any of the file paths to hide them from this board just be consistent in the file name and the cwd.

oh oh oh you might want to at the end of all that put "phpinfo()"; and just get a dump of your php setup too.



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 09-18-2002).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-18-2002 20:14

Interesting.

I did a little addition to it, and made it a little easier to read. It now shows you the decimal permissions value for both the file and the directory. You can now also specify the file in the URL:

code:
<?php
function get_perms($file) { // Utility function to get Unix Style permissions
$p_bin = substr(decbin(fileperms($file)), -9) ;
$p_arr = explode(".", substr(chunk_split($p_bin, 1, "."), 0, 17)) ;
$perms = "";
$i = 0;
foreach ($p_arr as $this) { $p_char = ( $i%3==0 ? "r" : ( $i%3==1 ? "w" : "x" ) );
$perms .= ( $this=="1" ? $p_char : "-" ) . ( $i%3==2 ? " " : "" );
$i++;
} return $perms;
}
if (!isset($filename)){
$filename = "test.php";
}
$owner = posix_getpwuid(fileowner($filename)); // Get the file's owner
$group = posix_getgrgid(filegroup($filename)); // Get the file's group name
$perms = get_perms($filename); // Get the current permisssions
$dir = dirname($filename); // For giggles let's get the firectory info too.
$dirowner = posix_getpwuid(fileowner($dir));
$dirgroup = posix_getgrgid(filegroup($dir));
$dirperms = get_perms($dir);
$chmodperms = substr(base_convert(fileperms($filename), 10, 8), 3);
$dirchmodperms = substr(base_convert(fileperms(getcwd()), 10, 8), 2);

echo "<b>File name:</b> ".$filename."<br />\n";
echo "<b>File owner:</b> ".$owner['name']."<br />\n";
echo "<b>File group:</b> ".$group['name']."<br />\n";
echo "<b>File permissions:</b> ".$perms." (".$chmodperms.")<br />\n";
echo "<b>Dir info cwd:</b> ".getcwd()."<br />\n";
echo "<b>Dir name:</b> ".$dir."<br />\n";
echo "<b>Dir owner:</b> ".$dirowner['name']."<br />\n";
echo "<b>Dir group:</b> ".$dirgroup['name']."<br />\n";
echo "<b>Dir permissions:</b> ".$dirperms."(".$dirchmodperms.")<br />\n";
?>





[This message has been edited by Pugzly (edited 09-18-2002).]

[This message has been edited by Pugzly (edited 09-18-2002).]

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-18-2002 21:30

Hey there, good day to you!


<BLOCKQUOTE><FONT face="Verdana, Arial">quote:</font><HR>
File name: /home/usrname/public_html/chats/public/chatters.txt
File owner: usrname
File group: usrname
File permissions: -w- --- --- (200)
Dir info cwd: /home/usrname/public_html/chats
Dir name: /home/usrname/public_html/chats/public
Dir owner: usrname
Dir group: usrname
Dir permissions: rwx r-x r-x (777)

--------------------------------------------------------------------------------
PHP Version 4.2.2

System Linux www.server5indallas.com 2.4.18-0.26 #1 Mon Apr 15 13:00:26 EDT 2002 i686 unknown
Build Date Sep 9 2002 15:30:31
Configure Command './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-swf=/usr/local/flash' '--enable-ftp' '--with-gd=../gd-1.8.4' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-imap=../imap-2001.BETA.SNAP-0105220031' '--with-mcrypt' '--with-ming=../ming-0.1.1' '--enable-magic-quotes' '--with-mysql' '--with-pear' '--enable-xslt' '--with-xslt-sablot' '--enable-track-vars' '--with-ttf' '--enable-versioning' '--with-zlib'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/lib/php.ini
Debug Build no
Thread Safety disabled

This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.2.0, Copyright (c) 1998-2002 Zend Technologies



--------------------------------------------------------------------------------

PHP 4 Credits

--------------------------------------------------------------------------------

Configuration
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference
On On
allow_url_fopen
1 1
always_populate_raw_post_data
0 0
arg_separator.input
& &
arg_separator.output
& &
asp_tags
Off Off
auto_append_file
no value no value
auto_prepend_file
no value no value
browscap
no value no value
default_charset
no value no value
default_mimetype
text/html text/html
define_syslog_variables
Off Off
disable_functions
no value no value
display_errors
On On
display_startup_errors
Off Off
doc_root
no value no value
enable_dl
On On
error_append_string
no value no value
error_log
no value no value
error_prepend_string
no value no value
error_reporting
2039 2039
expose_php
On On
extension_dir
./ ./
file_uploads
1 1
gpc_order
GPC GPC
highlight.bg
#FFFFFF #FFFFFF
highlight.comment
#FF8000 #FF8000
highlight.default
#0000BB #0000BB
highlight.html
#000000 #000000
highlight.keyword
#007700 #007700
highlight.string
#DD0000 #DD0000
html_errors
On On
ignore_user_abort
Off Off
implicit_flush
Off Off
include_path
.:/usr/local/lib/php .:/usr/local/lib/php
log_errors
Off Off
magic_quotes_gpc
On On
magic_quotes_runtime
Off Off
magic_quotes_sybase
Off Off
max_execution_time
30 30
open_basedir
no value no value
output_buffering
no value no value
output_handler
no value no value
post_max_size
55M 55M
precision
14 14
register_argc_argv
On On
register_globals
On On
safe_mode
Off Off
safe_mode_exec_dir
no value no value
safe_mode_gid
Off Off
safe_mode_include_dir
no value no value
sendmail_from
me@localhost.com me@localhost.com
sendmail_path
/usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
short_open_tag
On On
SMTP
localhost localhost
sql.safe_mode
Off Off
track_errors
Off Off
unserialize_callback_func
no value no value
upload_max_filesize
2M 2M
upload_tmp_dir
no value no value
user_dir
no value no value
variables_order
EGPCS EGPCS
xmlrpc_error_number
0 0
xmlrpc_errors
Off Off
y2k_compliance
Off Off


xslt
XSLT support enabled


xml
XML Support active
XML Namespace Support active
EXPAT Version 1.95.2


swf
swf support enabled


standard
Regex Library Bundled library enabled
Dynamic Library Support enabled
Path to sendmail /usr/sbin/sendmail -t -i

Directive Local Value Master Value
assert.active
1 1
assert.bail
0 0
assert.callback
no value no value
assert.quiet_eval
0 0
assert.warning
1 1
safe_mode_allowed_env_vars
PHP_ PHP_
safe_mode_protected_env_vars
LD_LIBRARY_PATH LD_LIBRARY_PATH
url_rewriter.tags
a=href,area=href,frame=src,form=fakeentry a=href,area=href,frame=src,form=fakeentry


session
Session Support enabled

Directive Local Value Master Value
session.auto_start
Off Off
session.cache_expire
180 180
session.cache_limiter
nocache nocache
session.cookie_domain
no value no value
session.cookie_lifetime
0 0
session.cookie_path
/ /
session.cookie_secure
Off Off
session.entropy_file
no value no value
session.entropy_length
0 0
session.gc_maxlifetime
1440 1440
session.gc_probability
1 1
session.name
PHPSESSID PHPSESSID
session.referer_check
no value no value
session.save_handler
files files
session.save_path
/tmp /tmp
session.serialize_handler
php php
session.use_cookies
On On
session.use_trans_sid
1 1


posix
Revision $Revision: 1.42.2.2 $


pcre
PCRE (Perl Compatible Regular Expressions) Support enabled
PCRE Library Version 3.4 22-Aug-2000


mysql
MySQL Support enabled
Active Persistent Links 1
Active Links 1
Client API version 3.23.39
MYSQL_MODULE_TYPE builtin
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_INCLUDE
MYSQL_LIBS

Directive Local Value Master Value
mysql.allow_persistent
On On
mysql.default_host
no value no value
mysql.default_password
no value no value
mysql.default_port
no value no value
mysql.default_socket
no value no value
mysql.default_user
no value no value
mysql.max_links
Unlimited Unlimited
mysql.max_persistent
Unlimited Unlimited


ming
Ming SWF output library the funk in your trunk
Version 0.2a


mcrypt
mcrypt support enabled
version 2.4.x
Supported ciphers twofish rijndael-128 rijndael-192 rijndael-256 saferplus rc2 xtea serpent safer-sk64 safer-sk128 cast-256 loki97 gost threeway cast-128 blowfish des blowfish-compat tripledes enigma arcfour panama wake
Supported modes ofb cfb nofb cbc ecb stream ncfb ctr

Directive Local Value Master Value
mcrypt.algorithms_dir
no value no value
mcrypt.modes_dir
no value no value


imap
IMAP Support enabled
IMAP c-Client Version 2001


gd
GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with TTF library
JPG Support enabled
PNG Support enabled
WBMP Support enabled


ftp
FTP support enabled


curl
CURL support enabled
CURL Information libcurl 7.9.8 (OpenSSL 0.9.6b)


ctype
ctype functions enabled (experimental)


calendar
Calendar support enabled


bcmath
BCMath support enabled


zlib
ZLib Support enabled
'zlib:' fopen wrapper enabled
Compiled Version 1.1.3
Linked Version 1.1.3

Directive Local Value Master Value
zlib.output_compression
Off Off


apache
APACHE_INCLUDE
APACHE_TARGET
Apache Version Apache/1.3.26
Apache Release 10326100
Apache API Version 19990320
Hostname:Port www.thedomain.com:80
User/Group nobody(99)/99
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 0
Timeouts Connection: 300 - Keep-Alive: 30
Server Root /usr/local/apache
Loaded Modules mod_auth_mysql, mod_log_bytes, mod_bwlimited, mod_php4, mod_frontpage, mod_ssl, mod_setenvif, mod_so, mod_auth, mod_access, mod_rewrite, mod_alias, mod_userdir, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_status, mod_negotiation, mod_mime, mod_log_config, mod_env, http_core

Directive Local Value Master Value
child_terminate
0 0
engine
1 1
last_modified
0 0
xbithack
0 0


Apache Environment
Variable Value
DOCUMENT_ROOT /home/usrname/public_html
HTTP_ACCEPT */*
HTTP_ACCEPT_LANGUAGE en-us
HTTP_CONNECTION Keep-Alive
HTTP_COOKIE anonlogin=-1; phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D
HTTP_HOST www.thedomain.com
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
PATH /usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin
REMOTE_ADDR mybloodyIP
REMOTE_PORT 1752
SCRIPT_FILENAME /home/usrname/public_html/chats/test.php
SERVER_ADDR REMOVED
SERVER_ADMIN webmaster@mydomain.com
SERVER_NAME www.mydomain.com
SERVER_PORT 80
SERVER_SIGNATURE <ADDRESS>Apache/1.3.26 Server at www.mydomain.com Port 80</ADDRESS>

SERVER_SOFTWARE Apache/1.3.26 (Unix) AuthMySQL/2.20 mod_log_bytes/0.3 mod_bwlimited/1.0 PHP/4.2.2 FrontPage/5.0.2.2510 mod_ssl/2.8.9 OpenSSL/0.9.6b
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.0
REQUEST_METHOD GET
QUERY_STRING
REQUEST_URI /chats/test.php
SCRIPT_NAME /chats/test.php


HTTP Headers Information
HTTP Request Headers
HTTP Request GET /chats/test.php HTTP/1.0
Accept */*
Accept-Language en-us
Connection Keep-Alive
Cookie anonlogin=-1; phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D
Host www.mydomain.com
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
HTTP Response Headers
X-Powered-By PHP/4.2.2
Connection close
Content-Type text/html


Additional Modules


Environment
Variable Value
PWD /root
HOSTNAME www.server5indallas.com
LS_OPTIONS --color=tty -F -a -b -T 0
CLASSPATH .:/usr/local/jdk/lib/classes.zip
LESSOPEN

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-18-2002 22:09

Alright I'll take a look but no guarantees.

Oh and hey Pugz I see your cleaned up code and raise you one
http://www.bitdamaged.com/testpages/fileinfo

You can set either a file name or a directory and get pretty much the equivalent of a Unix ls -l command It's also slightly secured via HTTP authentication



.:[ Never resist a perfect moment ]:.

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-18-2002 22:20

Thanks Bit!

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-18-2002 22:37

I think I have it

try this

<?
$u = posix_getpwuid(posix_getuid());
$g = posix_getgrgid($u['gid']);
echo $u['name'].".".$g['name'];
?>

and tell me what you get. If it's not usrname.usrname Then you are not going to be able to chmod the file when it's perms have been set to 200 because the default apache user is not the owner.



.:[ Never resist a perfect moment ]:.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-18-2002 23:15

Damn it....

Okay - I seem to be having an "issue" with your script, Bit.....

If I specify a file, it says DIRECTORY at the top, and gives me that info. I can't seem to get it to display FILE.....

The only thing I've changed so far is some minor appearance stuff -

code:
<?
/***********************************************************
Simple directory listing script. If installed an Apache mod
this is secured using standard HTTP Authentication for security
purposes.

THIS NOT SECURE AND THE AUTHOR TAKES NO REPSONSIBLITY!!!
this script is to be used for debugging purposes only and should
be removed when not needed.

Set the $auth_user and $auth_pass settings to something
specific to you.

Then the $filename parameter can either be set in the
script or in the URL.

questions, comments, additions
miker@bitdamaged.com


************************************************************/
unset($auth_user, $auth_pwd);

// SET THESE HERE
$auth_user = "whoever";
$auth_pass = "whatever";

// Filename to use if nothing is set in the URL.
// You can set this to "getcwd()" and it will show whatever
// Directory the script is in.
if (!isset($filename)) {
$filename = "test.php";
}
// If PHP is not an apache mod you can just call "get_info($filename)"
// and remove this part. Your security risks increas however
if ($HTTP_SERVER_VARS['PHP_AUTH_USER'] == $auth_user && $HTTP_SERVER_VARS['PHP_AUTH_PW'] == $auth_pass) {
if ($filename) echo get_info($filename);
} else {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'You are not authorized to view this page';
exit;
}

function get_info($file) {
if (is_dir($file)) {
$out = get_table($file,get_directory_contents($file));
} else {
$out = get_table($file, getfileinfo($file));
}
return $out;
}


// Function to get Unix style file info, returns hash, can be file or dir.
function get_directory_contents($dir) {
$out = array();
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
array_push($out, getfileinfo($file));
}
}
closedir($handle);
return $out;
}

// Function to get a nice array for an individual file
function getfileinfo($file) {
$out = array();
$out['name'] = (is_dir($file)) ? $file."/" : $file;
$owner = posix_getpwuid(fileowner($filename));
$out['owner'] = $owner['name'];
$out['perms'] = (is_dir($file)) ? "d ".get_perms($file) : "- ".get_perms($file);
$group = posix_getgrgid(filegroup($filename));
$out['group'] = $group['name'];
$out['size'] = filesize($file);
$out['mod'] = date("M d G:i", filemtime($file));
return $out;
}

// Utility function to get Unix Style permissions
function get_perms($file) {
$p_bin = substr(decbin(fileperms($file)), -9) ;
$p_arr = explode(".", substr(chunk_split($p_bin, 1, "."), 0, 17)) ;
$perms = ""; $i = 0;
foreach ($p_arr as $this) {
$p_char = ( $i%3==0 ? "r" : ( $i%3==1 ? "w" : "x" ) );
$perms .= ( $this=="1" ? $p_char : "-" ) . ( $i%3==2 ? " " : "" );
$i++;
}
return $perms;
}

// Take what we have and make a table
function get_table($file, $fileinfo) {
// If it's a directory it's an array of arrays.
if (is_array($fileinfo)) {
$table = "<table cellpadding=\"0\" cellspacing=\"5\" border=\"0\" bgcolor=\"#ffffff\">";
$table .= "<tr><td colspan=\"6\" bgcolor=\"#dddddd\" align=\"center\">";
$table .= "\nDirectory: ".$file;
$table .= "\n</td></tr>";
$table .= "\n<tr><td align=\"center\">Perms</td><td align=\"center\">Owner</td><td align=\"center\">Group</td><td align=\"center\">Size</td><td align=\"center\">Modified</td><td align=\"center\">Filename</td></tr>";
foreach ($fileinfo as $v) {
$table .= "\n<tr>";
$table .= "<td align=\"center\">".$v['perms']."</td>";
$table .= "<td align=\"center\"> ".$v['owner']." </td>";
$table .= "<td align=\"center\"> ".$v['group']." </td>";
$table .= "<td align=\"center\"> ".$v['size']." </td>";
$table .= "<td align=\"center\"> ".$v['mod'] ."</td>";
$table .= "<td align=\"center\">". $v['name']." </td>";
$table .= "</tr>";
}
$table .= "\n</table>";
// If not a directory.
} else {
$table = "<table cellpadding=\"0\" cellspacing=\"5\" border=\"0\" bgcolor=\"#ffffff\">";
$table .= "<tr><td colspan=\"6\" bgcolor=\"#dddddd\" align=\"center\">";
$table .= "\nFile: ".$file;
$table .= "\n</td></tr>";
$table .= "\n<tr>";
$table .= "<td align=\"center\">". $fileinfo['perms']." </td>";
$table .= "<td align=\"center\">". $fileinfo['owner']." </td>";
$table .= "<td align=\"center\">". $fileinfo['group']." </td>";
$table .= "<td align=\"center\">". $fileinfo['size']." </td>";
$table .= "<td align=\"center\">". $fileinfo['mod']." </td>";
$table .= "<td align=\"center\">". $fileinfo['name']." </td>";
$table .= "</tr>\n</table>";
}

return $table;
}
?>



bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-19-2002 00:15

Still in progress on this one

I just fixed it and then broke it again.
but it should be fixed now. Try the new version, it now allows you to dig into directories. I'm going to try to get it to sort properly now. I'm using some array's of associative arrays so I have to figure out how to sort the parent array according to the value of one of it's children's values.



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 09-19-2002).]

[This message has been edited by bitdamaged (edited 09-19-2002).]

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-19-2002 01:32

Bugger!

It's nobody.nobody

freakin a... I'm screwed eh?

Since the host tells me I can do this, and I can't... what am I to do?
He told me today, to go to forums to find a solution... these people suck!
I wish my client didn't want them, I'd be switching to someone else!!!

I'm pissed... sorry... Any suggestions as to what I can tell the provider?
I swear, these pills aren't doing crap for my stress level...

thanks again for your time

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-19-2002 02:20

you can try using chgrp to switch it to the nobody group but I doubt that would work.

You could also create some sort of PHP uploader to do your ftp stuff for you since that should upload any files as nobody and keep them with those user/group perms which should then allow you to change it.

Can you see the file?



.:[ Never resist a perfect moment ]:.

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 09-21-2002 22:43

I'll try that, thanks...

Sorry it took so long to reply, been off working...

later

« BackwardsOnwards »

Show Forum Drop Down Menu