Re: [PHP] ftp_connect returns false
On Thursday 19 August 2004 13:43, DBW wrote: Just to clarify a point, does it matter where you are coming from and executing the php script? i.e. I am using a browser that is behind a firewall blocks ftp (hence why I am trying to set up this ftp stuff through php). I am pretty sure that it doesn't, since I have used other sample scripts around the web run on their own server and they work fine. Just want to check to make sure this is actually the case. The ftp connection is made from where the php script resides. Which means on the webserver. So if the host has blocked outgoing ftp connections from the webserver you're hosed. That is why I suggested that you try an ftp connection to the webserver itself (from the webserver of course): 1) I'm assuming that your host machine has both the webserver installed (obviously) and that it has an ftpserver (for you put stuff into your webspace). 2) I'm further assuming that your host has not blocked ftp connections coming from localhost Thus if you're able to connect locally then it is a good indication that php's ftp functions are not a fault, and that it is the host's network configuration that is preventing you from making outgoing ftp connections. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* He that breaks a thing to find out what it is has left the path of wisdom. -- J.R.R. Tolkien */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] oop too slow
Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] ||| [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Thanks a lot help Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] oop too slow
Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] || | [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Thanks a lot help Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: oop too slow
On Thu, 19 Aug 2004 11:21:16 +0200, Krzysztof Gorzelak wrote: Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Why are you doing 300(!!!) mysql queries? I guess you can retrieve the same data with much less queries. 300 queries are slow ... not OOP. thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: oop too slow
maybe you can rewrite your SQL statements in a way that will improve retrieval time. Google for it. things like select * from ... when you are not using all fields is bad practise. there are many others. Angelo Thomas Seifert [EMAIL PROTECTED] 8/19/2004 11:33:05 AM On Thu, 19 Aug 2004 11:21:16 +0200, Krzysztof Gorzelak wrote: Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Why are you doing 300(!!!) mysql queries? I guess you can retrieve the same data with much less queries. 300 queries are slow ... not OOP. thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: oop too slow
Krzysztof, Take a look at some PHP Profiling extensions, such as Advanced PHP Debugger or XDebug. This will help you locate the slow parts of your script. Krzysztof Gorzelak [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] ||| [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Thanks a lot help Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php with mysql ( support data manipulation or not )??
Hi , Regarding to php with mysql , if the php with mysql implement data manipulating like (insert , update , delete ..etc) or just implement the query operation only ??. Best Regards,, ayman amin Egypt - Cairo
[PHP] Re: oop too slow
Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Why are you doing 300(!!!) mysql queries? I guess you can retrieve the same data with much less queries. 300 queries are slow ... not OOP. Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: oop too slow
Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Why are you doing 300(!!!) mysql queries? I guess you can retrieve the same data with much less queries. 300 queries are slow ... not OOP. Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need Someone to Develop a Project
We have an organization that conducts an annual music awards show. I have written a specification for a nominating module that we would like to develop to replace the paper ballot system. I'm not a PHP developer, but based on my research, this project should be straight forward, using PHP and MySQL. Since there is not a big pile of money available, it may be more expensive than we can afford, but if there are any experienced developers looking for new projects, please contact me off list, and I will forward a copy of the spec to you. The project needs to be completed with a week to 10 days, so if you're swamped, no need to take a look. No beginners, please. Project portfolio required for selection. It is possible that this newsgroup is not the appropriate forum for this request. Is there a site somewhere where I can post the spec and invite bids? I recall that there are several, but I cannot remember where they are. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php with mysql ( support data manipulation or not )??
[snip] Regarding to php with mysql , if the php with mysql implement data manipulating like (insert , update , delete ..etc) or just implement the query operation only ??. [/snip] You can do any SQL operation with PHP and MySQL. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: oop too slow
[snip] Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... [/snip] So let me see if I understand. It takes 1.2 seconds to generate 1500 objects (30*10*5)? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Links with parameters in DB
Hi!! I have links saved in the DB and some of them may have parameters. Those parameters may come from a php variable. The problem is that when I recover the link form the DB I get the link plus the name of the variable instead of its value. Here is an example: I have this in the DB: | Link | | orders.php?idorder=$idorder | And the code: (Suposed idorder=5) .. Connect to the DB .. $link=eval(mysql_result($result,$i,link)); . . and then i put this: a href=?=$link?Link to order/a But what i see the link i see this: orders.php?idorder=$idorder Instead of: orders.php?idorder=5 What am I doing wrong? I´m despearte, Help please Thanks in advance ;)
RE: [PHP] Re: oop too slow
[snip] Yes it does. Do you think it's not so slow ? [snip] Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... [/snip] So let me see if I understand. It takes 1.2 seconds to generate 1500 objects (30*10*5)? [/snip] How large are the objects? I do not think that this is too slow. How fast do you think it should be? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Links with parameters in DB
[snip] $link=eval(mysql_result($result,$i,link)); [/snip] Try just eval on the field you pull from the database... echo eval($databaseItem) then work your processing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP:Problem with Japanese data
Hi Gurus, (B (BI am using PHP 4.3.8 on Linux with Postgres 7.3.4. (BThe problem is I am unable to insert some japanese datat in the database (Busing PHP. (BI am sending you the character which gives problem, its "$BG=(B". (BThe problem arises when user enters only this characters and tries to save. (BIf this character is in between a string then data gets inserted but, when I (Bretrieve the data from database. (BThe above given character is corrupted. (B (BCan anybody please help me this regard. (B (BThanking you all in anticipation. (B (BRegards, (B (BUmesh. (B*** (BUmesh A. Deshmukh. (Bmanas solutions pvt. ltd. (B+91-20-4223991/2 (B***
RE: [PHP] Links with parameters in DB
[snip] $i=0; $q=select * from links'; while ($imysql_num_rows($result)) { $link=eval(mysql_result($result,$i,link)); . . and then i put this: [/snip] What happens if you do this? while($i mysql_num_rows($result)){ $link = eval($result); echo $link; } P.S. Please reply to the list too, I am quite busy and may not be able to follow up. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: oop too slow
[snip] [snip] Yes it does. Do you think it's not so slow ? [snip] Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... [/snip] So let me see if I understand. It takes 1.2 seconds to generate 1500 objects (30*10*5)? [/snip] How large are the objects? I do not think that this is too slow. How fast do you think it should be? As fast as java is. Object are as simple as String objects in Java. There are only few methods, constructor and __soString. It should get data from base and return one line of html code. [/snip] You cannot compare JAVA to PHP because the methodologies are so different. And personally I find Java to be terribly slow when working with externally stored data. We have pretty much stopped developing in Java P.S. Always reply to the list, not directly to someone unless they ask you to. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Links with parameters in DB
It doesn´t work, I have other fields in the DB apart from the field 'Link', so if I use $link = eval($result); I get a parse error. Apart from that, I have to write the name of the field (link), if not the server won´t know the field I´m refering to. Thanks - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: WebMaster. Radio ECCA [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, August 19, 2004 1:28 PM Subject: RE: [PHP] Links with parameters in DB [snip] $i=0; $q=select * from links'; while ($imysql_num_rows($result)) { $link=eval(mysql_result($result,$i,link)); . . and then i put this: [/snip] What happens if you do this? while($i mysql_num_rows($result)){ $link = eval($result); echo $link; }
RE: [PHP] Links with parameters in DB
[snip] It doesn´t work, I have other fields in the DB apart from the field 'Link', so if I use $link = eval($result); I get a parse error. Apart from that, I have to write the name of the field (link), if not the server won´t know the field I´m refering to. [/snip] Then did you eval that? I meant for you to use a proper rendering of the eval statement by itself, i.e. $sql = SELECT * FROM table ; $result = mysql_query($sql, $connection); while($row = mysql_fetch_array($result)){ $link = eval($row['Link']); echo $link; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Links with parameters in DB
I tried what you said but i get an eval error: Parse error: parse error, unexpected '=' in /index.php(135) : eval()'d code on line 1 ;( - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: WebMaster. Radio ECCA [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, August 19, 2004 1:38 PM Subject: RE: [PHP] Links with parameters in DB [snip] It doesn´t work, I have other fields in the DB apart from the field 'Link', so if I use $link = eval($result); I get a parse error. Apart from that, I have to write the name of the field (link), if not the server won´t know the field I´m refering to. [/snip] Then did you eval that? I meant for you to use a proper rendering of the eval statement by itself, i.e. $sql = SELECT * FROM table ; $result = mysql_query($sql, $connection); while($row = mysql_fetch_array($result)){ $link = eval($row['Link']); echo $link; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Links with parameters in DB
[snip] I tried what you said but i get an eval error: Parse error: parse error, unexpected '=' in /index.php(135) : eval()'d code on line 1 [/snip] You will probably have to escape the equals sign -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Links with parameters in DB
[snip] [snip] I tried what you said but i get an eval error: Parse error: parse error, unexpected '=' in /index.php(135) : eval()'d code on line 1 [/snip] You will probably have to escape the equals sign [/snip] Have you RTFM on eval? http://www.php.net/eval You have to use valid PHP code. Your stored code is currently not valid if I read this correctly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Links with parameters in DB
On Thu, 19 Aug 2004 14:01:45 +0100, WebMaster. Radio ECCA [EMAIL PROTECTED] wrote: I tried what you said but i get an eval error: Parse error: parse error, unexpected '=' in /index.php(135) : eval()'d code on line 1 ;( - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: WebMaster. Radio ECCA [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, August 19, 2004 1:38 PM Subject: RE: [PHP] Links with parameters in DB [snip] It doesn´t work, I have other fields in the DB apart from the field 'Link', so if I use $link = eval($result); I get a parse error. Apart from that, I have to write the name of the field (link), if not the server won´t know the field I´m refering to. [/snip] Then did you eval that? I meant for you to use a proper rendering of the eval statement by itself, i.e. $sql = SELECT * FROM table ; $result = mysql_query($sql, $connection); while($row = mysql_fetch_array($result)){ $link = eval($row['Link']); echo $link; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php try this eval(\$link = \$row[Link]\;); echo $link; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mkdir() permissions
Dear List! Anyone out there using cPanel? Perhaps you could instruct me as to how to rebuild PHP, assuming we have similar file structure, such that cPanel seems to do. Many kind regards! Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validate XML data
It is possible to validate a XML document with XML Schema Definition Language (XSDL). Is it possible to use XSDL in Php? Thanks, Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] managing cvs from php
Hi, I use cvs from my internal projects and will soon need to let others change template files from a web form. The user will load the current template, edit, preview and if ok publish. Since I'd like to keep a history and track those changes one option for me would be to add a cvs call with a commit off the changed file. I do not need to do other fancy functions. Just commit and get the result if it worked. My current (not working) test script is simply $cmd = cd .$pathToFile. ; /usr/bin/cvs ci -m '.$logMsg.' .$file ; passthru($cmd) ; If I echo the $cmd and paste in a shell the command works. When I execute from web nothing happens and no output is seen (error_reporting(E_ALL)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cannot Load DLLs (WinXP, Apache 2, PHP 5)
I can't get PHP to load php_mysql.dll, required to use the mysql_*() functions. I have tried a variety of values for extension_dir, including C:/php/ext, C:\php\ext, C:\php\, ./ext/, ext/. I have copied php_mysql to all these directories, but it is not loading it. PHP is stored in C:/php, and works perfectly apart from not finding the MySQL dll file. If you could advise me for how to get PHP to load this DLL, I would be very grateful! This was just disussed a few days ago. Copy the libmysql.dll file **that comes with PHP5** into the windows/system32/ directory. New installation instructions exist that recommend never copying any files to the Windows system directory. It's preferred to leave all files in the PHP directory and make it (the PHP folder) available to the systems PATH by editing the appropriate system environment variable. People copy files into the Windows system directory because it's in the PATH so no additional setup is required. Do not fall into this trap. Add the PHP directory to your PATH as doing so will make the world a better place. The updated manual is as follows: http://php.net/manual/en/install.windows.manual.php If setup this way the above problem would not exist, PHP will find libmysql.dll. A FAQ on editing the systems path is here: http://php.net/manual/en/faq.installation.php#faq.installation.addtopath Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Someone to Develop a Project
It is possible that this newsgroup is not the appropriate forum for this request. Is there a site somewhere where I can post the spec and invite bids? I recall that there are several, but I cannot remember where they are. http://www.php.net/links.php#jobs Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] managing cvs from php
$cmd = cd .$pathToFile. ; /usr/bin/cvs ci -m '.$logMsg.' .$file ; passthru($cmd) ; If I echo the $cmd and paste in a shell the command works. When I execute from web nothing happens and no output is seen (error_reporting(E_ALL)) Does the apache user have read/write privileges on the files in that directory? CVS makes heavy usage of stderr, so that may be a reason you are not seeing output. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/PearDB works on commandline but not via http....
Justin Patrin wrote: Did you try: if(PEAR::isError($db)) { echo $db-getMessage().' '.$db-getUserInfo(); } It's probably because: 1) the postgres the module isn't in the PHP that apache is using 2) the postgres module isn't loaded in the PHP that apache is using 3) the postgres module in the PHP that apache is using is connecting via a socket instead of a port (or vice-versa) I think you may have something with the apache module points. I'll ask if apache has been built or is just the install from the linux distro. I built apache previously, but I didn't install this machine Thanks for the ideas, Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate XML data
It's possible in PHP 5, but not in PHP 4 And I advise to use the most recent libxml2 libraries, since they made big improvements concerning XSD support lately chregu On Thu, 19 Aug 2004 17:11:47 +0200, Jacob Friis Larsen [EMAIL PROTECTED] wrote: It is possible to validate a XML document with XML Schema Definition Language (XSDL). Is it possible to use XSDL in Php? Thanks, Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [EMAIL PROTECTED] | gnupg-keyid 0x5CE1DECB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: oop too slow
You could simply recall the constructor if the object exist. This way you do not create the objects for every data entry you have and aviously it will use less ressources. Also like someone else told you, Get a Debuger! It will point out the slow part of your code. For example i had 30 000 lines of code in php5 oo (templating system + e-com) to generate a page it would take 0.3 seconds. I concider this as not too bad. Yann On Thu, 2004-08-19 at 07:26, Krzysztof Gorzelak wrote: Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Why are you doing 300(!!!) mysql queries? I guess you can retrieve the same data with much less queries. 300 queries are slow ... not OOP. Well, I changed my script a little for tests and turned off the queries. Now I'm setting some defaults data to those 300 objects but it's still too slow. I create for every value, key and product a different object so it's in fact 30*10*5 objects. Then I run __toString() method one by one and generate my page. Is it proper to creating a separate objects for all values ? It makes my code much more easy... Krzysztof Gorzelak [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Security Workbook
Chris Shiflett wrote: This news is a bit old, but I have made the workbook for my OSCON tutorial freely available from this URL: http://shiflett.org/php-security.pdf It's a 55 page PDF that has a lot of information (more than the slides) about some of the more important security topics. I hope you find it helpful. Chris I printed this out the day you sent it, but it had been sitting on my desk, unread, until today. Just got finished with it. Very helpful methods. I thank you sir. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate XML data
It's possible in PHP 5, but not in PHP 4 Could you link me to the documentation? And I advise to use the most recent libxml2 libraries, since they made big improvements concerning XSD support lately It is possible to validate a XML document with XML Schema Definition Language (XSDL). Is it possible to use XSDL in Php? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nonstandard SMTP line terminator
Hi, I am using mail() with php 4.3.8 on FreeBSD 4.10 to send bulk mail. Although I use \r\n in the header parameters, some mail servers respond with Nonstandard SMTP line terminator. What can I do? Thanks, Ufuk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] oop too slow
on 19/8/04 9:49, Krzysztof Gorzelak at [EMAIL PROTECTED] wrote: Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] ||| [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? This is something that I've wrestled with too. If you make each item you deal with a clean, self-sufficient object, with self-storage, data hiding etc, it is inevitable that you run into this problem. It is a symptom of a fundamental clash between Relational DB and OO points of view. The only trick I have found to work around it that is OO-clean is to use factory methods or objects that create multiple objects from a single DB query, so as well as having a 'get' method that populates an object from a DB, make another means of creating an object from local data that has been obtained from a larger query that returned sufficient values to populate multiple items. I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Yes, that's the correct way to represent a M:M relation in a relational DB. The join table is an artefact of a relational model, rather than an OO one, so the answer is to hide the existence of this table within the objects at either end - so have product and key objects, but not product_key objects. Each object should have a method that retrieves instances of all the related objects of the other kind. This is really a different manifestation of the first problem. Ultimately the trick is to create separate factory objects or higher-level methods inside the existing objects that can create multiple instances from a single database query. Having said that, it's difficult to spot the best places to do this. For example, you might normally create multiple product objects from an array of database IDs like so: foreach($productids as $id) $products[] = new product($id); You can see that this would cause a query for each instantiation. With a product factory class, you might do this instead: $products = product_factory::get($productids); Which achieves the same result, but using only a single DB query (hidden inside the factory class, which does NOT call the product class in the same way!). The next problem is keeping your product_factory and product classes in sync - I'm sure there must be a nice pattern to deal with that somewhere. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Nonstandard SMTP line terminator
Hello, On 08/19/2004 01:33 PM, Ufuk M. Fakioglu wrote: I am using mail() with php 4.3.8 on FreeBSD 4.10 to send bulk mail. Although I use \r\n in the header parameters, some mail servers respond with Nonstandard SMTP line terminator. If you are doing exactly how it is described in the mail() function documentation and still get that results, that sounds like a mail() function bug dealing with line endings. I have seen people complaining of the exactly the same thing, so you'd better not use the mail() function at all. If you are using sendmail or some equivalente, you may want to try this class for composing and sending messages that comes with a sub-class specialized in deliverying via sendmail. That class also provides you easy control of sendmail options that are more appropriate for bulk mailing. If you do not want to change your scripts much, you can use a wrapper function named sendmail_mail() that works exactly like the mail() function but works directly with sendmail and lets you change tune the options for bulk mailing as it would be useful for you. http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] oop too slow
When i have many many objects of the same type to build, i do something like this... function getEvents($sql = '') { $events = $this-dbh-query( SELECT cols, cols, FROM table,table WHERE blah blah balh ($sql ? AND $sql : ''),'rows_array'); $rv = array(); foreach($events as $event) { $rv[] = new CalendarEvent($event); } return $rv; } my event class takes an array of data and uses phps list function to load its members. In this case, i save 100s and 100s of queries , using just 1. Its a massive improvment if it fits your scheme. To get one event, i create a method called getEvent($id) that is a wrapper to getEvents, and only uses the first record.. of coarse, there is only one record.. but ya.. cheers Jason Marcus Bointon [EMAIL PROTECTED] wrote: on 19/8/04 9:49, Krzysztof Gorzelak at [EMAIL PROTECTED] wrote: Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] ||| [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? This is something that I've wrestled with too. If you make each item you deal with a clean, self-sufficient object, with self-storage, data hiding etc, it is inevitable that you run into this problem. It is a symptom of a fundamental clash between Relational DB and OO points of view. The only trick I have found to work around it that is OO-clean is to use factory methods or objects that create multiple objects from a single DB query, so as well as having a 'get' method that populates an object from a DB, make another means of creating an object from local data that has been obtained from a larger query that returned sufficient values to populate multiple items. I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Yes, that's the correct way to represent a M:M relation in a relational DB. The join table is an artefact of a relational model, rather than an OO one, so the answer is to hide the existence of this table within the objects at either end - so have product and key objects, but not product_key objects. Each object should have a method that retrieves instances of all the related objects of the other kind. This is really a different manifestation of the first problem. Ultimately the trick is to create separate factory objects or higher-level methods inside the existing objects that can create multiple instances from a single database query. Having said that, it's difficult to spot the best places to do this. For example, you might normally create multiple product objects from an array of database IDs like so: foreach($productids as $id) $products[] = new product($id); You can see that this would cause a query for each instantiation. With a product factory class, you might do this instead: $products = product_factory::get($productids); Which achieves the same result, but using only a single DB query (hidden inside the factory class, which does NOT call the product class in the same way!). The next problem is keeping your product_factory and product classes in sync - I'm sure there must be a nice pattern to deal with that somewhere. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] arrays() current() next() who to use
I'm setting up an array based on recordset that does a loop as follows: do { //SET ARRAYS $z['username'][$k] = $row_rsUSERIDID['uname']; $z['distance'][$k++] = $totaldist; } while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID)); //SET NEW ARRAY $z['user'] = $z['username']; //SORT BY DISTANCES natsort ($z['distance']); reset ($z['distance']); foreach($z['distance'] as $k = $v){ $newuser = {$z['user'][$k]}; echo $newuser . br; } How can I now get this output displyed in groups of 10 so that I can display them 10 at a time on a page then click a next button to dispaly they next 10 and so forth? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] downloading files
I posted a simular question before and never really got an answer. The post drifted off into some other valuable information, but I still have the same question. I am trying to create a site with file downloads. The files on the server that are to be downloaded need to be protected somehow. I have already created a login page for the site so users must log in. The download files are in a directory protected by htaccess which it is my understanding that PHP can go underneath htaccess to get access to the files. My problem is where do I put this directory? I was already told to put it outside the web root directory, but I really dont know where the best place is. Anyone have a suggestion? Thanks, Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/PearDB works on commandline but not via http....
On Thu, 19 Aug 2004 08:44:39 -0700, pw [EMAIL PROTECTED] wrote: Justin Patrin wrote: Did you try: if(PEAR::isError($db)) { echo $db-getMessage().' '.$db-getUserInfo(); } It's probably because: 1) the postgres the module isn't in the PHP that apache is using 2) the postgres module isn't loaded in the PHP that apache is using 3) the postgres module in the PHP that apache is using is connecting via a socket instead of a port (or vice-versa) I think you may have something with the apache module points. I'll ask if apache has been built or is just the install from the linux distro. I built apache previously, but I didn't install this machine Write a script with just: ?php phpinfo(); ? Run it through apache. Look for the postgres module (may be called pgsql). -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] downloading files
Hi Aaron, [..] The download files are in a directory protected by htaccess which it is my understanding that PHP can go underneath htaccess to get access to the files. My problem is where do I put this directory? I was already told to put it outside the web root directory, [..] Both are good methods to protect your files. And yes, you can access your files because PHP is working on the servers side and doesnt need to obey the .htaccess restrictions you defined for user/clients. With .htaccess protection you can access them by yourself later using login/password combination. Outside your DocumentRoot you won't have the possibility and without any help of serverside processes you will not be able to access them. That way you also dont need to worry about any .htaccess settings :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] downloading files
Aaron Todd wrote: I posted a simular question before and never really got an answer. The post drifted off into some other valuable information, but I still have the same question. I am trying to create a site with file downloads. The files on the server that are to be downloaded need to be protected somehow. I have already created a login page for the site so users must log in. The download files are in a directory protected by htaccess which it is my understanding that PHP can go underneath htaccess to get access to the files. My problem is where do I put this directory? I was already told to put it outside the web root directory, but I really dont know where the best place is. Anyone have a suggestion? Thanks, Aaron I use the following structure (simplified): /path/to/web/sites /website1 /classes (php classes) /templates (page templates, as with Smarty) /documents (put uploaded documents here) /webroot (web-accessible files here) /img(static images) /js (javascript files) Hope this helps. Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nonstandard SMTP line terminator
On Thu, 19 Aug 2004 19:33:11 +0300, Ufuk M. Fakioglu [EMAIL PROTECTED] wrote: Hi, I am using mail() with php 4.3.8 on FreeBSD 4.10 to send bulk mail. Although I use \r\n in the header parameters, some mail servers respond with Nonstandard SMTP line terminator. What can I do? If you send some code, perhaps we can help. Perhaps you should be using \n instead of \r\n? Or maybe anohter part of the message uses \n instead of \r\n? Otherwise, you can look into a different mailing system. http://pear.php.net/package/Mail http://pear.php.net/package/Mail_mime -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] downloading files
You can put the files that need to be downloaded in a directory somewhere outside of the web server root, but in that case your PHP program will need to read the file and print it to the browser, and it will also need printing the HTTP headers: Content-type: application/octet-stream Content-disposition: attachment; file=$filename Content-length: xxx [blank line] Or you can put the files somewhere on the web server tree, protect the directory with .htaccess (username + password), and just put a simple link to those files. When someone will click that link, it will be asked for a username and password in a popup window that the browser will open. If you don't want to appear that window, you can set your server to redirect the user to a php script, for a certain Status code that is generated when authorization is required, and that PHP script can ask nice for a username and password that can be used then by the script to allow access to that file (but this way might be more complicated without real benefits). Teddy Teddy - Original Message - From: Aaron Todd [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 19, 2004 8:30 PM Subject: [PHP] downloading files I posted a simular question before and never really got an answer. The post drifted off into some other valuable information, but I still have the same question. I am trying to create a site with file downloads. The files on the server that are to be downloaded need to be protected somehow. I have already created a login page for the site so users must log in. The download files are in a directory protected by htaccess which it is my understanding that PHP can go underneath htaccess to get access to the files. My problem is where do I put this directory? I was already told to put it outside the web root directory, but I really dont know where the best place is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Nonstandard SMTP line terminator
Here's the piece of code that composes and sends the e-mails: $row=mysql_fetch_array($sql); $name=$row[1]; $email=$row[2]; $subject=$_POST[subject]; $msg=stripslashes($_POST[msg]); $msg=str_replace(RCPT_NAME, $name, $msg); mail($email, $subject, $msg, From: Mozaik [EMAIL PROTECTED]\r\n. Return-Path: Mozaik [EMAIL PROTECTED]\r\n. Content-type: text/html; charset=iso-8859-9\r\n); Could it be the SQL query returning the nonstandard terminator? How do I decide to use \n instead of \r\n? Thanks, Ufuk JP On Thu, 19 Aug 2004 19:33:11 +0300, Ufuk M. Fakioglu [EMAIL PROTECTED] wrote: Hi, I am using mail() with php 4.3.8 on FreeBSD 4.10 to send bulk mail. Although I use \r\n in the header parameters, some mail servers respond with Nonstandard SMTP line terminator. What can I do? JP If you send some code, perhaps we can help. Perhaps you should be JP using \n instead of \r\n? Or maybe anohter part of the message uses \n JP instead of \r\n? JP Otherwise, you can look into a different mailing system. JP http://pear.php.net/package/Mail JP http://pear.php.net/package/Mail_mime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] download file question...
hi... i can allow files to be uploaded to my app. are there corresponding scripts/code to allow files to be downloaded to the user via the browser?? just occurred to me that i'll want to do this... nothing jumps out at me searching google/php.net for this... thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] download file question...
[snip] nothing jumps out at me searching google/php.net for this... [/snip] Have you searched the mailing list archives? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SimpleXML
Hello there, I'm new to all this newsgroup stuff, so please tell me if I'm putting this in the wrong place. I am having some problems with the XML features (I use the fancy new SimpleXML). It works like a dream when I'm retrieving information from an XML document, but when I want to insert new tags it screws up. I'm trying to create a function that saves error logs in an XML file, which should look like this: ?xml version='1.0' standalone='yes'? errors error number2/number stringCould not bla bla/string filefilename.php/file line56/line /error error number1/number stringFailed to bla bla/string filefilename2.php/file line123/line /error /errors Well, You get the picture... The thing is, I don't know how to add another error tag. I've tried to use simplexml_load_file() to open the error log file, then using $xml-error[] = number... or $xml-error[] = new ObjectWithSomeProperties, I've even tried to load a string containing the tags (number, string etc.) into simplexml_load_string, then inserting it with $xml-error[] = $newobject, but none of these works, which leads me to believe that I can't use the [] thing to make a new error tag. But how do I do it then? Best regards, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Nonstandard SMTP line terminator
On Thu, 19 Aug 2004 21:33:22 +0300, Ufuk M. Fakioglu [EMAIL PROTECTED] wrote: Here's the piece of code that composes and sends the e-mails: $row=mysql_fetch_array($sql); $name=$row[1]; $email=$row[2]; $subject=$_POST[subject]; $msg=stripslashes($_POST[msg]); $msg=str_replace(RCPT_NAME, $name, $msg); mail($email, $subject, $msg, From: Mozaik [EMAIL PROTECTED]\r\n. Return-Path: Mozaik [EMAIL PROTECTED]\r\n. Content-type: text/html; charset=iso-8859-9\r\n); Could it be the SQL query returning the nonstandard terminator? How do I decide to use \n instead of \r\n? Check the manual and/or RFC and/or the package you end up using. Thanks, Ufuk JP On Thu, 19 Aug 2004 19:33:11 +0300, Ufuk M. Fakioglu [EMAIL PROTECTED] wrote: Hi, I am using mail() with php 4.3.8 on FreeBSD 4.10 to send bulk mail. Although I use \r\n in the header parameters, some mail servers respond with Nonstandard SMTP line terminator. What can I do? JP If you send some code, perhaps we can help. Perhaps you should be JP using \n instead of \r\n? Or maybe anohter part of the message uses \n JP instead of \r\n? JP Otherwise, you can look into a different mailing system. JP http://pear.php.net/package/Mail JP http://pear.php.net/package/Mail_mime -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SimpleXML
From: Daniel Schierbeck [EMAIL PROTECTED] I am having some problems with the XML features (I use the fancy new SimpleXML). It works like a dream when I'm retrieving information from an XML document, but when I want to insert new tags it screws up. Someone will correct me if I'm wrong, but I don't think you can add elements to the XML file in this way. You can change existing values, but cannot add new elements from what I've seen. It seems pretty intuitive that it would work in the way you describe, so I don't know why it doesn't. ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] download file question...
From: bruce [EMAIL PROTECTED] i can allow files to be uploaded to my app. are there corresponding scripts/code to allow files to be downloaded to the user via the browser?? How about a link to the file? If you want to get more complicated, search the archives for readfile and download... ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Nonstandard SMTP line terminator
From: Ufuk M. Fakioglu [EMAIL PROTECTED] Here's the piece of code that composes and sends the e-mails: $row=mysql_fetch_array($sql); $name=$row[1]; $email=$row[2]; $subject=$_POST[subject]; Bad idea here. You're script is vulnerable to mail header injection attacks. Malicious users can send a multi-line subject and insert additional headers and/or content into your email messages. This will allow them to set false return paths, false content or have your server send out spam for them. Filter any newlines from $_POST['subject'] before you use it. $msg=stripslashes($_POST[msg]); $msg=str_replace(RCPT_NAME, $name, $msg); mail($email, $subject, $msg, From: Mozaik [EMAIL PROTECTED]\r\n. Return-Path: Mozaik [EMAIL PROTECTED]\r\n. Content-type: text/html; charset=iso-8859-9\r\n); Could it be the SQL query returning the nonstandard terminator? How do I decide to use \n instead of \r\n? Have you tried just using \n in the headers you create above? What OS are you running? Are the error messages you're receiving from a specific OS? This doesn't really sound like a PHP issue. More like your mail server is sending out mail in a bad format (maybe by using \n instead of \r\n?)... ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
From: Vern [EMAIL PROTECTED] How can I now get this output displyed in groups of 10 so that I can display them 10 at a time on a page then click a next button to dispaly they next 10 and so forth? Can't you do all that sorting in your query so you can just retrieve 10 rows at a time using LIMIT? ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
Problem with that is it sorts according the results of the recordset range. For instance: It will show the user 1 trhough 10 sorted by miles then 20 - 30 sorted by miles, however, in 1 through 10 could have a range of 0 to 1000 miles and the next set will have 5 to 200 miles. What I need is to sort them all by miles first. The only way I know to do that is to do the way I set it up. So if I create an array, sort that array by the miles then use that array. However the array is different that the recordset and thus does not use LIMIT. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How do I use sessions if cookies are turned off in the browser?
Hi, I have a PHP file containing the code below. It works great when all default setting exist in IE; each time I click on refresh, the session variable is incremented and displays on the screen. If I change my browsers setting to block all cookies, my session variable appears not to increment and refreshing the screen displays the same text all the time. Q1. Is this because sessions use session cookies and IE blocks these at high security? Q2. I was told that if cookies are turned off, there is a way to use the session ID variable to accomplish what I want instead of cookies. How can I do this OR please point me to an easy tutorial. Thanks, Don == Start of code == ?PHP session_start(); header(Cache-control: private); //IE 6 Fix if(!$_SESSION['count']){ $_SESSION['count'] = 1; } else { $_SESSION['count']++; } ? You have visited ? echo $_SESSION['count']; ? pages so far! === End of code === -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate XML data
On Thu, 19 Aug 2004 18:06:27 +0200, Jacob Friis Larsen [EMAIL PROTECTED] wrote: It's possible in PHP 5, but not in PHP 4 Could you link me to the documentation? http://ch2.php.net/manual/en/function.dom-domdocument-schemavalidate.php chregu And I advise to use the most recent libxml2 libraries, since they made big improvements concerning XSD support lately It is possible to validate a XML document with XML Schema Definition Language (XSDL). Is it possible to use XSDL in Php? -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [EMAIL PROTECTED] | gnupg-keyid 0x5CE1DECB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I use sessions if cookies are turned off in the browser?
On Thu, 19 Aug 2004 16:50:28 -0400, Don [EMAIL PROTECTED] wrote: Hi, I have a PHP file containing the code below. It works great when all default setting exist in IE; each time I click on refresh, the session variable is incremented and displays on the screen. If I change my browsers setting to block all cookies, my session variable appears not to increment and refreshing the screen displays the same text all the time. Q1. Is this because sessions use session cookies and IE blocks these at high security? Q2. I was told that if cookies are turned off, there is a way to use the session ID variable to accomplish what I want instead of cookies. How can I do this OR please point me to an easy tutorial. rtm http://us4.php.net/session session.use_trans_sid SID -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I use sessions if cookies are turned off in the browser?
On Thu, 19 Aug 2004 16:50:28 -0400, Don [EMAIL PROTECTED] wrote: Q1. Is this because sessions use session cookies and IE blocks these at high security? Q2. I was told that if cookies are turned off, there is a way to use the session ID variable to accomplish what I want instead of cookies. How can I do this OR please point me to an easy tutorial. Basically, in order for your session to work, you have to let the page that you're viewing know what the session id is. Let's look at your code. == Start of code == ?PHP session_start(); header(Cache-control: private); //IE 6 Fix if(!$_SESSION['count']){ $_SESSION['count'] = 1; } else { $_SESSION['count']++; } ? You have visited ? echo $_SESSION['count']; ? pages so far! === End of code === Looking at this code, there's no link to another page, so there's no way of letting the web server (and PHP in this case) know what the session id is. If your php.ini hasn't been changed, you could see the session in action by adding a link that points to the same page. Say for example, the name of this file is 'session.php'. Add the following line to your page: a href=session.phpSee the session in action!/a PHP will rewrite this to: a href=session.php?SID=12345678123456781234567812345678See the session in action!/a Clicking on the link will then show $_SESSION['count'] incrementing. You should have seen something similar even if you have cookies the first time you start your browser (assuming your only using session cookies) since PHP hasn't received any session information from the browser. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I use sessions if cookies are turned off in the browser?
Don wrote: If I change my browsers setting to block all cookies, my session variable appears not to increment and refreshing the screen displays the same text all the time. You need to pass the session id in the URL if cookies are off. There is a constant, SID, that you may be able to use, or otherwise create it with session_name() and session_id(). $link = 'http://www.yourdomain.com/page.php?'.SID; -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: download file question...
Bruce [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hi... i can allow files to be uploaded to my app. are there corresponding scripts/code to allow files to be downloaded to the user via the browser?? just occurred to me that i'll want to do this... nothing jumps out at me searching google/php.net for this... thanks What about pointing a link to the file?!?: a href=/path/to/your/file.pdflink/a If the file is outside of the webroot root or in a protected directory you can use PEAR's HTTP_Download: http://pear.php.net/package/HTTP_Download Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
Vern [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Problem with that is it sorts according the results of the recordset range. For instance: It will show the user 1 trhough 10 sorted by miles then 20 - 30 sorted by miles, however, in 1 through 10 could have a range of 0 to 1000 miles and the next set will have 5 to 200 miles. What I need is to sort them all by miles first. The only way I know to do that is to do the way I set it up. So if I create an array, sort that array by the miles then use that array. However the array is different that the recordset and thus does not use LIMIT. What about this: SELECT * FROM table ORDER BY miles LIMIT 0, 10 Then pass the offset to your query function and exchange it with 0: SELECT * FROM table ORDER BY miles LIMIT $offset, 10 Of course you have to properly validate that $offset is an integer before using it in the query. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] oop too slow
U¿ytkownik Jason Davidson [EMAIL PROTECTED] napisa³ w wiadomo¶ci news:[EMAIL PROTECTED] When i have many many objects of the same type to build, i do something like this... function getEvents($sql = '') { $events = $this-dbh-query( SELECT cols, cols, FROM table,table WHERE blah blah balh ($sql ? AND $sql : ''),'rows_array'); $rv = array(); foreach($events as $event) { $rv[] = new CalendarEvent($event); } return $rv; } my event class takes an array of data and uses phps list function to load its members. In this case, i save 100s and 100s of queries , using just 1. Its a massive improvment if it fits your scheme. To get one event, i create a method called getEvent($id) that is a wrapper to getEvents, and only uses the first record.. of coarse, there is only one record.. but ya.. cheers Jason Marcus Bointon [EMAIL PROTECTED] wrote: on 19/8/04 9:49, Krzysztof Gorzelak at [EMAIL PROTECTED] wrote: Hi I'm trying my new php5 script, but it takes about 1.2s to generate my page. That is, how my oop model looks like : [category] ||| [photo] [desc] [products] [products] | [product] ||| [photo] [desc] [keys] [keys] | [key] | [values] | [value] Each object gets data from mysql by itself. The generation time of 1 category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I said more than a 1s (on quite fast machine). How can this model be improved? Do I create too many objects ? What are the oop solutions for such problem ? This is something that I've wrestled with too. If you make each item you deal with a clean, self-sufficient object, with self-storage, data hiding etc, it is inevitable that you run into this problem. It is a symptom of a fundamental clash between Relational DB and OO points of view. The only trick I have found to work around it that is OO-clean is to use factory methods or objects that create multiple objects from a single DB query, so as well as having a 'get' method that populates an object from a DB, make another means of creating an object from local data that has been obtained from a larger query that returned sufficient values to populate multiple items. I also use an extra table to create many-to-many relation betwean a product and a key. Is this the only way in mysql ? [product] | [product_id, key_id] | [key] Yes, that's the correct way to represent a M:M relation in a relational DB. The join table is an artefact of a relational model, rather than an OO one, so the answer is to hide the existence of this table within the objects at either end - so have product and key objects, but not product_key objects. Each object should have a method that retrieves instances of all the related objects of the other kind. This is really a different manifestation of the first problem. Ultimately the trick is to create separate factory objects or higher-level methods inside the existing objects that can create multiple instances from a single database query. Having said that, it's difficult to spot the best places to do this. For example, you might normally create multiple product objects from an array of database IDs like so: foreach($productids as $id) $products[] = new product($id); You can see that this would cause a query for each instantiation. With a product factory class, you might do this instead: $products = product_factory::get($productids); Which achieves the same result, but using only a single DB query (hidden inside the factory class, which does NOT call the product class in the same way!). The next problem is keeping your product_factory and product classes in sync - I'm sure there must be a nice pattern to deal with that somewhere. Marcus -- Thanks a lot, after your replies I made a little google search on 'factory class' and found a great article: http://www.phppatterns.com/index.php/article/articleview/49/1/1/. My objects are still too slow (0,3s) but now I'm going to try Advanced PHP Debugger. Krzysztof Gorzelak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
The miles are being caluculated during the loop that is created using the recordset not in the database. First I create a do..while loop to get the miles do { $k = 0; //SET FIRST ARRAY OF ONLINE USERS AND CALCULATE MILES do { //GEOZIP $zip2 = $row_rsUSERIDID['zip']; $coor1=mycoors($zip1); $coor2=mycoors($zip2); $line1=split(\|,$coor1); $line2=split(\|,$coor2); $totaldist=distance($line1[0],$line1[1],$line2[0],$line2[1],mi); //SET NEW ARRAY WITH MILES $z['username'][$k] = $row_rsUSERIDID['uname']; $z['distance'][$k++] = $totaldist; } while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID)); //SET NEW ARRAY $z['user'] = $z['username']; //SORT BY DISTANCES natsort ($z['distance']); reset ($z['distance']); //DISPLAY USER INFORMATION SORTED BY MILES foreach($z['distance'] as $k = $v){ $newuser = $z['user'][$k]; echo $newuser . - . $v . br; } } while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID)); I now what to display this info 10 records at a time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Security Workbook
--- John Nichel [EMAIL PROTECTED] wrote: Chris Shiflett wrote: This news is a bit old, but I have made the workbook for my OSCON tutorial freely available from this URL: http://shiflett.org/php-security.pdf It's a 55 page PDF that has a lot of information (more than the slides) about some of the more important security topics. I hope you find it helpful. Chris I printed this out the day you sent it, but it had been sitting on my desk, unread, until today. Just got finished with it. Very helpful methods. I thank you sir. No problem - thanks for the kind feedback. :-) I'm glad you find it helpful. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Security Workbook
Thanks for the article Chris. Printing it out now and will read it later. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
* Thus wrote Vern: I'm setting up an array based on recordset that does a loop as follows: do { //SET ARRAYS $z['username'][$k] = $row_rsUSERIDID['uname']; $z['distance'][$k++] = $totaldist; } while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID)); ... How can I now get this output displyed in groups of 10 so that I can display them 10 at a time on a page then click a next button to dispaly they next 10 and so forth? Well, this is the hard way to do things, and very inefficient but: foreach(array_slice($z['distance'], $start, 10) { //... } Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
Well, this is the hard way to do things, and very inefficient but: foreach(array_slice($z['distance'], $start, 10) { //... } If you think there's a better way of doing it I would like to hear it. However this is resulting in an Parse error on the foreach line: foreach(array_slice($z['distance'], $start, 10)) { $newuser = $z['user'][$k]; echo $newuser . - . $v . br; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
If you think there's a better way of doing it I would like to hear it. However this is resulting in an Parse error on the foreach line: foreach(array_slice($z['distance'], $start, 10)) { $newuser = $z['user'][$k]; echo $newuser . - . $v . br; } foreach needs an as, probably that was meant to say: foreach(array_slice($z['distance'], $start, 10) as $k = $v) { ... - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nueva web necesita enlaces php
Apreciados colegas, estoy desarrollando una web en php que si bien no es muy complicada espero sea útil. Se trata de http://www.rutaweb.com/ La web principalmente está dedicada a enlaces de calidad pero en breve estrenaré sección de PHP con tutoriales y scripts. De momento agradecería que le echarais un ojo y me hicieseis alguna sugerencia, observación, etc. Además estoy buscando ENLACES DE CALIDAD de los temas que se muestran en el portal, si crees que hay algún enlace que deberia aparecer decidmelo! Saludos y gracias
Re: [PHP] Nueva web necesita enlaces php
On Fri, 20 Aug 2004 03:30:28 +0200, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Apreciados colegas, estoy desarrollando una web en php que si bien no es muy complicada espero sea útil. Se trata de http://www.rutaweb.com/ La web principalmente está dedicada a enlaces de calidad pero en breve estrenaré sección de PHP con tutoriales y scripts. De momento agradecería que le echarais un ojo y me hicieseis alguna sugerencia, observación, etc. Además estoy buscando ENLACES DE CALIDAD de los temas que se muestran en el portal, si crees que hay algún enlace que deberia aparecer decidmelo! me llamo matt try this list: http://news.php.net/group.php?group=php.general.es -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP, over javascript code simple \n
Im having problems. Because my javascript is inside a PHP code. Now below are 1 line code of a print function that display this on the html header. i must put \n after the Firstname. But PHP actually reads \n so when i view it on a browser the js code moves down. Which is wrong, because it wont work anymore.. what i want is js should use the \n instead. is there any alternative for \n? so it can display properly on php? ?php print( if (document.rpcjs_louie.ColCustName.value == \\) { walangfield += \Missing: Firstname\n\; } ); ? -- Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP, over javascript code simple \n
Got it. use ' and not because php reads if its under On Fri, 20 Aug 2004 11:10:24 +0800, Louie Miranda [EMAIL PROTECTED] wrote: Im having problems. Because my javascript is inside a PHP code. Now below are 1 line code of a print function that display this on the html header. i must put \n after the Firstname. But PHP actually reads \n so when i view it on a browser the js code moves down. Which is wrong, because it wont work anymore.. what i want is js should use the \n instead. is there any alternative for \n? so it can display properly on php? ?php print( if (document.rpcjs_louie.ColCustName.value == \\) { walangfield += \Missing: Firstname\n\; } ); ? -- Louie Miranda http://www.axishift.com -- Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP, over javascript code simple \n
* Thus wrote Louie Miranda: Im having problems. Because my javascript is inside a PHP code. Now below are 1 line code of a print function that display this on the html header. i must put \n after the Firstname. But PHP actually reads \n so when i view it on a browser the js code moves down. Which is wrong, because it wont work anymore.. what i want is js should use the \n instead. is there any alternative for \n? so it can display properly on php? ?php print( if (document.rpcjs_louie.ColCustName.value == \\) { walangfield += \Missing: Firstname\n\; } ); ? I'd only print() javascript only if absolutely necessary. otherwise simply break out of php: ?php // php code ? if (document.rpcjs_louie.ColCustName.value == ) { walangfield += Missing: Firstname\n; } ?php ? Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Storing, formatting and displaying data
Hi all, I would like to create a program that allow users to insert text into a database, than that text to appear in a web page formatted as HTML. It is simple to replace the end of line with br /\n in order to format that text as html, but I don't know how I could let the users to create bulleted lists, tables, etc. Lets say that the users are admins that I can trust, but they don't know HTML at all, however, they want to insert a table, or a list, etc. Are there any solutions for this? I am thinking to something like inserting table COL1##COL2##COL3 CEL1##CEL2##CEL3 /table ...for the tables, or something like that, then to make the program transform this in a true table. But maybe there are better solutions. Thanks for any ideas. Teddy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing, formatting and displaying data
Octavian Rasnita wrote: Hi all, I would like to create a program that allow users to insert text into a database, than that text to appear in a web page formatted as HTML. It is simple to replace the end of line with br /\n in order to format that text as html, but I don't know how I could let the users to create bulleted lists, tables, etc. What you are looking for is a web based html editor - but they do not usually have a database plugged in at the back end. For that you will need to look at a wiki, a CMS or a blogging tool that combines an html editor. Media Wiki is one such project. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing, formatting and displaying data
Use WISIWYG editor, integrate it into your forms and presto, for example, from www.interactivetools.com, that does not work with tables, but you can find one, I think. -- Tadas Talaikis [EMAIL PROTECTED] http://www.xongoo.com - Original Message - From: Octavian Rasnita [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, August 20, 2004 8:14 AM Subject: [PHP] Storing, formatting and displaying data Hi all, I would like to create a program that allow users to insert text into a database, than that text to appear in a web page formatted as HTML. It is simple to replace the end of line with br /\n in order to format that text as html, but I don't know how I could let the users to create bulleted lists, tables, etc. Lets say that the users are admins that I can trust, but they don't know HTML at all, however, they want to insert a table, or a list, etc. Are there any solutions for this? I am thinking to something like inserting table COL1##COL2##COL3 CEL1##CEL2##CEL3 /table ...for the tables, or something like that, then to make the program transform this in a true table. But maybe there are better solutions. Thanks for any ideas. Teddy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php