Re: [PHP] redirect http to https
On 4/10/07, Zoltán Németh [EMAIL PROTECTED] wrote: I have separate document roots for the http and the https stuff, say htdocs and htdocs-secure - this can be done with apache configuration then I need only to put a single redirecting line into the htdocs/index.php like ?php header(Location: https://my.server.com/;); ? and that's all greets Zoltán Németh 2007. 04. 9, hétfő keltezéssel 08.40-kor Ben Liu ezt írta: What's the prescribed method for redirecting a user forcibly to from the non-SSL secured version of a page to the SSL-secured version? Is this handled at the web server level or at the script level. I found this by googling: ?php if($_SERVER['SERVER_PORT'] !== $encport || $_SERVER['HTTPS'] !== on) {header(Location: https://.$_SERVER['SERVER_NAME'].$_SERVER ['SCRIPT_NAME']);exit;} ? What do people think about this solution? Thanks, - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe you should also be sending a 301 status header so user agents can be made aware of the redirect and make updates accordingly (bookmarks, etc.) http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2
[PHP] XSLTProcessor-transformToURI() error handling
If there is a failure in 'XSLTProcessor-transformToURI()' (it returns false) is nothing written to the file specified? I ask because I'm implementing a caching system. I'm having the output written to a cache file and want to be guaranteed that in case of error, the specified file remains as it was before the operation. In other words, I'd like the destination file to be written to IF and ONLY IF the transformation is successful. Is this the case? Jason Karns ~~~ The Ohio State University [www.osu.edu] Computer Science Engineering [www.cse.osu.edu] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Logical OR in assignment
I once saw the use of OR (|) in assignment. $x = $y | $z; Does this use bitwise OR? I'm trying to see if I could use the above expression in place of: $x = is_null($y) ? $z : $y; Jason Karns ~~~ The Ohio State University [www.osu.edu] Computer Science Engineering [www.cse.osu.edu] -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 9/22/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SPL Iterator and Associative Array
I'm going to try my best to explain what I'm trying to do. I have my own class that has an array member. This class itself implements Iterator. One of the fields in the array is itself an array that I would like to iterate over. Here's some code: class Folio implements Iterator { $projects = array( array( 'title'=, 'clip'=, 'small'=array('1','2','3')), array( 'title'=, 'clip'=, 'small'=array('0','1','2')) ); function title($x){ return current($this-projects[$]['small']); } function smalls($x){ return $this-projects[$x]['small']; } } And I'd like to do: foreach($folio-smalls() as $s){ echo $folio-title(); } However, at the moment, doing this doesn't increment through the 'small' array. It loops the correct number of times. But it only prints the first one. I assumed it was because it wasn't moving the internal array pointer. So I tried making the method smalls return a reference. Doing that made the following work perfectly: reset($folio-smalls()); while($s = current($folio-smalls())){ echo $folio-small(); next($folio-smalls()); } But trying the foreach loop printed the second, and third elements, then tried to output one passed the end of the array. From what I understand, foreach simply expands to reset(); while($x=current()) {...; next();} What do I do? Jason Karns ~~~ The Ohio State University [www.osu.edu] Computer Science Engineering [www.cse.osu.edu] smime.p7s Description: S/MIME cryptographic signature
[PHP] RE: SPL Iterator and Associative Array
-Original Message- From: Greg Beaver [mailto:[EMAIL PROTECTED] Sent: Friday, June 02, 2006 10:39 PM To: Jason Karns Cc: php-general@lists.php.net Subject: Re: SPL Iterator and Associative Array Jason Karns wrote: I'm going to try my best to explain what I'm trying to do. I have my own class that has an array member. This class itself implements Iterator. One of the fields in the array is itself an array that I would like to iterate over. Here's some code: snip snip Hi Jason, The code you pasted is littered with fatal errors and bugs (I marked one example with ^^ above). Please paste a real batch of code that you've tested and reproduces the error and that will be much more helpful. The PHP version would be helpful to know as well. Greg -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.1/354 - Release Date: 6/1/2006 ?php class Folio implements Iterator { private $projects = array(); private $valid = FALSE; public function __construct($file = null) { if(!is_null($file)) $this-load($file); } public function load($file){ ... $keys = array(); $values = array(); foreach ($projects as $project) { $small = array(); $big = array(); foreach ($xpath-query('showcase/images/screenshot/thumbnail',$project) as $img){ $small[] = $img-nodeValue;} foreach ($xpath-query('showcase/images/screenshot/src',$project) as $img){ $big[] = $img-nodeValue;} $keys[] = $xpath-query('@id',$project)-item(0)-nodeValue; $values[] = array( 'title'=$xpath-query('showcase/title',$project)-item(0)-nodeValue, 'href'=$xpath-query('livesite',$project)-item(0)-nodeValue, 'clip'=$xpath-query('showcase/images/feature/thumbnail',$project)-item(0) -nodeValue, 'big'=$big, 'small'=$small, 'text'=$xpath-query('showcase/description',$project)-item(0)-nodeValue); } $this-projects = array_combine($keys,$values); } function smalls($x=null){ if(is_null($x) or !key_exists($x,$this-projects)) $x = $this-key(); return $this-projects[$x]['small']; } function small_src($x=null){ if(is_null($x) or !key_exists($x,$this-projects)) $x = $this-key(); return current($this-projects[$x]['small']); } function small($x=null){ if(is_null($x) or !key_exists($x,$this-projects)) $x = $this-key(); return 'a href='.$this-small_href().' title='.$this-small_title().''.$this-small_img($x).'/a'; } } ? ?php reset($folio-smalls()); while($s = current($folio-smalls())){ echo $folio-small(); next($folio-smalls()); } foreach($folio-smalls() as $s){ echo $folio-small(); } ? Production server will be PHP 5.1.2, developing on 5.0.5 I am also considering making my own 'project' object and having Folio have an array of 'projects' rather than using the array of associative arrays. Would this provide a solution? Thanks, Jason smime.p7s Description: S/MIME cryptographic signature
RE: [PHP] Re: array variables with or without quotes
I believe it is because without the quotes, it is expecting a predefined constant. With the quotes, it is expecting an array key. This is why if you use a word that is not defined as a constant, php will first look for it as a constant, won't find it, then looks through the array treating it like a key. If it is found as a constant, then the constant's value is used as the key. Jason -Original Message- From: Chuck Anderson [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 22, 2006 3:30 PM To: php-general@lists.php.net Subject: [PHP] Re: array variables with or without quotes 2dogs wrote: I recently encountered a situation where I had to retrieve data from a MYSQL database table with a field named include. My code looked like this: $content_result = mysql_query('SELECT * FROM calander') or die(mysql_error()); $content_row = mysql_fetch_array($content_result); if ($content_row[include]) {go do something;} When I tried to run this, PHP treated the word -include- as a control structure rather than an index name. Understandable. So, I put it in single quotes ('include') to see what would happen and it works fine. But I don't understand why! What is the difference between $content_row [include] and $content_row['include']? I have been unable to resolve this question in the php manual, I need enlightenment. 2dogs http://www.php.net/manual/en/language.types.array.php#language.types.array.f oo-bar -- * Chuck Anderson . Boulder, CO http://www.CycleTourist.com Integrity is obvious. The lack of it is common. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php smime.p7s Description: S/MIME cryptographic signature
RE: [PHP] Re: [PHP-DB] Drag and Drop with PHP and MySQL
I've used this (radlinks upload) on one of my sites and it works great. Drag and drop, even multiple files. Jason Karns ~~~ Web Designer Applications Programmer 3AM Productions www.3amproductions.net - Things look different @3AM -Original Message- From: Joe Harman [mailto:[EMAIL PROTECTED] Sent: Friday, November 18, 2005 11:31 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: [PHP-DB] Drag and Drop with PHP and MySQL Here is what you are asking for I think.. it uses Java. I did have a complication letting the applet install.. also, it's not free, but there is a Lite version. Hope this helps http://www.radinks.com/upload/dnd.php Joe On 11/18/05, Nate Nielsen [EMAIL PROTECTED] wrote: You wont be able to do the drag and drop, but you can gracefully do multiple file uploads with flash (via flash 8). It also lets you know the progress of the file upload itself. I've done a snazzy picture upload tool for a Flex (generates flash applications on the fly with ActionScript and XML files only - no actual flash IDE) - it allows you to select a file, hit upload, shows a progress bar of the transfer (you can cancel at any time) - and when done, the image is made into a thumbnail and shown on the screen. -obviously, no page reloads and totally cross compatible. I wouldnt know where to start with regular flash as I'm a programmer, so only Flex appeals to me - but I know it can be done, and isnt extremely complicated. My guess is that you could have a flash guru whip something out pretty fast. =) -Nate Nielsen [EMAIL PROTECTED] - Original Message - From: Jasper Bryant-Greene [EMAIL PROTECTED] To: Joe Harman [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Friday, November 18, 2005 8:52 PM Subject: Re: [PHP] Re: [PHP-DB] Drag and Drop with PHP and MySQL Joe Harman wrote: Hi Chris, I would think that there has to be something out there like a Javascript that would accomplish that... that would be my first guess anyhow... there possibly could be something done in flash that would act as a drop area for the file... let us know what you find Joe There's no way the browser is going to let JS have access to the user's filesystem. I would expect ditto for Flash, although I don't use it. Jasper On 11/18/05, Micah Stevens [EMAIL PROTECTED] wrote: No. That would be nice though eh? What I have done in the past is when a user needs to upload a file, I give them a linked button that links to a ftp:// style address. This ftp account points to a directory that PHP can have access to. The user then drags and drops (IE only) the files on this new window, which uploads the files to this directory. Once they're done, they close the window, and hit a second button 'Click here when finished uploading' which tells php to grab all the files in the upload directory and put them where they need to go. This is far from ideal, causes miserable problems when more than one person is using the technique at once, and offers a host of security and usability issues. Oh, and it's IE only, Firefox can't do this, and I don't think opera/safari can either. However, it's much better than uploading a ton of files individually using a form. I only use this for applications where I can be sure that only one user will use it at once, and they're trusted. In a pinch it works though. I don't care so much about drag and drop, I was just trying to solve the multi-file upload issue. I wish there was a better way. If I'm stupid and there is, I'd love to hear about it. -Micah On Friday 18 November 2005 5:42 pm, Chris Payne wrote: HI there everyone, I have a file upload system where you select via requester the file to upload, it then uploads it with PHP and stores the info in a MySQL database. Is there an interface / programming method I can use which I can DRAG a file from the desktop into an area in a form just as if I had used a file requester to select a file? Learning a new programming technique is no problem as long as it can be used with PHP and MYSQL. Any helps / pointers would be REALLY welcome. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fckeditor and PDF and pesky users
-Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Monday, October 17, 2005 5:11 PM To: Torgny Bjers Cc: php-general@lists.php.net Subject: Re: [PHP] fckeditor and PDF and pesky users On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote: Also, when using iframe/ you are weeding out those old browsers that If somebody else wants to weed out old browsers, that's all fine and good, but that's not me... Besides, if this is for an editor interface, for a specific client, one could reasonably demand that they use at least one of the newer browsers such as IE5+ or Mozilla. If not for a specific client, or subset of clients, but for a general update of an entire application that is open sourced, I agree with Jasper, don't touch it. :) I personally don't think I should demand editors use a specific browser. I believe in customer choice. For that matter, *I* probably don't use a browser that does this right, being as I'm usually on Linux, almost always on Netscape, and very very very rarely do PDF and/or Flash work really right for me. And you know what? I very very very seldom care badly enough about any of the content I'm missing and when I do care enough to go get it, I'm disappointed by the content more often than I'm pleased that I took that effort. Again, this is obviously MY weird world-view at work here. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Not that you'd want to use a deprecated tag, but using an embed tag with a src value pointing to a PDF file (with appropriate height/width) will render the entire Adobe plugin with toolbars and all directly in the page, as demonstrated here: http://www.cstv.com/auto_pdf/p_hotos/s_chools/osu/sports/m-footbl/auto_pdf/w eekly-release Jason Karns -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php