Re: [PHP] Login is not working. Please help....
You do know your code is open for sql injection attacks. php.net search for sql injection and session spoofing HTH Andy On Friday 14 October 2005 09:25, Jochem Maas wrote: try some code indentation to make it more readable. someone else pointed you to the 'user' 'name' mismatch already I see. twistednetadmin wrote: ... session_start(); switch (@$_GET['action']) // Gets set by the form action { case login: $sql = SELECT name FROM DB WHERE name='$_POST[user]'; $result = mysql_query($sql) or die(Couldn't execute query.); $num = mysql_num_rows($result); if ($num ==1) // loginname found { $sql = SELECT name FROM DB WHERE name='$_POST[user]' AND pass=password('$_POST[pass]'); $result2 = mysql_query($sql) or die(Couldn't execute query 2.); $num2 = mysql_num_rows($result2); if ($num2 0) // password is correct { $_SESSION['auth']=yes; $logname=$_POST['user']; $_SESSION['logname'] = $logname; header(Location: page1.php); } else // password is not correct { unset($action); header(Location: loginerror.php); } } elseif ($num == 0) // Wrong name. Name not in db { unset($action); header(Location: loginerror.php); } } ... -- Now listening to on amaroK Geek code: www.vlaamse-kern.com/geek Registered Linux User No 379093 If life was for sale, what would be its price? www.vlaamse-kern.com/sas/ for free php utilities -- pgpwq1LTh5cxi.pgp Description: PGP signature
[PHP] file_exists()
Hi file_exists('字.gif') always returns false. Can anyone help me find out a way to make it work also for these kind of filenames?
Re: [PHP] How can I count the usage of mail function in scripts?
Andy Pieters schrieb: While it *is* possible to do what you ask for, it would be worthless. I can write from scratch a php script that * looks up the mx record for a given email address * connects to the mail server looked up * send the message. Since the SMTP protocol is fairly simple, I am sure many others can and will use this to circumvent your limitations. And with PHPMailer there's a package that does this work for you ;-) As I said: What I do with my traffic is none of the hoster's business. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Classes or functions
I'd say it depends on the size of your project and on any plans to reuse the code. Classes are better suited for building libraries of code you use in other projects. And any large project runs into problems with function names if the programmer doesn't use a rigorous naming system (like function package_subpackage_functionname() { ... }) and if such names are used one could just as good use classes. Technical difference: Functions are a little bit faster (think of PHP having to look just one time instead of one time for findeing the class and one time for finding the method). Depending on PHP version: PHP4 has an affinity to using functions because the classes are not as mature and full-featured as in PHP5. So: with PHP4, you actively have to choose using classes; with PHP5, you want to use classes. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: OOP Newbie - why does this not work?
Andy Pieters wrote: While the use of () or not doesn't impede the function of his code, I consider it good programming habit to always add () to the class creator. Since it is creator? you mean constructor (same difference). considered a function, you wouldn't call a function like x=function but 'method' would be more 'correct'. and I don't agree that it is considered a function as you are not directly calling the constructor (if it even exists), but rather instantiating an instance of a class. but that is all rather purist, and not really in the spirit of php. regardless you cant write ... :-) class Test {} $x = new (Test); although you can do the following (for the benefit of the OP): class Test {} $a = b; $b = Test; $c = a; $d = ( ${${$c}} ); /* (the brackets are optional) */ $x = new $d;/* or: $x = $d(); */ $y = new ${(b)}; /* or: $y = new ${(b)}(); */ $z = new ${${$c}}; /* or: $z = new ${${$c}}(); */ ${} = new Test; var_dump($x, $y, $z, ${}); rather x=function(). It is more consistent that way. Consistency shares a house with Standards, and you know what they say about Stan ;-) On Friday 21 October 2005 16:31, Jochem Maas wrote: Nathan Tobik wrote: You have to show us the definition for your class, also your syntax for new is wrong. It should be: $liveclass = new Test(); it can also be (if you have nothing to pass to the constructor function): $liveclass = new Test; Nate Tobik (412)661-5700 x206 VigilantMinds -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: OOP Newbie - why does this not work? Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Html_entities o que ??
Hola lista: Resulta que estoy tratando de crear un RSS 2.0 para mi web y estoy medio que parado por ciertas y determinadas cosillas. La primera es que las noticias las introduzco en la BDatos usando un editor WYSIWYG (TinyMCE Editor) y entonces en los campos TEXT de la tabla me sale contenido HTML. Por ejemplo si alineo el contenido del TEXTAREA a la derecha me introduce esto en la Bdatos: div align=rightCONTENIDO/div Entonces a la hora de mostrar el fichero XML generado me da problemas porque en el área de la descripción me sale todo ese código HTML. Miren el código para hacer el RSS: $contar_noticias = $db-Execute(SELECT COUNT(IDN) AS cantidad FROM noticia); $rscantidad = $contar_noticias-fetchRow(); # RSS File $res = ; $res.= ?xml version=\1.0\ encoding=\UTF-8\?\n; $res.= rss version=\2.0\\n; $res.= \tchannel\n; $res.= \t\ttitle![CDATA[RSS Portal de los Joven Club de Computacioacute;n y Electroacute;nica de Granma]]/title\n; $res.= \t\tdescription![CDATA[RSS Portal de los Joven Club de Computacioacute;n y Electroacute;nica de Granma]]/description\n; $res.= \t\tlanguagees-es/language\n; $res.= \t\tgeneratorRSS Portal JClub Granma/generator\n; if ($rscantidad[0] 0) { $fecha_noticias= $db-SQLDate('d M Y - h:i:s A', 'FechaN'); $noticia = $db-Execute(SELECT IDN, IDC, $fecha_noticias, TituloN, DescN, AutorN FROM noticia WHERE (NACtiva0) ORDER BY FechaN DESC); while ($rs=$noticia-fetchRow()) { $res.=\t\titem\n; $res.=\t\t\ttitle![CDATA[ . stripslashes($rs['TituloN']) . ]]/title\n; // $res.=\t\t\tdescription![CDATA[ . stripslashes($rs['DescN']) . ]]/description\n; $res.=\t\t\tpubDate . stripslashes($fecha_noticias) . /pubDate\n; $res.=\t\t\tlink . $PageAdress . amp;IDC= . $rs['IDC'] . amp;IDN= . $rs['IDN'] . /link\n; $res.=\t\t\tauthor . stripslashes($rs[AutorN]) . /author\n; $res.=\t\t/item\n; } } $res.= \t/channel\n; $res.= /rss\n; $actual =date(Ymd); $handler=fopen(../noticias- . $actual . .xml, 'w+'); if (!fputs($handler, $res)) { $tpl-assign(msg,No se pudo crear el RSS); } else { $tpl-assign(msg,El fichero RSS ha sido creado satisfactoriamente); } fclose($handler); $file = noticias- . $actual . .xml; $tpl-assign('file', $file); Luego el otro problema y un poco OFF TOPIC es que no se como decirle a un arhivo XML que use un fichero XSL para poder mostrar el fichero XML con estilo. Salu2 y gracias de antemano ReynierPM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP to read news
On 10/19/05, Steve [EMAIL PROTECTED] wrote: I'm looking for some help with reading freely available news files like this: news://newsclip.ap.org/[EMAIL PROTECTED] news://newsclip.ap.org/[EMAIL PROTECTED]/%3E%3C/media. I'm able to connect to the newsgroup with the IMAP functions just file, but this type of news url can be placed in a browser like mozilla and the message will be pulled, so i'm thinking it should be much easier than that. When you use the browser to access using the news: protocol you are actually invoking NNTP functions. That's whats the IMAP functions you are using are also doing. So that is the proper way. I imagine if you search for NNTP and PHP you will find some third party classes and code that might help out too... c -- Chris Lott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP on Windows 2003 Server
Hi, I have enough experience working with PHP on Windows XP over IIS, but now I need to work on Windows Server 2003, algo with IIS. I installed PHP (With the installer that I downloaded from www.php.net) but it doesn't work. When I try to see a PHP page I receive the following message: The server can not found What can I do? Ahead of time, thank you very much. Tom. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ugh, w32 anything is making me want to drink!
John Nichel wrote: Jay Blanchard wrote: [snip] I just noticed that extension_dir in phpinfo is c:\php4 THAT AIN'T RIGHT! Why is PHP not loading the proper ini file? This is probably the source of my problems all along! ACK! This is what happens when you go over to the dark side. [/snip] It's not my fault! How do I fix this? Hell if I know, I haven't touched a Windows machine in years. Move the ini file you want it to read to the location it's looking in? You could symbolic link itoops...wait...no, you can't. ;) actually the underlying 'OS' does support something I think they call hard links - but you need a 3rd extension to use it (free download somewhere, gives you an extra item in context menu) ... behold the power of the dark side. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML-RPC Error:-32300:transport error - could not open socket
I'm having any issue finding out why this is happening and how to fix it. Is it a permissions problem between php and the server or something else? Help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML-RPC Error:-32300:transport error - could not open socket
Dan McCullough wrote: I'm having any issue finding out why this is happening and how to fix it. Is it a permissions problem between php and the server or something else? Help Without looking up this specific error code thoroughly through Google or elsewhere, I would have to ask you to submit the code excerpt that generates this error. If it is a permission error it could be because you are trying to listen to a system reserved port in the 0-1024 range, or it could be that the URL that you are trying to open is actually invalid. For instance, if trying to connect to http:// you could have forgotten a slash, or used backslashes, or any other common mistake. Please submit more information the next time, and use Google, it actually finds information for you. :) Regards, Torgny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] JPG Slide show
Hi, Found this on one of my favourite tech show sites: http://www.flickr.com/photos/globalhermit/sets/1134389/show/ Is there something in PHP I can script or find toproduce a slide show of the contents of a Linux directory? (Baby pictures :) ) John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Calling PostgreSQL MySQL Stored Procedures
Can any one please tell me how you call a stored procedure in either PostgreSQL or MySQL from php? Cheers -c
Re: [PHP] Calling PostgreSQL MySQL Stored Procedures
One more caveat: With an without parameters would be very helpful. -c On 10/22/05 11:55 AM, Colin Shreffler [EMAIL PROTECTED] wrote: Can any one please tell me how you call a stored procedure in either PostgreSQL or MySQL from php? Cheers -c Thank you, Colin Shreffler Principal 303.349.9010 - cell [EMAIL PROTECTED] Warp 9 Software, LLC. 6791 Halifax Avenue Castle Rock, CO 80104 Confidentiality Notice: The information in this e-mail may be confidential and/or privileged. This e-mail is intended to be reviewed by only the individual or organization named in the e-mail address. If you are not the intended recipient, you are hereby notified that any review, dissemination or copying of this e-mail and attachments, if any, or the information contained herein, is strictly prohibited. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML-RPC Error:-32300:transport error - could not open socket
Tried Google and the guy who created the snippet they had no helpful information about the error. On 10/22/05, Torgny Bjers [EMAIL PROTECTED] wrote: Dan McCullough wrote: I'm having any issue finding out why this is happening and how to fix it. Is it a permissions problem between php and the server or something else? Help Without looking up this specific error code thoroughly through Google or elsewhere, I would have to ask you to submit the code excerpt that generates this error. If it is a permission error it could be because you are trying to listen to a system reserved port in the 0-1024 range, or it could be that the URL that you are trying to open is actually invalid. For instance, if trying to connect to http:// you could have forgotten a slash, or used backslashes, or any other common mistake. Please submit more information the next time, and use Google, it actually finds information for you. :) Regards, Torgny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Email Validation built-in? RFC
It would be nice to have a php function valid_email or something but until then i suppose we just make do with what is available, for what I need I use the following:- eregi(^[a-z0-9]+([_\\.-][a-z0-9]+)* .@.([a-z0-9]+([\.-][a-z0-9]+)*)+.\\.[a-z]{2,}.$,$email) Ive never had problems with it but have up to now no need for multilanguage validation. What is wrong with that validation anyway? Richard Lynch wrote: Given: It is unacceptable to reject perfectly valid email addresses, no matter how arcane. [Like mine. :-)] The CORRECT RegEx for validating an email is 3 pages long, and performance in PHP would probably not be so good... In today's Security-conscious world, data validation is a requirement. The (relatively) recent changes in domain names that allow UTF (Unicode?) characters. Checking MX records is not reliable at all. Forcing users to respond to email is A) burdensome to real users in many cases, and B) no real barrier to halfway intelligent fake users. ... would it not make sense for there to be a BUILT-IN PHP function of a TRUE email syntactic validation? So at least one KNOWS that the email is a valid construct, before you even try (if you try at all) to make sure that a person actually checks it at least once in their life. Currently, email syntax validation is being done in very limited fashion, if not outright wrong by rejecting what actually ARE valid email addresses in about 10,000,000 PHP scripts by users who don't have any realistic options to truly do it right because who can really live with that 3-page Regex in their PHP code? Yes, in the past, I may have come down squarely on the opposite side of this topic, but I've changed my mind. I believe PHP needs a built-in syntactically CORRECT email validation function, vetted and tested by professionals, instead of the mess we now have. PLEASE do not point me to any existing email validation code unless you believe it is not only 100% correct and complete with RFC definitions of syntactically valid email. Not interested. I've already seen them, and been burned by them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] looking for test code..
hi.. before i reinvent the wheel... i'm looking for some code that i can modify to use as a job posting app...i've been looking over google/freshmeat/sourceforge/hotscripts/etc.. my basic needs: -allow user to enter job function, for a number of fields -allow user to maintain/update/delete/enable to jobs -allow admin to enable/disable users -allow user to login/register -allow company user to create jobs -allow regular user to submit resume for a job if anybody knows of job posting/resume code, great! if you alos know of a different app that i could look at, and possibly rewrite/reengineer to get what i need, i'll take that as well.. this is for testing, more than anything... thanks bruce [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Memory Leak?
I've written a script to munge and import 108,000+ records. To avoid spiking the server, I'm sleep()ing 1 second for each record. So it takes 30+ hours to run, so what? This data changes daily but not really much more often than that, mostly. Anyway, it seems to be using an awful lot of RAM for what it's doing. Like, 80 Meg or so. php.ini memory_limit is set to 100M by my ISP. I can use my own php.ini and change that, if needed. Most of the fields are short, and the longest is maybe a varchar(255) and there are only ~15 fields. There's only a couple $query strings in each iteration, a couple MySQL result handles, and 2 copies (raw and munged) of each field's data. That don't sound like 80 Meg worth of data to this naive user. I got worried about the RAM, so stopped the process and added some RAM usage calls, started it over, and am logging the RAM usage at each record. I've written a pretty PNG graph and I'd like some experts to look at the graph, look at the code, and then tell me. 1. Do I have a memory leak that is gonna kill me and I have to fix it? 2. Is PHP's garbage-collection so non-aggressive that this is just normal? 3. Is there some kind of 80/20 or 90/10 rule in the guts of PHP garbage-collection, so that reducing my memory_limit would just fix this? 4. Can you spot any obvious/easy ways to alter the source to reduce memory usage without micro-managing or adding needless complications nor, perhaps most important, adding too much time onto the 30-hour process. Below is a link to the graph, some commentary, and there's a link to the PHP source code at the bottom-right of the web page. Hope all this isn't too presumptious... TIA! http://l-i-e.com/feedbaby/memory_leak.htm -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] WWW-Authenticate
Does anyone see anything wrong with my code below? It works in other files, on other servers. I copied and pasted it exactly? It won't recognise the user name or password. Does Authenticate work on all servers? Here is my phpinfo if that helps?! http://www.royalarchmasonsofquebec.com/phpinfo.php I don't get it. John ?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'password' ) ) { header('WWW-Authenticate: Basic realm=Private'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' . 'a href=' . $PHP_SELF . 'Try again/a or contact a href=[EMAIL PROTECTED]GSE/a'; exit; } else { ? in ?php } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
Because of the way it spikes and maintains, I'm guess that this is normal behavior, but we'll see what the real experts have to say. In theory, if you allow a process 100MB of memory and it thinks it might need some stuff again later, it's likely to cache for faster reuse of that data later. But putting all that aside, because I really have no idea, only hunches, I'm wondering if you might want to rethink how you're doing this in general. Does it make a difference if instead of one record at a time, you pull 10, 20, 100... might speed up your process a little and if it doesn't use any more memory, then why not? Another thought.. can you use database replication here? So instead of dumping all the records and processing and inserting the ones that are new, you'd only be acting on what's changed since the last backup. With real replication, you can do this realtime (or at least semi-realtime), but you could simulate replication in your PHP script as well. The idea is to see what INSERT, UPDATE, DELETE and ALTER (maybe some other) commands are run on SourceDB and perform the same actions on DestinationDB. This can be done by either recording the actions for playback on the DestDB later or by performing the same actions on the DestDB at the same time as the SourceDB effectively mirroring the databases. I'm not sure what 'data munging' is going on or if this is the right solution for you, but it might be worth checking into. Here's the manual page for MySQL's replication: http://dev.mysql.com/doc/refman/5.0/en/replication.html But if you get the theory, you could easily keep a list of the INSERT/DELETE/UPDATE/etc that your scripts do on SourceDB and either do the same thing on DestDB right then, or play it back later like during nightly maintenance. Good luck Richard! -TG = = = Original message = = = I've written a script to munge and import 108,000+ records. To avoid spiking the server, I'm sleep()ing 1 second for each record. So it takes 30+ hours to run, so what? This data changes daily but not really much more often than that, mostly. Anyway, it seems to be using an awful lot of RAM for what it's doing. Like, 80 Meg or so. php.ini memory_limit is set to 100M by my ISP. I can use my own php.ini and change that, if needed. Most of the fields are short, and the longest is maybe a varchar(255) and there are only ~15 fields. There's only a couple $query strings in each iteration, a couple MySQL result handles, and 2 copies (raw and munged) of each field's data. That don't sound like 80 Meg worth of data to this naive user. I got worried about the RAM, so stopped the process and added some RAM usage calls, started it over, and am logging the RAM usage at each record. I've written a pretty PNG graph and I'd like some experts to look at the graph, look at the code, and then tell me. 1. Do I have a memory leak that is gonna kill me and I have to fix it? 2. Is PHP's garbage-collection so non-aggressive that this is just normal? 3. Is there some kind of 80/20 or 90/10 rule in the guts of PHP garbage-collection, so that reducing my memory_limit would just fix this? 4. Can you spot any obvious/easy ways to alter the source to reduce memory usage without micro-managing or adding needless complications nor, perhaps most important, adding too much time onto the 30-hour process. Below is a link to the graph, some commentary, and there's a link to the PHP source code at the bottom-right of the web page. Hope all this isn't too presumptious... TIA! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
On Sat, 2005-10-22 at 17:36, Richard Lynch wrote: I've written a script to munge and import 108,000+ records. To avoid spiking the server, I'm sleep()ing 1 second for each record. So it takes 30+ hours to run, so what? This data changes daily but not really much more often than that, mostly. Anyway, it seems to be using an awful lot of RAM for what it's doing. Like, 80 Meg or so. php.ini memory_limit is set to 100M by my ISP. I can use my own php.ini and change that, if needed. Most of the fields are short, and the longest is maybe a varchar(255) and there are only ~15 fields. There's only a couple $query strings in each iteration, a couple MySQL result handles, and 2 copies (raw and munged) of each field's data. That don't sound like 80 Meg worth of data to this naive user. I got worried about the RAM, so stopped the process and added some RAM usage calls, started it over, and am logging the RAM usage at each record. I've written a pretty PNG graph and I'd like some experts to look at the graph, look at the code, and then tell me. 1. Do I have a memory leak that is gonna kill me and I have to fix it? 2. Is PHP's garbage-collection so non-aggressive that this is just normal? 3. Is there some kind of 80/20 or 90/10 rule in the guts of PHP garbage-collection, so that reducing my memory_limit would just fix this? 4. Can you spot any obvious/easy ways to alter the source to reduce memory usage without micro-managing or adding needless complications nor, perhaps most important, adding too much time onto the 30-hour process. Below is a link to the graph, some commentary, and there's a link to the PHP source code at the bottom-right of the web page. Hope all this isn't too presumptious... The code looks fine, nothing being accumulated in the script itself so my guess is that mysql is hanging onto something... possibly query caching. Either that or as you say PHP itself though I can't say I've experienced any huge memory issues in the past with long running scripts. I'd definitely guess caching of some sort, especially since the memory consumption levels out :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] WWW-Authenticate
On Sat, 2005-10-22 at 17:59, John Taylor-Johnston wrote: Does anyone see anything wrong with my code below? It works in other files, on other servers. I copied and pasted it exactly? It won't recognise the user name or password. Does Authenticate work on all servers? Here is my phpinfo if that helps?! http://www.royalarchmasonsofquebec.com/phpinfo.php I don't get it. John ?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'password' ) ) { header('WWW-Authenticate: Basic realm=Private'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' . 'a href=' . $PHP_SELF . 'Try again/a or contact a href=[EMAIL PROTECTED]GSE/a'; exit; } else { ? in ?php } ? Check phpinfo() and let us know the value of register_globals. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
On Sat, 2005-10-22 at 16:36 -0500, Richard Lynch wrote: I've written a script to munge and import 108,000+ records. [snip] http://l-i-e.com/feedbaby/memory_leak.htm It looks fine to me, but you might like to try accumulating the records say up to 100 at a time and then doing extended INSERTs (if your MySQL version supports them) like this: INSERT INTO tablename (col1, col2) VALUES ('value1', 'value2'), ('value3', 'value4'), ('value5', 'value6'), ('value7', 'value7') ... and so on. These are apparently much nicer for MySQL to process, which may result in lower memory usage and faster operation. -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] WWW-Authenticate
Robert Cummings wrote: On Sat, 2005-10-22 at 17:59, John Taylor-Johnston wrote: Does anyone see anything wrong with my code below? It works in other files, on other servers. I copied and pasted it exactly? It won't recognise the user name or password. Does Authenticate work on all servers? Here is my phpinfo if that helps?! http://www.royalarchmasonsofquebec.com/phpinfo.php I don't get it. John ?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'password' ) ) { header('WWW-Authenticate: Basic realm=Private'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' . 'a href=' . $PHP_SELF . 'Try again/a or contact a href=[EMAIL PROTECTED]GSE/a'; exit; } else { ? in ?php } ? Check phpinfo() and let us know the value of register_globals. register_globalsOn On -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamically Loading Plugins
Hi all. I have need to dynamically load some classes. I have created an abstract class that defines a function. Note that I'm using PHP 4 so abstract is not enforced. 3rd party plugins will then implement this interface. Users will upload their plugins via a web interface. After I save the php class file to the directory ./plugins, I will need to load it later. Basically I need to do something like. $dir = dir(plugins); while($entry=$dir-read() ) { //skip non class php files. if(!eregi(.+\.class\.php$, $entry )) { continue; }//end if //dynamically load class and call it //require class require_once(plugins/.$entry); //get the class name from the entry $classname = ??? ?; $plugin = new $classname(); //result array $results = $plugin-getObjects(); //do other stuff }//end while -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] WWW-Authenticate
On Sat, 2005-10-22 at 18:21, John Taylor-Johnston wrote: Robert Cummings wrote: On Sat, 2005-10-22 at 17:59, John Taylor-Johnston wrote: Does anyone see anything wrong with my code below? It works in other files, on other servers. I copied and pasted it exactly? It won't recognise the user name or password. Does Authenticate work on all servers? Here is my phpinfo if that helps?! http://www.royalarchmasonsofquebec.com/phpinfo.php I don't get it. John ?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'password' ) ) { header('WWW-Authenticate: Basic realm=Private'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' . 'a href=' . $PHP_SELF . 'Try again/a or contact a href=[EMAIL PROTECTED]GSE/a'; exit; } else { ? in ?php } ? Check phpinfo() and let us know the value of register_globals. register_globals On On Sorry to have asked, just re-read the post and realized you posted a link to your phpinfo(). (man I'm not sleeping enough lately :/) Anyways viewing your phpinfo() shows that the server is in CGI mode contrary to the requirements listed here :( http://ca.php.net/features.http-auth Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] WWW-Authenticate
Robert Cummings wrote: On Sat, 2005-10-22 at 18:21, John Taylor-Johnston wrote: Robert Cummings wrote: On Sat, 2005-10-22 at 17:59, John Taylor-Johnston wrote: Does anyone see anything wrong with my code below? It works in other files, on other servers. I copied and pasted it exactly? It won't recognise the user name or password. Does Authenticate work on all servers? Here is my phpinfo if that helps?! http://www.royalarchmasonsofquebec.com/phpinfo.php I don't get it. John ?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'password' ) ) { header('WWW-Authenticate: Basic realm=Private'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' . 'a href=' . $PHP_SELF . 'Try again/a or contact a href=[EMAIL PROTECTED]GSE/a'; exit; } else { ? in ?php } ? Check phpinfo() and let us know the value of register_globals. register_globalsOn On Sorry to have asked, just re-read the post and realized you posted a link to your phpinfo(). (man I'm not sleeping enough lately :/) Anyways viewing your phpinfo() shows that the server is in CGI mode contrary to the requirements listed here :( http://ca.php.net/features.http-auth Cheers, Rob. Back to the drawing board. Thanks Rob! Good grief. I know why too. They are running a client admin that needs it that way probably. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file_exists()
Jonny Bergström schrieb: Hi file_exists('字.gif') always returns false. Can anyone help me find out a way to make it work also for these kind of filenames? Unicode filenames can't be properly handled up to now for all I know. Perhaps waiting for PHP6 might be your only solution. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
On Sat, 2005-10-22 at 19:19, Oliver Grätz wrote: Jonny Bergström schrieb: Hi file_exists('字.gif') always returns false. Can anyone help me find out a way to make it work also for these kind of filenames? Unicode filenames can't be properly handled up to now for all I know. Perhaps waiting for PHP6 might be your only solution. You could try execing a shell command to give you the answer. I don't know if it'll work, but worth a shot if you're in a bind. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using PHP-based form authentication, circumventing existing Apache .htaccess require valid-user
Hello, all - I'm trying to think of how this might be possible, but I can't seem to come up with anything. I'd like to make a login form of sorts, which would enable a user to authenticate against. A simple HTML form, with a PHP back-end, where a user enters a username and password. If this authentication succeeds, the user is redirected to the protected area. However, this protected area was originally protected by an Apache .htaccess-style require valid-user. After authentication succeeds, I'd like to redirect the user to the Apache protected directory, circumventing the .htaccess require valid-user method - because the user has already authenticated by some other means, and there's no need to re-authenticate against HTTP Basic Authentication. Anyone know if this is possible, and if so, how this might work? I'm just looking for some ideas here. As always, thanks for the time -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
Robert Cummings schrieb: You could try execing a shell command to give you the answer. I don't know if it'll work, but worth a shot if you're in a bind. Yep, good idea. Use the native code of the OS ofr listing the file (dir, ls...) and parse the result. OLLi Manche sagen, Computer seien besser als Menschen - aber viel Spaß im Leben haben sie nicht. [Peter Ustinov] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using PHP-based form authentication, circumventing existing Apache .htaccess require valid-user
On Sat, 2005-10-22 at 19:28, Dan Trainor wrote: Hello, all - I'm trying to think of how this might be possible, but I can't seem to come up with anything. I'd like to make a login form of sorts, which would enable a user to authenticate against. A simple HTML form, with a PHP back-end, where a user enters a username and password. If this authentication succeeds, the user is redirected to the protected area. However, this protected area was originally protected by an Apache .htaccess-style require valid-user. After authentication succeeds, I'd like to redirect the user to the Apache protected directory, circumventing the .htaccess require valid-user method - because the user has already authenticated by some other means, and there's no need to re-authenticate against HTTP Basic Authentication. Anyone know if this is possible, and if so, how this might work? I'm just looking for some ideas here. If you know the appropriate login and password then you can redirect using the username and password in the url (not very secure though): http://user:[EMAIL PROTECTED]/blahBlahBlah.php Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using PHP-based form authentication, circumventing existing Apache .htaccess require valid-user
Robert Cummings wrote: On Sat, 2005-10-22 at 19:28, Dan Trainor wrote: Hello, all - I'm trying to think of how this might be possible, but I can't seem to come up with anything. I'd like to make a login form of sorts, which would enable a user to authenticate against. A simple HTML form, with a PHP back-end, where a user enters a username and password. If this authentication succeeds, the user is redirected to the protected area. However, this protected area was originally protected by an Apache .htaccess-style require valid-user. After authentication succeeds, I'd like to redirect the user to the Apache protected directory, circumventing the .htaccess require valid-user method - because the user has already authenticated by some other means, and there's no need to re-authenticate against HTTP Basic Authentication. Anyone know if this is possible, and if so, how this might work? I'm just looking for some ideas here. If you know the appropriate login and password then you can redirect using the username and password in the url (not very secure though): http://user:[EMAIL PROTECTED]/blahBlahBlah.php Cheers, Rob. Thanks for the suggestion, Rob, but the dominant browser (sadly, IE) no longer supports this in later versions. Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
Good idea yes. But apparantly Windows couldn't do it either. :-( function file_exists_windows($path) { exec('dir ' . $path, $output, $return_status); return $return_status == 0 ? true : false; // Windows dir will return 0 when something was found } It works with normal ascii file names, but other than that it's a no. Makes you wonder what the problem is here, maybe exec() not supporting unicode either.
Re: [PHP] Ugh, w32 anything is making me want to drink!
On 10/22/05, Jochem Maas [EMAIL PROTECTED] wrote: John Nichel wrote: Jay Blanchard wrote: [snip] I just noticed that extension_dir in phpinfo is c:\php4 THAT AIN'T RIGHT! Why is PHP not loading the proper ini file? This is probably the source of my problems all along! ACK! This is what happens when you go over to the dark side. [/snip] It's not my fault! How do I fix this? Hell if I know, I haven't touched a Windows machine in years. Move the ini file you want it to read to the location it's looking in? You could symbolic link itoops...wait...no, you can't. ;) actually the underlying 'OS' does support something I think they call hard links - but you need a 3rd extension to use it (free download somewhere, gives you an extra item in context menu) ... behold the power of the dark side. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I don't know if this has been said or not, but phpinfo() shows the path to the ini near the top like: Configuration File (php.ini) Path d:\program files\easyphp1-8\apache\php.ini
Re: [PHP] Using PHP-based form authentication, circumventing existing Apache .htaccess require valid-user
You USED to be able to do that by putting http://username:[EMAIL PROTECTED] but then Microsoft, in its infinite wisdom, decided that was a security risk and stopped supporting it. AFAIK, there's no way to SET the USER/PASS from server to browser... H. You could maybe use cURL to login, then pass back all the responses to the browser, and then the headers that make them be logged in would work for both your login and their .htaccess. The PHP Form and HTTP Auth part of all this for your first login is documented right in the manual, so you needn't strain your brain on that bit. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
On Sat, October 22, 2005 7:12 pm, Jonny Bergström wrote: Good idea yes. But apparantly Windows couldn't do it either. :-( function file_exists_windows($path) { exec('dir ' . $path, $output, $return_status); return $return_status == 0 ? true : false; // Windows dir will return 0 when something was found } First, I don't think $return_status is what you think it is. $return_status is FALSE if your command is not syntactically valid. It will be TRUE if your command is syntactically valid, but you'll need to LOOK at $output to see if the file is listed or not. It works with normal ascii file names, but other than that it's a no. Makes you wonder what the problem is here, maybe exec() not supporting unicode either. If the filename is funky, you are going to have to do whatever you would do in a DOS prompt to escape it, munge, or otherwise convert it to whatever that version of Windows uses. Inlucding 8.3 on ancient Windows, if PHP runs on that junk. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ugh, w32 anything is making me want to drink!
On Sat, October 22, 2005 7:14 pm, Eric Butera wrote: On 10/22/05, Jochem Maas [EMAIL PROTECTED] wrote: John Nichel wrote: Jay Blanchard wrote: [snip] I just noticed that extension_dir in phpinfo is c:\php4 THAT AIN'T RIGHT! Why is PHP not loading the proper ini file? This is probably the source of my problems all along! ACK! IF you are using Apache, and you should be :-), you MIGHT be able to use that Apache directive that tells PHP to find the ini file elsewhere Otherwise, it's compiled into the DLL and you are stuck. A Windoze shortcut WILL NOT WORK That 3rd party thing might. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using PHP-based form authentication, circumventing existing Apache .htaccess require valid-user
Richard Lynch wrote: You USED to be able to do that by putting http://username:[EMAIL PROTECTED] but then Microsoft, in its infinite wisdom, decided that was a security risk and stopped supporting it. AFAIK, there's no way to SET the USER/PASS from server to browser... H. You could maybe use cURL to login, then pass back all the responses to the browser, and then the headers that make them be logged in would work for both your login and their .htaccess. The PHP Form and HTTP Auth part of all this for your first login is documented right in the manual, so you needn't strain your brain on that bit. Thanks for the response, Richard - However, I'm not looking to insert usernames or passwords into the client browser. I'm simply looking for a way to have apache totally ignore all AuthConfig information if the user has already authenticated to the system using some PHP form hackery. I think I found a solution here that I'm going to play with. Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing two post values
Depending on your requirements, I think add one room at a time. For instance, your property sheet comes up initially with No rooms configured. Then have a SELECT/OPTION pulldown for type: Bedroom Bathroom Living Room Garage Dining Room Kitchen etc... Then have an X and Y input box. You could even get fancy and have addition room info like irregular cutouts that reduce the room's square footage, etc. User clicks ADD and it creates an entry in the database and returns to the Add Rooms screen with a list of all the rooms already configured. Finally just put a Done or Finished button that moves to the next step in the process (or back to a main screen). When the number of items is almost always unknown, your best bet is to keep the interface flexible. Otherwise you end up with Well, we only built this to handle 4 bedrooms.. this property has 5.. ok, just add it as a living room and we'll make sure the customer knows it's another bedroom. That's just clumsy. Database could have a Proprerty table (main info regarding the property), a PropertyFeatures table (containing info about rooms, yard, etc.. with the PropertyID that it belongs to), then maybe a third table for addition info regarding the PropertyFeature, like irregular cutouts, wall paint color, carpet/flooring type, etc. I don't know how much control you have or how many requirements that may conflict with this you have are, but that's how I'd design it. Good luck! -TG = = = Original message = = = Hi, I have a form on my site with a database driven amount of rooms for a property - bedrooms, bathrooms and receptions. For each room there will be a textfield allowing users to enter the x and y dimensions. For each room I need to insert the values to the database, however I cant think of a way to do this. All one can do with php is a foreach on the $_POST values whereas I need to process two at a time i.e. one insert of the x and y values per room. Here is the form I have created: form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post table tr ?php $i = 1; while( $i = $frm[Number_Of_Bedrooms] ) ? tr tdBedroom ?php echo $i ? tdX:input name=bedroom_?php echo $i ?_x type=text //td tdY:input name=bedroom_?php echo $i ?_y type=text //td /tr ?php $i++; $i = 1; while( $i = $frm[Number_Of_Bathrooms] ) ? tr tdBathroom ?php echo $i ? tdX:input name=bathroom_?php echo $i ?_x type=text //td tdY:input name=bathroom_?php echo $i ?_y type=text //td /tr ?php $i++; $i = 1; while( $i = $frm[Number_Of_Receptions] ) ? tr tdReception ?php echo $i ? tdX:input name=reception_?php echo $i ?_x type=text //td tdY:input name=reception_?php echo $i ?_y type=text //td /tr ?php $i++; ? tr tdnbsp;/td tdinput type=submit name=Submit value=? echo $frm[submit_text]; ?/td tdnbsp;/td /tr /table /form ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
On Sat, October 22, 2005 5:04 pm, [EMAIL PROTECTED] wrote: Does it make a difference if instead of one record at a time, you pull 10, 20, 100... might speed up your process a little and if it doesn't use any more memory, then why not? I could make a buffer of N lines and read them, I guess. I kinda figured at 1 line a second, PHP and the OS would have no problem buffering from the disk. Another thought.. can you use database replication here? So instead of dumping all the records and processing and inserting the ones that are new, you'd only be acting on what's changed since the last backup. With real replication, you can do this realtime (or at least semi-realtime), but you could simulate replication in your PHP script as well. This data's coming from an external source. Replication is probably not gonna happen. Though I am going to ask for a timestamp column so I can ignore rows that haven't changed since my last import. That should kill about 90% of the MySQL processing, which seems to be the biggest CPU sink here. If that happens, I can probably change the sleep to usleep and a quarter second or so. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing two post values
On Sat, October 22, 2005 7:14 pm, Shaun wrote: For each room I need to insert the values to the database, however I cant think of a way to do this. All one can do with php is a foreach on the $_POST values whereas I need to process two at a time i.e. one insert of the x and y values per room. Here is the form I have created: Actually, PHP will let you process the variables in any manner you see fit. :-) What I would recommend in THIS case is to take advantage of your room numbers to do more like this: form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post table tr ?php $i = 1; while( $i = $frm[Number_Of_Bedrooms] ){ ? tr tdBedroom ?php echo $i ? tdX:input name=bedroom_?php echo $i ?_x type=text //td tdY:input name=bedroom_?php echo $i ?_y type=text //td input name=bedroom_x[?php echo $i?] / input name=bedroom_y[?php echo $i?] / At the other end, when you process these, you'll have: $property_id = $_POST['propery_id']; $bedroom_x = $_POST['bedroom_x']; $bedroom_y = $_POST['bedroom_y']; while (list($i, $x) = each($bedroom_x)){ $y = $bedroom_y[$i]; echo Bedroom $i: ($x, $y)br /\n; } Note that PHP is one of the FEW languages that lets you use arrays as NAME= in the HTML form and you can do something useful with it. ASP don't do that. JavaScript will choke on those names, most likely. So, in reality, it's PHP's flexibility in processing of POST data that is going to make this simple and natural rather than contrived and complex. NOTE: This sample code contains no error-checking, data scrubing, nor data-vaildation. That's all got to be added by you. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling PostgreSQL MySQL Stored Procedures
On Sat, October 22, 2005 12:55 pm, Colin Shreffler wrote: Can any one please tell me how you call a stored procedure in either PostgreSQL or MySQL from php? WILD GUESS: $query = call silly_sproc(); mysql_query($query, $connection) or die(mysql_error($connection)); pg_exec($connection, $query) or die(pg_last_error($connection)); With an argument is left as an exercise to the reader. HINT: Stuff whatever you would type in the mysql/psql monitor into $query No promise this works, as I've only done user-defiend functions rather than stored procedures (unless those are the same...) in PostgreSQL, and my webhost's MySQL probably ain't up to stored procedures yet. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
On 10/23/05, Oliver Grätz [EMAIL PROTECTED] wrote: I believe that the problem is not Windows being unable to look fpr unicode files but PHP being unable to put th unicode string correctly in the command line you are trying to execute. Check this by doing exec('echo test.txt'.$path); and checking if the unicode arrives in the text file. If not, perhaps the multibyte-extension might help out. Yes PHP won't do this either. Unfortunately the DOS box in Windows doesn't allow entering kanji either, but running a normal batch file with the same echo line does indeed work, test.txt containing the correct characters as entered into the .bat file.
Re: [PHP] Dynamically Loading Plugins
On Sat, October 22, 2005 5:56 pm, Todd Nine wrote: I have need to dynamically load some classes. I have created an abstract class that defines a function. Note that I'm using PHP 4 so abstract is not enforced. 3rd party plugins will then implement this interface. Users will upload their plugins via a web interface. After I save the php class file to the directory ./plugins, I will need to load it later. Basically I need to do something like. Am I to understand that users are uploading PHP code you're going to execute?... Sure hope you trust them :-) Anyway, if you can force them to use that __autoload() thingie (see the manual) then you're all set. Their class name matches their filename and it just works like Magic when you make a new $whatever. Or, the other way around, you know what to make a new of because it matches the filename. You need unique filenames anyway, so that keeps your class names unique, unless somebody crams some helper class into their file. May want to have a rule that additional classes in a file MUST have the filename and underscore as the first part of any helper classes, just to avoid collisions. That would probably be the right way If your version of PHP does not support __autoload, check in PECL and PEAR and in user-contributed notes for work-arounds and backward-compatible functions. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JPG Slide show
On Sat, October 22, 2005 11:15 am, John Taylor-Johnston wrote: Found this on one of my favourite tech show sites: http://www.flickr.com/photos/globalhermit/sets/1134389/show/ Is there something in PHP I can script or find toproduce a slide show of the contents of a Linux directory? (Baby pictures :) ) If you can't find it in one of the 10,000 PHP image gallery scripts out there, I'll eat my hat. :-) Simplest way isn't PHP at all, but a META HTTP-EQUIV=REFRESH tag in the HTML to go to the next URL/image. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML-RPC Error:-32300:transport error - could not open socket
On Sat, October 22, 2005 10:19 am, Dan McCullough wrote: I'm having any issue finding out why this is happening and how to fix it. Is it a permissions problem between php and the server or something else? Help Go to the command line/shell or even, gak, MS-DOS, and type: telnet XYZ 32000 XYZ should be an IP address like 192.168.1.1 or a domain name. Either the server responds, or it's not working and PHP can't fix it. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP on Windows 2003 Server
On Sat, October 22, 2005 9:49 am, Tomás Liendo wrote: Hi, I have enough experience working with PHP on Windows XP over IIS, but now I need to work on Windows Server 2003, algo with IIS. I installed PHP (With the installer that I downloaded from www.php.net) but it doesn't work. When I try to see a PHP page I receive the following message: The server can not found What can I do? That usually means you have the IP/domainname wrong. If you are using 'localhost' try 127.0.0.1 instead, and if that works, you just have to fix the hosts file that Windows doesn't provide by default in some weird directory I'll never remember. info.com it. If 127.0.0.1 is what you are using, try 'localhost' for fun. If neither of those work, use the actual IP address of the machine. Run the command winipcfg and it should tell you what the IP is in a fancy window. Or, if not, because MS changed that this week, ipconfig in an MS-DOS prompt, if it exists in Win2003, should do the trick. You can also use ping to figure out if the machine is there, unless that's been turned off on the box. Also try a different browser. IE often lies in its error messages. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Email Validation built-in? RFC
On Sat, October 22, 2005 2:32 pm, James Benson wrote: It would be nice to have a php function valid_email or something but until then i suppose we just make do with what is available, for what I need I use the following:- eregi(^[a-z0-9]+([_\\.-][a-z0-9]+)* .@.([a-z0-9]+([\.-][a-z0-9]+)*)+.\\.[a-z]{2,}.$,$email) Ive never had problems with it but have up to now no need for multilanguage validation. What is wrong with that validation anyway? If you are lucky, it does not reject any valid emails. For sure, however, it is not the 3-page 'correct' validation and therefore must accept at least SOME invalid emails... Almost for sure, it doesn't accept the new-fangled international emails. Presumably, if a built-in PHP function did this, changing it in one place would make everybody's code work right for this monumental change... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
One other thing to keep in mind. Connecting to a database and disconnecting takes some amount of time. If you do it in batches of 10, 100, whatever then make sure you only connect and disconnect once or else you won't have any time savings at all (and will burden the server unnecessarily). Sucks that you don't have more control over the incoming data. Good luck in finding a solution. -TG = = = Original message = = = On Sat, October 22, 2005 5:04 pm, [EMAIL PROTECTED] wrote: Does it make a difference if instead of one record at a time, you pull 10, 20, 100... might speed up your process a little and if it doesn't use any more memory, then why not? I could make a buffer of N lines and read them, I guess. I kinda figured at 1 line a second, PHP and the OS would have no problem buffering from the disk. Another thought.. can you use database replication here? So instead of dumping all the records and processing and inserting the ones that are new, you'd only be acting on what's changed since the last backup. With real replication, you can do this realtime (or at least semi-realtime), but you could simulate replication in your PHP script as well. This data's coming from an external source. Replication is probably not gonna happen. Though I am going to ask for a timestamp column so I can ignore rows that haven't changed since my last import. That should kill about 90% of the MySQL processing, which seems to be the biggest CPU sink here. If that happens, I can probably change the sleep to usleep and a quarter second or so. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory Leak?
On Sat, October 22, 2005 9:24 pm, [EMAIL PROTECTED] wrote: Sucks that you don't have more control over the incoming data. Just for the record, for when the source of this data reads this thread. I am ECSTATIC to have this data, period. :-) I know we'll work out a viable solution in time, even if replication is not in the cards. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Declaring vars as INT ?
On Fri, October 21, 2005 2:39 pm, Chris Knipe wrote: Function DoSomething($Blah) { $Blah = (int) $Blah; return $Blah } $Blah, cannot be larger than 2147483647, and sometimes, I get negative integers back from the above function. This is with PHP 4.4.0 on FreeBSD 5.4-STABLE. Can anyone else perhaps confirm this, and if it is indeed true, is this a bug, or a limitation somewhere on PHP? Any other ways to confirm that *large* numbers, are indeed integers? I'm working with numbers in the form of mmddsss (20051025001 for today for example) PHP integers are limited by 32-bit hardware and a simplicity of design to -2147483648 to 2147483647. There are no unsigned, long, double long, or google ungle longles. [I made that last one up, but it sure sounds good, don't it?] Your options are, however, several. 1. Use BCMATH or that fancy new-fangled big-number package to deal with numbers as big as you want, subject only to the amount of RAM in your box and the number of values you want to use at one time. Performance will not be integer-fast as these packages use string-manipulation to compute mathematical values, but they can get VERY big numbers, with whatever precision you specify. 2. In this particular instance, it's a *DATE* so you should consider converting it to a Unix time-stamp. This does limit you to 1/1/1970 midnight to somewhere in March 2038, however, as that is the same 32-bit limited range in number of seconds between 1/1/1970 midnight and 2 * 2147483647 seconds later than that. Note that this is strictly hardware-based, so if you get a 64-bit machine, your date range goes until, like, 1970 + 2 * (2038 - 1970) If your dates range beyond 1/1/1970 and/or 2038, you may want to simply NOT convert them to integer in the first place. Also note that database software can generally provide more options for date storage, date arithmetic and date-handling in general. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing two post values
...not quite sure what you're asking. Are you asking for help on how to process these variables? I wrote this off the top of my head... meaning that I did not test it... since I don't know if this was what you were asking... I just fiddled with it. Add this code and tell me if it prints out the sql statements the way you wanted BTW, I think your code is wrong here form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post should be form action=?php echo $frm['action'];?property_id=?php echo $_GET['property_id']; ? method=post -Minuk BEGIN CODE $roomArray = array(); $roomArray['bedroom'] = array(); $roomArray['bathroom'] = array(); $roomArray['reception']=array(); /* * I am assuming all you have are 3 types of rooms, 'bedroom', 'bathroom', and 'reception' * * I am also assuming that the lowest room number is 1 and that the all the room values are of the following format : * * ROOMNAME_ROOMNUMBER_X * ROOMNAME_ROOMNUMBER_Y * * the format is strict, there must be an _ after the room name and one after room number */ /* * Loop through post, and if the form name starts with a room name... then try to decipher the form name. * If appropriate, then add. */ foreach ($_POST as $key=$value) { /* * see if the $key has _ after the first character * and another _ after the first one * * Search for the following * * Valid form names are of * *CHARACTER + (1 or more letters) + _ + NUMBER + (1 or more numbers) + _ + (X or Y) * * Using explode, if we break a form name at the '_', the valid types should break into three pieces *room name *room number *room dimension(x or y) */ $roomDataArray = explode('_', $key); if (count($roomDataArray)==3) { $roomName = $roomDataArray[0]; $roomNumber = $roomDataArray[1]; $roomDimension = $roomDataArray[2]; /* * check to see if $roomName exists in $roomArray, * $roomNumber is a number * $roomDimension is 'X' or 'Y' * $_POST[$key] is a number 0 */ if (isset($roomArray[$roomName]) is_numeric($roomNumber) (strcasecmp($roomDimension, 'x') == 0 || strcasecmp($roomDimension, 'y')==0) is_numeric($_POST[$key]) ) { if (!isset($roomArray[$roomName][$roomNumber])) $roomArray[$roomName][$roomNumber] = array(); $roomArray[$roomName][$roomNumber][$roomDimension] = $value; //By the way, $_POST[$key] = $value, in case I lost 'ya there } } } /* * At this point, $roomArray should be of the following format * * $roomArray['bedroom'][1][x] = 10; * $roomArray['bedroom'][1][y] = 20; * . * . * . * etc. * * generate an insert sql statement PER ROOM */ echo 'sql commands BRBR'; foreach ($roomArray as $roomName=$roomNumberDataArray) foreach ($roomNumberDataArray as $roomNumber=$roomDimensionArray) foreach ($roomDimensionArray as $roomDimension = $value) { $sql = 'insert into database.table(roomName, roomNumber, roomDimensionName, roomDimensionValue) values ('.$roomName.', '.$roomNumber.', '.$roomDimension.', '.$value.');'; echo $sql.'BR'; } echo 'done'; END CODE Shaun wrote: Hi, I have a form on my site with a database driven amount of rooms for a property - bedrooms, bathrooms and receptions. For each room there will be a textfield allowing users to enter the x and y dimensions. For each room I need to insert the values to the database, however I cant think of a way to do this. All one can do with php is a foreach on the $_POST values whereas I need to process two at a time i.e. one insert of the x and y values per room. Here is the form I have created: form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post table tr ?php $i = 1; while( $i = $frm[Number_Of_Bedrooms] ){ ? tr tdBedroom ?php echo $i ? tdX:input name=bedroom_?php echo $i ?_x type=text //td tdY:input name=bedroom_?php echo $i ?_y type=text //td /tr ?php $i++; } $i = 1; while( $i = $frm[Number_Of_Bathrooms] ){ ? tr tdBathroom ?php echo $i ? tdX:input name=bathroom_?php echo $i ?_x type=text //td tdY:input name=bathroom_?php echo $i ?_y type=text //td /tr ?php $i++; } $i = 1; while( $i = $frm[Number_Of_Receptions] ){ ? tr tdReception ?php echo $i ? tdX:input name=reception_?php echo $i ?_x type=text //td tdY:input name=reception_?php echo $i ?_y type=text //td /tr ?php $i++; } ? tr tdnbsp;/td tdinput type=submit name=Submit value=? echo $frm[submit_text]; ?/td tdnbsp;/td /tr /table /form -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Submit/Validate triggering problem.
On Fri, October 21, 2005 10:51 am, Uros Dukanac wrote: I can make workaround by checking the value of $Filter (is it A or B) to determine which button sent a request (see Workaround code after Original code), but it looks dirty to me, and I'm wondering why to do that It's pretty standard to check which button was pressed by what values are sent from the browser. That's just how it's done. if ($AForm-validate() Filter == A) I got no clue what all the QuickForm and validate() stuff is doing, but you may not really care about validate() here unless $Filter == 'B'... So I'd maybe switch the order of the tests and put $Filter first. Or maybe you always want validate() for A to run, even when they don't click on A? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Ugh, w32 anything is making me want to drink!
Hello Richard, Saturday, October 22, 2005, 6:37:14 PM, you wrote: Otherwise, it's compiled into the DLL and you are stuck. A Windoze shortcut WILL NOT WORK One of the easiest ways to ensure you're using the php.ini file you want is to create the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath I usually stick my php.ini in my php folder because I ensure that I (my user account) has sufficient rights to modify anything in the php folder whereas the server admin wouldn't give my user account rights to modify files in the Windows folder. You can read more here: http://docs.php.net/en/configuration.html#configuration.file In addition to setting the directives in the php.ini file for your extensions folder, I'd also add it to your Windows Path. You can do that by: Right-click My Computer Choose properties Advanced tab Click the Environment Variables button Under System variables, edit the Path At the end of the path line, add a semi-colon (if there isn't one) Then type in the full path to your extensions folder i.e. C:\PHP\ext Click, Ok, then Ok, then Ok. Restart your webserver, run phpinfo() and make sure that the ini path is the one you specified. Just FYI, you might add the main php folder to your path as well because some of the .dlls you want might be in that folder libeay32.dll for instance. -- TBUDL/BETA/DEV/TECH Lists Moderator / PGP 0x6C0AB16B __ Geocaching:http://gps.PCWize.com ( ) ( ___)(_ _)( ___) TBUDP Wiki Site: http://www.PCWize.com/thebat/tbudp )(__ )__) _)(_ )__) Roguemoticons Smileys:http://PCWize.com/thebat ()()()(__)PHP Tutorials and snippets:http://www.DevTek.org What's the difference between ignorance and apathy? I don't know and I don't care. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] White background with imagecreatetruecolor()
On Tue, October 18, 2005 2:21 pm, John Nichel wrote: I'm diving into the gd functions for the first time, and I'm having a problem creating a white background for an image when using imagecreatetruecolor(). The manual says that this function will create a _black_ image, but looking at imagecolorallocate() it says that the first call to this function fills the background color, and they have examples like this... $im = imagecreatetruecolor('example.jpg'); // sets background to red $background = imagecolorallocate($im, 255, 0, 0); And that creates the image with the right sizes and positions, but the background is black. Is there something wrong in my code, or is the manual wrong on the imagecolorallocate() function? TIA. I believe the automatic filling in of the background color may have been only in GD 1.0 or something... I'm not sure I ever saw it work. On the plus side, it's easy to fill in the background: imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $background); -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Email Validation built-in? RFC
Hello, on 10/22/2005 12:58 AM Richard Lynch said the following: Checking MX records is not reliable at all. I agree that it is less useful today, but it still help catches many domain name typos. ... would it not make sense for there to be a BUILT-IN PHP function of a TRUE email syntactic validation? I don't see that being much better than passing a good regular expression to preg_match. Currently, email syntax validation is being done in very limited fashion, if not outright wrong by rejecting what actually ARE valid email addresses in about 10,000,000 PHP scripts by users who don't have any realistic options to truly do it right because who can really live with that 3-page Regex in their PHP code? For many years I use this regular expression in popular email validation and forms generation and validation classes. http://www.phpclasses.org/formsgeneration http://www.phpclasses.org/emailvalidation Rather than accepting only valid characters, it rejects all invalid characters as specified in the RFC. ^([-!#$%'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$ I think it could be enhanced to reject all invalid characters as specified in the RFC instead of accepting only the valid ASCII characters. It would be just a matter of changing a variable in both the classes above. Other than using that expression in PHP, the forms class can do the same in Javascript to reduce server round trip to check the email format. The email validation class can perform subsequent validation of DNS records and simulate delivery to see if the remote SMTP server would accept. It returns 3 kinds of results: Yes, no, maybe (not possible to determine for sure). It is even capable to distinguish a real rejection from a whitelist temporary rejection. -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inserting NULL Integer Values
On Tue, October 18, 2005 2:15 pm, Shaun wrote: Thanks for your replies, rather than check each vaule by name I am trying to produce a more dynamic solution: foreach ($_POST as $key = $value) { if ($value == '') { $_POST[$key] == 'NULL'; If you actually have == in this line, that is your trouble. } } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Forcing auto_prepend_file to work regardless of what document was accessed
Hello, all - Anyone know if it's possible to use auto_prepend_file to force the appending of a file to the request, regardless of what kind of document is generated? I can see this being a problem if the document was a picture or a video or some such - but is thre a hidden argument list to auto_prepend_file where I can force inclusion of this file, if x, y, and z document types were requested? Thanks! -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forcing auto_prepend_file to work regardless of what document was accessed
On Sat, October 22, 2005 11:25 pm, Dan Trainor wrote: Anyone know if it's possible to use auto_prepend_file to force the appending of a file to the request, regardless of what kind of document is generated? I can see this being a problem if the document was a picture or a video or some such - but is thre a hidden argument list to auto_prepend_file where I can force inclusion of this file, if x, y, and z document types were requested? Not the way you describe it, but... In .htaccess, put: Files .xyz ForceType application/x-httpd-php /Files Now all your .xyz files ARE PHP files. auto_prepend will happen. PHP will parse the files but do nothing unless they happen to contain the character combination ?php (or ? or ?= if you have short_tags on) This may or may not be suitable in your environment. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forcing auto_prepend_file to work regardless of what document was accessed
Richard Lynch wrote: On Sat, October 22, 2005 11:25 pm, Dan Trainor wrote: Anyone know if it's possible to use auto_prepend_file to force the appending of a file to the request, regardless of what kind of document is generated? I can see this being a problem if the document was a picture or a video or some such - but is thre a hidden argument list to auto_prepend_file where I can force inclusion of this file, if x, y, and z document types were requested? Not the way you describe it, but... In .htaccess, put: Files .xyz ForceType application/x-httpd-php /Files Now all your .xyz files ARE PHP files. auto_prepend will happen. PHP will parse the files but do nothing unless they happen to contain the character combination ?php (or ? or ?= if you have short_tags on) This may or may not be suitable in your environment. This would be a great solution, and I'm sure my concern is something that's been discussed many times on this list - I'm worried about the performance hit that the machine would take, if/when parsing a large number of files, in this manner. For small sites, I have no problem adding .html, .htm and friends to PHP's own AddType. But I'm not so sure for larger sites. I'll browse the archive for info and data, and weigh my options. Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JPG Slide show
... out there, I'll eat my hat. :-) Get your false teeth out and glue them on. I defy you to find one that works. Was it a php3 thing where = meant echo ? I saw this in a number of scripts where folks were still using ? instead of ?php !? I've spent 2-3 hours trying to get a number (I can name them) of galeries to work. :( Show me one that generates thumbnails - And works for you personally. But thanks for the Yahoo key words to search with: PHP image gallery scripts. Any one :) Please. Richard Lynch wrote: On Sat, October 22, 2005 11:15 am, John Taylor-Johnston wrote: Found this on one of my favourite tech show sites: http://www.flickr.com/photos/globalhermit/sets/1134389/show/ Is there something in PHP I can script or find toproduce a slide show of the contents of a Linux directory? (Baby pictures :) ) If you can't find it in one of the 10,000 PHP image gallery scripts out there, I'll eat my hat. :-) Simplest way isn't PHP at all, but a META HTTP-EQUIV=REFRESH tag in the HTML to go to the next URL/image. -- John Taylor-Johnston - If it's not Open Source, it's Murphy's Law. ' ' 'Collège de Sherbrooke: ô¿ôhttp://www.collegesherbrooke.qc.ca/languesmodernes/ - 819-569-2064 °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures /(_)\ Université de Sherbrooke ^ ^ http://compcanlit.ca/ T: 819.569.2064