Re: [PHP] I lied, another question / problem
I believe that only two things could be messing up your validation: a) input data b) your function a) Do a var_dump on your input data. Is there any white space characters or anything else that do not belong there in the string? b) Rewrite your function/rethink what you are doing. You said that your function should match letters from a to Z and some special characters like ' - _ . Try this regex: ^(\w+\s?[\'\-\_\.]?)+$ I would write the function as follows: function invalidchar ( $input ) { if ( preg_match ( ^(\w+\s?[\'\-\_\.]?)+$, $input ) ) { // string matches against the pattern, everything is ok return $input; } else { return false; } } if ( invalidchar ( $my_string ) == false ) { // do some stuff } else { echo You passed the test; } // untested // frank 16 jan 2007 kl. 04.47 skrev Beauford: My apologies, but I am just so frustrated right now. It seems my function doesn't work either (if that's even the problem, which at this time I just don't know). Somehow my variable is still getting a value, and I have no idea how. Even if I don't return anything it still gets a value. Basically this has just broken my whole site. If anyone can figure this out let me know, right now I just have to put this site up with no validation. Thanks -Original Message- From: Beauford Sent: January 15, 2007 10:26 PM To: 'PHP' Subject: RE: [PHP] I lied, another question / problem Does anyone have any idea to this problem? All the code is in the emails I have written to the list. I have temporarily solved the problem by writing my own function not using any pregs, eregs, or any other regs and it works perfectly. It's probably not considered good programming, but it works the way it is supposed to. I would however like to know what the issue is with the original code, or if this is actually a bug in PHP. Thanks -Original Message- From: Beauford [mailto:[EMAIL PROTECTED] Sent: January 15, 2007 7:22 PM To: 'PHP' Subject: RE: [PHP] I lied, another question / problem -Original Message- From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] Sent: January 15, 2007 7:53 PM To: Beauford Cc: 'PHP' Subject: Re: [PHP] I lied, another question / problem # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: I have file which I use for validating which includes the following function: function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { That regexp matches if $strvalue consists of zero or more ocurrences of a letter, a whitespace character, and any character whose numeric value lies between the numeric values of ' and . in your locale. Zero or more means it also matches an empty string. I'm still confused. This works perfectly on my other two pages with the exact same code. So why is it only this one page that is causing a problem? I don't know, I don't care. You have enough problems with the single regex, let's concentrate on fixing this first. This certainly has a bearing. If the code works here then there is nothing wrong with the code. There is something else going on. If I enter the word test in my form, without the quotes, then why is the fuction returning anything since this is a valid entry. Should it not only return a value if there is a problem. I don't understand that paragraph. The regexp matches, and the function returns *nothing* just as you programmed it. That, of course, means that the variable you are assigning this *nothing* gets set to *nothing*, which, in PHP lingo, is null. The problem is that it is returning *something*, and that's what I am trying to figure out. If I put this in my code after I do the checking it works, but it should not work if the function is retuning *nothing*. So the original question remains, what is being returned and why? If($formerror) echo Testing; This will display Testing - it should not display anything since nothing should be returned. All I want to accomplish here is to allow the user to enter a to z, A to Z, and /\'-_. and a space. Is there a better way to do this? 1. Do you really want to let them enter backslashes, or are you trying to escape the apostrophe? 2. Does that mean that /\'-_. (without the quotes) and (that's three spaces) are valid entries? Where do you see 3 spaces? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. Thanks -- 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] I lied, another question / problem
# [EMAIL PROTECTED] / 2007-01-15 19:22:24 -0500: From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: I have file which I use for validating which includes the following function: function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { That regexp matches if $strvalue consists of zero or more ocurrences of a letter, a whitespace character, and any character whose numeric value lies between the numeric values of ' and . in your locale. Zero or more means it also matches an empty string. All I want to accomplish here is to allow the user to enter a to z, A to Z, and /\'-_. and a space. Is there a better way to do this? 1. Do you really want to let them enter backslashes, or are you trying to escape the apostrophe? 2. Does that mean that /\'-_. (without the quotes) and (that's three spaces) are valid entries? Where do you see 3 spaces? That's a value the regexp will match. Is that intended? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. You don't understand that single function, and it does something else than you think it does. I told you what it actually does, but you chose to ignore the information. I don't know how I could help you more. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-14 20:47:02 +0100: Roman Neuhauser wrote: I have a circular dependency, and am looking for thoughts on breaking the cycle without (much) redundancy or hard to automate procedures. I'm developing two programs, Testilence, a unit testing library, and Amock (library for mock object generation, but that's irrelevant in this discussion); both programs have unit tests based on Testilence, but Amock itself should not depend on Testilence, and neither should contain (or depend on) nontested code. Testilence contains some utility classes I'd like to use in Amock (or indeed, anywhere). I could fork them, but would like to avoid this if at all possible. I think I can't pull them out into a separate library for both Amock and Testilence to depend on because that would create a dependency loop between the utility and Testilence since I'd like to keep using Testilence for the utility's unit tests. isn't there a circular dependency anyway? given that you unit test Testilence with Testilence? I should've stressed that I'm coming from the packaging side (think RPMs or such). You can run Testilence's test suite without having Testilence installed (both are in the same tarball), so there's no cycle. The goal is to make a successful run of the test suite a prerequisite of the utility installation... Think RPM or similar: if X.rpm depends on Y.rpm in runtime, you cannot make Y's installation depend on execution of commands from X. ok, I'm not grokking this fully - I'll just have to take you word on it :-) if these utility classes are utility classes I wonder whether it's not better if they have no external dependencies? That depends on relative merits in individual situations, I cannot answer this question as is either way. whilst reading about Testilence I remember coming across a mention of runkit runkit is mention because I'm considering its use for better test isolation, I haven't thought of using it for normal code. ... whilst I wonder whether using runkit for anything other than experimental stuff, could runkit not offer a solution (e.g. renaming the class dependent on the context of it's usage)? probably not, right? How would this work? from looking at runkit it would seem using runkit_import() would work, it would mean you simply 'include' the utility class(es) in both Testilence and Amock using runkit_import() and that would simply cause the second 'include' to overwrite the class definition of the first include. this could also be tackled using a chain of __autoload() functions. either way having a runtime dependency in your code is probably not a good idea even for a develop-time tool like yours is (because it's marked experimental and it raises the bar as to the getting your tool working) Both Amock and Testilence are versioned using Subversion, so I could leave the classes in Testilence and use svn:externals to put them in Amock too. That would lead to name clashes if both programs were used together, and that is a showstopper. given that they are the same code would conditional loading of the utlity classes not work? i.e. only load if they don't already exist That seems quite fragile, but I admit I haven't thought it through. unless the class is called something silly like 'Foo' or 'Utility' then I think that in practice the problem is negligable. this could be augemented with the use of a [number of] Interfaces - if the class already exists and doesn't implement the required interfaces then your code bails out. I'm not concerned about the user who's *attempting* to shoot himself in the foot, I'm worrying about my code shooting an unsuspecting user in the butt. from what I read it should be possible to at least give the user clear feedback as to why he has a hole in his foot - proper feedback should be enough for the user to address the problem. and if the user is defining his own RNeuhauserTestUtility class (or what ever you decide to call it ;-) then he probably needs some feedback! I think that a suitably 'weird' name for the class in question should be enough in practice to avoid problems (even if theoretically it's not an optimum solution) So far I'm leaning towards pulling the utility out from Testilence, sacrificing the ability to unit test the library without jumping through hoops. that seems sane - hopefully the utility won't change half as often as the 'real' tools and given that you test the utility yourself before packaging you know that it works ... maybe including your test results in the utility package is something to consider? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] odbc_execute
Hi; I'm e newbie in PHP. I have to reda data from an AS400 system; I use an ODBC connection and I have to read data from a table with This the SQL Statement $query_stm = SELECT * . FROM cordo.plavt . where atcdim = ? . and atdtvf = 999; This is the prepare statement : $result = odbc_prepare ($dbconn, $query_stm); This is the execute statement $exc = odbc_execute ($result, array($Targa)); I test the execution of the odbc_execute and I have TRUE, so all works fine; But now how can retrieve the data from the result set? ; It seems thet all the fetch function work with the odbc_exec statement; Can someone helps me ? ManyThanks Silvio Anzola Progetti IT Locatrent S.p.a. ALD Automotive Via Cavriana 14 20134 Milano Tel. 02/73898340 Fax.02/738976822 http://www.locatrent.it BLOCKED::http://www.locatrent.it/ [EMAIL PROTECTED]
[PHP] Re: Forms and destroying values
Hello all, give this a try Beauford. META HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHE Place that up in the head of the documement. It's not PHP but it used to work. I haven't used it in a few years. Beauford [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
# [EMAIL PROTECTED] / 2007-01-16 11:41:08 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-14 20:47:02 +0100: Roman Neuhauser wrote: The goal is to make a successful run of the test suite a prerequisite of the utility installation... Think RPM or similar: if X.rpm depends on Y.rpm in runtime, you cannot make Y's installation depend on execution of commands from X. ok, I'm not grokking this fully - I'll just have to take you word on it :-) 1. testilence.rpm requires (installed) testilence-util.rpm to install since testilence uses testilence-util at runtime, and 2. testilence-util.rpm requires (installed) testilence.rpm before it will install, because it runs commands (installed by testilence.rpm) as part of its install procedure ... whilst I wonder whether using runkit for anything other than experimental stuff, could runkit not offer a solution (e.g. renaming the class dependent on the context of it's usage)? probably not, right? How would this work? from looking at runkit it would seem using runkit_import() would work, it would mean you simply 'include' the utility class(es) in both Testilence and Amock using runkit_import() and that would simply cause the second 'include' to overwrite the class definition of the first include. That is evil. You have installed Testilence, it works. You install Amock, Testilence broke. Reason: incompatible versions of the utility. I know that whatever solution I end with will affect all clients of the classes (Amock, Testilence, 3rd party sw), what I'm looking for is something that will be easy to express and support using deployed packaging systems (*BSD ports, pkgsrc, RPM, whatever Debian uses ATM). this could also be tackled using a chain of __autoload() functions. How could you use Testilence to test your __autoload() if Testilence already used it? How could you test anything that depends on __autoload() if Testilence used that mechanism? What would preserve the mechanism if the CUT used a naive __autoload()? FMPOV __autoload() is untouchable and shouldn't be used at all. either way having a runtime dependency in your code is probably not a good idea even for a develop-time tool like yours is (because it's marked experimental and it raises the bar as to the getting your tool working) If you can install Testilence you can probably also extract a tarball into a directory in your include_path. :) Both Amock and Testilence are versioned using Subversion, so I could leave the classes in Testilence and use svn:externals to put them in Amock too. That would lead to name clashes if both programs were used together, and that is a showstopper. given that they are the same code would conditional loading of the utlity classes not work? i.e. only load if they don't already exist That seems quite fragile, but I admit I haven't thought it through. unless the class is called something silly like 'Foo' or 'Utility' then I think that in practice the problem is negligable. Still the objection I gave above: seemingly independent programs would silently influence each other's behavior. I'd rather make this relationship visible through the explicit dependency. So far I'm leaning towards pulling the utility out from Testilence, sacrificing the ability to unit test the library without jumping through hoops. that seems sane - hopefully the utility won't change half as often as the 'real' tools and given that you test the utility yourself before packaging you know that it works ... maybe including your test results in the utility package is something to consider? I'd include the tests of course. The steps would then be: install utility + its tests: no tests are run install Testilence + its tests: both utility's and Testilence's tests are run before anything is installed For other users of the utility, such as Amock: see above, plus: install Amock + its tests: both utility's and Amock's tests are run before anything is installed -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
ok, I'm starting to grok it now :-) Roman Neuhauser wrote: ... from looking at runkit it would seem using runkit_import() would work, it would mean you simply 'include' the utility class(es) in both Testilence and Amock using runkit_import() and that would simply cause the second 'include' to overwrite the class definition of the first include. That is evil. You have installed Testilence, it works. You install Amock, Testilence broke. Reason: incompatible versions of the utility. ah yes I see what you mean. ... So far I'm leaning towards pulling the utility out from Testilence, sacrificing the ability to unit test the library without jumping through hoops. that seems sane - hopefully the utility won't change half as often as the 'real' tools and given that you test the utility yourself before packaging you know that it works ... maybe including your test results in the utility package is something to consider? I'd include the tests of course. The steps would then be: install utility + its tests: no tests are run install Testilence + its tests: both utility's and Testilence's tests are run before anything is installed For other users of the utility, such as Amock: see above, plus: install Amock + its tests: both utility's and Amock's tests are run before anything is installed my gut says that it would be easiest to just keep to seperate copies of the utility class(es) one for each project, although it kind of depends on how large complicated the utlity is ... this would remove all the described problems and leave you with only the 'slightly' inelegant situation where you have to, internally, sync the [relevant parts of the] 2 codebases now and again. given that there is a possibility of different version of the utility being required (as per you 'That is evil' reply) the '2 seperate copies of the codebase' approach might be simplest and most reliable way of tackling the problem ... again (AFAIKT) this mostly comes down to you personally being able to accept the relative inelegance of the solution. I'm trying to act as an extra braincell here - forgive me if what I'm saying is way too simple to be worthwhile :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
# [EMAIL PROTECTED] / 2007-01-16 13:56:01 +0100: my gut says that it would be easiest to just keep to seperate copies of the utility class(es) one for each project, although it kind of depends on how large complicated the utlity is ... this would remove all the described problems and leave you with only the 'slightly' inelegant situation where you have to, internally, sync the [relevant parts of the] 2 codebases now and again. given that there is a possibility of different version of the utility being required (as per you 'That is evil' reply) the '2 seperate copies of the codebase' approach might be simplest and most reliable way of tackling the problem ... again (AFAIKT) this mostly comes down to you personally being able to accept the relative inelegance of the solution. It's two if you only count Amock, but I already have another potential use. If PHP had namespaces, I'd be happy. If PHP had a preprocessor, I'd use that to get around the lack of namespaces and give each client a non-conflicting, private version of the utility. Simple copyrename as you suggest would seem to lead to maintenance hell (read: bugs). I'm trying to act as an extra braincell here - forgive me if what I'm saying is way too simple to be worthwhile :-) Don't worry, I'm grateful for the input! And no, not too simple. After all I'm not looking for something sufficiently complicated, I'm looking for something so easy even I won't screw it! -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Forms and destroying values
Beauford wrote: Thanks, a little confusing there. You would think though that once the info is transmitted by the browser it would be forgotten by the browser. Anyway, I do have a work around, and since PHP can't do anything about what the browser does, this will have to suffice. But a refresh button is basically a retry the last operation so it's not surprising the same information is sent again. The correct solution here is to use the technique mentioned by Satyam. Bascially: form action=handler.php method=post blah /form handler.php ?php if (!empty($_POST)) { // Do stuff with $_POST, store it in a DB whatever. header('Location: hander.php') exit; } // Normal page output not referring in any way to $_POST echo Normal Page. // If you have to present the data previously given in $_POST, then // either store it in a DB or in a Session when handling the data above, // then access the data from the DB or Session here. // EOF ? This technique also means that the back button in the users browser is not broken by posting forms... which is nice. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] classes and objects: php5. The Basics
Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to prevent DomDocument from adding a !DOCTYPE.
Hello there, Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Thx in advance. Mathijs. --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 000703-1, 01/15/2007 Tested on: 1/16/2007 3:37:11 PM avast! - copyright (c) 1988-2007 ALWIL Software. http://www.avast.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] classes and objects: php5. The Basics
[snip] http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? [/snip] foo() is a function and would not be static, it can be public (default without explicit declaration in PHP5), protected and private. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] classes and objects: php5. The Basics
Backward compatibility with PHP4, where member functions couldn't be declared as static. Any member function could be called statically providing a static context instead of an object instance. 2007/1/16, Cheseldine, D. L. [EMAIL PROTECTED]: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] classes and objects: php5. The Basics
Forgot to mention that calling a non-statical function this way should generate an E_STRICT warning. 2007/1/16, Martin Alterisio [EMAIL PROTECTED]: Backward compatibility with PHP4, where member functions couldn't be declared as static. Any member function could be called statically providing a static context instead of an object instance. 2007/1/16, Cheseldine, D. L. [EMAIL PROTECTED]: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: classes and objects: php5. The Basics
Cheseldine, D. L. wrote: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave Hi Dave, the example code seems to be damn old. It doesn't even make use of the access control modifiers. To answer your question: foo() can be called statically this way since PHP5 still supports the PHP4-way of calling static methods (backwards-compatibility). In PHP4 one can call any method statically, since there is no static modifier in PHP4. Hint: In this case PHP5 generates an error of the type E_STRICT, which tells you that one can't call a given instance method statically. error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 'on'); Regards, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] classes and objects: php5. The Basics
Martin Alterisio wrote: Forgot to mention that calling a non-static function this way should generate an E_STRICT warning. and IIRC it will eventually be made a fatal error in php6, somebody please correct me if I'm wrong! 2007/1/16, Martin Alterisio [EMAIL PROTECTED]: Backward compatibility with PHP4, where member functions couldn't be declared as static. Any member function could be called statically providing a static context instead of an object instance. 2007/1/16, Cheseldine, D. L. [EMAIL PROTECTED]: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- 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] Going back with multiple submits to the same page
At 10:52 PM +0100 1/15/07, Otto Wyss wrote: When values are entered on one of my page I submit the result back to the same page (form action=same_page). Unfortunately each submit adds an entry into the history, so history back doesn't work in a single step. Yet if the count of submits were known I could use goto(n). What's the best way to get this count? PHP or Javascript? O. Wyss Wyss: Considering that this is client-side (i.e., history), I would look to javascript, namely: location.replace('whatever'); The location object has two methods: a) reload; b) replace. This is where the back button get's it's value. Replace that value and I think you'll find a solution, or at least that's where I would look. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running exec() on client
Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. Doe anyone have any suggestions? Cheers George, an Englishman abroad in sunny Edinburgh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
El Tue, 16 Jan 2007 15:07:36 - George Pitcher [EMAIL PROTECTED] escribió: Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. Doe anyone have any suggestions? Cheers George, an Englishman abroad in sunny Edinburgh You do not need to have apache installed to run PHP you just need PHP-CLI (Command Line Interface) -- Miguel J. Jiménez Área de Internet/XSL [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla. Teléfono: 955 036 800 - Fax: 955 036 849 http://www.isotrol.com ¿Cuántas lecciones más necesitaremos para aprender cuántas lecciones más necesitaremos para acertar? Juan José Ibaretxe (13/01/2007) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hash/checksum for an image?
At 5:16 PM -0800 1/15/07, Brian Dunning wrote: I want to make sure that a jpg uploaded by the user is unique. I was thinking about storing a hash code for each image in its MySQL record (got a db record for each uploaded image already). Is there an easy way to generate such a string? I do a similar thing on one of my projects and use an m5 hash to keep unique id's for every image. However, I don't specifically know of any way to make sure that the jpg the user is uploading indeed unique. The user may submit the same image more than once. It's possible to look at the header and data of the image to detect uniqueness. In my Mac programming days I used to store image information inside the not-used portions of the header (lot's of room there), but I am clueless as to how to do that with php. However, php is so robust I would be surprised if there's not a way to bit-twiddle a file -- does anyone have an example or can provide a reference? Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] running exec() on client
Miguel, You do not need to have apache installed to run PHP you just need PHP-CLI (Command Line Interface) Yes, I do know that, but what I want is for my colleague to follow a link on her web page that will trigger the php command, passing any required parameters. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-16 13:56:01 +0100: my gut says that it would be easiest to just keep to seperate copies of the utility class(es) one for each project, although it kind of depends on how large complicated the utlity is ... this would remove all the described problems and leave you with only the 'slightly' inelegant situation where you have to, internally, sync the [relevant parts of the] 2 codebases now and again. given that there is a possibility of different version of the utility being required (as per you 'That is evil' reply) the '2 seperate copies of the codebase' approach might be simplest and most reliable way of tackling the problem ... again (AFAIKT) this mostly comes down to you personally being able to accept the relative inelegance of the solution. It's two if you only count Amock, but I already have another potential use. If PHP had namespaces, I'd be happy. If PHP had a preprocessor, I'd use that to get around the lack of namespaces and give each client a non-conflicting, private version of the utility. Simple copyrename as you suggest would seem to lead to maintenance hell (read: bugs). if your utility implemented a mechanism to tell the using code it's version couldn't the using code use that to determine whether the minimum utility package version was available and simply bail out with suitable message if not ... again given that the utility class is exactly that it would be reasonable to assume that is be sufficiently simple to maintain BC, then again maybe not. could you point me at the svn web view that shows the utility code in question? it might give me some ideas. I'm trying to act as an extra braincell here - forgive me if what I'm saying is way too simple to be worthwhile :-) Don't worry, I'm grateful for the input! And no, not too simple. After all I'm not looking for something sufficiently complicated, I'm looking for something so easy even I won't screw it! okay then :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
George Pitcher wrote: Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. why is it slowing down? is this down to other work the server is doing? are the files being generated becoming 'heavier'? (it's a have your cake or eat it kind of situation, no?) isn't it cheaper to install a dedicated server for your app? (rather than making you jump thru hoops, I mean AFAICT this is a core business activity.) an entry level windows server will set you back for the price of a few days work - seems to me to be a much more cost effective attack plan. I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. what he allows and what you can actually do are 2 different thing. ;-) Doe anyone have any suggestions? Cheers George, an Englishman abroad in sunny Edinburgh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] circular dependency between libraries
# [EMAIL PROTECTED] / 2007-01-16 16:01:39 +0100: could you point me at the svn web view that shows the utility code in question? it might give me some ideas. I don't think it's relevant, but here you go: http://svn.sigpipe.cz/viewvc/view/trunk/testilence/src/Testilence/util.php?view=markup -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] running exec() on client
Jochem, -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: 16 January 2007 3:31 pm To: George Pitcher Cc: php-general@lists.php.net Subject: Re: [PHP] running exec() on client George Pitcher wrote: Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. why is it slowing down? is this down to other work the server is doing? are the files being generated becoming 'heavier'? (it's a have your cake or eat it kind of situation, no?) The other wor being done is requests for the documents being made by our clients (universities), file upload (usually large tiff files) and file download (usually small text-PDFs). We only have 80 clients so I would have thought the server should cope. isn't it cheaper to install a dedicated server for your app? (rather than making you jump thru hoops, I mean AFAICT this is a core business activity.) an entry level windows server will set you back for the price of a few days work - seems to me to be a much more cost effective attack plan. Unfortunately my bosses are pennypinching when it comes to these things, though I will be asking - just in case. I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. what he allows and what you can actually do are 2 different thing. ;-) Alas, my colleague often needs IT help, and the tecchie is 6 feet away (literally), whereas I am 380 miles away, so any underhand activity by me is bound to be noticed. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
# [EMAIL PROTECTED] / 2007-01-16 15:18:50 -: You do not need to have apache installed to run PHP you just need PHP-CLI (Command Line Interface) Yes, I do know that, but what I want is for my colleague to follow a link on her web page that will trigger the php command, passing any required parameters. You probably don't want to do that, at least not when you can't install a web server. Or was that ban Apache-specific? 1. Modify the PHP script to use $argv instead of $_GET/$_POST. 2. Install the CLI SAPI. 3. Write a small dialogue that prompts for whatever arguments using any of the languages available on Windows (Python would be ok) and start your PHP script from that, $argv populated from the form. Your colleague will see a usual buttons-sweet-buttons GUI application, you will be able to reuse the PHP script. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.
# [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100: Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Doesn't DOMDocument *require* DTD? I thought it's either that or a document fragment (which is probably what you're looking for). -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] running exec() on client
Roman, -Original Message- From: Roman Neuhauser [mailto:[EMAIL PROTECTED] Sent: 16 January 2007 4:53 pm To: George Pitcher Cc: php-general@lists.php.net Subject: Re: [PHP] running exec() on client # [EMAIL PROTECTED] / 2007-01-16 15:18:50 -: You do not need to have apache installed to run PHP you just need PHP-CLI (Command Line Interface) Yes, I do know that, but what I want is for my colleague to follow a link on her web page that will trigger the php command, passing any required parameters. You probably don't want to do that, at least not when you can't install a web server. Or was that ban Apache-specific? 1. Modify the PHP script to use $argv instead of $_GET/$_POST. 2. Install the CLI SAPI. 3. Write a small dialogue that prompts for whatever arguments using any of the languages available on Windows (Python would be ok) and start your PHP script from that, $argv populated from the form. Your colleague will see a usual buttons-sweet-buttons GUI application, you will be able to reuse the PHP script. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 I think it was any web server. Thanks for the suggestion - I'll have a look at that. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
George Pitcher wrote: Jochem, -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: 16 January 2007 3:31 pm To: George Pitcher Cc: php-general@lists.php.net Subject: Re: [PHP] running exec() on client George Pitcher wrote: Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. why is it slowing down? is this down to other work the server is doing? are the files being generated becoming 'heavier'? (it's a have your cake or eat it kind of situation, no?) The other wor being done is requests for the documents being made by our clients (universities), file upload (usually large tiff files) and file download (usually small text-PDFs). We only have 80 clients so I would have thought the server should cope. I'm guessing a bit but it sounds like inserting a stack of RAM will make the problem go away for the foreseable future. isn't it cheaper to install a dedicated server for your app? (rather than making you jump thru hoops, I mean AFAICT this is a core business activity.) an entry level windows server will set you back for the price of a few days work - seems to me to be a much more cost effective attack plan. Unfortunately my bosses are pennypinching when it comes to these things, though I will be asking - just in case. in which case he should understand that RAM is *a lot* cheaper than the days of work your going to be doing (on top of your normal activities), no? I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. what about PDF generation? no need for COM, should give you nice compact file sizes (as well as readonly docs) ... downside is the ammount of coding it would take ... then again your average penny-wise, pound-foolish PHB will probably see it as a cheaper alternative. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. what he allows and what you can actually do are 2 different thing. ;-) Alas, my colleague often needs IT help, and the tecchie is 6 feet away (literally), whereas I am 380 miles away, so any underhand activity by me is bound to be noticed. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] running exec() on client
I'm guessing a bit but it sounds like inserting a stack of RAM will make the problem go away for the foreseable future. I will ask. isn't it cheaper to install a dedicated server for your app? (rather than making you jump thru hoops, I mean AFAICT this is a core business activity.) an entry level windows server will set you back for the price of a few days work - seems to me to be a much more cost effective attack plan. Unfortunately my bosses are pennypinching when it comes to these things, though I will be asking - just in case. in which case he should understand that RAM is *a lot* cheaper than the days of work your going to be doing (on top of your normal activities), no? I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. what about PDF generation? no need for COM, should give you nice compact file sizes (as well as readonly docs) ... downside is the ammount of coding it would take ... then again your average penny-wise, pound-foolish PHB will probably see it as a cheaper alternative. I do a lot of PDF building and that was my first suggestion, before we looked at Word. My colleague rejected this on the grounds that publishers wouldn't know what to do with them! I think she is wrong. But I yielded on this point. You know what female colleagues are like? (To any females on this list - you are all wonderful people.) One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. what he allows and what you can actually do are 2 different thing. ;-) Alas, my colleague often needs IT help, and the tecchie is 6 feet away (literally), whereas I am 380 miles away, so any underhand activity by me is bound to be noticed. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
George Pitcher wrote: I'm guessing a bit but it sounds like inserting a stack of RAM will make the problem go away for the foreseable future. I will ask. ... I do a lot of PDF building and that was my first suggestion, before we looked at Word. My colleague rejected this on the grounds that publishers wouldn't know what to do with them! I think she is wrong. you know she is - PDF is designed and aimed specifically for/at publishers!??! some of my client (who have nothing to do with IT in general) are capable of generating PDFs all on their own and add a few lines into their email signature explain how to deal with PDF (and where to download the reader). oh well you can't fight a brick wall thought can you :-/ But I yielded on this point. You know what female colleagues are like? the *kind* of colleague you describe come in both male and female flavour - I find neither very tasty. (To any females on this list - you are all wonderful people.) One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. what he allows and what you can actually do are 2 different thing. ;-) Alas, my colleague often needs IT help, and the tecchie is 6 feet away (literally), whereas I am 380 miles away, so any underhand activity by me is bound to be noticed. Cheers George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running exec() on client
First.. I apologize for power-reading your message and not really grasping everything you're trying to do. From the responses, it sounds like my vote would be for PDF as well, being a very universal format and very easy to work with and makes small enough for your needs. If a file is still too big, maybe look at Zip'ing it (you should be able to compress it with PHP.. forget if you need an additional library or not, but that's a viable option as well). But if you really need client side scripting and can't install Apache (or even if you can, but you're on a Windows box and don't want to have to), might I recommend http://www.winbinder.comRubem has done a brilliant job making a native PHP environment for Windows using standard Windows API. Very similar to GTK, but not as clunky and ugly.. although Winbinder is really designed just for Windows environments, so no cross platforum client side GUI. But fantastic for Windows. Good luck, whatever you decide. And watch out for those female colleagues.. they tend to talk and one of them is bound to hear about your comments here :) -TG = = = Original message = = = Hi, I am looking for a solution to a server problem. I am part of a 2-person team - I look after document scanning, OCR (by outside agencies) as well as all development. My colleague is responsible for obtaining copyright permission from publishers (for what I do). Part of her process is sending emails to publishers with Word attachments. These are presently being generated by PHP on our NT server,but recently the process has started to slow down the server to the point of uselessness. I'm looking for an alternative way to do this. My colleague has rejected text file attachments as looking unprofessional. I would like to find a way of generating these files without actually needing to use COM, or winword on the server. We looked at RTF templates but found the filesize too great. One option I am considering is installing PHP on her PC and doing the letter generation locally, but don't know how I'm going to trigger it esp as our IT person has said I can't install Apache. Doe anyone have any suggestions? Cheers George, an Englishman abroad in sunny Edinburgh ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bug? (_ENV in PHP v5.2.0)
Hi Eli, Check variable_order in php.ini (http://us2.php.net/manual/en/ini.core.php#ini.variables-order) if the E is missing you will not get any environment variables. - Frank Hi, System: Win32 PHP 5.2.0 Apache 2.0.54 (PHP in CGI mode) CGI vars are not automatically loaded into $_ENV global array. Only when calling getenv('var'), just then the variable appears in $_ENV. Besides, it seems that the env vars are loaded automatically into $_SERVER. And $HTTP_ENV_VARS is always NULL. ?php echo before getenv...; echo br\$_ENV: ; var_dump($_ENV); echo br\$HTTP_ENV_VARS: ; var_dump($HTTP_ENV_VARS); getenv('SERVER_PROTOCOL'); echo hrafter getenv...; echo br\$_ENV: ; var_dump($_ENV); echo br\$HTTP_ENV_VARS: ; var_dump($HTTP_ENV_VARS); ? === output: before getenv... $_ENV: array(0) { } $HTTP_ENV_VARS: NULL after getenv... $_ENV: array(1) { [SERVER_PROTOCOL]= string(8) HTTP/1.1 } $HTTP_ENV_VARS: NULL Is it a bug? Or this is the way it should work? -thanks, Eli -- 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] I lied, another question / problem
Obviously I'm not quite understanding, maybe a further explanation is needed to help me understand. This is how I see it from what you said - am in in the right ballpark. The function is returning a null value if there is no error, and I guess PHP sees 'null' or as a value. So how do I get around this? This is how I call the function. if($result = ValidateString($orgname, 1)) { $formerror['orgname'] = $result; } If there is an error an error string will be returned (i.e. Error in field), if not I want nothing returned. Later on in the page I use - if(!$formerror) blah blah. This is where the problem is because if null or is being returned then $formerror has a value which breaks the above if. I hope this helps. Thanks -Original Message- From: Roman Neuhauser [mailto:[EMAIL PROTECTED] Sent: January 16, 2007 5:49 AM To: Beauford Cc: 'PHP' Subject: Re: [PHP] I lied, another question / problem # [EMAIL PROTECTED] / 2007-01-15 19:22:24 -0500: From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: I have file which I use for validating which includes the following function: function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { That regexp matches if $strvalue consists of zero or more ocurrences of a letter, a whitespace character, and any character whose numeric value lies between the numeric values of ' and . in your locale. Zero or more means it also matches an empty string. All I want to accomplish here is to allow the user to enter a to z, A to Z, and /\'-_. and a space. Is there a better way to do this? 1. Do you really want to let them enter backslashes, or are you trying to escape the apostrophe? 2. Does that mean that /\'-_. (without the quotes) and (that's three spaces) are valid entries? Where do you see 3 spaces? That's a value the regexp will match. Is that intended? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. You don't understand that single function, and it does something else than you think it does. I told you what it actually does, but you chose to ignore the information. I don't know how I could help you more. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- 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] sms through teleflip and php?
Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks!
Re: [PHP] sms through teleflip and php?
I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_SESSION variable gets lost on FORM action
Hi, I'm working on a website and one of the features that I've implemented so far is the user timeout. Every time that a user browses to a different page, the variable named $_SESSION['user']['lastactive'] is updated to the current time. However, before that, my PHP scripts check if the session for this user had timed out or not... The script that checks that is named session.php and it is included in every file. If it detects a timeout, it sets a variable $_SESSION['form']['errors'] to a string ('Your session has expired... Bla, bla, bla...') and then redirects to the login.php and the user will see that he his being asked to login again for the reason displayed. Everything works great except in one situation... If the timeout period happens when the user is filling a form, the action that it executes (process.php) will also include session.php and it sets the error string but when it redirects to login.php the $_SESSION['form']['errors'] variable is empty... Can anyone help me with this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
Beauford wrote: Obviously I'm not quite understanding, maybe a further explanation is needed to help me understand. This is how I see it from what you said - am in in the right ballpark. The function is returning a null value if there is no error, and I guess PHP sees 'null' or as a value. So how do I get around this? This is how I call the function. if($result = ValidateString($orgname, 1)) { $formerror['orgname'] = $result; } If there is an error an error string will be returned (i.e. Error in field), if not I want nothing returned. Later on in the page I use - if(!$formerror) blah blah. This is a bad way to test for a value also, unless you expecting only TRUE or FALSE and you are sure that it will always be set. Otherwise you should do something like this if ( isset($formerror) $formerror != '' ) { // Display Error } Also, going back to your original post, the function function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { return *; } } You would always return SOMETHING. Even if it is FALSE Give this a try: ?PHP function invalidchar($strvalue) { if ( preg_match(|^[[:alpha:][:space:]\'\.-]+$|, $strvalue) ) { return $strvalue; } return 'BAD'; //-- For testing only return FALSE; //-- Left this so you could return false and not a string } echo '('.invalidchar('something').')'; ? Jim Lucas This is where the problem is because if null or is being returned then $formerror has a value which breaks the above if. I hope this helps. Thanks -Original Message- From: Roman Neuhauser [mailto:[EMAIL PROTECTED] Sent: January 16, 2007 5:49 AM To: Beauford Cc: 'PHP' Subject: Re: [PHP] I lied, another question / problem # [EMAIL PROTECTED] / 2007-01-15 19:22:24 -0500: From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: I have file which I use for validating which includes the following function: function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { That regexp matches if $strvalue consists of zero or more ocurrences of a letter, a whitespace character, and any character whose numeric value lies between the numeric values of ' and . in your locale. Zero or more means it also matches an empty string. All I want to accomplish here is to allow the user to enter a to z, A to Z, and /\'-_. and a space. Is there a better way to do this? 1. Do you really want to let them enter backslashes, or are you trying to escape the apostrophe? 2. Does that mean that /\'-_. (without the quotes) and (that's three spaces) are valid entries? Where do you see 3 spaces? That's a value the regexp will match. Is that intended? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. You don't understand that single function, and it does something else than you think it does. I told you what it actually does, but you chose to ignore the information. I don't know how I could help you more. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- 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] $_SESSION variable gets lost on FORM action
On 1/16/07, Nuno Oliveira [EMAIL PROTECTED] wrote: Hi, I'm working on a website and one of the features that I've implemented so far is the user timeout. Every time that a user browses to a different page, the variable named $_SESSION['user']['lastactive'] is updated to the current time. However, before that, my PHP scripts check if the session for this user had timed out or not... The script that checks that is named session.php and it is included in every file. If it detects a timeout, it sets a variable $_SESSION['form']['errors'] to a string ('Your session has expired... Bla, bla, bla...') and then redirects to the login.php and the user will see that he his being asked to login again for the reason displayed. Everything works great except in one situation... If the timeout period happens when the user is filling a form, the action that it executes (process.php) will also include session.php and it sets the error string but when it redirects to login.php the $_SESSION['form']['errors'] variable is empty... You must be unsetting the individual $_SESSION['form']['errors'] variable or the entire $_SESSION array somewhere in there. David
Re: [PHP] Mailing list combined with PHP based forum
On Tuesday 16 January 2007 03:27, Dave M G wrote: PHP Users, I'm creating a PHP based forum, and what I'd like to do is have it work so that people can view and read the information via email, just like a mailing list The mailing part just need some kind of user list... with particulary an email address as part of the information information. Thereafter you just need to make php send mail to all the users on the list with an option to choose not to send to ignorant users ;) Yahoo! Groups does this, so I know this sort of thing is possible in principle. Somewhere down here I get confused do you, as you said with the top statement, just want to read and view? OR do you want the whole package? But so far as I can tell, open source PHP based forums, like phpBB and Simple Machines, don't commonly have this feature. Perhaps it's not possible with PHP? Anyway... here is what we did to get the commodities to let a mail be included on a webpage: It is very possible, me and a friend, built a plugin system for Second Life; Send information to a webpage with mail, of people loggin in on the webpage or the game... we never got around to do the chat part cuz jabber server did the job for us, witch integrated both the web and game cross chatting. We did get the mail messaging working and recognizing ppl from game to the webpage, all information was written to a user database. We had no intentions of building a forum since live chat for 3g mobile phones was our goal, but a forum sounds quite easy in comparison, at a first glance that is... I would imagine this is accomplished with a Cron job that checks an email account and passes the messages to the PHP system for parsing into the forum. Could be, rather I think some engine like the jabber server would be to prefer... Check out the 2.x branch. Can anyone start me off with some tips as to how, and if, this might be possible? A cron would maby be easier to both work and not so tought on the hardware; it would't be instant thou... Thanks for any advice or informaiton. -- Dave M G Ubuntu 6.06 LTS Kernel 2.6.17.7 Pentium D Dual Core Processor PHP 5, MySQL 5, Apache 2 -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100: Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Doesn't DOMDocument *require* DTD? I thought it's either that or a document fragment (which is probably what you're looking for). And how should i do this? Do you have any example avelable? Thx. --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 000703-2, 01/16/2007 Tested on: 1/16/2007 8:42:48 PM avast! - copyright (c) 1988-2007 ALWIL Software. http://www.avast.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variable gets lost on FORM action
David Giragosian wrote: On 1/16/07, Nuno Oliveira [EMAIL PROTECTED] wrote: Hi, I'm working on a website and one of the features that I've implemented so far is the user timeout. Every time that a user browses to a different page, the variable named $_SESSION['user']['lastactive'] is updated to the current time. However, before that, my PHP scripts check if the session for this user had timed out or not... The script that checks that is named session.php and it is included in every file. If it detects a timeout, it sets a variable $_SESSION['form']['errors'] to a string ('Your session has expired... Bla, bla, bla...') and then redirects to the login.php and the user will see that he his being asked to login again for the reason displayed. Everything works great except in one situation... If the timeout period happens when the user is filling a form, the action that it executes (process.php) will also include session.php and it sets the error string but when it redirects to login.php the $_SESSION['form']['errors'] variable is empty... You must be unsetting the individual $_SESSION['form']['errors'] variable or the entire $_SESSION array somewhere in there. David Hi Davis, thanks for the reply. I think that I've found the problem... But if you (or anyone else) can confirm I would appreciate. Sometimes in my code I use the Header('Location: index.php?var=value'); and I've found out (I think) that when one of these headers are executed by PHP, the rest of the script gets executed. I'm thinking that this is the problem because I've eliminated all the occurrences where the SESSION var was cleared until only one exists and it was after a Location Header. I've put an exit(); after the header and the problem was gone... :) Is this the correct PHP/HTML behavior or is there another problem? Am I supposed to put an exit(); after a header Location to make sure that no more code gets executed? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sms through teleflip and php?
Maybe phpMailer isn't sending the correct headers either. Sometimes all it takes is one missing header that a system is looking for and it may filter it as spam or something. Again, I encourage you to examine the headers from your Thunderbird good email and compare it to your PHP and/or phpMailer headers that are getting sent. Possibly try to emulate the successful email as much as possible by copying the headers from a known successful message. If that doesn't work, then you may contact teleflip or whatever service you're trying to send text messages to and ask them if they can provide any information as to why it may not be going through. Never know, might find someone with half a brain who can help. -TG = = = Original message = = = I tried using phpMailer and all and it nothing seems to work right. I can send it fine through thunderbird but it just seems to complain via php. Not sure why. On 1/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
This is a bad way to test for a value also, unless you expecting only TRUE or FALSE and you are sure that it will always be set. Otherwise you should do something like this if ( isset($formerror) $formerror != '' ) { // Display Error } The problem here is this. formerror is an array and can have formerror['a'], formerror['b'], etc. I don't care how many errors there are, I only want to know if there was an error somewhere along the way. Example: if I have two fields, Name and Age and they both have errors, I would echo $formerror['name'] and $formerror['age'] Then I check if(!$formerror) { do something.. This would not get done as the above two have errors, which is what I want. The problem still lies with something being returned from the function even if there are no errors. So if(!$formerror) never gets done. Which is the problem. Another question, and not related, how do I kill a session when someone leaves a particular page. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] More efficient thumbnail script
Hello, First off, thanks to everyone who helped me get started with a thumbnail gallery that would display info you could just copy/paste into a weblog (Or any webpage) and have the picture display. I am moving along with a few additions and seem to be running into a problem. The script I have works just fine, it's just slow when you put some large files in it, the page takes awhile to load weither I'm calling it through the php file it's self or through a include in an html file. I don't know enough about php (read: Hardly anything) to figure out if there is an issue with the script that I'm using or if it's the hard ware that is the problem. The php script I'm using can be seen here: http://www.raoset.com/ tests/picture/images/wheeler.php the html file I want to include it in is: http://www.raoset.com/tests/ pictures/index.shtml My goal for this script, is to have it so that you can upload pictures into a specific directory, see the images display in a thumbnail format on the screen, and be able to delete the file if you did the wrong one. I know there are places like flickr that can do all of this, and it's free. But I'm in it much more so for the knowledge of learning how to do it. my php version is 4.4.1 and I'm running on a Power PC 1.2Ghz processor with 1.0 Gb of ram and 2 300gig HD stripped into a raid array to provide redundant backup. Anyway.. Let me know if there is any more info you need and thanks in advance for any help or pointers you could give! As always RTFM is okay just please point me to the right FM ;) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com We hold these truths to be self-evident. That all men are created equal, that they are endowed by their creator with certain unalienable rights, (and) that among these are Life, Liberty, and the pursuit of Happiness. smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] sms through teleflip and php?
also consider that there maybe a reverse lookup being done on the sending MTA that the sms gateway doesn't consider kosher .. and/or that the IP of the sending MTA is grey-listed/black-listed. also a check may be being done to see if the sender's account exists on the sender's [your servers] domain. check the relevant logs on your server to see what (if anything) the sms gateway is asking your server. (no idea what/where those logs are hiding out). sorry if this all sounds vague, I'm mostly parroting what others have said in the past - I'm hardly what you would call knowledgable with regard to mail servers and all that jazz. [EMAIL PROTECTED] wrote: Maybe phpMailer isn't sending the correct headers either. Sometimes all it takes is one missing header that a system is looking for and it may filter it as spam or something. Again, I encourage you to examine the headers from your Thunderbird good email and compare it to your PHP and/or phpMailer headers that are getting sent. Possibly try to emulate the successful email as much as possible by copying the headers from a known successful message. If that doesn't work, then you may contact teleflip or whatever service you're trying to send text messages to and ask them if they can provide any information as to why it may not be going through. Never know, might find someone with half a brain who can help. -TG = = = Original message = = = I tried using phpMailer and all and it nothing seems to work right. I can send it fine through thunderbird but it just seems to complain via php. Not sure why. On 1/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
generating/resampling image data is a relatively heavy job for a script to perform. there maybe optimizations available in the script itself but generally caching the results the generation/resampling action is the way to increase performance ... you need a mechanism to check/store/retrieve cached images [and a way to automatically regenerate a cached image when the source image has changes]. another thing to consider on top of caching is to store the cached data on a 'ram' drive ... on linux I often use a sub directory on /dev/shm (which is a part of the filesystem which actually exists only in shared memory - more than likely that you dont have access to this on a shared hosting environment. Jason Pruim wrote: Hello, First off, thanks to everyone who helped me get started with a thumbnail gallery that would display info you could just copy/paste into a weblog (Or any webpage) and have the picture display. I am moving along with a few additions and seem to be running into a problem. The script I have works just fine, it's just slow when you put some large files in it, the page takes awhile to load weither I'm calling it through the php file it's self or through a include in an html file. I don't know enough about php (read: Hardly anything) to figure out if there is an issue with the script that I'm using or if it's the hard ware that is the problem. The php script I'm using can be seen here: http://www.raoset.com/tests/picture/images/wheeler.php the html file I want to include it in is: http://www.raoset.com/tests/pictures/index.shtml My goal for this script, is to have it so that you can upload pictures into a specific directory, see the images display in a thumbnail format on the screen, and be able to delete the file if you did the wrong one. I know there are places like flickr that can do all of this, and it's free. But I'm in it much more so for the knowledge of learning how to do it. my php version is 4.4.1 and I'm running on a Power PC 1.2Ghz processor with 1.0 Gb of ram and 2 300gig HD stripped into a raid array to provide redundant backup. Anyway.. Let me know if there is any more info you need and thanks in advance for any help or pointers you could give! As always RTFM is okay just please point me to the right FM ;) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com We hold these truths to be self-evident. That all men are created equal, that they are endowed by their creator with certain unalienable rights, (and) that among these are Life, Liberty, and the pursuit of Happiness. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPUnit2 and TDD
On 2/14/06, Paul Scott [EMAIL PROTECTED] wrote: I am busy porting/rewriting our framework (http://avoir.uwc.ac.za/projects/nextgen http://kngforge.uwc.ac.za) from PHP4 to PHP5, and would like to know if there are any additional mailing lists that anyone knows of that are specifically focused around this topic. If there are none, I would like to propose one, which I will gladly host. Is anyone on this list doing TDD? What resources are you using? Is anyone interested in helping me with the PHP version of Fitnesse and Fit Server? Any help would be greatly appreciated! That being said, I must say that writing unit tests before code is way better than I thought it would be, and also kind of fun! PHPUnit2 is an excellent piece of work, a big thanks to Sebastian Bergmann... --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Why not use PHPUnit3? Another great resource as far as I am concerned are the SitePoint forums located at http://www.sitepoint.com/forums/. Lots of great discussions there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
At 1/16/2007 12:54 PM, Jason Pruim wrote: First off, thanks to everyone who helped me get started with a thumbnail gallery that would display info you could just copy/paste into a weblog (Or any webpage) and have the picture display. I am moving along with a few additions and seem to be running into a problem. The script I have works just fine, it's just slow when you put some large files in it, the page takes awhile to load weither I'm calling it through the php file it's self or through a include in an html file. ... The php script I'm using can be seen here: http://www.raoset.com/ tests/picture/images/wheeler.php the html file I want to include it in is: http://www.raoset.com/tests/ pictures/index.shtml Jason, I'm not able to see your PHP script because when I navigate to the script it is interpreted, not downloaded as text. Please copy the script into a file ending in .txt if you'd like people to be able to read it. Is your thumbnail script slow because you're creating images on the fly every time? If so, an obvious fix would be to cache thumbnails on the server so you only have to create them once. The logic could look something like: if (thumnbail doesn't exist) { // create thumbnail save it to the server } // use existing file Then you might consider putting the thumbnail-cacheing logic into the script that lets people upload their images in the first place, so there won't be so much processing the first time the thumbnail gallery is loaded. Regards, Paul __ Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
On Jan 16, 2007, at 4:10 PM, Jochem Maas wrote: generating/resampling image data is a relatively heavy job for a script to perform. there maybe optimizations available in the script itself but generally caching the results the generation/resampling action is the way to increase performance ... you need a mechanism to check/store/ retrieve cached images [and a way to automatically regenerate a cached image when the source image has changes]. another thing to consider on top of caching is to store the cached data on a 'ram' drive ... on linux I often use a sub directory on /dev/shm (which is a part of the filesystem which actually exists only in shared memory - more than likely that you dont have access to this on a shared hosting environment. Luckily I'm not in a shared hosting environment. :) I sit about 3 feet away from the server that is running my script. I will look into caching the info though to see if I can figure out what I would have to change/add/delete to accomplish this. Would upgrading to PHP 5* be of any help? I've thought about upgrading but not knowing much about how to run the server from the command line(Part of what I'm learning) I didn't want to screw anything up. Jason Pruim wrote: Hello, First off, thanks to everyone who helped me get started with a thumbnail gallery that would display info you could just copy/paste into a weblog (Or any webpage) and have the picture display. I am moving along with a few additions and seem to be running into a problem. The script I have works just fine, it's just slow when you put some large files in it, the page takes awhile to load weither I'm calling it through the php file it's self or through a include in an html file. I don't know enough about php (read: Hardly anything) to figure out if there is an issue with the script that I'm using or if it's the hard ware that is the problem. The php script I'm using can be seen here: http://www.raoset.com/tests/picture/images/wheeler.php the html file I want to include it in is: http://www.raoset.com/tests/pictures/index.shtml My goal for this script, is to have it so that you can upload pictures into a specific directory, see the images display in a thumbnail format on the screen, and be able to delete the file if you did the wrong one. I know there are places like flickr that can do all of this, and it's free. But I'm in it much more so for the knowledge of learning how to do it. my php version is 4.4.1 and I'm running on a Power PC 1.2Ghz processor with 1.0 Gb of ram and 2 300gig HD stripped into a raid array to provide redundant backup. Anyway.. Let me know if there is any more info you need and thanks in advance for any help or pointers you could give! As always RTFM is okay just please point me to the right FM ;) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com We hold these truths to be self-evident. That all men are created equal, that they are endowed by their creator with certain unalienable rights, (and) that among these are Life, Liberty, and the pursuit of Happiness. -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves. -Abraham Lincoln smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] sms through teleflip and php?
Thanks for all the insights. It appears that it might have thought my email was spam as I sent it from another server and it worked fine. Thanks! On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: also consider that there maybe a reverse lookup being done on the sending MTA that the sms gateway doesn't consider kosher .. and/or that the IP of the sending MTA is grey-listed/black-listed. also a check may be being done to see if the sender's account exists on the sender's [your servers] domain. check the relevant logs on your server to see what (if anything) the sms gateway is asking your server. (no idea what/where those logs are hiding out). sorry if this all sounds vague, I'm mostly parroting what others have said in the past - I'm hardly what you would call knowledgable with regard to mail servers and all that jazz. [EMAIL PROTECTED] wrote: Maybe phpMailer isn't sending the correct headers either. Sometimes all it takes is one missing header that a system is looking for and it may filter it as spam or something. Again, I encourage you to examine the headers from your Thunderbird good email and compare it to your PHP and/or phpMailer headers that are getting sent. Possibly try to emulate the successful email as much as possible by copying the headers from a known successful message. If that doesn't work, then you may contact teleflip or whatever service you're trying to send text messages to and ask them if they can provide any information as to why it may not be going through. Never know, might find someone with half a brain who can help. -TG = = = Original message = = = I tried using phpMailer and all and it nothing seems to work right. I can send it fine through thunderbird but it just seems to complain via php. Not sure why. On 1/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com.
Re: [PHP] sms through teleflip and php?
blackwater dev wrote: Thanks for all the insights. It appears that it might have thought my email was spam as I sent it from another server and it worked fine. which makes it even more likely that the 'bad' server doesn't have it's relevant MX DNS records setup properly - I can't really tell you what properly entails - it's a responsiblity I hand off to the relevant sys admin :-) Thanks! On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: also consider that there maybe a reverse lookup being done on the sending MTA that the sms gateway doesn't consider kosher .. and/or that the IP of the sending MTA is grey-listed/black-listed. also a check may be being done to see if the sender's account exists on the sender's [your servers] domain. check the relevant logs on your server to see what (if anything) the sms gateway is asking your server. (no idea what/where those logs are hiding out). sorry if this all sounds vague, I'm mostly parroting what others have said in the past - I'm hardly what you would call knowledgable with regard to mail servers and all that jazz. [EMAIL PROTECTED] wrote: Maybe phpMailer isn't sending the correct headers either. Sometimes all it takes is one missing header that a system is looking for and it may filter it as spam or something. Again, I encourage you to examine the headers from your Thunderbird good email and compare it to your PHP and/or phpMailer headers that are getting sent. Possibly try to emulate the successful email as much as possible by copying the headers from a known successful message. If that doesn't work, then you may contact teleflip or whatever service you're trying to send text messages to and ask them if they can provide any information as to why it may not be going through. Never know, might find someone with half a brain who can help. -TG = = = Original message = = = I tried using phpMailer and all and it nothing seems to work right. I can send it fine through thunderbird but it just seems to complain via php. Not sure why. On 1/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
Jason Pruim wrote: On Jan 16, 2007, at 4:10 PM, Jochem Maas wrote: generating/resampling image data is a relatively heavy job for a script to perform. there maybe optimizations available in the script itself but generally caching the results the generation/resampling action is the way to increase performance ... you need a mechanism to check/store/retrieve cached images [and a way to automatically regenerate a cached image when the source image has changes]. another thing to consider on top of caching is to store the cached data on a 'ram' drive ... on linux I often use a sub directory on /dev/shm (which is a part of the filesystem which actually exists only in shared memory - more than likely that you dont have access to this on a shared hosting environment. Luckily I'm not in a shared hosting environment. :) I sit about 3 feet away from the server that is running my script. I will look into caching the info though to see if I can figure out what I would have to change/add/delete to accomplish this. I wouldn't bother with worrying about stored cached image output on /dev/shm until you have got caching working - although disk access is relatively slow it's not half as slow as regenerating a thumbnail on every request. here is a class that might help you when it comes to caching images, assuming you can work out how it works ;-) (I'm sure this class is not perfect but it works for me :-) ?php class ImageCache { var $validTypes = array('png','gif','jpeg'); var $cacheFileName; var $cacheFileType; var $cacheDir; var $im; /* you must give a valid 'cache' dir */ function ImageCache($cDir) { $this-cacheDir = $cDir; } /* generate a cache file name for the image your are generating * if your generated output image is dependent on the values of one or more request * variables then you should add the names to the $args array e.g. * * your script take width/height parameter: /image.php?width=200height=160 * * $args should be the following array: array('width', 'height'); */ function genCacheFileName($args = array(), $type = '', $prefix = '') { /* name/val pair delimiter in the string that results in the hash for the cache id */ $qHashMark = '%~^*'; $qry = array(); $args = (array)$args; natsort($args); foreach ($args as $arg) { if (($val = $this-getR( $arg, false )) !== false) { $qry[] = {$arg}=.str_replace($qHashMark,'',$val); } } $sep = '-:-'; $hash = md5($_SERVER['HTTP_HOST'] .$sep. $_SERVER['SCRIPT_NAME'] .$sep. join($qHashMark,$qry)); if (!in_array($type, $this-validTypes)) { if ($type == 'jpg') { $type = 'jpeg'; } else { $type = 'png'; } } $this-cacheFileType = $type; if (!$prefix) { $prefix = 'cacheimg'; } return ($this-cacheFileName = {$prefix}_{$hash}.{$type}); } /* get the fullpath to the location where the cache file is saved/stored */ function getCacheFilePath() { return $this-cacheDir . '/' . $this-cacheFileName; } /* Return true if the cache file is younger than the source file(s), * false otherwise. * * if this func returns true you can output the relevant cache file, * if false is returned it's your responsibility to generate the output file * and save it to the location given by $this-getCacheFilePath() * * the (array of) files passed to this function should be complete paths, * not just filesnames. */ function checkCache( $files = array() ) { $cacheState = true; $cf = $this-getCacheFilePath(); $mTime= is_readable($cf) ? filemtime($cf): 0; $lastModified = gmdate(D, d M Y H:i:s , $mTime).GMT; $files= (array) $files; if (!count($files) || !$mTime) { $cacheState = false; } else { foreach($files as $file) { if ($mTime filemtime( $file )) { $cacheState = false; break; } } } if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { /* The UA has the exact same image we have. */ header(HTTP/1.1 304 Not Modified); exit; } else { unset($headers); header(Last-Modified: .$lastModified); return true; } } else { // not cached - or cache invalidated // must cache the (new) data. return false; } } function showImage($type = '', $quality = 100) { header(
Re: [PHP] More efficient thumbnail script
On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: ... if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { I was waiting for this to be mentioned... I would use a more detailed approach: http://pastebin.ca/319054 Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
Curt Zirzow wrote: On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: ... if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { I was waiting for this to be mentioned... I would use a more detailed approach: http://pastebin.ca/319054 could you clarify alittle? (beyond not using the apache specific getallheaders() function - I chose to go that route because I never run on anything other than apache) is the value of $headers['If-Modified-Since'] identical to $_SERVER['HTTP_IF_MODIFIED_SINCE'] or *can* they differ (i.e. would it be stupid to assume that apache 'normalized' the modidfied-since string?) is my code borked or merely not covering a number of edge cases related to older or more exotic browsers - my code does output 304 headers at the right time AFAIHT. but going by your code there could, it seems, be improvement ... i'd like to understand what exactly the improvement is (would be) about. tia rgds, Jochem Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
Beauford wrote: ... function invalidchar($strvalue) { if(!ereg(^[[:alpha:][:space:]\'-.]*$, $strvalue)) { That regexp matches if $strvalue consists of zero or more ocurrences of a letter, a whitespace character, and any character whose numeric value lies between the numeric values of ' and . in your locale. Zero or more means it also matches an empty string. .. Further to my previous email, there is something weird going on here. I just tried using this: if (!ereg('^[A-Za-z0-9]', $strvalue)) { return error; } stop using bleeding ereg*() function - move to preg_*() funcs like the rest of the world did 5+ years ago. When I enter the word Test, which is valid, I am still getting an error 'Test' is not valid according to the regexp your using. ?php $strs = array(Test, Jochem, @##^%, , Test1, Test!, J*nk); // match a non-empty string containing *only* alpha numeric chars foreach ($strs as $s) { if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { echo error in string: \$s\ \n; } else { echo no problemo: \$s\ \n; } } ? (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) you need to read up and do lots of practicing with regexps - we do realise that regexps are not easy, unfortunately there is no shortcut to learning how to use them. I doubt many on this list could be considered expert in the field of regexps, but you have to get yourself a basic grasp or these things will bite you in the ass until the cows come home. start here: http://php.net/pcre http://php.net/manual/en/reference.pcre.pattern.modifiers.php http://php.net/manual/en/reference.pcre.pattern.syntax.php returned - but only on this one page. So there has got to be something on this page that is screwing this up, but what. I have been over and over this and can't see a problem. I could really use another pair of eyes on this as it is driving me nuts. I regexps drives everyone nuts to start with. first there is only the mountain, then the mountain is not a mountain, finally there is just mountain. am now into hour 6 with this. Absolutely ridiculous. thats nothing. most people take months to get anywhere useful with regexps, well okay I'm speaking for myself - I was in your position somewhere back in 2001, I was regularly sweating it for weeks trying to understand and getting certain regexps work 'properly'. don't give up. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
Beauford wrote: This is a bad way to test for a value also, unless you expecting only TRUE or FALSE and you are sure that it will always be set. Otherwise you should do something like this if ( isset($formerror) $formerror != '' ) { // Display Error } The problem here is this. formerror is an array Then check it as an array. $formerror = array(); ... do your validation here which may/may not add to the array. if (!empty($formerror)) { echo Something went wrong!; print_r($formerror); } else { echo Everything is ok!; } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odbc_execute
ANZOLA Silvio wrote: Hi; I'm e newbie in PHP. I have to reda data from an AS400 system; I use an ODBC connection and I have to read data from a table with This the SQL Statement $query_stm = SELECT * . FROM cordo.plavt . where atcdim = ? . and atdtvf = 999; This is the prepare statement : $result = odbc_prepare ($dbconn, $query_stm); This is the execute statement $exc = odbc_execute ($result, array($Targa)); I test the execution of the odbc_execute and I have TRUE, so all works fine; But now how can retrieve the data from the result set? ; It seems thet all the fetch function work with the odbc_exec statement; See comment here: http://www.php.net/manual/en/function.odbc-prepare.php#71616 You need to pass the $result from the prepare statement to the _fetch_* functions. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
$formerror = array(); ... do your validation here which may/may not add to the array. if (!empty($formerror)) { echo Something went wrong!; print_r($formerror); } else { echo Everything is ok!; } As I said the problem is that a value is being returned, how I check it is really not an issue as I know there is value there. I guess I need to figure out how to only return something if there is an error, and not return anything if there is no error, or just totally revise the way I am doing this period. I have corrected the problem, but it is messy and it is cumbersome, but it will have to do until I can work out something better. At least now I can take my time and work on this. I appreciate all the suggestions and maybe I can incorporate some of them once I do a rewrite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bug? (_ENV in PHP v5.2.0)
Frank M. Kromann wrote: Hi Eli, Check variable_order in php.ini (http://us2.php.net/manual/en/ini.core.php#ini.variables-order) if the E is missing you will not get any environment variables. - Frank Thanks, Frank.. That worked! :-) -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variable gets lost on FORM action
Nuno Oliveira wrote: Sometimes in my code I use the Header('Location: index.php?var=value'); and I've found out (I think) that when one of these headers are executed by PHP, the rest of the script gets executed. I'm thinking that this is the problem because I've eliminated all the occurrences where the SESSION var was cleared until only one exists and it was after a Location Header. I've put an exit(); after the header and the problem was gone... :) Is this the correct PHP/HTML behavior or is there another problem? Am I supposed to put an exit(); after a header Location to make sure that no more code gets executed? Redirecting using a Location header is not the only thing you can do with the header() function. It will never end processing of the script no matter what you pass to it. The example on the manual page for the header() function says as much (http://php.net/header), you read that right? ?php header(Location: http://www.example.com/;); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ? -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php