[PHP] Fixing Invalid Characters in RSS Feeds.. ?
I wrote a custom blog/CMS script that I use to generate RSS feeds. Every so often, in the process of cutting and pasting from other sites I will inadvertently enter a bad character that RSS doesn't like which causes the whole feed to break. (For example, versions of quotation marks or long dashes). My solution now is to check the feed at feedvalidator.org and then edit any offending characters by hand. Does anyone know an easier way to do this? In truth, I'm not sure I know what kind of characters are valid and which are not and why. Is there an easy way to validate and correct any incoming text? Thanks, - schnippy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Insert one or many chekbox values in a db mysql
Try this article on Evolt: http://www.evolt.org/article/Storing_form_array_data_to_MySQL_using_PHP/18/60222/ that covers the whole process with good code examples.. - schnippy On 8/9/05, Jesús Alain Rodríguez Santos <[EMAIL PROTECTED]> wrote: > Hi, I have 5 chekboxes in a page, I would like insert the values of all > chekboxes checked in a mysql db. > > > -- > Este mensaje ha sido analizado por MailScanner > en busca de virus y otros contenidos peligrosos, > y se considera que está limpio. > > -- > 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
Re: [PHP] php output to string
* Jesús Fernández <[EMAIL PROTECTED]>: > thanks, it works, but that returns the php code. > what i actually need is the output of that php code evaluated. So eval() the string... -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Insert one or many chekbox values in a db mysql
Jesús Alain Rodríguez Santos wrote: Hi, I have 5 chekboxes in a page, I would like insert the values of all chekboxes checked in a mysql db. Okay, have fun. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] N/A
R. Ragunathan wrote: hi, can we implement lock to a table using postgres with php. if any of u all knows the solution do reply back. http://www.catb.org/~esr/faqs/smart-questions.html Pay close attention to the sections dealing with "Before you ask", and "Use meaningful, specific subject headers" -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Restarting windows from php
Does anyone have any idea how to restart windows from a php script? I tried the following: exec('SHUTDOWN -r -t 01'); or exec('SHUTDOWN /r'); I received the following warning message: Warning: exec(): Unable to fork [SHUTDOWN -r -t 01]. I never used this kind of functions before. What's wrong? In IIS for "Execute Permissions" I have "Scripts and Executables". What permissions should I set for the Internet Guest Account? Or something else caused the problem, not the permissions? Please help me.:) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restarting windows from php
[snip] Does anyone have any idea how to restart windows from a php script? I tried the following: exec('SHUTDOWN -r -t 01'); or exec('SHUTDOWN /r'); I received the following warning message: Warning: exec(): Unable to fork [SHUTDOWN -r -t 01]. I never used this kind of functions before. What's wrong? In IIS for "Execute Permissions" I have "Scripts and Executables". What permissions should I set for the Internet Guest Account? Or something else caused the problem, not the permissions? Please help me.:) [/snip] Everyone, repeat after me.. PHP is server-side, there's no place like home, PHP is server-side, there's no place like home, PHP is server-side, there's no place like home.. If you are trying to restart Windows, locally, you have to use something client-side to affect that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
I don't want to restart windows locally, I want to restart it remotely. I need a php script that restarts the server. Is this possible or not? On 8/10/05, Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] > Does anyone have any idea how to restart windows from a php script? > I tried the following: > exec('SHUTDOWN -r -t 01'); > or > exec('SHUTDOWN /r'); > > I received the following warning message: Warning: exec(): Unable to > fork [SHUTDOWN -r -t 01]. > > I never used this kind of functions before. What's wrong? In IIS for > "Execute Permissions" I have "Scripts and Executables". What > permissions should I set for the Internet Guest Account? Or something > else caused the problem, not the permissions? Please help me.:) > [/snip] > > Everyone, repeat after me.. > > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home.. > > If you are trying to restart Windows, locally, you have to use something > client-side to affect that. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
Hi, I think, Karl says that to how to shutdown the server. This is posible with rundll, or using Win32API functions. This is the detailed information about how to use Win32API functions in PHP: http://www.php.net/manual/en/ref.w32api.php So, also this is an information about ExitWindows() API function: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/exitwindows.asp Best Regards. "Jay Blanchard" <[EMAIL PROTECTED]> writes: > [snip] > Does anyone have any idea how to restart windows from a php script? > I tried the following: > exec('SHUTDOWN -r -t 01'); > or > exec('SHUTDOWN /r'); > > I received the following warning message: Warning: exec(): Unable to > fork [SHUTDOWN -r -t 01]. > > I never used this kind of functions before. What's wrong? In IIS for > "Execute Permissions" I have "Scripts and Executables". What > permissions should I set for the Internet Guest Account? Or something > else caused the problem, not the permissions? Please help me.:) > [/snip] > > Everyone, repeat after me.. > > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home.. > > If you are trying to restart Windows, locally, you have to use something > client-side to affect that. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Cafer Şimşek http://cafer.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
First off, windows has no clue what a fork is, much less the command 'shutdown -r -t 01'. You can get a windows based version here for windows 2000, http://support.microsoft.com/default.aspx?scid=kb;en-us;317371&sd=tech If you on windows xp or 2003 servers I'm not sure how this will work now that MS in there infinate wisdom has implemented the shutdown/ reboot logging stuff where you have to tell it why your rebooting or shutting it down. (IMHO the dumbest thing ever) >From personal experiance I would test this on a local machine first before putting it on a production system, as they don't always act the way you intend them to. Second, why are you having to reboot the system? Is an application stopping or something else like that because it would be easier to restart the service / application than rebooting the sytem if thats the case. Karl-Heinz Christian Zeck ([EMAIL PROTECTED]) wrote: > > I don't want to restart windows locally, I want to restart it > remotely. I need a php script that restarts the server. Is this > possible or not? > > > On 8/10/05, Jay Blanchard <[EMAIL PROTECTED]> wrote: > > [snip] > > Does anyone have any idea how to restart windows from a php script? > > I tried the following: > > exec('SHUTDOWN -r -t 01'); > > or > > exec('SHUTDOWN /r'); > > > > I received the following warning message: Warning: exec(): Unable to > > fork [SHUTDOWN -r -t 01]. > > > > I never used this kind of functions before. What's wrong? In IIS for > > "Execute Permissions" I have "Scripts and Executables". What > > permissions should I set for the Internet Guest Account? Or something > > else caused the problem, not the permissions? Please help me.:) > > [/snip] > > > > Everyone, repeat after me.. > > > > PHP is server-side, there's no place like home, > > PHP is server-side, there's no place like home, > > PHP is server-side, there's no place like home.. > > > > If you are trying to restart Windows, locally, you have to use something > > client-side to affect that. > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- "Computers are like air conditioners - they stop working properly when you open Windows" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
Hello Karl-Heinz, Wednesday, August 10, 2005, 3:05:32 PM, you wrote: KHCZ> Does anyone have any idea how to restart windows from a php script? KHCZ> I tried the following: KHCZ> exec('SHUTDOWN -r -t 01'); KHCZ> or KHCZ> exec('SHUTDOWN /r'); KHCZ> I received the following warning message: Warning: exec(): KHCZ> Unable to fork [SHUTDOWN -r -t 01]. KHCZ> I never used this kind of functions before. What's wrong? In IIS KHCZ> for "Execute Permissions" I have "Scripts and Executables". What KHCZ> permissions should I set for the Internet Guest Account? Or KHCZ> something else caused the problem, not the permissions? Please KHCZ> help me.:) While you can call shutdown directly from exec - some things are best not called like this. PHP will be left hanging waiting for the process to finish, so you'll get a really nasty shutdown going on without properly ending your sessions. You'd be better off looking at COM scripting it to be honest. Or write a Windows application that does what you require (closes down all services smoothly, reboots, etc) and exec that, providing your IIS user has the correct permissions to do so. The warning most likely comes from IIS, or your php.ini settings - I just tested "shutdown -i" on Apache (in WinXP) and it ran without any problems. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services Zend Certified Engineer "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restarting windows from php
Could be that he's trying to use PHP to restart the server. Or could be using php via command line or through a system like GTK or Winbinder. It's worth noting that you should make sure you're restarting the machine you think you are, but the question still remains... is this possible and how is it done? If shutdown can't be forked, is it an issue of PHP spinning off the program and not and returning control to PHP before the program is finished (so they run concurrently)... if that's the case, is there a way to make PHP give full control to the program it calls? If just using EXEC to call a program is considered 'forking', is there another method? Could you use PHP to EXEC a script file that ran shutdown instead? Would this behave better? Is there a way to do this and/or any tricks to making it work? I think that's the question being asked. -TG = = = Original message = = = [snip] Does anyone have any idea how to restart windows from a php script? I tried the following: exec('SHUTDOWN -r -t 01'); or exec('SHUTDOWN /r'); I received the following warning message: Warning: exec(): Unable to fork [SHUTDOWN -r -t 01]. I never used this kind of functions before. What's wrong? In IIS for "Execute Permissions" I have "Scripts and Executables". What permissions should I set for the Internet Guest Account? Or something else caused the problem, not the permissions? Please help me.:) [/snip] Everyone, repeat after me.. PHP is server-side, there's no place like home, PHP is server-side, there's no place like home, PHP is server-side, there's no place like home.. If you are trying to restart Windows, locally, you have to use something client-side to affect that. ___ 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[2]: [PHP] Restarting windows from php
Hello Joseph, Wednesday, August 10, 2005, 3:26:05 PM, you wrote: JO> First off, windows has no clue what a fork is, A fork is several different things, and there's no reason why Windows cannot implement a fork via its standard APIs. JO> much less the command 'shutdown -r -t 01'. -r = Shutdown with restart -t = Set the timeout for shutdown (xx seconds) 01 = The timeout value Open a command prompt, type in it. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services Zend Certified Engineer "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restarting windows from php
Just out of interest, how is the restart going to authenticate itself to get up and running? I used to do something like this between two servers - but the were Macs and I was using Frontier and it did work, but not without the odd mishap. If you just want to do it remotely (without recourse to PHP), look at VNC. George > -Original Message- > From: Jay Blanchard [mailto:[EMAIL PROTECTED] > Sent: 10 August 2005 3:09 pm > To: Karl-Heinz Christian Zeck; php-general@lists.php.net > Subject: RE: [PHP] Restarting windows from php > > > [snip] > Does anyone have any idea how to restart windows from a php script? > I tried the following: > exec('SHUTDOWN -r -t 01'); > or > exec('SHUTDOWN /r'); > > I received the following warning message: Warning: exec(): Unable to > fork [SHUTDOWN -r -t 01]. > > I never used this kind of functions before. What's wrong? In IIS for > "Execute Permissions" I have "Scripts and Executables". What > permissions should I set for the Internet Guest Account? Or something > else caused the problem, not the permissions? Please help me.:) > [/snip] > > Everyone, repeat after me.. > > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home, > PHP is server-side, there's no place like home.. > > If you are trying to restart Windows, locally, you have to use something > client-side to affect that. > > -- > 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] redirect based off server string
Anyone have a script or know of a way to check and see what the url is of a system and then sending it to another url if it is not right? I have this problem where if someone is using: http://www.ces.ncsu.edu/depts/fourh instead of: http://www.nc4h.org to get to my site it is breaking other pieces within it (though there is code in place which supposedly stops this from happening, I have found that this is not the case) what I plan on doing is invoking the script on the main page of each man sub-directory and the main page so that it should catch the majority of folks. Any suggestions/help would be greatly appreciated! Robert -- Robert Sossomon, Business and Technology Application Technician 4-H Youth Development Department 512 BrickHaven Drive Suite 220L, Campus Box 7606 N.C. State University Raleigh NC 27695-7606 Phone: 919/515-8474 Fax: 919/515-7812 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] display error line in object method
Hi, I have a db wrapper class. I use it like this : $db->query"(SQL HERE") or die ($db->error()); Is there a way to display the line on which $db->error() is executed without doing die (__LINE__." ".$db->error() )? If i put __LINE__ in the class the line number is always the line in the class file. I want when i call $db->error() to display the current line number. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] redirect based off server string
Try doing a pattern match on the server string and then using Header to redirect them if its coming from the old server: if (preg_match("/ces.ncsu/i", $_SERVER["HTTP_HOST"])) { header("Location: http://www.nc4h.org";); } - schnippy On 8/10/05, Robert Sossomon <[EMAIL PROTECTED]> wrote: > Anyone have a script or know of a way to check and see what the url is of a > system and then sending it to another url if it is not right? > > I have this problem where if someone is using: > http://www.ces.ncsu.edu/depts/fourh > instead of: > http://www.nc4h.org > > to get to my site it is breaking other pieces within it (though there is code > in > place which supposedly stops this from happening, I have found that this is > not > the case) > > what I plan on doing is invoking the script on the main page of each man > sub-directory and the main page so that it should catch the majority of folks. > > Any suggestions/help would be greatly appreciated! > > Robert > > -- > Robert Sossomon, Business and Technology Application Technician > 4-H Youth Development Department > 512 BrickHaven Drive Suite 220L, Campus Box 7606 > N.C. State University > Raleigh NC 27695-7606 > Phone: 919/515-8474 > Fax: 919/515-7812 > [EMAIL PROTECTED] > > -- > 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
RE: [PHP] display error line in object method
From: Georgi Ivanov [mailto:[EMAIL PROTECTED] > Hi, > I have a db wrapper class. > I use it like this : > $db->query"(SQL HERE") or die ($db->error()); > Is there a way to display the line on which $db->error() is > executed without > doing die (__LINE__." ".$db->error() )? > If i put __LINE__ in the class the line number is always the > line in the class > file. > > I want when i call $db->error() to display the current line number. Probably not the answer you're looking for, but I think your best option may be to pass __LINE__ as an arg to error() and use it there as you please. I don't know of any $parent::__LINE__ syntax, which is what it sounds like you're asking about... -- Mike Johnson Smarter Living, Inc. Web Developerwww.smartertravel.com [EMAIL PROTECTED] (617) 886-5539 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display error line in object method
Thank you for the replay. I know i can pass __LINE to $db->error(). This is not the idea. I want $db->error() to print the line on which it was executed . $parent::__LINE__ Who is the $parent here ? On Wednesday 10 August 2005 18:20, Mike Johnson wrote: > From: Georgi Ivanov [mailto:[EMAIL PROTECTED] > > > Hi, > > I have a db wrapper class. > > I use it like this : > > $db->query"(SQL HERE") or die ($db->error()); > > Is there a way to display the line on which $db->error() is > > executed without > > doing die (__LINE__." ".$db->error() )? > > If i put __LINE__ in the class the line number is always the > > line in the class > > file. > > > > I want when i call $db->error() to display the current line number. > > Probably not the answer you're looking for, but I think your best option > may be to pass __LINE__ as an arg to error() and use it there as you > please. I don't know of any $parent::__LINE__ syntax, which is what it > sounds like you're asking about... > > -- > Mike Johnson Smarter Living, Inc. > Web Developerwww.smartertravel.com > [EMAIL PROTECTED] (617) 886-5539 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] display error line in object method
From: Georgi Ivanov [mailto:[EMAIL PROTECTED] > Thank you for the replay. > I know i can pass __LINE to $db->error(). > This is not the idea. I want $db->error() to print the line > on which it was > executed . > $parent::__LINE__ > Who is the $parent here ? There isn't, necessarily. That was pseudo-code to demonstrate what I thought you were asking about. The point of my reply was "I don't think it's possible to do what you want to do here," and offer up an alternative in passing __LINE__ as an argument to error(). Good luck! -- Mike Johnson Smarter Living, Inc. Web Developerwww.smartertravel.com [EMAIL PROTECTED] (617) 886-5539 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] REGEX for query
Howdy boys and girls! I have a rather interesting issue. I need to locate every query in every PHP application we have for an integration project. I have started doing some research, but I wanted throw this out there as a little exercize because it is interesting. Several queries are written as $variableName = "SELECT foo FROM bar WHERE glorp = '12' "; Others are written as $variableName = "INSERT INTO bar (foo) "; $variableName .= "VALUES ('".$foo."') "; And still others may be written as $variableName = "SELECT foo "; $variableName .= "FROM bar "; $variableName .= "WHERE glorp = '12' "; while('stinky' == $caca){ $variableName .= "AND poot = '" . $caca['texture'] . "' "; } How would you begin to get the queries using PHP? Regex? Other methods? I am working on isolating where the applications live right now, but I would be thrilled to read your opinions and methods. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Re[2]:[PHP] Restarting windows from php
Richard, thanks for the pointer on the shutdown command, nice to see them implement that in 2k3 and XP, I don't use them on a regular base and sure don't use them in server environment. As for the fork, windows can't preform a fork of a process. There are API's out there that can do this for windows such as perls Win32::Process, or using the MKS Toolkit, i think the developer or interopertablility versions will do this. If you have documents showing that windows can do a fork, I would like to read about it, however the last time I checked this was not possible, maybe they are trying to implement this, if so thats great, it will be a plus for them. Thanks, Richard Davey ([EMAIL PROTECTED]) wrote: > > Hello Joseph, > > Wednesday, August 10, 2005, 3:26:05 PM, you wrote: > > JO> First off, windows has no clue what a fork is, > > A fork is several different things, and there's no reason why Windows > cannot implement a fork via its standard APIs. > > JO> much less the command 'shutdown -r -t 01'. > > -r = Shutdown with restart > -t = Set the timeout for shutdown (xx seconds) > 01 = The timeout value > > Open a command prompt, type in it. > > Best regards, > > Richard Davey > -- > http://www.launchcode.co.uk - PHP Development Services > Zend Certified Engineer > "I do not fear computers. I fear the lack of them." - Isaac Asimov > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- "Computers are like air conditioners - they stop working properly when you open Windows" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] force download
some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
Karl-Heinz Christian Zeck wrote: Does anyone have any idea how to restart windows from a php script? I tried the following: exec('SHUTDOWN -r -t 01'); or exec('SHUTDOWN /r'); I received the following warning message: Warning: exec(): Unable to fork [SHUTDOWN -r -t 01]. There are a couple of possible causes here. First I would try this instead... system('shutdown -r -t 1 &'); I don't have a windows machine I can restart at the moment to try this, but you might have more luck with system than with exec. Another possible cause is that the user the web server runs as doesn't have sufficient permissions to initiate a restart. While the error you're getting doesn't appear to have anything to do with permissions I would certainly consider it a possibility. -Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] REGEX for query
Jay Blanchard wrote: > I have a rather interesting issue. I need to locate every query in > every PHP application we have for an integration project. I have > started doing some research, but I wanted throw this out there as a > little exercize because it is interesting. > > Several queries are written as [...] > How would you begin to get the queries using PHP? Regex? Other > methods? I am working on isolating where the applications live right > now, but I would be thrilled to read your opinions and methods. Assuming unix, I'd do the following from the root of the application to get a list of files that contain queries: $ egrep "=[:space:]*\".*\b(SELECT|INSERT|UPDATE)\b" * -ril That is assuming that you always assign a query to a variable before executing it, and the select|insert|update is always on the same line as the assignment operator. For example, the above would not catch: $variableName = "SELECT foo "; But if you're reasonably sure you don't do that anywhere then it might be enough. I'm assuming that at some point you're going to want to update those queries, or the code surrounding them. I'd use a good editor that supports regex searches across multiple files. I'd suggest jEdit (www.jedit.org); it's quite powerful and free, but your favorite editor may have similar functionality already. My next step would be to load all of the files that egrep found for me into jEdit, then do a regex search across all buffers for a similar pattern ( =\s*".*\b(SELECT|INSERT|UPDATE)\b ). jEdit also has a feature known as HyperSearch which opens a dockable window that lists every occurrence by file and line number, and allows you to jump from occurrence to occurence by clicking on each one. I'd then hit each one and do the appropriate update (that is, assuming the update in question isn't so simple that it can be done with a global search and replace). Anyway, that's how I'd do it. Hope you got something out of this... :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic object instances
Hello List, I would like to create an object inside a function with its classname and a parameter list submitted by the function call. function create($class, $parameter) { $obj = new $class($parameter); return $obj; } This is working very well. But I have not every time the same count of parameters for a class constructor. If this is a normal method call of an object I can realise it like this: $ret = call_user_func_array(array(&$obj, 'method'), $parameter_array); The $parameter_array contains as many entries as the function needs. Works well too. But how can I write a function to instance objects with various count of parameters in the constructor? I know, can do this with an eval. But I would like to find a solution where I don't need an eval. thanks for all answers, Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Fixing Invalid Characters in RSS Feeds.. ?
Hello, on 08/10/2005 10:05 AM Greg Schnippel said the following: I wrote a custom blog/CMS script that I use to generate RSS feeds. Every so often, in the process of cutting and pasting from other sites I will inadvertently enter a bad character that RSS doesn't like which causes the whole feed to break. (For example, versions of quotation marks or long dashes). My solution now is to check the feed at feedvalidator.org and then edit any offending characters by hand. Does anyone know an easier way to do this? In truth, I'm not sure I know what kind of characters are valid and which are not and why. Is there an easy way to validate and correct any incoming text? There is no such thing as invalid RSS characters. All characters are valid as long as they are properly encoded to include in XML documents. If you are not sure how to do it, you may want to take a look at this RSS writer and XML writer classes that do it properly: http://www.phpclasses.org/rsswriter http://www.phpclasses.org/xmlwriter -- 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] redirect based off server string
If you are using apache you can use the redirect module Servername www.ces.ncsu.edu ServerAlias * Redirect permanent / http://www.nc4h.org/ -- Leon On Wednesday 10 August 2005 16:52, Robert Sossomon wrote: > Anyone have a script or know of a way to check and see what the url is of a > system and then sending it to another url if it is not right? > > I have this problem where if someone is using: > http://www.ces.ncsu.edu/depts/fourh > instead of: > http://www.nc4h.org > > to get to my site it is breaking other pieces within it (though there is > code in place which supposedly stops this from happening, I have found that > this is not the case) > > what I plan on doing is invoking the script on the main page of each man > sub-directory and the main page so that it should catch the majority of > folks. > > Any suggestions/help would be greatly appreciated! > > Robert > > -- > Robert Sossomon, Business and Technology Application Technician > 4-H Youth Development Department > 512 BrickHaven Drive Suite 220L, Campus Box 7606 > N.C. State University > Raleigh NC 27695-7606 > Phone: 919/515-8474 > Fax: 919/515-7812 > [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] N/A
As Ireland's property developers scramble to snap up every last square metre of prime Dublin real estate, a green oasis in the heart of this booming capital is standing firm against the tide of change. All this may seem highly irrelevent, but when you have a N/A subject, then anything is in. Consider yourself lucky, that Jay, and Jasper, gave your question enough seriousness to direct you to the manual. Personally I would have simply directed you to ESR's essay on Smart Questions(available from John Nichels response) On 8/9/05, R. Ragunathan <[EMAIL PROTECTED]> wrote: > > > hi, > > can we implement postgres transactions with php. > if anyone knows the solution please reply back. > > -- > 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
Re: [PHP] force download
That would be browser dependent, something you have no control over. Maybe you can include a little text message saying "right-click save as" for the users not intelligent enough to figure it out themselves. - Original Message - From: "Sebastian" <[EMAIL PROTECTED]> To: Sent: Wednesday, August 10, 2005 12:00 PM Subject: [PHP] force download some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- 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] Re: dynamic object instances
* Thomas Angst <[EMAIL PROTECTED]>: > I would like to create an object inside a function with its classname > and a parameter list submitted by the function call. > > function create($class, $parameter) { > $obj = new $class($parameter); > return $obj; > } > > This is working very well. But I have not every time the same count of > parameters for a class constructor. > If this is a normal method call of an object I can realise it like this: > > $ret = call_user_func_array(array(&$obj, 'method'), $parameter_array); > The $parameter_array contains as many entries as the function needs. > Works well too. > > But how can I write a function to instance objects with various count of > parameters in the constructor? > I know, can do this with an eval. But I would like to find a solution > where I don't need an eval. Use the func_* functions, along with array_shift(). In addition, you'll need to use either a standard-named static instantiator, or the class name as the constructor method: function create($class) { $args = func_get_args(); array_shift($args); // remove $class from the args list // Do this if using a standard-named static instantiator method // across classes; in this case 'init': return call_user_func_array(array($class, 'init'), $args); // Or use a function named after the class name as the instantiator // method (ala PHP4): return call_user_func_array(array($class, $class), $args); } -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] html_entity_decode () for …, ’, etc.
I tried using html_entity_decode () but why won't these characters decode: ’ – … “ ” -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Gathering CPU info from Linux and FreeBSD and placing it into a MySQL db
Hey all, First time poster to this mailing list, but I've been lurking for a week now, and it seems like there are a lot of helpful people on this list. I hope to help others out with problems I can answer for them in the future. Now, I have an important task at hand. My company has assigned me to write a script that will log into both our BSD and Linux boxes (we have about 400 boxes), gather up all the information about each system (Operating System, External IP Address, LAN Controller, Video Card, USB devices, Serial Port, Amount of Memory, # of Hard Drives, HD Brand, and HD Type (ide ata scsi raid)). We've gone over a few ideas, although we're not set in stone which route we want to take, or if there is an easier solution to this task at hand. Heck, even if there is something that has already been coded and can act as a foundation for this project would be grand. Okay, so here's what we've come up with so far: 1) Using parts of PHPSysInfo - Hack apart this script I found called phpsysinfo. I've already hacked it apart and it only displays what we're looking for. You can see what I'm talking about if you visit http://morano.hopto.org/phpsysinfo/index.php - Use the XML portion of the script to export all gathered data into an XML file. - Take the XML file and import it into the MySQL db 2) Finding a script that already does all this already (Ideal Solution) - I'm open to ideas on this one. After snooping around Linux and BSD, I've gathered that using a combination of sysctl, uname, and dmesg would get me the results I need, but this seems like the hard way, unless someone has already implemented a solution using these tools and PHP. Finding a script that already does everything I want IS the ideal solution, the trouble is finding it. I know it can be done, but I've been bashing my head against the wall for the past day and a half now. My head hurts and has a couple knots due to the wall being so thick, so now I turn to you folks in search for some guidance. If there is anything else I can answer to help clarify my task at hand, please let me know. I'm stepping out for lunch, but I'm pretty much stuck at work until a solution has been found, so I'll be checking the mailing list frequently (about every 5 mins!). The URL I provided to contains everything that is needed to be gathered. Also, if there are other resources such as forums, web site tutorials, script archives, etc. that I might be able to find answers from, I'd love to check them out. Thanks in advance. Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
James R. wrote: That would be browser dependent, something you have no control over. Maybe you can include a little text message saying "right-click save as" for the users not intelligent enough to figure it out themselves. - Original Message - From: "Sebastian" <[EMAIL PROTECTED]> To: Sent: Wednesday, August 10, 2005 12:00 PM Subject: [PHP] force download some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- there has to be a way to tell stupid IE Not to open the damn file. i'll be damned to find a way. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
James R. wrote: That would be browser dependent, something you have no control over. Maybe you can include a little text message saying "right-click save as" for the users not intelligent enough to figure it out themselves. - Original Message - From: "Sebastian" <[EMAIL PROTECTED]> To: Sent: Wednesday, August 10, 2005 12:00 PM Subject: [PHP] force download some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- forgot to mention, they can't right click to "save as" because if you notice from my code i am pushing the file to them... without an actual path to the file. so if they did do a "save as" it'll just save the php/html output, which will be blank in this case. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
A comment is inline. Sebastian wrote: some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } if you just remove this extension check, and set everything as an attachment, that is the normal way to do things. The major browsers will pop up a Save As... dialog header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] what should I look for with this error
I get this error a lot, and think it may be an easy fix, but don't really know what to look for. 'Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_Test.php on line 556' what does this indicate? -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] what should I look for with this error
[snip] I get this error a lot, and think it may be an easy fix, but don't really know what to look for. 'Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_Test.php on line 556' what does this indicate? [/snip] Two and a half words. missing semi-colon - usually just above the line mentioned. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html_entity_decode () for …, ’, etc.
Hi Marco To awnser you question I do not know why it is excluded from the default decode array. Maybe it could be that these are multibyte characters (any takers)? You can get a list of the entities that are changed $trans = get_html_translation_table(HTML_ENTITIES); echo"";print_r($trans);echo""; to add some extras as you have below, use something similar to function htmldecode($string) { $trans = get_html_translation_table(HTML_ENTITIES); $trans[chr(0xe2).chr(0x80).chr(0xa6)] = '…'; $trans = array_flip($trans); return strtr($string, $trans); } $string = "…&"; echo htmldecode($string) ."\n"; Note: obviously hex e2 80 a6 make up the hellip chars. Hope this helps Cheers -- Leon On Wednesday 10 August 2005 20:55, Marco wrote: > I tried using html_entity_decode () but why won't these characters decode: > > ’ > – > … > “ > ” -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what should I look for with this error
I don't see any missing semi-colons off hand. The error is supposedly on line 556 in the below code: Wealth Development Mortgage :: TEAM HOME CONTACT US PAYMENT CALCULATOR HOME COMPANY TEAM CONTACT APPLY ONLINE TEAM Secure Loan Application Wealth Development Mortgage Company provides fast mortgage approvals online. Your Application will be placed in top priority and receive immediate attention. LOAN INFORMATION Loan Purpose: Purchase Refinance - No Cash Refinance - Cash Out Refinance - Debt Consolidation Refinance - Change Loan Type Construction Loan Other Loan Purpose Property Use: Select One -- Primary Residence Secondary Residence Investment Property Loan Type: 30 Year Fixed 15 Year Fixed 10/1 ARM 7/1 ARM 5/1 ARM 3/1 ARM 1 year ARM 6 month ARM 0ption ARM 10 year Interest Only 5 year Interest Only 3 year Interest Only HELOC Property Type: Single Family Detached Townhouse Condo Multi Unit Interest Rate: Select One -- 1.000 1.125 1.250 1.375 1.500 1.625 1.750 1.875 2.000 2.125 2.250 2.375 2.500 2.625 2.750 2.875 3.000 3.125 3.250 3.375 3.500 3.625 3.750 3.875 4.000 4.125 4.250 4.375 4.500 4.625 4.750 4.875 5.000 5.125 5.250 5.375 5.500 5.625 5.750 5.875 6.000 6.125 6.250 6.375 6.500 6.625 6.750 6.875 7.000 7.125 7.250 7.375 7.500 7.625 7.750 7.875 8.000 8.125 8.250 8.375 8.500 8.625 8.750 8.875 9.000 9.125 9.250 9.375 9.500 9.625 9.750 9.875 10.000 10.125 10.250 10.375 10.500 10.625 10.750
Re: [PHP] force download
On Wed, August 10, 2005 12:49 pm, Chris wrote: >> if ($extension != 'txt') >> { >>header("Content-disposition: inline; filename=\"$file[type]\""); >> } >> else >> { >>// force txt files to prevent XSS >>header("Content-disposition: attachment; filename=\"$file[type]\""); >> } The Content-disposition header is a made-up bull-crap thing that came about with "html enhanced" (cough, cough) email. If you want *EVERY* browser to download something, forget this header and use: header("Content-type: application/octet-stream"); The Content-disposition will, on *SOME* browsers, on *SOME* OSes appear to be useful for getting the filename in the dialog prompt for "Save As..." to be the filename you want. Unfortunately, it does *NOT* work universally. If you want a UNIVERSAL solution, make the URL look like it's a "static" URL and have the filename you want to be used appear at the end of the URL. Converting dynamic to static-looking URLs is covered in many places. Google for PHP $_SERVER PATHINFO Under no circumstances should you be using headers like "audio/mpeg" if you want me to download it -- I guarantee my browser will open that up in an MP3 player. Many other users will also have been led through the process to make that happen. But if the browser doesn't download "application/octet-stream" it's a very very very broken browser. -- 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] force download
On Wed, August 10, 2005 12:43 pm, Sebastian wrote: >> That would be browser dependent, something you have no control over. >> Maybe you can include a little text message saying "right-click save >> as" for the users not intelligent enough to figure it out themselves. I defy you to find any web browser that doesn't download a file whose Content-type: header is application/octet-stream Right-click is NOT universal. Macs don't even *have* a right-click! -- 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] html_entity_decode () for …, ’, etc.
On Wed, August 10, 2005 11:55 am, Marco wrote: > I tried using html_entity_decode () but why won't these characters decode: > > ’ > – > … > “ > ” WILD GUESS: Those are not standards-based, and are some made-up Microsoft crap? -- 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] html_entity_decode () for …, ’, etc.
> > … Is this the IP range assigned to hell? I always suspected they were on the net. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what should I look for with this error
Bruce Gilbert wrote: Your heredoc is messed up. Look into getting an editor which will highlight the errors for you. This mailing list isn't here to syntax check (unless it's 4:30 on a Friday). -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display error line in object method
On Wed, August 10, 2005 8:10 am, Georgi Ivanov wrote: > Hi, > I have a db wrapper class. > I use it like this : > $db->query"(SQL HERE") or die ($db->error()); > Is there a way to display the line on which $db->error() is executed > without > doing die (__LINE__." ".$db->error() )? Sure! Use these guys: http://php.net/trigger_error http://php.net/set_error_handler > If i put __LINE__ in the class the line number is always the line in the > class > file. > > I want when i call $db->error() to display the current line number. There may also be some fancy new way to output the whole stack of functions called... I haven't really checked that out 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: Re[2]: [PHP] Restarting windows from php
On Wed, August 10, 2005 7:45 am, Richard Davey wrote: > Hello Joseph, > > Wednesday, August 10, 2005, 3:26:05 PM, you wrote: > > JO> much less the command 'shutdown -r -t 01'. > > -r = Shutdown with restart > -t = Set the timeout for shutdown (xx seconds) > 01 = The timeout value > > Open a command prompt, type in it. C:\Windows> shutdown -r -t 01 Bad command or filename I dunno if YOUR Windows box has some cygwin thingie or something that makes shutdown be a real command, or if it's just a versioning issue, but the single test platform I had available pretty much had no shutdown command. Win 98 SE, I believe. I've got XP on my laptop, and if I cared enough about Windows, I guess I could test that too... -- 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] Gathering CPU info from Linux and FreeBSD and placing it into aMySQL db
Can I ask why you are trying to write a script that from what I understand goes to each box to retrieve the data instead of pushing the data to the central db? You could write a little script in PHP that gathers the required information and then does an insert into your database. Then from the database you can create a webpage that is a view of all of your machines. On the local machine you can schedule your script to run every X minutes via crontab. If I misread your email and headed down the wrong path please let me know. Nate Tobik (412)661-5700 x206 VigilantMinds -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
On Wed, August 10, 2005 7:05 am, Karl-Heinz Christian Zeck wrote: > Does anyone have any idea how to restart windows from a php script? You could send it the various hacks such as Ping of Death ranging up to current Microsoft Windows bugs from any remote computers :-) > I tried the following: > exec('SHUTDOWN -r -t 01'); > or > exec('SHUTDOWN /r'); > > I received the following warning message: Warning: exec(): Unable to > fork [SHUTDOWN -r -t 01]. Try something much more simple than "SHUTDOWN" Can you do "DIR"? exec("DIR", $output, $error); echo "OS Error: $error\n"; echo implode("\n", $output); I believe "Unable to fork" translates into: "I can't even start an MS-DOS prompt up, much less run your command!" > I never used this kind of functions before. What's wrong? In IIS for > "Execute Permissions" I have "Scripts and Executables". What > permissions should I set for the Internet Guest Account? Or something > else caused the problem, not the permissions? Please help me.:) First, you have to figure out for sure for sure what user/account PHP runs as. should clarify that. Next, log in as that user and see if you can shutdown the machine. If that *USER* can't do it, with a human typing, it's for sure PHP won't be any better at it. Next, figure out where the shutdown command actually lives, and provide a FULL PATH to it: C:\Windows\System32\blah\blah\blah\blah\shutdown.exe You never know for sure if PHP's user is getting a full logged-in shell with all the $PATH ($path?) stuff, or some kind of half-assed crippled shell. Use a full pathname for everything, and you can ignore this issue. Use the extra arguments to exec() as I did in the "DIR" example so you can get the output from the Operating System about what happened. Shutting down from PHP is not really any different from shutting down from any other program or an MS-DOS prompt -- shutdown will terminate PHP cleanly, just as it terminates every other program cleanly. WARNING: Seriously consider what happens if... You get this to work, and some Bad Guy who hates you gains access to your web page somehow. They can write PHP script on THEIR server to hit that page, oh, every 5 minutes, and your box will never be up long enough for you to do anything remote with it at all. Or a disgrunted employee could put a Scheduled Task on the box to do it internally. Or... You REALLY need to be certain about the security/usability implications of this before you finalize it. Lock down access to that page as much as you can. SSL, password protected, maybe even have the script record a time-stamp when it's run, and refuse to run itself more often than 3 times in one 24-hour period. -- 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] what should I look for with this error
[snip] 755 lines of code that should have never been posted in its entirity, especially without line numbers or something saying <---HERE IS THE PROBLEM LINE [/snip] Dude, when you have a syntax error like this only post 20 or 30 lines of the code surrounding the line and then point out which line is #foo, 'k? Your HEREDOC appears to be messed up. On line 623 the closing identifier is not in first column of the line (when I cut n paste the code into an editor. That is a requirement for the heredoc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic object instances
Matthew Weier O'Phinney schrieb: Use the func_* functions, along with array_shift(). In addition, you'll need to use either a standard-named static instantiator, or the class name as the constructor method: function create($class) { $args = func_get_args(); array_shift($args); // remove $class from the args list // Do this if using a standard-named static instantiator method // across classes; in this case 'init': return call_user_func_array(array($class, 'init'), $args); // Or use a function named after the class name as the instantiator // method (ala PHP4): return call_user_func_array(array($class, $class), $args); } Thanks for you answer, but sorry, I do not understand your hint. I tried this code: class test { var $txt; function test($txt) { $this->txt = $txt; } function out() { echo $this->txt; } } $obj = call_user_func_array(array('test', 'test'), array('foobar')); $obj->out(); But I'm getting an error while accessing the $this pointer in the constructor. Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] what should I look for with this error
[snip] Dude, when you have a syntax error like this only post 20 or 30 lines of the code surrounding the line and then point out which line is #foo, 'k? Your HEREDOC appears to be messed up. On line 623 the closing identifier is not in first column of the line (when I cut n paste the code into an editor. That is a requirement for the heredoc. [/snip] You also didn't close the PHP block after END_FORM; Then you need to open a PHP block at about line 635 before the if statement. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] graph - dowloads/hr
On Tue, August 9, 2005 3:07 pm, Sebastian wrote: > i'd like to create a graph with the amount of downloads per hour, i am a > little confused how i should go about this. > > i know i can use rrdtool/mrtg, but im looking for more 'user friendly' > graphs with custom colors,etc. > > each time someone downloads a file it is incremented in the db and the > last time the file was downloaded. i am unsure about the data i would > need to store to create and if what i am storing is enough to do this. > any suggestions or tools that already exists to create this types of > graph? select count(*) as score from downloads where date_add(download_time, interval 1 hour) >= now() group by filename order by score desc Then you use jpgraph on that result set. Or just roll your own with http://php.net/gd -- 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] Gathering CPU info from Linux and FreeBSD and placing it into aMySQL db
Hi Nate, We are a hosting company. We use this Mambo-like CMS called CATS, which pretty much tells us what company owns what server(s) in our data centers. CATS will provide us with a list of details on the specs for each machine they own, which include the specs I listed (memory, # of cpus, etc.) Someone in our company deleted the table within the MySQL db that listed our 400+ machines. Since IT is slammed with other tasks, they have assigned me to this job. This is a step by step as to what I've decided needs to happen, in order for this task to operate (somewhat) smoothly. 1) Read IP addresses from a tab-delimited file, which will follow the format: abc.com 64.64.64.1 domain.com 255.213.6.4 blah.co.uk 29.42.200.9 etc.net 13.14.15.255 2) Assign the $domain variable to the domain name in each line, then assign $ipaddress to the actual ip address 3) Take $ipaddress and ssh into each box (we have a private/public ssh key set up) 4) (This is the undecided step) Run script to gather the necessary server information and export info into either a)CSV or b)XML 5) Take exported file and upload it/email it to my box/my email address 6) Take exported file and create a script to import the information into the CATS MySQL db (not handled by me, but I can easily take over responsibility on creating this script and implement it into my code) 7) Lather, rinse, repeat :) Hope this helps to clear up some information. I got more answers to any questions anyone might have. Thanks again :) Patrick On Wed, 2005-08-10 at 16:41 -0400, Nathan Tobik wrote: > Can I ask why you are trying to write a script that from what I > understand goes to each box to retrieve the data instead of pushing the > data to the central db? > > You could write a little script in PHP that gathers the required > information and then does an insert into your database. Then from the > database you can create a webpage that is a view of all of your > machines. On the local machine you can schedule your script to run > every X minutes via crontab. > > If I misread your email and headed down the wrong path please let me > know. > > Nate Tobik > (412)661-5700 x206 > VigilantMinds > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
Richard Lynch wrote: On Wed, August 10, 2005 12:49 pm, Chris wrote: if ($extension != 'txt') { header("Content-disposition: inline; filename=\"$file[type]\""); } else { // force txt files to prevent XSS header("Content-disposition: attachment; filename=\"$file[type]\""); } The Content-disposition header is a made-up bull-crap thing that came about with "html enhanced" (cough, cough) email. If you want *EVERY* browser to download something, forget this header and use: header("Content-type: application/octet-stream"); The Content-disposition will, on *SOME* browsers, on *SOME* OSes appear to be useful for getting the filename in the dialog prompt for "Save As..." to be the filename you want. Unfortunately, it does *NOT* work universally. If you want a UNIVERSAL solution, make the URL look like it's a "static" URL and have the filename you want to be used appear at the end of the URL. Converting dynamic to static-looking URLs is covered in many places. Google for PHP $_SERVER PATHINFO Under no circumstances should you be using headers like "audio/mpeg" if you want me to download it -- I guarantee my browser will open that up in an MP3 player. Many other users will also have been led through the process to make that happen. But if the browser doesn't download "application/octet-stream" it's a very very very broken browser. if i don't use Content-disposition IE downloads the file as "unknown" (mp3, exe, or otherwise) with no extension and the names the file you are downloading becomes the name of the script that was called. lol? can never win with IE .. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php output to string
On Tue, August 9, 2005 2:55 pm, Jesús Fernández wrote: > Hi there, > i'm a little newbie you know. > I have a php that returns some xml, and i want to parse that xml through > php. the xml returned depends on the variable passed thru the url. what i > need is to get the output of that php file and store it in a string. i > have > tried everything i have though, readfile, include, file_get_contents even > eval. also i have tried with ob_start and so. but no luck. Try this: file_get_contents("http://example.com/yourfile.xml";); That will get you the exact same thing your browser would show 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] Regular expressions book
The best I found is: O'Reilly book - Mastering Regular Expressions On 8/3/05, -k. <[EMAIL PROTECTED]> wrote: > > Has anyone here tried to learn Regular expressions with RegexBuddy? > > http://www.regular-expressions.info/regexbuddy.html > > It looks pretty cool, and even has some PHP specific stuff, but you have > to pay to play. > > > > > -k. > > __ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] html_entity_decode () for …, ’, etc.
Richard Lynch wrote: On Wed, August 10, 2005 11:55 am, Marco wrote: I tried using html_entity_decode () but why won't these characters decode: ’ – … “ ” WILD GUESS: Those are not standards-based, and are some made-up Microsoft crap? Nah, they are standard HTML entities. Depending on your PHP version, you may like to try playing with the third parameter, perhaps setting it to "UTF-8". See the following URL for more information: http://www.php.net/html_entity_decode AFAIK multibyte encodings such as UTF-8 aren't supported by some PHP versions though. It may be a PHP 5 feature? Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gathering CPU info from Linux and FreeBSD and placing it into aMySQL db
On 8/10/05, Patrick - Jupiter Hosting <[EMAIL PROTECTED]> wrote: > Hi Nate, > > We are a hosting company. We use this Mambo-like CMS called CATS, which > pretty much tells us what company owns what server(s) in our data > centers. CATS will provide us with a list of details on the specs for > each machine they own, which include the specs I listed (memory, # of > cpus, etc.) Someone in our company deleted the table within the MySQL > db that listed our 400+ machines. Since IT is slammed with other tasks, > they have assigned me to this job. Sounds like you want Nagios. http://www.nagios.org/ -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rename an uploaded file.
On Tue, August 9, 2005 6:16 am, Stut wrote: > Colons (:) are not allowed in Windows filenames. Of course they aren't allowed in file NAMES -- Because they are an integral part of a drive letter designation such as "C:" which is what is being used here. There's nothing wrong with the C: part of the filenames. >> $old = 'C:\\homedirectory\uploadedfiles\\newfile.gif'; > > Also, you don't need to escape the backslashes when using single quotes. But you should. ' and \ are both special character sequences inside of '' $string = 'Don\'t you know \\ is not the same as /?'; \h (or anything other than ' or \ behind \) will "work" but is not Good Programming, imho. You can also, in some versions, "get away" with having \ inside of "" so long as the following character isn't special: $string = "C:\homedirectory\uploadedfiles\\newfile.gif"; Note that the 'n' character is special (newline) but 'h' and 'u' are not (I don't think) so this "should work" That doesn't make it Good Practice. -- 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[4]: [PHP] Restarting windows from php
Hello Richard, Wednesday, August 10, 2005, 9:40:02 PM, you wrote: RL> I dunno if YOUR Windows box has some cygwin thingie or something RL> that makes shutdown be a real command, or if it's just a RL> versioning issue, but the single test platform I had available RL> pretty much had no shutdown command. RL> Win 98 SE, I believe. RL> I've got XP on my laptop, and if I cared enough about Windows, I RL> guess I could test that too... ... and it would work. Yes of course it's version specific (NT range up, 2K, NT, XP, etc) Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services Zend Certified Engineer "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
> I never used this kind of functions before. What's wrong? In IIS for > "Execute Permissions" I have "Scripts and Executables". What > permissions should I set for the Internet Guest Account? Or something > else caused the problem, not the permissions? Please help me.:) On windows, php uses cmd.exe to do exec() stuff. IIRC< if your web server/php script is running as an underprivileged user (which it should be), it probably don't have read/exec access to cmd.exe. This is one possible cause of the fork error you mentioned. You can solve this by giving your php script access to cmd.exe, or copying cmd.exe into the directory that contains your php dll or exe. (you may have already done this, or this may be different in newer versions of windows -- I haven't had this issue in a while) Tyler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
On Wed, August 10, 2005 2:07 pm, Sebastian wrote: > if i don't use Content-disposition IE downloads the file as "unknown" > (mp3, exe, or otherwise) with no extension and the names the file you > are downloading becomes the name of the script that was called. lol? So here's what you do. Go ahead and RENAME your PHP script to "next_hit_song.mp3" Then use .htaccess to tell Apache that it's *REALLY* a PHP script even though it ends in .mp3 application/x-httpd-php That is what I mean by making the URL look "static" IE is so [bleeping] stupid about URLs and content-type and rich media, that you simply cannot give it any room for a mistake. Consider the MP3s and m3u s on the pages here: http://uncommonground.com/ http://uncommonground.com/artist_profile/Ellen+Rosner Every one of the MP3/m3u files you can find there is really a PHP script. They just happen to end in .mp3 and .m3u so IE can't [bleep] up. The dynamic MP3 downloads (and streams) have the MP3 ID3 tags inserted at download time, so the artists can correct typos or give me info like song title and whatnot lonnng after the actual mp3 is created, identified, and cataloged. The m3u playlists are coming out the database from queries with all kinds of "interesting" properties. New playlist every day on the homepage. Different playlist every download on the calendar pages: http://uncommonground.com/events.htm While you are there, check out that PDF. Yup. That ain't really a PDF, it's a PHP script. But even IE can't manage to screw up when the URL is http://uncommonground.com/events.pdf I do need to fix the ones where the date (past/future months) is passed as a GET argument. Some versions of IE on the Mac mess that up. Sigh. In my spare time. -- 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] Gathering CPU info from Linux and FreeBSD and placing it into aMySQL db
Hi Greg, Thanks for the link, although I don't think this is exactly what I am looking for. I am looking for a rather simple way to automate the ssh into each box and gathering of the system information, instead of monitoring the servers. This is going to be a one time operation, as once we gather all the information, regular backups will (finally) be made so this won't happen again in the future. With this now being my 2nd week into the job, I'm learning that the new people who just joined the company are replacing the rather unorganized people who have thrown us into this rut. Thanks again for the link (that's a rather cool piece of software!), but I think I'm looking for something a tad more simple. Got any more links to throw at me? :) Patrick On Wed, 2005-08-10 at 16:13 -0500, Greg Donald wrote: > On 8/10/05, Patrick - Jupiter Hosting <[EMAIL PROTECTED]> wrote: > > Hi Nate, > > > > We are a hosting company. We use this Mambo-like CMS called CATS, which > > pretty much tells us what company owns what server(s) in our data > > centers. CATS will provide us with a list of details on the specs for > > each machine they own, which include the specs I listed (memory, # of > > cpus, etc.) Someone in our company deleted the table within the MySQL > > db that listed our 400+ machines. Since IT is slammed with other tasks, > > they have assigned me to this job. > > Sounds like you want Nagios. > > http://www.nagios.org/ > > > -- > Greg Donald > Zend Certified Engineer > MySQL Core Certification > http://destiney.com/ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gathering CPU info from Linux and FreeBSD and placing it into aMySQL db
On Wed, 2005-08-10 at 19:07, Patrick - Jupiter Hosting wrote: > Hi Greg, > > Thanks for the link, although I don't think this is exactly what I am > looking for. I am looking for a rather simple way to automate the ssh > into each box and gathering of the system information, instead of > monitoring the servers. This is going to be a one time operation, as > once we gather all the information, regular backups will (finally) be > made so this won't happen again in the future. > > With this now being my 2nd week into the job, I'm learning that the new > people who just joined the company are replacing the rather unorganized > people who have thrown us into this rut. > > Thanks again for the link (that's a rather cool piece of software!), but > I think I'm looking for something a tad more simple. Got any more links > to throw at me? :) You might try an "expect" script and call it from 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
[PHP] Redisplaying information from a HTML form
Hi there I'm absolutely new at this so forgive me if none of it makes any sense! I'm trying to write a page which lets you apply for tickets. I've written it in PHP and used simple variable names for all the input fields. Upon clicking submit, I want the form to be checked for incorrect formats and blank fields. I've managed to write the checking program in such a way that clicking submit launches an 'error' page which displays at the top of the page which field is wrong, and then redisplays the form. (The form redisplay is done using a function which uses the variables I used in the HTML form page). My problem is this: when the 'error' page comes up all of the text boxes will quite happily redisplay the data that was put into them, but I have a couple of drop-down boxes and radio buttons which lose their value. Is there a way I can make these boxes and buttons retain their value? Thanks Ravi Gogna -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restarting windows from php
Richard Lynch wrote: On Wed, August 10, 2005 7:05 am, Karl-Heinz Christian Zeck wrote: Does anyone have any idea how to restart windows from a php script? ... SSL, password protected, maybe even have the script record a time-stamp when it's run, and refuse to run itself more often than 3 times in one 24-hour period. but Richard, if it's only able to do it once every 8 hours how do you expect him to run a stable machine? ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic object instances
Thomas Angst wrote: Hello List, I would like to create an object inside a function with its classname and a parameter list submitted by the function call. function create($class, $parameter) { $obj = new $class($parameter); return $obj; } This is working very well. But I have not every time the same count of parameters for a class constructor. If this is a normal method call of an object I can realise it like this: $ret = call_user_func_array(array(&$obj, 'method'), $parameter_array); The $parameter_array contains as many entries as the function needs. Works well too. But how can I write a function to instance objects with various count of parameters in the constructor? I know, can do this with an eval. But I would like to find a solution where I don't need an eval. to keep it easy have your ctors be able to except an assoc array as the first argument as an alternative to its normal arg list - or just use an assoc array period - that combined with a call to expand() in the ctor. then... something like: function create($class, $params) { if (!class_exists($class)) { return null; } return new $class( $params ); } btw if your on php4 your probably what to be using lots of f'ing '&' signs. alternatively it's either: 1. use eval() - yuck 2. make all your objects have empty ctors and force them to have an _init() method that actually does the work e.g. function create($class) { if (!class_exists($class)) { return null; } $params = func_get_args(); $params = array_slice($params, 1); $o = new $class(); call_user_func_array(array($o, '_init'), $params); return $o; } 3. re-evaluate what you are trying to achieve with the create function. maybe you need a factory base class instead? (for instance) thanks for all answers, Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what should I look for with this error
John Nichel wrote: Bruce Gilbert wrote: Your heredoc is messed up. Look into getting an editor which will highlight the errors for you. This mailing list isn't here to syntax check (unless it's 4:30 on a Friday). can we hold you to that John ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] N/A
Rory Browne wrote: As Ireland's property developers scramble to snap up every last square metre of prime Dublin real estate, a green oasis in the heart of this booming capital is standing firm against the tide of change. fantastic Rory! lol All this may seem highly irrelevent, but when you have a N/A subject, then anything is in. Consider yourself lucky, that Jay, and Jasper, gave your question enough seriousness to direct you to the manual. Personally I would have simply directed you to ESR's essay on Smart Questions(available from John Nichels response) On 8/9/05, R. Ragunathan <[EMAIL PROTECTED]> wrote: hi, can we implement postgres transactions with php. if anyone knows the solution please reply back. -- 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
Re: [PHP] Re: dynamic object instances
Thomas Angst wrote: > Thanks for you answer, but sorry, I do not understand your hint. I tried > this code: > class test { >var $txt; >function test($txt) { $this->txt = $txt; } >function out() { echo $this->txt; } > } > $obj = call_user_func_array(array('test', 'test'), array('foobar')); > $obj->out(); > But I'm getting an error while accessing the $this pointer in the > constructor. This will not work, since it is like calling a static class method, and $this is not allowed to be used in static methods. I solved this with eval() function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic object instances
Eli wrote: Thomas Angst wrote: > Thanks for you answer, but sorry, I do not understand your hint. I tried > this code: > class test { >var $txt; >function test($txt) { $this->txt = $txt; } >function out() { echo $this->txt; } > } > $obj = call_user_func_array(array('test', 'test'), array('foobar')); > $obj->out(); > But I'm getting an error while accessing the $this pointer in the > constructor. This will not work, since it is like calling a static class method, and $this is not allowed to be used in static methods. I solved this with eval() function. I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil - eval :-) - besides eval is very slow - not something you (well me then) want to use in a function dedicated to object creation which is comparatively slow anyway (try comparing the speed of cloning and creating objects in php5 for instance regardless - nice one for posting this Eli - I recommend anyone who doesn't understand what he wrote to go and figure it out, good learning material :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redisplaying information from a HTML form
Ravi Gogna wrote: Hi there I'm absolutely new at this so forgive me if none of it makes any sense! I'm trying to write a page which lets you apply for tickets. I've written it in PHP and used simple variable names for all the input fields. Upon clicking submit, I want the form to be checked for incorrect formats and blank fields. I've managed to write the checking program in such a way that clicking submit launches an 'error' page which displays at the top of the page which field is wrong, and then redisplays the form. (The form redisplay is done using a function which uses the variables I used in the HTML form page). My problem is this: when the 'error' page comes up all of the text boxes will quite happily redisplay the data that was put into them, but I have a couple of drop-down boxes and radio buttons which lose their value. Is there a way I can make these boxes and buttons retain their value? short answer: yes. longer answer: either generate some javascript to set the correct option or when/if you use php to 'build' the selectboxes add the string ' selected="selected"' to the HTML of the option that should be selected, for checkboxes you would add the string ' checked="checked"' to the relevant radiobuttons (or checkboxes). Thanks Ravi Gogna -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display error line in object method
On 8/10/05, Georgi Ivanov <[EMAIL PROTECTED]> wrote: > Hi, > I have a db wrapper class. > I use it like this : > $db->query"(SQL HERE") or die ($db->error()); > Is there a way to display the line on which $db->error() is executed without > doing die (__LINE__." ".$db->error() )? http://us3.php.net/debug_backtrace Wouldn't that work? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic object instances
Jochem Maas wrote: Eli wrote: I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil - eval :-) - besides eval is very slow - not something you (well me then) want to use in a function dedicated to object creation which is comparatively slow anyway (try comparing the speed of cloning and creating objects in php5 for instance regardless - nice one for posting this Eli - I recommend anyone who doesn't understand what he wrote to go and figure it out, good learning material :-) You're right that using eval() slows.. But using the _init() function as you suggested is actually tricking in a way you move the constructor params to another function, but the initialization params should be sent to the constructor! I guess that it would be better if PHP will add a possibility to construct a dynamic class with variant number of params... ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How efficient is OOP in PHP5?
Hi all, I have heard that "function style is 400% faster than OOP in PHP", and give a little agreement. So in the past year, I write more PHP code in function way while less in OOP way. This morning, I read an article called "How efficient is OOP in PHP" according to the author's test, writing PHP code in procedural way(functions) is 200%+ faster than OOP way. But this article is written in 2003, now, I am using PHP5, how about the performance of OOP in PHP5? Could any one give me more efficient references? Any suggestion or help will be greatly appreciated. Qin Jianxiang -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets and SOAP
Hi, I want to implement a client-server relationship between a PHP server application and another .NET client application. I want the connection to be kept alive, so I use the socket routine running till disconnecting. I also want to transfer the data between the server and client using SOAP envelopes. How can I send SOAP envelopes (requests & responses) through the same socket? If it's not possible with PHP's SOAP library, is it possible with other SOAP library for PHP (such PEAR:SOAP)? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date field
I have a field 'updated' How can I tell if the date is older than 1 year ago (or should I think of 365 days)? `updated` date NOT NULL default '1999-12-12' I've looked at: http://ca3.php.net/manual/en/function.getdate.php Thanks, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date field
John Taylor-Johnston wrote: I have a field 'updated' How can I tell if the date is older than 1 year ago (or should I think of 365 days)? `updated` date NOT NULL default '1999-12-12' From the description you gave it looks like you're using a DBMS to store the date. If it's MySQL, then just do an SQL query with a WHERE clause like this: WHERE updated > DATE_SUB(NOW(), INTERVAL 1 YEAR) Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: date field
In PHP, you could do something like: $updated = strtotime($db_result['updated']); $one_year_ago = strtotime('-1 year'); if ($updated < $one_year_ago) { // updated date is older than a year ago } John Taylor-Johnston wrote: I have a field 'updated' How can I tell if the date is older than 1 year ago (or should I think of 365 days)? `updated` date NOT NULL default '1999-12-12' I've looked at: http://ca3.php.net/manual/en/function.getdate.php Thanks, John -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP GD and Unicode
Im doing a job that creates a business card that has double sided cards on it. - front side; is plain english - back side; is the desired languages I have been successfull with the japanese fonts displaying as an image (jpeg), that has the fonts in it. Now im trying the Arabic, Hebrew, Chinese. And i have no luck. Even if i try the aria.ttf font which supports.. *Unicode ranges*Basic Latin, Latin-1 Supplement, Latin Extended-A, Greek and > Coptic, Cyrillic, Cyrillic Supplementary, Hebrew, Reserved for Unicode > SubRanges, Arabic, Reserved for Unicode SubRanges, Arabic Presentation > Forms-A, Arabic Presentation Forms-B http://www.microsoft.com/typography/fonts/font.aspx?FID=8&FNAME=Arial > As described on the fonts info on this page. It displays fine on the browser if i set the correct charset ex: > > But when i try it on a image, that has been created with GD. It does nothing. I just want to confirm, it what im doing with the fonts possible thru GD/Jpeg? Please help, if this aint possible. I think imight purchase the PDFLib instead to test the unicode support. -- Louie Miranda http://www.axishift.com -- under development