Re: [PHP] general organization question
It'll make a small project seem huge in no time flat, but that's the price you pay for 'organization' and stuff. But frameworks can also make a huge project seem medium which is the advantage of organization. Also, it's quite often the case that a small project grows and slowly becomes a big project. At which time the payoff can be realized :) Da, this is true. It's what separates the good developer from the merely mediocre: experience teaches how to code a small project quickly, but keep it organized and flexible to adapt to the inevitable growth and refactoring. A framework that reflects this flexibility is a help, one that doesn't is a hindrance. ------ michal migurski- contact info, blog, and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best practise for resolving potential conflicts when editing db content?
I'm not sure table locking is the answer. I'm not talking about concurrency in the sense of 'simultaneous' updates and selects, but in the sense of an 'open record edit session' that predictably will overwrite the value of a record that may have been changed, after the edit session began, but before the edit session is committed. Martin Fowler's book, "Patterns of Enterprise Application Architecture" (dull name, I know) has an excellent chapter which describes various kinds of locks. The main applicable distinction in your case is whether you want your lock to be Optimistic or Pessimistic, in other words - do you expect that such conflicts will happen frequently, or no? If you expect conflicts often, make your lock pessimistic: when user A opens ups a record to edit, a flag gets set on the server which prevents user B from modifying the same record. This form of locking is also good when the change process is coarse, and losing edits would be a major inconvenience. In the case of editing a wiki page, you don't want user B to spend 20 minutes modifying a page, only to be told that there's a conflict and they should try again later, wasting all that work. You want them to know ahead of time. Your "beingedited" field in the DB is an example of a pessimistic lock. If you don't expect conflicts often, or the cost of a conflict is low, make your lock optimistic: when user A and user B both have a record open, the first one to commit wins, and the second one gets an error message. This is an easy one to implement if you version your changes in some way, perhaps by indicating which version a user started with at commit time. CVS works this way, as does my wiki software of choice, Tavi Wiki. For these applications, the cost of a conflict is high (which would indicate that a pessimistic lock might be better), but there is a clean method provided to resolve them when they come up. -- michal migurski- contact info, blog, and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] config.php
Is there anyway of creating a config.php file on the fly using a form. To obtain verbose output, include the keyword "how" at the beginning of your query. ------ michal migurski- contact info, blog, and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms
Thanks-- i got that going-GREAT ! now i have a form that creates the database and tables, any ideas how i can get this info to change the connect_db file so that it doesnt have to be done manually. See fopen(), fwrite(), and fclose(): http://php.net/manual/en/ref.filesystem.php Not sure exactly what you're doing, but having PHP (via http) use a mysql account with create privileges and write your configuration files is a gaping security hole - fine for a personal/internal/ephemeral/testing project, but terrible security practice for any application or site that faces the outside world. -- michal migurski- contact info, blog, and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Associative Array Benchmarking
> Although I'm not certain how well known this is, I thought I'd share > this with everyone who might have wondered if there was a benefit to > using or not using quotes when referencing associative arrays. The benefit to using quotes is that it's the right thing to do, unless you're looking for constants instead of strings. Sometimes a quick R of the first few chapters in TFM beats a benchmark. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lambert's Projection and PHP
> I'm working with a system that draws a map from certain information. > Lambert's projection seems to suit well to our needs. ... > I found a formula explaining the projection at > http://mathworld.wolfram.com/LambertConformalConicProjection.html . > Unfortunately there is no explanation that what units x and y are, so > drawing them or further conversion is impossible. x and y are the Cartesian coordinates on the projected map. To be useful, they generally need to be scaled, translated, and rotated to the particular dimensions of the map you wish to output. I have a small library of classes which implement albers conical equal are, lambert azimuthal equal area, and lambert conformal conic projections here: http://mike.teczno.com/map-code.tar Those files are the beginnings of something I am planning to contribute to the PEAR project, so if anyone has feedback or other projects they wish to see added, they are very welcome. See the test/lambert_conformal_conic.php file for an example of usage and a brief unit test. Note that the reference latitude & longitude and the standard parallels described in the mathworld write-up are the four arguments to the constructor, and that all lat/long units are expected in radian, not degrees. Sorry that the comments aren't as extensive as they ought to be. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multi-User Text-Editing
> Okay, i got the general idea, now it all comes down to the actual > writing. I'm making a function that compares two strings (the one in the > source i read used an exec() call, but i'd like to do it all in PHP) > per-line. This poses some difficulties. Here's the scenario: Tavi Wiki just calls out to the diff command using exec(), which is a lazy way of doing it. The wiki at c2.com does this too. Not sure what mediawiki (Raditha's suggestion) does. If you want to implement your own version of diff in PHP, you can start at the explanation here: http://c2.com/cgi/wiki?DiffAlgorithm Also there is this: http://pear.php.net/package/Text_Diff ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multi-User Text-Editing
> > You've just described a wiki - one example of a wiki that is written in > > PHP and MySQL is http://tavi.sourceforge.net. The code is a little > > spaghetti-like, but you should be able to look through the database schema > > to understand how they implement the multi-user text editing, and how to > > handle the related problems of locking and revision control. > > Wow, confusing code - but i think i got the idea. Just one thing: After > reading the code, it seems to me that every time someone makes a change > to a record, a new row is inserted into the DB with the full text of the > edited record - not just the changes. I saw that there was an automatic > expiration function, but still, wouldn't it be a drag for the server? Yeah, that's what happens. I think it's only a problem if you're storing truly stupendous amounts of text, and then it's just a storage problem - drives are cheap. If anything, storing the changes only would probably be a bigger processor load, since viewing any one page would mean having to reconstruct the content from all previous versions. This way, the overhead of a diff is only incurred when you want to view changes to a file between two given versions. I think the rationale behind CVS storing just diffs is that it has branches and merges, while wiki text generally does not. Also (conjecture) it may be a historical legacy of RCS, from a time when storage was not quite so cheap. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multi-User Text-Editing
> What i want is basically a way for many users to update, add or delete > parts of a text (the lyric). It will probably only be 'trusted' users > that'll be able to do it (users that has added more than x > artists/albums/songs). How can i make a CVS-like system, where you can > see the changes people made, maybe roll back to an earlier version etc. > etc.? You've just described a wiki - one example of a wiki that is written in PHP and MySQL is http://tavi.sourceforge.net. The code is a little spaghetti-like, but you should be able to look through the database schema to understand how they implement the multi-user text editing, and how to handle the related problems of locking and revision control. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
shell>$php -r "phpinfo();" | grep ftp Registered PHP Streams => php, http, ftp, compress.zlib shell>$ I looked at the complete output and did not see that anything else for FTP. What do I need to do add FTP support for the CLI? Just to be absolutely sure, try to use `grep -i ftp` -- the "FTP" in "FTP support => enabled" is in all-caps. If it's still missing, you will need to recompile PHP. I'm not sure if you're on a shared host or not, but this actually does not demand root permissions - you can install a personal PHP binary in your home directory with all the required features, and use that. See the manual for relevant configuration details. ---- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
#!/usr/local/bin/php output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? The version of PHP you're running on the command-line may or may not be the same installation as the one used by Apache. Use the following to see what your CLI installation does or does not have enabled: php -r "phpinfo();" -------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml tags interfere with php tags
How do I get an xml tag to work with a php script? php is trying to parse that. ' ?> ugly, huh? I'm not sure if there is a better way, but I use the above to prevent erroneous PHP parsing of xml declarations regardless of short_open_tags setting, and to keep my text editor's syntax highlighting from being fooled. -------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing large file
We have a text file that is 2.2gb in size that we are trying to parse using PHP to put the content into a mysql database. This file contains 40 million individual lines of data. Basically PHP isn't parsing it. Any suggestions of how we could do this? Process the file line-by-line instead of all-at-once, using fgets(). Check your max execution time, as William suggests. Post a little example code or an error message. michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'
> How can I get the URL of the page I am on without the 'www.' i.e. just > mydomain.com? I need to enurse this is correct in case the user types in > the domain without using the 'www.'. This should be Apache's job - you can configure the webserver to redirect requests from example.com to www.example.com without PHP's involvement, if that's what you're interested in. > I have looked at using substr but if the user leaves out the 'www.' then > substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a > better function to use in this instance? preg_match() should get you started. /(\w+\.\w+)$/ ought to match just the primary domain. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Spoofing - How?
> I've been asked to make a php script to automatically fill out and > submit a form on a remote site. I know this is possible, but have no > idea where to begin SimpleTest can do this quite elegantly. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bug with mktime??
gives the following output: $i : Month: Year 0 : 08 : 2004 1 : 10 : 2004 2 : 10 : 2004 3 : 12 : 2004 4 : 12 : 2004 5 : 01 : 2005 6 : 03 : 2005 7 : 03 : 2005 8 : 05 : 2005 9 : 05 : 2005 10 : 07 : 2005 11 : 07 : 2005 Your bug is being caused by short months. If you ask mktime() to give you the 31st day of november, it will assume you mean the 1st of december. You can see more clearly what's going on if you shorten your code, like so: for($i=0;$i < 12;$i++) { echo "{$i}: "; echo date("d m Y",mktime(0, 0, 0,date("m")+$i , date("d"), date("Y"))); echo ''; } It's a good thing you're trying this today; if you had tried it a few days ago, you wouldn't have had any idea that your method wasn't working. -- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Function with return?
> This code works. It calls the function and receives the appropriate > return value. > But, is there a better way of doing this? It seems a bit round-a-bout. Two options, details in the manual: call_user_func() or create_function(). ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: Undefined Variables Error Message
Hello all. I just finished placing a new server in production and PHP is not working. I am getting undefined variable messages when trying to submit php based forms. Register Globals is on in php.ini, but it still does not work. I have even tried copying a known-good php.ini from another server and the same behavior exists. I am running IIS in Windows 2000. Any ideas? Another website dies on line 4 here: $headers .= '...'; is equivalent to $headers = $headers . '...'; So it's probably complaining that $headers is not defined when you're trying to append something to it. Change that first ".=" to a "=", like the line above, and see if that doesn't help. ------ michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keep from using cache
> > Here's the problem... > > After a deletion, when the question list page is reloaded, the browser uses > > the cached version of the page and the question which was just deleted is > > still displayed. If you refresh the page, the question disappears. So, I > > know that the deletion is working. I just need to know how to force the > > browser to NOT use the cached version of the page. > > try these > > header("Cache-Control: private"); > header("Pragma: no-cache"); There are some bugs in IE5 which require the use of a few extra cache headers, for good measure. For data which I don't want cached, I use this: header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: post-check=0, pre-check=0'); // damnable IE5 header('Expires: Wed, 16 Nov 1977 10:00:00 CET'); // date in past header('Last-Modified: '.date('r'));// right -now- header('Pragma: no-cache'); // HTTP/1.0 - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking for utilities/applications in the PATH
> i am trying to do a simple check for archiving utilities (zip, unzip, > ...), to make sure they exist within the PATH, and are executable by > PHP. > > i could not find a better way to do this through php, so i went ahead > and did an > > exec('which ' . $utility, $output, $return_value); > > then, i check the $return_value for a non-zero value, which would > indicate that the utility was not found. using GNU/Linux this seems to > work fine, but i wouldn't mind keeping my work cross-platform. > > so, my question is, is there a better way to do this? If you don't want to use the shell, you can check the $_SERVER['PATH'] environment variable. On my (linux) system it looks like "sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin", so you could explode() that on ':' and then cycle through the files in each directory using readdir(), checking each with is_executable(). You could also just check the output of your exec() call - it should be the full path of the executable you're looking for. An empty return would imply that there isn't a matching executable. I think which always returns just the first match, since it's meant to show what would get called if you were to use that command. Personally I love using exec() to make php behave like bash at times, but posts on this list from pparently knowledgeable people occasionally imply that it's not the best/fastest/most stable method to use, so I try not to. -mike. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array?
> I cannot seem to access elements inside of the array $things in the code > below. All of the errors say "Undefined offset: 7 in > /Library/WebServer/Documents/lis/check.php on line 26" I don't see > why... print_r is your bestest buddy. > $results = mysql_query($q); > if ($results) { > while ($list=mysql_fetch_assoc($results)) { > $things[]=$list; > } > } > //$things[7] is a MySQL timestamp column named "last_login" $things[7] is actually an associative array containing the seventh result row from your query. If you check out the results of print_r($things), you'd see the array structure immediately. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delimiter question?
> How can I make the following work on an apache 2.0.46/php 4.3.2 > installation? > > /dist/gogo.php/order-inventory-form.php > > Right now, unless it is a question mark after the gogo.php script, it > will not run. Apache 2.0 differs from 1.3.x in its handling of path info. See: http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] post file from one server to other
> I have a database with binary file. I want to post that file from my > server to another one with posting method. I have no problem to post any > text data but I can not post binary data such as picture.jpe. The HTTP_Client class in Pear will handle post requests: http://pear.php.net/package/HTTP_Client http://pear.php.net/manual/en/package.http.http-client.php I believe it has pretty good support for sending binary data in that request. Your other option is to build your post requests manually, using sockets. I've done this, but it does require a lot of background knowledge of HTTP. Luckily there's someone on this list who knows a great deal about that. :) --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using php_value in .htaccess files
> Is there anything special one has to do in order to enable the use of > the "php_value" directive in the context of an apache .htaccess file? > > I notice that on some hosts I can drop in something like: > > php_value auto_prepend_file groove.php > > with impunity. Other hosts, it causes Apache to generate an internal > server error. I believe Apache's Allowoverride directive must have "Options" or "+Options" set for php_value changes to be permitted on a per-directory basis in .htaccess files. "Allowoverride All" is one way to make sure they're permitted. :D - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Runtime Debugger (Was: [PHP] how to count objects instances)
> There's no predefined variable or method for determining this, that I'm > aware of, short of counting how many "new Test" lines you have. > > You could write a wrapper class for Test that kept count of the > instances and returned a new object upon request... A slightly more general question: are there any PHP development environments that let you do something like a core dump, to see what kind of memory usage or variable allocation you have going on? Maybe a compilation option to PHP? A search of google turns up DBG and some commercial packages, but I lack the experience with such tools to evaluate them intelligently. I've done something like what the OP is asking about, by adding a log() feature and calling it when objects are instantiated or destroyed, but it sure would be nice to see something like this built-in. I'm a gdb beginner, but I'm willing to learn. I realize that this is a fairly complex problem compounded by the fact that PHP is generally a library used within an apache child process. Any thoughts? ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Text from file into database
> I want to create a script that will read each line of the file and > insert it to database. I am new to php and maybe you could help me You've been posting here for *months*, how new could you be? Look up the file() function. And the docs for your database. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem connecting to Postgres
> I am a newby having a configuration problem. I am using PHP 4.3.6 and > postgres 7.4.3 > > The problem is when I try to execute my php scripts that connect to > postgres from the command line I get error like this: > > Fatal error: Call to undefined function: pg_connect() in > /Users/jcapy2/Sites/Jesper/SyncPosgresToMbrMaxData > .php on line 28 > > But it works fine from a browser using apache. The version of PHP used by Apache may not necessarily have been configured the same way as the one you're using on the command line. Try phpinfo() to determine what's there, and recompile/reinstall if you're lacking PG support. Or, try to find the command line instance that corresponds to the apache module you're using. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
> If you think there's a better way of doing it I would like to hear it. > > However this is resulting in an Parse error on the foreach line: > > foreach(array_slice($z['distance'], $start, 10)) { > $newuser = $z['user'][$k]; > echo $newuser . " - " . $v . ""; >} "foreach" needs an "as", probably that was meant to say: foreach(array_slice($z['distance'], $start, 10) as $k => $v) { ... - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] managing cvs from php
> $cmd = "cd ".$pathToFile." ; /usr/bin/cvs ci -m '".$logMsg."' ".$file ; > > passthru($cmd) ; > > If I echo the $cmd and paste in a shell the command works. When I > execute from web nothing happens and no output is seen > (error_reporting(E_ALL)) Does the apache user have read/write privileges on the files in that directory? CVS makes heavy usage of stderr, so that may be a reason you are not seeing output. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Securing Forms???
> >> $token = md5(uniqid(rand(), true)); > >> > >> .. is a pretty bad idea, since the output could include quotes, > >> newlines, low-ascii-characters, thereby messing up the form. > >How do you figure that? md5() only returns 0-9 and a-f characters. > > From the manual: http://php.net/md5 > string md5 ( string str [, bool raw_output]) > "If the optional raw_output is set to TRUE, then the md5 digest is > instead returned in raw binary format with a length of 16." "true" is an argument to uniqid(), in that snippet: string uniqid ( [string prefix [, bool more_entropy]]) You would run the risk of messing up the form with (sound of pipe organ) *excessive entropy*. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SSH Authentication using php
> Ok, here's the whole project, I have an openbsd box using authpf which > uses authentication via ssh login. So, i'm trying to create a weblogin > using php so people just have to enter their username/password (which > would be a restricted unix account) to gain access to the internet. I > have authpf all setup, but I'd like to add a web login to make it more > user friendly. Thanks Ah, makes sense. Authorized_keys may be a good way to go. You may wish to run an instance of ssh-agent as the Apache user, and create a single ssh key for that user - importing the PID as an environment variable before you run your exec() line ought to make it work. You may have some difficulties keeping that ssh session open directly from PHP, though. I wonder whether you aren't subverting your network security somewhat, by enacting strict controls (with authpf) and then routing around them with an insecure web login. -mike. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SSH Authentication using php
> > Hi, what my goal is is to be able to authenticate a user by they SSH > > acount on the system using php. I tried looking on google, but didn't > > see anything with ssh. What i've tried to do is use the exec() and > > just do: > > > > exec("ssh [EMAIL PROTECTED]".escapleshellard("password")); > > > > You can try setting up authorized_keys for this. Then you don't need to > pass it the password. ...but you'd still need to provide the ssh passphrase, or have an instance of ssh-agent running. Teren, what are you trying to do exactly? Is ssh actually necessary, or are you really just trying to authenticate users by their unix accounts? - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string manipulation
> Hi I am trying to track down a method for transferring a database id > such as 5 into a nice formatted order id such as ORD0005 - where the > format for the order id is "ORD" + 5 digits made up of the database id See documentation for sprintf(). Try something like: $formatted = sprintf('ORD%05d', $id); ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable utf-8 in php?
> PHP seems to handle all strings as ISO-8859-1 by default. How can I tell > PHP to work with strings in UTF-8 format? This is important for sorting > and e.g. htmlentities(). Needs to be compiled in: http://php.net/manual/en/ref.mbstring.php Also available: http://php.net/manual/en/function.utf8-encode.php http://php.net/manual/en/function.utf8-decode.php ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Some weong when I start the apache and PHP
> Hello everyone! > > I just have installed the apache and PHP. When I installed apache, I ran > the command "./apachectl start" in its directory and there was an > information showing that it has been running, but when I input > "http://localhost/"; in browser I can't link to localhost.The error > mesage is below: > > "The connection was refused when attepting to contact localhost." Check your Apache config file -- it may be set to a port other than 80 (possibly 8080) by default. Change the port and restart Apache, or just point your browser to http://localhost:8080 ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variables ~ Best Practices
> I presume I am right in assuming that I can declare variables anywhere I > like providing I have started a session on the page but I cannot > actually use those variables until a post or some similar action has > been performed by the user. No, you can use them right away - they are stored server-side, so you don't need to wait for a request/response loop before reading them: session_start(); $_SESSION['foo'] = 'bar'; echo $_SESSION['foo']; // 'foo' is available immediately No need to perform any special declarations. It's cookies that need to wait for a subsequent request to be available via getcookie(). Careful with your session variable naming - you may want to implement a primitive namespace, by using named arrays in $_SESSION, such as $_SESSION['auth']['username'] or $_SESSION['prefs']['boxers_or_briefs']. -mike. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php reserved characters...
> > i tried to do a "\ > any idea as to what's going on, and can someone > > point me to a list of the actual php reserved > > chars/words couldn't seem to track them down > > on the php site/google... > > < is not reserved. The problem is your HTML. > > Your result ends up like this: Either that, or short_open_tags is not enabled. Try changing the first 'http://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
> I have to use cookies, since I am taking a class and it dictates that we > use cookies, but I can't email my instructor since she never responds. > So how do I use a cookie to record multiple values? Help would be > appreciative.a A few options: use multiple cookies, e.g. setcookie('cookie_a'), setcookie('cookie_b'), etc. Jordi's suggestion is also good, though I would suggest using serialize() to make a single string out of your values, like this: serialize(array('name1' => 'value', 'name2' => 'value'). Or, use PHP's built-in session support. The cookie stores a unique ID, whie the actual values are stored on the server. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cannot send session cookie
> When experimenting with a few simple lines of code > > This is line 14 >session_start(); > > > I get the following errors: > > Warning: session_start(): Cannot send session cookie - headers already sent by > (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15 What's on lines 1-13? Does it have whitespace or indents on line 14, like in your mail? Any use of headers, get/set cookies, or sessions must happen before any output such as HTML or print/echo is sent to the browser. Generally, it's a good idea to have set-up code such as session_start() be one of the very first things you call in a script. Wrong: Right: ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP5RC3] echo " $this->db->host " not work
> echo $this->db->host; > // will output > localhost > > but > echo " $this->db->host "; > // whill output > Object id #2->host > > is that a bug. or just have to workout by myself? http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Q] Why does my php file gets displayed instead of executed
> The problem is that the php script, validate_member_login.php, is > displayed in the browser rather than being executed. Are you running an Apache server? If so, be sure you have the appropriate AddType lines in your configuration, as described in http://www.php.net/manual/en/install.apache.php - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Emulating sprintf???
> Im trying to do something like sprintf() because I would like to have > control over placeholders. The code I've posted works for the most part, > but when I introduce content that has the same characters as my > placeholders (%s and %i), it breaks to hell... Anyone got any ideas on > how to fix, or tell me Im barking up the wrong tree... After the first call to substr_replace, you swap in some replacement text that contains an '%s'. Subsequent calls to substr_replace use your replacement text as the key, because it's no longer possible to uniquely determine what was part of the original string, and what was swapped in. Recommendation: don't use preg_match. You can try using preg_replace with arrays as arguments, but you may come closer to sprintf's correct behavior if you instead consume the pattern string ($sql) character by character, generating an output string made up of characters from the pattern string, and elements array_shifted off of $data as you encounter placeholders. Don't forget to add a placeholder that allows you to use '%' in that string -- sprintf uses '%%'. Much easier recommendation: use provided sprintf, but parse out any unwanted placeholders first, using preg_replace. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user tracking
> I am looking for some type of user tracking/stat collecting package. I > am sure there's a million; any recommendations? We have some specific > needs as well, so mostly likely I will be have to make some code > changes. So the simpler package the better. You don't mention any of the specific needs you have, but Webalizer has worked well for me as a nice aggregate log reporting tool. It's very flexible in terms of how it parses your logs and displays the data. If you need too track actions of a specific user, you'll need to look elsewhere. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Password encyption
> I realize the key needs to be stored somewhere which is part of the > problem of how to make it a bit more secure. I just don't feel safe if > a password in a flat file in clear text. Ideally the database should > support something like an ssh style public/private Key auth where the > private Key is stored internally to the database. Where would you store the passphrase to the key? This is a losing battle - at some point, anonymous requests from the outside world are going to have to result in some kind of access to the database. I think you'd be better off accepting the inherent security tradeoffs as a known variable, and working from there: write your code so it's not vulnerable to SQL injection or other attacks, limit the access permissions of the database user, put the file containing the password someplace where the webserver won't divulge its content (apache config or .htaccess is a personal favorite of mine), and (important!) back up your DB regularly so that you can recover from attacks cleanly. -mike. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] calling imagemagick from php
> I have actually changed my code to this for debug purposes > > system('convert -geometry 200 x 200 image.JPG theThumb.gif', $retval) > > and if I cut out string between the single quotes and just run it at a > command prompt, it works greatwhen I run this php script, I get > syntax errorswhat is wrong? Perhaps convert is not in your path? Also, I'm not sure that the -geometry argument is going to behave how you expect - typically, geometry is expressed as "WxH", not "W x H", in command-line arguments to imagemagick. In the former case, you will set the size of your output image to W width and H height. In the latter case, I believe that the 'x H' is ignored, and you implicitly set the size of your output image to W width and W height. Big difference for any aspect ratio besides 1:1. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Concatenate PHP code into a string
> Dear List, > How can I include a dynamically generated array: > e.g. for($i=0; $i { $cols[$i]= mysql_field_name($fields,$i); } > > into a MySQL insert query of the type: -snip- /** {{{2 * create an INSERT or UPDATE query based on values of an associative array, * where keys are the column names to be modified. * * @param arrayvalues an associative array * @param string table the table name * @param string type the query type, currently only 'INSERT' or * 'UPDATE' * @return mixed a SQL query string on success, false otherwise (e.g., no * keys found matching valid column names) */ function array_to_query($values, $table, $type) // {{{3 { if(!is_array($values)) return false; foreach($values as $col => $val) { $values[$col] = db::quote($val); if(is_null($val)) unset($values[$col]); } switch($type) { case 'INSERT': $query = sprintf('INSERT INTO %s (%s) VALUES (%s)', $table, join(',', array_keys($values)), join(',', $values)); break; case 'UPDATE': foreach($values as $col => $val) $values[$col] = " ${col} = ${val}"; $query = "UPDATE $table SET " . join(',', $values); break; default: trigger_error("Unrecognized query type '$type' supplied to db_array_to_query()", E_USER_WARNING); return false; } return $query; } - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a stupid question
> Maybe it has to be "Some text".aFunction();."sometext"; with the > semicolon after the function. > I don't really know, just guessing. Yeesh, that's not even remotely valid PHP. Why would that have been posted as advice? --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file locking question
> I have this script whereby I use the php function file(). > Just a quick question, do I need to implement file locking. If you want to ensure that the file is not changed by other scripts while you're reading from it, yes. Note that this is advisory only - writer scripts will only respect the lock if they request a write lock. See manual for details. > if so, can I just use something like > flock( file("/path/file.ext") ); flock() takes a file handle as an argument, not an array of strings: $fh = fopen("/path/file.ext", 'r'); flock($fh, LOCK_SH); // read from file here flock($fh, LOCK_UN); fclose($fh); See example 1 in the manual page for flock for more info. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mod_rewrite Issues
> This isn't exactly a PHP issue, but they seem to go rather hand in > hand... > > Right now I'm just running my own apache server on my computer and I'm > trying to protect my scripts using mod_rewrite. I uncommented all the > mod_rewrite lines in the apache configuration file and restarted it all. I > got no errors doing this, so I assume it compiled fine. > > The problem is, I can put a rewrite rule in the httpd.conf file or a > .htaccess file but it never rewrites any URLs... For example: > > RewriteEngine on > RewriteRule ^/woot$ /beta You may need to add a RewriteCond: http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteCond ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] src="test.php"
> I wondering how browsers handle the following html-codes: > > > and > > > are there any browser that will choke in it because the files don't have the > appropriate (.css and .js) extension? What matters is the appropriate Content-type header. See header(). ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] index.php not loading up
> [Wed Jun 16 13:49:12 2004] [error] [client 158.114.144.121] File does not exist: > /var/www/html/<, referer: http://158.114.148.90/index.php3 > [Wed Jun 16 13:49:14 2004] [error] [client 158.114.144.121] File does not exist: > /var/www/html/<, referer: http://158.114.148.90/index.php3 > [Wed Jun 16 13:49:16 2004] [error] [client 158.114.144.121] File does not exist: > /var/www/html/<, referer: http://158.114.148.90/index.php > [Wed Jun 16 13:49:18 2004] [error] [client 158.114.144.121] File does not exist: > /var/www/html/<, referer: http://158.114.148.90/index.php > > The index.php file is there, is it looking for some other file? Yes, it appears to be looking for "/var/www/html/<". Going back to your original post, this line is where your problem is: <http://158.114.148.90/ " alt="Keystone 2" /> I'm not even sure that's remotely valid PHP or HTML. What's it supposed to do? - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Eliminating all lowercase words
> $search "(([^\bA-Z][a-z]\b*?)*?)); > $replace = ""; > $add = preg_replace($search, $replace, $add); > > hWhen I tried it, it eliminated all lowercase words, and in the case of the > single upper case word, 'Bellingham', it retained only the capital 'B' -- > arrgh! You could just look for lowercase words, instead of "not-uppercase" words, like so: /\b[a-z]\w+\b/ ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Cookie Security?
> [snip} > > As well as much harder for AOL subscribers (whose IP's change per-request) > > to use the site. > [snip] > > WHAT?? Are you sure of this? AOL really breaks internet browsing this > much? Sorry, I can't believe this. If this was true, many things would > break. Not really -- HTTP is stateless, so there's really no reason for each request to come from the same IP. As other posters in this thread have pointed out, AOL uses an army of proxy servers. In the past, they've even cached and re-compressed images for the benefit of those on slow dialup. As you say, wacky stuff. You're on the right track, though - the way to make cookies tougher to crack is to associate the cookie with some other piece of user information. I've toyed with using an encrypted string based on the user agent as part of the cookie, but have never encountered a project where this level of care was called-for while SSL was not. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Cookie Security?
> > My login script sets unique, secure, cookies that identify the user. > > Some of my pages only display content if a secure cookie is present. > > Is this a bad idea for secure pages with sensitive details as I have > > heard that cookies can be faked? I am always interested in creating a > > secure environment for my website visitors and I want to make sure I > > am protecting their privacy. Any help on this matter is greatly > > appreciated. > > I would suggest tying your cookies to an IP. This makes it MUCH harder > for a cracker to use the cookie. You may just want to search for "PHP > secure cookies" on google. As well as much harder for AOL subscribers (whose IP's change per-request) to use the site. Cookies are easy to fake. In most cases, though, the cost (to an intruder) of interfering with a user session far outweighs the benefit. This is why most e-commerce sites are pretty lax about security while you browse, and why they immediately switch to SSL when you decide to pay. Consider the potential damage done to your users or the sensitivity of the information you're transmitting, and you may decide to go with SSL. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expedia.com
> When Expedia.com is searching for flights, it displays a page with a > little animated GIF progress bar, then display the results. > > How do they do that? How does the page sit idle until the query is > finished, and then sends a new page with the results? I was thinking > that they might use HTTP-REFRESH or something, and just keep hitting the > database until the result is there. But is there a "best way" to do > this? In my application, when the user clicks a certain button, it will > take 10-20 seconds for the operation to complete—during that time I need > the web browser to "waiit" for the data. The progress bar goes by too quickly for me to tell, but perhaps they are using a slow-loading resource someplace on the page? E.g., an image whose content-length is 64, whose 64th byte does not get sent by the server until the query is complete. Combine that with a bit of javascript waiting for the image to load, and you should have basic loading-bar behavior. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can someone explain this?
> Forgive me if my math is askew, but doesn't the negative imply the > number is signed? If I remember from my C++ days, a declaration of: > > unsigned int blah; > > Meant you could not store negative numbers in that variable. Hence, > negatives would be signed. No? Yes, but once it become a hex string (after dechex()), all that info is gone. I think the way to handle this situation is to use pack & unpack. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include and require
> Can anyone help me with this one: > Is there a difference between "include()" and "require()" ? http://php.net/require http://php.net/include require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP segfaults, any ideas?
Hi - I'm having some PHP segfault issues, and I can't seem to figure out what's wrong. Kinda frustrating :) The script i'm using to test is really simple, and as I tweak it to figure out the failure point, I'm finding that it /seems/ to break more reliably based on the presence of code **after** a call to exit. This seems counterintuitive to me. Being a novice to gdb, I was hoping someone might help me to understand this backtrace? #0 0x4010d76e in chunk_free () from /lib/libc.so.6 #1 0x4010d548 in free () from /lib/libc.so.6 #2 0x4033cb87 in shutdown_memory_manager (silent=1, clean_cache=0) at /usr/local/src/build/php-4.3.2/Zend/zend_alloc.c:532 #3 0x403236cc in php_request_shutdown (dummy=0x0) at /usr/local/src/build/php-4.3.2/main/main.c:992 #4 0x40365001 in apache_php_module_main (r=0x8103a84, display_source_mode=0) at /usr/local/src/build/php-4.3.2/sapi/apache/sapi_apache.c:60 #5 0x40365b7e in send_php (r=0x8103a84, display_source_mode=0, filename=0x0) at /usr/local/src/build/php-4.3.2/sapi/apache/mod_php4.c:617 #6 0x40365bd2 in send_parsed_php (r=0x8103a84) at /usr/local/src/build/php-4.3.2/sapi/apache/mod_php4.c:632 #7 0x08053c73 in ap_invoke_handler () #8 0x08068bf7 in process_request_internal () #9 0x08068c58 in ap_process_request () #10 0x0805fa95 in child_main () #11 0x0805fc40 in make_child () #12 0x0805fdb4 in startup_children () #13 0x0806042c in standalone_main () #14 0x08060c8f in main () #15 0x400b01c4 in __libc_start_main () from /lib/libc.so.6 ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] interesting
> What does the { } around the array mean? http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: best way to do this with arrays...
> the tricky part is I could have fifteen rows in the db all with > different start and end dates that I need to check each day against. Then do the data comparison in the DB -- SELECT * FROM your_table WHERE {$check_time} >= start_time AND {$check_time} <= end_time; (Adjust as appropriate for date formatting, SQL injection, etc.) If you're using MySQL, this page is informative: http://dev.mysql.com/doc/mysql/en/Date_and_time_types.html -mike. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick encoding question:
> I have a form and the people who submit are likely to include a bunch of > "¶" characters. (That's a paragraph symbol in case it doesn't come > through the list correctly.) > > However when I read it out of MySQL it comes back as "¶". What can I do > about this? Thanks! Looks like UTF-8. Make sure your output character encoding matches the database encoding, and use htmlentities() and the mb_* (multibyte string) functions where necessary. Debugging this stuff is a pain. :P ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: best way to do this with arrays...
> $start = '2004-07-04'; > $end = '2004-07-09'; > $check = '2004-07-06'; // the date you want to check > > $timestampStart = > mktime(0,0,0,substr($start,5,2),substr($start,8,2),substr($start,0,4)); > $timestampEnd = > mktime(0,0,0,substr($end,5,2),substr($end,8,2),substr($end,0,4)); > $timestampCheck = > mktime(0,0,0,substr($check,5,2),substr($check,8,2),substr($check,0,4)); FYI, the above can be shortened to: $timestampStart = strtotime($start); $timestampEnd = strtotime($end); $timestampCheck = strtotime($check); ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using php to modify a css file
> The reason for the two files is that My4CSS.css contains code that > doesn't break Netscape 4 (people are still using that garbage) and > MyCSS.css is the code that I want for decent browsers. Just doing the > AddType without changing the css files at all breaks things locally. > Without a not shouldn't make any difference -- but it does. It will only make a difference if the HTTP response from the server is different somehow -- contains junk, wrong headers, that sort of thing. The only way to reliably diagnose such problems is to figure out a way to view the entire HTTP response, headers and all. I use curl for this, but you might not have access to a command line. The mozilla view-headers thing I mentioned - I've never actually used it {{embarrassed shrug}} so I can't help you find it, but there are many ways of achieving the same end. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using php to modify a css file
> Then I added the following line to my .htaccess file AddType > application/x-httpd-php .css It works just fine at my hosting company > but I can't get it to work locally. Try fetching it with cUrl, or using Mozilla's view-headers feature. Make sure that the PHP is in fact being parsed, and that the Content-Type header is correct. You'd be better off not messing with AddType at all to parse .css files - it's more important that the content-type be "text/css." --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML problem
> I'm looking for a good tutorial in xml or a list with most of the xml > tags. I've googled for it but i can't find anything. Could someone send > me a link to that kind of tutorial? There are no "xml tags" as such; XML defines a grammar but not a vocabulary. The actual tags used depend on the specific application in question, e.g. XHTML defines one set of tags, SOAP another. You can define your own, if you want. A lot of parsers, like the xml_parse functions in PHP, can handle arbitrary XML input as long as it's "well-formed", that is, follows the syntax rules properly. Most of the syntax is described here: http://www.w3schools.com/xml/xml_syntax.asp ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_RAW_POST_DATA
> > Isn't this potentially a DoS attack vector anyway? I don't need a server > > to accept or read my obscenely long POST requests to clog the pipes with > > them. Would the proper way to handle this risk be to disallow POST at the > > webserver level, or does turning always_populate_raw_post_data off cause > > the connection to be automatically dropped after Connection: close? > > By default php streams the STDIN to a file so your just dealing with > buffer sized ~2K-4K. enabling this option makes php put the contents > into memory, thus leaving open the possiblity of someone using up all > your memory and bringing the machine to a standstill till, then when > swap space runs out.. watch out! :) This makes sense, thanks. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_RAW_POST_DATA
> > Anyone have any clue why this is the case? Is there a performance > > reason that raw post data must be explicitly enabled, or is it more of > > a protective measure for overly permissive beginner scripts? > > If it was always enabled, it sure would make a DoS attack easy. I'd just > send lots of huge POST requests to any PHP script on your server. Hope > you have "migs and megs of memories," as Strong Bad would say. :-) Isn't this potentially a DoS attack vector anyway? I don't need a server to accept or read my obscenely long POST requests to clog the pipes with them. Would the proper way to handle this risk be to disallow POST at the webserver level, or does turning always_populate_raw_post_data off cause the connection to be automatically dropped after Connection: close? -mike. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] default and another constructor
> No, you cannot do this kind of method overloading, not like this anyway. > If you are using PHP5 you can kind of emulate overloading by using the > __call() function... some googling will find examples. > > You can at least make the below work by removing the first forum() > instance and using > > function forum($naam=NULL,$tijd=NULL,$tekst=NULL) Another option, if you wish to have varying argument lists, is to define the methods with no arguments at all, and use the func_get_args(), func_num_args(), and func_get_arg() functions described here: http://php.net/manual/en/ref.funchand.php ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_RAW_POST_DATA
> > > Check the value of "always_populate_raw_post_data" in php.ini on > > both servers. > > > > Thats such a funny name. > > Not to mention misleading, since it doesn't always populate > $HTTP_RAW_POST_DATA when enabled. Always should mean always. Anyone have any clue why this is the case? Is there a performance reason that raw post data must be explicitly enabled, or is it more of a protective measure for overly permissive beginner scripts? Inquiring minds demand answers! --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Print a variable's name
> but what I want is to be able to pass any variable to a procedure and > have the variable name and value printed by the procedure. Because PHP passes arguments by value, you will be out of luck in most cases -- by the time your debugging function sees the argument, it's no longer tied to the calling scope. Michael Sims' example function works only for variables in the global scope, which probably won't work for anything complex enough to need its own debugging library. > I'm trying to extend my library of debugging functions/procedures by > having a procedure which can be used to "inspect" a variable whenever I > call it. You may find what you need in debug_backtrace(). Alternatively, just pass the variable name along: function echo_var($varname, $varvalue) { printf("%s: %s\n", $varname, $varvalue); } ...Which isn't much of an improvement over a plain old echo/print. And if that's good enough for Brian Kernighan, I'd hope it's good enough for you. :D ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select from 24 tables
> Up what creek? You didn't really provide any technical justification > for your suggestion. Up the creek of having to call for help on php-general because you have 24 identical tables you need to join, having never performed a join before. > The "pain" only occurs when writing the SQL statements to join the > tables. I don't think it's a good idea to optimize the database schema > for the sake of the programmer, who only has to write the SQL one time. I wholeheartedly disagree. :) I think that optimizing for the sake of the programmer, the bug fixer, and the possible inheritor of the project is a /great/ idea. Servers keep getting faster, while the human attention span and rate of familiarization with code stays approximately constant, so optimizing your development time is at least as sensible as optimizing SQL select performance, which is probably better handled through well-chosen indexes anyway. Optimizing for the programmer usually translates into thinking about the humans who will need to interpret your code, and making it easy to pick up the gist of your intent. A 24-table join is not a typical characteristic of what I'd consider a well-planned DB schema, whose meaning can be quickly grokked by a newcomer to the project. If all those 24 tables store the same kind of data, then there's no reason to split them up. Of course, we haven't seen the specific usage of those tables in this thread, but I'm basing my posts on the assumption that it's better for the OP to have a "marbles" table with a "color" column, than tables named "red_marbles", "blue_marbles", 'green_marbles," etc. If that's not the kind of data we're talking about, then I stand corrected, and John Nichel's initial response is all that's needed. A huge table count is often evidence of a need for some refactoring. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting text with multibyte characters
> Run into this before, PHP seams to do quite well when you set the locale > right ( de_DE ) which will place AÄBCD instead of ABCDÄÖÜ. > > Hope this helps :-) Thanks, I hadn't thought of that. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select from 24 tables
> This isn't always desirable, or even possible. I once designed a > database to hold characteristics for a series of 70 different tests. > There were about 50 different characteristics used in various > combinations for each test. Each characteristic could be one of many > values. So the characteristics tables all looked like this: > >id, name, value > > And the test tables looked like this: > >id, name, value In my experience, it's usually a safe assumption that if you have a bunch of tables all structured identically and used in similar ways, you should probably merge them all into a single table with an extra column that corresponds to whatever differentiating characteristic used to distinguish your original tables. I.e., go with John Holmes' suggestion before you're really up the creek. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting text with multibyte characters
Hi, Does anyone have any thoughts on how to effectively sort text with multi byte characters? I am working on a project that uses lots of German text, and the letters with umlauts don't sort correctly. I'm using the mb_* functions in a few places (to adapt an ASCII-encoded database to XML output for flash, which is always expected to be in UTF-8), but none of them seems to be made for string comparison. thanks, -mike. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Dump
> I just tested it and yes, the Michal function runs on Windows and Linux. > Just must write the path in the proper format for the OS you're using. Holy smokes, that's good news. :) Spreading dis-information is my price for not having the first clue about windows. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Dump
> Will this work on both a Windows and Unix server? No, it's most assuredly a unix-only thing. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Dump
> Is there an easy way to do a mysql dump routine written in php? I > basically want to write a function to backup a database and have it > create all the neccessary structures and data in the dump. I know > phpMyAdmin will do this for me, but I want to write a function to do > this incase the server doesn't have phpMyAdmin installed. Any ideas? Why not use the existing mysqldump command-line utility? function mysql_dump($db, $user, $pass) { return shell_exec("/path/to/mysqldump --user={$user} --password={$pass} --complete-insert --add-drop-table {$db}"); } Or, skip PHP entirely and place a call to mysqldump with a suitable select-privilege-only username & password in a cron job, if you're on a unix machine. I use the following shellscript to do periodic backups to RCS repositories in /usr/local/var/backups: #!/bin/sh if [ $# -ne 3 ]; then echo 'Usage:'; echo ' mysql-backup.sh '; exit; fi; USER=$1; PASS=$2; DB=$3; MYSQLDUMP=/usr/local/bin/mysqldump; BACKUP_DIR=/usr/local/var/backups; SQL_FILE=$DB.mysql; RCS_FILE=$SQL_FILE,v; cd $BACKUP_DIR; $MYSQLDUMP --user=$USER --password=$PASS --complete-insert --add-drop-table $DB > $SQL_FILE; the remaining lines can be ommitted if RCS isn't needed if [ ! -f $RCS_FILE ]; then echo "import" | rcs -q -i $SQL_FILE; else rcs -q -l $RCS_FILE; fi; echo "mysql_backup.sh" | ci -q $SQL_FILE; - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] regular expressions php/perl/actionscript
> > I'm wondering if Regular Expressions are the same in Perl and PHP (and > > possibly Actionscript)? They look the same and smell the same, but if > > I see a book in a store for Perl Regular Expressions that's $10 > > cheaper than the PHP one (is there one?), then is it the same thing? > > this page will tell you what php supports: > > http://us3.php.net/ereg Alternatively, try this: http://www.php.net/manual/en/ref.pcre.php "PCRE" == "Perl-compatible Regular Expressions". The ereg functions use a slightly different syntax. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs PERL? (Seriously OT Now....)
> Uh-oh, does that mean an Atheist has to use ASP??? ;) > [/snip] > > And if so, what must a Buddhist use? Lisp, of course. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making an app unviewable during system maintainance
> > Good point, though if this is a concern, the OP will probably use the > > built-in enforcement of referential integrity and transaction support > > of whatever database they are running. > > If a single database is spread over files A, B, and C, then in the time > it took for a naive backup to grab file A, files B and C may have > changed such that the database cannot be restored to an > internally-consistent state using files A, B, and C. At this point, > enforcement of referential integrity would actually work against you. Right, but if the database's built-in backup tool is used rather than the filesystem, it ought to respect the read/write locks that are a natural by-product of using begin/commit to wrap your transactions. E.g., a call to pg_dump should be guaranteed to pull the database in an internally-consistent state, if the application logic uses transactions correctly. I guess that's probably what you meant by "Use the DB to make the snapshot, then back up the snapshot." :) (I say "ought" and "should" because I'm no DB guru, myself) This popped up on /. yesterday, and it seems relevant: http://www.oreillynet.com/pub/wlg/4715 - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making an app unviewable during system maintainance
> > Don't take the database down for backups. > > > > I can think of no logical reason why you'd want to kill the DB to back > > it up, since it's just a big "read" operation. > > Referential integrity might be a reason. Good point, though if this is a concern, the OP will probably use the built-in enforcement of referential integrity and transaction support of whatever database they are running. *cough* postgresql ;) > However, I agree -- don't back up the database directly -- use whatever > utilities the database provides to dump the database, then back up the > dump. Depending on how well the dump utility works, you might be able > to do away with the downtime. mysql has mysqldump, and postgresql has pg_dump. Both of these are pretty much all you'd need, and neither requires any site downtime. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making an app unviewable during system maintainance
> Hi there I was wondering how people usually turn the app off during > system maintainance. During the hours of 6-7 the database goes down for > backing up, the users therefore keeping trying to get into the system, i > get an error that the database is down when i know it should be down > near that time. Without causing too many if statements what is the best > way to do this ? Don't take the database down for backups. I can think of no logical reason why you'd want to kill the DB to back it up, since it's just a big "read" operation. --------- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forking external binaries
> We have a web application that forks off an external program to inject > an email in the outgoing queue. At busy periods this external program > (qmail-inject) can take a little while to return. I'm currently using > popen() to spawn the qmail-inject binary. > > Is there a way to spawn the external binary but not wait for it to > return. I'd be happy to ignore any return value if the tradeoff was a > fast return. If you call it via exec(), you can append an ampersan to detach the controlling terminal: exec("/path/to/qmail-inject -args &"); Wish php had fork() in a non-experimental context. :\ ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and HTTP requests
> I realize it's a stupid question but I need a simple solution.. I'd like > to get contence from script-generated webpage (I send a regquest via get > or post method to a page and it generates a response page - how do get > that page as a string? Get the source of the page). It's obvious that it > cannot be shown with file functions. Only solution I was mentioned vas > CURL package but I'd like to solve this with standard functions. Is it > possible? fopen() can support streams, if your configuration allows it: http://php.net/manual/en/function.fopen.php Alternatively, you can use the socket functions to hand-roll an HTTP request, in the event that you need stricter control over POST contents or specific headers. http://php.net/manual/en/ref.sockets.php Or, if you're on a unix system, and curl's available as an executable, and you consider exec to be a "standard" function, there's always this: $response = shell_exec("curl http://www.example.com";); I always use last method that in preference to the curl functions. I find them incredibly overengineered. :) - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: oo question
> > One personal suggestion: you could directly put the code from > > initialize_customer() into the constructor. > > but i'm thinking that i might, at some point, want to use that method > after the object has been instantiated. i can't think of a specific > case, but i'm only imagining that it's possible. It could be useful when retrieving real data is expensive. I've been recently working with a data set that is derived from a highly-relational database served over HTTP via XML. It's time consuming to pull new information about a record and not all information is used everywhere, so I've been using a structure similar to yours with a lazy-load component -- the data source isn't actually accessed for a particular piece of information until that piece of information is specifically requested. In the example below, properties one and two might refer to linked or nested objects, each with a high cost of retrieval. The database access code that is now in your initialize_customer() method gets split up into logical chunks, and placed in the property_*() methods. Paraphrased/contrived example: class thing { var $id; var $property_one; var $property_two; function thing($id) { $this->id = $id; } function get_property_one() { if(!$this->property_one) { // perform request for property one, // set $this->property_one } return $this->property_one; } function get_property_two() { if(!$this->property_two) { // perform request for property two, // set $this->property_two } return $this->property_two; } } - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] test, please ignore
- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using ' to access session variables?
>Whats the difference between $_SESSION[foo] and $_SESSION['foo'] I have >been using the 's but they seem to be unecessary? Use the single-quotes -- array references often work without them, but the potential for conflict with constants and future PHP incompatibility is a possibility. If you (or PHP) had a constant foo defined, it would behave unexpectedly. >I run into trouble if I try something like: >$query = " select * from table where (test.id = '$_SESSION['foo']') "; >but the following works: >$query = " select * from table where (test.id = '$_SESSION[foo]') "; http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing // Works but note that this works differently outside string-quotes echo "A banana is $fruits[banana]."; // Works echo "A banana is {$fruits['banana']}."; // Works but PHP looks for a constant named banana first // as described below. echo "A banana is {$fruits[banana]}."; // Won't work, use braces. This results in a parse error. echo "A banana is $fruits['banana']."; - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: trying to output a hyperlink
>Although, it could be shortened even more, to: > >Click here"; > echo $link;?> Or still more, to: Click Here ...which starts to approach the original legibility of HTML for me, and the syntax hilighting in BBEdit is corrrect. I've been tending to use constructions like that instead of templating classes like smarty or printf constructiions, and I've been very pleased with em. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression Help
>I want to extract from a large number of html files everything between >the following specified comments, including the comments themselves: > >... >And the regular expression I've got is > >'/[(.+)/Uis' ...which gets you this (I added the parentheses in the middle so you could also get the stuff inside the CMS content delimiters): Array ( [0] => Array ( [0] => Breadth Requirement [1] => More Matched Content! ) [1] => Array ( [0] => Breadth Requirement [1] => More Matched Content! ) ) ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expressions with symmetrical contents
Hi, I'm trying to figure out an appropriate strategy for handling regexps where I need to parse input like the following: "{ {...} {...} (part I want to match) } more..." ...The catch being that thepart I want to match can contain escaped curly braces, like so: "\{" and "\}" It's not enough to just check for the first ending curly brace, using an expression like this: '/{[^{]*{[^}]+}[^{]*{[^}]+}(.*)}/s' = the part I'd like to match ...because there may be other curly braced content afterwards which should not be matched. Regular expressions seem like they're not suitable for this sort of input parsing, and I'm wondering if there is something else out there, like a generic SAX parser for input other than XML. The input I'm using is coming OS X text resources that are in RTF format, so I guess an RTF parser would work too. Any leads? ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression for a UK mobile phone number
>but the regular expression still seems to reject the number... Can you provide an example of numbers it rejects? My answer was based on the simple fact that you were testing for numbers that matched, and returning a rejection based on that. The regexp is simple enough -- some examples of input where it fails would be good, perhaps in a reduced case, like: foreach($array_of_inputs_to_check as $input) printf("input: %s, matches?: %d\n", $input, check($input); ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression for a UK mobile phone number
>I am trying to create a regular expression for a mobile phone number. The >number must be 12 digits long(0-9) and begin with 447 and have no spaces. >So far I have come up with this but it keeps telling me the number is >invalid even when its correct! Try this: $regexp = "/447[0-9]{9}/"; if($_POST[mobile_number] != ''){ if(!preg_match( $regexp, $_POST[mobile_number] )){ $error = "Invalid Mobile Number"; header("Location:edit_rep.php?error=$error&rep_id=".$_GET[rep_id]."&client_id=".$_GET[client_id]."&rep_name=".$_GET[rep_name]."&client_name=".$_GET[client_name].""); exit; } } Also, your regexp is a little permissive; you can anchor it like so: $regexp = "/^447[0-9]{9}$/"; - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php + lynx + grep
>Try adding the apache user to sudoers in /etc/sudoers if not already >there DANGER WILL ROBINSON. Don't add the Apache user to /etc/sudoers -- Apache's security model relies on that user being unprivileged. >> lynx --source http://weather.noaa.gov/weather/current/KTOL.html |grep >> -v '41-35-19N' |grep TOL | head -n 1 >> >> I need to get the output of the above command for a web site I'm >> working on. I've tried exec(), system() and neither seems to work. Have you verified that lynx, grep, and head are in PHP's path? Check the output of `which lynx` or phpinfo() to figure out what your path is, and whether it includes lynx. Alternatively, use a full path to lynx to avoid confusion. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flash MX
>> I have to send data to flash. Should i use the "urlencode()" or the >> "rawurlencode()" function to encode the data? > >If you are going to be doing this a lot, you should take a look at >AMFPHP, Flash Remoting for PHP, at >http://sourceforge.net/projects/amfphp/ > >This seems to be a fast, reliable way to send data back and forth between >your server and your Flash client. I have heard rumors that remoting is supposed to be "deprecated" in the next revision of flash, but I'm not sure how reliable those reports are. Remoting with AMFPHP is speedy and easy, but you may be a little better off using XML - it's definitely chatty, but the API is stable on both sides, and there's no reverse-engineering voodoo associated with it. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternatives to Flush()
>Thanks for taking the time to respond. > >I do have a database and have considered using it in conjunction with >cron. However, I don't like the disconnected nature of the solution. >There could be up to a minute delay before cron picks up the request. > >There's got to be another method similar to using flush(), that causes >the lengthy processing to immediately start as well as redirecting the >visitor to another page. > >Any ideas? I thought you might place the flush() in a while() loop, and keep outputting whitespace until you cross whatever buffering limit the server imposes, but of course this won't work since you can't send output before the Location: header. That's probably the source of the problem you have - with nothing to flush, flush() won't work. Two options I immediately thought of to drop into the background: start a command line php process, using exec() or the like with the usual '&' at the end to drop into the background -- I see Rich has just suggested this. If you want to avoid the database route, use a filesytem queue to signal cron on its next run. Tell the user that "their request will be handled in the order in which it was received" and then cron can check a file or directory for new requests, and process them. I don't think the minute delay is an issue, because the whole thing takes an hour, so what's a minute or two here or there? Jus let the user know they're in good hands and get to it when you get to it. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
>And finally, for those of you who are dying to know the answer to why I >can't use the header(). It's the 3rd party coding that contain the code, > >--snip-- >if(headers_sent()) >$this->Error(' '); >--snip-- Why not delete that part of the 3rd party code then? Or send your Location header before you call it? Curl won't help you here, for the same reasons that fsockopen won't work. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replacing chars in input
>I want to end up with > > A-Za-z0-9_- > >(letters, numbers, underscore and dash). > >If there isn't a handy character class waiting for me, what must I do to >get those chars replaced? $out = preg_replace('/\W+/', '', $in); ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
>In plain english, can't use the header("Location: "), so have to use >the fsockopen() instead. Just that header() is not allowed, don't ask me >why. Just couldn't get the browser perform the HTTP LOCATION event. >--snip-- >$host = "192.168.0.2"; >$port = 443; >$url_str = "ssl://www.whatever.com?str1=true&str2=false&str3=true"; > >$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30); >--snip-- > //send out to the browser. > fputs($fp, "Location: ".$url_str."\r\n"); That won't get sent to the browser, it will get sent to 192.168.0.2, which is (I guess) some machine behind your router. You can't initiate a TCP connection -- what fsockopen does -- with the client's machine. I'll ask even though you said not to - Why doesn't header() work? - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Storage
>I am creating a system to allow users to upload images to the site. >Would it be better to store the images in a MySQL table, or having it >save the images to a directory on the server? Anyone have any >suggestions on this? Pros? Cons? Depends on the details of your situation - I've generally preferred to store image in the filesystem. A few hosts I've used have administrative limits on the size of a BLOB field, so storing images in the filesystem was mandatory. If those images are stored within the docroot, you can also just refer to them by URI and let Apache handle all the appropriate headers and such, or if you're strapped for CPU you can even use a completely different webserver (thttpd, apache without PHP, etc.) to serve them. If they're stored in the database or outside the docroot, you can control access to them more easily. Keeping them in the database also means that you don't have to worry about various filesystem considerations, like keeping a world-writeable directory or potential undesired access from others users in a shared hosting environment. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php and CSS level 2
>RD> I do wonder if either of the above methods would force the RD> >browser to never cache the CSS file locally > >You know, I didn't think about that, as I've never personally used this >method. I've never had a need. Thinking about it now, I would also >think that you may need to send a content-type header of "text/css" to >the browser, as well, though I'm not positive on this. Gecko/Moz based browsers will ignore a stylesheet that lacks the appropriate Content-Type header, so definitely make sure it's there. Regarding the caching, I think just setting up the appropriate cache-control headers should make it indistinguishable from a regular, static CSS file. ----- michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php