PHP - Can't Open A Folder
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; } } Similar TutorialsThis topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=308625.0 Hello all, i am go9090go. Today i made a domains for a jar file people can upload from my website. I made this to make the jar file close source and its easy to update. Now i made a java classloader and everything i made works. The classloader call a php document with the password and username. The pass and name will be checked inside a databse and if its inside i use header() to load the jar file. But when i just go to my main domain i get the index of the site and people can easly download the jar file without have to walk thru the php pass checker. So i want to place the jar file inside a protected folder,and i want that only way you get acces to this jar is by the php file. How can i get a file from a protected folder? here is the php used when the jar file is not inside a protected folder: <?php $DBName = "name";//name database $DBUser = "name";//user $DBPassword = "pass"; //passs $DBHost = "host"; //might be different mysql_connect($DBHost, $DBUser, $DBPassword); mysql_select_db($DBName); $username = $_GET['username']; $password = $_GET['password']; $IP = $_SERVER['REMOTE_ADDR']; $string = "Java"; $pos = strpos($agent, $string); if (!strpos($_SERVER['HTTP_USER_AGENT'], "Java")) { echo("Your Auth has been banned for trying to breach security."); //mysql_query("delete from users where username='$username'"); exit(); } $query = "select * from users where name='$username' and pass='$password'"; mysql_query($query); $num = mysql_affected_rows(); if ($num > 0) { header('Location:script/Script.jar'); } ?> now i want to use the header to a file inside a folder that is protected : so how can i make the header() methode to open script.jar inside a protected folder. The folder haves name and pass: blabla,balbla for exempel thanks for help Hi,
I'm newbie. My requirement is to open network shared folder from PHP.
This works fine in IE but not in Chrome.
Can anyone please help me ....
Thanks
I 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'm trying to open a URL using fopen() and I keep getting this error: Code: [Select] Failed to open stream: Permission deniedI can not work out what is wrong, it's not a firewall as far as I can tell. 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? Not to say that this occurs in every php software out there, but I far too occasionally notice that the application is written with scattered php open and close tags, for instance
<?php if(true) ?> <?php { ?> Blah blah blah, because it's true <?php } else { ?> because it's not true <?php } ?>To me, it is extremely irritating. Regardless, I see a lot of open source software written this way and I can't help but think that there must be some underlying reason for it. Magento, for example, is written exactly in this manner. The templates are infested with these opened and closed php snippets. Obscurity is not security so I'm ruling security reasons out. Maybe it is more efficient? -- But I couldn't understand why, if so. It seems like that would put more of a drag on the system itself causing php to start and stop parsing continually and excessively, then again, I'm no expert in the field of memory consumption and other operating system complexities. Honestly, in my opinion, it is stupid. i would never write a program that way.. HEREDOCs are much more useful and eye pleasing than that awful <?php { ?> I had the misfortune a few months ago when I purchased an invoicing/customer maintenance system that I didn't know was written for PHP 5.2 or something lower, one that allowed short tags; and thus short tags were used in the same manner as I've described. Is this just plain disorganization or is there some deep-seated inner lining advantage that I'm not aware of? 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 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. <?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? 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? 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 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 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. 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 |