Php hide hidden files

PHP windows create hidden files

Is it possible to create hidden files/folders on windows using php (xampp)? And if it is, how?,A file in Windows is hidden if it has the hidden attribute set on it. There is no built in function to do this, so you need to use system/exec to execute the attrib application. Like this:,If you are looking for a way to set a file to read-only that will work on Windows AND *nix, then have a look at my answer to this other question: https://stackoverflow.com/a/27127640/430742, 1 In wWindows you can make files hidden so that they won’t be visible by default to the users, only to the OS. – Tiddo Feb 8 ’11 at 16:43

A file in Windows is hidden if it has the hidden attribute set on it. There is no built in function to do this, so you need to use system/exec to execute the attrib application. Like this:

$file = 'test.txt'; system('attrib +H ' . escapeshellarg($file)); 

Answer by Kristopher Roth

On a Windows system, a backup agent created temporary hidden files of nearly the same name as the original files, and in the same path. This was probably disturbing a process that used PHP scandir().,There are some articles about the hidden files in Linux style, how scandir() should ignore files that start with a dot, but there is rarely no info about Windows files.,I see that you have mentioned in the question that there are ways to exclude files starting with ‘.’ and stuff in linux but very less information about windows. Then check this out it not only eradicates files starting with ‘.’ & ‘..’ but also flags out the actually hidden files and will work for sure in windows.,A short test shows that neither scandir() nor glob() or others take care of the hidden flag.

Читайте также:  Create file in java on linux

I have tried this code on windows 7 and windows 8 & 8.1 and it surely excludes hidden files by flagging them out.

  > > function is_hidden_file($fn) < $dir = "\"".$fn."\""; $attr = trim(shell_exec("FOR %A IN (".$dir.") DO @ECHO %~aA")); if($attr[3] === 'h') return true; return false; >?> 

Answer by Zaylee Weber

A few simple techniques can help to hide PHP, possibly slowing down an attacker who is attempting to discover weaknesses in your system. By setting expose_php to off in your php.ini file, you reduce the amount of information available to them. ,Example #2 Using unknown types for PHP extensions,Example #1 Hiding PHP as another language, Another tactic is to configure web servers such as apache to parse different filetypes through PHP, either with an .htaccess directive, or in the apache configuration file itself. You can then use misleading file extensions:

# Make PHP code look like other code types AddType application/x-httpd-php .asp .py .pl

Answer by Kristopher Roth

Web Development Forum , Delete file from directory listing PHP 5 , Programming Forum , Directory Listing, File Upload, mkdir and rmdir 2

 // close directory closedir($myDirectory); // count elements in array $indexCount = count($dirArray); // sort 'em sort($dirArray); // print 'em print("$dirArray[$index]"); print(""); print(""); print(""); print("\n"); > > print("\n"); ?>

Answer by Amayah Joseph

Hide extensions for known file types (De-select) (critical) ,Set Windows to «Show hidden files, folders, or drives», and to NOT «Hide extensions for known file types», You can create a shortcut for future use to quickly open the ‘File Explorer Options’/ ‘Folder Options’ window, as you test out various different options. , Windows 10 labels this window ‘File Explorer Options’, and Windows 7, & 8 labels it ‘Folder Options’.

Читайте также:  Java запуск одного экземпляра

Load the following code into the ‘address bar’,
of any ‘Windows Explorer’ window,
and press the «Enter» keyboard key
(which is also known as the «Return» key.

C:\Windows\System32\rundll32.exe shell32.dll,Options_RunDLL 0

C:\Windows\System32\rundll32.exe shell32.dll,Options_RunDLL 0

Answer by Tori Leach

Hidden file / Hidden directory,In DOS systems, file directory entries include a Hidden file attribute which is manipulated using the attrib command. Using the command line command dir /ah displays the files with the Hidden attribute. In addition, there is a System file attribute that can be set on a file, which also causes the file to be hidden in directory listings. Use the command line command dir /as to display the files with the System attribute. ,Extended file attributes,Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Unix and Unix-like environments [ edit ]

In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config ), commonly called a dot file or dotfile, is to be treated as hidden – that is, the ls command does not display them unless the -a or -A flags ( ls -a or ls -A ) are used. [5] In most command-line shells, wildcards will not match files whose names start with . unless the wildcard itself starts with an explicit . .

Answer by Alec Hood

-- to display hidden files in current directory in windows 10 dir -h

Answer by Darian Bautista

Additional directories under /wp-content/ should be documented by whatever plugin / theme requires them. Permissions will vary.,NOTE: If you installed WordPress yourself, you likely DO need to modify file permissions. Some files and directories should be “hardened” with stricter permissions, specifically, the wp-config.php file. This file is initially created with 644 permissions, and it’s a hazard to leave it like that. See Security and Hardening.,No directories should ever be given 777, even upload directories. Since the php process is running as the owner of the files, it gets the owners permissions and can write to even a 755 directory.,In such an suexec configuration, the correct permissions scheme is simple to understand.

Permission Modes # Permission Modes

 7 5 5 user group world r+w+x r+x r+x 4+2+1 4+0+1 4+0+1 = 755 
  • Read 4 – Allowed to read files
  • Write 2 – Allowed to write/modify files
  • eXecute1 – Read/write/delete/modify/directory
 7 4 4 user group world r+w+x r r 4+2+1 4+0+0 4+0+0 = 744 

Additional directories under /wp-content/ should be documented by whatever plugin / theme requires them. Permissions will vary.

/ |- index.php |- wp-admin | `- wp-admin.css |- wp-blog-header.php |- wp-comments-post.php |- wp-commentsrss2.php |- wp-config.php |- wp-content | |- cache | |- plugins | |- themes | `- uploads |- wp-cron.php |- wp-includes `- xmlrpc.php 

You can make all the files in your wp-content directory writable in two steps, but before making every single file and folder writable you should first try safer alternatives like modifying just the directory. Try each of these commands first and if they don’t work then go recursive, which will make even your themes image files writable. Replace DIR with the folder you want to write in

chmod -v 746 DIR chmod -v 747 DIR chmod -v 756 DIR chmod -v 757 DIR chmod -v 764 DIR chmod -v 765 DIR chmod -v 766 DIR chmod -v 767 DIR 

The crux of this permission issue is how your server is configured. The username you use to FTP or SSH into your server is most likely not the username used by the server application itself to serve pages.

 7 7 7 user group world r+w+x r+w+x r+w+x 4+2+1 4+2+1 4+2+1 = 777 

Default Permissions (umask 022)

644 -rw-r--r-- /home/user/wp-config.php 644 -rw-r--r-- /home/user/cgi-bin/.htaccess 644 -rw-r--r-- /home/user/cgi-bin/php.ini 755 -rwxr-xr-x /home/user/cgi-bin/php.cgi 755 -rwxr-xr-x /home/user/cgi-bin/php5.cgi 
600 -rw------- /home/user/wp-config.php 604 -rw----r-- /home/user/cgi-bin/.htaccess 600 -rw------- /home/user/cgi-bin/php.ini 711 -rwx--x--x /home/user/cgi-bin/php.cgi 100 ---x------ /home/user/cgi-bin/php5.cgi 

755 > 100 – Because of the setup where the user account is the owner of the process running the php cgi, no other user or group needs access, so we disable all access except execution access. This is interesting because it really works. You can try reading the file, writing to the file, etc. but the only access you have to this file is to run php scripts. And as the owner of the file you can always change the permission modes back again.

$ cat: php5.cgi: Permission denied ./php5.cgi: Welcome 

Run the following command (on rpm based systems);

# rpm -qa | grep selinux selinux-policy-targeted-3.13.1-166.el7_4.7.noarch selinux-policy-3.13.1-166.el7_4.7.noarch libselinux-2.5-11.el7.x86_64 libselinux-python-2.5-11.el7.x86_64 libselinux-utils-2.5-11.el7.x86_64 

and to check whether it is the cause of denials of permissions:

One issue that selinux causes is blocking the wp-admin tools from writing out the `.htaccess` file that is required for url rewriting. There are several commands for inspecting this behaviour

# audit2allow -w -a type=AVC msg=audit(1517275570.388:55362): avc: denied < write >for pid=11831 comm="httpd" path="/var/www/example.org/.htaccess" dev="vda1" ino=67137959 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file Was caused by: The boolean httpd_unified was set incorrectly. Description: Allow httpd to unified Allow access by executing: # setsebool -P httpd_unified 1 
# ausearch -m avc -c httpd ---- time->Tue Jan 30 01:30:31 2018 type=PROCTITLE msg=audit(1517275831.762:55364): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44 type=SYSCALL msg=audit(1517275831.762:55364): arch=c000003e syscall=21 success=no exit=-13 a0=55b9c795d268 a1=2 a2=0 a3=1 items=0 ppid=11826 pid=11829 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1517275831.762:55364): avc: denied < write >for pid=11829 comm="httpd" name="bioactivator.org" dev="vda1" ino=67137958 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_sys_content_t:s0 tclass=dir ---- 

You can temporarily disable selinux to determine if it is the cause of the problems;

# setenforce usage: setenforce [ Enforcing | Permissive | 1 | 0 ] 

Источник

Оцените статью