[PHP] Re: how to check the form filled all
You might want to think about client side validation as well. This infomrs the user of any probelms *before* it hits your server. Now, this does *not* remove the step of form value checking on the server. Check out... http://groups.yahoo.com/group/javascript_validation/ A nice little client-side validation class, cross browser. Hope this helps. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on EPOCH limitations
How can I determine if a given UNIX timestamp is out of range on the current system? Right now I get an error thrown that tells me the timestamp is out of range. I'd like to "catch" that error, deal with it in my own manner, and not have the user see what went wrong. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Q on RegExp & extended Char
I should have posted some "rules" with this... assuming: - a SPACE is used to delimit first from last name [Walter Torres] - a HYPHEN is used to separate a dual name (British style) [Conrad-Smyth] - an APOSTROPHE is used in many Irish and Scotish names [O'Reilly] - a PERIOD is used in titles, suffixes [Dr. Sr. Jr.] - a PERIOD is used for Initials [Walter G. Torres] then... - allow apostrophes, but only if preceded *and* followed by a Alpha/Extend - allow hyphen/dash, but only if preceded *and* followed by a Alpha/Extend - allow PERIOD, but only if preceded by a Alpha/Extend *and* followed by a SPACE or EOS - allow SPACE, but only if preceded *and* followed by a Alpha/Extend also... - allow x80 thru xFF I've come up with this... /^([a-z\x80-\xFF]+(. )?[ ]?)+$/i |_||___||__| ^ ^^ ^ | || | | whole block ONE or more times || | || | SPACE - ZERO or ONE times alpha & extended | ONE or more | PERIOD - ZERO or ONE times but I can't seem to figure out how to get the HYPEN & apostrophe rules in here. But this does allow multiple spaces - which It really shouldn't but... It also lets me add SPACEs at the end, oh well... Any ideas? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on RegExp & extended Char
I've hit my limit on regular expressions. I need to check a string to see if it contains legal characters... A thru Z [a-z], SPACE, PERIOD, DASH/HYPHEN, APOSTROPHE [\' -,\.] OK, this is not a problem. My problem comes in with extended characters, as these examples... González Vänligen före innehålla I'm trying to build a RegExp that will see if the string is a proper name format or not. Names only have A thru Z, extended characters for other languages (than English), SPACE, PERIOD, DASH/HYPHEN, APOSTROPHE Dr. Roger O'Malley Mrs. Sara Harris-Henderson I have a RegExp to do English letters, but not the extended set... Manuel González Försök Bokstäver Contém Espaço-Válido (Ok, these are not really names, but you get the idea) Any ideas on this? All I want to know is if a given string contains only these types of characters. anything else would give me a FALSE. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] setlocale Q
Why does... // assume October... setlocale(LC_TIME, "de_GR"); echo strftime("%d. %B %Y"); gives me 'October'? and this... // assume October... setlocale(LC_TIME, "de"); echo strftime("%d. %B %Y"); gives me 'October'? and this... // assume October... setlocale(LC_TIME, "d"); echo strftime("%d. %B %Y"); gives me 'oktober'? I'm on a Win 2k box. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & JavaScript
"Martin Towell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi everybody! > > > > Have somebody any idea how I could do something like that? > > > > > settype($phpScreenWidth, "string"); > > settype($phpScreenHeight, "string"); > > ?> This is a serverside process This says the var $phpScreenWidth and the var $phpScreenHeight are to be strings. At this point they have no value associated with them. This is done on your server, *before* the page is given to the user... > > > > var phpScreenWidth, phpScreenHight; > > > > phpScreenWidth = screen.width; > > phpScreenHeight = screen.height; > > > > This is a clientside process This retrieves the width and height of the users browser window and drops that value into 2 JavaScript variables. This is done on the clinets browser, *after* the page is given to the user... > > > echo "Width:|".$phpScreenWidth."|"; > > echo "Height:|".$phpScreenHeight."|"; > > ?> This is a serverside process this displays the values of the vars $phpScreenWidth and $phpScreenHeight. This varaibles do *not* have any values. This is done on your server, *before* the page is given to the user... > > I know that this code is not working, it is just to see what I want to > > do. ASSUPTION: all 3 sections are on the same PHP page to be servered. Section #1 and #3 will be processed on the server *before* the page is given to the user. Section #2 will be processed on the clients browser *after* the page is given to the user. Your trying to clean the dinner dishes *before* you've set the table for dinner. It looks like you want to know the width and height of the clients browser window. And you want your PHP process to know this so it can do some magic. Well, first your going to have to serve up a page that retrieves that info, via JavaScript, places that info in 2 HIDDEN form objects, SUBMIT that info back to your PHP process and pull that data from the POST variables. *Then* you can do your magic in PHP with these values. Or, you can translate your magic into JavaScript and let JS do your magic on the clients browser. Does this help you? Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on preg_split
I have an array... [ sample of contents below] [0] => [1] => # words are recognized ceaselessly: true, yes, on, false, no, off. [2] => # --- [3] => [4] => [5] => # The mailing address of the list. [6] => # If empty, default is derived from address given in VMD.rc. [7] => LIST_ADDRESS= [8] => I have this script segment that processes the array into an associated array of name/value pairs... // Loop through file contents array foreach ($content as $i => $value) { // If we have any data in this line if (! empty ($value)) { // If this line is not a comment if ( $value{0} != '#') { list($a, $b) = split("=", $value); $content[$a] = $b; } // kill orginal array element unset($content[$i]); } } this work fine, but I saw a piece of script where someone used... list($a, $b) = preg_split("/=/",$content[$i], -1, PREG_SPLIT_NO_EMPTY); I inserted this in my script, and removed both IF statements. This works fine on the blank elements, but spits out warnings on the elements that do not have an '=' in it. I guess my problem stems from the fact I can't (don't know how to) read a file one line at a time. If I could to that, then I could just ignore blank lines, and or comment lines right off the bat. Anyone have any ideas on how best to solve this? Or at least a better solution? And parse_ini_file() does not help with this, unless someone can tell me how to change the delimiter this method assumes. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] there has to be a better way...
"Daevid Vincent" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here is a snippet from my dhcp web page found on my site below... Not > exactly what you want, but could help you start... thanks! > // read in the dhcp_map.ini file to map MAC addresses to images > $mapFile = "./dhcp_map.ini"; > if( $fp = @fopen($mapFile, "r") ) > { > while( $line = fgets($fp, 1024) ) this pulls out 1024 bytes of data form the file. right? or does this pull UPTO 1024 bytes of data or the EOL, which ever is first? > if ($line{0} != "#") $tempMap .= $line; // strip > out # comments > } else echo "ERROR: Can't read ".$mapFile.""; > fclose ($fp); > $map = explode("\n", $tempMap); OK. $tempMap is a string var. Each line of the file has a /n delimiting it. Now make an array of these line. Right? > for($i = 0; $i < count($map); $i++) > { > list($mac, $image, $name) = preg_split("/\s/",$map[$i], -1, > PREG_SPLIT_NO_EMPTY); walk down the map array. split each element on the SPACE, but don't deal with blank lines ... seems almost the same. nice use of PREG_SPLIT. I guess that helps with the BLANK lines. if fgets() onlt pulls out so much data, not to EOL, why use it? If I understand right, if I pull out 1028 of data, the '#' on each line could be anywhere in that buffer, not just at the first character. That's why I pulled in the entire file into a string var and then exploded it into an array split on EOL characters. Am I missing something? Thanks for your sample. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] there has to be a better way...
"- Edwin -" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 22 Oct 2003 03:10:44 -0500 > "jsWalter" <[EMAIL PROTECTED]> wrote: > > [snip] > > There must be a better way to do this. > [/snip] > > http://www.php.net/manual/en/function.parse-ini-file.php ? thanks. But, my concern with that is my config files use '#' for comment lines, not ';' Is there a way around this? Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] there has to be a better way...
I need to read (write comes later) from a config file that we used to handle manually. I'm getting lazy, so I'm writing a web interface for this. What I have does this... - open a given file - dump entire file into a string - explode string into an array at the EOL marker - walk down this new array - decide if there is anything in current element - decide if current line is a comment - split line at '=' into 2 variables - add new key and value from these variables back into array - kill original array element There must be a better way to do this. All this seems a bit over kill to me. Does anyone have any ideas on this? Thanks Walter This is what I have... $value) { // If we have any data in this line if (! empty ($value)) { // If this line is not a comment if ( $value{0} != '#') { list($a, $b) = split("=", $value); $content[$a] = $b; } // kill original array element unset($content[$i]); } } // show me what I have echo ''; echo print_r($content); echo ''; ?> # Sample config file data, just 2 lines from the file... # # The "Personal Name" of the list, used in outgoing headers. # If empty, default is the same as the list's username. # if explicitly `false', then it is redefined empty. LIST_NAME="RMT Working Group" # The address of the list's admin or owner. # if explicitly `false', then it is redefined empty. [EMAIL PROTECTED] ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] set the PHP to look at library files.
"Robert Cummings" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > See the "include_path" setting in your php.ini file. Right! I have many classes I've pulled from phpclasses.org. They all sit in a CLASSES directory inside my PHP directory. Just like PEAR, same format as well. Just modify your 'include_path' variable in your php.ini file and your in business! Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Q on setlocale...
"Tom Rogers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Those locales actually have to be available or they will be ignored and that > will depend on what type of system your running on. OK, I'm on Windows 2k, and after reading Microsofts docs, I thought it was all there. Maybe not. > For example on my system (linux) I had to do > > localedef -ci es_ES -f ISO_8859-1:1987 es_ES > > and then a restart on apache to get the Spanish locale working. Restart the server? No way to set this on the fly? > (Did I mention manuals :) No, but I got 2 private messages stating "RTFM" and no other comments. They were a big help. :/ I'm beginning to think this is tougher than I thought. :/ What I'm trying to do is have my new Class be aware of the LOCALE setting and take advantage of that info to return translated strings based upon that setting. I was hoping not to have a method in my Class to define LOCALE, I wanted to pick it up from the system, and even let the user set it on the fly. Thanks for your help Tom. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on setlocale...
"Tom Rogers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Sunday, September 28, 2003, 5:39:53 PM, you wrote: > j> I found this function, setlocale... > > j> now, is there a way to GET the LOCALE setting of a machine? > > j> Walter > > > call setlocale with 0 (zero or NULL) as the second parameter and it returns the current setting Thanks Tom... Now, if I understand this properly, This should return French_France... setlocale (LC_ALL, 'fr_FR'); echo setlocale (LC_ALL, ''); and this English_ Great Britain setlocale (LC_ALL, 'en_GB'); echo setlocale (LC_ALL, ''); and this German_Germany setlocale (LC_ALL, 'de_DE'); echo setlocale (LC_ALL, ''); and this Russian_Russia setlocale (LC_ALL, 'ru_RU'); echo setlocale (LC_ALL, ''); Well, all of them return the same thing for me... English_United States.1252 The 2 lines I have given in my examples are the only 2 lines in the script. I must be doing something wrong. Any ideas? Thanks Walter PS: And yes, I read the manual, much slower this time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on setlocale...
I found this function, setlocale... now, is there a way to GET the LOCALE setting of a machine? Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: static class call..
"Greg Beaver" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi Walter, Hi Greg... > in PHP 4, you can kludge this: > > Class Foo > { > function getBaz($set = null) > { > static $_TintBaz = 9; > if (!is_null($set)) { > $_TintBaz = $set; > } > return $_TintBaz; > } > } So I take it that this "kludge" will return a method variable, not a class property. mmm. Thx for the help. This Class thing is getting clear as mud! ;) Thank you for your help Greg. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] static class call..
Is there a way that a method within a Class, when called statically, can access a property of that Class? Class Foo { var $_TintBaz = 9; function getBaz() { return Foo::_TintBaz; // <-- line 8 } } echo Foo::getBaz(); This returns... Parse error: parse error, unexpected ';', expecting '(' in test 02.php on line 8 And of course, can't use 'return Foo::_TintBaz;' in a statically called Class. Is there any hope? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on Class, inhertance, ec... (a bit long)
"Martin Towell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What about something like this? I've been playing with that same approach this evening. But I guess I was hoping for a more direct, 1 level of inderection instead of 2. But, by making a "base" method in the main class, and it knowing about the second level of indirection, that sort-of solves the issue. Thanks for your time and thoughts. It help clarify my thinking and approach, and just showed me that I wasn't to far off the path, as it were. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on Class, inhertance, ec... (a bit long)
I have a quandary and I hope I can explain myself well enough that someone may understand and enlighten me. I am in the middle of building a (largish) Class. It is done for the most part, at least all pieces are there. Now I'm just trying to put the pieces together in a logical order. This is my issue; I have 2 sets of 12 methods that are identical in nature, but differ in implementation. Sort of like DB and Auth can handle different databases. (And yes, I've been studying them, but still am at a loss) I have my main class, BAZ, then I have 2 sub Classes, BAR and FOO. If x = 1, then I want to load BAR and utilize these 12 methods that are defined there. If x =2, then I want to load FOO and utilize these 12 methods that are defined there. The methods in each Sub-Class have the same names. My question is, how do I "wrap" this so that my methods calls are ignorant of with sub-class is used? Example: $myObject = new BAZ ( x = 2 ); // Utilize methods in FOO $myFred = $myObject->Fred; $myBarney = $myObject->Barney; or $myObject = new BAZ ( x = 1 ); // Utilize methods in BAR $myFred = $myObject->Fred; $myBarney = $myObject->Barney; And to throw a monkey with this wrenth, the 'factory' of the main class needs access to a few of these 'common' methods as well to prep several properties. Each sub-class contains about 600 lines of code, that I would rather not have in a single class file. Also, do I have to have these 12 methods names defined, but empty, in the main class? I hope this explains my non-understanding of PHP OOP to the level that someone can point me in the right direction. Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] javascript open window and a PHP script...
That's it! It works like a charm! Thank you very, very much! Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] javascript open window and a PHP script...
I have a link on a page... Add or Update Your Event This open the PHP file just fine and passes the vars fine. But I need a new window to open via JavaScript. Why? Because I have a "RETURN" link on the opening page that closes the child page, and if this new window is not opened via JavaScript I get the "Close Window OK?" dialog. The only way to not get that annoying dialog is to have that child window opened via JavaScript. So I did this... Add or Update Your Event A child window opens, I get 1 error dialog and a Download dialog, and then the page opens fine. error: IE cannot download calendar.php from window.open('... IE was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again. I hit OK and both the error dialog and the download page goes away. But the desired page is displayed in the child window! And the "RETURN" link closes the window without complaint! So, I've solved one issue to raise another. Anyone have any idea on this? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Editor - which to use?
I use Homesite. It has plug-ins for PHP so you have tps and cose completion. I just modified another plug it has so I can see then entire list of methods a script has in a window, which can then jump to, scroll to, insert here. And I can hit F-12 and it will talk to my apache server and run the script right there! All in one! Thee is CVS integration for Homesite, I just never got around to it. I just use WinCVS, I'm just lazy. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Working with PHP Class Within Javascript
"Harry Yau" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > I am writing a HTML page to gather whole bunch of information > provided by user and pass it to the PHP script to generate a report base > on these information. Namely, user inputs data in textfields of a HTML > FORM. Since, there is a lot of fields in the field, when the form > submitted, the URL to the PHP script become very long. That is because you sent the data as a GET. Use a POST and the URL will not change. > I am wondering two way to solve this problem. > First, I create a PHP Class to store all Infomation and using > JavaScript function in the HTML page to "PUT" those value of fields into > my PHP Class Object. Then pass the PHP Class Object to the PHP script. > However, I wondering is it possible for the JaveScript function to > manipulate the PHP Class Object, and How? How could I Call the PHP Class > Constructor inside the JavaScript function?? Moreover, How could I pass > the PHP Class Object from the HTML page to the PHP Script?? Is it > possible to do so?? In a Word, No. you are mixing apples and oranges. Javascript is all client-side (Yes, I knowm just ignore server-side for now, that is not what he is asking) and PHP is all server-side, not client-side at all. You use our JS to do what ever you want to do on the client machine. Then POST your name/value pairs to your server, which in turn calls your PHP to retrieve thosse name/value pairs and process them as needed. > Second solution I've thought of was writing another PHP function > inside the HTML page and doing the job as the JavaScript function. > However, I have no I idea how could the HTML page call the PHP function > when the user submitted the HTML FORM. Once again, How could I pass the > PHP Class Object from the HTML page to the PHP Script at the end?? Agagin, same issue. You can't do anything PHP on the clinte side. Yes think of this as 2 sides to the same coin. The JS will handle all client-side stuff, formatting, validation, calculations, etc and the HTML wraps it all up into name/value pairs to be sent to the server-side process to handle. Your server-side process, in this case PHP, will retrieve these name/value pairs from the server, process them as needed and return back a page that tells the user whatever you want to tell the user. Does that help? Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classes Tutorials
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Although i dont code for pear standards, i must recommend learning the pear > code, its how i taught myself classes. I concur. It is how I am learning this stuff. That and my stupid questions to this list (see previous posts just yesterday) Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on class failure...
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The constructor should be as quick as possible and have as little > logic as possible. What kind of failure are you trying to catch? not really trying to 'catch' a failure. I have to parse the given string format and determine if that format is valid. If yes, then I can do more work and return an instance. If no, I wanted to return a NULL. That way I know it failed. Maybe I should be looking at PEAR::Error istead of a NULL on faliure. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on class failure...
"Raditha Dissanayake" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi, > > It's generaly considered that constructors are supposed return an > instance of that class. Use a factory instead if you want to return nulls; A Factory? OK, I'll look that up, do some readng and try that route. So, if I understand you, using this 'factory' I can either return a new class instance (if it passes all the tests) or a NULL value (no instance) if it fails? Thanks for the pointer. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] advise on new class of mine
Thanks Curt for your reply. It helped my head a bit. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on accessing properties of parent from child class...
I've read the entire manual on classes, and I did not see an answer to my question. I see how to access methods of a parent from the child... parentName::foo(); or parent::foo(); but I would like to gain access to read and/or modify properties from the parent. Yes, I built getters that work, but I was wondering about a more direct method. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on class failure...
I found this in the docs... If you want your constructor to possibly not create the object class A { function A() { // ... // some error occurred $this = null; return; } } I tested it, it works great. Then I read on... Setting $this to null isn't available in PHP 4.3.3R3 anymore. Maybe in version below also. Great! :/ I have 4.3.2, so I guess it would work for me. If this "feature" has been removed, can someone show me a good way to indicate a failure on object instantiation? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] advise on new class of mine
I'm in the process of building my first "real" class. 43 methods, 23 properties, nearly 1000 lines of codes. What I would like to know... Is it better to keep al this in a single file? Or break it up into sub-classes? This does have logical sections, so a breakup would be possible, but then I'm not sure how I would piece it back together. Also... Many properties are not required at object instantiation, but I define them none-the-less. Many are derived from multiple others. It is better to define all properties, many may never be used, or simply define them as they are called? I define them all now, so there is a (ever so) slight hit on cycles for this. If I define them as they are called, then each needs a conditional to process to run each time that GETTER is called. Or is this "6 of one and half-dozen of another"? Now, this gets broken up, many of the properties correspond the different sections. then he properties should be defined as called, because their package would only be loaded when called. Am I talking in circles here? Does anyone have any advise? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Q on Regular Expressions - solved
Once again, I ask a stupid question, wotk on it some more and find the answer under my nose. Thanks anyway, I have what I'm looking for. Walter BTW: If you would like to know what I did, or even look at it and comment... === /* American Standard Format - accepts SLASH or DASH "02/03/1994 14:15:29 EST"-- American Standard 24 Hr Clock "02/03/1994 02:15:29 PM EST" -- American Standard 12 Hr Clock "02/03/1994 14:15:29"-- zone is optional "02/03/1994" -- only date Will work on dates before 1000, but must have leading ZEROs */ $strDate = "01-02-1994"; file://$strDate = "01/02/1994 01:02:03"; file://$strDate = "01/02/1994 01:02:03 GMT"; file://$strDate = "01/02/1994 01:02:03 AM GMT"; $regExp = "^"; // Start at begining of string $regExp .= "("; // Start Date Block $regExp = "([0-9]{2})[-|\/]"; // Month DASH or SLASH $regExp .= "([0-9]{2})[-|\/]"; // Day DASH or SLASH $regExp .= "([0-9]{4})";// Year $regExp .= ")?";// End Time Block $regExp .= "("; // Start Time Block $regExp .="[[:space:]]"; // Space $regExp .= "([0-9]{2}):"; // Hour COLON $regExp .= "([0-9]{2}):"; // Minute COLON $regExp .= "([0-9]{2})";// Seconds $regExp .= "("; // Start Meridium Block $regExp .="[[:space:]]"; // Space $regExp .= "[a-zA-Z]{1,2}"; // AM/PM $regExp .= ")?";// End Meridium Block $regExp .= "("; // Start TZ Block $regExp .="[[:space:]]"; // Space $regExp .= "[a-z|A-Z]{1,3}"; // Time Zone $regExp .= ")?";// End TZ Block $regExp .= ")?";// End Time Block $regExp .= "$"; // End at end of string if (ereg ($regExp, $strDate, $regs)) { echo ''; echo '|' . $strDate . '|' . ''; echo print_r($regs); echo ''; } else { echo "Invalid date format: $strDate"; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on Regular Expressions
Thanks for the pointer, but this only deals with date/time in EPOCH range. I'm trying to handle dates pre-epoch. Thanks Walter "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote jsWalter ([EMAIL PROTECTED]): > > I have a fairly complicated regular expression that was written for perl. > > > > I've spent the last 4 days trying to convert it to PHP. > > have you looked at strtotime()? > http://php.net/strtotime > > The Date formats it can find are defined here: > http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html > > > Those regex's look like a nightmare, like they usually do :) > > > > > # Does input match this RegEx? > > > > (($day,$mon,$yr,$hr,$min,$sec,$tz) = > > /^ > > (\w{1,3}) # month > > \s+ > > (\d\d?) # day > > \s+ > > (\d\d?):(\d\d)# hour:min > > (?::(\d\d))? # optional seconds > > \s+ > > (?:([A-Za-z]+)\s+)? # optional timezone > > (\d+) # year > > \s*$ # allow trailing whitespace > > /x) > > > > > Curt > -- > "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on Regular Expressions
I have a fairly complicated regular expression that was written for perl. I've spent the last 4 days trying to convert it to PHP. I guess I'm just that bright. I can't even get the sub parts (between the || to work, much less the conditionals Would someone mind showing me how I can make this work in PHP? Thanks walter # Does input match this RegEx? (($day,$mon,$yr,$hr,$min,$sec,$tz) = /^ (\w{1,3}) # month \s+ (\d\d?) # day \s+ (\d\d?):(\d\d)# hour:min (?::(\d\d))? # optional seconds \s+ (?:([A-Za-z]+)\s+)? # optional timezone (\d+) # year \s*$ # allow trailing whitespace /x) # If not that one, then this RegEx? || # Then the Unix 'ls -l' date format (($mon, $day, $yr, $hr, $min, $sec) = /^ (\w{3}) # month \s+ (\d\d?) # day \s+ (?: (\d\d\d\d) | # year (\d{1,2}):(\d{2}) # hour:min (?::(\d\d))? # optional seconds ) \s*$ /x) # If not that one, then this RegEx? || # ISO 8601 format '1996-02-29 12:00:00 -0100' and variants (($yr, $mon, $day, $hr, $min, $sec, $tz) = /^ (\d{4}) # year [-\/]? (\d\d?) # numerical month [-\/]? (\d\d?) # day (?: (?:\s+|[-:Tt]) # separator before clock (\d\d?):?(\d\d)# hour:min (?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional) )?# optional clock \s* ([-+]?\d\d?:?(:?\d\d)? |Z|z)? # timezone (Z is "zero meridian", i.e. GMT) \s*$ /x) # If not that one, then this RegEx? || # Windows 'dir' 11-12-96 03:52PM (($mon, $day, $yr, $hr, $min, $ampm) = /^ (\d{2})# numerical month - (\d{2})# day - (\d{2})# year \s+ (\d\d?):(\d\d)([APap][Mm]) # hour:min AM or PM \s*$ /x) # I guess not any. So bale! || return; # unrecognized format -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and Apache
I have a complete setup and testing procedure for windows class machines. Hope it can help you. www.torres.ws/dev/php Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on "inhert" class code
Evans, thx for your effort. I see what your says, as I noticed the trouble at 3 this morning! This is how I fixed it... $session = &Auth::_importGlobalVariable("session"); $session[$this->_sessionName]['data']['_loginAttempts'] = $this->_loginAttempts; Pretty much the way you indicated. But then, as I read more, decoded the Class in my head more, I noticed that they had a method to deal with this issue. So I figured I'd juut use that method, in case something changes in future it won't bite me! // Store class var in session data Auth::setAuthData('_loginAttempts', $this->_loginAttempts); Thanks for your help. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on "inhert" class code
I have a parent Class that does this in one of it's methods... $session = &Auth::_importGlobalVariable("session"); $session[$this->_sessionName]['registered'] = true; I would like to "hook" into this in on eof my methods in a child class I thought I could do this... [538] $session = Auth::_importGlobalVariable("session"); [539] $session[Auth::_sessionName]['registered'] = true; But I get this error: Parse error: parse error, unexpected ']', expecting '(' in mypath\AuthUser.php on line 539 OK, I guessed wrong (again). This is how PEAR::Auth deals with inserting its class vars into a session and I want to piggyback on that. No need to roll my own, I think. Can someone show me the errors of my ways? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] vars between instantiate class...
Thanks. That is waht I needed to know! It works! Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] vars between instantiate class...
I am trying to see how many times a person has tried to log in during a session. the login script... $objAuth->start(); if ($objAuth->getAuth()) // is user logged in already ...display hello page... else ...display login page OK, so far so good. If the user punches in anything wrong, the login gets displayed again. Now I want to track this iteration of attempts. In the START method, I did this... $this->_loginAttempts = $this->_loginAttempts + 1; then I added echo $objAuth->getLoginAttempts(); before ...display login page... to see how it tracks. It always displays '1' To me, it looks like '$objAuth->start();' , which is called each time the page runs, which is each time a login attempt is made, is re-initializing all the class vars to their default state. If I make _loginAttempts = 8, then it displays 9. So, my question (this time) is how do I get the class to track this counter? I hope I explained this well enough. I really don't think this is a PEAR::Auth specific question. I think it's just a "how do I keep this counter going in a class" question. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on Class and EXTEND
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > jsWalter wrote: > > I'm wanting to EXTEND the orginal class. > > > > meaning, my THECHILD class efines new methods/properties, and I want it used > > as if it was part of the orginal THEPARENT Class. > > > > Me just being picky. > > It doesn't work that way, exactly. The child class can define new > methods and properties, but you must make an instance of the child > class, which will include the methods/properties from the parent, and > the new ones you have written. > > If I'm understanding you correctly, you could rename you parent class to > child, name the child class the same as your parent and have the "old > class" extend the "new class" you've written. You code should then work > the same, but have the new methods/properties available. What I am trying to do is EXTEND the PEAR::Auth Class with new properties and methods. But I still want to use the original instantiation call... $myAuth =& Auth(); So, I don't think I can rename the orginal Class in this case. I'm just being particular. Or do I have to create my new EXTENDED Class and then add code to PEAR::Auth to make it work as if it is always just Auth? (I was told I could not do that) Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Q on Class and EXTEND
> -Original Message- > From: Matt Matijevich [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 03, 2003 11:21 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [PHP] Q on Class and EXTEND > > > I dont know much about classes, but dont you want > > $a = new THECHILD('walter'); //so you can access $a->abc > > instead of > > $a = new THEPARENT ('walter'); No, I'm wanting to EXTEND the orginal class. meaning, my THECHILD class efines new methods/properties, and I want it used as if it was part of the orginal THEPARENT Class. Me just being picky. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on Class and EXTEND
I found a piece of code in the docs, and thought it was a way to EXTEND a Class with new properties tha cna be accessed from original Class Object. can someone tell me what I did wrong? Thx Walter = name = $newName ; } } class THECHILD extends THEPARENT { var $abc; var $xyz = "xyz"; // NOTE: this value will be lost during unserialization function _ATOM() { // NOTE: $this->xyz is now "xyz" $this = unserialize (serialize (new THEPARENT())); // NOTE: Original value of $this->xyz is lost $this->$abc = "abc"; // Better: initialize values after ser/unser. step } } $a = new THEPARENT ('walter'); echo $a->name . ''; echo $a->abc . ''; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can someone explain...
this difference bewteen A and B below? A)$a = &new className(true, 6); B)$a = new className(true, 6); /* missing & on the NEW */ thanks walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP if exit Q
If I am in a second level IF conditional and it failes, I want to jump out of the parent IF. How can I do that? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] weird output on my Apache2, PHP 4.2.3 Win2k box...
Can someone tell me why all mt PHP generated HTML has this pre-pended to it? And how can I turn it off? Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dev style guide
> -Original Message- > From: Chris W. Parker [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 4:33 PM > To: Jay Blanchard; Mike Migurski; jsWalter > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP] dev style guide > Ahhh /Hungarian/ notation. Now that makes sense. I *thought* there > was something funny about "polish notation" (which as I've found out is > a certain way of expressing mathematical equations [iirc]). OK, OK, my math geek-ness reared its ugly head. Hungarian notation is waht I shoulfd have said. ;) > I've found a few articles on Hungarian notation but none of them have > been all that great. Real wordy and without good examples. Do you have > any examples/articles to contribute? This is what I found on the issue around the 'net... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsgen/htm l/hunganotat.asp http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com: 80/support/kb/articles/Q173/7/38.ASP&NoWebContent=1 http://www.gregleg.com/oldHome/hungarian.html this one is short and sweet... http://www4.ncsu.edu:8030/~moriedl/projects/hungarian/ walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dev style guide
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote jsWalter ([EMAIL PROTECTED]): > > Is there a style guide for coding practices used when creating code to be > > shared with the community? > > The rule is to code they way the community has been coding. Thanks, I was afraid someone would say that. mmm... the reason I was asking is that I like to use polish notation for vars. It helps me remeber what the [EMAIL PROTECTED] I was doing last week. Having opened several (at random) Package files, I noticed that none of them to that. Just wondering. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dev style guide
Is there a style guide for coding practices used when creating code to be shared with the community? Walter -- Ankh if you love Isis. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how can I get errors to display in a browser?
"Comex" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > display_errors Bingo! thanks walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how can I get errors to display in a browser?
I have a test script, with deliberate errors. The broswer shows nothing, blank, empty. It used to show errors, now it does not. No idea what I did to turn it off. Can someone tell me hoew to turn it back on? In my php.ini file, it says... error_reporting = E_ALL I thought that was what it needed. I guess not. Thanks walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php4apache2.dll
Well, thanks Even, but my post stated what my phpinfo() was telling me was loading. My question is how can I tell if mod_php is running? Thanks anyway. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php4apache2.dll
What part of phpinfo.php tells me that mod_php4 is loaded and running on my Apache2/PHP 4.3.2 Win 2k system? php.conf (apache conf): # Windows Win32 version LoadModule php4_module modules/php4apache2.dll LoadFile "/etc/php/php4ts.dll" NOTE: pls, no comments on the lack of volume letter, this works if Apache *and* php are on the same volume. phpinfo - apache2handler: Loaded Modules: core mod_win32mpm_winnt http_core mod_so mod_access mod_actions mod_aliasmod_asis mod_auth mod_autoindexmod_cgi mod_dir mod_env mod_imap mod_include mod_isapimod_log_config mod_mime mod_negotiation mod_setenvif mod_userdir sapi_apache2 mod_ssl thanks walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and mod_perl
Anyone have any idea why I can't run PHP and mod_perl in the same web structure? I am getting this in my error log... [Thu Jul 17 14:02:07 2003] [error] 2508: ModPerl::Registry: Unterminated <> operator at G:/home/walter/htdocs/test.php line 1. This is my php file... "; ?> Any ideas? And yes, it worked before I installed mod_perl thanks walter -- In heaven an angel is nobody in particular. - George Bernard Shaw -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and MYSQL
"Bob G" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Please help I am going quite mad. > ... The PHP.INI file is in the PHP directory. the php.ini in your PHP directory is useless It needs to be in 1 of 3 places... 1) the IIS root directory, meaning where IIS EXE is at, *not* the web root 2) C:\WINNT (or where ever your system directory is called) 3) C:\php4 (this is HARD CODED as a last resort) I have mine in my web server directory *and* in my PHP directory. That way I can run it via web server or command line. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Q on echo phpinfo() ;
"Philip Olson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > You may set the location of php.ini by using the PHPRC > environment variable or during ./configure use the > --with-config-file-path directive. So, I take it that this is a setting you use during compile time. So, to fix this, as not to mandate the use of 'C:\winnt' I could just recompile everything. mmm. > Maybe you should just copy a php.ini into the directory PHP > is looking for it in, which appears to be C:\WINNIT. I was really hoping not to have to do that. It is so *Microsoft* in implementation. I was really hoping that something that came from outside the DarkSide would not be tempted. > If PHP was actually reading a php.ini, you would have instead > seen it as C:\WINNIT\php.ini as opposed to just a directory > path. So because no php.ini is being read, PHP is using all > default values as per a stock php.ini-dist. OK! Now I see. PHP is using default values since it can't "see" a php.ini file where it thinks it should be, the C:\WINNT directory. Well, I copied my php.ini into C:\winnt removed my "fix" for DB.php, restarted my Apache and sure enough, phpinfo() shows C:\WINNT\php.ini and DB.php no longer returns an error! :( [why the sad face? It thought you said it now works?] The sad face is because I am forced to place files in the windows directory. There was nothing I could do about Apache and it's use of the Registry, now it looks like I'm forced to do things "The Microsoft Way" with PHP. At least Perl is set up without using Microsoft's mandates. Thanks for the info Philip. I appreciate it. Now things are clearer. PHP now works, but I'm not happy, but that's not relevant. I'm always causing trouble. Now I 'need' to see if I can find someone who can re-compile this for me (no I don't have access to any of these tools. I'm learning PHP now since I was told that is what I need to add to my skill set if I want to get a job, again. I got laid off 6 months ago after 7 years as an Lead Internet Technologies Architect. PHP was just something I never had to deal with. The fortune 1000 didn't "want" that, so, I didn't do it. That'll teach me!) Anyway, Thanks Philip. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Q on echo phpinfo() ;
I ran this as a script from my Apache and it gave me a beautiful web page just full of wonderful information! But I have a question on just 1 item... Configuration File (piping) Path C:\WINNIT How does this value get set? My PHP is installed at 'G:\etc\php' My php.ini is there as well. The paths are set (in that ini file) as... include_path = ".;G:\etc\php\extensions;G:\etc\php\pear" extension_dir = "G:\etc\php\extensions" Even My Apache is told to look there as well... # Windows Win32 version LoadFile "/etc/php/gnu_gettext.dll" LoadModule php4_module "/etc/php/sapi/php4apache2.dll" Action application/x-httpd-php "/etc/php/php.exe" ScriptAlias /php/ "/etc/php/" (pls don't comment about there being volume letters missing to this block, I want to focus on the issue of a path being defined from out of the blue) Is this being hard coded somewhere? If so, then why does my PHP work at all? I have nothing that belongs to PHP in the system directory. Well, not completely true. PEAR installed a pear.ini in the system directory itself (I wish it didn't, but my PEAR not working properly is a different issue.) Nothing I've read from the web or the documentation has given me any understand on how this is set and why PHP file are needed in the location that the says to place them. I guess, this is a question for the folks who wrote the executables for Windows. Thanks for any help and enlightenment. Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php