PHP - Folder Navigation
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? 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>'; Hi, I am am looking to develop further the code below. This code allows me to display a left navigation bar with Main Links and then if you click a Main link, that link is listed first in the list and its' submenu appears below. For the majority of links in the navigation bar this is fine. But for about 2 of the Main links this basic navigation is not suitable. I need the navigation for 2 of the links to offer more depth. So, for example, if you click Accessories in: Shoes Trousers Shirts Accessories Looks like this if Accessories is clicked: Accessories Belts Cuff Links Wallets Shoes Trousers Shirts Looks like this if belts is clicked (Main link name changed and submenu changed): Accessories - Belts Brown leather Black Leather Multicolour Designs All casual All formal Shoes Trousers Shirts Looks like this is Brown Leather is clicked: Brown Leather Belts Armani Brown Leather Belt 32" Armani Brown Leather Belt 34" Hugo Boss Brown Leather Belt 32" Hugo Boss Brown Leather Belt 34" Shoes Trousers Shirts Currently the code does not allow for this depth in the navigation bar. Any ideas how it could be done? Do I need additional tables for each subcategory. How do I ensure the category clicked does not appear in the rest of the navigation bar, as in the code I have at the moment? Currently the code is: $res = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($res)) { $cats[$row['categoryid']] = $row['categoryname']; } if(isset($_GET['category'])) { $selcat = $_GET['category']; } if(isset($_GET['product'])) { $prod_info = mysql_fetch_array(mysql_query("SELECT * FROM products WHERE productid = ".$_GET['product'])); //Prod_Info now gets stored for use in the main display. $selcat = $prod_info['categoryid']; } if(isset($selcat)) { echo "<a href='categorylist.php?category=".$selcat."'>".$cats[$selcat]."</a>"; unset($cats[$selcat]); //Gets rid of it for later. $res = mysql_query("SELECT productid,name FROM products WHERE categoryid = ".$selcat); while($row = mysql_fetch_array($res)) { echo "<a href='product.php?product=".$row['productid']."'>".$row['name']."</a>"; } } foreach($cats AS $key => $cat) { echo "<a href='categoryview.php?category=".$key."'>".$cat."</a>"; } Thank you for looking at this post, Matt. 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 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?
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. 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";} ?> 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. 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? 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'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, How could I make a php script that creates a new folder (with the name as the date) every day automatically? Cheers, George 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 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. <?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 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
Hello, i am looking for a way to create a new folder when a customer uploads photos. I would like the folder to be named their email address. The photo uploader code is below: - [php <?php if($logged[scrollingpicturedisplay] == "yes"){ if($difference == "Gone"){ }else{ if($logged[spd_process] == "1"){ }else{ ?> <div id="spd"> <link href="/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/swfobject.js"></script> <script type="text/javascript" src="/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript"> $(function() { $('#custom_file_upload').uploadify({ 'uploader' : '/uploadify.swf', 'script' : 'uploadify.php?user=<?php echo("$logged[ip]");?>', 'cancelImg' : '/cancel.png', 'folder' : '/wuploads', 'multi' : true, 'auto' : true, 'fileExt' : '*.ZIP;*.zip;*.rar;*.jpg', 'queueID' : 'custom-queue', 'queueSizeLimit' : 1000, 'simUploadLimit' : 1000, 'removeCompleted': true, 'onSelectOnce' : function(event,data) { $('#status-message').text(data.filesSelected + ' files have been added to the queue.'); }, 'onAllComplete' : function(event,data) { $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.'); php/] and i think this is the code for the create new folder [php <? mkdir("/wuploads/{$slide['email']}"); ?> php/] The email is stored on the users database as the field 'email' i then would like it to put the photos in the created folder which i think is something like this [php 'folder' : '/wuploads/$slide['email']', php/] The pictures go into the correct folder if i use this, however the create folder part of it doesnt seem to work. any help would be great, thanks |