php-general Digest 15 Nov 2004 07:34:56 -0000 Issue 3113

Topics (messages 201996 through 202016):

paypal ipn - subscriptions
        201996 by: nate.savingadvice.com
        202001 by: Michelle Konzack

Re: Silly OOP question
        201997 by: Dusty Bin
        201998 by: Dusty Bin
        201999 by: Klaus Reimer

Mysql 4.1.7 + PHP 4.3.9
        202000 by: electroteque

Atom 2 RSS Script? Anyone got one?
        202002 by: Nick Wilson

unable to use vars in foreach
        202003 by: Jonathan Villa
        202004 by: Ryan King
        202005 by: Jonathan Villa
        202009 by: Ryan King
        202011 by: Jonathan Villa

Re: unable to use vars in foreach [updated question]
        202006 by: Jonathan Villa
        202010 by: Ryan King

Re: PHPINIPATH/PHPINIDIR/PHPININAME?
        202007 by: David Garamond
        202008 by: raditha dissanayake

Array from database table
        202012 by: Richard
        202014 by: raditha dissanayake

Sessions: I don't get it!!
        202013 by: Don
        202015 by: nate.savingadvice.com

Converting a string into ASCII and a bit more - newbie
        202016 by: Alp

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 ---
I'm creating a subscription service where customers will signup and pay $X
per month to have access to this service. I've done the easy part, which is
communicating back and forth with paypal. Anytime a transaction is made,
it's sent to my ipn.php script. The part I'm having difficulty with is
figuring out how to manage who does and doesn't have access to the service
based on what paypal sends me.

 

It looks like there are 6 different transaction types possible for
subscriptions.

"subscr_signup"
"subscr_cancel"

"subscr_modify"

"subscr_failed"

"subscr_payment"

"subscr_eot"

 

For example, what if someone cancels their subscription? I don't think I can
turn off their service immediately because their month might not be over
yet.

 

Another thought. Would I just mark their account active if they are
"subscr_signup" or "subscr_payment" and leave it at that unless paypal tells
me otherwise (from subscr_failed, or subscr_cancel, or subscr_eot). OR
should I record the date of the "subscr_signup" or "subscr_payment" and only
allow them access for one month after that date?

Anyone have experience creating something like this? Would really appreciate
hearing how you did it. Or if you haven't, but have ideas, let me know!


Thanks!
Nate


--- End Message ---
--- Begin Message ---
Hello nate, 

Am 2004-11-14 11:46:57, schrieb [EMAIL PROTECTED]:
> I'm creating a subscription service where customers will signup and pay $X
> per month to have access to this service. I've done the easy part, which is
> communicating back and forth with paypal. Anytime a transaction is made,
> it's sent to my ipn.php script. The part I'm having difficulty with is
> figuring out how to manage who does and doesn't have access to the service
> based on what paypal sends me.

> It looks like there are 6 different transaction types possible for
> subscriptions.

> For example, what if someone cancels their subscription? I don't think I can
> turn off their service immediately because their month might not be over
> yet.

This is handled by you and your program...

> Another thought. Would I just mark their account active if they are
> "subscr_signup" or "subscr_payment" and leave it at that unless paypal tells
> me otherwise (from subscr_failed, or subscr_cancel, or subscr_eot). OR
> should I record the date of the "subscr_signup" or "subscr_payment" and only
> allow them access for one month after that date?

The last one...

I do not use paypal but a bank (VISA/Master/...) and I let my
$USER pay for 3m, 6m. After this time the account will expire. 

For the 1m I using auto-renew and I have the permission to make
banktransfers automaticly.

If the bank reject, the Accout expires... 
...and if not it will be renewed 1m.

> Anyone have experience creating something like this? Would really appreciate
> hearing how you did it. Or if you haven't, but have ideas, let me know!
> 
> 
> Thanks!
> Nate

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/ 
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

Attachment: signature.pgp
Description: Digital signature


--- End Message ---
--- Begin Message --- Brent Clements wrote:
I've always wondered this about OOP and maybe you guys can answer this question.

I'm writing a php application and I'm trying to figure out the correct way to 
right the oop part of this application.

for instance.

I have a "project.class" file that has functions for dealing with individual 
projects because you break down ideas into singular entities in OOP(as I understand it)

But what if I wanted to deal with multiple projects such as getting a list of the projects in my database, 
should I create a function in the "project.class" to handle the now plural request, or should I 
create a "projects.class" file that has a function called "getProjects".

Hopefully I'm explaining this question right. It makes sense in my own head. :-)

Thanks,
Brent
Brent,
there are many ways so skin a cat, but one way to solve your problem in an OO manner would be a container class, call it projects or what you will.
An example(not tested) could be:
<?php
class Container {
private projects = array(); // Contains projects
private projectsLoaded = false;
...
other methods
...
public function getProjects() {
if (!$this->projectsLoaded) {
$this->loadProjects();
}
return $this->projects;
}
private function loadProjects() {
//code to load the projects into the project array
$this->projectsLoaded = true;
}
}
?>
In your main code you can have something like:
$container = new Container;
foreach($container->getProjects as $project) {
$something = $project->someMethod(...);
...
...
}

Hope this helps. . . Dusty
--- End Message ---
--- Begin Message ---
Dusty Bin wrote:
<snip>
</snip>
foreach($container->getProjects as $project) {
<snip>
</snip>
Sorry about the typo, of course it should read:
foreach($container->getProjects() as $project) {

Dusty
--- End Message ---
--- Begin Message --- Daniel Schierbeck wrote:
you can implement it completely statically so you don't need to instanciate the class
Well, it might be useful to have more than one list of projects, ie if you want all design-related projects, or all PHP-projects.

But then you might need a class to organize these Project Lists. Maybe THIS is then well suited for static methods ;-)

--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message --- Is this a possible combination ? Work is trying to compile PHP4 against 4.1, I havent even tried it apart from against PHP5. It says in the manual that the mysqli driver is the only one compatible with 4.1, although I have managed to compile both mysql and mysqli in php5, and run my apps ok as i was in php4 using the mysql driver. Is the only difference the OLD_PASSWORD stuff ?
--- End Message ---
--- Begin Message ---
hi all, 

im all tired out of searching, just cant seem to find a script that will
convert atom 0.3 to any rss format. Does anyone have one or know where i
can get hold of one?

I know about 2rss.com but they insert ads as i understand it so that
just wont do :)

thanks for any links or help..
-- 
Nick W

--- End Message ---
--- Begin Message ---
I'm using PHP 5.0.2

Here is a snippet of my code

$post=$_POST;//this is actually happening in an include somewhere else and
autoprepended.  Works just fine.

$modules = simplexml_load_file(MODULES);

foreach ($modules->module as $mod) {
    echo $mod->postName.'<br>';
    if (isset($post[$mod->postName])) {
    die('in post');
    ....
    .....

echo-ing the postName works just fine, but when I get to the checking
whether or not the val is set, I get the error:

Warning: Illegal offset type in unset in /var/www/.....

If I replace $post[$mod->postName] with a hardcoded val, it works

$post['news']

The values of $mod->postName are names of checkboxes.

--- End Message ---
--- Begin Message ---
 
On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <[EMAIL PROTECTED]> 
wrote:
>
>$modules = simplexml_load_file(MODULES);
>

Are you certain that MODULES has been defined()? And what do you get when you 
print_r($modules)?

-ryan

--- End Message ---
--- Begin Message ---
>
> On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <[EMAIL PROTECTED]>
> wrote:
>>
>>$modules = simplexml_load_file(MODULES);
>>
>
> Are you certain that MODULES has been defined()? And what do you get when
> you print_r($modules)?
>
> -ryan
>

Yes MODULES is defined.  It's defined in an include file.  In my loop,
when I echo the $mod->postName the values print just fine.  My issue is in
the conditional.

--- End Message ---
--- Begin Message ---
        
On Sunday, November 14, 2004, at 08:36PM, Jonathan Villa <[EMAIL PROTECTED]> 
wrote:

>>
>> On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <[EMAIL PROTECTED]>
>> wrote:
>>>
>>>$modules = simplexml_load_file(MODULES);
>>>
>>
>> Are you certain that MODULES has been defined()? And what do you get when
>> you print_r($modules)?
>>
>> -ryan
>>
>
>Yes MODULES is defined.  It's defined in an include file.  In my loop,
>when I echo the $mod->postName the values print just fine.  My issue is in
>the conditional.

AHA!

Here's what I think's going on (sorry I don't have time to investigate it 
myself)....

$mod->postName is a simplexml object.  Due to some php5 magic, when used it a 
situation that calls for a string (like echo $xmlobj), it echos the proper 
value. However, when using it as an array subscript does not appear to qualify 
as this situation. To solve this try either:

$post[(string)$xmlobj]
OR
$post[strval($xmlobj)]

I hope this is clear and helpful.

-ryan

--- End Message ---
--- Begin Message ---
ah yes!!!! thanks!!!! both worked...

I had written a function to this... I knew there had to be a much easier
way!!!

>
> On Sunday, November 14, 2004, at 08:36PM, Jonathan Villa <[EMAIL PROTECTED]>
> wrote:
>
>>>
>>> On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa
>>> <[EMAIL PROTECTED]>
>>> wrote:
>>>>
>>>>$modules = simplexml_load_file(MODULES);
>>>>
>>>
>>> Are you certain that MODULES has been defined()? And what do you get
>>> when
>>> you print_r($modules)?
>>>
>>> -ryan
>>>
>>
>>Yes MODULES is defined.  It's defined in an include file.  In my loop,
>>when I echo the $mod->postName the values print just fine.  My issue is
>> in
>>the conditional.
>
> AHA!
>
> Here's what I think's going on (sorry I don't have time to investigate it
> myself)....
>
> $mod->postName is a simplexml object.  Due to some php5 magic, when used
> it a situation that calls for a string (like echo $xmlobj), it echos the
> proper value. However, when using it as an array subscript does not appear
> to qualify as this situation. To solve this try either:
>
> $post[(string)$xmlobj]
> OR
> $post[strval($xmlobj)]
>
> I hope this is clear and helpful.
>
> -ryan
>

--- End Message ---
--- Begin Message ---
So, searching php.net (I swear I did before...)

I found this at http://us2.php.net/language.types.array

" You cannot use arrays or objects as keys. Doing so will result in a
warning: Illegal offset type."

Neverthought that my var was an object, just thought maybe a string.  My
new question is, how can I convert this object to a string?  Or get the
val of it

Here is my XML

<module name="News">
<postName>news</postName>
    <pageLevelPermissions>News : Add
       <authenticatedPage>news.add.php</authenticatedPage>
       <navDisplay page="/news/news.add.php">Add</navDisplay>
    </pageLevelPermissions>
    <pageLevelPermissions>News : Current
       <authenticatedPage>news.current.php</authenticatedPage>
       <navDisplay page="/news/news.current.php">Current</navDisplay>
    </pageLevelPermissions>
    <pageLevelPermissions>News : Archived
       <authenticatedPage>news.archived.php</authenticatedPage>
       <navDisplay page="/news/news.archived.php">Archived</navDisplay>
    </pageLevelPermissions>
</module>

--- End Message ---
--- Begin Message ---
 
On Sunday, November 14, 2004, at 08:44PM, Jonathan Villa <[EMAIL PROTECTED]> 
wrote:

>So, searching php.net (I swear I did before...)
>
>I found this at http://us2.php.net/language.types.array
>
>" You cannot use arrays or objects as keys. Doing so will result in a
>warning: Illegal offset type."
>
>Neverthought that my var was an object, just thought maybe a string.  My
>new question is, how can I convert this object to a string?  Or get the
>val of it

See my post from about 1 minute ago.

-ryan

--- End Message ---
--- Begin Message --- Jordi Canals wrote:
On Sun, 14 Nov 2004 23:42:58 +0700, David Garamond
<[EMAIL PROTECTED]> wrote:

Greg Donald wrote:



print_r($_ENV);

What should I see in it?


RTFM

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.environment

Um, am I missing something here? ITTRFMTR (is that the right fine manual to read?)

I originally asked why the php cli binary cannot be told to look for php.ini in a custom location specified via an environment variable (it only accepts the -c command line argument). All other interpreters I know can. So if there _is_ an env var to do that, what is it? I didn't see it and certainly strace doesn't show my /usr/bin/php doing any getenv() during startup.

Regards,
dave

--- End Message ---
--- Begin Message ---
David Garamond wrote:


Um, am I missing something here? ITTRFMTR (is that the right fine manual to read?)

I originally asked why the php cli binary cannot be told to look for php.ini in a custom location specified via an environment variable (it only accepts the -c command line argument). All other interpreters I know can. So if there _is_ an env var to do that, what is it? I didn't see it and certainly strace doesn't show my /usr/bin/php doing any getenv() during startup.

Regards,
dave

perhaps people had trouble reading your post properly because of all the CAPS.


-- Raditha Dissanayake. ------------------------------------------------------------------ http://www.radinks.com/print/card-designer/ | Card Designer Applet http://www.radinks.com/upload/ | Drag and Drop Upload

--- End Message ---
--- Begin Message ---
How do I get the data from a mysql database into and array that looks
like this
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) 

The table has three fields but I only need the data from one field.

$query="SELECT amenityID FROM property_amenity where listingId =
'$listingId'";

--- End Message ---
--- Begin Message ---
Richard wrote:

How do I get the data from a mysql database into and array that looks
like this
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )

by using mysql_fetch_row() or mysql_fetch_array()

The table has three fields but I only need the data from one field.

$query="SELECT amenityID FROM property_amenity where listingId =
'$listingId'";





--
Raditha Dissanayake.
------------------------------------------------------------------
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/              | Drag and Drop Upload

--- End Message ---
--- Begin Message ---
I'd like to do something with sessions that should be easy. But I'm new 
to this, and obviously I'm missing something somewhere...

I want to use cookies if the visitor allows, but tack the session info 
(SID) "get style" on the URL of a linked page *only if* the visitor 
blocks cookies. I've tried a lot of variations, but nothing really 
works. I either  get the entire SID value in the URL (even if cookies 
are accepted), or the SID doesn't show up in the URL, which means it 
works only with visitors who accept cookies.

Below is my most recent attempt. simple.php detects whether the visitor 
accepts cookies by forcing a page reload (my thanks to Chris Shiflett), 
then attempts a redirection, based on whether cookies are accepted. 
Doesn't work.

Anyone got any ideas?

TIA.

-------------------------
<?
# simple.php

ini_set('session.use_trans_sid', 0);
ini_set('session.use_cookies', 1);
ini_set('register_globals', 0);
session_start();

if (! isset($_GET['cac'])) {
 header('Set-Cookie: accept_cookies=yes');
 header('Location: ' . $_SERVER['PHP_SELF'] . '?cac=1');
}

$_SESSION['accepts_cookies'] = isset($_COOKIE['accept_cookies']);

$_SESSION['session_num'] = session_id();

if ($_SESSION['accepts_cookies']) {
 header('location: simple2.php');
}
else {
 header('location: simple2.php?'. strip_tags(SID));
}

die;

?>
--------------------------
<?
# simple2.php
//ini_set('session.use_trans_sid', 0);
//ini_set('session.use_cookies', 1);
//ini_set('session.use_only_cookies', 1);
//ini_set('register_globals', 0);
session_start(); 
?>
<html>
<head>
<title>Processing Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<? echo "Old Session ID: " . $_SESSION['session_num'] . "<br>";
   echo "This Session ID: " . session_id() . "<br>"; 
   echo "SID: " . SID . "<br>"; ?>
<blockquote> 
<?
 echo
?>
</blockquote> 

</body>
</html>

--- End Message ---
--- Begin Message ---
Looks like you're making it way more complicated than it needs to be. PHP
will automatically tack on the Session ID tag to your local url's, but only
if it needs to. There is no need to append the SID to url's manually.

Nate

-----Original Message-----
From: Don [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 14, 2004 9:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Sessions: I don't get it!!

I'd like to do something with sessions that should be easy. But I'm new 
to this, and obviously I'm missing something somewhere...

I want to use cookies if the visitor allows, but tack the session info 
(SID) "get style" on the URL of a linked page *only if* the visitor 
blocks cookies. I've tried a lot of variations, but nothing really 
works. I either  get the entire SID value in the URL (even if cookies 
are accepted), or the SID doesn't show up in the URL, which means it 
works only with visitors who accept cookies.

Below is my most recent attempt. simple.php detects whether the visitor 
accepts cookies by forcing a page reload (my thanks to Chris Shiflett), 
then attempts a redirection, based on whether cookies are accepted. 
Doesn't work.

Anyone got any ideas?

TIA.

-------------------------
<?
# simple.php

ini_set('session.use_trans_sid', 0);
ini_set('session.use_cookies', 1);
ini_set('register_globals', 0);
session_start();

if (! isset($_GET['cac'])) {
 header('Set-Cookie: accept_cookies=yes');
 header('Location: ' . $_SERVER['PHP_SELF'] . '?cac=1');
}

$_SESSION['accepts_cookies'] = isset($_COOKIE['accept_cookies']);

$_SESSION['session_num'] = session_id();

if ($_SESSION['accepts_cookies']) {
 header('location: simple2.php');
}
else {
 header('location: simple2.php?'. strip_tags(SID));
}

die;

?>
--------------------------
<?
# simple2.php
//ini_set('session.use_trans_sid', 0);
//ini_set('session.use_cookies', 1);
//ini_set('session.use_only_cookies', 1);
//ini_set('register_globals', 0);
session_start(); 
?>
<html>
<head>
<title>Processing Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<? echo "Old Session ID: " . $_SESSION['session_num'] . "<br>";
   echo "This Session ID: " . session_id() . "<br>"; 
   echo "SID: " . SID . "<br>"; ?>
<blockquote> 
<?
 echo
?>
</blockquote> 

</body>
</html>

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

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

My question could have quite stright forward answer or the question itself
might be silly but being a newbie, I'll ask it anyway.
 First I am trying to convert each character in a string into their
respective ASCII codes and then keep these again in a string. Such as:
string : ABCDEFGHIJ, expect to see in the result : 65666768697071727374
Then I would like to further manipulate this result with some math, say add
10 to each pair (the ascii code) so the new result becomes:
75767778798081828384
For my first attempt I tried:
$x=1
while ($x<=strlen($string)) {
    $holder = ord(substr($string, $x, 1));
    $result = $result . $holder;
    }
and failed since it takes ages to process and does not really return a
proper value/result but repetitive number such as 11111..........
I have also tried a 'for' example I found which failed as well.
I truely hope an expert here could show me some light and point me in the
right direction.
I have 2 sets installed on my PC as PHPDEV423 and XAMPP 1.4.9 (set to use
php4) and it fails in both.

Thanks in advance,

Alp
P.S.: I hope I have posted this in the correct NG

--- End Message ---

Reply via email to