[PHP] caveats for upgrade from 4.2.2 to 4.3
any warnings, problems, or other issues we should be aware of... production server, already addressed the register_globals issue Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Call to undefined function: xml_parser_create()... but CGI compiled --with-xml
>a production box running 4.2.2 recently had a script added to it requiring use >of xml functionality. The box was already compiled (a few versions earlier) >with the --with-xml option. Since then, have upgraded this box twice >(though it >is due for another) using config.nice to ensure the same options are installed. > >have configured this as an apache module and as the CGI... the apache module >uses the XML functions just fine. The CGI however gives the error in the >subject. > >Have compared phpinfo() on each, and added extension_dir and include_dir to the >standalone php's php.ini so that it matches the apache module version, still no >joy. > >Any thoughts, recommendations, or hints as to what I may be missing which would >cause the cgi version not to compile with the xml features even when >the --with-xml option is and has been specified since 4.0.x and through every >upgrade since then thanks to using the same config.nice. any takers on this? Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Call to undefined function: xml_parser_create()... but CGI compiled --with-xml
a production box running 4.2.2 recently had a script added to it requiring use of xml functionality. The box was already compiled (a few versions earlier) with the --with-xml option. Since then, have upgraded this box twice (though it is due for another) using config.nice to ensure the same options are installed. have configured this as an apache module and as the CGI... the apache module uses the XML functions just fine. The CGI however gives the error in the subject. Have compared phpinfo() on each, and added extension_dir and include_dir to the standalone php's php.ini so that it matches the apache module version, still no joy. Any thoughts, recommendations, or hints as to what I may be missing which would cause the cgi version not to compile with the xml features even when the --with-xml option is and has been specified since 4.0.x and through every upgrade since then thanks to using the same config.nice. thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] best method to resize images
have a situation where clients will be uploading images via a web interface. We need to process these images to create thumbnails. In the past we have used image but have found that the output is somewhat less than desireable and limited to jpg. We would like to be able to soften the image prior to resize so it is a little clearer in the thumbnail, as well as have the option of working with gif, png, etc... Comments appreciated. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing of large csv file for insert into pgsql via PHP
we have a number of csv dumps that occasionally have to be used to update tables in a postgres database... normally this is done by uploading the file and whomever running a php based parser which opens the file into an array via file(), does a split() on the comma, then executes an insert or update to the database with the split array values. we have a new upload that involves a 143mb file, compared to previous upload sizes of 10k to 150k. Is there a more efficient way to handle this rather than having PHP load the entire file into an array (which would have to be in memory during the operation, correct?). Perhaps fopen and reading line by line, or would that be the same load? thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamically generate a drop down list
>> Is it possible to have a function which echoes the values as they are >> read from the database? > >something like > >function init_auth_list() > { > print " select the name of >the author"; > $query="select name from author order by name"; > $result=pg_exec($GLOBALS["db"],$query); > $numrows=pg_numrows($result); > $i=0; > while($i<$numrows) > { > $row=pg_fetch_row($result,$i); > print "option name=\"".$row[0]."\">$row[0]"; > $i++; > } > print ""; > } Two things with this, and opinions may vary... Functions shouldn't print or echo anything, rather you should return what is to be displayed. Also you may want to clean up/condense your while in the following manner; select the name of the author"; $query="select name from author order by name"; $result=pg_exec($GLOBALS["db"],$query); $numrows=pg_numrows($result); # $i=0; moved to while statement while($i=0;$i<$numrows;$i++;){ $row=pg_fetch_row($result,$i); $return.="option name=\"".$row[0]."\">$row[0]"; # $i++; moved to while statement } $return.=""; return $return; } ?> then print your select box with the following much of that is personal preference mind you; Dave >> I tried doing something of this sort..but didn't work.. >> Any suggestions? >> Thanks in advance, >> Mukta >> > >hope it works, this is just from the top of my head... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] scoring/sorting db search results based on score
Appreciate the responses... >> Try >> SELECT , (((keywords LIKE '%$search%') * 5) + ((title LIKE >> '%$search%') * 3) + (description LIKE '%$search%')) score FROM . >> ORDER BY score DESC > >PostgreSQL cannot type cast the Boolean type so you have to use a case >statement, also changing like to ilike will get results regardless of >case. > >SELECT , ((CASE WHEN (keywords ILIKE '%$search%') THEN 5 ELSE 0 END) + >(CASE WHEN (title ILIKE '%$search%') THEN 3 ELSE 0 END) + (CASE WHEN >(description ILIKE '%$search%') THEN 1 ELSE 0 END)) AS score FROM >ORDER BY score DESC We are talking a db of under 10k records where the search would take place on. what are the ramifications of this as a load on the postgres server? Wouldn't want to have a great search query that grinds the server to a halt everytime someone searches regardless of the accuracy of the end result :) Thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] scoring/sorting db search results based on score
looking for code snippets or links to examples of the following; - Have a database with multiple fields that will be searched against (happens to be PostgreSQL in this instance, but we can migrate any MySQL based examples/code) - We wish to score search results - ie: a match in "keywords" is worth 5 points, "title" worth 3, and "description" worth 1, perhaps even so far as multiple matches producing multiples of the point value(though that can be a later consideration) - Once we get the results, we would want to display in the order of the scoring, most points first etc... Obviously there are convoluted ways to accomplish, but I am looking to maximize the database performance, limit the number of recursive searches, and use the database/PHP each handle their portion of the search/score/ranking based on their strengths and use of system resources. appreciate any feedback Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upgrading 4.2.2 to 4.3.2
any takers on this? >-Original Message- >From: Dave [Hawk-Systems] [mailto:[EMAIL PROTECTED] >Sent: Thursday, July 10, 2003 11:09 AM >To: [EMAIL PROTECTED] >Subject: [PHP] Upgrading 4.2.2 to 4.3.2 > > >Live server was previously a 4.0.4 install that we upgraded to 4.2.2 >Am getting ready to upgrade it again to 4.3.2 and wish to verify some things. > >1) any caveats to be aware of? > >2) it appears from reading INSTALL that a seperate build isn't required if we >want to run both dynamic and static, just run the dynamic install? > >3) if the above (dynamic) is correct, will using an existing config.nice still >work for the upgrade considering the config.nice is from 4.0.4 and freebsd has >been patched and upgraded since then as well. file contained below > > >#! /bin/sh ># ># Created by configure > >"./configure" \ >"--with-apxs=/usr/local/sbin/apxs" \ >"--with-config-file-path=/usr/local/etc" \ >"--enable-versioning" \ >"--with-system-regex" \ >"--disable-debug" \ >"--enable-track-vars" \ >"--without-gd" \ >"--disable-pear" \ >"--without-mysql" \ >"--with-gd=/usr/local" \ >"--with-ttf=/usr/local" \ >"--with-zlib" \ >"--with-mcrypt=/usr/local" \ >"--with-mhash=/usr/local" \ >"--with-imap=/usr/local" \ >"--with-mysql=/usr/local" \ >"--with-pgsql=/usr/local/pgsql" \ >"--with-dbase" \ >"--with-ldap=/usr/local" \ >"--with-openssl=/usr" \ >"--with-snmp=/usr/local" \ >"--enable-ucd-snmp-hack" \ >"--with-xml=/usr/local" \ >"--enable-ftp" \ >"--with-curl=/usr/local" \ >"--with-gettext=/usr/local" \ >"--enable-sockets" \ >"--enable-sysvsem" \ >"--enable-sysvshm" \ >"--enable-trans-sid" \ >"--prefix=/usr/local" \ >"i386--freebsd4.3" \ >"$@" > > >Comments and feedback appreciated. > >Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upgrading 4.2.2 to 4.3.2
Live server was previously a 4.0.4 install that we upgraded to 4.2.2 Am getting ready to upgrade it again to 4.3.2 and wish to verify some things. 1) any caveats to be aware of? 2) it appears from reading INSTALL that a seperate build isn't required if we want to run both dynamic and static, just run the dynamic install? 3) if the above (dynamic) is correct, will using an existing config.nice still work for the upgrade considering the config.nice is from 4.0.4 and freebsd has been patched and upgraded since then as well. file contained below #! /bin/sh # # Created by configure "./configure" \ "--with-apxs=/usr/local/sbin/apxs" \ "--with-config-file-path=/usr/local/etc" \ "--enable-versioning" \ "--with-system-regex" \ "--disable-debug" \ "--enable-track-vars" \ "--without-gd" \ "--disable-pear" \ "--without-mysql" \ "--with-gd=/usr/local" \ "--with-ttf=/usr/local" \ "--with-zlib" \ "--with-mcrypt=/usr/local" \ "--with-mhash=/usr/local" \ "--with-imap=/usr/local" \ "--with-mysql=/usr/local" \ "--with-pgsql=/usr/local/pgsql" \ "--with-dbase" \ "--with-ldap=/usr/local" \ "--with-openssl=/usr" \ "--with-snmp=/usr/local" \ "--enable-ucd-snmp-hack" \ "--with-xml=/usr/local" \ "--enable-ftp" \ "--with-curl=/usr/local" \ "--with-gettext=/usr/local" \ "--enable-sockets" \ "--enable-sysvsem" \ "--enable-sysvshm" \ "--enable-trans-sid" \ "--prefix=/usr/local" \ "i386--freebsd4.3" \ "$@" Comments and feedback appreciated. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fsockopen -> returning results from port 80, 8080 and 443 requests
any takers on this, before I give up and drop to curl for those types of requests? Dave >Creating a quick script where we can poll the services on a particular >server to >verify if they are running or not. this will be included in a larger scope >application once the details are worked out. > >Am having a problem getting results from queries to web server ports though. >Port 80(std), 8080(FP), and 443(SSL) either timeout without returning any >results, or error with some of the other attempts at illiciting a response that >we have tried (like specifying ssl:// prior to the hostname). > >Code and two smaple outputs below. Thoughts? > >Dave > \n","Testing TELNET:\n","Testing FTP:\n","Testing HTTP:\n","Testing HTTPS:\n","Testing SMTP:\n","Testing POP3:\n","Testing IMAP:\n"); $portput=array("","","","GET / HTTP/1.1\r\nHost: $host\r\n\r\n","GET / HTTP/1.1\r\nHost: $host\r\n\r\n","","",""); $portprepend=array("","","","tcp://","ssl://","","",""); $port=array(22,23,21,80,443,25,110,143); for($i=0;$i\n"; }else{ # see if we have to nudge for a response if(strlen($portput[$i]>0)){ fputs ($fp, $portput[$i]); } # get the response $result.=$portstring[$i]." "; $result.= fgets($fp,1024); fclose ($fp); $result.="\n"; $result=trim($result); } echo $result; flush; } ?> 12:20:13-Testing SSH: SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201 12:20:13-Testing TELNET: Error(61): Connection refused 12:20:13-Testing FTP: 220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready. 12:20:13-Testing HTTP: Error(0): 12:20:13-Testing HTTPS: Error(0): 12:20:13-Testing SMTP: 220 isp1.nexusinternetsolutions.net ESMTP 12:20:13-Testing POP3: Error(61): Connection refused 12:20:13-Testing IMAP: Error(61): Connection refused 12:21:44-Testing SSH: SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201 12:21:44-Testing TELNET: Error(61): Connection refused 12:21:44-Testing FTP: 220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready. 12:21:44-Testing HTTP: 12:26:46-Testing HTTPS: 12:31:47-Testing SMTP: 220 isp1.nexusinternetsolutions.net ESMTP 12:31:47-Testing POP3: Error(61): Connection refused 12:31:47-Testing IMAP: Error(61): Connection refused -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Warning: Invalid argument supplied for foreach()
>Hi all, >I am getting crazy, can't understand what i missed! >Does anybody know? > >$champs = array ("titre_art" => "h3" ,"nom" => "bleu", "prenom" => "green", >"resume" => "bold"); > >foreach($champs as $key => $value) { > > >echo "$row($key))"; > } never used foreach()... but I would check the following: $row($key)) <= appears to have an extra ) though it would just be printed in your example $row($key) <= if it is an array reference, should be $row[$key] Here is another way to do your problem though while(list($key,$value)=each($champs)){ echo "$key"; } Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen -> returning results from port 80, 8080 and 443 requests
Creating a quick script where we can poll the services on a particular server to verify if they are running or not. this will be included in a larger scope application once the details are worked out. Am having a problem getting results from queries to web server ports though. Port 80(std), 8080(FP), and 443(SSL) either timeout without returning any results, or error with some of the other attempts at illiciting a response that we have tried (like specifying ssl:// prior to the hostname). Code and two smaple outputs below. Thoughts? Dave \n","Testing TELNET:\n","Testing FTP:\n","Testing HTTP:\n","Testing HTTPS:\n","Testing SMTP:\n","Testing POP3:\n","Testing IMAP:\n"); $portput=array("","","","GET / HTTP/1.1\r\nHost: $host\r\n\r\n","GET / HTTP/1.1\r\nHost: $host\r\n\r\n","","",""); $portprepend=array("","","","tcp://","ssl://","","",""); $port=array(22,23,21,80,443,25,110,143); for($i=0;$i\n"; }else{ # see if we have to nudge for a response if(strlen($portput[$i]>0)){ fputs ($fp, $portput[$i]); } # get the response $result.=$portstring[$i]." "; $result.= fgets($fp,1024); fclose ($fp); $result.="\n"; $result=trim($result); } echo $result; flush; } ?> 12:20:13-Testing SSH: SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201 12:20:13-Testing TELNET: Error(61): Connection refused 12:20:13-Testing FTP: 220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready. 12:20:13-Testing HTTP: Error(0): 12:20:13-Testing HTTPS: Error(0): 12:20:13-Testing SMTP: 220 isp1.nexusinternetsolutions.net ESMTP 12:20:13-Testing POP3: Error(61): Connection refused 12:20:13-Testing IMAP: Error(61): Connection refused 12:21:44-Testing SSH: SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201 12:21:44-Testing TELNET: Error(61): Connection refused 12:21:44-Testing FTP: 220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready. 12:21:44-Testing HTTP: 12:26:46-Testing HTTPS: 12:31:47-Testing SMTP: 220 isp1.nexusinternetsolutions.net ESMTP 12:31:47-Testing POP3: Error(61): Connection refused 12:31:47-Testing IMAP: Error(61): Connection refused -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] timing out exec statements
we are dropping to a perl script to process transactions, occasionally the remote server the perl script interacts with becomes bogged, the transaction goes into limbo, or for whatever reason the processing of that transaction hangs (happening about 0.2% of the time). Is there a way to time and timeout the exec statement... just assume it has failed, ditch the execution, and handle the failed transaction after X seconds? The alternative we have is to run the exec and redirect the return results to another script so that no single exec would graing the whole master php script to a halt. thoughts? Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] register_globals per virtual host
a while ago we upgraded the php installations on our servers. for a quick fix we set register_globals to on for code compatibility. Since then we have been cleaning up code to eliminate this. We likely still have some virtual hosts who are using these globals though, so while we are wanting them to modify their code, we wish to turn globals off for the rest of the server, and allow those sites to be the exception to the rule. Assumption is that adding a "php_admin_value register_globals on" to selected virtual host containers in apache will allow that particular site access to the globals while allowing the default (off) for the remainder of the sites. Is the assumption correct? Ramifications or caveats that should be considered? Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] *Premature end of script headers
>Guys? The support guy says that my php-script brings his php interpreter to >crash. I am astonished (wow-what a powerful man I am :) ) - no, but really, >it doesn't crash MY server? He also said, it happens just right after the >file is being asked for, that is, as I suspect, somewhere in the first lines >of my php code. Interesting... >I run 4.2.0, he runs 4.0.5 . Both Safe-mode "on", both, as I suspect, on >Windows, mySQL as well. you suspect he is on winodws or know he is? (No experience with the windows platform and PHP myself) >What could in these first lines of the code, which follows, bring his >machine to death? Please, someone - it's so urgent, really... > > >http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reconfigure not showing in phpinfo
Recently reconfigured php to add in support for some extensions we were previously not using (Pear among others). switched to src directory, backed up config.nice edited config.nice to remove/alter the appropriate "--without" lines rm config.cache ./config.nice make (no errors) make install (no errors) pretty seemless... in checking phpinfo() it doesn't show the altered config line though and stil shows the original config line from when we upgraded this server 4.2.2. Is there a cache of this that needs to be deleted somewhere? All the extensions and changes DID take place though and work just fine, just annoying that the phpinfo() which we use to check configurations isn't correctly displaying the current config. We do run a binary and module installation on the same server, and am referring primarily to the mod install. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] redirect missing function error
related to "Automatic include of files containing functions" Can we capture errors for missing functions and have the script correct the problem and attempt again? For example// $result=MyFunction($someVariable); if this function doesn't exist, PHP generates an error. Capture the error and fix it... error_handler case(missing_function){ require('/path/to/functions/'.$missing_function.'.php'); return/retry the function or line of code > elseif file doesn't exist terminate with helpful info... can't find function in functions dir... } in short, soe code to drop in the header of each document to remove the requirement to have any functions hard coded into the pages, and simply have a repository of functions in a directory that would be included only when called. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Automatic include of files containing functions
Here is what I am looking at for a partial solutions (see "redirect missing function error" for my next hurdle)... All functions are contained within individual files in a "functions" directory, none of which are hard included into the PHP pages; eg// ./functions/ShowThis.php ./functions/ShowThat.php ./functions/ShowOther.php in each PHP page... Now when we want to call functions, we use the following syntax... instead of; $MyInfo=ShowOther($someVariable); we use; $MyInfo=call_user_func(func('ShowOther'),$someVariable); This seems to accomplish what I want which is to remove my large 30 function text file from being loaded for every page when some pages only require one of the functions in the file. Comments? Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can PHP do this...?
>John, PHP-general, > >OK. I think I understand this, but let me ask just to be sure. > >So if I setup in my page something to this effect: >if ($_SERVER['!HTTPS']) { > echo "Switching over to SSL..."; > echo ""; yuck recommend insuring this is at the top of your page and using header() instead appears seamless to the client > } else { > echo "**Rest of Page**"; > } and would eliminate that as well -Start of file-- https://www.example.com/page.ext";); exit; } # rest of page here since if it isn't secure the page stops at the exit after the header has been sent to the browser to redirect. ?> -end of file-- Check your particular server response for the match, you may be able to just do; if (!$_SERVER['HTTPS']) { Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Automatic include of files containing functions
>I don't know about the efficiency .. but to do it .. you can use >function_exists() to see if a function is already defined if not include the >file for that function before using a function. Please check this for viability... # the directory ./includes/ contains # - get_my_info.php containing the function get_my_info() # - and numerous other functions which may or may not be # needed by any particular file # # include at the top of each page # function_do(FunctionName,FunctionVariables) function function_do($f_name,$f_string){ if (!function_exists($f_name)) { # function doesn't exists, needs to be included require('./includes/'.$f_name.'.php'); } else { # function already exists, no action required } eval("\$return=$f_name($f_string);"); return $return; } /* ... */ # when we need to run a function # instead of... $my_info = get_my_info('name','account'); # we would do... $my_info = function_do("get_my_info","'name','account'"); This would check to see if the function was already called and included, and if not, include, then run and return the result. this would avoid having to include explicitly any files containing functions on any page as they would all be loaded dynamically. Am I groking this correctly? Original questions/requirements included below. Dave >- Original Message - >From: "Dave [Hawk-Systems]" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, December 11, 2002 10:40 AM >Subject: [PHP] Automatic include of files containing functions > > >> On a few sites we have used a master include or function file containing >all the >> unctions required for the site... Some of these function files may >contain >> 30-40 functions and some pages use only 1 function from the file. >> >> Would like to be a little more dynamic in our approach of this, and have >started >> moving all the functions into their own files... for example moving >connectdb() >> from the functions.php file to a connectdb.php or connectdb.inc file. >> >> Then for any particular php page, we would pull in only the functions that >we >> need for that particular page. From a script/function management >perspective >> this would be ideal. >> >> Questions// >> >> What would this do as far as speed and efficiency (having to load 4 or 5 >> includes/requires rather than one larger include that has 25 functions >that >> aren't needed or used)? >> >> Then the hard one... >> >> Is there a way to have the PHP script dynamically pull in the required >include >> files? for example, have a function at the top of each page to include >any >> files required as a result of functions that exist in the script... ie: >this >> page uses abc() 123() and so it include/require ./includes/abc.php and >> ./includes/123.php which contain the appropriate functions. >> >> OR >> >> is there an easier way to manage what is becoming an over abundance of >functions >> for particular sites. >> >> Have gotten in the habit of creating a function for anything I have to do >more >> than 1 or 2 times on seperate pages just to speed and simplify code from a >> design and readability point of view. >> >> >> Appreciate any comments. >> >> Dave >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Automatic include of files containing functions
On a few sites we have used a master include or function file containing all the unctions required for the site... Some of these function files may contain 30-40 functions and some pages use only 1 function from the file. Would like to be a little more dynamic in our approach of this, and have started moving all the functions into their own files... for example moving connectdb() from the functions.php file to a connectdb.php or connectdb.inc file. Then for any particular php page, we would pull in only the functions that we need for that particular page. From a script/function management perspective this would be ideal. Questions// What would this do as far as speed and efficiency (having to load 4 or 5 includes/requires rather than one larger include that has 25 functions that aren't needed or used)? Then the hard one... Is there a way to have the PHP script dynamically pull in the required include files? for example, have a function at the top of each page to include any files required as a result of functions that exist in the script... ie: this page uses abc() 123() and so it include/require ./includes/abc.php and ./includes/123.php which contain the appropriate functions. OR is there an easier way to manage what is becoming an over abundance of functions for particular sites. Have gotten in the habit of creating a function for anything I have to do more than 1 or 2 times on seperate pages just to speed and simplify code from a design and readability point of view. Appreciate any comments. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mailing a cookiecontent
>Here's what I wanna do: >On the first page I collect a lot of formfield values into a cookie. On the >next page I display the content of this cookie. This works. >What I even want to do is mailing the cookie content in the same time I >submit the forms in the first page (or, when the new page loads). >I use this code on the second page: > >if ($REQUEST_METHOD=='POST') { > $name = escapeshellcmd($name); > $group = escapeshellcmd($group); > $to = "[EMAIL PROTECTED]"; > $from = "FROM: $name, $group"; > $subject = "The subject of this mail\n\n"; > $body = "Name: $name\t"; > $body .= "Group: $group\n"; > $body .= "\n\n$comments\n\n"; see below, but if you cookie is named cookiestr, just us the variable here $body .= "\n\n$cookiestr\n\n"; > > mail($to,$subject,$body,$from); > exit; >} > >Well, I recieve a mail, but the mailcontent is empty. >The cookie string is written to a hidden field like this: > > document.write('VALUE=\"'+cookiestr+'\">'); so your cookie variable name is "cookiestr" why use Javascript, and not just echo ''; Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex match problem
as part of a larger application we have a bit of code that processes whois to determine domain name expiry dates. Most formats are easily parsed, but Register.Com has thrown the little regex for a loop and I am unsure as to a clean workaround. Here is what we have; ... $pregmatchstring="/([\s])*(Renewal\DDate|Registered\sthrough|Expires|Record\sExp ires|Domain\sExpires|Expiry\sDate)([\D\s]*)(.*)/i"; ... exec($command,$cresult,$cstatus); # puts all lines into array $expire=''; for($i=0;$i strip space characters from the front (some indent) ([\s])* > identify the exipery date line from other verbose entries containing "expir" or similar (Renewal\DDate|Registered\sthrough|Expires|Record\sExpires|Domain\sExpires|Expir y\sDate) > any other spaces, .:, or other verbose crap afterwards **except for numbers** > essentially grabs everything else up to the first number > thought I was being slick with this one ([\D\s]*) > grab numbers/date - gets the 2002/12/01, 09-APR-03, 2002-08-19 00:00:00.000 (.*) > and make case insensitive /i takes care of Renewal-Date: 2002/12/01 Registered through- 08/16/02 00:00:00 Expires on: 09-APR-03 expires: 2003-01-17 02:16:03 Domain expires on 03-Apr-2003 Record expires on 2002-08-19 00:00:00.000 Record expires on 29-Mar-2003. Record expires on 2003-03-25. DOMAIN EXPIRES : 2003-03-25. Expiry Date..2003.03.25 HOWEVER... this simple solution breaks for register.com because of their date format Expires on..: Tue, Jul 29, 2003 because the regex only returns "29, 2003" as the date which barfs for the strtotime() not the regex fault of the strtotime fault, as they are doing what instructed... Any ideas on a way to simply overcome the register.com format and still keep a simple all inclusive regex for all registrars? Thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Not a Valid File-Handle Resource
>> $dataFile = >> @fopen("/home/blurredv/data/".$username."Contact.txt","w"); >> fputs($dataFile, $line); >> fclose ($dataFile); >> >> These are the errors: >> >> Warning: Supplied argument is not a valid File-Handle resource in >> /home/blurredv/public_html/redcarbon/update.php on line 34 >> Warning: Supplied argument is not a valid File-Handle resource in >> /home/blurredv/public_html/redcarbon/update.php on line 35 >> >> Note: My script work perfectly with different path names under Windows >> NT. Do I have to do something special for Unix. >> >> Thanks in advance, > >At a guess, the value you are using as a filename is incorrect, but you are >suppressing any error message from fopen - better that you test that result >and be prepared to handle an error situation. > >For a further guess, the value $username doesn't have a trailing slash. or moving to Unix introduced case sensitivity which windows has a habit of ignoring (or correcting for you). Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] String Manipulation
>Wow, Thank you for the explanation, it helped out a lot ;) >I don't know regex very well, but I hope that this will give me a better >understanding of it. >Thank you Yet again, >Mike > good luck understanding. personally it is one of those things that I dust off and pull out the help docs everytime I need it... never use it enough to sit down and really become proficient at writing them, and each time I do it is like pulling teeth. Would love to see a nice walkthrough with excercises and such, just havn't bothered. Instead I suffer through each time it must be used to accomplish an end goal. End results from a carefully crafted regex cannot be beat though. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paying Job...
>I have never charge by the page simply because I don't want to be >limited in my design. Also, I don't want them saying I've added unneeded >pages to up the price. or have customers nitpicking about removing pages to cut costs... >I don't know how you would charge by the script since you should be >using object oriented code. Wouldn't this be similar to charging by the >page? how much code is original these days either... we have a collection of snippets for just about every instance... perhaps only charging the a quarter of the value of the development for an app, but rehashing the code for several other lcients cutting down on development time. >So that leaves hourly or by the project (not mentioned). Personally, I >like to do it by the project, although I am probably a minority in my >preference. By the project gives the client a nice set price. However, >the scope has to be extremely well defined. It should be anyway, but thats the trick... otherwise the simple aplpication will in teh customer eyes include this, that, and the other thing, despite the 30-50 hours that adds to the developemnt. You can't overstate the boundries of deliverables in a contract. >more so if charging by the project. I then charge by the hour for >requests outside the original scope, which happens all the time. It also >keeps them in check on their requests. Depending on the client, I >require a third or half up front for a project. good form. Always build in some slush factor as well... clients ask for minor this and minor that... if you have built in some slush, you can give them those without additional cost. the more they beat you up on the contract price, the more "slush" you remove, and make them aware that "its all fine, but every little extra will have to be charged now" since theve removed your flexibility. Look at it like you aren't doing the development, you are outsourcing it... what is going to ensure that at the end of the project you have enough to pay your developer plus posket a few bucks. Take those steps, and make sure everyone is clear about everything. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HTTP_POST_FILES undefined - What happen?
>Thought I turned on register_globals on in the php.ini, my server >didn't know the HTTP_POST_FILES. > >echo $HTTP_POST_FILES[$file]['type'] ; > >echo $HTTP_POST_FILES[$file]['name'] ; > >echo $HTTP_POST_FILES[$file]['size'] ; > >I've always get these messages: > >PHP Warning: Undefined variable: HTTP_POST_FILES in >c:\inetpub\wwwroot\ohabolana\scripts\sary_vaovao.inc on line 4 PHP >Warning: Undefined variable: HTTP_POST_FILES in >c:\inetpub\wwwroot\ohabolana\scripts\sary_vaovao.inc on line 5 PHP >Warning: Undefined variable: HTTP_POST_FILES in >c:\inetpub\wwwroot\ohabolana\scripts\sary_vaovao.inc on line 6 first, you are uploading the file to this page correct? perhaps a bit of code showing your file handling? FYI/ depending on version you can use $_FILES for short if register globals is on you can refer to the files as the form field name for your file upload $upfile[$i] $upfile_name[$i] $upfile_type[$i] $upfile_size[$i] you may wish to reconsider globals defaulting to on though, (see security section on file uploads) also check to see that the file was indeed uploaded... features.file-upload -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
>>how about this curve... getting PHP to append a line to the apache log. > >How about reading the documentation? Deserved that for not being clear enough... see below. >http://php.net/error_log > >>would much rather pump the clf formatted log sting directly into the >appropriate >>apache log, but if I am not mistaken, using the above function would require >>permissions for user nobody(www, whatever) on the log files, no? > >Nope. >PHP is running as part of Apache. >PHP can ask Apache to write stuff into its own log. >That's one of the features of http://php.net/error_log > error_log into the apache generated "httpd-error.log" (or whatever you like to have it named) works just fine. error_log($fEntry,0); #success, entry appears in httpd-error.log What I am trying to do is to append an entry to the bottom of the "httpd-access.log" when the file upload succeeds to record the filesize etc... when attempting to do so a permission error is generated since uid nobody(web server) isn't allowed to write to the log file which is owned by the user (or root, or whomever) in this case (safe mode restriction, and file permissions) the safe mode restriction and file permissions are bypassed when writing to the httpd-error.log file, as the command was evidently designed to do. It does not bypass when using error_log($fEntry,3,"/path/to/httpd-access.log"); even though both files have the same ownership and permissions(644)... the command simply succeeds on the httpd-error.log and doesn't on the httpd-access.log ...or more correctly on our server setup :) Could remove safe mode and modify file permissions, but that requires opening up security (and log editing by clients) to accomplish it. Or am I missing something? Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
>>I want to be able to view a single log that contains the following: > >http://php.net/error_log > how about this curve... getting PHP to append a line to the apache log. Currently we are exporting via fopen clf formatted logs for file uploads (whose file sizes are not recorded by Apache's logging) then doing a merge of the log files afterwards... would much rather pump the clf formatted log sting directly into the appropriate apache log, but if I am not mistaken, using the above function would require permissions for user nobody(www, whatever) on the log files, no? cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex in_array or array_search
other than each'ing an array and performing a regex match, is there an easier way to parse through the values in an array for a value matching *something*somethingelse* thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file() and array values contain extra \n
>Start from scratch. You have a file with a single user on each line: > >tom\n >dick\n >harry\n > >You use file() to read into array $users. > >You compare as in above. > >You add a user by: > > $users[] = "NEW_USER\n"; > >You write out the file as above. curious... when I ran through that (before posting initially) was getting the following from print_r of the file() results... Array ( [0] => admin [1] => user1 [2] => user2 [3] => user3 [4] => ) which lead me to believe that the last \n was parsing as an extra element in the array... (not sure why), thus the dilema of either trimming each element of the array, or pop'ing an element off the end of the array. both seemed annoying, thus the post after recoding it with each/trim into new array and use that for checking validity... I redid the original file using the script and got different results; Array ( [0] => admin [1] => user1 [2] => user2 [3] => user3 ) which is what I expected in the first place... as such, the original code could now just check for the username with a ."\n" on the end (as you recommended). Futsed up there somewhere... thus the seemingly stupid question. cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file() and array values contain extra \n
>> >> $users[]=$newuser; >> >> # adds the new user to the end of the above created users array >> >> # then write the array to the file >> >> $fd = fopen (".users", "w+"); >> >> fwrite ($fd, join("\n",$users)); >> >> fclose ($fd); >> >> >> >> the problem is after adding users, only the last user returns the user >> >> name in the array, all the other users have an additional "/n" at the >> >> end of them, which causes the check to barf. >> > >> >Well, if you RTFM, you'll know that file() "returns the file in an array >> > ... with the newline still attached". So one possible solution is after >> > using file(), loop through $users and remove the trailing "\n". >> >> thanks, I am/was looking to avoid looping through the array unnecessarily, >> and simply have them removed at the time of dumping the file into the >> array. > >Then use: > > if(in_array($HTTP_SERVER_VARS["REMOTE_USER"] . "\n", $users)) { ... } leaving that last user added to the file not to match since it will not have a \n at the end of it... adding one to the user as it is added into the array results in yet another array element after the file() since it reads the additional line as another array element. >BTW, it should be: > > fwrite ($fd, join('', $users)); > >otherwise each time you write the file out it will have an increasing number >of "\n" attached to each user. thats the crux... fwrite ($fd, join('', $users)); results in a long string of usernames in the, which can't be grabbed back into the array with the file... in short, there is no way to trim as you file() to eliinate this (from what i can see) other than running it through each() or something and rebuilding the array after trimming. Was hoping for something a little more eloquent. cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file() and array values contain extra \n
>On Tuesday 16 July 2002 21:53, Dave [Hawk-Systems] wrote: >> $users=file('.users'); >> # puts users in the file into an array so we can >> # check for valid or priv users with >> if(in_array($HTTP_SERVER_VARS["REMOTE_USER"], $users)){} >> >> # we add additional users to the .users file with the following >> $users[]=$newuser; >> # adds the new user to the end of the above created users array >> # then write the array to the file >> $fd = fopen (".users", "w+"); >> fwrite ($fd, join("\n",$users)); >> fclose ($fd); >> >> the problem is after adding users, only the last user returns the user name >> in the array, all the other users have an additional "/n" at the end of >> them, which causes the check to barf. > >Well, if you RTFM, you'll know that file() "returns the file in an array ... >with the newline still attached". So one possible solution is after using >file(), loop through $users and remove the trailing "\n". thanks, I am/was looking to avoid looping through the array unnecessarily, and simply have them removed at the time of dumping the file into the array. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Purpose of $$var ?????
variable variable... right up there with array array basically what you are saying is resolve $var, then find out what that variable holds example; assume your $counter is currently at 5 $var = "v".$counter."_high_indiv"; would mean that $var= "v5_high_indiv" assuming that v5_high_indiv is dynamically assigned somewhere as a variable $$var is the value of $v5_high_indiv make sense? variable variables are especially good in loops... for example, if you have variables called $user1, $user2, $user3 to print out all the variables would require one line per variable (and alot of typing). using variable variables you could print out the value of all users by looping it for($i=1;$i<100;$i++){ $user="user".$i; echo $$user; } Dave >-Original Message- >From: Scott Fletcher [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, July 16, 2002 9:54 AM >To: [EMAIL PROTECTED] >Subject: [PHP] Purpose of $$var ? > > >The script was working great before PHP 4.2.x and not after that. So, I >looked through the code and came upon this variable, "$$var". I have no >idea what the purpose of the double "$" is for a variable. Anyone know? > >--clip-- >$var = "v".$counter."_high_indiv"; >$val3 = $$var; >--clip > >Thanks, > FletchSOD > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file() and array values contain extra \n
$users=file('.users'); # puts users in the file into an array so we can # check for valid or priv users with if(in_array($HTTP_SERVER_VARS["REMOTE_USER"], $users)){} # we add additional users to the .users file with the following $users[]=$newuser; # adds the new user to the end of the above created users array # then write the array to the file $fd = fopen (".users", "w+"); fwrite ($fd, join("\n",$users)); fclose ($fd); the problem is after adding users, only the last user returns the user name in the array, all the other users have an additional "/n" at the end of them, which causes the check to barf. I want to ensure that the .users file is in; user1 user2 user3 ...format, am I missing something in the reconstruction of the users file that can eliminate the "\n" being placed into the array on the next file() call? hope that made sense... thank. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php