php-general Digest 13 Oct 2007 06:47:14 -0000 Issue 5070

Topics (messages 263157 through 263175):

Screenshot from web page
        263157 by: Gevorg Harutyunyan
        263158 by: Al

Re: round()
        263159 by: Jürgen Wind
        263161 by: Instruct ICC
        263167 by: Instruct ICC
        263171 by: tedd
        263172 by: tedd

exit and ob_*
        263160 by: Philip Thompson
        263162 by: Philip Thompson
        263163 by: Robert Cummings
        263164 by: Robert Cummings
        263165 by: Philip Thompson
        263166 by: Andrew Ballard
        263168 by: Philip Thompson

header error without whitespace issue
        263169 by: Brad

Re: A two flavored post
        263170 by: Dan

Re: Classes - Dumb question
        263173 by: tedd
        263174 by: tedd
        263175 by: Christian Hänsel

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

I would like to make web page screenshot and generate an image for
example .jpg or .png using PHP,Apache.

If any one has experiance in doing that please help.

I know that there are lot of services like that, but I don't want to use them.
In real I need that to generate screenshot of my local server pages.

-- 
Best Regards,
Gevorg Harutyunyan

--- End Message ---
--- Begin Message --- Check the Imagick php-extension API for the Imagemagick commands. I recall there is a an html=> jpg or any image format.

Gevorg Harutyunyan wrote:
Hi,

I would like to make web page screenshot and generate an image for
example .jpg or .png using PHP,Apache.

If any one has experiance in doing that please help.

I know that there are lot of services like that, but I don't want to use them.
In real I need that to generate screenshot of my local server pages.


--- End Message ---
--- Begin Message ---


tedd wrote:
> 
> At 7:30 PM -0700 10/11/07, Instruct ICC wrote:
>>
>>
>>Now I see why BCMath was mentioned.
> 
> Yes, but precision is not the issue.
> 
> It doesn't make any difference if you are rounding.
> 
> (a) 1.489123451985765
> 
> or
> 
> (b) 148912345198576.5
> 
> You still have to make a decision as to if the above (a) rounds to:
> 
> (a) 1.48912345198577
> 
> or
> 
> (a) 1.48912345198576
> 
> or the above (b) rounds to:
> 
> (b)148912345198577
> 
> or
> 
> (b) 148912345198576
> 
> It's a question of rounding, not precision.
> 
> Cheers,
> 
> tedd
> 
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

It's a question of what you expect from a rounding function. 
If you work with reals on a computer you always have a bit of "fuzzynes" 
due to the internal conversions from float to binary and resulting
truncations.
If you need reproducable results which fit your expectations and if speed 
doesn't matter just use your own routine depending on string comparison.

YMMV
-- 
View this message in context: 
http://www.nabble.com/round%28%29-tf4602528.html#a13177072
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
> > Yes, but precision is not the issue.
> > 
> > It doesn't make any difference if you are rounding.
> > You still have to make a decision


Uuhm, what was $t on the platform before the round please (the += 
.0000000......1 post)?  Then that will confirm that precision is not the 
problem.



Also, "making a decision" is setting the optional precision value in the round 
function.
_________________________________________________________________
Climb to the top of the charts!  Play Star Shuffle:  the word scramble 
challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct

--- End Message ---
--- Begin Message ---
> > > Yes, but precision is not the issue.
> > > 
php -r '$t=123.45; echo $t . "\n"; $t+=0.00000000001; echo $t . "\n";'
123.45
123.45000000001
php -r '$t=123.45; echo $t . "\n"; $t+=0.000000000001; echo $t . "\n";'
123.45
123.45

php -r '$t=123.45678901234567; echo $t . "\n";'
123.45678901235

Geee garbage in, garbage out.
round would have been given garbage to process depending upon the precision 
desired.

Anyway, you can still believe what you want.  I see others agree.

_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by 
today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline

--- End Message ---
--- Begin Message ---
At 11:08 AM -0700 10/12/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote:
It's a question of what you expect from a rounding function.
If you work with reals on a computer you always have a bit of "fuzzynes"
due to the internal conversions from float to binary and resulting
truncations.

It is only "reals" that use a rounding function.

If you need reproducable results which fit your expectations and if speed
doesn't matter just use your own routine depending on string comparison.

Yes, I can round my own -- one that is more accurate than round(). But, I was wondering if others had observed that round() was not as accurate as other methods -- and that was the point of my initial post.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 12:55 PM -0700 10/12/07, Instruct ICC wrote:
 > > > Yes, but precision is not the issue.
 > >
php -r '$t=123.45; echo $t . "\n"; $t+=0.00000000001; echo $t . "\n";'
123.45
123.45000000001
php -r '$t=123.45; echo $t . "\n"; $t+=0.000000000001; echo $t . "\n";'
123.45
123.45

php -r '$t=123.45678901234567; echo $t . "\n";'
123.45678901235

Geee garbage in, garbage out.
round would have been given garbage to process depending upon the precision desired.

Anyway, you can still believe what you want.  I see others agree.


Never mind.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hi. This is weird. Here's my structure. I have an index.php file that just
includes the content depending on what page the user is on. So, because of
potential redirection from those sub-pages, I call ob_start() before any
output (in index.php). I'm doing some testing and I'm wanting to see what
information's in a variable, etc. So, I display the variable contents and
call 'exit' so that the page doesn't continue and get redirected elsewhere.
However, when I call 'exit' on one of these sub-pages, I get no output from
that sub-page.

During testing, I took out the redirection and commented the exit line. The
output displayed. Before commenting the exit function call, I called
ob_clean to see if it had something to do with there being content in the
buffer - the content of the sub-page showed WITH the exit. Why would no
information show when calling exit(), even if ob_start had been called? I've
never had to deal with this before.

[examples]
// This is content from a sub-page called from index.php

[example code: does not work]
echo 'hi';
exit;
// 'hi' does NOT display
...

[example code: does work]
ob_clean();
echo 'hi';
exit;
// 'hi' DOES display
...

[/examples]

I suppose this isn't a big deal during production, but during testing it's
really frustrating. Does anyone have any suggestions as to why 'exit' is
functioning (no pun intended) this way? Note: I do want what's currently in
the buffer to be sent to the browser, so I don't want to have to call
ob_clean. Any thoughts?

Another person (*francois at bonzon dot com) *mentions this on the PHP exit
page <http://www.php.net/exit>, but I'm still not sure why it happens.

Thanks in advance,
~Philip

--- End Message ---
--- Begin Message ---
On 10/12/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> Have you checked your error log to see if there an error being generated
> that you can't see?
>
> Cheers,
> Rob.


Yes, no unusual errors. The thing is... this wasn't an issue when I was
developing on a Suse box running apache. Recently, I moved development over
to Win 2k3 running IIS6. Since then, several issues have cropped up. =/
Think this could be IIS-related?

~Philip


On Fri, 2007-10-12 at 14:03 -0500, Philip Thompson wrote:
> > Hi. This is weird. Here's my structure. I have an index.php file that
> just
> > includes the content depending on what page the user is on. So, because
> of
> > potential redirection from those sub-pages, I call ob_start() before any
> > output (in index.php). I'm doing some testing and I'm wanting to see
> what
> > information's in a variable, etc. So, I display the variable contents
> and
> > call 'exit' so that the page doesn't continue and get redirected
> elsewhere.
> > However, when I call 'exit' on one of these sub-pages, I get no output
> from
> > that sub-page.
> >
> > During testing, I took out the redirection and commented the exit line.
> The
> > output displayed. Before commenting the exit function call, I called
> > ob_clean to see if it had something to do with there being content in
> the
> > buffer - the content of the sub-page showed WITH the exit. Why would no
> > information show when calling exit(), even if ob_start had been called?
> I've
> > never had to deal with this before.
> >
> > [examples]
> > // This is content from a sub-page called from index.php
> >
> > [example code: does not work]
> > echo 'hi';
> > exit;
> > // 'hi' does NOT display
> > ...
> >
> > [example code: does work]
> > ob_clean();
> > echo 'hi';
> > exit;
> > // 'hi' DOES display
> > ...
> >
> > [/examples]
> >
> > I suppose this isn't a big deal during production, but during testing
> it's
> > really frustrating. Does anyone have any suggestions as to why 'exit' is
> > functioning (no pun intended) this way? Note: I do want what's currently
> in
> > the buffer to be sent to the browser, so I don't want to have to call
> > ob_clean. Any thoughts?
> >
> > Another person (*francois at bonzon dot com) *mentions this on the PHP
> exit
> > page <http://www.php.net/exit>, but I'm still not sure why it happens.
> >
> > Thanks in advance,
> > ~Philip
> --
> ...........................................................
> SwarmBuy.com - http://www.swarmbuy.com
>
>     Leveraging the buying power of the masses!
> ...........................................................
>

--- End Message ---
--- Begin Message ---
Have you checked your error log to see if there an error being generated
that you can't see?

Cheers,
Rob.


On Fri, 2007-10-12 at 14:03 -0500, Philip Thompson wrote:
> Hi. This is weird. Here's my structure. I have an index.php file that just
> includes the content depending on what page the user is on. So, because of
> potential redirection from those sub-pages, I call ob_start() before any
> output (in index.php). I'm doing some testing and I'm wanting to see what
> information's in a variable, etc. So, I display the variable contents and
> call 'exit' so that the page doesn't continue and get redirected elsewhere.
> However, when I call 'exit' on one of these sub-pages, I get no output from
> that sub-page.
> 
> During testing, I took out the redirection and commented the exit line. The
> output displayed. Before commenting the exit function call, I called
> ob_clean to see if it had something to do with there being content in the
> buffer - the content of the sub-page showed WITH the exit. Why would no
> information show when calling exit(), even if ob_start had been called? I've
> never had to deal with this before.
> 
> [examples]
> // This is content from a sub-page called from index.php
> 
> [example code: does not work]
> echo 'hi';
> exit;
> // 'hi' does NOT display
> ...
> 
> [example code: does work]
> ob_clean();
> echo 'hi';
> exit;
> // 'hi' DOES display
> ...
> 
> [/examples]
> 
> I suppose this isn't a big deal during production, but during testing it's
> really frustrating. Does anyone have any suggestions as to why 'exit' is
> functioning (no pun intended) this way? Note: I do want what's currently in
> the buffer to be sent to the browser, so I don't want to have to call
> ob_clean. Any thoughts?
> 
> Another person (*francois at bonzon dot com) *mentions this on the PHP exit
> page <http://www.php.net/exit>, but I'm still not sure why it happens.
> 
> Thanks in advance,
> ~Philip
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
On Fri, 2007-10-12 at 14:30 -0500, Philip Thompson wrote:
> On 10/12/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > Have you checked your error log to see if there an error being generated
> > that you can't see?
> >
> > Cheers,
> > Rob.
> 
> 
> Yes, no unusual errors. The thing is... this wasn't an issue when I was
> developing on a Suse box running apache. Recently, I moved development over
> to Win 2k3 running IIS6. Since then, several issues have cropped up. =/
> Think this could be IIS-related?

No idea, I've never used IIS :)

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
On 10/12/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2007-10-12 at 14:30 -0500, Philip Thompson wrote:
> > On 10/12/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> > >
> > > Have you checked your error log to see if there an error being
> generated
> > > that you can't see?
> > >
> > > Cheers,
> > > Rob.
> >
> >
> > Yes, no unusual errors. The thing is... this wasn't an issue when I was
> > developing on a Suse box running apache. Recently, I moved development
> over
> > to Win 2k3 running IIS6. Since then, several issues have cropped up. =/
> > Think this could be IIS-related?
>
> No idea, I've never used IIS :)
>
> Cheers,
> Rob.
>

Oh lucky you! I'm drafting reasons on why we should switch to apache. I may
have some leverage with this issue! ;-) Thanks for you help. Anyone else
have some thoughts?

~Philip

--- End Message ---
--- Begin Message ---
On 10/12/07, Philip Thompson <[EMAIL PROTECTED]> wrote:
> I suppose this isn't a big deal during production, but during testing it's
> really frustrating. Does anyone have any suggestions as to why 'exit' is
> functioning (no pun intended) this way? Note: I do want what's currently in
> the buffer to be sent to the browser, so I don't want to have to call
> ob_clean. Any thoughts?

I don't know about the behavior, but if you want the contents to be
sent, you can flush them using ob_flush() instead of clearing them
with ob_clean().

Andrew

--- End Message ---
--- Begin Message ---
On 10/12/07, Andrew Ballard <[EMAIL PROTECTED]> wrote:
>
> On 10/12/07, Philip Thompson <[EMAIL PROTECTED]> wrote:
> > I suppose this isn't a big deal during production, but during testing
> it's
> > really frustrating. Does anyone have any suggestions as to why 'exit' is
> > functioning (no pun intended) this way? Note: I do want what's currently
> in
> > the buffer to be sent to the browser, so I don't want to have to call
> > ob_clean. Any thoughts?
>
> I don't know about the behavior, but if you want the contents to be
> sent, you can flush them using ob_flush() instead of clearing them
> with ob_clean().
>
> Andrew


That's the issue. The contents from the super page (index.php) ARE being
flushed. However, the contents of the sub-pages are NOT being flushed -
nothing is displayed. That's why this is weird. "Some" of the buffer is
flushed, but not the whole thing. Or, the contents of the sub-pages are
making it into the buffer (which makes no sense - size is definitely not an
issue).

However, I did call ob_flush to see if this would work. Nope. It didn't make
a difference. But this makes sense b/c the contents of the super-page are
already flushed. Blegh!!!

This is frustrating. Is happy hour here yet?!

~Philip

--- End Message ---
--- Begin Message ---
Error =

WARNING: Cannot modify header information - headers already sent by (output
started at /home/zoneof5/public_html/index-dev.html:10) in line 1528 of file
common.inc.php

 

Which comes from me trying to take a login script and put it into an
existing .html file with .htaccess configured to parse php scripts.

 

Research yields that the header needs to be loaded before anything.

The header is being called by another file “common.inc.php”

 

How do I safely extract this call from the existing script and place the
call at the beginning of the .html or just simply fix the error?

 

Php code;

 

 

<?php

include('./amember/config.inc.php');

$t = & new_smarty();

$_product_id = array('ONLY_LOGIN');

if (isset($_REQUEST['amember_redirect_url']))

    $_SESSION['amember_redirect_url'] = $_REQUEST['amember_redirect_url'];

function rcmp_begin_date($a, $b){

    return strcmp($b['begin_date'], $a['begin_date']);

}

include($config['plugins_dir']['protect'] . '/php_include/check.inc.php');

$payments = & $db->get_user_payments(intval($_SESSION['_amember_id']), 1);

usort($payments, 'rcmp_begin_date');

$now = date('Y-m-d');

$urls = array();

foreach ($payments as $k=>$v){

    if (($v['expire_date'] >= $now) && ($v['begin_date'] <= $now)) {

        $p = get_product($v['product_id']);

        $url = $p->config['url'];

        if (strlen($url)){

            $urls[] = $url;

        }

    }

}

if ($_SESSION['amember_redirect_url']) {

        $redirect = $_SESSION['amember_redirect_url'];

        unset($_SESSION['amember_redirect_url']);

} elseif (count(array_unique($urls)) == 1){

    if (in_array('htpasswd_secure', $plugins['protect'])){

        $member_login_pw = 

        htpasswd_secure_get_login($_SESSION['_amember_user']['login']).

        ':'.

        htpasswd_secure_get_passwd($_SESSION['_amember_user']['pass']);

        $redirect = add_password_to_url($urls[0], $member_login_pw);

    } else {

        if ($config['display_member_pw_urls']) {

             $member_login_pw = 

             $_SESSION['_amember_user']['login'].

             ':'.

             $_SESSION['_amember_user']['pass'];

             $redirect = add_password_to_url($urls[0], $member_login_pw);

        } else {

            $redirect = add_password_to_url($urls[0]);

        }

    }

} else {

    $redirect = $config['root_url'] . "/amember/member.php";

}

#print_r($urls);

html_redirect("$redirect", 0, 'Redirect', _LOGIN_REDIRECT);

?>


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.8/1064 - Release Date: 10/11/2007
3:09 PM
 

--- End Message ---
--- Begin Message --- In addition to what everyone else has suggested you probably also want to have your page work for people without javascript enabled, or the handicapped. One way you could do this is have a div and the PHP generates the div where you would put the link, with code for the link inside with the PHP variable so you have
----------------------
|  abc.com/?a=value  |
----------------------
the div wouldn't really have a border, it's just there so you can see it.
Anyway, for those lucky people who have JavaScript enabled you could simply use JS to change the innerhtml of the div to have the new JS generated link.

- Dan

Nathan Nobbe"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
On 10/4/07, tedd <[EMAIL PROTECTED]> wrote:

Hi gang:

I asked this question on the javascript list, but for some reason
it's taking forever to post there. So, I figured that I would ask
here as well.

I'm currently sending data (the value of s) to another script via the
html statement:

<a href="img.php?s=<?php echo($value);?>">Click here</a>

However, I need to add another variable, namely a javascript
variable, to the GET string.

How can I send both a php and a javascript variable together at the same
time?



the question is when is the variable you want to append available to the
javascript.
as soon as you get the variable in the javascript the next thing you can do
is append
it to the value of the href attribute of the <a> tag.

<html>
   <head>
       <script type="text/javascript">
           window.onload = function() {
var someLinkHref = document.getElementById('someLink').href;
               someLinkHref += "&anotherVar=8";
               alert(someLinkHref);
           }
       </script>
   </head>
   <body>
       <a id="someLink" href="http://somesite.com?a=5";>
           click here
       </a>
   </body>
</html>

if you want to use the onclick event handler as rob suggested, you could
stash the variable in the Window
global object, then reference it in the implementation of the onclick
function (though i still have mixed feelings
about that approach [the Window object part that is]).

-nathan


-nathan


--- End Message ---
--- Begin Message ---
At 2:44 PM +0100 10/12/07, Stut wrote:
You can limit the need to add more code like so...

function customer($whatWas, $customertype, $whatAdditional)
{
    /* do "what was" (i.e., common to all) */
    /* then do what's additional unique to type */
    $func = strtolower($customertype).'Customer';
    $func($whatAdditional);
}

That's something I haven't seen before (in this language) -- that's slick.

Thanks,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 9:03 AM -0500 10/12/07, Jay Blanchard wrote:
tedd said:

In either case, I still have to write more code to accommodate
scaling. And, if I have more customer types, then it's a simple
matter to add more customer functions and addition case statements to
the initial customer function. I don't see the benefit in using a
class. At this point, it just looks like a different way of doing
things.
[/snip]

No doubt. (are you by chance continuing the other argument, re: interfaces?)

No, I didn't really understand the argument anyway. An interface to me "currently" is what the user uses to trigger my scripts.

, but you have to break open the original tested function, add code to it, test it, etc. Every time you add a new case you have to break open the existing function to add that case. After a while, say if you need to drop a customer type you would have to (not really, you can leave it there and never exercise the case) break open the original code and delete the un-used code. Any way that you slice it the original customer function becomes more and more like spaghetti every day. Documentation for the function has to change each time as well.

Every time you add more code, the documentation should change regardless.

Every time you add more code, you have to test it anyway.

Spaghetti is not caused by adding more code, but by poor design.

With a class you can inherit all of the base class functionality into a new customer type. You do not have to break open the base class to add a case, you just have to create an extension class. Documentation is unique to each class.

No matter what, you have to break something open to add code -- if nothing else, the script.

I do see and understand the methodology afforded by OOP, but, I don't see an overwhelming reason to use it. Maybe in my next decade of programming I'll get with the program. After all, I don't keypunch anymore and that's progress. :-)

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---

""Jay Blanchard"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED]
[snip]
First of all what you call "normal" is procedural or functional
programming. There is nothing wrong with doing things this way and may
be
especially quick and efficient when doing basic web sites and
applications.
Document well and you will have no problem maintaining your code.

One correction.  What is being described is procedural or imperative
programming.  Functional programming is another beast entirely
(closures,
first-class functions, immutable variables, etc.).  PHP is not a
functional
language by any stretch of the imagination.  For functional programming,
see
Erlang, Haskel, ML, LISP, and to a lesser extent Javascript.
[/snip]

Thanks for the correction Larry, I knew the difference and just brain
farted.

Thanks guys,

I will try to test some of this stuff for my new project... could be fun from what I have seen so far.

Cheers!

Chris

--
-------------------------------------
My baby's first words will be
"Hello World"

--- End Message ---

Reply via email to