Re: [PHP] Preserving URL after redirect?
Richard Heyes wrote: So, my question is how would I do that, and I strongly suspect if it's possible at all an .htaccess file with the proper entries would be the way to do it, not using PHP code to redirect as I am now. Is this the case? You would need to use mod_rewrite. You might also be able to get this to work by changing the include_path and creating a special "loader" script in their folder. define('INCLUDE_PATH', ''); ini_set("include_path", INCLUDE_PATH); That way the application includes would still work if you didn't specify absolute paths... I have a few scripts that use the include_path, and they look something like: That way I just have the initial call to set the include path, and I don't have to worry about it anymore. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CVS Scripts
Eric Butera wrote: On Thu, Mar 6, 2008 at 10:58 AM, Adrian Walls <[EMAIL PROTECTED]> wrote: Firstly thanks for a sensible reply. I am using Zend Studio Server and I haven't upgraded to Zend Studio for Eclipse as yet. It also has some CVS capability not its not what I am after. Google was my first stop but it didn't turn up anything which appeared to be in a stable enough state. Hence my email to the list to see if anyone else had come across such a solution. My application is built from several modules contained with cvs. Some of these modules are used across projects. I wanted to create my own web-based script to check these out of cvs and to build and configure the application on the fly. I had a look at cruisecontrol but its not really what I am looking for either. Adrian. -Original Message- From: Wolf [mailto:[EMAIL PROTECTED] Sent: 06 March 2008 15:42 To: Adrian Walls Cc: 'Eric Butera'; php-general@lists.php.net Subject: RE: [PHP] CVS Scripts Adrian Walls <[EMAIL PROTECTED]> wrote: > 1. It is a legal thing, whether it means anything or not or regardless of > what anyone else's take is on it. > > 2. It was a straight forward question I asked. I guess it was my mistake > for thinking this was a place to ask questions rather than somewhere to take > the p*ss. I'll not make the same mistake again. > We're a bunch of helpful and flippant sods on this list, so take the criticism as constructive (trim your own sig file down and remove the white space and see if you can NOT send the confidentiality notices when broadcast mailing). As for automatic CVS via PHP, it depends on your take on it... Eclipse has a CVS piece to it which seems to work well (I've installed it, but most of my stuff is layered and I don't have a reason for CVS), though someone also posted about cruisecontrol on the sourceforge site. What have you found and tried via a google search? Wolf Maybe look at Phing[1]? Skimming over the docs (I know you said you use CVS) I saw a task you can define to check files out form SVN. There might be a cvs one somewhere or you could extend it and write your own. [1] http://phing.info/ Another option would be to write your own. If your requirements are super specific, then that might be the best route. I can't imagine it would be too difficult. You can use shell_exec to execute the CVS checkout, and any other CVS command necessary. Don't forget to use escapeshellcmd() either: http://us3.php.net/manual/en/function.escapeshellcmd.php After it's checked out, then you can use shell_exec() again to run the compile command. If it takes a long time, you might be best just sending the command to the output so you can copy and paste and run it yourself, or just make sure you set_time_limit(0), or some amount of time it should finish compiling in. I assume it's an internal app, so you wouldn't have to worry too much about it looking pretty or any of the other time consuming operations. $cmd = escapeshellcmd('/usr/bin/cvs -d :ext:[EMAIL PROTECTED]:/.../cvsroot checkout module'); $output = shell_exec($cmd); // do something with output if you need $cmd = escapeshellcmd('/path/to/module/configure'); $output = shell_exec($cmd); echo "done!"; ?> Something like that anyway. That's overly simplified of course, but it should get you a start if you want to write it yourself. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CVS Scripts
Wolf wrote: I am using Zend Studio Server and I haven't upgraded to Zend Studio for Eclipse as yet. It also has some CVS capability not its not what I am after. Google was my first stop but it didn't turn up anything which appeared to be in a stable enough state. Hence my email to the list to see if anyone else had come across such a solution. My application is built from several modules contained with cvs. Some of these modules are used across projects. I wanted to create my own web-based script to check these out of cvs and to build and configure the application on the fly. I had a look at cruisecontrol but its not really what I am looking for either. You're probably going to have to code that sucker on your own and slide it in as a cron job on your build server to get the latest/greatest whenever needed. I haven't come across anything like it before, but I definitely like the concept. Wolf I had an idea to tie a ticket system with SVN. Each ticket would be associated to a change in the code. In the ticket system you put in the different revisions that were checked in for that ticket. Then when you go to "promote" the ticket for testing, it'll check and make sure that there were no conflicting changes and merge it if possible to the next branch. The details are a little fuzzy after a few months of not thinking about it. The XML output from SVN would come in quite handy at that point though. It would have been cool, but it would have been complicated. We didn't have the time to work on it. I think Trac is somewhat similar. PS. sorry for the thread hijack :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Transferring files between computers using php
Rahul wrote: Zareef Ahmed wrote: On 3/7/08, Rahul <[EMAIL PROTECTED]> wrote: Thank you all so much for replying... I guess I was very vague in describing the situation. I will write in detail: I have three computers A, B and C. To login to B and C I should use A because it has a SSH key. I don't have any other way of accessing these two computers. Now, if I need to transfer a file between B and C, I am unable to find a way that would work... because I don't know how to authenticate without SSH keys... I was gathering some data in B and C using PHP. Now, I need these two computers to coordinate a little and didn't want to use a server in between and so I was thinking of establishing a direct connection between them.. If you have ruled out web server and ssh, then you can use ftp using PHP or use NFS mounting. Zareef Ahmed wrote: On 3/7/08, Shawn McKenzie <[EMAIL PROTECTED]> wrote: Rahul wrote: I have a small file to be transferred between two computers every few seconds. I'm using unix with a bare bones version of php, i.e. just the original thing that gets installed when I run "yum install php". As there is no webserver on any of these machines, I was wondering if there is a way to transfer a small file between them and if there is, could someone be kind enough to provide me with an example please? Thank You FYI... If you're using yum I assume it's a Linux machine (maybe Fedora) and not Unix. If you want to use rsync and scp in a cronjob (for continuous transfer at a predefined interval), you may need to set your server (read ssh) to accept connection without password. Ref : http://linuxproblem.org/art_9.html BUT If you really want to do that from PHP, you can install a web server and enable http as your stream for opening files. (In php.ini) You can read the file using fopen or any other file functions, then can write that file to the server on which script will be running, then you can set this script as your cron job. For example : $filecontents=file_get_contents("http://firstserver/file.txt";); $fp=fopen("path to local file", "mode"); Now use $fiiecontents to write the file using $fp resource. BUT remember, using rsync is always a better solution, and file_get_contents and file functions are resource hungry, specially they will consume more memory of your system. -- 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 Well I haven't ruled our webserver and ssh but I don't have much options. Number 1 is that I have many such computers and I don't think I can afford to install a webserver on all of them atleast. And coming to SSH, I can't use it because of the scenario that I explained. Please let me know if you have any other advice. Thank You I second the NFS mounting. You can share a directory somewhere on computer A. Then computers B and C connect to it. That way with PHP you just copy the file to the shares, and computers B and C automatically see the file there. Outside of that FTP might work well for you. Maybe even SCP, since you already have the keys on server A (as long as you don't have a password when connecting to B or C). rsync can work over SSH as well, and you could create a simple script to run rsync as often as you need. haha, I guess that's not exactly seconding NFS, more seconding not transferring files over HTTP. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SMTP
Alain Roger wrote: Hi, i know that this is not necessary the best forum for that, but i need to get a real feedback and i guess you already faced the same issue as mine. basically, i develop php web application on windows XP platform. So i have apache 2.24 installed and PHP 5.2.4. now i would like to test if my application send emails, so i've checked my php.ini file and it seems ok. i tried to use IIS from windows to define a default SMTP server, but as my emails are not sent, i guess something is wrong with IIS. so does it exist a free SMTP server (similar that linux daemon) but running on windows XP ? if yes, where can i find it and what steps should i perform to be sure my emails are sent ? i do not want to transfer all my web application each time i want to test email sending... i would like to test it locally. thanks for your feedback. I could be wrong, but I thought that you had to specify the SMTP server in the php.ini file. http://us2.php.net/manual/en/ref.mail.php#ini.smtp > now i would like to test if my application send emails, so i've checked my > php.ini file and it seems ok. Maybe that means you already did that. The second issue might be that your SMTP server is MS Exchange, and it requires authentication. If that is the case, then search for php SMTP authentication: http://www.google.com/search?q=php+smtp+authentication&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unexcepted $this
Murat BEŞER wrote: I can't under stood but PHP gaves me an error: "UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' " When I removed jpg extension check it's okay... PHP script runs well. What is the problem :) public function loadImages($folder) { $result = $this->filemanager->fecthFiles($folder); $images = array(); if (sizeof($result)>=1 && $result !== false) { foreach ($result as $file) { if ($this->getFileExtension($file) == 'gif' || $this->getFileExtension($file) == 'png' || $this->getFileExtension($file) == 'jpg') { $images[] = array('name'=>$file); } } } return $images; } Try storing the value in a variable first. It'll also have the side-effect of being marginally faster too. $extension = $this->getFileExtension($file); if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') { // do something } That might help, but I would think that the way you had it would also work. Let us know what happens when you use the variable like I showed above. Thanks, -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unexcepted $this
Philip Thompson wrote: On Mar 10, 2008, at 8:32 AM, Ray Hauge wrote: Murat BEŞER wrote: I can't under stood but PHP gaves me an error: "UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' " When I removed jpg extension check it's okay... PHP script runs well. What is the problem :) public function loadImages($folder) { $result = $this->filemanager->fecthFiles($folder); $images = array(); if (sizeof($result)>=1 && $result !== false) { foreach ($result as $file) { if ($this->getFileExtension($file) == 'gif' || $this->getFileExtension($file) == 'png' || $this->getFileExtension($file) == 'jpg') { $images[] = array('name'=>$file); } } } return $images; } Try storing the value in a variable first. It'll also have the side-effect of being marginally faster too. Good call. $extension = $this->getFileExtension($file); if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') { Correction: ... $extension == 'png' ... Personally, I like the in_array() version better - it cleaner and you can expand upon it more more easily. $extensions = array('gif, 'png', 'jpg' [, 'm4a'[, 'etc']]); if (in_array($extension, $extensions)) { ... } // do something } That might help, but I would think that the way you had it would also work. Let us know what happens when you use the variable like I showed above. Thanks, -- Ray Hauge HTH, ~Philip "Personally, most of my web applications do not have to factor 13.7 billion years of space drift in to the calculations, so PHP's rand function has been great for me..." ~S. Johnson Thanks for the catch. I work from home and I hadn't had my coffee yet in the morning. I usually check my news and email right after I get up and before I go to work :) I have been starting to use in_array more often as well. Far too many times I'll have to go back and add more options later, then the IF statement gets huge. Someday I'll kick the habit for good though. Oh, it might also be a bit easier to store the acceptable extensions in an array before the IF statement $ext = $this->getFileExtension($file); $acceptableExtensions = array('png', 'gif', 'jpg'); if ( in_array($ext, $acceptableExtensions) ) { // do something } That way the conditional doesn't grow as more and more values get added. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV speed
Wolf wrote: Danny Brow wrote: I have about 10 csv files I need to open to access data. It takes a lot of time to search each file for the values I need. Would it be best to just dump all the cvs files to an SQL db and then just grab what I need from there? I'm starting to think it would make a lot of sense. What do you guys think? Thanks, Dan Dan, I can tell you that depending on the size of your files is going to dictate the route you want to go. I have a CSV with 568,000+ lines with 19 different pieces to each line. The files are around 180M apiece and it takes my server about 2 seconds to run a system grep against the files. I can run a recursive call 7 times against a MySQL database with the same information and it takes it about 4 seconds. IF you have system call ability, a grep wouldn't be bad, otherwise I'd suggest loading the csv files into MySQL tables and checking them for the information, then dropping the tables when you get the next files. You can backup the databases such as a cron job overnight even. HTH, Wolf If you do go the MySQL route, MySQL can import CSV files natively, and it'll be a lot faster than doing it through PHP. Just look up the syntax for the LOAD DATA INFILE command... or look here. http://dev.mysql.com/doc/refman/5.1/en/load-data.html Here's an example: LOAD DATA LOCAL INFILE '/importfile.csv' INTO TABLE test_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1, filed2, field3); I've had to do imports of a million or more records from CSV files, and PHP is a lot slower than MySQL at importing them :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] setcookie
Wolf wrote: Tim Daff wrote: Hi, I am learning PHP, I am trying to set a simple cookie: Cookies Firefox is returning this error: Warning: Cannot modify header information - headers already sent by (output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in /Users/Daff/Sites/php_sandbox/cookies.php on line 7 I have googled this and can't find out what I am doing wrong. Any help you could give me would be much appreciated. Tim Cookies Cookies HAVE to be at the top of the page... You output ANYTHING else and you get the error you wound up getting. Wolf If you're not sure if data has already been sent to the client (I ran into an included file having a space after >?) you can use http://us3.php.net/manual/en/function.headers-sent.php before you call setcookie(); If nothing else it'll help with diagnosing this error when you run into it again. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Quick Reminder....
Jason Pruim wrote: On Mar 12, 2008, at 11:06 AM, Daniel Brown wrote: On Wed, Mar 12, 2008 at 11:01 AM, TG <[EMAIL PROTECTED]> wrote: How about something OT that we can argue about... driving on the left side of the road versus the right side. How does your country compare? Here in Pennsyltucky, a lot of people drive on the left, despite the fact that the whole US is supposed to drive on the right. It usually doesn't turn out very good. .:shakes head, solemnly:. Not very good at all. Up here in the great big hand (Michigan for those who don't know) during the winter we have so much snow on the ground that you just kind of drive where ever looks like road... Even if it means you have people passing on your right going the opposite way. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] I'm in Fargo, North Dakota (the "that's a state?" state). We experience very much the same thing. Especially on the side roads that don't get cleared as well. You just have to make sure that you don't run into each other and you're good. As far as replies, I like bottom posting because it keeps the conversation flow more in tact. GMail does a good job regardless of bottom or top posting though. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's wrong the __autoload()?
Greg Donald wrote: On 3/12/08, Robert Cummings <[EMAIL PROTECTED]> wrote: Just because someone got a flashy new toy doesn't mean I want it. I've got better things to do than play with flashy toys for the mere purpose of playing with flashy toys. I like to use tools that get jobs done. Translation: I'm too lazy to learn anything new since I already know PHP. Languages come and go. There's a reason why we no longer need a cgi-bin and Perl to make an animated gif. Going further, who the hell even uses animated gifs any more? Ummm, I originally looked into Ruby and RoR because someone spouted off "better" and "easier". After reviewing, looking at the language, trying some code, reading other peoples blogs, magazine articles, searching the web... I decided, using the brain I've been nurturing since I was a fetus, that I preferred PHP. Great, just so long as we're clear on the point that Ruby is better than PHP, just not for you personally. I'm totally fine with leaving the discussion at the "differently preferred opinion" level. Sounds like a cop-out but I'm ok with your holding that position all the same. But then who would confront your rhetoric and propaganda? I do exhibit a bit of rhetoric at times, but in my defense it came standard with my inquisitive mind. Conversely I do not know what propaganda you speak of. I've never once made a specific claim in favor of Ruby that I couldn't back up with example code. You're assuming that we choose PHP over RoR based on having seen a 5 minute tutorial. Wow, aren't you just full of assumptions. Ok then, how many projects did you pursue before giving up and concluding Rails or Ruby was too much effort to learn? URL? I will point out it's probably a good thing this same lack of effort on your part did not occur when you began to learn PHP, otherwise we wouldn't even be having this discussion. Interestingly, laziness is one of the biggest motivators of innovation. Do more with less. Well that sure as hell ain't PHP. ROFL. More with less, using PHP, hilarious. /me points to SPL and laughs his ass off That SHOULD be part of any developers mandate... but not blindly. If by blindly you mean fun, fast, test-driven, productive development, then yeah I guess so. I didn't want to have to do this, but read some of Terry Chay's work on Ruby. There are plenty of people who just prefer PHP to RoR. Some people like Java, some people like .NET, etc. Get over yourself. You come to a PHP mailing list to proclaim that RoR is better? What did you expect? It's people like you that turn a lot of people off to Ruby. The community is insane! This was a great read. If nothing else he's funny. http://terrychay.com/blog/article/php-ruby-evil-good.shtml -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's wrong the __autoload()?
Ray Hauge wrote: Greg Donald wrote: On 3/12/08, Robert Cummings <[EMAIL PROTECTED]> wrote: Just because someone got a flashy new toy doesn't mean I want it. I've got better things to do than play with flashy toys for the mere purpose of playing with flashy toys. I like to use tools that get jobs done. Translation: I'm too lazy to learn anything new since I already know PHP. Languages come and go. There's a reason why we no longer need a cgi-bin and Perl to make an animated gif. Going further, who the hell even uses animated gifs any more? Ummm, I originally looked into Ruby and RoR because someone spouted off "better" and "easier". After reviewing, looking at the language, trying some code, reading other peoples blogs, magazine articles, searching the web... I decided, using the brain I've been nurturing since I was a fetus, that I preferred PHP. Great, just so long as we're clear on the point that Ruby is better than PHP, just not for you personally. I'm totally fine with leaving the discussion at the "differently preferred opinion" level. Sounds like a cop-out but I'm ok with your holding that position all the same. But then who would confront your rhetoric and propaganda? I do exhibit a bit of rhetoric at times, but in my defense it came standard with my inquisitive mind. Conversely I do not know what propaganda you speak of. I've never once made a specific claim in favor of Ruby that I couldn't back up with example code. You're assuming that we choose PHP over RoR based on having seen a 5 minute tutorial. Wow, aren't you just full of assumptions. Ok then, how many projects did you pursue before giving up and concluding Rails or Ruby was too much effort to learn? URL? I will point out it's probably a good thing this same lack of effort on your part did not occur when you began to learn PHP, otherwise we wouldn't even be having this discussion. Interestingly, laziness is one of the biggest motivators of innovation. Do more with less. Well that sure as hell ain't PHP. ROFL. More with less, using PHP, hilarious. /me points to SPL and laughs his ass off That SHOULD be part of any developers mandate... but not blindly. If by blindly you mean fun, fast, test-driven, productive development, then yeah I guess so. I didn't want to have to do this, but read some of Terry Chay's work on Ruby. There are plenty of people who just prefer PHP to RoR. Some people like Java, some people like .NET, etc. Get over yourself. You come to a PHP mailing list to proclaim that RoR is better? What did you expect? It's people like you that turn a lot of people off to Ruby. The community is insane! This was a great read. If nothing else he's funny. http://terrychay.com/blog/article/php-ruby-evil-good.shtml One last link, because this one is the one that has caused the most "controversy" (for lack of a better word). http://terrychay.com/blog/article/is-ruby-the-dog-and-php-the-dogfood.shtml -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's wrong the __autoload()?
Greg Donald wrote: On 3/12/08, Ray Hauge <[EMAIL PROTECTED]> wrote: You come to a PHP mailing list to proclaim that RoR is better? No dumbass, I have already been here for a long time: This is my last post on this thread. It's obvious nobody is going to convince anyone else of their being right or wrong. The issue people are having is your attitude from about reply #2 from you on this thread. I just wanted to make that point clear. Trolling and being antagonistic doesn't get you anywhere. The point of this reply is I didn't say anything about how long you've been around here. The fact is you're still here, and we're talking PHP. I will give you that you weren't the first to submit an opinion of Ruby being the best or the worst. Your first reply was simply open minded, but then you got your feathers all ruffled when someone said they didn't like Ruby, albeit in a somewhat negative connotation. >> It's people like you that turn a lot of people off to Ruby. >I choose to use a language for a while before forming an opinion. I >certainly wouldn't let someone's opinion sway my own inquisitive >nature to have a go at it myself. The reason it turns people off is you have to work with the community as well as the language. If you want the project to get better, you need to be able to work with the community. I will admit that the PHP Internals list can get pretty heated as well, but those arguments are usually based on technical opinions and not religious fervor for the language*. * Note: I haven't read a whole lot on the Internals list, but based on summaries by PHP|Architect and other sources I have assumed my conclusion. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unexcepted $this
Eric Butera wrote: 2008/3/13 Anup Shukla <[EMAIL PROTECTED]>: Murat BEŞER wrote: > So what do you thing about on this thing ? > I really would like to figure out the problem. However, my simple script to mimic your code did not throw any errors. If you could provide some more details, maybe we can figure out the problem. -- Regards, Anup Shukla -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It could just be a special character in the code somewhere. Since pushing/pulling files happens across so many servers with different encodings it happens sometimes. On OSX there is a text editor named TextWrangler that has a feature called "Zap Gremlins" that I use to get rid of it when it happens. Would it be possible to post the code you have now to http://pastebin.com/ ? That might assist in locating odd characters if that's the case, though I'd think that your editor would display them as well. Usually an "Unexpected " means that you missed a parenthesis or curly brace, etc. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Objects as array key names??
Jim Lucas wrote: This question should probably be directed at the PHP Internals list, but I thought I would start by asking here first if anybody would even use this feature. It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an array. The examples that were shown to me make me think that this would be an awesome ability to have within PHP. Here is an example of how I would use such a feature. I have a table of "customers". I have a table customers "contact_locations". This table has a reference ID back to the "customers" table. Now, in my array of information that I build I have this. $res = query('Select c_id, c_first_name, c_last_name FROM customers'); $customers = array(); while ( $row = fetch_assoc($res) ) { $customers[$row]['contact_locations'] = array(); $SQL = "SELECT * FROM contact_locations WHERE c_id={$row['c_id']}"; $loc_res = query($SQL); while ( $loc_row = fetch_assoc($loc_res) ) { $customers[$row]['contact_locations'][] = $loc_row; } } Now, contained within one array "$customers" I have all the information that would be needed for displaying any type of information related to a customer or a customers location. By doing having this feature, I could build the ability to do xPath searches within the base array. That would be nice. Anyways, what do you all think? Worth it or not? Jim Lucas Maybe I don't get the new concept, but what would be wrong with: // START CODE // $cid = null; $customers = array(); while ( $row = fetch_assoc($res) ) { $cid = $row['cid']; $customers[$cid] = $row; $customers[$cid]['contact_locations'] = array(); $SQL = "SELECT * FROM contact_locations WHERE c_id={$cid}"; $loc_res = query($SQL); while ( $loc_row = fetch_assoc($loc_res) ) { $customers[$cid]['contact_locations'][] = $loc_row; } } // END CODE // Now you can easily reference all of your customers by ID and get any of the data you want. I would actually just load the record I want from the database and not chew up all that memory, but this is just an example anyway. I guess it could allow you to somewhat consolidate a two-dimensional array down to a single dimension. In order to use the data, you'd have to use array_keys() or something similar to use it though. It's an interesting idea, but I don't know how practical it would be. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Closures
I've been reading up on some of the parts of PHP that has been suggested could be improved so that I could be more well informed. One of the more "interesting" (for lack of a better word) suggestions is closures. I've used closures primarily in JavaScript, and they are handy in that context, but JavaScript handles events and other more dynamic situations like that. I can't really think of any good examples of why I'd want to use a closure instead of just calling functions or class methods in PHP. Variable functions and call_user_func*() have worked for any of the cases where I did need to be a bit more dynamic. I found a great summary of some discussion on the internals mailing list over here: http://devzone.zend.com/node/view/id/2013#Heading1 After reading that article through, I do like Wez's idea of how to create anonymous functions. The point about it causing confusion with people coming from other languages definitely applies though. This article also gives me a second idea for this post. How many people would want closures in PHP? In summary: Would you want closures in PHP, and why? -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closures
Nathan Nobbe wrote: if we were going to see support for anything anonymous that i would welcome it would be anonymous objects and the ability to create an object on the fly from an interface as per java 5. I'm not sure if this would solve your problem (my lack of java knowledge is showing), but you can create objects either by creating a new stdClass() object, or by using (object)NULL. Example: test1 = 1; $object->test2 = 2; echo $object->test1 . "\n"; echo $object->test2; ?> After trying to add a way to call a function from an object variable, I have come to the conclusion that it's kinda ugly. test = 2; $obj->myTestFunc = "myTestFunc"; function myTestFunc () { return "test"; } echo call_user_func($obj->myTestFunc) . $obj->test; ?> Does anyone have a link to some documentation about the stdClass? All I could find was a bunch of bug reports and other stuff that wasn't what I was looking for. I would have thought there'd be a page for it in the manual, but I didn't find one there either. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why use {} around vraiable?
Lamp Lists wrote: hi, I saw several times that some people use this $parameters = array( 'param1' => "{$_POST["param1"]}", 'param2' => "{$_POST["param2"]}" ); or $query = mysql_query("SELECT * FROM table1 WHERE id='{$session_id}'"); I would use: $parameters = array( 'param1' => $_POST["param1"], 'param2' => $_POST["param2"] ); and $query = mysql_query("SELECT * FROM table1 WHERE id=' ".$session_id." ' "); does it really matter? is there really difference or these are just two "styles"? thanks. -ll Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ The brackets are used to enforce that the entire contents between them is a variable. It helps when you're using class members. $example = "this is an {$example->text}"; It's also handy when you're putting variables in a heredoc. I would suggest not using "{$_POST["param1"]}", like you said. It's just going to make PHP figure out the string, then put the value in that string. If you really wanted to make sure it's a string type then you can do (string)$_POST['param1']. The short answer is you can do it the way you're doing and everything will work out just fine :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spider
tedd wrote: Hi gang: How do you spider a remote web site in php? I get the general idea, which is to take the root page, strip out the links and repeat the process on those links. But, what's the code? Does anyone have an example they can share or a direction for me to take? Also, is there a way to spider through a remote web site gathering directory permissions? I know there are applications, such as Site-sucker, that will travel a remote web site looking for anything that it can download and if found, do so. But is there a way to determine what the permissions are for those directories? If not, can one attempt to write a file and record the failures/successes (0777 directories)? What I am trying to do is to develop a way to test if a web site is secure or not. I'm not trying to develop evil code, but if it can be done then I want to know how. Thanks and Cheers, tedd Have a look at something like this: http://simplehtmldom.sourceforge.net/ I haven't used it, but if it works you should be able to pull up a list of all the tags quite easily through the DOM ala: foreach($dom->find('a') as $node) echo $node->href . ''; -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] google books
John Pillion wrote: Not a PHP question. but could someone point me in the direction of how to download/display only a portion of a PDF, much like google books does? For example, if you have a 200 page pdf, but the user wishes to see the portion that is on page 150. rather than downloading the entire PDF, only download/display page 150? I would like to avoid having to split them into 200 individual PDF's (whether manually or automatically). Any suggestions? - JP You could use FPDF and FPDI to just load up the one page: http://www.setasign.de/support/manuals/fpdi/ Just use importPage($thePageNumberYouWanted); $pdf = new fpdi('P', 'pt', 'letter'); $pdf->setSourceFile(self::PATH); $tpl = $pdf->ImportPage(1); $pdf->AddPage(); $pdf->useTemplate($tpl, 0, 0); $data = $pdf->buffer; $pdf->closeParsers(); header("Content-type: application/pdf"); header("Content-disposition: inline; filename=FileName.pdf"); header("Content-length: " . strlen($data)); echo $data; I just realized that the version of FPDI I've been using is a little old. There's a new update out, so some of the above code might change a little. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about linux editor
Sudhakar wrote: i need to connect to the linux server using an editor. can anyone suggest which would be an ideal linux editor to connect to the server. apart from the ip address, username and password are there any other details i would need to connect to the server. please advice. thanks. I also will typically use SSH + vi, but Zend Studio (not sure about Eclipse) can open an SSH connection and edit files that way. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates Again
Zoltán Németh wrote: VamVan írta: Hello All, I have a date in 2008-03-29 12:15:00 format. - How can I reduce one day from it? - How can I reduce one hour from it? - How can I add 1 hour to today's date? Thanks just convert it to a timestamp with strtotime() then you can manipulate it by adding/substracting - 86400 for a day - 3600 for an hour then convert back with strftime() http://hu.php.net/strtotime http://hu.php.net/strftime greets, Zoltán Németh I believe you can also use strtoime() http://us.php.net/manual/en/function.strtotime.php $time = strtotime($inputTime); $time = strtotime('-1 day', $time); $outputTime = strftime('%Y-%m%d', $time); I'm not sure which is more efficient, but it helps when you're looking for "next thursday" or other things like that. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] April Fools Easter Egg
Don't forget to check your phpinfo() page for the annual easter egg. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] April Fools Easter Egg
tedd wrote: At 9:23 AM -0500 4/1/08, Ray Hauge wrote: Don't forget to check your phpinfo() page for the annual easter egg. -- Ray Hauge www.primateapplications.com You got me. Cheers, tedd Here's the image that I see on PHP 5.1.0. My 5.2.5 site has a distorted image instead of the dog. 5.1.0: http://www.primateapplications.com/info.php.gif 5.2.5: http://www.primateapplications.com/info.php -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluating math without eval()
Jason Norwood-Young wrote: On Thu, 2008-04-10 at 13:15 +0100, Richard Heyes wrote: First post to this list! I'm trying to figure out how to evaluate a string with a mathematical expression and get a result, but without using eval() as I'm accepting user input into the string. I don't just want addition, subtraction, multiplication and division - I'd like to take advantage of other functions like ceil, floor etc. So the string "18-10" should give me 8, "ceil(1/2)*10" should be 10 (if my maths is correct) and the string "18-10;\r\nunlink('/var/www/*');" should not execute. If you can provide your users with distinct inputs (if it's a form) go that route. Thanks Richard Unfortunately it's not that simple. The equation sits in a DB and can be anything - eg. ((([valuation]/[purchaseprice])/100)*100)/[numyears] would be a typical field. [valuation], [purchaseprice] and [numyears] gets replaced by relevant fields from user-entered data. But the system is expandable which means I don't know what the equations, data or fields are going to be beforehand. I'm working on some kinda preg_replace function to sanitize the data at the moment and then run an eval - arg I hate regexp! Ideally eval would have some kind of sandboxing option, or you could limit the functions available in an eval. J you might be able to leverage a call to expr on a bash sell. Just replace the variables you're expecting with preg_replace or some similar function. http://hacktux.com/bashmath http://sysblogd.wordpress.com/2007/08/26/let-bash-do-the-math-doing-calculations-using-that-bash/ I'm not sure if that's any more secure than eval though. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Should This Newbie Learn From Dreamweaver?
revDAVE wrote: First of all - I know this is an entirely subjective question, and I know there's no single approach to learning this technology. I'm just looking for a few hints from seasoned professionals basically whether Dreamweaver verbose code (at least it looks like that to me at this beginning point) is all 'needed & necessary'... Like you said it's all subjective, but my opinion is to learn the basics first, then you can rely on your tools to take the mundane work out of the way for you. I'd still suggest using an editor with code completion though, because it will help you when you're trying to remember parameter orders or even function names to a point. After you feel comfortable with that, then you'll be able to understand what the program is doing for you and it won't be a "black box" that really is unsupportable. I find the best way to do that is to come up with some little program that you code up for fun to help get you through the learning stages. You'll learn more figuring out how to get something to work than just copying and pasting code. That's my 2 cents. Hope that helps. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] peer review (was php framework vs just php?)
Jay Blanchard wrote: I did a quick and dirty of just one of those functions. This function takes a table and creates a form based on the table. It needs quite a bit of refining, but I am willing to share and let you guys and gals throw suggestions; I use a very similar style of approach, but it's more on a field by field basis rather than a whole form. I also wrote mine on company time, so here's an example: 'first_name'); ?> UI::getBlankTextField($table, 'first_name'); ?> 'city'); ?> ?> 'state'); ?> 'state'); ?> 'zip'); ?> ?> The UI class figures out the max-length of the field, and there are also configurations to determine what type of field it is (text, phone, date, textarea, etc.) and security settings based on the user logged in. This has helped keep my template files very clean, and I still have full control over the form by not including the fields I don't want. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting iostat -x %b with php
What is the best way to extract just the drive load information (%b column) from "iostat -x" (on FreeBSD)? I imagine to exec() the "iostat -x" and then process the result with regex, but I am not sure if this is the best way - for instance, is %b is aways the Nth column in the returned value? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] creating an xls file from mysql data
Chris wrote: Richard Kurth wrote: This script will create an xls file from the data that is sent to it When I run this it only gets one recored and it is supposet to get all the records that are past by the $_POST[selectedcontactlist] I think I have a } in the wrong place but I can not figure it out anybody have a suggestion $_POST[selectedcontactlist]="3,45,65,23,12,4,56"; //this is a sample of what is past $ExplodeIt = explode(",",rtrim($_POST[selectedcontactlist],",")); $Count = count($ExplodeIt); for ($i=0; $i < $Count; $i++) { $sql = "SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]'"; Instead of doing that, do this: /** * This section makes sure the id's you are going to use in your query are actually integer id's. * If they aren't, you'll get an sql error. * */ $ids = array(); foreach ($_POST['selectedcontactlist'] as $id) { if (!is_int($id)) { continue; } $ids[] = $id; } // all posted values are duds? show an error. if (empty($ids)) { echo "No id's are numeric, try again"; exit; } $sql = "select * from contacts where id in (" . implode(',', $ids) . ")"; That'll get everything for all of those id's and then you can loop over it all once: // print out the header for the csv file here. // then loop over the results: while ($row = mysql_fetch_assoc($sql_result)) { // put it into file here. } // close the file // print it out. Or you can do it straight from MySQL, which is a lot faster: SELECT [fields] INTO OUTFILE '/path/to/file.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM [tables] WHERE [conditions] If you want a header row, then you can use a UNION statement. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
Sudhakar wrote: > i do not want > this to happen, if a user simply hits the spacebar and does not type > anything i should be able to display an alert message. From usability point of view such check will, in many cases, generate annoyance, and bring nothing. If I do not want to enter anything, and you "error me" to enter "something", I'll do like this - asdlöfjasdpoöfja spdfj as fsdaölkjf And your check is dead. If you want "something", you will get "something". It is hard (from usability point of view) to "validate" textarea to that extent, and especially - to get reasonable answers... I work for a scientific database, where all content providers are very intelligent, well educated and very disciplined, and the content editors still have hard time thinking how to guide the content provider so that they provide reasonable input. Your problem is not so much php related, but a usability and editorial one. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating using php
Sudhakar wrote: > if( strlen(trim($name) == 0 ) || !preg_match('/^[a-zA-Z ]+$/x', $name) ) > { > $error.="Name is blank or has special characters "; > } You have messed up the brackets. This - strlen(trim($name) == 0 ) should be - strlen(trim($name)) == 0 Then the script does what you want. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] the class as a namespace
Is there a notion of the class as a namespace? My understanding is that the namespaces are intended to help organize the classes in large projects (and are not perfect). Is it considered good style to use a class simply to box related functions? For instance, a class called "files", contains functions I need for dealing with files - and the instantiated object is _simply_ used to access these functions - the instantiated object is not a file in itself. Thus what I do is not $INSTANTIATED_OBJECT->save(), but $INSTANTIATED_OBJECT->save($file) (though I could do the first if I first, say, do $INSTANTIATED_OBJECT->file = $file. Accessing the functions using the scope resolution operator (::) avoids the need to instantiate an object, but does not allow the use of $this, and $this can be quite practical in order to group common logic into shared methods within the class and thus make the other methods smaller in terms of code (of course, one could use file::save, file::delete instead of $this->save and $this->delete, but it makes renaming objects more difficult). I would be interested to hear opinions. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install a newer version of php over an older version
Tony M wrote: > Can I install a newer version of php over an older version? Perhaps what you need is this - "Upgrading PHP with the Install To upgrade, run the installer either graphically or from the command line as normal. The installer will read your current install options, remove your old installation, and reinstall PHP with the same options as before. It is recommended that you use this method of keeping PHP updated instead of manually replacing the files in the installation directory." You can read it here - http://at.php.net/install.windows Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using SVN w/ Zend Studio for Eclipse
> I do not want to copy the project into a new > directory as the existing directory is where Apache's DocumentRoot is > set. And although that's simple to change, I really don't think any > IDE should mandate where I set my project's directory on the > filesystem. I use PDT, and there is no problem to import a project from its current location. It might take you a while to exactly figure out how to do it, Eclipse is a bit organic in respect to the organization and working of the menus. > Also, if I try to create a new project from an SVN > Repository, it doesn't allow me to select what directory I want the > code checked out in. This works very well with PDT and Subclipse. > Otherwise I'd just cringe and let it overwrite > what's in my existing document root, since that's all versioned code > anyhow. If your current document root is a checked out svn project, PDT/Subclipse will "see" this, no need to overwrite anything. > If any of you have run into similar frustrations, I'd love to hear it. > So far I've spent the better part of the evening fiddling with > extremely rudimentary features which no IDE in any programming > environment I've ever worked with has imposed on me. Perhaps this > thing isn't ready for mainstream yet, or perhaps I'm missing something > obvious. Again, I work with PDT/Subclipse. Eclipse is simply too organic compared to what you are used to. Just relax and give it a try and you'll love it. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the class as a namespace
Richard Heyes wrote: > That's a common use of static classes. Eg: > > HTTP::Redirect($url); > > In fact this (from the article I've read) is exactly how namespaces will > look like. So in the above example, HTTP could be either a namespace or > a class. Right. Namespaces do look similar. And PEAR employs similarly looking packages naming convention. So it seems the static classes (which are actually simply classes with static methods/properties, right) are the best "namespaces like" way, until the namespaces arrive. Thanks for your note, Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with internal data formats
John Gunther wrote: > What technique can I use to take an 8-byte double precision value, as > stored internally, and assign its value to a PHP float variable without > having the bytes misinterpreted as a character string. Does it get misinterpreted, or do you just want to be sure? The documentation says - "Some references to the type "double" may remain in the manual. Consider double the same as float; the two names exist only for historic reasons." Does this cover your case? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with internal data formats
John Gunther wrote: > Example: I extract the 8 bytes 40 58 FF 5C 28 F5 C2 8F from > an external file You mean you "extract" "40 58 FF 5C 28 F5 C2 8F", so to speak, as a string, right? Sorry, for asking, but somehow I do not the case. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] changing order of items
afan pasalic wrote: this one bugs me for a while. how to change order. I have a list of tasks. by status, task could be 1 (todo) or 0 (done) - status value stored in mysql. I can list tasks per status or all. order number is stored in mysql too. the easiest way to change order is to have form for each task where you will enter manually number and then submit (one submit button for whole form). but, if you change order number for any task you have to change then all order numbers "below" the task manually solution with "arrows" (or up/down buttons) where you click on arrow and the task switch the place with its "neighbor" is easy and fancy. Though, I get in trouble if, e.g. tasks 10, 11, 12, and 13 change status from 1 to 0 and I have to move task 14 to place 6. I have to click first 4 times (to switch places with tasks 13, 12, 11, and 10) - but nothing is actually happening on screen (of course) before start switching places with 9, 8, 7, and 6. how do you avoid this "gap"? what solution do you use at all? You have two different issues - a) how to execute the change, and b) what interface to provide. To execute the change, basically you have to reorder. The best algorithm is question of mathematics - you can implement "something" and improve it independently from the interface. As for the interface, the first is kind of the simplest, but somehow primitive. The second is a bit better, but you have noticed, not much better. The most elegant, considering the time we live in, would be drag & drop AJAX (here - http://tool-man.org/examples/, there are excellent examples, perhaps there are more). It's also a question if tasks really need to be reordered manually. If all tasks have a deadline, you might sort them by date. If some don't, you can provide them unsorted, until they get one. Sorting tasks by moving them up/down works when you have 25 tasks, but it does not work when you have 50, 100, 1 000 (if you are a team leader and have 5-7 people team) - in that case sort by date might be better. If you get more advanced, and store time needed to complete a task, you could automatically shift all tasks (of a person) - when one gets delayed or takes longer, than planned. Hope that helps, Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SCanning text of PDF documents
Angelo Zanetti wrote: Hi All. This is a quick question. A client of ours wants a solution that when a PDF document is uploaded that we use PHP to scan the documents contents and save it in a DB. I know you can do this with normal text documents using the file commands and functions. Is it possible with PDF documents? My feeling is NO, but perhaps someone will prove me wrong. Thanks in advance. Angelo Web: http://www.elemental.co.za One thing you'll have to watch is that if the PDF was created by a scanner, then the "text" on the PDF is actually just an image and cannot be read without OCR. I got stumped on that one for a while when I was doing something similar :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] changing order of items
Eric Butera wrote: I use this: http://developer.yahoo.com/yui/examples/dragdrop/dd-reorder.html Looks good. I still can't decide for one of these "big" libraries, prefer to use "small" things which I can fix/change, if the author does not have time or desire. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] changing order of items
afan pasalic wrote: > But, actually, I need something more simple. Nothing "fancy" :D. I thought so from the beginning, just thought - it does not hurt to show different possibilities. May be you will not implement it now, but when you know about it, it might give you ideas in future. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] changing order of items
Jason Murray wrote: I am assuming that each time you click the up or down arrow you are re-loading the page (via a GET request). A simple solution to this, would be to adjust the URLs assigned to the up and down arrows to carry an extra variable, the item either directly above or directly below the one selected, and instead of doing whole-sale renumbering, create a swap function. That just swaps the position of the two items. Very good idea. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about validation and sql injection
Hej Sudhakar, what a long e-mail ;) ! I would suggest you use e-mail address as user name. There are many good reasons why to do so, I will give you some, if you wish. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SetEnv directives in VirtualHost configuration not accessible in PHP
I had similar problem some time ago, and there was some solution, which I can't remember now. Do you still have the problem? I'll can have a look, if still needed. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML file locking
Kaja wrote: Does anyone know if any of the PHP 5 XML libraries use flock() internally? I'd like to use XMLReader and XMLWriter but I need to make sure theres no writing going on while reading and no more than one writer at time. And if I have to use DOM, does DOM lock the file when it calls save()? Or is there any xml library that allows you to pass in an already opened file stream ? Thanks. For such a low level question, I think you better ask on the developers list. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML file locking
bruce wrote: Couldn't you also create a rather simple test to determine if the locking of the file takes place? I personally do not trust file system level locks. Even if a software is not intended to be portable across operating systems, it is possible to use different file systems under the same operating system, and the rules might be different. Using file system level locks would require all possible file systems to be taken into account. And on top of that, the file systems are actively developed, so this is one more point to monitor, while maintaining the software. A less trouble free way is to create a file with the same name and extension ".locked" or similar, prior to read/write operations. Of course, this works only if the file is accessing only by one program, or if all programs accessing the file follow the same convention - but you should see that many file system level locks are advisory, as well. See this - http://en.wikipedia.org/wiki/File_locking -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Enterprise
I just read an interesting article about enterprise software. One of the most common arguments against PHP tends to be "It's not enterprise ready." This article talks more about ruby, but it could be about any "non-enterprise" language as well. http://lists.canonical.org/pipermail/kragen-tol/2005-April/000772.html I recently got a new job at a hospital, and the "enterprise software" they have is no where near as high quality as it could/should be. This is my first job at a somewhat large organization (500+ employees) so I was kind of shocked at the state of their software. Typically healthcare systems are further behind in the technology adoption, but having to deal with workarounds all day long sure gets old. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] use of static methods after namespaces arrive
In which situation would somebody use a static method, instead of a function in a namespace, after the namespaces arrive with 5.3? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT Smarty problem
Hi George, I tried your code and it works. If you have some way of remote assistance I can have a look "on-site", if you like. But it could be that you just need a good sleep, and then look again ;) Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT Smarty problem
Gabriel Sosa wrote: > try doing this.. > > {if $clearance eq 0} > > instead use == > > i saw that some version of smarty has a bug related to this issue > > BTW .. you could use the options helper [1] > > saludos > gabriel Right... I forgot to ask which Smarty version you have. I tried it with the last. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] use of static methods after namespaces arrive
Adam Richardson wrote: If the functionality doesn't conceptually promote the inclusion of the variables it works on (i.e., no class variables), doesn't conceptually fit a scheme where instances can exist, and likely won't benefit from refactoring into component methods, then I could see using a namespaced function. Here I would do the same. Most of the time, though, I'd probably start out with a class method instead of a namespaced function so I could more readily adapt to OOP practices if desired as the implementation evolves. Hm... Would you consider it safer to convert a static method into an instance method, than implementing a namespaced function into a (new) class and redirecting the calls? I am not starting a fight, I am really interested in what you think. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bulk Email Problems
Hi Andre, I am not sure I understand what is the problem. What does it mean - that worked fine for the last few years resulting in many requests for forgotten passwords and renewed site activity. And what does it mean - Last year, we sent it again, after a few minor code changes, and had no response whatsoever. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] class? package?
If you are designing with OO principles, could you give an explanation of what is the difference classes and packages? A class is a language construct, classes are processed/executed by php. A package is an architectural approach - this is how you combine your code/classes. When I was summarizing the OO principles, that question confused me: http://phparch.cn/index.php/php/43-php-advanced-programming/170-principles-of-object-oriented-design If you try to follow all these principles, it might take very long before you write even a line of code ;) Take what you understand and leave the rest for later. You will become better, but will never be perfect ;) Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] class? package?
Shelley wrote: Probably you have noticed this: The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all. If that's the case, then why not just use one class as one package? What's the point of splitting a package into several classes? :-( I think somebody already answered. It is actually up to you. My grandmother used to write letters starting with a capital letter, writing the whole letter as one long sentence and ending with a dot. This would perhaps confuse most high school teachers, but in her case it somehow worked :) If we take this worn out example - if you have a class "dog" and a class "cat" - it becomes quite clear why you need several classes. You can put them in a package called "animals" - but as other people already noted, the "packages" in php have only a symbolic role, just for clarity of code organization. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
hce wrote: Let me first describe the requirement more: The C program is a major business server I would not connect applications on low level. I would think of a "web services" type of interface - http request and xml response (Steven suggested, for example, SOAP - but it does not need to be that complicated). The has several benefits - a) Clearly defined, the "web services" gate will not be affected by changes in the C program. b) You can use the "web services" gate to plug not only your php application, but any other application that can (be made to) talk "web services". c) The implementation of the php application, in this case, will be trivial, resulting in cheaper developers/development/maintenance/expansion. (ii) What is the maximum number concurrent requests in a PHP web application? Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? Nobody can tell you this for your existing infrastructure. The only thing you can do is try and optimize. Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UK PHP Host/Developer Required
2. It's useful if the host company and the client keep the same office hours. If you have a hosting company with 9 to 5 office hours, you are dead, even if it is next door. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] class? package?
Shelley wrote: I am working on a sns site, and now my practice is grouping classes of a function "classes of a function"... perhaps "classes related to certain functionality"? (i. e. subscription) together. When I need it, just load the "package": subscription. Right? ;) Hm... I do not know your project, but to have many classes just to handle subscription, sounds a bit too much to me. Why don't you have a class called "subscription", which might even extend a class called "person" or "user" - the "subscription" class can have methods, for instance "subscribe" and "unsubscribe", and because "subscription" extends "person" or "user" - it already "knows" who is the "person"/"user". And then, for example, to subscribe a "person"/"user", you do - $subscription->subscribe($list_id); Other possible actions - $subscription->un_subscribe($list_id); $subscription->is_subscriber($list_id); $subscription->lists(); etc. This way class "subscription" "packs" the methods needed to handle subscription related activities, so in your own jargon, this "class" is a "package". Of course, if the subscription process is extremely complicated, you can have more classes. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF to images or something similar
Hi!. I need to create a pageflip magazine (you know, a flash magazine). My client ask me to do a little php program that convert a full pdf magazine into a pageflip magazine. My doubt is: It's possible with php to read a full pdf and make an image for each page? Thanks a lot. Ray. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UK PHP Host/Developer Required
Robin Vickery wrote: Out of hours technical support often gets billed at a punitive rate. Which is a bugger if their "out of hours" is your working day. It seems you haven't tried Rackspace (UK) yet. And while you might get tech support out of hours, accounts and billing usually keep normal office hours. True. But if you pay your bills on time, you will never talk to these. Iv PS I am NOT advocating that one should take hosting outside the UK. I do projects in Austria and I do have the hosting in the UK. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPMailer not working but Squirell mail works
Shiplu wrote: In my web server, I cant send mail by PHPMailer. What does this mean? Do you get an error message, etc.? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Canvas examples
Richard Heyes wrote: Does anyone have any more examples of the new canvas element they've written? FF only: http://www.phpguru.org/canvas.html This is a pretty interesting use of Canvas as well. Thanks for sharing! http://ejohn.org/blog/processingjs/ -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Canvas examples
Richard Heyes wrote: I guess the other browser doesn't do much with ? Nope. Eg: This gets shown on none supporting browsers, but not on supportive browsers. MSIE just shows the text and doesn't do anything with the canvas. One thing about using a canvas is bandwidth. If it's a big concern I would hazard a guess that a bar chart (for example) would cost less in terms of code required to build the image compared to JPGraph, and also less in terms of output (particularly if you were to use output compression). Another idea for dynamic graphing could be: http://solutoire.com/plotr/ It also uses the canvas element, but if you use excanvas for IE it'll work in most newer browsers. I've used it in a project to provide dynamic bar graphs from a queue so that they could see in semi-real time how many customer requests were in different queues. It was an internal app, or else I'd link it :( -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Separating words based on capital letter
Roman Neuhauser wrote: implode(' ', preg_split('~(?=[[:upper:]])~', 'FooBarBaz', -1, PREG_SPLIT_NO_EMPTY)); Or just.. preg_replace('/\B[A-Z]/', ' $0', 'FooBarBaz') Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: self:: vs this
M.Sokolewicz wrote: Basically what you can remember here is: :: calls a property or method in a STATIC context (ie. without access to the object's (if any) actual properties) -> calls a propert or method in a DYNAMIC context (ie. WITH access to that specific object's collection of methods and properties). While that's generally true, self::, parent::, ClassName:: and ParentClassName:: can all be used in both contexts when calling methods. Consider the following code: At first glance these all appear to be static method calls, but $this is available in every case. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and Ajax problem
Richard Kurth wrote: if(response.indexOf('|' != -1)) { Spot the misplaced bracket. if($_GET['takeaction']=="delete"){ $uid=$_GET['uid']; echo $uid; This is wide open to XSS attacks, you need to be just as careful with scripts intended to be accessed via javascript as you do with user facing scripts. If uid is as it sounds, an integer, then intval($_GET['uid']) will do nicely; otherwise at least use htmlentities() to prevent XSS. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing Spaces from Array Values
Jim Lucas wrote: foreach ( $someArray AS $k => $v ) { $someArray[$k] = preg_replace('!\s!', '', $v);// Removes white space ' ', \n, \r\n, etc... $someArray[$k] = str_replace(' ', '', $v);// Removes only spaces } str_replace() also operates on arrays so there's no need for the loop: $someArray = str_replace(' ', '', $someArray); And if you want to replace all whitespace: $space = array(' ', "\t", "\n", "\r", "\x0B", "\x0C"); $someArray = str_replace($space, '', $someArray); Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] magic quotes
Phil Princely wrote: What do people on this list usually do with this kind of problem. To me, the .htaccess seems the easiest solution, since I don't have to change any scripts. I would certainly turn it off in php.ini or apache config files if possible (the .htaccess line should be "php_flag magic_quotes_gpc off" by the way). However, if you end up doing it at runtime, then it's best to use Environment/magic_quotes_gpc_off.php in PHP_Compat. magic_quotes_gpc has been very inconsistent between PHP versions so a generic stripslashes_array() function is unwise. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] magic quotes
Phil Princely wrote: thanks for all the help. My code was wrong in the first post, I just copied it straight from the web. This one works: if (get_magic_quotes_gpc()) { stripslashes_array($_GET); stripslashes_array($_POST); stripslashes_array($_REQUEST); stripslashes_array($_COOKIE); } set_magic_quotes_runtime(0); set_magic_quotes_runtime() has no effect on magic_quotes_gpc. function stripslashes_array(&$arr) { foreach (array_keys($arr) as $k) { $arr[$k] = stripslashes($arr[$k]); } } This function breaks arrays, ignores keys, and takes into account none of PHP's inconsistencies with magic_quotes_gpc. As I said before, if you need to do it at runtime, use the PHP_Compat code. Here's the two relevant files, if you can't use the PEAR installer: http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/_magic_quotes_inputs.php?revision=1.3&view=markup http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/magic_quotes_gpc_off.php?revision=1.7&view=markup I tried searching for setini, but came up with nothing, except this: setIni('magic_quotes_gpc', 'Off', $inifile); // didn't work: unknown function ini_set() is probably what you're thinking of, but magic_quotes_gpc is applied before your script is executed so it will have no effect. That's why the only option at runtime is to reverse it. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expression and forbidden words
Nicolas Quirin wrote: Hi, i'm french, i'm using regular expressions in php in order to rewrite hyperlink tags in a specific way before apache output is beeing sent to client. Purpose is to replace href attribute of any A html tag by a javascript function calling an ajax loader. Currently I have wrote that: $pattern = '/(.*?)<\\/a>/i'; $replacement = '$5'; $html_mark = preg_replace($pattern, $replacement, $html_mark); it works, but it's too permissive, it replaces too much links (some links with some get parameters must stay unchanged) I don't really understand my pattern...it's a little strange for me...lol I wouldn't like to rewrite links that contains any of the following words in get parameters (query string): noLoader noLeftCol skipallbutpage skipservice i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or '.' examples: http://dev.netdoor.fr/index.php?page=./comptes/index.php&noLoader&noLeftCol&idx=6&bdx=423&skipservice";>test =>must be not rewritted! name =>must be rewritted like this : name Please help me...:0) best regards nicolas The key here is (?!) - the negative assertion, it should look something like this: $p = '#href="(?:\.|http://dev.netdoor.fr)/index\.php\?page=(?![^"]*(?:noLoader|noLeftCol|skipallbutpage|skipservice))([^"]*)">(.*?)#is'; $r = 'OnClick="javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$1\');">$2'; Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] repetition of tedious references
Olav Mørkrid wrote: consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three* times, which gets excessive and unreadable. is there any way to only have to write $_SERVER["HTTP_ACCEPT_LANGUAGE"] only once? You can use empty() to take one of them out, since "0" is presumably also not a desired input: $language = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? "*" : $_SERVER['HTTP_ACCEPT_LANGUAGE']; There's a new ?: operator in PHP 6 which will make that even shorter, however unlike empty(), it currently throws a notice with unset operands. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] repetition of tedious references
Olav Mørkrid wrote: i didn't know about empty. thanks! do you have a link to this new php 6 ? : convention? I haven't seen any documentation yet but it currently operates like: ($a ?: $b) === (empty($a) ? $b : $a) with the exception that if $a is unset then an E_NOTICE error is raised. It remains to be seen in the final version whether that notice is raised or that this operator exists at all Arpad it would be great if php 6 could have a solution for this. php is sweet when it's compact! On 18/07/07, Arpad Ray <[EMAIL PROTECTED]> wrote: You can use empty() to take one of them out, since "0" is presumably also not a desired input: $language = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? "*" : $_SERVER['HTTP_ACCEPT_LANGUAGE']; There's a new ?: operator in PHP 6 which will make that even shorter, however unlike empty(), it currently throws a notice with unset operands. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XUL and PHP - what's your opinion?
I keep hearing about XUL, and I was wondering what the opinion of the masses was on this subject for an internal application where the browser is pre-determined. From my point of view I, having only read about it and not used it, is that XUL would make your applications look more like a desktop application. Some of the widgets they provide come in handy, like tables that can sort themselves instead of using AJAX/another page hit. The down sides that I see is there would be a 99.999% chance of a learning curve for any new developers that come into the company. Also, I'm not sure if XUL would cause extra programming overhead than regular HTML/JS. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $previous variable ?
On Wednesday 12 July 2006 14:31, Richard Lynch wrote: > On Tue, July 11, 2006 2:24 am, Roman Rumisek wrote: > > I am using apache 2.0.50 and php 4.4.3RC2 as mod (on Mandrake 10.1). > > When I run this script: > > > > > > > > in cli php, i give 'Undefined variable' error message - OK. > > But under apache, this variable has value 'N'. Is it error ? > > I found nothing about $previous variable in php.ini and php config > > directories. > > My first guess would be that you have "register_globals" set to "ON" > in Apache, and $previous is set in Cookies or Get data. > > It's also possible that you have managed to do this in some setup with > session.auto_start and where $_SESSION['previous'] is set to "N" > > Having register_globals set to "ON" is probably a Bad Idea for various > reason. > > Using short tags ( > Finally, echo "$previous"; is silly, as the quote marks serve no > purpose at all. echo $previous; would be better. > > -- > Like Music? > http://l-i-e.com/artists.htm A bit off topic, but I hadn't heard about short tags being a bad idea. What reasons make short tags worse than the regular tags. Just curious. Ray -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $previous variable ?
[snip] Yep, they can interfere with xml processing, and they also make your code less portable, as they may not be enabled in another environment. If you are sure your code is never going to move or be mixed with xml, by all means use them, but why not get into good habits? [/snip] Good points. Thanks. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Studio, phpMyAdmin, and mysql.sock
On Thursday 13 July 2006 21:53, Dave M G wrote: > PHP List, > > I am trying out Zend Studio for editing and debugging my PHP scripts. > > When I first ran it, it kept giving me this error: > Can't connect to local MySQL server through socket /tmp/mysql.sock > > After some research on the web, I found that this could be solved by > editing /etc/mysql/my.conf so that it said: > socket = /tmp/mysql.sock > > I was not thrilled about the idea of changing my MySQL server to meet > the needs of one application, but I wanted to see if it would work, and > it does. > > But, now phpMyAdmin doesn't work, saying: > The server is not responding (or the local MySQL server's socket is not > correctly configured) > > So what I really want to do is put my /etc/mysql/my.conf file back to > the way it was, and make Zend listen on mysql's default socket, not on > /tmp/mysql.sock. > > But, after much searching on the web, and in the Zend forums, I can't > find any information on configuring Zend in this matter. > > What do I need to do to make Zend listen on the MySQL socket that I want > it to listen on? > > (Which, by the way, is /var/run/mysqld/mysqld.sock) > > Thank you for any advice. > > -- > Dave M G I ran into this problem myself. I had to not use --skip-networking. I use Slackware linux, so that was in the /etc/rc.d/rc.mysqld script. I don't know why that would make PHPMyAdmin not work though. HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return XML using PHP and Content-Type with UTF-8 breaks the UTF-8
On Wednesday 19 July 2006 09:27, Mathijs wrote: > Hello there, > > I Have an problem with UTF-8 and XML. > > I Output perfect XML (according to IE, Opera and Firefox). > I use the Content-Type header with "text/xml; charset=utf-8". > For some reason this breaks UTF-8 output. > When i remove it it works. But i need the text/xml header. > > If i save an document as .xml with the same contents as UTF-8 it works. > > Is this a known problem? > > Thx in advanced. I would try just specifying UTF-8 in the XML header, and remove the charset from the content-type header, and just have the text/xml. HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Basic PHP knowledge test
On Wednesday 19 July 2006 10:31, John Nichel wrote: > We're looking to hire an entry level php programmer here, and I've been > tasked with writing the test to evaluate the potential candidates. > Being the lazy guy that I am, I naturally turned to Google to see if I > could find some tests that I could use. After clicking thru many links, > and finding mostly 'basic php tutorials', I've come here to ask you > people to do my homework for me. ;) Does anyone have any > links/resources for a basic php knowledge test? If not, I'll have to > write one from scratch myself, and mess up the rest of my day of goofing > off/sleeping. > > -- > John C. Nichel IV > Programmer/System Admin (ÜberGeek) > Dot Com Holdings of Buffalo > 716.856.9675 > [EMAIL PROTECTED] I just recently ran into the same problem. I got tired of trying to find one, so I made it myself. It's very specific to what we do here though. I'd definitely be interested in that info though, because we're still looking, and I'm not totally happy with mine, as I didn't have a whole lot of time to write it. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Basic PHP knowledge test
On Wednesday 19 July 2006 11:12, John Nichel wrote: > Yeah, reading the writing on the wall, I think I'm just going to have to > suck it up, and write it. The worst part of it is, I'm going to have to > be involved in the interview process, and I'm *not* a people person. ;) > > I think I'll go with a few syntax questions (not really worried about > that aspect, cause even after 8 years of doing php, I still hit the > manual a few times a week), maybe have the people write a basic function > or two to check how clean/readable their code it. Possibly also test > how efficient their code would be (like to they call a function inside > of a loop to get a static value that could have been set outside the > loop). Basic db stuff...ugh, I don't feel like doing this. > > I'll post what I come up with here; maybe we (this list) can combine > ideas and such, and actually put together a pretty good test or two so > we can spare the next poor soul who gets put into this position by MBA > wielding managers. That's pretty much what I did. I went with questions that would show how much they understand from a conceptual level. I don't know many people who don't have www.php.net as a bookmark. I did basic questions to show they understood OOP, recursion, pass-by-reference, etc. I also had to be in the interview. There were a lot of odd moments of silence when people were looking at me to ask some questions. I just wanted him to do the quiz and that was pretty much it ;) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Basic PHP knowledge test
On Thursday 20 July 2006 07:23, John Nichel wrote: > Yeah, one of my earliest thoughts on this was to have them write > something simple like connecting to a db, selecting multiple rows, > parsing our the result, and displaying it in some fashion. Don't forget making it secure. Here is one of my questions people can use if they like. Feel free to re-word it. I'm a programmer, not a writer ;) What change(s) would you make to the following code to make it more secure? $id = $_GET['id']; mysql_query(“DELETE FROM myTbl WHERE id = $id”); I like this question, because they have to know at least the fundamentals of PHP security. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session breaks when form data submitted
On Thursday 20 July 2006 09:09, Jeffrey wrote: > We have a site which requires users log in. Once they do so a session is > created (session_start), some data is saved as session data, > particularly data which identifies the user, their privileges, etc. If > the session ends, breaks, etc. The user must log in again. > > There are also forms on the site. When a user submits a form, data, both > posted and session, is saved to a MySQL database. > > If a session breaks when a user submits data via the form, the result is > that the user must log in again, the data is lost and the user unhappy. > This happens rarely - but when it does, it can upset the user who has > put effort into completing the form. > > Is there a simple yet secure way of preventing this problem - for > example passing the session id with the form and resurrecting the > session if it has broken? > > Thanks, > > Jeff To my knowledge, this particular behavior is by design. After the time limit for a session has been reached, then the garbage collection will usually clean it up. The only way to not break a session is to never clean up the session files, or set the timeout to a day or so. I wouldn't suggest sending the PHPSESSID via a form. That leads to people being able to hijack sessions ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Case Closed - Idiot Found Behind Keyboard] Re: [PHP] APC - problems with CLI & odd return values from apc_clear_cache()
On Saturday 29 July 2006 05:47, Jochem Maas wrote: > Jon Anderson wrote: > > Just replying to the list on this one 'cause I'm pretty sure you're on > > it. :-) > > > > AFAIK, with many caches the web server cache and CLI caches are > > exclusive to each process. The APC manual seems to suggest that the CLI > > cache is not connected to the web server cache: > > > > From: http://ca.php.net/manual/en/ref.apc.php > > > > apc.enable_cli *integer* > > <http://ca.php.net/manual/en/language.types.integer.php> > > > >Mostly for testing and debugging. Setting this enables APC for the > >CLI version of PHP. Normally you wouldn't want to create, populate > >and tear down the APC cache on every CLI request, but for various > >test scenarios it is handy to be able to enable APC for the CLI > >version of APC easily. > > thanks, you are right - what I thought had been working all this time had > not, or atleast the code did work but it was clearing the cache belonging > to the CLI, which was a pointless act! > > I'm an idiot. > > but wanting to clear the webservers APC cache from a cmdline script doesn't > seem like such a stupid thing to want to do. but there is no nice way of > doing it; so now I do this at the end of my cmdline script instead: > > exec('apachectl -k graceful'); > > which sucks in so many ways it hurts but it does clear the APC cache You could create a script that basically just does apc_clear_cache() et all. and call it from lynx, curl, wget, etc. and throw that into a cron job. That would technically get you to call the script from the cli, but it should clear the webserver cache. Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieving response headers from an off-site page
On Monday 31 July 2006 17:36, John Gunther wrote: > I'm trying to programatically retrieve a sales tax lookup page using > file_get_contents() but the page doesn't return data unless a session id > is first retrieved and then supplied. > > You can see how it works as follows: > > The first time I send the following request: > http://www7.nystax.gov/STLR/stlrHome?street=48%20central%20ave&zip=12472&B1 >=Lookup%20Address I get an empty form back, and one of the response headers > is Set-Cookie with a value of, say, > JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49;Path=/ > > If I then reload the same URL, the resulting page includes the desired > info, probably because the second time one of the request headers is > Cookie with a value of JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49 > > I want to get the second version of the page, the one with data, using > file_get_contents(), but it appears I first have to get the page to > return a sessionid and then I have to send it in a Cookie header the > second time. > > Reading the first GET's response headers and sending the needed request > header on the second GET - in combination with file_get_contents() - is > just beyond me. Can anyone enlighten me? > > John Gunther I deal with screen-scraping a lot at work. I would suggest using cURL to store the cookie data, and then subsequently get the data you need. check out http://us3.php.net/manual/en/ref.curl.php and the curl man page for more info. or, you can use your own HTTP implementation ;) HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] writing to fild on another server
On Friday 04 August 2006 10:07, Robert Cummings wrote: > You mean the http protocol won't let you write. At any rate, you can try > using ftp instead of http (you'll need to make sure it's set up on the > images server). Alternatively you can use a network file system or use > CURL or low level sockets to POST them to your images server. > That's what I was thinking if you wanted to keep it all HTTP. You could have an script on the images server that you submit the file to through a POST. Then the script would move it to the appropriate place. Remember to keep security in mind though. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cron running 'Hello world' script dies with "Could not startup."
On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote: > > Does the user running the cron have permission to execute the php binary? > > Yes, the file's owner is me and it's my crontab. Also, I've made the file > readable to all, just in case. All directories up the directory tree are > readable/executable, as well. I think he's asking if the php program is executable to you, the user. It is possible that it would only have execute for owner and group, not other. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cron running 'Hello world' script dies with "Could not startup."
On Tuesday 08 August 2006 09:01, Ivo F.A.C. Fokkema wrote: > On Tue, 08 Aug 2006 09:01:42 -0500, Ray Hauge wrote: > > On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote: > >> > Does the user running the cron have permission to execute the php > >> > binary? > >> > >> Yes, the file's owner is me and it's my crontab. Also, I've made the > >> file readable to all, just in case. All directories up the directory > >> tree are readable/executable, as well. > > > > I think he's asking if the php program is executable to you, the user. > > It is possible that it would only have execute for owner and group, not > > other. > > Sorry, yes, The PHP binary is executable by all. Actually, I'm very sure > the error message "Could not startup." is generated by PHP-cli. When > googling on that exact message, I found it in the PHP-cli source code > (including the period at the end). However, I cannot determine from the > PHP-cli source code what's up. It looks like when you run the script, then it works just fine, but it blows up when you run it through cron. Two things I would check: 1) Cron can read your *.php files. 2) Cron can run php to test #2, have cron do a php -i and see what happens. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server
On Wednesday 09 August 2006 11:20, Dave M G wrote: > PHP List, > > In the last stage of my current script, I need to take a bunch of data > from the database and put it into a text file for the user to save to > their computer and import into an application. > > The file being created is just a list of Japanese words and definitions > delineated by tabs. > > The file format should be a text file. Actually, it could also be CSV > file, since it's tab delineated data. > > The application being imported to only accepts EUC-JP encoding for text > files that include Japanese text, so my data, which is stored in the > database as UTF-8, will need to be converted to EUC-JP at some point > along the way to being written to the file. > > This file need not ever be stored on the server. In fact, I'd rather it > not so as to avoid any headaches with permissions settings (which always > give me a headache, but that's a rant for another day). > > So, I'm looking on php.net for functions that would be able to create a > file out of some data and pass it along to the user. > > But it seems that the assumption of all the file functions (that I've > found) such as fwrite(), fopen(), file(), readfile(), and others are all > about taking an existing file and working with it. And more importantly, > all of them seem to assume that the place where the file would be stored > is on the servers system, and not immediately passed on to the user. > > I have a suspicion that this is one of those situations where the > starting point is assumed to be so simple that no one goes out of their > way to document or explain it. > > I'm too lost to know where to begin. > > How do I create a file that the user saves, and is not stored on the > server? > > -- > Dave M G For re-encoding to EUC-JP, I would check out the multibyte functions... specifically mb_convert_encoding: http://us2.php.net/manual/en/function.mb-convert-encoding.php HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to get PHP5
On Wednesday 09 August 2006 12:03, Jonathan Duncan wrote: > On Wed, 9 Aug 2006, Chris W. Parker wrote: > > Hello, > > > > Generally (well, actually 100%) I just use whatever version of PHP is > > included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS). > > None of the versions I've used have come with PHP5 and I'd really like > > to get with the times and use PHP5. > > > > I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative > > things about it in general (FC5). > > > > I've never compiled PHP myself so admittedly I'm a bit skeered... Is the > > recommended path to just go with whatever distro I prefer and then > > download PHP5 from php.net and install it myself? > > > > Thanks, > > Chris. > > Yes, I would recommend that. If you are serious about using PHP for a > while it would be benefitial to you to understand the installation aspect > of the language. If you are comfortable with the command line this should > be pretty easy for you. If not it will be a bit harder but still very > possible. Here are installation instructions from php.net: > > http://www.php.net/manual/en/install.unix.php > > Good luck! > > Jonathan Also, when compiling it yourself you can specify what extensions you want. This allows you to keep your install as minimal as possible for your needs, which increases the performance of PHP. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compiling and iconv
I use Slackware linux, and XMLRPC is not compiled in by default with my distro, so I'm compiling PHP myself. It's always been a simple enough task. First I get and install the required xmlrpc-epi libraries, and then I compile PHP telling it where I just installed them. Now I get this error message: undefined reference to `libiconv' when compiling PHP. I did some searching, and the only thing I've found in reference to this error was a bug in version 4.3.10. Has anyone run into this issue, or have some suggestions? I have checked that /usr/include/iconv.h is there, and it defines all the iconv_* and iconv compiler flags etc. I can also vouch that using iconv on the command line works just fine. Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem Loading Extension
Hello everyone, I successfully compiled PHP 4.4.3 and PHP 5.1.4 today. I'm having a problem with loading the PDFLib extension (pdflib_php.so). It works fine in PHP 4, but PHP5 is not loading it. I do know that I have the file in the correct location (same as the mysql.so file), and when I take out mysql.so, then mysql functions are not available. I am not sure why this module is not loading. I checked the error_log, and I didn't get any error messages at all. STFW didn't give me a whole lot of information. Anyone have any ideas of where to look to find out why it's not loading? Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem Loading Extension
On Friday 11 August 2006 18:15, Michael B Allen wrote: > On Fri, 11 Aug 2006 17:50:12 -0500 > > Ray Hauge <[EMAIL PROTECTED]> wrote: > > Hello everyone, > > > > I successfully compiled PHP 4.4.3 and PHP 5.1.4 today. I'm having a > > problem with loading the PDFLib extension (pdflib_php.so). It works fine > > in PHP 4, but PHP5 is not loading it. I do know that I have the file in > > the correct location (same as the mysql.so file), and when I take out > > mysql.so, then mysql functions are not available. I am not sure why this > > module is not loading. > > > > I checked the error_log, and I didn't get any error messages at all. > > STFW didn't give me a whole lot of information. Anyone have any ideas of > > where to look to find out why it's not loading? > > Was the module compiled for 5? Check the apache error.log. If the .so > can't resolve a symbol or similar, usually that type of error appears in > the apache error log. Also, of course the .so needs to be in the right > location and the php.ini needs the appropriate extension directive. > > Mike Thanks for the info. I found out I had to download the latest version of PDFlib to support PHP 5.1.X. It's working fine now. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compiling and iconv
On Sunday 13 August 2006 22:00, Chris wrote: > Ray Hauge wrote: > > I use Slackware linux, and XMLRPC is not compiled in by default with my > > distro, so I'm compiling PHP myself. It's always been a simple enough > > task. First I get and install the required xmlrpc-epi libraries, and then > > I compile PHP telling it where I just installed them. Now I get this > > error message: > > > > undefined reference to `libiconv' > > > > when compiling PHP. I did some searching, and the only thing I've found > > in reference to this error was a bug in version 4.3.10. Has anyone run > > into this issue, or have some suggestions? > > > > I have checked that /usr/include/iconv.h is there, and it defines all the > > iconv_* and iconv compiler flags etc. I can also vouch that using iconv > > on the command line works just fine. > > Try explicitly telling php where iconv is by adding this option to your > configure command: > > --with-iconv-dir=/usr Thanks for the reply. I enentually got it to comipile by adding "-liconv" to the LDFLAGS environment variable to tell it to actually link in the iconv code. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OT? XUL XML-RPC Client
We've decided to start using XUL for intranet applications. I've written up my XML-RPC server (php script) and I had found a tutorial showing how to use XML-RPC through XUL/JavaScript, but now I can't find any information on it. Anyone have any experience/links to information about XML-RPC with XUL? Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Capturing System output
On Tuesday 15 August 2006 09:19, Brad Bonkoski wrote: > Hello All.. > > Had this problem in the past, and always programmed around it, but > wondering if there is an easier way. > > Good Example: > Creating a setup for connecting to a mysql database. Want to do > something simple to make sure they have entered a valid > username/password for the database. > So, the idea is something like: > $rc = exec("mysql -u $user -p{$pass}", $output); > The problem is one error, the stderr does not go to the output array, > but rather to the screen. > > Previously I would redirect the stderr to a file, and then evaluate the > contents of the file, but is there an easier way to get this into the > PHP variable with no risk of having the output make it through to the > screen? > > Thanks > -Brad I'd take a look at shell_exec. There'sa comment about capturing stderr. I'm not sure if shell_exec captures stderr, but it should at least point you in the right direction. Just do a search for stderr and you should find some good info. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Capturing System output
On Tuesday 15 August 2006 09:38, Brad Bonkoski wrote: > Stut wrote: > > Brad Bonkoski wrote: > >> Had this problem in the past, and always programmed around it, but > >> wondering if there is an easier way. > >> > >> Good Example: > >> Creating a setup for connecting to a mysql database. Want to do > >> something simple to make sure they have entered a valid > >> username/password for the database. > >> So, the idea is something like: > >> $rc = exec("mysql -u $user -p{$pass}", $output); > >> The problem is one error, the stderr does not go to the output array, > >> but rather to the screen. > >> > >> Previously I would redirect the stderr to a file, and then evaluate > >> the contents of the file, but is there an easier way to get this into > >> the PHP variable with no risk of having the output make it through to > >> the screen? > > > > I may be missing something, but why in the name of all that is holy > > would you want to shell out to try connecting to mysql? Why not use > > mysql_connect and avoid the potentially massive security hole you're > > building? > > > > -Stut > > Perhaps poor illustration of the question...the question being how to > issue system like commands in PHP which would allow you to trap not only > stdout, but also stderr. > -Brad Best example I found was: $shell_return = shell_exec($shell_command." 2>&1"); that should redirect stderr to stdout and thus you'd get both. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating User Friendly URLS
On Thursday 17 August 2006 09:43, Dave M G wrote: > PHP List, > > My goal is to create user and search engine friendly URLs like: > mysite.com/my_web_page_title > > Instead of: > mysite.com/index.php?pageID=1 > > I asked about this before: > http://marc.theaimsgroup.com/?l=php-general&m=113597988027012&w=2 > > And there is this helpful tutorial: > http://agachi.name/weblog/archives/2005/01/30/rewriting-dynamic-urls-into-f >riendly-urls.htm > > > Both of which refer to a variable called $_SERVER['PATH_INFO']. > > But, in the php.net manual, in the predefined variables page, > 'PATH_INFO' is only obliquely referenced in the $_SERVER variable > description, under the 'PATH_TRANSLATED' element. > > When I've tried echoing out the contents of $_SERVER['PATH_INFO'], I get > nothing. > > I'm trying to set it so that pages are named according to their title in > my MySQL database. So my script will pull "my_web_page_title" out of the > URL, match that against the database, and then display the appropriate > contents. > > I thought I could do this by simply making my link into: > My Web Page Title > > And then stripping out the "index.php", and using the remainder for > both the URL and the database lookup. > > But, while I'm sure there are more steps than that, I'm halted initially > because I'm not sure where in the $_SERVER array my URL is being stored. > > Any advice on how to proceed here would be greatly appreciated. Thank you. > > -- > Dave M G Richard has a good article related to this. Mostly it's about how to force a download with a correct filename, but the last part of the article should get you pointed in the right direction if you don't want to use mod_rewrite with apache. http://richardlynch.blogspot.com/ -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] active directory and PHP
On Thursday 17 August 2006 11:35, Michael B Allen wrote: > Hi Alain, > > PlexSSO is by far the best and easiest solution available for PHP SSO > with Active Directory. We provide: > > o Windows Integerated Authentication (WIA) > o Script level access to user info like username, home drive, etc. > o Script level access control using windows group names > > Someone else mentioned LDAP but I don't know why because it doesn't > provide authentication [1]. For authorization LDAP doesn't automatically > perform proper group expansion and is redundant to start with since the > Kerberos ticket has the fully expanded groups in it already. > > Our authorization code very easy to use. An access check looks like: > > if (plexsso_is_memberof("FOONET\\Managers")) { > echo "You're a manager."; > } > ?> > > None of the mod_authz_* Apache modules can do this. These checks are > also very fast. Once the SIDs for the groups used in your scripts are > cached they're instantaneous. > > Check us out. It's very affordable (free for 25 users and 25 groups), > we're adding major features in our next release, and we bring serious > SSO experience to the table. > >http://www.ioplex.com/ > > Mike > > [1] You could proxy the user's username and password to ldap_sasl_bind but > aside from being a hack it's not SSO and doesn't scale because it requires > communication with the DC whereas Kerberos does not. And it's insecure > because you have to cache the users "credentials" in the user's session. > > -- > Michael B Allen > PHP Active Directory SSO > http://www.ioplex.com/ > > On Thu, 17 Aug 2006 12:14:18 +0200 > > "Alain Roger" <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm new to PHP, so sorry if my question looks like stupid. > > > > I have a web application which use authorization and authentication > > process to log-in. > > I would like to know if it exists a way to synchronize the authentication > > with our Active Directory domain ? > > Something like a single side-on. > > > > In fact, i want from my web application users to make them remember only > > their login/pwd from Active directory to use my application. LDAP can authenticate with Active Directory just fine: http://www.google.com/search?hl=en&q=php+exchange+ldap+authentication&btnG=Google+Search or http://www.google.com/search?hl=en&lr=&q=php+active+directory+ldap+authentication&btnG=Search The question is how secure is it. You can set up LDAP to use SSL, so that would make it more secure. Kerberos is more secure than LDAP, and you _could_ set it up so that the browser forwards the ticket on to mod_kerb for authentication, thus not needing a sign-on other than to the domain. From my experiences that isn't exactly easy to set up though. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dhtml/javasript layer tips or software (0.T)
On Friday 18 August 2006 10:30, Ryan A wrote: > Hello, > I am working on a php project that needs a little > extra JS/DHTML solution. I am sure some of you might > have come to use something like this before, please > recommend a solution (commerial solutions are fine / > willing to pay) > > Basically, I will have a page with around 10 questions > for students and then two buttons for [HINT] and > [SOLUTION] > > When either of these buttons/text is clicked the > resulting text should be displayed in the side/bottom > cell, the user should also be able to 'close' this > resulting explanation. > > Note, on each page there will be around 10 questions, > so each of these questions will have a hint & solution > button/text. > > Thanks in advance, > Ryan > > -- > - The faulty interface lies between the chair and the keyboard. > - Creativity is great, but plagiarism is faster! > - Smile, everyone loves a moron. :-) > > __ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com I find that the Yahoo User Interface Library is pretty nice. http://developer.yahoo.com/yui/index.html I'm not sure that you really need a library to do what you want though. It could be as simple as using a div, and then the buttons change text with innerHTML (as long as you're not expecting to use that text after the submit). -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Emphasizing first letter of string?
$string) { $strings[$key] = '' . $string[0] . '' . substr($string, 1); } ?> Micky Hulse wrote: Hi, It is getting late, and I do not think I am thinking clearly... What would be the best way to wrap tag around the first letter of a string? I know it has to be a combination of str_replace() and substr(), but due to my level of sleepiness I am having a lot of trouble working this one out... Basically, if a config variable == true I want my script to loop through an array of strings and emphasize the first letter of each string. Make sense? Sorry, I am pretty sleepy... Hmmm, I am betting I will discover the answer as soon as I send this email. :D Anyway, any help would be great! Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overriding core functions
You can't just define a new function with the same name. The only way I know to literally redefine the function is using the runkit extension - http://pecl.php.net/package/runkit That allows you to rename functions as well as moving them, so you could rename it to something like old_mysql_query() then define your own mysql_query(). Arpad Alex Turner wrote: It may be possible to override the core function - I don't actually know. If you just define a new function with the same function it might work OK. The snag I see coming at you like a tonne of bricks is 'how do you call the original function once you have overridden it.'. This like like calling SUPER. in Java. AJ Peter Lauri wrote: Yes, that could solve it. However, my question was if I can override the core functions :) Similar that I can do Parent::myFunction() in a subclass, I want to do that, but with core functions :) -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 22, 2006 7:27 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] Overriding core functions Peter Lauri wrote: Hi, I want to add some functionality when calling the mysql_query(): function my_query($Query) { //do stuff before mysql_query($Query); //do things after } // or something like: class PeteDB { var $conn; function PeteDB($db, $usr, $pwd, $etc) { $this->conn = mysql_connect($db, $usr, $pwd, $etc); if (!is_resource($this->conn)) die('db is useless'); // trigger_error() } function query($qry/*, $args*/) { // do stuff $r = mysql_query($qry, $this->conn); // do more stuff return $r; } } /* tada! hint: always use some kind of wrapper for things like db related functions (because it allows for stuff like this and, for instance, makes it alot easier to switch dbs - because you only have to change code in one place, not counting any db-specific sql floating around your app) */ This would just be for one project where I want to record all Queries and the result of them, creating an own logging function. I did a lot of Google, but no article that I found that take care of this subject. /Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overriding core functions
Brad Bonkoski wrote: Some already good workarounds given for this question... BUT. Is it even possible to override a core function? Like I wrote a function called 'exit' and I got a parser error, which leads me to believe it is not even possible to override the core functions. Is this true of ALL PHP functions? -B 'exit' is a language construct like 'echo', so I don't think you'd be able to redefine that even with runkit. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php