PHP - How To Hide .appledouble Folder?
Hi
Sorry if this is the wrong place for this but I'm totally stumped here and I know its a basic question but I'm very new to php and I need help :-) Basically all i would like to do is hide certain file types, folders (specifically the folder .AppleDouble) and hidden files, below is my code so far and I'd really appreciate it if anyone could help me out by taking a look! Any help would be very gratefully received! Here's my code so far: <? $rootdir = "../media/Documents"; function printdir($dir) { $dircount = 0; $filecount = 0; $handle = opendir($dir); while (false != ($file = readdir($handle))) { if (@filetype($dir . "/" . $file) == "dir" AND $file != "." AND $file != "..") { $dirlist[$dircount] = $file; $dircount++; } else { if (strtolower(substr($file, -4)) == ".avi") { $filelist[$filecount] = substr($file, 0, (strlen($file)-4)); $filecount++; } } } closedir($handle); if ($dircount>0) {sort ($dirlist);} if ($filecount>0) {sort ($filelist);} for ($i = 0; $i < $dircount; $i++) { echo "<dl>\n"; echo "<dt><B>" . $dirlist[$i] . "</B></dt>\n"; flush(); printdir($dir . "/" . $dirlist[$i]); echo "</dl>\n\n"; } for ($i = 0; $i < $filecount; $i++) { echo "<dd>" . $filelist[$i] . "</dd>\n"; flush(); } if ($filecount + $dircount == 0) { echo "<dd><i><empty folder></i></dd>\n"; } } printdir($rootdir); ?> Similar TutorialsI got this script: But it give me error, file_get_contents cannot open stream. I need to add the FTP connection with user/pass paramaters. then look in set http url, to get the file contents(images) and transfer to ftp server location. Can Anyone take alook and tell me if I am going down the right path and how to get there. Please Code: [Select] function postToHost($host, $port, $path, $postdata = array(), $filedata = array()) { $data = ""; $boundary = "---------------------".substr(md5(rand(0,32000)),0,10); $fp = fsockopen($host, $port); fputs($fp, "POST $path HTTP/1.0\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: multipart/form-data; boundary=".$boundary."\n"); // Ab dieser Stelle sammeln wir erstmal alle Daten in einem String // Sammeln der POST Daten foreach($postdata as $key => $val){ $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"".$key."\"\n\n".$val."\n"; } // Sammeln der FILE Daten if($filedata) { $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"".$filedata['name']."\"; filename=\"".$filedata['name']."\"\n"; $data .= "Content-Type: ".$filedata['type']."\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $filedata['data']."\n"; $data .= "--$boundary--\n"; } // Senden aller Informationen fputs($fp, "Content-length: ".strlen($data)."\n\n"); fputs($fp, $data); // Auslesen der Antwort while(!feof($fp)) { $res .= fread($fp, 1); } fclose($fp); return $res; } $postdata = array('var1'=>'today', 'var2'=>'yesterday'); $filedata = array( 'type' => 'image/png', 'data' => file_get_contents('http://xxx/tdr-images/images/mapping/dynamic/deals/spot_map') ); echo '<pre>'.postToHost ("localhost", 80, "/test3.php", $postdata, $filedata).'</pre>'; I want to copy everything in templates/blue to the folder code/ However: shell_exec("cp -r 'templates/blue' 'code'"); Creates a folder called blue inside code. I tried cp -r 'templates/blue/*' 'code', but that didn't do anything. Any ideas? Hey, I'm trying to build up a simple framework for my projects, and need a little help! How can I find folders using PHP? I have one file called global.php which will include a folder called "plugins". Inside "plugins" will be all the actual site files. I do not want a index.php?page=pluginfilehere... I want strictly say.. example.com/site/index.php. So inside plugins folder, I will have another folder called site, which inside that will be the .php files for it. But, keep in mind, I will not just have a folder called site in the plugins.. It could be called account, or user whatever I am building! Thanks in advance. - Justin hi i am a making a site in which m saving a songs information in database then fetching that out for inserting song link m using readdir function that read all song in a folder then save them in database but i have problem when that read file name .mp3 also include with that which i don't want to show on page where i fetch that mean simply i want that i can insert song name separately and file separately... and i want to use readdir also for getting file name becoz that easy way instead of upload through panel ..? any idea or solution about adding separately file name Hi, I want to be able to click on the photo and go to the next one in a folder. I have this code already, I just am not quite sure how to finish it. -George Code: [Select] <?php $count = $_GET['count']; $dir = "images"; $names = array(); $handle = opendir($dir); while ($name = readdir($handle)){ if(is_dir("$dir/$name")) { if($name != '.' && $name != '..') { echo "directory: $name\n"; } } elseif ($name != '.DS_Store' ) { $names[] = $name; } } closedir($handle); $numberofitems = count($names); $numberofitems--; if ($count <= $numberofitems){ echo "<p>"; echo "<img src='images/".$names[$count]."'>"; } else {echo "end";} ?> Hi, How could I make a php script that creates a new folder (with the name as the date) every day automatically? Cheers, George Hey, I hope you will understand what I am saying, because english isn't my main language -.-, Anyway, I need to create a folder navigation, what I mean is like you got folder on your comp : C:\navThing\ (and many sub folders and files) what I want to do is list all files from the current directory where the user is. if he is in C:\navThing\ show dir and files in C:\navThing\ only... if he is in C:\navThing\lol\ show dir and files in C:\navThing\lol only... but I don't know how to get the user position, for the moment I'm using $_GET, but well, I don't think it's really secure... ( xxx.php?path=lol/ ) if anybody can think of any other way, where the user can't modify it tell me, I thougth session would be good, but what if he use previous... anyway any suggestion? How to define default folder. For example I have folder images and in that folder specific image. In the root directory I have index.php with Code: [Select] <?php require_once("public/includes/header.php"); ?>and in index.php there are links which goes to different folder: Code: [Select] <a href="public/sajt/kategorija.php?id=<?php echo $id; ?>">which also have header.php, but there is no image. How to make default folder for image, or some similar solution? <?php $zip = new ZipArchive; $res = $zip->open('test.zip'); if ($res === TRUE) { $zip->renameName('currentname.txt','newname.txt'); $zip->close(); } else { echo 'failed, code:' . $res; } ?> I can rename a text file name but I can't rename a folder name.Can you help me? Hi I am trying to get the structure of some folders/files on my server to create an xml "Feed" which then goes to a flash file. I keep getting the error message that I can't open the folder (it is set to 755) ERROR: Could not open folder: http://www.name/templates/bluezoo/mp3s What am I doing wrong please. Many thanks in advance Edward Here's some php: Code: [Select] $directoryLocation="http://www.name/templates/bluezoo/mp3s"; // XML Doctype $xml = new DomDocument('1.0', 'UTF-8'); $xml->xmlStandalone = false; // XML Root element $root = $xml->createElement('mp3s'); $root = $xml->appendChild($root); // Grab a list of folders from the specified directory if ($dir = @opendir($directoryLocation)) { while (false !== ($file = readdir($dir))) { if (is_dir($directoryLocation . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..') { // If it is a folder, put it in the folders array $folders[] = $file; } } Hi all - I have a form that let's a user upload an image to their specified folder. The folder is determined by the "password" the user inputs. The "password" is really just the folder name on my server, so if "michael83" was entered as a password, the directory would be "images/uploaded/michael83". That works great now, thanks to a forum user, litebearer. Thanks again. Here's my second question: I'm working on a "history" page so that a user can input their "password" and view their upload history. The form works right now. If you enter a "password" (folder name) that exists, the code will spit out the contents / files. So, now I'm looking for two things: (1) if a user enters a "password" (folder name) that exists, but there are no files in the folder, "There are no files in the $dir directory." will be echoed; and (2) if a "password" (folder name) is entered that does NOT exist, "The directory $dir does not exist." will be echoed. Here's my code so far (minus the if statements I'm looking for): $dir = $_POST['password']; $path = "images/uploaded/". $dir; $dir_handle = @opendir($path); while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." ) continue; if(isset($_POST['Submit'])) $url = "http://www.mysite.com/". $path . "/" . $file; { echo "<a href=\"$url\">$url</a><br />"; }} closedir($dir_handle); As always, many thanks in advance for any help on this. I have a site that I have the same information on several pages in different folders. Right now I have an include page in each folder and when I need to change the information on the include page, I have to do it for every folder, even though the information is all the same. What I need to do is have one include page that I can modify and all the other pages in the different folders can include it. I know I'm kind of rambling here but I hope I'm making sense. I need to know how to include a file from one folder into a page from another folder. Here's what I've tried so far and it didn't work... not sure what else to try. Code: [Select] include("http://www.website.com/include.inc.php"); The file that I'm trying to include this into is located at http://www.website.com/folder1/page.php ... so include("include.inc.php") won't work... I have to specify what folder or directory to pull the include file from. Sorry about the rambling and thanks in advance for any help. Hi, I just connect to my server through ftp. i want to edit php.ini file. which is placed in /etc/php.ini "etc" folder. but i'm unable to see etc folder. there are only two folders one is cgi-bin and other is www. can anyone help me to find out etc folder. i've check to show hidden files in filezilla. Thanks Ok so what I am trying to do is have multiple folders pull from one folder. So if I have this structu Code: [Select] /test1/some_folder /test2/some_folder /test3/some_folder I would want all of those folders named some_folder to read from a master directory. I dont need them to be able to go that specific url just need it to include the files from the main directory in each of those. Imagine I was setting up shared functions and just wanted to store them in one place but be able to include them on any site. I didnt know what to google (tried folder redirection but didnt seem right) so if anyone can offer a suggestion as to what to google or wants to provide an answer it would be appreciated. Hi I've got a file upload script i've written and I have set the folder to 777 to allow uploads With the permission set to 777 does this open me up to potential uploads from 3rd parties? (ie: viruses etc)? So I thought what I would do is 1: Set folder to 777 to allow uploads 2: Upload file 3: Set folder to 755 to disable uploads Would this be the best method to do it? Or is that a waste of time and am I safe just leaving it as 777 Thanks Hi all, I'm trying to echo all the files in the folder 'pics' <?php $dir = "pics/"; // Open a directory, and read its contents if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ echo '<img src="pics/' .$file . '" width="120px" height="120px" />'; } closedir($dh); } } ?>
The above code outputs the following. (there is only one image in the folder) So the code gets the image correctly and works with multiple images in the folder, but also produces two broken pathways at the beginning. <img src="pics/." width="120px" height="120px" /><img src="pics/.." width="120px" height="120px" /><img src="pics/j1.jpg" width="120px" height="120px" />
My question is why, I can't figure out what is happening. Any pointers or explanations would be appreciated. Cheers for your time.
Paul
Securing my upload folder “upl”
The upl folder is used to store anything that is uploaded by the user for their needs that is not a part of the back end, as such all content in this folder is subject to being locked down and and supplied after checking credentials.
The upl folder has an .htaccess file that locks down all remote access. order deny,allow deny from all
When something is needed from this directory we jump that wall with the help of apache after credentials are verified.
I think this is straight forward so far.
For images something like; <img src=”downloader.php?app=1&id=20&type=thumb”>
For files something like; <a href=”downloader.php?app=1&id=20&type=file&fileid=1212”>
After we check creds, we use similar to below to get data from that locked down folder.
$size = filesize($file); header ( 'Content-Description: File Transfer' ); header("Content-Type: application/force-download"); header ( 'Content-Type: application/octet-stream' ); header ( "Content-Disposition: attachment; filename=\"".basename($file)."\""); header ( 'Expires: 0' ); header ( 'Cache-Control: must-revalidate' ); header ( 'Pragma: public' ); header ( 'Content-Length: ' . filesize ( $file ) ); ob_clean(); flush(); readfile ( $file ); exit();
seems to work pretty swimmingly for the most part. My problem is (or at lease a mild nuisance) is that it seems that these images loaded in this manner are not subject to the cache system of a browser? It looks like they reload every time a page is visited. Is there a way around this?
I have a folder with php includes files and one of them has the username and password of the database. Is there any way that i can lock the folder and unlock it with php. Or do it using the cpanel of my server? |