php-general Digest 21 Aug 2004 11:03:57 -0000 Issue 2949
Topics (messages 194379 through 194388):
Re: [OFF] Double charges to credit cards
194379 by: Justin Patrin
Re: SimpleXML
194380 by: Daniel Schierbeck
Linkpoint API question
194381 by: Brian Dunning
194382 by: Justin Patrin
194385 by: Curt Zirzow
Get reference count on a variable.
194383 by: Robert Cummings
194384 by: Curt Zirzow
194387 by: Robert Cummings
Re: Re:Re: [PHP] How do I use sessions if cookies are turned off in the browser?
194386 by: Chris Shiflett
Re: avi to wmv convert
194388 by: Peter Clarke
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 ---
On Fri, 20 Aug 2004 13:37:23 -0700, Brian Dunning
<[EMAIL PROTECTED]> wrote:
> This question is not necessarily PHP-specific, though we are running
> PHP classes.
>
> Online store, credit card authorized at time of order, credit card
> charged at time of shipment (could be anywhere from a few minutes to a
> couple weeks later). Standard stuff. But customers are complaining that
> they're being double-charged. Turns out that both the authorization and
> the charge are showing up on their statements. Our merchant provider,
> ConcordEFSnet whose API we're using, says that this is just the way it
> works and there's nothing we can do about it.
This is bull, there's no way it works this way.
>
> Sounds too incredible to be true. I've never seen anything like this on
> my own credit card statements, and I can't imagine that Amazon, et. al.
> have this problem, though they follow our same business process. Can
> anyone shed any light on this?
>
How are you "charging" when the order ships? Are you doing a "Sale" or
a "Capture" transaction. Normally when you authorize an amount, it
puts a hold on the amount on the credit card. When you want to charge,
you have to do a "Capture" of the "Authorization". If you instead do a
"Sale", the authorization will show up as a block on the credit card.
It *should* go away after 30 or so days.
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--
--- End Message ---
--- Begin Message ---
Rick Fletcher wrote:
Daniel Schierbeck wrote:
I am having some problems with the XML features (I use the fancy new
SimpleXML). It works like a dream when I'm retrieving information from
an XML document, but when I want to insert new tags it screws up. I'm
trying to create a function that saves error logs in an XML file,
which should look like this:
<?xml version='1.0' standalone='yes'?>
<errors>
<error>
<number>2</number>
<string>Could not bla bla</string>
<file>filename.php</file>
<line>56</line>
</error>
<error>
<number>1</number>
<string>Failed to bla bla</string>
<file>filename2.php</file>
<line>123</line>
</error>
</errors>
I tried to use SimpleXML myself and had some strange behavior, so I
ended up switching to DOM. I was already basically familiar with DOM
anyway from javascript so development went quickly. You should take a
look: http://www.php.net/dom
There's more than one way to do it, of course, but code to add an
element to this tree could look something like this:
<?php
// load the existing tree
$doc = new DOMDocument();
$doc->load( "errors.xml" );
// count the number of existing "error" nodes
$errors_node = $doc->documentElement;
$error_count = $errors_node->getElementsByTagName( "error" )->length;
// create the new "error" node...
$error_node = $doc->createElement( "error" );
// ...and its children
$number_node = $doc->createElement( "number", $error_count + 1 );
$string_node = $doc->createElement( "string", "New error message" );
$file_node = $doc->createElement( "file", "foo.php" );
$line_node = $doc->createElement( "line", "32" );
// add the children to the error node
$error_node->appendChild( $number_node );
$error_node->appendChild( $string_node );
$error_node->appendChild( $file_node );
$error_node->appendChild( $line_node );
// add the new "error" node to the tree
$doc->documentElement->appendChild( $error_node );
// save back to the file
$doc->save( "errors.xml" );
?>
-- Rick
Thanks, that looks promising! It would be slick if SimpleXML could
handle that type of insertion, but i guess you can't get everything, eh?
Best regards, Daniel
--- End Message ---
--- Begin Message ---
I telephoned *just* as the Linkpoint API support folks left for the
weekend....
Currently we are doing just a SALE transaction. I want instead to first
submit an authorization with AVS and CVV2 information, make a decision
(2 out of 3) and then process the charge or not. The documentation is
not clear to me: does anybody know which of Linkpoint's "ordertypes"
these would be? Would the first be PREAUTH and the second be POSTAUTH?
Many thanks,
- Brian
--- End Message ---
--- Begin Message ---
On Fri, 20 Aug 2004 17:16:03 -0700, Brian Dunning
<[EMAIL PROTECTED]> wrote:
> I telephoned *just* as the Linkpoint API support folks left for the
> weekend....
>
> Currently we are doing just a SALE transaction. I want instead to first
> submit an authorization with AVS and CVV2 information, make a decision
> (2 out of 3) and then process the charge or not. The documentation is
> not clear to me: does anybody know which of Linkpoint's "ordertypes"
> these would be? Would the first be PREAUTH and the second be POSTAUTH?
>
I don't know about Linkpoint, but with Verisign, this would be:
"Authorization" for the initial check
"Delayed Capture" to actually charge the card
"Void" to cancel the Authorization
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--
--- End Message ---
--- Begin Message ---
* Thus wrote Brian Dunning:
> I telephoned *just* as the Linkpoint API support folks left for the
> weekend....
>
> Currently we are doing just a SALE transaction. I want instead to first
> submit an authorization with AVS and CVV2 information, make a decision
> (2 out of 3) and then process the charge or not. The documentation is
> not clear to me: does anybody know which of Linkpoint's "ordertypes"
> these would be? Would the first be PREAUTH and the second be POSTAUTH?
I'm not sure and am just throwing a wild guess at this but from the
sounds of it, that info should be provided with PREAUTH.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!
--- End Message ---
--- Begin Message ---
Hi All,
I think I'm looking for something that doesn't exist, but just in
case thought I'd check the list. Does anyone know if a PHP function
exists to get the number of references on a given variable's data? I was
hoping to create a way for a factory to automatically recycle resources
without the need for the developer to call some kind of free() method.
If I could get the internal reference count then I'd be able to
determine if it is free by virtue of only 1 reference (the factory).
This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
Thanks in advance.
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
* Thus wrote Robert Cummings:
> Hi All,
>
> I think I'm looking for something that doesn't exist, but just in
> case thought I'd check the list. Does anyone know if a PHP function
> exists to get the number of references on a given variable's data? I was
> hoping to create a way for a factory to automatically recycle resources
> without the need for the developer to call some kind of free() method.
> If I could get the internal reference count then I'd be able to
> determine if it is free by virtue of only 1 reference (the factory).
> This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
unfortantly there isn't a method to determain this.
Be careful with PHP5, i'm not sure if its applicable in your
situation, but there does seem to be rumor that php5 objects are
assigned by reference, which isn't true:
$o1 = new object();
$o2 = $o1;
unset($o2);
the Object still exists, and the destructor isn't called.
vs.
$o3 = new object();
$o4 =& $o3;
unset($o3);
The object will no longer exist, destructor is called.
To elaborate a bit more on this... objects in php5 add a new
layer to variable existance.
When an object is created it creates itself into its own memory
space and a new variable ($o1) is allocated to point to that
objects memory space.
When the variable ($o1) is assigned to another variable ($o2), a
memory is allocated to point to the object as well. So now
two allocated variables are pointing to the same object. When one
of the variables is destroyed, since another variable still points
to the object, the object will continue to exist. Until all
variables pointing to that object no longer exits.
In unix filesystem terms, a variable of an object is very much like
how a hard link is treated. The allocated filename (variable in
php's case), points to the allocated data (object). When no other
filename points to the same data, the data is released from usage.
In the later example (using =&), the new variable created ($o4),
points to ($o3). So, as the manual explains, the new variable
($o4) is a symoblic link to the original variable ($o3).
I hope that wasn't too much info :)
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!
--- End Message ---
--- Begin Message ---
On Sat, 2004-08-21 at 00:10, Curt Zirzow wrote:
> * Thus wrote Robert Cummings:
> > Hi All,
> >
> > I think I'm looking for something that doesn't exist, but just in
> > case thought I'd check the list. Does anyone know if a PHP function
> > exists to get the number of references on a given variable's data? I was
> > hoping to create a way for a factory to automatically recycle resources
> > without the need for the developer to call some kind of free() method.
> > If I could get the internal reference count then I'd be able to
> > determine if it is free by virtue of only 1 reference (the factory).
> > This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
>
> unfortantly there isn't a method to determain this.
>
> Be careful with PHP5, i'm not sure if its applicable in your
> situation, but there does seem to be rumor that php5 objects are
> assigned by reference, which isn't true:
>
> $o1 = new object();
> $o2 = $o1;
> unset($o2);
>
> the Object still exists, and the destructor isn't called.
>
> vs.
>
> $o3 = new object();
> $o4 =& $o3;
> unset($o3);
>
> The object will no longer exist, destructor is called.
>
>
> To elaborate a bit more on this... objects in php5 add a new
> layer to variable existance.
>
> When an object is created it creates itself into its own memory
> space and a new variable ($o1) is allocated to point to that
> objects memory space.
>
> When the variable ($o1) is assigned to another variable ($o2), a
> memory is allocated to point to the object as well. So now
> two allocated variables are pointing to the same object. When one
> of the variables is destroyed, since another variable still points
> to the object, the object will continue to exist. Until all
> variables pointing to that object no longer exits.
>
> In unix filesystem terms, a variable of an object is very much like
> how a hard link is treated. The allocated filename (variable in
> php's case), points to the allocated data (object). When no other
> filename points to the same data, the data is released from usage.
>
> In the later example (using =&), the new variable created ($o4),
> points to ($o3). So, as the manual explains, the new variable
> ($o4) is a symoblic link to the original variable ($o3).
Hmmm, I think you got some wires crossed :) Your two examples are
identical in functionality; except that your assertion that the object
no longer exists in example 2 is incorrect. In PHP5 object assignment
results in a reference assignment instead of a copy as in PHP4. Try
running the following sample script:
<?
class Foo
{
var $foo = 0;
function __destruct()
{
echo 'Destruction: '.$this->foo."\n";
}
}
$o1 = new Foo();
$o2 = $o1;
$o1->foo = 1;
echo "Checkpoint 1\n";
unset( $o1 );
echo "Checkpoint 2\n";
unset( $o2 );
echo "Checkpoint 3\n";
$o3 = new Foo();
$o4 =& $o3;
$o3->foo = 2;
echo "Checkpoint A\n";
unset( $o3 );
echo "Checkpoint B\n";
unset( $o4 );
echo "Checkpoint C\n";
So to take your example of symbolic links. When a new object is created
the memory is allocated and a symbolic link is created to that memory.
Then when you assign the object to another variable then another
symbolic link is created. So in your examples the mere assignment of the
newly created object:
$o1 = new object();
creates a symbolic link. Thus when the __destruct() method is
automatically called I can be certain that no "symbolic links" exist. So
for my factory example the __destruct() method could inform the factory
that the the resource consumed by the object being destroyed is now
re-usable.
In PHP5 to get a copy of, versus a reference to, an object the developer
must call the __clone() method for the target object:
$obj = new Foo();
$copyNotReference = $obj->__clone();
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
--- John Holmes <[EMAIL PROTECTED]> wrote:
> From: "fongming" <[EMAIL PROTECTED]>
> > You also can use follows:
> >
> > <a href=script.php?PHPSESSID=session_id();></a>
>
> You can, if you want to make the (incorrect) assumption that everyone
> will have "PHPSESSID" as the name of their sessions...
>
> That's what session_name() is for and the SID constant...
Yep, and...
That syntax is wrong anyway - session_id() only returns the session
identifier when used in PHP, not within HTML. :-)
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/
--- End Message ---
--- Begin Message ---
John Nichel wrote:
Peter Clarke wrote:
John Nichel wrote:
Jay Blanchard wrote:
[snip]
In what manual?
[/snip]
TFM!
I'm sorry, I didn't quite catch that. Could you hold my hand, and
point it out to me? If you were a real pal, you would write the code
for me too. ;)
The only manual I know of is at www.php.net
It provides a tool for searching the online documentation.
Searching for 'avi' produces just one result of:
http://www.php.net/function.getimagesize
in which a user posts about finding dimensions etc from media files.
I cannot find anywhere that mentions converting avi files to wmv files.
The point of the razzing is to get one to do some research. If you
don't see it in the manual, chances are PHP cannot do it on it's own.
Without seeing any 'video' functions listed in 'THE MANUAL', I would
hazard a guess that converting between two different video formats is a
bit beyond the scope of PHP. Not to say that this cannot be done, as
I'm sure there is an API out there that PHP can interact with, but
someplace like Google would be a better place to start a search like there.
Agreed, my issue is with the pure unhelpfulness of the responses to the
question. The response was:
"There are a few listed in the manual."
which is totally wrong.
Peter
--- End Message ---