[PHP] ecommerce related question
Firstly, not really a php question, but generic web stuff, but I feel it's still better answered here. Recently a friend came to me asking to create an ecommerce website. In the past my php work has been primarily a hobby, and as such haven't really taken much interest or effort into security aspects of it. Given the nature of the project, I realise security is a must. My question is: what recommended reading for security or ecommerce can any of you suggest? -- Thanks, Travis Moore tra...@live.com OR trabus2...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD - JPEG to PNG with transparency and color
Following files: bg.png - Clear Transparent Image 14416fed5d4f78.jpg - Normal Jpeg Image The Code: header('content-type: image/png'); $watermark = imagecreatefromjpeg('14416fed5d4f78.jpg'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefrompng('bg.png'); $size = getimagesize('bg.png'); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagepng($image); imagedestroy($image); imagedestroy($watermark); The Problem: The code above works fine in sense of syntax! bg.png acts as a transparent border for 14416fed5d4f78.jpg to keep the size of bg.png and not the size of 14416fed5d4f78.jpg so it doesn't blow up 14416fed5d4f78.jpg. However, the image comes out black/white and has lost its color! I looked all over Google and I've found nothing so far that's functional to give the new created png file the correct colors as the original 14416fed5d4f78.jpg. I figure that I'm missing some small elements to the process of creating the png... Anyone have any ideas, pointers, advice, or correct solution to make this possible? Sincerely, Travis L. Font Interactive Developer BSN 5901 Broken Sound Parkway NW 6th Floor Boca Raton, FL 33487 Main Ph.: 561-994-8335 Ext.737 Fax: 561-998-4635 Toll Free: 1-800-939-4071 Ext.737 http://www.bsnonline.net/ / http://www.endorush.com/ / http://www.tlfapparel.com/ The 27th Fastest Growing Private Company In America* The 2nd Fastest Growing Private Company In The Miami-Fort Lauderdale Metro Region* The 4th Fastest Growing Private Company In The Health Industry* [*Above Rankings Were Determined By Inc. 500/5,000] This e-mail, and any attachment, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, copying, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The contents of this message may contain personal views which are not the views of BSN.
RE: [PHP] Generating Random Numbers with Normal Distribution
Here's random! I'm going to close my eyes think of some drinking water and running AT the same time and just start pushing numbers on the pad however way my fingers desire while not thinking about it! Here: 7914718845748671454531587148354531452141857 Good enough? -Travis
Re: [PHP] Unexpected values in an associative array
On 7/31/07, Ken Tozier <[EMAIL PROTECTED]> wrote: > > ... > // set fetch prefs > $this->db->setAttribute(PDO:: FETCH_ASSOC, > true); // also tried 1 > ... > Is that the way to do it? Hmm.. Maybe I sent you in the wrong direction - I can't find any docs on using setAttribute to set the fetch mode. Anyway, setAttribute always works like this: setAttribute(attribute_to_set,value_to_set_to); I was expecting something like: setAttribute(PDO::FETCH_MODE, PDO::FETCH_ASSOC); I don't think that works though, can't find anything in docs relating to attribute called FETCH_MODE. Anyway I dug in some code and this is what you can do: foreach ($pdo->query($query, PDO::FETCH_ASSOC)) {} Query can take a second parameter. Another option: PDOStatement->setFetchMode(PDO::FETCH_ASSOC).. so your original code goes from: foreach ($pdo->query($query) as $row) {} To: $statement = $pdo->query($query); $statement->setFetchMode(PDO::FETCH_ASSOC); foreach( $statement as $row) {} There must be a way to set it with setAttribute for the connection though, instead of just on a per-statement basis... Travis Doherty
Re: [PHP] Reading registry values
On 7/31/07, Crash Dummy <[EMAIL PROTECTED]> wrote: > > > Hope this isn't overkill but it is a module (read "COM", or "VBA > module") > > to manipulate the registry: > > "Overkill" is a massive understatement. :-) No doubt. To answer everyone's curiosity as to why I want to access the registry, I am > working on my home computer with a dynamic IP, and I need to know what it > is so > I can modify my httpd.conf (or hosts) file, if necessary. You might use http://www.php.net/reserved.variables "SERVER_ADDR" to get the address of the host you are running under if you wanted to access it from PHP only. Travis Doherty
Re: [PHP] Feisty Fawn and apt-get
Skip Evans wrote: > Hey all, > > I've installed Feisty Fawn on the curmudgeon barber's machine, but it > won't get any of the outside packages I've tried to get. I've tried an > > apt-get install {package} > > ...on digikam, kate, gftp, and others. All stuff I had no trouble > getting with Edgy. > > I checked the sources.list file and it has both universe and > multiverse enabled. > > Is there something with the FF repositories or something I'm missing? > > Thanks, > Skip Wrong list? T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A problem with passing $_GET in an url
If you're using window.location="./script.php?var=value", it's not actually using a variable, it's using a string. If you're just using the above as an example, then could you please post the line of javascript for redirecting. Travis. Davis Chan wrote: Hi! New to this newsgroup and is debugging a strange behaviour in a site under development. The developement platform is a Linux box running Fedora Core 6, Apache 2.2.3-5 and php-5.1.6-3. Here is the general flow of that particular part of the site: php generated form ---(data submitted by pressing "submit" on the form and "ok" on a javascript confirm box)---> window.location="./script.php?var=value" ---> script.php process the form data The problem is I cannot pass the "var=value" to script.php (the url on browser only says ./script.php? and $_GET is empty with a print_r() ) but if I type in the url manually, the script.php works. I checked the javascript also and it is ok. I understand this might not be a php problem but I am totally lost. Any idea, insight, opinion is welcomed. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bounce composition
Richard Lynch wrote: >On Wed, May 2, 2007 2:57 pm, Oliver Block wrote: > > >>Am Mittwoch, 2. Mai 2007 20:11 schrieb Richard Lynch: >> >> >>>Does anybody have or know of a good simple PHP script that can take >>>an >>>email as an input, and compose a "Bounce" email as output? >>> >>>I need something that does just that, without a huge framework or a >>>zillion other "features"... >>> >>> >>please try this: >> >>$env['from'] = '[EMAIL PROTECTED]'; >>$env['to'] = '[EMAIL PROTECTED]'; >>$env['remail'] = imap_fetchheader($stream, $msgno); >> >> > >I don't think that's what a "bounce" looks like, is it?... > >I guess I was hoping somebody had worked out the minutiae of composing >a bounce message in PHP from the input headers. > >I don't need help with the IMAP part of it, just the RFC bit about >making up a bounce message, without actually having to spend hours >poring over RFCs, which is not my idea of a Good Time... :-) > >Or maybe I'm making a mountain out of a molehill, and that IS what a >bounced email looks like... > > > Hey Richard, DJB's bounce format is pretty popular: http://cr.yp.to/proto/qsbmf.txt Best case would be to give a 400 for temp failure (plz try later) or a 500 for perm error right at the mail server. Not sure if you can get your logic in up the stream though before it gets to you. If you can you never have to deal with bounce messages and the entire queuing process that goes along with it, mail server maintenance, etc.. Bounce to the enveloper sender, not the "From" header. I also believe bounces are supposed to have an envelope sender of "<>" to avoid bounce loops... not sure on that though. Cheers Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_replace and regular expressions.
Okay, so what I have is a BB code type of thing for a CMS, which I for obvious reasons can't allow HTML. Here's the snippet of my function: function bbCode($str) { $db = new _Mysql; $strOld = $str; $strNew = $str; $getRegexs = $db->query("SELECT `regex`,`replace`,`search` FROM `_bb_codes`"); while ($getRegex = mysql_fetch_assoc($getRegexs)) { $search = base64_decode($getRegex['search']); $regex = base64_decode($getRegex['regex']); $replace = base64_decode($getRegex['replace']); if (preg_match($search,$strNew) == 1) { for ($i = 1; $i < 20; $i++) { $strNew = $strOld; $strNew = preg_replace($regex,$replace,$strNew); if ($strNew == $strOld) { break; } else { $strOld = $strNew; } } } } $return = $strNew; return $return; } ** But, for something like this: [quote][quote]Quote #2[/quote]Quote #1[/quote]No quote. I'll get: [quote]Quote #2[/quote]Quote #1 No quote. Despite being in the loop. Regex is: /\[quote\]((.*|\n)*)\[\/quote\]/ Replace is: $1 Both are stored base64 encoded in a database. Any help / suggestions much appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL Source Control
Richard Davey wrote: > Hi all, > > I know a lot of you use various means for PHP source control (CVS, > SVN, etc), which is all well and fine, but how do you manage source > control on your databases? > > Say you've got an upgrade to a site, all of the new PHP files are > controlled by SVN, so you can rollback at any time, but say the > upgrade includes several key modifications to a MySQL table and > perhaps the changing of some core data. > > How (if at all?!) do you handle the versioning of the database and > data itself, so you can keep both PHP and SQL structure in sync? > > Cheers, > > Rich One thing we do is add a table called 'versions' to each application, this table just has one row and a column for the schema version (and sometimes other stuff less important.) When the app runs it checks to ensure that its defined constant DBVERSION matches that of the database it is running against. This has actually helped out more than once, though not a solution to the actual problem. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MD5 & bot Question
Robert Cummings wrote: >On Mon, 2007-04-09 at 12:51 -0400, tedd wrote: > > >>At 9:58 AM -0400 4/9/07, Robert Cummings wrote: >> >> >> >>>Hi Tedd, >>> >>>Put down the crack pipe please... captcha images are usually generated >>>on the fly. Their image repository is 0. Their image universe is all of >>>the permutations of an image containing all of the range of serial codes >>>embedded in the images according to their morphing routine. I highly >>>doubt the US Government could afford the space required to store all of >>>the permutations. Considering the number of bytes available to a >>>dynamically generated image, it is highly likely that the images would >>>be capable of exhausting the entire md5 universe. >>> >>>Cheers, >>>Rob. >>> >>> >>Rob: >> >>Duh -- put down the joint and stay on the subject. We were talking >>about M$'s "picture" captcha where they show pictures and ask a >>question like "Pick the picture that shows a kitty" and NOT an "on >>the fly" graphic captcha. There are different types of captchas. >> >> > >Ah, I see. I was too lazy to go check since I don't use Microsoft except >insofar as to make things work in their crappy browser. Either way, can >you verify the images are static? See if getting two kitty cats produces >the same md5 signature :) Just because it's a picture doesn't invalidate >what I said. > >Cheers, >Rob. > > Steganography has been able to "hide" text in images for quite some time now. Basically you cram whatever info you want into the 'unused' or 'less used' bytes of the image. With this in mind I imagine even if you did have an image repository of only 8 images you could add some random bytes to the right spots in the image without distorting it beyond recognition/corrupting it, and therefore get a hybrid of static/on-the-fly images, that hashing couldn't break so simply. 2 cents... Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] keeping credit card info in session
Jochem Maas wrote: >unless you are a payment gateway or a bank don't touch credit card numbers. >there are plenty of threads in the archive of this list that give good reasons >not to e.g. being sued out of existence. > > 100% agreed. Never touch credit card numbers. You can't just take credit card numbers and manually process them in 'card not present' transactions (or MOTO in more archaic terms.) You need a merchant account that allows for this -- usually at a higher discount rate. Check the merchant agreement. Your client should get an account like this, or better yet, provide you with the instructions on how to integrate his site with the payment providers so that you never have to worry about credit cards. As an additional note... Maybe your SSL cert secures the numbers from the client to the server, and just maybe your PHP scripts have no security flaws in them, but you must remember the server itself and everything else outside of PHP. What if someone found a flaw in the FTP server for example, or the mail server even, and used that to get the CC info. I would hate to be explaining to a list of 1000 clients that I was responsible for their card numbers being stolen. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP4 vs PHP5
Robert Cummings wrote: >Or... there's some strong arming happening to force the move. PHP4 >userbase greatly outnumbers the PHP5 userbase. I think the userbase >speaks louder than the support timeframe. > >Cheers, >Rob. > > Damien Seguy's latest stats showing the adoption rates of PHP5 show what Rob said. http://www.nexen.net/chiffres_cles/phpversion/16814-php_stats_evolution_for_march_2007.php I'm sure many of the polled domains are shared hosts, who have users, which exponentially complicates the task of migration. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5
Myron Turner wrote: > Travis Doherty wrote: > >>> >> >> What about the argument that PHP4 is dead. It's done. It's over. >> There is no reason anyone should be using it, less perhaps a lack of >> time to tweak scripts for an upgrade from 4 to 5. Even if that is the >> case, get to work :p >> >> "Support for PHP 4 will be dropped at the end of the year, 8 months from >> now. So now is the time to start upgrading all your scripts as we won't >> be releasing new versions after December 31st, 2007." >> >> http://derickrethans.nl/php_quebec_conference_rip_php_4.php >> >> Travis Doherty >> >> > > This is fine, as long as the newer versions are backwardly > compatible. If , in particular, if the next version or version 6 does > not support the PHP 4 object oriented model, it could present real > problems for some software. PHP isn't used only for "scripts" but for > large projects. For example, I just began to configure a DokuWicki > installation, writing code for various features which are not included > in the install. DokuWicki uses the PHP 4 object oriented model > throughout, and user plugins, such as mine, are written to the same > model. DokuWicki contains over 300 php files and more than 3 megs of > code. It would be no small task to convert such a project over to the > PHP 5 OO model. DokuWiki should run just fine under PHP5. It may throw some E_STRICT errors warning of things that will be deprecated in a later major PHP release. I doubt DokuWiki needs register_globals, and magic_quotes shouldn't be a question. Use the strict level warnings as hints to help you find what needs to be modified in your own code. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5
Fernando Cosso wrote: > Hi > I know this topic has to be discussed several times but I have a > situation I > need some advices. > > I am working in a small company. The company does everything you need. > Computer service, sell computers, install servers, web page, etc. I am in > the web department. The guys from the server installation and that > stuff are > using a modified debian, which for default in his stable release has php4 > and apache 1.33. > I am new at the company and I have to decide what I need and what I am > going > to do. My choice is to use the CMS Mambo and make the modification > that each > client would ask. > So I've seen that php5 has a lot of cool staff, like mysqli and the > new (and > faster) object oriented thing. I would like to know if it is "safe" to > use > this version. I know that mambo use objects so I think that php5 will > do a > better job running it. I also think php5 (or php6) is the future we > can use > php4 for ever. > So whats your opinion? > Thanks > > A last comment: I apologize for my English, please let me know you didn't > understand something > What about the argument that PHP4 is dead. It's done. It's over. There is no reason anyone should be using it, less perhaps a lack of time to tweak scripts for an upgrade from 4 to 5. Even if that is the case, get to work :p "Support for PHP 4 will be dropped at the end of the year, 8 months from now. So now is the time to start upgrading all your scripts as we won't be releasing new versions after December 31st, 2007." http://derickrethans.nl/php_quebec_conference_rip_php_4.php Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Upgrade: 5 or 6
Tijnema ! wrote: > On 3/28/07, Davi <[EMAIL PROTECTED]> wrote: > >> >> Hi all. >> >> I've reading on some sites [1,2] that PHP 6 is comming soon... >> >> What should I do? >> Migrate my server and apps to PHP 5 now and, later to PHP 6, or wait >> some more >> time and migrate all to PHP 6? >> >> TIA > > > I think you should migrate to PHP5 now, as i think it will take some > time before a real PHP6 release is coming. I don't know where you > useit for. Is it development or productional? For development you > could work with a CVS Snapshot, but that's not recommended for > productional. > But of course if you don't have any problems with the PHP you are > currently using (I guess PHP 4.x), then it's not really needed to > upgrade. I agree and disagree - I agree with "you should migrate to PHP5 *NOW*" (my emphasis added) and I disagree with "then it's not really needed to upgrade." (unless you don't care about security.) Ilia Alshanetsky gave a great talk on this topic recently, http://ilia.ws/talks/ scroll to the bottom to "(PDF) Migrating to PHP 5.2.1". Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Zoltán Németh wrote: >2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: > > >>Hi Everyone, >> >>First off, I'm using PHP 5.2.0 and apache 1.3.33 >> >>I am trying to figure out what format a string is in in a database. >>It's a timecard system that I have found on-line and I am attempting >>to figure out how to write a script that would give me everyones >>timecard for the month on one screen I can print out for accounting >>to use. Below is an example of one of the lines in the database, What >>I'm really interested in is how it represents the "day". >> >>user dayjob_name >>minutes sequence >> >>root 1171774800 Production & technology Manager >>990 3 >> >>I have not been able to find ANY info about that format, other then >>other people using it in blogs. I think I can figure out the rest as >>I go if I know how to decode the day. Any help or pointers to the "M" >>would be GREATLY appreciated! :) >> >> >> >> >> > >what does strtotime return for that string? > > > It's already a time, strtotime should return FALSE. It probably can't parse that string to a time. Travis D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: > Hi Everyone, > > First off, I'm using PHP 5.2.0 and apache 1.3.33 > > I am trying to figure out what format a string is in in a database. > It's a timecard system that I have found on-line and I am attempting > to figure out how to write a script that would give me everyones > timecard for the month on one screen I can print out for accounting > to use. Below is an example of one of the lines in the database, What > I'm really interested in is how it represents the "day". > > user dayjob_name > minutes sequence > > root 1171774800 Production & technology Manager > 990 3 > Looks like epoch time. Use date("Y-m-d",$epochtime); to get a standard date string out of it. www.php.net/date/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
Jake Gardner wrote: > He said if you run the /script/ itself 1000 times, not a loop with 1000 > iterations. This is quite possible; I am fairly certain there are > websites > out there that get accessed well over 1000 times a minute, yes? > > So every minute, that website is saving a total of 2.6 seconds to do... > whatever it is websites do in their free time. > > In reality, scripts rarely get executed once and then are deleted; > they are > used repetitively, and the more a script is used, the more significant > the > gain. Claiming to look practically on a small gain /within one > execution of > a script/ is impractical in itself. I still wouldn't go around telling people to re-write all of their code to use for loops instead of while loops (or whatever was faster for whatever architecture.) Keep in mind that .000xx seconds in performance improvement certainly does make a difference on a site that is accessed millions of times a day, however, one bug caused by writing code that reads poorly instead of writing clean code can cost a *lot* more in the end. - Use what reads easier when deciding if a for/while loop is best. - Profile your code and find the right places to optimize. Optimizing code that takes .0001 seconds to run down to .1 seconds is great, 10x improvement! Who cares. Find the chunk that takes 0.5 seconds to run and optimize that to 0.05 seconds. 10x improvement still, except that this time it actually makes a practical difference. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Important Design Patterns
Tijnema ! wrote: > On 3/25/07, PHP Developer <[EMAIL PROTECTED]> wrote: > >> hello all, >> As we know, there are a lot of php design patterns(more than 20). I >> want to know that which patterns are important and necessary for ZCE >> exam. >> PHP5 Study Guide only covers Singleton,Factory,Registry,MVC and >> ActiveRecord. But i still feel that more patterns are necessary for >> the exam. >> Cheers, >> Daniel > > > I'm not able to give an answer, but was it really needed to post this > message three times?? > > Tijnema Taking the Zend ZCE exam puts you under a strict NDA. Nobody can tell you what you will see on the exam. Study the exam guide and if design patterns really interest you then take it to the next level out of personal interest. Since patterns are not "PHP-only" you can really study these from any language, or even grab a language-agnostic design pattern book. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Computing and calculating dates
Otto Wyss wrote: > This probably has been asked several times yet I can't find a > satisfying solution. What's the simplest way to compute dates like > > local_formated_date + 7; // days > local_formated_date > local_formated_first_day_next_month; > local_formated_date > (current_date + 14) > > etc. Which functions are best suited for such calculations? > > O. Wyss > www.php.net/strtotime is probably a good start. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an FTP account on the fly from PHP
PHP Fusebox wrote: > I built a CMS that lets a super user create and manage basic users > (among lots of other things). I want basic users to get an FTP account > that is automatically associated with their website user account, and > managed from my add/edit user form. For example if I create a user > named [EMAIL PROTECTED] for him to login to my web app, I want my > users to be able to use their same login name and password to access > their web folder via FTP. > > I am running on LAMP on a CPanel server with ProFTP as the FTP server > software, but I have no clue how to get PHP to be able to create, > edit, or delete an FTP account. Can someone point me in the right > direction? > ProFTPd? It can authenticate against MySQL tables... It gets authentication from your database. We used to do this many many years ago... It worked fine and was probably choke full of security problems. Setting up ProFTPd for MySQL authentication was a pain, I'm sure its easier today. Once you have that setup, its just a simple matter of CRUD SQL queries. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
Tijnema ! wrote: > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: > >> Your test isn't exactly fair. The for loop has no statements in it, and >> the while loop has one. Your tests show while as approx 7% faster, while >> a modified test shows an approximate 30% speed improvement: >> >> Do this: >> >> for ($i=0;$i<1000;$i++) {} >> >> v.s.: >> >> $i = 0; >> while ($i++ < 1000) {} > This has been asked many times, probably likewise for every language. Search for the same question on the C programming language for a more in depth discussion of this and to find out why one way is faster than the other... Major factor: Don't forget the difference between pre and post increment operators. $i++ and ++$i. For reference this is my PHP test script and results: {{{ [EMAIL PROTECTED] tdoherty $ cat ./forwhile.php [EMAIL PROTECTED] tdoherty $ php ./forwhile.php For pre-increment (10): 0.035 For post-increment (10): 0.060 While pre-increment (10): 0.029 While post-increment (11): 0.056 }}} After multiple runs I see that the for pre-increment loop is fastest. Note that the while loop with a post-increment runs once more than with a pre-increment. Everytime I run, the results are *very* different, though still fall within similar comparitive domains. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] close session when browser is closed
Juergen Wind wrote: >Travis Doherty wrote: > > >>By default the session cookie expires when the browseris closed. >> >> >this is not always true: f.e. FF requires *all* open windows to be closed to >forget that session. > > Personally I think this does make sense. I fully expect the browser to maintain cookies "Until it is closed" -- If I have closed one tab that had set a cookie, re-opening that URL in a new window/tab should still cause the browser to send in my cookie. > > >>If the browser refuses the cookie, sessions won't work anyway. >> >> >again: this is not always true. Only if "session.use_only_cookies = 1" >otherwise the session id can alternatively propagate using the query string >or hidden input fields. >(if "session.use_trans_sid = 1") > > That is correct - as I mentioned "(unless its in the URL...)" ... It's kind of weird to pass sessions through URLs though, I prefer clean, simple URLs such as www.example.com/resource/topic.html, instead of something like www.example.com/?x=resource&y=1113&this=44&PHPSESSID=123124124124124&bookmarkable=not_really Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing variables
itoctopus wrote: >Since you're new to this, always be sure to clean up the output you get from >$_GET or $_POST to avoid sql injection. > >Fore example: $search_value = htmlentities($_GET['search_value'], >ENT_QUOTES); >If you're casting to something other than a string (such as int) than you're >safe and you don't have to use htmlentities. > > > Good call. One better is prepared statements. Avoid the problem all together. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] close session when browser is closed
Alain Roger wrote: > Hi Brad, > > yes this is one possibility, but since i use https, i should not be > afraid > by storing data in $_SESSION variables. Just a note that while SSL may help to protect the session id from being packet sniffed you should still be concerned about storing sensitive data in _SESSION. Anyone local to the system can probably read plaintext session data from the session cache. HTTPS only protects communications between the client and the server at best, do be afraid! Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] close session when browser is closed
Alain Roger wrote: > Hi, > > I would like to know what is the best solution for my problem. > > When a user is connected to a https page and a session is open, if user > close his browser, the session ID is still active in the browser > "history". > It means that next time when user will start his browser, the browser > will > re-use the same session ID and will work with php pages without any > problem. > > I was thinking to use cookie to solve this issue, but what should i do > when > user browser refuse cookies ? > > thanks a lot, > This seems odd. By default the session cookie expires when the browser is closed. You can change this by changing ini setting session.cookie_lifetime to something other than default value of zero, in number of seconds. I don't believe using HTTPS changes any of this, I have more than one app that use HTTPS for session cookies and have no problems with it persisting after the browser is closed (well, some browsers can do weird things sometimes... you never really know.) If the browser refuses the cookie, sessions won't work anyway. The session key is sent to the browser as a cookie (unless its in the URL...) www.php.net/session/ Take a look at cookie_lifetime and you might like the cache_expire docs on the same page too. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions timing out, php5
Paul Nowosielski wrote: >Dear all, > >I'm having an issue where sessions timeout after inactivity. > >I have session.cache_expire set to 1440. > >But some users have reported sessions timing out after a couple hours. > > > Are you storing sessions in /tmp? Possible that your OS has a cron job running that clears out that directory, especially if these complaints are usually around midnight when these types of jobs typically run. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reverse http authentication
Chris W wrote: > I want to read a page that is protected with http authentication. How > do I pass the user name and password to be authenticated with my php > code? > Have you tried to just put the username and password in the URL? I'm not sure if this works, its so simple its worth a try. Instead of using (whatever function you use) like the first example try changing it like the second: x('http://example.com/protected/page.php'); x('http://username:[EMAIL PROTECTED]/protected/page.php'); Of course it depends on the 'x' you are using... I'm really not sure if PHP's functions will take care of moving that username/password information into the header of the HTTP request or just leave it there. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Filtering _REQUEST.. Why is this bad?
Hello. Came across some code that startled me. Mostly because it goes against the generally accepted idea of detecting and rejecting bad input instead of trying to escape it, secondly because "it just feels wrong." The only technical case I have so far is for inserting a double/single quote into the database. It will get inserted as its htmlentities equiv of '"' for example. In the future if they wanted to display the data in the database in a format other than html it will be messy. So... the question is: What else is wrong with this? or.. Why is this so bad? $val) { if (is_array($val)) { $return[$key]= recursiveFilter($val); } else { $return[$key] = htmlentities($val,ENT_QUOTES); } } return $return; } $_REQUEST= recursiveFilter($_REQUEST); // queries directly inserting from $_REQUEST // echo'ing of data directly from $_REQUEST ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make Browse Folder Dialog
Aslam Bari wrote: >Hello, >Just a minute. I know the php script will run on server. Suppose i m working >on server machine and i need to make a project for myself. The machine is >only one and same. Also there are a lot of file and directory methods >available in PHP, Whats that? Actually i want to show the files of selected >folder on screen. >Thanks... > > Yes, PHP has file handling functions for use on the server it is running on. As long as we're clear that it can't touch the filesystem of the user of the application :D If you just wanted to make a list of folders and let them select one you could build the list using an HTML SELECT box. Once they have selected an item and click on submit, you would use similar code that you used to populate your directory list to show a list of all files in that directory. The code at Example 2 on the php.net readdir documentation is probably one good place to start: http://www.php.net/readdir A hint from another thread today to save yourself trouble: Always use full paths when working with files. T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make Browse Folder Dialog
Børge Holen wrote: >On Wednesday 24 January 2007 07:32, Travis Doherty wrote: > > >>Aslam Bari wrote: >> >> >>>Dear All, >>>I m new in this Forum. I m making a project in which i need to show user a >>>Browse Folder Dialog Box, In which he can select a folder and after this i >>>will do some manipulation on that folder's content. So the problem is that >>>i could not found any sample on Web , how to show "Folder Dialog" in any >>>way (HTML, JavaScript, PHP etc). Plz has anybody some idea how to do some >>>work around this. >>> >>>Thanks... >>> >>> >>PHP won't let you edit files on your users' computer. Ever. >> >>Maybe it would be worth your time to look into a different language to >>do whatever it is you want to do, something like Visual Basic might suit >>you well (last time I used it there was a control that would popup the >>standard windows 'Select Folder' dialog.) >> >>Travis Doherty >> >> > >Ouch, this is close to swearing in the church... > > > :p I suppose it is. Use the right tool for the job right? PHP on a server won't ever let the OP manipulate the content of a folder on his users computer. T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Splitting long text
Anas Mughal wrote: > I have been using the below function successfully. Hope it works for you. > -- Anas > > > > // textwrap 1.1 Brian Moon <[EMAIL PROTECTED]> > // This code is part of the Phorum project <http://phorum.org> > // $String The string to be wrapped. > // $breaksAt How many characters each line should be. > // $breakStr What character should be used to cause a break. > // $padStr Allows for the wrapped lines to be padded at the begining. Short of string padStr in that function, and bool cut in the native PHP one, I don't see why someone wouldn't just use http://php.net/wordwrap/ . Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make Browse Folder Dialog
Aslam Bari wrote: >Dear All, >I m new in this Forum. I m making a project in which i need to show user a >Browse Folder Dialog Box, In which he can select a folder and after this i >will do some manipulation on that folder's content. So the problem is that i >could not found any sample on Web , how to show "Folder Dialog" in any way >(HTML, JavaScript, PHP etc). Plz has anybody some idea how to do some work >around this. > >Thanks... > > PHP won't let you edit files on your users' computer. Ever. Maybe it would be worth your time to look into a different language to do whatever it is you want to do, something like Visual Basic might suit you well (last time I used it there was a control that would popup the standard windows 'Select Folder' dialog.) Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting naughty sites
Tom Chubb wrote: > On 28/11/06, Dave Goodchild <[EMAIL PROTECTED]> wrote: > >> Hi all. I am building a web app and as part of it advertisers can upload >> their ad image and website URL to go with their ad. Is there a good >> way to >> detect whether that site is a porn site via php? >> >> -- >> http://www.web-buddha.co.uk >> >> > I remember seeing something that used GD to detect colours similar to > flesh within an image and thinking it was funny that someone had taken > so much time to to it, but I can't remember where it was. > I think it was on phpclasses.org but can't find it. Maybe someone else > remembers it? > And more recently a commercial vendor is performing something along the lines of 'curve recognition' to the same effect. That's fine for any vector graphics (banner ads might fall here.) False positives will be high with beach photos from family vacation, for example. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Serving out a file to Firefox ... headers?
Brian Dunning wrote: > Sorry to revisit this issue YET ONE MORE TIME... :) :) > > My online store sends out the file for download upon purchase. Below > are the headers I send, and I understood that it should work for all > browsers. It does not work for Firefox. Suggestions? > > header('Content-Type: application/octet-stream'); > header('Content-Disposition: attachment; filename='.$filename); > $size = filesize('../../store/files/'.$filename); > header('Content-Length: '.$size); > readfile('../../store/files/'.$filename); > Pretty sure Richard already squared this one away, I think this is the article you are looking for: http://richardlynch.blogspot.com/ Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attaching File to be Emailed
[EMAIL PROTECTED] wrote: > I need to take a word document or pdf file from either a MySQL db or > from a > directory, which will then be sent via php script. How can I go about > doing > this? Can anyone provide sample code or point me in the right direction. > Brian Dunning started a thread about nine minutes before you on sending a file to the browser. "Serving out a file to Firefox ... headers?" That's pretty much all you need to do to read from a file (adding in whatever fixes the problem he is experiencing with FireFox of course.) If you wanted to store the data in a MySQL database it would be the same procedure, except you would query the database (BLOB column type) and echo that data instead of using readfile() to get your data. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ftp a file-->errors in rendered page, Ftp the file again-->works fine. Huh?
Nicholas Crosby wrote: >Hello: > >I would appreciate any help on this that someone might have. A student of >mine found this issue. He ftp's a file to a server and looks at it through a >browser, there are errors. He uploads the file again, it works fine. I am >stumped. Any ideas? Here is the text of the file that he is uploading. >Basically, if you add some more text to the bottom and upload it, the page >will not generate the proper output. > > The file is uploaded using an FTP client or it is uploaded using PHP's FTP functions? If I understand correctly, it sounds like the FTP client is having troubles uploading the file. Try to minimize the script and see if you can still reproduce: Hello"; ?> If you upload a script like that, does it get something simple done correctly or does that also require a second upload? Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Smart Quotes not so smart
Robert Cummings wrote: >On Wed, 2006-11-15 at 20:36 -0600, Larry Garfield wrote: > > >>I've run into this sort of issue a few times before, and never found a good >>solution. Now a client has been hit with it and is asking for a solution, >>and I'm not convinced there is one. :-) >> >>Client has a large MS SQL database with lots of data. Some of that data >>includes "smart quotes", aka curly quotes, but not real ones. They're the MS >>Word character encoding standards? What's that?" smart quotes. On their old >>setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually >>worked just fine. On our old devel setup (the same but with a different ODBC >>driver), it worked fine. >> >>On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP >>5.1.6), it works fine. On their new live setup, however, (same, but again >>not sure of the ODBC driver) they're getting the dreaded squares or question >>marks or accented characters that signify a garbled smart quote. I know >>they're not unicode characters because Windows, the DB server, and the driver >>are all set to either UTF-8 or UTF-16. >> >>We've tried eliminating middle-men to no avail. I've also tried doing a >>find-replace on the smart quote characters before they're inserted into the >>database, copying and pasting them from Word, and PHP skips right past them >>and enters them into the database. >> >>All we're left with is MAYBE telling them to dry a different ODBC driver or >>else fixing the data by hand. I don't like either option, myself. Does >>anyone have any better ideas to suggest? Any idea what those smart quotes >>actually are, and if they exist in ANY valid character set other than Word >>itself? >> >> > >There's a few different charsets that support them. Either way, can you >open up some content that has them using a hex editor and tell us the >hex codes for the bytes? That will help determine what charset. > >Cheers, >Rob. > > John Walker's insight might be a good lead on some more information on exactly what these are, even if it doesn't directly solve the problem. I can only guess that their 'smart quotes' exported to HTML from Office apps are the same 'smart quotes' in your database... who knows :p http://www.fourmilab.ch/webtools/demoroniser/ Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
David Giragosian wrote: > Does Daylight Savings alter Zulu time? (I'm guessing "yes"). How did the > military deal with that? > > I use a date-time field as a primary key in db tables that get an > insert a > minute. I had to jump through a number of hoops to turn off DST on the > (RH > Linux) server. > > David > UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone >> Due to daylight saving time, UTC is local time at the Royal Observatory, Greenwich <http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich> only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 <http://en.wikipedia.org/wiki/UTC%2B1>, known in the United Kingdom <http://en.wikipedia.org/wiki/United_Kingdom> as British Summer Time <http://en.wikipedia.org/wiki/British_Summer_Time> (BST). Similar circumstances apply in many places. << ** Travis Doherty TixTime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
Richard Lynch wrote: >What is the least-stupid way to fix this, and get 20:00 in the >Portland OR server to turn into: >Mon, 03 Apr 2006 20:00:00 CDT >which is what time it really was. > >E. Without changing the schema which means having to re-do >everything else in the application. That's probably the RIGHT way to >fix it, but that ain't happening. > > Yeah... I ran into the same stuff a few weeks ago with the DST change. The quickest solution that is *almost* OK is using putenv("tz=america/montreal") or putenv("tz=america/san_diego") etc.. (should really be the date_default_timezone_get/set functions) Datetime fields do not have timezone stored (mysql too.) The only real solution to this problem is to always store datetimes in GMT/UTC. That is the correct thing to do, and until that is done our workaround still has one problem (that isn't big enough to warrant reworking the ticketing code that inserts to the db...) The remaining problem is that until we store in UTC we will never know which 01:30:00 a timestamp refers to, EDT or EST (Eastern Daylight, or Eastern Standard.) In UTC this doesn't happen. Of course there is no problem for spring, only in the fall time change. This can be a big problem to some apps, and others might be fine with the workaround like we've done where you loose a tiny bit of data (It's 08:00 on the day after the timechange, is this ticket from 01:30:00 6.5 or 7.5 hours old? who cares.. just reply.) Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date calculation
Ron Piggott (PHP) wrote: >I have one more date based question. > >I have a month field ( $month ) and a day field ( $day ) being submitted >by a form. > >I have a third field to be used as a date reminder for the information >which was submitted as part of the form. It is a reminder to complete a >task for the date was which was submitted as part of the form. > >How do I calculate the $reminder date based on $month and $day and have >it output in the -MM-DD format? $reminder is the number of days >before $month $day (I want to use $reminder in a date format to SELECT >records from a mySQL table) This is why I am wanting put $reminder into >a date format > >If $month was 6 and $day was 7 and $reminder was 6 then I would want the >output to be 2007-06-01 --- We have already passed June 1st in 2006. >However if $month was 11 then I would want the output to use this years >date --- 2006-11-01 > >Any suggestions? > >Ron > > > I think it would be easier to ask the user to enter his reminder in the standard date format of -mm-dd and use a JavaScript date picker box to prompt for it. Anyway, you could do something like this: $reminderStamp = strtotime("+{$addMonths} months",time()); $reminderStamp = strtoTime("+{$addDays} days",$reminderStamp); $date = date("Y-m-d",$reminderStamp); $date should have a string like -mm-dd that is $addMonths and $addDays into the future. I didn't test this. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Month in a numeric form
Ron Piggott (PHP) wrote: >Is there a way I am able to use the DATE command to convert January to >1, February to 2, etc. > > > What is wrong with date()? www.php.net/date $month = 'Jan'; $numericMonth = date('m', strtotime("$month 01 2000"); Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with overly aggressive anti-spam measures
Dave M G wrote: > 1. Spamassassin says: > > Spam detection software, running on the system "homebase", has > identified this incoming email as possible spam. [...] > > Content analysis details: (0.3 points, 5.0 required) > > pts rule name description > -- > -- > 0.3 AWLAWL: From: address is in the auto white-list > > I looked up about auto white-lists on the net, and it says that it's a > comparison between the current and previous emails. But for testing > purposes, I don't really want it to compare against previous emails, > since previous test emails would be "spammier" and bias spamassassin > the wrong way. > > How can I compensate for this? Yup, as you mentioned the AWL (auto-white-list) is a comparison to previous messages. If that is the only rule that gets hit it looks like you are doing pretty good. You did include the body of the message in the test right? Not just the headers? I expected you would have hit more rules than that. Of course, that is an 'out-of-the-box' install of SA, most people have special rules in there, bayes training done, etc... I believe there is also a website that you can copy paste the message into to perform the same test (see message on this list, "Peter Lauri - PHP Mailer and SMTP = SPAM?") That site might have other rules configured (SARE... etc) that you might be hitting. Worth a shot. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with overly aggressive anti-spam measures
Dave M G wrote: > PHP List, > > I run a few various social groups, and with each one I keep in contact > with members by emailing them short newsletters. > > All my user information is stored in a MySQL database. I use PHP to > get the relevant contact information, and use the mail() command to > send out the emails one by one, so that each email is a little > personalized. > > I've used this system for many years now with no problems up until now. > > What has changed, though, is that in recent years, anti-spam measures > have become so aggressive that more and more people who sign up to my > groups complain that they never receive the emails. > > A lot of the times, after they alert me to the issue, I can educate > them a little about the anti-spam measures they most likely have on > their system, and walk them through how to make it so that my > newsletters go through. > > However, that is clearly not enough. > > To shorten a story that has already gone on a little long, it's come > to my attention that part of the reason that my emails may not be > getting through are because the headers are not sufficiently > legitimate looking enough to bypass some server side anti-spam > measures. Things like "Return-Path" are being set so that they look > like they come from an email address that begins with the username > "nobody". > > If possible, can anyone help me with creating the PHP code that will > make an email as legitimate as it can be? I know I can't totally > prevent my email from being marked as spam (after all, if it were > possible, all the spammers would do it). But as much as I can prevent > anti-spam measures getting a false positive when testing my email, the > better. > > Here is the PHP code I currently use (trimmed for clarity): > > while ( $member = mysql_fetch_row($mysqlResult) ) > { > $subscriber = $member[0]; > $email = $member[1]; > $subject = "Report for " . date('l jS F Y'); > $mailContent = "This is an email to " . $subscriber . " at " . $email > . "."; > $fromAddress = "[EMAIL PROTECTED]" > mail($email, $subject, $mailContent, $fromAddress); > } > > > And here is what the headers for an email from that code looks like: > > -Account-Key: account5 > X-UIDL: UID497-1152485402 > X-Mozilla-Status: 0001 > X-Mozilla-Status2: > Return-path: <[EMAIL PROTECTED]> > Envelope-to: [EMAIL PROTECTED] > Delivery-date: Sun, 03 Sep 2006 14:22:42 -0700 > Received: from nobody by server.myhostingservice.com with local (Exim > 4.52) > id 1GJzQQ-0005pA-Mz > for [EMAIL PROTECTED]; Sun, 03 Sep 2006 14:22:42 -0700 > To: [EMAIL PROTECTED] > Subject: Report for Monday 4th September 2006 > From: [EMAIL PROTECTED] > Message-Id: <[EMAIL PROTECTED]> > Date: Sun, 03 Sep 2006 14:22:42 -0700 > > Which parts are key to change, and how? > > Thank you for any and all advice. > > -- > Dave M G > Ubuntu 6.06 LTS > Kernel 2.6.17.7 > Pentium D Dual Core Processor > PHP 5, MySQL 5, Apache 2 > If it is sendmail it would be the -f parameter to set the Envelope-From address. ie... php.ini would have 'sendmail_path = /pathto/sendmail -f [EMAIL PROTECTED]'. Since PHP 4.0.5 you can also set the additional_parameter like php.net/manual/function.mail.php (the example there is specifically for this use.) What you actually should be doing: install SpamAssasin on your workstation and run the message through it in test mode... Figure out what rules get hit and work to resolve those. Run it like `spamassassin -t < message_with_headers` So, you'd copy your complete message (as you have above) into message_with_headers and run it through SA. Maybe SA is giving you points for things like too many exclamations, certain ratio of HTML... I doubt that having a return-path of 'nobody' is the lowest-hanging fruit you can pick up here to make yourself look less spammy. Also make sure the sending mail server isn't listed in any blacklists (yahoo for RBL lookup tool to check.) Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange errors from command line vs. web
blackwater dev wrote: > Ok, dumb question but how do I do that? I know how to re-compile the > standard php. My code also uses mssql via freetds, does that somehow > need > to be enabled as it doesn't seem to fail there. > > Thanks! > >> > >> > echo "about to connect"; >> > $this->connectionID= @mysql_connect($this->host, $this->user, >> > $this->password); >> > echo "after connect"; >> > > Just to verify that this is in fact the problem you should remove the '@' sign from mysql_connect. '@' is a way of supressing errors, you specifically WANT that error. Is there a reason you have the '@' there? If the error is 'Undefined function mysql_connect' then you do need to get MySQL support compiled in... If it is available on the apache module it should be available to the CLI as well. If there is no 'undefined function' error then you should also be calling 'echo mysql_error()' to see what the error is after connecting. That error is going to give you more info than any of us can. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange errors from command line vs. web
> I have some code that makes a connection to the db. When I run this code > from the command line, it stops at the db connection. If I call the script > from the browser, it works fine. I've changed the permissions and that > didn't work. The db connection is the basic, localhost, root, with no > password. > > What else can I try? Try to get the error message from the DB Connection when it stops. If MySQL something like this (from the PHP Manual for mysql_connect) $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Problem
Richard Lynch wrote: >>if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); } >> >> > >*IF* you are using PHP5 (?) and *IF* your security settings allow it, >the optional fifth argument will let you specify the "real" sender of >the message, which the responder may or may not be using to bounce to. > >http://php.net/mail > > Richard is correct on that. The fifth argument isn't only for the envelope sender, so ensure you include the '-f' for sendmail and compat. wrappers. php.net/mail: ChangeLog: "4.0.5 The additional_parameters parameter was added." >... which the responder may or may not be using to bounce to. > > They should *always* be sending to the envelope from address (SMTP `MAIL FROM` command), with an empty envelope sender (SMTP `MAIL FROM:<>`) to avoid loops. The RFC's are a rather in depth, so here is an excerpt from Wikipedia that pretty much sums up what the RFCs do contain: [http://en.wikipedia.org/wiki/Bounce_message] > The Return-Path is visible in delivered mail as header field > Return-Path inserted by the final SMTP mail transfer agent > <http://en.wikipedia.org/wiki/Mail_transfer_agent> (MTA), also known > as mail delivery agent > <http://en.wikipedia.org/wiki/Mail_delivery_agent> (MDA). The MDA > simply copies the *reverse path* in the SMTP MAIL FROM command into > the Return-Path. The MDA also removes bogus Return-Path header fields > inserted by other MTAs, this header field is generally guaranteed to > reflect the last reverse path seen in the MAIL FROM command. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Problem
> I have an issue with sending email via PHP which may be a configuration > problem with either PHP, Apache, or possibly a Sendmail, but I don't know > which yet. I figured I'd start here first. > > Here's the situation. I have several webpages that send email to users for > various reasons. We have our webserver, an intranet webserver, configured to > connect to our smtp server which sits on a different box. The script looks > like this: > > $from = "[EMAIL PROTECTED]"; > $to = "[EMAIL PROTECTED]"; > $subject = "Test"; > $msg = "This is a test from my sitennTimestamp: " . date("r"); > $headers = "From:$fromrn"; > if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); } > ?> > > This works great when it works. Users receive email as expected and when they > hit reply it goes back to the webmaster email address. The problem is if the > to email address isn't a valid one. When this happens, the mail server > bounces the message back to [EMAIL PROTECTED] instead of [EMAIL PROTECTED] > > I've tried adding reply-to to the mail headers and that doesn't work either. > We tried sending the same failed message using webmin and that worked great, > which is why I believe this to be a PHP or Apache problem. Is it a UNIX box? Sendmail takes the -f parameter in your php.ini to configure its envelope from address... Does not extract it from message headers. The fifth argument to mail() also supports doing this if you need to change it on a per-mail basis. I would just set it in php.ini. (like: sendmail_path = '/usr/bin/sendmail -f [EMAIL PROTECTED]') If its a Win box there is a sendmail_from config param in php.ini. php.net/manual/function.mail.php read for 'Additional Params' the fifth argument, it specifically deals with this case. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there a list of all Timezones as an array or someting?
Google Kreme wrote: > On 20 Sep 2006, at 06:15 , Chris Boget wrote: > >> $timeZonesArray = array( 'GMT'=> array( 'GMT' => +0 >> // GMT > > > Er... ok, but that seems to be missing quite a lot. For example, I > notice that India Standard Time (IST; UTC +5:30) is missing from your > array. Granted, it's only 1.1 Billion people and the largest English > speaking population in the world... (or second most, depending on > whom you ask). > > Or did you just forget to paste the Asia portion of the array? > Most Linux boxen have `|/usr/share/zoneinfo/zone.tab`, or grab it from the database tables in a mysql server (assuming it is setup with timezones imported) which would be the mysql.timezone* tables. |http://www.php.net/putenv The comments have quite a bit on timezones and PHP. The command you will use to change the timezone of the running script is: putenv("TZ=$zone"); The equiv to set a MySQL connection to a certain timezone would be: SET time_zone = '$zone'; http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html That URL has the MySQL side of setting timezones. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reverse of date("w")
Chris Ditty wrote: > Another way to do it would be to store the unix epoch and then just > get the > weekday name from that? More overhead than Travis's idea, but just as > good > and you could possibly use the date/time later on. I use the DATETIME fieldtypes in MySQL, same idea... 100% agreed that keeping that timestamp for later use is a good idea. For Kevin's original question.. Here is the MySQL function to get that short weekday name off of a DATETIME column: Table with datetime column: mysql> SELECT id,effectivetime -> FROM event -> WHERE employee_id ='1001'; +-+-+ | id | effectivetime | +-+-+ | 184 | 2006-09-18 18:50:25 | | 182 | 2006-09-17 23:12:17 | | 178 | 2006-09-12 21:59:44 | +-+-+ 3 rows in set (0.00 sec) Query to get 'weekday': mysql> SELECT id,effectivetime,DATE_FORMAT(effectivetime,"%a") AS weekday -> FROM event -> WHERE employee_id = '1001'; +-+-+-+ | id | effectivetime | weekday | +-+-+-+ | 184 | 2006-09-18 18:50:25 | Mon | | 182 | 2006-09-17 23:12:17 | Sun | | 178 | 2006-09-12 21:59:44 | Tue | +-+-+-+ 3 rows in set (0.00 sec) Those DATETIME columns can do some other neat things too: SELECT * FROM events WHERE starttime BETWEEN '2006-09-18' AND '2006-09-28' Gives me a list of events happening in a certain period... SELECT * FROM events WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) < starttime Gets you the last 30 days without needing to make those '2006-09-18' style strings in PHP code. http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html They should all work on DATETIME type columns, storing seconds since epoch doesn't quite give you that (you could work it in pretty easily I'm sure, why not use the native column type!) Cheers, Travis > > On 9/18/06, Travis Doherty <[EMAIL PROTECTED]> wrote: > >> >> Kevin Murphy wrote: >> >> > Not really. If it were always "today" that would work, but in this >> > case, I was thinking of storing a day of the week in a database >> > ("3"), and then display the info based on that digit. So assuming >> > that the number was in fact 3, then: >> > >> > echo date("D","3"); >> > >> > Would return "Wed". >> > >> > Is there any function like that? Oh, and it has to run on PHP 4. >> > >> >> Any reason you wouldn't write it yourself? >> >> > function getDayFromInteger($integer) >> { >> >>$days = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); >> >>if (isset($days[$integer])) >>{ >> return $days[$integer]; >>} >> >>return false; >> >> } >> ?> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reverse of date("w")
Kevin Murphy wrote: > Not really. If it were always "today" that would work, but in this > case, I was thinking of storing a day of the week in a database > ("3"), and then display the info based on that digit. So assuming > that the number was in fact 3, then: > > echo date("D","3"); > > Would return "Wed". > > Is there any function like that? Oh, and it has to run on PHP 4. > Any reason you wouldn't write it yourself? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail in Spam Box
kartikay malhotra wrote: > Hi all! > > I've use PHP mail to send mail to my Gmail ID. But it gets delivered > to my > Spam box and not the Inbox :( > > Am I missing a header, signature, certificate? > > Thanks > KM > > Is the system you are sending from listed in any RBLs? If you don't set a subject line, SpamAssassin hits you hard, make sure you have a real To:, From:, and Subject: header. The date header also needs to be set - with the correct time. Spam scores come from many different sources of information - two major sources are the message itself and the server sending the message. If you can send mail from this server using a normal mail client and it does not get blocked as spam then it is probably your message. If sending using a normal client still gets blocked as spam in you gmail account chances are it is the server and not your code. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image location hiding techniques
hbeaumont hbeaumont wrote: >Hi, > >I have a site with images that I want people to download but not have >the direct path to. ie. I do not want them to be able to just view the >source, find the dir and then download everything or direct link to >them. > >However I can see no way to do this other than keeping the images on >disk, having a php script read them and then spit them out. example: > >view.php?92348924 where 92348924 is a code that translates to the >image on disk. > > > Doing this would cause an extra hit to disk to load the PHP script and the image instead of just the image file, if you are concerned about disk I/O. You could go the script route as you have mentioned and also add a check on HTTP_REFERER to ensure they came from your site. You might even set a cookie and ensure that exists as well. Randomize the image numbers so they are not sequential, add some alpha characters to make it real fun. Give a 404 Not Found instead of an error if the referer or cookie wasn't set to add some obscurity to the mix. This will deter most people from grabbing all of the images, but if they are available to the public for download it will always be possible for someone to figure out your counter measures. It doesn't mean you can't make it trivial enough that they move along to the next site. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help plz [Books]
Ligaya Turmelle wrote: > I personally liked George Schlossnagle's book "Advanced PHP > Programming", published by Sams. > I am also assuming you actually do know the basics of MySQL and PHP > and are looking for that next step - past the beginner stuff. I agree. I have seen this book alone take "coder" to developer. It is not a beginner's book - but will help you get closer to expert faster than a two foot stack of beginner level material (again, assuming you "are looking for that next step") Leave section five (Extensions) until you are more experienced. "High Performance MySQL" by Zawodny & Balling, O'Reilly -- not PHP specific but essential if your MySQL databases will have heavy load on them. Travis Doherty Ligaya Turmelle wrote: > I personally liked George Schlossnagle's book "Advanced PHP > Programming", published by Sams. > > http://www.amazon.com/gp/product/0672325616/qid=1137394700/sr=2-1/ref=pd_bbs_b_2_1/104-0195316-0794320?s=books&v=glance&n=283155 > > > suresh kumar wrote: > >> hi, >>i am working as a web designer in PHP & Mysql.i >> know the basics of PHP & Mysql,i want 2 become PHP >> Expert,i am planning to buy one Book,but i dont know >> which book 2 buy.plz give me info . >> A.suresh >> >> Send instant messages to your online friends >> http://in.messenger.yahoo.com > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to find the system tmp folder
Samuel DeVore wrote: >How does one find the system temp folder? from php? in a platform >independant way > > > This should help: http://www.php.net/manual/en/function.tempnam.php It does return the name of the temp file created (or FALSE), which could be parsed to get the temp directory as PHP best sees fit. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: failed to open stream warning
zedleon wrote: >>Warning: fopen(home/path/temp") failed to open stream: No such file or >>directory >>I am trying to write a script to work with GnuPG, but can't get past this >>basic problem. >>Everything I try gives me the same warning. > >I just corrected the code...I had it correct but posted it in correctly. > >$fp = fopen("home/path/temp" "w+"); >puts($fp, $msg); >fclose($fp); > >Still getting the same warning... > > There is still an error in that code (missing comma) and the error message also has an unmatched quote. The actual error message seems clear "No such file or directory" - does "home/path/temp" exist, did you mean "/home/path/temp". Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 403 not working -- apache 2 / php5 / linux
you have to allow others to read it. You have it so only root can access the file. Try this: chmod 644 test.php while logged in as root. This should put the file as -rw-r--r-- 1 root root test.php HTH Travis - Original Message - From: "Jason Morehouse" <[EMAIL PROTECTED]> To: Sent: Monday, January 10, 2005 12:49 PM Subject: [PHP] 403 not working -- apache 2 / php5 / linux Hello. I'm not sure if this is an apache problem or php... but wondering if anyone has come across the same problem. -rw---1 root root test.html -rw---1 root root test.php Trying to access test.html via a browser servers up the apache 403 error page. The test.php however produces: Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/www/test.php' for inclusion (include_path='.:/www/php') in Unknown on line 0 Any ideas? Thanks! -- Jason Morehouse Vendorama - Create your own online store http://www.vendorama.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if(date("Y-m-d") >
Maybe this will help. Just keep adding to $var[] until you add all your weeks. Then execute it. This is written to run on the command line, but you can replace the \n with to get your breaks in HTML. $numweeks = count($var); echo "Number of weeks: " . $numweeks . "\n"; $today = date("Y-m-d"); for ($i=0;$i<$numweeks;$i++) { if ($today >= $var[$i]) { $lastweek = $i + 1; } } echo "This is week $lastweek.\n"; ?> HTH Trav www.pinkbunnysuit.com - Original Message - From: "John Taylor-Johnston" <[EMAIL PROTECTED]> To: Sent: Monday, January 10, 2005 12:08 PM Subject: [PHP] if(date("Y-m-d") > Hi, I would like some help to improve this script. I'm a teacher with a schedule of 17 weeks. Instead of using if(date("Y-m-d") >= $week3) I would like to do a "for i = 1 to 17" and if the current date date("Y-m-d") = week[i] I would like to echo "This is week $week[i]"; Can someone show me how please? if(date("Y-m-d") >= $week3) { echo "this is week 3"); } ?> Thanks, John -- John Taylor-Johnston - "If it's not Open Source, it's Murphy's Law." '''Collège de Sherbrooke: ô¿ôhttp://www.collegesherbrooke.qc.ca/languesmodernes/ - 819-569-2064 °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures /(_)\ Université de Sherbrooke ^ ^ http://compcanlit.ca/ T: 819.569.2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GMT
Here has always been a problem I run into with GMT translation. You have to make sure that the system you are working with is set to the correct time zone so that any application trying to automatically figure out the time have the starting point. This is easy enough in Windows, but can mean making sure your /etc/localtime (See http://www.linuxforum.com/linux_tutorials/68/1.php) is correct in linux. Of course there are GUI tools to help with this also for those non-console people. Unfortunately some people rely on shared servers where you do not have root access to change /etc/localtime. Therefore you must have an overloadable function to return the time in GMT. Where it can accept an offset or rely on the systems timezone. To me, it seems best to just use a variable. Print out the time, then do a correct offset for it. But for something already done, see http://us3.php.net/manual/en/function.gmdate.php Travis - Original Message - From: "Bruno B B Magalhães" <[EMAIL PROTECTED]> To: Sent: Tuesday, January 04, 2005 5:04 AM Subject: [PHP] GMT Hi you all, How do you work with GMT time-zones? I mean, I´ve developed a support system, with projects, bugs, tasks, etc... but as I user date()ç,I is 6 hours late from my client´s time-zone... And I would like to make it a little more dynamic than just put a variable in the code and add to the hour. Regards, Bruno B B Magalhães -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Post Data
Why reinvent the wheel by writing your own webserver? Apache allows for it to be used within other products. Just redistrbute it according to the license. - Original Message - From: "Shane Mc Cormack" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 21, 2004 10:36 PM Subject: Re: [PHP] PHP and Post Data That works on a normal webserver yes. However, I am programming my own, and I have the Posted Data stored in the memory of the webserver, and when i execute the PHP.exe i need to tell it what the PostData is somehow. - Shane John Nichel wrote: Shane Mc Cormack wrote: Hi I'm trying to integrate PHP Support into a basic webserver i am creating for personal use (Windows). However i've run into a problem. I've got the _GET vars working, (using the QUERY_STRING Environment Variable), yet i can't figure out how to get the _POST vars set. my webserver has the POST data stored in a variable, i jsut need to know how to tell PHP the post data. On the webserver GET support works perfectly, as does POST support, all i need to do is tell PHP what the data is. Any help would be appreciated. Not sure I follow quite what you're asking, but if you have a form like this... Once you submit the form (to myform.php), the data posted from the form will be available in the $_POST super global array... $_POST['foo'] $_POST['bar'] http://us4.php.net/manual/en/language.variables.external.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to distribute php codes safely?
Well a simple search on Google for "PHP Encoder" brougt back these: http://www.ioncube.com/ $199 http://www.rssoftlab.com/downloads.php - Appears to be Free I am sure there are more. Check http://freshmeat.net for a good Open Source product. Also try http://www.sourceforge.net. As always check to see if the encoders support your current version of PHP. Also, always do a Google search first. Trav - Original Message - From: "Jonathan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 16, 2004 8:21 AM Subject: [PHP] How to distribute php codes safely? Hi, Is there a replace to Zend encoder that I can use for free? Zend encoder is too expensive for a small fry developer like me. Thanks for your help. Jonathan Tang -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting mail() to return false/0
- Original Message - From: "Paul Reinheimer" <[EMAIL PROTECTED]> Hi, I was working with the mail function today to experiment with sending a few messages, and threw in the apropriate checks so when mail() can't send the message the apropriate errors were raised, however, I discovered I couldn't actually get mail() to return 0. Take the following call: mail("dude", "Daily Feed Update", "body"); I assume "dude" is a local user you are mailing to? Make sure you also give a FROM address. Try this: mail("[EMAIL PROTECTED]", "Daily Feed Update", "body", "From: [EMAIL PROTECTED]") -Trav When I run that exact call (well, I prepend echo, but you get the idea) it returns 1. I can't for the life of me understand why my MTA would accept an email with a destination of 'dude'. Any thoughts? paul -- Paul Reinheimer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
Nevermind. I got it - Original Message - From: "Travis Conway" <[EMAIL PROTECTED]> To: "PHP-GEMERAL" <[EMAIL PROTECTED]> Sent: Monday, December 13, 2004 9:30 PM Subject: [PHP] php.ini What is the default place for php.ini? I have a few copies when I do a `whereis php.ini`. I figure it is the /etc/php.ini. Anyone shed some light? Also, is there anything that must be done after I modify the php.ini? Trav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php.ini
What is the default place for php.ini? I have a few copies when I do a `whereis php.ini`. I figure it is the /etc/php.ini. Anyone shed some light? Also, is there anything that must be done after I modify the php.ini? Trav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP &Apache Upload file Permission denied
What user did you run your command line as? Trav - Original Message - From: "Michael Leung" <[EMAIL PROTECTED]> To: "Travis Conway" <[EMAIL PROTECTED]> Cc: "Andre Dubuc" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, December 12, 2004 8:01 PM Subject: Re: [PHP] PHP &Apache Upload file Permission denied Hi all, I am more believing this is a kind of apache configure problem. If that's Fedora 3 problem, I can't do this kind in command line. Therefore, if I bypassed Apache, my problem is solved. Moreover, my system is highly OOP , I can't fall back into PHP 4. yours, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP &Apache Upload file Permission denied
Ha! Sorry for that Fedora 3 is causing all kinds of havoc. I would stay away for a while. Trav - Original Message - From: "Michael Leung" <[EMAIL PROTECTED]> To: "Andre Dubuc" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, December 12, 2004 7:25 PM Subject: Re: [PHP] PHP &Apache Upload file Permission denied Hi Andre, thank you, I have hided my html path in the message. I have replace my real path with '/var/www/html/'. the error message should be like this. Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to > move '/tmp/phpjsLZfC' to '/var/www/html/test/icons.zip' in > /var/www/html/simple_upload.php on line 76. Pervious error message , I have some typing mistakes in there. Yes, this kind of script is working in my pervious old server. But after I have upgraded the OS to Fedora 3 with PHP 5.0.2 and Apache 2. The script does not work any more. I am thinking may be I need to modify some configure in Apache 2 to allow the upload file function. yours, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command Line
- Original Message - From: "- Edwin -" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: "Travis Conway" <[EMAIL PROTECTED]> Sent: Sunday, December 12, 2004 10:40 AM Subject: Re: [PHP] Command Line Hi, On Sun, 12 Dec 2004 09:15:46 -0600 "Travis Conway" <[EMAIL PROTECTED]> wrote: How do you reference command line arguments in php? i.e., chkmd5.php file.md5 I am wanting to reference file.md5. Since the output of md5sum is not in the RFC I am having to manually parse each md5 and detect whether it is in Win32, Linux, or BSD format. I'm not sure what you meant by that (since an md5 checksum is an md5 checksum) but... What I mean is that a Win32 md5sum outputs like hash *file Linux: file:hash -or hash:file and BSD: (file) hash So if I run md5sum -c file.md5 and it was created on another platform, md5sum will not check md5. The hash will be the same but not the file output format. That is all. And since php has good built in md5() support it helps out. I think you're looking for "argv": http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server PS Btw, it's "php-geNeral" and not "php-geMeral" ;) It is much easier to just ask you guys though. Trav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Command Line
How do you reference command line arguments in php? i.e., chkmd5.php file.md5 I am wanting to reference file.md5. Since the output of md5sum is not in the RFC I am having to manually parse each md5 and detect whether it is in Win32, Linux, or BSD format. And since php has good built in md5() support it helps out. Travis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs JSP?
Did he really ask that question on a PHP board? That is like walking into a Coke factory, going to the manager and asking "pepsi or coke?" - Original Message - From: "Raditha Dissanayake" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, December 11, 2004 7:11 AM Subject: Re: [PHP] PHP vs JSP? Peter Lauri wrote: Best groupmember, Why should I choose PHP instead of JSP/Servlets when it comes to develop a high-traffic site. Assume that the infrastructure for both are set up. It only comes to efficiency (both coding and running)? What are your experience? As a sun certified java programmer, let me assure you that PHP is easier to work with. -- - Best Of Times /Peter Lauri -- Raditha Dissanayake. -- http://www.radinks.com/print/card-designer/ | Card Designer Applet http://www.radinks.com/upload/ | Drag and Drop Upload -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For Loop
try for($i=0;$i>$months_arr_length;$i++) look at it as this: for(i as starting point; till i is what? greater than my length; increment i how? by 1) { HTH Trav - Original Message - From: "R. Van Tassel" <[EMAIL PROTECTED]> To: "'PHP general'" <[EMAIL PROTECTED]> Sent: Wednesday, December 08, 2004 3:41 PM Subject: [PHP] For Loop I have a question about the following code: ** $months_arr = array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"); $months_arr_length = count($months_arr); for($i = 0; $i = $months_arr_length; $i++){ echo $months_arr[1]." "; } *** When I run the code above it continues and never stops. According to the PHP documentation the second condition works as follows: "In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends." In the first iteration of the loop $i would equal 0 and the array length is 12. 12 is consistent. To it seems that the loop should STOP when the counter reaches 12, equal to the length of the array. Why is it continuing in a neverending loop? What am I missing? Changing the condition of the for loop to $i <= $months_arr_length; fixes everything and it works properly. Can someone please explain where my confusion is? Thanks, ~R. Van Tassel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql error
Try: SELECT * FROM listing WHERE listing.state = 'WA' AND listing.type = 'RES' AND listing.county = 'clark' AND (listing.price > 15 OR listing.price <=20) Try to not use the word "type". Do not know what it is but I have some problems using it. In the event you have weird problems, try putting the table name before the field like I did (i.e., listing.type). You probably also need the price in params since you want to OR just on those two items. I also assume that you have the price field as a int, bigint, or similar field type which does not require a tick around the value. I also dont think that the back tick works. HTH Travis - Original Message - From: "Richard Kurth" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 05, 2004 3:05 PM Subject: [PHP] mysql error Could somebody tell me way these query gets a error 1064 and does not work. error=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"SELECT * FROM listing WHERE `state` = 'WA' AND `type` = 'RES' query="SELECT * FROM listing WHERE `state` = 'WA' AND `type` = 'RES' AND `county` = 'clark' AND `price` > '15' OR `price` <= '20'"; -- Best regards, Richard mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php 4 to 5
Well, I look at other people's code sice I am new to the whole language. I have only been working with it for about a month and half now. I do have prior experience with languages such as ASP (both JScript and VBscript based). I am probably not going to upgrade now since my stuff "just works". I was just wondering what would be the main advantage. - Original Message - From: "Greg Beaver" <[EMAIL PROTECTED]> To: "Travis Conway" <[EMAIL PROTECTED]> Cc: "PHP-GEMERAL" <[EMAIL PROTECTED]> Sent: Sunday, November 28, 2004 6:15 PM Subject: [PHP] Re: php 4 to 5 Travis Conway wrote: I do not know much about the history of php and do not know why there is active development on both the 4 and 5 major versions, but is there a definite reason for me to migrate from 4 to 5 on my servers? Depends on what you wish to do with php. PHP 5 has far better support for xml and soap than php 4. It has a stricter object model and supports native exceptions for error handling. Iterators, reflection, and __call()/__get()/__set() provide incredibly flexibility. It is new, and so not nearly as stable as PHP 4. Any solutions would need to be custom-written for PHP 5 at this point, although options are beginning to appear. PHP 4 has a big history and is very stable. There are shortcomings that are addressed in PHP 5, but there is a huge codebase. So, the question is, do you rely on other people's code, or your own? If you rely on other people's code, I would wait a year or two to upgrade. Otherwise, what are you waiting for? :) Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php 4 to 5
I do not know much about the history of php and do not know why there is active development on both the 4 and 5 major versions, but is there a definite reason for me to migrate from 4 to 5 on my servers? Trav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mass MySQL INSERT
I am fairly new to the concept of working wity mysql and php. I am looping thru a text file full of county names and attempting to add these to a database. Now the table exists and if I enter the SQL statement manually against the database it works. The user also has read and write permissions to the table and the columns in the table. Here is my php code: $lines = file("/tmp/new1.txt"); foreach ($lines as $line_num => $line) { echo($line . '... '); $link = mysql_connect('naabe', 'naabe', 'x') or die('could not connect: ' . mysql_error()); // I use substr to remove the space at the end of every line. $sql = "INSERT INTO countries (country) VALUES ('" . substr($line,0,strlen($line)-1) . "')"; echo ($sql . ' ...'); mysql_query($sql); mysql_close(); flush(); } This is how I configured php4.3.9 ./configure --enable-so --with-mysql=/usr/local/mysql --enable-filepro --with-apx2=/usr/local/apache2/bin/apxs --with-jpg --with-png --with-xml It will print to the screen the line and the SQL statement correctly. The password is correct. The database name is naabe, the user is naabe. Anyone know what I could be doing wrong? Trav
Re: [PHP] Re: A native Windows binding for PHP
Another way to make money on free software is consulting. Many organizations don't have the time, resources, or interest in adapting free software for their needs. cheers, Travis Manuel Lemos wrote: Hello, "Rubem Pechansky" <[EMAIL PROTECTED]> wrote in message.. I have designed and successfully prototyped a native Windows binding for PHP. This binding is already capable of doing dialogs, controls, and a lot more with very few lines of code. PHP can thus be used as a tool for developing native Windows applications, so it can compete with several much more expensive languages/environments. Go to http://hypervisual.com/winbind/ for more details. This library will eventually grow into a full-fledged IDE. I believe this idea has great potential in the low-end market given the enormous installed base of Windows users and the ever-growing interest about PHP. I'd like to open the code source *and* make a profit at the same time (although I'm not sure if that's possible), so I'm open to any ideas or business opportunities regarding the large-scale development of this product. What do you think? Does this idea have potential? Would any serious company be interested in investing on a project like this? I think that once you have opened the source code, it is hard to make a profit just from its development. On the other hand you can always open the source of the library and develop closed source extensions or tools that make the development of your library more powerful and useful so it will be an advantage for people to buy those extensions and tools from you instead of developing themselves. Regards, Manuel Lemos -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grab a range of rows from a mysql result
select * from foo limit n, m n == starting index, zero-based m == maximum number of rows to return. You probably shouldn't cross-post to different mailing lists. cheers, Travis [EMAIL PROTECTED] wrote: I need to grab a range of rows from a mysql result resource. The resource is made up of 1000+ records from a mysql table that I am breaking up to make my PHP application run faster. I have figured out how to compute the range but I don¹t know how to pull out a group of rows within a range from a mysql result resource. Anyone have any insights into how I can do this in PHP? VR/Tim -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] placing values in html teaxtarea
Would you please turn off return receipt in your messages? Thanks! Travis Hull, Douglas D wrote: After doing calculations etc on my data I am wanting to place it in a textarea form in html. I am having trouble getting my data to show up in my texarea. For example, say after all my calculations I my field called $test ends up containing "This is a test". Here is what I tried: I can add the $test to input like this but not a textarea. Name: Is this possible? Thanks, Doug -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get users MAC-address of visitor
I don't think you can get that information. The packet at the MAC level is encpasulating the IP datagram. When the datagram is passed along to another network (e.g. through a router), another MAC packet is constructed, and the payload (datagram) of the original MAC packet is placed into the new MAC packet. At that point, the original MAC address is lost. cheers, Travis Yngve wrote: Hi! I wonder how i can retrive the MAC-address of the visitor using PHP? What i am thinking about is using the MAC-address instead of the IP-address to ban troublesome users from forums etc. If i just use the IP-address some users will just change it. I know that it´s possibly to spoof the MAC address but it´s much harder than just changing the IP-address. Do you think that there is a big speed penalty by using the MAC-address? I could just use it when the users first arrives to the site. Then he/she could be logged in using a session the rest of his visit. I could also store the MAC-address of the user in encoded form in a cookie so that i won´t have to retrive the MAC-address "the hard way" on every visit. Comments and tips would be greatly appreciated! Yours supersinerely, Yngve -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fw:
$conn = mysql_connect("localhost:3308","user","password"); You are connecting as user "user" with password "password" in the code, yet the error message references "[EMAIL PROTECTED]" so I'm pretty confused. cheers, Travis Sriranganath wrote: - Original Message - From: Sriranganath To: [EMAIL PROTECTED] Sent: Tuesday, June 15, 2004 9:50 AM Dear Sir, I am finding difficulty in inserting a record into a MySQL DB through PHP inpsite of all the privileges given to that database . Can u plz clarify it? Plz let me know what are all the processes that i have to start or include ..;;; in my files: Plz go through my code: and associated erors messages : if (isset($_POST['submit'])) { $conn = mysql_connect("localhost:3308","user","password"); mysql_select_db("database"); $query = "insert into branch (sol_id,sol_desc,ip_address,email_id) values ('".$_POST['solid']."', '".$_POST['brname']."', '".$_POST['ipadd']."', '".$_POST['email']."')"; if (mysql_query($query)) echo 'Success'; else echo 'Failed'; } else { ?> Sol-ID Branch Name IP-Address E-Mail ?> after submitting the inputs; it is giving the following errors: username is the finfaq and database name is also finfaq password and username when i give directly to mysql, it is accepting. Warning: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in /var/www/html/whatnew/a.php on line 3 Warning: MySQL Connection Failed: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in /var/www/html/whatnew/a.php on line 3 Failed When i try to insert directly into the table, it is allowing:. regards Sriranganath -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php as user apache
John W. Holmes wrote: From: "Nirnimesh" <[EMAIL PROTECTED]> I have a problem regarding using my php scripts to write files to my account. We know that php runs as user apache. Now giving write permissions to apache for uploading files to my account essentially means that I have to give write permissions for apache (i.e. o+w). Now, does that not mean that any user which is can run php scripts can have access to my account? Yes (well, has access to that directory). Is there any configuration setting that I'm missing. Safe mode, open_basedir, etc. Is there a way to cause PHP scripts to run as the user and group associated with the apache virtual host? cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Justin Patrin wrote: Travis Low wrote: [I hate K&R indenting] And I'm one of them. :-) I like the K&R version because it saves verticaly space and most editors can't really handle correct tabbing... Arrggghh...TABS. Don't even get me started on tabs... cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
I have to say I like everything about the PEAR coding standards except for the K&R bracing style. I much prefer: if( foo ) { blah; } to if( foo ) { blah; } The latter form (K&R) conserves vertical space, but I find it a lot harder to follow. Harder to move blocks of code around too. I'm sure plenty of people disagree, so of course this is IMHO. cheers, Travis Michael Nolan wrote: charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] triggering php scripts...
Chris Wagner wrote: i am wondering if there is a good way to trigger a php script from a web page *without* sending the user to a new page or opening a new browser windows. for instance, suppose you wanted to make a button/link on a web page that, when clicked, would cause a database entry to be decremented. however, you do not want to refresh the page or open a popup window or any stinky little tricks like that. Use a virtual include to call the php script. or, if this is not possible, does anyone know how to trigger a php script when someone accesses a particular file from an apache server? or if a file from a particular directory is downloaded... I don't think you can do that unless the php script is used to access the file or perform the download you speak of. cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ColdFusion / SQL > PHP / mySQL HELP!
Here's what you do. Assume 10-hour work days. Obviously, you want to start with the schema. That's pretty darn important, so allow yourself a whole day for that. You have four days left. Oh wait -- you will probably have to work the weekend for this one. So you have six days left. That's 60 hours, or 3600 minutes. You have 300 files, so you can't spend more than 12 minutes per file. Wait, you said OVER 300, so try to keep it to 10 minutes per file. To play it safe, spend no more than 8 minutes per file -- that way, you have a little extra time in case something unexpected comes up. It might be easier to buy a CFM-to-PHP converter. You can get those at most Kmart stores. They're usually next to the bacon stretchers and smoke-shifters. Hope this helps! cheers, Travis Chris Jernigan wrote: Hi everyone, Ok, I need serious help. I have been handed a project by my boss to convert an existing site that was built using ColdFusion / SQL into a site that will use PHP / mySQL. The site relies heavily on calls to the database for everything from site content, to an admin area where you can edit that content, to a news ticker, to the actual navigation of the site. What's the problem? I have one week to do this. Oh, and did I mention that I know VERY little about PHP / mySQL. I know NOTHING about ColdFusion or MSSQL. And to top it off, the site in question contains over 300 .cfm files! Does anyone have any idea how I could pull this off? Even if I had a working knowledge of ColdFusion, MSSQL, PHP, mySQL...still one week isn't enough time to retool a site of this proportion. Especially considering that I don't understand any of the code that I'm staring at. I've been a web designer for about five years now. Notice I said "designer" not "developer". I want to learn PHP / mySQL but in order to complete this project I also need to understand ColdFusion in order to replicate the site functionality. Any advice on what I should do? Thanks in advance for your help, Chris -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php and java applets
The link you provided seems broken -- here's another: http://www.raditha.com/java/sandbox/ raditha dissanayake wrote: Tom Playford wrote: That was my original plan. The problem is that if someone works out the commands needed to communicate with the php control page, they will be able to bypass the Java access control systems. I suppose I could use https, but does that encrypt the url and post data? I think you have found yourself trapped in the java applet sandbox. You need to create a signed applet. see http://www.radinks.com/java/sandbox/ for a brief guide. all the best -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cpanel accounting library
Jordi Canals wrote: I'm working on some scripts to manage the [cpanel] accounts directly from PHP (Scripts will be GNU/GPL licensed). After STFW, I've not found any good documentation on it, just the short samples on http://www.cpanel.net/remoteaccess-php.html I haven't found anything more detailed on their site. I just ended up looking at the scripts themselves. They are just wrappers around the scripts that are part of the cpanel installation. If you find more documentation, I'd love to know about it. At this moment, I have access to some servers with the accounting libs installed, but I have no access to the fonts (Which could help to make it work). I didn't have to do anything with the fonts. What problems are you having? If anyone can post a link where to find good docs about this cpanel lib, and, if possible the source code for it, it will help me so much. Here's a snippet: # cpanel idiotically outputs html rather than # programmatically-useful error codes. Thus, we have to manipluate # the output before and after calling cpanel function. flush(); ob_start(); # You can get the $cpkey from the WHM. The rest are yours to fill in. createacct( "localhost", "root", $cpkey, 0, $domain, $acctuser, $acctpass, "packagename" ); ob_end_clean(); # Now we check after the fact to see if account was created. # This is a VERY WEAK test, needs improvement. $accounts = listaccts( "localhost", "root", $cpkey , 0); $keys = array_keys( $accounts ); $account_found = NULL; for( $i = 0; $i < count( $keys ); $i++ ) { if( in_array( $domain, $accounts[$keys[$i]] ) ) { $account_found = TRUE; break; } } There are a few gotchas with this API. For one thing, createacct() always returns the string "Account Creation Complete" no matter if the account was created or not. You have to verify the creation some other way. For another thing, the createacct() function writes directly to the output stream. So all of the stuff you see when you create an account the normal way (using the Cpanel web interface) will be displayed unless you stop it. That's what the flush() and the ob_* stuff does. If you find more information, that would be great. We can trade notes. cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why i could not use DB.php?
David wrote: > hi > I want to use the DB.php to access mysql database, so I add the following line to my > file: > require_once 'DB.php'; Is "my file" the file referenced in the error message below? Namely, D:\Apache2\htdocs\dunj\test\member\connectDatabase.php. I'm guessing the message "No such file or directory" probably came from the operating system. Naively, I would say it means you're wrong about the existence of d:\php\PEAR\DB.php, but I suppose it's possible that the OS might give the same message if the webserver didn't have permissions to read d:\ or d:\php or d:\php\PEAR, etc. Good luck. Travis > > but I get the following error info: > Warning: main(DB.php): failed to open stream: No such file or directory in > D:\Apache2\htdocs\dunj\test\member\connectDatabase.php on line 2 > > Fatal error: main(): Failed opening required 'DB.php' (include_path='.;d:\php\PEAR') > in D:\Apache2\htdocs\dunj\test\member\connectDatabase.php on line 2 > > what happened? > i am convinced that the DB.php exists under the directory 'd:\php\PEAR'. > > > David Oilfield > China Lottery Online Co. Ltd. > Email:[EMAIL PROTECTED] > Mobile:13521805655 > Phone:010-83557528-263 > -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] i need help
You need to learn how to use regular expressions. The manual page is here: http://www.php.net/manual/en/ref.pcre.php I could easily write the regular expression for you, but then you wouldn't learn anything. cheers, Travis Student wrote: Hi i was hoping if someone can help; I want to trim the following text [i:abcdef] but the inside text is different at time eg abcdef, bcdefg, etc etc how can i trim [i:(some text here)] so that i can replace them with nothing. eg these are to be trimmed. [i:abcdef] [i:bcdefg] [i:xyzab] [i:priftds] how can i trim them.. thanks -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what do '?' and ':' do?
They confuse non-C programmers, mostly. See this: http://www.php.net/operators.comparison cheers, Travis Radek Zajkowski wrote: Here's a code snippet // call gui object method $method = $cmd."Object"; $class_name = $objDefinition->getClassName($obj_type); $module = $objDefinition->getModule($obj_type); $module_dir = ($module == "") ? "" : $module."/"; what does the semicolon and the question mark do? TIA R> - -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create if table not exists
The manual says: "; } ?> To paraphrase, just use mysql_list_tables() to get a table list in a result set, then go through the result set to see if the named table exists. But wouldn't it be easier to create the tables in the first place? cheers, Travis John Taylor-Johnston wrote: How can I check if a table exists in a mysql db. If it table does not exist, then, $news = mysql_query($sql_create); else $news = mysql_query($sql); Not sure I know where to start? -snip $server = "localhost"; $user = "user1"; $pass = ""; $db="user1table"; $table="comments"; $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $sql = 'SELECT * FROM '.$table.' WHERE MATCH (username) AGAINST (\''.stripslashes($searchenquiry).'\' IN BOOLEAN MODE) ORDER BY id asc;'; $sql_create = "CREATE TABLE ".$table." ( id int(11) NOT NULL auto_increment, username varchar(100) NOT NULL, comment text, PRIMARY KEY (id) ); Sorry, I'm not even sure if this is a php thing as much as it is also mysql. - John -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New Newbie Question
Change: value= to value="" or value="" cheers, Travis Ronald "The Newbie" Allen wrote: Here is my problem: When I get the value of $date and I echo it it shows up just fine $date = date("Y-m-d H:i"); echo "$date"; 2004-05-15 16:20 but when I go to insert the value into a form like this Time: size="50"> it only displays 2004-05-15 why is this????? Annoying Master Station Log Time: size="50"> -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SuExec and PHP
I sent this a couple days ago and haven't heard a peep. Can anyone help me? Or, is there a better place I could be asking these questions? cheers, Travis Travis Low wrote: Greetings. We have a need for our PHP scripts to run as the user and group associated with each Apache virtual domain on our Redhat server. Currently, all PHP scripts run as nobody.nobody. I know that the apache suexec module allows CGI scripts to run as the user and group of the virtual host, but that doesn't seem to be the case for PHP scripts run under the apache php module (mod_php). So my questions are: (1) Can we use suexec to force PHP scripts (running under mod_php) to run as the user/group associated with the virtual host? If so, how? Are there any special configuration tricks to make this happen? (2) If we CAN'T use suexec with mod_php, I assume we can run PHP as CGI to solve our problem. However, I'm worried about performance. Have any of you done this on linux? Is it difficult to configure? Do you have to audit all of your PHP scripts? Etc., etc. I did read the pages http://www.php.net/security.cgi_bin and http://www.php.net/manual/en/security.apache.php, but did not come away with clear answers to my questions. There were also a lot of contradictory comments at the bottom of those pages, and a whole mess of stuff on google, so I'm getting more lost, not less. Please help! cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5() with rand() || Strange results, need help....
Besides checking the browser cookie settings, have one of the affected users turn off the auto-fill form feature, then tell the browser to forget all saved form information. Let us know what happens. cheers, Travis CF High wrote: Re: the browser track, it looks like all adversely affected users; i.e. those who can no longer log in, have a browser of I.E. 6.0. I know that in many cases I.E. 6.0 has session and cookie vars disabled by default. Is it possible, a long, long shot, that rand() behaves differently in I.E. 6.0 -- I know PHP is server side, but I'm looking for any clues --Noah "John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] CF High wrote: If anyone has any clues as to what might be happening; i.e. why the md5'd submitted plain text password does not match the stored md5'd password, please, please let me know. md5() results in a 32 character string. What kind of field are you storing it in? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 - instanceof
An instance only exists after it has been instantiated. So you can't know anything about an instance (== an object) beforehand. It's like knowing a person before they are born. Maybe you mean you want to determine if class B is a subclass of class A. That's the same problem again. Even if PHP5 had a Class object (a la Java), you'd have to instantiate *it* in order to find the relationship between class A and class B. Prior to that point, you only have text strings to work with. I suppose you could search the text of the file for "extends FooBar" or something. cheers, Travis Martin Towell wrote: I have been playing with PHP5 and am liking it more and more. But I have one question about "instanceof" If you have something like this: This would echo "BA". That's good, I understand that. Now the question: Is it possible to determine if B is an instance of A without instantiating it? Thanks Martin -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SuExec and PHP
Greetings. We have a need for our PHP scripts to run as the user and group associated with each Apache virtual domain on our Redhat server. Currently, all PHP scripts run as nobody.nobody. I know that the apache suexec module allows CGI scripts to run as the user and group of the virtual host, but that doesn't seem to be the case for PHP scripts run under the apache php module (mod_php). So my questions are: (1) Can we use suexec to force PHP scripts (running under mod_php) to run as the user/group associated with the virtual host? If so, how? Are there any special configuration tricks to make this happen? (2) If we CAN'T use suexec with mod_php, I assume we can run PHP as CGI to solve our problem. However, I'm worried about performance. Have any of you done this on linux? Is it difficult to configure? Do you have to audit all of your PHP scripts? Etc., etc. I did read the pages http://www.php.net/security.cgi_bin and http://www.php.net/manual/en/security.apache.php, but did not come away with clear answers to my questions. There were also a lot of contradictory comments at the bottom of those pages, and a whole mess of stuff on google, so I'm getting more lost, not less. Please help! cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_RAW_POST_DATA
Chris Shiflett wrote: --- Curt Zirzow <[EMAIL PROTECTED]> wrote: Check the value of "always_populate_raw_post_data" in php.ini on both servers. Thats such a funny name. Not to mention misleading, since it doesn't always populate $HTTP_RAW_POST_DATA when enabled. Always should mean always. No, no, that's crazy talk. :-) cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: protecting web page
Petr U. wrote: On Sat, 08 May 2004 21:00:43 -0500 Anguz <[EMAIL PROTECTED]> wrote: > > Do you know any solution that can help me. I've find an application named > > HTML guard but it only work for static html pages. I need more a class or > > function to prevent for printing. There is _no way_ to really hide/protect html page on client side.. If someone (some knowing) would like to show your source and it's important for him, then he spend some time to break this ugly protection. Just to strengthen/clarify this statement, look at it this way. The user has downloaded the data to his machine. You don't have any control over the data after that point. Heck, the user can just print the screen they are looking at. How you gonna stop that? If you're just looking to discourage casual copying, then carry on. :-) If it's really important, you might be able to generate non-printable PDF files, or generate images containing the desired text, or stuff like that. Just to make copying/printing harder. cheers, Travis -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Profiling (Was: Re: [PHP] PHP Website Architecture)
Hi Richard, Just curious...how do you do your profiling? cheers, Travis Richard Davey wrote: Hello Ryan, Friday, May 7, 2004, 4:51:45 PM, you wrote: RA> Nearly all programs can be written in *one* very large .php file but just RA> thinking of going back in to make changes 3 months down the road would be a RA> nightmare. I was just looking at this the other day - I had a local site running here and profiling the index page took around 800ms with 30 include files. Out of interest I dumped a load of those files into one and re-profiled it (11 includes rather than 300) and the load time dropped dramatically (300ms). I know there are other factors at play here (Windows vs. Unix, cached vs. needing to seek across the hard drive every time), but the difference still surprised me. Of course I could never cope with all of those files "as one", but I will definitely keep them split up locally and combine into one when published live. -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A work around my HTTP_REFERER Prob...
How about something like this: Write a script on server 1 to accept "username" and "password" parameters. If successful, it echoes "1", if not, it echoes "0". On server 2, you do something like this: $s = file("http://server1?login.php?username=$username&password=$password";); if ($s[0]) { # User is logged in. } You can also write the script on server1 so that it only returns 1 if the request came from server2. Disclaimer: I know this scheme isn't airtight, but it beats relying on the referer. cheers, Travis [EMAIL PROTECTED] wrote: To recap... We have two servers: 1. USA - holds most of our databases, and E-mail. but specifically, the usernames and passwords, or all our users (Lotus Domino Server) 2. UK - Runs our website. (Unix Server) We wanted to be able to allow people to login on on server 1, and getr authenticated etc, and then get redirected to server 2. Using http_referer we would confirm that they came from server 1 However, as I discovered, that is not possible. So what we did was this: On the login form on server 1, the referering URL to server 2, contains a varibale called 'secure' we asign that variable that value of '4654376534' and divide it by the day (eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide by 7) I know that this is crackable, but it's just a stop gap measure... My problem today is this: It's not confirming the values? See my code below session_start(); $today_day = date("d"); $code1 = ($today_day+1) * $secure; $code2 = $today_day * $secure; $code3 = ($today_day-1) * $secure; $master_code = 4654376534; if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 == $master_code)) { $_SESSION[logged] = 'true'; $login_info = "You are now Logged in"; } else if ($_SESSION[logged] == 'true') { $login_info = "You are still Logged in"; } = I start by getting the date $today_day As we're in two time zones, I don't wanna get caught out by the time difference, so I've created a +/- 1 each side ($code1-3) and fianlly, asigned the master input variable (the decoder) Now it all works great..! (all variables echo what they should) however, I'm not getting logged in? I'm really stumped... any ideas? Tris... * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** -- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php