php-general Digest 15 Mar 2013 06:21:40 -0000 Issue 8163
php-general Digest 15 Mar 2013 06:21:40 - Issue 8163 Topics (messages 320536 through 320556): Re: Accessing Files Outside the Web Root 320536 by: Jim Giner 320537 by: Ravi Gehlot 320538 by: Dale H. Cook 320541 by: Jim Giner 320544 by: Maciek Sokolewicz 320545 by: Marc Guay 320547 by: Dale H. Cook 320550 by: Dale H. Cook Accessing Files Outside the Web Root - Progress Report 1 320539 by: Dale H. Cook 320540 by: Jim Giner 320548 by: Dale H. Cook 320551 by: Jim Giner variable type - conversion/checking 320542 by: georg 320543 by: Matijn Woudt 320546 by: Samuel Lopes Grigolato 320554 by: Jim Lucas 320555 by: Matijn Woudt 320556 by: Jim Lucas ODBC obscuring the SQL result ? 320549 by: georg PHP context editor 320552 by: georg php gd extension with cPanel 320553 by: David Mehler Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 3/13/2013 4:38 PM, Dale H. Cook wrote: Let me preface my question by noting that I am virtually a PHP novice. Although I am a long-time webmaster, and have used PHP for some years to give visitors access to information in my SQL database, this is my first attempt to use it for another purpose. I have browsed the mailing list archives and have searched online but have not yet succeeded in teaching myself how to do what I want to do. This need not provoke a lengthy discussion or involve extensive hand-holding - if someone can point to an appropriate code sample or online tutorial that might do the trick. I am the author of a number of PDF files that serve as genealogical reference works. My problem is that there are a number of sites which are posing as search engines and which display my PDF files in their entirety on their own sites. These pirate sites are not simply opening a window that displays my files as they appear on my site. They are using Google Docs to display copies of my files that are cached or stored elsewhere online. The proof of that is that I can modify one of my files and upload it to my site. The file, as seen on my site, immediately displays the modification. The same file, as displayed on the pirate sites, is unmodified and may remain unmodified for weeks. It is obvious that my files, which are stored under public_html, are being spidered and then stored or cached. This displeases me greatly. I want my files, some of which have cost an enormous amount of work over many years, to be available only on my site. Legitimate search engines, such as Google, may display a snippet, but they do not display the entire file - they link to my site so the visitor can get the file from me. A little study has indicated to me that if I store those files in a folder outside the web root and use PHP to provide access they will not be spidered. Writing a PHP script to provide access to the files in that folder is what I need help with. I have experimented with a number of code samples but have not been able to make things work. Could any of you point to code samples or tutorials that might help me? Remember that, aside from the code I have written to handle my SQL database I am a PHP novice. Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants; Plymouth Co. MA Coordinator for the USGenWeb Project Administrator of http://plymouthcolony.net You can't link to these files outside of the web root using any html tags - you have to do it thru php. So, instead of an a tag pointing to it, just have the a tag point to a script with a url containing a ?file=xxx portion as in: a href=pdflookups.php?filename=pdf_1Show Me File 1/a In that script you simply recognize the filename argument and retrieve it from the folder that you are storing it in and send that pdf to the client or place it in the page that you are currently trying to display. Whatever. And use a captcha (which I personally can never read!) to keep the robots at bay. ---End Message--- ---BeginMessage--- Hello Dale, The spiders are not the only problem. The issue here is that anyone can download your files from your website and then make them available elsewhere. In order to address the problem, you should create a Members Restricted Area where members only could download your files. You can then make your PDF directory only visible through your Members Restricted Area. That directory would be invisible to the web. In some Linux distros, if the file/directory is not a member of www-data, it is not visible online. But you can still link the files to your PHP page. Ravi. On Wed, Mar 13, 2013 at
php-general Digest 15 Mar 2013 19:32:31 -0000 Issue 8164
php-general Digest 15 Mar 2013 19:32:31 - Issue 8164 Topics (messages 320557 through 320585): Re: variable type - conversion/checking 320557 by: Peter Ford 320559 by: tamouse mailing lists Type of a variable in PHP 320558 by: Kevin Peterson 320560 by: Karim Geiger 320563 by: Lester Caine 320565 by: Sebastian Krebs rather a HTML Q; however 2-FRAME 320561 by: georg 320564 by: tamouse mailing lists 320567 by: Tim Streater 320575 by: georg 320576 by: georg 320577 by: Stuart Dallas 320578 by: georg 320581 by: tamouse mailing lists 320582 by: Jim Giner Re: PHP context editor 320562 by: Karim Geiger 320566 by: Sebastian Krebs Undefined index 320568 by: Jay Blanchard 320570 by: Serge Fonville 320571 by: Jay Blanchard 320572 by: Serge Fonville 320573 by: Lester Caine 320579 by: Tim Streater 320580 by: Jay Blanchard Re: Accessing Files Outside the Web Root 320569 by: Dale H. Cook 320574 by: Stuart Dallas 320583 by: Dale H. Cook 320584 by: Marc Guay PDO Transaction 320585 by: Simon Dániel Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS ---End Message--- ---BeginMessage--- On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any
Re: [PHP] variable type - conversion/checking
On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Type of a variable in PHP
Have two questions - 1. How to find type of a variable in PHP. 2. How to find the type of an array in PHP. Please help.
Re: [PHP] Type of a variable in PHP
Hi, On Fri, 2013-03-15 at 09:55 +, Kevin Peterson wrote: Have two questions - 1. How to find type of a variable in PHP. 2. How to find the type of an array in PHP. Please help. Use this: http://php.net/manual/en/function.gettype.php Regards Karim -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 signature.asc Description: This is a digitally signed message part
[PHP] rather a HTML Q; however 2-FRAME
I have a need to make a pure display in a (HTML tagged area defined by) FRAME now so far I have only succeeded in making output into a frame by landing a clicked tag to open the new doc (href or src) in a specified frame. Possibly its not solvable with framework of frames. ( I know, FRAMEs are a dying breed, depressed by HTML society, sorry deprecated possibly my issue is fixable by style-sheets but I havnt gotten that far yet, too complex ) tnx for any input georg
Re: [PHP] PHP context editor
Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 signature.asc Description: This is a digitally signed message part
Re: [PHP] Type of a variable in PHP
Karim Geiger wrote: Have two questions - 1. How to find type of a variable in PHP. 2. How to find the type of an array in PHP. Please help. Use this: http://php.net/manual/en/function.gettype.php BUT - bear in mind that the nice thing about PHP 'arrays' is that they are a not restricted to a single type. The elements of an array can be different types. It's more a 'basket' than a traditional array. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 5:00 AM, georg georg.chamb...@telia.com wrote: I have a need to make a pure display in a (HTML tagged area defined by) FRAME now so far I have only succeeded in making output into a frame by landing a clicked tag to open the new doc (href or src) in a specified frame. Possibly its not solvable with framework of frames. Not 100% sure of what you want, but can't you just populate the frames directly? frameset rows=10%,* frame name=upper src=upperframe.php frame name=lower src=lowerframe.php /frameset the link in the src attribute populates it initially. You already know how to populate them with links. ( I know, FRAMEs are a dying breed, depressed by HTML society, sorry deprecated possibly my issue is fixable by style-sheets but I havnt gotten that far yet, too complex ) Frames are not only deprecated, they are unsupported entirely in HTML5 (not that browsers won't continue to display them; just that they won't validate). Leap the hurdle and start to look at Web 3.0 stuff with backbone.js, twitter's bootstrap, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of a variable in PHP
2013/3/15 Kevin Peterson qh.res...@gmail.com Have two questions - 1. How to find type of a variable in PHP. gettype(), or one of the is_*()-functions. But for me more interesting for me: Why do you _need_ this? 2. How to find the type of an array in PHP. An array is of type array :) is_array() or again gettype(). Can you maybe describe what you want to achieve? In a dynamically typed language it is rarely _required_, that you know the _concrete_ type. Please help. -- github.com/KingCrunch
Re: [PHP] PHP context editor
2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 -- github.com/KingCrunch
[PHP] Re: rather a HTML Q; however 2-FRAME
On 15 Mar 2013 at 11:00, tamouse mailing lists tamouse.li...@gmail.com wrote: Frames are not only deprecated, they are unsupported entirely in HTML5 (not that browsers won't continue to display them; just that they won't validate). Meaning, in other words, that they *are* supported. It's unlikely in any case that any feature will ever be removed from a browser. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Undefined index....
I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) { // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Why do I get the notice that $xml is an undefined index? I do not want to suppress the notice, I just want to take care of it properly. I attempted setting $xml within the function but then the whole function fails for some reason in the depths of this hideous framework. Can anyone provide any insight? TVMIA! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP] Accessing Files Outside the Web Root
At 09:44 PM 3/14/2013, tamouse mailing lists wrote: If you are delivering files to a (human) user via their browser, by whatever mechanism, that means someone can write a script to scrape them. That script, however, would have to be running on my host system in order to access the script which actually delivers the file, as the latter script is located outside of the web root. Dale H. Cook, Market Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA http://plymouthcolony.net/starcityeng/index.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined index....
Hi, Two questions: Where is $xml defined and where is $pos defined? HTH Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl Convince Microsoft! They need to add TRUNCATE PARTITION in SQL Server https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table 2013/3/15 Jay Blanchard jay.blanch...@sigmaphinothing.org I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) { // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Why do I get the notice that $xml is an undefined index? I do not want to suppress the notice, I just want to take care of it properly. I attempted setting $xml within the function but then the whole function fails for some reason in the depths of this hideous framework. Can anyone provide any insight? TVMIA! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined index....
[snip] Two questions: Where is $xml defined and where is $pos defined? [/snip] $xml is defined in other functions, just not in this function. $pos is irrelevant to the question - it is just the string position within the file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined index....
So basically, $xml is out of scope for this function and you are appending to a nonexisting variable? Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl Convince Microsoft! They need to add TRUNCATE PARTITION in SQL Server https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table 2013/3/15 Jay Blanchard jay.blanch...@sigmaphinothing.org [snip] Two questions: Where is $xml defined and where is $pos defined? [/snip] $xml is defined in other functions, just not in this function. $pos is irrelevant to the question - it is just the string position within the file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined index....
Jay Blanchard wrote: I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) { // stuff $xml = ''; Should work here ... Since the call below is ADDING to $xml you do need something existing to add to so what does that give? while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Why do I get the notice that $xml is an undefined index? I do not want to suppress the notice, I just want to take care of it properly. I attempted setting $xml within the function but then the whole function fails for some reason in the depths of this hideous framework. Can anyone provide any insight? TVMIA! -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accessing Files Outside the Web Root
On 15 Mar 2013, at 13:11, Dale H. Cook webmas...@plymouthcolony.net wrote: At 09:44 PM 3/14/2013, tamouse mailing lists wrote: If you are delivering files to a (human) user via their browser, by whatever mechanism, that means someone can write a script to scrape them. That script, however, would have to be running on my host system in order to access the script which actually delivers the file, as the latter script is located outside of the web root. If a browser can get at it then a spider can get at it. All this talk of the web root is daft. Unless your site is being specifically targeted (highly unlikely) then it automated systems that are downloading your content and offering it on other websites. The only way such a system can discover content is if it's linked from somewhere. Whether that link uses a script that inside or outside the web root is completely irrelevant. Since copies of the content is now out there, anything you add now to protect your content is not going to get it back. You'll have to pursue legal avenues to prevent it being made available, and that's usually prohibitively expensive. Based on your description of your users, you have the age-old dilemma of balancing ease of use and security. The more you try to protect the content from these spiders the harder you'll make it for users. Here's what I'd do: make sure your details and your website info are plastered across every page of the PDF files. Make sure that where copies exist it's going to be obvious where the content came from. It sounds like you don't charge for the content (this problem wouldn't exist if you did), so you have nothing financial to gain from controlling these external copies, other than wanting it to be clear from whence it came and where to find more. At the end of the day the question is this: would you rather control access to your creation (in which case charge a nominal fee for it), or would you prefer that it (and your name/cause) gets in to as many hands as possible. As a professional photographer I made the latter choice a long time ago and haven't looked back since. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
Hi, yepp thnx, so far I have got, but now im in a situation where I have made 2nice frames one contining the picture (noscroll) and i want to have a quite narrow frame at the side displaying a text, however I want to fill both frames at one mouseclick... here Im utterly failing :( for some time now BR georg - Original Message - From: tamouse mailing lists tamouse.li...@gmail.com To: php-general@lists.php.net Sent: Friday, March 15, 2013 12:00 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME On Fri, Mar 15, 2013 at 5:00 AM, georg georg.chamb...@telia.com wrote: I have a need to make a pure display in a (HTML tagged area defined by) FRAME now so far I have only succeeded in making output into a frame by landing a clicked tag to open the new doc (href or src) in a specified frame. Possibly its not solvable with framework of frames. Not 100% sure of what you want, but can't you just populate the frames directly? frameset rows=10%,* frame name=upper src=upperframe.php frame name=lower src=lowerframe.php /frameset the link in the src attribute populates it initially. You already know how to populate them with links. ( I know, FRAMEs are a dying breed, depressed by HTML society, sorry deprecated possibly my issue is fixable by style-sheets but I havnt gotten that far yet, too complex ) Frames are not only deprecated, they are unsupported entirely in HTML5 (not that browsers won't continue to display them; just that they won't validate). Leap the hurdle and start to look at Web 3.0 stuff with backbone.js, twitter's bootstrap, etc. -- 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] rather a HTML Q; however 2-FRAME
To make things clearer. I already have the frames since earlier and want to fill then again, so it is not at the initial filling of the frames at creation. BR georg - Original Message - From: georg georg.chamb...@telia.com To: tamouse mailing lists tamouse.li...@gmail.com Cc: php-general@lists.php.net Sent: Friday, March 15, 2013 2:31 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME Hi, yepp thnx, so far I have got, but now im in a situation where I have made 2nice frames one contining the picture (noscroll) and i want to have a quite narrow frame at the side displaying a text, however I want to fill both frames at one mouseclick... here Im utterly failing :( for some time now BR georg - Original Message - From: tamouse mailing lists tamouse.li...@gmail.com To: php-general@lists.php.net Sent: Friday, March 15, 2013 12:00 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME On Fri, Mar 15, 2013 at 5:00 AM, georg georg.chamb...@telia.com wrote: I have a need to make a pure display in a (HTML tagged area defined by) FRAME now so far I have only succeeded in making output into a frame by landing a clicked tag to open the new doc (href or src) in a specified frame. Possibly its not solvable with framework of frames. Not 100% sure of what you want, but can't you just populate the frames directly? frameset rows=10%,* frame name=upper src=upperframe.php frame name=lower src=lowerframe.php /frameset the link in the src attribute populates it initially. You already know how to populate them with links. ( I know, FRAMEs are a dying breed, depressed by HTML society, sorry deprecated possibly my issue is fixable by style-sheets but I havnt gotten that far yet, too complex ) Frames are not only deprecated, they are unsupported entirely in HTML5 (not that browsers won't continue to display them; just that they won't validate). Leap the hurdle and start to look at Web 3.0 stuff with backbone.js, twitter's bootstrap, etc. -- 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] rather a HTML Q; however 2-FRAME
On 15 Mar 2013, at 13:34, georg georg.chamb...@telia.com wrote: To make things clearer. I already have the frames since earlier and want to fill then again, so it is not at the initial filling of the frames at creation. You want one action to change the content in two frames? For that you'll need to use Javascript, or reload the parent frame, neither of which involve PHP. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg - Original Message - From: Stuart Dallas stu...@3ft9.com To: georg georg.chamb...@telia.com Cc: PHP General Sent: Friday, March 15, 2013 2:38 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME On 15 Mar 2013, at 13:34, georg georg.chamb...@telia.com wrote: To make things clearer. I already have the frames since earlier and want to fill then again, so it is not at the initial filling of the frames at creation. You want one action to change the content in two frames? For that you'll need to use Javascript, or reload the parent frame, neither of which involve PHP. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Undefined index....
On 15 Mar 2013 at 13:10, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) { // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Why do I get the notice that $xml is an undefined index? Because it's undefined. So is $pos. From what you've written above, both are local to includeXML. But neither is passed in as a parameter, nor is global. You can't initialise it within the function, it seems to me. If $xml is supposed to be appended to and grown as you recurse up and down, then you have two choices: 1) Make them global 2) Pass both as extra parameters to includeXML In both cases, each needs to be initialised before the first call to the recursive function Solution (1) $xml = ''; $pos = 0;// Presumably. includeXML ($file, $locale, $url, 1); ... function includeXML ($file, $locale, $url, $level = 1) { global $xml, $pos; // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML ('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Solution (2) $xml = ''; $pos = 0;// Presumably. includeXML ($xml, $pos, $file, $locale, $url, 1); ... function includeXML ($xml, $pos, $file, $locale, $url, $level = 1) {// Note the on the first parameter // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML ($xml, $pos, 'repository/' . $included, $locale, (int)$level + $pos - 1); } } } BTW it seems to me that you'll have the same problem with $included unless there's other code in includeXML that you've omitted. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined index....
[snip] function includeXML($file, $locale, $url, $level = 1) { // stuff $xml = ''; Should work here ... Since the call below is ADDING to $xml you do need something existing to add to so what does that give? [/snip] Thanks Lester, that worked. I had just put that in the wrong place. *slaps forehead* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 9:11 AM, georg georg.chamb...@telia.com wrote: Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Maybe you want an IFRAME (Inline Frame) instead of FRAMESET/FRAME? Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg - Original Message - From: Stuart Dallas stu...@3ft9.com To: georg georg.chamb...@telia.com Cc: PHP General Sent: Friday, March 15, 2013 2:38 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME On 15 Mar 2013, at 13:34, georg georg.chamb...@telia.com wrote: To make things clearer. I already have the frames since earlier and want to fill then again, so it is not at the initial filling of the frames at creation. You want one action to change the content in two frames? For that you'll need to use Javascript, or reload the parent frame, neither of which involve PHP. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.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] rather a HTML Q; however 2-FRAME
On 3/15/2013 10:11 AM, georg wrote: Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg And apparently new to html as well if you want to use frames still :) Why not learn just a little css and html and develop something more current that you won't be re-visiting down the road some time and changing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accessing Files Outside the Web Root
At 09:27 AM 3/15/2013, Stuart Dallas wrote: You'll have to pursue legal avenues to prevent it being made available, and that's usually prohibitively expensive. Not necessarily. Most of the host systems for the scraper sites are responsive to my complaints. Even if a site owner will not respond to a DMCA takedown notice the host system will often honor that notice, and other site owners and hosts will back down when notified of my royalty rates for the use of my files by a commercial site. At the end of the day the question is this: would you rather control access to your creation (in which case charge a nominal fee for it), or would you prefer that it (and your name/cause) gets in to as many hands as possible. I merely wish to try to prevent commercial sites from profiting from my work without my permission. I am in the process of registering the copyright for my files with LOC, as my attorneys have advised. That will give my attorneys ammunition. Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants; Plymouth Co. MA Coordinator for the USGenWeb Project Administrator of http://plymouthcolony.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO Transaction
Hi, I have a trouble with PDO transactions. I would like to start using transactions, but I am not familiar with it. I have got a 'There is no active transaction' exception, however, I am using beginTransaction method, and also I have set PDO::ATTR_AUTOCOMMIT to false right after connecting to the database. In my whole code I have used the commit method only once. Between beginTransaction and commit methods, as far as I know, I did not use anything that could activate auto-commit. In my test code, there is only an exec method of PDO, and an execute of PDOStatement. Maybe one of these activated auto-commit? And what are the possible commands which are able to activate auto-commit? I know that the commit method can do that, but - as I already wrote - I have issued it only once, and it is in the destructor of a singleton class. So what could be the problem?
Re: [PHP] variable type - conversion/checking
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP context editor
On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: 2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is great as a full-blown IDE, or Geany is quite nice if you need something in-between those two. The great thing is that they are all available on Windows too. Thanks, Ash http://www.ashleysheridan.co.uk
Re: FW: [PHP] Accessing Files Outside the Web Root
On Fri, 2013-03-15 at 09:11 -0400, Dale H. Cook wrote: At 09:44 PM 3/14/2013, tamouse mailing lists wrote: If you are delivering files to a (human) user via their browser, by whatever mechanism, that means someone can write a script to scrape them. That script, however, would have to be running on my host system in order to access the script which actually delivers the file, as the latter script is located outside of the web root. Dale H. Cook, Market Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA http://plymouthcolony.net/starcityeng/index.html Not really. You script is web accessible right? It just opens a file and delivers it to the browser of your visitor. It's easy to make a script that pretends to be a browser and make the same request of your script to grab the file. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] variable type - conversion/checking
On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int I'm late in on this thread so apologies if I have missed something here .. but wouldn't is_int() do what the OP wants? rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Transaction
Simon Dániel wrote: Hi, I have a trouble with PDO transactions. I would like to start using transactions, but I am not familiar with it. I have got a 'There is no active transaction' exception, however, I am using beginTransaction method, and also I have set PDO::ATTR_AUTOCOMMIT to false right after connecting to the database. In my whole code I have used the commit method only once. Between beginTransaction and commit methods, as far as I know, I did not use anything that could activate auto-commit. In my test code, there is only an exec method of PDO, and an execute of PDOStatement. Maybe one of these activated auto-commit? And what are the possible commands which are able to activate auto-commit? I know that the commit method can do that, but - as I already wrote - I have issued it only once, and it is in the destructor of a singleton class. So what could be the problem? You don't say which database you are trying to access. Not all actually support transactions, and some need a connection correctly set. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On 03/15/2013 02:33 PM, richard gray wrote: On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int I'm late in on this thread so apologies if I have missed something here .. but wouldn't is_int() do what the OP wants? rich Nope, because the OP wants to test if a variable, that is a string, could be converted to an integer. Not if a variable is an integer. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int Thanks, Ash http://www.ashleysheridan.co.uk That is so about is_numeric(), but once I know it's a numeric, coercing it to just an int is easy. *Validating*, rather than just assuring, that a string is an integer is another matter; if you need to give feedback to the user, etc., in which case a Regex is better. (One small nit, + is possible on integers, too.)
Re: [PHP] PHP context editor
On Fri, Mar 15, 2013 at 4:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: 2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is great as a full-blown IDE, or Geany is quite nice if you need something in-between those two. The great thing is that they are all available on Windows too. Thanks, Ash http://www.ashleysheridan.co.uk Since we're doing this, lemme toss in my rec for Sublime Text 2. But I'm still holding onto my dear old Emacs, cos it's my frenz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 10:36 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 3/15/2013 10:11 AM, georg wrote: Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg And apparently new to html as well if you want to use frames still :) Why not learn just a little css and html and develop something more current that you won't be re-visiting down the road some time and changing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Although maybe there's something ascetic about going through features from the beginning and learning to hate them as much as we did. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP context editor
I've been playing with bluefish as of late. The openoffice folks have taken over that project. tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Mar 15, 2013 at 4:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: 2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is great as a full-blown IDE, or Geany is quite nice if you need something in-between those two. The great thing is that they are all available on Windows too. Thanks, Ash http://www.ashleysheridan.co.uk Since we're doing this, lemme toss in my rec for Sublime Text 2. But I'm still holding onto my dear old Emacs, cos it's my frenz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Re: [PHP] variable type - conversion/checking
tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int Thanks, Ash http://www.ashleysheridan.co.uk That is so about is_numeric(), but once I know it's a numeric, coercing it to just an int is easy. *Validating*, rather than just assuring, that a string is an integer is another matter; if you need to give feedback to the user, etc., in which case a Regex is better. (One small nit, + is possible on integers, too.) The op wasn't about casting a string to an int but detecting if a string was just a string representation of an int. Hence using a regex to determine that. Regular expressions are not just about giving feedback to the user. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP context editor
Sent from my Galaxy S®III Original message From: Ashley Sheridan a...@ashleysheridan.co.uk Date: 03/15/2013 5:03 PM (GMT-05:00) To: Sebastian Krebs krebs@gmail.com Cc: gei...@b1-systems.de,georg georg.chamb...@telia.com,PHP General List php-general@lists.php.net Subject: Re: [PHP] PHP context editor On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: 2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is great as a full-blown IDE, or Geany is quite nice if you need something in-between those two. The great thing is that they are all available on I've also been using something called Textpad on Windows. It's about 30 euros and very powerful.
Re: [PHP] variable type - conversion/checking
I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) Andrew
Re: [PHP] variable type - conversion/checking
2013/3/16 Ashley Sheridan a...@ashleysheridan.co.uk tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.casting http://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int Thanks, Ash http://www.ashleysheridan.co.uk That is so about is_numeric(), but once I know it's a numeric, coercing it to just an int is easy. *Validating*, rather than just assuring, that a string is an integer is another matter; if you need to give feedback to the user, etc., in which case a Regex is better. (One small nit, + is possible on integers, too.) The op wasn't about casting a string to an int but detecting if a string was just a string representation of an int. Hence using a regex to determine that. Regular expressions are not just about giving feedback to the user. Guess regex are the only useful solution here. When you consider to use built-in functions, just remember, that for example '0xAF' is an integer too, but '42.00' isn't. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- github.com/KingCrunch
Re: [PHP] variable type - conversion/checking
2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) It is semantically equivalent to $val == (int) $val and as far as I remember (I didn't read everything completely) this were mentioned. I didn't read, whether or not, it was accepted as solution ;) Andrew -- github.com/KingCrunch
Re: [PHP] variable type - conversion/checking
On Mar 15, 2013 9:54 PM, Sebastian Krebs krebs@gmail.com wrote: 2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) It is semantically equivalent to $val == (int) $val and as far as I remember (I didn't read everything completely) this were mentioned. I didn't read, whether or not, it was accepted as solution ;) Not quite. That method will massage both values to the same type for the comparison. Whoever shot it down said they both go to int. If that's the case, if ($val == (int)$val) is more like saying if ((int)$val === (int)$val) What I suggested converts the string to an int, the resulting int back to a string, then does a type-specific comparison to the original string value. Andrew
Re: [PHP] variable type - conversion/checking
Guess regex are the only useful solution here. When you consider to use built-in functions, just remember, that for example '0xAF' is an integer too, but '42.00' isn't. Shoot...I hadn't considered how PHP might handle hex or octal strings when casting to int. (Again, not in front of a computer where I can test it right now. ) Regexes have problems with more than 9 digits for 32-bit ints. I guess to some degree it depends on how likely you are to experience values that large. Andrew
Re: [PHP] variable type - conversion/checking
On Sat, Mar 16, 2013 at 2:54 AM, Sebastian Krebs krebs@gmail.comwrote: 2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) It is semantically equivalent to $val == (int) $val and as far as I remember (I didn't read everything completely) this were mentioned. I didn't read, whether or not, it was accepted as solution ;) Sebastian, This is not true. $val === (string)(int)$val will do a string compare, where as $val == (int) $val will do an integer compare, which will convert the left hand to integer too. Your equation will always evaluate as true. Andrews' solution should work too, but it depends on what you accept as integer, in this case you would be able to parse normal numbers, with optionally a sign and extra 0's in front. is_numeric will parse those integers, but also hexadecimal, octal and binary notations, and parses floating point integers. If you don't want the floating points, you could add an extra check that verifies it is not a float. - Matijn