php-general Digest 28 Mar 2009 04:27:29 -0000 Issue 6036

2009-03-27 Thread php-general-digest-help

php-general Digest 28 Mar 2009 04:27:29 - Issue 6036

Topics (messages 290755 through 290782):

Re: Regex
290755 by: Jesse.Hazen.arvatousa.com

Regex help please
290756 by: Shawn McKenzie
290759 by: haliphax
290762 by: Shawn McKenzie

Re: flushing AJAX scripts
290757 by: jim white
290758 by: Andrea Giammarchi
290760 by: Andrea Giammarchi

Re: utf-8-safe replacement for strtr()?
290761 by: Tom Worster

Re: Multiple cookies on the same computer
290763 by: Ken Watkins
290764 by: Ashley Sheridan
290767 by: Ken Watkins
290779 by: Michael A. Peters

fpdf adding font error
290765 by: Thodoris
290773 by: Tony Marston

Re: php5activescript.dll
290766 by: Jacques Manukyan

Re: Exporting text with chinese characters in CSV
290768 by: Michael Shadle

hierarchies
290769 by: PJ
290770 by: Jason Pruim
290772 by: PJ
290774 by: Jason Pruim
290776 by: Shawn McKenzie

pdflib greek problem
290771 by: Thodoris
290780 by: Michael A. Peters

validating and sanitizing input string encoding
290775 by: Tom Worster

SESSION values show up days later!
290777 by: Mary Anderson
290778 by: Tom Worster
290782 by: Paul M Foster

Sort a multi-dimensional array on a certain key followed by another key
290781 by: TS

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---
Jochem,

To be more specific, the error I get when using this regex is No ending
delimiter '/' found

 
 
 
Thanks,
 
Jesse Hazen
-Original Message-
From: Jochem Maas [mailto:joc...@iamjochem.com] 
Sent: Thursday, March 26, 2009 11:45 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] Regex

jesse.ha...@arvatousa.com schreef:
 Hi,
 
  
 
 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to
do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?
 

there is, your control-Z is not a Z at all, and it's only printed as ^Z
so you can see it ... it's actually a non-printing char.

try this regexp for stripping control chars:

/[\x00-\x1f]+/

  
 
  
 
  
 
 public function getSelection() {
 
  
 
 $choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;
 
 return $choice;
 
  
 
 }
 
  
 
 private function validateChoice($choice) {
 
  
 
 $choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);
 
 return $choice;
 
  
 
 }
 
  
 
  
 
  
 
 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as
ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?
 
  
 
  
 
  
 
 Thanks,
 
  
 
 Jesse Hazen
 
 

---End Message---
---BeginMessage---
I'm normally OK with regex, especially if I fiddle with it long enough,
however I have fiddled with this one so long that I'm either totally
missing it or it's something simple.  Does it have anything to do with
the backref, or the fact that the value of the backref has a $?  I have:

$out = '
{$sites}
tr
td
{Site.id}
/td
/tr
{/$sites}';

And I want to capture the first {$tag}, everything in between and the
last {$/tag}.  I have tried several things and here is my current regex
that looks like it should work, but doesn't:

preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);


Gives:

Array
(
[0] = Array
(
)

[1] = Array
(
)

[2] = Array
(
)

[3] = Array
(
)

)

-- 
Thanks!
-Shawn
http://www.spidean.com
---End Message---
---BeginMessage---
On Fri, Mar 27, 2009 at 9:40 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 I'm normally OK with regex, especially if I fiddle with it long enough,
 however I have fiddled with this one so long that I'm either totally
 missing it or it's something simple.  Does it have anything to do with
 the backref, or the fact that the value of the 

Re: [PHP] Regex

2009-03-27 Thread Jochem Maas
jesse.ha...@arvatousa.com schreef:
 Hi,
 
  
 
 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?
 

there is, your control-Z is not a Z at all, and it's only printed as ^Z
so you can see it ... it's actually a non-printing char.

try this regexp for stripping control chars:

/[\x00-\x1f]+/

  
 
  
 
  
 
 public function getSelection() {
 
  
 
 $choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;
 
 return $choice;
 
  
 
 }
 
  
 
 private function validateChoice($choice) {
 
  
 
 $choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);
 
 return $choice;
 
  
 
 }
 
  
 
  
 
  
 
 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?
 
  
 
  
 
  
 
 Thanks,
 
  
 
 Jesse Hazen
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Andrew Williams
can some tell why the below loop stop running after some time.

$start=10;
const run=0;
while($start run){

//do somthing

}

-- 
Best Wishes
Andrew Williams


Re: [PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Craig Whitmore
On Fri, 2009-03-27 at 08:11 +, Andrew Williams wrote:
 can some tell why the below loop stop running after some time.
 
 $start=10;
 const run=0;
 while($start run){
 
 //do somthing
 
 }
 
max_execution_time


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP and making a ZIP file

2009-03-27 Thread Ashley Sheridan
On Fri, 2009-03-27 at 16:11 +1100, Chris wrote:
 Ron Piggott wrote:
  Does anyone know how to make a ZIP file using PHP?  This is for an
  application where the files the user selected will be put into a ZIP
  file and then the ZIP file made available for download.  Ron
 
 http://www.php.net/zip would be a good place to start.
 
 Or http://pear.php.net/package/File_Archive if your host can't/won't 
 install the requirements.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
If you're hosting it yourself, and it's on a Linux platform, you could
shell out and archive it from there. That'll give you the advantage of
using any compression format the OS supports, and lets you do cool
things like spanned rar archives and such.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Exporting text with chinese characters in CSV

2009-03-27 Thread Ai Leen

Hi Everyone,

I need to export data from database with UTF-8 encoding to an csv file. I am 
outputing html tables with the Content Type set to msexcel.


The chinese texts came out as symbols. I tried
using mb_convert_encoding the text from UTF-8 to UTF-16LE
iconv from UTF8 to gb2312
iconv from UTF-8 to cp1252

Can anyone who has successfully export english text with chinese characters 
mixed in to CSV help?


Thank you very much,
Ai Leen 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Arno Kuhl
-Original Message-
From: Andrew Williams [mailto:andrew4willi...@gmail.com] 
Sent: 27 March 2009 10:12 AM
To: PHP LIST
Subject: [PHP] WHILE LOOP PROBLEM

can some tell why the below loop stop running after some time.

$start=10;
const run=0;
while($start run){

//do somthing

}

--

The webserver or php environment is probably terminating the script. It will
only run for the max number of seconds set in your php.ini file.

Arno


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exporting text with chinese characters in CSV

2009-03-27 Thread Ashley Sheridan
On Fri, 2009-03-27 at 17:40 +0800, Ai Leen wrote:
 Hi Everyone,
 
 I need to export data from database with UTF-8 encoding to an csv file. I am 
 outputing html tables with the Content Type set to msexcel.
 
 The chinese texts came out as symbols. I tried
 using mb_convert_encoding the text from UTF-8 to UTF-16LE
 iconv from UTF8 to gb2312
 iconv from UTF-8 to cp1252
 
 Can anyone who has successfully export english text with chinese characters 
 mixed in to CSV help?
 
 Thank you very much,
 Ai Leen 
 
 
Strictly speaking, a csv file won't contain HTML markup, so you should
probably just stick to delimited value lines in your file. Have you
tried changing the Content Type to text/plain and then save your PHP
script as utf-8. It's this last one that sometimes causes problems, as I
believe it is needed for PHP to correctly output utf-8.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] flushing AJAX scripts

2009-03-27 Thread Andrea Giammarchi

Some browser would like to receive at list N characters (bytes) even if
you force the flush, before the browser will show those characters.
In
any case, the Ajax request will not be completed until its readyState
will be 4, which means the page execution on the server has finished
(released, php has gone, flush or not flush)
For a task like this one you have few options:
 1 - launch  new thread if your host is able to do it
 2 - use a Comet like response (for php I wrote Phico some while ago)
In any case, I hope this stressful operation cannot be performed from thousand 
of users or you can say bye bye to the service.
Alternatives:
 1 - optimize your database
 2 - delegate the job once a time rather than every click (cronjob)
 3 - if the bottleneck is PHP, create an extension in C to perform the same task

Hope this help.

Regards

P.S.
Internet Explorer a part, you can read the responseText on readystate 3
which will be called different time (most likely for each flush).
If IE is not your target, you could consider this opportunity to read the sent 
stream so far.

 Date: Fri, 27 Mar 2009 08:49:35 +1100
 From: dmag...@gmail.com
 To: jbw2...@earthlink.net
 CC: php-general@lists.php.net
 Subject: Re: [PHP] flushing AJAX scripts
 
 jim white wrote:
  I am using jQuery AJAX request to run a script that can take several 
  minutes to create a report. I want to start the script and immediately 
  echo a response to close the connection and then let the script complete 
  a report which I can get later. I have tried several thing such as
  
  ob_start();
  echo json_encode(array(time=$now, message=Report has started 
  running!));
  ob_end_flush();
 
 Try something like this
 
 echo something;
 flush();
 
 without the ob* stuff.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

RE: [PHP] Regex

2009-03-27 Thread Bob McConnell
From: Nitsan Bin-Nun

 If you can point me on the character which control-z creates it would
make
 it easier, I have no idea of it ;)

On Thu, Mar 26, 2009 at 11:06 PM, jesse.ha...@arvatousa.com wrote:

 Thanks again. Sad to say, same result.

 The second option looped an error: Warning: preg_replace():
Compilation
 failed: nothing to repeat at offset 17

The actual value is 0x1A, and it maps to the ASCII SUB (substitute)
control character. The carrot-Z (^Z) representation is how Unix CLI
software would display it. Many control codes that didn't actually do
anything were printed on the terminals with the carrot prefix. Sometimes
codes that did trigger a function in the terminal would be printed that
way to prevent the function from triggering.

Control-Z is a left over from the CP/M days. It was used to mark the end
of text files, since the original file allocation table (FAT) only
tracked the number of clusters assigned to a file. Some MS-DOS and
MS-Windows applications still tack it on to the end of files. I guess
that's their idea of backward compatibility.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php5activescript.dll

2009-03-27 Thread Robert Johnson


I've been trying to locate this file and could not find it in the downloads 
area and got this message when I tried - http://pecl4win.php.net/ 

The pecl4win build box is temporarily out of service. We're preparing a 
new build system. 

Any suggestions?
Thanks. 


[PHP] Error printer_open()

2009-03-27 Thread Gerardo Picotti

Hi.
I'm trying to use the printer functions in my php development.
I add the php_printer.dll in the c:/php/ext/ path.
I add the line in the php.ini file like that: extension=php_printer.dll.
But that doesn't work and gives the next error:

Fatal error: Call to undefined function printer_open().

What can I do?
Thanks for your help!


Gerardo


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error printer_open()

2009-03-27 Thread Bastien Koert
On Fri, Mar 27, 2009 at 8:37 AM, Gerardo Picotti gpico...@erio.com.arwrote:

 Hi.
 I'm trying to use the printer functions in my php development.
 I add the php_printer.dll in the c:/php/ext/ path.
 I add the line in the php.ini file like that: extension=php_printer.dll.
 But that doesn't work and gives the next error:

 Fatal error: Call to undefined function printer_open().

 What can I do?
 Thanks for your help!


 Gerardo


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 Does the php_printer.dll exist in the EXT folder?


-- 

Bastien

Cat, the other other white meat


Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Ken Watkins
 On 3/26/2009 at 11:12 PM, in message 70.12.30978.2144c...@pb1.pair.com, 
 Shawn McKenzie nos...@mckenzies.net wrote:
Shawn McKenzie wrote:
 Ken Watkins wrote:
 Hi all.

 Newbie here.

 I have set up a blog site where my family creates posts and they get emailed 
 to members of the family. To keep up with their identities, I created a 
 script for each family member to run (dad.php, mom.php, etc.), and it sets a 
 cookie on each computer and uses sessions so I know who is connecting. It 
 works great unless I want to share a computer between two users.

 I thought I had a solution: install both Firefox and IE on the same computer 
 and set two different cookies. But this doesn't seem to work. My question 
 is: Is it possible to set one cookie for IE and another for Firefox so that, 
 depending on which browser is used, I can tell who is connecting to the 
 blog? If this is not possible, is there another easy way to do it?

 Thanks for your help.

 - Ken Watkins


 
 Even if you don't need it secure, have a login.  Dad and mom can login
 with dad or mom with no password if all you need to do is give them
 their own cookie/session.
 
 

Optionally, I just thought that if this was too much for them to
do/remember, they could have their own bookmarks, like Dad - Yoursite
(http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite
(http://www.yoursite.com/index.php?person=mom) and set the
session/cookie or whatever you're doing based on $_GET['person'].

I would still opt for the login though, even if not secure.

-- 
Thanks!
-Shawn
http://www.spidean.com 

 
Hi Shawn -

I was hoping to avoid logging in every time, but that may be the best way.
What I still don't understand is:  I thought that Firefox and IE each had their 
own cookies, and that I could determine the user by which browser they used. In 
other words, Firefox's cookie would be for dad and IE's for mom. But I can't 
figure out how to do that. Do Firefox and IE share cookies?

Thanks.
Ken


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex

2009-03-27 Thread Jesse.Hazen
Jochem,

Thanks, but this regex did not seem to work for me. At least, not on
Windows. I will not be able to test on linux for a few hours. 

I spoke too soon yesterday, too. Control-Z is a problem on Windows, and
not on Linux. However, on linux, control-D is a problem.


 
 
 
Thanks,
 
Jesse Hazen
-Original Message-
From: Jochem Maas [mailto:joc...@iamjochem.com] 
Sent: Thursday, March 26, 2009 11:45 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

jesse.ha...@arvatousa.com schreef:
 Hi,
 
  
 
 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to
do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?
 

there is, your control-Z is not a Z at all, and it's only printed as ^Z
so you can see it ... it's actually a non-printing char.

try this regexp for stripping control chars:

/[\x00-\x1f]+/

  
 
  
 
  
 
 public function getSelection() {
 
  
 
 $choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;
 
 return $choice;
 
  
 
 }
 
  
 
 private function validateChoice($choice) {
 
  
 
 $choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);
 
 return $choice;
 
  
 
 }
 
  
 
  
 
  
 
 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as
ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?
 
  
 
  
 
  
 
 Thanks,
 
  
 
 Jesse Hazen
 
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Ken Watkins
 On 3/26/2009 at 10:24 PM, in message 
 0a88dc6e-0655-4565-b9a7-e21337fc0...@bluerodeo.com, dg 
 dane...@bluerodeo.com wrote:

On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote:

 To keep up with their identities, I created a script for each family  
 member to run (dad.php, mom.php, etc.), and it sets a cookie on each  
 computer and uses sessions so I know who is connecting.

Each family member only uses her/his own page?  Maybe set a unique  
cookie name based on each page?

Hi.

No, they all go to a common page. I may have to take Shawn's suggestion and 
just have them login if I can't figure another way to do it.

Thanks.
Ken




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex

2009-03-27 Thread Jesse.Hazen
Bruce,

Sure thing. So basically what I am trying to accomplish is when this
script runs, a menu is displayed to the user, it looks somewhat like
this:



Welcome
To continue, please select your game mode.

[Mode]  [Description]
A.) Mode A
B.) Mode B
C.) Mode C
D.) Mode D
E.) Mode E
F.) Mode F
Q.) Quit.

To begin, please type the mode letter.

Mode:

 

Then, the below lines of code come into play:


public function getSelection() {

$choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;
return $choice;

}

private function validateChoice($choice) {

$choice = preg_replace(/[\x00-\x1f]+/,,$choice);
return $choice;

}


So now the script is waiting for user input. The next thing to happen,
right after this code, is:


private function validate($choice,$display,$input) {

$valid = false;
while(!$valid) {

switch($choice) {

case Q:
$display-writeCredits();
sleep(4);
exit(0);
case A:
$valid = true;
break;
case B:
$valid = true;
break;
case C:
$valid = true;
break;
case D:
$valid = true;
break;
case E:
$valid = true;
break;
case F:
$valid = true;
break;
default:
$display-writeInvalidChoice();
$choice =
$input-getSelection();
break;

}

}

return $choice;

}



Now, this is where the script loops infinitely. But, this is only the
first method which validates user input. There are several others.
Basically, my script should accept user input, strip anything that will
not be needed (like anything other than letters and numbers) and then
allow the user to proceed, where the script checks to see if the
numbers/letters they entered correspond to the menu's in any way.

Everything in the script runs perfect, except the fact that the control
statements print infinitely. And while I am sure there is something I
could do to this method to make it not loop infinitely, I would also
need to do this to several other loops. 


 
 
Thanks,
 
Jesse Hazen
-Original Message-
From: bruce [mailto:bedoug...@earthlink.net] 
Sent: Thursday, March 26, 2009 5:23 PM
To: Hazen, Jesse, arvato digital services llc; php-general@lists.php.net
Subject: RE: [PHP] Regex

hi...

if you haven't solved your issue... can you tell me in detail what
you're trying to accomplish? what are the steps to running the script?

thanks


-Original Message-
From: jesse.ha...@arvatousa.com [mailto:jesse.ha...@arvatousa.com]
Sent: Thursday, March 26, 2009 1:23 PM
To: php-general@lists.php.net
Subject: [PHP] Regex


Hi,

 

Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?

 

 

 

 

 

public function getSelection() {

 

$choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;

 

}

 

private function validateChoice($choice) {

 

$choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;

 

}

 

 

 

I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding 

Re: [PHP] Error printer_open()

2009-03-27 Thread Gerardo Picotti

Yes, dll file exists in this folder: C:\PHP\EXT


Bastien Koert escribió:



On Fri, Mar 27, 2009 at 8:37 AM, Gerardo Picotti gpico...@erio.com.ar 
mailto:gpico...@erio.com.ar wrote:


Hi.
I'm trying to use the printer functions in my php development.
I add the php_printer.dll in the c:/php/ext/ path.
I add the line in the php.ini file like that:
extension=php_printer.dll.
But that doesn't work and gives the next error:

Fatal error: Call to undefined function printer_open().

What can I do?
Thanks for your help!


Gerardo


-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php

Does the php_printer.dll exist in the EXT folder?


--

Bastien

Cat, the other other white meat



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Error printer_open()

2009-03-27 Thread Shawn McKenzie
Gerardo Picotti wrote:
 Hi.
 I'm trying to use the printer functions in my php development.
 I add the php_printer.dll in the c:/php/ext/ path.
 I add the line in the php.ini file like that: extension=php_printer.dll.
 But that doesn't work and gives the next error:
 
 Fatal error: Call to undefined function printer_open().
 
 What can I do?
 Thanks for your help!
 
 
 Gerardo
 
You restarted your web server?

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Shawn McKenzie
Ken Watkins wrote:
 On 3/26/2009 at 11:12 PM, in message 70.12.30978.2144c...@pb1.pair.com, 
 Shawn McKenzie nos...@mckenzies.net wrote:
 Shawn McKenzie wrote:
 Ken Watkins wrote:
 Hi all.

 Newbie here.

 I have set up a blog site where my family creates posts and they get 
 emailed to members of the family. To keep up with their identities, I 
 created a script for each family member to run (dad.php, mom.php, etc.), 
 and it sets a cookie on each computer and uses sessions so I know who is 
 connecting. It works great unless I want to share a computer between two 
 users.

 I thought I had a solution: install both Firefox and IE on the same 
 computer and set two different cookies. But this doesn't seem to work. My 
 question is: Is it possible to set one cookie for IE and another for 
 Firefox so that, depending on which browser is used, I can tell who is 
 connecting to the blog? If this is not possible, is there another easy way 
 to do it?

 Thanks for your help.

 - Ken Watkins


 Even if you don't need it secure, have a login.  Dad and mom can login
 with dad or mom with no password if all you need to do is give them
 their own cookie/session.


 
 Optionally, I just thought that if this was too much for them to
 do/remember, they could have their own bookmarks, like Dad - Yoursite
 (http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite
 (http://www.yoursite.com/index.php?person=mom) and set the
 session/cookie or whatever you're doing based on $_GET['person'].
 
 I would still opt for the login though, even if not secure.
 

No, they use their own cookies so if you want to do it that way, use:
$_SERVER['HTTP_USER_AGENT'] and set the cookie based upon the browser.

Another thought I had was if you can add domain aliases,
dad.yoursite.com and mom.yoursite.com, then they will each have
different cookies.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex

2009-03-27 Thread Jesse.Hazen
Jochem,

To be more specific, the error I get when using this regex is No ending
delimiter '/' found

 
 
 
Thanks,
 
Jesse Hazen
-Original Message-
From: Jochem Maas [mailto:joc...@iamjochem.com] 
Sent: Thursday, March 26, 2009 11:45 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

jesse.ha...@arvatousa.com schreef:
 Hi,
 
  
 
 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to
do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?
 

there is, your control-Z is not a Z at all, and it's only printed as ^Z
so you can see it ... it's actually a non-printing char.

try this regexp for stripping control chars:

/[\x00-\x1f]+/

  
 
  
 
  
 
 public function getSelection() {
 
  
 
 $choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;
 
 return $choice;
 
  
 
 }
 
  
 
 private function validateChoice($choice) {
 
  
 
 $choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);
 
 return $choice;
 
  
 
 }
 
  
 
  
 
  
 
 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as
ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?
 
  
 
  
 
  
 
 Thanks,
 
  
 
 Jesse Hazen
 
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Regex help please

2009-03-27 Thread Shawn McKenzie
I'm normally OK with regex, especially if I fiddle with it long enough,
however I have fiddled with this one so long that I'm either totally
missing it or it's something simple.  Does it have anything to do with
the backref, or the fact that the value of the backref has a $?  I have:

$out = '
{$sites}
tr
td
{Site.id}
/td
/tr
{/$sites}';

And I want to capture the first {$tag}, everything in between and the
last {$/tag}.  I have tried several things and here is my current regex
that looks like it should work, but doesn't:

preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);


Gives:

Array
(
[0] = Array
(
)

[1] = Array
(
)

[2] = Array
(
)

[3] = Array
(
)

)

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: RE: [PHP] flushing AJAX scripts

2009-03-27 Thread jim white
My page submits the AJAX request to complete a report that takes some 
time, and upon completion stores results in a database. A second AJAX 
request polls every 5 seconds and queries the database if the report is 
ready. This hopefully will get around any timeout problems I am having 
with a long running request, and seems to be working. It looks like I 
can accept the default behavior for now. I don't depend on getting a 
response from the original request, but is there a point where the AJAX 
response script will be stopped either by Apache or PHP before it can 
insert into the database?


Jim


Andrea Giammarchi wrote:

Some browser would like to receive at list N characters (bytes) even if
you force the flush, before the browser will show those characters.
In
any case, the Ajax request will not be completed until its readyState
will be 4, which means the page execution on the server has finished
(released, php has gone, flush or not flush)
For a task like this one you have few options:
 1 - launch  new thread if your host is able to do it
 2 - use a Comet like response (for php I wrote Phico some while ago)
In any case, I hope this stressful operation cannot be performed from thousand 
of users or you can say bye bye to the service.
Alternatives:
 1 - optimize your database
 2 - delegate the job once a time rather than every click (cronjob)
 3 - if the bottleneck is PHP, create an extension in C to perform the same task

Hope this help.

Regards

P.S.
Internet Explorer a part, you can read the responseText on readystate 3
which will be called different time (most likely for each flush).
If IE is not your target, you could consider this opportunity to read the sent 
stream so far.

  

Date: Fri, 27 Mar 2009 08:49:35 +1100
From: dmag...@gmail.com
To: jbw2...@earthlink.net
CC: php-general@lists.php.net
Subject: Re: [PHP] flushing AJAX scripts

jim white wrote:

I am using jQuery AJAX request to run a script that can take several 
minutes to create a report. I want to start the script and immediately 
echo a response to close the connection and then let the script complete 
a report which I can get later. I have tried several thing such as


ob_start();
echo json_encode(array(time=$now, message=Report has started 
running!));

ob_end_flush();
  

Try something like this

echo something;
flush();

without the ob* stuff.

--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx
  



--
James (Jim) B. White
tel: (919)-380-9615
homepage: http://jimserver.net/ 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] flushing AJAX scripts

2009-03-27 Thread Andrea Giammarchi

Sorry, Kim, but why on earth you are polling with a second request to know when 
the first one has finished?
I mean, when the first request inserts data in the database that's it, you'll 
manage the end of the request.

$A ---  do stuff; do stuff; do stuff; report ready;
$B --- report ready?
$B --- report ready?
$B --- report ready?
$B --- report ready?
report ready; --- notification to A
$B --- report ready;

the report ready, if it is when $A request has been finished, will be in $A, 
the polling via $B is absolutely useless, imo.

There is no timeout from Ajax, it simply keep waiting, but obviously if your 
PHP has max_execution_time 30 seconds and the script execution takes more than 
30 seconds there's no polling that could save you.

The same if the user closes the browser, connection lost, bye bye response.

To have a notice, you need Comet, try out Phico but still, a page that requires 
that much is not suitable for the web. Report creation should be a cronjob in a 
separed thread if it is that stressful.

Regards

 Date: Fri, 27 Mar 2009 10:47:10 -0400
 From: jbw2...@earthlink.net
 To: an_...@hotmail.com
 CC: php-general@lists.php.net
 Subject: Re: RE: [PHP] flushing AJAX scripts
 
 My page submits the AJAX request to complete a report that takes some 
 time, and upon completion stores results in a database. A second AJAX 
 request polls every 5 seconds and queries the database if the report is 
 ready. This hopefully will get around any timeout problems I am having 
 with a long running request, and seems to be working. It looks like I 
 can accept the default behavior for now. I don't depend on getting a 
 response from the original request, but is there a point where the AJAX 
 response script will be stopped either by Apache or PHP before it can 
 insert into the database?
 
 Jim

_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Re: [PHP] Regex help please

2009-03-27 Thread haliphax
On Fri, Mar 27, 2009 at 9:40 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 I'm normally OK with regex, especially if I fiddle with it long enough,
 however I have fiddled with this one so long that I'm either totally
 missing it or it's something simple.  Does it have anything to do with
 the backref, or the fact that the value of the backref has a $?  I have:

 $out = '
 {$sites}
 tr
        td
        {Site.id}
        /td
 /tr
 {/$sites}';

 And I want to capture the first {$tag}, everything in between and the
 last {$/tag}.  I have tried several things and here is my current regex
 that looks like it should work, but doesn't:

 preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);

Shawn,

First thing I see--your first capture group doesn't include the $, and
so your final capture group will always fail given your current $out
(because it's looking for {/sites} instead of {/$sites}). Also, your
{} are outside of your capture group in \1, but inside in \3. Here's
what I came up with:

$out = '
{$sites}
tr
   td
   {Site.id}
   /td
/tr
{/$sites}';
$matches = array();
preg_match_all('#{(\$[^}]+)}(.*?){(/\1)}#s', $out, $matches);
print_r($matches);

Produces this:

Array
(
[0] = Array
(
[0] = {$sites}
tr
   td
   {Site.id}
   /td
/tr
{/$sites}
)

[1] = Array
(
[0] = $sites
)

[2] = Array
(
[0] =
tr
   td
   {Site.id}
   /td
/tr

)

[3] = Array
(
[0] = /$sites
)

)

Keep in mind, I had to view the page source in order to see the HTML
tags, but it showed me everything I expected to see.

HTH,

-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] flushing AJAX scripts

2009-03-27 Thread Andrea Giammarchi

Sorry Jim, I meant Jim when I wrote Kim ... and 
Phico: 
http://webreflection.blogspot.com/2008/04/phomet-changes-name-so-welcome-phico.html

Regards

 From: an_...@hotmail.com
 To: php-general@lists.php.net
 Date: Fri, 27 Mar 2009 15:55:28 +0100
 Subject: RE: [PHP] flushing AJAX scripts
 
 
 Sorry, Kim, but why on earth you are polling with a second request to know 
 when the first one has finished?
 I mean, when the first request inserts data in the database that's it, you'll 
 manage the end of the request.
 
 $A ---  do stuff; do stuff; do stuff; report ready;
 $B --- report ready?
 $B --- report ready?
 $B --- report ready?
 $B --- report ready?
 report ready; --- notification to A
 $B --- report ready;
 
 the report ready, if it is when $A request has been finished, will be in $A, 
 the polling via $B is absolutely useless, imo.
 
 There is no timeout from Ajax, it simply keep waiting, but obviously if your 
 PHP has max_execution_time 30 seconds and the script execution takes more 
 than 30 seconds there's no polling that could save you.
 
 The same if the user closes the browser, connection lost, bye bye response.
 
 To have a notice, you need Comet, try out Phico but still, a page that 
 requires that much is not suitable for the web. Report creation should be a 
 cronjob in a separed thread if it is that stressful.
 
 Regards
 
  Date: Fri, 27 Mar 2009 10:47:10 -0400
  From: jbw2...@earthlink.net
  To: an_...@hotmail.com
  CC: php-general@lists.php.net
  Subject: Re: RE: [PHP] flushing AJAX scripts
  
  My page submits the AJAX request to complete a report that takes some 
  time, and upon completion stores results in a database. A second AJAX 
  request polls every 5 seconds and queries the database if the report is 
  ready. This hopefully will get around any timeout problems I am having 
  with a long running request, and seems to be working. It looks like I 
  can accept the default behavior for now. I don't depend on getting a 
  response from the original request, but is there a point where the AJAX 
  response script will be stopped either by Apache or PHP before it can 
  insert into the database?
  
  Jim
 
 _
 News, entertainment and everything you care about at Live.com. Get it now!
 http://www.live.com/getstarted.aspx

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Re: [PHP] utf-8-safe replacement for strtr()?

2009-03-27 Thread Tom Worster
On 3/26/09 11:36 AM, Nisse Engström news.nospam.0ixbt...@luden.se wrote:

 On Wed, 25 Mar 2009 11:32:42 +0100, Nisse Engström wrote:
 
 On Tue, 24 Mar 2009 08:15:35 -0400, Tom Worster wrote:
 
 strtr() with three parameters is certainly unsafe. but my tests are showing
 that it may be ok with two parameters if the strings in the second parameter
 are well formed utf-8.
 
 does anyone know more? can confirm or contradict?
 
 The two-argument version of strtr() should work fine
 since there are no collisions in utf-8 such that part
 of one character matches part of a different character.
 
 Oops. I meant to write that one complete character does
 not match any part of any other character. If a string
 of one or more utf-8 characters match a utf-8 text, it
 matches exactly those characters in the text. If that
 makes sense...

yes.

my conclusion is that 2-param strtr is safe if the subject text and
parameter strings are valid utf-8.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex help please

2009-03-27 Thread Shawn McKenzie
haliphax wrote:
 On Fri, Mar 27, 2009 at 9:40 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 I'm normally OK with regex, especially if I fiddle with it long enough,
 however I have fiddled with this one so long that I'm either totally
 missing it or it's something simple.  Does it have anything to do with
 the backref, or the fact that the value of the backref has a $?  I have:

 $out = '
 {$sites}
 tr
td
{Site.id}
/td
 /tr
 {/$sites}';

 And I want to capture the first {$tag}, everything in between and the
 last {$/tag}.  I have tried several things and here is my current regex
 that looks like it should work, but doesn't:

 preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);
 
 Shawn,
 
 First thing I see--your first capture group doesn't include the $, and
 so your final capture group will always fail given your current $out
 (because it's looking for {/sites} instead of {/$sites}). Also, your
 {} are outside of your capture group in \1, but inside in \3. Here's
 what I came up with:
 
 $out = '
 {$sites}
 tr
td
{Site.id}
/td
 /tr
 {/$sites}';
 $matches = array();
 preg_match_all('#{(\$[^}]+)}(.*?){(/\1)}#s', $out, $matches);
 print_r($matches);
 
 Produces this:
 
 Array
 (
 [0] = Array
 (
 [0] = {$sites}
 tr
td
{Site.id}
/td
 /tr
 {/$sites}
 )
 
 [1] = Array
 (
 [0] = $sites
 )
 
 [2] = Array
 (
 [0] =
 tr
td
{Site.id}
/td
 /tr
 
 )
 
 [3] = Array
 (
 [0] = /$sites
 )
 
 )
 
 Keep in mind, I had to view the page source in order to see the HTML
 tags, but it showed me everything I expected to see.
 
 HTH,
 

Yes, thank you.  I was fiddling before I got your post and I came up
with roughly the same.

preg_match_all('|{(\$[^}]+)}(.+){(/\1)}|Us', $out, $matches);

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Ken Watkins
 On 3/27/2009 at 10:19 AM, in message 6f.57.30978.d60ec...@pb1.pair.com, 
 Shawn McKenzie nos...@mckenzies.net wrote:
 Optionally, I just thought that if this was too much for them to
 do/remember, they could have their own bookmarks, like Dad - Yoursite
 (http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite
 (http://www.yoursite.com/index.php?person=mom) and set the
 session/cookie or whatever you're doing based on $_GET['person'].
 
 I would still opt for the login though, even if not secure.
 

No, they use their own cookies so if you want to do it that way, use:
$_SERVER['HTTP_USER_AGENT'] and set the cookie based upon the browser.

Another thought I had was if you can add domain aliases,
dad.yoursite.com and mom.yoursite.com, then they will each have
different cookies.
 
Shawn -
 
Yes, domain aliases sound good too. OK, you've given me a couple of good 
suggestions, and one of them should suit me :)
Thanks much.
 
Ken

 


Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Ashley Sheridan
On Fri, 2009-03-27 at 09:59 -0400, Ken Watkins wrote:
  On 3/26/2009 at 10:24 PM, in message 
  0a88dc6e-0655-4565-b9a7-e21337fc0...@bluerodeo.com, dg 
  dane...@bluerodeo.com wrote:
 
 On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote:
 
  To keep up with their identities, I created a script for each family  
  member to run (dad.php, mom.php, etc.), and it sets a cookie on each  
  computer and uses sessions so I know who is connecting.
 
 Each family member only uses her/his own page?  Maybe set a unique  
 cookie name based on each page?
 
 Hi.
 
 No, they all go to a common page. I may have to take Shawn's suggestion and 
 just have them login if I can't figure another way to do it.
 
 Thanks.
 Ken
 
 
 
 
You could have a landing page to the site, that consists of image links
(you could use their photo for this?) and each link is in the order of
page.php?person=mum etc. That would require an extra click, but no
typing for a login, and should make the unique person process a bit more
intuitive.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fpdf adding font error

2009-03-27 Thread Thodoris

Hello gang,
   I know this is not an fpdf mailing list but if anyone has experience 
on the matter please help. I am working on a pdf generation part of a 
project and I am using fpdf to generate them.


   The content of the pdf needs to be in greek. But I am having 
difficulties to get the pdf generated properly. This means that I can't 
see the greek in the pdf file that is generated. I have tried to set the 
encoding to non-UTF since fpdf doesn't support UTF-8 but the problem 
still remains. As a second solution I am trying to add new fonts with 
the ISO-8859-7 encoding but it doesn't work as expected. The font is not 
being although I am following the fpdf's directions step-by-step.



Does anybody know another way to generate pdf files with greek properly 
or can help me with the fpdf??


Thanks in advance.

--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php5activescript.dll

2009-03-27 Thread Jacques Manukyan
The site is under maintenance.  You could wait or download it from: 
http://kromann.info/download.php?strFolder=php5_1-Release_TSstrIndex=PHP5_1


Note that I do not know of the validity of that site so have your 
antivirus program ready.


-- Jacques Manukyan


Robert Johnson wrote:
I've been trying to locate this file and could not find it in the downloads 
area and got this message when I tried - http://pecl4win.php.net/ 

The pecl4win build box is temporarily out of service. We're preparing a 
new build system. 


Any suggestions?
Thanks. 

  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Ken Watkins
 On 3/27/2009 at 11:15 AM, in message 
 1238166938.3522.5.ca...@localhost.localdomain, Ashley Sheridan 
 a...@ashleysheridan.co.uk wrote:
On Fri, 2009-03-27 at 09:59 -0400, Ken Watkins wrote:
  On 3/26/2009 at 10:24 PM, in message 
  0a88dc6e-0655-4565-b9a7-e21337fc0...@bluerodeo.com, dg 
  dane...@bluerodeo.com wrote:
 
 On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote:
 
  To keep up with their identities, I created a script for each family  
  member to run (dad.php, mom.php, etc.), and it sets a cookie on each  
  computer and uses sessions so I know who is connecting.
 
 Each family member only uses her/his own page?  Maybe set a unique  
 cookie name based on each page?
 
 Hi.
 
 No, they all go to a common page. I may have to take Shawn's suggestion and 
 just have them login if I can't figure another way to do it.
 
 Thanks.
 Ken
 
 
 
 
You could have a landing page to the site, that consists of image links
(you could use their photo for this?) and each link is in the order of
page.php?person=mum etc. That would require an extra click, but no
typing for a login, and should make the unique person process a bit more
intuitive.


Ash
www.ashleysheridan.co.uk 
 
Hi Ash.
 
Hey, I like it. Clicking beats typing in my book. Thanks!
 
Ken


Re: [PHP] Exporting text with chinese characters in CSV

2009-03-27 Thread Michael Shadle
The php script language has no bearing on the output unless you have  
characters In the php file itself.


We had some issue like this at work. They found a way using iconv to  
to it but had to change because redhats iconv isn't updated. They do  
something with saving the output to a utf8 encoded page and then  
sending it out or something. I assume you're trying to have this be  
used in excel?


On Mar 27, 2009, at 2:59 AM, Ashley Sheridan  
a...@ashleysheridan.co.uk wrote:



On Fri, 2009-03-27 at 17:40 +0800, Ai Leen wrote:

Hi Everyone,

I need to export data from database with UTF-8 encoding to an csv  
file. I am

outputing html tables with the Content Type set to msexcel.

The chinese texts came out as symbols. I tried
using mb_convert_encoding the text from UTF-8 to UTF-16LE
iconv from UTF8 to gb2312
iconv from UTF-8 to cp1252

Can anyone who has successfully export english text with chinese  
characters

mixed in to CSV help?

Thank you very much,
Ai Leen



Strictly speaking, a csv file won't contain HTML markup, so you should
probably just stick to delimited value lines in your file. Have you
tried changing the Content Type to text/plain and then save your PHP
script as utf-8. It's this last one that sometimes causes problems,  
as I

believe it is needed for PHP to correctly output utf-8.


Ash
www.ashleysheridan.co.uk


--
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] hierarchies

2009-03-27 Thread PJ
I do have a bit of a problem which has not been clearly explained in
the suggestions to my previous posts and that is the question of
hierarchies. I have not yet understood how to include a file anywhere in
a directory tree and have it point to the right file which may be in the
top directory or, most likely, in a /lib/ directory from the file that
is including.
Any suggestions, or should I just make myself small and
wait for the rotten eggs and spoiled tomatoes to come raining down on my
head? :'(

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] hierarchies

2009-03-27 Thread Jason Pruim



PJ wrote:

I do have a bit of a problem which has not been clearly explained in
the suggestions to my previous posts and that is the question of
hierarchies. I have not yet understood how to include a file anywhere in
a directory tree and have it point to the right file which may be in the
top directory or, most likely, in a /lib/ directory from the file that
is including.
Any suggestions, or should I just make myself small and
wait for the rotten eggs and spoiled tomatoes to come raining down on my
head? :'(

  

Are you talking about having a file structure such as:

/home
/include
/webroot
/-images
/-css
/-java

And you want to include a file from the include folder which is above 
the webroot, so doesn't have access to it?


If that's the case... you just need to set the path such as: 
ini_set(include_path, /home/include);

then in your PHP file you should be able to: include(mysupperfile.php);
and it should work :)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] pdflib greek problem

2009-03-27 Thread Thodoris


Hi,
   I am trying the following code to generate a pdf:

   try {
   // Create a new pdf handler
   $pdf = new PDFlib();

   //  open new PDF file
   if ($pdf-begin_document(, ) == 0) {
   die(Error:  . $p-get_errmsg());
   }

   // Set some info to the new pdf
   $pdf-set_info(Creator, Test);
   $pdf-set_info(Author, Test);
   $pdf-set_info(Title, Test);
  
   // Start the page

   $pdf-begin_page_ext(595, 842, );
  
   // Load the documents font and set the details

   $font = $pdf-load_font(Times-Roman, iso8859-7, );
   $pdf-setfont($font,24.0);
   $pdf-set_parameter('autospace',TRUE);
  
   // Set the position inside the document

   $pdf-set_text_pos(50, 700);
  
   // Now start to show the data

   $str = 'Αυτό είναι ένα τεστ.';
   mb_convert_variables('ISO-8859-7','UTF-8',$str);
   $pdf-show($str);
  
   // End the page and the document

   $pdf-end_page_ext();
   $pdf-end_document();
  
   // Get the document from the buffer find it's length

   $buf = $pdf-get_buffer();
   $len = strlen($buf);
  
   // And finally print it out to the browser

   header(Content-type: application/pdf);
   header(Content-Length: $len);
   header(Content-Disposition: inline; filename=hello.pdf);
   print $buf;

   }
  
   catch (PDFlibException $e) {

   die(PDFlib exception occurred in hello sample:\n .
   [ . $e-get_errnum() . ]  . $e-get_apiname() . :  .
   $e-get_errmsg() . \n);
   }
   catch (Exception $e) {
   die($e);
   }

Although greek are printed normally the characters are overlapping on 
each other. The script in encoded in UTF-8.


Does anybody have any suggestions on this? Please any help would be 
appreciated.


--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] hierarchies

2009-03-27 Thread PJ
Jason Pruim wrote:


 PJ wrote:
 I do have a bit of a problem which has not been clearly explained in
 the suggestions to my previous posts and that is the question of
 hierarchies. I have not yet understood how to include a file anywhere in
 a directory tree and have it point to the right file which may be in the
 top directory or, most likely, in a /lib/ directory from the file that
 is including.
 Any suggestions, or should I just make myself small and
 wait for the rotten eggs and spoiled tomatoes to come raining down on my
 head? :'(

   
 Are you talking about having a file structure such as:

 /home
 /include
 /webroot
 /-images
 /-css
 /-java

 And you want to include a file from the include folder which is above
 the webroot, so doesn't have access to it?

 If that's the case... you just need to set the path such as:
 ini_set(include_path, /home/include);
 then in your PHP file you should be able to: include(mysupperfile.php);
 and it should work :)


Not quite, but interesting option. This would be fine on my local
intranet, if needed; but I don't think this would be allowed on a
virtual hosted site.

Actually, my problem is to use a header.php (for example) in pages in
the webroot directory or any directory within (or under) webroot:

/  webroot
/site1
   /files
   /images
   /lib
   /more files
   /admin
  /other_files
  /still_others
/site2
/site3
files
files
files...

I have the header.php file in /lib .
If I put include dirname(_FILE_)./lib/header.php; in a file under
/site1, the header is displayed.
If I put the same include statement in a file under /site1/files, the
header is not displayed; if I change the include to
.../../lib/header.php; it then works.
I want to be able to point to the include to the same file in the same
directory without having to change the include directive.

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: fpdf adding font error

2009-03-27 Thread Tony Marston
If you want to use UTF-8 fonts with FPDF then switch to TCPDF 
(www.tcpdf.org)

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

Thodoris t...@kinetix.gr wrote in message 
news:49ccee54.80...@kinetix.gr...
 Hello gang,
I know this is not an fpdf mailing list but if anyone has experience on 
 the matter please help. I am working on a pdf generation part of a project 
 and I am using fpdf to generate them.

The content of the pdf needs to be in greek. But I am having 
 difficulties to get the pdf generated properly. This means that I can't 
 see the greek in the pdf file that is generated. I have tried to set the 
 encoding to non-UTF since fpdf doesn't support UTF-8 but the problem still 
 remains. As a second solution I am trying to add new fonts with the 
 ISO-8859-7 encoding but it doesn't work as expected. The font is not being 
 although I am following the fpdf's directions step-by-step.


 Does anybody know another way to generate pdf files with greek properly or 
 can help me with the fpdf??

 Thanks in advance.

 -- 
 Thodoris
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] hierarchies

2009-03-27 Thread Jason Pruim

PJ wrote:

Jason Pruim wrote:
  

PJ wrote:


I do have a bit of a problem which has not been clearly explained in
the suggestions to my previous posts and that is the question of
hierarchies. I have not yet understood how to include a file anywhere in
a directory tree and have it point to the right file which may be in the
top directory or, most likely, in a /lib/ directory from the file that
is including.
Any suggestions, or should I just make myself small and
wait for the rotten eggs and spoiled tomatoes to come raining down on my
head? :'(

  
  

Are you talking about having a file structure such as:

/home
/include
/webroot
/-images
/-css
/-java

And you want to include a file from the include folder which is above
the webroot, so doesn't have access to it?

If that's the case... you just need to set the path such as:
ini_set(include_path, /home/include);
then in your PHP file you should be able to: include(mysupperfile.php);
and it should work :)




Not quite, but interesting option. This would be fine on my local
intranet, if needed; but I don't think this would be allowed on a
virtual hosted site.

Actually, my problem is to use a header.php (for example) in pages in
the webroot directory or any directory within (or under) webroot:

/  webroot
/site1
   /files
   /images
   /lib
   /more files
   /admin
  /other_files
  /still_others
/site2
/site3
files
files
files...

I have the header.php file in /lib .
If I put include dirname(_FILE_)./lib/header.php; in a file under
/site1, the header is displayed.
If I put the same include statement in a file under /site1/files, the
header is not displayed; if I change the include to
.../../lib/header.php; it then works.
I want to be able to point to the include to the same file in the same
directory without having to change the include directive.

  
I actually use that on a shared host... Really depends on the host 
though... My actual file path is something more like:


/home/
   /myusername/
   /include/
   /public_html/  Web root
  /file.php
  /another folder/


So all my files are inside my home folder on the server, but nothing 
outside of public_html is accessible from the web.


As for the rest... I haven't started using dir(__FILE__) stuff yet so I 
won't be any help with that...




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] validating and sanitizing input string encoding

2009-03-27 Thread Tom Worster
the article at http://devlog.info/2008/08/24/php-and-unicode-utf-8, among
other web pages, suggests checking for valid utf-8 string encoding using
(strlen($str)  !preg_match('/^.{1}/us', $str)). however, another article,
http://www.phpwact.org/php/i18n/charsets, says this cannot be trusted. i
work exclusively with mbstring environments so i could use
mb_check_encoding().

which leads to the question of what to do if mb_check_encoding() indicates
bad input?

i don't want to throw the form back to the user because most of my users
will not be able to rectify the input. errors in the data are undesirable,
of course, but in my application, no disastrous. so i'm inclined to the
approach mentioned here:
http://blog.liip.ch/archive/2005/01/24/how-to-get-rid-of-invalid-utf-8-chara
cters.html, i.e. iconv(UTF-8,UTF-8//IGNORE,$t), which will quietly
eliminate badly formed characters and move on (iconv will throw a notice on
bad utf-8).

so i'm considering using a function like this:

function clean_input($a) {
if ( is_array($a)  !empty($a) )
foreach ($a as $k = $v)
clean_input($v);
elseif ( is_string($a)  !mb_check_encoding($a, 'UTF-8'))
$a = iconv('UTF-8', 'UTF-8//IGNORE', $a);
}

and calling it on $_POST or $_GET as appropriate at the stop of any script
that uses those superglobals.

it seems a bit lazy to me but that's my nature and i think this might be
good enough. any thoughts?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] hierarchies

2009-03-27 Thread Shawn McKenzie
PJ wrote:
 Not quite, but interesting option. This would be fine on my local
 intranet, if needed; but I don't think this would be allowed on a
 virtual hosted site.
 
 Actually, my problem is to use a header.php (for example) in pages in
 the webroot directory or any directory within (or under) webroot:
 
 /  webroot
 /site1
/files
/images
/lib
/more files
/admin
   /other_files
   /still_others
 /site2
 /site3
 files
 files
 files...
 
 I have the header.php file in /lib .
 If I put include dirname(_FILE_)./lib/header.php; in a file under
 /site1, the header is displayed.
 If I put the same include statement in a file under /site1/files, the
 header is not displayed; if I change the include to
 .../../lib/header.php; it then works.
 I want to be able to point to the include to the same file in the same
 directory without having to change the include directive.
 

The problem is with how you are organizing your app.  Includes are
relative to the first file that's loaded, so if the first file that is
loaded is in /site1/files/ then you have to know where /lib/header.php
is from there.

Most people don't load individual files (at least not from different
dirs) as you seem to be doing.  My advice is to always load the same
file first from the root dir and then include your other files.  Then
those files will include header.php relative to the root dir.

*** Example:

(/site1/index.php)
?php
//based upon some criteria
include('files/yourfile.php');
?

(/site1/files/yourfile.php)
?php
include('lib/header.php');
?

*** Better Example:

(/site1/index.php)
?php
include('lib/header.php');
//based upon some criteria
include('files/yourfile.php');
?

(/site1/files/yourfile.php)
?php
//content that is original to this file
?


Above when I say based upon some criteria, it would be something like
this (example only):

switch ($_GET['file']) {
case 'yourfile':
include('files/yourfile.php');
break;

case 'somefile':
include('more_files/somefile.php');
break;
}

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SESSION values show up days later!

2009-03-27 Thread Mary Anderson

Hi all,
   I use session variables to store values from one page to another on 
my website.
   Alas, sometimes, but not always, the values persist from one 
invocation of the script to another!
   Just how, exactly, do I make them go away when a user exits the 
program? I assume my users will not always be logging out explicitly.

   Thanks.
maryfran

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SESSION values show up days later!

2009-03-27 Thread Tom Worster
On 3/27/09 5:39 PM, Mary Anderson maryf...@demog.berkeley.edu wrote:

 Hi all,
 I use session variables to store values from one page to another on
 my website.
 Alas, sometimes, but not always, the values persist from one
 invocation of the script to another!
 Just how, exactly, do I make them go away when a user exits the
 program? I assume my users will not always be logging out explicitly.

if this is on a server with low traffic, e.g. a development or test server,
it could be because of the way the garbage collector works. it's explained
in the manual.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multiple cookies on the same computer

2009-03-27 Thread Michael A. Peters

Ken Watkins wrote:

Hi all.

Newbie here.

I have set up a blog site where my family creates posts and they get emailed to 
members of the family. To keep up with their identities, I created a script for 
each family member to run (dad.php, mom.php, etc.), and it sets a cookie on 
each computer and uses sessions so I know who is connecting. It works great 
unless I want to share a computer between two users.

I thought I had a solution: install both Firefox and IE on the same computer 
and set two different cookies. But this doesn't seem to work. My question is: 
Is it possible to set one cookie for IE and another for Firefox so that, 
depending on which browser is used, I can tell who is connecting to the blog? 
If this is not possible, is there another easy way to do it?

Thanks for your help.

- Ken Watkins



Why not just use session cookies that expire as soon as a session is 
over (browser quits) and use a login?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] pdflib greek problem

2009-03-27 Thread Michael A. Peters

Thodoris wrote:


Hi,
   I am trying the following code to generate a pdf:

   try {
   // Create a new pdf handler
   $pdf = new PDFlib();

   //  open new PDF file
   if ($pdf-begin_document(, ) == 0) {
   die(Error:  . $p-get_errmsg());
   }

   // Set some info to the new pdf
   $pdf-set_info(Creator, Test);
   $pdf-set_info(Author, Test);
   $pdf-set_info(Title, Test);
 // Start the page
   $pdf-begin_page_ext(595, 842, );
 // Load the documents font and set the details
   $font = $pdf-load_font(Times-Roman, iso8859-7, );
   $pdf-setfont($font,24.0);
   $pdf-set_parameter('autospace',TRUE);
 // Set the position inside the document
   $pdf-set_text_pos(50, 700);
 // Now start to show the data
   $str = 'Αυτό είναι ένα τεστ.';
   mb_convert_variables('ISO-8859-7','UTF-8',$str);
   $pdf-show($str);
 // End the page and the document
   $pdf-end_page_ext();
   $pdf-end_document();
 // Get the document from the buffer find it's length
   $buf = $pdf-get_buffer();
   $len = strlen($buf);
 // And finally print it out to the browser
   header(Content-type: application/pdf);
   header(Content-Length: $len);
   header(Content-Disposition: inline; filename=hello.pdf);
   print $buf;
   }
 catch (PDFlibException $e) {
   die(PDFlib exception occurred in hello sample:\n .
   [ . $e-get_errnum() . ]  . $e-get_apiname() . :  .
   $e-get_errmsg() . \n);
   }
   catch (Exception $e) {
   die($e);
   }

Although greek are printed normally the characters are overlapping on 
each other. The script in encoded in UTF-8.


Does anybody have any suggestions on this? Please any help would be 
appreciated.




LaTeX has some greek stuff that works fairly well - though you have to 
use one of the fonts encoded for LaTeX.


If you mean to have a web app generate the PDF you'll have to output to 
.tex and then use a shell command to compile the document, but it is a 
solution that is fairly well tested for creation of Greek (monotonic and 
polytonic) PDF documents.


I know that isn't what you asked, but in case there isn't a PDFLib 
solution to the typesetting issue, I suspect an application designed for 
typesetting will give better results anyway.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-27 Thread TS
Ok so, I have an array

[0(index)][1st key][2nd key]

Basically I don't care about the index. As a matter of fact I'd prefer it
reset to still be in order afterwards.

However, I need to sort the 1st key and keep correlation w the second key.
Then sort on the second key.

I have video volumes and scenes like 

[0][110][1]
[1][110][3]
[2][110][2]
[3][110][4]

Any help would be much appreciated.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SESSION values show up days later!

2009-03-27 Thread Paul M Foster
On Fri, Mar 27, 2009 at 02:39:22PM -0700, Mary Anderson wrote:

 Hi all,
I use session variables to store values from one page to another on
 my website.
Alas, sometimes, but not always, the values persist from one
 invocation of the script to another!
Just how, exactly, do I make them go away when a user exits the
 program? I assume my users will not always be logging out explicitly.
Thanks.
 maryfran

Unset the variable. Session variables (as far as I know) will persist as
long as the user keeps open his browser, or until they time out. But you
can do unset($_SESSION['myvar']) to unset a particular variable at any
time (assuming you have previously called session_start()).

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: RE: [PHP] flushing AJAX scripts

2009-03-27 Thread jim white
Well, the point was that I had tried the first way, submitting one AJAX 
request and waiting for it to finish and it was timing out, probably on 
my firewall which it shouldn't have - but it did. The reports can take 
10 seconds or 10 minutes to create. Doing it this way I can still load 
the report even if the original request shuts down after 3-4 minutes.


Jim

Andrea Giammarchi wrote:
Sorry Jim, I meant Jim when I wrote Kim ... and 
Phico: http://webreflection.blogspot.com/2008/04/phomet-changes-name-so-welcome-phico.html


Regards

  

From: an_...@hotmail.com
To: php-general@lists.php.net
Date: Fri, 27 Mar 2009 15:55:28 +0100
Subject: RE: [PHP] flushing AJAX scripts


Sorry, Kim, but why on earth you are polling with a second request to know when 
the first one has finished?
I mean, when the first request inserts data in the database that's it, you'll 
manage the end of the request.

$A ---  do stuff; do stuff; do stuff; report ready;
$B --- report ready?
$B --- report ready?
$B --- report ready?
$B --- report ready?
report ready; --- notification to A
$B --- report ready;

the report ready, if it is when $A request has been finished, will be in $A, 
the polling via $B is absolutely useless, imo.

There is no timeout from Ajax, it simply keep waiting, but obviously if your 
PHP has max_execution_time 30 seconds and the script execution takes more than 
30 seconds there's no polling that could save you.

The same if the user closes the browser, connection lost, bye bye response.

To have a notice, you need Comet, try out Phico but still, a page that requires 
that much is not suitable for the web. Report creation should be a cronjob in a 
separed thread if it is that stressful.

Regards



Date: Fri, 27 Mar 2009 10:47:10 -0400
From: jbw2...@earthlink.net
To: an_...@hotmail.com
CC: php-general@lists.php.net
Subject: Re: RE: [PHP] flushing AJAX scripts

My page submits the AJAX request to complete a report that takes some 
time, and upon completion stores results in a database. A second AJAX 
request polls every 5 seconds and queries the database if the report is 
ready. This hopefully will get around any timeout problems I am having 
with a long running request, and seems to be working. It looks like I 
can accept the default behavior for now. I don't depend on getting a 
response from the original request, but is there a point where the AJAX 
response script will be stopped either by Apache or PHP before it can 
insert into the database?


Jim
  

_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx



_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx
  



--
James (Jim) B. White
tel: (919)-380-9615
homepage: http://jimserver.net/ 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-27 Thread Jim Lucas

TS wrote:

Ok so, I have an array

[0(index)][1st key][2nd key]

Basically I don't care about the index. As a matter of fact I'd prefer it
reset to still be in order afterwards.

However, I need to sort the 1st key and keep correlation w the second key.
Then sort on the second key.

I have video volumes and scenes like 


[0][110][1]
[1][110][3]
[2][110][2]
[3][110][4]

Any help would be much appreciated.




plaintext?php

function recursive_ksort($ar) {
if ( is_array($ar) ) {
ksort($ar);
foreach ( $ar AS $k = $v ) {
if ( is_array($v) ) {
recursive_ksort($v);
$ar[$k] = $v;
}
}
} else {
echo 'ERROR: recursive_ksort() expect the first argument to be 
an array()';
}
return false;
}

$d[0][110][1] = '01101';
$d[0][110][2] = '01102';
$d[0][110][3] = '01103';
$d[1][113][3] = '11103';
$d[1][115][1] = '11101';
$d[1][114][3] = '11103';
$d[2][110][2] = '21102';
$d[3][114][2] = '31102';
$d[2][110][1] = '21101';
$d[3][110][3] = '31103';
$d[2][110][4] = '21104';
$d[3][111][4] = '31104';

recursive_ksort($d);

print_r($d);

?

Seems to work for me.  Give it a run and let us know...


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php