[PHP] Script under Windows OK, under Linux, not...
Hi, I have the following code : $_fp = fopen("/home/dh2240/mgt/index.php", "a+") or die(); $_contents = fread($_fp,filesize("/home/dh2240/mgt/index.php")); fclose ($_fp); //Menu elements $_sme = strpos("$_contents","sub_menu_elements"); echo "sme = $_sme"; ... It should display somthing like "sme = 850", after finding the string in the specified file. Under windows, this script works fine (except replacing the "/home/dh2240/mgt/index.php" by "c:/apache/htdocs/mgt/index.php")... it seems that the file index.php cannot be opened under linux... The file is chmod 777, along with the directory /mgt, and the files identical, but still no luck... The fopen does not die(), but it does not seem to read any data from the file... I'm confused, and not sure how to check what is happening... Anyone got any ideas ? Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Script under Windows OK, under Linux, not...
It could be somthing to do with my hoster running Linux in Safe Mode... I am not sure what this could entail, so I'll keep looking. Again, if anyone has any info, it would be appreciated!!! Cheers, Daniel "Daniel Page" <[EMAIL PROTECTED]> a écrit dans le message news: [EMAIL PROTECTED] > Hi, > > I have the following code : > > $_fp = fopen("/home/dh2240/mgt/index.php", "a+") or die(); > $_contents = fread($_fp,filesize("/home/dh2240/mgt/index.php")); > fclose ($_fp); > file://Menu elements > $_sme = strpos("$_contents","sub_menu_elements"); > echo "sme = $_sme"; > ... > > It should display somthing like "sme = 850", after finding the string in the > specified file. > > Under windows, this script works fine (except replacing the > "/home/dh2240/mgt/index.php" by "c:/apache/htdocs/mgt/index.php")... it > seems that the file index.php cannot be opened under linux... > The file is chmod 777, along with the directory /mgt, and the files > identical, but still no luck... The fopen does not die(), but it does not > seem to read any data from the file... I'm confused, and not sure how to > check what is happening... Anyone got any ideas ? > > Cheers, > Daniel > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Protecting include files
If someone wants to call your .inc file like http://www.my.site/lib.inc they will see the code, as it is a text file. OK, we all know that. As the .inc file is in reality a renamed php script, containing variables, functions, etc, if you call it .php instead of .inc, it will be parsed by PHP, but as you have no output (echo or print() ), you will just see a blank page. To illustrate better, I use a large (20k) PHP library on my site. It was called stdlib.inc, but because of the problem listing .inc files, I renamed it stdlib.php. If you want to test, look here. You should only see a blank page, and not 1200 lines of code! http://www.dlpage.com/lib/stdlib.php Cheers, Daniel "Sid" <[EMAIL PROTECTED]> a écrit dans le message news: [EMAIL PROTECTED] > Hi, > > I have a php script which includes .inc files. Is there any way in which I > can prevent a normal surferfrom viewing these files. Is there any command > that I can add to a .htaccess file. > > Thanks > > ~~~ \\__ > ! SIDDHARTH HEGDE / CHAOSGAMERZ.COM ! > ! Webmaster \ For PC Game screeshots, cheat! > ! http://www.ChaosGamerz.COM o| o codes, trainers, downloads, ! >  To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to insert time and date into mysql?
The easiest way is to create a timestamp field (see manual depending on how you want to store the date, as you can go from to ddmmhhmmss...), and when you create your DB update query, use now(). for example, update a field with a new email address, and the user's current ip with the time of the update where his user id number is 123456789. UPDATE mail_address SET email = '$email', timesent = now(), ip = '$ip' WHERE user_id = 123456789; now() will set the value of the field timesent to the current time of the mysql server. Cheers, Daniel "Zenith" <[EMAIL PROTECTED]> a écrit dans le message news: 97jep3$sgu$[EMAIL PROTECTED] > How can I insert time and date into mysql table, > if the table i have to insert has a field of type time, and a field of type > date. > > Then how can I insert it in PHP, if I use time() function?? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Limit the amount of returns in a MySQL query
Hi All, Imagine I have a giant database table tracking email addresses (I don't but it is the first example that jumps to mind after my recent antispam campaign!). If i do a select * from mailaddresses; I will get all of the table. If i do a select * from mailaddresses where id < 10; I will get all the records where the id is less than 10... The problem is that I want 10 records, period, so if id is not a primary key, I could have 60 records that match... or if it is a P.K., but I delete 2 to 8, it will only return 2 records (1 and 9...) How can I structure the query to only return only 10 records ? the idea being able to construct a query where if there are more than 10 (or x) results on a page, you click on a link 'page 2' and so on, and the next query will return the next 10 (or x) records... Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Protecting include files
> I have used a few different Web hosting companies, and I > have never seen a case where my home directory was my > document root. I have always had a directory like > public_html/ or www/ that was my personal document root, so > as long as I don't place files in there, they are not > accessible via URL. > > Does your experience differ? I have experience with 3 hosters...My homepage - 10 ? a year, no frills, no tech support except via forum where I parked my domain. They allocate a web root directory (/home/dh) for my homepage,You control what you place there and everything is visible unless you .htaccess the directory. For work, our old ISP still has a hosting contract for our old site that is still active. You can get the company to create a directory with specific access rights for FTP access... but you cannot access these directories at all via the web server (lack of access rights for apache and php) - and their phone support is worse than what I pay 10 euros a year from my personal host, but that is another discussion! As for our 50 meg of space that we recieve at work from FT-Oleane with our internet access package, I believe that it is again a plain, no frills, no private directory visible root... I know that you can get much better services, but from there, you really need to go and rent a virtual linux box, and not just space on what is called here "mutualised hosting", or even trust your business oriented ISP to give you a professional hosting and online storage solution... but for that, the price is not the same... The final solution is to install a Linux gateway for the home network, and get a dynamic DNS solution up and running, and from there, you manage your own rights, and to heck with 200 sites on a box! (the bandwidth could be better too!) Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL for storing PHP code
Hi, Would it be possible to store PHP code in a MySQL table, then via a web page, connect to the DB, recover the code that corresponds to a certain id number, then include that code for execution? For example (quick, dirty, and untested!): $sql = "SELECT phpcode FROM phpstorage WHERE codeid = 1"; $result = mysql_query($sql); $_php_code = mysql_result($result, 0,"phpcode"); echo $_php_code; Will the echo (or print() ) just output code that can be read by the reader of the page, or will it generate output that will be executed? If the echo/print does not work, is there another way to do this? Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL for storing PHP code
Thanks for the comments everyone! eval() has just made my day :) Cheers, Daniel "Daniel Page" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hi, > > Would it be possible to store PHP code in a MySQL table, then via a web > page, connect to the DB, recover the code that corresponds to a certain id > number, then include that code for execution? > > For example (quick, dirty, and untested!): > > $sql = "SELECT phpcode FROM phpstorage WHERE codeid = 1"; > $result = mysql_query($sql); > $_php_code = mysql_result($result, 0,"phpcode"); > echo $_php_code; > > Will the echo (or print() ) just output code that can be read by the reader > of the page, or will it generate output that will be executed? > > If the echo/print does not work, is there another way to do this? > > Cheers, > Daniel > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Add a record and recover it's ID in one operation
Hi, Imagine a table with an auto-increment id number field and a text field for the username. User B (with user name 'johnny') could write to the database a millisecond after user A, with the same username. When user A looks for the last record written by Johnny, A will find the record entered by B. Is there a way to directly recover the auto-incremented number as like a return value (or somthing like that) of the write query as to be able to identify immediately what record you just wrote? This is just for argument's sake - I just would like to know if it is possible. My current solution is inserting the login time of the current user and/or IP, and adding that to make a temporary ID key where you select the latest entry written where username = your username and login time string = hhmmss info so you can immdately find your latest entered data, though recovering immediately the ID would have been a more elegant solution for this. Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add a record and recover it's ID in one operation
Thanks! I stand corrected. I'll check the PHP online manual more often, and for now, I'm off to optimise my database and rewrite a few queries :) Cheers, Daniel "Leif K-Brooks" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > www.php.net/mysql-insert-id > > Daniel Page wrote: > > >Hi, > > > >Imagine a table with an auto-increment id number field and a text field for > >the username. > >User B (with user name 'johnny') could write to the database a millisecond > >after user A, with the same username. When user A looks for the last record > >written by Johnny, A will find the record entered by B. > > > >Is there a way to directly recover the auto-incremented number as like a > >return value (or somthing like that) of the write query as to be able to > >identify immediately what record you just wrote? > > > >This is just for argument's sake - I just would like to know if it is > >possible. My current solution is inserting the login time of the current > >user and/or IP, and adding that to make a temporary ID key where you select > >the latest entry written where username = your username and login time > >string = hhmmss info so you can immdately find your latest entered data, > >though recovering immediately the ID would have been a more elegant solution > >for this. > > > >Cheers, > >Daniel > > > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php