php-general Digest 24 Sep 2009 17:10:40 -0000 Issue 6356

Topics (messages 298307 through 298325):

Re: Does anyone here use TCPDF?
        298307 by: Dave M G
        298308 by: Ralph Deffke
        298309 by: Ben Dunlap

PHPlot patch
        298310 by: Chandana
        298311 by: Sudheer Satyanarayana

Re: session.gc_maxlifetime
        298312 by: Tom Worster
        298319 by: Ben Dunlap
        298321 by: Ralph Deffke

catch an iconv E_NOTICE
        298313 by: Tom Worster
        298315 by: David Otton
        298316 by: Tommy Pham
        298324 by: Tom Worster

stdout as input
        298314 by: Christoph Boget
        298317 by: Tommy Pham
        298318 by: Christoph Boget
        298320 by: Ben Dunlap
        298322 by: Shawn McKenzie
        298323 by: Christoph Boget

variable
        298325 by: Grega Leskovšek

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Ralph, Paul,

Thank you for responding.

> I don't use TCPDF; I use FPDF, but I imagine the drill is about the same
>   
I tried using FPDF, but it did not support UTF-8/Japanese. It claims
some support in the documentation, but after much experimentation, I
verified it does not. That is why I switched to TCPDF.

> What you're asking sounds like you want to *edit* an existing PDF via a
> PHP class,

No, I just want to write on top of it. And that was possible with
FPDI/FPDF, but I had to abandon those as they did not support Japanese.

I attempted to use the same functions as FPDI/FPDF, but they did not
work in TCPDF.

> have a look in the archive of this list. there is a topic "writing japanese
> test in an excisting pdf" its of 31. of August, this should help
>   

That was a thread I started. Things have changed slightly since I now
know that only TCPDF supports Japanese.

So I still need to know if/how to write text into a PDF, like I did with
FPDF, but with TCPDF instead.

If this turns out to not be possible, I am going to be suffering a great
deal.

-- 
Dave M G

--- End Message ---
--- Begin Message ---
Hi Dave,

if its the case u could do a good deal, why u don't climp urself into the
pdf format? It is nothing else then a presentation format, not magic,
complicated and huge yes, but at the end just a text file. I am not that pdf
specialist, but I know at least for the older pdf formats the enconding is
open and well documented. I have a book on my shelf called 'pdf bible' an it
explains the pdf byte code.

Another idea would be to contact all the companies creating these pdf
converters (html pdf, word-pdf, pdf-word) they should be able to tell u the
answer.

And even may be there is a programm u could use in a OS batch process to put
ur text in.
At least just contact Adobe and ask them how to do it, u might get an
answer.

sorry thats all I have coming up in my mind for now.

[email protected]

"Dave M G" <[email protected]> wrote in message
news:[email protected]...
> Ralph, Paul,
>
> Thank you for responding.
>
> > I don't use TCPDF; I use FPDF, but I imagine the drill is about the same
> >
> I tried using FPDF, but it did not support UTF-8/Japanese. It claims
> some support in the documentation, but after much experimentation, I
> verified it does not. That is why I switched to TCPDF.
>
> > What you're asking sounds like you want to *edit* an existing PDF via a
> > PHP class,
>
> No, I just want to write on top of it. And that was possible with
> FPDI/FPDF, but I had to abandon those as they did not support Japanese.
>
> I attempted to use the same functions as FPDI/FPDF, but they did not
> work in TCPDF.
>
> > have a look in the archive of this list. there is a topic "writing
japanese
> > test in an excisting pdf" its of 31. of August, this should help
> >
>
> That was a thread I started. Things have changed slightly since I now
> know that only TCPDF supports Japanese.
>
> So I still need to know if/how to write text into a PDF, like I did with
> FPDF, but with TCPDF instead.
>
> If this turns out to not be possible, I am going to be suffering a great
> deal.
>
> -- 
> Dave M G



--- End Message ---
--- Begin Message ---
> I attempted to use the same functions as FPDI/FPDF, but they did not
> work in TCPDF.

Which functions did you use in FPDF?

Ben

--- End Message ---
--- Begin Message ---
Hi,

I was using Phplot for a project of mine and I had to do some modifications
in the phplot.php code to show the data values at the peaks of the graph. I
would like to commit the modification code to the phplot repository so that
others can also use it as an inbuilt functionality. 

If I want to commit to the phplot, how may I achieve it?

Thank you
-- 
View this message in context: 
http://www.nabble.com/PHPlot-patch-tp25550789p25550789.html
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
On Thursday 24 September 2009 03:33 PM, Chandana wrote:
Hi,

I was using Phplot for a project of mine and I had to do some modifications
in the phplot.php code to show the data values at the peaks of the graph. I
would like to commit the modification code to the phplot repository so that
others can also use it as an inbuilt functionality.

If I want to commit to the phplot, how may I achieve it?
As any other project, contact the project developers and offer them your patch.


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net


--- End Message ---
--- Begin Message ---
it could be ip address changes. interesting thought.

i think i should add some special logging.

it's a dedicated freebsd server with one app.


On 9/23/09 6:43 PM, "Ralph Deffke" <[email protected]> wrote:

> finaly we went with a custom cooky handling, however the customers
> requirements where two days.
> 
> if u are shure that the server is still the same hardware like it has been 6
> years ago then it might be some client stuff, however if there are other
> applications, pages running (virtual servers) then it would still be to
> consider. mamory and resource management is deep os. again I wouldn't trust
> for that amount of session livetime.
> 
> I dont think, putting it down to three hours would help much.
> 
> and of course, it could be client side also. Can't you figure out the
> clients?
> and keep in mind that a lot of people connect to UMTS rigzt now, these
> systems deconnect on idle lines and reconect without the users even know it.
> Also a lot of lines change IP address at midnihgt.
> 
> cheers
> [email protected]
> 
> "Tom Worster" <[email protected]> wrote in message
> news:c6e00521.12d98%[email protected]...
>> there's a need for long timeouts in this app but could perhaps be reduced
>> from 6 to 3 hours.
>> 
>> the sessions are cookie based using php's 'file' handler and
>> session.cookie_lifetime=0. the server appears to have plenty of free
> memory
>> and appears not to have swapped in nearly a year of uptime. load averages
>> indicate a pretty quiet server. there are currently 170 kbyte total in 90
>> serialized session files which is typical and not a memory load. the
>> distribution of modification times doesn't indicate heavy activity: ~20
>> files in the last 15 minutes and 35 in the last hour.
>> 
>> so i think the os can handle this. plus the app ran for 6 years before
>> anyone reported being prematurely logged off. i'm looking for other
>> possibilities: odd browser behavior, network trouble, ...
>> 
>> 
>> are there any browsers that have configurable cookie handling policy such
>> that they time out a cookie?
>> 
>> one web site i use displays this curious message: "For your protection,
>> sessions are open for a limited period of time on our website. Please
>> sign-on again. NOTE: Your browser may also limit secure connection time,
> and
>> automatically log you out independent of our timeout procedure."
>> 
>> that could be referring to browsers timing out an ssl connection. or
> perhaps
>> the cookie?
>> 
>> 
>> btw: when you said in your email you wouldn't trust a long gc_maxlifetime,
>> and you would only use a cookie-based solution for long session. did you
>> mean that you wouldn't trust php's cookie-based session handler? and you
>> would use a custom handler instead?
>> 
>> 
>> On 9/22/09 4:46 PM, "Ralph Deffke" <[email protected]> wrote:
>> 
>>> Hi Tom,
>>> 
>>> in sometimes 2001 I did have incidences with those things, and as I
> remember
>>> over the past years there where some trouble with operating systems and
>>> stuff. This part is very deep inside the os. I would expect that this is
>>> still to consider. I also would check, if this occurs on very busy/low
>>> memory server.
>>> 
>>> If I would programm the garbage collection clean up part, and if the
> server
>>> is about to run out of memory, I would kill sessions being longer time
> idle
>>> even when they are not yet as old as it is set in the gc_maxlifetime.
> This
>>> would be far better then shutting down the whole server just because
> there a
>>> 100 of idle sessions waiting to get used again.
>>> 
>>> as u mention a maxlivetime of 6h I would bet, that this is the problem.
> I
>>> would not trust such a long lifetime at all.
>>> 
>>> If sessions have to be active such a long time, I would see only cooky
> based
>>> solutions
>>> 
>>> let me know, what u did investigate on this.
>>> 
>>> [email protected]
>>> 
>>> 
>>> "Tom Worster" <[email protected]> wrote in message
>>> news:c6deae55.12cae%[email protected]...
>>>> thank you, Ralph!
>>>> 
>>>> i'm going to be bold and assume that tom at punkave dot com is right
>>> despite
>>>> that the report was discarded.
>>>> 
>>>> i got a complaint from a client about some users reporting being logged
>>> out
>>>> with rather short periods of inactivity. but session.gc_maxlifetime is
> set
>>>> to 6 hours so i don't think that's the source of the problem.
>>>> 
>>>> 
>>>> On 9/22/09 4:17 PM, "Ralph Deffke" <[email protected]> wrote:
>>>> 
>>>>> Hi Tom,
>>>>> 
>>>>> i did find this in the bug reports, its pretty new and should be an
>>> answer.
>>>>> 
>>>>> http://news.php.net/php.doc.bugs/2653
>>>>> 
>>>>> [email protected]
>>>>> 
>>>>> 
>>>>> "Tom Worster" <[email protected]> wrote in message
>>>>> news:c6de9eee.12c8d%[email protected]...
>>>>>> i'm not 100% sure what the manual means when it says...
>>>>>> 
>>>>>> session.gc_maxlifetime integer
>>>>>> session.gc_maxlifetime specifies the number of seconds after which
> data
>>>>> will
>>>>>> be seen as 'garbage' and cleaned up. Garbage collection occurs during
>>>>>> session start.
>>>>>> 
>>>>>> what event exactly does the "after which" here refer to?
>>>>>> 
>>>>>> i'd like to think that it means that a session is eligible for gc no
>>>>> sooner
>>>>>> than session.gc_maxlifetime seconds after the most recent access
> (read
>>> or
>>>>>> write) to that session. but it seems dangerously presumptuous to
> assume
>>>>> that
>>>>>> this is the case.
>>>>>> 
>>>>>> what do you take it to mean?
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 



--- End Message ---
--- Begin Message ---
> it could be ip address changes. interesting thought.

As far as I'm aware, PHP session-management doesn't care about source
IP, out-of-the-box -- your app would have to be coded to care. Plus I
suspect you would have started seeing the problem a long time ago, if
changing source IPs were the cause.

Ben

--- End Message ---
--- Begin Message ---
php not but perhaps the client its not clear and commonly defined what
clients do with cookies on reconnect and stuff or long idle times.

I would expect as source the new browsers where more and more users use
subwindows to have concurrent sessions, does anybody know how they handle ip
changes? I'm not.

these things are new and that would fit that the problem is new as well.


"bdunlap" <[email protected]> wrote in message
news:[email protected]...
> > it could be ip address changes. interesting thought.
>
> As far as I'm aware, PHP session-management doesn't care about source
> IP, out-of-the-box -- your app would have to be coded to care. Plus I
> suspect you would have started seeing the problem a long time ago, if
> changing source IPs were the cause.
>
> Ben



--- End Message ---
--- Begin Message ---
i have this hack that works up to a point...

function my_err_handler($errno, $errstr, $errfile, $errline) {
    if ( preg_match('/iconv/', $errstr) ) {
        throw new Exception('iconv error');
    } else {
        // ? how to invoke default error handler ?
    }
}
set_error_handler("my_err_handler", E_NOTICE);

try {
    $s = iconv($enc1, $enc2, $s);
} catch (Exception $e) {
    // deal with the failed conversion
}

but i'd like proceed with default error handling in the branch with the
question marks. how can i do that?



--- End Message ---
--- Begin Message ---
2009/9/24 Tom Worster <[email protected]>:

> but i'd like proceed with default error handling in the branch with the
> question marks. how can i do that?

An error handler that passes through to the previous error handler:

<?php
error_reporting(E_ALL);

function my_error_handler($errno, $errstr, $errfile, $errline) {
    restore_error_handler();
    trigger_error($errstr, $errno);
}

set_error_handler('my_error_handler', E_ALL);

trigger_error('TEST', E_USER_ERROR);

You'll lose the file and line, though, because you're actually raising
another error with the same message at a new point in the code.

--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: Tom Worster <[email protected]>
> To: PHP General List <[email protected]>
> Sent: Thursday, September 24, 2009 6:42:29 AM
> Subject: [PHP] catch an iconv E_NOTICE
> 
> i have this hack that works up to a point...
> 
> function my_err_handler($errno, $errstr, $errfile, $errline) {
>     if ( preg_match('/iconv/', $errstr) ) {
>         throw new Exception('iconv error');
>     } else {
>         // ? how to invoke default error handler ?

http://www.php.net/manual/en/function.restore-error-handler.php

>     }
> }
> set_error_handler("my_err_handler", E_NOTICE);
> 
> try {
>     $s = iconv($enc1, $enc2, $s);
> } catch (Exception $e) {
>     // deal with the failed conversion
> }
> 
> but i'd like proceed with default error handling in the branch with the
> question marks. how can i do that?
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On 9/24/09 10:30 AM, "David Otton" <[email protected]> wrote:

> 2009/9/24 Tom Worster <[email protected]>:
> 
>> but i'd like proceed with default error handling in the branch with the
>> question marks. how can i do that?
> 
> An error handler that passes through to the previous error handler:
> 
> <?php
> error_reporting(E_ALL);
> 
> function my_error_handler($errno, $errstr, $errfile, $errline) {
>     restore_error_handler();
>     trigger_error($errstr, $errno);
> }
> 
> set_error_handler('my_error_handler', E_ALL);
> 
> trigger_error('TEST', E_USER_ERROR);
> 
> You'll lose the file and line, though, because you're actually raising
> another error with the same message at a new point in the code.

and i'd need to set my error handler back again to catch the next iconv
error:

function my_err_handler($errno, $errstr, $errfile, $errline) {
    if ( preg_match('/iconv/', $errstr) ) {
        throw new Exception('iconv error');
    } else {
        restore_error_handler();
        trigger_error($errstr, $errno);
        set_error_handler('my_error_handler', E_ALL);
    }
}
set_error_handler('my_error_handler', E_ALL);

not lovely. as it stands, my own code writes the error message to the log
file in that place. i'm not sure this is an improvement.



--- End Message ---
--- Begin Message ---
I've read the section in the docs about i/o streams and other related
sections I was able to find but couldn't figure out how to do what I
need.  From the command line, I'm trying to pipe stdout in to my php
script which should then see it as input.  A simplistic example would
be:

echo bob | myScript.php

In myScript.php, I'm doing:

  $handle = popen( 'php://stdin', 'r' );
  echo var_export( $handle, TRUE ) . "\n\n";

I've also tried php://stdout and php://input.  I also tried eschewing
the php:// pseudo protocol and popen altogether and going with the
STDIN and STDOUT constants.  None of that worked.  Is there a way I
can pipe/redirect output from a command line uhh, command as input to
my script?

thnx,
Christoph

--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: Christoph Boget <[email protected]>
> To: PHP General <[email protected]>
> Sent: Thursday, September 24, 2009 6:51:56 AM
> Subject: [PHP] stdout as input
> 
> I've read the section in the docs about i/o streams and other related
> sections I was able to find but couldn't figure out how to do what I
> need.  From the command line, I'm trying to pipe stdout in to my php
> script which should then see it as input.  A simplistic example would
> be:
> 
> echo bob | myScript.php
> 
> In myScript.php, I'm doing:
> 
>   $handle = popen( 'php://stdin', 'r' );
>   echo var_export( $handle, TRUE ) . "\n\n";
> 
> I've also tried php://stdout and php://input.  I also tried eschewing
> the php:// pseudo protocol and popen altogether and going with the
> STDIN and STDOUT constants.  None of that worked.  Is there a way I
> can pipe/redirect output from a command line uhh, command as input to
> my script?
> 
> thnx,
> Christoph
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Isn't it simpler with
http://www.php.net/manual/en/function.shell-exec.php
?


--- End Message ---
--- Begin Message ---
> Isn't it simpler with
> http://www.php.net/manual/en/function.shell-exec.php
> ?

Perhaps.  But the command to execute would be relatively arbitrary.
What I'm trying to do is set up a script that will filter the results
of a grep.  But what I'm grepping and where I'm starting from would
change.  I suppose I could pass those arguments to my script and
access it using argv but I'm actually kind of curious how (if) I can
access output which has been piped (or redirected) to my script.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
> echo bob | myScript.php
>
> In myScript.php, I'm doing:
>
>  $handle = popen( 'php://stdin', 'r' );
>  echo var_export( $handle, TRUE ) . "\n\n";

What output are you getting from those lines, and what were you
expecting? $handle is just a resource, same as if you opened a regular
file -- you still need to read data from it with something like
fgets().

If I'm writing a quick-and-dirty script to process piped-in data, I
find this construct to work reasonably well:

while(!feof(STDIN)) {
    $line = fgets(STDIN);

    // trim() $line here if I don't want trailing/vertical whitespace

    // now do something with $line
}

The one weakness of that form is that I always get an empty line at
the end, but as long as I check for that in the loop (which I should
usually be doing anyway), it's no problem.

Ben

--- End Message ---
--- Begin Message ---
bdunlap wrote:
>> echo bob | myScript.php
>>
>> In myScript.php, I'm doing:
>>
>>  $handle = popen( 'php://stdin', 'r' );
>>  echo var_export( $handle, TRUE ) . "\n\n";
> 
> What output are you getting from those lines, and what were you
> expecting? $handle is just a resource, same as if you opened a regular
> file -- you still need to read data from it with something like
> fgets().
> 
> If I'm writing a quick-and-dirty script to process piped-in data, I
> find this construct to work reasonably well:
> 
> while(!feof(STDIN)) {
>     $line = fgets(STDIN);
> 
>     // trim() $line here if I don't want trailing/vertical whitespace
> 
>     // now do something with $line
> }
> 
> The one weakness of that form is that I always get an empty line at
> the end, but as long as I check for that in the loop (which I should
> usually be doing anyway), it's no problem.
> 
> Ben

Exactly.  And if you just want redirected data you can try:

$data = file_get_contents("php://stdin");

--or--

For an array of lines:

$lines = file("php://stdin");

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

--- End Message ---
--- Begin Message ---
> Exactly.  And if you just want redirected data you can try:
> $data = file_get_contents("php://stdin");
> --or--
> For an array of lines:
> $lines = file("php://stdin");

This is exactly what I was looking for.  Thanks Shawn and Ben!

thnx,
Christoph

--- End Message ---
--- Begin Message ---
Suppose I have a variable $i = 0 or 1 or 2
and I have variables $item0, $item1 and $item2
how do I print the variable $item0 using a combination of variable $item and
variable $i?
or with this code it gives me an error:
$i = 0;
$item0 = "test";
echo $item$i; #how do I properly use this variable $item with $i?

Thanks in advance, Yours, Grega


-- Peace refuge: http://users.skavt.net/~gleskovs/
When the sun rises I receive and when it sets I forgive;) Grega Leskovšek

--- End Message ---

Reply via email to