Jump to content

Search the Community

Showing results for tags 'directories'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 6 results

  1. Here is my code which i use to recieve uploaded files. $filepath = $_SERVER['DOCUMENT_ROOT'] . "file/"; $fileunzippath = $filepath."unzipped/"; $exclude_list = array(".", "..", "...", "index.php", ".php", ".htaccess"); if($_FILES["zip_file"]["name"]) { $filename = $_FILES["zip_file"]["name"]; $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; $name = explode(".", $filename); $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); foreach($accepted_types as $mime_type) { if($mime_type == $type) { $okay = true; break; } } $continue = strtolower($name[1]) == 'zip' ? true : false; if(!$continue) { $message = "The file you are trying to upload is not a .zip file. Please try again."; } $string = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $filename); $clean_name = strtr($string, array('Š' => 'S','Ž' => 'Z','š' => 's','ž' => 'z','Ÿ' => 'Y','À' => 'A','Á' => 'A','Â' => 'A','Ã' => 'A','Ä' => 'A','Å' => 'A','Ç' => 'C','È' => 'E','É' => 'E','Ê' => 'E','Ë' => 'E','Ì' => 'I','Í' => 'I','Î' => 'I','Ï' => 'I','Ñ' => 'N','Ò' => 'O','Ó' => 'O','Ô' => 'O','Õ' => 'O','Ö' => 'O','Ø' => 'O','Ù' => 'U','Ú' => 'U','Û' => 'U','Ü' => 'U','Ý' => 'Y','à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a','å' => 'a','ç' => 'c','è' => 'e','é' => 'e','ê' => 'e','ë' => 'e','ì' => 'i','í' => 'i','î' => 'i','ï' => 'i','ñ' => 'n','ò' => 'o','ó' => 'o','ô' => 'o','õ' => 'o','ö' => 'o','ø' => 'o','ù' => 'u','ú' => 'u','û' => 'u','ü' => 'u','ý' => 'y','ÿ' => 'y')); $clean_name = strtr($clean_name, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $clean_name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $clean_name); $target_path = $filepath.$clean_name; // change this to the correct site path if(move_uploaded_file($source, $target_path)) { echo "Source: ".$source."<br/>"; echo "Type: ".$type."<br/>"; echo "Filename: ".$filename."<br/>"; $zip = new ZipArchive(); $x = $zip->open($target_path); if ($x === true) { $zip->extractTo($fileunzippath.$clean_name); // change this to the correct site path $zip->close(); $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } } $message = "Your .zip file was uploaded and unpacked."; } else { $message = "There was a problem with the upload. Please try again."; } } Specifically i want to highlight this part: $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } When I upload a zip file containing 2 directories(one called 'part0', and one called 'bad'), they get unzipped correctly and it gives no errors, however the fake directories(not called part0 or part1) I put in there are still there. Any Help?
  2. Hi I am frustrated from this simple task, I've been testing this script for two hours trying to find the problem but no luck! My script reads a command line argument(ARGV[0]), then creates a directory named as #{ARGV[0]}, then it reads the DATA object (after the __END__ which looks below), and create those directories inside ARGV[0] __END__ app/views/layouts app/models app/controllers config db doc lib public/javascripts public/stylesheets public/images log note that I am using Notpad++ and i have EOL set to UNIX, so it is NOT supposed to cause any \n troubles My script creates what looks like directories, i can see them in my FTP but I can't delete any! when I asked my instructor about it, he said, review your code, lib (directory) is NOT like lib? so I am wondering where did the question mark come from? also note that I do NOT see ? when i use SSH client or FTP! i had to run another script to delete these weird directories this is my script require 'fileutils' include FileUtils if ARGV.empty? puts "__________________________________________ _ _" puts " " puts "USAGE: ruby script/generate.rb Your_Site_Name" puts "__________________________________________ _ _" elsif Dir.exists?("/home/students/myname/public_html/cis113/#{ARGV[0]}") puts "This directory already exist!" puts "Would you like to use the existing directory (Y/N)?" #I need help with this part later #read DATA and create directories else Dir.mkdir("/home/students/myname/public_html/cis113/#{ARGV[0]}") DATA.each do |line| FileUtils.mkpath ("/home/students/myname/public_html/cis113/#{ARGV[0]}/#{line}") end end help is highly appreciated
  3. Hi guys, I am trying to understand these questions regarding function and how or where can i get some knowledge to understand and create the code. questions are: 1. Open the text file “status.txt” as read only using variable $handle to store the file handle. 2. Begin a session. (what does it mean begin session? does it mean start using the if condition?) 3. Return the number of elements in array $days. 4. Convert an array $data with five elements into a string that is delimited by tab. (what does it mean by delimited by tab?) 5. Check if the form text item "status" obtained via get method is empty. Thank you in advance!
  4. Thank you for your time. I am not sure where this really belongs the HTML, CSS, Application Design or one of the PHP topics. So I figured I would post here. In my search I have found topics that come close to my question but have not provided a fix for my issue. So I'm asking for help. That and I am a beggining Web Developer. Problem: the php includes I use are not displayed on web pages in subdirectories. If I add ../ to the php include so it is like this: <?php include ("../menu.php"); ?> on the newpage.php only some of the included files are shown on the page in the subdirectory. All links on the file newpage.php now act as though they were written <a href="../menu.php">link</a> and don't work. They are acctually written <a href="menu.php">link</a>. Directory & Files / index.php header.php footer.php menu.php <!-- contains all links for site --> style.css subdir/ newpage.php newpage.php include code <div id="links"> <?php include ("menu.php"); ?> </div> Question? How do I fix it so that the menu.php and other included files are shown on the subdir pages? How do I make the links properly reflect the location. Since absolute or relative pathing appears to muck it up. FYI: I do not have CLI access to the server. Only ftp access. Thanks again for any help you may provide.
  5. Hi, We've recently purchased a website at work and have it up and running on the previous owners server at a cost, we can't have FTP access to this for some reason so attempting any changes is a pain. I've got the files from the owner and am trying to set them up on WAMP to ensure that i can move over and setup / develop when needed. I received 3 files which i'll list below: SQL file SITENAME.com Folder PHP Folder Initially i thought that i should merge the php and sitename folders together (which i did) - this allowed the majority of things to work on the front end of the site but then when i went to go to the admin directory /admin/ i received a tonne of errors about missing filepaths etc. trying to resolve appears to lead me around 30 different files which i need to change a require_once function on. I'm thinking it's got to be easier than this but obviously i'm not entirely sure what i'm supposed to do with said folders? Anyone have any ideas? (and apologies if this isn't in the correct category.) Thanks, Reece
  6. Hello. I'm having trouble understanding the below code: <?php $dirName = 'secondDir'; $handle = opendir($dirName); while($printFiles = readdir($handle)){ if($printFiles != '.' && $printFiles != '..'){ echo "<a href = '".$dirName.'/'.$printFiles."'>".$printFiles."</a></br>"; } } closedir($handle); ?> Specifically, it's the if statement that's giving me a hard time. I know what it is, and I know what it does, but I don't understand the logic behind the condition; how does it work to remove the dots before the file list? Are the dots part of the readdir structure? If they are, then how come they can be removed by asking to print out a file list IF they aren't a part of it? I'm not sure if I am making any sense, but if anybody understands, could you please explain this to me? Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.