Re: [PHP] Array question
Mike, See entire function under topic Array question - maybe UTF?... I am trying to change accented characters to their equivalent without accents. And yes, the arrays look fine after var_dump()... Gerry On 2/27/07, Ford, Mike [EMAIL PROTECTED] wrote: On 27 February 2007 04:23, Gerry D wrote: I have a question on how to retrieve the value that corresponds to a key in an array. $fruit = array('a' = 'apple', 'b' = 'banana', 'c' = 'cranberry'); $key = array_search($c, $fruit); if ( $key === FALSE ) $n = $c; else { $n = $fruit[$key]; // how to get the value??? } the array_search works ok, but how do I get the value? all I get back is 'a' or 'b', not 'apple' or 'banana'... Please show a little more code, as it looks to me as though this should work how you think it should. Specifically: how do we know what is in $c? how do you know the array_search works? how do you know $n is only getting 'a', 'b', or 'c'? (Hint: var_dump() is your friend!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array question
I have a question on how to retrieve the value that corresponds to a key in an array. $fruit = array('a' = 'apple', 'b' = 'banana', 'c' = 'cranberry'); $key = array_search($c, $fruit); if ( $key === FALSE ) $n = $c; else { $n = $fruit[$key]; // how to get the value??? } the array_search works ok, but how do I get the value? all I get back is 'a' or 'b', not 'apple' or 'banana'... TIA Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] JPEG info needed
I need PHP to find out if a jpeg file uses progressive encoding. None of the standard exif or image functions seem to be able to tell me that. (please correct me if I'm wrong) Can anybody help me? TIA Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shopping cart
So if I understand you gentlemen correctly, these pre-builds serve as examples how NOT to do it? Gerry On 8/20/06, Larry Garfield [EMAIL PROTECTED] wrote: On Sunday 20 August 2006 20:17, Gerry D wrote: On 8/19/06, Larry Garfield [EMAIL PROTECTED] wrote: OSCommerce is crap. Don't bother. Why do you say that, Larry? I may want to get into an app like that because I think one of my clients is ready for it. What are the cons, and what are my options? What are Drupal's limitations? I tried using it for a client last summer, because it was available free on the client's web host. It is extremely rigid. If you want a program that works the way they want and looks kinda like Buy.com with a table-based layout in 3 columns with certain visual effects, it's fine. If you want to change or customize anything, good luck. Nearly everything is hard coded with HTML and presentation PHP and business logic PHP all mixed in together. With a table based layout. Ugh. As for using pre-build vs. rolling your own, the main reason I favor ready-made is the bank hookups. Anytime financial stuff is involved, I'd rather use something someone else already debugged than roll my own. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shopping cart
On 8/19/06, Larry Garfield [EMAIL PROTECTED] wrote: OSCommerce is crap. Don't bother. Why do you say that, Larry? I may want to get into an app like that because I think one of my clients is ready for it. What are the cons, and what are my options? What are Drupal's limitations? TIA Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to run one php app from another?
I don't know if you solved this already, but I use it to redirect to different pages depending on whther the user is logged in or not. Something like header(location:/page/?p=login); works fine. You were on the right track. Gerry On 6/15/06, tedd [EMAIL PROTECTED] wrote: Hi gang: This seems like so obvious a question, I am reluctant to ask. In any event, I simply want my php application to run another, like so: switch (option) { case a: run a.php; exit; break; case b: run b.php; exit; break; case c: run c.php; exit; break; } I know that from within an application I can run another php application via a user click (.e., button), or from javascript event (onclick), or even from cron. But, what if you want to run another application from the results of a calculation inside your main application without a user trigger. How do you do that? I have tried header(Location: http://www.example.com/;); ob_start(), ob_flush() and such, but I can't get anything to work. Is there a way? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to run one php app from another? RECAP
On 6/16/06, tedd [EMAIL PROTECTED] wrote: At 2:35 PM +0200 6/16/06, Barry wrote: But once output is made. You can't remove it. That isn't possible with PHP. I think I get it now. PHP does everything before the user see's anything. Any links (direct or via a form) are objects that the browser can act upon per the user through html or js, but not php. Interesting. Perfectly doable in PHP. Just have the form action go to a new php script and do your logic, then use header(location:...) to redirect. Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] page redirecting
On 6/28/06, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, June 28, 2006 5:17 am, kristianto adi widiatmoko wrote: i need to redirecting page, it could be done by using header function like this header(Location : page2.php?var1=foo); Then, the URL should be a full, complete URL, and not just a local reference. Sure you can use a local page, I do it all the time. You could just use session_start() at the top of both pages, and slam the data into $_SESSION, and then your Location: redirect would work Yep. Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks
Jay, I use a technique to prevent hitting the back button and resubmitting data. I use a 2-script process, one with the form and submit button (I set a session var here), and a second form (the action script). The action script makes sure the session variable is set, processes the info, then clears the session var. If the session var is not set, an error is displayed. Gerry On 6/26/06, Jay Blanchard [EMAIL PROTECTED] wrote: I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. The steps are; 1. Fill out form 2. Click 'Submit' 3. Data gets stored (including unique data and time stamp data in this casewhich should work out well) If the process sees the unique data and a timestamp sometime within the last minute it should ignore the subsequent attempt. 4. A reply is returned to the user based on the first click. The data returned to the user would be different for each click, that is why this is so important. The first data returned is the correct data. My confusion is in this (as I have mentioned in the past couple of weeks, most of the confusion is as a result of a lack of rest, which leads to not thinking clearly, which leads to me feeling ignorant); upon the second click, where I check to see if the data has been entered and find that it has how do I get it to return the data back to the user. I think I see it now..let's see.if I; Select * from foo where data is what it is and time is within last interval that I decide upon; if(1 == mysql_num_rows(that query up there)){ get that data for return to the user; } else { Insert data, do calcs, return data back to user; } Does that look reasonable, or am I missing something? Thanks for any insight! -- 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] Functions
On 6/30/06, Richard Lynch [EMAIL PROTECTED] wrote: #2. Don't alter the case of the input data, if at all possible. Accept what the user has given, and take it as it is. You can make your application not care about case, and you can format the case on ouput (maybe even with fancy CSS stuff) but don't mess with their input. Why not clean up crappy input right at the source, Richard? Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Chicago PHP Conference
Richard, Within the US that might be ok, but given latest developments, who wants to fly into the US from elsewhere? I could drive from Canada if I take 2 weeks vacation... I don't want to be a show stopper, but I think you need to explain what your target audience is re global travel, not just weather in Chicago. Having said that, I like your idea. Gerry On 8/12/06, Richard Lynch [EMAIL PROTECTED] wrote: It may have started as a joke on PHP-General, but this just isn't funny anymore. I'm in the pre-planning phase of organizing a PHP Conference in Chicago. Due to Chicago weather patterns, the ideal time would be Spring or Autumn. Given that cheap airfare generally requires significant advance notice, I am pre-emptorily eliminating Autumn 2006 as a viable option. If you are interested in attending please reply OFF-LIST with your name, email, and some basic input for ideal time-frames in the FALL or SPRING of 2007. Suggested Topics would be great, and offers to be a Speaker by well-known responders would also be MOST welcome. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comment form spammer
My implementation of captcha eliminated chinese spam. See http://www.lilyregister.com/page/?p=contact Gerry On 8/9/06, Micky Hulse [EMAIL PROTECTED] wrote: Hi, Recently, a client of mine was getting a ton of spam email from a site called hotbox.com. I updated her form to one with more spam security, but she is still receiving junk email. Anyone feel like sharing code snippets that will help beef-up spam protection for a contact script? Do you all enable a CAPTCHA system? Here is what I am currently using in my contact form script to protect from spam: # Error text: $no_go = 'Forbidden - You are not authorized to view this page!'; # First, make sure the form was posted from a browser. # For basic web-forms, we don't care about anything other than requests from a browser: if(!isset($_SERVER['HTTP_USER_AGENT'])) { die($no_go); exit(); } # Make sure the form was indeed POST'ed (requires your html form to use action=post): if(!$_SERVER['REQUEST_METHOD'] == POST) { die($no_go); exit(); } # Host names from where the form is authorized to be posted from: $auth_hosts = array(site1.com, site2.com); # Where have we been posted from? $from_array = parse_url(strtolower($_SERVER['HTTP_REFERER'])); # Test to see if the $from_array used www to get here. $www_used = strpos($from_array['host'], www.); # Make sure the form was posted from an approved host name: if(!in_array(($www_used === false ? $from_array['host'] : substr(stristr($from_array['host'], '.'), 1)), $auth_hosts)) { //log_bad_request(); header(HTTP/1.0 403 Forbidden); exit(); } # Attempt to defend against header injections: $bad_strings = array(Content-Type:, MIME-Version:, Content-Transfer-Encoding:, bcc:, cc:); # Loop through each POST'ed value and test if it contains one of the $bad_strings: foreach($_POST as $k = $v) { foreach($bad_strings as $v2) { if(strpos($v, $v2) !== false) { log_bad_request(); header(HTTP/1.0 403 Forbidden); exit(); } } } # Made it past spammer test, free up some memory and continue rest of script: unset($k, $v, $v2, $bad_strings, $auth_hosts, $from_array, $www_used); -- 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] A way to stop spam on this list
They're not Jap but Chi. And they drove me crazy on my websites until I fixed them. http://www.lilyregister.com/page/?p=contact is what stopped the idiots. Gerry On 6/19/06, Denis Gerasimov [EMAIL PROTECTED] wrote: Hello List Members, I am very tired of deleting spam messages received from PHP mailing lists and I think we all are. As I can see most of the spam messages are in Chinese / Japanese. Since this is an English-only mailing list I would like to suggest blocking all messages containing such Chinese / Japanese characters in body, or at least marking all of them with the word [SPAM] in subject (so mail clients will be able to deliver it to the Spam folder). AFAIK PHP lists use some home-grown moderator so doing this should be an easy task. Of course that may affect some legal users that have such characters in their signatures, but in this case it sounds reasonable just to reply with an email explaining blocking policy so any legal user will know what to do to get his message go through the moderator. What do you think? Have a great day, Denis S Gerasimov Web Developer Team Force LLC Web:http://www.team-force.org/ www.team-force.org RU Int'l: +7 8362-213555 email:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unicode
Tedd, Interesting that nobody knows the answer... I am struggling with this very issue for an international lily register... http://www.lilyregister.com/ Gerry On 6/5/06, tedd [EMAIL PROTECTED] wrote: At 7:08 PM -0700 6/4/06, Rasmus Lerdorf wrote: Larry Garfield wrote: In C or C++, yes. In PHP, do not assume the same string-number mapping. Numeric definition is irrelevant. Right, and now bring Unicode into the picture and this becomes even more true. -Rasmus I know there's always RTFM, but if you would care to discuss it, I would like to know why. How does php handle Unicode code-points and char-sets? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New Help with Javascript Navigation
Yah, and why are people still mindlessly clicking OK to install ActiveX plugins? On 4/27/06, Porpoise [EMAIL PROTECTED] wrote: Gerry D [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Interesting discussions... :) I see two issues: 1. if you are exposing php scripts to the client, how does the server side processing know what it should do and what the client should see? 2. and why can't JS write to the client's file system? Or read from files? Come to my website and let me first read all your private information, then trash it... Hackers and other cyber vandals would love you to implement this feature... LOL /Gerry D Isn't that feature called ActiveX?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New Help with Javascript Navigation
Interesting discussions... :) I see two issues: 1. if you are exposing php scripts to the client, how does the server side processing know what it should do and what the client should see? 2. and why can't JS write to the client's file system? Or read from files? Come to my website and let me first read all your private information, then trash it... Hackers and other cyber vandals would love you to implement this feature... LOL Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Removing special chars
I would like to replace all chars in a string that are not a-z or 0-9 with a space. I can use a series of str_replace functions, but there has to be a faster way. I know there is a solution but my chemo-brain is slowing me down today. Sorry... Any suggestions? TIA Gerry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php