PHP - Can't Access Directory Or File Through Php Code
I have a weird kind of problem.
I uploaded all upload-directories through FTP which have 777 permissions and owner name 'abc' This means I can access all of them through the codes. But while creating files inside those full permitted directories, the compiler complains for access denied. Meanwhile, a different directory is created with same name whose owner is 'apache' itself and the previous directory is lost. Then I cannot change the permissions of that directory through FTP. I don't if it is apache server's problem itself or not. Or is it a way to define user while creating/editing/deleting files and directories through php code itself? Similar TutorialsHello, folks. I am having a little trouble with this script. I want it to be able to read a directory, not just a file, and list all files in the directory along with their id3 tags. I can't get it to read all the files, it reads only the first file in the directory. Here, I'm posting the basic (stripped down) script, without mods or add-ons. I would appreciate any help. Thanks. Code: [Select] <?php require('error.inc.php'); require('id3.class.php'); $nome_arq = 'music.mp3'; $myId3 = new ID3($nome_arq); if ($myId3->getInfo()){ echo('<HTML>'); echo('<a href= "'.$nome_arq.'">Click to play: </a><br>'); echo('<table border=1> <tr> <td><strong>Artist</strong></td> <td><strong>Title</strong></font></div></td> <td><strong>Track</strong></font></div></td> <td><strong>Album/Year</strong></font></div></td> <td><strong>Genre</strong></font></div></td> <td><strong>Comments</strong></font></div></td> </tr> <tr> <td>'. $myId3->getArtist() . ' </td> <td>'. $myId3->getTitle() . ' </td> <td>'. $myId3->getTrack() . ' </td> <td>'. $myId3->getAlbum() . '/'.$myId3->getYear().' </td> <td>'. $myId3->getGender() . ' </td> <td>'. $myId3->tags['COMM']. ' </td> </tr> </table>'); echo('</HTML>'); }else{ echo($errors[$myId3->last_error_num]); } ?> I havent included the whole title as it wouldnt let me but I was wondering if someone could help me on this? I know this is possible as torrentflux caters for this but unsure of where to start. I dont want to allow file or directory uploads or creation in my /etc/php.ini file (this is turned off). Yet then torrentflux allows me to link a torrent from an external source (using legal downloads of course ) but then it uploads it on my server and creates folders on a per user basis. How is this possible can someone give me some pointers please? I look forward to any replies, Jeremy. Hi guys, I am making a site where users upload files (like images, pdfs, etc) to the server. My question is, how does Facebook handle file permissions, restricting access to files uploaded to their servers based on what a user sets? Because I need to implement a similar thing and have no idea how to do it in a clean way. I have had two thoughts on storing the files 1) in a DB or 2) in a folder out of the wwwroot, which would prevent access by anyone without knowing the path (or some such) but it is the more "real" permissions implementation I am stuck on. I obviously would like to achieve this with PHP and MySQL(i). Any help is much appreciated. Cheers in advance. I'm in the middle of making my own CMS system, where a user can create a page online via a text editor, I know how to create and save the file, but to make the process easier I would like to a function where a user can click a button find a list of files and folders, pick the folder location to save a new file to. Instead of having to type something like this /commonPages/aboutUs/ with the file name being test.php What would be the easiest way to do this? I have just been looking at opendir() and my first thought was to use <input type="file" />, but then I remember that was only for inputting a particular file name, which would be useful for renaming a file at a later date. For example, if we wanted to change test.php to something more meaningful ie history.php In my script, I'm trying to create a file with the name of a variable in a different directory. My code is: Code: [Select] $handle = fopen("cheese/" . $page . ".html", "w");Output: Warning: fopen(cheese/test.html) [function.fopen]: failed to open stream: No such file or directory in /home/a5938041/public_html/newfile/newpage.php on line 6 What's happening here? (sorry I'm a total noob.) Why does this code: Code: [Select] require_once "../../media/php/classes/Mysql.inc.php"; Work when I go to: http://mysite.com/API/v1/index.php But when I go to: http://mysite.com/index.php it doesn't work. The require is being called from another class, which I call from the two pages above. The class loads, but in the second link, I get failed to open stream: No such file or directory but the first one works fine. What would cause this? could this be an htaccess thing? htaccess: Code: [Select] Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ /$1.php [L,QSA] I have a file that an ajax function calls on my site, and I want to make sure only the right pages access it. For example. I have page called home (home.php) and on that page i have an ajax call, which calls a file called ajax.php. I want to make sure that when ajax.php is being executed, it is being executed via an ajax call, which is coming from the home page. is this possible? Is it possible to allow a script running on another server to write/read a specific file on my server? I can set file permissions, but not having any luck with file paths due to php5 blocking http:// urls. Hello everybody , This is my first topic here and I hope I will find the solution for my problem. I want to restrict access to file (for exemple: http://www.mysite.com/files/file0000.zip) to a just a specific IP that will be read from the database. And also store all other IPs trying to access this file. Can this be done, maybe through some php and htaccess? Thank you for any help or any other ideas. Hey, I dont know whats wrong but i was hoping someone could take a look at the code and provide some errors that maybe causing this script not to work. I want it to display all the .jpg pictures in thumbnails, it currently does not even get the pictures. code: <?php $pic_listing = mysql_query("SELECT * FROM toplist WHERE id='". $id ."'") or die(mysql_error()); while($serverpic = mysql_fetch_array($pic_listing)) { $servername = $serverpic["servername"]; } $directory = "images/serverpic/" . $servername . ""; $images = glob("" . $directory . "*.jpg"); if(empty($images)) { ?> <div class="highslide-gallery"> <?php foreach($images as $image) { ?> <a href="images/serverpic/<?php echo $servername . "/" . $image; ?>" class="highslide" onclick="return hs.expand(this)"> <img src="images/serverpic/<?php echo $servername . "/" . $image; ?>" alt="Highslide JS" width="100" height="100" title="Click to enlarge" /> </a> <div class="highslide-caption"> <?php } ?> </div> </div> <?php } ?> hey guys im tyring to read my directory (whole of the web server)...i want to be able to put the file name and root into an array...im just wanting to know whats the best function i need to do this please?...thank you After a user on my site deletes their account I want their profile picture to be deleted from my images folder. I was testing the unlink function on my index.php file and it is failing. Here is the error: Warning: unlink(/assets/img/avatars/users/jasongordon.png): No such file or directory in /home/www-data/big.com/index.php on line 86 My code was just: unlink('/assets/img/avatars/users/jasongordon.png'); I'm not sure why this fails because my file does exist. file_get_contents() has suddenly stopped working for me. I keep getting this error: Code: [Select] Warning: file_get_contents(/Users/ttocskcaj/MineCMS/public/js/jquery.js ) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /Users/ttocskcaj/MineCMS/controllers/m.controller.php on line 44 The file(s) definitely exist, I can use nano to open them, and permissions are 777 on all the files. The lampp error log has nothing. Not even a No such file or directory error as you'd expect. Any ideas what's going on? I have a file system browser i'm writing for a client. I would like to know if there's a way to determine if an object is a directory or file, so I can display a proper icon next to it depending on what it is. Any help is appreciated. Hi,
I have this code
<?php // Must include this include("geoiploc.php"); function getYJLINKS($default_font_family,$yj_copyrightear,$yj_templatename,$show_tools,$show_fres,$show_rtlc,$validators_off,$totop_off){ $allLinks = array(); if((function_exists('toolbox_urls') && $show_tools == 1) || $validators_off == 1 || $totop_off == 1){ echo '<div class="validators">'; if($validators_off == 1){ $allLinks[] ='<a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3" target="_blank" title="CSS Validity">CSS Valid</a>'; $allLinks[] ='<a href="http://validator.w3.org/check/referer" target="_blank" title="XHTML Validity">XHTML Valid</a>'; } if($totop_off == 1){ $allLinks[] ='<a class="yjscroll" href="#stylef'.$default_font_family.'">Top</a>'; } if (function_exists('toolbox_urls') && $show_tools == 1): global $font_size; global $font_direction; if ($show_fres == 1): $allLinks[] = '<a id="fontSizePlus" class="fs" href="javascript:;" rel="nofollow">+</a>'; $allLinks[] = '<a id="fontSizeMinus" class="fs" href="javascript:;" rel="nofollow">-</a>'; $allLinks[] = '<a id="fontSizeReset" class="fs" href="javascript:;" rel="nofollow">reset</a>'; endif; if ($show_rtlc == 1): $allLinks[] = '<a class="tdir" href="'.$font_direction[1].'" rel="nofollow">RTL</a>'; $allLinks[] = '<a class="tdir" href="'.$font_direction[2].'" rel="nofollow">LTR</a>'; endif; endif; echo implode(' | ',$allLinks); echo '</div>'; } // loading this from a database $ip = $_SERVER["REMOTE_ADDR"]; // listing Country Flags Images $dir = 'images/flags'; $file_display = array('png'); if (file_exists ($dir) == false) { echo 'Directory \'', $dir, '\' not found!'; } else{ $dir_contents = scandir($dir); foreach($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); If($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) if($file == '..' || $file == '.') { continue; } $code = strtolower(getCountryFromIP($ip, "code")); echo '<div class="yjsgcp">Palana.it ® 1994 - '.$yj_copyrightear.' :: Tutti i diritti riservati :: Realizzazione Palana.it ││ Utente rilevato: IP: '. $ip . ', '.getCountryFromIP($ip, " NamE ").' ('.getCountryFromIP($ip, "code").'-'.getCountryFromIP($ip, "AbBr").') '; echo '<img src="', $dir, '/', $code, '.png" /> </div>'; } } } ?>The problem, as we see (http://www.palana.it), is that code printed the Italian flag but many times there are images in the directory, that is over 204. See bottom of the page. How can I fix the code to get ONE display? $file="../myclients/clients/".$company_name."/Download/".$file_name; $size = filesize($path); // not working i try with function also function formatbytes($file, $type) { switch($type){ case "KB": $filesize = filesize($file) * .0009765625; // bytes to KB break; case "MB": $filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB break; case "GB": $filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625; // bytes to GB break; } if($filesize <= 0){ return $filesize = 'unknown file size';} else{return round($filesize, 2).' '.$type;} } echo formatbytes($file, "KB"); uploaded file size is 488 kb but it showing "unknown file size" please help me. I have a MS Access database file hosted on my Godaddy server. I would like a simple php script to be able to access it and return values from it when I enter info from drop down boxes. Eg column one is item name Column two is price Column three is items remaining I want to pick an item from column one and have the appropriate values from columns two and three returned. I have done many searches but most reveal php scripts that interrogate SQL databases. Excuse my ignorance but are these what I want? If not can anyone please get me going on a php script? Ideally I don't want to change the format of the MS access database - I have it in xls and simply export and save it to access. If there is a simple way of reading directly from a specific tab in Excel that would be a better solution. Thank you. I've got a question, I thought I'd be able to do this fairly easily. I don't want to do an .htaccess solution also. I tried this, define('ACCESS', TRUE); // then on other page if(!defined('ACCESS'){die('Direct access not allowed.');} Need some assistance, appreciated. A shipping vendor (like Stamps.Com) provides me a Printable Shipping Label to display on my website for Visitors to print.
When Visitors come to my page, my PHP code:
$Shipping_Label_Data = $LabelVendor->data[0]->contents; // vendor's API echo '<img src="/Label-Directory/'.$Order_Number.'.png" />'; Later I realized the security flaw: any snooper can fish for other Visitor's labels in my Label directory. What is the best way to prevent the display of other people's labels? Thank you!! RewriteCond %{HTTP_HOST} !^www.example.com.au$ [NC] RewriteCond %{HTTP_HOST} !^https://www.example.com.au$ [NC] RewriteRule ^(.*)$ http://www.example.com.au/$1 [R,L]Hi All I have my website 90% working on https, fully working on http and I have managed to redirect from none www to www What I am looking to do it if the user happens to enter https then make them go to my www version I have manage to get them to go to my www version if they do not put in www but I am lost in how to redirect them from https to http here is what I have so far and I just cannot figure it out thanks Alan |