Re: [PHP] java .vs php
Quoting [EMAIL PROTECTED]: I know Yahoo! uses PHP and I've heard Google does as well? Google uses Python. http://www.python.org/Quotes.html -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling competing edits in a wiki engine?
Quoting Silvio Porcellana [EMAIL PROTECTED]: Ok, I don't know if this makes much sense, but you end up with a script that gets executed (without user interaction) every 'n' microseconds, so your session data is always up to date (at maximum, with a delay of 'n' * 2 microseconds). You'd have to take into account the round-trip to the server and back. I'd say that on average we're talking seconds here, not microseconds. Besides, a ping every few minutes or so is quite enough. The real downside I see it having to rely on JavaScript, but that's that. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php is not writing errors in logfile
Quoting Jacob Friis Saxberg [EMAIL PROTECTED]: I have asked Php to log errors in a file but it doesn't. error_reporting = E_ALL display_errors = Off log_errors = On error_log = /var/log/php-errors.log Any idea what's wrong? Maybe that's not the right php.ini. Look at phpinfo(). Or the user that the webserver runs as doesn't have the right to access the logfile. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Postgres auto-commit
How can I disable auto-commit for a Postgres connection? Apparently server-side autocommit was thrown out in Postgres 8.0, and clients have to issue their own setting (which is sensible). The default is on (which I don't want). psql is apparently able to set or unset the AUTOCOMMIT option, but I found nothing similar for PHP. There is no ini setting for it. There is no function for it. Perhaps the options part of the connection string passed to pg_connect() might work, if I only knew what it's supposed to contain... Can anybody shed some light on this? -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Postgres auto-commit
Quoting Skippy [EMAIL PROTECTED]: How can I disable auto-commit for a Postgres connection? Apparently server-side autocommit was thrown out in Postgres 8.0, and clients have to issue their own setting (which is sensible). Apparently this will work (or at least it will be accepted by pg_connect): $conn = pg_connect(dbname=test host=localhost user=postgres options='-c AUTOCOMMIT=true'); Warning: it fails if you use values other than those that will set it to true (true, on, 1). Apparently you can't use false, off, 0. But I've noticed you can leave the value empty: $conn = pg_connect(dbname=test host=localhost user=postgres options='-c AUTOCOMMIT='); Hopefully, this has the off effect. Will have to test more. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class for creating RSS 2 feed?
Quoting Murray @ PlanetThoughtful [EMAIL PROTECTED]: Just curious if anyone knows of an existing class that will take MySQL records containing HTML and create a valid RSS 2.0 newsfeed from them? http://software.zuavra.net/rowd_feed/ -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gettext best practice
How do you people best deal with text meant for i18n via gettext, which is either large or contains HTML tags, or both? The GNU gettext manual, in section 3.2, recommends to split long texts at paragraph level, or in the case of long --help screens, in batches of 5-10 lines at most. I can dig this, but I'd still appreciate some feedback. Formatting, however, is a slightly different issue. The manual seems to have been written mainly for C users, and as such only deals with spaces, tabs and newlines. Of course, structural HTML is a big no-no IMO (ie. the likes of p, li or tables). But styling HTML is often needed (strong, em ...). Am I right in assuming that a small set of pure style-related HTML should be allowed? I'm thinking strong, em, del and ins. The alternative of replacing them with %s instead and inserting them in the code on the fly looks like an attrocity to me. And allowing any tags still doesn't make me 100% happy; consider borderline complications due to HTML vs XHTML, or the very principle of separating content from presentation, which seems to be breached. And how should br be dealt with? Allow it, or go with newlines instead, and decide in the code if I want to apply a nl2br() or not? -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: gettext best practice
Quoting Mark Rees [EMAIL PROTECTED]: Consider whether you will always display the information in a web browser. If there is any possibility that another program may be used for display, you don't want the HTML tags in the database. In this particular situation I'm dealing with I only have web browsers to worry about. However, for the sake of argument: couldn't I still allow those styling tags and do some post-processing in the code? Such as stripping the tags, or converting them to something else. Things like bold and italic are almost universally meaningful. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Big file encryption
Quoting Ahmed Saad [EMAIL PROTECTED]: // do whatever with the chuck you read. // you can encrypt it and write all the chunks to the same file But if you encrypt one chunk at a time and concatenate them later, or if you encrypt the whole thing, will you still get the same result? -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Big file encryption
On Thu, 14 Jul 2005 16:24:25 +0200 david forums [EMAIL PROTECTED] wrote: Not at all cause the chunk are beeing free every time it is write in the file. so it does not excide the amount you set. What I meant was that if the encryption algorithm inserts some magic info at the beginning of every chunk, then simply concatenating several encrypted pieces won't produce a valid piece, the same way concatenating several zip files won't produce a big valid zip file. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing password in cookie
On Sat, 09 Apr 2005 14:51:49 -0400 [EMAIL PROTECTED] wrote: A digression to a related issue (where I did take the conservative approach): A system I'm working on now was originally set up with password hashes in the database -- the PW itself was never stored. But the client wanted an email me my password feature so we had to encrypt and store the PW. Of course if someone had access to the database they'd get a lot of other stuff probably more useful than PWs so I don't worry about this too much. But I would rather have used the hash. You could've changed the password for them to something random, mail it to them and keep the hash in the database. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Eliminating CLI overhead
I intend to run a lot of PHP scripts, all the time, on a Linux machine. The scripts were designed for CLI environment, since they will handle the entire management of the machine, being started by init and then effectively and completely taking over. I'm wondering whether starting up the PHP interpreter for every script hurts performance, if there's anything I can do about it, and if possible, would the potential gain be noticeable? We're talking a machine in the range of 1 GHz CPU speed, with IDE disk drives. I've already considered all kinds of Linux-specific tricks, I'm interested in the pure PHP aspect of the issue. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: stream_set_timeout() stream_get_meta_data() etc...
On Wed, 09 Feb 2005 13:28:47 -0500 Al [EMAIL PROTECTED] wrote: Here is the code I ended up with, I left some test stuff included so anyone who may need it has a good start. Oh, and another thing: if anybody's going to implement this using sockets instead of fopen(), make sure to send the header Connection: close in the request to the remote server. These days most servers implement HTTP 1.1, which activates persistent connections by default ie. you'll never get EOF and you'll always time out. I'm not sure how fopen() overcomes this, it either has other means of detecting that the request was answered or it uses Connection: close too. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: stream_set_timeout() stream_get_meta_data() etc...
Quoting Al [EMAIL PROTECTED]: Darn, I left out an important function, the fread(). Code snip should be: $fp= fopen(http://www.anything.com/foo.html, 'rb'); if(!fp) {do something different} stream_set_timeout($fp, 2); $contents= fread($fp, 20); $status= stream_get_meta_data($fp); if($status[timed_out] {do something}; It appears to me there is a basic logic problem. The script must get past the fread() function before it gets to the stream_get_meta_data($fp). But, it hangs up on fread() and the script times out. Set the stream to non-blocking mode (stream_set_blocking). Now all read functions will return instantly, regardless if any data came through. You can test whether you got back anything by checking the returned data. If you now read from the non-blocked stream in a cycle, you will have no dead times and you will always retain control. Only now can you rely on comparing time() with a control value set before entering the cycle and decide to abort if a number of seconds has passed. stream_set_timeout() will be pretty much superfluous at this point and may even hinder your reading from the stream. Important tip: in a non-blocking cycle you MUST have an usleep() somewhere. Otherwise that cycle will consume 100% CPU while it runs. An usleep(1000) will suffice, adjust as needed. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] identifying the country of the people who connect to web site / portal
On Sat, 27 Nov 2004 12:35:53 + [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: We would like to identify the country of the people who connect to our website / portal using php. The idea is to provide them directly with the homepage in their language. Is that possible? Has anybody ever doen anything like that using php? Just because my IP address says I'm somewhere it doesn't mean you should slap me with a certain language which I may or may not understand. People travel. There are also countries who use more than one language. Surfers can set their language preferences in their browser. You should look at the Accept-Language and Accept-Charset headers that the browser sends and decide based on them. That's the sensible criterium IMO. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Atom 2 RSS Script? Anyone got one?
On Sun, 14 Nov 2004 16:48:57 +0100 Nick Wilson [EMAIL PROTECTED] wrote: hi all, im all tired out of searching, just cant seem to find a script that will convert atom 0.3 to any rss format. Does anyone have one or know where i can get hold of one? That's probably because most people have the data in a personal format which they convert to either RSS or Atom. Related to your problem, try looking for an XSLT transformation script. Both RSS and Atom are XML so it should work (actually, only the source needs to be XML). Sorry, can't point out any ready-made ones. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] set_include_path() isn't persistent
On Tue, 9 Nov 2004 01:39:03 +1100 Justin French [EMAIL PROTECTED] wrote: On 09/11/2004, at 1:26 AM, John Nichel wrote: Justin French wrote: Hi, Experimenting with set_include_path(), but it would appear that it doesn't persist for the duration of the request, just the current script. That is to say, an included file will not inherit the include_path() of the parent file. Is there any way to persist this without re-setting it on each file? Justin .htaccess or in the httpd.conf Figured as much... the catch is that I'd rather not have to explicitly set the path in htaccess (eg /usr/home/foo/public/bah/), but can't find a way yet to set a relative path in htaccess (eg ../ for one level up from this htaccess file). Any ideas? Did you try ini_set('include_path','path')? I recall doing this recently in a root script and then include() -ing other scripts. It worked out well. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] User's language settings
On Mon, 08 Nov 2004 22:37:41 +0100 Marek Kilimajer [EMAIL PROTECTED] wrote: How can I determine user's primary language? $_SERVER[HTTP_ACCEPT_LANGUAGE] - string with user's language preferences. However only a fraction of users willingly set it, so many times it will be on its default value, english even for russian speaking visitors. Perhaps try to advertise it somewhere on your site, how to set it in various browsers. People will use this once they realise the setting is there. It's very nice to go to a website without doing anything special and be greeted by your mother tongue. Once they experience this they will like it. HTTP_ACCEPT_LANGUAGE will look like this: ro,en-us;q=0.7,en;q=0.3 Comma is the main delimiter, separating languages. The q signifies precedence among similar languages, such as en-us vs en. Otherwise, the order in which the languages were given sets precedence. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Authentification related to browser window
Quoting Cristi Barladeanu [EMAIL PROTECTED]: My problem is pretty simple. User enters the site, logins, and after that he hits ctrl+n or something, to open a new window from same browser. Can I make him to login again in the new window but to keep him logged in the old one? Now i'm using sessions, but i realise that the cookies set by them are related to browser, so every window use them. You'll need to use URL session id's. I seem to recall that PHP sessions can be configured to use only them and never cookies. This way, the session id is passed as a GET parameter to every page you go to on your site. A new browser window won't have the id by default (if you go to the homepage) but it will if you do open this link in a new tab or new window. Session id's in the URL have a lot of downsides to them. First of all, you have to propagate them by hand. ALL links on your site must be careful to include them as GET parameters, and all POST forms must include them too. It's gets tedious very fast, and is error prone. Plus, it doesn't solve your problem 100%, as you can see above. If the new window is derived from an existing link they'll still seem already logged on. Finally, there are horrible security issues with URL sid's. The user may chose to save an URL containing a sid to his bookmarks, where they can be seen by someone else. They may send the URL (with the sid included) to a friend who may pass it on to others. The URL also gets passed to other sites in the Referer HTTP header. Finally, as long as they have JavaScript active in the browser, any site can check their recent browsing history and pick up the sid from there. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] enrypt and decrypt
Quoting Merlin [EMAIL PROTECTED]: Merlin wrote: Hi there, I would like to encrypt some info and later be able to decrypt it. As I saw there is only one way encryption possible with encrypt. Has anybody an idea how to do a 2 way encrypten? Thank you for any help, Merlin Hi, that requires to install another module?! It does not have to be that secure. Is there an easier way to encrypt an 8 digit ID without going through the hastle of updating the system? That sounds like a standard function to me. There are pure software solutions available. There was a 3 kb class included with Horde for instance, which could be used very nicely. It was called HCEMD5 and could do encryption/decryption with a secret and a public key (which were simple strings). You can also look in pear.php.net and see if any packages are good for you. I think this may do what you want: http://pear.php.net/package/Crypt_RC4 You can use PEAR packages without needing a priviledged user to install them on the server. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dirty words
On Sat, 16 Oct 2004 07:41:11 -0700 (PDT) Mag [EMAIL PROTECTED] wrote: I am useing file_get_contents on a remote page then using stristr() to make sure there are no bad words and its a family site. May I point out this is a lost battle from the start? If someone really wants to enter bad words they will, by masking them in various ways; humans will interpret the bad words correctly in far more cases than you can filter with software. Additionally, you will end up filtering parts of legit words that look like bad words. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lock or critical section
Quoting Jean-Yves [EMAIL PROTECTED]: Is there a documented way to create in PHP a critical section: I want a piece of code to not be executed in the same time several times? Give us a set of criteria and we'll see about it. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular expression help
I'm trying to replace all occurances of the X character in a text with Y, but only those X's that occur between bold tags (b/b). -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expression help
Quoting John Holmes [EMAIL PROTECTED]: From: Skippy [EMAIL PROTECTED] I'm trying to replace all occurances of the X character in a text with Y, but only those X's that occur between bold tags (b/b). ?php $str = 'This X and this X will not be fixed, but bthis X and/b and hopefully this bX/b should be, along b with this X also. /b, but not this X.'; function myreplace($match) { $from = 'X'; $to = 'Y'; return str_replace($from,$to,$match[0]); } $new_str = preg_replace_callback('#b.*/b#Uis','myreplace',$str); echo $new_str; ? It works great, thank you. I had tried something on my own previously, but without the ungreedy modifier and with replacements inside a repeated while{} cycle instead of a callback. The main drawback in my version was that an X near hopefully would have been replaced as well (since technically it is between b and /b). But that wasn't what I wanted, of course. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Inline diff coded in PHP
I'm looking for PHP code that will produce diff's between two texts, and render them inline. By that I mean not the standard *nix diff output, which compares and outputs lines, but a diff that compares inline text and outputs the bits before and after in place, marked with a custom span or something. Example of *nix diff: - this is the old line + this is the new line Example of what I need: this is the span class=oldold/span span class=newnew/span line I've seen this done in the htmldiff package, which is a C program. Except I don't want to diff HTML code, but regular text. I actually need this for a wiki engine, so it can present diffs between page changes in a better way. So: * Anybody seen such code? the PEAR diff only does line diffs. * Know of any GPL'd wiki engine which has my kind of diffs already implemented (as PHP?) * Any pointers about how I should go about writing my own such diff? -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Location header does not work?
Quoting Justin Patrin [EMAIL PROTECTED]: On Tue, 3 Aug 2004 15:34:27 -0500 (CDT), Bing Du [EMAIL PROTECTED] wrote: The latest message I got was 'Redirection limit for this URL exceeded. Unable to load the requested page.This may be caused by cookies that are blocked.'. Your page is redirecting you over and over again. Your problem is that you're not checking for https before you redirect! If the user comes in with the https URL, you're still redirecting them. Try checking the value of $_SERVER['HTTPS']. Also, FWIW, you're supposed to also change the HTTP response code to one that explains the reason for the redirect. Some server setups will throw a 500 Server Error if you use just Location. So add the following before any other header output: header($_SERVER['SERVER_PROTOCOL'].' 302 Found'); The HTTP RFC offers various 3xx response codes and you should make the effort of using the appropriate one. Other often useful responses are 301 Moved Permanently and 303 See Other. The actual text doesn't matter but the code does. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Java Script or PHP
Quoting Curt Zirzow [EMAIL PROTECTED]: What is the correct way to open the page from the print link to a new page? @media print { .css { its: all here; } } Yeah, but sometimes you want the print version to be more nifty, like have all the pages in an article instead of just the current page. That calls for some server-side work AND a specific print-only CSS. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browser reload problem
Quoting Ashley M. Kirchner [EMAIL PROTECTED]: PayPal passes a ton of data back to us when someone's done purchasing something. I use some of that information and shove it all into a database. Problem is, if someone hits reload on their browser, I get the same data re-inserted again. Reload the page four times, and I will get four records with the same data inserted. How can I avoid this? I'd like to silently either discard the information after it's been inserted, or silently prevent it from being re-inserted again. 1. Receive PayPal data in your script. 2. Process it (stick into database). 3. Redirect to another script and forward any data you want displayed. 4. Have the 2nd script show whatever confirmation message you want. The user can now reload all he wants, he gets just the 2nd script which doesn't do anything but display the same message over and over. ATTENTION: if you receive the PayPal data by POST be sure to redirect using 303 See Other, which will deactivate the POST and force the redirect to use GET. Of course, forwarding any data to the 2nd script should be done as GET parameters. Or, even better, just forward the 2nd script the database ID of the data you just recorded and if it needs to display anything it can get it from there. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Graphing Webstats using MRTG/PHP/MYSQL?
Quoting Louie Miranda [EMAIL PROTECTED]: has anyone know any tools related to this? Graphing Webstats using MRTG/PHP/MYSQL? Why MRTG _and_ PHP? AFAIK MRTG produces its own HTML and images. You can either use MRTG with whatever data (webstats) you collected or you can use PHP+MySQL for that and generate graphs from PHP. There must be PHP solutions to generating graphs out there, or you can write your own. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: If...Or...Else
On Sun, 25 Jul 2004 15:42:42 +0200 rush [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ah right.. :) Jason OR has a very low priority , and right argument is not evaluated if left one is true. Same thing happens with ||, FWIW. The if condition is not evaluated further than it needs to be in either case. In other words OR is here so that you could in pre exception handling days easily write something like this: mysql_query(...) OR die; This also works with ||: mysql_query(...) || die; I just wanted to make things clear, because the way you said it above may lead to misinterpretations, such as believing that || makes all the elements in a condition evaluate even if not necessary, which is not true. So OR simply has lower precedence than ||, but no other hidden properties. Any idea why the need to have two logical operators with the same meaning BUT different precedences? I dig the need to put in OR as an alias, but why confuse people with the precedence issue? One would tend to think || and OR are perfectly interchangeable. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mailing list spam protection?
Quoting bruce [EMAIL PROTECTED]: i got a msg stating that i had signed up, using my email address, stating that i should enter my information, etc... i've never signed up... as i stated before... if you get the msgs.. just delete and keep going... To me it seems like a company making anti-spam apps tries to promote their product through... spam. And they tried to make it elaborate by aledgedly speaking on behalf of well known communities. Nice way of making themselves popular (not) within those very communities... -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't install PHP on Windows/Apache
On Mon, 19 Jul 2004 13:58:15 -0300 abrea [EMAIL PROTECTED] wrote: Dear list, I am trying to install PHP 4.3.8 as a module of Apache 2.0.50 on a Windows 98 computer. Apache alone runs ok. After I installed PHP with the installer package, I added the following line at the end of the Apache httpd.conf together with the AddType statements: # LoadModule php4_module c:/php/php4apache.dll There are a couple more PHP dll's that you must copy to either the Apache directory or your system dir. I haven't worked on Windows recently. See the help file that came with PHP for Windows, it has a section about Apache. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mixing $_POST with text in a variable
On Mon, 19 Jul 2004 14:15:09 -0400 Jason Barnett [EMAIL PROTECTED] wrote: Markus Stobbs wrote: $message = Name: $Name Division: $Division Phone: $Phone Email: $Email; ...but when I change $Name and the other variables to $_POST['Name'], I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /web/scd/vets/Vislab/eventrequest.php on line 94 When you have a variable that is inside a text string (double quotes) like that then you do not need to have the quotes for your array index. So in your case something like this should work: $message = Name: $_POST[Name] Division: $_POST[Division] Phone: $_POST[Phone] Email: $_POST[Email]; I think this is just solving one bad practice (inserting array elements directly in strings) with another (letting undefined constants such as Name pass as variable values). The problem for Markus is that there's a limit to what kind of variables you can use directly inside strings. In particular, as he noticed, array elements referred by association ($_POST['Name']) won't work. Your workaround uses a trick: by not enclosing the element identificator (Name) in quotes, it is considered to be a constant. Since there's no constant with that name defined, it evaluates to the name of the constant, which is Name. This is bad practice; the manual page for constants specifically calls it that. And because you don't use quotes to delimitate the identificator, you don't have Markus's problem. The proper solution is to use string concatenation and thus place your variables outside of the string: $message = Name: .$_POST['Name']. Division: .$_POST['Division']. Phone: .$_POST['Phone']. Email: .$_POST['Email']; It's good habit to restrain yourself from both the above bad practices. Try to always use concatenation and specifically put variables outside of strings, and always use the quotes for array identificators. Once the habit is in you'll have less headaches to worry about. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Emtying Variables
On Sun, 18 Jul 2004 11:29:25 +1000 Trejkaz Xaoza [EMAIL PROTECTED] wrote: Php wrote: And you can also used a php variable to detect multiple submit: Even better would be using a token which you give to the user when the form is displayed. That way they can't accidentally submit the form on first entry to the site (and believe me, this can happen, because Konqueror occasionally remembers a form submission page was in its window the last time it was run, and tries to reload the page!) In order to tackle reload issues, I prefer to use 3 scripts: A: one to display the form B: one to receive it through POST and process it (ie. send email) C: one to display an OK or error message Of course, depending on situation, two or more of the above can be the same script behaving differently. To avoid the reload problem, moving from step B to step C is done via: header($_SERVER['SERVER_PROTOCOL'].' 303 See Other'); header('Location: C_script_here'); The 303 response forces the browser to use GET for the redirect location. So no matter how many times the user reloads C they will only get the OK or error message, no actuall re-processing is performed. And because the redirect was done via HTTP 3xx code, not JavaScript, if the user uses BACK in the browser they go directly to A. For all purposes, B is invisible to the user. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Is Function Constants the Correct Term?
On Sun, 18 Jul 2004 05:44:21 -0400 Jason Barnett [EMAIL PROTECTED] wrote: If you're trying to protect your login credentials, you could create a class for performing mysql actions. Then put the credentials into private/protected members or constants. How does that protect them? Ultimately, the credentials are still plain text in the source. Nothing you do from PHP's point of view will protect them from someone who has access to the source or can inject code into yours. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: old guy newbie needs some help
On Mon, 19 Jul 2004 01:41:49 +0800 Jason Wong [EMAIL PROTECTED] wrote: Not strictly correct. Use session_start() *before* *any* *output* - the archives keep pointing this out. A quick search on the error message cannot send headers will lead to loads of answers. Yet people still keep asking this question over and over. Some of the newbies can't really help it. It's somewhat non-intuitive to realise that session_start() will issue send HTTP headers, which in turn must be issued before regular output. Personally, I'd suggest always starting a script with ob_start(), this way the whole load of problems created by HTTP headers dissapears. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if((strtolower(substr($author, 0, 1)) == $ausenquiry))
On Mon, 12 Jul 2004 15:22:05 -0400 John Taylor-Johnston [EMAIL PROTECTED] wrote: So how would I recode $ausenquiry so if ausenquiry=e, it will choose words that begin with e, sorted this way: Before the actual sort, use strtr() with a translation array on a copy of the string. Use the strtr() to transform all occurances of similar characters to only one ie. becomes e. Then you can search for e and it will match. If you have special characters in the search string too, use the translation for it as well. Basically, it's all about bringing the strings you work with to a common denominator. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: using the mssql functions on a linux server
On Mon, 12 Jul 2004 14:54:15 -0400 [EMAIL PROTECTED] (Edward Peloke) wrote: Is this the only way around it? Can I get to mssql without using the mssql extension? I don't think so. Plus, the entire setup is a bit complicated and you need FreeTDS as well as UnixODBC installed, plus some /etc configuration magic. FWIW, I have an article on the subject. It's in Romanian, but the commands, configuration files and testing PHP code are clearly marked and are of course universal, so perhaps you can make do with just some copypaste. See here: http://rowd.zuavra.net/articole/11/p2/ P.S.: If anyone wishes to put an English version on their site please contact me in private. I'll take the time to translate it. I haven't put the English version on the Web myself since my site is meant to be in Romanian only. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to make HTTP call to another address?
Quoting Arnout Boks [EMAIL PROTECTED]: Maybe it helps to open the address with the fopen( )- or file( )-function to read it's contents. I use this method to get data from (dynamic) html pages on another website. I don't have that much knowledge about Java servlets, so I don't know if this works for that also. It should work for any HTTP URL. But I'd recommend using fsockopen() instead of fopen(). fsockopen() has a built-in timeout, and you need this if you don't want to make your visitors wait indefinitely. The timeout works two-fold: there's a timeout for opening the socket, specified in the fsockopen() call; then there's a timeout control set with socket_set_timeout(). You can do something along these lines: * open socket with fsockopen() * if opening worked and it didn't time out, use socket_set_timeout() * do a while loop based on feof() and socket_get_status() (check for end-of-file and read timeout, respectively) * while in the loop, read from the socket A common pitfall: you will also get the HTTP response headers this way. Just skip everything at the top of the file until you meet a double newline (\n\n) for the first time. But you may want to check those headers to see if the server responded with a 200 OK code. The code is the first word on the first line of the response. Here's a nifty trick from the PHP-GTK crowd: use socket_set_blocking to set the stream to NON-blocking mode. Then all read calls to the socket will return immediately, regardless if they read something or not. In the long run, this will give the same results as with blocking mode, but you may save up a second or two due to increased responsiveness. Oh, and very IMPORTANT, do a small usleep() in every loop if you use non-blocking, even usleep(1000) will suffice; otherwise you risk killing the CPU on the server. -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] addslashes vs string unescape
I'm confronted with a somewhat weird problem and hopefully someone can make a suggestion. I have to perform the following 3-step task: Step 1. Someone provides a string (let's call it the formatting string) which contains a PHP expression, which will apply a PHP function on another string, let's call this one the random string. I don't control either the formatting nor the random string. Example of formatting string: trim('%val%') Step 2. As you may have guessed, I have to insert the random string in the formatting string before I can eval() the latter. So I need to replace %val% with the random string. But I have to be careful, since the random string may itself contain either double or single quotes, which will break the eval() later. So I also need an addslashes(). Operations performed: $for_eval=str_replace('%val%',addslashes($random),$format); $for_eval='$final_result='.$for_eval.';'; eval($for_eval); Step 3. After the above, I should have the formatted string in $final_result. *** So now for the problem: addslashes() indiscriminately escapes with backslashes both single and double quotes. Strings variables can be specified with either single or double quotes; each of the cases, in turn, will not un-escape the other type of quote. For example, a string enclosed in double quotes will not un-escape \' and a string enclosed in single quotes will not un-escape \. But my addslashes() escaped both types of quotes. And the formatting string (see step 1) will necessarily have enclosed the string to be (%val%) in only one of the two types of quotes. So, after all steps are performed, I may very well be left with either single or double quotes still escaped, depending on the type of quotes which were used in the formatting string. I was under the impression that double quote strings will be interpreted as to unescape single quotes too. However, the manual says they don't do that; they unescape some common print sequences (such as tab or newline), double quotes (of course), backslash itself, and octal or hexa expressions. NOT single quotes. If only I could be sure of the type of quotes which were used in the formatting string, I could only escape those by hand. But I can't be sure. Also, I can't forcefully strip slashes from the final result, because I don't know which sequences that look like escapes are really escapes or are just legitimate pieces of string. If only double quote strings would un-escape both types of quotes; they don't, so their un-escape action is not a 100% reversion of the addslashes() effect. Any ideas? -- Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: addslashes vs string unescape
On Mon, 12 Jul 2004 17:15:15 +0200 Daniel Kullik [EMAIL PROTECTED] wrote: Skippy wrote: Can you use this? It seems to work, at first test, but it's somewhat convoluted. I've found another fairly reasonable solution: using $val instead of %val%. This way I don't need to ever show the actual contents of the random string in the eval() and the problem becomes void. I said fairly reasonable because it will still require a painful porting period and letting people know they should move to $val, but in the long run it will work. Here's a lesson about not testing well enough before deploying. Thank you for the help just the same. -- Skippy - Romanian Web Developers - http://ROWD.ORG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php