php-general Digest 21 Apr 2005 11:45:57 -0000 Issue 3410

Topics (messages 213544 through 213556):

Re: Abstract Legacy question
        213544 by: Rob Agar

Re: script
        213545 by: tommy
        213546 by: Philip Hallstrom

Re: parse error, unexpected T_CLASS
        213547 by: Kim Briggs

Regular Expression to replace pseudo-HTML?
        213548 by: Murray . PlanetThoughtful

Re: email through PHP]
        213549 by: Balwant Singh

Re: delete session cookie?
        213550 by: William Stokes

Re: Classe Variable
        213551 by: Petar Nedyalkov

Re: Session variables are not stored when set in implicitly calledconstructor!??
        213552 by: Jochem Maas

Is it possible to get the whole address (including http:// ) ?
        213553 by: Labunski

Need urgent help on post php long code
        213554 by: Pieter du Toit

PHP4 to PHP5 upgrade help
        213555 by: Mike

PDO and Oracle...
        213556 by: Charles FENDT

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

Andy Pieters wrote:
> This is kinda hard to say in words, so I'll give a little example
> 
> Class A
>   function x
>     calls function guid
>   function y
>   function z
>   function guid
> Class B extends A
>  function y
>    calls function x
>  function guid
> 
> So what I'm wondering is when class B calls its function Y, 
> it will in its 
> turn call function X (which is not overloaded in class B) and 
> function X 
> calls the function GUID from which class?  Class A or Class B?

class B.  Which makes sense if you think about the code, which will look
like

$this->guid()

... and '$this' is a 'B' 

Rob

--- End Message ---
--- Begin Message ---
Thank you both, this was indeed helpful.

Now for one more question...

I'd like to get my code to calculate the time between the current date (when the page is loaded by the visitor) and the very next Tuesday at 11pm. I suspect I can do this with date("w") but I can't quite figure out how to make Tuesday the beginning or end of the week in order to accomplish this...

maybe I'm going about this the wrong way.

Again, any pointers or assistance appreciated.

Tommy


On Apr 19, 2005, at 10:34 PM, Rob Agar wrote:


here's the clue to the other half of the puzzle:

you can do this kind of thing in php

if (whatever)
{
        include 'something.php';
}
else
{
        include 'something else.php';
}

hth,
Rob

-----Original Message-----
From: Stephen Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 20 April 2005 11:53 AM
To: tommy
Cc: php-general@lists.php.net
Subject: Re: [PHP] script


http://php.net/time http://php.net/date http://php.net/mktime


one or a combination of these functions will help you do what you want.

HTH
On Apr 19, 2005, at 6:37 PM, tommy wrote:

I'm hoping someone on this list can help me with something
I've been
struggling with lately...

I have a php based web page that I'd like to have load an
include file
only when it is Tuesday 11pm - Weds 1 am Eastern Standard
time (USA).
At other times I would like my page to load and alternate include
file.

If someone could help me with the code or point me in the right
direction it would be very appreciated.

Thanks.

Tommy.

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


*********
Stephen Johnson
[EMAIL PROTECTED]
http://www.thelonecoder.com

--continuing the struggle against bad code--
*********

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


--- End Message ---
--- Begin Message ---
I'd like to get my code to calculate the time between the current date (when the page is loaded by the visitor) and the very next Tuesday at 11pm. I suspect I can do this with date("w") but I can't quite figure out how to make Tuesday the beginning or end of the week in order to accomplish this...

maybe I'm going about this the wrong way.

Again, any pointers or assistance appreciated.

Hmm... well, using date("w") will tell you what day of the week it is, and you know that 0=sunday and 2=tuesday.

use that and some logic to compute the number of days between today and the next tuesday.

Then figure out how many seconds have elapsed for today and use that in conjunction with the number of days in between and the number of seconds to get to 11pm (23*60*60).

Then substract the two... and pass that to date in the format you want.

Or something like that :)

-philip
--- End Message ---
--- Begin Message ---
On 4/20/05, Jochem Maas <[EMAIL PROTECTED]> wrote:
>> Dasmeet Singh wrote:

>> BTW.. pls suggest some good editor.. I use notepad currently..

> http://www.php-editors.com/
> http://www.google.com/search?hl=en&lr=&q=good+editor+for+php&btnG=Search
> 
> choose one.
> 

This can take a long time, I know.  My favorite by far on Windows is
Crimson Editor (also free as in beer).

http://www.crimsoneditor.com/

-KB

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

 

I'm hoping someone can help me figure out a regex that will replace
pseudo-HTML codes in a string with desired HTML equivalents. In particular,
I'm trying to implement a message quoting facility, such as when you click
on the 'quote'  button in phpBB.

 

An example of a source string would be:

 

<source string>

 

[quote="John"]Some quoted text.

 

Some more quoted text.

 

[quote="Mary"]My older comment.[/quote][/quote]

 

My current comments.

 

</source string>

 

Ideally, I'd like this to become something like:

 

<regexed string>

 

<div class='quotehead'>

            John wrote:

</div>

<div cass='quote'>

            Some quoted text.

 

Some more quoted text.

<div class='quotehead'>

            Mary wrote:

</div>

<div class='quote'>

            My older comment.

</div>

</div>

 

My current comments.

 

</regexed string>

 

Given that pseudo-HTML seems common on bulletin board systems I'd hoped
there'd be a published function available to handle it, but I haven't had
any luck finding one and while I've been able to find a couple of regex
examples (eg http://www.regexlib.com/REDetails.aspx?regexp_id=520) they
appear to be aimed at ASP.NET rather than PHP and my attempts to get them
working in PHP (hampered, admittedly, by my general confusion about regex's)
haven't met with any luck.

 

Truly, any help immensely appreciated!

 

Much warmth,

 

Murray

 


--- End Message ---
--- Begin Message ---
thanks to all for the kind support.

i resolved the problem, i would like to share the same with you:-

1. made the changes in php.ini (gave sendmail path)
2. gave my smtp server ip address and name in /etc/hosts file 
3. gave my smtp server name in /etc/mail/sendmail.mc file
4. then made sendmail.cf file from sendmail.mc file.

now i am able to send the mail to outside through PHP. pls feel free to
give your suggestion on the above.

once again thanks to all

with best wishes
balwant


-----Forwarded Message-----

From: Balwant Singh <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: Ken <[EMAIL PROTECTED]>, php-general@lists.php.net
Subject: Re: [PHP] email through PHP
Date: 19 Apr 2005 17:15:11 +0530

thanks for your email,

i read the manual and already tried  the setting as told by you but its
not working.  

i would like to again inform that i want to send email through PHP which
is on a linux machine and our Company SMTP sever is on Windows Machine. 
i am certain the somebody has already tested it and can give me
solution.  pls help.

 

with best wishes
balwant


On Tue, 2005-04-19 at 17:20, Angelo Zanetti wrote:
> why dont you read the manual, thats what its for. 
> I know you can specify your smtp server setttings in your php.ini
> file.
> so just set your smtp to the windows server address
> 
> from PHP.ini
> 
> [mail function]
> ; For Win32 only.
> SMTP = smtp.myserver.com ; for Win32 only
> 
> ; For Win32 only.
> sendmail_from = [EMAIL PROTECTED]; for Win32 only
> 
> ; For Unix only.  You may supply arguments as well (default: "sendmail
> -t -i").
> ;sendmail_path =
> 
> hope this helps
> 
> Angelo Zanetti
> Z Logic
> [c] +27 72 441 3355
> [t] +27 21 464 1363
> [f] +27 21 464 1371
> www.zlogic.co.za
> 
> Balwant Singh wrote: 
> > i want to use the SMTP server which is already exists.  
> > pls. give more details..........
> > 
> > with best wishes
> > balwant
> > 
> > On Tue, 2005-04-19 at 15:59, Ken wrote:
> >   
> > > On 19 Apr 2005 15:04:08 +0530, Balwant Singh <[EMAIL PROTECTED]> wrote:
> > >     
> > > > hi,
> > > > 
> > > > I am using FEDORA 3 and PHP. I want to send email to outside by my above
> > > > mentioned linux machine through PHP. For this i want to use my SMTP
> > > > sever, which is on a WINDOWS machine
> > > > 
> > > > Please inform what setting to be done in php.ini or any other file to
> > > > send the email.
> > > > 
> > > > with best wishes
> > > > balwant
> > > > 
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > 
> > > > 
> > > >       
> > > 
> > > erm, isn't it easier to have the smtp on your fedora box instead...?
> > >     
> > 
> >   

--- End Message ---
--- Begin Message ---
Thanks. That's  what I was looking for...

"Burhan Khalid" <[EMAIL PROTECTED]> kirjoitti 
viestissä:[EMAIL PROTECTED]
> William Stokes wrote:
>> Hello,
>>
>> Is it possible to delete a session cookie from browser? If so how?
>
> http://www.php.net/manual/en/function.session-destroy.php
>
> See the example. 

--- End Message ---
--- Begin Message ---
On Wednesday 20 April 2005 21:04, Jochem Maas wrote:
> Petar Nedyalkov wrote:
> > On Wednesday 20 April 2005 13:29, marc serra wrote:
> >>Hi,
> >>i got a problem to write automaticaly varibles in classes.
> >>
> >>i got a simple object name test like this
> >>
> >>classes Test{
> >>    public     $id;
> >>    public     $text;
> >>}
> >>
> >>i want to affect my value to my variable like this
> >>$test = new Test
>
> missing a ';' above
>
> >>$champ = id;
>
> I think this should be:
> $champ = 'id';
>
> >>$valeur_champ = 4;
> >>
> >>$test->$champ = $valeur_champ;
> >
> > Just use $test->{$champ}
> >
> > ;-)
>
> curlies are not required in this case (although they do allow more complex
> expressions), the following works for me:
>
> class T{public $id;}$t=new T;
> $a="i";$b="d";$c="id";$v=4;$t->$c=$v;$t->{$b.$a}=5;
> var_dump($c,$v,$t->$c,$t->id,$t->{$a.$b},$t);

Curlies are just a good practice :-)

>
> >>my example is stupid i know but its just for an example.
> >>in fact when i write $test->$champ = $valeur_champ; I want that php
> >>execute $test->id = 4;
> >>
> >>can someone help me plz,
> >>
> >>Marc.

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436

Attachment: pgpO4Vm69VhdL.pgp
Description: PGP signature


--- End Message ---
--- Begin Message --- Jason Barnett wrote:
Adam wrote:

Hallo again,
thank You for Your response.



// singleton for request
class Request {
  function __destructor() {
      $_SESSION["variable"] = "hallo";

The __destructor() method is supposed to be about killing the class (Request). It's probably bad practice to be changing $_SESSION vars inside of there even if that $_SESSION var affects your class. Here, read this page and maybe it will make more sense to you: http://php.net/manual/en/language.oop5.decon.php


i agree that in *most* cases destructor should only clean up after object.
unfortunatly for "request" class there are few requirements:
1) must allow immidiate use w/o any explicit initialization or finalizaion.
e.g. at any file You can use only Request::getInstance()->isRefresh() /**
test if this request was caused by browser refresh */. this should be one
and only line (except for inclusion of request.php oc) referencing request
class -- no explicit call to Request::saveToSession() or anything ugly and
potentialy disastrous like that.


Well ok, but why can't you just have saveToSession() in the conditional
block?

<?php

$_SESSION['Request'] = Request::getInstance();


look $_SESSION['Request'] is now a reference to the Request getInstance(); when this session is closed the object will automatically be serialized - no need to saveToSession or whatever!.... just make sure you have always declared the Request class before you start the session.

so have the Request::getInstance() deal with checking/setting 
$_SESSION['Request'] internally.

if ($_SESSION['Request']->isRefresh() ) {
  $_SESSION['Request']->saveToSession();
  /* etc. */
  exit();
}

/* Rest of script follows here */

?>

IMHO the point of OOP is to keep each function split into the minimal
functionality that you need.  This allows you to reuse code easier
because a function does only the *minimum* amount of work necessary
instead of extra (unintended) functionality.


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

I know for example how to get http vars or basename, but this time I need to 
get the whole address, including http:// .

Is it possible?


Thanks in advance,
Lab. 

--- End Message ---
--- Begin Message ---
I have the following code:
function display_setcom() {

global $config;

dsprint("display_setcom()");

dprint($_SESSION["logged_in"]);

$user_id = $_SESSION["logged_in"];

$result = mysql_query("SELECT users.user_first_name, users.user_last_name, 
users.user_cell, users.user_idnom, users.user_email, users.user_adres1, 
users.user_adres2, users.user_pcode, users.user_city, users.user_prov FROM 
users WHERE users.user_id = '$user_id'");

if (mysql_num_rows($result) == 1) {

$user_detail = check_user_details($user_id); //app.func.inc.php


dprint($user_detail);

if ($user_detail === true) {

$row = mysql_fetch_assoc($result);

dprint($row);

extract($row);




$ewal_result = mysql_query("SELECT DECODE(ewallet.ewal_pass, 
'{$config["password_password"]}') AS ewal_pass FROM ewallet WHERE 
ewallet.user_id = '$user_id'");

if (!mysql_error()) {

if (mysql_num_rows($ewal_result) > 0) {

$row = mysql_fetch_assoc($ewal_result);

extract($row);

dprint($row);

}

} else {

dprint(mysql_error());

}


dprint($ewal_tosetcom);

$Co_ID = $config["e_wallet"]["Co_ID"];

$Outlet = $config["e_wallet"]["Outlet"];

$transac = get_nextid($_SESSION["database"], "transacs", "tran_id", "tran");

!!!!! this is where i echo all my required vars to post, and i get a value 
for each, but when i post to the next form only $co_id and $outlet is posted 
!!!!!!

echo "Admin testing<br>";

echo "coid = ".$Co_ID;

echo "Outlet = ".$Outlet;

echo "user_email = ".$user_email;

echo "ewal_pass = ".$ewal_pass;

echo "user_id = ".$user_id.$transac;

echo <<< END

<p class="WARN">The following details are used for your credit card 
transactions,<br>if they are incorrect or incomplete, please go to <a 
href="index1.php?display=details">My Details</a> and update your 
details.<br>If it is correct, you can click on the button below to TopUp 
eWallet</p>

<form action="testvars.php" method="post" name="setcom">

<table CLASS="PREDICT" border="1" align="center">

<tr class="minmaxtxt">

<td>Name:</td>

<td class="minmaxtxtco"><input name='Name' type='hidden' maxlength='25' 
size='35' value="$user_first_name $user_last_name">$user_first_name 
$user_last_name</td>

</tr>

<tr class="minmaxtxt">

<td>Cellphone Number:</td>

<td class="minmaxtxtco"><input name='Tel' type='hidden' maxlength='10' 
size='15' value="$user_cell">$user_cell</td>

</tr>

<tr class="minmaxtxt">

<td>ID Number:</td>

<td class="minmaxtxtco"><input name='Addonfields' type='hidden' 
maxlength='13' size="17" value="Identity:$user_idnom">$user_idnom</td>

</tr>

<tr class="minmaxtxt">

<td>Address:</td>

<td>

<table border="1" class="PREDICT">

<tr class="minmaxtxt">

<td>Streetname & Number:</td>

<td class="minmaxtxtco"><input name='Address1' type='hidden' maxlength='255' 
size='15' value="$user_adres1">$user_adres1</td>

</tr>

<tr class="minmaxtxt">

<td>Suburb/Area:</td>

<td class="minmaxtxtco"><input name='Address2' type='hidden' maxlength='255' 
size='15' value="$user_adres2">$user_adres2</td>

</tr>

<tr class="minmaxtxt">

<td>Post/Zip Code:</td>

<td class="minmaxtxtco"><input name='Zip' type='hidden' maxlength='9' 
size='10' value="$user_pcode">$user_pcode</td>

</tr>

<tr class="minmaxtxt">

<td>City:</td>

<td class="minmaxtxtco"><input name='City' type='hidden' maxlength='25' 
size='15' value="$user_city">$user_city</td>

</tr>

<tr class="minmaxtxt">

<td>Province/State:</td>

<td class="minmaxtxtco"><input name='State' type='hidden' maxlength='25' 
size='15' value="$user_prov">$user_prov</td>

</tr>

<tr class="minmaxtxt">

<td>Country</td>

<td class="minmaxtxtco">

<select name="Country">

<option value="ZA">South Africa</option>

</select>

</td>

</tr>

</table>

</td>

<tr class="ROW1">

</table>

<br>

<table class="PREDICT" border="1" align="center">

<tr class="minmaxtxtco">

<td>TopUp Amount:</td>

<td><input type="text" name="CC_amount">

</tr>

<tr class="minmaxtxt">

<td colspan="2" align="center">

<input type="submit" name="register" value="TopUp eWallet" onClick="if 
(!ValidAmount(setcom.CC_amount.value)) { alert('Please enter a valid 
amount'); return (false);};">

</td>

</tr>

</table>

<input type="hidden" name="Co_ID" value="$Co_ID">

<input type="hidden" name="Outlet" value="$Outlet">

<input type="hidden" name="UserName" value="$user_email">

<input type="hidden" name="Password" value="$ewal_pass">

<input type="hidden" name="Reference" value="$user_id:$transac">

<input type="hidden" name="Lang" value="ENG">


END;

if ($tosetcom === 0) { //If the user has not been registered yet.

print("\t\t\t<input type=\"hidden\" name=\"ConfirmPassword\" 
value=\"$ewal_pass\">\n");

}

print("\t\t</form>\n");

} else {

print("<p class=\"WARN\">Your details are not complete. Please update them 
at <a href=\"index1.php?display=details\">My Details</a> before you can 
TopUp your account</p>\n");

}

} else {

$_SESSION["error"] .= "<p class=\"WARN\">Could not fetch user details, 
please try again later.</p>\n";

dprint(mysql_error());

}

}

i really need help here, have a deadline

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

I want to upgrade my server from PHP 4.3.10 to PHP 5.0.4, however, many of
my clients run scripts that will break if I do.

The main problem seems to be 'classes'.

Is there a way to put a band-aid on these scripts that will allow them to
function when I upgrade?



+--------------------------------------------+
Mike Yrabedra 
[EMAIL PROTECTED] 
Your Mac Intelligence Resource
+--------------------------------------------+
W: http://www.macagent.com/

--- End Message ---
--- Begin Message ---
I try to use PDO to access to Oracle database...
I use "PDO::prepare" and bindParam to set var values...
but it didn't work !!!

PDO_PARAM_INT didn't work with columns of type NUMBER...

What can i do ???

Regards,

FENDT Charles
--- End Message ---

Reply via email to