Re: [PHP] Re: Zend + Eclipse + Standized Framework
Greg Donald wrote: On Mon, 2005-11-14 at 03:55 -0500, Roman Ivanov wrote: What features do you need from a framework? Convention over configuration. (Yaml, not XML. ActiveRecord not Propel/Phing.) Hard to do in pure PHP. But I tried: http://cvs.sourceforge.net/viewcvs.py/naturalgine/NECMS_0_3/tools/ori.php?rev=1.1.1.1view=markup A persist-able domain model where logic and data are presented in one wrapping. (I don't want to re-assign my data in the view for use in the template after it's already ready already in the controller, pointless.) Don't know what you're talking about. Example? A database-agnostic database abstraction layer capable of using database meta data effectively. (Why am I still writing SQL?) LOL. What you really want is a built-in high-performance object-oriented database with decent OO interface. So far I hacked this thing, using MySQL: http://cvs.sourceforge.net/viewcvs.py/naturalgine/NECMS_0_3/tools/nodes.php?rev=1.2view=markup When I port the whole thing to PHP 5, I will try to make it to use PDO. Ajax, built-in. (Cause all the cool kids are using it.) Will be done some day. Right now, you can use AJAX all you want, but you have to code it yourself. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Zend + Eclipse + Standized Framework
Dan Rossi wrote: Personally, i am trying to avoid all these frameworks until everyones ideas are collabroated into one as i think they only work for some or for the developers purposes only. What features do you need from a framework? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the purpose of sessions extension?
Richard Lynch wrote: But it ain't easy the first time. If you're using DB to store session data, and trying to improve session security, than it ain't easy even the second time. Or the third. In fact, I gave up on that extension before it became easy. After that my session-related code shrunk by half. And I have 100% control over what happens and when it happens. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Filtering and Escaping (Was: Select and $_POST)
Richard Lynch wrote: If you had anything other than $_OCLEAN in an echo and friends, then you would know you were screwing up. Personally, if I pull something info from the database, then I do not usually sanitize it. Yes, I know it's less secure, but I'm willing to take such (negligible) risk for extra performance. So I sanitize data on input only. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
Richard Lynch wrote: On Thu, November 10, 2005 3:29 pm, GamblerZG wrote: IMO, the best way is to re-generate SIDs on each request, but such method will decrease perfomance of a script. But if Cookies are off, you just destroyed their Back button in their browser, which should be a crime. Call me evil, but I prefer not to use GET-based sessions (after seing at least 3 websites hacked because of that stuff), so users without cookies can't login anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Select and $_POST
Curt Zirzow wrote: There is a pecl extension that you can register, custom superglobals although it comes with some extra stuff as well: http://php.net/runkit I wish it would be a part of core distribution. Would be extremely useful. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
Richard Lynch wrote: IP is useless for identification or authentication of the general web-surfer: Users behind firwalls will all appear to be from one (1) IP AOL users change IPs faster than drummers change underwear I think it's still reasonable to restrict a session to a single IP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
Chris Shiflett wrote: GamblerZG wrote: I think it's still reasonable to restrict a session to a single IP. No, it's not, for all of the reasons Richard mentioned and more. I agree that using only IP to identify session is bad. Using only SID is ok. Using SIDs that are tied to a single IP is even _more secure_, since the possible attacker would need to have exactly the same IP as a victim of session hijacking. This comes at a price of a small inconvinience for dial-up users (since they would need to login on each reconnect), but I think such price it reasonable. IMO, the best way is to re-generate SIDs on each request, but such method will decrease perfomance of a script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
Richard Lynch wrote: AOL users WILL change their IP in a single [web-surfing] session. Ugh... I did not know that. That's horrible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
GamblerZG wrote: This comes at a price of a small inconvinience for dial-up users (since they would need to login on each reconnect), but I think such price it reasonable. Ok, scrap this statement. I did not know about AOL thing. But this one still stands: IMO, the best way is to re-generate SIDs on each request, but such method will decrease perfomance of a script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Issues - Where to look?
Richard Lynch wrote: Please pay attention. Sorry, I did not see your message when I posted that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
I'm using this, but I'm not sure whether it's bug-free: preg_match('/^([.0-9a-z_+-]+)@([0-9a-z-]+\.)+[0-9a-z]{2,6}$/i', $email); Note: IIRC, PEAR function will invalidate all adresses in museum TLD. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Richard Lynch's Email Address ...
James Benson wrote: Would it not be better something like valid_email() email_validate()? Anyway, I agree that PHP needs such function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Assuming something is not a logical fallacy, just like inability to use inductive logic is not a virtue, but rather an extreme case of sophism (I mean the original sophism, which was a name for a certain philosophy). Well, it IS extra work. If nobody needs forums, than the notion of the fact that creating them would require some activity is irrelevant. If, on the other hand, forums are needed, than the concern should be phrased differently altogether. BTW, what IS you concern? The mailing list exists and, many believe, work just fine. Currently, the universe is the way it is and, many believe, it works just fine. Why should we do anything at all? -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Lester Caine wrote: Forums are even more restrictive than newsgroups so I don't see that they add anything that is not currently available, and this list has considerably less traffic than some of the others I am a moderator on ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Lester Caine wrote: GamblerZG wrote: I do not see anything horrible in my message. It's not like I'm _demanding_ something, or suggesting to tear down mailing lists. Neither did I suggest that mailing lists suck. In case of php.internals they totally make sense. But I _do_ think that forum efficient in case of high-volume messaging. Having had to endure the newgroup interface while my eMail address was being bounced, I much prefer being able to manage the content of my eMail folders. I don't have to have a network connection while searching or reviewing material and I can add my own local notes as well. Forums are even more restrictive than newsgroups so I don't see that they add anything that is not currently available, and this list has considerably less traffic than some of the others I am a moderator on ;) I understand that mail lists are convenient for many people. But personally, I would like forums because I do not read all the messages here. Newsgroup partially solves the problem, but it's quite slow, and I can't post from a computer where I did not configure email client. PDA is no good either. Plus, forums have other nice features: formatting, syntax highlighting, images, ability to edit messages and make them sticky. Also, you can monitor a single thread by email, without receiving all of the messages in the forum. Finally, forum can be much more newbie-friendly if you allow anonymous users to post. It is the main reason I think there are many other people who would also like to have web conference. Instead of «subscribe, post, wait, receive gadzillion of mails, receive needed reply, unsubscribe, delete gadzillion of mails», it would be just «post, wait, receive reply». -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Richard Davey wrote: php.net does not exist in any one location. It's an interesting perspective. Thanks for an insightful reply. Start now and we'll check in on your progress in a years time :) You're joking, but I might actually do it. I was thinking about such forum before. It could be useful for many purposes. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Template style question
Leonard Burton wrote: [[tag with db query]] table trtdcolname/tdtdcolname/tdtdcolname/td/tr trtd%var1%/tdTd%var2%/tdtd%var3%/td/tr /table [[/tag with db query]] I would like it to be able to parse the line with the %var1% (which is the column name with % or some other indicator on each side) in it and then have it generate how many ever rows as nessecary. Currently, my parsing engine loads the template, preg_splits() it so each template tag is on a new line, and then passes through the resulting array and executes the code for whatever tag is chosen. Why don't you use PHP itself? //db query ? table trtdcolname/tdtdcolname/tdtdcolname/td/tr ?php foreach ($row = query($result)) { echo trtd$row[var1]/tdTd$row[var2]/tdtd$row[var3]/td/tr; } ? /table ?php db query -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Miles Thompson wrote: You missed the most important: This list works, why break it? Nope, I did not miss it. It's just not a proper reply to the message. I did not suggest to disable mailing lists or change them in any way, so the break factor does not apply. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Larry E. Ullman wrote: One of the fallacies in your argument is that the lack of an official forum on php.net implies such distaste for message boards. I don't have a big screen TV but I have anything but distaste for them! Well, let me give you a different example. I don't have a TV at all, even though I could buy one. Knowing this, would you assume that I don't like watching it? The same thing with forum. It's a usual feature, just like website is. Would you be surprised if PHP had no website? Would you ask why it doesn't? Also, you should realize that your question could be rephrased as Why hasn't someone else done all this extra work (creating and managing a forum) because I would prefer it? Are you saying that I'm the only PHP user that might like discussing things on a forum? Again, forums are very common. Some people like them, other people like mailing lists. In case of PHP, I find the lack of forum weird, because it's a web development language. Besides, you're implying that maintaining forum is extra work, while maintaining mailing lists isn't. Extra work for extra users you can live without, eh? In any case, if you are sincerely interested in either a support Web forum or a legitimate answer to your question, you may have better luck if your inquiry were more I would appreciate it if... or has an official forum been considered? and less this system that you've been using for years sucks and this is why I'm right. I do not see anything horrible in my message. It's not like I'm _demanding_ something, or suggesting to tear down mailing lists. Neither did I suggest that mailing lists suck. In case of php.internals they totally make sense. But I _do_ think that forum efficient in case of high-volume messaging. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Robert Cummings wrote: On Sat, 2005-11-05 at 00:56, GamblerZG wrote: Miles Thompson wrote: You missed the most important: This list works, why break it? Nope, I did not miss it. It's just not a proper reply to the message. I did not suggest to disable mailing lists or change them in any way, so the break factor does not apply. Then you suggest fragmenting the list into 3 factions, those who would continue to use the list, those who would use the forum, and those who would use both. By such a fragmentation of the list, solutions and advice would be spread across multiple locations thus diluting the efficacy of the list. I seriously doubt that giving people a choice over communication methods would reduce efficiency. It's like saying that having multiple OSes reduces efficiency of programming. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
PS: Sorry for missing verbs and articles in my last message. I have a good excuse: it't 2:22 AM here. *smilie* -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: match by relevancy
John Taylor-Johnston wrote: I'm using PHP Version 4.3.9 and MySQL 4.1.12. I recently upgraded from PHP 4.1.x and MySQL 4.0.x. Basically my SQL below now render empty set. It worked until my upgrade. Basically ORDER BY relevancy DESC no longer works, I think!? I got help building this $SQL here, so I'm hoping Sgt./Corporal what's his name, who answered my original question, is still around. Sorry to be off topic. I see no inpsiration in the relevant part of the Doc: http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html nor http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html Desperately looking for an answer. Any thoughts? SELECT *,MATCH (AU,ST,SD) AGAINST ('johnston' IN BOOLEAN MODE) AS relevancy FROM ccl.ccl_main WHERE MATCH (AU,ST,SD) AGAINST ('johnston' IN BOOLEAN MODE) ORDER BY relevancy DESC; John Hm... You're using literal string 'johnston' for matching. Shouldn't quotes be replaced with backticks (`)? -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No forums?
Robert Cummings wrote: On Sat, 2005-11-05 at 02:17, GamblerZG wrote: Robert Cummings wrote: On Sat, 2005-11-05 at 00:56, GamblerZG wrote: Miles Thompson wrote: You missed the most important: This list works, why break it? Nope, I did not miss it. It's just not a proper reply to the message. I did not suggest to disable mailing lists or change them in any way, so the break factor does not apply. Then you suggest fragmenting the list into 3 factions, those who would continue to use the list, those who would use the forum, and those who would use both. By such a fragmentation of the list, solutions and advice would be spread across multiple locations thus diluting the efficacy of the list. I seriously doubt that giving people a choice over communication methods would reduce efficiency. It's like saying that having multiple OSes reduces efficiency of programming. I didn't use the word efficiency, I used the word efficacy (feel free to look it up). Cheers, Rob. They're synonyms, and I do not see a big difference in their meanings. Feel free to disambiguate. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Abstract Classes?
Oliver Grätz wrote: GamblerZG schrieb: But what benefit is there is having it as an explicitly abstract class? Why can't it just be a normal class definition which you inherit from? The idea is that a high-level language should prohobit you from doing things that do not make sence. Why they implemented it in PHP? Because it's there in Java, I guess. No, it's there because it makes sense. I did not say abstractness did not make sense. But it's not crucial. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Abstract Classes?
Alan Lord wrote: But what benefit is there is having it as an explicitly abstract class? Why can't it just be a normal class definition which you inherit from? The idea is that a high-level language should prohobit you from doing things that do not make sence. Why they implemented it in PHP? Because it's there in Java, I guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
The second one is by using two different apache modules. It *does not break anything*, but it's a pain to setup. Judging sheerly by functionality and compatibility the second ways is better. However, judging from what I know about PHP, nobody tries to make that way easier, because everybody assume that everyone else use the first way. Is it good old catch 22 in action, or are there some design considerations I'm not aware of? A great number of people have worked on, and are working on, ways to make this easier. Most people, however, find it more practical to simply have 2 different server configurations (old and new) and migrate clients onto the new server slowly, at the CLIENT'S pace, instead of losing customers by just trashing their site out from under them. Actually, I was speaking about PHP developers. The sheer fact that they bothered to write compatibility mode shows that they don't really count on hosters using two engines side-by-side. On the other hand, the only disadvantage of such approach is installation, and developers have the power to remove this shortcoming. Since they preferred the first way of handling compatibility, there must be some language design issues with the second one. It would be interesting to know/discuss them. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
Richard Lynch wrote: PHP developers assume that PHP5 will be frequently used to parse PHP4 scripts. Why? Because that's how the real world works. The real world works that way because, as you just said, installing 2 php modules side by side is a great deal of system administration. And what's so horrible about using separate engines to run php 4 and 5 scripts? Nothing, if you can identify which are which, and have the infrastructure to set up both and... It's a great deal of system administration Let me get it straight. There are two ways of running PHP four and five on one server. First one is by using five's compatibility mode, and it breaks some of the old scripts. The second one is by using two different apache modules. It *does not break anything*, but it's a pain to setup. Judging sheerly by functionality and compatibility the second ways is better. However, judging from what I know about PHP, nobody tries to make that way easier, because everybody assume that everyone else use the first way. Is it good old catch 22 in action, or are there some design considerations I'm not aware of? -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Obsession with BC, take 2
Since nobody ansvered the real question my previous message, I will re-phrase it. PHP developers assume that PHP5 will be frequently used to parse PHP4 scripts. Why? And what's so horrible about using separate engines to run php 4 and 5 scripts? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
Robert Cummings wrote: On Wed, 2005-10-12 at 17:31, GamblerZG wrote: Since nobody ansvered the real question my previous message, I will re-phrase it. PHP developers assume that PHP5 will be frequently used to parse PHP4 scripts. Why? And what's so horrible about using separate engines to run php 4 and 5 scripts? You can use separate engines. The topic has been addresses many times already. Yes, but separating PHP 4 and 5 is still a non-trivial task. For example, IIRC, FreeBSD's port system does not allow you to install both mods at the same time. Besides, developers do not expect PHP to be used that way, so they are likely to sacrifice certain features for the sake of compatibility. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Obsession with BC
Recently, I asked my hosting provider when they are going to switch to PHP5. They replied that it will not happen any time soon, since they will install PHP5 only on new servers. Their reasoning was simple: PHP5 will inevitably break some old scripts, and it's just not worh all the trouble. Such attitude is common, and it totally makes sence from a business perspective. That begs the question, why PHP developers are so worried about maintaining BC? There is a simple alternative: ?php //parse this with mod_php4 function class_method($var){ } ? ?php5 //parse this with mod_php5 class clazz implements Something{ function method($var) { } } ? So what's the reasoning behind BC maintenanse? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
?php //parse this with mod_php4 function class_method($var){ } ? ?php5 //parse this with mod_php5 class clazz implements Something{ function method($var) { } } ? Ummm, maybe your speaking alien, but could you clarify how that solves the problem you are addressing? First, if every version of the language would have it's own tag, then there would be no need to maintain BC beyond reasonable necessity. Second, hosing providers would be more apt to uprade. They would simply add new module without removing the old one. This way both old and new scripts would work perfectly fine without the need for some kind of compatibility mode. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
It does? I wouldn't waste my money with a host that was unable to provide PHP 5 support, at least in some way. I think the it will break lots of scripts is a cop-out. There are various ways to allow both on one server. Assuming they're technically proficient enough of course. 'What is the best way to get to get to Detroit from here?' 'You don't need to go to Detroit. It's cold in there. San-Francisco is much better.' Do you see the problem here? You're not adressing the issue I spoke about. Issue: I think BC slows down the evolution of the language. I know for sure it makes some people less willing to upgrade. And there are ways of avoding unnecessary BC maintenance altogether. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
On the final hand, if you pass the pages off from apache to a php exe or module.. How does Apache know which one to pass it to? Php4 or Php5? By the processing instruction target. That's what it's there for. I guess php 5 and 4 are not the best examples, since php5 already uses '?php' PITarget. Let's say '?php6' means PHP6, and '?php' means 4/5. If I have both php4 and php5 code in a page should i run both sections or only the sections listed for php5(if it's on php5)? You shouldn't run any sections, and give an error. The whole point is to separate different versions of the language instead of mixing them. Do you know a lot of scripts which use features specific to both php4 and php5? I don't. And it's an awful practice anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
Kilbride, James wrote: Perhaps I'm missing something but doesn't Apache hand off to PHP before it looks at anything inside the file? Doesn't it hand it off at the fact that the target is SomeFile.php. So the tag ?php4/5/6/X doesn't mean anything since by the time the tag gets read it's already in PHP4 or 5 or 6. So the tags can't be used. On the other hand you COULD name the files .php4, .php5 and set apache to pass .php4 files to php4 and .php5 files to php5.. I guess you're right. Different filenames would be more appropriate. Doing it with different tags is not impossible, but it would not be handled by 2 separate modules. You can already do this as far as I know. I _would_ be able to do it if had my own server with full access to htconfig. But then I would just use PHP5, since it's so much better than 4. Moreover, separation is not encouraged by the language itself. There are de-facto standards, and handling 5 and 4 separately is not one of them. Why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
Richard Davey wrote: You either code for PHP4 or you code for 5. That's exactly my point. Backwards compatibility doesn't slow down the evolution of a language Not true. Quite a few of the discussions of new features and even some bugfixes end up on can't be done because of BC. And if PHP was to totally change its language structure on every new version, I can't think of too many people that would continue using it. Did I say something about totally changing the language structure? Where? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom session handling - bad or good idea?
I'm not speaking about session_set_save_handler, I'm considering writing session handler from scratch. Is it a bad idea? If so, why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include (evaluate) PHP/HTML code stored in a variable
eval('? '.$code.' ?php'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delay?
What's keeping you. There are no official PHP forums. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OO DB in PHP?
When you have objects stored on disk, it's usually very convenient to read them on demand. However, MySQL is clearly not meant for this purpose. Query overhead, complexity of SQL needed, and some other limitation make object storage and retrieval a headache. The question is, is it possible to write reasonably efficient OO database in php? Two main factors would be: 1) Is is possible to make fast B-tree index search without writing any C code? 2)How long does it takes for PHP to open 1 file? (It will need to open hundreds of them.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Question about OO
Maybe it's just me, but the core concept of __autoload() seems to be broken to me. Moreover, every proposed solution I've heard about is totally inside the box. I would do it like this: 1) Define $_AUTOLOAD superglobal. 2) If I need SomeClass to be autoloaded I write this: $_AUTOLOAD['SomeClass'] = 'some/dir/some_classs.php'; 3) If I care, I could check whether $_AUTOLOAD['SomeClass'] is already set and generate an error. This would mimic Java behaviour (it's about competing with Java, is it?) without creating artificial headache for programmers. But wait! What do I know? This will cbreak BC; moreover, BC will be broken by this. Forget I said something. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OO DB in PHP?
Did you have some code that you need help debugging? Since you have asked... http://fs.net/projects/naturalgine Could you please download the latest version, open tools/objects.php and look at getObjects() function? Just take a look at it, and you will undesrstand what am I talking about, and why I don't want to use mySQL. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sanitizing get vars
set_magic_quotes_runtime( 0 ); This is for database, not for showing data in browser. For browser you need to kill all unknow tags and all unknown properties of known tags. Afterwards, you need to prepend http:// to any urls that have unknow protocols. Alternatively, you can make sure that data diplayed to user is submitted by the same user. Example of the former method: http://token.by.ru/ksscripts/htmlparser6.txt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delay?
Sebastian wrote: yea.. takes hours... sometimes 6+ or more. i dont post that much to the list for this reason.. if it stays like this i'll just unsubscribe.. its pointless... this is suppose to be E-mail, not post office mail. I don't understand why everyone like these mailing lists so much. Web-forums more convenient. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error suppression operator (@)
I would like to know, whether using @ is a good practice. For example, I have an array of unknown length $array. Is it all right write something like this: @list($first, $second) = $array; or is it better to do length check? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Controlling file access with PHP
Problem: I have db with users, groups, passwords and permissions. I need to restrict access to some files for general public, but allow certain groups to download those files. Access restrictions should be based on permissions in the database. I can set_time_limit() to a very big number, output file header, read file through PHP and output it through PHP, but that's not a very elegant solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Critical Thinking, or Several Why Questions
You can ask about a question. You can even try to improve the performance of a function. But at the end of the day unless you can come up with something that will do what the PHP community at large expects *and* it is faster it's not going to happen. How exactly PHP community at large supposed to verbalize its expectations, if not through discussion of language features? IMO, by posting statements like the one above you suppress (possible) discussions. Trust me, the core PHP dev team wants to improve performance just like you do. They are human and may miss some possibilities. I do not say that I will necessarily point to those possibilities, but still it is possible. Moreover, developers might not use the language the way I do. It's just that they also have to do silly little things like maintain BC. They'll break BC if there's a really, REALLY good reason why, but most of the time the answer is no. I did not ask developers to break BC. In fact, I did not ask developers to do anything at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Performance optimization
Are there any decent resources dedicated to PHP code optimization? By decent I mean ones that do not ask you to completely ruin readability for the sake of extra 0.003 seconds. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Performance optimization
The best way to go about it is to get a code profiler. apd / xdebug / Zend are popular choices. Can't seem to install apd 0.9something or xdebug 1.0.something. pear calls phpize, which in turn outputs some cryptic message and exits. (In case of APD it's something like error on line 59. I'm not sure what file that is.) I use PHP 4.3.4 on SuSE. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL empty row
DB Error: constraint violation What DB do you use? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Critical Thinking, or Several Why Questions
Why include_once() is doing some fancy logic, which nobody needs? Why array_shift() re-indexes arrays? Why 2 simple string comparisons are slower than one preg_match()? Why microtime(TRUE) returns only fraction of real time that is smaller than 1? Why microtime() does not return float in the first place? Why user-defined session-handling functions receive serialized session data that is already serialized? Why parser reads multi-line comment slower than it reads heredoc or single-quoted string? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Critical Thinking, or Several Why Questions
Why don't you RTFM? There is nothing in manual that answers any of those questions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Critical Thinking, or Several Why Questions
What fancy logic? And why does no one need it? I'm referring to this: http://archives.devshed.com/a/ng/557-22943/ Now surely you can RTFM and find more answers. If you disagree with the way that some things work you have a couple of options; a. Contact the PHP development group and explain what you would like to happen. 2. Write an extension yourself that 'fixes' the items you have questions about. But the named issues are pretty obvious, so I assume that there are some reasons why things work as described. Maybe I use functions in the way they were not meant to be used. Maybe there are engine limitations... Manual (and believe me, I read it occasionaly) describes only what function does, not how it works inside, or why it works in this particular way. PS: As I see from the manual on php.net, developers actually fixed microtime() in php 5. I either missed that example, or my manual is slightly outdated. Sorry. However, the rest of the questions still stand. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Critical Thinking, or Several Why Questions
A sample use: [...] 'include_once' allows me to lazy load -- and thus optimize my application. Sure, it may be a slight performance hit -- but not nearly that of loading the files in question. I do not question usefulness of include_once(). In fact, currently I'm developing application that might use it exactly the way you described. There are many API functions in several files, and there are cases when I do not need all of them. That is exactly why I am concerned with it's performance, and that is why I asked about it here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compact, human-editable serialization
Somewhere around here I asked about human-readable serialization and there was no solution that fitted my needs. So I wrote my own serialize/deserialize pair. The decode function is different from the one I posted here before. This function, in my opinion, is written very efficiently, but it's still about 10-50 times slower than serialize. I guess it's not too bad, because I compete with pure C++ code, but I would still appreciate any suggestion for performance tune-up. PS: If someone would write the same functions in C, they wold probably be faster than PHP's de/serialize. And they provide output that is much more compact. And it's human-editable. PHP developers, if you read this, think about it. --- function encode($var) { if (is_array($var)) { $code = '('; foreach ($var as $key = $value) { $code .= encode($key).'='.encode($value).','; } $code = chop($code, ','); //remove unnecessary coma $code .= ')'; return $code; } else { if (is_string($var)) { //this also catches string with numbers inside if (strpos($var, ') !== FALSE) { $var = str_replace(', '', $var); } return '.$var.'; } elseif (is_numeric($var)) { return $var; } elseif (is_bool($var)) { return ($var ? 'T' : 'F'); } else { return 'N'; } } } function decode($str) { preg_match_all('/(.*?)/s', $str, $matches, PREG_PATTERN_ORDER); $dStack = $matches[1]; $str = preg_replace('/.*?/s', 'D', $str); preg_match_all(/'(.*?)'/s, $str, $matches, PREG_PATTERN_ORDER); $sStack = $matches[1]; $str = preg_replace(/'.*?'/s, S, $str); if (preg_match('/[\']/', $string)) { user_error(Unpaired quotes, E_USER_WARNING); return; } $str = preg_replace('/\s/', '', $str); $str = preg_replace('/,\)/', ')', $str); preg_match_all('/([^TFNDS=,\(\)]+)/i', $str, $matches, PREG_PATTERN_ORDER); $xStack = $matches[1]; $str = preg_replace('/[^TFNDS=,\(\)]+/i', 'X', $str); $heap = array(); $ptr = strlen($str) - 1; while ($ptr != 0) { switch ($str{$ptr}) { case 'D': $string = array_pop($sStack); while ($str{$ptr - 1} == 'D') { $string = array_pop($dStack).''.$string; $str{$ptr} = '_'; --$ptr; } $str{$ptr} = '$'; $heap[$subPtr] = $string; break; case 'S': $string = array_pop($sStack); while ($str{$ptr - 1} == 'S') { $string = array_pop($sStack).'.$string; $str{$ptr} = '_'; --$ptr; } $str{$ptr} = '$'; $heap[$ptr] = $string; break; case 'T': $heap[$ptr] = TRUE; $str{$ptr} = '$'; break; case 'F': $heap[$ptr] = FALSE; $str{$ptr} = '$'; break; case 'N': $heap[$ptr] = NULL; $str{$ptr} = '$'; break; case 'X': $number = array_pop($xStack); $str{$ptr} = '$'; if (is_numeric($number)) { $heap[$ptr] = $number + 0; } else { user_error('Invalid character sequence in array ['.($ptr - 1).']', E_USER_WARNING); return; } break; } //braces, commas and equal signs are ignored --$ptr; } while (($aStart = strrpos($str, '(')) !== FALSE) { $aEnd = strpos($str, ')', $aStart); if ($aEnd === FALSE) { user_error(Array beginning at [$aStart] is not closed, E_USER_WARNING); return; } $ptr = $aStart + 1; if ($str{$ptr} == ',' || $str{$ptr} == '=') { user_error(Invalid array entry [$ptr], E_USER_WARNING); return; } $str{$aEnd} = ','; //comma serves as a trigger, so array should end with one $aStack = array(); while ($ptr $aEnd) { switch ($str{$ptr}) { case '=': $str{$ptr} = '_'; $keyPtr = $ptr - 1; while ($str{$keyPtr} != '$') { if ($str{$keyPtr} != '_') { user_error(Invalid character sequence in array [$keyPtr], E_USER_WARNING); return; } $str{$keyPtr} = '_'; --$keyPtr; } $str{$keyPtr} = '_'; $valPtr = $ptr + 1; if ($str{$valPtr} != '$') { user_error(Invalid character sequence in array [$keyPtr], E_USER_WARNING); return; } $str{$valPtr} = '_'; $aStack[$heap[$keyPtr]]= $heap[$valPtr]; $commaPtr =
[PHP] Re: MySQL empty row
Please replace die($res-getMessage()) with user_error($res-getMessage(), E_USER_ERROR) and then post the output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to call a static class and method dynamically
class MyClass { function static_method() { echo 'I'm in static_method !'; } } You can call the function statically using the double colon ( :: ) operator : Ahem. Double colon does now works with dynamic names. If I'm not mistaken, call_user_func(array('class', 'function')) is the only way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to call a static class and method dynamically
I ment: Double colon does no_t_ works with dynamic names. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Storing data structires in DB
Ok, I wrote something that fits my needs. But, as I said, it is slow. Too slow. Is anyone except me interested in human-editable serialize? Can anyone help me with optimization? And please do not tell me that I need to write it in C++. The thing should be portable. == define('CMS_ARR_BEGIN', 1); define('CMS_ARR_END', 2); define('CMS_COMA', 3); define('CMS_ARROW', 4); define('CMS_SCALAR', 5); function encode($var) { if (is_array($var)) { $code = '('; foreach ($var as $key = $value) { $code .= encode($key).'='.encode($value).','; } $code = chop($code, ','); //remove unnecessary coma $code .= ')'; return $code; } else { if (is_string($var)) { if (strpos($var, ') !== FALSE) { $var = str_replace(', '', $var); } return '.$var.'; } elseif (is_numeric($var)) { return $var; } elseif (is_bool($var)) { return ($var ? 'T' : 'F'); } else { return 'N'; } } } function decode($str){ $stack = array(); $scalars = array(); $strLen = strlen($str); while ($ptr $strLen) { $ptrChar = $str{$ptr}; if (preg_match('/\s/', $ptrChar )) { //do nothing } else { if ($ptrChar == '(') { $stack[] = CMS_ARR_BEGIN; } elseif ($ptrChar == ')') { $arrBegins = array_pop(array_keys($stack, CMS_ARR_BEGIN)); if ($arrBegins === FALSE) { user_error(Unexpected ')', E_USER_WARNING); return; } $arrTokens = array_splice($stack, $arrBegins + 1); //get array content array_pop($stack); //remove beginning token if (empty($arrTokens)) { //empty array $scalars[] = array(); $stack[] = CMS_SCALAR; continue; } $arrScalars = array(); foreach ($arrTokens as $token) { if ($token == CMS_SCALAR) { $arrScalars[] = array_pop($scalars); /*arrScalars are now reversed, so first token is the last scalar*/ } } if ($arrTokens[sizeof($arrTokens) - 1] != CMS_COMMA) {//for symmetry array_push($arrTokens, CMS_COMMA); } $arrBuffer = array(); reset($arrTokens); while (list(, $token) = each($arrTokens)) { if ($token == CMS_SCALAR) { list(,$nextTok) = each($arrTokens); if ($nextTok == CMS_COMMA) { $arrBuffer[] = array_pop($arrScalars); continue; } elseif ($nextTok == CMS_ARROW) { list(, $valTok) = each($arrTokens); if ($valTok != CMS_SCALAR) { var_dump($arrTokens); var_dump($arrScalars); user_error(Invalid token encountered during array compression: $valKey = $valTok, E_USER_WARNING); return; } $arrBuffer[array_pop($arrScalars)] = array_pop($arrScalars); list($valKey, $valTok) = each($arrTokens); if ($valTok != CMS_COMMA) { var_dump($arrTokens); var_dump($arrScalars); user_error(Invalid token encountered during array compression: $valKey = $valTok, E_USER_WARNING); return; } } else { echo Array compression dump:\n; var_dump($arrTokens); var_dump($arrScalars); user_error(Invalid token encountered during array compression:$ntk = $nextTok, E_USER_WARNING); return; } } else { echo Array compression dump:\n; var_dump($arrTokens); var_dump($arrScalars); user_error(Invalid token encountered during array compression:$key = $token, E_USER_WARNING); return; } } $scalars[] = $arrBuffer; //now multiple scalars replaced with array itself $stack[] = CMS_SCALAR; } elseif (preg_match('/[\']/', $ptrChar)) { $qEnd = strpos($str, $ptrChar, $ptr + 1); while ($str{$qEnd + 1} == $str{$qEnd}) { //deal with escapes $qEnd = strpos($str, $ptrChar,
[PHP] Re: Simple CMS program
When I went to a site that lists and compares CMS programs, I was overwhelmed by at least 100 listings. Again, I would like to rely on personal experience. What I am seeking is a CMS that will provide users at my client (a Yacht Club) to update news items, and if possible, update a calendar using a Web based editor. Not a full fledged portal CMS. Whatever you do, do not use PHP-Nuke or PostNuke. They are popular and they seem good at the beginning, but you will regret using them after a while. (Their internal design is not thought-through.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing data structires in DB
You are looking for serialize here. I bet you'd be better off with an existing XML format for something like this though. WDDX is an unusual extension for most of the hosting providers. And writing my own XML serialization mechanism is an overkill. Moreover, XML is not-compact, harder to edit and probably slower to parse. Compare this: wddxPacket version='1.0'header comment='PHP'/datastruct var name='pi'number3.1415926/number/varvar name='cities' array length='3'stringAustin/stringstringNovato/string stringSeattle/string/array/var/struct/data/wddxPacket (taken from php manual) to this a:2:{i:0;d:3.141592606840537025709636509418487548828125;i:1;a:3:{i:0;s:6:Austin;i:1;s:6:Novato;i:2;s:6:Seattle;}} (Number is given exactly as it was output by serialize. What a happy coincidence.) and to this array(3.1415926,array('Austin','Novato','Seattle')) (which could be reduced even more by elliminating the outer array() statement) I'm surprised that there is no way to safely serialize and unserialize things using the same syntax as PHP itself uses. I can, of course, write PHP data structure parser in PHP, but that's twisted way of doing it, and it will be *slow*. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Storing data structires in DB
Ok, let me ask in a different way. Is there any way to make eval to parse only data structures, without executing any functions it may encounter? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing data structires in DB
Why would you _manually_ edit a serialized array??? One would think you would UNSERIALIZE (http://us4.php.net/unserialize) the serialized array *before* working with the data. Well, I guess my initial posting was a bit misleading. I'm writing a content management system, and that system needs to give its users ability to create arbitrary data structures. Suppose users should be able to create hyperlinked menus. Each menu entry must have text, URL and, possibly, title. There are several ways to achieve such functionality. 1) Write big and ugly interface that does only that creates menus. Not very smart, because tomorrow users might need to create nested categories or some other things. 2) Invent your own syntax for menu programming and write small, but still ugly procedure that parses that syntax. 3) Invent your own syntax for data structure programming, and write function that parses it into PHP data structures. Almost a good solution, but then I would need some way to store, retrieve and edit data. 4) Use something that already exists. If I can, I would prefer to stick with 4. After all, PHP has var_export() and eval(). The problem is, var_export() stuffs its output with junk (extra commas, newlines, spaces), and eval() executes any code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Storing data structires in DB
Output of serialize() is barely readable and definetely is not suited for manual editing. It is quite simple to create var_export() clone that does not add junk to it's output. But then I would need to exec() the string to get a data structure back, which is bad security practice. Is there any good way to store/retrieve data structures (multidimetional arrays) to/from database? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php